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.

IWDG —

class EVT::core::DEV::IWDG

The IWDG is the independent watchdog, which is used to detect software failures.

This class represents features common to watchdog timers.

Subclassed by EVT::core::DEV::IWDGf3xx

Public Functions

virtual void init() = 0

Initializes and activates the watchdog timer.

virtual void refresh() = 0

Refreshes the watchdog timer.

LED

class EVT::core::DEV::LED

Public Types

enum ActiveState

Represents if the LED is active high or active low.

Values:

enumerator HIGH
enumerator LOW

Public Functions

LED(EVT::core::IO::GPIO &gpio, ActiveState activeState)

Create an instance of the LED based on the given GPIO pin.

Parameters
  • gpio[in] GPIO pin

  • activeState[in] Represents if the LED is active high or active low

void toggle()

Toggle the current state of the LED.

void setState(EVT::core::IO::GPIO::State state)

Set the current state of the LED.

Parameters

state[in] The state to set the LED to.

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::RTCf3xx

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 uint32_t getTime() = 0

Get the timestamp since epoch in seconds.

Returns

The time since epoch as determined by the RTC

virtual void setTime(EVT::core::time::TimeStamp &time) = 0

Set the time of the real time clock.

Parameters

time[in] The time to set the RTC to use.

Timer

class EVT::core::DEV::Timer

This class will represent an internal general purpose timer device for the STM32.

It is capable of triggering interrupts with a given frequency

Subclassed by EVT::core::DEV::RTCTimer, EVT::core::DEV::Timerf3xx

Public Functions

virtual void startTimer(void (*irqHandler)(void *htim)) = 0

Starts the given timer and registers the given interrupt pointer to trigger when the timer overflows.

Parameters

irqHandler[in] The IRQ Handler function pointer. Sets a new interrupt handler function

virtual void startTimer() = 0

Starts the given timer using the IRQ Handler already assigned to that timer.

virtual void stopTimer() = 0

Stops the current timer from running.

Does not complete its current counting sequence.

virtual void reloadTimer() = 0

Resets the timer counter.

virtual void setPeriod(uint32_t clockPeriod) = 0

Set the clock period for the timer.

Will stop the timer, re-initialize the device with the updated period. You must call startTimer again to continue timer operation.

Parameters

clockPeriod[in] the clock period in ms. An interrupt will be triggered at that frequency.

EEPROM

class EVT::core::DEV::EEPROM

EEPROMs are a type of small non-volatile storage devices.

This class represents features common across all EEPROMs.

Subclassed by EVT::core::DEV::M24C32

Public Functions

virtual uint8_t readByte(uint32_t address) = 0

Read 8 bits of data from the given address.

Parameters

address[in] The address to read from

Returns

The 8 bits of data at the address

virtual uint16_t readHalfWord(uint32_t address) = 0

Read 16 bits of data from the given address.

Parameters

address[in] The address to read from

Returns

The 16 bits of data at the address

virtual uint32_t readWord(uint32_t address) = 0

Read 32 bits of data from the given address.

Parameters

address[in] The address to read from

Returns

The 32 bits of data at the address

virtual void readBytes(uint32_t address, uint8_t *buffer, uint8_t numBytes) = 0

Read a number of consecutive bytes starting at a given memory address.

Parameters
  • address[in] The memory address to start reading from

  • buffer[out] Buffer to output bytes to

  • numBytes[in] The number of bytes to read

virtual void readHalfWords(uint8_t address, uint16_t *buffer, uint8_t numHWords) = 0

Read a number of consecutive half words starting at a given memory address.

Parameters
  • address[in] The memory address to start reading from

  • buffer[out] Buffer to output half words to

  • numHWords[in] The number of half words to read

virtual void readWords(uint8_t address, uint32_t *buffer, uint8_t numWords) = 0

Read a number of consecutive words starting at a given memory address.

Parameters
  • address[in] The memory address to start reading from

  • buffer[out] Buffer to output words to

  • numWords[in] The number of words to read

virtual void writeByte(uint32_t address, uint8_t data) = 0

Write 8 bits of data to the given address.

Parameters
  • address[in] The address to write to

  • data[in] The data to write out

virtual void writeHalfWord(uint32_t address, uint16_t data) = 0

Write 16 bits of data to the given address.

Parameters
  • address[in] The address to write to

  • data[in] The data to write out

virtual void writeWord(uint32_t address, uint32_t data) = 0

