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 
9 #pragma once
10 
21 #include <stdbool.h>
22 #include <stdint.h>
23 
24 #include "mutex.h"
25 #include "periph/gpio.h"
26 #include "periph/uart.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 typedef enum {
42 
46 typedef enum {
55 
59 typedef enum {
67 
71 typedef enum {
79 
83 typedef enum {
89 
93 typedef enum {
98 
102 typedef uint8_t dfplayer_source_set_t;
103 
107 typedef struct dfplayer dfplayer_t;
108 
119  uint16_t track);
120 
130 
134 typedef struct {
136  gpio_t busy_pin;
137  uint8_t volume;
139 
168 typedef struct {
169  union {
170  uint16_t number;
171  struct {
172  uint8_t folder;
173  uint8_t file;
174  };
175  };
178 
182 struct dfplayer {
185  uint32_t last_event_us;
186  uint8_t buf[6];
188  uint8_t len;
189  uint8_t flags;
192  gpio_t busy_pin;
196 };
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 
dfplayer_mode_t
Enumeration of the playback modes supported by the DFPlayer.
@ DFPLAYER_MODE_REPEAT
Repeating a single file.
@ DFPLAYER_MODE_REPEAT_DIR
Repeating a directory.
@ DFPLAYER_MODE_NUMOF
Number of supported playback modes.
@ DFPLAYER_MODE_NORMAL
Normal playback.
@ DFPLAYER_MODE_UNKOWN
No idea, the data sheet is vague.
@ DFPLAYER_MODE_RANDOM
Playing all files in random order.
dfplayer_scheme_t
Enumeration of the different naming schemes.
@ DFPLAYER_SCHEME_FOLDER_FILE
Naming scheme <folder>/<file>
@ DFPLAYER_SCHEME_NUMOF
Number of naming schemes supported.
@ DFPLAYER_SCHEME_MP3_FILE
Naming scheme MP3/<number>
dfplayer_source_t
Enumeration of the different sources for playback supported.
@ DFPLAYER_SOURCE_NUMOF
Number of supported playback modes.
@ DFPLAYER_SOURCE_SDCARD
Read files from SD card.
@ DFPLAYER_SOURCE_FLASH
Read files from NOR flash.
@ DFPLAYER_SOURCE_AUX
No idea, the data sheet never mentions AUX again.
@ DFPLAYER_SOURCE_SLEEP
No idea, the data sheet is extremely vague on this.
@ DFPLAYER_SOURCE_USB
Read files from USB storage.
dfplayer_rx_state_t
Enumeration of the RX states of the DFPlayer driver.
@ DFPLAYER_RX_STATE_DATA
Receiving data.
@ DFPLAYER_RX_STATE_VERSION
Waiting for version (0xff)
@ DFPLAYER_RX_STATE_LENGTH
Waiting for length (0x06)
@ DFPLAYER_RX_STATE_START
Waiting for start symbol (0x7e)
@ DFPLAYER_RX_STATE_NUMOF
Number of RX states.
uint8_t dfplayer_source_set_t
Set of DFPlayer playback sources.
dfplayer_eq_t
Enumeration of the equalizer settings supported by the DFPlayer.
@ DFPLAYER_EQ_NUMOF
Number of supported equalizer settings.
@ DFPLAYER_EQ_CLASSIC
The "Classic" equalizer setting.
@ DFPLAYER_EQ_NORMAL
The "Normal" equalizer setting.
@ DFPLAYER_EQ_BASE
The "Base" equalizer setting.
@ DFPLAYER_EQ_ROCK
The "Rock" equalizer setting.
@ DFPLAYER_EQ_JAZZ
The "Jazz" equalizer setting.
@ DFPLAYER_EQ_POP
The "Pop" equalizer setting.
void(* dfplayer_cb_src_t)(dfplayer_t *dev, dfplayer_source_set_t srcs)
Signature of the function called when a medium was inserted/ejected.
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.
dfplayer_state_t
Enumeration of the detectable states of the DFPlayer.
@ DFPLAYER_STATE_PAUSED
Playback is paused, can be resumed.
@ DFPLAYER_STATE_PLAYING
Currently playing a file.
@ DFPLAYER_STATE_STOPPED
No file playing.
@ DFPLAYER_STATE_NUMOF
Number of DFPlayer states supported by the driver.
Low-level GPIO peripheral driver interface definitions.
uint_fast8_t uart_t
Define default UART type identifier.
Definition: uart.h:84
Mutex for thread synchronization.
Data structure representing a file on the DFPlayer.
uint8_t file
Name of the file (naming scheme "42/123.mp3")
uint8_t folder
Folder of the file (naming scheme "42/123.mp3")
dfplayer_scheme_t scheme
Used naming scheme.
uint16_t number
Number of the file (naming scheme "MP3/1337.mp3")
Initialization parameters of a DFPlayer Mini device descriptor.
gpio_t busy_pin
GPIO connected to the DFPlayer's busy pin.
uint8_t volume
Initial volume.
uart_t uart
UART interface connected to the DFPlayer.
A DFPlayer Mini device descriptor.
dfplayer_source_set_t srcs
Set of available playback sources.
mutex_t mutex
Used to mutual exclusive access.
dfplayer_file_t file
Currently played song.
dfplayer_cb_done_t cb_done
Function to call when playing a track completed.
uint8_t flags
Flags storing info about the driver state.
uart_t uart
UART interface connected to the DFPlayer.
gpio_t busy_pin
GPIO connected to the DFPlayer's busy pin.
dfplayer_cb_src_t cb_src
Function to call when set of available playback sources changes.
uint8_t buf[6]
Data buffer for response from DFPlayer.
mutex_t sync
Used to wait on ISR.
dfplayer_rx_state_t state
Current state of the DFPlayer.
uint32_t last_event_us
Time stamp of the last event in µs.
uint8_t len
Length of the frame in the buffer.
Mutex structure.
Definition: mutex.h:39
Low-level UART peripheral driver interface definition.