Skip to content

Commit 3158bb2

Browse files
committed
Driver Corrections
1 parent cbb144c commit 3158bb2

File tree

13 files changed

+41
-36
lines changed

13 files changed

+41
-36
lines changed

src/Driver.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class AudioDriver {
193193
GpioPin pin = pins().getPinID(PinFunction::PA);
194194
if (pin == -1)
195195
return false;
196-
//AD_LOGI("setPAPower pin %d -> %d", pin, enable);
196+
AD_LOGI("setPAPower pin %d -> %d", pin, enable);
197197
digitalWrite(pin, enable ? HIGH : LOW);
198198
return true;
199199
}
@@ -286,13 +286,13 @@ class AudioDriverAC101Class : public AudioDriver {
286286
};
287287

288288
/**
289-
* @brief Driver API for the CS43l22 codec chip
289+
* @brief Driver API for the CS43l22 codec chip on 0x94 (0x4A<<1)
290290
* @author Phil Schatzmann
291291
* @copyright GPLv3
292292
*/
293293
class AudioDriverCS43l22Class : public AudioDriver {
294294
public:
295-
AudioDriverCS43l22Class(uint16_t deviceAddr = 0x94) {
295+
AudioDriverCS43l22Class(uint16_t deviceAddr = 0x94 ) {
296296
this->deviceAddr = deviceAddr;
297297
}
298298

@@ -304,12 +304,18 @@ class AudioDriverCS43l22Class : public AudioDriver {
304304
codec_cfg = codecCfg;
305305
// manage reset pin -> acive high
306306
setPAPower(true);
307-
delay(10);
307+
// Setup enable pin for codec
308+
delay(100);
308309
int vol = map(volume, 0, 100, DEFAULT_VOLMIN, DEFAULT_VOLMAX);
309310
uint32_t freq = getFrequency(codec_cfg.i2s.rate);
310311
uint16_t outputDevice = getOutput(codec_cfg.output_device);
311312
AD_LOGD("cs43l22_Init");
312-
return cs43l22_Init(deviceAddr, outputDevice, vol, freq, getI2C()) == 0;
313+
bool result = cs43l22_Init(deviceAddr, outputDevice, vol, freq, getI2C()) == 0;
314+
if (!result){
315+
AD_LOGE("error: cs43l22_Init");
316+
}
317+
cs43l22_Play(deviceAddr, nullptr, 0);
318+
return result;
313319
}
314320

315321
bool setMute(bool mute) {

src/Driver/cs43l22/cs43l22.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,8 @@ static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
477477

478478
void AUDIO_IO_Init(void) {}
479479
void AUDIO_IO_DeInit(void) {}
480-
void AUDIO_IO_Write(uint8_t addr, uint16_t reg, uint8_t value) {
481-
i2c_bus_write_bytes(i2c_handle, addr, (uint8_t *)&reg, sizeof(uint16_t), &value, 1);
480+
void AUDIO_IO_Write(uint8_t addr, uint8_t reg, uint8_t value) {
481+
i2c_bus_write_bytes(i2c_handle, addr, &reg, 1, &value, 1);
482482
}
483483

484484

src/Driver/cs43l22/cs43l22.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ uint32_t cs43l22_Reset(uint16_t DeviceAddr);
196196
/* AUDIO IO functions */
197197
void AUDIO_IO_Init(void);
198198
void AUDIO_IO_DeInit(void);
199-
void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint8_t Value);
200-
uint8_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg);
199+
void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
200+
uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg);
201201

202202
/* Audio driver structure */
203203
//extern AUDIO_DrvTypeDef cs43l22_drv;

src/Driver/es7210/es7210.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,6 @@ void es7210_read_all(void)
507507
{
508508
for (int i = 0; i <= 0x4E; i++) {
509509
uint8_t reg = es7210_read_reg(i);
510-
AD_LOGI("REG:%02x, %02x\n", reg, i);
510+
AD_LOGI("REG:%02x, %02x", reg, i);
511511
}
512512
}

src/Driver/es7243/es7243.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ error_t es7243_adc_config_i2s(codec_mode_t mode, I2SDefinition *iface)
120120

121121
error_t es7243_adc_set_voice_mute(bool mute)
122122
{
123-
AD_LOGI( "Enter into es7243_mute(), mute = %d\n", mute);
123+
AD_LOGI( "Enter into es7243_mute(), mute = %d", mute);
124124
if (mute) {
125125
es7243_write_reg(0x05, 0x1B);
126126
} else {

src/Driver/es8311/es8311.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ static int get_coeff(uint32_t mclk, uint32_t rate)
233233
static void es8311_mute(int mute)
234234
{
235235
uint8_t regv;
236-
AD_LOGI( "Enter into es8311_mute(), mute = %d\n", mute);
236+
AD_LOGI( "Enter into es8311_mute(), mute = %d", mute);
237237
regv = es8311_read_reg(ES8311_DAC_REG31) & 0x9f;
238238
if (mute) {
239239
es8311_write_reg(ES8311_SYSTEM_REG12, 0x02);
@@ -700,6 +700,6 @@ void es8311_read_all()
700700
{
701701
for (int i = 0; i < 0x4A; i++) {
702702
uint8_t reg = es8311_read_reg(i);
703-
AD_LOGI("REG:%02x, %02x\n", reg, i);
703+
AD_LOGI("REG:%02x, %02x", reg, i);
704704
}
705705
}

src/Driver/es8388/es8388.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void es8388_read_all()
5151
for (int i = 0; i < 50; i++) {
5252
uint8_t reg = 0;
5353
es_read_reg(i, &reg);
54-
AD_LOGI("%x: %x\n", i, reg);
54+
AD_LOGI("%x: %x", i, reg);
5555
}
5656
}
5757

@@ -76,7 +76,7 @@ static int es8388_set_adc_dac_volume(int mode, int volume, int dot)
7676
AD_LOGD("es8388_set_adc_dac_volume: %d.%d", volume,dot);
7777
int res = 0;
7878
if ( volume < -96 || volume > 0 ) {
79-
AD_LOGW("Warning: volume < -96! or > 0!\n");
79+
AD_LOGW("Warning: volume < -96! or > 0!");
8080
if (volume < -96)
8181
volume = -96;
8282
else

src/Driver/tas5805m/tas5805m.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static error_t tas5805m_transmit_registers(const tas5805m_cfg_reg_t *conf_buf, i
9090
break;
9191
case CFG_END_1:
9292
if (CFG_END_2 == conf_buf[i + 1].offset && CFG_END_3 == conf_buf[i + 2].offset) {
93-
AD_LOGI( "End of tms5805m reg: %d\n", i);
93+
AD_LOGI( "End of tms5805m reg: %d", i);
9494
}
9595
break;
9696
default:

src/Driver/wm8994/wm8994.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ uint32_t wm8994_ReadID(uint16_t DeviceAddr)
525525
/* Initialize the Control interface of the Audio Codec */
526526
AUDIO_IO_Init();
527527

528-
return ((uint32_t)AUDIO_IO_Read(DeviceAddr, WM8994_CHIPID_ADDR));
528+
return ((uint32_t)AUDIO_IO_Read16(DeviceAddr, WM8994_CHIPID_ADDR));
529529
}
530530

531531
/**

src/Driver/wm8994/wm8994.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ uint32_t wm8994_Reset(uint16_t DeviceAddr);
154154
void AUDIO_IO_Init(void);
155155
void AUDIO_IO_DeInit(void);
156156
void AUDIO_IO_Write16(uint8_t Addr, uint16_t Reg, uint16_t Value);
157-
uint8_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg);
157+
uint8_t AUDIO_IO_Read16(uint8_t Addr, uint16_t Reg);
158158
void AUDIO_IO_Delay(uint32_t Delay);
159159

160160
/* Audio driver structure */

0 commit comments

Comments
 (0)