API¶
The EVT-core library is broken up into several semantic sections. The sections are meant as a way to divide functionality semantically. Each section may or may not have additional divisions between platform specific and platform agnostic features. For more information on each section, and for specifics on using the EVT-core API refer to the links below.
DEV¶
Devices, representation of hardware that can be interfaced with. In general, devices are communicated with via some sort of IO interface, but that is not strictly a rule. An LED is a simplistic example of a device.
LED¶
RTC¶
-
class EVT::core::DEV::RTC¶
The RTC is the real time clock interface.
This class represents features common acrross real time clocks.
Subclassed by EVT::core::DEV::RTCf302x8
Public Functions
-
virtual void getTime(EVT::core::time::TimeStamp &time) = 0¶
Get the current time as determined by the real time clock.
- Parameters
time – [out] The time struct to populate
-
virtual void getTime(EVT::core::time::TimeStamp &time) = 0¶
IO¶
IO represents different IO interfaces. The common ones are I2C, GPIO, PWM, and CAN. IO generally includes and means for interfacing beyond the microcontroller running the code.
Each platform will implement the IO functionality (if supported by the microcontroller). Since the IO interfaces represent common functionality shared across many devices, platform specific functionality may be supported by the platform’s implementation of the IO interface.
ADC¶
-
class EVT::core::IO::ADC¶
Subclassed by EVT::core::IO::ADCf302x8
CAN¶
-
class EVT::core::IO::CAN¶
Generic interface for CAN bus communication.
Devices can send and recieve messages over the CAN bus using this interface.
This provides the standard set of features supported across all hardware for CAN communication. Any hardware specific features are not included. This interface should be used for the majority of cases and should be deviated from when there is a need for hardware spoecific functionality.
NOTE: You cannot directly make an instance of this class via a constructor. You will need to use the getCAN function in the IO namespace.
Subclassed by EVT::core::IO::CANf302x8
Public Functions
-
CAN(Pin txPin, Pin rxPin, bool loopbackEnabled = false)¶
Creates a new instance of the CAN interface which will use the given transmit and receive pins.
- Parameters
txPin[in] – The pin to use for transmitting data
rxPin[in] – The pin to use for receiving data
loopbackEnabled[in] – Flag to enable CAN loop back functionality
-
virtual void transmit(CANMessage &message) = 0¶
Transmit the message over CAN.
- Parameters
message[in] – The message to send over CAN.
-
virtual CANMessage *receive(CANMessage *message, bool blocking = false) = 0¶
Receive a message over CAN.
The user can either receive in blocking or non-blocking mode. In blocking mode, the code will hang until a message is received then return a pointer to the message that was passed in. In non-blocking, a nullptr will be returned if no message is currently in the mailbox.
- Parameters
message[out] – The message to populate with data
blocking[in] – Used to determine if received should block or not, by default receive is blocking
- Returns
A pointer to the passed in message, nullptr if message not received.
-
CAN(Pin txPin, Pin rxPin, bool loopbackEnabled = false)¶
GPIO¶
-
class EVT::core::IO::GPIO¶
Interface for interacting with GPIO pins on a device.
GPIO pins can have their state read and written to.
This provides the standard set of features supported across all hardware for GPIO pins. Hardware specific features are not included. This interface should be used for the majority of cases and should only be deviated from when there is a need for hardware specific functionality.
NOTE: You cannot directly make an instance of this class via a constructor. To make an instance, use the GPIO::getInstance method.
Subclassed by EVT::core::IO::GPIOf302x8
Public Types
-
enum State¶
Binary representation of the states the GPIO can be in.
Values:
-
enumerator LOW¶
-
enumerator HIGH¶
-
enumerator LOW¶
Public Functions
-
GPIO(Pin pin)¶
Create a new GPIO interface on a specific pin.
The direction will not be set and will have to be set manually.
- Parameters
pin[in] – The pin for the GPIO instance to use.
-
GPIO(Pin pin, Direction direction)¶
Create a new GPIO instance on a specific pin with a given direction.
- Parameters
pin[in] – The pin for the GPIO instance to use.
direction[in] – The directional flow of data.
-
virtual void setDirection(Direction direction) = 0¶
Set the direction of the pin.
- Parameters
direction[in] – The direction of information.
-
virtual void writePin(State state) = 0¶
Used for writing a state to a pin.
- Parameters
state[in] – The state to write to the pin
-
virtual void registerIRQ(TriggerEdge edge, void (*irqHandler)(GPIO *pin)) = 0¶
Registers the IRQHandler for this instances GPIO pin on the given edge condition.
- Parameters
edge[in] – The edge trigger event to trigger the interrupt
irqHandler[in] – The function pointer to handle the GPIO interrupt
-
enum State¶
I2C¶
-
class EVT::core::IO::I2C¶
Subclassed by EVT::core::IO::I2Cf302x8
Public Functions
-
I2C(Pin sclPin, Pin sdaPin)¶
Make an instance of an I2C interface that will use the given pins for clock and data lines.
- Parameters
sclPin[in] – The clock pin
sdaPin[in] – The data pin
-
virtual uint8_t read(uint8_t addr) = 0¶
Read a single byte back from the I2C bus.
- Parameters
addr[in] – The 7 bit unshifted I2C address to read from.
- Returns
The byte read from the address.
-
void write(uint8_t addr, uint8_t *bytes, uint8_t length)¶
Write out multiple bytes over I2C.
Each byte will be written one by one.
-
void read(uint8_t addr, uint8_t *bytes, uint8_t length)¶
Read multiple bytes from an I2C device.
- Parameters
addr[in] – The 7 bit unshifted I2C address to write to
bytes[out] – The buffer to fill with the read in bytes.
length[in] – The number of bytes to read.
-
void writeReg(uint8_t addr, uint8_t reg, uint8_t byte)¶
Write a value to a register has that 8 bit addresses and 8 bit values.
- Parameters
addr – The 7 bit unshifted I2C address to write to.
reg – The 8 bit register
byte – The byte to write out
-
uint8_t readReg(uint8_t addr, uint8_t reg)¶
Read a value from a register that has an 8 bit address and 8 bit value.
- Parameters
addr[in] – The 7 bit unshifted I2C address to read from.
reg[in] – The 8 bit register
- Returns
The 8 bit value of the register.
-
void writeReg(uint8_t addr, uint8_t *reg, uint8_t regLength, uint8_t *bytes, uint8_t length)¶
Write out a multi byte register value.
- Parameters
addr[in] – The 7 bit unshifted I2C address to write to
reg[in] – The register bytes
regLength[in] – The number of bytes in the register address
bytes[in] – The data to write out
length[in] – The number of bytes in the data
-
void readReg(uint8_t addr, uint8_t *reg, uint8_t regLength, uint8_t *bytes, uint8_t length)¶
Read a value from a register.
- Parameters
addr[in] – The 7 bit unshifted I2C address to read from.
reg[in] – The bytes containing the register to read from
regLength[in] – The size in bytes of the register
bytes[out] – The bytes read from the register
length[in] – The size of the data returned by the register in bytes
-
I2C(Pin sclPin, Pin sdaPin)¶
PWM¶
-
class EVT::core::IO::PWM¶
Subclassed by EVT::core::IO::PWMf302x8
Public Functions
-
virtual void setDutyCycle(float dutyCycle) = 0¶
Set the duty cycle for the pin to operate at.
- Parameters
dutyCycle[in] – Duty cycle to set the pin to.
-
virtual void setPeriod(float period) = 0¶
Set the period for the PWM in seconds.
- Parameters
period[in] – The period of the PWM in seconds.
-
virtual void setDutyCycle(float dutyCycle) = 0¶
UART¶
-
class EVT::core::IO::UART¶
Interface for UART operations.
The UART has the ability for character and byte centered operations.
This provides the standard set of features that are shared across all UART modules. Hardware specific features are not included.
The UART modules support both character and byte oriented transmit and receive operations. While fundametally these operations are the same, semantically this makes working with character cetered data and byte centered data cleaner.
NOTE: You cannot directly make an instance of this class via a constructor. To make an isntance, use the UART::getInstance method.
Subclassed by EVT::core::IO::UARTf302x8
Public Types
-
enum Parity¶
Represents the options for the parity settings that may be used when setting up a UART.
Values:
-
enumerator NONE¶
-
enumerator ODD¶
-
enumerator EVEN¶
-
enumerator MASK¶
-
enumerator SPACE¶
-
enumerator NONE¶
Public Functions
-
UART(Pin txPin, Pin rxPin, uint32_t baudrate)¶
Creates a new UART instance that will have the given TX and RX pins as well as the given baud rate.
-
virtual void setBaudrate(uint32_t baudrate) = 0¶
Set the baudrate that the UART will operate with.
- Parameters
baudrate[in] – The new baudrate to use
-
virtual void setFormat(WordLength wordLength = WordLength::EIGHT, Parity parity = Parity::NONE, NumStopBits numStopBits = NumStopBits::ONE) = 0¶
Set the format that data will be communicated with over UART.
DEFAULT: 8 bit words, no parity, 1 stop bit
- Parameters
wordLength[in] – The number of bits in a work (5-8)
parity[in] – The parity settings to use.
numStopBits[in] – The number of stop bits (1-2)
-
virtual bool isReadable() = 0¶
Determins if the UART is currently readable.
- Returns
True if the UART is readable.
-
virtual bool isWritable() = 0¶
Determins if the UART is currently writable.
- Returns
True if the UART is writable
-
virtual void putc(char c) = 0¶
Put a single character to the UART module.
- Parameters
c[in] – The character to send over UART.
-
virtual void puts(const char *s) = 0¶
Put a null-terminal string out over UART.
- Parameters
s[in] – The null-terminated string to put over UART.
-
virtual char getc() = 0¶
Blocking call to read a single character from the UART module.
- Returns
The character read in over UART.
-
char *gets(char *buf, size_t size)¶
Blocking call to get a string from the UART module.
Stops when a newline or EOF character is received or if the maximum size is reached.
- Parameters
buf – The character array to fill
size – The maximum number of characters to read.
- Returns
The buf pointer on success, NULL otherwise
-
virtual void printf(const char *format, ...) = 0¶
Print a formatted string over UART, not great performance so best in test situations not production.
- Parameters
format – The format string to print out.
-
virtual void write(uint8_t byte) = 0¶
Write out a single byte over UART.
- Parameters
byte[in] – The byte to write out over UART.
-
virtual uint8_t read() = 0¶
Blocking reading of a single byte from the UART.
- Returns
The byte read in from UART.
-
enum Parity¶
Types¶
CANMessage¶
-
class EVT::core::IO::CANMessage¶
Represents a generic CAN message which can be sent and received over a CAN bus.
Public Functions
-
CANMessage(uint32_t id, uint8_t dataLength, uint8_t *payload)¶
Create an instance of a CANMessage.
-
CANMessage()¶
Create an empty CANMessage, the id will be 0, dataLength will be 0 and the payload will be empty.
-
uint8_t getDataLength()¶
Get the size of the payload in bytes.
- Returns
The size of the payload in bytes.
-
uint8_t *getPayload()¶
Get the pointer to the payload.
- Returns
pointer to the payload.
-
void setId(uint32_t id)¶
Set the id of the CAN Message.
- Parameters
id[in] – The id of the CAN message
-
void setDataLength(uint8_t size)¶
Set the size of the payload in bytes.
- Parameters
size[in] – The size of the payload in bytes
-
void setPayload(const uint8_t *payload)¶
Set the payload to the contents of the provided array.
Does a copy of the bytes stored.
NOTE: Will copy over CAN_MAX_PAYLOAD_SIZE number of bytes over
- Parameters
payload[in] – The payload to copy over
-
CANMessage &operator=(const CANMessage &other)¶
Assignment operator where the contents of the CANMessage is copied into this message.
- Parameters
other – The CANMessage to copy from
-
CANMessage(uint32_t id, uint8_t dataLength, uint8_t *payload)¶
Platform Implementations¶
Supported Platforms:
Platform¶
Platform represents the microcontroller that the code is running on. Platform specific code such as system setup is included here. For example, placing the microcontroller into a “low power mode” is specific to the microcontroller itself.
Utils¶
Utilities refer to software utilities that make development easier. These can be used to reduce duplicated code, abstract common tasks, or handle functionality that is very common across platforms such as having the system wait for a number of seconds.
Time¶
-
namespace EVT::core::time¶
The functions defined in here are used for time based operations.
All operations are platform independent.
Functions
-
void wait(uint32_t ms)¶
Function to have the program hold for a set amount of time before continuing.
- Parameters
ms – The number of milliseconds to wait for
-
struct TimeStamp¶
- #include <time.hpp>
Struct representing a timestamp.
-
void wait(uint32_t ms)¶