inc/ssm2602.h File Reference

#include "tll_config.h"
#include <isrDisp.h>

Include dependency graph for ssm2602.h:

This graph shows which files directly or indirectly include this file:


Defines

#define SSM2602_RX   (0x01)
 .h This file contains the register, function declarations for the ssm2602 audio codec.
#define SSM2602_TX   (0x01<<1)
#define SSM2602_DEFAULT_INPUT_VOLUME   0x27
#define SSM2602_I2C_SCLK   400000
#define SSM2602_I2C_ADDR_A   0x1a
#define SSM2602_I2C_ADDR_B   0x1b
#define R0_LEFT_CHANNEL_ADC_INPUT_VOLUME   (0x00)
#define R1_RIGHT_CHANNEL_ADC_INPUT_VOLUME   (0x01)
#define R2_LEFT_CHANNEL_DAC_VOLUME   (0x02)
#define R3_RIGHT_CHANNEL_DAC_VOLUME   (0x03)
#define R4_ANALOG_AUDIO_PATH   (0x04)
#define R5_DIGITAL_AUDIO_PATH   (0x05)
#define R6_POWER_MANAGEMENT   (0x06)
#define R7_DIGITAL_AUDIO_IF   (0x07)
#define R8_SAMPLING_RATE   (0x08)
#define R9_ACTIVE   (0x09)
#define R15_SOFTWARE_RESET   (0x0f)
#define R16_ALC_CONTROL_1   (0x10)
#define R17_ALC_CONTROL_2   (0x11)
#define R18_NOISE_GATE   (0x12)
#define LRINBOTH   0x100
#define LINMUTE   0x080
#define LINVOL   0x03f
#define LRHPBOTH   0x100
#define LZCEN   0x080
#define LHPVOL   0x07f
#define MICBOOST2   0x100
#define SIDETONE_ATT   0x0c0
#define SIDETONE_EN   0x020
#define DACSEL   0x010
#define AUDIO_BYPASS   0x008
#define INSEL   0x004
#define MUTEMIC   0x002
#define MICBOOST   0x001
#define HPOR   0x010
#define DACMU   0x008
#define DEEMPH   0x006
#define ADCHPF   0x001
#define BCLKINV   0x080
#define MS   0x040
#define LRSWAP   0x020
#define LRP   0x010
#define WL   0x00c
#define FORMAT   0x003
#define CLKODIV2   0x080
#define CLKDIV2   0x040
#define SR   0x03c
#define BOSR   0x002
#define USB   0x001
#define SOFT_RESET   0x1ff
#define PCM_DATA_WORD_SIZE   32
#define SAMPLING_FREQUENCY   8000
#define CMD_WRITE   0
#define CMD_READ   1
#define AUDIO_ANALOG_LOOPBACK_FEATURE   ENABLED
#define AUDIO_PLAYBACK_FEATURE   ENABLED
#define AUDIO_DIGITAL_LOOPBACK_FEATURE   ENABLED
#define MAX_DMA_LEN   65536
#define ssm2602_deinit(void)   ssm2602_init()
 De-initialize the i2c interface and SSM2602 reset.
#define MICIN   0
#define LINEIN   1
#define AUDIO_SOURCE   LINEIN

Typedefs

typedef enum __Ssm2602Channel eSsm2602Channel
 audio channels on SSM2602
typedef enum __Ssm2602SampleFreq eSsm2602SampleFreq
 SSM2602 Sample Fequencies.

Enumerations

enum  __Ssm2602Channel { SSM2602_MAIN_IN = 0, SSM2602_MAIN_OUT }
 audio channels on SSM2602 More...
enum  __Ssm2602SampleFreq {
  SSM2602_SR_8000 = 0, SSM2602_SR_8020, SSM2602_SR_11025, SSM2602_SR_12000,
  SSM2602_SR_16000, SSM2602_SR_22050, SSM2602_SR_24000, SSM2602_SR_32000,
  SSM2602_SR_44100, SSM2602_SR_48000, SSM2602_SR_88200, SSM2602_SR_96000
}
 SSM2602 Sample Fequencies. More...

Functions

int ssm2602_init (isrDisp_t *pIsrDisp, int volumeOut, int frequency, int flags)
 Initialize the i2c interface and SSM2602 reset.
int ssm2602_i2c_init_playback (void)
 Initialize the SSM2602 in playback mode.
void reconfig_dma (unsigned char *pSamples, unsigned int nBytes)
 Reconfigure dma channel 4 after done with transfering the 1st part of audio data.
void ssm2602_sport0_init_playback (void)
 Initialize the audio codec in playback mode.
void ssm2602_sport0_deinit_playback (void)
 De-initialize the playback mode of audio codec.
void ssm2602_sport0_playback_dma (unsigned char *pSamples, unsigned int nBytes)
 Playback sound at pSamples location whith len bytes.
int ssm2602_setVolume (eSsm2602Channel channel, unsigned char left, unsigned char right)
 SSM2602 set volume.
