GOMspace NanoPower P31u API

Enums

enum KEPSStatus

EPS function return values.

Values:

EPS_OK

Requested function completed successfully.

EPS_ERROR

Generic error.

EPS_I2C_ERROR

I2C error.

EPS_ERROR_CONFIG

Configuration error.

EPS_ERROR_INTERNAL

An error was thrown by the subsystem.

Functions

KEPSStatus k_eps_init(KEPSConf config)

Initialize the interface with the EPS.

Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • config: Interface configuration values

void k_eps_terminate(void)

Terminate the EPS interface.

KEPSStatus k_eps_ping(void)

Ping the EPS.

Return
KEPSStatus EPS_OK if OK, error otherwise

KEPSStatus k_eps_reset(void)

Hard reset the EPS.

Note
It will wait 400ms before re-powering
Return
KEPSStatus EPS_OK if OK, error otherwise

KEPSStatus k_eps_reboot(void)

Reboot the EPS (soft reset)

Note
Output power will not be affected
Return
KEPSStatus EPS_OK if OK, error otherwise

KEPSStatus k_eps_configure_system(const eps_system_config_t *config)

Configure the NanoPower’s system.

Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • config: Pointer to system configuration values

KEPSStatus k_eps_configure_battery(const eps_battery_config_t *config)

Configure the NanoPower’s battery.

Note
Configuration must be saved using k_eps_save_battery_config between 1 and 30 seconds after calling this function, otherwise the changes will be erased.
Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • config: Pointer to battery configuration values

KEPSStatus k_eps_save_battery_config(void)

Save the current battery configuration to EEPROM.

Return
KEPSStatus EPS_OK if OK, error otherwise

KEPSStatus k_eps_set_output(uint8_t channel_mask)

Turn on/off the NanoPower outputs.

Note
Cannot be used to control heaters
Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • channel_mask: Bitmask for output channels (MSB [X X 3.3V 3.3V 3.3V 5V 5V 5V] LSB). 0 = Off, 1 = On

KEPSStatus k_eps_set_single_output(uint8_t channel, uint8_t value, int16_t delay)

Turn on/off a single output.

Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • channel: Output to control. 0-5 = Output channels, 6 = BP4 heater, 7 = BP4 switch
  • value: Desired output value. 0 = Off, 1 = On
  • delay: Amount of time, in seconds, to wait before changing the output’s value

KEPSStatus k_eps_set_input_value(uint16_t in1_voltage, uint16_t in2_voltage, uint16_t in3_voltage)

Set photovoltaic input voltages.

Note
Only used when eps_hk_t.ppt_mode is Fixed
Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • in1_voltage: Voltage value for PV1 [mV]
  • in2_voltage: Voltage value for PV2 [mV]
  • in3_voltage: Voltage value for PV3 [mV]

KEPSStatus k_eps_set_input_mode(uint8_t mode)

Set photovoltaic inputs’ power-point tracking mode.

Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • mode: PPT mode. 0 = hardware default power points, 1 = maximum power-point tracking, 2 = software-defined power points (set with k_eps_set_input_value)

KEPSStatus k_eps_set_heater(uint8_t cmd, uint8_t heater, uint8_t mode)

Control heaters.

Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • cmd: Heater control command (should always be 0 for now)
  • heater: Heater to control
  • mode: State to set heater to. 0 = Off, 1 = On

KEPSStatus k_eps_reset_system_config(void)

Reset system configuration to default values.

Return
KEPSStatus EPS_OK if OK, error otherwise

KEPSStatus k_eps_reset_battery_config(void)

Reset battery configuration to default values.

Note
Values must be saved using k_eps_save_battery_config between 1 and 30 seconds after calling this function, otherwise the changes will be erased
Return
KEPSStatus EPS_OK if OK, error otherwise

KEPSStatus k_eps_reset_counters(void)

Reset system counters (boot count, watchdog reboot counts, etc)

Return
KEPSStatus EPS_OK if OK, error otherwise

KEPSStatus k_eps_get_housekeeping(eps_hk_t *buff)

Get system housekeeping data.

Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • buff: Pointer to storage structure

KEPSStatus k_eps_get_system_config(eps_system_config_t *buff)

Get system configuration values.

Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • buff: Pointer to storage structure

KEPSStatus k_eps_get_battery_config(eps_battery_config_t *buff)

Get battery configuration values.

Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • buff: Pointer to storage structure

KEPSStatus k_eps_get_heater(uint8_t *bp4, uint8_t *onboard)

Get heaters’ statuses.

Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • bp4: Status of BP4 heater. 0 = Off, 1 = On
  • onboard: Status of onboard heater. 0 = Off, 1 = On

KEPSStatus k_eps_watchdog_kick(void)

Kick the EPS’s watchdog once.

Return
KEPSStatus EPS_OK if OK, error otherwise

KEPSStatus k_eps_watchdog_start(uint32_t interval)

Start a thread to kick the EPS’s watchdog.

