#include <avr/io.h>
Go to the source code of this file.
Functions | |
void | USART0_init (uint16_t baudval) |
Initialise USART0 and set baud rate. | |
void | USART1_init (uint16_t baudval) |
Initialise USART1 and set baud rate. | |
void | USART0_transmit_string (char *data) |
Transmit a string via USART0 at currently set baud rate. | |
void | USART1_transmit_string (char *data) |
Transmit a string via USART1 at currently set baud rate. | |
void | USART0_transmit (unsigned char data) |
Transmit a character via USART0 at currently set baud rate. | |
void | USART1_transmit (unsigned char data) |
Transmit a character via USART1 at currently set baud rate. | |
void | USART0_transmit_uint8 (uint8_t val) |
Transmit an 8 bit unsigned integer via USART0 at currently set baud rate. | |
void | USART1_transmit_uint8 (uint8_t val) |
Transmit an 8 bit unsigned integer via USART1 at currently set baud rate. | |
void | USART0_transmit_int8 (int8_t val) |
Transmit an 8 bit signed integer via USART0 at currently set baud rate. | |
void | USART1_transmit_int8 (int8_t val) |
Transmit an 8 bit signed integer via USART1 at currently set baud rate. | |
void | USART0_transmit_uint16 (uint16_t val) |
Transmit a 16 bit unsigned integer via USART0 at currently set baud rate. | |
void | USART1_transmit_uint16 (uint16_t val) |
Transmit a 16 bit unsigned integer via USART1 at currently set baud rate. | |
void | USART0_transmit_int16 (int16_t val) |
Transmit a 16 bit signed integer via USART0 at currently set baud rate. | |
void | USART1_transmit_int16 (int16_t val) |
Transmit a 16 bit signed integer via USART1 at currently set baud rate. | |
void | USART0_transmit_bcd (uint8_t val) |
Interpret an 8 bit unsigned integer as a BCD value and transmit it as two ASCII characters via USART0. | |
void | USART1_transmit_bcd (uint8_t val) |
Interpret an 8 bit unsigned integer as a BCD value and transmit it as two ASCII characters via USART1. | |
void | USART0_transmit_bin (uint8_t val) |
Transmit an 8 bit unsigned integer as eight ASCII characters 0 or 1 via USART0. | |
void | USART1_transmit_bin (uint8_t val) |
Transmit an 8 bit unsigned integer as eight ASCII characters 0 or 1 via USART1. | |
void | USART0_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 on USART0. | |
void | USART1_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 on USART1. | |
uint8_t | USART0_receive (void) |
Receive an 8 bit value from USART0 by polling. | |
uint8_t | USART1_receive (void) |
Receive an 8 bit value from USART1 by polling. | |
void | USART0_flush (void) |
Repeatedly receive and discard values received by the USART0 until the input buffer empties. | |
void | USART1_flush (void) |
Repeatedly receive and discard values received by the USART1 until the input buffer empties. |
void USART0_flush | ( | void | ) |
Repeatedly receive and discard values received by the USART0 until the input buffer empties.
Uses polling.
Note that in the event of continuous input, this function may never complete.
void USART0_init | ( | uint16_t | baudval | ) | [inline] |
Initialise USART0 and set baud rate.
baudval | Value to put in UBRR0 to selectbaud rate. |
Initialise USART0 on microcontrollers where there are two USARTs which use the newer register and bit position names which include a USART number
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
uint8_t USART0_receive | ( | void | ) |
Receive an 8 bit value from USART0 by polling.
Uses polling, so waits for receive buffer to fill before returning.
void USART0_transmit | ( | unsigned char | data | ) |
Transmit a character via USART0 at currently set baud rate.
data | Character to transmit. |
Transmit a character via USART0, using polling, not interrutps. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty
void USART0_transmit_bcd | ( | uint8_t | val | ) |
Interpret an 8 bit unsigned integer as a BCD value and transmit it as two ASCII characters via USART0.
val | Value to transmit. |
Interpret an 8 bit unsigned integer as a BCD value and transmit it via the USART as exactly 2 characters. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART0_transmit_bin | ( | uint8_t | val | ) |
Transmit an 8 bit unsigned integer as eight ASCII characters 0 or 1 via USART0.
val | Value to transmit. |
Transmit an 8 bit unsigned integer as eight ASCII characters 0 or 1.
Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART0_transmit_int16 | ( | int16_t | val | ) |
Transmit a 16 bit signed integer via USART0 at currently set baud rate.
val | value to transmit. |
Transmit a 16 bit signed integer via the USART, as an optional minus sign followed by up to five decimal characters, using polling, not interrutps. Doesn't output leading zeroes, so number of characters transmitted may vary. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART0_transmit_int8 | ( | int8_t | val | ) |
Transmit an 8 bit signed integer via USART0 at currently set baud rate.
val | Value to transmit. |
Transmit an 8 bit signed integer via USART0, as an optional minus sign followed by up to three decimal characters, using polling, not interrutps. Doesn't output leading zeroes, so number of characters transmitted may vary. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART0_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 on USART0.
nibble | 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 USART0_transmit_string | ( | char * | data | ) |
Transmit a string via USART0 at currently set baud rate.
data | Pointer to start of string. |
Transmit a string via USART0, using polling, not interrutps. Doesn't change baud rate. Doesn't interrupt any existing transmit already in progress. Uses polling, so waits for transmit buffer to be empty
void USART0_transmit_uint16 | ( | uint16_t | val | ) |
Transmit a 16 bit unsigned integer via USART0 at currently set baud rate.
val | Value to transmit. |
Transmit a 16 bit unsigned integer via USART0, as a series of up to five decimal characters, using polling, not interrutps. Doesn't output leading zeroes, so number of characters transmitted may vary. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART0_transmit_uint8 | ( | uint8_t | val | ) |
Transmit an 8 bit unsigned integer via USART0 at currently set baud rate.
val | Character to transmit. |
Transmit an 8 bit unsigned integer via USART0, as a series of up to three decimal characters, using polling, not interrutps. Doesn't output leading zeroes, so number of characters transmitted may vary. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART1_flush | ( | void | ) |
Repeatedly receive and discard values received by the USART1 until the input buffer empties.
Uses polling.
Note that in the event of continuous input, this function may never complete.
void USART1_init | ( | uint16_t | baudval | ) | [inline] |
Initialise USART1 and set baud rate.
baudval | Value to put in UBRR1 to selectbaud rate. |
Initialise USART1 on microcontrollers where there are two USARTs which use the newer register and bit position names which include a USART number
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
uint8_t USART1_receive | ( | void | ) |
Receive an 8 bit value from USART1 by polling.
Uses polling, so waits for receive buffer to fill before returning.
void USART1_transmit | ( | unsigned char | data | ) |
Transmit a character via USART1 at currently set baud rate.
data | Character to transmit. |
Transmit a character via USART1, using polling, not interrutps. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty
void USART1_transmit_bcd | ( | uint8_t | val | ) |
Interpret an 8 bit unsigned integer as a BCD value and transmit it as two ASCII characters via USART1.
val | Value to transmit. |
Interpret an 8 bit unsigned integer as a BCD value and transmit it via the USART as exactly 2 characters. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART1_transmit_bin | ( | uint8_t | val | ) |
Transmit an 8 bit unsigned integer as eight ASCII characters 0 or 1 via USART1.
val | Value to transmit. |
Transmit an 8 bit unsigned integer as eight ASCII characters 0 or 1.
Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART1_transmit_int16 | ( | int16_t | val | ) |
Transmit a 16 bit signed integer via USART1 at currently set baud rate.
val | value to transmit. |
Transmit a 16 bit signed integer via the USART, as an optional minus sign followed by up to five decimal characters, using polling, not interrutps. Doesn't output leading zeroes, so number of characters transmitted may vary. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART1_transmit_int8 | ( | int8_t | val | ) |
Transmit an 8 bit signed integer via USART1 at currently set baud rate.
val | Value to transmit. |
Transmit an 8 bit signed integer via USART1, as an optional minus sign followed by up to three decimal characters, using polling, not interrutps. Doesn't output leading zeroes, so number of characters transmitted may vary. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART1_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 on USART1.
nibble | 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 USART1_transmit_string | ( | char * | data | ) |
Transmit a string via USART1 at currently set baud rate.
data | Pointer to start of string. |
Transmit a string via USART1, using polling, not interrutps. Doesn't change baud rate. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty
void USART1_transmit_uint16 | ( | uint16_t | val | ) |
Transmit a 16 bit unsigned integer via USART1 at currently set baud rate.
val | Value to transmit. |
Transmit a 16 bit unsigned integer via USART1, as a series of up to five decimal characters, using polling, not interrutps. Doesn't output leading zeroes, so number of characters transmitted may vary. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters
void USART1_transmit_uint8 | ( | uint8_t | val | ) |
Transmit an 8 bit unsigned integer via USART1 at currently set baud rate.
val | Character to transmit. |
Transmit an 8 bit unsigned integer via USART1, as a series of up to three decimal characters, using polling, not interrutps. Doesn't output leading zeroes, so number of characters transmitted may vary. Doesn't interrupt any existing transmit already in progress.
Uses polling, so waits for transmit buffer to be empty before appending new characters