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 &keyOnSwGpio, IO::GPIO &vicorSwGpio)¶
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
-
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
-
int checkOnSw()¶
Manually checks the device on switch.
Will transition the bike to On mode accordingly
- Returns
0 on success
-
explicit APMManager(APMUart &apmUart, DEV::SIM100 &sim100, IO::GPIO &accessorySwGpio, IO::GPIO &chargeSwGpio, IO::GPIO &keyOnSwGpio, IO::GPIO &vicorSwGpio)¶
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
-
explicit APMUart(IO::UART *apmUart, bool apmDebugPrint = false)¶
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
Public Functions
-
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
-
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.
-
SIM100(IO::CAN &can)¶