Write 32 bits of data to the given address.

Parameters
  • address[in] The address to write to

  • data[in] The data to write out

virtual void writeBytes(uint32_t address, uint8_t *dataArr, uint8_t numBytes) = 0

Write a number of consecutive bytes to a given memory address.

Parameters
  • address[in] The address to start writing to

  • dataArr[in] The array of bytes to write out

  • numBytes[in] The number of bytes to write out

virtual void writeHalfWords(uint8_t address, uint16_t *dataArr, uint8_t numHWords) = 0

Write a number of consecutive half words to a given memory address.

Parameters
  • address[in] The address to start writing to

  • dataArr[in] The array of half words to write out

  • numHWords[in] The number of half words to write out

virtual void writeWords(uint8_t address, uint32_t *dataArr, uint8_t numWords) = 0

Write a number of consecutive half words to a given memory address.

Parameters
  • address[in] The address to start writing to

  • dataArr[in] The array of half words to write out

  • numWords[in] The number of half words to write out

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::ADCf3xx

Public Functions

ADC(Pin pin)

Setup the given pin for ADC (analog to digital) usage.

Parameters

pin[in] The pin to setup for ADC

virtual float read() = 0

Reads the current voltage in volts on the ADC.

Returns

The voltage in volts

virtual uint32_t readRaw() = 0

Read the raw value from the ADC.

Returns

The raw value from the ADC

virtual float readPercentage() = 0

Read the value from the ADC as a percentage of the possible values from 0 to 1 This is based on the maximum possible valie the ADC can read.

Returns

The ADC value as a percentage

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::CANf3xx

Public Types

enum CANStatus

Represents potential errors that may take place when using the CAN interface.

Values:

enumerator OK
enumerator TIMEOUT
enumerator ERROR

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 CANStatus connect(bool autoBusOff = false) = 0

Join the CAN network.

Will attempt to connect to the CAN network and return the corresponding status.

Parameters

autoBusOff[in] Indicates whether AutoBusOff should be enabled

Returns

The status associated with the success of joining the network

virtual CANStatus disconnect() = 0

Disconnect from the CAN network.

Returns

The status associated with attempting to disconnect

virtual CANStatus transmit(CANMessage &message) = 0

Transmit the message over CAN.

Parameters

message[in] The message to send over CAN.

Returns

The status associated with sending the message

virtual CANStatus 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.

Returns

The status of the receive call, CANStatus::TIMEOUT returned if no message received

virtual CANStatus addCANFilter(uint16_t filterExplicitId, uint16_t filterMask, uint8_t filterBank) = 0

Instantiates a new CAN filter using the 16-bit ID-Mask mode.

If a filter bank that is already in use is provided, the existing filter will be overwritten. A second pair of filter Id and mask can be given to the same filter bank.

Parameters
  • filterExplicitId[in] 11-bit identifier that must be an exact match to pass

  • filterMask[in] 16-bit mask where [1] means care and [0] means don’t care

  • filterBank[in] value between 0-13 where the filter info is stored

Returns

The status associated with adding a new CAN message filter

virtual CANStatus enableEmergencyFilter(uint32_t state) = 0

Enable or disable a filter that lets through any CAN messages that, following the CANopen standard, begin with the Emergency code of 001.

Parameters

state[in] Enum passed to set filter functional state

Returns

The status associated with setting the energency filter state

void addIRQHandler(void (*handler)(CANMessage&, void *priv), void *priv)

Add an interrupt handler for CAN messages.

This will be called with the provided private data when a new CAN message comes in.

NOTE: Having an interrupt handler will bypass the CAN’s internal storage queue thus making CAN::receive ineffective.

Parameters
  • handler[in] The interrupt handler. Takes in a CANmessage and some other parameter

  • priv[in] The private data to pass into the handler

Public Static Attributes

static constexpr uint32_t DEFAULT_BAUD = 500000

Default CAN baudrate.

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::GPIOf3xx

Public Types

enum State

Binary representation of the states the GPIO can be in.

Values:

enumerator LOW
enumerator HIGH
enum Direction

Binary representation of the flow of information, either input or output.

Values:

enumerator INPUT
enumerator OUTPUT
enum TriggerEdge

Enum to handler the possible GPIO trigger states.

Values:

enumerator RISING
enumerator FALLING
enumerator RISING_FALLING
enum Pull

Direction for the internal resistor.

Values:

