STC15W408AS library 0.9.0
Macros | Functions
UART1

Macros

#define uart1_init(uart_baudrate)
 Initiazlize UART1. More...
 

Functions

void uart1_send_byte (uint8_t data)
 
uint8_t uart1_receive_byte ()
 Receive byte from UART1. More...
 
int putchar (int ch)
 Send character to UART1. More...
 
int getchar (void)
 Receive character from UART1. More...
 

Detailed Description

Functions and data structures related to exchange data thru UART1

Author
Michael Golovanov

Macro Definition Documentation

◆ uart1_init

#define uart1_init (   uart_baudrate)
Value:
{ \
SCON = 0x50; /* Set Mode1: 8-Bit UART with Variable Baud Rate */ \
timer2_mode0_reload(timer2_mode0_baudrate_to_ticks(uart_baudrate)); \
AUXR &= 0xE2; \
AUXR |= 0x15; \
}
#define timer2_mode0_baudrate_to_ticks(uart_baudrate)
Calculate timer2 ticks for UART baudrate.
Definition: timer2_to_ms.h:126

Initiazlize UART1.

Initialize uart using Timer2. Set timer according to baudrate

Parameters
uart_baudrateuint32_t uart baudrate, like 9600 and etc

Function Documentation

◆ getchar()

int getchar ( void  )

Receive character from UART1.

This method need for scanf

Returns
received char

◆ putchar()

int putchar ( int  ch)

Send character to UART1.

This method need for printf

Parameters
chcharacter to send
Returns
char sended to UART

◆ uart1_receive_byte()

uint8_t uart1_receive_byte ( )

Receive byte from UART1.

This receive is implemented as synhcronous operation. Waiting until byte is received

Returns
received byte

◆ uart1_send_byte()

void uart1_send_byte ( uint8_t  data)

Send byte to UART

Parameters
databyte to send