LPCOpen Platform for LPC18XX/43XX microcontrollers: BOARD: UDA1380 Audio codec interface module

| LPCOpen Platform for LPC18XX/43XX microcontrollers 18XX43XX LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers

- Main Page
- Modules
- Data Structures
- Files

Macros | Functions
BOARD: UDA1380 Audio codec interface module
BOARD: Common board components used with board drivers

## Detailed Description

UDA1380 Audio codec interface module, the module registers are accessed using I2C. The board which uses this module must define UDA1380_I2C_BUS to I2C0, I2C1, etc, based on which I2C bus is connected to UDA1380. All the functions in this modules assumes that the I2C interrupt for UDA1380_I2C_BUS is enabled and Chip_I2C_MasterStateHandler(UDA1380_I2C_BUS) is called from the ISR. If the functions are to be used in polling mode the caller must replace the event handler to Chip_I2C_EventHandlerPolling(), by using API Chip_I2C_SetMasterEventHandler(). A macro I2CDEV_UDA1380_ADDR must be defined to the appropriate slave address of UDA1380 audio codec.

## Macros
#define | UDA_EVALM_CLK 0x00
#define | UDA_BUS_CTRL 0x01
#define | UDA_POWER_CTRL 0x02
#define | UDA_ANALOG_CTRL 0x03
#define | UDA_HPAMP_CTRL 0x04
#define | UDA_MASTER_VOL_CTRL 0x10
#define | UDA_MIXER_VOL_CTRL 0x11
#define | UDA_MODE_CTRL 0x12
#define | UDA_MUTE_CTRL 0x13
#define | UDA_MIXER_FILTER_CTRL 0x14
#define | UDA_DEC_VOL_CTRL 0x20
#define | UDA_PGA_CTRL 0x21
#define | UDA_ADC_CTRL 0x22
#define | UDA_AGC_CTRL 0x23
#define | UDA_TOTAL_REG 0x24
#define | EVCLK_EV2 (1 << 15)
#define | EVCLK_EV1 (1 << 14)
#define | EVCLK_EV0 (1 << 13)
#define | EVCLK_EN_ADC (1 << 11)
#define | EVCLK_EN_DEC (1 << 10)
#define | EVCLK_EN_DAC (1 << 9)
#define | EVCLK_EN_INT (1 << 8)
#define | EVCLK_ADC_CLK (1 << 5)
#define | EVCLK_DAC_CLK (1 << 4)
#define | EVCLK_SYS_DIV1 (1 << 3)
#define | EVCLK_SYS_DIV0 (1 << 2)
#define | EVCLK_PLL1 (1 << 1)
#define | EVCLK_PLL0 (1 << 0)
#define | UDA1380_REG_EVALCLK_DEFAULT_VALUE (0xF << 8 | 0x3 << 4 | 1 << 1)
#define | UDA1380_REG_I2S_DEFAULT_VALUE 0x0000
#define | UDA1380_REG_PWRCTRL_DEFAULT_VALUE (1 << 15 | 1 << 13 | 1 << 10 | 1 << 8 | 1 << 6 | 1 << 4 | 0x0F)
#define | UDA1380_REG_ANAMIX_DEFAULT_VALUE 0x0000
#define | UDA1380_REG_HEADAMP_DEFAULT_VALUE ( 1 << 9 | 2)
#define | UDA1380_REG_MSTRVOL_DEFAULT_VALUE 0x0000
#define | UDA1380_REG_MIXVOL_DEFAULT_VALUE 0x0000
#define | UDA1380_REG_MODEBBT_DEFAULT_VALUE 0x0000
#define | UDA1380_REG_MSTRMUTE_DEFAULT_VALUE (2 << 8 | 2)
#define | UDA1380_REG_MIXSDO_DEFAULT_VALUE 0x0000
#define | UDA1380_REG_DECVOL_DEFAULT_VALUE 0xE4E4 /* Decrease Volume -28dB */
#define | UDA1380_REG_PGA_DEFAULT_VALUE 0x0000
#define | UDA1380_REG_ADC_DEFAULT_VALUE 0x0001 /* Apply 0bB VGA Gain, enable DC Filter */
#define | UDA1380_REG_AGC_DEFAULT_VALUE 0x0000
#define | UDA1380_REG_L3_DEFAULT_VALUE 0x0000
#define | UDA1380_LINE_IN 0
#define | UDA1380_MIC_IN_L (1 << 2)
#define | UDA1380_MIC_IN_LR (3 << 2)
#define | UDA1380_U8(val) (((val) >> 8) & 0xFF), ((val) & 0xFF)