enumerator NO_PULL
enumerator PULL_UP
enumerator PULL_DOWN

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, Pull pull = Pull::PULL_DOWN)

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.

  • pull[in] The direction of the internal pull resistor

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 State readPin() = 0

Used for reading the state of a pin.

Returns

The state of 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

I2C

class EVT::core::IO::I2C

Contains generic implementations for some of the I2C functionality.

Some hardware has the ability to implement the functionality in this file so specific implementations of the I2C driver may override these methods for a hardware speedup.

Subclassed by EVT::core::IO::I2Cf3xx

Public Types

enum I2CStatus

Represents potential errors that may take place when using the I2C interface.

Each method that interfaces over I2C could potentially return one of these errors, or OK if no error.

Values:

enumerator TIMEOUT
enumerator BUSY
enumerator ERROR
enumerator OK

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 I2CStatus write(uint8_t addr, uint8_t byte) = 0

Write a single byte out over I2C.

Parameters
  • addr[in] The 7 bit unshifted I2C address to write to

  • byte[in] The value to write over I2C

Returns

The status of making the write request

virtual I2CStatus read(uint8_t addr, uint8_t *output) = 0

Read a single byte back from the I2C bus.

Parameters
  • addr[in] The 7 bit unshifted I2C address to read from

  • output[out] The location to store the result from the read

Returns

The status of making the read request

virtual I2CStatus write(uint8_t addr, uint8_t *bytes, uint8_t length)

Write out multiple bytes over I2C.

Each byte will be written one by one.

Parameters
  • addr[in] The 7 bit unshifted I2C address to write to

  • bytes[in] The bytes to write out over I2C

  • length[in] The number of bytes to write out

Returns

The status of making the write request

virtual I2CStatus 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

Returns

The status of making the read request

virtual I2CStatus 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[in] The 7 bit unshifted I2C address to write to

  • reg[in] The 8 bit register

  • byte[in] The byte to write out

Returns

The status of attempting to write out to a register

virtual I2CStatus readReg(uint8_t addr, uint8_t reg, uint8_t *output)

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

  • output[out] Will store the value of the read request

Returns

The 8 bit value of the register

virtual I2CStatus 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

Returns

The status of attempting to write out to the register

virtual I2CStatus 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

Returns

The status of reading from the register

virtual I2CStatus writeMemReg(uint8_t addr, uint32_t memAddress, uint8_t byte, uint16_t memAddSize, uint8_t maxWriteTime) = 0

Write a single byte to a register in memory.

This is a separate method from normal I2C communication because memory read/write methods use a slightly different I2C pattern.

Parameters
  • addr[in] The 7 bit unshifted I2C address to write to

  • memAddress[in] The word containing the register to write to

  • byte[in] The data to write out

  • memAddSize[in] The number of bytes in the memory address (1 or 2)

Returns

The status of writing out a memory register

virtual I2CStatus readMemReg(uint8_t addr, uint32_t memAddress, uint8_t *byte, uint16_t memAddSize) = 0

Read a single byte from a register in memory.

This is a separate method from normal I2C communication because memory read/write methods use a slightly different I2C pattern.

Parameters
  • addr[in] The 7 bit unshifted I2C address to read from

  • memAddress[in] The word containing the register to read from

  • byte[out] The byte read from memory

  • memAddSize[in] The number of bytes in the memory address (1 or 2)

Returns

The result of attempting to read from memory

virtual I2CStatus writeMemReg(uint8_t addr, uint32_t memAddress, uint8_t *byte, uint8_t size, uint16_t memAddSize, uint8_t maxWriteTime) = 0

Write a number of bytes to consecutive registers in memory, starting at a specified register.

This is a separate method from normal I2C communication because memory read/write methods use a slightly different I2C pattern.

Parameters
  • addr[in] The 7 bit unshifted I2C address to write to

  • memAddress[in] The word containing the register to start writing to

  • byte[in] The list of data to write out

  • size[in] The number of bytes to be written

  • memAddSize[in] The number of bytes in the memory address (1 or 2)

Returns

The status of writing out to the memory address

virtual I2CStatus readMemReg(uint8_t addr, uint32_t memAddress, uint8_t *byte, uint8_t size, uint16_t memAddSize) = 0

Read a number of consecutive bytes, starting at a specified register in memory.

This is a separate method from normal I2C communication because memory read/write methods use a slightly different I2C pattern.

