High-side Switch
-
class Hss
High side switch API.
Subclassed by hss::HssIno
Public Functions
-
Hss(GPIOPAL *den, GPIOPAL *in, ADCPAL *is, TimerPAL *timer, BtxVariants_t *btxVariant)
High-Side-Switch constructor.
- Parameters:
den – [in] Diagnosis enable GPIO instance
in – [in] Switch input GPIO instance
is – [in] Diagnose current ADC instance
timer – [in] Timer instance
btxVariant – [in] BTx variant
-
Hss(GPIOPAL *den, GPIOPAL *in0, GPIOPAL *in1, GPIOPAL *dsel, ADCPAL *is, TimerPAL *timer, BtxVariants_t *btxVariant)
High-Side-Switch constructor.
This constructor is used to define all necessary pins of the 24V PROFET.
- Parameters:
den – [in] Diagnosis enable GPIO instance
in0 – [in] Switch input 0 GPIO instance
in1 – [in] Switch input 1 GPIO instance
dsel – [in] Diagnosis select GPIO instance
is – [in] Diagnose current ADC instance
timer – [in] Timer instance
btxVariant – [in] BTx variant
-
~Hss()
Destructor of the High-Side-Switch class.
-
Error_t init()
Initialize the High-Side-Switch.
This function initializes all necessary objects of the High-Side-Switch. It returns an error code to see if everything was initialized correctly.
- Returns:
High-side switch error code
-
Error_t enable(Channel_t ch = CHANNEL0)
Enable the High-Side-Switch.
This function is turning on the High-Side-Switch. It is also setting the status of the switch to ON.
- Parameters:
ch – [in] Channel number. Default 0.
- Returns:
High-side switch error code
-
Error_t disable(Channel_t ch = CHANNEL0)
Disable the High-Side-Switch.
This function turns off the High-Side-Switch. It is also setting the status of the switch to OFF.
- Parameters:
ch – [in] Channel number. Default 0.
- Returns:
High-side switch error code
-
Error_t enableDiag()
Enable diagnosis function.
This function is enabling the diagnosis function of the High-Side-Switch.
- Returns:
High-side switch error code
-
Error_t disableDiag()
Disable diagnosis function.
This function is disabling the diagnosis function of the High-Side-Switch
- Returns:
High-side switch error code
-
Status_t getSwitchStatus()
Get the switch status.
This function returns the current status of the switch.
- Return values:
0 – Uninitialized
1 – Initialized
2 – Power on
3 – Power off
- Returns:
Status_t
-
DiagStatus_t diagRead(float senseCurrent, Channel_t ch = CHANNEL0)
Diagnosis of the Sensor.
This function is using the IS signal to determine the state of the switch. It returns an diagnosis state of the switch.
Note
This function should be called only after you get the Is value. Also note, in case you are using shield with no channel differentiation, then ignore the ‘ch’ parameter and this will default to CHANNEL0.
- Parameters:
senseCurrent – [in] Sensed current value
ch – [in] Channel no. Unused.
- Return values:
0 – Switch is working fine
1 – Fault condition detected
2 – Open Load in ON or Inverse Current
- Returns:
DiagStatus_t
-
float readIs(uint16_t rSense, Channel_t ch = CHANNEL0)
Read ADC value for IS.
This functions is reading the IS signal of the switch. It returns the calculated current, which is depending on the IS signal.
Note
Before calling this function, ensure IS pin is initialized and you do not have to pass channel in case your shield does not support multiple channel and this would default to CHANNEL0 applicable.
- Parameters:
rSense – [in] Resistor value of the current sense resistor in [Ohm]
ch – [in] Channel number
- Returns:
Value of the current flowing through the switch in [A]
-
void setCurrentOffset(float offset)
Set current offset.
This function can be used to change the value of the internal variable of the current offset
- Parameters:
offset – [in] Desired value of the current offset in [A]
-
Hss(GPIOPAL *den, GPIOPAL *in, ADCPAL *is, TimerPAL *timer, BtxVariants_t *btxVariant)