From: kyz Date: Thu, 21 Mar 2024 03:32:30 +0000 (+0800) Subject: V2.1版本 X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=fec32343244ea72719423c8689a63115507a94e4;p=yn%2Fweldingcontroller.git V2.1版本 主程序定位到 ITCM 加载地址 0x1000 bootloader程序 从spiflash 读取主程序到itcm,跳转执行 --- diff --git a/Core/Src/main.c b/Core/Src/main.c index 09ca587..b3a000c 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -82,7 +82,7 @@ int main(void) //主程序从flash加载到ITCM中运行,加载地址1000 //程序0x00001000不放0地址,否则许多内存读写函数会判为NULL? //在这里手动修改VTOR -// SCB->VTOR = 0x1000; + SCB->VTOR = 0x1000; /* USER CODE END 1 */ /* Enable the CPU Cache */ diff --git a/MDK-ARM/welding_controller_v2.uvprojx b/MDK-ARM/welding_controller_v2.uvprojx index 8b612f8..d0273af 100644 --- a/MDK-ARM/welding_controller_v2.uvprojx +++ b/MDK-ARM/welding_controller_v2.uvprojx @@ -275,8 +275,8 @@ 1 - 0x8000000 - 0x20000 + 0x1000 + 0x1f000 1 diff --git a/lib/gas_flow_20240320.lib b/lib/gas_flow_20240320.lib new file mode 100644 index 0000000..3be86d5 Binary files /dev/null and b/lib/gas_flow_20240320.lib differ diff --git a/ui/TFT/6.png.tft b/ui/TFT/6.png.tft index f079288..38190f5 100644 Binary files a/ui/TFT/6.png.tft and b/ui/TFT/6.png.tft differ diff --git a/user/user.h b/user/user.h index 2ac267e..a60ed21 100644 --- a/user/user.h +++ b/user/user.h @@ -26,7 +26,7 @@ //-------------------- #define APP_VER_MAJOR 2 -#define APP_VER_MINOR 0 +#define APP_VER_MINOR 1 #define VREF 2.5f diff --git a/user/user_cdc_rx_2.c b/user/user_cdc_rx_2.c index 6dd5e3c..e11264d 100644 --- a/user/user_cdc_rx_2.c +++ b/user/user_cdc_rx_2.c @@ -105,7 +105,7 @@ */ -#define APP_FLAG 0x00505041 //'APP\0' +#define FW_APP_FLAG 0x31505041 //'APP1' typedef struct{ uint16_t cmd; @@ -243,7 +243,7 @@ int32_t load_app( void ) return -1; user_sflash_read( APP_INFO_PART_ADDR, (uint8_t*)&fw_info, sizeof( fw_info ) ); - if( fw_info.flag != APP_FLAG || fw_info.addr <= 0x00000000 || fw_info.addr+fw_info.size > 0x40000 ) //itcm + if( fw_info.flag != FW_APP_FLAG || fw_info.addr <= 0x00000000 || fw_info.addr+fw_info.size > 0x40000 ) //itcm return -2; user_sflash_read( APP_PART_ADDR, (uint8_t*)fw_info.addr, fw_info.size ); @@ -297,7 +297,7 @@ int32_t handle_cdc_pkt( cdc_pkt_t *pkt ) resp[0] = 0; resp[1] = 'B'; resp[2] = 1; //BOOT_VER_MAJOR; - resp[3] = 2; //BOOT_VER_MINOR; + resp[3] = 0; //BOOT_VER_MINOR; put_u32_big( &resp[4], 0 ); //fw size put_u32_big( &resp[8], 0 ); //fw crc #else @@ -369,7 +369,7 @@ int32_t handle_cdc_pkt( cdc_pkt_t *pkt ) break; case 0x0004: //reboot { - fw.flag = APP_FLAG; + fw.flag = FW_APP_FLAG; user_sflash_erase( APP_INFO_PART_ADDR, APP_INFO_PART_SIZE ); user_sflash_write( APP_INFO_PART_ADDR, (uint8_t*)&fw, sizeof( fw ) ); resp[0] = 1; @@ -466,7 +466,7 @@ int32_t get_app_fw_info( uint32_t * fw_size, uint16_t fw_crc ) p = (uint32_t*)(app_start+1024); flag = p[0]; - if( flag != 0x00505041 ) + if( flag != FW_APP_FLAG ) return 0; sw_ver_addr = (uint8_t *)p[1]; diff --git a/user/user_flowmeter.c b/user/user_flowmeter.c index 81f3ac7..9ce296d 100644 --- a/user/user_flowmeter.c +++ b/user/user_flowmeter.c @@ -136,7 +136,10 @@ void user_flowmeter_task( void* unused ) //读取到 流量 err = 0; g_dev.flowmeter.flow_speed_raw = reg_values[0]/10.0f; - g_dev.flowmeter.flow_speed = g_dev.flowmeter.flow_speed_raw + g_dev.cfg.cal.flowrate; + if( g_dev.flowmeter.flow_speed_raw + g_dev.cfg.cal.flowrate > 0 ) + g_dev.flowmeter.flow_speed = g_dev.flowmeter.flow_speed_raw + g_dev.cfg.cal.flowrate; + else + g_dev.flowmeter.flow_speed = 0; g_dev.flowmeter.flow_total = ((reg_values[1]<<16)|reg_values[2])/10.0f; g_dev.flowmeter.tem = reg_values[3]/10.0f; g_dev.flowmeter.state = reg_values[4]; diff --git a/user/user_ui.c b/user/user_ui.c index 40f5c79..633f7a2 100644 --- a/user/user_ui.c +++ b/user/user_ui.c @@ -89,6 +89,7 @@ void ui_handle_lcd_pkt( void ) { uint16_t ctrl_addr; uint16_t ctrl_value; + int16_t flow_cal_x10; uint8_t *p; static net_cfg_t net_cfg; @@ -166,7 +167,8 @@ void ui_handle_lcd_pkt( void ) }else{ g_dev.cfg.cal.flowrate = off; dev_cfg_store( &g_dev.cfg ); - lcd_write_u16( lcd_flow_cal_value_addr, off*10 ); + flow_cal_x10 = (int16_t)(g_dev.cfg.cal.flowrate*10); + lcd_write_s16( lcd_flow_cal_value_addr, flow_cal_x10 ); } } } @@ -280,6 +282,12 @@ void lcd_write( uint16_t addr, uint16_t *value, uint8_t reg_nr ) } }; +void lcd_write_s16( uint16_t addr, int16_t value ) +{ + uint16_t reg_value = (uint16_t)value; + lcd_write( addr, ®_value, 1 ); +} + void lcd_write_u16( uint16_t addr, uint16_t value ) { uint16_t reg_value = value; @@ -298,6 +306,7 @@ void lcd_power_off( void ) void user_ui_task( void* unused ) { + int16_t flow_cal_x10; uint16_t reg_values[16]; //uint32_t last_tick = xTaskGetTickCount(); EventBits_t uxBits; @@ -334,7 +343,8 @@ void user_ui_task( void* unused ) osDelay(10 ); lcd_write_text( lcd_tcp_server_addr, (uint8_t*)&g_dev.cfg.net.tcp_server, lcd_tcp_server_size ); osDelay(10 ); - lcd_write_u16( lcd_flow_cal_value_addr, g_dev.cfg.cal.flowrate*10 ); + flow_cal_x10 = (int16_t)(g_dev.cfg.cal.flowrate*10); + lcd_write_s16( lcd_flow_cal_value_addr, flow_cal_x10 ); osDelay(10 ); while(1){