Parameters
  • addr[in] The 7 bit unshifted I2C address to read from

  • memAddress[in] The word containing the register to start reading from

  • byte[out] The list of bytes read from memory

  • size[in] The number of bytes to be read

  • memAddSize[in] The number of bytes in the memory address (1 or 2)

  • output[out] The value to store the read back memory

Returns

The status of reading from the memory address;

PWM

class EVT::core::IO::PWM

Subclassed by EVT::core::IO::PWMf3xx

Public Functions

PWM(Pin pin)

Setup the given pin for PWM usage.

Parameters

pin[in] The pin to setup for PWM

virtual void setDutyCycle(uint32_t dutyCycle) = 0

Set the duty cycle for the pin to operate at.

Parameters

dutyCycle[in] Duty cycle as a whole number to set the pin to.

virtual void setPeriod(uint32_t period) = 0

Set the period for the PWM in microseconds.

Parameters

period[in] The period of the PWM in microseconds.

virtual uint32_t getDutyCycle() = 0

Get the current duty cycle.

Returns

The duty cycle the PWM is operating at.

virtual uint32_t getPeriod() = 0

Get the current period.

Returns

The period the PWM is operating at in microseconds.

SPI

class EVT::core::IO::SPI

Subclassed by EVT::core::IO::SPIf3xx

Public Types

enum SPIStatus

Represents the current state of using the SPI interface.

Values:

enumerator OK
enumerator ERROR
enumerator BUSY
enumerator TIMEOUT

Public Functions

SPI(GPIO *CSPins[], uint8_t pinLength, Pin sckPin, Pin mosiPin, Pin misoPin)

Constructs an SPI instance in full duplex mode to send and receive data.

Parameters
  • CSPins – an array of chip select pins for selecting which device to communicate with.

  • pinLength – the number of pins in the chip select array

  • sckPin – the pin for the clk line

  • mosiPin – the mosi pin for sending data

  • misoPin – the miso pin for receiving data

SPI(GPIO *CSPins[], uint8_t pinLength, Pin sckPin, Pin mosiPin)

Constructs an SPI instance in half duplex mode to only send data.

Parameters
  • CSPins – an array of chip select pins for selecting which device to communicate with.

  • pinLength – the number of pins in the chip select array

  • sckPin – the pin for the clk line

  • mosiPin – the mosi pin for sending data

virtual bool startTransmission(uint8_t device) = 0

Begin a device transmission.

Call before each set of read and write interactions.

Parameters

device – the device number in the CSPins array

Returns

true if valid device, false if device not in CSPins

virtual bool endTransmission(uint8_t device) = 0

Toggle the state of the chip select pin of a device back at the end of a transmission.

Call when finished reading or writing a data packet.

Parameters

device – the device index in the CSPins

Returns

true if valid device, false if device not in CSPins

virtual SPI::SPIStatus write(uint8_t byte) = 0

Writes a single byte out to the SPI device.

Call startTransmission() first to initiate device communication.

Parameters

byte – the byte to write

Returns

the status after calling the function

virtual SPI::SPIStatus read(uint8_t *out) = 0

Reads a single byte from a SPI device.

Call startTransmission() first to initiate device communication.

Parameters

out – the byte read

Returns

the status after calling the function

virtual SPI::SPIStatus write(uint8_t *bytes, uint8_t length)

Writes an array of bytes to the SPI device.

Call startTransmission() first to initiate device communication.

Parameters
  • bytes – an array of bytes of length n to write to SPI device

  • length – the length of the array

Returns

the status after calling the function

virtual SPI::SPIStatus read(uint8_t *bytes, uint8_t length)

Reads an array of bytes from a SPI device.

Parameters
  • device – the device to write to in CSPins

  • bytes – an array of length n to receive the bytes from an SPI device

  • length – the number of bytes to receive

Returns

SPIStatus of the HAL function call

SPI::SPIStatus writeReg(uint8_t device, uint8_t reg, uint8_t byte)

Writes a byte of data to a register of a device.

Parameters
  • device – the device index in the CSPins

  • reg – the register address to write to

  • byte – the byte of data to write

Returns

the status after calling the function

SPI::SPIStatus readReg(uint8_t device, uint8_t reg, uint8_t *out)

Reads a byte of data from a register from a device.

Parameters
  • device – the device index in the CSPins

  • reg – the register address to read from

  • out – the byte of data from the device

Returns

the status after calling the function

SPI::SPIStatus writeReg(uint8_t device, uint8_t reg, uint8_t *bytes, uint8_t length)

