Go to the source code of this file.
Data Structures | |
| struct | wm8960_audio_format |
| struct | wm8960_config |
| struct | wm8960_control_t |
Macros | |
| #define | WM8960_I2C_ADDR 0x1A |
Typedefs | |
| typedef enum wm8960_module | wm8960_module_t |
| typedef enum wm8960_play_source | wm8960_play_source_t |
| typedef enum wm8960_route | wm8960_route_t |
| typedef enum wm8960_protocol | wm8960_protocol_t |
| typedef enum wm8960_input | wm8960_input_t |
| typedef struct wm8960_audio_format | wm8960_audio_format_t |
| typedef struct wm8960_config | wm8960_config_t |
Enumerations | |
| enum | wm8960_module { wm8960_module_adc = 0 , wm8960_module_dac = 1 , wm8960_module_vref = 2 , wm8960_module_headphone = 3 , wm8960_module_micbais = 4 , wm8960_module_ana_in = 6 , wm8960_module_lineout = 7 , wm8960_module_speaker = 8 , wm8960_module_output_mixer = 9 } |
| enum | wm8960_play_source { wm8960_play_source_input_mixer = 1 , wm8960_play_source_input3 = 2 , wm8960_play_source_dac = 4 } |
| enum | wm8960_route { wm8960_route_bypass = 0 , wm8960_route_playback = 1 , wm8960_route_playback_and_record = 2 , wm8960_route_record = 5 } |
| enum | wm8960_protocol { wm8960_bus_i2s = 2 , wm8960_bus_left_justified = 1 , wm8960_bus_right_justified = 0 , wm8960_bus_pcma = 3 , wm8960_bus_pcmb = 3 | (1 << 4) } |
| enum | wm8960_input { wm8960_input_closed = 0 , wm8960_input_single_ended_mic = 1 , wm8960_input_differential_mic_input2 = 2 , wm8960_input_differential_mic_input3 = 3 , wm8960_input_line_input2 = 4 , wm8960_input_line_input3 = 5 } |
Functions | |
| hpm_stat_t | wm8960_init (wm8960_control_t *control, wm8960_config_t *config) |
| WM8960 initialize function. More... | |
| hpm_stat_t | wm8960_deinit (wm8960_control_t *control) |
| Deinit the WM8960 codec. More... | |
| hpm_stat_t | wm8960_set_data_route (wm8960_control_t *control, wm8960_config_t *config) |
| Set audio data route in WM8960. More... | |
| hpm_stat_t | wm8960_set_left_input (wm8960_control_t *control, wm8960_input_t input) |
| Set left audio input source in WM8960. More... | |
| hpm_stat_t | wm8960_set_right_input (wm8960_control_t *control, wm8960_input_t input) |
| Set right audio input source in WM8960. More... | |
| hpm_stat_t | wm8960_set_protocol (wm8960_control_t *control, wm8960_protocol_t protocol) |
| Set the audio transfer protocol. More... | |
| hpm_stat_t | wm8960_set_volume (wm8960_control_t *control, wm8960_module_t module, uint32_t volume) |
| Set the volume of different modules in WM8960. More... | |
| hpm_stat_t | wm8960_set_module (wm8960_control_t *control, wm8960_module_t module, bool enable) |
| Enable/disable expected module. More... | |
| hpm_stat_t | wm8960_config_input_to_output_mixer (wm8960_control_t *control, uint32_t play_source) |
| SET the WM8960 play source. More... | |
| hpm_stat_t | wm8960_set_data_format (wm8960_control_t *control, uint32_t sysclk, uint32_t sample_rate, uint32_t bits) |
| Configure the data format of audio data. More... | |
| hpm_stat_t | wm8960_write_reg (wm8960_control_t *control, uint8_t reg, uint16_t val) |
| Write register to WM8960 using I2C. More... | |
| hpm_stat_t | wm8960_read_reg (uint8_t reg, uint16_t *val) |
| Read register from WM8960 using I2C. More... | |
| hpm_stat_t | wm8960_modify_reg (wm8960_control_t *control, uint8_t reg, uint16_t mask, uint16_t val) |
| Modify some bits in the register using I2C. More... | |
| #define WM8960_I2C_ADDR 0x1A |
| typedef struct wm8960_audio_format wm8960_audio_format_t |
| typedef struct wm8960_config wm8960_config_t |
| typedef enum wm8960_input wm8960_input_t |
| typedef enum wm8960_module wm8960_module_t |
| typedef enum wm8960_play_source wm8960_play_source_t |
| typedef enum wm8960_protocol wm8960_protocol_t |
| typedef enum wm8960_route wm8960_route_t |
| enum wm8960_input |
| enum wm8960_module |
| enum wm8960_play_source |
| enum wm8960_protocol |
| enum wm8960_route |
| hpm_stat_t wm8960_config_input_to_output_mixer | ( | wm8960_control_t * | control, |
| uint32_t | play_source | ||
| ) |
SET the WM8960 play source.
| control | WM8960 control structure. |
| play_source | play source |
| hpm_stat_t wm8960_deinit | ( | wm8960_control_t * | control | ) |
Deinit the WM8960 codec.
This function close all modules in WM8960 to save power.
| control | WM8960 control structure pointer. |
| hpm_stat_t wm8960_init | ( | wm8960_control_t * | control, |
| wm8960_config_t * | config | ||
| ) |
WM8960 initialize function.
| control | WM8960 control structure. |
| config | WM8960 configuration structure. |
| hpm_stat_t wm8960_modify_reg | ( | wm8960_control_t * | control, |
| uint8_t | reg, | ||
| uint16_t | mask, | ||
| uint16_t | val | ||
| ) |
Modify some bits in the register using I2C.
| control | WM8960 control structure. |
| reg | The register address in WM8960. |
| mask | The mask code for the bits want to write. The bit you want to write should be 0. |
| val | Value needs to write into the register. |
| hpm_stat_t wm8960_read_reg | ( | uint8_t | reg, |
| uint16_t * | val | ||
| ) |
Read register from WM8960 using I2C.
| reg | The register address in WM8960. |
| val | Value written to. |
| hpm_stat_t wm8960_set_data_format | ( | wm8960_control_t * | control, |
| uint32_t | sysclk, | ||
| uint32_t | sample_rate, | ||
| uint32_t | bits | ||
| ) |
Configure the data format of audio data.
This function would configure the registers about the sample rate, bit depths.
| control | WM8960 control structure pointer. |
| sysclk | system clock of the codec which can be generated by MCLK or PLL output. |
| sample_rate | Sample rate of audio file running in WM8960. WM8960 now supports 8k, 11.025k, 12k, 16k, 22.05k, 24k, 32k, 44.1k, 48k and 96k sample rate. |
| bits | Bit depth of audio file (WM8960 only supports 16bit, 20bit, 24bit and 32 bit in HW). |
| hpm_stat_t wm8960_set_data_route | ( | wm8960_control_t * | control, |
| wm8960_config_t * | config | ||
| ) |
Set audio data route in WM8960.
This function would set the data route according to route.
| control | WM8960 control structure. |
| config | Audio configure structure in WM8960. |
| hpm_stat_t wm8960_set_left_input | ( | wm8960_control_t * | control, |
| wm8960_input_t | input | ||
| ) |
Set left audio input source in WM8960.
| control | WM8960 control structure. |
| input | Audio input source. |
| hpm_stat_t wm8960_set_module | ( | wm8960_control_t * | control, |
| wm8960_module_t | module, | ||
| bool | enable | ||
| ) |
Enable/disable expected module.
| control | WM8960 control structure. |
| module | Module expected to enable. |
| enable | Enable or disable moudles. |
| hpm_stat_t wm8960_set_protocol | ( | wm8960_control_t * | control, |
| wm8960_protocol_t | protocol | ||
| ) |
Set the audio transfer protocol.
| control | WM8960 control structure. |
| protocol | Audio data transfer protocol. |
| hpm_stat_t wm8960_set_right_input | ( | wm8960_control_t * | control, |
| wm8960_input_t | input | ||
| ) |
Set right audio input source in WM8960.
| control | WM8960 control structure. |
| input | Audio input source. |
| hpm_stat_t wm8960_set_volume | ( | wm8960_control_t * | control, |
| wm8960_module_t | module, | ||
| uint32_t | volume | ||
| ) |
Set the volume of different modules in WM8960.
This function would set the volume of WM8960 modules. Uses need to appoint the module. The function assume that left channel and right channel has the same volume.
Module:wm8960_module_adc, volume range value: 0 is mute, 1-255 is -97db to 30db Module:wm8960_module_dac, volume range value: 0 is mute, 1-255 is -127db to 0db Module:wm8960_module_headphone, volume range value: 0 - 2F is mute, 0x30 - 0x7F is -73db to 6db Module:wm8960_module_ana_in, volume range value: 0 - 0x3F is -17.25db to 30db Module:wm8960_module_speaker, volume range value: 0 - 2F is mute, 0x30 - 0x7F is -73db to 6db
| control | WM8960 control structure. |
| module | Module to set volume, it can be ADC, DAC, Headphone and so on. |
| volume | Volume value need to be set. |
| hpm_stat_t wm8960_write_reg | ( | wm8960_control_t * | control, |
| uint8_t | reg, | ||
| uint16_t | val | ||
| ) |
Write register to WM8960 using I2C.
| control | WM8960 control structure. |
| reg | The register address in WM8960. |
| val | Value needs to write into the register. |