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);
Committer:
Davidroid
Date:
Thu Jul 13 16:12:04 2017 +0000
Revision:
8:73df2d2b721c
Parent:
7:10e489682b80
Aligning to ARM mbed coding style.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
grussian 0:c175921ca7c3 1 /**
grussian 4:715dcaf74418 2 *******************************************************************************
Davidroid 7:10e489682b80 3 * @file XNucleoIPS02A1.h
grussian 5:b683e69b181c 4 * @author ADG
grussian 4:715dcaf74418 5 * @version V1.0.1
grussian 5:b683e69b181c 6 * @date 01-July-2016
Davidroid 7:10e489682b80 7 * @brief Header file for the X-NUCLEO-IPS02A1 expansion board
grussian 4:715dcaf74418 8 *******************************************************************************
grussian 4:715dcaf74418 9 * @attention
grussian 4:715dcaf74418 10 *
grussian 6:c313d3a5c61a 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
grussian 4:715dcaf74418 12 *
grussian 4:715dcaf74418 13 * Redistribution and use in source and binary forms, with or without modification,
grussian 4:715dcaf74418 14 * are permitted provided that the following conditions are met:
grussian 4:715dcaf74418 15 * 1. Redistributions of source code must retain the above copyright notice,
grussian 4:715dcaf74418 16 * this list of conditions and the following disclaimer.
grussian 4:715dcaf74418 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
grussian 4:715dcaf74418 18 * this list of conditions and the following disclaimer in the documentation
grussian 4:715dcaf74418 19 * and/or other materials provided with the distribution.
grussian 4:715dcaf74418 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
grussian 4:715dcaf74418 21 * may be used to endorse or promote products derived from this software
grussian 4:715dcaf74418 22 * without specific prior written permission.
grussian 4:715dcaf74418 23 *
grussian 4:715dcaf74418 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
grussian 4:715dcaf74418 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
grussian 4:715dcaf74418 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
grussian 4:715dcaf74418 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
grussian 4:715dcaf74418 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
grussian 4:715dcaf74418 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
grussian 4:715dcaf74418 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
grussian 4:715dcaf74418 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
grussian 4:715dcaf74418 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
grussian 4:715dcaf74418 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
grussian 4:715dcaf74418 34 *
grussian 4:715dcaf74418 35 ******************************************************************************
Davidroid 7:10e489682b80 36 */
Davidroid 7:10e489682b80 37
grussian 0:c175921ca7c3 38
grussian 0:c175921ca7c3 39 /* Define to prevent recursive inclusion -------------------------------------*/
Davidroid 7:10e489682b80 40
grussian 0:c175921ca7c3 41 #ifndef __X_NUCLEO_IPS02A1_H
grussian 0:c175921ca7c3 42 #define __X_NUCLEO_IPS02A1_H
grussian 0:c175921ca7c3 43
grussian 0:c175921ca7c3 44
grussian 0:c175921ca7c3 45 /* Includes ------------------------------------------------------------------*/
Davidroid 7:10e489682b80 46
Davidroid 7:10e489682b80 47 #include "VPS2535H.h"
Davidroid 7:10e489682b80 48
grussian 0:c175921ca7c3 49
grussian 0:c175921ca7c3 50 /* Classes -------------------------------------------------------------------*/
Davidroid 7:10e489682b80 51
grussian 0:c175921ca7c3 52 /** Class X_NUCLEO_IPS02A1 is intended to represent the intelligent power switch
grussian 0:c175921ca7c3 53 * Nucleo Expansion Board with the same name.
grussian 0:c175921ca7c3 54 *
grussian 0:c175921ca7c3 55 * The expansion board is featuring basically of:\n
grussian 5:b683e69b181c 56 * -# a VPS2535H power switch\n
grussian 0:c175921ca7c3 57 *
grussian 0:c175921ca7c3 58 * It is intentionally implemented as a singleton because only one
Davidroid 7:10e489682b80 59 * XNucleoIPS02A1 at a time might be deployed in a HW component stack.\n
grussian 0:c175921ca7c3 60 * In order to get the singleton instance you have to call class method `Instance()`,
grussian 0:c175921ca7c3 61 * e.g.:
grussian 0:c175921ca7c3 62 * @code
grussian 0:c175921ca7c3 63 * // Intelligent Power Switch expansion board singleton instance
Davidroid 7:10e489682b80 64 * static XNucleoIPS02A1 *<TODO>_expansion_board = XNucleoIPS02A1::instance();
grussian 0:c175921ca7c3 65 * @endcode
grussian 0:c175921ca7c3 66 */
grussian 0:c175921ca7c3 67
Davidroid 7:10e489682b80 68 class XNucleoIPS02A1
grussian 0:c175921ca7c3 69 {
Davidroid 7:10e489682b80 70 public:
Davidroid 7:10e489682b80 71 /**
Davidroid 7:10e489682b80 72 * @brief Get singleton instance
Davidroid 7:10e489682b80 73 * @return a pointer to the initialized singleton instance of class X_NUCLEO_IPS02A1
Davidroid 7:10e489682b80 74 * @param[in] none
Davidroid 7:10e489682b80 75 */
Davidroid 7:10e489682b80 76 static XNucleoIPS02A1& instance (PinName in1, PinName in2, PinName frstdby,
Davidroid 7:10e489682b80 77 PinName sense1, PinName sense2, float vref, float rsense, float rd1, float rd2);
Davidroid 7:10e489682b80 78
Davidroid 7:10e489682b80 79 /**
Davidroid 7:10e489682b80 80 * @brief get current measurement from singleton's power switch
Davidroid 7:10e489682b80 81 * @retval *hips contain status of the operation
Davidroid 7:10e489682b80 82 * param[in] Channel number: CHANNEL_1 or CHANNEL_2
Davidroid 7:10e489682b80 83 */
Davidroid 7:10e489682b80 84 float get_current(int ch);
Davidroid 7:10e489682b80 85
Davidroid 7:10e489682b80 86 /**
Davidroid 7:10e489682b80 87 * Power switch.
Davidroid 7:10e489682b80 88 */
Davidroid 7:10e489682b80 89 VPS2535H &vps2535h;
Davidroid 7:10e489682b80 90
Davidroid 7:10e489682b80 91
Davidroid 7:10e489682b80 92 protected:
Davidroid 7:10e489682b80 93 /**
Davidroid 7:10e489682b80 94 * Constructor.
Davidroid 7:10e489682b80 95 */
Davidroid 7:10e489682b80 96 XNucleoIPS02A1(PinName in1, PinName in2, PinName frstdby,
grussian 0:c175921ca7c3 97 PinName sense1, PinName sense2, float vref,float rsense,float rd1,float rd2);
grussian 0:c175921ca7c3 98
grussian 0:c175921ca7c3 99 /**
Davidroid 7:10e489682b80 100 * @brief Initialize the singleton's power switch to default settings
grussian 0:c175921ca7c3 101 * @retval true if initialization successful,
grussian 0:c175921ca7c3 102 * @retval false otherwise
grussian 0:c175921ca7c3 103 */
Davidroid 7:10e489682b80 104 bool init(void) {
Davidroid 7:10e489682b80 105 return (init_VPS2535H());
grussian 0:c175921ca7c3 106 }
grussian 0:c175921ca7c3 107
Davidroid 7:10e489682b80 108 /**
Davidroid 7:10e489682b80 109 * @brief Initialize the singleton's power switch
Davidroid 7:10e489682b80 110 * @retval true if initialization successful,
Davidroid 7:10e489682b80 111 * @retval false otherwise
Davidroid 7:10e489682b80 112 */
Davidroid 7:10e489682b80 113 bool init_VPS2535H(void);
grussian 0:c175921ca7c3 114
grussian 0:c175921ca7c3 115
Davidroid 7:10e489682b80 116 private:
Davidroid 7:10e489682b80 117 /**
Davidroid 7:10e489682b80 118 * Singleton instance of class XNucleoIPS02A1.
Davidroid 7:10e489682b80 119 */
Davidroid 7:10e489682b80 120 static XNucleoIPS02A1 *_instance;
Davidroid 7:10e489682b80 121 };
grussian 0:c175921ca7c3 122
grussian 0:c175921ca7c3 123 #endif /* __X_NUCLEO_IPS02A1_H */
grussian 0:c175921ca7c3 124
grussian 0:c175921ca7c3 125
grussian 0:c175921ca7c3 126 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/