dfplayer_internal.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 
18 #ifndef DFPLAYER_INTERNAL_H
19 #define DFPLAYER_INTERNAL_H
20 
21 #include <stdint.h>
22 
23 #include "dfplayer_types.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
93 int dfplayer_transceive(dfplayer_t *dev, uint16_t *resp,
94  uint8_t cmd, uint8_t p1, uint8_t p2);
95 
117 int dfplayer_file_cmd(dfplayer_t *dev, uint8_t cmd, uint8_t p1, uint8_t p2);
118 
130 int dfplayer_reset(dfplayer_t *dev);
131 
138 void dfplayer_uart_rx_cb(void *dev, uint8_t data);
139 
153 static inline int dfplayer_cmd_2param(dfplayer_t *dev, uint8_t cmd,
154  uint8_t p1, uint8_t p2)
155 {
156  return dfplayer_transceive(dev, NULL, cmd, p1, p2);
157 }
158 
171 static inline int dfplayer_cmd_1param(dfplayer_t *dev, uint8_t cmd, uint8_t param)
172 {
173  return dfplayer_transceive(dev, NULL, cmd, 0, param);
174 }
175 
187 static inline int dfplayer_cmd(dfplayer_t *dev, uint8_t cmd)
188 {
189  return dfplayer_transceive(dev, NULL, cmd, 0, 0);
190 }
191 
204 static inline int dfplayer_query(dfplayer_t *dev, uint16_t *resp, uint8_t cmd)
205 {
206  return dfplayer_transceive(dev, resp, cmd, 0, 0);
207 }
208 
209 #ifdef __cplusplus
210 }
211 #endif
212 
213 #endif /* DFPLAYER_INTERNAL_H */
214 
dfplayer_reset
int dfplayer_reset(dfplayer_t *dev)
Reset the DFPlayer Mini MP3 player.
dfplayer_file_cmd
int dfplayer_file_cmd(dfplayer_t *dev, uint8_t cmd, uint8_t p1, uint8_t p2)
Send a command selecting a playback file.
dfplayer_types.h
Types used in the DFPlayer Mini Device Driver.
dfplayer_transceive
int dfplayer_transceive(dfplayer_t *dev, uint16_t *resp, uint8_t cmd, uint8_t p1, uint8_t p2)
Exchange a frame with the DFPlayer Mini.
dfplayer_cmd_2param
static int dfplayer_cmd_2param(dfplayer_t *dev, uint8_t cmd, uint8_t p1, uint8_t p2)
Send a command with two parameters to the DFPlayer Mini.
Definition: dfplayer_internal.h:153
dfplayer_uart_rx_cb
void dfplayer_uart_rx_cb(void *dev, uint8_t data)
UART-ISR handler of the DFPLayer driver.
dfplayer_cmd
static int dfplayer_cmd(dfplayer_t *dev, uint8_t cmd)
Send a command without parameters to the DFPlayer Mini.
Definition: dfplayer_internal.h:187
dfplayer_query
static int dfplayer_query(dfplayer_t *dev, uint16_t *resp, uint8_t cmd)
Send a query and receive the response.
Definition: dfplayer_internal.h:204
dfplayer_cmd_1param
static int dfplayer_cmd_1param(dfplayer_t *dev, uint8_t cmd, uint8_t param)
Send a command with one parameter to the DFPlayer Mini.
Definition: dfplayer_internal.h:171
dfplayer
A DFPlayer Mini device descriptor.
Definition: dfplayer_types.h:184