Listening to the beep generated by codecDemo_c6v0 gets very annoying after a couple of minutes, so we will try and improve matters by adding a couple of functions that will enable us to change and mute the volume. We'll also modify the code to use the beep generator to play a tune. We're limited to a fairly simple tune because the beep generator only generates audio frequencies across two octave major scales. For those who are musically minded, we define the mapping between notes (pitch) and beep frequencies, and the beep ON time (see section 6.21 of the data sheet) as well, in the codec_CS42L52.h
header file. We call this recipe codecDemo_c6v1.
Follow the outlined steps to use the audio codec:
Clone the previous recipe and name the folder
codecDemo_C6v1
.Open the RTE manager and add Board Support for Buttons (API) and LED (API). Click Resolve and OK.
Add a function named
setVolume()
to thecodec_CS42L52.c
file:static void setVolume(int32_t vol) { ...