## Functions
void | UDA1380_REG_Write (uint8_t reg, uint16_t val)
| Write a 16-bit value to UDA Register. More...
uint16_t | UDA1380_REG_Read (uint8_t reg)
| Read a 16-bit value from UDA1380 codec register. More...
int | UDA1380_REG_WriteVerify (uint8_t reg, uint16_t val)
| Writes a value to a UDA register, read back and verify the value. More...
int | UDA1380_REG_WriteMult (const uint8_t *buff, int len)
| Write multiple value to UDA1380 registers. More...
int | UDA1380_REG_VerifyMult (uint8_t reg, const uint8_t *value, uint8_t *buff, int len)
| Verify values in multiple UDA1380 registers. More...
int | UDA1380_Init (int input)
| Initialize UDA1380 to its default state. More...

## Macro Definition Documentation

#define EVCLK_ADC_CLK (1 << 5)

Definition at line 74 of file uda1380.h.

#define EVCLK_DAC_CLK (1 << 4)

Definition at line 75 of file uda1380.h.

#define EVCLK_EN_ADC (1 << 11)

Definition at line 70 of file uda1380.h.

#define EVCLK_EN_DAC (1 << 9)

Definition at line 72 of file uda1380.h.

#define EVCLK_EN_DEC (1 << 10)

Definition at line 71 of file uda1380.h.

#define EVCLK_EN_INT (1 << 8)

Definition at line 73 of file uda1380.h.

#define EVCLK_EV0 (1 << 13)

Definition at line 69 of file uda1380.h.

#define EVCLK_EV1 (1 << 14)

Definition at line 68 of file uda1380.h.

#define EVCLK_EV2 (1 << 15)

Evalutation mode and clock setting register bits

Definition at line 67 of file uda1380.h.

#define EVCLK_PLL0 (1 << 0)

Definition at line 79 of file uda1380.h.

#define EVCLK_PLL1 (1 << 1)

Definition at line 78 of file uda1380.h.

#define EVCLK_SYS_DIV0 (1 << 2)

Definition at line 77 of file uda1380.h.

#define EVCLK_SYS_DIV1 (1 << 3)

Definition at line 76 of file uda1380.h.

#define UDA1380_LINE_IN 0

LINE_IN_L in left stream, LINE_IN_R in Right stream

Definition at line 103 of file uda1380.h.

#define UDA1380_MIC_IN_L (1 << 2)

MIC audio in Left stream, Line_IN_R in Right stream

Definition at line 104 of file uda1380.h.

#define UDA1380_MIC_IN_LR (3 << 2)

MIC audio in Left & Right stream

Definition at line 105 of file uda1380.h.

#define UDA1380_REG_ADC_DEFAULT_VALUE 0x0001 /* Apply 0bB VGA Gain, enable DC Filter */

Definition at line 97 of file uda1380.h.

#define UDA1380_REG_AGC_DEFAULT_VALUE 0x0000

Definition at line 98 of file uda1380.h.

#define UDA1380_REG_ANAMIX_DEFAULT_VALUE 0x0000

Definition at line 86 of file uda1380.h.

#define UDA1380_REG_DECVOL_DEFAULT_VALUE 0xE4E4 /* Decrease Volume -28dB */

Definition at line 95 of file uda1380.h.

#define UDA1380_REG_EVALCLK_DEFAULT_VALUE (0xF << 8 | 0x3 << 4 | 1 << 1)

UDA1380 register default values

Definition at line 82 of file uda1380.h.

#define UDA1380_REG_HEADAMP_DEFAULT_VALUE ( 1 << 9 | 2)

Definition at line 87 of file uda1380.h.

#define UDA1380_REG_I2S_DEFAULT_VALUE 0x0000

Definition at line 83 of file uda1380.h.

#define UDA1380_REG_L3_DEFAULT_VALUE 0x0000

Definition at line 100 of file uda1380.h.

#define UDA1380_REG_MIXSDO_DEFAULT_VALUE 0x0000

Definition at line 93 of file uda1380.h.

#define UDA1380_REG_MIXVOL_DEFAULT_VALUE 0x0000

Definition at line 90 of file uda1380.h.

#define UDA1380_REG_MODEBBT_DEFAULT_VALUE 0x0000

Definition at line 91 of file uda1380.h.

#define UDA1380_REG_MSTRMUTE_DEFAULT_VALUE (2 << 8 | 2)

Definition at line 92 of file uda1380.h.

