diff options
Diffstat (limited to 'Core/Inc/cs4272.h')
| -rwxr-xr-x | Core/Inc/cs4272.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Core/Inc/cs4272.h b/Core/Inc/cs4272.h index 423b7c0..4e22263 100755 --- a/Core/Inc/cs4272.h +++ b/Core/Inc/cs4272.h @@ -26,16 +26,27 @@ #define CS4272_I2C_ADDR (0b0010000 << 1)
#define SAMPLE_RATE 48000
-#define BUFFER_SIZE 512
+#define BUFFER_SIZE 1024
-extern volatile int32_t rx_buffer[BUFFER_SIZE];
-extern volatile int32_t tx_buffer[BUFFER_SIZE];
-extern volatile float samples[BUFFER_SIZE];
+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);
-#define INT24_MAX 0x7FFFFF
+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_ */
|
