#include <avr/io.h>
Go to the source code of this file.
Functions | |
void | USART_init (uint16_t baudval) |
Initialise USART and set baud rate. | |
void | USART_transmit_string (const unsigned char *data) |
Transmit a string via USART at currently set baud rate. | |
void | USART_transmit (unsigned char data) |
Transmit a character via USART at currently set baud rate. | |
void | USART_transmit_uint8 (uint8_t val) |
Transmit an 8 bit unsigned integer via USART at currently set baud rate. | |
void | USART_transmit_int8 (int8_t val) |
Transmit an 8 bit signed integer via USART at currently set baud rate. | |
void | USART_transmit_uint16 (uint16_t val) |
Transmit a 16 bit unsigned integer via USART at currently set baud rate. | |
void | USART_transmit_int16 (int16_t val) |
Transmit a 16 bit signed integer via USART at currently set baud rate. | |
void | USART_transmit_bcd (uint8_t val) |
Interpret an 8 bit unsigned integer as a BCD value and transmit it as two ASCII characters. | |
void | USART_transmit_bin (uint8_t val) |
Transmit an 8 bit unsigned integer as eight ASCII characters 0 or 1. | |
void | USART_transmit_nibble (uint8_t nibble) |
Transmit the lowest 4 bits of an 8 bit unsigned integer as a single ASCII character 0-9 or A-F. | |
uint8_t | USART_receive (void) |
Receive an 8 bit value from the USART by polling. | |
void | USART_flush (void) |
Repeatedly receive and discard values received by the USART until the input buffer empties. | |
void | usart_out_iso_time (uint8_t *time_store) |
Output a time value in ISO format to USART, from data stored in memory. |
void USART_flush | ( | void | ) |
Repeatedly receive and discard values received by the USART until the input buffer empties.
Uses polling.
Note that in the event of continuous input, this function may never complete.
void USART_init | ( | uint16_t | baudval | ) | [inline] |
Initialise USART and set baud rate.
baudval | Value to put in UBRR0 to selectbaud rate. |
The baudval parameter will depend on the CPU clock frequency see the tables in the microcontroller documentation for suitable values
Clears any existing transmissions, turns off double speed, enables transmitter and receiver.
Note that this initialisation DOESN'T enable the interrupts Rx complete and Tx Complete
baudval | Value to put in UBRR to selectbaud rate. |
The baudval parameter will depend on the CPU clock frequency see the tables in the microcontroller documentation for suitable values
Clears any existing transmissions, turns off double speed, enables transmitter and receiver.
Note that this initialisation DOESN'T enable the interrupts Rx complete and Tx Complete
void usart_out_iso_time | ( | uint8_t * | time_store | ) |
Output a time value in ISO format to USART, from data stored in memory.
time_store | Pointer to 7 BCD values representing in order seconds,minutes,hours,day,month,day of week(ignored),year. |
15:23:00 on 3rd April 2010 would be "2010-04-03 15:23:00"
Uses polling. Calls USART_transmit and USART_transmit_hex
Output a time value in ISO format to USART, from data stored in memory.
time_store | Pointer to 7 BCD values representing in order seconds,minutes,hours,day,month,day of week(ignored),year. |
15:23:00 on 3rd April 2010 would be "2010-04-03 15:23:00"
Uses polling. Calls USART_transmit and USART_transmit_hex
uint8_t USART_receive | ( | void | ) |
Receive an 8 bit value from the USART by polling.
void USART_transmit | ( | unsigned char | data | ) |
Transmit a character via USART at currently set baud rate.
data | Character to transmit. |
Uses polling, so waits for transmit buffer to be empty
void USART_transmit_bcd | ( | uint8_t | val | ) |
Interpret an 8 bit unsigned integer as a BCD value and transmit it as two ASCII characters.
val | Value to transmit. |
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART_transmit_bin | ( | uint8_t | val | ) |
Transmit an 8 bit unsigned integer as eight ASCII characters 0 or 1.
val | Value to transmit. |
Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART_transmit_int16 | ( | int16_t | val | ) |
Transmit a 16 bit signed integer via USART at currently set baud rate.
val | value to transmit. |
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART_transmit_int8 | ( | int8_t | val | ) |
Transmit an 8 bit signed integer via USART at currently set baud rate.
val | Value to transmit. |
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART_transmit_nibble | ( | uint8_t | nibble | ) |
Transmit the lowest 4 bits of an 8 bit unsigned integer as a single ASCII character 0-9 or A-F.
nibble | Value to transmit. |
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART_transmit_string | ( | const unsigned char * | data | ) | [inline] |
Transmit a string via USART at currently set baud rate.
data | Pointer to start of string. |
Uses polling, so waits for transmit buffer to be empty
void USART_transmit_uint16 | ( | uint16_t | val | ) |
Transmit a 16 bit unsigned integer via USART at currently set baud rate.
val | Value to transmit. |
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART_transmit_uint8 | ( | uint8_t | val | ) |
Transmit an 8 bit unsigned integer via USART at currently set baud rate.
val | Character to transmit. |
Uses polling, so waits for transmit buffer to be empty before appending new characters