#define UDA1380_REG_MSTRVOL_DEFAULT_VALUE 0x0000

Definition at line 89 of file uda1380.h.

#define UDA1380_REG_PGA_DEFAULT_VALUE 0x0000

Definition at line 96 of file uda1380.h.

#define UDA1380_REG_PWRCTRL_DEFAULT_VALUE (1 << 15 | 1 << 13 | 1 << 10 | 1 << 8 | 1 << 6 | 1 << 4 | 0x0F)

Definition at line 85 of file uda1380.h.

#define UDA1380_U8 | ( |  | val | ) | (((val) >> 8) & 0xFF), ((val) & 0xFF)

Convert a 16 bit register value to 2 x 8 bit values that could be written to the I2C bus in an efficient way.

Definition at line 116 of file uda1380.h.

#define UDA_ADC_CTRL 0x22

Definition at line 62 of file uda1380.h.

#define UDA_AGC_CTRL 0x23

Definition at line 63 of file uda1380.h.

#define UDA_ANALOG_CTRL 0x03

Definition at line 53 of file uda1380.h.

#define UDA_BUS_CTRL 0x01

Definition at line 51 of file uda1380.h.

#define UDA_DEC_VOL_CTRL 0x20

Definition at line 60 of file uda1380.h.

#define UDA_EVALM_CLK 0x00

Definition at line 50 of file uda1380.h.

#define UDA_HPAMP_CTRL 0x04

Definition at line 54 of file uda1380.h.

#define UDA_MASTER_VOL_CTRL 0x10

Definition at line 55 of file uda1380.h.

#define UDA_MIXER_FILTER_CTRL 0x14

Definition at line 59 of file uda1380.h.

#define UDA_MIXER_VOL_CTRL 0x11

Definition at line 56 of file uda1380.h.

#define UDA_MODE_CTRL 0x12

Definition at line 57 of file uda1380.h.

#define UDA_MUTE_CTRL 0x13

Definition at line 58 of file uda1380.h.

#define UDA_PGA_CTRL 0x21

Definition at line 61 of file uda1380.h.

#define UDA_POWER_CTRL 0x02

Definition at line 52 of file uda1380.h.

#define UDA_TOTAL_REG 0x24

Definition at line 64 of file uda1380.h.

## Function Documentation

int UDA1380_Init | ( | int | input | ) |

Initialize UDA1380 to its default state.

Parameters

  input | : Audio input source (Must be one of UDA1380_LINE_IN or UDA1380_MIC_IN_L or UDA1380_MIC_IN_LR)

Returns
  1 on Success and 0 on failure

Definition at line 136 of file uda1380.c.

uint16_t UDA1380_REG_Read | ( | uint8_t | reg | ) |

Read a 16-bit value from UDA1380 codec register.

Parameters

  reg | : Register from which the value to be read

Returns
  Returns the value read from the register

Definition at line 100 of file uda1380.c.

int UDA1380_REG_VerifyMult | ( | uint8_t | reg,
|  | const uint8_t * | value,
|  | uint8_t * | buff,
|  | int | len
| ) |  |

Verify values in multiple UDA1380 registers.

Parameters

  reg | : Starting register from which data be read
  value | : Pointer to memory which contains values to be compared
  buff | : Pointer to memory to which data be read
  len | : Length of bytes in value buff

Returns
  1 on Success & Data is valid, 0 on Failure

Definition at line 118 of file uda1380.c.

void UDA1380_REG_Write | ( | uint8_t | reg,
|  | uint16_t | val
| ) |  |

Write a 16-bit value to UDA Register.

Parameters

  reg | : Register to which val be written
  val | : 16-Bit value to be written

Returns
  Nothing

Definition at line 92 of file uda1380.c.

int UDA1380_REG_WriteMult | ( | const uint8_t * | buff,
|  | int | len
| ) |  |

Write multiple value to UDA1380 registers.

Parameters

  buff | : Pointer to buffer (See note section)
  len | : Number of bytes in buff

Returns
  1 on Success, 0 on failure

Note
  buff[0] must be the address of the register to which the first data i.e, buff[1], buff[2] be written, the next bytes buff[3], buff[4] be written to register buff[0]+1 and so on.

Definition at line 174 of file uda1380.c.

int UDA1380_REG_WriteVerify | ( | uint8_t | reg,
|  | uint16_t | val
| ) |  |

Writes a value to a UDA register, read back and verify the value.

Parameters

  reg | : Register to which the value be written
  val | : Value to be written

Returns
  1 On success, 0 on failure

Definition at line 109 of file uda1380.c.