Loading...
Searching...
No Matches
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
9#pragma once
10
19
20#include <stdint.h>
21
22#include "dfplayer_types.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
92int dfplayer_transceive(dfplayer_t *dev, uint16_t *resp,
93 uint8_t cmd, uint8_t p1, uint8_t p2);
94
116int dfplayer_file_cmd(dfplayer_t *dev, uint8_t cmd, uint8_t p1, uint8_t p2);
117
130
137void dfplayer_uart_rx_cb(void *dev, uint8_t data);
138
152static inline int dfplayer_cmd_2param(dfplayer_t *dev, uint8_t cmd,
153 uint8_t p1, uint8_t p2)
154{
155 return dfplayer_transceive(dev, NULL, cmd, p1, p2);
156}
157
170static inline int dfplayer_cmd_1param(dfplayer_t *dev, uint8_t cmd, uint8_t param)
171{
172 return dfplayer_transceive(dev, NULL, cmd, 0, param);
173}
174
186static inline int dfplayer_cmd(dfplayer_t *dev, uint8_t cmd)
187{
188 return dfplayer_transceive(dev, NULL, cmd, 0, 0);
189}
190
203static inline int dfplayer_query(dfplayer_t *dev, uint16_t *resp, uint8_t cmd)
204{
205 return dfplayer_transceive(dev, resp, cmd, 0, 0);
206}
207
208#ifdef __cplusplus
209}
210#endif
211
static int dfplayer_cmd(dfplayer_t *dev, uint8_t cmd)
Send a command without parameters to the DFPlayer Mini.
int dfplayer_reset(dfplayer_t *dev)
Reset the DFPlayer Mini MP3 player.
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.
void dfplayer_uart_rx_cb(void *dev, uint8_t data)
UART-ISR handler of the DFPLayer driver.
static int dfplayer_query(dfplayer_t *dev, uint16_t *resp, uint8_t cmd)
Send a query and receive the response.
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.
static int dfplayer_cmd_1param(dfplayer_t *dev, uint8_t cmd, uint8_t param)
Send a command with one parameter to the DFPlayer Mini.
int dfplayer_file_cmd(dfplayer_t *dev, uint8_t cmd, uint8_t p1, uint8_t p2)
Send a command selecting a playback file.
Types used in the DFPlayer Mini Device Driver.
struct dfplayer dfplayer_t
A DFPlayer Mini device descriptor.