diff --git a/.gitignore b/.gitignore index 8b1112e..128bb0a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ WpfApp1/WpfApp1/obj/* WpfApp1/WpfApp1/bin/* GD32F103C8T6/App/Output/* GD32F103C8T6/Bootloader/Output/* -GD32F103C8T6/._GD32F10x.emProject +*.emProject *.emSession *.jlink ._* \ No newline at end of file diff --git a/GD32F103C8T6/App/User/Peripheral/Api/api.h b/GD32F103C8T6/App/User/Peripheral/Api/api.h index e550350..a648016 100644 --- a/GD32F103C8T6/App/User/Peripheral/Api/api.h +++ b/GD32F103C8T6/App/User/Peripheral/Api/api.h @@ -22,7 +22,7 @@ #define API_FRAME_RESPONSE (0x01) /* 响应帧 */ #define API_FRAME_NOTIFICATION (0x02) /* 通知帧 */ -#define SOFTWARE_VERSION ("V1.28") +#define SOFTWARE_VERSION ("V1.29") #define HARDWARE_VERSION ("V1.01") extern uint8_t api_upgrade_mode; diff --git a/GD32F103C8T6/App/User/Peripheral/QGEL50X/qgel50x.c b/GD32F103C8T6/App/User/Peripheral/QGEL50X/qgel50x.c deleted file mode 100644 index 3b8fe10..0000000 --- a/GD32F103C8T6/App/User/Peripheral/QGEL50X/qgel50x.c +++ /dev/null @@ -1,328 +0,0 @@ -#include "qgel50x.h" - -#ifdef USE_QGEL50X - -/* 0: 未播放; 1: 正在播放 */ -static uint8_t qgel50x_status = 0; /* 播放状态(模块) */ -static uint8_t qgel50x_play_status = 0; /* 播放状态(用户) */ - -static uint8_t qgel50x_send_count = 0; - -static uint8_t qgel50x_status_stop_try_count = 0; -static uint8_t qgel50x_status_playing_try_count = 0; - -static uint8_t qgel50x_door_opening_warning_task_uuid = 0; -static uint8_t qgel50x_left_turn_warning_task_uuid = 0; -static uint8_t qgel50x_right_turn_warning_task_uuid = 0; -static uint8_t qgel50x_reverse_warning_task_uuid = 0; -static uint8_t qgel50x_arrival_warning_task_uuid = 0; -static uint8_t qgel50x_departure_warning_task_uuid = 0; -static uint8_t qgel50x_please_note_that_task_uuid = 0; - -static void qgel50x_door_opening_warning_task(uint8_t uuid); -static void qgel50x_left_turn_warning_task(uint8_t uuid); -static void qgel50x_right_turn_warning_task(uint8_t uuid); -static void qgel50x_reverse_warning_task(uint8_t uuid); -static void qgel50x_arrival_warning_task(uint8_t uuid); -static void qgel50x_departure_warning_task(uint8_t uuid); -static void qgel50x_please_note_that_task(uint8_t uuid); -static void qgel50x_status_parsing_task(uint8_t uuid); - -void qgel50x_init(void) -{ - /* 创建任务, 并挂起 */ - qgel50x_door_opening_warning_task_uuid = task_create(qgel50x_door_opening_warning_task, 200); - task_suspend(qgel50x_door_opening_warning_task_uuid); - - qgel50x_left_turn_warning_task_uuid = task_create(qgel50x_left_turn_warning_task, 200); - task_suspend(qgel50x_left_turn_warning_task_uuid); - - qgel50x_right_turn_warning_task_uuid = task_create(qgel50x_right_turn_warning_task, 200); - task_suspend(qgel50x_right_turn_warning_task_uuid); - - qgel50x_reverse_warning_task_uuid = task_create(qgel50x_reverse_warning_task, 200); - task_suspend(qgel50x_reverse_warning_task_uuid); - - qgel50x_arrival_warning_task_uuid = task_create(qgel50x_arrival_warning_task, 200); - task_suspend(qgel50x_arrival_warning_task_uuid); - - qgel50x_departure_warning_task_uuid = task_create(qgel50x_departure_warning_task, 200); - task_suspend(qgel50x_departure_warning_task_uuid); - - qgel50x_please_note_that_task_uuid = task_create(qgel50x_please_note_that_task, 100); - task_suspend(qgel50x_please_note_that_task_uuid); - - task_create(qgel50x_status_parsing_task, 10); -} - -void qgel50x_send_pulse(uint8_t count) -{ - for (uint8_t i = 0; i < count; i++) - { - gpio_bit_write(QGEL50X_TG1_PERIPH, QGEL50X_TG1_PIN, SET); - delay_us(100); - gpio_bit_write(QGEL50X_TG1_PERIPH, QGEL50X_TG1_PIN, RESET); - delay_us(100); - } -} - -/** - * @brief 音量 + - */ -void qgel50x_volume_up(void) -{ - qgel50x_send_pulse(3); -} - -/** - * @brief 音量 - - */ -void qgel50x_volume_down(void) -{ - qgel50x_send_pulse(4); -} - -/** - * @brief 停止播放 - */ -void qgel50x_stop(void) -{ - /* 停止 */ - qgel50x_send_pulse(1); - - delay_ms(100); - - qgel50x_play_status = 0; - - /* 挂起任务 */ - task_suspend(qgel50x_door_opening_warning_task_uuid); - task_suspend(qgel50x_left_turn_warning_task_uuid); - task_suspend(qgel50x_right_turn_warning_task_uuid); - task_suspend(qgel50x_reverse_warning_task_uuid); - task_suspend(qgel50x_arrival_warning_task_uuid); - task_suspend(qgel50x_departure_warning_task_uuid); - task_suspend(qgel50x_please_note_that_task_uuid); -} - -/** - * @brief 开门预警 - */ -void qgel50x_door_opening_warning(void) -{ - task_resume(qgel50x_door_opening_warning_task_uuid); -} - -void qgel50x_left_turn_warning(void) -{ - task_resume(qgel50x_left_turn_warning_task_uuid); -} - -void qgel50x_right_turn_warning(void) -{ - task_resume(qgel50x_right_turn_warning_task_uuid); -} - -void qgel50x_reverse_warning(void) -{ - task_resume(qgel50x_reverse_warning_task_uuid); -} - -void qgel50x_arrival_warning(void) -{ - task_resume(qgel50x_arrival_warning_task_uuid); -} - -void qgel50x_departure_warning(void) -{ - //task_resume(qgel50x_status_parsing_task_uuid); -} - -void qgel50x_please_note_that(void) -{ - /* 开始任务 */ - task_resume(qgel50x_please_note_that_task_uuid); -} - -static void qgel50x_door_opening_warning_task(uint8_t uuid) -{ - /* 默认以200ms间隔检测 */ - task_set_frequency(uuid, 200); - - /* 未播放语音 */ - if(qgel50x_status == 0) - { - if(qgel50x_play_status == 0) - { - /* 车辆上下客,请勿靠近 */ - qgel50x_send_pulse(27); - - /* 正在播放, 此时 模块状态 应为 1 */ - qgel50x_play_status = 1; - } - else - { - /* 未播放 */ - qgel50x_play_status = 0; - - task_set_frequency(uuid, 2000); - } - } -} - -static void qgel50x_left_turn_warning_task(uint8_t uuid) -{ - /* 默认以200ms间隔检测 */ - task_set_frequency(uuid, 200); - - /* 未播放语音 */ - if(qgel50x_status == 0) - { - if(qgel50x_play_status == 0) - { - /* 车辆左转,请注意避让 */ - qgel50x_send_pulse(31); - - /* 正在播放, 此时 模块状态 应为 1 */ - qgel50x_play_status = 1; - } - else - { - /* 未播放 */ - qgel50x_play_status = 0; - - task_set_frequency(uuid, 2000); - } - } -} - -void qgel50x_right_turn_warning_task(uint8_t uuid) -{ - /* 默认以200ms间隔检测 */ - task_set_frequency(uuid, 200); - - /* 未播放语音 */ - if(qgel50x_status == 0) - { - if(qgel50x_play_status == 0) - { - /* 车辆右转,请注意避让 */ - qgel50x_send_pulse(30); - - /* 正在播放, 此时 模块状态 应为 1 */ - qgel50x_play_status = 1; - } - else - { - /* 未播放 */ - qgel50x_play_status = 0; - - task_set_frequency(uuid, 2000); - } - } -} - -void qgel50x_reverse_warning_task(uint8_t uuid) -{ - /* 默认以200ms间隔检测 */ - task_set_frequency(uuid, 200); - - /* 未播放语音 */ - if(qgel50x_status == 0) - { - if(qgel50x_play_status == 0) - { - /* 倒车,请注意避让 */ - qgel50x_send_pulse(28); - - /* 正在播放, 此时 模块状态 应为 1 */ - qgel50x_play_status = 1; - } - else - { - /* 未播放 */ - qgel50x_play_status = 0; - - task_set_frequency(uuid, 2000); - } - } -} - -static void qgel50x_arrival_warning_task(uint8_t uuid) -{ - /* 默认以200ms间隔检测 */ - task_set_frequency(uuid, 200); - - /* 未播放语音 */ - if(qgel50x_status == 0) - { - if(qgel50x_play_status == 0) - { - /* 车辆进站,请注意 */ - qgel50x_send_pulse(26); - - /* 正在播放, 此时 模块状态 应为 1 */ - qgel50x_play_status = 1; - } - else - { - /* 未播放 */ - qgel50x_play_status = 0; - - task_set_frequency(uuid, 2000); - } - } -} - -static void qgel50x_departure_warning_task(uint8_t uuid) -{ -} - -static void qgel50x_please_note_that_task(uint8_t uuid) -{ - qgel50x_send_count++; - - switch (qgel50x_send_count) - { - case 1: - qgel50x_send_pulse(15); /* 请 */ - task_set_frequency(uuid, 300); - break; - case 2: - qgel50x_send_pulse(16); /* 注意 */ - task_set_frequency(uuid, 500); - break; - case 3: - qgel50x_send_count = 0; - task_set_frequency(uuid, 2000); - break; - } -} - -static void qgel50x_status_parsing_task(uint8_t uuid) -{ - /* 正在播放 */ - if(gpio_input_bit_get(QGEL50X_TG4_PERIPH, QGEL50X_TG4_PIN) == SET) - { - qgel50x_status_playing_try_count++; - - if(qgel50x_status_playing_try_count > 4) - { - qgel50x_status = SET; - - qgel50x_status_playing_try_count = 0; - } - } - else - { - qgel50x_status_stop_try_count++; - - if(qgel50x_status_stop_try_count > 4) - { - qgel50x_status = RESET; - - qgel50x_status_stop_try_count = 0; - } - } -} - -#endif \ No newline at end of file diff --git a/GD32F103C8T6/App/User/Peripheral/QGEL50X/qgel50x.h b/GD32F103C8T6/App/User/Peripheral/QGEL50X/qgel50x.h deleted file mode 100644 index 4bfd981..0000000 --- a/GD32F103C8T6/App/User/Peripheral/QGEL50X/qgel50x.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef QGEL50X_H -#define QGEL50X_H - -#include "main.h" - -#ifdef USE_QGEL50X - -void qgel50x_init(void); -void qgel50x_send_pulse(uint8_t count); - -void qgel50x_volume_up(void); -void qgel50x_volume_down(void); -void qgel50x_stop(void); -void qgel50x_door_opening_warning(void); -void qgel50x_left_turn_warning(void); -void qgel50x_right_turn_warning(void); -void qgel50x_reverse_warning(void); -void qgel50x_arrival_warning(void); -void qgel50x_departure_warning(void); -void qgel50x_please_note_that(void); - -#endif - -#endif \ No newline at end of file diff --git a/GD32F103C8T6/App/User/Peripheral/V58/v58.c b/GD32F103C8T6/App/User/Peripheral/V58/v58.c deleted file mode 100644 index 1a4753d..0000000 --- a/GD32F103C8T6/App/User/Peripheral/V58/v58.c +++ /dev/null @@ -1,326 +0,0 @@ -#include "v58.h" - -/* 0: 未播放; 1: 正在播放 */ -static uint8_t v58_status = 0; /* 播放状态(模块) */ -static uint8_t v58_play_status = 0; /* 播放状态(用户) */ - -static uint8_t v58_send_count = 0; - -static uint8_t v58_status_stop_try_count = 0; -static uint8_t v58_status_playing_try_count = 0; - -static uint8_t v58_door_opening_warning_task_uuid = 0; -static uint8_t v58_left_turn_warning_task_uuid = 0; -static uint8_t v58_right_turn_warning_task_uuid = 0; -static uint8_t v58_reverse_warning_task_uuid = 0; -static uint8_t v58_arrival_warning_task_uuid = 0; -static uint8_t v58_departure_warning_task_uuid = 0; -static uint8_t v58_please_note_that_task_uuid = 0; - -static void v58_door_opening_warning_task(uint8_t uuid); -static void v58_left_turn_warning_task(uint8_t uuid); -static void v58_right_turn_warning_task(uint8_t uuid); -static void v58_reverse_warning_task(uint8_t uuid); -static void v58_arrival_warning_task(uint8_t uuid); -static void v58_departure_warning_task(uint8_t uuid); -static void v58_please_note_that_task(uint8_t uuid); -static void v58_status_parsing_task(uint8_t uuid); - -void v58_init(void) -{ - /* 创建任务, 并挂起 */ - v58_door_opening_warning_task_uuid = task_create(v58_door_opening_warning_task, 200); - task_suspend(v58_door_opening_warning_task_uuid); - - v58_left_turn_warning_task_uuid = task_create(v58_left_turn_warning_task, 200); - task_suspend(v58_left_turn_warning_task_uuid); - - v58_right_turn_warning_task_uuid = task_create(v58_right_turn_warning_task, 200); - task_suspend(v58_right_turn_warning_task_uuid); - - v58_reverse_warning_task_uuid = task_create(v58_reverse_warning_task, 200); - task_suspend(v58_reverse_warning_task_uuid); - - v58_arrival_warning_task_uuid = task_create(v58_arrival_warning_task, 200); - task_suspend(v58_arrival_warning_task_uuid); - - v58_departure_warning_task_uuid = task_create(v58_departure_warning_task, 200); - task_suspend(v58_departure_warning_task_uuid); - - v58_please_note_that_task_uuid = task_create(v58_please_note_that_task, 100); - task_suspend(v58_please_note_that_task_uuid); - - task_create(v58_status_parsing_task, 10); -} - -void v58_send_pulse(uint8_t count) -{ - for (uint8_t i = 0; i < count; i++) - { - gpio_bit_write(V58_DATA_PERIPH, V58_DATA_PIN, SET); - delay_us(100); - gpio_bit_write(V58_DATA_PERIPH, V58_DATA_PIN, RESET); - delay_us(100); - } -} - -/** - * @brief 音量 + - */ -void v58_volume_up(void) -{ - v58_send_pulse(2); -} - -/** - * @brief 音量 - - */ -void v58_volume_down(void) -{ - v58_send_pulse(3); -} - -/** - * @brief 停止播放 - */ -void v58_stop(void) -{ - delay_ms(100); - - /* 停止 */ - v58_send_pulse(1); - - delay_ms(100); - - v58_play_status = 0; - - /* 挂起任务 */ - task_suspend(v58_door_opening_warning_task_uuid); - task_suspend(v58_left_turn_warning_task_uuid); - task_suspend(v58_right_turn_warning_task_uuid); - task_suspend(v58_reverse_warning_task_uuid); - task_suspend(v58_arrival_warning_task_uuid); - task_suspend(v58_departure_warning_task_uuid); - task_suspend(v58_please_note_that_task_uuid); -} - -/** - * @brief 开门预警 - */ -void v58_door_opening_warning(void) -{ - task_resume(v58_door_opening_warning_task_uuid); -} - -void v58_left_turn_warning(void) -{ - task_resume(v58_left_turn_warning_task_uuid); -} - -void v58_right_turn_warning(void) -{ - task_resume(v58_right_turn_warning_task_uuid); -} - -void v58_reverse_warning(void) -{ - task_resume(v58_reverse_warning_task_uuid); -} - -void v58_arrival_warning(void) -{ - task_resume(v58_arrival_warning_task_uuid); -} - -void v58_departure_warning(void) -{ - // task_resume(v58_status_parsing_task_uuid); -} - -void v58_please_note_that(void) -{ - /* 开始任务 */ - task_resume(v58_please_note_that_task_uuid); -} - -static void v58_door_opening_warning_task(uint8_t uuid) -{ - /* 默认以200ms间隔检测 */ - task_set_frequency(uuid, 200); - - /* 未播放语音 */ - if (v58_status == 0) - { - if (v58_play_status == 0) - { - /* 车辆上下客,请勿靠近 */ - v58_send_pulse(8); - - /* 正在播放, 此时 模块状态 应为 1 */ - v58_play_status = 1; - } - else - { - /* 未播放 */ - v58_play_status = 0; - - task_set_frequency(uuid, 2000); - } - } -} - -static void v58_left_turn_warning_task(uint8_t uuid) -{ - /* 默认以200ms间隔检测 */ - task_set_frequency(uuid, 200); - - /* 未播放语音 */ - if (v58_status == 0) - { - if (v58_play_status == 0) - { - /* 车辆左转,请注意避让 */ - v58_send_pulse(10); - - /* 正在播放, 此时 模块状态 应为 1 */ - v58_play_status = 1; - } - else - { - /* 未播放 */ - v58_play_status = 0; - - task_set_frequency(uuid, 2000); - } - } -} - -void v58_right_turn_warning_task(uint8_t uuid) -{ - /* 默认以200ms间隔检测 */ - task_set_frequency(uuid, 200); - - /* 未播放语音 */ - if (v58_status == 0) - { - if (v58_play_status == 0) - { - /* 车辆右转,请注意避让 */ - v58_send_pulse(9); - - /* 正在播放, 此时 模块状态 应为 1 */ - v58_play_status = 1; - } - else - { - /* 未播放 */ - v58_play_status = 0; - - task_set_frequency(uuid, 2000); - } - } -} - -void v58_reverse_warning_task(uint8_t uuid) -{ - /* 默认以200ms间隔检测 */ - task_set_frequency(uuid, 200); - - /* 未播放语音 */ - if (v58_status == 0) - { - if (v58_play_status == 0) - { - /* 倒车,请注意避让 */ - v58_send_pulse(13); - - /* 正在播放, 此时 模块状态 应为 1 */ - v58_play_status = 1; - } - else - { - /* 未播放 */ - v58_play_status = 0; - - task_set_frequency(uuid, 2000); - } - } -} - -static void v58_arrival_warning_task(uint8_t uuid) -{ - /* 默认以200ms间隔检测 */ - task_set_frequency(uuid, 200); - - /* 未播放语音 */ - if (v58_status == 0) - { - if (v58_play_status == 0) - { - /* 车辆进站,请注意 */ - v58_send_pulse(7); - - /* 正在播放, 此时 模块状态 应为 1 */ - v58_play_status = 1; - } - else - { - /* 未播放 */ - v58_play_status = 0; - - task_set_frequency(uuid, 2000); - } - } -} - -static void v58_departure_warning_task(uint8_t uuid) -{ -} - -static void v58_please_note_that_task(uint8_t uuid) -{ - v58_send_count++; - - switch (v58_send_count) - { - case 1: - v58_send_pulse(19); /* 请 */ - task_set_frequency(uuid, 360); - break; - case 2: - v58_send_pulse(39); /* 注意 */ - task_set_frequency(uuid, 450); - break; - case 3: - v58_send_count = 0; - task_set_frequency(uuid, 2000); - break; - } -} - -static void v58_status_parsing_task(uint8_t uuid) -{ - /* 正在播放 */ - if (gpio_input_bit_get(V58_STATUS_PERIPH, V58_STATUS_PIN) == SET) - { - v58_status_playing_try_count++; - - if (v58_status_playing_try_count > 4) - { - v58_status = SET; - - v58_status_playing_try_count = 0; - } - } - else - { - v58_status_stop_try_count++; - - if (v58_status_stop_try_count > 4) - { - v58_status = RESET; - - v58_status_stop_try_count = 0; - } - } -} \ No newline at end of file diff --git a/GD32F103C8T6/App/User/Peripheral/V58/v58.h b/GD32F103C8T6/App/User/Peripheral/V58/v58.h deleted file mode 100644 index d793918..0000000 --- a/GD32F103C8T6/App/User/Peripheral/V58/v58.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __V58_H -#define __V58_H - -#include "main.h" - -void v58_init(void); -void v58_send_pulse(uint8_t count); -void v58_volume_up(void); -void v58_volume_down(void); -void v58_stop(void); -void v58_door_opening_warning(void); -void v58_left_turn_warning(void); -void v58_right_turn_warning(void); -void v58_reverse_warning(void); -void v58_arrival_warning(void); -void v58_departure_warning(void); -void v58_please_note_that(void); - -#endif \ No newline at end of file diff --git a/GD32F103C8T6/App/User/Peripheral/WT588FxxA/wt588fxxa.c b/GD32F103C8T6/App/User/Peripheral/WT588FxxA/wt588fxxa.c new file mode 100644 index 0000000..72d850c --- /dev/null +++ b/GD32F103C8T6/App/User/Peripheral/WT588FxxA/wt588fxxa.c @@ -0,0 +1,371 @@ +#include "wt588fxxa.h" + +// /* 0: 未播放; 1: 正在播放 */ +// static uint8_t wt588fxxa_status = 0; /* 播放状态(模块) */ +// static uint8_t wt588fxxa_play_status = 0; /* 播放状态(用户) */ + +// static uint8_t wt588fxxa_send_count = 0; + +// static uint8_t wt588fxxa_status_stop_try_count = 0; +// static uint8_t wt588fxxa_status_playing_try_count = 0; + +// static uint8_t wt588fxxa_door_opening_warning_task_uuid = 0; +// static uint8_t wt588fxxa_left_turn_warning_task_uuid = 0; +// static uint8_t wt588fxxa_right_turn_warning_task_uuid = 0; +// static uint8_t wt588fxxa_reverse_warning_task_uuid = 0; +// static uint8_t wt588fxxa_arrival_warning_task_uuid = 0; +// static uint8_t wt588fxxa_departure_warning_task_uuid = 0; +// static uint8_t wt588fxxa_please_note_that_task_uuid = 0; + +// static void wt588fxxa_door_opening_warning_task(uint8_t uuid); +// static void wt588fxxa_left_turn_warning_task(uint8_t uuid); +// static void wt588fxxa_right_turn_warning_task(uint8_t uuid); +// static void wt588fxxa_reverse_warning_task(uint8_t uuid); +// static void wt588fxxa_arrival_warning_task(uint8_t uuid); +// static void wt588fxxa_departure_warning_task(uint8_t uuid); +// static void wt588fxxa_please_note_that_task(uint8_t uuid); +// static void wt588fxxa_status_parsing_task(uint8_t uuid); + +void wt588fxxa_init(void) +{ + ///* 创建任务, 并挂起 */ + //wt588fxxa_door_opening_warning_task_uuid = task_create(wt588fxxa_door_opening_warning_task, 200); + //task_suspend(wt588fxxa_door_opening_warning_task_uuid); + + //wt588fxxa_left_turn_warning_task_uuid = task_create(wt588fxxa_left_turn_warning_task, 200); + //task_suspend(wt588fxxa_left_turn_warning_task_uuid); + + //wt588fxxa_right_turn_warning_task_uuid = task_create(wt588fxxa_right_turn_warning_task, 200); + //task_suspend(wt588fxxa_right_turn_warning_task_uuid); + + //wt588fxxa_reverse_warning_task_uuid = task_create(wt588fxxa_reverse_warning_task, 200); + //task_suspend(wt588fxxa_reverse_warning_task_uuid); + + //wt588fxxa_arrival_warning_task_uuid = task_create(wt588fxxa_arrival_warning_task, 200); + //task_suspend(wt588fxxa_arrival_warning_task_uuid); + + //wt588fxxa_departure_warning_task_uuid = task_create(wt588fxxa_departure_warning_task, 200); + //task_suspend(wt588fxxa_departure_warning_task_uuid); + + //wt588fxxa_please_note_that_task_uuid = task_create(wt588fxxa_please_note_that_task, 100); + //task_suspend(wt588fxxa_please_note_that_task_uuid); + + //task_create(wt588fxxa_status_parsing_task, 10); + + //wt588fxxa_send_pulse(0x1D); +} + +void wt588fxxa_send_pulse(uint8_t count) +{ + // for (uint8_t i = 0; i < count; i++) + // { + // gpio_bit_write(wt588fxxa_DATA_PERIPH, wt588fxxa_DATA_PIN, SET); + // delay_us(100); + // gpio_bit_write(wt588fxxa_DATA_PERIPH, wt588fxxa_DATA_PIN, RESET); + // delay_us(100); + // } + + uint8_t S_DATA; + uint8_t B_DATA; + S_DATA = count; + //P_DATA = 0; + gpio_bit_write(WT588FXXA_DATA_PERIPH, WT588FXXA_DATA_PIN, RESET); + delay_ms(5); // 延时 5ms + B_DATA = S_DATA & 0X01; + for (uint8_t j = 0; j < 8; j++) + { + if (B_DATA == 1) + { + //P_DATA = 1; + gpio_bit_write(WT588FXXA_DATA_PERIPH, WT588FXXA_DATA_PIN, SET); + delay_us(600); // 延时 600us + //P_DATA = 0; + gpio_bit_write(WT588FXXA_DATA_PERIPH, WT588FXXA_DATA_PIN, RESET); + delay_us(200); // 延时 200us + } + else + { + //P_DATA = 1; + gpio_bit_write(WT588FXXA_DATA_PERIPH, WT588FXXA_DATA_PIN, SET); + delay_us(200); // 延时 200us + //P_DATA = 0; + gpio_bit_write(WT588FXXA_DATA_PERIPH, WT588FXXA_DATA_PIN, RESET); + delay_us(600); // 延时 600us + } + S_DATA = S_DATA >> 1; + B_DATA = S_DATA & 0X01; + } + //P_DATA = 1; + gpio_bit_write(WT588FXXA_DATA_PERIPH, WT588FXXA_DATA_PIN, SET); + + delay_ms(2); +} + +/** + * @brief 音量 + + */ +void wt588fxxa_volume_up(void) +{ + //wt588fxxa_send_pulse(2); +} + +/** + * @brief 音量 - + */ +void wt588fxxa_volume_down(void) +{ + //wt588fxxa_send_pulse(3); +} + +/** + * @brief 停止播放 + */ +void wt588fxxa_stop(void) +{ + delay_ms(100); + + /* 停止 */ + wt588fxxa_send_pulse(0xFE); + + delay_ms(100); + + //wt588fxxa_play_status = 0; + + ///* 挂起任务 */ + //task_suspend(wt588fxxa_door_opening_warning_task_uuid); + //task_suspend(wt588fxxa_left_turn_warning_task_uuid); + //task_suspend(wt588fxxa_right_turn_warning_task_uuid); + //task_suspend(wt588fxxa_reverse_warning_task_uuid); + //task_suspend(wt588fxxa_arrival_warning_task_uuid); + //task_suspend(wt588fxxa_departure_warning_task_uuid); + //task_suspend(wt588fxxa_please_note_that_task_uuid); +} + +/** + * @brief 开门预警 + */ +void wt588fxxa_door_opening_warning(void) +{ + //task_resume(wt588fxxa_door_opening_warning_task_uuid); + wt588fxxa_send_pulse(0x06); + wt588fxxa_send_pulse(0xF2); +} + +void wt588fxxa_left_turn_warning(void) +{ + //task_resume(wt588fxxa_left_turn_warning_task_uuid); + wt588fxxa_send_pulse(0x08); + wt588fxxa_send_pulse(0xF2); +} + +void wt588fxxa_right_turn_warning(void) +{ + //task_resume(wt588fxxa_right_turn_warning_task_uuid); + wt588fxxa_send_pulse(0x07); + wt588fxxa_send_pulse(0xF2); +} + +void wt588fxxa_reverse_warning(void) +{ + //task_resume(wt588fxxa_reverse_warning_task_uuid); + wt588fxxa_send_pulse(0x0B); + wt588fxxa_send_pulse(0xF2); +} + +void wt588fxxa_arrival_warning(void) +{ + wt588fxxa_send_pulse(0x05); + wt588fxxa_send_pulse(0xF2); +} + +void wt588fxxa_departure_warning(void) +{ +} + +void wt588fxxa_please_note_that(void) +{ + // /* 开始任务 */ + // task_resume(wt588fxxa_please_note_that_task_uuid); +} + +// static void wt588fxxa_door_opening_warning_task(uint8_t uuid) +// { +// /* 默认以200ms间隔检测 */ +// task_set_frequency(uuid, 200); + +// /* 未播放语音 */ +// if (wt588fxxa_status == 0) +// { +// if (wt588fxxa_play_status == 0) +// { +// /* 车辆上下客,请勿靠近 */ +// wt588fxxa_send_pulse(0x06); + +// /* 正在播放, 此时 模块状态 应为 1 */ +// wt588fxxa_play_status = 1; +// } +// else +// { +// /* 未播放 */ +// wt588fxxa_play_status = 0; + +// task_set_frequency(uuid, 2000); +// } +// } +// } + +// static void wt588fxxa_left_turn_warning_task(uint8_t uuid) +// { +// /* 默认以200ms间隔检测 */ +// task_set_frequency(uuid, 200); + +// /* 未播放语音 */ +// if (wt588fxxa_status == 0) +// { +// if (wt588fxxa_play_status == 0) +// { +// /* 车辆左转,请注意避让 */ +// wt588fxxa_send_pulse(0x08); + +// /* 正在播放, 此时 模块状态 应为 1 */ +// wt588fxxa_play_status = 1; +// } +// else +// { +// /* 未播放 */ +// wt588fxxa_play_status = 0; + +// task_set_frequency(uuid, 2000); +// } +// } +// } + +// void wt588fxxa_right_turn_warning_task(uint8_t uuid) +// { +// /* 默认以200ms间隔检测 */ +// task_set_frequency(uuid, 200); + +// /* 未播放语音 */ +// if (wt588fxxa_status == 0) +// { +// if (wt588fxxa_play_status == 0) +// { +// /* 车辆右转,请注意避让 */ +// wt588fxxa_send_pulse(0x07); + +// /* 正在播放, 此时 模块状态 应为 1 */ +// wt588fxxa_play_status = 1; +// } +// else +// { +// /* 未播放 */ +// wt588fxxa_play_status = 0; + +// task_set_frequency(uuid, 2000); +// } +// } +// } + +// void wt588fxxa_reverse_warning_task(uint8_t uuid) +// { +// /* 默认以200ms间隔检测 */ +// task_set_frequency(uuid, 200); + +// /* 未播放语音 */ +// if (wt588fxxa_status == 0) +// { +// if (wt588fxxa_play_status == 0) +// { +// /* 倒车,请注意避让 */ +// wt588fxxa_send_pulse(0x0B); + +// /* 正在播放, 此时 模块状态 应为 1 */ +// wt588fxxa_play_status = 1; +// } +// else +// { +// /* 未播放 */ +// wt588fxxa_play_status = 0; + +// task_set_frequency(uuid, 2000); +// } +// } +// } + +// static void wt588fxxa_arrival_warning_task(uint8_t uuid) +// { +// /* 默认以200ms间隔检测 */ +// task_set_frequency(uuid, 200); + +// /* 未播放语音 */ +// if (wt588fxxa_status == 0) +// { +// if (wt588fxxa_play_status == 0) +// { +// /* 车辆进站,请注意 */ +// wt588fxxa_send_pulse(0x05); + +// /* 正在播放, 此时 模块状态 应为 1 */ +// wt588fxxa_play_status = 1; +// } +// else +// { +// /* 未播放 */ +// wt588fxxa_play_status = 0; + +// task_set_frequency(uuid, 2000); +// } +// } +// } + +// static void wt588fxxa_departure_warning_task(uint8_t uuid) +// { +// } + +// static void wt588fxxa_please_note_that_task(uint8_t uuid) +// { +// wt588fxxa_send_count++; + +// switch (wt588fxxa_send_count) +// { +// case 1: +// wt588fxxa_send_pulse(19); /* 请 */ +// task_set_frequency(uuid, 360); +// break; +// case 2: +// wt588fxxa_send_pulse(39); /* 注意 */ +// task_set_frequency(uuid, 450); +// break; +// case 3: +// wt588fxxa_send_count = 0; +// task_set_frequency(uuid, 2000); +// break; +// } +// } + +// static void wt588fxxa_status_parsing_task(uint8_t uuid) +// { +// /* 正在播放 */ +// if (gpio_input_bit_get(V58_STATUS_PERIPH, V58_STATUS_PIN) == RESET) +// { +// wt588fxxa_status_playing_try_count++; + +// if (wt588fxxa_status_playing_try_count > 4) +// { +// wt588fxxa_status = SET; + +// wt588fxxa_status_playing_try_count = 0; +// } +// } +// else +// { +// wt588fxxa_status_stop_try_count++; + +// if (wt588fxxa_status_stop_try_count > 4) +// { +// wt588fxxa_status = RESET; + +// wt588fxxa_status_stop_try_count = 0; +// } +// } +// } \ No newline at end of file diff --git a/GD32F103C8T6/App/User/Peripheral/WT588FxxA/wt588fxxa.h b/GD32F103C8T6/App/User/Peripheral/WT588FxxA/wt588fxxa.h new file mode 100644 index 0000000..61fafb5 --- /dev/null +++ b/GD32F103C8T6/App/User/Peripheral/WT588FxxA/wt588fxxa.h @@ -0,0 +1,19 @@ +#ifndef __WT588FXXA_H +#define __WT588FXXA_H + +#include "main.h" + +void wt588fxxa_init(void); +void wt588fxxa_send_pulse(uint8_t count); +void wt588fxxa_volume_up(void); +void wt588fxxa_volume_down(void); +void wt588fxxa_stop(void); +void wt588fxxa_door_opening_warning(void); +void wt588fxxa_left_turn_warning(void); +void wt588fxxa_right_turn_warning(void); +void wt588fxxa_reverse_warning(void); +void wt588fxxa_arrival_warning(void); +void wt588fxxa_departure_warning(void); +void wt588fxxa_please_note_that(void); + +#endif \ No newline at end of file diff --git a/GD32F103C8T6/App/User/app.c b/GD32F103C8T6/App/User/app.c index 21d3ed6..a5ee18c 100644 --- a/GD32F103C8T6/App/User/app.c +++ b/GD32F103C8T6/App/User/app.c @@ -148,7 +148,7 @@ void app_init(void) api_init(); /* 语音芯片初始化 */ - v58_init(); + wt588fxxa_init(); m62429_init(); @@ -507,7 +507,7 @@ static void vehicle_status_parsing_task(uint8_t uuid) /* 优先级最高, 如果状态为触发, 关闭语音 */ if (reversing_status == 0) { - v58_stop(); + wt588fxxa_stop(); /* 修改系统当前状态 */ diaodu_status = 0xFF; @@ -554,7 +554,7 @@ static void vehicle_status_parsing_task(uint8_t uuid) if (diaodu_status == 1) { /* 关闭语音 */ - v58_stop(); + wt588fxxa_stop(); /* 重置进站状态 */ diaodu_status_temporry = diaodu_status = 0; @@ -601,7 +601,7 @@ static void vehicle_status_parsing_task(uint8_t uuid) status_type = 4; /* 优先级最高,关闭语音 */ - v58_stop(); + wt588fxxa_stop(); door_status = 0x01; turn_left_status = 0x01; @@ -752,34 +752,34 @@ EXECUTE: strobe_light_reset(); /* 停止语音播报 */ - v58_stop(); + wt588fxxa_stop(); } else { /* 停止语音播报 */ - v58_stop(); + wt588fxxa_stop(); /* 播报语音 */ switch (status_type) { case 0: - v58_door_opening_warning(); + wt588fxxa_door_opening_warning(); break; case 1: - v58_left_turn_warning(); + wt588fxxa_left_turn_warning(); break; case 2: - v58_right_turn_warning(); + wt588fxxa_right_turn_warning(); break; case 3: - v58_reverse_warning(); + wt588fxxa_reverse_warning(); break; case 4: - v58_arrival_warning(); + wt588fxxa_arrival_warning(); break; case 5: @@ -929,7 +929,7 @@ void api_notify_get_can_type(void) void api_notify_send_audio_pulse(uint8_t pulse_count) { - v58_send_pulse(pulse_count); + wt588fxxa_send_pulse(pulse_count); api_response_send_audio_pulse(API_SUCCESS); } @@ -939,26 +939,31 @@ void api_notify_data_forwarding(uint8_t type, uint8_t value) switch (type) { case 0x00: + vehicle_status_trigger_mode = 1; door_front_upload_status = 0x01; door_front_status_temporary = value; break; case 0x01: + vehicle_status_trigger_mode = 1; door_back_upload_status = 0x01; door_back_status_temporary = value; break; case 0x02: + vehicle_status_trigger_mode = 1; turn_left_upload_status = 0x01; turn_left_status_temporary = value; break; case 0x03: + vehicle_status_trigger_mode = 1; turn_right_upload_status = 0x01; turn_right_status_temporary = value; break; case 0x04: + vehicle_status_trigger_mode = 1; reversing_upload_status = 0x01; reversing_status_temporary = value; break; diff --git a/GD32F103C8T6/App/main.c b/GD32F103C8T6/App/main.c index b4898b6..f79f422 100644 --- a/GD32F103C8T6/App/main.c +++ b/GD32F103C8T6/App/main.c @@ -60,10 +60,10 @@ static void bsp_initialization(void) gpio_config(AMP_CTRL_PERIPH, AMP_CTRL_PIN, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, SET); /* DATA 控制脚 初始化 */ - gpio_config(V58_DATA_PERIPH, V58_DATA_PIN, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, RESET); + gpio_config(WT588FXXA_DATA_PERIPH, WT588FXXA_DATA_PIN, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, RESET); /* STATUS 控制脚 初始化 */ - gpio_config(V58_STATUS_PERIPH, V58_STATUS_PIN, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, nullptr); + gpio_config(WT588FXXA_STATUS_PERIPH, WT588FXXA_STATUS_PIN, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, nullptr); iic_config(M62429_SDA_PERIPH, M62429_SDA_PIN, M62429_SCL_PERIPH, M62429_SCL_PIN); diff --git a/GD32F103C8T6/App/main.h b/GD32F103C8T6/App/main.h index 067b29e..85ed7fd 100644 --- a/GD32F103C8T6/App/main.h +++ b/GD32F103C8T6/App/main.h @@ -34,7 +34,7 @@ #include "diaodu.h" #include "setting.h" #include "m62429.h" -#include "v58.h" +#include "wt588fxxa.h" /* 上位机 通讯串口 */ #define HOST_USART_PERIPH USART1 @@ -90,13 +90,13 @@ #define AMP_CTRL_PERIPH GPIOB #define AMP_CTRL_PIN GPIO_PIN_5 -/* V58 DATA 控制脚 */ -#define V58_DATA_PERIPH GPIOA -#define V58_DATA_PIN GPIO_PIN_4 +/* WT588FXXA DATA 控制脚 */ +#define WT588FXXA_DATA_PERIPH GPIOA +#define WT588FXXA_DATA_PIN GPIO_PIN_7 -/* AK517 STATUS 控制脚 */ -#define V58_STATUS_PERIPH GPIOA -#define V58_STATUS_PIN GPIO_PIN_7 +/* WT588FXXA STATUS 控制脚 */ +#define WT588FXXA_STATUS_PERIPH GPIOA +#define WT588FXXA_STATUS_PIN GPIO_PIN_4 #define M62429_SCL_PERIPH GPIOB #define M62429_SCL_PIN GPIO_PIN_10 diff --git a/GD32F103C8T6/GD32F10x.emProject b/GD32F103C8T6/GD32F10x.emProject index f16ce35..b3fcaa2 100644 --- a/GD32F103C8T6/GD32F10x.emProject +++ b/GD32F103C8T6/GD32F10x.emProject @@ -33,7 +33,7 @@ arm_target_device_name="CS32F103C8" arm_target_interface_type="SWD" c_preprocessor_definitions="ARM_MATH_CM3;GD32F10X_MD;USE_STDPERIPH_DRIVER;__GD32F103_SUBFAMILY;__GD32F10X_FAMILY;__NO_FPU_ENABLE" - c_user_include_directories="$(ProjectDir);$(ProjectDir)/CMSIS_5/CMSIS/Core/Include;$(ProjectDir)/User;$(ProjectDir)/User/Peripheral/Api;$(ProjectDir)/User/Peripheral/AK517;$(ProjectDir)/User/Peripheral/CAN;$(ProjectDir)/User/Peripheral/DiaoDu;$(ProjectDir)/User/Peripheral/M62429;$(ProjectDir)/User/Peripheral/QGEL50X;$(ProjectDir)/User/Peripheral/V58;$(ProjectDir)/../../../../arm/GD32F10x/Driver/Include;$(ProjectDir)/../../../../arm/GD32F10x/System/Include;$(ProjectDir)/../../../../arm/GD32F10x/Utils/Byte" + c_user_include_directories="$(ProjectDir);$(ProjectDir)/CMSIS_5/CMSIS/Core/Include;$(ProjectDir)/User;$(ProjectDir)/User/Peripheral/Api;$(ProjectDir)/User/Peripheral/AK517;$(ProjectDir)/User/Peripheral/CAN;$(ProjectDir)/User/Peripheral/DiaoDu;$(ProjectDir)/User/Peripheral/M62429;$(ProjectDir)/User/Peripheral/QGEL50X;$(ProjectDir)/User/Peripheral/V58;$(ProjectDir)/User/Peripheral/WT588FXXA;$(ProjectDir)/../../../../arm/GD32F10x/Driver/Include;$(ProjectDir)/../../../../arm/GD32F10x/System/Include;$(ProjectDir)/../../../../arm/GD32F10x/Utils/Byte" debug_register_definition_file="$(ProjectDir)/GD32F10x_MD_Registers.xml" debug_stack_pointer_start="__stack_end__" debug_start_from_entry_point_symbol="Yes" @@ -41,7 +41,7 @@ gcc_entry_point="Reset_Handler" link_linker_script_file="$(ProjectDir)/GD32F10x_Flash.icf" linker_memory_map_file="$(ProjectDir)/GD32F103C8_MemoryMap.xml" - linker_output_format="hex" + linker_output_format="bin" linker_printf_fp_enabled="Float" linker_section_placements_segments="FLASH1 RX 0x08000000 0x00020000;RAM1 RWX 0x20000000 0x00005000;" macros="DeviceHeaderFile=$(PackagesDir)/GD32F10x/Device/Include/gd32f10x.h;DeviceSystemFile=$(PackagesDir)/GD32F10x/Device/Source/system_gd32f10x.c;DeviceVectorsFile=$(PackagesDir)/GD32F10x/Source/gd32f10x_md_Vectors.s;DeviceFamily=GD32F10x;DeviceSubFamily=GD32F103;Target=GD32F103C8" @@ -165,9 +165,9 @@ - - - + + + diff --git a/GD32F103C8T6/GD32F10x.emSession b/GD32F103C8T6/GD32F10x.emSession index b8dd771..1e29b30 100644 --- a/GD32F103C8T6/GD32F10x.emSession +++ b/GD32F103C8T6/GD32F10x.emSession @@ -2,7 +2,8 @@ - + + @@ -33,11 +34,13 @@ + + - + @@ -88,27 +91,27 @@ - - - - - - + + + + - + - - + - + - + + + + - +