WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
warpos::Platform Class Reference

Holds all platform-specific interfaces. More...

#include <Platform.h>

Public Member Functions

 Platform ()
virtual ~Platform ()
virtual int16 startup ()
 Initialize the platform.
virtual int16 setPinMode (const GpioConfig_t &config)
 Set the mode for a given GPIO pin on platform.
virtual int16 writePin (uint8 bank, uint32 pin, uint32 value)
 Write data value to a pin.
virtual int16 readPin (uint8 bank, uint32 pin, uint32 &value)
 Read data value from a pin.
virtual int32 openSPI (const SpiConfig_t &config)
 Open and configure SPI.
virtual int16 readSPI (int32 spi_device, uint8 *buffer, uint8 size)
 Read a set of bytes via SPI.
virtual int16 writeSPI (int32 spi_device, uint8 *buffer, uint8 size)
 Write a set of bytes via SPI.
virtual int16 readWriteSPI (int32 spi_device, uint8 *buffer, uint8 size)
 Write and read a set of bytes via SPI.
virtual int32 openSerial (const UartConfig_t &config)
 Open and configture UART connection.
virtual int16 writeSerial (int32 device_fd, uint8 *buffer, uint8 size)
 Write a byte to UART.
virtual uint32 readSerial (int32 device_fd, uint8 *buffer, uint32 size)
 Read a byte from UART.
virtual uint32 bytesReadySerial (int32 device_fd)
 Check number of bytes ready to read on UART.
virtual int32 openI2C (const I2cConfig_t &config)
 Open an I2C device.
virtual int16 writeI2C (int32 i2c_fd, uint8 i2c_address, uint8 *buffer, uint8 size)
 Write a byte to I2C.
virtual int16 readI2C (int32 i2c_fd, uint8 i2c_address, uint8 *buffer, uint32 size)
 Read a byte from I2C.
virtual int16 writeI2CAddress (int32 i2c_fd, uint8 i2c_address, uint32 mem_address, uint8 *buffer, uint32 size, bool memory_16=false)
 Write a buffer of data to an I2C address.
virtual int16 readI2CAddress (int32 i2c_fd, uint8 i2c_address, uint32 mem_address, uint8 *buffer, uint32 size, bool memory_16=false)
 Write a buffer of data to an I2C address.
virtual int16 openPwmChannel (PwmConfig_t &config)
 Open a PWM channel.
virtual int16 writePwm (int32 pwm_fd, uint8 channel, uint32 value)
 Write a buffer of data to an I2C address.
virtual int32 openAdc (const AdcConfig_t &adc)
 Open an ADC device.
virtual int16 readAdc (int32 adc_fd, uint32 adc_ch_idx, floating_point &read_voltage)
 Read a voltage value from ADC.

Detailed Description

Holds all platform-specific interfaces.

The Platform class is the warpOS method for applying the HAL, or Hardware Abstraction Layer. Platform defines all basic interfaces which are typical of hardware, such as writing to buffers, controlling pins, etc.

The Platform class by itself does not do anything. Users seeking to implement should create a child class with Platform as its base and implement the functions documented herein.

Constructor & Destructor Documentation

◆ Platform()

warpos::Platform::Platform ( )
inline

◆ ~Platform()

virtual warpos::Platform::~Platform ( )
inlinevirtual

Member Function Documentation

◆ bytesReadySerial()

virtual uint32 warpos::Platform::bytesReadySerial ( int32 device_fd)
inlinevirtual

Check number of bytes ready to read on UART.

Parameters
device_fdThe file descriptor of the device to check
Returns
Number of bytes available

◆ openAdc()

virtual int32 warpos::Platform::openAdc ( const AdcConfig_t & adc)
inlinevirtual

Open an ADC device.

Parameters
adcADC configuration object
Returns
File descriptor for the device
Note
THIS FUNCTION CURRENTLY ASSUMES ADC IS CONFIGURED BY IOC OUTSIDE OF CODE

◆ openI2C()

virtual int32 warpos::Platform::openI2C ( const I2cConfig_t & config)
inlinevirtual

Open an I2C device.

Parameters
configI2C configuration object
Returns
File descriptor for the device

◆ openPwmChannel()

virtual int16 warpos::Platform::openPwmChannel ( PwmConfig_t & config)
inlinevirtual

Open a PWM channel.

Parameters
configPWM configuration object
Returns
Error code corresponding to success/failure

◆ openSerial()

virtual int32 warpos::Platform::openSerial ( const UartConfig_t & config)
inlinevirtual

Open and configture UART connection.

Parameters
configUART config object for the device
Returns
File descriptor for the device

◆ openSPI()

virtual int32 warpos::Platform::openSPI ( const SpiConfig_t & config)
inlinevirtual

Open and configure SPI.

Parameters
configSPI config for the device
Returns
File descriptor for the device

◆ readAdc()

virtual int16 warpos::Platform::readAdc ( int32 adc_fd,
uint32 adc_ch_idx,
floating_point & read_voltage )
inlinevirtual

Read a voltage value from ADC.

Parameters
adc_fdThe file descriptor pointing to the ADC to read
adc_ch_idxThe index of the ADC channel to read from (determines which pin/sensor is read)
read_voltageImplicit return of voltage value read from ADC
Returns
Error code corresponding to success/failure

◆ readI2C()

virtual int16 warpos::Platform::readI2C ( int32 i2c_fd,
uint8 i2c_address,
uint8 * buffer,
uint32 size )
inlinevirtual

Read a byte from I2C.

