43 #define CHIP_NAME "YuToneWorld SYN6288"
44 #define MANUFACTURER_NAME "YuToneWorld"
45 #define SUPPLY_VOLTAGE_MIN 2.4f
46 #define SUPPLY_VOLTAGE_MAX 5.1f
47 #define MAX_CURRENT 280.0f
48 #define TEMPERATURE_MIN -35.0f
49 #define TEMPERATURE_MAX 85.0f
50 #define DRIVER_VERSION 2000
74 handle->
debug_print(
"syn6288: uart_init is null.\n");
80 handle->
debug_print(
"syn6288: uart_deinit is null.\n");
86 handle->
debug_print(
"syn6288: uart_read is null.\n");
92 handle->
debug_print(
"syn6288: uart_write is null.\n");
98 handle->
debug_print(
"syn6288: uart_flush is null.\n");
104 handle->
debug_print(
"syn6288: delay_ms is null.\n");
111 handle->
debug_print(
"syn6288: uart init failed.\n");
143 handle->
debug_print(
"syn6288: uart deinit failed.\n");
190 handle->
debug_print(
"syn6288: uart flush failed.\n");
197 handle->
debug_print(
"syn6288: uart write failed.\n");
202 memset(temp, 0,
sizeof(uint8_t) * 2);
203 len = handle->
uart_read((uint8_t *)temp, 2);
206 handle->
debug_print(
"syn6288: uart read failed.\n");
210 if ((temp[0] == 0x41) && (temp[1] == 0x4F))
216 else if ((temp[0] == 0x41) && (temp[1] == 0x4E))
231 handle->
debug_print(
"syn6288: command receive failed.\n");
272 handle->
debug_print(
"syn6288: uart flush failed.\n");
279 handle->
debug_print(
"syn6288: uart write failed.\n");
284 len = handle->
uart_read((uint8_t *)&temp, 1);
287 handle->
debug_print(
"syn6288: uart read failed.\n");
297 handle->
debug_print(
"syn6288: command receive failed.\n");
337 handle->
debug_print(
"syn6288: uart flush failed.\n");
344 handle->
debug_print(
"syn6288: uart write failed.\n");
349 len = handle->
uart_read((uint8_t *)&temp, 1);
352 handle->
debug_print(
"syn6288: uart read failed.\n");
362 handle->
debug_print(
"syn6288: command receive failed.\n");
402 handle->
debug_print(
"syn6288: uart flush failed.\n");
409 handle->
debug_print(
"syn6288: uart write failed.\n");
414 len = handle->
uart_read((uint8_t *)&temp, 1);
417 handle->
debug_print(
"syn6288: uart read failed.\n");
427 handle->
debug_print(
"syn6288: command receive failed.\n");
467 handle->
debug_print(
"syn6288: uart flush failed.\n");
474 handle->
debug_print(
"syn6288: uart write failed.\n");
479 len = handle->
uart_read((uint8_t *)&temp, 1);
482 handle->
debug_print(
"syn6288: uart read failed.\n");
492 handle->
debug_print(
"syn6288: command receive failed.\n");
567 handle->
debug_print(
"syn6288: uart flush failed.\n");
574 handle->
debug_print(
"syn6288: uart write failed.\n");
579 len = handle->
uart_read((uint8_t *)&temp, 1);
582 handle->
debug_print(
"syn6288: uart read failed.\n");
592 handle->
debug_print(
"syn6288: command receive failed.\n");
645 handle->
mode = (uint8_t)mode;
697 handle->
type = (uint8_t)type;
763 handle->
buf[0] = 0xFD;
764 handle->
buf[1] = (6 + 3) / 256;
765 handle->
buf[2] = (6 + 3) % 256;
766 handle->
buf[3] = 0x01;
767 handle->
buf[4] = 0x00;
768 strncpy((
char *)&handle->
buf[5],(
char *)cmd, 6);
769 for (i = 0; i < 6 + 5; i++)
771 xor_cal ^= handle->
buf[i];
773 handle->
buf[6+5] = xor_cal;
777 handle->
debug_print(
"syn6288: uart flush failed.\n");
784 handle->
debug_print(
"syn6288: uart write failed.\n");
789 len = handle->
uart_read((uint8_t *)&temp, 1);
792 handle->
debug_print(
"syn6288: uart read failed.\n");
802 handle->
debug_print(
"syn6288: command receive failed.\n");
841 handle->
buf[0] = 0xFD;
842 handle->
buf[1] = (4 + 3) / 256;
843 handle->
buf[2] = (4 + 3) % 256;
844 handle->
buf[3] = 0x01;
845 handle->
buf[4] = 0x00;
846 strncpy((
char *)&handle->
buf[5], (
char *)cmd, 4);
847 for (i = 0; i < 4 + 5; i++)
849 xor_cal ^= handle->
buf[i];
851 handle->
buf[4+5] = xor_cal;
855 handle->
debug_print(
"syn6288: uart flush failed.\n");
862 handle->
debug_print(
"syn6288: uart write failed.\n");
867 len = handle->
uart_read((uint8_t *)&temp, 1);
870 handle->
debug_print(
"syn6288: uart read failed.\n");
880 handle->
debug_print(
"syn6288: command receive failed.\n");
920 handle->
buf[0] = 0xFD;
921 handle->
buf[1] = (5 + 3) / 256;
922 handle->
buf[2] = (5 + 3) % 256;
923 handle->
buf[3] = 0x01;
924 handle->
buf[4] = 0x00;
925 strncpy((
char *)&handle->
buf[5],(
char *)cmd, 5);
926 for (i = 0; i < 5 + 5; i++)
928 xor_cal ^= handle->
buf[i];
930 handle->
buf[5+5] = xor_cal;
934 handle->
debug_print(
"syn6288: uart flush failed.\n");
941 handle->
debug_print(
"syn6288: uart write failed.\n");
946 len = handle->
uart_read((uint8_t *)&temp, 1);
949 handle->
debug_print(
"syn6288: uart read failed.\n");
959 handle->
debug_print(
"syn6288: command receive failed.\n");
993 len = (uint8_t)strlen(text);
996 handle->
debug_print(
"syn6288: text is too long.\n");
1000 handle->
buf[0] = 0xFD;
1001 handle->
buf[1] = (uint8_t)((len + 3) / 256);
1002 handle->
buf[2] = (len + 3) % 256;
1003 handle->
buf[3] = 0x01;
1005 strncpy((
char *)&handle->
buf[5], text, len);
1006 for (i = 0; i < len + 5; i++)
1008 xor_cal ^= handle->
buf[i];
1010 handle->
buf[len+5] = xor_cal;
1014 handle->
debug_print(
"syn6288: uart flush failed.\n");
1021 handle->
debug_print(
"syn6288: uart write failed.\n");
1026 l = handle->
uart_read((uint8_t *)&temp, 1);
1029 handle->
debug_print(
"syn6288: uart read failed.\n");
1039 handle->
debug_print(
"syn6288: command receive failed.\n");
1062 handle->
debug_print(
"syn6288: volume invalid.\n");
1067 memset((
char *)cmd, 0,
sizeof(
char)*8);
1068 (void)snprintf((
char *)cmd, 8,
"v[%d]", (int16_t)volume);
1095 *volume = handle->
volume;
1117 handle->
debug_print(
"syn6288: volume is invalid.\n");
1122 memset((
char *)cmd, 0,
sizeof(
char)*8);
1123 (void)snprintf((
char *)cmd, 8,
"m[%d]", (int16_t)volume);
1172 handle->
debug_print(
"syn6288: speed is invalid.\n");
1177 memset((
char *)cmd, 0,
sizeof(
char)*8);
1178 (void)snprintf((
char *)cmd, 8,
"t[%d]", (int16_t)speed);
1179 handle->
speed = speed;
1205 *speed = handle->
speed;
1227 uint8_t xor_cal = 0;
1238 len = (uint8_t)strlen(command);
1241 handle->
debug_print(
"syn6288: command is too long.\n");
1245 handle->
buf[0] = 0xFD;
1246 handle->
buf[1] = (uint8_t)((len + 3) / 256);
1247 handle->
buf[2] = (len + 3) % 256;
1248 handle->
buf[3] = 0x01;
1249 handle->
buf[4] = 0x00;
1250 strncpy((
char *)&handle->
buf[5], command, len);
1251 for (i = 0; i < len + 5; i++)
1253 xor_cal ^= handle->
buf[i];
1255 handle->
buf[len + 5] = xor_cal;
1259 handle->
debug_print(
"syn6288: uart flush failed.\n");
1266 handle->
debug_print(
"syn6288: uart write failed.\n");
1271 l = handle->
uart_read((uint8_t *)&temp, 1);
1274 handle->
debug_print(
"syn6288: uart read failed.\n");
1284 handle->
debug_print(
"syn6288: command receive failed.\n");
#define SUPPLY_VOLTAGE_MAX
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define CHIP_NAME
chip information definition
driver syn6288 header file
uint8_t syn6288_get_mode(syn6288_handle_t *handle, syn6288_mode_t *mode)
get the chip mode
uint8_t syn6288_set_background_volume(syn6288_handle_t *handle, uint8_t volume)
set the synthesis background volume
syn6288_mode_t
syn6288 mode enumeration definition
uint8_t syn6288_set_baud_rate(syn6288_handle_t *handle, syn6288_baud_rate_t rate)
set the baud rate
syn6288_baud_rate_t
syn6288 baud rate enumeration definition
uint8_t syn6288_get_background_volume(syn6288_handle_t *handle, uint8_t *volume)
get the chip synthesis background volume
uint8_t syn6288_get_synthesis_volume(syn6288_handle_t *handle, uint8_t *volume)
get the chip synthesis volume
uint8_t syn6288_set_synthesis_volume(syn6288_handle_t *handle, uint8_t volume)
set the chip synthesis volume
uint8_t syn6288_get_baud_rate(syn6288_handle_t *handle, syn6288_baud_rate_t *rate)
get the baud rate
uint8_t syn6288_set_synthesis_speed(syn6288_handle_t *handle, uint8_t speed)
set the synthesis speed
uint8_t syn6288_get_synthesis_speed(syn6288_handle_t *handle, uint8_t *speed)
get the synthesis speed
uint8_t syn6288_set_mode(syn6288_handle_t *handle, syn6288_mode_t mode)
set the chip mode
@ SYN6288_BAUD_RATE_38400_BPS
@ SYN6288_BAUD_RATE_9600_BPS
@ SYN6288_BAUD_RATE_19200_BPS
uint8_t syn6288_init(syn6288_handle_t *handle)
initialize the chip
syn6288_type_t
syn6288 type enumeration definition
uint8_t syn6288_power_down(syn6288_handle_t *handle)
power down the chip
uint8_t syn6288_synthesis_sound(syn6288_handle_t *handle, syn6288_sound_t sound)
synthesis the sound
uint8_t syn6288_stop(syn6288_handle_t *handle)
stop the chip
syn6288_ring_t
syn6288 ring enumeration definition
syn6288_status_t
syn6288 status enumeration definition
syn6288_sound_t
syn6288 sound enumeration definition
uint8_t syn6288_get_status(syn6288_handle_t *handle, syn6288_status_t *status)
get the current status
uint8_t syn6288_get_text_type(syn6288_handle_t *handle, syn6288_type_t *type)
get the chip text type
uint8_t syn6288_set_text_type(syn6288_handle_t *handle, syn6288_type_t type)
set the chip text type
uint8_t syn6288_synthesis_message(syn6288_handle_t *handle, syn6288_message_t message)
synthesis the message
uint8_t syn6288_deinit(syn6288_handle_t *handle)
close the chip
uint8_t syn6288_synthesis_text(syn6288_handle_t *handle, char *text)
synthesis the test
uint8_t syn6288_resume(syn6288_handle_t *handle)
resume the chip
syn6288_message_t
syn6288 message enumeration definition
uint8_t syn6288_synthesis_ring(syn6288_handle_t *handle, syn6288_ring_t ring)
synthesis the ring
uint8_t syn6288_info(syn6288_info_t *info)
get chip's information
uint8_t syn6288_pause(syn6288_handle_t *handle)
pause the chip
uint8_t syn6288_set_command(syn6288_handle_t *handle, char *command)
send the command to the chip
syn6288 handle structure definition
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)
syn6288 information structure definition
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v