Dynamic pin assignment for serial port on Kinetis running MQX 3.8.1

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Dynamic pin assignment for serial port on Kinetis running MQX 3.8.1

跳至解决方案
1,281 次查看
Jeronimo479
Contributor II

In the file, init_gpio.c, there is a function, _bsp_serial_io_init() that is used to initialize the hardware pins used by each UART device. The port&pins are hard-coded to a port and mux assignment via a switch statement with no parameters.

On my rev 1 board I want to use Port XYZ Alt N, but on my Rev 2 board I want to use Port PDQ Alt M. I want my CPU to discover what board type I'm running on and use the correct pins for that board. How can I do this at run-time if the function wants them to be hard-coded in the library?

标签 (1)
标记 (3)
0 项奖励
回复
1 解答
1,033 次查看
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Unfortunately there is no way to do that without modifying the MQX code.

One thing you can do is to add a new option in the ioctl of the driver you want to use.

You have to modify the uint_32 _kuart_polled_ioctl function in the serl_pol_kuart.c and add the command or option to change the pins to be used. Similar way as you modify the baud-rate, parity and other parameters.

Other way is to modify directly to the registers in the application, just like in a bareboard project.

I hope this helps.

在原帖中查看解决方案

0 项奖励
回复
1 回复
1,034 次查看
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Unfortunately there is no way to do that without modifying the MQX code.

One thing you can do is to add a new option in the ioctl of the driver you want to use.

You have to modify the uint_32 _kuart_polled_ioctl function in the serl_pol_kuart.c and add the command or option to change the pins to be used. Similar way as you modify the baud-rate, parity and other parameters.

Other way is to modify directly to the registers in the application, just like in a bareboard project.

I hope this helps.

0 项奖励
回复