ST / X_NUCLEO_IPS02A1

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:
grussian
Date:
Thu Jul 28 16:05:28 2016 +0000
Revision:
5:b683e69b181c
Parent:
4:715dcaf74418
Child:
6:c313d3a5c61a
changed component name from vps235h2 to vps2535h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
grussian 0:c175921ca7c3 1 /**
grussian 4:715dcaf74418 2 *******************************************************************************
grussian 4:715dcaf74418 3 * @file IPS.c
grussian 5:b683e69b181c 4 * @author ADG
grussian 5:b683e69b181c 5 * @version V1.0.1
grussian 5:b683e69b181c 6 * @date 01-July-2016
grussian 4:715dcaf74418 7 * @brief IPS (Intelligent Power Switch) module driver common interface.
grussian 4:715dcaf74418 8 *
grussian 4:715dcaf74418 9 *******************************************************************************
grussian 4:715dcaf74418 10 * @attention
grussian 4:715dcaf74418 11 *
grussian 4:715dcaf74418 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
grussian 4:715dcaf74418 13 *
grussian 4:715dcaf74418 14 * Redistribution and use in source and binary forms, with or without modification,
grussian 4:715dcaf74418 15 * are permitted provided that the following conditions are met:
grussian 4:715dcaf74418 16 * 1. Redistributions of source code must retain the above copyright notice,
grussian 4:715dcaf74418 17 * this list of conditions and the following disclaimer.
grussian 4:715dcaf74418 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
grussian 4:715dcaf74418 19 * this list of conditions and the following disclaimer in the documentation
grussian 4:715dcaf74418 20 * and/or other materials provided with the distribution.
grussian 4:715dcaf74418 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
grussian 4:715dcaf74418 22 * may be used to endorse or promote products derived from this software
grussian 4:715dcaf74418 23 * without specific prior written permission.
grussian 4:715dcaf74418 24 *
grussian 4:715dcaf74418 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
grussian 4:715dcaf74418 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
grussian 4:715dcaf74418 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
grussian 4:715dcaf74418 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
grussian 4:715dcaf74418 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
grussian 4:715dcaf74418 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
grussian 4:715dcaf74418 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
grussian 4:715dcaf74418 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
grussian 4:715dcaf74418 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
grussian 4:715dcaf74418 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
grussian 4:715dcaf74418 35 *
grussian 4:715dcaf74418 36 ******************************************************************************
grussian 4:715dcaf74418 37 */
grussian 0:c175921ca7c3 38
grussian 0:c175921ca7c3 39 /* Define to prevent recursive inclusion -------------------------------------*/
grussian 0:c175921ca7c3 40 #ifndef __IPS_H
grussian 0:c175921ca7c3 41 #define __IPS_H
grussian 0:c175921ca7c3 42
grussian 0:c175921ca7c3 43 #include <stdint.h>
grussian 0:c175921ca7c3 44
grussian 0:c175921ca7c3 45
grussian 0:c175921ca7c3 46 /* Exported types ------------------------------------------------------------*/
grussian 0:c175921ca7c3 47
grussian 0:c175921ca7c3 48 /**
grussian 0:c175921ca7c3 49 * @brief IPS Init Structure definition
grussian 0:c175921ca7c3 50 */
grussian 0:c175921ca7c3 51
grussian 0:c175921ca7c3 52 typedef struct
grussian 0:c175921ca7c3 53 {
grussian 0:c175921ca7c3 54 uint32_t Init; /* Inserted for sake of generality */
grussian 0:c175921ca7c3 55 }IPS_InitTypeDef;
grussian 0:c175921ca7c3 56
grussian 0:c175921ca7c3 57 /**
grussian 0:c175921ca7c3 58 * @brief IPS State structures definition
grussian 0:c175921ca7c3 59 */
grussian 0:c175921ca7c3 60 typedef enum
grussian 0:c175921ca7c3 61 {
grussian 0:c175921ca7c3 62 IPS_SUCCESS = 0x00, /*!< No error */
grussian 0:c175921ca7c3 63 IPS_FAIL = 0x01, /*!< Error */
grussian 0:c175921ca7c3 64 IPS_WRONG_CHANNEL = 0x02, /*!< Wrong IPS channel selected */
grussian 0:c175921ca7c3 65 }IPS_StatusTypeDef;
grussian 0:c175921ca7c3 66
grussian 0:c175921ca7c3 67 /**
grussian 0:c175921ca7c3 68 * @brief IPS I/O error type structures definition
grussian 0:c175921ca7c3 69 */
grussian 0:c175921ca7c3 70 typedef enum
grussian 0:c175921ca7c3 71 {
grussian 0:c175921ca7c3 72 IPS_IO_SUCCESS = 0x00, /*!< No error */
grussian 0:c175921ca7c3 73 IPS_IO_FAIL = 0x01, /*!< Error */
grussian 0:c175921ca7c3 74 IPS_ADC_INIT_FAILED = 0x02, /*!< ADC Init failed */
grussian 0:c175921ca7c3 75 IPS_ADC_CAL_FAILED = 0x03, /*!< ADC Calibration failed */
grussian 0:c175921ca7c3 76 IPS_ADC_CONF_CH_FAILED = 0x04, /*!< ADC Configure Channel failed */
grussian 0:c175921ca7c3 77 IPS_ADC_START_FAILED = 0x05, /*!< ADC Start Conversion failed */
grussian 0:c175921ca7c3 78 IPS_ADC_STOP_FAILED = 0x06, /*!< ADC Stop Conversion failed */
grussian 0:c175921ca7c3 79 IPS_ADC_STATE_FAILED = 0x07, /*!< ADC Get State failed */
grussian 0:c175921ca7c3 80 IPS_ADC_POLL_FAILED = 0x08 /*!< ADC Poll for conversion failed */
grussian 0:c175921ca7c3 81 }IO_ErrorType;
grussian 0:c175921ca7c3 82
grussian 0:c175921ca7c3 83 /**
grussian 0:c175921ca7c3 84 * @brief IPS handle Structure definition
grussian 0:c175921ca7c3 85 */
grussian 0:c175921ca7c3 86 typedef struct
grussian 0:c175921ca7c3 87 {
grussian 0:c175921ca7c3 88 uint8_t ipsChannel; /* IPS channel to get sense measurement*/
grussian 0:c175921ca7c3 89 IPS_StatusTypeDef Status; /* IPS Status */
grussian 0:c175921ca7c3 90 IO_ErrorType IO_Status; /* IO Status */
grussian 0:c175921ca7c3 91 float SenseRawValue; /* V-Sense raw value */
grussian 0:c175921ca7c3 92 float GNDSenseRawValue; /* GND Value */
grussian 0:c175921ca7c3 93 float TemperatureValue; /* Chip Temperature */
grussian 0:c175921ca7c3 94 float VccValue; /* Vcc Value */
grussian 0:c175921ca7c3 95 float IValue; /* Current Value */
grussian 0:c175921ca7c3 96 }IPS_HandleTypeDef;
grussian 0:c175921ca7c3 97
grussian 0:c175921ca7c3 98 /**
grussian 0:c175921ca7c3 99 * @brief IPS component id enumerator definition
grussian 0:c175921ca7c3 100 */
grussian 0:c175921ca7c3 101 typedef enum
grussian 0:c175921ca7c3 102 {
grussian 0:c175921ca7c3 103 IPS_NONE_COMPONENT = 0,
grussian 5:b683e69b181c 104 ISP_VPS2535H_COMPONENT = 1
grussian 0:c175921ca7c3 105 } IPS_ComponentTypeDef;
grussian 0:c175921ca7c3 106
grussian 0:c175921ca7c3 107 /**
grussian 0:c175921ca7c3 108 * @brief IPS driver extended structure definition
grussian 0:c175921ca7c3 109 */
grussian 0:c175921ca7c3 110 typedef struct
grussian 0:c175921ca7c3 111 {
grussian 0:c175921ca7c3 112 IPS_ComponentTypeDef
grussian 0:c175921ca7c3 113 id; /* This id must be unique for each component belonging to this class that wants to extend common class */
grussian 0:c175921ca7c3 114 void *pData; /* This pointer is specific for each component */
grussian 0:c175921ca7c3 115 } IPS_DrvExtTypeDef;
grussian 0:c175921ca7c3 116
grussian 0:c175921ca7c3 117 /**
grussian 0:c175921ca7c3 118 * @brief Intelligent Power Switch driver structure definition
grussian 0:c175921ca7c3 119 */
grussian 0:c175921ca7c3 120 typedef struct
grussian 0:c175921ca7c3 121 {
grussian 0:c175921ca7c3 122 IPS_StatusTypeDef (*Init)(IPS_HandleTypeDef *);
grussian 0:c175921ca7c3 123 IPS_StatusTypeDef (*Close)(void);
grussian 0:c175921ca7c3 124 IPS_StatusTypeDef (*ConfigureMuxChannel)(uint8_t, uint8_t);
grussian 0:c175921ca7c3 125 IPS_StatusTypeDef (*GetSenseChannelDiagnostic)(IPS_HandleTypeDef *);
grussian 0:c175921ca7c3 126 IPS_StatusTypeDef (*GetTemperatureChipSense)(IPS_HandleTypeDef *);
grussian 0:c175921ca7c3 127 IPS_StatusTypeDef (*GetVccSense)(IPS_HandleTypeDef *hips);
grussian 0:c175921ca7c3 128 IPS_StatusTypeDef (*GetCurrentSense)(IPS_HandleTypeDef *hips);
grussian 0:c175921ca7c3 129 IPS_DrvExtTypeDef *extData;
grussian 0:c175921ca7c3 130 }IPS_DrvTypeDef;
grussian 0:c175921ca7c3 131
grussian 0:c175921ca7c3 132 #endif /* __IPS_H */
grussian 0:c175921ca7c3 133
grussian 0:c175921ca7c3 134 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
grussian 0:c175921ca7c3 135