STM32f103 rt-thread 版本4.0.2,可能是的用的rt-thread版本较低,在drv_can存在一个设置CAN速率的BUG,322行
case RT_CAN_CMD_SET_BAUD:
argval = (rt_uint32_t) arg;
if (argval != CAN1MBaud &&
argval != CAN800kBaud &&
argval != CAN500kBaud &&
argval != CAN250kBaud &&
argval != CAN125kBaud &&
argval != CAN100kBaud &&
argval != CAN50kBaud &&
argval != CAN20kBaud &&
argval != CAN10kBaud)
{
return -RT_ERROR;
}
arg为传入参数void类型指针,argval这样提取数码是不正确
应该改为
argval = *(rt_uint32_t*) arg;