62 #ifndef MP3_WTV020SD_P07_PORT 63 #define MP3_WTV020SD_P07_PORT GPIO_B_NUM 65 #ifndef MP3_WTV020SD_P07_PIN 66 #define MP3_WTV020SD_P07_PIN 0 68 #ifndef MP3_WTV020SD_P02_PORT 69 #define MP3_WTV020SD_P02_PORT GPIO_B_NUM 71 #ifndef MP3_WTV020SD_P02_PIN 72 #define MP3_WTV020SD_P02_PIN 1 74 #ifndef MP3_WTV020SD_P06_PORT 75 #define MP3_WTV020SD_P06_PORT GPIO_C_NUM 77 #ifndef MP3_WTV020SD_P06_PIN 78 #define MP3_WTV020SD_P06_PIN 1 80 #ifndef MP3_WTV020SD_P04_PORT 81 #define MP3_WTV020SD_P04_PORT GPIO_B_NUM 83 #ifndef MP3_WTV020SD_P04_PIN 84 #define MP3_WTV020SD_P04_PIN 0 86 #ifndef MP3_WTV020SD_P05_PORT 87 #define MP3_WTV020SD_P05_PORT GPIO_B_NUM 89 #ifndef MP3_WTV020SD_P05_PIN 90 #define MP3_WTV020SD_P05_PIN 1 92 #ifndef MP3_WTV020SD_RESET_PORT 93 #define MP3_WTV020SD_RESET_PORT GPIO_B_NUM 95 #ifndef MP3_WTV020SD_RESET_PIN 96 #define MP3_WTV020SD_RESET_PIN 1 100 #define MP3_BUSY_PORT_BASE GPIO_PORT_TO_BASE(MP3_WTV020SD_P06_PORT) 101 #define MP3_BUSY_PIN_MASK GPIO_PIN_MASK(MP3_WTV020SD_P06_PIN) 103 #define MP3_PLAY_PORT_BASE GPIO_PORT_TO_BASE(MP3_WTV020SD_P07_PORT) 104 #define MP3_PLAY_PIN_MASK GPIO_PIN_MASK(MP3_WTV020SD_P07_PIN) 105 #define MP3_NEXT_PORT_BASE GPIO_PORT_TO_BASE(MP3_WTV020SD_P02_PORT) 106 #define MP3_NEXT_PIN_MASK GPIO_PIN_MASK(MP3_WTV020SD_P02_PIN) 108 #define MP3_RESET_PORT_BASE GPIO_PORT_TO_BASE(MP3_WTV020SD_RESET_PORT) 109 #define MP3_RESET_PIN_MASK GPIO_PIN_MASK(MP3_WTV020SD_RESET_PIN) 110 #define MP3_CLK_PORT_BASE GPIO_PORT_TO_BASE(MP3_WTV020SD_P04_PORT) 111 #define MP3_CLK_PIN_MASK GPIO_PIN_MASK(MP3_WTV020SD_P04_PIN) 112 #define MP3_DATA_PORT_BASE GPIO_PORT_TO_BASE(MP3_WTV020SD_P05_PORT) 113 #define MP3_DATA_PIN_MASK GPIO_PIN_MASK(MP3_WTV020SD_P05_PIN) 116 static uint8_t initialized = 0;
117 static int mp3_line_command(uint16_t cmd);
122 if(mode != MP3_WTV020SD_GPIO_MODE && mode != MP3_WTV020SD_LINE_MODE) {
123 return MP3_WTV020SD_ERROR;
126 if(mode == MP3_WTV020SD_GPIO_MODE) {
149 return MP3_WTV020SD_SUCCESS;
155 if(initialized != MP3_WTV020SD_GPIO_MODE) {
156 return MP3_WTV020SD_ERROR;
159 return MP3_WTV020SD_SUCCESS;
165 if(initialized != MP3_WTV020SD_GPIO_MODE) {
166 return MP3_WTV020SD_ERROR;
169 return MP3_WTV020SD_SUCCESS;
175 if(initialized != MP3_WTV020SD_GPIO_MODE) {
176 return MP3_WTV020SD_ERROR;
181 return MP3_WTV020SD_SUCCESS;
187 if((initialized != MP3_WTV020SD_GPIO_MODE) &&
188 (initialized != MP3_WTV020SD_LINE_MODE)) {
189 return MP3_WTV020SD_ERROR;
192 return MP3_WTV020SD_BUSY;
194 return MP3_WTV020SD_IDLE;
200 if(initialized != MP3_WTV020SD_LINE_MODE) {
201 return MP3_WTV020SD_ERROR;
210 return MP3_WTV020SD_SUCCESS;
216 if(initialized != MP3_WTV020SD_LINE_MODE) {
217 return MP3_WTV020SD_ERROR;
219 mp3_line_command(track);
221 return MP3_WTV020SD_SUCCESS;
227 if(initialized != MP3_WTV020SD_LINE_MODE) {
228 return MP3_WTV020SD_ERROR;
230 mp3_line_command(track);
231 return MP3_WTV020SD_SUCCESS;
237 if(initialized != MP3_WTV020SD_LINE_MODE) {
238 return MP3_WTV020SD_ERROR;
240 mp3_line_command(MP3_WTV020SD_STOP_VAL);
241 return MP3_WTV020SD_SUCCESS;
247 if(initialized != MP3_WTV020SD_LINE_MODE) {
248 return MP3_WTV020SD_ERROR;
250 mp3_line_command(MP3_WTV020SD_PLAY_PAUSE_VAL);
251 return MP3_WTV020SD_SUCCESS;
255 mp3_line_command(uint16_t cmd)
258 if(initialized != MP3_WTV020SD_LINE_MODE) {
259 return MP3_WTV020SD_ERROR;
263 for(mask = 0x8000; mask > 0; mask >> 1) {
279 return MP3_WTV020SD_SUCCESS;
int mp3_wtv020sd_reset(void)
Trigger a module reset.
#define GPIO_SET_PIN(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE high.
int mp3_wtv020sd_sync_play(uint16_t track)
Plays the selected track and waits until it stops.
Header file with register and macro declarations for the cc2538 GPIO module.
#define GPIO_CLR_PIN(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE low.
void clock_delay_usec(uint16_t dt)
Delay a given number of microseconds.
int mp3_wtv020sd_pause(void)
Pauses the current track.
Header file for the MP3 WTV020SD driver.
int mp3_wtv020sd_async_play(uint16_t track)
Plays the selected track and returns immediately.
#define GPIO_READ_PIN(PORT_BASE, PIN_MASK)
Read pins with PIN_MASK of port with PORT_BASE.
#define GPIO_SOFTWARE_CONTROL(PORT_BASE, PIN_MASK)
Configure the pin to be software controlled with PIN_MASK of port with PORT_BASE. ...
#define GPIO_SET_INPUT(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to input.
#define GPIO_SET_OUTPUT(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to output.
int mp3_wtv020sd_gpio_play(void)
Function to play a current track.
int mp3_wtv020sd_config(uint8_t mode)
Init function for the MP3 driver.
int mp3_wtv020sd_busy(void)
Get the current status of the device (playing/stopped)
int mp3_wtv020sd_gpio_next(void)
Advances and play the next track, wraps over the playlist.
int mp3_wtv020sd_stop(void)
Stops the current track.
int mp3_wtv020sd_gpio_stop(void)
Function to stop a current track.