LTlib LaurTec Library  4.0.1
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
module_UART.h File Reference
#include "LTlib.h"

Go to the source code of this file.

Macros

#define UART1_data_ready()   (PIR1bits.RCIF)
 
#define UART1_close()   (RCSTA&=0b01001111,TXSTAbits.TXEN=0)
 
#define UART1_TX_busy()   (!TXSTAbits.TRMT)
 

Functions

void UART1_open (unsigned int baud_rate)
 
void UART1_write_byte (unsigned char data)
 
unsigned char UART1_read_byte (void)
 
void UART1_write_message (const unsigned char *data)
 
void UART1_write_string (unsigned char *data)
 

Macro Definition Documentation

#define UART1_close ( )    (RCSTA&=0b01001111,TXSTAbits.TXEN=0)

This macro close the USART disabling RX and TX buffer.

Parameters
none
Returns
none

Definition at line 122 of file module_UART.h.

#define UART1_data_ready ( )    (PIR1bits.RCIF)

This macro is used to check if the USART has some data in the RX buffer.

Parameters
none
Returns
status 1: The USART has some data in the RX buffer. 0: The RX buffer is empty.

Definition at line 112 of file module_UART.h.

#define UART1_TX_busy ( )    (!TXSTAbits.TRMT)

This macro is used to check if the USART is busy sending other data out.

Parameters
none
Returns
status 1: The USART module is busy 0: The USART module can send other data out.
Note
You are supposed to check the busy flag before sending data out.

Definition at line 135 of file module_UART.h.

Function Documentation

void UART1_open ( unsigned int  baud_rate)

This function Opens the UART module enabling TX and RX channels.

Parameters
dataByte to write [min: UART_BAUDRATE_9600, max: UART_BAUDRATE_115200]
Returns
void

You must use the constants UART_BAUDRATE_9600, UART_BAUDRATE_19200, UART_BAUDRATE_57600, UART_BAUDRATE_115200 to set the baudrate

Definition at line 48 of file module_UART.c.

References PIN_AS_INPUT.

unsigned char UART1_read_byte ( void  )

This function reads a byte from the RX buffer

Parameters
none
Returns
byte Value out of the RX buffer.

Definition at line 224 of file module_UART.c.

void UART1_write_byte ( unsigned char  data)

This function writes a byte to the UART module.

Parameters
dataByte to write [min: 0, max: 255]
Returns
void
Warning
this function is a blocking one since it waits for the byte to be sent out.

Definition at line 163 of file module_UART.c.

References UART1_TX_busy.

void UART1_write_message ( const unsigned char *  data)

This function writes a constant message to the UART.

Parameters
*dataConstant string pointer
Returns
none
Note
A constant message is a string within "" like this "Hello World".

Definition at line 178 of file module_UART.c.

References UART1_TX_busy, and UART1_write_byte().

void UART1_write_string ( unsigned char *  data)

This function writes a string to the UART.

Parameters
*dataPointer to the array of char (string)
Returns
none
Note
A string is an array of chars.

Definition at line 201 of file module_UART.c.

References UART1_TX_busy, and UART1_write_byte().