dfplayer_types.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_TYPES_H
20 #define DFPLAYER_TYPES_H
21 
22 #include <stdbool.h>
23 #include <stdint.h>
24 
25 #include "kernel_types.h"
26 #include "mutex.h"
27 #include "periph/gpio.h"
28 #include "periph/uart.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
37 typedef enum {
44 
48 typedef enum {
57 
61 typedef enum {
69 
73 typedef enum {
81 
85 typedef enum {
91 
95 typedef enum {
100 
104 typedef uint8_t dfplayer_source_set_t;
105 
109 typedef struct dfplayer dfplayer_t;
110 
121  uint16_t track);
122 
132 
136 typedef struct {
138  gpio_t busy_pin;
139  uint8_t volume;
141 
170 typedef struct {
171  union {
172  uint16_t number;
173  struct {
174  uint8_t folder;
175  uint8_t file;
176  };
177  };
180 
184 struct dfplayer {
187  uint32_t last_event_us;
188  uint8_t buf[6];
190  uint8_t len;
191  uint8_t flags;
194  gpio_t busy_pin;
198 };
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 #endif /* DFPLAYER_TYPES_H */
205 
dfplayer_mode_t
dfplayer_mode_t
Enumeration of the playback modes supported by the DFPlayer.
Definition: dfplayer_types.h:61
dfplayer::len
uint8_t len
Length of the frame in the buffer.
Definition: dfplayer_types.h:190
dfplayer::file
dfplayer_file_t file
Currently played song.
Definition: dfplayer_types.h:189
dfplayer::buf
uint8_t buf[6]
Data buffer for response from DFPlayer.
Definition: dfplayer_types.h:188
dfplayer::mutex
mutex_t mutex
Used to mutual exclusive access.
Definition: dfplayer_types.h:192
dfplayer::state
dfplayer_rx_state_t state
Current state of the DFPlayer.
Definition: dfplayer_types.h:197
dfplayer_params_t::busy_pin
gpio_t busy_pin
GPIO connected to the DFPlayer's busy pin.
Definition: dfplayer_types.h:138
DFPLAYER_EQ_JAZZ
@ DFPLAYER_EQ_JAZZ
The "Jazz" equalizer setting.
Definition: dfplayer_types.h:52
DFPLAYER_RX_STATE_LENGTH
@ DFPLAYER_RX_STATE_LENGTH
Waiting for length (0x06)
Definition: dfplayer_types.h:40
DFPLAYER_MODE_NORMAL
@ DFPLAYER_MODE_NORMAL
Normal playback.
Definition: dfplayer_types.h:66
DFPLAYER_SOURCE_AUX
@ DFPLAYER_SOURCE_AUX
No idea, the data sheet never mentions AUX again.
Definition: dfplayer_types.h:76
dfplayer_rx_state_t
dfplayer_rx_state_t
Enumeration of the RX states of the DFPlayer driver.
Definition: dfplayer_types.h:37
DFPLAYER_SOURCE_NUMOF
@ DFPLAYER_SOURCE_NUMOF
Number of supported playback modes.
Definition: dfplayer_types.h:79
DFPLAYER_MODE_REPEAT
@ DFPLAYER_MODE_REPEAT
Repeating a single file.
Definition: dfplayer_types.h:64
DFPLAYER_MODE_RANDOM
@ DFPLAYER_MODE_RANDOM
Playing all files in random order.
Definition: dfplayer_types.h:65
dfplayer_eq_t
dfplayer_eq_t
Enumeration of the equalizer settings supported by the DFPlayer.
Definition: dfplayer_types.h:48
DFPLAYER_EQ_NORMAL
@ DFPLAYER_EQ_NORMAL
The "Normal" equalizer setting.
Definition: dfplayer_types.h:49
DFPLAYER_EQ_CLASSIC
@ DFPLAYER_EQ_CLASSIC
The "Classic" equalizer setting.
Definition: dfplayer_types.h:53
uart_t
unsigned int uart_t
Define default UART type identifier.
Definition: uart.h:76
dfplayer_state_t
dfplayer_state_t
Enumeration of the detectable states of the DFPlayer.
Definition: dfplayer_types.h:85
uart.h
Low-level UART peripheral driver interface definition.
dfplayer_source_t
dfplayer_source_t
Enumeration of the different sources for playback supported.
Definition: dfplayer_types.h:73
DFPLAYER_EQ_NUMOF
@ DFPLAYER_EQ_NUMOF
Number of supported equalizer settings.
Definition: dfplayer_types.h:55
DFPLAYER_RX_STATE_START
@ DFPLAYER_RX_STATE_START
Waiting for start symbol (0x7e)
Definition: dfplayer_types.h:38
DFPLAYER_MODE_REPEAT_DIR
@ DFPLAYER_MODE_REPEAT_DIR
Repeating a directory.
Definition: dfplayer_types.h:63
dfplayer::cb_done
dfplayer_cb_done_t cb_done
Function to call when playing a track completed.
Definition: dfplayer_types.h:185
DFPLAYER_SOURCE_SLEEP
@ DFPLAYER_SOURCE_SLEEP
No idea, the data sheet is extremely vague on this.
Definition: dfplayer_types.h:77
DFPLAYER_MODE_UNKOWN
@ DFPLAYER_MODE_UNKOWN
No idea, the data sheet is vague.
Definition: dfplayer_types.h:62
DFPLAYER_SCHEME_NUMOF
@ DFPLAYER_SCHEME_NUMOF
Number of naming schemes supported.
Definition: dfplayer_types.h:98
dfplayer_params_t
Initialization parameters of a DFPlayer Mini device descriptor.
Definition: dfplayer_types.h:136
DFPLAYER_SOURCE_FLASH
@ DFPLAYER_SOURCE_FLASH
Read files from NOR flash.
Definition: dfplayer_types.h:78
dfplayer_file_t::number
uint16_t number
Number of the file (naming scheme "MP3/1337.mp3")
Definition: dfplayer_types.h:172
DFPLAYER_EQ_BASE
@ DFPLAYER_EQ_BASE
The "Base" equalizer setting.
Definition: dfplayer_types.h:54
DFPLAYER_STATE_PLAYING
@ DFPLAYER_STATE_PLAYING
Currently playing a file.
Definition: dfplayer_types.h:86
DFPLAYER_EQ_ROCK
@ DFPLAYER_EQ_ROCK
The "Rock" equalizer setting.
Definition: dfplayer_types.h:51
DFPLAYER_MODE_NUMOF
@ DFPLAYER_MODE_NUMOF
Number of supported playback modes.
Definition: dfplayer_types.h:67
dfplayer_file_t::scheme
dfplayer_scheme_t scheme
Used naming scheme.
Definition: dfplayer_types.h:178
mutex.h
Mutex for thread synchronization.
gpio.h
Low-level GPIO peripheral driver interface definitions.
DFPLAYER_RX_STATE_NUMOF
@ DFPLAYER_RX_STATE_NUMOF
Number of RX states.
Definition: dfplayer_types.h:42
DFPLAYER_SOURCE_SDCARD
@ DFPLAYER_SOURCE_SDCARD
Read files from SD card.
Definition: dfplayer_types.h:75
dfplayer::last_event_us
uint32_t last_event_us
Time stamp of the last event in µs.
Definition: dfplayer_types.h:187
dfplayer_cb_src_t
void(* dfplayer_cb_src_t)(dfplayer_t *dev, dfplayer_source_set_t srcs)
Signature of the function called when a medium was inserted/ejected.
Definition: dfplayer_types.h:131
dfplayer_file_t::file
uint8_t file
Name of the file (naming scheme "42/123.mp3")
Definition: dfplayer_types.h:175
dfplayer_cb_done_t
void(* dfplayer_cb_done_t)(dfplayer_t *dev, dfplayer_source_t src, uint16_t track)
Signature of the function called when a playback of track completed.
Definition: dfplayer_types.h:120
dfplayer_file_t::folder
uint8_t folder
Folder of the file (naming scheme "42/123.mp3")
Definition: dfplayer_types.h:174
dfplayer::sync
mutex_t sync
Used to wait on ISR.
Definition: dfplayer_types.h:195
DFPLAYER_RX_STATE_DATA
@ DFPLAYER_RX_STATE_DATA
Receiving data.
Definition: dfplayer_types.h:41
dfplayer_params_t::volume
uint8_t volume
Initial volume.
Definition: dfplayer_types.h:139
dfplayer::flags
uint8_t flags
Flags storing info about the driver state.
Definition: dfplayer_types.h:191
dfplayer::srcs
dfplayer_source_set_t srcs
Set of available playback sources.
Definition: dfplayer_types.h:196
DFPLAYER_SCHEME_FOLDER_FILE
@ DFPLAYER_SCHEME_FOLDER_FILE
Naming scheme <folder>/<file>
Definition: dfplayer_types.h:96
dfplayer::busy_pin
gpio_t busy_pin
GPIO connected to the DFPlayer's busy pin.
Definition: dfplayer_types.h:194
DFPLAYER_STATE_NUMOF
@ DFPLAYER_STATE_NUMOF
Number of DFPlayer states supported by the driver.
Definition: dfplayer_types.h:89
DFPLAYER_EQ_POP
@ DFPLAYER_EQ_POP
The "Pop" equalizer setting.
Definition: dfplayer_types.h:50
dfplayer::uart
uart_t uart
UART interface connected to the DFPlayer.
Definition: dfplayer_types.h:193
DFPLAYER_STATE_PAUSED
@ DFPLAYER_STATE_PAUSED
Playback is paused, can be resumed.
Definition: dfplayer_types.h:87
DFPLAYER_SOURCE_USB
@ DFPLAYER_SOURCE_USB
Read files from USB storage.
Definition: dfplayer_types.h:74
DFPLAYER_STATE_STOPPED
@ DFPLAYER_STATE_STOPPED
No file playing.
Definition: dfplayer_types.h:88
DFPLAYER_RX_STATE_VERSION
@ DFPLAYER_RX_STATE_VERSION
Waiting for version (0xff)
Definition: dfplayer_types.h:39
dfplayer_file_t
Data structure representing a file on the DFPlayer.
Definition: dfplayer_types.h:170
dfplayer_source_set_t
uint8_t dfplayer_source_set_t
Set of DFPlayer playback sources.
Definition: dfplayer_types.h:104
dfplayer::cb_src
dfplayer_cb_src_t cb_src
Function to call when set of available playback sources changes.
Definition: dfplayer_types.h:186
kernel_types.h
Types used by the kernel.
dfplayer_params_t::uart
uart_t uart
UART interface connected to the DFPlayer.
Definition: dfplayer_types.h:137
mutex_t
Mutex structure.
Definition: mutex.h:120
dfplayer
A DFPlayer Mini device descriptor.
Definition: dfplayer_types.h:184
DFPLAYER_SCHEME_MP3_FILE
@ DFPLAYER_SCHEME_MP3_FILE
Naming scheme MP3/<number>
Definition: dfplayer_types.h:97
dfplayer_scheme_t
dfplayer_scheme_t
Enumeration of the different naming schemes.
Definition: dfplayer_types.h:95