Microchip® Advanced Software Framework

avr32/applications/evk1100-control-panel/serial/serial.c File Reference
#include "gpio.h"
#include "FreeRTOS.h"
#include "queue.h"
#include "task.h"
#include "serial.h"
#include <avr32/io.h>
#include "board.h"
#include "usart.h"

Data Structures

struct  usartPrivateData
 

Macros

#define serHANDLE   ( ( xComPortHandle ) 1 )
 
#define serINVALID_COMPORT_HANDLER   ( ( xComPortHandle ) 0 )
 
#define serINVALID_QUEUE   ( ( xQueueHandle ) 0 )
 
#define serNO_BLOCK   ( ( portTickType ) 0 )
 

Typedefs

typedef struct usartPrivateData xUsartPrivateData
 

Functions

static int iprvSerialCreateQueues (unsigned portBASE_TYPE uxRxQueueLength, xQueueHandle *pxRxedChars, unsigned portBASE_TYPE uxTxQueueLength, xQueueHandle *pxCharsForTx)
 
static portBASE_TYPE prvUSART_ISR_NonNakedBehaviour (xUsartPrivateData *pxUsart)
 
unsigned portSHORT usUsartPutString (xComPortHandle pxPort, const signed portCHAR *const pcString, unsigned portSHORT usStringLength)
 Put a string to Usart. More...
 
void vSerialClose (xComPortHandle xPort)
 Close the serial port. More...
 
void vUSART0_ISR (void)
 
static void vUSART1_ISR (void)
 
signed portBASE_TYPE xUsartGetChar (xComPortHandle pxPort, signed portCHAR *pcRxedChar, portTickType xBlockTime)
 Get char from Usart. More...
 
xComPortHandle xUsartInit (eCOMPort UsartId, unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxRxQueueLength, unsigned portBASE_TYPE uxTxQueueLength)
 Init the serial port. More...
 
signed portBASE_TYPE xUsartPutChar (xComPortHandle pxPort, signed portCHAR cOutChar, portTickType xBlockTime)
 Put char to Usart. More...
 

Variables

xUsartPrivateData xUsart0 = {&AVR32_USART0, NULL, NULL}
 
xUsartPrivateData xUsart1 = {&AVR32_USART1, NULL, NULL}
 

#define serHANDLE   ( ( xComPortHandle ) 1 )
#define serINVALID_COMPORT_HANDLER   ( ( xComPortHandle ) 0 )

Referenced by xUsartInit().

#define serINVALID_QUEUE   ( ( xQueueHandle ) 0 )
#define serNO_BLOCK   ( ( portTickType ) 0 )

Referenced by usUsartPutString().

static int iprvSerialCreateQueues ( unsigned portBASE_TYPE  uxRxQueueLength,
xQueueHandle pxRxedChars,
unsigned portBASE_TYPE  uxTxQueueLength,
xQueueHandle pxCharsForTx 
)
static

References NULL, pdFAIL, pdPASS, and xQueueCreate().

Referenced by xUsartInit().

unsigned portSHORT usUsartPutString ( xComPortHandle  pxPort,
const signed portCHAR *const  pcString,
unsigned portSHORT  usStringLength 
)

Put a string to Usart.

Parameters
pxPortThe Usart handle to put the string to
pcStringThe string to transmit
usStringLengthThe number of char to transmit.

References pdPASS, serNO_BLOCK, and xUsartPutChar().

Referenced by ustracedump_Print(), vcom1shell_PrintMsg(), and vtracedump_PrintBlocking().

void vSerialClose ( xComPortHandle  xPort)

Close the serial port.

Parameters
xPortThe handle of the usart to close

References usartPrivateData::usart.

void vUSART0_ISR ( void  )
static void vUSART1_ISR ( void  )
static
signed portBASE_TYPE xUsartGetChar ( xComPortHandle  pxPort,
signed portCHAR *  pcRxedChar,
portTickType  xBlockTime 
)

Get char from Usart.

Parameters
pxPortThe Usart handle to get the char from
pcRxedCharThe rxed char(output)
xBlockTimeThe max time to wait for a rxed char

References pdFALSE, pdTRUE, xQueueReceive, and usartPrivateData::xRxedChars.

Referenced by com1shell_GetChar(), and prvGetChar().

xComPortHandle xUsartInit ( eCOMPort  UsartId,
unsigned portLONG  ulWantedBaud,
unsigned portBASE_TYPE  uxRxQueueLength,
unsigned portBASE_TYPE  uxTxQueueLength 
)

Init the serial port.

Parameters
UsartIdThe identifier of the Usart to init.
ulWantedBaudThe required baudrate.
uxRxQueueLengthThe length of the Rx buffer (if 0, rx is not supported).
uxTxQueueLengthThe length of the Tx buffer (if 0, tx is not supported).
Returns
xComPortHandle Handler on the COM port.

Configure USART.

References usart_options_t::baudrate, CP_PBA_SPEED, gpio_enable_module_pin(), INTC_register_interrupt(), iprvSerialCreateQueues(), pdFAIL, portENTER_CRITICAL, portEXIT_CRITICAL, serCOM1, serINVALID_COMPORT_HANDLER, usartPrivateData::usart, USART_1_STOPBIT, usart_init_rs232(), USART_NO_PARITY, USART_NORMAL_CHMODE, USART_OPTIONS, vUSART0_ISR(), vUSART1_ISR(), usartPrivateData::xCharsForTx, usartPrivateData::xRxedChars, and xUsart1.

Referenced by itracedump_Init(), and portTASK_FUNCTION().

signed portBASE_TYPE xUsartPutChar ( xComPortHandle  pxPort,
signed portCHAR  cOutChar,
portTickType  xBlockTime 
)

Put char to Usart.

Parameters
pxPortThe Usart handle to put the char to
cOutCharThe char to transmit
xBlockTimeThe max time to wait for getting the right to transmit the char.

References pdFAIL, pdPASS, usartPrivateData::usart, usartPrivateData::xCharsForTx, and xQueueSend.

Referenced by usUsartPutString(), vcom1shell_PutChar(), vtracedump_Putchar(), and vtracedump_Putchar_Block().

xUsartPrivateData xUsart0 = {&AVR32_USART0, NULL, NULL}
xUsartPrivateData xUsart1 = {&AVR32_USART1, NULL, NULL}

Referenced by xUsartInit().