|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
-
-
- #include <Arduino.h>
- #include "control_cs42448.h"
- #include "Wire.h"
-
-
- #define CS42448_Chip_ID 0x01
- #define CS42448_Power_Control 0x02
- #define CS42448_Functional_Mode 0x03
- #define CS42448_Interface_Formats 0x04
- #define CS42448_ADC_Control_DAC_DeEmphasis 0x05
- #define CS42448_Transition_Control 0x06
- #define CS42448_DAC_Channel_Mute 0x07
- #define CS42448_AOUT1_Volume_Control 0x08
- #define CS42448_AOUT2_Volume_Control 0x09
- #define CS42448_AOUT3_Volume_Control 0x0A
- #define CS42448_AOUT4_Volume_Control 0x0B
- #define CS42448_AOUT5_Volume_Control 0x0C
- #define CS42448_AOUT6_Volume_Control 0x0D
- #define CS42448_AOUT7_Volume_Control 0x0E
- #define CS42448_AOUT8_Volume_Control 0x0F
- #define CS42448_DAC_Channel_Invert 0x10
- #define CS42448_AIN1_Volume_Control 0x11
- #define CS42448_AIN2_Volume_Control 0x12
- #define CS42448_AIN3_Volume_Control 0x13
- #define CS42448_AIN4_Volume_Control 0x14
- #define CS42448_AIN5_Volume_Control 0x15
- #define CS42448_AIN6_Volume_Control 0x16
- #define CS42448_ADC_Channel_Invert 0x17
- #define CS42448_Status_Control 0x18
- #define CS42448_Status 0x19
- #define CS42448_Status_Mask 0x1A
- #define CS42448_MUTEC_Pin_Control 0x1B
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- static const uint8_t default_config[] = {
- 0xF4,
- 0x76,
- 0x1C,
- 0x63,
- 0xFF
- };
-
- bool AudioControlCS42448::enable(void)
- {
- Wire.begin();
-
- if (!write(CS42448_Power_Control, 0xFF)) return false;
- if (!write(CS42448_Functional_Mode, default_config, sizeof(default_config))) return false;
- if (!write(CS42448_Power_Control, 0)) return false;
- return true;
- }
-
- bool AudioControlCS42448::volumeInteger(uint32_t n)
- {
- uint8_t data[9];
- data[0] = 0;
- for (int i=1; i < 9; i++) {
- data[i] = n;
- }
- return write(CS42448_DAC_Channel_Mute, data, 9);
- }
-
- bool AudioControlCS42448::volumeInteger(int channel, uint32_t n)
- {
-
- return true;
- }
-
- bool AudioControlCS42448::inputLevelInteger(int32_t n)
- {
-
- return true;
- }
-
- bool AudioControlCS42448::inputLevelInteger(int chnnel, int32_t n)
- {
-
- return true;
- }
-
- bool AudioControlCS42448::write(uint32_t address, uint32_t data)
- {
- Wire.beginTransmission(i2c_addr);
- Wire.write(address);
- Wire.write(data);
- if (Wire.endTransmission() == 0) return true;
- return false;
- }
-
- bool AudioControlCS42448::write(uint32_t address, const void *data, uint32_t len)
- {
- Wire.beginTransmission(i2c_addr);
- Wire.write(address | 0x80);
- const uint8_t *p = (const uint8_t *)data;
- const uint8_t *end = p + len;
- while (p < end) {
- Wire.write(*p++);
- }
- if (Wire.endTransmission() == 0) return true;
- return false;
- }
-
-
|