PIC24 Support Libraries
Functions
pic24_serial.c File Reference
#include "pic24_serial.h"
#include "pic24_uart.h"
#include "pic24_unittest.h"
#include <libpic30.h>

Go to the source code of this file.

Functions

void outChar (uint8_t u8_c)
 A system-dependent macro to output one character. More...
 
void outString (const char *psz_s)
 
uint16_t inString (char *psz_buff, int16_t u16_maxCount)
 
uint16_t inStringEcho (char *psz_buff, int16_t u16_maxCount)
 
void outUint8 (uint8_t u8_x)
 
void outUint16 (uint16_t u16_x)
 
void outUint32 (uint32_t u32_x)
 
void outUint8Decimal (uint8_t u8_x)
 
void outUint16Decimal (uint16_t u16_x)
 
uint8_t inChar (void)
 
uint8_t inCharEcho (void)
 
uint8_t isCharReady (void)
 
void configDefaultUART (uint32_t u32_baudRate)
 

Detailed Description

Implementation of serial I/O functions prototyped in pic24_serial.h

Definition in file pic24_serial.c.

Function Documentation

◆ configDefaultUART()

void configDefaultUART ( uint32_t  u32_baudRate)

Configures a UART based compiler setting of DEFAULT_UART and sets __C30_UART to the default UART. If you want to configure a different UART, then call the configUARTx function explicitly.

Parameters
u32_baudRateThe baud rate to use.

Definition at line 347 of file pic24_serial.c.

Referenced by configBasic().

◆ inChar()

uint8_t inChar ( void  )

Read a character from the serial port. This function blocks until a character is read. The serial port used is selected by the __C30_UART variable, which defaults to 1.

Returns
Character read from the serial port.

Definition at line 277 of file pic24_serial.c.

Referenced by inCharEcho().

◆ inCharEcho()

uint8_t inCharEcho ( void  )

Same as inChar(), except echo character that is back to console

Definition at line 305 of file pic24_serial.c.

◆ inString()

uint16_t inString ( char *  psz_buff,
int16_t  u16_maxCount 
)

Reads a string into psz_buff, assumes psz_buff can hold at least u16_maxCount+1 characters. String reading halts when either a newline or carriage return is read, or u16_maxCount characters is read. The return string is always null-terminated. The return count does not includes the null terminator. An input string of just '
' returns a null string.

Parameters
psz_buffpointer to buffer for storing string read from console
u16_maxCountmaximum number of characters to read from console.

Definition at line 140 of file pic24_serial.c.

◆ inStringEcho()

uint16_t inStringEcho ( char *  psz_buff,
int16_t  u16_maxCount 
)

Same as inString(), except echoes characters to console as they are read.

Definition at line 147 of file pic24_serial.c.

◆ isCharReady()

uint8_t isCharReady ( void  )

Determine if a character is ready to be read from the serial port.

Returns
non-zero value if character is ready, zero otherwise..

Definition at line 316 of file pic24_serial.c.

◆ outChar()

void outChar ( uint8_t  u8_c)

A system-dependent macro to output one character.

Write a character to the serial port. This function blocks until a character is written. The UART used is determined by the __C30_UART variable, which defaults to 1.

Parameters
u8_cCharacter to write

Definition at line 58 of file pic24_serial.c.

Referenced by inCharEcho(), and outString().

◆ outString()

void outString ( const char *  psz_s)

Write a null-terminated string to the serial port. See file documentation for End-of-line behavior when passed a "\n" (newline).

Parameters
psz_sPointer to null-terminated string to print.

Definition at line 90 of file pic24_serial.c.

Referenced by checkDeviceAndRevision(), checkOscOption(), configBasic(), outUint16(), outUint16Decimal(), outUint32(), outUint8(), outUint8Decimal(), and printResetCause().

◆ outUint16()

void outUint16 ( uint16_t  u16_x)

Output u16_x as formatted hex value with leading "0x".

Parameters
u16_xvalue to output.

Definition at line 176 of file pic24_serial.c.

◆ outUint16Decimal()

void outUint16Decimal ( uint16_t  u16_x)

Output u16_x as decimal value.

Parameters
u16_xvalue to output.

Definition at line 242 of file pic24_serial.c.

◆ outUint32()

void outUint32 ( uint32_t  u32_x)

Output u32_x as formatted hex value with leading "0x".

Parameters
u32_xvalue to output.

Definition at line 190 of file pic24_serial.c.

◆ outUint8()

void outUint8 ( uint8_t  u8_x)

Output u8_x as formatted hex value with leading "0x".

Parameters
u8_xvalue to output.

Definition at line 167 of file pic24_serial.c.

Referenced by printResetCause().

◆ outUint8Decimal()

void outUint8Decimal ( uint8_t  u8_x)

Output u8_x as decimal value.

Parameters
u8_xvalue to output.

Definition at line 207 of file pic24_serial.c.