mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Convert SmartFusion2 CLI to use the interrupt UART driver functions instead of the polled UART driver functions.
This commit is contained in:
parent
5ff880fee8
commit
063c05ccad
|
@ -50,6 +50,7 @@
|
|||
</option>
|
||||
<option id="gnu.c.compiler.option.misc.verbose.1351799799" name="Verbose (-v)" superClass="gnu.c.compiler.option.misc.verbose" value="true" valueType="boolean"/>
|
||||
<option id="gnu.c.compiler.option.optimization.flags.435998408" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="-ffunction-sections -fdata-sections" valueType="string"/>
|
||||
<option id="gnu.c.compiler.option.misc.other.1001754914" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -Wextra" valueType="string"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2036217646" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.cross.cortexm3.exe.debug.612642130" name="GNU C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cross.cortexm3.exe.debug">
|
||||
|
|
|
@ -98,18 +98,14 @@
|
|||
#include <stdint.h>
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
/* Driver includes required for UART IO. */
|
||||
#include "drivers/mss_uart/mss_uart.h"
|
||||
extern const mss_uart_instance_t * const pxUART;
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_IDLE_HOOK 1
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
||||
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 130 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 27648 ) )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 80 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 25000 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 10 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* Driver includes. */
|
||||
#include "drivers/mss_uart/mss_uart.h"
|
||||
|
@ -73,6 +73,11 @@
|
|||
/* The maximum time in ticks to wait for the UART access mutex. */
|
||||
#define cmdMAX_MUTEX_WAIT ( 200 / portTICK_RATE_MS )
|
||||
|
||||
/* Characters are only ever received slowly on the CLI so it is ok to pass
|
||||
received characters from the UART interrupt to the task on a queue. This sets
|
||||
the length of the queue used for that purpose. */
|
||||
#define cmdRXED_CHARS_QUEUE_LENGTH ( 10 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
|
@ -80,6 +85,19 @@
|
|||
*/
|
||||
static void prvUARTCommandConsoleTask( void *pvParameters );
|
||||
|
||||
/*
|
||||
* Ensure a previous interrupt driven Tx has completed before sending the next
|
||||
* data block to the UART.
|
||||
*/
|
||||
static void prvSendBuffer( const uint8_t * pcBuffer, size_t xBufferLength );
|
||||
|
||||
/*
|
||||
* A UART is used for printf() output and CLI input and output. Configure the
|
||||
* UART and register prvUARTRxNotificationHandler() to handle UART Rx events.
|
||||
*/
|
||||
static void prvConfigureUART( void );
|
||||
static void prvUARTRxNotificationHandler( mss_uart_instance_t * this_uart );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Const messages output by the command console. */
|
||||
|
@ -87,10 +105,24 @@ static const uint8_t * const pcWelcomeMessage = ( uint8_t * ) "\r\n\r\nFreeRTOS
|
|||
static const uint8_t * const pcEndOfOutputMessage = ( uint8_t * ) "\r\n[Press ENTER to execute the previous command again]\r\n>";
|
||||
static const uint8_t * const pcNewLine = ( uint8_t * ) "\r\n";
|
||||
|
||||
/* The UART used by the CLI. */
|
||||
static const mss_uart_instance_t * const pxUART = &g_mss_uart0;
|
||||
static const IRQn_Type xUART_IRQ = UART0_IRQn;
|
||||
|
||||
/* Because characters are received slowly (at the speed somebody can type) then
|
||||
it is ok to pass received characters from the Rx interrupt to the task on a
|
||||
queue. This is the queue used for that purpose. */
|
||||
static xQueueHandle xRxedChars = NULL;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vUARTCommandConsoleStart( uint16_t usStackSize, unsigned portBASE_TYPE uxPriority )
|
||||
{
|
||||
/* A UART is used for printf() output and CLI input and output. Note there
|
||||
is no mutual exclusion on the UART, but the demo as it stands does not
|
||||
require mutual exclusion. */
|
||||
prvConfigureUART();
|
||||
|
||||
/* Create that task that handles the console itself. */
|
||||
xTaskCreate( prvUARTCommandConsoleTask, /* The task that implements the command console. */
|
||||
( const int8_t * const ) "CLI", /* Text name assigned to the task. This is just to assist debugging. The kernel does not use this name itself. */
|
||||
|
@ -106,7 +138,6 @@ static void prvUARTCommandConsoleTask( void *pvParameters )
|
|||
int8_t cRxedChar, cInputIndex = 0, *pcOutputString;
|
||||
static int8_t cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];
|
||||
portBASE_TYPE xReturned;
|
||||
mss_uart_instance_t * const pxUART = &g_mss_uart0;
|
||||
|
||||
( void ) pvParameters;
|
||||
|
||||
|
@ -116,24 +147,21 @@ mss_uart_instance_t * const pxUART = &g_mss_uart0;
|
|||
pcOutputString = FreeRTOS_CLIGetOutputBuffer();
|
||||
|
||||
/* Send the welcome message. */
|
||||
MSS_UART_polled_tx_string( pxUART, ( uint8_t * ) pcWelcomeMessage );
|
||||
prvSendBuffer( pcWelcomeMessage, strlen( ( char * ) pcWelcomeMessage ) );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* No characters received yet for the current input string. */
|
||||
cRxedChar = 0;
|
||||
|
||||
/* Only interested in reading one character at a time. */
|
||||
if( MSS_UART_get_rx( pxUART, ( uint8_t * ) &cRxedChar, sizeof( cRxedChar ) ) > 0 )
|
||||
/* Wait for the next character to arrive. */
|
||||
if( xQueueReceive( xRxedChars, &cRxedChar, portMAX_DELAY ) == pdPASS )
|
||||
{
|
||||
/* Echo the character back. */
|
||||
MSS_UART_polled_tx( pxUART, ( uint8_t * ) &cRxedChar, sizeof( cRxedChar ) );
|
||||
prvSendBuffer( ( uint8_t * ) &cRxedChar, sizeof( cRxedChar ) );
|
||||
|
||||
/* Was it the end of the line? */
|
||||
if( cRxedChar == '\n' || cRxedChar == '\r' )
|
||||
{
|
||||
/* Just to space the output from the input. */
|
||||
MSS_UART_polled_tx_string( pxUART, ( uint8_t * ) pcNewLine );
|
||||
prvSendBuffer( ( uint8_t * ) pcNewLine, strlen( ( char * ) pcNewLine ) );
|
||||
|
||||
/* See if the command is empty, indicating that the last command is
|
||||
to be executed again. */
|
||||
|
@ -153,8 +181,7 @@ mss_uart_instance_t * const pxUART = &g_mss_uart0;
|
|||
xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );
|
||||
|
||||
/* Write the generated string to the UART. */
|
||||
MSS_UART_polled_tx_string( pxUART, ( uint8_t * ) pcOutputString );
|
||||
vTaskDelay( 1 );
|
||||
prvSendBuffer( ( uint8_t * ) pcOutputString, strlen( ( char * ) pcOutputString ) );
|
||||
|
||||
} while( xReturned != pdFALSE );
|
||||
|
||||
|
@ -166,7 +193,7 @@ mss_uart_instance_t * const pxUART = &g_mss_uart0;
|
|||
cInputIndex = 0;
|
||||
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
||||
|
||||
MSS_UART_polled_tx_string( pxUART, ( uint8_t * ) pcEndOfOutputMessage );
|
||||
prvSendBuffer( ( uint8_t * ) pcEndOfOutputMessage, strlen( ( char * ) pcEndOfOutputMessage ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -204,3 +231,60 @@ mss_uart_instance_t * const pxUART = &g_mss_uart0;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSendBuffer( const uint8_t * pcBuffer, size_t xBufferLength )
|
||||
{
|
||||
const portTickType xVeryShortDelay = 2UL;
|
||||
|
||||
MSS_UART_irq_tx( ( mss_uart_instance_t * ) pxUART, pcBuffer, xBufferLength );
|
||||
|
||||
/* Ensure any previous transmissions have completed. The default UART
|
||||
interrupt does not provide an event based method of signally the end of a Tx
|
||||
- this is therefore a crude poll of the Tx end status. Replacing the
|
||||
default UART handler with one that 'gives' a semaphore when the Tx is
|
||||
complete would allow this poll loop to be replaced by a simple semaphore
|
||||
block. */
|
||||
while( MSS_UART_tx_complete( ( mss_uart_instance_t * ) pxUART ) == pdFALSE )
|
||||
{
|
||||
vTaskDelay( xVeryShortDelay );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvConfigureUART( void )
|
||||
{
|
||||
/* Initialise the UART which is used for printf() and CLI IO. */
|
||||
MSS_UART_init( ( mss_uart_instance_t * ) pxUART, MSS_UART_115200_BAUD, MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT );
|
||||
|
||||
/* Characters are only ever received slowly on the CLI so it is ok to pass
|
||||
received characters from the UART interrupt to the task on a queue. Create
|
||||
the queue used for that purpose. */
|
||||
xRxedChars = xQueueCreate( cmdRXED_CHARS_QUEUE_LENGTH, sizeof( char ) );
|
||||
|
||||
/* The interrupt handler makes use of FreeRTOS API functions, so its
|
||||
priority must be at or below the configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY
|
||||
setting (the higher the numeric priority, the lower the logical priority). */
|
||||
NVIC_SetPriority( xUART_IRQ, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
|
||||
|
||||
/* Set the UART Rx notification function. */
|
||||
MSS_UART_set_rx_handler( ( mss_uart_instance_t * ) pxUART, prvUARTRxNotificationHandler, MSS_UART_FIFO_SINGLE_BYTE );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvUARTRxNotificationHandler( mss_uart_instance_t * pxUART )
|
||||
{
|
||||
uint8_t cRxed;
|
||||
portBASE_TYPE xHigherPriorityTaskWoken;
|
||||
|
||||
/* The command console receives data very slowly (at the speed of somebody
|
||||
typing), therefore it is ok to just handle one character at a time and use
|
||||
a queue to send the characters to the task. */
|
||||
if( MSS_UART_get_rx( pxUART, &cRxed, sizeof( cRxed ) ) == sizeof( cRxed ) )
|
||||
{
|
||||
xHigherPriorityTaskWoken = pdFALSE;
|
||||
xQueueSendFromISR( xRxedChars, &cRxed, &xHigherPriorityTaskWoken );
|
||||
|
||||
/* portEND_SWITCHING_ISR() or portYIELD_FROM_ISR() can be used here. */
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,6 +104,21 @@
|
|||
* been discovered. If the green LED toggles every 200ms, then an issue has
|
||||
* been discovered with at least one task.
|
||||
*
|
||||
* FreeRTOS+CLI command console. The command console is access through UART0
|
||||
* using 115200 baud and the Microsemi MSS UART drivers. Type "help" to see a
|
||||
* list of registered commands, which include some basic file system commands
|
||||
* (see FreeRTOS+FAT SL comments below). The FreeRTOS+CLI license is different
|
||||
* to the FreeRTOS license, see http://www.FreeRTOS.org/cli for license and
|
||||
* usage details.
|
||||
*
|
||||
* FreeRTOS+FAT SL. FreeRTOS+FAT SL is demonstrated using a RAM disk. [At the
|
||||
* time of writing] The functionality of the file system demo is identical to
|
||||
* the functionality of the FreeRTOS Win32 simulator file system demo with the
|
||||
* command console being accessed via the UART (as described above) instead of
|
||||
* a network terminal. The FreeRTOS+FAT SL license is different to the FreeRTOS
|
||||
* license, see http://www.FreeRTOS.org/fat_sl for license and usage details,
|
||||
* and a description of the file system demo functionality.
|
||||
*
|
||||
* See the documentation page for this demo on the FreeRTOS.org web site for
|
||||
* full information, including hardware setup requirements.
|
||||
*/
|
||||
|
@ -115,7 +130,7 @@
|
|||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "timers.h"
|
||||
#include "semphr.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* Standard demo application includes. */
|
||||
#include "integer.h"
|
||||
|
@ -163,7 +178,7 @@ standard demo flash timers. */
|
|||
|
||||
/* The size of the stack and the priority used by the UART command console
|
||||
task. */
|
||||
#define mainUART_COMMAND_CONSOLE_STACK_SIZE ( configMINIMAL_STACK_SIZE * 3 )
|
||||
#define mainUART_COMMAND_CONSOLE_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 )
|
||||
#define mainUART_COMMAND_CONSOLE_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -180,31 +195,28 @@ static void prvCheckTimerCallback( xTimerHandle xTimer );
|
|||
extern void vRegisterSampleCLICommands( void );
|
||||
extern void vRegisterFileSystemCLICommands( void );
|
||||
|
||||
/* Prepare to run the full demo: Configure the IO, register the CLI
|
||||
* commands, and depending on configuration, generate a set of sample files on
|
||||
* a RAM disk.
|
||||
*/
|
||||
static void prvPrepareForFullDemo( void );
|
||||
|
||||
/*
|
||||
* Creates and verifies different files on the volume, demonstrating the use of
|
||||
* various different API functions.
|
||||
*/
|
||||
extern void vCreateAndVerifySampleFiles( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void main_full( void )
|
||||
{
|
||||
xTimerHandle xCheckTimer = NULL;
|
||||
|
||||
/* If the file system is only going to be accessed from one task then
|
||||
F_FS_THREAD_AWARE can be set to 0 and the set of example files are created
|
||||
before the RTOS scheduler is started. If the file system is going to be
|
||||
access from more than one task then F_FS_THREAD_AWARE must be set to 1 and
|
||||
the set of sample files are created from the idle task hook function
|
||||
vApplicationIdleHook() - which is defined in this file. */
|
||||
#if F_FS_THREAD_AWARE == 0
|
||||
{
|
||||
/* Initialise the drive and file system, then create a few example
|
||||
files. The output from this function just goes to the stdout window,
|
||||
allowing the output to be viewed when the UDP command console is not
|
||||
connected. */
|
||||
vCreateAndVerifySampleFiles();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Register both the standard and file system related CLI commands. */
|
||||
vRegisterSampleCLICommands();
|
||||
vRegisterFileSystemCLICommands();
|
||||
/* Prepare to run the full demo: Configure the IO, register the CLI
|
||||
commands, and depending on configuration, generate a set of sample files on
|
||||
a RAM disk. */
|
||||
prvPrepareForFullDemo();
|
||||
|
||||
/* Start all the other standard demo/test tasks. The have not particular
|
||||
functionality, but do demonstrate how to use the FreeRTOS API and test the
|
||||
|
@ -331,3 +343,25 @@ unsigned long ulErrorFound = pdFALSE;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvPrepareForFullDemo( void )
|
||||
{
|
||||
/* If the file system is only going to be accessed from one task then
|
||||
F_FS_THREAD_AWARE can be set to 0 and the set of example files are created
|
||||
before the RTOS scheduler is started. If the file system is going to be
|
||||
access from more than one task then F_FS_THREAD_AWARE must be set to 1 and
|
||||
the set of sample files are created from the idle task hook function
|
||||
vApplicationIdleHook() - which is defined in this file. */
|
||||
#if F_FS_THREAD_AWARE == 0
|
||||
{
|
||||
/* Initialise the drive and file system, then create a few example
|
||||
files. The output from this function just goes to the stdout window,
|
||||
allowing the output to be viewed when the UDP command console is not
|
||||
connected. */
|
||||
vCreateAndVerifySampleFiles();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Register both the standard and file system related CLI commands. */
|
||||
vRegisterSampleCLICommands();
|
||||
vRegisterFileSystemCLICommands();
|
||||
}
|
||||
|
|
|
@ -119,8 +119,6 @@ void vApplicationIdleHook( void );
|
|||
void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName );
|
||||
void vApplicationTickHook( void );
|
||||
|
||||
/* The UART used for printf() and CLI IO. */
|
||||
const mss_uart_instance_t * const pxUART = &g_mss_uart0;
|
||||
/*-----------------------------------------------------------*/
|
||||
/* See the documentation page for this demo on the FreeRTOS.org web site for
|
||||
full information - including hardware setup requirements. */
|
||||
|
@ -152,9 +150,6 @@ static void prvSetupHardware( void )
|
|||
functions. The name ParTest is now somewhat obsolete - originally it
|
||||
stood for PARallel port Test. */
|
||||
vParTestInitialise();
|
||||
|
||||
/* Initialise the UART which is used for printf() and CLI IO. */
|
||||
MSS_UART_init( pxUART, MSS_UART_115200_BAUD, MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ static void printchar(char **str, int c)
|
|||
}
|
||||
else
|
||||
{
|
||||
MSS_UART_polled_tx( pxUART, ( uint8_t * ) &c, sizeof( uint8_t ) );
|
||||
/* Output char here. */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* Defines
|
||||
|
@ -71,7 +71,7 @@ void UART1_IRQHandler(void);
|
|||
/*******************************************************************************
|
||||
* Local functions.
|
||||
*/
|
||||
static void global_init(mss_uart_instance_t * this_uart, uint32_t baud_rate,
|
||||
static void global_init(mss_uart_instance_t * this_uart, uint32_t baud_rate,
|
||||
uint8_t line_config);
|
||||
static void MSS_UART_isr(mss_uart_instance_t * this_uart);
|
||||
static void default_tx_handler(mss_uart_instance_t * this_uart);
|
||||
|
@ -79,7 +79,7 @@ static void default_tx_handler(mss_uart_instance_t * this_uart);
|
|||
static void config_baud_divisors
|
||||
(
|
||||
mss_uart_instance_t * this_uart,
|
||||
uint32_t baudrate
|
||||
uint32_t baudrate
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -95,10 +95,10 @@ mss_uart_instance_t g_mss_uart1;
|
|||
/***************************************************************************//**
|
||||
* See mss_uart.h for details of how to use this function.
|
||||
*/
|
||||
void
|
||||
void
|
||||
MSS_UART_init
|
||||
(
|
||||
mss_uart_instance_t* this_uart,
|
||||
mss_uart_instance_t* this_uart,
|
||||
uint32_t baud_rate,
|
||||
uint8_t line_config
|
||||
)
|
||||
|
@ -128,7 +128,7 @@ MSS_UART_init
|
|||
*/
|
||||
void MSS_UART_lin_init
|
||||
(
|
||||
mss_uart_instance_t* this_uart,
|
||||
mss_uart_instance_t* this_uart,
|
||||
uint32_t baud_rate,
|
||||
uint8_t line_config
|
||||
)
|
||||
|
@ -153,10 +153,10 @@ void MSS_UART_lin_init
|
|||
/***************************************************************************//**
|
||||
* See mss_uart.h for details of how to use this function.
|
||||
*/
|
||||
void
|
||||
void
|
||||
MSS_UART_irda_init
|
||||
(
|
||||
mss_uart_instance_t* this_uart,
|
||||
mss_uart_instance_t* this_uart,
|
||||
uint32_t baud_rate,
|
||||
uint8_t line_config,
|
||||
mss_uart_rzi_polarity_t rxpol,
|
||||
|
@ -176,13 +176,13 @@ MSS_UART_irda_init
|
|||
|
||||
/* Disable IrDA mode */
|
||||
set_bit_reg8(&this_uart->hw_reg->MM1, EIRD);
|
||||
((rxpol == MSS_UART_ACTIVE_LOW) ? clear_bit_reg8(&this_uart->hw_reg->MM1,EIRX) :
|
||||
((rxpol == MSS_UART_ACTIVE_LOW) ? clear_bit_reg8(&this_uart->hw_reg->MM1,EIRX) :
|
||||
set_bit_reg8(&this_uart->hw_reg->MM1,EIRX));
|
||||
|
||||
((txpol == MSS_UART_ACTIVE_LOW) ? clear_bit_reg8(&this_uart->hw_reg->MM1,EITX) :
|
||||
|
||||
((txpol == MSS_UART_ACTIVE_LOW) ? clear_bit_reg8(&this_uart->hw_reg->MM1,EITX) :
|
||||
set_bit_reg8(&this_uart->hw_reg->MM1,EITX));
|
||||
|
||||
((pw == MSS_UART_3_BY_16) ? clear_bit_reg8(&this_uart->hw_reg->MM1,EITP) :
|
||||
|
||||
((pw == MSS_UART_3_BY_16) ? clear_bit_reg8(&this_uart->hw_reg->MM1,EITP) :
|
||||
set_bit_reg8(&this_uart->hw_reg->MM1,EITP));
|
||||
/* Disable SmartCard Mode */
|
||||
clear_bit_reg8(&this_uart->hw_reg->MM2, EERR);
|
||||
|
@ -191,10 +191,10 @@ MSS_UART_irda_init
|
|||
/***************************************************************************//**
|
||||
* See mss_uart.h for details of how to use this function.
|
||||
*/
|
||||
void
|
||||
void
|
||||
MSS_UART_smartcard_init
|
||||
(
|
||||
mss_uart_instance_t* this_uart,
|
||||
mss_uart_instance_t* this_uart,
|
||||
uint32_t baud_rate,
|
||||
uint8_t line_config
|
||||
)
|
||||
|
@ -205,7 +205,7 @@ MSS_UART_smartcard_init
|
|||
|
||||
/* Perform generic initialization */
|
||||
global_init(this_uart, baud_rate, line_config);
|
||||
|
||||
|
||||
/* Disable LIN mode */
|
||||
clear_bit_reg8(&this_uart->hw_reg->MM0, ELIN);
|
||||
|
||||
|
@ -213,10 +213,10 @@ MSS_UART_smartcard_init
|
|||
clear_bit_reg8(&this_uart->hw_reg->MM1, EIRD);
|
||||
|
||||
/* Enable SmartCard Mode : Only when data is 8-bit and 2 stop bits*/
|
||||
if( ( MSS_UART_DATA_8_BITS | MSS_UART_TWO_STOP_BITS) ==
|
||||
if( ( MSS_UART_DATA_8_BITS | MSS_UART_TWO_STOP_BITS) ==
|
||||
(line_config & (MSS_UART_DATA_8_BITS | MSS_UART_TWO_STOP_BITS)))
|
||||
{
|
||||
set_bit_reg8(&this_uart->hw_reg->MM2, EERR);
|
||||
set_bit_reg8(&this_uart->hw_reg->MM2, EERR);
|
||||
/* Enable single wire half-duplex mode */
|
||||
set_bit_reg8(&this_uart->hw_reg->MM2,ESWM);
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ MSS_UART_enable_irq
|
|||
ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1));
|
||||
ASSERT(MSS_UART_INVALID_IRQ > irq_mask);
|
||||
|
||||
if(((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) &&
|
||||
if(((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) &&
|
||||
(MSS_UART_INVALID_IRQ > irq_mask))
|
||||
{
|
||||
/* Clear any previously pended interrupts */
|
||||
|
@ -460,10 +460,10 @@ MSS_UART_enable_irq
|
|||
*/
|
||||
this_uart->hw_reg->IER |= (uint8_t)irq_mask & IIRF_MASK;
|
||||
|
||||
/*
|
||||
/*
|
||||
* bit 4 - Receiver time-out interrupt
|
||||
* bit 5 - NACK / ERR signal interrupt
|
||||
* bit 6 - PID parity error interrupt
|
||||
* bit 6 - PID parity error interrupt
|
||||
* bit 7 - LIN break detection interrupt
|
||||
* bit 8 - LIN Sync detection interrupt
|
||||
*/
|
||||
|
@ -496,10 +496,10 @@ MSS_UART_disable_irq
|
|||
*/
|
||||
this_uart->hw_reg->IER &= ((uint8_t)(~((uint32_t)irq_mask & (uint32_t)IIRF_MASK)));
|
||||
|
||||
/*
|
||||
/*
|
||||
* bit 4 - Receiver time-out interrupt
|
||||
* bit 5 - NACK / ERR signal interrupt
|
||||
* bit 6 - PID parity error interrupt
|
||||
* bit 6 - PID parity error interrupt
|
||||
* bit 7 - LIN break detection interrupt
|
||||
* bit 8 - LIN Sync detection interrupt
|
||||
*/
|
||||
|
@ -575,28 +575,28 @@ MSS_UART_set_loopback
|
|||
/* Disable local loopback */
|
||||
clear_bit_reg8(&this_uart->hw_reg->MCR,LOOP);
|
||||
break;
|
||||
|
||||
|
||||
case MSS_UART_LOCAL_LOOPBACK_ON:
|
||||
/* Enable local loopback */
|
||||
set_bit_reg8(&this_uart->hw_reg->MCR,LOOP);
|
||||
break;
|
||||
|
||||
|
||||
case MSS_UART_REMOTE_LOOPBACK_OFF:
|
||||
case MSS_UART_AUTO_ECHO_OFF:
|
||||
/* Disable remote loopback & automatic echo*/
|
||||
this_uart->hw_reg->MCR &= ~RLOOP_MASK;
|
||||
break;
|
||||
|
||||
|
||||
case MSS_UART_REMOTE_LOOPBACK_ON:
|
||||
/* Enable remote loopback */
|
||||
this_uart->hw_reg->MCR |= (1u << RLOOP);
|
||||
break;
|
||||
|
||||
|
||||
case MSS_UART_AUTO_ECHO_ON:
|
||||
/* Enable automatic echo */
|
||||
this_uart->hw_reg->MCR |= (1u << ECHO);
|
||||
break;
|
||||
|
||||
|
||||
case MSS_UART_INVALID_LOOPBACK:
|
||||
/* Fall through to default. */
|
||||
default:
|
||||
|
@ -1045,7 +1045,7 @@ MSS_UART_set_rx_timeout_handler
|
|||
/***************************************************************************//**
|
||||
* See mss_uart.h for details of how to use this function.
|
||||
*/
|
||||
void
|
||||
void
|
||||
MSS_UART_enable_half_duplex
|
||||
(
|
||||
mss_uart_instance_t * this_uart
|
||||
|
@ -1062,7 +1062,7 @@ MSS_UART_enable_half_duplex
|
|||
/***************************************************************************//**
|
||||
* See mss_uart.h for details of how to use this function.
|
||||
*/
|
||||
void
|
||||
void
|
||||
MSS_UART_disable_half_duplex
|
||||
(
|
||||
mss_uart_instance_t * this_uart
|
||||
|
@ -1083,13 +1083,13 @@ void
|
|||
MSS_UART_set_rx_endian
|
||||
(
|
||||
mss_uart_instance_t * this_uart,
|
||||
mss_uart_endian_t endian
|
||||
mss_uart_endian_t endian
|
||||
)
|
||||
{
|
||||
ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1));
|
||||
ASSERT(MSS_UART_INVALID_ENDIAN > endian);
|
||||
|
||||
if(((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) &&
|
||||
if(((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) &&
|
||||
(MSS_UART_INVALID_ENDIAN > endian))
|
||||
{
|
||||
/* Configure MSB first / LSB first for receiver */
|
||||
|
@ -1105,13 +1105,13 @@ void
|
|||
MSS_UART_set_tx_endian
|
||||
(
|
||||
mss_uart_instance_t * this_uart,
|
||||
mss_uart_endian_t endian
|
||||
mss_uart_endian_t endian
|
||||
)
|
||||
{
|
||||
ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1));
|
||||
ASSERT(MSS_UART_INVALID_ENDIAN > endian);
|
||||
|
||||
if(((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) &&
|
||||
if(((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) &&
|
||||
(MSS_UART_INVALID_ENDIAN > endian))
|
||||
{
|
||||
/* Configure MSB first / LSB first for transmitter */
|
||||
|
@ -1132,8 +1132,8 @@ MSS_UART_set_filter_length
|
|||
{
|
||||
ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1));
|
||||
ASSERT(MSS_UART_INVALID_FILTER_LENGTH > length);
|
||||
|
||||
if(((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) &&
|
||||
|
||||
if(((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) &&
|
||||
(MSS_UART_INVALID_FILTER_LENGTH > length))
|
||||
{
|
||||
/* Configure glitch filter length */
|
||||
|
@ -1192,7 +1192,7 @@ MSS_UART_enable_afclear
|
|||
if((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1))
|
||||
{
|
||||
/* Enable address flag clearing */
|
||||
/* Disable RX FIFO till another address flag with
|
||||
/* Disable RX FIFO till another address flag with
|
||||
correct address is received */
|
||||
set_bit_reg8(&this_uart->hw_reg->MM2,EAFC);
|
||||
}
|
||||
|
@ -1219,7 +1219,7 @@ MSS_UART_disable_afclear
|
|||
/***************************************************************************//**
|
||||
* See mss_uart.h for details of how to use this function.
|
||||
*/
|
||||
void
|
||||
void
|
||||
MSS_UART_enable_rx_timeout
|
||||
(
|
||||
mss_uart_instance_t * this_uart,
|
||||
|
@ -1240,7 +1240,7 @@ MSS_UART_enable_rx_timeout
|
|||
/***************************************************************************//**
|
||||
* See mss_uart.h for details of how to use this function.
|
||||
*/
|
||||
void
|
||||
void
|
||||
MSS_UART_disable_rx_timeout
|
||||
(
|
||||
mss_uart_instance_t * this_uart
|
||||
|
@ -1258,7 +1258,7 @@ MSS_UART_disable_rx_timeout
|
|||
/***************************************************************************//**
|
||||
* See mss_uart.h for details of how to use this function.
|
||||
*/
|
||||
void
|
||||
void
|
||||
MSS_UART_enable_tx_time_guard
|
||||
(
|
||||
mss_uart_instance_t * this_uart,
|
||||
|
@ -1279,7 +1279,7 @@ MSS_UART_enable_tx_time_guard
|
|||
/***************************************************************************//**
|
||||
* See mss_uart.h for details of how to use this function.
|
||||
*/
|
||||
void
|
||||
void
|
||||
MSS_UART_disable_tx_time_guard
|
||||
(
|
||||
mss_uart_instance_t * this_uart
|
||||
|
@ -1315,11 +1315,11 @@ MSS_UART_set_address
|
|||
/***************************************************************************//**
|
||||
* See mss_uart.h for details of how to use this function.
|
||||
*/
|
||||
void
|
||||
void
|
||||
MSS_UART_set_ready_mode
|
||||
(
|
||||
mss_uart_instance_t * this_uart,
|
||||
mss_uart_ready_mode_t mode
|
||||
mss_uart_ready_mode_t mode
|
||||
)
|
||||
{
|
||||
ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1));
|
||||
|
@ -1330,7 +1330,7 @@ MSS_UART_set_ready_mode
|
|||
{
|
||||
/* Configure mode 0 or mode 1 for TXRDY and RXRDY */
|
||||
((MSS_UART_READY_MODE0 == mode) ? clear_bit_reg8(&this_uart->hw_reg->FCR,RDYMODE) :
|
||||
set_bit_reg8(&this_uart->hw_reg->FCR,RDYMODE) );
|
||||
set_bit_reg8(&this_uart->hw_reg->FCR,RDYMODE) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1341,11 +1341,11 @@ static void
|
|||
config_baud_divisors
|
||||
(
|
||||
mss_uart_instance_t * this_uart,
|
||||
uint32_t baudrate
|
||||
uint32_t baudrate
|
||||
)
|
||||
{
|
||||
ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1));
|
||||
|
||||
|
||||
if((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1))
|
||||
{
|
||||
uint32_t baud_value;
|
||||
|
@ -1378,31 +1378,31 @@ config_baud_divisors
|
|||
baud_value = baud_value_by_64 / 64u;
|
||||
fractional_baud_value = baud_value_by_64 - (baud_value * 64u);
|
||||
fractional_baud_value += (baud_value_by_128 - (baud_value * 128u)) - (fractional_baud_value * 2u);
|
||||
|
||||
|
||||
/* Assert if integer baud value fits in 16-bit. */
|
||||
ASSERT(baud_value <= UINT16_MAX);
|
||||
|
||||
|
||||
if(baud_value <= (uint32_t)UINT16_MAX)
|
||||
{
|
||||
if(baud_value > 1u)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* Use Frational baud rate divisors
|
||||
*/
|
||||
/* set divisor latch */
|
||||
set_bit_reg8(&this_uart->hw_reg->LCR,DLAB);
|
||||
|
||||
|
||||
/* msb of baud value */
|
||||
this_uart->hw_reg->DMR = (uint8_t)(baud_value >> 8);
|
||||
/* lsb of baud value */
|
||||
this_uart->hw_reg->DLR = (uint8_t)baud_value;
|
||||
|
||||
|
||||
/* reset divisor latch */
|
||||
clear_bit_reg8(&this_uart->hw_reg->LCR,DLAB);
|
||||
|
||||
|
||||
/* Enable Fractional baud rate */
|
||||
set_bit_reg8(&this_uart->hw_reg->MM0,EFBR);
|
||||
|
||||
|
||||
/* Load the fractional baud rate register */
|
||||
ASSERT(fractional_baud_value <= (uint32_t)UINT8_MAX);
|
||||
this_uart->hw_reg->DFR = (uint8_t)fractional_baud_value;
|
||||
|
@ -1414,15 +1414,15 @@ config_baud_divisors
|
|||
*/
|
||||
/* set divisor latch */
|
||||
set_bit_reg8(&this_uart->hw_reg->LCR,DLAB);
|
||||
|
||||
|
||||
/* msb of baud value */
|
||||
this_uart->hw_reg->DMR = (uint8_t)(baud_value >> 8u);
|
||||
/* lsb of baud value */
|
||||
this_uart->hw_reg->DLR = (uint8_t)baud_value;
|
||||
|
||||
|
||||
/* reset divisor latch */
|
||||
clear_bit_reg8(&this_uart->hw_reg->LCR,DLAB);
|
||||
|
||||
|
||||
/* Disable Fractional baud rate */
|
||||
clear_bit_reg8(&this_uart->hw_reg->MM0,EFBR);
|
||||
}
|
||||
|
@ -1433,7 +1433,7 @@ config_baud_divisors
|
|||
/***************************************************************************//**
|
||||
* See mss_uart.h for details of how to use this function.
|
||||
*/
|
||||
void
|
||||
void
|
||||
MSS_UART_set_usart_mode
|
||||
(
|
||||
mss_uart_instance_t * this_uart,
|
||||
|
@ -1521,13 +1521,13 @@ static void global_init
|
|||
clear_bit_reg8(&this_uart->hw_reg->MM2,EAFM);
|
||||
|
||||
/* disable TX time gaurd */
|
||||
clear_bit_reg8(&this_uart->hw_reg->MM0,ETTG);
|
||||
clear_bit_reg8(&this_uart->hw_reg->MM0,ETTG);
|
||||
|
||||
/* set default RX timeout */
|
||||
clear_bit_reg8(&this_uart->hw_reg->MM0,ERTO);
|
||||
clear_bit_reg8(&this_uart->hw_reg->MM0,ERTO);
|
||||
|
||||
/* disable fractional baud-rate */
|
||||
clear_bit_reg8(&this_uart->hw_reg->MM0,EFBR);
|
||||
clear_bit_reg8(&this_uart->hw_reg->MM0,EFBR);
|
||||
|
||||
/* disable single wire mode */
|
||||
clear_bit_reg8(&this_uart->hw_reg->MM2,ESWM);
|
||||
|
@ -1538,8 +1538,8 @@ static void global_init
|
|||
this_uart->hw_reg->TTG = 0u;
|
||||
/* set default RX timeout */
|
||||
this_uart->hw_reg->RTO = 0u;
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Configure baud rate divisors. This uses the frational baud rate divisor
|
||||
* where possible to provide the most accurate baud rat possible.
|
||||
*/
|
||||
|
@ -1560,11 +1560,11 @@ static void global_init
|
|||
this_uart->tx_handler = NULL_HANDLER;
|
||||
this_uart->linests_handler = NULL_HANDLER;
|
||||
this_uart->modemsts_handler = NULL_HANDLER;
|
||||
this_uart->rto_handler = NULL_HANDLER;
|
||||
this_uart->nack_handler = NULL_HANDLER;
|
||||
this_uart->rto_handler = NULL_HANDLER;
|
||||
this_uart->nack_handler = NULL_HANDLER;
|
||||
this_uart->pid_pei_handler = NULL_HANDLER;
|
||||
this_uart->break_handler = NULL_HANDLER;
|
||||
this_uart->sync_handler = NULL_HANDLER;
|
||||
this_uart->break_handler = NULL_HANDLER;
|
||||
this_uart->sync_handler = NULL_HANDLER;
|
||||
|
||||
/* Initialize the sticky status */
|
||||
this_uart->status = 0u;
|
||||
|
|
Loading…
Reference in a new issue