Writes a series of bytes to a device’s registers starting at a specific one.

(Device must support a multi-byte write)

Parameters
  • device – the device index in the CSPins

  • reg – the register address to start the write at

  • bytes – an array of bytes of length n to write to SPI device

  • length – the length of the array

Returns

the status after calling the function

SPI::SPIStatus readReg(uint8_t device, uint8_t reg, uint8_t *bytes, uint8_t length)

Reads a series of bytes from a device’s registers starting at a specific one.

Parameters
  • device – the device index in the CSPins

  • reg – the register address to start the read from

  • bytes – an array of bytes of length n to store the byte from an SPI device

  • length – the length of the array

Returns

the status after calling the function

virtual void configureSPI(uint32_t baudRate, uint8_t mode, uint8_t order) = 0

Configures the SPI transmit mode.

Parameters
  • baudRate – the baudrate to transmit at (4MHz to 31.25KHz)

  • mode – The SPIMode to use when sending (0-3)

  • order – MSB first or LSB first

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 fundamentally these operations are the same, semantically this makes working with character centered data and byte centered data cleaner.

NOTE: You cannot directly make an instance of this class via a constructor. To make an instance, use the UART::getInstance method.

Subclassed by EVT::core::IO::UARTf3xx

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
enum WordLength

Represents the possible lengths of words that can exist for UART.

Values:

enumerator FIVE
enumerator SIX
enumerator SEVEN
enumerator EIGHT
enum NumStopBits

Represents the number of stop bits that are used.

Values:

enumerator ONE
enumerator TWO

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.

Parameters
  • txPin[in] The UART TX pin.

  • rxPin[in] The UART RX pin.

  • baudrate[in] The baudrate to operate the UART with.

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 void sendBreak() = 0

Sends a serial break condition over UART.

virtual bool isReadable() = 0

Determines if the UART is currently readable.

Returns

True if the UART is readable.

virtual bool isWritable() = 0

Determines 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[out] The character array to fill

  • size[in] 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[in] 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.

virtual void writeBytes(uint8_t *bytes, size_t size) = 0

Write an arbitrary number of bytes out over UART.

Parameters
  • bytes[in] The data to send out over UART

  • size[in] The number of bytes to send out over UART.

virtual void readBytes(uint8_t *bytes, size_t size) = 0

Blocking reading of an arbitrary number of bytes in over UART.

Parameters
  • bytes[out] The data buffer to fill

  • size[in] The number of bytes to read in.

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, bool isExtended)

Create an instance of a CANMessage.

Parameters
  • id[in] The id of the CAN Message

  • dataLength[in] The size of the payload (<= CAN_MAX_PAYLOAD_SIZE)

  • payload[in] The data in the CAN message

CANMessage()

Create an empty CANMessage, the id will be 0, dataLength will be 0 and the payload will be empty.

uint32_t getId()

Get the id of the CAN message.

Returns

id of the specific CAN message

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[in] The CANMessage to copy from

bool isCANExtended()

Get if the CAN message is extended or no.

Returns

True if the message is extended

Public Static Attributes

static constexpr uint8_t CAN_MAX_PAYLOAD_SIZE = 8

Represents the maximum payload size of a CAN message.

Platform Implementations

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.

STM32f3xx

Interrupt priorities are configured with priorities defined by stm32f3xx.hpp. A lower number corresponds to a higher priority. Interrupts of higher priority may interrupt those of lower priority.

namespace EVT::core::platform

Functions

void stm32f3xx_init()

Handles system level initialization of the STM32F302x8.

This makes a series of calls into the HAL to enable system peripherals and enable all required clock.

Variables

constexpr uint32_t CLK_SPEED = 8000000
constexpr uint32_t CAN_INTERRUPT_PRIORITY = 4
constexpr uint32_t ADC_INTERRUPT_PRIORITY = 5
constexpr uint32_t TIMER_INTERRUPT_PRIORITY = 9
constexpr uint32_t GPIO_INTERRUPT_PRIORITY = 10

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

uint32_t millis()

Get the milliseconds since system startup.

Returns

Time in milliseconds

struct TimeStamp
#include <time.hpp>

Struct representing a timestamp.

Public Members

uint16_t year

The current year.

uint8_t month

The current month (1-12)

uint8_t day

The current day (1-31)

uint8_t hour

The hour in a 24 hour timeframe.

uint8_t minute

The minute (0-59)

uint8_t second

The second (0-59)