core/uart/uart.c File Reference
#include "sceptre.h"
#include "uart.h"
#include <string.h>
Go to the source code of this file.
Data Structures |
struct | uart_buffer_t |
struct | uart_rx_tx_buffer_t |
Defines |
#define | UART_BUFFER_SIZE 0x200 |
#define | UART_BUFFER_MASK (UART_BUFFER_SIZE-1) |
#define | UART0_RX_FIFO_SIZE 16 |
#define | UART0_TX_FIFO_SIZE 16 |
#define | UART1_RX_FIFO_SIZE 16 |
#define | UART1_TX_FIFO_SIZE 16 |
Functions |
void | uart0_handler (void) |
uint32_t | uart_buffer_has_data (uart_buffer_t *p_buffer) |
bool_t | uart_buffer_is_full (uart_buffer_t *p_buffer) |
bool_t | uart_buffer_getc (uint32_t *p_ch, uart_buffer_t *p_buffer) |
bool_t | uart_buffer_putc (uint32_t ch, uart_buffer_t *p_buffer) |
bool_t | uart0_init (uint32_t baudrate, uint8_t data_bits, char parity, uint8_t stop_bits) |
uint32_t | uart0_send (const uint8_t *p_data, uint32_t data_size, bool_t cr_to_crlf) |
bool_t | uart0_putc (uint32_t ch) |
bool_t | uart0_getc (uint32_t *p_ch, uint32_t timeout_in_ms) |
void | uart0_flush_buffers (void) |
void | uart0_set_rx_hook (uart_rx_hook_t f) |
void | uart1_handler (void) |
bool_t | uart1_init (uint32_t baudrate, uint8_t data_bits, char parity, uint8_t stop_bits) |
uint32_t | uart1_send (const uint8_t *p_data, uint32_t data_size, bool_t cr_to_crlf) |
bool_t | uart1_putc (uint32_t ch, bool_t right_now) |
bool_t | uart1_getc (uint32_t *p_ch, uint32_t timeout_in_ms) |
void | uart1_flush_buffers (void) |
void | uart1_set_rx_hook (uart_rx_hook_t f) |
Detailed Description
Implementation of UART0 & UART1 drivers.
Definition in file uart.c.
Function Documentation
void uart0_flush_buffers |
( |
void |
|
) |
|
Clear the TX & RX data buffers of UART0.
Definition at line 358 of file uart.c.
bool_t uart0_getc |
( |
uint32_t * |
p_ch, |
|
|
uint32_t |
timeout_in_ms | |
|
) |
| | |
Get a character from UART0.
- Parameters:
-
| p_ch | Pointer to variable where the received character will be stored. |
| timeout_in_ms | Time (ms) to wait for a character to come in, 0 equals no wait. |
- Returns:
- true on success, false otherwise.
Definition at line 345 of file uart.c.
void uart0_handler |
( |
void |
|
) |
|
Flush a buffer.
- Parameters:
-
| p_buffer | Pointer to the buffer to flush. |
UART0 interrupt handler
Definition at line 156 of file uart.c.
bool_t uart0_init |
( |
uint32_t |
baudrate, |
|
|
uint8_t |
data_bits, |
|
|
char |
parity, |
|
|
uint8_t |
stop_bits | |
|
) |
| | |
Initialize UART0, setup pin select, clock, parity, stop bits, FIFO, etc.
- Parameters:
-
| baudrate | Baudrate |
| data_bits | Number of data bits [5,6,7,8] |
| parity | Parity ['n','N,'o','O','e','E','1','0'] |
| stop_bits | Number of stop bits [1,2] |
- Returns:
- false if the interrupt handler could not be installed in the VIC table, true otherwise.
Definition at line 239 of file uart.c.
bool_t uart0_putc |
( |
uint32_t |
ch |
) |
|
Send one character using UART0.
- Parameters:
-
- Returns:
- true on success, false otherwise.
Definition at line 325 of file uart.c.
uint32_t uart0_send |
( |
const uint8_t * |
p_data, |
|
|
uint32_t |
data_size, |
|
|
bool_t |
cr_to_crlf | |
|
) |
| | |
Send a block of data using UART0.
- Parameters:
-
| p_data | Pointer to data. |
| data_size | Number of bytes to send. |
| cr_to_crlf | Convert CR to CRLF or not. |
- Returns:
- The number of characters sent.
Definition at line 301 of file uart.c.
Set RX hook for UART1.
- Parameters:
-
| f | Pointer to hook function. |
Definition at line 370 of file uart.c.
void uart1_flush_buffers |
( |
void |
|
) |
|
Clear the TX & RX data buffers of UART1.
Definition at line 586 of file uart.c.
bool_t uart1_getc |
( |
uint32_t * |
p_ch, |
|
|
uint32_t |
timeout_in_ms | |
|
) |
| | |
Get a character from UART1.
- Parameters:
-
| p_ch | Pointer to variable where the received character will be stored. |
| timeout_in_ms | Time (ms) to wait for a character to come in, 0 equals no wait. |
- Returns:
- true on success, false otherwise.
Definition at line 573 of file uart.c.
void uart1_handler |
( |
void |
|
) |
|
UART0 interrupt handler
Definition at line 384 of file uart.c.
bool_t uart1_init |
( |
uint32_t |
baudrate, |
|
|
uint8_t |
data_bits, |
|
|
char |
parity, |
|
|
uint8_t |
stop_bits | |
|
) |
| | |
Initialize UART1, setup pin select, clock, parity, stop bits, FIFO, etc.
- Parameters:
-
| baudrate | Baudrate |
| data_bits | Number of data bits [5,6,7,8] |
| parity | Parity ['n','N,'o','O','e','E','1','0'] |
| stop_bits | Number of stop bits [1,2] |
- Returns:
- false if the interrupt handler could not be installed in the VIC table, true otherwise.
Definition at line 467 of file uart.c.
Send one character using UART1.
- Parameters:
-
| ch | Character to send. |
| right_now | If true will send character immediately. |
- Returns:
- true on success, false otherwise.
Definition at line 546 of file uart.c.
uint32_t uart1_send |
( |
const uint8_t * |
p_data, |
|
|
uint32_t |
data_size, |
|
|
bool_t |
cr_to_crlf | |
|
) |
| | |
Send a block of data using UART1.
- Parameters:
-
| p_data | Pointer to data. |
| data_size | Number of bytes to send. |
| cr_to_crlf | Convert CR to CRLF or not. |
- Returns:
- The number of characters sent.
Definition at line 521 of file uart.c.
Set RX hook for UART1.
- Parameters:
-
| f | Pointer to hook function. |
Definition at line 598 of file uart.c.
Get the next character from the buffer.
- Parameters:
-
| p_ch | Pointer to variable where the character will be stored. |
| p_buffer | Pointer to the buffer to get the character from. |
- Returns:
- true if a character was read, false if not.
Definition at line 114 of file uart.c.
uint32_t uart_buffer_has_data |
( |
uart_buffer_t * |
p_buffer |
) |
[inline] |
Get the number of characters available in a buffer.
- Parameters:
-
| p_buffer | Pointer to the buffer. |
- Returns:
- The number of characters in the buffer.
Definition at line 89 of file uart.c.
Check if a buffer is full or not.
- Parameters:
-
| p_buffer | Pointer to the buffer to check. |
- Returns:
- true if the buffer is full, false if it isn't.
Definition at line 101 of file uart.c.
Put a character in the buffer.
- Parameters:
-
| ch | Character to put in the buffer. |
| p_buffer | Pointer to the buffer to put the character in. |
- Returns:
- true if the character was written, false if it wasn't.
Definition at line 133 of file uart.c.