Hi,
With MQX 3.8.
We are using the macro BSPCFG_ENABLE_TTYA and the API function _mcf54xx_uart_serial_polled_install to configure the UART and use it as the default interface for the Shell and the standard IO functions. This works just fine. Now we want to enable/disable the uart at runtime. We have tried disabling the UART,
- writing directly to the peripheral registers,
- using _io_set_handle(IO_PROC_STDOUT(or IN), gs_NullDrv) (as suggested in the forum)
- or with _io_fclose().
Either MQX crashes or the UART does not get disabled. What would be the right way to disable and re-enable the UART?
Solved! Go to Solution.
Sorry I only have MQX 4.2 installed on my PC.
Please refer to the implement in MQX 4.2
serial.h
#define IO_IOCTL_SERIAL_DISABLE_RX _IO(IO_TYPE_SERIAL,0x17)
#define IO_IOCTL_SERIAL_WAIT_FOR_TC _IO(IO_TYPE_SERIAL,0x18)
sel_pol_kuart.c
case IO_IOCTL_SERIAL_DISABLE_RX:
if( *(bool *)param_ptr == TRUE )
{
/* disable receiver */
sci_ptr->C2 &=~UART_C2_RE_MASK;
}
else
{
/* enable receiver */
sci_ptr->C2 |= UART_C2_RE_MASK;
}
break;
Regards
Daniel
I am getting IO_ERROR_INVALID_IOCTL_CMD, is it possible IO_IOCTL_SERIAL_DISABLE_RX is not implemented in MQX 3.8?
Sorry I only have MQX 4.2 installed on my PC.
Please refer to the implement in MQX 4.2
serial.h
#define IO_IOCTL_SERIAL_DISABLE_RX _IO(IO_TYPE_SERIAL,0x17)
#define IO_IOCTL_SERIAL_WAIT_FOR_TC _IO(IO_TYPE_SERIAL,0x18)
sel_pol_kuart.c
case IO_IOCTL_SERIAL_DISABLE_RX:
if( *(bool *)param_ptr == TRUE )
{
/* disable receiver */
sci_ptr->C2 &=~UART_C2_RE_MASK;
}
else
{
/* enable receiver */
sci_ptr->C2 |= UART_C2_RE_MASK;
}
break;
Regards
Daniel
I ported the code to 3.8 and is all ok. Thanks for your help.
Hi
I would suggest you use I/O control commands.
IO_IOCTL_SERIAL_CLEAR_STAT : Clear the statistics.
IO_IOCTL_SERIAL_SET_BAUD: Set the BAUD rate.
IO_IOCTL_SERIAL_DISABLE_RX: Disable or enable UART receiver.
Regards
Daniel