/* * cs4272.h * * Created on: Aug 16, 2026 * Author: ozpv */ #ifndef INC_CS4272_H_ #define INC_CS4272_H_ #include /* cs4272k-czzr 7. REGISTER QUICK REFERENCE */ #define MODE_CONTROL_1 0x01 #define DAC_CONTROL 0x02 #define DAC_VOLUME_AND_MIXING_CONTROL 0x03 #define DAC_CH_A_VOLUME_CONTROL 0x04 #define DAC_CH_B_VOLUME_CONTROL 0x05 #define ADC_CONTROL 0x06 #define MODE_CONTROL_2 0x07 #define CHIP_ID 0x08 #define CS4272_CHIP_ID 0x0 /* set by ad0 ncs pin */ #define CS4272_I2C_ADDR (0b0010000 << 1) #define SAMPLE_RATE 48000 #define BUFFER_SIZE 1024 typedef enum Channel { LEFT = 0, RIGHT = 1, MONO = 0, } Channel; extern int32_t rx_buffer[BUFFER_SIZE]; extern int32_t tx_buffer[BUFFER_SIZE]; extern const uint8_t CS4272_CONFIG[7]; uint8_t CS4272_Init(void); static inline __attribute__((always_inline)) float int24_t_to_f32(const int32_t in) { return ((float)(in << 8)) / ((float)INT32_MAX); } static inline __attribute__((always_inline)) int32_t f32_to_int24_t(const float in) { return ((int32_t)(in * ((float)INT32_MAX))) >> 8; } #endif /* INC_CS4272_H_ */