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 
9 #pragma once
10 
21 #include <stdint.h>
22 #include <periph/gpio.h>
23 #include <mutex.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
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)
45 #define DFPLAYER_BAUD (9600)
46 #define DFPLAYER_DATA_BITS (UART_DATA_BITS_8)
47 #define DFPLAYER_PARITY (UART_PARITY_NONE)
48 #define DFPLAYER_STOP_BITS (UART_STOP_BITS_1)
55 #define DFPLAYER_CMD_NEXT (0x01)
56 #define DFPLAYER_CMD_PREV (0x02)
57 #define DFPLAYER_CMD_VOLUME_INC (0x04)
58 #define DFPLAYER_CMD_VOLUME_DEC (0x05)
59 #define DFPLAYER_CMD_SET_VOLUME (0x06)
60 #define DFPLAYER_CMD_SET_EQUALIZER (0x07)
61 #define DFPLAYER_CMD_SET_SOURCE (0x09)
62 #define DFPLAYER_CMD_STANDBY_ENTER (0x0a)
63 #define DFPLAYER_CMD_STANDBY_EXIT (0x0b)
64 #define DFPLAYER_CMD_RESET (0x0c)
65 #define DFPLAYER_CMD_PLAY (0x0d)
66 #define DFPLAYER_CMD_PAUSE (0x0e)
67 #define DFPLAYER_CMD_FILE (0x0f)
68 #define DFPLAYER_CMD_PLAY_FROM_MP3 (0x12)
69 #define DFPLAYER_CMD_PLAY_ADVERT (0x13)
70 #define DFPLAYER_CMD_ABORT_ADVERT (0x15)
71 #define DFPLAYER_CMD_REPEAT_FOLDER (0x17)
72 #define DFPLAYER_CMD_RANDOM (0x18)
73 #define DFPLAYER_CMD_REPEAT (0x19)
74 #define DFPLAYER_CMD_GET_STATUS (0x42)
75 #define DFPLAYER_CMD_GET_VOLUME (0x43)
76 #define DFPLAYER_CMD_GET_EQUALIZER (0x44)
77 #define DFPLAYER_CMD_GET_MODE (0x45)
78 #define DFPLAYER_CMD_GET_VERSION (0x46)
79 #define DFPLAYER_CMD_FILES_USB (0x47)
80 #define DFPLAYER_CMD_FILES_SDCARD (0x48)
81 #define DFPLAYER_CMD_FILES_FLASH (0x49)
82 #define DFPLAYER_CMD_FILENO_USB (0x4b)
83 #define DFPLAYER_CMD_FILENO_SDCARD (0x4c)
84 #define DFPLAYER_CMD_FILENO_FLASH (0x4d)
91 #define DFPLAYER_CLASS_MASK (0xf0)
92 #define DFPLAYER_CLASS_NOTIFY (0x30)
93 #define DFPLAYER_CLASS_RESPONSE (0x40)
100 #define DFPLAYER_NOTIFY_INSERT (0x3a)
101 #define DFPLAYER_NOTIFY_EJECT (0x3b)
102 #define DFPLAYER_NOTIFY_DONE_USB (0x3c)
103 #define DFPLAYER_NOTIFY_DONE_SDCARD (0x3d)
104 #define DFPLAYER_NOTIFY_DONE_FLASH (0x3e)
112 #define DFPLAYER_NOTIFY_READY (0x3f)
119 #define DFPLAYER_MASK_USB (0x01)
120 #define DFPLAYER_MASK_SDCARD (0x02)
121 #define DFPLAYER_MASK_PC (0x04)
122 #define DFPLAYER_MASK_FLASH (0x08)
129 #define DFPLAYER_RESPONSE_ERROR (0x40)
130 #define DFPLAYER_RESPONSE_OK (0x41)
131 /* Beware: Handle every code of class response (0x4*) that does not indicate
132  * an error (0x40) as success */
139 #define DFPLAYER_ERROR_BUSY (0x00)
140 #define DFPLAYER_ERROR_FRAME (0x01)
141 #define DFPLAYER_ERROR_FCS (0x02)
149 #define DFPLAYER_ERROR_NO_SUCH_FILE (0x06)
156 #define DFPLAYER_DEVICE_USB (0x01)
157 #define DFPLAYER_DEVICE_SDCARD (0x02)
167 #define DFPLAYER_STATUS_PLAYING (0x01)
168 #define DFPLAYER_STATUS_PAUSE (0x02)
184 #define DFPLAYER_FLAG_NO_ACK_BUG (0x01)
187 #define DFPLAYER_BOOTUP_TIME_MS (3000)
188 #define DFPLAYER_TIMEOUT_MS (100)
189 #define DFPLAYER_SEND_DELAY_MS (100)
190 #ifndef DFPLAYER_RETRIES
191 #define DFPLAYER_RETRIES (5)
192 #endif /* DFPLAYER_RETRIES */
193 #define DFPLAYER_MAX_VOLUME (30)
194 #define DFPLAYER_MAX_FOLDER (99)
195 #define DFPLAYER_MAX_MP3_FILE (9999)
196 #define DFPLAYER_MAX_ADVERT_FILE (9999)
197 #define DFPLAYER_LOWEST_QUERY (0x40)
199 #ifdef __cplusplus
200 }
201 #endif
Low-level GPIO peripheral driver interface definitions.
Mutex for thread synchronization.