dfplayer_constants.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Marian Buschsieweke
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
19 #ifndef DFPLAYER_CONSTANTS_H
20 #define DFPLAYER_CONSTANTS_H
21 
22 #include <stdint.h>
23 #include <periph/gpio.h>
24 #include <mutex.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
33 #define DFPLAYER_START (0x7e)
34 #define DFPLAYER_VERSION (0xff)
35 #define DFPLAYER_LEN (0x06)
36 #define DFPLAYER_NO_ACK (0x00)
37 #define DFPLAYER_ACK (0x01)
38 #define DFPLAYER_END (0xef)
44 #define DFPLAYER_BAUD (9600)
45 #define DFPLAYER_DATA_BITS (UART_DATA_BITS_8)
46 #define DFPLAYER_PARITY (UART_PARITY_NONE)
47 #define DFPLAYER_STOP_BITS (UART_STOP_BITS_1)
53 #define DFPLAYER_CMD_NEXT (0x01)
54 #define DFPLAYER_CMD_PREV (0x02)
55 #define DFPLAYER_CMD_VOLUME_INC (0x04)
56 #define DFPLAYER_CMD_VOLUME_DEC (0x05)
57 #define DFPLAYER_CMD_SET_VOLUME (0x06)
58 #define DFPLAYER_CMD_SET_EQUALIZER (0x07)
59 #define DFPLAYER_CMD_SET_SOURCE (0x09)
60 #define DFPLAYER_CMD_STANDBY_ENTER (0x0a)
61 #define DFPLAYER_CMD_STANDBY_EXIT (0x0b)
62 #define DFPLAYER_CMD_RESET (0x0c)
63 #define DFPLAYER_CMD_PLAY (0x0d)
64 #define DFPLAYER_CMD_PAUSE (0x0e)
65 #define DFPLAYER_CMD_FILE (0x0f)
66 #define DFPLAYER_CMD_PLAY_FROM_MP3 (0x12)
67 #define DFPLAYER_CMD_PLAY_ADVERT (0x13)
68 #define DFPLAYER_CMD_ABORT_ADVERT (0x15)
69 #define DFPLAYER_CMD_REPEAT_FOLDER (0x17)
70 #define DFPLAYER_CMD_RANDOM (0x18)
71 #define DFPLAYER_CMD_REPEAT (0x19)
72 #define DFPLAYER_CMD_GET_STATUS (0x42)
73 #define DFPLAYER_CMD_GET_VOLUME (0x43)
74 #define DFPLAYER_CMD_GET_EQUALIZER (0x44)
75 #define DFPLAYER_CMD_GET_MODE (0x45)
76 #define DFPLAYER_CMD_GET_VERSION (0x46)
77 #define DFPLAYER_CMD_FILES_USB (0x47)
78 #define DFPLAYER_CMD_FILES_SDCARD (0x48)
79 #define DFPLAYER_CMD_FILES_FLASH (0x49)
80 #define DFPLAYER_CMD_FILENO_USB (0x4b)
81 #define DFPLAYER_CMD_FILENO_SDCARD (0x4c)
82 #define DFPLAYER_CMD_FILENO_FLASH (0x4d)
88 #define DFPLAYER_CLASS_MASK (0xf0)
89 #define DFPLAYER_CLASS_NOTIFY (0x30)
90 #define DFPLAYER_CLASS_RESPONSE (0x40)
96 #define DFPLAYER_NOTIFY_INSERT (0x3a)
97 #define DFPLAYER_NOTIFY_EJECT (0x3b)
98 #define DFPLAYER_NOTIFY_DONE_USB (0x3c)
99 #define DFPLAYER_NOTIFY_DONE_SDCARD (0x3d)
100 #define DFPLAYER_NOTIFY_DONE_FLASH (0x3e)
108 #define DFPLAYER_NOTIFY_READY (0x3f)
109 
114 #define DFPLAYER_MASK_USB (0x01)
115 #define DFPLAYER_MASK_SDCARD (0x02)
116 #define DFPLAYER_MASK_PC (0x04)
117 #define DFPLAYER_MASK_FLASH (0x08)
123 #define DFPLAYER_RESPONSE_ERROR (0x40)
124 #define DFPLAYER_RESPONSE_OK (0x41)
125 /* Beware: Handle every code of class response (0x4*) that does not indicate
126  * an error (0x40) as success */
127 
132 #define DFPLAYER_ERROR_BUSY (0x00)
133 #define DFPLAYER_ERROR_FRAME (0x01)
134 #define DFPLAYER_ERROR_FCS (0x02)
142 #define DFPLAYER_ERROR_NO_SUCH_FILE (0x06)
143 
148 #define DFPLAYER_DEVICE_USB (0x01)
149 #define DFPLAYER_DEVICE_SDCARD (0x02)
157 #define DFPLAYER_STATUS_PLAYING (0x01)
158 #define DFPLAYER_STATUS_PAUSE (0x02)
173 #define DFPLAYER_FLAG_NO_ACK_BUG (0x01)
174 
176 #define DFPLAYER_BOOTUP_TIME_MS (3000)
177 #define DFPLAYER_TIMEOUT_MS (100)
178 #define DFPLAYER_SEND_DELAY_MS (100)
179 #ifndef DFPLAYER_RETRIES
180 #define DFPLAYER_RETRIES (5)
181 #endif /* DFPLAYER_RETRIES */
182 #define DFPLAYER_MAX_VOLUME (30)
183 #define DFPLAYER_MAX_FOLDER (99)
184 #define DFPLAYER_MAX_MP3_FILE (9999)
185 #define DFPLAYER_MAX_ADVERT_FILE (9999)
186 #define DFPLAYER_LOWEST_QUERY (0x40)
188 #endif /* DFPLAYER_CONSTANTS_H */
189 
mutex.h
Mutex for thread synchronization.
gpio.h
Low-level GPIO peripheral driver interface definitions.