42#define CHIP_NAME "YuToneWorld SYN6288E"
43#define MANUFACTURER_NAME "YuToneWorld"
44#define SUPPLY_VOLTAGE_MIN 2.4f
45#define SUPPLY_VOLTAGE_MAX 5.1f
46#define MAX_CURRENT 280.0f
47#define TEMPERATURE_MIN -35.0f
48#define TEMPERATURE_MAX 85.0f
49#define DRIVER_VERSION 1000
73 handle->
debug_print(
"syn6288e: uart_init is null.\n");
79 handle->
debug_print(
"syn6288e: uart_deinit is null.\n");
85 handle->
debug_print(
"syn6288e: uart_read is null.\n");
91 handle->
debug_print(
"syn6288e: uart_write is null.\n");
97 handle->
debug_print(
"syn6288e: uart_flush is null.\n");
103 handle->
debug_print(
"syn6288e: delay_ms is null.\n");
110 handle->
debug_print(
"syn6288e: uart init failed.\n");
142 handle->
debug_print(
"syn6288e: uart deinit failed.\n");
189 handle->
debug_print(
"syn6288e: uart flush failed.\n");
196 handle->
debug_print(
"syn6288e: uart write failed.\n");
201 memset(temp, 0,
sizeof(uint8_t) * 2);
202 len = handle->
uart_read((uint8_t *)temp, 2);
205 handle->
debug_print(
"syn6288e: uart read failed.\n");
209 if ((temp[0] == 0x41) && (temp[1] == 0x4F))
215 else if ((temp[0] == 0x41) && (temp[1] == 0x4E))
230 handle->
debug_print(
"syn6288e: command receive failed.\n");
271 handle->
debug_print(
"syn6288e: uart flush failed.\n");
278 handle->
debug_print(
"syn6288e: uart write failed.\n");
283 len = handle->
uart_read((uint8_t *)&temp, 1);
286 handle->
debug_print(
"syn6288e: uart read failed.\n");
296 handle->
debug_print(
"syn6288e: command receive failed.\n");
336 handle->
debug_print(
"syn6288e: uart flush failed.\n");
343 handle->
debug_print(
"syn6288e: uart write failed.\n");
348 len = handle->
uart_read((uint8_t *)&temp, 1);
351 handle->
debug_print(
"syn6288e: uart read failed.\n");
361 handle->
debug_print(
"syn6288e: command receive failed.\n");
401 handle->
debug_print(
"syn6288e: uart flush failed.\n");
408 handle->
debug_print(
"syn6288e: uart write failed.\n");
413 len = handle->
uart_read((uint8_t *)&temp, 1);
416 handle->
debug_print(
"syn6288e: uart read failed.\n");
426 handle->
debug_print(
"syn6288e: command receive failed.\n");
466 handle->
debug_print(
"syn6288e: uart flush failed.\n");
473 handle->
debug_print(
"syn6288e: uart write failed.\n");
478 len = handle->
uart_read((uint8_t *)&temp, 1);
481 handle->
debug_print(
"syn6288e: uart read failed.\n");
491 handle->
debug_print(
"syn6288e: command receive failed.\n");
566 handle->
debug_print(
"syn6288e: uart flush failed.\n");
573 handle->
debug_print(
"syn6288e: uart write failed.\n");
578 len = handle->
uart_read((uint8_t *)&temp, 1);
581 handle->
debug_print(
"syn6288e: uart read failed.\n");
591 handle->
debug_print(
"syn6288e: command receive failed.\n");
644 handle->
mode = (uint8_t)mode;
696 handle->
type = (uint8_t)type;
762 handle->
buf[0] = 0xFD;
763 handle->
buf[1] = (6 + 3) / 256;
764 handle->
buf[2] = (6 + 3) % 256;
765 handle->
buf[3] = 0x01;
766 handle->
buf[4] = 0x00;
767 strncpy((
char *)&handle->
buf[5],(
char *)cmd, 6);
768 for (i = 0; i < 6 + 5; i++)
770 xor_cal ^= handle->
buf[i];
772 handle->
buf[6+5] = xor_cal;
776 handle->
debug_print(
"syn6288e: uart flush failed.\n");
783 handle->
debug_print(
"syn6288e: uart write failed.\n");
788 len = handle->
uart_read((uint8_t *)&temp, 1);
791 handle->
debug_print(
"syn6288e: uart read failed.\n");
801 handle->
debug_print(
"syn6288e: command receive failed.\n");
840 handle->
buf[0] = 0xFD;
841 handle->
buf[1] = (4 + 3) / 256;
842 handle->
buf[2] = (4 + 3) % 256;
843 handle->
buf[3] = 0x01;
844 handle->
buf[4] = 0x00;
845 strncpy((
char *)&handle->
buf[5], (
char *)cmd, 4);
846 for (i = 0; i < 4 + 5; i++)
848 xor_cal ^= handle->
buf[i];
850 handle->
buf[4+5] = xor_cal;
854 handle->
debug_print(
"syn6288e: uart flush failed.\n");
861 handle->
debug_print(
"syn6288e: uart write failed.\n");
866 len = handle->
uart_read((uint8_t *)&temp, 1);
869 handle->
debug_print(
"syn6288e: uart read failed.\n");
879 handle->
debug_print(
"syn6288e: command receive failed.\n");
919 handle->
buf[0] = 0xFD;
920 handle->
buf[1] = (5 + 3) / 256;
921 handle->
buf[2] = (5 + 3) % 256;
922 handle->
buf[3] = 0x01;
923 handle->
buf[4] = 0x00;
924 strncpy((
char *)&handle->
buf[5],(
char *)cmd, 5);
925 for (i = 0; i < 5 + 5; i++)
927 xor_cal ^= handle->
buf[i];
929 handle->
buf[5+5] = xor_cal;
933 handle->
debug_print(
"syn6288e: uart flush failed.\n");
940 handle->
debug_print(
"syn6288e: uart write failed.\n");
945 len = handle->
uart_read((uint8_t *)&temp, 1);
948 handle->
debug_print(
"syn6288e: uart read failed.\n");
958 handle->
debug_print(
"syn6288e: command receive failed.\n");
992 len = (uint8_t)strlen(text);
995 handle->
debug_print(
"syn6288e: text is too long.\n");
999 handle->
buf[0] = 0xFD;
1000 handle->
buf[1] = (uint8_t)((len + 3) / 256);
1001 handle->
buf[2] = (len + 3) % 256;
1002 handle->
buf[3] = 0x01;
1004 strncpy((
char *)&handle->
buf[5], text, len);
1005 for (i = 0; i < len + 5; i++)
1007 xor_cal ^= handle->
buf[i];
1009 handle->
buf[len+5] = xor_cal;
1013 handle->
debug_print(
"syn6288e: uart flush failed.\n");
1020 handle->
debug_print(
"syn6288e: uart write failed.\n");
1025 l = handle->
uart_read((uint8_t *)&temp, 1);
1028 handle->
debug_print(
"syn6288e: uart read failed.\n");
1038 handle->
debug_print(
"syn6288e: command receive failed.\n");
1061 handle->
debug_print(
"syn6288e: volume invalid.\n");
1066 memset((
char *)cmd, 0,
sizeof(
char)*8);
1067 (void)snprintf((
char *)cmd, 8,
"[v%d]", (int16_t)volume);
1094 *volume = handle->
volume;
1116 handle->
debug_print(
"syn6288e: volume is invalid.\n");
1121 memset((
char *)cmd, 0,
sizeof(
char)*8);
1122 (void)snprintf((
char *)cmd, 8,
"[m%d]", (int16_t)volume);
1171 handle->
debug_print(
"syn6288e: speed is invalid.\n");
1176 memset((
char *)cmd, 0,
sizeof(
char)*8);
1177 (void)snprintf((
char *)cmd, 8,
"[t%d]", (int16_t)speed);
1178 handle->
speed = speed;
1204 *speed = handle->
speed;
1226 uint8_t xor_cal = 0;
1237 len = (uint8_t)strlen(command);
1240 handle->
debug_print(
"syn6288e: command is too long.\n");
1244 handle->
buf[0] = 0xFD;
1245 handle->
buf[1] = (uint8_t)((len + 3) / 256);
1246 handle->
buf[2] = (len + 3) % 256;
1247 handle->
buf[3] = 0x01;
1248 handle->
buf[4] = 0x00;
1249 strncpy((
char *)&handle->
buf[5], command, len);
1250 for (i = 0; i < len + 5; i++)
1252 xor_cal ^= handle->
buf[i];
1254 handle->
buf[len + 5] = xor_cal;
1258 handle->
debug_print(
"syn6288e: uart flush failed.\n");
1265 handle->
debug_print(
"syn6288e: uart write failed.\n");
1270 l = handle->
uart_read((uint8_t *)&temp, 1);
1273 handle->
debug_print(
"syn6288e: uart read failed.\n");
1283 handle->
debug_print(
"syn6288e: command receive failed.\n");
#define SUPPLY_VOLTAGE_MAX
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define CHIP_NAME
chip information definition
driver syn6288e header file
uint8_t syn6288e_set_background_volume(syn6288e_handle_t *handle, uint8_t volume)
set the synthesis background volume
syn6288e_baud_rate_t
syn6288e baud rate enumeration definition
uint8_t syn6288e_set_baud_rate(syn6288e_handle_t *handle, syn6288e_baud_rate_t rate)
set the baud rate
uint8_t syn6288e_get_synthesis_speed(syn6288e_handle_t *handle, uint8_t *speed)
get the synthesis speed
uint8_t syn6288e_get_baud_rate(syn6288e_handle_t *handle, syn6288e_baud_rate_t *rate)
get the baud rate
uint8_t syn6288e_get_synthesis_volume(syn6288e_handle_t *handle, uint8_t *volume)
get the chip synthesis volume
uint8_t syn6288e_set_synthesis_speed(syn6288e_handle_t *handle, uint8_t speed)
set the synthesis speed
syn6288e_mode_t
syn6288e mode enumeration definition
uint8_t syn6288e_set_synthesis_volume(syn6288e_handle_t *handle, uint8_t volume)
set the chip synthesis volume
uint8_t syn6288e_get_background_volume(syn6288e_handle_t *handle, uint8_t *volume)
get the chip synthesis background volume
uint8_t syn6288e_get_mode(syn6288e_handle_t *handle, syn6288e_mode_t *mode)
get the chip mode
uint8_t syn6288e_set_mode(syn6288e_handle_t *handle, syn6288e_mode_t mode)
set the chip mode
@ SYN6288E_BAUD_RATE_9600_BPS
@ SYN6288E_BAUD_RATE_19200_BPS
@ SYN6288E_BAUD_RATE_38400_BPS
syn6288e_type_t
syn6288e type enumeration definition
uint8_t syn6288e_synthesis_text(syn6288e_handle_t *handle, char *text)
synthesis the test
uint8_t syn6288e_synthesis_sound(syn6288e_handle_t *handle, syn6288e_sound_t sound)
synthesis the sound
syn6288e_message_t
syn6288e message enumeration definition
syn6288e_ring_t
syn6288e ring enumeration definition
uint8_t syn6288e_init(syn6288e_handle_t *handle)
initialize the chip
uint8_t syn6288e_synthesis_ring(syn6288e_handle_t *handle, syn6288e_ring_t ring)
synthesis the ring
uint8_t syn6288e_deinit(syn6288e_handle_t *handle)
close the chip
uint8_t syn6288e_info(syn6288e_info_t *info)
get chip's information
uint8_t syn6288e_set_text_type(syn6288e_handle_t *handle, syn6288e_type_t type)
set the chip text type
struct syn6288e_handle_s syn6288e_handle_t
syn6288e handle structure definition
uint8_t syn6288e_get_text_type(syn6288e_handle_t *handle, syn6288e_type_t *type)
get the chip text type
struct syn6288e_info_s syn6288e_info_t
syn6288e information structure definition
uint8_t syn6288e_get_status(syn6288e_handle_t *handle, syn6288e_status_t *status)
get the current status
uint8_t syn6288e_stop(syn6288e_handle_t *handle)
stop the chip
uint8_t syn6288e_power_down(syn6288e_handle_t *handle)
power down the chip
uint8_t syn6288e_synthesis_message(syn6288e_handle_t *handle, syn6288e_message_t message)
synthesis the message
uint8_t syn6288e_pause(syn6288e_handle_t *handle)
pause the chip
syn6288e_status_t
syn6288e status enumeration definition
uint8_t syn6288e_resume(syn6288e_handle_t *handle)
resume the chip
syn6288e_sound_t
syn6288e sound enumeration definition
uint8_t syn6288e_set_command(syn6288e_handle_t *handle, char *command)
send the command to the chip
uint8_t(* uart_flush)(void)
uint8_t(* uart_write)(uint8_t *buf, uint16_t len)
void(* delay_ms)(uint32_t ms)
uint8_t(* uart_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint8_t background_volume
uint16_t(* uart_read)(uint8_t *buf, uint16_t len)
uint8_t(* uart_init)(void)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v