[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
第一步:
485 引脚 :uart4 TX PA1 RX PA0 EN PA3
第二步:
添加Freemodbus库
选择Slave mode
改为串口4
保存,退出!
第三步:pkgs --update
scons --target=mdk5
重新生成工程!
第四步:复旦微的pin device框架好像木有唉!485的使能引脚这里修改为手动配置引脚即可.
然后重新手动处理了EN引脚的:
#if defined(RT_MODBUS_SLAVE_USE_CONTROL_PIN)
//rt_pin_mode(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_MODE_OUTPUT);
FL_GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitStruct.pin = FL_GPIO_PIN_4;
GPIO_InitStruct.mode = FL_GPIO_MODE_OUTPUT; GPIO_InitStruct.outputType =
FL_GPIO_OUTPUT_PUSHPULL; GPIO_InitStruct.pull = FL_DISABLE; FL_GPIO_Init(GPIOA,
&GPIO_InitStruct); #endif void vMBPortSerialEnable(BOOL xRxEnable, BOOL
xTxEnable) { rt_uint32_t recved_event; if (xRxEnable) { /* enable RX interrupt
*/ serial->ops->control(serial, RT_DEVICE_CTRL_SET_INT, (void
*)RT_DEVICE_FLAG_INT_RX); /* switch 485 to receive mode */ #if
defined(RT_MODBUS_SLAVE_USE_CONTROL_PIN) FL_GPIO_ResetOutputPin(GPIOA,
FL_GPIO_PIN_4); //rt_pin_write(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_LOW);
#endif } else { /* switch 485 to transmit mode */ #if
defined(RT_MODBUS_SLAVE_USE_CONTROL_PIN) FL_GPIO_SetOutputPin(GPIOA,
FL_GPIO_PIN_4); //rt_pin_write(MODBUS_SLAVE_RT_CONTROL_PIN_INDEX, PIN_HIGH);
#endif /* disable RX interrupt */ serial->ops->control(serial,
RT_DEVICE_CTRL_CLR_INT, (void *)RT_DEVICE_FLAG_INT_RX); } if (xTxEnable) { /*
start serial transmit */ rt_event_send(&event_serial,
EVENT_SERIAL_TRANS_START); } else { /* stop serial transmit */
rt_event_recv(&event_serial, EVENT_SERIAL_TRANS_START, RT_EVENT_FLAG_OR |
RT_EVENT_FLAG_CLEAR, 0, &recved_event); } }
呦呵编译过了!
第五步:
看结果!
呃呃呃!
问题来了,这里呆掉了!找了好久没找到原因唉!
脑壳疼,下一节接着解BUG。