Dynamic pin assignment for serial port on Kinetis running MQX 3.8.1

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dynamic pin assignment for serial port on Kinetis running MQX 3.8.1

Jump to solution
708 Views
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?

Labels (1)
Tags (3)
0 Kudos
1 Solution
460 Views
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.

View solution in original post

0 Kudos
1 Reply
461 Views
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 Kudos