AudioDAC/Drivers/CS43L22/CS43L22.h
2021-04-04 22:50:51 +02:00

73 lines
2.0 KiB
C

/*
* CS43L22.h
*
* Created on: Apr 3, 2021
* Author: Think
*/
#ifndef CS43L22_H
#define CS43L22_H
#include <inttypes.h>
#include "stm32f4xx_hal.h"
#include "MY_TYPES.h"
#define CS43L22_RESGISTER_COUNT 36
//CS43L22 register definitio
#define ID 0x01
#define POWER_CTL_1 0x02
#define POWER_CTL_2 0x04
#define CLOCKING_CTL 0x05
#define INTERFACE_CTL_1 0x06
#define INTERFACE_CTL_2 0x07
#define PASSTHROUGH_A_SELECT 0x08
#define PASSTHROUGH_B_SELECT 0x09
#define ANALOG_ZC_AND_SR_SETTING 0x0A
#define PASSTHROUGH_GANG_CONTROL 0x0C
#define PLAYBACK_CTL_1 0x0D
#define MISC_CTL 0x0E
#define PLAYBACK_CTL_2 0x0F
#define PASSTHROUGH_A_VOL 0x14
#define PASSTHROUGH_B_VOL 0x15
#define PCMA_VOL 0x1A
#define PCMB_VOL 0x1B
#define BEEP_FREQ_ON_TIME 0x1C
#define BEEP_VOL_OFF_TIME 0x1D
#define BEEP_TONE_CFG 0x1E
#define TONE_CTL 0x1F
#define MASTER_A_VOL 0x20
#define MASTER_B_VOL 0x21
#define HEADPHONE_A_VOLUME 0x22
#define HEADPHONE_B_VOLUME 0x23
#define SPEAKER_A_VOLUME 0x24
#define SPEAKER_B_VOLUME 0x25
#define CHANNEL_MIXER_AND_SWAP 0x26
#define LIMIT_CTL_1_THRESHOLDS 0x27
#define LIMIT_CTL_2_THRESHOLDS 0x28
#define LIMITER_ATTACK_RATE 0x29
#define OVERFLOW_AND_CLOCK_STATUS 0x2E
#define BATTERY_COMPENSATION 0x2F
#define VP_BATTERY_LEVEL 0x30
#define SPEAKER_STATUS 0x31
#define CHARGE_PUMP_FREQUENCY 0x34
//CS43L22 Structure
typedef struct
{
I2C_HandleTypeDef *i2cHandler;
} CS43L22;
//Driver function declaration
bool CS43L22_Init(CS43L22 *device, I2C_HandleTypeDef *i2cHandler);
const uint8_t * const CS43L22_GetRegisterArray(void);
bool CS43L22_Reset(CS43L22 *device);
bool CS43L22_ApplyConfig(CS43L22 *device);
bool CS43L22_GetDeviceID(CS43L22 *device, uint8_t *chipID, uint8_t *chipREVID);
bool CS43L22_ReadRegister(CS43L22 *device, uint8_t registerAddr, uint8_t *data);
bool CS43L22_WriteRegister(CS43L22 *device, uint8_t registerAddr, uint8_t data);
bool CS43L22_RegisterDump(CS43L22 *device, uint8_t registers[36]);
#endif //CS43L22_H