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);

x_nucleo_ips02a1.cpp

Committer:
grussian
Date:
2016-06-13
Revision:
4:715dcaf74418
Parent:
2:06d0eb54630a
Child:
5:b683e69b181c

File content as of revision 4:715dcaf74418:

/**
 ******************************************************************************
 * @file    x_nucleo_ips02A1.cpp
 * @author  APG Mass Market
 * @version V1.0.1
 * @date    16-Nov-2015
 * @brief   Implementation file for the X_NUCLEO_IPS02A1 singleton class
 ******************************************************************************
 * @attention
 *
 * <h2><center>&copy; 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.
 *
 ******************************************************************************
*/ 

/* Includes ------------------------------------------------------------------*/
#include "mbed.h"
#include "x_nucleo_ips02a1.h"

/* Static variables ----------------------------------------------------------*/
X_NUCLEO_IPS02A1* X_NUCLEO_IPS02A1::_instance = NULL;


/* Methods -------------------------------------------------------------------*/
/**
 * @brief  Constructor
 * @return    a pointer to the initialized singleton instance of class X_NUCLEO_IPS02A1
 * @param[in] in1, input1 Pin for the power switch
 * @param[in] in2, input1 Pin for the power switch
 * @param[in] frstdby ,stand-by Pin
 * @param[in] 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
 */
 
X_NUCLEO_IPS02A1::X_NUCLEO_IPS02A1(PinName in1, PinName in2, PinName frstdby,
             PinName sense1, PinName sense2, float vref,float rsense,float rd1,float rd2) : vps235h2( *(new VPS235H2(in1, in2, frstdby,
             sense1, sense2, vref,rsense,rd1,rd2)) )   

{
}


/**
 * @brief     Get singleton instance
 * @return    a pointer to the initialized singleton instance of class X_NUCLEO_IPS02A1
 * @param[in] none
 */
 X_NUCLEO_IPS02A1& X_NUCLEO_IPS02A1::Instance(PinName in1, PinName in2, PinName frstdby,
             PinName sense1, PinName sense2, float vref,float rsense,float rd1,float rd2) {
	if(_instance == NULL) {
		_instance = new X_NUCLEO_IPS02A1(in1,in2,frstdby,
             sense1,sense2,vref,rsense,rd1,rd2);

		if(_instance != NULL) {
			bool ret = _instance->Init();
			if(!ret) {
				error("Failed to init X_NUCLEO_IPS02A1 expansion board!\n");
			}
		}
	}

	return (*_instance);
}

/**
 * @brief  Initialize the singleton's power switch
 * @retval true if initialization successful, 
 * @retval false otherwise
 */
bool X_NUCLEO_IPS02A1::Init_VPS235H2(void) {
  vps235h2.Init(NULL);
  return true;
}

 
/**
 * @brief    get current measurement from singleton's power switch
 * @retval   *hips contain status of the operation
 * param[in] Channel number: CHANNEL_1 or CHANNEL_2
 */
float  X_NUCLEO_IPS02A1:: GetCurrent(int Ch){
  
  return vps235h2.GetCurrent(Ch);
  
}


/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/