Robobo
|
#include "../chip.h"
#include <stdint.h>
Go to the source code of this file.
Macros | |
#define | USART_MODE_ASYNCHRONOUS (US_MR_CHRL_8_BIT | US_MR_PAR_NO) |
#define | USART_MODE_IRDA (AT91C_US_USMODE_IRDA | AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE | AT91C_US_FILTER) |
#define | AT91C_US_USMODE_SPIM 0xE |
#define | US_SPI_CPOL_0 (0x0<<16) |
#define | US_SPI_CPHA_0 (0x0<<8) |
#define | US_SPI_CPOL_1 (0x1<<16) |
#define | US_SPI_CPHA_1 (0x1<<8) |
#define | US_SPI_BPMODE_0 (US_SPI_CPOL_0|US_SPI_CPHA_1) |
#define | US_SPI_BPMODE_1 (US_SPI_CPOL_0|US_SPI_CPHA_0) |
#define | US_SPI_BPMODE_2 (US_SPI_CPOL_1|US_SPI_CPHA_1) |
#define | US_SPI_BPMODE_3 (US_SPI_CPOL_1|US_SPI_CPHA_0) |
Functions | |
void | USART_Configure (Usart *usart, uint32_t mode, uint32_t baudrate, uint32_t masterClock) |
Configures an USART peripheral with the specified parameters. More... | |
uint32_t | USART_GetStatus (Usart *usart) |
Get present status. | |
void | USART_EnableIt (Usart *usart, uint32_t mode) |
Enable interrupt. | |
void | USART_DisableIt (Usart *usart, uint32_t mode) |
Disable interrupt. | |
void | USART_SetTransmitterEnabled (Usart *usart, uint8_t enabled) |
Enables or disables the transmitter of an USART peripheral. More... | |
void | USART_SetReceiverEnabled (Usart *usart, uint8_t enabled) |
Enables or disables the receiver of an USART peripheral. More... | |
void | USART_Write (Usart *usart, uint16_t data, volatile uint32_t timeOut) |
Sends one packet of data through the specified USART peripheral. This function operates synchronously, so it only returns when the data has been actually sent. More... | |
uint8_t | USART_WriteBuffer (Usart *usart, void *buffer, uint32_t size) |
Sends the contents of a data buffer through the specified USART peripheral. This function returns immediately (1 if the buffer has been queued, 0 otherwise); poll the ENDTX and TXBUFE bits of the USART status register to check for the transfer completion. More... | |
uint16_t | USART_Read (Usart *usart, volatile uint32_t timeOut) |
Reads and return a packet of data on the specified USART peripheral. This function operates asynchronously, so it waits until some data has been received. More... | |
uint8_t | USART_ReadBuffer (Usart *usart, void *buffer, uint32_t size) |
Reads data from an USART peripheral, filling the provided buffer until it becomes full. This function returns immediately with 1 if the buffer has been queued for transmission; otherwise 0. More... | |
uint8_t | USART_IsDataAvailable (Usart *usart) |
Returns 1 if some data has been received and can be read from an USART; otherwise returns 0. More... | |
void | USART_SetIrdaFilter (Usart *pUsart, uint8_t filter) |
Sets the filter value for the IRDA demodulator. More... | |
void | USART_PutChar (Usart *usart, uint8_t c) |
Sends one packet of data through the specified USART peripheral. This function operates synchronously, so it only returns when the data has been actually sent. More... | |
uint32_t | USART_IsRxReady (Usart *usart) |
Return 1 if a character can be read in USART. | |
uint8_t | USART_GetChar (Usart *usart) |
Reads and returns a character from the USART. More... | |
This module provides several definitions and methods for using an USART peripheral.
#define AT91C_US_USMODE_SPIM 0xE |
SPI mode
#define USART_MODE_ASYNCHRONOUS (US_MR_CHRL_8_BIT | US_MR_PAR_NO) |
#define USART_MODE_IRDA (AT91C_US_USMODE_IRDA | AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE | AT91C_US_FILTER) |
IRDA mode
void USART_Configure | ( | Usart * | usart, |
uint32_t | mode, | ||
uint32_t | baudrate, | ||
uint32_t | masterClock | ||
) |
Configures an USART peripheral with the specified parameters.
usart | Pointer to the USART peripheral to configure. |
mode | Desired value for the USART mode register (see the datasheet). |
baudrate | Baudrate at which the USART should operate (in Hz). |
masterClock | Frequency of the system master clock (in Hz). |
uint8_t USART_GetChar | ( | Usart * | usart | ) |
Reads and returns a character from the USART.
usart | Pointer to an USART peripheral. |
uint8_t USART_IsDataAvailable | ( | Usart * | usart | ) |
Returns 1 if some data has been received and can be read from an USART; otherwise returns 0.
usart | Pointer to an Usart instance. |
void USART_PutChar | ( | Usart * | usart, |
uint8_t | c | ||
) |
Sends one packet of data through the specified USART peripheral. This function operates synchronously, so it only returns when the data has been actually sent.
usart | Pointer to an USART peripheral. |
c | Character to send |
uint16_t USART_Read | ( | Usart * | usart, |
volatile uint32_t | timeOut | ||
) |
Reads and return a packet of data on the specified USART peripheral. This function operates asynchronously, so it waits until some data has been received.
usart | Pointer to an USART peripheral. |
timeOut | Time out value (0 -> no timeout). |
uint8_t USART_ReadBuffer | ( | Usart * | usart, |
void * | buffer, | ||
uint32_t | size | ||
) |
Reads data from an USART peripheral, filling the provided buffer until it becomes full. This function returns immediately with 1 if the buffer has been queued for transmission; otherwise 0.
usart | Pointer to an USART peripheral. |
buffer | Pointer to the buffer where the received data will be stored. |
size | Size of the data buffer (in bytes). |
void USART_SetIrdaFilter | ( | Usart * | pUsart, |
uint8_t | filter | ||
) |
Sets the filter value for the IRDA demodulator.
pUsart | Pointer to an Usart instance. |
filter | Filter value. |
void USART_SetReceiverEnabled | ( | Usart * | usart, |
uint8_t | enabled | ||
) |
Enables or disables the receiver of an USART peripheral.
usart | Pointer to an USART peripheral |
enabled | If true, the receiver is enabled; otherwise it is disabled. |
void USART_SetTransmitterEnabled | ( | Usart * | usart, |
uint8_t | enabled | ||
) |
Enables or disables the transmitter of an USART peripheral.
usart | Pointer to an USART peripheral |
enabled | If true, the transmitter is enabled; otherwise it is disabled. |
void USART_Write | ( | Usart * | usart, |
uint16_t | data, | ||
volatile uint32_t | timeOut | ||
) |
Sends one packet of data through the specified USART peripheral. This function operates synchronously, so it only returns when the data has been actually sent.
usart | Pointer to an USART peripheral. |
data | Data to send including 9nth bit and sync field if necessary (in the same format as the US_THR register in the datasheet). |
timeOut | Time out value (0 = no timeout). |
uint8_t USART_WriteBuffer | ( | Usart * | usart, |
void * | buffer, | ||
uint32_t | size | ||
) |
Sends the contents of a data buffer through the specified USART peripheral. This function returns immediately (1 if the buffer has been queued, 0 otherwise); poll the ENDTX and TXBUFE bits of the USART status register to check for the transfer completion.
usart | Pointer to an USART peripheral. |
buffer | Pointer to the data buffer to send. |
size | Size of the data buffer (in bytes). |