• 大小: 13KB
    文件类型: .c
    金币: 1
    下载: 0 次
    发布日期: 2021-05-17
  • 语言: 其他
  • 标签: TAS571  

资源简介

用STM32的MCU对TAS5715进行初始化的初始代码,能让初学者很快上手,且很简杰

资源截图

代码片段和文件信息


/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  */
/* Includes ------------------------------------------------------------------*/
#include “main.h“
#include “stm32f0xx_hal.h“
#include “stdio.h“
#include “data.h“
/* Private variables ---------------------------------------------------------*/

I2C_HandleTypeDef hi2c1;

void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_I2C1_Init(void);

HAL_StatusTypeDef write_TAS5715(uint8_t reg_add uint8_t reg_value);

#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch FILE *f)
#endif 

HAL_StatusTypeDef write_TAS5715(uint8_t reg_add uint8_t reg_value){
  uint8_t temp_data[2];
  temp_data[0]=reg_add;
  temp_data[1]=reg_value;
  return(HAL_I2C_Master_Transmit(&hi2c1TAS5715_DEVICE_ADDRESStemp_data210000));
}

void init_TAS5715(void){ 
   int i;
       for(i=0;i<5;i++){
        write_TAS5715(TAS5715_table[i][0]TAS5715_table[i][1]);
      }
 }


void Glfon_stereo_WM8960(void){ 
  uint8_t temp_data[21];
  //0x29 00 7E FF 86 03 02 00 F4 00 7E FF 86 00 FD FC CA 03 81 FE B3    
  temp_data[0]=0x29; temp_data[1]=0x00; temp_data[2]=0x7e; temp_data[3]=0xff; temp_data[4]=0x86;
  temp_data[5]=0x03; temp_data[6]=0x02; temp_data[7]=0x00; temp_data[8]=0xf4; temp_data[9]=0x00;
  temp_data[10]=0x7e; temp_data[11]=0xff; temp_data[12]=0x86; temp_data[13]=0x00; temp_data[14]=0xfd;
  temp_data[15]=0xfc; temp_data[16]=0xca; temp_data[17]=0x03; temp_data[18]=0x81; temp_data[19]=0xfe;
  temp_data[20]=0xb3; 
  HAL_I2C_Master_Transmit(&hi2c1TAS5715_DEVICE_ADDRESStemp_data2110000);
  
  //0x2a 00 7E FF 86 03 02 00 F4 00 7E FF 86 00 FD FC CA 03 81 FE B3  
  temp_data[0]=0x2a; temp_data[1]=0x00; temp_data[2]=0x7e; temp_data[3]=0xff; temp_data[4]=0x86;
  temp_data[5]=0x03; temp_data[6]=0x02; temp_data[7]=0x00; temp_data[8]=0xf4; temp_data[9]=0x00;
  temp_data[10]=0x7e; temp_data[11]=0xff; temp_data[12]=0x86; temp_data[13]=0x00; temp_data[14]=0xfd;
  temp_data[15]=0xfc; temp_data[16]=0xca; temp_data[17]=0x03; temp_data[18]=0x81; temp_data[19]=0xfe;
  temp_data[20]=0xb3; 
  HAL_I2C_Master_Transmit(&hi2c1TAS5715_DEVICE_ADDRESStemp_data2110000);
  
  //0x2b 00 7E FF 86 03 02 00 F4 00 7E FF 86 00 FD FC CA 03 81 FE B3  
  temp_data[0]=0x2b; temp_data[1]=0x00; temp_data[2]=0x7e; temp_data[3]=0xff; temp_data[4]=0x86;
  temp_data[5]=0x03; temp_data[6]=0x02; temp_data[7]=0x00; temp_data[8]=0xf4; temp_data[9]=0x00;
  temp_data[10]=0x7e; temp_data[11]=0xff; temp_data[12]=0x86; temp_data[13]=0x00; temp_data[14]=0xfd;
  temp_data[15]=0xfc; temp_data[16]=0xca; temp_data[17]=0x03; temp_data[18]=0x81; temp_data[19]=0xfe;
  temp_data[20]=0xb3; 
  HAL_I2C_Master_Transmit(&hi2c1TAS5715_DEVICE_ADDRESS

评论

共有 条评论