API

This documentation outlines the library for the APM.

APM

The code in the top level APM directory represents the universal board code containing the base functionality for the APM board. It involves methods such as state control.

APMManager

class APM::APMManager

Public Functions

explicit APMManager(APMUart &apmUart, DEV::SIM100 &sim100, IO::GPIO &accessorySwGpio, IO::GPIO &chargeSwGpio, IO::GPIO &vicorSwGpio, EVT::core::DEV::Timerf302x8 &gfdTimer, IO::GPIO &accessoryLed, IO::GPIO &onLed, IO::GPIO &mcRelayGpio)

Create a new APMManager Initializes the IO Devices.

Parameters

baud – the baudrate for the UART device

APMUart &getApmUart() const

Returns the APMUart object by reference.

Returns

const reference to the APMUart object

DEV::SIM100 &getSim100() const

Returns a reference to the Sim100 object for this class.

Returns

reference to the SIM100 module

EVT::core::DEV::Timer &getGFDTimer() const

Gets a reference of the held GFD Timer.

This is used for interrupts to update the timer behavior as necessary.

Returns

reference to the Timer object this->gfdTimer

APMMode getCurrentMode() const

Returns the current mode.

Returns

the current mode

int offToAccessoryMode()

Function to handle the transition from OFF mode to Accessory Mode.

Returns

0 on success.

int accessoryToOnMode()

Function to transition from Accessory Mode to On Mode.

Returns

0 on success.

int onToAccessoryMode()

Function to transition from On Mode to Accessory Mode.

Returns

0 on success

bool isIsolationChecking() const

Check the debug status to determine if SIM100 should be checked for isolation faults.

Returns

True if the SIM100 should be checked. False if not.

void setCheckGFDIsolationState(bool state)

Sets the variable checkGFDIsolationState for debugging.

If set false then the isolation check is not performed.

Parameters

state – The bool state to update the variable to

APMUart

class APM::APMUart

Public Functions

explicit APMUart(IO::UART *apmUart, bool apmDebugPrint = false)

Creates the APMUart class.

Parameters
  • apmUart – pointer to the Uart device used for printing

  • apmDebugPrint – boolean to determine whether or not debug statements should be printed.

void startupMessage() const

Function to print the startup message to the user.

Parameters

uart – the uart device to send the message over

void setDebugPrint(bool debugPrint)

Set the boolean variable to determine whether or not debug statements will be print to the UART device.

Parameters

debugPrint – True if messages should be printed. False if not.

void printDebugString(const char *message) const

Function to conditionally print a debug string.

Parameters

message – The string to print

void printString(const char *message) const

Function to always print a message using the UART device.

Parameters

message – the message to print

char getc() const

Passthrough for apmUart->getc()

Returns

The character read in over UART.

char *gets(char *buf, size_t size) const

Passthrough for apmUart->gets()

Parameters
  • buf – The character array to fill

  • size – The maximum number of characters to read.

Returns

The buf pointer on success, NULL otherwise

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.

SIM100

class APM::DEV::SIM100

This class represents the interface for interacting with the SIM100 ground fault detection board.

For documentation on the CAN interface please see: https://sendyne.com/Products/SIM100%20Isolation%20Monitor.html

Public Types

enum IsolationStateResponse

Enumeration to hold the possible responses for the isolation state from the SIM100 board.

Values:

enumerator CANError
enumerator HardwareError
enumerator HighBatteryVoltage
enumerator LowBatteryVoltage
enumerator IsolationError
enumerator NoError

Public Functions

explicit SIM100(IO::CAN &can)
Parameters

can

int getPartName(char *buf, size_t size)

Returns the part name into the relevant buf variable.

The max length of the part name is 16 bytes.

Parameters
  • buf – the buffer to store the part name into

  • size – the allocated size of buf

Returns

0 on success

int getVersion(char *buf, size_t size)

Reads the firmware version from the board.

Parameters
  • buf – the char array to store the firmware version into

  • size – the allocated size of buf

Returns

0 on success

uint16_t setMaxWorkingVoltage(uint16_t maxVoltage = DEV1_MAX_BATTERY_VOLTAGE)

Sets the max working voltage for the SIM100 load.

Parameters

maxVoltage – the maximum voltage as expressed as a 2 byte unsigned integer. defaults to the max operating voltage for the DEV1 pack

Returns

The maxVoltage response from the GFD Board.

IsolationStateResponse getIsolationState()

Reads the isolation state of the GFD board.

Returns

0 on success. Returns a relevant error code on failure.

int restartSIM100()

Restarts the SIM100 board.

Returns

0 on success. Error code on failure