K1Guitar/device/AW816/Drv_AW816.h

30 lines
1.1 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __DRV_AW816_H
#define __DRV_AW816_H
#include <stdint.h>
#include "at32f403a_407.h"
/* AW816 挂接在硬件 I2C1 上PB6=SCL / PB7=SDA与 AD85020B 共用同一总线)
I2C1 的初始化由 wk_i2c1_init() 完成(或复用 AD85020B 的 I2C 初始化)。 */
/* 器件地址7 位地址 0x5A。
写地址 = 0x5A<<1 = 0xB4读地址 = 0xB5。
AT32 官方 i2c_application 库的 i2c_master_transmit/receive 期望 8 位格式地址
(内部做 &0xFE / |0x01所以直接传 0xB4 / 0xB5。 */
#define AW816_DEV_ADDR 0x5A /* 7 位地址 */
#define AW816_WR_ADDR 0xB4 /* 写地址8 位格式) */
#define AW816_RD_ADDR 0xB5 /* 读地址8 位格式) */
#define AW816_I2C_TIMEOUT 1000
/* I2C 外设I2C1 */
#define AW816_I2C I2C1
/* 函数声明 */
extern void AW816_Init(void);
extern void AW816_Set_Volume(int16_t vol); /* 音量 -9000 ~ 1200 */
extern void AW816_Set_Reverb(uint8_t rev); /* 混响 0~100 */
extern uint8_t AW816_Read_Cmd(uint8_t ctrl, uint8_t *out_lo, uint8_t *out_hi);
#endif