更改按键,已经添加msp重启
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
button_t btn;
|
||||
|
||||
cfg_board_pin_io_t key_switch = {
|
||||
.pin = 9,
|
||||
.en_lev = 0,};
|
||||
.pin = 18,
|
||||
.en_lev = 1,};
|
||||
cfg_board_pin_io_t boot_switch = {
|
||||
.pin = 18,
|
||||
.en_lev = 0,};
|
||||
@@ -174,7 +174,7 @@ void button_work_init() {
|
||||
|
||||
pin_cfg_input(&key_switch);
|
||||
// pin_cfg_output(&boot_switch);
|
||||
gpio_to_high_z(&boot_switch);
|
||||
// gpio_to_high_z(&boot_switch);
|
||||
|
||||
button_init(&btn, read_button_pin, my_button_handler);
|
||||
|
||||
@@ -209,3 +209,21 @@ void key_test(void)
|
||||
|
||||
boot_set_high_z();
|
||||
}
|
||||
|
||||
void boot_set_2(uint8_t value)
|
||||
{
|
||||
pin_cfg_output(&boot_switch);
|
||||
pin_set_valid(&boot_switch, value);
|
||||
os_work_suspend(&work_handler_button);
|
||||
}
|
||||
|
||||
void boot_set_high_z_2(void)
|
||||
{
|
||||
pin_cfg_input(&key_switch);
|
||||
os_work_resume(&work_handler_button,10);
|
||||
}
|
||||
|
||||
bool key_get_status(void)
|
||||
{
|
||||
return pin_get_valid(&key_switch);
|
||||
}
|
||||
@@ -61,3 +61,9 @@ void boot_set(uint8_t value);
|
||||
void boot_set_high_z(void);
|
||||
|
||||
void key_test(void);
|
||||
|
||||
void boot_set_2(uint8_t value);
|
||||
|
||||
void boot_set_high_z_2(void);
|
||||
|
||||
bool key_get_status(void);
|
||||
|
||||
@@ -448,7 +448,15 @@ void fc_put_ack(void)
|
||||
// printf("ACK\n");
|
||||
}
|
||||
|
||||
|
||||
// MSP重启命令
|
||||
void msp_send_reboot(msp_port_t *msp)
|
||||
{
|
||||
msp_send2(msp, MSP_REBOOT, NULL, 0);
|
||||
}
|
||||
void msp_request_type(msp_port_t *msp)
|
||||
{
|
||||
msp_send2(msp, MSP_FC_VARIANT, NULL, 0);
|
||||
}
|
||||
// MSP数据读取,并根据读取的数据进行处理
|
||||
void msp_recv_loop(msp_port_t *msp)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define MSP_SONAR_ALTITUDE 58
|
||||
#define MSP_ARMING_CONFIG 61
|
||||
#define MSP_RX_MAP 64 // get channel map (also returns number of channels total)
|
||||
#define MSP_REBOOT 68 // 重启命令
|
||||
#define MSP_LOOP_TIME 73 // FC cycle time i.e looptime parameter
|
||||
#define MSP_STATUS 101
|
||||
#define MSP_RAW_IMU 102
|
||||
@@ -366,7 +367,10 @@ void msp_handle_get_gcs(msp_gcs_t pkt);
|
||||
// 回复请求包处理
|
||||
void fc_put_ack(void);
|
||||
|
||||
|
||||
// 发送MSP重启命令
|
||||
void msp_send_reboot(msp_port_t *msp);
|
||||
// 请求飞控类型
|
||||
void msp_request_type(msp_port_t *msp);
|
||||
// 接口层
|
||||
int MSP_wirite(const void *data, uint32_t size, uint32_t wait_ms);
|
||||
int MSP_read(void *data, uint32_t size, uint32_t wait_ms);
|
||||
|
||||
@@ -172,7 +172,7 @@ int fc_reboot(void)
|
||||
break;
|
||||
case PROTOCOL_MSP:
|
||||
{
|
||||
|
||||
msp_send_reboot(&protocol.msp);
|
||||
}
|
||||
break;
|
||||
case PROTOCOL_MAVLINK:
|
||||
|
||||
@@ -522,9 +522,9 @@ void resend_user_parse(void *resend_device)
|
||||
// 修改灯珠颜色
|
||||
protocol_set_message_status(MESSAGE_FC_ISP);
|
||||
// 重启飞控,并使其进入isp烧录模式 需要在能够识别飞控的情况下才需要重启
|
||||
if(sertrf.fc_protocol_status != PROTOCOL_STATUS_TYPE_IDLE && sertrf.fc_protocol_status != PROTOCOL_STATUS_NO_DATA)
|
||||
fc_reboot();
|
||||
boot_set(0);
|
||||
// if(sertrf.fc_protocol_status != PROTOCOL_STATUS_TYPE_IDLE && sertrf.fc_protocol_status != PROTOCOL_STATUS_NO_DATA)
|
||||
fc_reboot();
|
||||
boot_set_2(0);
|
||||
os_thread_sleep(1000);
|
||||
//串口切换为偶校验模式,并清除缓存
|
||||
uart_set_parity_switch(sertrf.device.embedded_device, 0x02);
|
||||
@@ -556,7 +556,7 @@ void resend_user_parse(void *resend_device)
|
||||
printf("stmisp: sync ok\n");
|
||||
os_thread_sleep(100);
|
||||
|
||||
boot_set_high_z();
|
||||
boot_set_high_z_2();
|
||||
// 全盘擦除
|
||||
if(!cmd_extended_erase_mass(&sertrf.stmisp_device))
|
||||
printf("stmisp: erase mass error\n");
|
||||
@@ -604,6 +604,7 @@ void resend_user_parse(void *resend_device)
|
||||
uart_set_parity_switch(sertrf.device.embedded_device, 0x00);
|
||||
SYS_LOG_INF("RESEND_CMD_FC_ISP_END2");
|
||||
resend_send_cmd(resend_device, RESEND_CMD_ACK, 0);
|
||||
esp_restart();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user