ATmega328p USART driver.
More...
Go to the source code of this file.
ATmega328p USART driver.
- Copyright
- 2019-2020, Remi Andruccioli remi..nosp@m.andr.nosp@m.uccio.nosp@m.li@g.nosp@m.mail..nosp@m.com
Describes the driver implementation for the USART of the ATMega328p.
Definition in file usart.c.
◆ putchar()
Transmit a single character on the serial line.
- Parameters
-
c | The character to transmit, that will be cast to an unsigned char. |
- Returns
- The actual value of the transmitted character, resulting from the cast, as an int.
Definition at line 40 of file usart.c.
◆ puts()
int puts |
( |
const char * |
s | ) |
|
Transmit the NUL-terminated string s
followed by a trailing newline on the serial line, without any formatting.
- Parameters
-
- Returns
- A non-negative number on success, otherwise EOF on error.
Definition at line 52 of file usart.c.
◆ GetEnablingStatus()
Retrieve the enabling status of the serial line.
- Returns
- An Lz_SerialEnableFlags containing the enabling status.
Definition at line 79 of file usart.c.
◆ GetStopBits()
Retrieve the number of stop bits currently used by the serial line.
- Returns
- An Lz_SerialStopBits containing the number of stop bits.
Definition at line 100 of file usart.c.
◆ GetParityBit()
Retrieve the kind of parity currently used by the serial line.
- Returns
- An Lz_SerialParityBit containing the kind of parity.
Definition at line 115 of file usart.c.
◆ GetSize()
Retrieve the character size currently used by the serial line.
- Returns
- An Lz_SerialSize containing the character size.
Definition at line 138 of file usart.c.
◆ SetEnablingStatus()
Set the enabling/disabling of Tx/Rx of the serial line.
- Parameters
-
flags | An Lz_SerialEnableFlags containing enable flags. |
Definition at line 165 of file usart.c.
◆ SetStopBits()
Set the number of stop bits of the serial line.
- Parameters
-
stopBits | An Lz_SerialStopBits defining the number of stop bits. |
Definition at line 224 of file usart.c.
◆ SetParityBit()
Set the kind of parity bit of the serial line.
- Parameters
-
parityBit | An Lz_SerialParityBit defining the kind of parity. |
Definition at line 294 of file usart.c.
◆ SetSize()
Set the character size of the serial line.
- Parameters
-
size | An Lz_SerialSize defining the character size. |
Definition at line 378 of file usart.c.
◆ SetSpeed()
Set the baud rate of the serial line.
- Parameters
-
speed | An Lz_SerialSpeed value defining the baud rate. |
Definition at line 421 of file usart.c.
◆ Arch_GetSerialConfiguration()
Retrieve the current configuration of the serial line.
- Parameters
-
Definition at line 441 of file usart.c.
◆ Arch_SetSerialConfiguration()
Configure the seria line according to the parameter.
- Parameters
-
configuration | A pointer to an existing Lz_SerialConfiguration containg the full configuration to set up the serial line. |
Definition at line 451 of file usart.c.
◆ Arch_InitSerial()
void Arch_InitSerial |
( |
void |
| ) |
|
Initialize serial line with default configuration at system startup.
< member: enableFlags
< member: stopBits
< member: parityBits
< member: size
< member: speed
Definition at line 480 of file usart.c.
◆ currentSerialSpeed
The current serial baud rate.
This is used to save the current setting of the serial baud rate. On AVR, the setting of the speed isn't always accurate once calculated, so we use this variable to store it and be able to retrieve it easily.
Definition at line 37 of file usart.c.
◆ setStopBits
void(* const setStopBits[])(void) |
|
static |
Initial value:= {
}
static void SetStopBits1(void)
Set USART to use 1 stop bit.
static void SetStopBits2(void)
Set USART to use 2 stop bits.
Jump table to functions setting the number of stop bits of the serial line.
- Warning
- This table must be ordered by entry values of enum Lz_SerialStopBits.
Definition at line 205 of file usart.c.
◆ setParityBit
void(* const setParityBit[])(void) |
|
static |
Initial value:= {
}
static void SetParityBitEven(void)
Set even parity bit.
static void SetParityBitNone(void)
Set no parity bit.
static void SetParityBitOdd(void)
Set odd parity bit.
Jump table to functions setting the kind of parity of the serial line.
- Warning
- This table must be ordered by entry values of enum Lz_SerialParityBit.
Definition at line 274 of file usart.c.
◆ setSize
void(* const setSize[])(void) |
|
static |
Initial value:= {
}
static void SetSize5(void)
Set character size to 5 bits.
static void SetSize7(void)
Set character size to 7 bits.
static void SetSize6(void)
Set character size to 6 bits.
static void SetSize8(void)
Set character size to 8 bits.
Jump table to functions setting character sizes of the serial line.
- Warning
- This table must be ordered by entry values of enum Lz_SerialSize.
Definition at line 357 of file usart.c.
◆ serialSpeedRegisterValue
const uint16_t serialSpeedRegisterValue[] |
|
static |
Initial value:= {
}
unsigned int uint16_t
Represents a unsigned integer type with width of exactly 16 bits.
Jump table containing the setting values of UBRR0L and UBRR0H registers for baud rates defined in Lz_SerialSpeed.
- Warning
- This table must be ordered by entry values of enum Lz_SerialSpeed.
Definition at line 400 of file usart.c.