CARME-M4 BSP  V1.5
Sound

CARME-M4 Sound controller. More...

+ Collaboration diagram for Sound:

Files

file  cs42l51.h
 CS42L51 codec support functions.
 
file  cs42l51.c
 CS42L51 codec support functions.
 

Macros

#define CODEC_I2C   CARME_I2C_AUDIO
 
#define CODEC_I2S   SPI2
 
#define CODEC_I2S_EXT   I2S2ext
 
#define CODEC_I2S_CLK   RCC_APB1Periph_SPI2
 
#define CODEC_ADDRESS   0x94
 
#define CHIP_ID   0x01
 
#define POWER_CONTROL   0x02
 
#define MIC_POWER_AND_SPEED   0x03
 
#define INTERFACE_CONTROL   0x04
 
#define MIC_CONTROL   0x05
 
#define ADC_CONTROL   0x06
 
#define ADC_CONFIGURE   0x07
 
#define DAC_OUTPUT_CONTROL   0x08
 
#define DAC_CONTROL   0x09
 
#define ALCA_AND_PGAA_CONTROL   0x0A
 
#define ALCB_AND_PGAB_CONTROL   0x0B
 
#define ADCX_ATTENUATOR   0x0D
 
#define ADCX_MIXER_VOLUME_CONTROL   0x0F
 
#define PCMA_MIXER_VOLUME_CONTROL   0x10
 
#define PCMB_MIXER_VOLUME_CONTROL   0x11
 
#define BEEP_FREQUENCY_AND_TIMING   0x12
 
#define BEEP_OFF_TIME_AND_VOLUME   0x13
 
#define BEEP_AND_TONE_CONFIGURATION   0x14
 
#define TONE_CONTROL   0x15
 
#define AOUTA_VOLUME_CONTROL   0x16
 
#define AOUTB_VOLUME_CONTROL   0x17
 
#define PCM_CHANNEL_MIXER   0x18
 
#define LIMITER_THRESHOLD   0x19
 
#define LIMITER_RELEASE   0x1A
 
#define LIMITER_ATTACK   0x1B
 
#define ALC_ENABLE_AND_ATTACK   0x1C
 
#define ALC_RELEASE   0x1D
 
#define ALC_THRESHOLD   0x1E
 
#define NOISE_GATE   0x1F
 
#define STATUS_REGISTER   0x20
 
#define CHARGE_PUMP_FREQUENCY   0x21
 

Functions

uint8_t CS42L51_Init (int8_t Volume)
 Codec CS42L51 low-layer and register initialization. More...
 
uint8_t CS42L51_Status (void)
 Get the status of the cs42l51 codec. More...
 
void CS42L51_VolumeOutCtrl (int8_t Volume)
 Codec CS42L51 output volume control. More...
 
void CS42L51_Mute (uint8_t on)
 Mute the CS42L51 output. More...
 
void CS42L51_CtrlInterface_Init (void)
 Codec CS42L51 ctrl line configuration and register initialization. More...
 
void CS42L51_AudioInterface_Init (void)
 Codec CS42L51 audio line configuration. More...
 
void CS42L51_WriteReg (uint8_t reg, uint8_t data)
 Write a byte to a register of the cs42l51 codec. More...
 
uint8_t CS42L51_ReadReg (uint8_t reg)
 Read a byte from a register of the cs42l51 codec. More...
 

Detailed Description

CARME-M4 Sound controller.

Macro Definition Documentation

#define ADC_CONFIGURE   0x07

Cmd ADC cfg

Definition at line 92 of file cs42l51.h.

#define ADC_CONTROL   0x06

Cmd ADC ctrl

Definition at line 91 of file cs42l51.h.

#define ADCX_ATTENUATOR   0x0D

Cmd ADCx attenuator

Definition at line 97 of file cs42l51.h.

#define ADCX_MIXER_VOLUME_CONTROL   0x0F

Cmd ADCx mixer volume ctrl

Definition at line 98 of file cs42l51.h.

#define ALC_ENABLE_AND_ATTACK   0x1C

Cmd ALC enable and attack

Definition at line 111 of file cs42l51.h.

#define ALC_RELEASE   0x1D

Cmd ALC release

Definition at line 112 of file cs42l51.h.

#define ALC_THRESHOLD   0x1E

Cmd ALC threshold

Definition at line 113 of file cs42l51.h.

#define ALCA_AND_PGAA_CONTROL   0x0A

Cmd ALCA and PGAA ctrl

Definition at line 95 of file cs42l51.h.

#define ALCB_AND_PGAB_CONTROL   0x0B

Cmd ALCB and PGAB ctrl

Definition at line 96 of file cs42l51.h.

#define AOUTA_VOLUME_CONTROL   0x16

Cmd AOutA vol ctrl

Definition at line 105 of file cs42l51.h.

#define AOUTB_VOLUME_CONTROL   0x17

Cmd AOutB vol ctrl

Definition at line 106 of file cs42l51.h.

#define BEEP_AND_TONE_CONFIGURATION   0x14

Cmd Beep and tone cfg

Definition at line 103 of file cs42l51.h.

#define BEEP_FREQUENCY_AND_TIMING   0x12

Cmd Beep freq and timing

Definition at line 101 of file cs42l51.h.

#define BEEP_OFF_TIME_AND_VOLUME   0x13

Cmd Beep off time and vol

Definition at line 102 of file cs42l51.h.

#define CHARGE_PUMP_FREQUENCY   0x21

Cmd Charge pump freq

Definition at line 116 of file cs42l51.h.

#define CHIP_ID   0x01

Cmd Chip ID