Note
The watchdog kick requires a write to EEPROM, which has a limited lifespan. It is recommended that the watchdog interval be very large (ex. 48 hours)
Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • interval: Time to sleep in between kicks [seconds]

KEPSStatus k_eps_watchdog_stop(void)

Stop the watchdog thread.

Return
KEPSStatus EPS_OK if OK, error otherwise

KEPSStatus k_eps_passthrough(const uint8_t *tx, int tx_len, uint8_t *rx, int rx_len)

Pass a command packet directly through to the EPS.

Useful for executing commands which have not been implemented in this API

Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • tx: Pointer to command packet to send
  • tx_len: Size of command packet
  • rx: Pointer to storage for command response
  • rx_len: Expected length of command response

KEPSStatus kprv_eps_transfer(const uint8_t *tx, int tx_len, uint8_t *rx, int rx_len)

Write command to EPS and read back a response.

Return
KEPSStatus EPS_OK if OK, error otherwise
Parameters
  • tx: Pointer to command packet to send
  • tx_len: Size of command packet
  • rx: Pointer to storage for command response
  • rx_len: Expected length of command response

struct KEPSConf
#include <gomspace-p31u-api.h>

Kubos -> EPS Configuration.

Public Members

char *bus

I2C bus device EPS is connected to.

uint8_t addr

EPS I2C slave address.

struct eps_resp_header
#include <gomspace-p31u-api.h>

Response header structure.

Public Members

uint8_t cmd

Command which produced this response.

uint8_t status

Status/Error byte.

struct eps_system_config_t
#include <gomspace-p31u-api.h>

System configuration.

Public Members

uint8_t ppt_mode

Mode for power-point tracking [1 = Automatic maximum, 2 = Fixed].

uint8_t battheater_mode

Mode for battery heater activation [0 = Manual, 1 = Auto].

int8_t battheater_low

Turn heater on at [degC] (auto mode)

int8_t battheater_high

Turn heater off at [degC] (auto mode)

uint8_t output_normal_value[8]

Normal mode output values [0 = Off, 1 = On].

uint8_t output_safe_value[8]

Safe mode output values [0 = Off, 1 = On].

uint16_t output_initial_on_delay[8]

Default output power on delays [seconds].

uint16_t output_initial_off_delay[8]

Default output power off delays [seconds].

uint16_t vboost[3]

Fixed PPT point for boost converters [mV].

struct eps_battery_config_t
#include <gomspace-p31u-api.h>

Battery mode configuration (Config2)

Public Members

uint16_t batt_maxvoltage

Voltage threshold to be in FULL mode.

uint16_t batt_safevoltage

Voltage threshold to trigger NORMAL -> SAFE mode.

uint16_t batt_criticalvoltage

Lowest allowable voltage (below -> CRITICAL mode)

uint16_t batt_normalvoltage

Voltage threshold to trigger SAFE -> NORMAL mode.

uint32_t reserved1[2]

Reserved.

uint8_t reserved2[4]

Reserved.

struct eps_hk_t
#include <gomspace-p31u-api.h>

P31u-8 housekeeping.

NOTE that some changes have been made from the GomSpace datasheet due to the complier mis-matches the bytes in the data structure 1) Changed counter_wdt_gnd and counter_boot from uint32_t to uint16_t 2) The attribute((packed)) attribute is removed

The data sizes at other parts of this API are changed accordingly

Public Members

uint16_t vboost[3]

Voltage of input voltage boost converters [mV].

uint16_t vbatt

Voltage of battery [mV].

uint16_t curin[3]

Input currents [mA].

uint16_t cursun

Current from boost converters [mA].

uint16_t cursys

Current out of battery [mA].

uint16_t reserved1

Reserved for future use.

uint16_t curout[6]

Output currents [mA].

uint8_t output[8]

Output statuses [0 = Off, 1 = On].

uint16_t output_on_delta[8]

Time until output power on [seconds].

uint16_t output_off_delta[8]

Time until output power off [seconds].

uint16_t latchup[6]

Number of output latch-up events.

uint32_t wdt_i2c_time_left

Time left for I2C watchdog [seconds].

uint32_t wdt_gnd_time_left

Time left for dedicated watchdog [seconds].

uint8_t wdt_csp_pings_left[2]

Pings left for CSP watchdog.

uint32_t counter_wdt_i2c

Number of I2C watchdog reboots.

uint16_t counter_wdt_gnd

Number of dedicated watchdog reboots.

uint32_t counter_wdt_csp[2]

Number of CSP watchdog reboots.

uint16_t counter_boot

Number of EPS reboots.

int16_t temp[6]

Temperatures [degC] [0 = Temp1, Temp2, Temp3, Temp4, BP4a, BP4b].

uint8_t boot_cause

Cause of last EPS reset.

uint8_t batt_mode

Mode for battery [0 = Initial, 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full].

uint8_t ppt_mode

Mode of power-point tracker [1 = Automatic maximum, 2 = Fixed].

uint16_t reserved2

Reserved.