LibDriver LD3320
Loading...
Searching...
No Matches
driver_ld3320_mp3.c
Go to the documentation of this file.
1
36
37#include "driver_ld3320_mp3.h"
38
39static ld3320_handle_t gs_handle;
40
49{
50 if (ld3320_irq_handler(&gs_handle) != 0)
51 {
52 return 1;
53 }
54 else
55 {
56 return 0;
57 }
58}
59
69uint8_t ld3320_mp3_init(char *name, void (*receive_callback)(uint8_t type, uint8_t index, char *text))
70{
71 uint8_t res;
72
73 /* link driver */
85 DRIVER_LD3320_LINK_DEBUG_RECEIVE_CALLBACK(&gs_handle, receive_callback);
89
90 /* init chip */
91 res = ld3320_init(&gs_handle);
92 if (res != 0)
93 {
94 ld3320_interface_debug_print("ld3320: init failed.\n");
95
96 return 1;
97 }
98
99 /* set mp3 mode */
100 res = ld3320_set_mode(&gs_handle, LD3320_MODE_MP3);
101 if (res != 0)
102 {
103 ld3320_interface_debug_print("ld3320: set mode failed.\n");
104 (void)ld3320_deinit(&gs_handle);
105
106 return 1;
107 }
108
109 /* configure the mp3 */
110 res = ld3320_configure_mp3(&gs_handle, name);
111 if (res != 0)
112 {
113 ld3320_interface_debug_print("ld3320: configure mp3 failed.\n");
114 (void)ld3320_deinit(&gs_handle);
115
116 return 1;
117 }
118
119 return 0;
120}
121
129uint8_t ld3320_mp3_start(void)
130{
131 uint8_t res;
132
133 /* start */
134 res = ld3320_start(&gs_handle);
135 if (res != 0)
136 {
137 return 1;
138 }
139
140 /* set speaker volume */
142 if (res != 0)
143 {
144 return 1;
145 }
146
147 /* set headset volume */
149 if (res != 0)
150 {
151 return 1;
152 }
153 else
154 {
155 return 0;
156 }
157}
158
166uint8_t ld3320_mp3_stop(void)
167{
168 uint8_t res;
169
170 /* stop */
171 res = ld3320_stop(&gs_handle);
172 if (res != 0)
173 {
174 return 1;
175 }
176 else
177 {
178 return 0;
179 }
180}
181
189uint8_t ld3320_mp3_deinit(void)
190{
191 uint8_t res;
192
193 /* mp3 deinit */
194 res = ld3320_deinit(&gs_handle);
195 if (res != 0)
196 {
197 return 1;
198 }
199 else
200 {
201 return 0;
202 }
203}
driver ld3320 mp3 header file
uint8_t ld3320_deinit(ld3320_handle_t *handle)
deinit the chip
uint8_t ld3320_stop(ld3320_handle_t *handle)
stop the process
uint8_t ld3320_init(ld3320_handle_t *handle)
initialize the chip
uint8_t ld3320_configure_mp3(ld3320_handle_t *handle, char *name)
configure the mp3
struct ld3320_handle_s ld3320_handle_t
ld3320 handle structure definition
uint8_t ld3320_set_headset_volume(ld3320_handle_t *handle, uint8_t volume_left, uint8_t volume_right)
set the headset volume
uint8_t ld3320_start(ld3320_handle_t *handle)
start the process
uint8_t ld3320_irq_handler(ld3320_handle_t *handle)
irq handler
uint8_t ld3320_set_mode(ld3320_handle_t *handle, ld3320_mode_t mode)
set the chip mode
uint8_t ld3320_set_speaker_volume(ld3320_handle_t *handle, uint8_t volume)
set the speaker volume
@ LD3320_MODE_MP3
uint8_t ld3320_mp3_stop(void)
mp3 example stop
uint8_t ld3320_mp3_irq_handler(void)
mp3 irq
uint8_t ld3320_mp3_deinit(void)
mp3 example deinit
#define LD3320_MP3_DEFAULT_SPEAKER_VOLUME
ld3320 mp3 example default definition
uint8_t ld3320_mp3_start(void)
mp3 example start
uint8_t ld3320_mp3_init(char *name, void(*receive_callback)(uint8_t type, uint8_t index, char *text))
mp3 example init
uint8_t ld3320_interface_mp3_read(uint32_t addr, uint16_t size, uint8_t *buffer)
interface mp3 read
uint8_t ld3320_interface_reset_gpio_init(void)
interface reset gpio init
uint8_t ld3320_interface_spi_write_cmd(uint8_t *buf, uint16_t len)
interface spi bus write
void ld3320_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t ld3320_interface_reset_gpio_deinit(void)
interface reset gpio deinit
uint8_t ld3320_interface_spi_init(void)
interface spi bus init
uint8_t ld3320_interface_reset_gpio_write(uint8_t data)
interface reset gpio write
uint8_t ld3320_interface_spi_read_address16(uint16_t reg, uint8_t *buf, uint16_t len)
interface spi bus read
uint8_t ld3320_interface_mp3_deinit(void)
interface mp3 deinit
uint8_t ld3320_interface_spi_deinit(void)
interface spi bus deinit
uint8_t ld3320_interface_mp3_init(char *name, uint32_t *size)
interface mp3 init
void ld3320_interface_delay_us(uint32_t us)
interface delay us
void ld3320_interface_debug_print(const char *const fmt,...)
interface print format data