STC15W408AS library 0.12.0
Loading...
Searching...
No Matches
UART1 9bit, 8-bit with parity, 8-bit with two stop bits send/receive functions

9-bit

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.
 

8-bit with parity bit

8-bit receive and send with parity bit functions

#define uart1_send_byte_even_parity(byte)
 Send byte over UART1 in mode 2, 3 with even parity bit.
 
#define uart1_send_byte_odd_parity(byte)
 Send byte over UART1 in mode 2, 3 with odd parity bit.
 
#define uart1_send_byte_space_parity(byte)
 Send byte over UART1 in mode 2, 3 with space parity bit.
 
#define uart1_send_byte_mark_parity(byte)
 Send byte over UART1 in mode 2, 3 with mark parity bit.
 
#define uart1_receive_byte_even_parity(byte)
 Receive byte over UART1 in mode 2, 3 with even parity bit.
 
#define uart1_receive_byte_odd_parity(byte)
 Receive byte over UART1 in mode 2, 3 with odd parity bit.
 
#define uart1_receive_byte_mark_parity(byte)
 Receive byte over UART1 in mode 2, 3 with mark parity bit.
 
#define uart1_receive_byte_space_parity(byte)
 Receive byte over UART1 in mode 2, 3 with space parity bit.
 

8-bit-2-stop-bit functions

8-bit with two stop bits receive and send functions

#define uart1_send_byte_2stop_bits(byte)
 Send byte over UART1 in mode 2, 3 with 2 stop bits.
 
#define uart1_receive_byte_2stop_bits(byte)
 Receive byte over UART1 in mode 2, 3 with 2 stop bits.
 

Detailed Description

This module contains functions:

This header file included in UART1 mode 2, 3 headers and do not need to be included explicitly.

Author
Michael Golovanov

Macro Definition Documentation

◆ uart1_receive_9bit

#define uart1_receive_9bit (   byte,
  ninth 
)
Value:
do { \
RI=0; \
while(!RI); \
/* After RI flag set to 1 */ \
/* SBUF contains first 8-bit data */ \
/* and RB8 contains 9th bit */ \
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
byteuint8_t the 8-bit data value to be received (0-255).
ninthuint8_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
byteuint8_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 { \
/* Try to receive byte */ \
/* util parity bit is to be valid */ \
bool is_parity_valid = false; \
while (!is_parity_valid) \
{ \
/* Receive 8-bit to SBUF */ \
/* and parity bit to RB8 */ \
RI = 0; \
while (!RI); \
\
byte = SBUF; \
\
/* Load received 8-bit to ACC for */ \
/* even parity calculation */ \
ACC = byte; \
\
/* Validate received and calculated */ \
/* parity bits */ \
is_parity_valid = P == RB8; \
} \
} while (0)

Receive byte over UART1 in mode 2, 3 with even parity bit.

Parameters
byteuint8_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 { \
/* Try to receive byte */ \
/* util parity bit is to be valid */ \
bool is_parity_valid = false; \
while (!is_parity_valid) \
{ \
RI = 0; \
while (!RI); \
\
byte = SBUF; \
\
/* RB8 contains parity bit */ \
is_parity_valid = RB8 == 1; \
} \
} while (0)

Receive byte over UART1 in mode 2, 3 with mark parity bit.

Parameters
byteuint8_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 { \
/* Try to receive byte */ \
/* util parity bit is to be valid */ \
bool is_parity_valid = false; \
while (!is_parity_valid) \
{ \
/* Receive 8-bit to SBUF */ \
/* and parity bit to RB8 */ \
RI = 0; \
while (!RI); \
\
byte = SBUF; \
\
/* Load received 8-bit to ACC for */ \
/* even parity calculation */ \
ACC = byte; \
\
/* For odd parity even parity P */ \
/* should be inverted */ \
is_parity_valid = P != RB8; \
} \
} while (0)

Receive byte over UART1 in mode 2, 3 with odd parity bit.

Parameters
byteuint8_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 { \
/* Try to receive byte */ \
/* util parity bit is to be valid */ \
bool is_parity_valid = false; \
while (!is_parity_valid) \
{ \
RI = 0; \
while (!RI); \
\
byte = SBUF; \
\
/* RB8 contains parity bit */ \
is_parity_valid = RB8 == 0; \
} \
} while (0)

Receive byte over UART1 in mode 2, 3 with space parity bit.

Parameters
byteuint8_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 contains 9-th bit value */ \
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
byteuint8_t byte to be sent
ninthuint8_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
byteuint8_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 { \
/* P is even parity bit for ACC value */ \
ACC = byte; \
uart1_send_9bit(byte, P); \
} while (0)

Send byte over UART1 in mode 2, 3 with even parity bit.

Parameters
byteuint8_t byte to be sent

◆ uart1_send_byte_mark_parity

#define uart1_send_byte_mark_parity (   byte)
Value:
do { \
/* Parity bit is always 1 */ \
uart1_send_9bit(byte, 1); \
} while (0)

Send byte over UART1 in mode 2, 3 with mark parity bit.

Parameters
byteuint8_t byte to be sent

◆ uart1_send_byte_odd_parity

#define uart1_send_byte_odd_parity (   byte)
Value:
do { \
/* P is even parity bit for ACC value */ \
ACC = byte; \
/* For the odd parity P should be inverted*/ \
uart1_send_9bit(byte, !P); \
} while (0)

Send byte over UART1 in mode 2, 3 with odd parity bit.

Parameters
byteuint8_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
byteuint8_t byte to be sent