LPCOpen Platform for LPC18XX/43XX microcontrollers: BOARD: WM8903 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: WM8903 Audio codec interface module
BOARD: Common board components used with board drivers

## Detailed Description

WM8903 Audio codec interface module, the module registers are accessed using I2C. The board which uses this module must define WM8903_I2C_BUS to I2C0, I2C1, etc, based on which I2C bus is connected to WM8903. All the functions in this modules assumes that the I2C interrupt for WM8903_I2C_BUS is enabled and Chip_I2C_MasterStateHandler(WM8903_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_WM8903_ADDR must be defined to the appropriate slave address of WM8903 audio codec.

## Macros
#define | WM8903_CLK_MCLK 1
#define | WM8903_CLK_FLL 2
#define | WM8903_FLL_MCLK 1
#define | WM8903_FLL_BCLK 2
#define | WM8903_FLL_LRCLK 3
#define | WM8903_FLL_FREE_RUNNING 4
#define | WM8903_SW_RESET_AND_ID 0x00
#define | WM8903_REVISION 0x01
#define | WM8903_BIAS_CONTROL_0 0x04
#define | WM8903_VMID_CONTROL_0 0x05
#define | WM8903_MIC_BIAS_CONTROL_0 0x06
#define | WM8903_ANALOGUE_DAC_0 0x08
#define | WM8903_ANALOGUE_ADC_0 0x0A
#define | WM8903_POWER_MANAGEMENT_0 0x0C
#define | WM8903_POWER_MANAGEMENT_1 0x0D
#define | WM8903_POWER_MANAGEMENT_2 0x0E
#define | WM8903_POWER_MANAGEMENT_3 0x0F
#define | WM8903_POWER_MANAGEMENT_4 0x10
#define | WM8903_POWER_MANAGEMENT_5 0x11
#define | WM8903_POWER_MANAGEMENT_6 0x12
#define | WM8903_CLOCK_RATES_0 0x14
#define | WM8903_CLOCK_RATES_1 0x15
#define | WM8903_CLOCK_RATES_2 0x16
#define | WM8903_AUDIO_INTERFACE_0 0x18
#define | WM8903_AUDIO_INTERFACE_1 0x19
#define | WM8903_AUDIO_INTERFACE_2 0x1A
#define | WM8903_AUDIO_INTERFACE_3 0x1B
#define | WM8903_DAC_DIGITAL_VOLUME_LEFT 0x1E
#define | WM8903_DAC_DIGITAL_VOLUME_RIGHT 0x1F
#define | WM8903_DAC_DIGITAL_0 0x20
#define | WM8903_DAC_DIGITAL_1 0x21
#define | WM8903_ADC_DIGITAL_VOLUME_LEFT 0x24
#define | WM8903_ADC_DIGITAL_VOLUME_RIGHT 0x25
#define | WM8903_ADC_DIGITAL_0 0x26
#define | WM8903_DRC_0 0x28
#define | WM8903_DRC_1 0x29
#define | WM8903_DRC_2 0x2A
#define | WM8903_DRC_3 0x2B
#define | WM8903_ANALOGUE_LEFT_INPUT_0 0x2C
#define | WM8903_ANALOGUE_RIGHT_INPUT_0 0x2D
#define | WM8903_ANALOGUE_LEFT_INPUT_1 0x2E
#define | WM8903_ANALOGUE_RIGHT_INPUT_1 0x2F
#define | WM8903_ANALOGUE_LEFT_MIX_0 0x32
#define | WM8903_ANALOGUE_RIGHT_MIX_0 0x33
#define | WM8903_ANALOGUE_SPK_MIX_LEFT_0 0x34
#define | WM8903_ANALOGUE_SPK_MIX_LEFT_1 0x35
#define | WM8903_ANALOGUE_SPK_MIX_RIGHT_0 0x36
#define | WM8903_ANALOGUE_SPK_MIX_RIGHT_1 0x37
#define | WM8903_ANALOGUE_OUT1_LEFT 0x39
#define | WM8903_ANALOGUE_OUT1_RIGHT 0x3A
#define | WM8903_ANALOGUE_OUT2_LEFT 0x3B
#define | WM8903_ANALOGUE_OUT2_RIGHT 0x3C
#define | WM8903_ANALOGUE_OUT3_LEFT 0x3E
#define | WM8903_ANALOGUE_OUT3_RIGHT 0x3F
#define | WM8903_ANALOGUE_SPK_OUTPUT_CONTROL_0 0x41
#define | WM8903_DC_SERVO_0 0x43
#define | WM8903_DC_SERVO_2 0x45
#define | WM8903_DC_SERVO_4 0x47
#define | WM8903_DC_SERVO_5 0x48
#define | WM8903_DC_SERVO_6 0x49
#define | WM8903_DC_SERVO_7 0x4A
#define | WM8903_DC_SERVO_READBACK_1 0x51
#define | WM8903_DC_SERVO_READBACK_2 0x52
#define | WM8903_DC_SERVO_READBACK_3 0x53
#define | WM8903_DC_SERVO_READBACK_4 0x54
#define | WM8903_ANALOGUE_HP_0 0x5A
#define | WM8903_ANALOGUE_LINEOUT_0 0x5E
#define | WM8903_CHARGE_PUMP_0 0x62
#define | WM8903_CLASS_W_0 0x68
#define | WM8903_WRITE_SEQUENCER_0 0x6C
#define | WM8903_WRITE_SEQUENCER_1 0x6D
#define | WM8903_WRITE_SEQUENCER_2 0x6E
#define | WM8903_WRITE_SEQUENCER_3 0x6F
#define | WM8903_WRITE_SEQUENCER_4 0x70
#define | WM8903_GPIO_CONTROL_1 0x74
#define | WM8903_GPIO_CONTROL_2 0x75
#define | WM8903_GPIO_CONTROL_3 0x76
#define | WM8903_GPIO_CONTROL_4 0x77
#define | WM8903_GPIO_CONTROL_5 0x78
#define | WM8903_INTERRUPT_STATUS 0x79
#define | WM8903_INTERRUPT_STATUS_MASK 0x7A
#define | WM8903_INTERRUPT_POLARITY_1 0x7B
#define | WM8903_INTERRUPT_CONTROL 0x7E
#define | WM8903_FLL_CONTROL_1 0x80
#define | WM8903_FLL_CONTROL_2 0x81
#define | WM8903_FLL_CONTROL_3 0x82
#define | WM8903_FLL_CONTROL_4 0x83
#define | WM8903_CLOCK_RATE_TEST_4 0xA4
#define | WM8903_ANALOGUE_OUTPUT_BIAS_0 0xAC
#define | WM8903_ANALOGUE_OUTPUT_BIAS_2 0xBB
#define | WM8903_REGISTER_COUNT 84
#define | WM8903_MAX_REGISTER 0xBB
#define | WSEQ_BUSY_BIT 0
#define | WSEQ_BUSY_MASK (1<<WSEQ_BUSY_BIT)
#define | FLL_LOCK_EINT_BIT 5
#define | FLL_LOCK_EINT_MASK (1<<FLL_LOCK_EINT_BIT)
#define | WM8903_FLL_1288MHZ_K (0x3127)
#define | WM8903_FLL_1288MHZ_N (0x8 << 5)
#define | WM8903_DAC_DIGITAL_1_VALUE 0x0240

## Functions
uint32_t | WM8903_REG_Write (uint8_t reg, uint16_t val)
| Write a 16-bit value to Codec Register. More...
uint16_t | WM8903_REG_Read (uint8_t reg)
| Read a 16-bit value from WM8903 codec register. More...
int | WM8903_Init (int input)
| Initialize WM8903 to its default state. More...
void | WM8903_DeInit (void)
| Disable the WM8903. More...
void | WM8903_DumpAllRegisters (void)
| Debug function to print contents of all WM8903 registers to debug console. More...

## Macro Definition Documentation

#define FLL_LOCK_EINT_BIT 5

Definition at line 151 of file wm8903.h.

#define FLL_LOCK_EINT_MASK (1<<FLL_LOCK_EINT_BIT)

Definition at line 152 of file wm8903.h.

#define WM8903_ADC_DIGITAL_0 0x26

Definition at line 87 of file wm8903.h.

#define WM8903_ADC_DIGITAL_VOLUME_LEFT 0x24

Definition at line 85 of file wm8903.h.

#define WM8903_ADC_DIGITAL_VOLUME_RIGHT 0x25

Definition at line 86 of file wm8903.h.

#define WM8903_ANALOGUE_ADC_0 0x0A

Definition at line 66 of file wm8903.h.

#define WM8903_ANALOGUE_DAC_0 0x08

Definition at line 65 of file wm8903.h.

#define WM8903_ANALOGUE_HP_0 0x5A

Definition at line 119 of file wm8903.h.

#define WM8903_ANALOGUE_LEFT_INPUT_0 0x2C

Definition at line 92 of file wm8903.h.

#define WM8903_ANALOGUE_LEFT_INPUT_1 0x2E

Definition at line 94 of file wm8903.h.

#define WM8903_ANALOGUE_LEFT_MIX_0 0x32

Definition at line 96 of file wm8903.h.

#define WM8903_ANALOGUE_LINEOUT_0 0x5E

Definition at line 120 of file wm8903.h.

#define WM8903_ANALOGUE_OUT1_LEFT 0x39

Definition at line 102 of file wm8903.h.

#define WM8903_ANALOGUE_OUT1_RIGHT 0x3A

Definition at line 103 of file wm8903.h.

#define WM8903_ANALOGUE_OUT2_LEFT 0x3B

Definition at line 104 of file wm8903.h.

#define WM8903_ANALOGUE_OUT2_RIGHT 0x3C

Definition at line 105 of file wm8903.h.

#define WM8903_ANALOGUE_OUT3_LEFT 0x3E

Definition at line 106 of file wm8903.h.

#define WM8903_ANALOGUE_OUT3_RIGHT 0x3F

Definition at line 107 of file wm8903.h.

#define WM8903_ANALOGUE_OUTPUT_BIAS_0 0xAC

Definition at line 142 of file wm8903.h.

#define WM8903_ANALOGUE_OUTPUT_BIAS_2 0xBB

Definition at line 143 of file wm8903.h.

#define WM8903_ANALOGUE_RIGHT_INPUT_0 0x2D

Definition at line 93 of file wm8903.h.

#define WM8903_ANALOGUE_RIGHT_INPUT_1 0x2F

Definition at line 95 of file wm8903.h.

#define WM8903_ANALOGUE_RIGHT_MIX_0 0x33

Definition at line 97 of file wm8903.h.

#define WM8903_ANALOGUE_SPK_MIX_LEFT_0 0x34

Definition at line 98 of file wm8903.h.

#define WM8903_ANALOGUE_SPK_MIX_LEFT_1 0x35

Definition at line 99 of file wm8903.h.

#define WM8903_ANALOGUE_SPK_MIX_RIGHT_0 0x36

Definition at line 100 of file wm8903.h.

#define WM8903_ANALOGUE_SPK_MIX_RIGHT_1 0x37

Definition at line 101 of file wm8903.h.

#define WM8903_ANALOGUE_SPK_OUTPUT_CONTROL_0 0x41

Definition at line 108 of file wm8903.h.

#define WM8903_AUDIO_INTERFACE_0 0x18

Definition at line 77 of file wm8903.h.

#define WM8903_AUDIO_INTERFACE_1 0x19

Definition at line 78 of file wm8903.h.

#define WM8903_AUDIO_INTERFACE_2 0x1A

Definition at line 79 of file wm8903.h.

#define WM8903_AUDIO_INTERFACE_3 0x1B

Definition at line 80 of file wm8903.h.

#define WM8903_BIAS_CONTROL_0 0x04

Definition at line 62 of file wm8903.h.

#define WM8903_CHARGE_PUMP_0 0x62

Definition at line 121 of file wm8903.h.

#define WM8903_CLASS_W_0 0x68

Definition at line 122 of file wm8903.h.

#define WM8903_CLK_FLL 2

Definition at line 50 of file wm8903.h.

#define WM8903_CLK_MCLK 1

Definition at line 49 of file wm8903.h.

#define WM8903_CLOCK_RATE_TEST_4 0xA4

Definition at line 141 of file wm8903.h.

#define WM8903_CLOCK_RATES_0 0x14

Definition at line 74 of file wm8903.h.

#define WM8903_CLOCK_RATES_1 0x15

Definition at line 75 of file wm8903.h.

#define WM8903_CLOCK_RATES_2 0x16

Definition at line 76 of file wm8903.h.

#define WM8903_DAC_DIGITAL_0 0x20

Definition at line 83 of file wm8903.h.

#define WM8903_DAC_DIGITAL_1 0x21

Definition at line 84 of file wm8903.h.

#define WM8903_DAC_DIGITAL_1_VALUE 0x0240

Definition at line 160 of file wm8903.h.

#define WM8903_DAC_DIGITAL_VOLUME_LEFT 0x1E

Definition at line 81 of file wm8903.h.

#define WM8903_DAC_DIGITAL_VOLUME_RIGHT 0x1F

Definition at line 82 of file wm8903.h.

#define WM8903_DC_SERVO_0 0x43

Definition at line 109 of file wm8903.h.

#define WM8903_DC_SERVO_2 0x45

Definition at line 110 of file wm8903.h.

#define WM8903_DC_SERVO_4 0x47

Definition at line 111 of file wm8903.h.

#define WM8903_DC_SERVO_5 0x48

Definition at line 112 of file wm8903.h.

#define WM8903_DC_SERVO_6 0x49

Definition at line 113 of file wm8903.h.

#define WM8903_DC_SERVO_7 0x4A

Definition at line 114 of file wm8903.h.

#define WM8903_DC_SERVO_READBACK_1 0x51

Definition at line 115 of file wm8903.h.

#define WM8903_DC_SERVO_READBACK_2 0x52

Definition at line 116 of file wm8903.h.

#define WM8903_DC_SERVO_READBACK_3 0x53

Definition at line 117 of file wm8903.h.

#define WM8903_DC_SERVO_READBACK_4 0x54

Definition at line 118 of file wm8903.h.

#define WM8903_DRC_0 0x28

Definition at line 88 of file wm8903.h.

#define WM8903_DRC_1 0x29

Definition at line 89 of file wm8903.h.

#define WM8903_DRC_2 0x2A

Definition at line 90 of file wm8903.h.

#define WM8903_DRC_3 0x2B

Definition at line 91 of file wm8903.h.

#define WM8903_FLL_1288MHZ_K (0x3127)

Definition at line 156 of file wm8903.h.

#define WM8903_FLL_1288MHZ_N (0x8 << 5)

Definition at line 157 of file wm8903.h.

#define WM8903_FLL_BCLK 2

Definition at line 53 of file wm8903.h.

#define WM8903_FLL_CONTROL_1 0x80

Definition at line 137 of file wm8903.h.

#define WM8903_FLL_CONTROL_2 0x81

Definition at line 138 of file wm8903.h.

#define WM8903_FLL_CONTROL_3 0x82

Definition at line 139 of file wm8903.h.

#define WM8903_FLL_CONTROL_4 0x83

Definition at line 140 of file wm8903.h.

#define WM8903_FLL_FREE_RUNNING 4

Definition at line 55 of file wm8903.h.

#define WM8903_FLL_LRCLK 3

Definition at line 54 of file wm8903.h.

#define WM8903_FLL_MCLK 1

Definition at line 52 of file wm8903.h.

#define WM8903_GPIO_CONTROL_1 0x74

Definition at line 128 of file wm8903.h.

#define WM8903_GPIO_CONTROL_2 0x75

Definition at line 129 of file wm8903.h.

#define WM8903_GPIO_CONTROL_3 0x76

Definition at line 130 of file wm8903.h.

#define WM8903_GPIO_CONTROL_4 0x77

Definition at line 131 of file wm8903.h.

#define WM8903_GPIO_CONTROL_5 0x78

Definition at line 132 of file wm8903.h.

#define WM8903_INTERRUPT_CONTROL 0x7E

Definition at line 136 of file wm8903.h.

#define WM8903_INTERRUPT_POLARITY_1 0x7B

Definition at line 135 of file wm8903.h.

#define WM8903_INTERRUPT_STATUS 0x79

Definition at line 133 of file wm8903.h.

#define WM8903_INTERRUPT_STATUS_MASK 0x7A

Definition at line 134 of file wm8903.h.

#define WM8903_MAX_REGISTER 0xBB

Definition at line 146 of file wm8903.h.

#define WM8903_MIC_BIAS_CONTROL_0 0x06

Definition at line 64 of file wm8903.h.

#define WM8903_POWER_MANAGEMENT_0 0x0C

Definition at line 67 of file wm8903.h.

#define WM8903_POWER_MANAGEMENT_1 0x0D

Definition at line 68 of file wm8903.h.

#define WM8903_POWER_MANAGEMENT_2 0x0E

Definition at line 69 of file wm8903.h.

#define WM8903_POWER_MANAGEMENT_3 0x0F

Definition at line 70 of file wm8903.h.

#define WM8903_POWER_MANAGEMENT_4 0x10

Definition at line 71 of file wm8903.h.

#define WM8903_POWER_MANAGEMENT_5 0x11

Definition at line 72 of file wm8903.h.

#define WM8903_POWER_MANAGEMENT_6 0x12

Definition at line 73 of file wm8903.h.

#define WM8903_REGISTER_COUNT 84

Definition at line 145 of file wm8903.h.

#define WM8903_REVISION 0x01

Definition at line 61 of file wm8903.h.

#define WM8903_SW_RESET_AND_ID 0x00

Definition at line 60 of file wm8903.h.

#define WM8903_VMID_CONTROL_0 0x05

Definition at line 63 of file wm8903.h.

#define WM8903_WRITE_SEQUENCER_0 0x6C

Definition at line 123 of file wm8903.h.

#define WM8903_WRITE_SEQUENCER_1 0x6D

Definition at line 124 of file wm8903.h.

#define WM8903_WRITE_SEQUENCER_2 0x6E

Definition at line 125 of file wm8903.h.

#define WM8903_WRITE_SEQUENCER_3 0x6F

Definition at line 126 of file wm8903.h.

#define WM8903_WRITE_SEQUENCER_4 0x70

Definition at line 127 of file wm8903.h.

#define WSEQ_BUSY_BIT 0

Definition at line 149 of file wm8903.h.

#define WSEQ_BUSY_MASK (1<<WSEQ_BUSY_BIT)

Definition at line 150 of file wm8903.h.

## Function Documentation

void WM8903_DeInit | ( | void |  | ) |

Disable the WM8903.

Returns
  Nothing

Definition at line 241 of file wm8903.c.

void WM8903_DumpAllRegisters | ( | void |  | ) |

Debug function to print contents of all WM8903 registers to debug console.

Returns
  Nothing

Definition at line 342 of file wm8903.c.

int WM8903_Init | ( | int | input | ) |

Initialize WM8903 to its default state.

Parameters

  input | : Audio input source (Must be one of WM8903_LINE_IN or WM8903_MIC_IN_L or WM8903_MIC_IN_LR)

Returns
  1 on Success and 0 on failure

Definition at line 205 of file wm8903.c.

uint16_t WM8903_REG_Read | ( | uint8_t | reg | ) |

Read a 16-bit value from WM8903 codec register.

Parameters

  reg | : Register from which the value to be read

Returns
  Returns the value read from the register

Definition at line 180 of file wm8903.c.

uint32_t WM8903_REG_Write | ( | uint8_t | reg,
|  | uint16_t | val
| ) |  |

Write a 16-bit value to Codec Register.

Parameters

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

Returns
  Status of I2C write.

Definition at line 194 of file wm8903.c.