Firmware to manage X-Nucleo-IPS02A1 (24V) Intelligent Power Switch.
Dependents: HelloWorld_IPS02A1
Fork of X_NUCLEO_IPS02A1 by
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 2:06d0eb54630a, committed 2016-04-07
- Comitter:
- grussian
- Date:
- Thu Apr 07 15:38:10 2016 +0000
- Parent:
- 1:95670ff9e177
- Child:
- 3:9edf6b8f3b2f
- Commit message:
- added Component-class and ReadId
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Interfaces/Component_class.h Thu Apr 07 15:38:10 2016 +0000
@@ -0,0 +1,75 @@
+/**
+ ******************************************************************************
+ * @file Component_class.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 13-April-2015
+ * @brief This file contains the abstract class describing the interface of a
+ * generic component.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+
+/* Define to prevent from recursive inclusion --------------------------------*/
+
+#ifndef __COMPONENT_CLASS_H
+#define __COMPONENT_CLASS_H
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include <stdint.h>
+
+
+/* Classes ------------------------------------------------------------------*/
+
+/** An abstract class for Generic components.
+ */
+class Component
+{
+public:
+ /**
+ * @brief Initializing the component.
+ * @param init Pointer to device specific initalization structure.
+ * @retval "0" in case of success, an error code otherwise.
+ */
+ virtual int Init(void *init) = 0;
+
+ /**
+ * @brief Getting the ID of the component.
+ * @param id Pointer to an allocated variable to store the ID into.
+ * @retval "0" in case of success, an error code otherwise.
+ */
+ virtual int ReadID(uint8_t *id) = 0;
+};
+
+#endif /* __COMPONENT_CLASS_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/Interfaces/PowerSwitch.h Thu Apr 07 13:42:04 2016 +0000
+++ b/Components/Interfaces/PowerSwitch.h Thu Apr 07 15:38:10 2016 +0000
@@ -42,27 +42,17 @@
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
+#include <Component_class.h>
/* Classes ------------------------------------------------------------------*/
/** An abstract class for Generic Power Switch
*/
-class PowerSwitch
+class PowerSwitch : public Component
{
public:
- /**
- * @brief Initialization of IPS
- * @param[out] ptr Pointer to device specific initalization structure
- * @return 0 in case of success, an error code otherwise
- */
- virtual int Open(void *ptr) = 0;
+ /* Provide Ch current w/o checking status of convertion */
+ virtual float GetCurrent(int Ch);
- /**
- * @brief Close IPS
- * @param[in] void
- * @return 0 in case of success, an error code otherwise
- */
- virtual int Close(void) = 0;
-
};
#endif /* __GENERIC_IPS_CLASS_H */
--- a/Components/vps235h2/vps235h2_class.cpp Thu Apr 07 13:42:04 2016 +0000
+++ b/Components/vps235h2/vps235h2_class.cpp Thu Apr 07 15:38:10 2016 +0000
@@ -47,7 +47,7 @@
* @retval IPS_SUCCESS
*/
-int VPS235H2 :: Open(void *init_struct) {
+int VPS235H2 :: Init(void *init_struct) {
VPS235H2_Init();
return IPS_SUCCESS;
--- a/Components/vps235h2/vps235h2_class.h Thu Apr 07 13:42:04 2016 +0000
+++ b/Components/vps235h2/vps235h2_class.h Thu Apr 07 15:38:10 2016 +0000
@@ -101,13 +101,20 @@
virtual ~VPS235H2() {}
/*** Interface Methods ***/
- virtual int Open(void *init_struct);
+ virtual int Init(void *init_struct);
virtual int Close(void);
+ /* 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);
/* Provide Ch current Value with status of convertion */
IPS_StatusTypeDef VPS235H2_GetSecureCurrentSense(IPS_HandleTypeDef *hips);
-
+ /**
+ * @brief Getting the ID of the component.
+ * @param id Pointer to an allocated variable to store the ID into.
+ * @retval "0" in case of success, an error code otherwise.
+ */
+
protected:
/*** Methods ***/
IPS_StatusTypeDef VPS235H2_Close(void);
--- a/x_nucleo_ips02a1.cpp Thu Apr 07 13:42:04 2016 +0000
+++ b/x_nucleo_ips02a1.cpp Thu Apr 07 15:38:10 2016 +0000
@@ -83,7 +83,7 @@
* @retval false otherwise
*/
bool X_NUCLEO_IPS02A1::Init_VPS235H2(void) {
- vps235h2.Open(NULL);
+ vps235h2.Init(NULL);
return true;
}

X-NUCLEO-IPS02A1 - 24V Intelligent power switch expansion board