Skip to content

Class safety

ClassList > safety

Public Functions

Type Name
void disableSafetyApi ()
disable the safet API fault detection task
void enableSafetyApi ()
enable the safet API fault detection task
bool getChannelError (channel_t channels_error)
check if the channel faced an error (went over/under threshold)
safety_reaction_t getChannelReaction ()
returns the reaction to do when encoutering an error.
float32_t getChannelThresholdMax (channel_t channels_threshold)
get the maximum threshold of the selected channel
float32_t getChannelThresholdMin (channel_t channels_threshold)
get the minimum threshold of the selected channel
bool getChannelWatch (channel_t channels_watch)
check if a channel is being monitored or not.
void init_shield ()
Initializes thresholds min/max with the default value from the device tree, if values were stored and found in the flash they will be used instead. All the channels will be monitored to detect potential faults in voltage/current.
void init_shield (channel_t * channels_watch, uint8_t channels_watch_number)
Initializes thresholds min/max with the default value from the device tree, if values were stored and found in the flash they will be used instead. All the channels will be monitored to detect potential faults in voltage/current.
int8_t retrieveThreshold (channel_t channel_threshold_retrieve)
store the current minimum and maximum threshold in the flash (non volatile memory)
void setChannelReaction (safety_reaction_t channels_reaction)
Set the reaction to do if an error has been detected. Choose either open-circuit (both switches are opened and no power flows in the output) or short-circuit (high-side switch is opened, and low-side is closed maintaining the output in short-circuit)
int8_t setChannelThresholdMax (channel_t * channels_threshold, float32_t * threshold_max, uint8_t channels_threshold_number)
set the maximum threshold for the channels present in the list safety_channels.
int8_t setChannelThresholdMin (channel_t * channels_threshold, float32_t * threshold_min, uint8_t channels_threshold_number)
set the minimum threshold for the channels present in the list safety_channels.
int8_t setChannelWatch (channel_t * channels_watch, uint8_t channels_watch_number)
Enables the monitoring of the selected channels for safety.
int8_t storeThreshold (channel_t channel_threshold_store)
store the current minimum and maximum threshold in the flash (non volatile memory)
int8_t unsetChannelWatch (channel_t * channels_watch, uint8_t channels_watch_number)
Disables the monitoring of the selected channels for safety.

Public Functions Documentation

function disableSafetyApi

disable the safet API fault detection task

void safety::disableSafetyApi () 

Returns:

none


function enableSafetyApi

enable the safet API fault detection task

void safety::enableSafetyApi () 

Returns:

none


function getChannelError

check if the channel faced an error (went over/under threshold)

bool safety::getChannelError (
    channel_t channels_error
) 

Parameters:

  • channels_error the channel to check
  • V1_LOW
  • V2_LOW
  • V_HIGH
  • I1_LOW
  • I2_LOW
  • I_HIGH
  • TEMP_SENSOR
  • EXTRA_MEAS
  • ANALOG_COMM

Returns:

true if the channel faced an error, false if not


function getChannelReaction

returns the reaction to do when encoutering an error.

safety_reaction_t safety::getChannelReaction () 

Returns:

Open_Circuit or Short_Circuit


function getChannelThresholdMax

get the maximum threshold of the selected channel

float32_t safety::getChannelThresholdMax (
    channel_t channels_threshold
) 

Parameters:

  • channels_threshold the channel to check
  • V1_LOW
  • V2_LOW
  • V_HIGH
  • I1_LOW
  • I2_LOW
  • I_HIGH
  • TEMP_SENSOR
  • EXTRA_MEAS
  • ANALOG_COMM

Returns:

the maximum threshold


function getChannelThresholdMin

get the minimum threshold of the selected channel

float32_t safety::getChannelThresholdMin (
    channel_t channels_threshold
) 

Parameters:

  • channels_threshold the channel to check
  • V1_LOW
  • V2_LOW
  • V_HIGH
  • I1_LOW
  • I2_LOW
  • I_HIGH
  • TEMP_SENSOR
  • EXTRA_MEAS
  • ANALOG_COMM

Returns:

the minimum threshold


function getChannelWatch

check if a channel is being monitored or not.

bool safety::getChannelWatch (
    channel_t channels_watch
) 

Parameters:

  • channels_watch the channel to check
  • V1_LOW
  • V2_LOW
  • V_HIGH
  • I1_LOW
  • I2_LOW
  • I_HIGH
  • TEMP_SENSOR
  • EXTRA_MEAS
  • ANALOG_COMM

Returns:

true if the channel is being monitored, false if not


function init_shield [1/2]

Initializes thresholds min/max with the default value from the device tree, if values were stored and found in the flash they will be used instead. All the channels will be monitored to detect potential faults in voltage/current.

void safety::init_shield () 

Returns:

none


function init_shield [2/2]

Initializes thresholds min/max with the default value from the device tree, if values were stored and found in the flash they will be used instead. All the channels will be monitored to detect potential faults in voltage/current.

