提交支持modbus tcp支持
This commit is contained in:
parent
fc164fe8e5
commit
a8e85805ef
|
@ -331,8 +331,7 @@ void bms_init_comm(void)
|
|||
w5500_modbus_tcp_array[i].send_call = w5500_tcp_send;
|
||||
w5500_modbus_tcp_array[i].buf_size = MODBUS_BUF_SIZE;
|
||||
w5500_modbus_tcp_array[i].ctrl_rx_int_call = eth_ctrl_rx_int;
|
||||
}
|
||||
|
||||
};
|
||||
drv_w5500_set_close_call(&w5500, w5500_tcp_close_call);
|
||||
drv_spi_init(kSpiDev_3, kSpiFreq_Div2, kSpiMode_C0E0, SpiFrame_MSBFirst, kGpioType_W5500Clk, kGpioType_W5500Miso, kGpioType_W5500Mosi);
|
||||
//drv_spi_set_dma(kSpiDev_3, true, true);
|
||||
|
|
|
@ -23,12 +23,7 @@ bool is_first_run = false;
|
|||
static int a = 0;
|
||||
void task_1ms_handler(uint32_t base_time)
|
||||
{
|
||||
if(is_first_run == true)
|
||||
{
|
||||
a++;
|
||||
}
|
||||
KIT_DEBUG_PRINTF("cur_hv init start \r\n");
|
||||
bms_poll_cur_hv(base_time);
|
||||
bms_poll_w5500();
|
||||
}
|
||||
|
||||
void task_can1_handler(uint32_t base_time)
|
||||
|
@ -40,8 +35,7 @@ void task_can1_handler(uint32_t base_time)
|
|||
SN_BMS_INIT_CALL user_task_call;
|
||||
void task_10ms_handler(uint32_t base_time)
|
||||
{
|
||||
// static uint32_t cout10ms = 0;
|
||||
//cout10ms++;
|
||||
bms_poll_cur_hv(base_time);
|
||||
bms_poll_signal(base_time);
|
||||
|
||||
#ifdef LIB_CREAT
|
||||
|
@ -69,7 +63,7 @@ void task_100ms_handler(uint32_t base_time)
|
|||
}
|
||||
|
||||
|
||||
GLOBAL_TASK_VARS_CCM(poll_1ms_task, 4, 100, 5000, 400, poll_1ms_task_init, task_1ms_handler, NULL);
|
||||
GLOBAL_TASK_VARS_CCM(poll_1ms_task, 4, 1, 5000, 400, poll_1ms_task_init, task_1ms_handler, NULL);
|
||||
GLOBAL_TASK_VARS_CCM(poll_100ms_task, 1, 100, 2000, 400, NULL, task_100ms_handler, NULL);
|
||||
|
||||
GLOBAL_TASK_VARS_CCM(poll_10ms_task, 3, 100, 2000, 400, poll_10ms_task_init, task_10ms_handler, NULL);
|
||||
|
|
|
@ -1046,8 +1046,8 @@
|
|||
<TargetCommonOption>
|
||||
<Device>STM32F407VGTx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F4xx_DFP.3.0.0</PackID>
|
||||
<PackURL>https://www.keil.com/pack/</PackURL>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.14.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00010000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
|
|
|
@ -37,13 +37,25 @@ void drv_w5500_init(W5500Item *item, uint32_t ip, uint16_t *port_array, uint32_t
|
|||
|
||||
KIT_MODULE_PRINTF(W5500_PRT_EN, "w5500 connet res %d\r\n", cnt < 100);
|
||||
cnt = 0;
|
||||
//设置网关IP 子网掩码 MAC 源IP
|
||||
//设置网关IP
|
||||
WRITE_LT_INT32U(buf, cnt, gateway_ip);
|
||||
drv_w5500_write_comm_reg(item, W5500_GAR0_REG_0x01, buf, 4);
|
||||
|
||||
//设置子网掩码
|
||||
cnt = 0;
|
||||
WRITE_LT_INT32U(buf, cnt, net_mask);
|
||||
kit_copy_buf(&buf[cnt], mac, 6);
|
||||
cnt += 6;
|
||||
drv_w5500_write_comm_reg(item, W5500_SUBR0_REG_0x05, buf, 4);
|
||||
|
||||
//设置MAC 地址
|
||||
cnt = 0;
|
||||
kit_copy_buf(buf, mac, 6);
|
||||
drv_w5500_write_comm_reg(item, W5500_SHAR0_REG_0x09, buf, 6);
|
||||
|
||||
//设置ip地址
|
||||
cnt = 0;
|
||||
WRITE_LT_INT32U(buf, cnt, ip);
|
||||
drv_w5500_write_comm_reg(item, W5500_GAR0_REG_0x01, buf, 4 + 4 + 6 + 4);
|
||||
drv_w5500_write_comm_reg(item, W5500_SIPR0_REG_0x0F, buf, 4);
|
||||
|
||||
buf[0] = timeout / 200;
|
||||
drv_w5500_write_comm_reg(item, W5500_GAR0_REG_0x01, buf, 1);
|
||||
#ifdef W5500_DEBUG
|
||||
|
|
Loading…
Reference in New Issue