int ssm2602_setSamplingFeq (eSsm2602Channel channel, eSsm2602SampleFreq freq)
 SSM2602 set sampling fequency.
int ssm2602_i2c_init_bypass (void)
 Initialize the SSM2602 in analog loopback mode.
int ssm2602_i2c_init_digital_loopback (void)
 Initialize the SSM2602 in digital loopback mode.
void ssm2602_sport0_init_digital_loopback (void)
 Initialize the audio codec in digital loopback mode.
void ssm2602_sport0_deinit_digital_loopback (void)
 De-initialize the digital loopback mode of audio codec.
int audio_test (void)
 Tests the SSM2602 features.
int ssm2602_txDma (unsigned char *address, int count)
 Set the tx DMA.

Define Documentation

#define ADCHPF   0x001

#define AUDIO_ANALOG_LOOPBACK_FEATURE   ENABLED

#define AUDIO_BYPASS   0x008

#define AUDIO_DIGITAL_LOOPBACK_FEATURE   ENABLED

#define AUDIO_PLAYBACK_FEATURE   ENABLED

#define AUDIO_SOURCE   LINEIN

#define BCLKINV   0x080

#define BOSR   0x002

#define CLKDIV2   0x040

#define CLKODIV2   0x080

#define CMD_READ   1

#define CMD_WRITE   0

#define DACMU   0x008

#define DACSEL   0x010

#define DEEMPH   0x006

#define FORMAT   0x003

#define HPOR   0x010

#define INSEL   0x004

#define LHPVOL   0x07f

#define LINEIN   1

#define LINMUTE   0x080

#define LINVOL   0x03f

#define LRHPBOTH   0x100

#define LRINBOTH   0x100

#define LRP   0x010

#define LRSWAP   0x020

#define LZCEN   0x080

#define MAX_DMA_LEN   65536

#define MICBOOST   0x001

#define MICBOOST2   0x100

#define MICIN   0

#define MS   0x040

#define MUTEMIC   0x002

#define PCM_DATA_WORD_SIZE   32

#define R0_LEFT_CHANNEL_ADC_INPUT_VOLUME   (0x00)

#define R15_SOFTWARE_RESET   (0x0f)

#define R16_ALC_CONTROL_1   (0x10)

#define R17_ALC_CONTROL_2   (0x11)

#define R18_NOISE_GATE   (0x12)

#define R1_RIGHT_CHANNEL_ADC_INPUT_VOLUME   (0x01)

#define R2_LEFT_CHANNEL_DAC_VOLUME   (0x02)

#define R3_RIGHT_CHANNEL_DAC_VOLUME   (0x03)

#define R4_ANALOG_AUDIO_PATH   (0x04)

#define R5_DIGITAL_AUDIO_PATH   (0x05)

#define R6_POWER_MANAGEMENT   (0x06)

#define R7_DIGITAL_AUDIO_IF   (0x07)

#define R8_SAMPLING_RATE   (0x08)

#define R9_ACTIVE   (0x09)

#define SAMPLING_FREQUENCY   8000

#define SIDETONE_ATT   0x0c0

#define SIDETONE_EN   0x020

#define SOFT_RESET   0x1ff

#define SR   0x03c

#define SSM2602_DEFAULT_INPUT_VOLUME   0x27

int ssm2602_deinit ( void   )     ssm2602_init()

De-initialize the i2c interface and SSM2602 reset.

This function:- 1. Soft resets the SSM2602 audio codec. 2. De-initalizes the i2c interface.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
None. 
Returns:
Zero on success. Negative value on failure.

#define SSM2602_I2C_ADDR_A   0x1a

#define SSM2602_I2C_ADDR_B   0x1b

#define SSM2602_I2C_SCLK   400000

#define SSM2602_RX   (0x01)

.h This file contains the register, function declarations for the ssm2602 audio codec.

#define SSM2602_TX   (0x01<<1)

#define USB   0x001

#define WL   0x00c


Typedef Documentation

typedef enum __Ssm2602Channel eSsm2602Channel

audio channels on SSM2602

typedef enum __Ssm2602SampleFreq eSsm2602SampleFreq

SSM2602 Sample Fequencies.


Enumeration Type Documentation

enum __Ssm2602Channel

audio channels on SSM2602

Enumerator:
SSM2602_MAIN_IN  main output channel
SSM2602_MAIN_OUT 

enum __Ssm2602SampleFreq

SSM2602 Sample Fequencies.

Enumerator:
SSM2602_SR_8000 
SSM2602_SR_8020 
SSM2602_SR_11025 
SSM2602_SR_12000 
SSM2602_SR_16000 
SSM2602_SR_22050 
SSM2602_SR_24000 
SSM2602_SR_32000 
SSM2602_SR_44100 
SSM2602_SR_48000 
SSM2602_SR_88200 
SSM2602_SR_96000 


Function Documentation

int audio_test ( void   ) 

Tests the SSM2602 features.

This function provides a user interface to test the codec features.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
None. 
Returns:
Zero if the test passed. Negative value if the test failed.

