Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
mp3-wtv020sd.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015, Zolertia
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the Institute nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*/
29
/* -------------------------------------------------------------------------- */
30
/**
31
* \addtogroup zoul-sensors
32
* @{
33
*
34
* \defgroup zoul-mp3-wtv020sd MP3 WTV020SD driver compatible with Zoul-based
35
* platforms
36
*
37
* Driver to control the MP3 WTV020SD board in MP3 mode (GPIO based) and the
38
* 2-line serial mode (CLK/DI). Loop Mode and Key Modes not implemented.
39
* More product information available at:
40
* http://avrproject.ru/chasy-budilnik/WTV020SD.pdf
41
* An example on how to wire with a sound power amplifier and speakers at
42
* http://www.hackster.io/zolertia
43
* Based on the Arduino Wtv020sd16p library
44
* @{
45
*
46
* \file
47
* Header file for the MP3 WTV020SD driver
48
*/
49
/* -------------------------------------------------------------------------- */
50
#ifndef MP3_WTV020SD_H_
51
#define MP3_WTV020SD_H_
52
/* -------------------------------------------------------------------------- */
53
#include <stdint.h>
54
/* -------------------------------------------------------------------------- */
55
#define MP3_WTV020SD_ERROR -1
56
#define MP3_WTV020SD_SUCCESS 0x00
57
#define MP3_WTV020SD_GPIO_MODE 0x01
58
#define MP3_WTV020SD_LINE_MODE 0x02
59
#define MP3_WTV020SD_IDLE 0x00
60
#define MP3_WTV020SD_BUSY 0x0F
61
/* -------------------------------------------------------------------------- */
62
#define MP3_WTV020SD_PLAY_PAUSE_VAL 0xFFFE
63
#define MP3_WTV020SD_STOP_VAL 0xFFFF
64
#define MP3_WTV020SD_VOLUME_MIN 0xFFF0
65
#define MP3_WTV020SD_VOLUME_MAX 0xFFF7
66
/* -------------------------------------------------------------------------- */
67
#define MP3_USEC_DELAY 1000
68
#define MP3_USEC_CMD_DELAY 100
69
#define MP3_USEC_RESET_DELAY ((MP3_USEC_DELAY) * 30)
70
/* -------------------------------------------------------------------------- */
71
#define MP3_TRACK_BASE 0
/* 0000.ad4 */
72
/* -------------------------------------------------------------------------- */
73
/**
74
* \brief Init function for the MP3 driver
75
*
76
* Configures the pins required to operate in either driver mode
77
*
78
* \param mode drive the board using GPIOs or the two-line mode, using
79
* either MP3_WTV020SD_GPIO_MODE or MP3_WTV020SD_LINE_MODE
80
* \return MP3_WTV020SD_ERROR if invalid mode selected, otherwise it
81
* will return MP3_WTV020SD_SUCCESS
82
*/
83
int
mp3_wtv020sd_config
(uint8_t mode);
84
/**
85
* \brief Function to play a current track
86
*
87
* \return MP3_WTV020SD_ERROR if invalid mode used, otherwise it will
88
* return MP3_WTV020SD_SUCCESS
89
*/
90
int
mp3_wtv020sd_gpio_play
(
void
);
91
/**
92
* \brief Function to stop a current track
93
*
94
* \return MP3_WTV020SD_ERROR if invalid mode used, otherwise it will
95
* return MP3_WTV020SD_SUCCESS
96
*/
97
int
mp3_wtv020sd_gpio_stop
(
void
);
98
/**
99
* \brief Advances and play the next track, wraps over the playlist
100
*
101
* \return MP3_WTV020SD_ERROR if invalid mode used, otherwise it will
102
* return MP3_WTV020SD_SUCCESS
103
*/
104
int
mp3_wtv020sd_gpio_next
(
void
);
105
/**
106
* \brief Get the current status of the device (playing/stopped)
107
*
108
* \return MP3_WTV020SD_BUSY if a track is playing, otherwise it will
109
* return MP3_WTV020SD_IDLE
110
*/
111
int
mp3_wtv020sd_busy
(
void
);
112
/**
113
* \brief Trigger a module reset
114
*
115
* \return MP3_WTV020SD_ERROR if invalid mode used, otherwise it will
116
* return MP3_WTV020SD_SUCCESS
117
*/
118
int
mp3_wtv020sd_reset
(
void
);
119
/**
120
* \brief Plays the selected track and waits until it stops
121
*
122
* \param track forwards and play the selected track, starting from
123
* MP3_TRACK_BASE (0000.ad4) up to MP3_TRACK_BASE + 511
124
* (0511.ad4)
125
* \return MP3_WTV020SD_ERROR if invalid mode used, otherwise it will
126
* return MP3_WTV020SD_SUCCESS
127
*/
128
int
mp3_wtv020sd_sync_play
(uint16_t track);
129
/**
130
* \brief Plays the selected track and returns immediately
131
*
132
* \param track forwards and play the selected track, starting from
133
* MP3_TRACK_BASE (0000.ad4) up to MP3_TRACK_BASE + 511
134
* (0511.ad4)
135
* \return MP3_WTV020SD_ERROR if invalid mode used, otherwise it will
136
* return MP3_WTV020SD_SUCCESS
137
*/
138
int
mp3_wtv020sd_async_play
(uint16_t track);
139
/**
140
* \brief Stops the current track
141
*
142
* \return MP3_WTV020SD_ERROR if invalid mode used, otherwise it will
143
* return MP3_WTV020SD_SUCCESS
144
*/
145
int
mp3_wtv020sd_stop
(
void
);
146
/**
147
* \brief Pauses the current track
148
*
149
* \return MP3_WTV020SD_ERROR if invalid mode used, otherwise it will
150
* return MP3_WTV020SD_SUCCESS
151
*/
152
int
mp3_wtv020sd_pause
(
void
);
153
154
/* -------------------------------------------------------------------------- */
155
#endif
/* ifndef MP3_WTV020SD_H_ */
156
/* -------------------------------------------------------------------------- */
157
/**
158
* @}
159
* @}
160
*/
mp3_wtv020sd_async_play
int mp3_wtv020sd_async_play(uint16_t track)
Plays the selected track and returns immediately.
Definition
mp3-wtv020sd.c:225
mp3_wtv020sd_reset
int mp3_wtv020sd_reset(void)
Trigger a module reset.
Definition
mp3-wtv020sd.c:198
mp3_wtv020sd_gpio_stop
int mp3_wtv020sd_gpio_stop(void)
Function to stop a current track.
Definition
mp3-wtv020sd.c:163
mp3_wtv020sd_gpio_play
int mp3_wtv020sd_gpio_play(void)
Function to play a current track.
Definition
mp3-wtv020sd.c:153
mp3_wtv020sd_pause
int mp3_wtv020sd_pause(void)
Pauses the current track.
Definition
mp3-wtv020sd.c:245
mp3_wtv020sd_stop
int mp3_wtv020sd_stop(void)
Stops the current track.
Definition
mp3-wtv020sd.c:235
mp3_wtv020sd_busy
int mp3_wtv020sd_busy(void)
Get the current status of the device (playing/stopped).
Definition
mp3-wtv020sd.c:185
mp3_wtv020sd_sync_play
int mp3_wtv020sd_sync_play(uint16_t track)
Plays the selected track and waits until it stops.
Definition
mp3-wtv020sd.c:214
mp3_wtv020sd_gpio_next
int mp3_wtv020sd_gpio_next(void)
Advances and play the next track, wraps over the playlist.
Definition
mp3-wtv020sd.c:173
mp3_wtv020sd_config
int mp3_wtv020sd_config(uint8_t mode)
Init function for the MP3 driver.
Definition
mp3-wtv020sd.c:120
arch
platform
zoul
dev
mp3-wtv020sd.h
Generated on
for Contiki-NG by
1.17.0