Implementation example
Low-level functions
Some low-level functions provide flexible management of the memory (SPI Flash/NOR,
etc.). Other types of memories can be supported simply by replacing the body of these low-
level functions by the corresponding functions for the memory.
Example: the Media_Init function should contain the entire memory initialization
procedure. The application can just call to corresponding memory driver function (that is the
NOR_Init() function).
Table 9.
Function name
Media_Init
Media_StartReadSequence Enables reading from the memory medium.
Media_ReadByte
Media_ReadHalfWord
Media_BufferRead
Driver firmware flowcharts
Figure 5
Figure 5.
Audio file
16/26
I2S_CODEC low-level driver functions
and
Figure 6
illustrate the driver functionality.
Driver's functional flowchart 1
I2S_CODEC_Init
Initialize GPIOs
and memory
Read audio file header,
set audio parameters
Correct format
Yes
Read audio file header,
set audio parameters
2
2
Configure I
S, I
C
and codec
End
Calls the initialization procedure for the used memory medium.
Reads and returns a byte from the memory medium.
Reads and returns a half word from the memory medium.
Reads a buffer of bytes from the memory medium (used to read
the wave file header).
Play
Initialize medium
reading sequence
Set the Playing
status variable
No
Enable SPI2 TXE
interrupt
End
Description
Pause
Power down
codec
Disable SPI2 TXE
Disable SPI2 TXE
interrupt
Save indexes
Set the Paused
Set the Stopped
status variable
status variable
End
AN2739
Stop
Power down
codec
interrupt
Reset indexes
End
ai15118
Need help?
Do you have a question about the STM32F103 Series and is the answer not in the manual?
Questions and answers