42 const unsigned char value = (
unsigned char)c;
66 for (i = 0; i <
sizeof(newLine) - 1; ++i) {
214 all_entries_of_enum_Lz_SerialStopBits_must_be_set_in_setStopBits
229 if (stopBits <= __LZ_SERIAL_STOP_BITS_ENUM_BEGIN ||
230 stopBits >= __LZ_SERIAL_STOP_BITS_ENUM_END) {
284 all_entries_of_enum_Lz_SerialParityBit_must_be_set_in_setParityBit
299 if (parityBit <= __LZ_SERIAL_PARITY_BIT_ENUM_BEGIN ||
300 parityBit >= __LZ_SERIAL_PARITY_BIT_ENUM_END) {
368 all_entries_of_enum_Lz_SerialSize_must_be_set_in_setSize
383 if (size <= __LZ_SERIAL_SIZE_ENUM_BEGIN ||
384 size >= __LZ_SERIAL_SIZE_ENUM_END) {
411 all_entries_of_enum_Lz_SerialSpeed_must_be_set_in_serialSpeedRegisterValue
426 if (speed <= __LZ_SERIAL_SPEED_ENUM_BEGIN ||
427 speed >= __LZ_SERIAL_SPEED_ENUM_END) {
unsigned int uint16_t
Represents a unsigned integer type with width of exactly 16 bits.
unsigned char uint8_t
Represents a unsigned integer type with width of exactly 8 bits.
Architecture Abstraction API.
void(*)(void) Arch_LoadFunctionPointerFromProgmem(const void *source)
Return a function pointer stored in program memory.
InterruptsStatus Arch_DisableInterruptsGetStatus(void)
Disable all interrupts and return the previous interrupts status.
void Arch_RestoreInterruptsStatus(const InterruptsStatus interruptsStatus)
Restore a previously saved interrupts status.
uint8_t InterruptsStatus
Define the type used to store interrupts status.
uint16_t Arch_LoadU16FromProgmem(const void *source)
Return a double-byte word stored in program memory.
Basic type definitions and useful macros.
#define NULL
NULL pointer.
#define STATIC_ASSERT(C, M)
Perform an assertion at compile time.
#define HI8(X)
Take the high byte of a 16-bit value.
#define CLEAR_BITS(V, T, X)
Clear the corresponding bits of X in the value V of type T.
#define ELEMENTS_COUNT(X)
Get the number of elements in a statically initialized array.
#define LO8(X)
Take the low byte of a 16-bit value.
Macro aliases on compiler facilities.
Include appropriate config file.
const bool LZ_CONFIG_SERIAL_USE_INTERRUPTS
When 1, serial input and output will use interrupt blocking.
#define LZ_CONFIG_SERIAL_NEWLINE
The sequence to use for new lines on the serial line.
const bool LZ_CONFIG_CHECK_WRONG_ENUM_ENTRIES_IN_SERIAL
When 1, check for enum parameters that are over the admissible values defined by the enum.
void Kernel_Panic(void)
Kernel panic.
Kernel symbols definition.
Serial port configuration interface.
Lz_SerialSpeed
Define the baud rate of the serial line.
@ LZ_SERIAL_SPEED_4800
Use a 4800 baud rate on the serial line.
Lz_SerialParityBit
Define the kind of parity bit to use on serial line.
@ LZ_SERIAL_PARITY_EVEN
Use even parity bit.
@ LZ_SERIAL_PARITY_ODD
Use odd parity bit.
@ LZ_SERIAL_PARITY_NONE
Use no parity bit.
Lz_SerialSize
Define the size of the character used on serial line.
@ LZ_SERIAL_SIZE_6
Use 6-bit character size on serial line.
@ LZ_SERIAL_SIZE_7
Use 7-bit character size on serial line.
@ LZ_SERIAL_SIZE_5
Use 5-bit character size on serial line.
@ LZ_SERIAL_SIZE_8
Use 8-bit character size on serial line.
Lz_SerialEnableFlags
Define flags for enabling/disabling serial transmission/reception.
@ LZ_SERIAL_ENABLE_RECEIVE
Enable serial reception.
@ LZ_SERIAL_DISABLE_ALL
Disable both serial transmission and reception.
@ LZ_SERIAL_ENABLE_TRANSMIT
Enable serial transmission.
Lz_SerialStopBits
Define the number of stop bits to use on serial line.
@ LZ_SERIAL_STOP_BITS_1
Use 1 stop bit.
@ LZ_SERIAL_STOP_BITS_2
Use 2 stop bits.
stdio standard header file.
#define EOF
Defines the End-Of-File constant.
Represents the configuration of a serial interface.
enum Lz_SerialParityBit parityBit
The kind of parity bit.
enum Lz_SerialStopBits stopBits
The number of stop bits.
enum Lz_SerialEnableFlags enableFlags
The enable/disable Tx/Rx options.
enum Lz_SerialSize size
The size of the character.
enum Lz_SerialSpeed speed
The baud rate.
Describes the memory mapping for the USART.
volatile uint8_t ucsr0b
USART Control and Status Register B.
volatile uint8_t ucsr0c
USART Control and Status Register C.
volatile uint8_t ucsr0a
USART Control and Status Register A.
volatile uint8_t ubrr0l
USART Baud Rate Register low
volatile uint8_t udr0
USART I/O Data Register
volatile uint8_t ubrr0h
USART Baud Rate Register high
static const uint16_t serialSpeedRegisterValue[]
Jump table containing the setting values of UBRR0L and UBRR0H registers for baud rates defined in Lz_...
static void SetSpeed(const enum Lz_SerialSpeed speed)
Set the baud rate of the serial line.
static void SetStopBits(const enum Lz_SerialStopBits stopBits)
Set the number of stop bits of the serial line.
static void SetSize7(void)
Set character size to 7 bits.
static enum Lz_SerialSpeed currentSerialSpeed
The current serial baud rate.
static void SetStopBits1(void)
Set USART to use 1 stop bit.
static enum Lz_SerialStopBits GetStopBits(void)
Retrieve the number of stop bits currently used by the serial line.
static enum Lz_SerialSize GetSize(void)
Retrieve the character size currently used by the serial line.
static Usart *const usart
A constant pointer to the memory mapped Usart structure.
static enum Lz_SerialEnableFlags GetEnablingStatus(void)
Retrieve the enabling status of the serial line.
static enum Lz_SerialParityBit GetParityBit(void)
Retrieve the kind of parity currently used by the serial line.
static void SetSize8(void)
Set character size to 8 bits.
void Arch_GetSerialConfiguration(Lz_SerialConfiguration *const configuration)
Retrieve the current configuration of the serial line.
void Arch_SetSerialConfiguration(const Lz_SerialConfiguration *const configuration)
Configure the serial line according to the parameter.
static void SetSize6(void)
Set character size to 6 bits.
static void SetParityBitEven(void)
Set even parity bit.
static void SetParityBitNone(void)
Set no parity bit.
static void(*const setSize[])(void)
Jump table to functions setting character sizes of the serial line.
static void SetParityBit(const enum Lz_SerialParityBit parityBit)
Set the kind of parity bit of the serial line.
static void(*const setStopBits[])(void)
Jump table to functions setting the number of stop bits of the serial line.
void Arch_InitSerial(void)
Initialize serial line with default configuration at system startup.
static void SetStopBits2(void)
Set USART to use 2 stop bits.
int puts(const char *s)
Transmit the NUL-terminated string s followed by a trailing newline on the serial line,...
static void(*const setParityBit[])(void)
Jump table to functions setting the kind of parity of the serial line.
static void SetSize5(void)
Set character size to 5 bits.
static void SetParityBitOdd(void)
Set odd parity bit.
static void SetSize(const enum Lz_SerialSize size)
Set the character size of the serial line.
int putchar(int c)
Transmit a single character on the serial line.
static void SetEnablingStatus(const enum Lz_SerialEnableFlags flags)
Set the enabling/disabling of Tx/Rx of the serial line.
USART API for the ATmega328P.
@ UCSR0A_UDRE0
USART Data Register Empty
@ UCSR0B_UCSZ02
Character Size 2
@ UCSR0B_RXEN0
Receiver Enable
@ UCSR0B_TXEN0
Transmitter Enable
@ UCSR0C_UMSEL01
USART Mode Select 1.
@ UCSR0C_UPM01
Parity Mode 1
@ UCSR0C_UCSZ00
Character Size 0
@ UCSR0C_UMSEL00
USART Mode Select 0.
@ UCSR0C_UPM00
Parity Mode 0
@ UCSR0C_USBS0
Stop Bit Select
@ UCSR0C_UCSZ01
Character size 1
#define UCSR0A
USART Control and Status Register A.