ST / X_NUCLEO_IPS02A1

Dependents:   HelloWorld_IPS02A1

Fork of X_NUCLEO_IPS02A1 by ST Expansion SW Team

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers VPS2535H.h Source File

VPS2535H.h

Go to the documentation of this file.
00001 /**
00002  *******************************************************************************
00003  * @file    VPS2535H.h
00004  * @author  ADG
00005  * @version V1.0.1
00006  * @date    01-July-2016
00007  * @brief   vps2535h module driver.
00008  *          This file provides firmware functions to manage the following 
00009  *          functionalities of the vps2535h power switch:
00010  *           + Initialization and de-initialization functions
00011  *           + Diagnostic Sense Pin Configuration
00012  *           + Get Sense Diagnostic Values
00013  *******************************************************************************
00014  * @attention
00015  *
00016  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
00017  *
00018  * Redistribution and use in source and binary forms, with or without modification,
00019  * are permitted provided that the following conditions are met:
00020  *   1. Redistributions of source code must retain the above copyright notice,
00021  *      this list of conditions and the following disclaimer.
00022  *   2. Redistributions in binary form must reproduce the above copyright notice,
00023  *      this list of conditions and the following disclaimer in the documentation
00024  *      and/or other materials provided with the distribution.
00025  *   3. Neither the name of STMicroelectronics nor the names of its contributors
00026  *      may be used to endorse or promote products derived from this software
00027  *      without specific prior written permission.
00028  *
00029  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00030  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00031  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00032  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00033  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00034  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00035  *  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00036  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00037  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00038  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  *
00040  ******************************************************************************
00041  */ 
00042 
00043 
00044 /* Define to prevent recursive inclusion -------------------------------------*/
00045 
00046 #ifndef __VPS2535H_CLASS_H
00047 #define __VPS2535H_CLASS_H
00048  
00049 
00050 /* Includes ------------------------------------------------------------------*/
00051 
00052 #include "mbed.h"
00053 #include "PowerSwitch.h"
00054 #include "VPS2535H_def.h"
00055  
00056  
00057 /* Classes -------------------------------------------------------------------*/
00058 
00059 /** Class representing a VPS2535H power switch component
00060  */  
00061  
00062 class VPS2535H : public PowerSwitch {
00063     
00064 public:    
00065     DigitalOut In_1,In_2,Fr_Stby;
00066  
00067     /** Constructor
00068      * @param[in] input Pin for the power switch
00069      * @param[out] sense1 and sense2, outputs from Ch1 and Ch2
00070      * @param[in] vref, reference voltage
00071      * @param[in] rsense, sense resistor ouside of chip
00072      * @param[in] rd1, upper partitor resistor (=R6 in schematic) to protect ADC 
00073      * @param[in] rd1, lower partitor resistor (=R7 in schematic) to protect ADC
00074      */
00075     VPS2535H(PinName in1, PinName in2, PinName frStdby,
00076              PinName sense1, PinName sense2, float vref,float rsense,float rd1,float rd2):
00077              PowerSwitch(),
00078              In_1 (in1),
00079              In_2 (in2),
00080              Fr_Stby(frStdby),
00081              V_REF(vref), 
00082              R_SENSE(rsense),
00083              R_D1(rd1),
00084              R_D2(rd2),
00085              CurrentSense1(sense1),
00086              CurrentSense2(sense2)
00087     {
00088              In_1 = In_2 = Fr_Stby = 0;
00089     }
00090  
00091     /** Destructor
00092     */
00093     virtual ~VPS2535H() {}
00094   
00095     /*** Interface Methods ***/
00096     virtual int init(void *init_struct);
00097     virtual int close(void);
00098 
00099     /* Getting the ID of the component */
00100     virtual int read_id(uint8_t *id) {
00101         return (int) 235;
00102     }
00103 
00104     /* Provide Ch current w/o checking status of convertion */
00105     virtual float get_current(int Ch);
00106 
00107     /* Provide Ch current Value with status of convertion */
00108     IPS_StatusTypeDef VPS2535H_get_secure_current_sense(IPS_HandleTypeDef *hips);
00109 
00110  
00111 protected:
00112     IPS_StatusTypeDef VPS2535H_close(void);
00113     IPS_StatusTypeDef VPS2535H_init(void);
00114     IPS_StatusTypeDef VPS2535H_get_sense_channel_diagnostic(IPS_HandleTypeDef *);
00115  
00116 private:
00117     const float V_REF;      // Reference voltage for V-sense measurement
00118     const float R_SENSE;    // R-sense value depending on resistor connected to V-sense  output
00119     const float R_D1;       // R_D1 upper divisor partitor resistor (=R6 in schematic)
00120     const float R_D2;       // R_D2 lower divisor partitor resistor (=R7 in schematic)
00121     AnalogIn CurrentSense1; // V-Sense Output from Ch1
00122     AnalogIn CurrentSense2; // V-Sense Output  from Ch2
00123 };
00124 #endif /* __VPS2535H_CLASS_H */
00125 
00126 
00127 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
00128