void safety::init_shield (
    channel_t * channels_watch,
    uint8_t channels_watch_number
) 

Parameters:

  • channels_watch A list of the channels to watch. The variables in the list can be : V1_LOW, V2_LOW, V_HIGH, I1_LOW, I2_LOW, I_HIGH, TEMP_SENSOR, EXTRA_MEAS, ANALOG_COMM
  • channels_watch_number The number of channels present in the list channels_watch.

Returns:

none


function retrieveThreshold

store the current minimum and maximum threshold in the flash (non volatile memory)

int8_t safety::retrieveThreshold (
    channel_t channel_threshold_retrieve
) 

Parameters:

  • channel_threshold_retrieve the channel for which we store the threshold in the NVS
  • V1_LOW
  • V2_LOW
  • V_HIGH
  • I1_LOW
  • I2_LOW
  • I_HIGH
  • TEMP_SENSOR
  • EXTRA_MEAS
  • ANALOG_COMM

Returns:

0 if parameters were correcly retreived, negative value if there was an error: -1: NVS is empty -2: NVS contains data, but their version doesn't match current version -3: NVS data is corrupted -4: NVS contains data, but not for the requested channel


function setChannelReaction

Set the reaction to do if an error has been detected. Choose either open-circuit (both switches are opened and no power flows in the output) or short-circuit (high-side switch is opened, and low-side is closed maintaining the output in short-circuit)

void safety::setChannelReaction (
    safety_reaction_t channels_reaction
) 

Parameters:

  • channels_reaction the reaction to do
  • Open_Circuit
  • Short_Circuit

Returns:

none


function setChannelThresholdMax

set the maximum threshold for the channels present in the list safety_channels.

int8_t safety::setChannelThresholdMax (
    channel_t * channels_threshold,
    float32_t * threshold_max,
    uint8_t channels_threshold_number
) 

Parameters:

  • channels_threshold A list of the channels to set the threshold. The variables in the list can be : V1_LOW, V2_LOW, V_HIGH, I1_LOW, I2_LOW, I_HIGH, TEMP_SENSOR, EXTRA_MEAS, ANALOG_COMM
  • threshold_max A list of the maximum threshold to apply to the channels in safety_channels.
  • channels_threshold_number the number of channels present in the list channel_threshold

Returns:

0 if sucessfull, or -1 if not.


function setChannelThresholdMin

set the minimum threshold for the channels present in the list safety_channels.

int8_t safety::setChannelThresholdMin (
    channel_t * channels_threshold,
    float32_t * threshold_min,
    uint8_t channels_threshold_number
) 

Parameters:

  • channels_threshold A list of the channels to set the threshold. The variables in the list can be : V1_LOW, V2_LOW, V_HIGH, I1_LOW, I2_LOW, I_HIGH, TEMP_SENSOR, EXTRA_MEAS, ANALOG_COMM
  • threshold_min A list of the minimum threshold to apply to the channels in safety_channels.
  • channels_threshold_number the number of channels present in the list channel_threshold

Returns:

0 if sucessfull, or -1 if not.


function setChannelWatch

Enables the monitoring of the selected channels for safety.

int8_t safety::setChannelWatch (
    channel_t * channels_watch,
    uint8_t channels_watch_number
) 

Parameters:

  • channels_watch A list of the channels to watch. The variables in the list can be : V1_LOW, V2_LOW, V_HIGH, I1_LOW, I2_LOW, I_HIGH, TEMP_SENSOR, EXTRA_MEAS, ANALOG_COMM
  • channels_watch_number The number of channels present in the list channels_watch.

Returns:

0 if sucessfull, or -1 if there was an error


function storeThreshold

store the current minimum and maximum threshold in the flash (non volatile memory)

int8_t safety::storeThreshold (
    channel_t channel_threshold_store
) 

Parameters:

  • channel_threshold_store the channel for which we store the threshold in the NVS
  • V1_LOW
  • V2_LOW
  • V_HIGH
  • I1_LOW
  • I2_LOW
  • I_HIGH
  • TEMP_SENSOR
  • EXTRA_MEAS
  • ANALOG_COMM

Returns:

0 if parameters were correcly stored, -1 if there was an error.


function unsetChannelWatch

Disables the monitoring of the selected channels for safety.

int8_t safety::unsetChannelWatch (
    channel_t * channels_watch,
    uint8_t channels_watch_number
) 

Parameters:

  • channels_watch A list of the channels to unwatch. The variables in the list can be : V1_LOW, V2_LOW, V_HIGH, I1_LOW, I2_LOW, I_HIGH, TEMP_SENSOR, EXTRA_MEAS, ANALOG_COMM
  • channels_watch_number The number of channels present in the list channels_watch.

Returns:

0 if sucessfull, or -1 if there was an error



The documentation for this class was generated from the following file docs/core/zephyr/modules/owntech_safety_api/zephyr/public_api/SafetyAPI.h