Loading...
Searching...
No Matches
dfplayer_internal.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Marian Buschsieweke
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
16
17#include <stdint.h>
18
19#include "dfplayer_types.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
89int dfplayer_transceive(dfplayer_t *dev, uint16_t *resp,
90 uint8_t cmd, uint8_t p1, uint8_t p2);
91
113int dfplayer_file_cmd(dfplayer_t *dev, uint8_t cmd, uint8_t p1, uint8_t p2);
114
127
134void dfplayer_uart_rx_cb(void *dev, uint8_t data);
135
149static inline int dfplayer_cmd_2param(dfplayer_t *dev, uint8_t cmd,
150 uint8_t p1, uint8_t p2)
151{
152 return dfplayer_transceive(dev, NULL, cmd, p1, p2);
153}
154
167static inline int dfplayer_cmd_1param(dfplayer_t *dev, uint8_t cmd, uint8_t param)
168{
169 return dfplayer_transceive(dev, NULL, cmd, 0, param);
170}
171
183static inline int dfplayer_cmd(dfplayer_t *dev, uint8_t cmd)
184{
185 return dfplayer_transceive(dev, NULL, cmd, 0, 0);
186}
187
200static inline int dfplayer_query(dfplayer_t *dev, uint16_t *resp, uint8_t cmd)
201{
202 return dfplayer_transceive(dev, resp, cmd, 0, 0);
203}
204
205#ifdef __cplusplus
206}
207#endif
208
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.