Parameters
i2c_fdThe file descriptor to read
bufferImplicit return of values read from buffer
sizeThe number of bytes to read
Returns
Error code corresponding to success/failure

◆ readI2CAddress()

virtual int16 warpos::Platform::readI2CAddress ( int32 i2c_fd,
uint8 i2c_address,
uint32 mem_address,
uint8 * buffer,
uint32 size,
bool memory_16 = false )
inlinevirtual

Write a buffer of data to an I2C address.

Parameters
i2c_fdThe file descriptor to write
i2c_addressThe I2C address to communicate with
mem_addressThe memory address to communicate with
bufferThe buffer of data to read to
sizeThe maximum amount of data (not including address) to read
memory_16Boolean if the memory addresses are 16 bit or 8 bit, default to false (8 bit)
Returns
Error code corresponding to success/failure

◆ readPin()

virtual int16 warpos::Platform::readPin ( uint8 bank,
uint32 pin,
uint32 & value )
inlinevirtual

Read data value from a pin.

Parameters
bankThe bank on which to set the pin
pinThe pin to read
valueImplicit return of the pin value
Returns
Error code corresponding to success/failure

◆ readSerial()

virtual uint32 warpos::Platform::readSerial ( int32 device_fd,
uint8 * buffer,
uint32 size )
inlinevirtual

Read a byte from UART.

Parameters
device_fdFile descriptor of the device to read
bufferImplicit return of values read from buffer
sizeThe number of bytes to read
Returns
The number of bytes read

◆ readSPI()

virtual int16 warpos::Platform::readSPI ( int32 spi_device,
uint8 * buffer,
uint8 size )
inlinevirtual

Read a set of bytes via SPI.

Parameters
spi_deviceThe device to read from
bufferThe buffer of values to read
sizeThe number of bytes to read
Returns
Error code corresponding to success/failure

◆ readWriteSPI()

virtual int16 warpos::Platform::readWriteSPI ( int32 spi_device,
uint8 * buffer,
uint8 size )
inlinevirtual

Write and read a set of bytes via SPI.

Parameters
spi_deviceThe device to write/read
bufferThe buffer to write from and read to
sizeNumber of bytes to write/read
Returns
Error code corresponding to success/failure

◆ setPinMode()

virtual int16 warpos::Platform::setPinMode ( const GpioConfig_t & config)
inlinevirtual

Set the mode for a given GPIO pin on platform.

Parameters
configThe GPIO config to set up for the pin
Returns
Error code corresponding to success/failure

◆ startup()

virtual int16 warpos::Platform::startup ( )
inlinevirtual

Initialize the platform.

Parameters
bankThe bank on which to set the pin
pinThe pin to set
modeOperating mode for the pin
speedSpeed for output pins (not always used)
output_typeOutput type for the pin
pullSets pull (up/down/no) for the selected pin
alternateSpecifies peripheral connected to pins
Returns
Error code corresponding to success/failure

◆ writeI2C()

virtual int16 warpos::Platform::writeI2C ( int32 i2c_fd,
uint8 i2c_address,
uint8 * buffer,
uint8 size )
inlinevirtual

Write a byte to I2C.

Parameters
i2c_fdThe file descriptor to write
i2c_addressThe address to write
bufferThe buffer of values to write
sizeThe number of bytes to write
Returns
Error code corresponding to success/failure

◆ writeI2CAddress()

virtual int16 warpos::Platform::writeI2CAddress ( int32 i2c_fd,
uint8 i2c_address,
uint32 mem_address,
uint8 * buffer,
uint32 size,
bool memory_16 = false )
inlinevirtual

Write a buffer of data to an I2C address.

Parameters
i2c_fdThe file descriptor to write
i2c_addressThe I2C address to communicate with
mem_addressThe memory address to communicate with
bufferThe buffer of data to write
sizeThe amount of data (not including address) to write
memory_16Boolean if the memory addresses are 16 bit or 8 bit, default to false (8 bit)
Returns
Error code corresponding to success/failure

◆ writePin()

virtual int16 warpos::Platform::writePin ( uint8 bank,
uint32 pin,
uint32 value )
inlinevirtual

Write data value to a pin.

Parameters
bankThe bank on which to set the pin
pinThe pin to write
valueThe value to write. Can be anything but typically HIGH/LOW
Returns
Error code corresponding to success/failure

◆ writePwm()

virtual int16 warpos::Platform::writePwm ( int32 pwm_fd,
uint8 channel,
uint32 value )
inlinevirtual

Write a buffer of data to an I2C address.

Parameters
pwm_fdThe file descriptor to write
channelthe Channel to write to
valueThe value to write
Returns
Error code corresponding to success/failure

◆ writeSerial()

virtual int16 warpos::Platform::writeSerial ( int32 device_fd,
uint8 * buffer,
uint8 size )
inlinevirtual

Write a byte to UART.

Parameters
device_fdThe file descriptor of the device to write
bufferThe buffer of values to write
sizeThe number of bytes to write
Returns
Error code corresponding to success/failure

◆ writeSPI()

virtual int16 warpos::Platform::writeSPI ( int32 spi_device,
uint8 * buffer,
uint8 size )
inlinevirtual

Write a set of bytes via SPI.

Parameters
spi_deviceThe device to write to
bufferThe buffer of values to write
sizeThe number of bytes to write
Returns
Error code corresponding to success/failure

The documentation for this class was generated from the following file:
  • /Users/mickey/Documents/Projects/warptwin/warpos/src/flight/Platform.h