Xbee Arduino
Arduino Driver for Xbee
Loading...
Searching...
No Matches
port.h File Reference

Platform-specific abstraction layer for hardware interfaces. More...

#include <stdint.h>
Include dependency graph for port.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  uart_status_t {
  UART_SUCCESS = 0 , UART_INIT_FAILED , UART_ERROR_TIMEOUT , UART_ERROR_OVERRUN ,
  UART_ERROR_UNKNOWN
}
 

Functions

int portUartRead (uint8_t *buffer, int length)
 Reads data from the UART. More...
 
int portUartWrite (const uint8_t *buf, uint16_t len)
 Writes data to the UART. More...
 
uint32_t portMillis (void)
 Returns the number of milliseconds since the program started. More...
 
void portFlushRx (void)
 Flushes the UART receive buffer. More...
 
int portUartInit (uint32_t baudrate, void *device)
 Initializes the UART for communication on the Arduino platform. More...
 
void portDelay (uint32_t ms)
 Delays execution for a specified number of milliseconds. More...
 
void portDebugPrintf (const char *format,...)
 Prints debug information to the Serial output. More...
 

Detailed Description

Platform-specific abstraction layer for hardware interfaces.

This file defines the platform-specific functions and macros used by the XBee library to interface with hardware. It provides abstraction for serial communication, timing, GPIO control, and other low-level operations required by the XBee modules.

Version
1.0
Date
2024-08-08

@license MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author
Felix Galindo @contact felix.nosp@m..gal.nosp@m.indo@.nosp@m.digi.nosp@m..com

Enumeration Type Documentation

◆ uart_status_t

Enumerator
UART_SUCCESS 
UART_INIT_FAILED 
UART_ERROR_TIMEOUT 
UART_ERROR_OVERRUN 
UART_ERROR_UNKNOWN 

Function Documentation

◆ portDebugPrintf()

void portDebugPrintf ( const char *  format,
  ... 
)

Prints debug information to the Serial output.

This function provides a formatted print capability for debugging purposes, similar to printf.

Parameters
formatThe format string (same as printf).
...The values to print.

◆ portDelay()

void portDelay ( uint32_t  ms)

Delays execution for a specified number of milliseconds.

This function pauses execution for the specified duration using Arduino's delay() function.

Parameters
msThe number of milliseconds to delay.

◆ portFlushRx()

void portFlushRx ( void  )

Flushes the UART receive buffer.

This function clears any data that may be present in the UART's receive buffer.

◆ portMillis()

uint32_t portMillis ( void  )

Returns the number of milliseconds since the program started.

This function uses Arduino's millis() function to return the time elapsed since the device was powered on.

Returns
uint32_t The number of milliseconds since startup.

◆ portUartInit()

int portUartInit ( uint32_t  baudrate,
void *  device 
)

Initializes the UART for communication on the Arduino platform.

This function sets up the UART peripheral with the specified baud rate.

Parameters
baudrateThe baud rate for UART communication.
devicePointer to the HardwareSerial or SoftwareSerial instance representing the UART to use.
Returns
int Returns 0 on success, or -1 if the device is not specified.

◆ portUartRead()

int portUartRead ( uint8_t *  buffer,
int  length 
)

Reads data from the UART.

This function reads up to the specified number of bytes from the UART and stores them in the provided buffer. It blocks until the requested number of bytes has been read or an error occurs.

Parameters
bufferPointer to the buffer where the data will be stored.
lengthMaximum number of bytes to read.
Returns
int Returns the number of bytes actually read, or -1 if the serial port is not initialized.

◆ portUartWrite()

int portUartWrite ( const uint8_t *  data,
uint16_t  length 
)

Writes data to the UART.

This function sends the specified number of bytes from the provided buffer over the UART.

Parameters
dataPointer to the data to be written.
lengthNumber of bytes to write.
Returns
int Returns the number of bytes successfully written, or -1 if the serial port is not initialized.