![]() |
MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
Data Structures | |
| struct | sgtl_audio_format_t |
| Audio format configuration. More... | |
| struct | sgtl_config_t |
| Initailize structure of sgtl5000. More... | |
| struct | sgtl_handle_t |
| SGTL codec handler. More... | |
Macros | |
| #define | CHIP_ID 0x0000U |
| Define the register address of sgtl5000. More... | |
| #define | SGTL5000_HEADPHONE_MAX_VOLUME_VALUE 0x7FU |
| SGTL5000 volume setting range. | |
| #define | SGTL5000_I2C_ADDR 0x0A |
| SGTL5000 I2C address. More... | |
| #define | SGTL_I2C_HANDLER_SIZE CODEC_I2C_MASTER_HANDLER_SIZE |
| sgtl handle size | |
| #define | SGTL_I2C_BITRATE 100000U |
| sgtl i2c baudrate | |
Functions | |
| status_t | SGTL_Init (sgtl_handle_t *handle, sgtl_config_t *config) |
| sgtl5000 initialize function. More... | |
| status_t | SGTL_SetDataRoute (sgtl_handle_t *handle, sgtl_route_t route) |
| Set audio data route in sgtl5000. More... | |
| status_t | SGTL_SetProtocol (sgtl_handle_t *handle, sgtl_protocol_t protocol) |
| Set the audio transfer protocol. More... | |
| void | SGTL_SetMasterSlave (sgtl_handle_t *handle, bool master) |
| Set sgtl5000 as master or slave. More... | |
| status_t | SGTL_SetVolume (sgtl_handle_t *handle, sgtl_module_t module, uint32_t volume) |
| Set the volume of different modules in sgtl5000. More... | |
| uint32_t | SGTL_GetVolume (sgtl_handle_t *handle, sgtl_module_t module) |
| Get the volume of different modules in sgtl5000. More... | |
| status_t | SGTL_SetMute (sgtl_handle_t *handle, sgtl_module_t module, bool mute) |
| Mute/unmute modules in sgtl5000. More... | |
| status_t | SGTL_EnableModule (sgtl_handle_t *handle, sgtl_module_t module) |
| Enable expected devices. More... | |
| status_t | SGTL_DisableModule (sgtl_handle_t *handle, sgtl_module_t module) |
| Disable expected devices. More... | |
| status_t | SGTL_Deinit (sgtl_handle_t *handle) |
| Deinit the sgtl5000 codec. More... | |
| status_t | SGTL_ConfigDataFormat (sgtl_handle_t *handle, uint32_t mclk, uint32_t sample_rate, uint32_t bits) |
| Configure the data format of audio data. More... | |
| status_t | SGTL_SetPlay (sgtl_handle_t *handle, uint32_t playSource) |
| select SGTL codec play source. More... | |
| status_t | SGTL_SetRecord (sgtl_handle_t *handle, uint32_t recordSource) |
| select SGTL codec record source. More... | |
| status_t | SGTL_WriteReg (sgtl_handle_t *handle, uint16_t reg, uint16_t val) |
| Write register to sgtl using I2C. More... | |
| status_t | SGTL_ReadReg (sgtl_handle_t *handle, uint16_t reg, uint16_t *val) |
| Read register from sgtl using I2C. More... | |
| status_t | SGTL_ModifyReg (sgtl_handle_t *handle, uint16_t reg, uint16_t clr_mask, uint16_t val) |
| Modify some bits in the register using I2C. More... | |
Driver version | |
| #define | FSL_SGTL5000_DRIVER_VERSION (MAKE_VERSION(2, 1, 1)) |
| CLOCK driver version 2.1.1. More... | |
| struct sgtl_audio_format_t |
Data Fields | |
| uint32_t | mclk_HZ |
| master clock | |
| uint32_t | sampleRate |
| Sample rate. | |
| uint32_t | bitWidth |
| Bit width. | |
| sgtl_sclk_edge_t | sclkEdge |
| sclk valid edge | |
| struct sgtl_config_t |
Data Fields | |
| sgtl_route_t | route |
| Audio data route. More... | |
| sgtl_protocol_t | bus |
| Audio transfer protocol. | |
| bool | master_slave |
| Master or slave. More... | |
| sgtl_audio_format_t | format |
| audio format | |
| uint8_t | slaveAddress |
| code device slave address | |
| codec_i2c_config_t | i2cConfig |
| i2c bus configuration | |
| sgtl_route_t sgtl_config_t::route |
| bool sgtl_config_t::master_slave |
True means master, false means slave.
| struct sgtl_handle_t |
Data Fields | |
| sgtl_config_t * | config |
| sgtl config pointer | |
| uint8_t | i2cHandle [SGTL_I2C_HANDLER_SIZE] |
| i2c handle | |
| #define FSL_SGTL5000_DRIVER_VERSION (MAKE_VERSION(2, 1, 1)) |
| #define CHIP_ID 0x0000U |
| #define SGTL5000_I2C_ADDR 0x0A |
| enum sgtl_module_t |
| enum sgtl_route_t |
| enum sgtl_protocol_t |
| anonymous enum |
| anonymous enum |
| anonymous enum |
| enum sgtl_sclk_edge_t |
| status_t SGTL_Init | ( | sgtl_handle_t * | handle, |
| sgtl_config_t * | config | ||
| ) |
This function calls SGTL_I2CInit(), and in this function, some configurations are fixed. The second parameter can be NULL. If users want to change the SGTL5000 settings, a configure structure should be prepared.
| handle | Sgtl5000 handle structure. |
| config | sgtl5000 configuration structure. If this pointer equals to NULL, it means using the default configuration. |
| status_t SGTL_SetDataRoute | ( | sgtl_handle_t * | handle, |
| sgtl_route_t | route | ||
| ) |
This function would set the data route according to route. The route cannot be combined, as all route would enable different modules.
| handle | Sgtl5000 handle structure. |
| route | Audio data route in sgtl5000. |
| status_t SGTL_SetProtocol | ( | sgtl_handle_t * | handle, |
| sgtl_protocol_t | protocol | ||
| ) |
Sgtl5000 only supports I2S, I2S left, I2S right, PCM A, PCM B format.
| handle | Sgtl5000 handle structure. |
| protocol | Audio data transfer protocol. |
| void SGTL_SetMasterSlave | ( | sgtl_handle_t * | handle, |
| bool | master | ||
| ) |
| handle | Sgtl5000 handle structure. |
| master | 1 represent master, 0 represent slave. |
| status_t SGTL_SetVolume | ( | sgtl_handle_t * | handle, |
| sgtl_module_t | module, | ||
| uint32_t | volume | ||
| ) |
This function would set the volume of sgtl5000 modules. This interface set module volume. The function assume that left channel and right channel has the same volume.
kSGTL_ModuleADC volume range: 0 - 0xF, 0dB - 22.5dB kSGTL_ModuleDAC volume range: 0x3C - 0xF0, 0dB - -90dB kSGTL_ModuleHP volume range: 0 - 0x7F, 12dB - -51.5dB kSGTL_ModuleLineOut volume range: 0 - 0x1F, 0.5dB steps
| handle | Sgtl5000 handle structure. |
| module | Sgtl5000 module, such as DAC, ADC and etc. |
| volume | Volume value need to be set. The value is the exact value in register. |
| uint32_t SGTL_GetVolume | ( | sgtl_handle_t * | handle, |
| sgtl_module_t | module | ||
| ) |
This function gets the volume of sgtl5000 modules. This interface get DAC module volume. The function assume that left channel and right channel has the same volume.
| handle | Sgtl5000 handle structure. |
| module | Sgtl5000 module, such as DAC, ADC and etc. |
| status_t SGTL_SetMute | ( | sgtl_handle_t * | handle, |
| sgtl_module_t | module, | ||
| bool | mute | ||
| ) |
| handle | Sgtl5000 handle structure. |
| module | Sgtl5000 module, such as DAC, ADC and etc. |
| mute | True means mute, and false means unmute. |
| status_t SGTL_EnableModule | ( | sgtl_handle_t * | handle, |
| sgtl_module_t | module | ||
| ) |
| handle | Sgtl5000 handle structure. |
| module | Module expected to enable. |
| status_t SGTL_DisableModule | ( | sgtl_handle_t * | handle, |
| sgtl_module_t | module | ||
| ) |
| handle | Sgtl5000 handle structure. |
| module | Module expected to enable. |
| status_t SGTL_Deinit | ( | sgtl_handle_t * | handle | ) |
Shut down Sgtl5000 modules.
| handle | Sgtl5000 handle structure pointer. |
| status_t SGTL_ConfigDataFormat | ( | sgtl_handle_t * | handle, |
| uint32_t | mclk, | ||
| uint32_t | sample_rate, | ||
| uint32_t | bits | ||
| ) |
This function would configure the registers about the sample rate, bit depths.
| handle | Sgtl5000 handle structure pointer. |
| mclk | Master clock frequency of I2S. |
| sample_rate | Sample rate of audio file running in sgtl5000. Sgtl5000 now supports 8k, 11.025k, 12k, 16k, 22.05k, 24k, 32k, 44.1k, 48k and 96k sample rate. |
| bits | Bit depth of audio file (Sgtl5000 only supports 16bit, 20bit, 24bit and 32 bit in HW). |
| status_t SGTL_SetPlay | ( | sgtl_handle_t * | handle, |
| uint32_t | playSource | ||
| ) |
| handle | Sgtl5000 handle structure pointer. |
| playSource | play source value, reference _sgtl_play_source. |
| status_t SGTL_SetRecord | ( | sgtl_handle_t * | handle, |
| uint32_t | recordSource | ||
| ) |
| handle | Sgtl5000 handle structure pointer. |
| recordSource | record source value, reference _sgtl_record_source. |
| status_t SGTL_WriteReg | ( | sgtl_handle_t * | handle, |
| uint16_t | reg, | ||
| uint16_t | val | ||
| ) |
| handle | Sgtl5000 handle structure. |
| reg | The register address in sgtl. |
| val | Value needs to write into the register. |
| status_t SGTL_ReadReg | ( | sgtl_handle_t * | handle, |
| uint16_t | reg, | ||
| uint16_t * | val | ||
| ) |
| handle | Sgtl5000 handle structure. |
| reg | The register address in sgtl. |
| val | Value written to. |
| status_t SGTL_ModifyReg | ( | sgtl_handle_t * | handle, |
| uint16_t | reg, | ||
| uint16_t | clr_mask, | ||
| uint16_t | val | ||
| ) |
| handle | Sgtl5000 handle structure. |
| reg | The register address in sgtl. |
| clr_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. |