void reconfig_dma ( unsigned char *  pSamples,
unsigned int  nBytes 
)

Reconfigure dma channel 4 after done with transfering the 1st part of audio data.

This function will do the following:- 1. Disable dma4. 2. Reconfigure dma4 according to the even or odd number of interrupts. 3. Enable dma4.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
pSample - pointer to the start address of the audio data nBytes - audio data number in bytes
Returns:
void

int ssm2602_i2c_init_bypass ( void   ) 

Initialize the SSM2602 in analog loopback mode.

This function configures the Audio codec for only loopback mode: - a. Unmute left & right channel ADC volume. Set to some audible volumes. ???Check if this is required b. Analog Audio Path: Enable BYPASS, select input as Line In & rest default. c. Power up & Soft reset.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
None. 
Returns:
Zero on success. Negative value on failure.

int ssm2602_i2c_init_digital_loopback ( void   ) 

Initialize the SSM2602 in digital loopback mode.

This function configures the Audio codec for only digital loopback mode (Record + Playback) : - a. Left & right channel DAC volume. Set to some audible volumes. b. Digital audio path: Unmute, & other default values. f. Digital Audio I/F: Configure it for 32 bit data length & I2S mode. c. Sampling rate: 8KHz, normal mode (not usb) & other default values. d. Audio Input Path: Disable the BYPASS (since default enabled). ///???This might reduce the noise. e. Activate the digital core in ACTIVE register.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
None. 
Returns:
Zero on success. Negative value on failure.

int ssm2602_i2c_init_playback ( void   ) 

Initialize the SSM2602 in playback mode.

This function configures the Audio codec for only playback: - 1. Left & right channel DAC volume. Set to some audible volumes. 2. Digital audio path: Unmute, & other default values. 3. Digital Audio I/F: Configure it for 32 bit data length & I2S mode. 4. Sampling rate: 8KHz, normal mode (not usb) & other default values. 5. Audio Input Path: Disable the BYPASS (since default enabled). ///???This might reduce the noise. 6. Activate the digital core in ACTIVE register.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
None. 
Returns:
Zero on success. Negative value on failure.

int ssm2602_init ( isrDisp_t pIsrDisp,
int  volumeOut,
int  frequency,
int  flags 
)

Initialize the i2c interface and SSM2602 reset.

This function:- 1. Initalizes the i2c interface as the master. 2. Soft resets the SSM2602 audio codec.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
None. 
Returns:
Zero on success. Negative value on failure.

register own ISR with isr dispatcher

int ssm2602_setSamplingFeq ( eSsm2602Channel  channel,
eSsm2602SampleFreq  freq 
)

SSM2602 set sampling fequency.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
srFreq sampling frequency
Returns:
void

int ssm2602_setVolume ( eSsm2602Channel  channel,
unsigned char  left,
unsigned char  right 
)

SSM2602 set volume.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
channel input or output channel
left left volume (0 softest 127 loudest +6dB)
right right volume (0 softest 127 loudest +6dB)
Note for output volume <64 channel is muted
Returns:
void

void ssm2602_sport0_deinit_digital_loopback ( void   ) 

De-initialize the digital loopback mode of audio codec.

This function disables the dma and the sport.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
None. 
Returns:
void

void ssm2602_sport0_deinit_playback ( void   ) 

De-initialize the playback mode of audio codec.

This function disables the dma and the sport.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
None. 
Returns:
void

void ssm2602_sport0_init_digital_loopback ( void   ) 

Initialize the audio codec in digital loopback mode.

This function:- 1. Configures the sport interface. 2. Uses the peripheral DMA3 to transfer data from peripheral to the memory. 3. Uses the peripheral DMA4 to transfer data from memory (stored by DMA3) to the peripheral.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
None. 
Returns:
void

void ssm2602_sport0_init_playback ( void   ) 

Initialize the audio codec in playback mode.

This function:- 1. Configures the sport interface. 2. Configures the SSM2602 in playback mode. 3. Uses the peripheral DMA to transfer data from memory to the peripheral.

Pre-conditions:

Post condtions:

Parameters:

Parameters:
None. 
Returns:
void

void ssm2602_sport0_playback_dma ( unsigned char *  pSamples,
unsigned int  nBytes 
)

Playback sound at pSamples location whith len bytes.

This function will do the following:- 1. Configures the sport interface. 2. Configures the SSM2602 in playback mode. 3. Configure DMA to write audio data to the sport0 FIFO

Note: this interface does not define sample width or frequency

Pre-conditions:

Post condtions:

Parameters:

Parameters:
pSamples pointer to samples for playing
len number of bytes to play
Returns:
void

int ssm2602_txDma ( unsigned char *  address,
int  count 
)

Set the tx DMA.

This function provides a user interface to set the TX dma

Pre-conditions:

Post condtions:

Parameters:

Parameters:
Memory location, count
Returns:
Zero if passed. Negative value if failed.


Generated on 3 Mar 2014 for PAL bare-c Library by  doxygen 1.4.7