- 积分
- 553
- 在线时间
- 3224 小时
- 最后登录
- 2024-5-27
- 阅读权限
- 50
- 精华
- 0
- UID
- 511731
- 帖子
- 1057
- 精华
- 0
- 经验
- 553 点
- 金钱
- 423 ¥
- 注册时间
- 2012-7-17
|
楼主 |
发表于 2024-5-15 21:17
|
显示全部楼层
#define DAC_ADDR_L 0x90
void dac_Init()
{
HAL_GPIO_WritePin(GPIOA, set_Pin, GPIO_PIN_RESET);
HAL_Delay(200);
HAL_GPIO_WritePin(GPIOA, set_Pin, GPIO_PIN_SET);
}
void dac_set()
{
uint8_t sendbuffer1[] = {0x00,0x82};
HAL_I2C_Master_Transmit(&hi2c2, DAC_ADDR_L, sendbuffer1,2, HAL_MAX_DELAY); // 00.SYSTEM CONFIG, 1000 0010
uint8_t sendbuffer2[] = {0x01,0xFF};
HAL_I2C_Master_Transmit(&hi2c2, DAC_ADDR_L, sendbuffer2,2, HAL_MAX_DELAY); // 01.SYS MODE CONIFG, 1111 1111
uint8_t sendbuffer3[] = {0x25,0x66};
HAL_I2C_Master_Transmit(&hi2c2, DAC_ADDR_L, sendbuffer3,2, HAL_MAX_DELAY); // 37.GPIO1/2 CONFIG, 0110 0110
uint8_t sendbuffer4[] = {0x29,0x00};
HAL_I2C_Master_Transmit(&hi2c2, DAC_ADDR_L, sendbuffer4,2, HAL_MAX_DELAY); // 41.GPIO OUTPUT ENABLE, 0000 0000
uint8_t sendbuffer5[] = {0x2a,0x03};
HAL_I2C_Master_Transmit(&hi2c2, DAC_ADDR_L, sendbuffer5,2, HAL_MAX_DELAY); // 42.GPIO INPUT, 0000 0011
uint8_t sendbuffer6[] = {0x39,0xC7};
HAL_I2C_Master_Transmit(&hi2c2, DAC_ADDR_L, sendbuffer6,2, HAL_MAX_DELAY); // 57.INPUT SELECTION, 1100 0111
uint8_t sendbuffer7[] = {0x40,0x10};
HAL_I2C_Master_Transmit(&hi2c2, DAC_ADDR_L, sendbuffer7,2, HAL_MAX_DELAY); // 64.CH1 SLOT CONFIG, 0001 0000
uint8_t sendbuffer8[] = {0x41,0x21};
HAL_I2C_Master_Transmit(&hi2c2, DAC_ADDR_L, sendbuffer8,2, HAL_MAX_DELAY); // 65.CH2 SLOT CONFIG, 0010 0001
uint8_t sendbuffer9[] = {0x4a,0x00};
HAL_I2C_Master_Transmit(&hi2c2, DAC_ADDR_L, sendbuffer9,2, HAL_MAX_DELAY); // 74.VOLUME CH1, 0000 0000
uint8_t sendbuffer0[] = {0x4b,0x00};
HAL_I2C_Master_Transmit(&hi2c2, DAC_ADDR_L, sendbuffer0,2, HAL_MAX_DELAY); // 75.VOLUME CH2, 0000 0000
uint8_t sendbuffera[] = {0x59,0x30};
HAL_I2C_Master_Transmit(&hi2c2, DAC_ADDR_L, sendbuffera,2, HAL_MAX_DELAY); // 89.IIR BANDWIDTH & S/PDIF SEL, 0011 0000
}
|
|