Firmware to manage X-Nucleo-IPS02A1 (24V) Intelligent Power Switch.

Dependents:   HelloWorld_IPS02A1

Fork of X_NUCLEO_IPS02A1 by ST Expansion SW Team

X_NUCLEO_IPS02A1 24V Intelligent Power Switch (IPS) Nucleo Expansion Board Firmware Package

Introduction

This firmware package includes Components Device Drivers and Board Support Package for STMicroelectronics X-NUCLEO-IPS02A1 IPS Expansion Board.

Firmware Library

Class X_NUCLEO_IPS02A1 is intended to represent the Intelligent Power Switch expansion board with the same name.

The expansion board is basically featuring by one IP:

  • vps2535h vertical power switch.

It is intentionally implemented as a singleton because only one X-NUCLEO-IPS02A1 at a time might be deployed in a HW component stack. In order to get the singleton instance you have to call class method `Instance()`, e.g.:

// IPS expansion board singleton instance
static X_NUCLEO_IPS02A1 *ips_expansion_board = X_NUCLEO_IPS02A1::Instance();

How to use the firmware package

The basic operations to deal with the firmware pkg and use the IPS are the following :

1) instantiate the X_NUCLEO by calling class method `Instance()`:

// Sensors expansion board singleton instance
static X_NUCLEO_IPS02A1 *sensors_expansion_board = X_NUCLEO_IPS02A1::Instance();

2) Switch-on or Switch-off loads output (Channel 1 or Channel 2) by setting or clearing associated digital input :

            ips_expansion_board.vps2535h.Fr_Stby = 1; // set Fr_Stby pin
            ips_expansion_board.vps2535h.In_1 = 1; // switch-on Channel 1
            ips_expansion_board.vps2535h.In_2 = 0; // switch-off Channle 2 

3) Read Current circulating on Channel 1 or Channel 2 and print on the Terminal

            Multisense_Signal= ips_expansion_board.GetCurrent(CHANNEL_1);
            printf("Current Ch1 = %2.3fA \n\r", Multisense_Signal);
            Multisense_Signal= ips_expansion_board.GetCurrent(CHANNEL_2);
            printf("Current Ch2 = %2.3fA \n\r", Multisense_Signal);
Revision:
3:9edf6b8f3b2f
Parent:
2:06d0eb54630a
Child:
4:715dcaf74418
--- a/Components/vps235h2/vps235h2_class.h	Thu Apr 07 15:38:10 2016 +0000
+++ b/Components/vps235h2/vps235h2_class.h	Thu May 26 10:13:36 2016 +0000
@@ -45,39 +45,35 @@
   *
   ********************************************************************************
   */
-
+ 
 /* Define to prevent recursive inclusion -------------------------------------*/
 #ifndef __VPS220H1_CLASS_H
 #define __VPS220H1_CLASS_H
-
+ 
 /* Includes ------------------------------------------------------------------*/
 #include "mbed.h"
 #include "PowerSwitch.h"
 #include "IPS.h"
 #include "vps235h2.h"
-
-
-
+ 
+ 
 /* Classes -------------------------------------------------------------------*/
 /** Class representing a VPS235H2 power switch component
  */  
-
+ 
 class VPS235H2 : public PowerSwitch {
     
 public:    
     DigitalOut In_1,In_2,Fr_Stby;
-   
-  
  
     /** Constructor
-      * @param[in] input Pin for the power switch
-      * @param[out] sense1 and sense2, outputs from Ch1 and Ch2
-      * @param[in] vref, reference voltage
-      * @param[in] rsense, sense resistor ouside of chip
-      * @param[in] rd1, upper partitor resistor (=R6 in schematic) to protect ADC 
-      * @param[in] rd1, lower partitor resistor (=R7 in schematic) to protect ADC
-    
-      */
+     * @param[in] input Pin for the power switch
+     * @param[out] sense1 and sense2, outputs from Ch1 and Ch2
+     * @param[in] vref, reference voltage
+     * @param[in] rsense, sense resistor ouside of chip
+     * @param[in] rd1, upper partitor resistor (=R6 in schematic) to protect ADC 
+     * @param[in] rd1, lower partitor resistor (=R7 in schematic) to protect ADC
+     */
     VPS235H2(PinName in1, PinName in2, PinName frStdby,
              PinName sense1, PinName sense2, float vref,float rsense,float rd1,float rd2):
              PowerSwitch(),
@@ -91,11 +87,9 @@
              CurrentSense1(sense1),
              CurrentSense2(sense2)
              {
-                  
-             In_1 = In_2 = Fr_Stby = 0; 
-      
+             In_1 = In_2 = Fr_Stby = 0;
     }
-    
+ 
     /** Destructor
     */
     virtual ~VPS235H2() {}
@@ -106,7 +100,7 @@
     /* Getting the ID of the component */
     virtual int ReadID(uint8_t *id) { return (int) 235; }
     /* Provide Ch current w/o checking status of convertion */
-    float GetCurrent(int Ch);
+    virtual float GetCurrent(int Ch);
     /* Provide Ch current Value with status of convertion */
     IPS_StatusTypeDef VPS235H2_GetSecureCurrentSense(IPS_HandleTypeDef *hips);
     /**
@@ -114,28 +108,22 @@
      * @param  id Pointer to an allocated variable to store the ID into.
      * @retval "0" in case of success, an error code otherwise.
      */
-
-   protected:
+ 
+protected:
     /*** Methods ***/
     IPS_StatusTypeDef VPS235H2_Close(void);
     IPS_StatusTypeDef VPS235H2_Init(void);
     IPS_StatusTypeDef VPS235H2_GetSenseChannelDiagnostic(IPS_HandleTypeDef *);
-
-   private:
+ 
+private:
     const float V_REF;      // Reference voltage for V-sense measurement
     const float R_SENSE;    // R-sense value depending on resistor connected to V-sense  output
     const float R_D1;       // R_D1 upper divisor partitor resistor (=R6 in schematic)
     const float R_D2;       // R_D2 lower divisor partitor resistor (=R7 in schematic)
     AnalogIn CurrentSense1; // V-Sense Output from Ch1
     AnalogIn CurrentSense2; // V-Sense Output  from Ch2
-    
 };
 #endif /* __VPS235H2_CLASS_H */
-
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 
-  
-  
-  
-
+ 
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ 
\ No newline at end of file