#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().
typedef struct usartPrivateData xUsartPrivateData |
|
static |
References NULL, pdFAIL, pdPASS, and xQueueCreate().
Referenced by xUsartInit().
|
static |
References pdFALSE, pdTRUE, portENTER_CRITICAL, portEXIT_CRITICAL, usartPrivateData::usart, usartPrivateData::xCharsForTx, xQueueReceiveFromISR(), xQueueSendFromISR, and usartPrivateData::xRxedChars.
Referenced by vUSART0_ISR(), and vUSART1_ISR().
unsigned portSHORT usUsartPutString | ( | xComPortHandle | pxPort, |
const signed portCHAR *const | pcString, | ||
unsigned portSHORT | usStringLength | ||
) |
Put a string to Usart.
pxPort | The Usart handle to put the string to |
pcString | The string to transmit |
usStringLength | The 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.
xPort | The handle of the usart to close |
References usartPrivateData::usart.
void vUSART0_ISR | ( | void | ) |
References portENTER_SWITCHING_ISR, portEXIT_SWITCHING_ISR, and prvUSART_ISR_NonNakedBehaviour().
Referenced by xUsartInit().
|
static |
References portENTER_SWITCHING_ISR, portEXIT_SWITCHING_ISR, and prvUSART_ISR_NonNakedBehaviour().
Referenced by xUsartInit().
signed portBASE_TYPE xUsartGetChar | ( | xComPortHandle | pxPort, |
signed portCHAR * | pcRxedChar, | ||
portTickType | xBlockTime | ||
) |
Get char from Usart.
pxPort | The Usart handle to get the char from |
pcRxedChar | The rxed char(output) |
xBlockTime | The 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.
UsartId | The identifier of the Usart to init. |
ulWantedBaud | The required baudrate. |
uxRxQueueLength | The length of the Rx buffer (if 0, rx is not supported). |
uxTxQueueLength | The length of the Tx buffer (if 0, tx is not supported). |
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.
pxPort | The Usart handle to put the char to |
cOutChar | The char to transmit |
xBlockTime | The 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().