PIC24 Support Libraries
Macros | Functions
esos_pic24_rs232.h File Reference

This file contains macros, prototypes, and definitions for Microchip PIC24 Family specific communications on ESOS. More...

#include "esos.h"
#include "esos_comm.h"
#include "esos_pic24.h"

Go to the source code of this file.

Macros

#define IS_CHAR_READY_UART1()   U1STAbits.URXDA
 
#define IS_TRANSMIT_BUFFER_FULL_UART1()   U1STAbits.UTXBF
 
#define IS_TRANSMIT_COMPLETE_UART1()   U1STAbits.TRMT
 
Constants for the UxMODE.PDSEL bitfield
#define UXMODE_PDSEL_8DATA_NOPARITY   0
 
#define UXMODE_PDSEL_8DATA_EVENPARITY   1
 
#define UXMODE_PDSEL_8DATA_ODDPARITY   2
 
#define UXMODE_PDSEL_9DATA_NOPARITY   3
 

Functions

static void CONFIG_BAUDRATE_UART1 (uint32_t baudRate)
 
static void CONFIG_PDSEL_UART1 (uint8_t u8_pdsel)
 
static void CONFIG_STOPBITS_UART1 (uint8_t u8_numStopbits)
 
static void ENABLE_UART1 ()
 
void __esos_configUART1 (uint32_t u32_baudRate)
 
static void WAIT_UNTIL_TRANSMIT_COMPLETE_UART1 ()
 

Detailed Description

This file contains macros, prototypes, and definitions for Microchip PIC24 Family specific communications on ESOS.

This file contains routines which configure and use the UARTs on the PIC. See pic24_serial.h for higher-level routines, which should typically be called by the user rather than these routines.

Definition in file esos_pic24_rs232.h.

Macro Definition Documentation

◆ IS_CHAR_READY_UART1

#define IS_CHAR_READY_UART1 ( )    U1STAbits.URXDA

Determine if a character is available in the UART's receive buffer.

Returns
True (1) if character is available, 0 if not.

Definition at line 138 of file esos_pic24_rs232.h.

◆ IS_TRANSMIT_BUFFER_FULL_UART1

#define IS_TRANSMIT_BUFFER_FULL_UART1 ( )    U1STAbits.UTXBF

Determine if a the transmit buffer is full.

Returns
True (1) if the transmit buffer if full, false (0) if not.

Definition at line 144 of file esos_pic24_rs232.h.

◆ IS_TRANSMIT_COMPLETE_UART1

#define IS_TRANSMIT_COMPLETE_UART1 ( )    U1STAbits.TRMT

Determines if all characters placed in the UART have been sent. Returns 1 if the last transmission has completed, or 0 if a transmission is in progress or queued in the transmit buffer.

Returns
True (1) if the last transmission has completed, 0 if not.

Definition at line 151 of file esos_pic24_rs232.h.

Referenced by WAIT_UNTIL_TRANSMIT_COMPLETE_UART1().

Function Documentation

◆ CONFIG_BAUDRATE_UART1()

static void CONFIG_BAUDRATE_UART1 ( uint32_t  baudRate)
inlinestatic

The underlying PIC24 HW libraries choose a default baudrate appropriate to the chosen MCU model. Only uncomment the line below if you want ESOS to build the UART with a "non-standard" baudrate. Used by configUART1 to set up the UART.

 #define DEFAULT_BAUDRATE  9600

Configure the UART's baud rate, based on FCY. Note that the value computed is truncated, not rounded, since this is done using integer arithmetic. That is, BRG = truncate(FCY/16/baud - 1), giving an actual baud rate of FCY/16/(reg + 1).

NOTE: this code sets BRGH=0 (16 clocks for each bit). Be careful about using BRGH=1 - this uses only four clock periods to sample each bit and can be very intolerant of baud rate error - you may see framing errors.

Parameters
baudRateDesired baud rate.

Definition at line 92 of file esos_pic24_rs232.h.

Referenced by __esos_configUART1().

◆ CONFIG_PDSEL_UART1()

static void CONFIG_PDSEL_UART1 ( uint8_t  u8_pdsel)
inlinestatic

Select the parity and number of data bits for the UART. Use constants UXMODE_PDSEL_8DATA_NOPARITY and following.

Parameters
u8_pdselParity and number of data bits.

Definition at line 113 of file esos_pic24_rs232.h.

Referenced by __esos_configUART1().

◆ CONFIG_STOPBITS_UART1()

static void CONFIG_STOPBITS_UART1 ( uint8_t  u8_numStopbits)
inlinestatic

Select the number of stop bits for this UART. Valid values are 1 or 2.

Parameters
u8_numStopbitsNumber of stop bits.

Definition at line 122 of file esos_pic24_rs232.h.

◆ ENABLE_UART1()

static void ENABLE_UART1 ( )
inlinestatic

Enable RX, TX for UART.

Definition at line 128 of file esos_pic24_rs232.h.

◆ WAIT_UNTIL_TRANSMIT_COMPLETE_UART1()

static void WAIT_UNTIL_TRANSMIT_COMPLETE_UART1 ( )
inlinestatic

Waits until all characters placed in the UART have been sent.

Definition at line 165 of file esos_pic24_rs232.h.