Definition at line 86 of file cs42l51.h.

#define CODEC_ADDRESS   0x94

I2C address of codec

Definition at line 84 of file cs42l51.h.

#define CODEC_I2C   CARME_I2C_AUDIO

I2C bus to codec

Definition at line 80 of file cs42l51.h.

#define CODEC_I2S   SPI2

I2S bus to codec

Definition at line 81 of file cs42l51.h.

#define CODEC_I2S_CLK   RCC_APB1Periph_SPI2

I2S RCC

Definition at line 83 of file cs42l51.h.

#define CODEC_I2S_EXT   I2S2ext

I2Sext to codec

Definition at line 82 of file cs42l51.h.

#define DAC_CONTROL   0x09

Cmd DAC ctrl

Definition at line 94 of file cs42l51.h.

#define DAC_OUTPUT_CONTROL   0x08

Cmd DAC output ctrl

Definition at line 93 of file cs42l51.h.

#define INTERFACE_CONTROL   0x04

Cmd Interface ctrl

Definition at line 89 of file cs42l51.h.

#define LIMITER_ATTACK   0x1B

Cmd Limiter attack

Definition at line 110 of file cs42l51.h.

#define LIMITER_RELEASE   0x1A

Cmd Limiter release

Definition at line 109 of file cs42l51.h.

#define LIMITER_THRESHOLD   0x19

Cmd Limiter threshold

Definition at line 108 of file cs42l51.h.

#define MIC_CONTROL   0x05

Cmd Mic ctrl

Definition at line 90 of file cs42l51.h.

#define MIC_POWER_AND_SPEED   0x03

Cmd Mic power and speed

Definition at line 88 of file cs42l51.h.

#define NOISE_GATE   0x1F

Cmd Noise gate

Definition at line 114 of file cs42l51.h.

#define PCM_CHANNEL_MIXER   0x18

Cmd PCM channel mixer

Definition at line 107 of file cs42l51.h.

#define PCMA_MIXER_VOLUME_CONTROL   0x10

Cmd PCMA mixer volume ctrl

Definition at line 99 of file cs42l51.h.

#define PCMB_MIXER_VOLUME_CONTROL   0x11

Cmd PCMB mixer volume ctrl

Definition at line 100 of file cs42l51.h.

#define POWER_CONTROL   0x02

Cmd Power ctrl

Definition at line 87 of file cs42l51.h.

#define STATUS_REGISTER   0x20

Cmd Status register

Definition at line 115 of file cs42l51.h.

#define TONE_CONTROL   0x15

Cmd Tone ctrl

Definition at line 104 of file cs42l51.h.

Function Documentation

void CS42L51_AudioInterface_Init ( void  )

Codec CS42L51 audio line configuration.

Returns
None

Definition at line 275 of file cs42l51.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CS42L51_CtrlInterface_Init ( void  )

Codec CS42L51 ctrl line configuration and register initialization.

Returns
None

Definition at line 263 of file cs42l51.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint8_t CS42L51_Init ( int8_t  Volume)

Codec CS42L51 low-layer and register initialization.

Parameters
[in]VolumeCS42L51_VolumeOutCtrl.
Returns
1 if no codec is found, else 0.

Set mic power and speed

  • Select single speed mode (4-50 kHz)

Configure the interface

  • DAC and ADC interface is I2S

Set mic control

Set ADC control configuration

  • Enable the high-pass filter

Set the ADC configuration

  • Select the line in as source

Set DAC output configuration

  • HP Gain is 0.6047

Set DAC configuration

  • Data selection is 00 for PCM or 01 for signal processing engine
  • Soft ramp

Set PCMx mixer volume

  • mute the mixer channel

Set PCM channel mixer AOUTA = Channel L AOUTB = Channel R ADCA = Channel L ADCB = Channel R

Set limiter threshold

  • Maximum threshold = 0 dB
  • Cushion threshold = 0 dB

Limiter release rate

  • Disabled
  • Both channel
  • slowest release

Limiter attack rate

  • fastest attack

Enable periodic beep sound

  • On time: 5.2 s
  • Off time: 5.2 s
  • Frequency: 260.87 Hz (C4)
  • Volume: +12 dB
  • Repeat beep

Definition at line 133 of file cs42l51.c.

+ Here is the call graph for this function:

void CS42L51_Mute ( uint8_t  on)

Mute the CS42L51 output.

Parameters
[in]onif 0 the codec will unmute the output, else it will mute it.
Returns
None

Definition at line 369 of file cs42l51.c.

+ Here is the call graph for this function:

uint8_t CS42L51_ReadReg ( uint8_t  reg)

Read a byte from a register of the cs42l51 codec.

Parameters
[in]regRegister address to read
Returns
Data

Definition at line 117 of file cs42l51.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint8_t CS42L51_Status ( void  )

Get the status of the cs42l51 codec.

Returns
Status register

Definition at line 315 of file cs42l51.c.

+ Here is the call graph for this function:

void CS42L51_VolumeOutCtrl ( int8_t  Volume)

Codec CS42L51 output volume control.

Parameters
[in]VolumeBinary code volume setting
0001 1000 +12.0 dB
... ...
0000 0000 0.0 dB
1111 1111 -0.5 dB
1111 1110 -1.0 dB
... ...
0011 0100 -102 dB
... ...
0001 1001 -102 dB
Returns
None

Definition at line 337 of file cs42l51.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CS42L51_WriteReg ( uint8_t  reg,
uint8_t  data 
)

Write a byte to a register of the cs42l51 codec.

Parameters
[in]regRegister address to write
[in]dataData
Returns
None

Definition at line 104 of file cs42l51.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: