|
9-bit receive and send functions
|
| #define | uart1_send_9bit(byte, ninth) |
| | Send 9-bit data over UART1 in mode 2, 3.
|
| |
| #define | uart1_receive_9bit(byte, ninth) |
| | Receive 9-bit data over UART1 in mode 2, 3.
|
| |
This module contains functions:
- Sending and receiving 9-bit data in UART1 mode 2 and 3.
- Sending and receiving 8-bit data with parity bit in UART1 mode 2 and 3.
- Sending and receiving 8-bit data with 2 stop bits in UART1 mode 2 and 3.
This header file included in UART1 mode 2, 3 headers and do not need to be included explicitly.
- Author
- Michael Golovanov
◆ uart1_receive_9bit
| #define uart1_receive_9bit |
( |
|
byte, |
|
|
|
ninth |
|
) |
| |
Value:do { \
RI=0; \
while(!RI); \
\
\
\
byte = SBUF; \
ninth = RB8; \
} while (0)
Receive 9-bit data over UART1 in mode 2, 3.
The function blocks until the 9bits is fully received.
- Parameters
-
| byte | uint8_t the 8-bit data value to be received (0-255). |
| ninth | uint8_t the 9th bit of the received data. 1 or 0. |
- Note
- Requires UART1 to be previously initialized and started.
-
Uses polling (blocking) method for receveive.
- Warning
- Should not be called from interrupt service routines
◆ uart1_receive_byte_2stop_bits
| #define uart1_receive_byte_2stop_bits |
( |
|
byte | ) |
|
Value:do { \
uart1_receive_byte_mark_parity(byte); \
} while (0)
Receive byte over UART1 in mode 2, 3 with 2 stop bits.
- Parameters
-
| byte | uint8_t the 8-bit data value to be received (0-255). |
- Attention
- This function is blocking until the byte is fully received with valid stop bits.
◆ uart1_receive_byte_even_parity
| #define uart1_receive_byte_even_parity |
( |
|
byte | ) |
|
Value:do { \
\
\
bool is_parity_valid = false; \
while (!is_parity_valid) \
{ \
\
\
RI = 0; \
while (!RI); \
\
byte = SBUF; \
\
\
\
ACC = byte; \
\
\
\
is_parity_valid = P == RB8; \
} \
} while (0)
Receive byte over UART1 in mode 2, 3 with even parity bit.
- Parameters
-
| byte | uint8_t the 8-bit data value to be received (0-255). |
- Attention
- This function is blocking until the byte is fully received with valid parity bit. Receive byte with non-valid parity bit will not unblock the function.
◆ uart1_receive_byte_mark_parity
| #define uart1_receive_byte_mark_parity |
( |
|
byte | ) |
|
Value:do { \
\
\
bool is_parity_valid = false; \
while (!is_parity_valid) \
{ \
RI = 0; \
while (!RI); \
\
byte = SBUF; \
\
\
is_parity_valid = RB8 == 1; \
} \
} while (0)
Receive byte over UART1 in mode 2, 3 with mark parity bit.
- Parameters
-
| byte | uint8_t the 8-bit data value to be received (0-255). |
- Attention
- This function is blocking until the byte is fully received with valid parity bit. Receive byte with non-valid parity bit will not unblock the function.
◆ uart1_receive_byte_odd_parity
| #define uart1_receive_byte_odd_parity |
( |
|
byte | ) |
|
Value:do { \
\
\
bool is_parity_valid = false; \
while (!is_parity_valid) \
{ \
\
\
RI = 0; \
while (!RI); \
\
byte = SBUF; \
\
\
\
ACC = byte; \
\
\
\
is_parity_valid = P != RB8; \
} \
} while (0)
Receive byte over UART1 in mode 2, 3 with odd parity bit.
- Parameters
-
| byte | uint8_t the 8-bit data value to be received (0-255). |
- Attention
- This function is blocking until the byte is fully received with valid parity bit. Receive byte with non-valid parity bit will not unblock the function.
◆ uart1_receive_byte_space_parity
| #define uart1_receive_byte_space_parity |
( |
|
byte | ) |
|
Value:do { \
\
\
bool is_parity_valid = false; \
while (!is_parity_valid) \
{ \
RI = 0; \
while (!RI); \
\
byte = SBUF; \
\
\
is_parity_valid = RB8 == 0; \
} \
} while (0)
Receive byte over UART1 in mode 2, 3 with space parity bit.
- Parameters
-
| byte | uint8_t the 8-bit data value to be received (0-255). |
- Attention
- This function is blocking until the byte is fully received with valid parity bit. Receive byte with non-valid parity bit will not unblock the function.
◆ uart1_send_9bit
| #define uart1_send_9bit |
( |
|
byte, |
|
|
|
ninth |
|
) |
| |
Value:do { \
\
TB8 = ninth; \
SBUF = byte; \
\
while (!TI); \
TI = 0; \
} while (0)
Send 9-bit data over UART1 in mode 2, 3.
The function blocks until the byte is fully transmitted.
- Note
- Requires UART1 to be previously initialized and started.
-
Uses polling (blocking) method for transmission.
- Parameters
-
| byte | uint8_t byte to be sent |
| ninth | uint8_t 9th bit of the byte to be sent. Should be 0 or 1. |
- Warning
- Should not be called from interrupt service routines
◆ uart1_send_byte_2stop_bits
| #define uart1_send_byte_2stop_bits |
( |
|
byte | ) |
|
Value:do { \
uart1_send_9bit(byte, 1); \
} while (0)
Send byte over UART1 in mode 2, 3 with 2 stop bits.
- Parameters
-
| byte | uint8_t the 8-bit data value to be sent (0-255). |
- Attention
- This function is blocking until the byte is fully sent.
◆ uart1_send_byte_even_parity
| #define uart1_send_byte_even_parity |
( |
|
byte | ) |
|
Value:do { \
\
ACC = byte; \
uart1_send_9bit(byte, P); \
} while (0)
Send byte over UART1 in mode 2, 3 with even parity bit.
- Parameters
-
| byte | uint8_t byte to be sent |
◆ uart1_send_byte_mark_parity
| #define uart1_send_byte_mark_parity |
( |
|
byte | ) |
|
Value:do { \
\
uart1_send_9bit(byte, 1); \
} while (0)
Send byte over UART1 in mode 2, 3 with mark parity bit.
- Parameters
-
| byte | uint8_t byte to be sent |
◆ uart1_send_byte_odd_parity
| #define uart1_send_byte_odd_parity |
( |
|
byte | ) |
|
Value:do { \
\
ACC = byte; \
\
uart1_send_9bit(byte, !P); \
} while (0)
Send byte over UART1 in mode 2, 3 with odd parity bit.
- Parameters
-
| byte | uint8_t byte to be sent |
◆ uart1_send_byte_space_parity
| #define uart1_send_byte_space_parity |
( |
|
byte | ) |
|
Value:do { \
\
uart1_send_9bit(byte, 0); \
} while (0)
Send byte over UART1 in mode 2, 3 with space parity bit.
- Parameters
-
| byte | uint8_t byte to be sent |