µTasker Forum
µTasker Forum => NXPTM M522XX, KINETIS and i.MX RT => Topic started by: neil on June 21, 2023, 10:51:30 AM
-
Hi Mark,
Hope you are keeping well..
I call the below to open a Uart and pulse input channels. If I want to call the routine again, do I have to close any handles first? If so how is this done?
Best Regards
Neil
--------------------------
TTYTABLE tGSMInterfaceParameters; // table for passing information to driver
QUEUE_HANDLE fnSetGSMSerialMode(unsigned char ucDriverMode)//
{
GPTIMER_SETUP gptimer_setup; // interrupt configuration parameters
tGSMInterfaceParameters.Channel = 1; // set UART channel for serial use
tGSMInterfaceParameters.ucSpeed = SERIAL_BAUD_115200; // baud rate
tGSMInterfaceParameters.Rx_tx_sizes.RxQueueSize = 400; // input buffer size
tGSMInterfaceParameters.Rx_tx_sizes.TxQueueSize = 800; // output buffer size
// tGSMInterfaceParameters.Rx_tx_sizes.TxQueueSize = 3000; // output buffer size Large size as may be used with diagnostics
tGSMInterfaceParameters.Task_to_wake = TASK_GSM; // wake self when messages have been received
tGSMInterfaceParameters.Config = (CHAR_8 | NO_PARITY | ONE_STOP | CHAR_MODE | RTS_CTS | INFORM_ON_FRAME_TRANSMISSION);
// tGSMInterfaceParameters.ucDMAConfig = 0; // NO DMA for UART1
gptimer_setup.int_type = GPT_TIMER_INTERRUPT;
gptimer_setup.int_handler = DCDPulse_int;
gptimer_setup.channel = 1; // general purpose timer channel 1
gptimer_setup.int_priority = GPTIMER0_INTERRUPT_PRIORITY; // define interrupt priority
gptimer_setup.mode = GPT_CAPTURE_RISING_EDGE; // set up capture mode and define the timer clock
gptimer_setup.usCaptureCount = 0; // request this many capture values to be recorded before calling our interrupt
gptimer_setup.capture_list = 0; // the capture list for saving to
fnConfigureInterrupt((void *)&gptimer_setup); // enter interrupt for DMA timer test
if ((GSMPortID = fnOpen( TYPE_TTY, ucDriverMode, &tGSMInterfaceParameters )) != 0)
{ // open or change the channel with defined configurations (initially inactive)
fnDriver( GSMPortID, ( TX_ON | RX_ON ), 0 ); // enable rx and tx
if (tGSMInterfaceParameters.Config & RTS_CTS) { //
fnDriver( GSMPortID, (MODIFY_INTERRUPT | ENABLE_CTS_CHANGE), 0 ); // activate CTS interrupt when working with HW flow control (this returns also the present control line states)
fnDriver( GSMPortID, (MODIFY_CONTROL | SET_RTS), 0 ); // activate RTS line when working with HW flow control
}
}
return GSMPortID;
}
-
Hi Neil
You can call with the ucDriverMode set to MODIFY_CONFIG is you want to change the UART settings (such as the baud rate).
The UART doesn't support close and re-open since this is something that is never (up to now) needed in an embedded system. It would be possible since the driver handles a close but it would require the UART's memory management to be changed to use dynamic heap (such as when the buffer sizes need to change) rather than uMalloc() as it presently uses.
If you want to stop the UART for some time you can also do
fnDriver( GSMPortID, ( TX_OFF | RX_OFF ), 0 );
and then later re-enable it with
fnDriver( GSMPortID, ( TX_ON | RX_ON ), 0 );
Regards
Mark