PIC24 Support Libraries
Macros | Functions
pic24_uart.h File Reference
#include <stdint.h>
#include "pic24_chip.h"
#include "pic24_libconfig.h"
#include "pic24_util.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
 

Functions

static void WAIT_UNTIL_TRANSMIT_COMPLETE_UART1 ()
 
void outChar1 (uint8_t u8_c)
 
uint8_t inChar1 (void)
 
void configUART1 (uint32_t u32_baudRate)
 
uint8_t isCharReady1 (void)
 
void checkRxErrorUART1 (void)
 

Detailed Description

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 pic24_uart.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 57 of file pic24_uart.h.

Referenced by inChar1(), and isCharReady1().

◆ 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 63 of file pic24_uart.h.

Referenced by outChar1().

◆ 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 70 of file pic24_uart.h.

Referenced by WAIT_UNTIL_TRANSMIT_COMPLETE_UART1().

Function Documentation

◆ checkRxErrorUART1()

void checkRxErrorUART1 ( void  )

Check UART1 RX for error, call reportError() if error found.

Definition at line 70 of file pic24_uart.c.

Referenced by inChar1(), and WAIT_UNTIL_TRANSMIT_COMPLETE_UART1().

◆ configUART1()

void configUART1 ( uint32_t  u32_baudRate)

Configure the UART. Settings chosen:

  • TX is on RP11
  • RX is on RP10
  • Format is 8 data bits, no parity, 1 stop bit
  • CTS, RTS, and BCLK not used
Parameters
u32_baudRateThe baud rate to use.

Definition at line 250 of file pic24_uart.c.

Referenced by configDefaultUART(), and WAIT_UNTIL_TRANSMIT_COMPLETE_UART1().

◆ inChar1()

uint8_t inChar1 ( void  )

Wait for a byte to be available from UART1 RX.

Returns
Character read from UART1 RX.

Definition at line 214 of file pic24_uart.c.

Referenced by inChar(), outChar1(), and WAIT_UNTIL_TRANSMIT_COMPLETE_UART1().

◆ isCharReady1()

uint8_t isCharReady1 ( void  )

Return true if character is ready to be read

Definition at line 206 of file pic24_uart.c.

Referenced by isCharReady(), outChar1(), and WAIT_UNTIL_TRANSMIT_COMPLETE_UART1().

◆ outChar1()

void outChar1 ( uint8_t  u8_c)

Output u8_c to UART1 TX.

Parameters
u8_cCharacter to write

Definition at line 145 of file pic24_uart.c.

Referenced by checkRxErrorUART1(), outChar(), and WAIT_UNTIL_TRANSMIT_COMPLETE_UART1().

◆ 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 73 of file pic24_uart.h.