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 8:73df2d2b721c, committed 2017-07-13
- Comitter:
- Davidroid
- Date:
- Thu Jul 13 16:12:04 2017 +0000
- Parent:
- 7:10e489682b80
- Commit message:
- Aligning to ARM mbed coding style.
Changed in this revision
--- a/Components/VPS2535H/VPS2535H.cpp Tue May 09 09:37:03 2017 +0000 +++ b/Components/VPS2535H/VPS2535H.cpp Thu Jul 13 16:12:04 2017 +0000 @@ -94,18 +94,20 @@ * @retval IPS_StatusTypeDef status */ IPS_StatusTypeDef VPS2535H::VPS2535H_get_sense_channel_diagnostic(IPS_HandleTypeDef *hips){ - hips->SenseRawValue = 0; //if channel is wrong Sense value is 0 - hips->GNDSenseRawValue = 0; // VPS2535H doesn't require GND measurement compensation - hips-> Status =IPS_WRONG_CHANNEL; - hips->IO_Status = IPS_IO_FAIL; - if (hips ->ipsChannel == CHANNEL_1) - hips->SenseRawValue = CurrentSense1.read() * V_REF * ((R_D1+R_D2)/(R_D2)); - if (hips ->ipsChannel == CHANNEL_2) - hips->SenseRawValue = CurrentSense2.read() * V_REF * ((R_D1+R_D2)/(R_D2)); + hips->SenseRawValue = 0; //if channel is wrong Sense value is 0 + hips->GNDSenseRawValue = 0; // VPS2535H doesn't require GND measurement compensation + hips-> Status =IPS_WRONG_CHANNEL; + hips->IO_Status = IPS_IO_FAIL; + if (hips ->ipsChannel == CHANNEL_1) { + hips->SenseRawValue = CurrentSense1.read() * V_REF * ((R_D1+R_D2)/(R_D2)); + } + if (hips ->ipsChannel == CHANNEL_2) { + hips->SenseRawValue = CurrentSense2.read() * V_REF * ((R_D1+R_D2)/(R_D2)); + } - hips->IO_Status = IPS_IO_SUCCESS; - hips->Status =IPS_SUCCESS; - return hips-> Status; + hips->IO_Status = IPS_IO_SUCCESS; + hips->Status =IPS_SUCCESS; + return hips-> Status; } /** @@ -120,18 +122,18 @@ */ IPS_StatusTypeDef VPS2535H::VPS2535H_get_secure_current_sense(IPS_HandleTypeDef *hips){ - if ((hips ->ipsChannel != CHANNEL_1) && (hips ->ipsChannel != CHANNEL_2)) { - hips->Status = IPS_WRONG_CHANNEL; - return IPS_WRONG_CHANNEL; - } + if ((hips ->ipsChannel != CHANNEL_1) && (hips ->ipsChannel != CHANNEL_2)) { + hips->Status = IPS_WRONG_CHANNEL; + return IPS_WRONG_CHANNEL; + } - /* Get sense feedback */ - if ((VPS2535H_get_sense_channel_diagnostic(hips) == IPS_SUCCESS) && (hips->Status == IPS_SUCCESS)) { - hips->IValue= K*hips->SenseRawValue/R_SENSE; - return IPS_SUCCESS; - } - else - return IPS_FAIL; // see hips->Status + /* Get sense feedback */ + if ((VPS2535H_get_sense_channel_diagnostic(hips) == IPS_SUCCESS) && (hips->Status == IPS_SUCCESS)) { + hips->IValue= K*hips->SenseRawValue/R_SENSE; + return IPS_SUCCESS; + } else { + return IPS_FAIL; // see hips->Status + } } /** @@ -141,13 +143,13 @@ */ float VPS2535H::get_current(int Ch) { - if (Ch == CHANNEL_1) { - return (K*CurrentSense1.read()* ((R_D1+R_D2)/(R_D2)) * V_REF/R_SENSE); - } - if (Ch == CHANNEL_2) { - return (K*CurrentSense2.read()* ((R_D1+R_D2)/(R_D2)) * V_REF/R_SENSE); - } - return 0; + if (Ch == CHANNEL_1) { + return (K*CurrentSense1.read()* ((R_D1+R_D2)/(R_D2)) * V_REF/R_SENSE); + } + if (Ch == CHANNEL_2) { + return (K*CurrentSense2.read()* ((R_D1+R_D2)/(R_D2)) * V_REF/R_SENSE); + } + return 0; }
--- a/Components/VPS2535H/VPS2535H.h Tue May 09 09:37:03 2017 +0000 +++ b/Components/VPS2535H/VPS2535H.h Thu Jul 13 16:12:04 2017 +0000 @@ -97,7 +97,9 @@ virtual int close(void); /* Getting the ID of the component */ - virtual int read_id(uint8_t *id) { return (int) 235; } + virtual int read_id(uint8_t *id) { + return (int) 235; + } /* Provide Ch current w/o checking status of convertion */ virtual float get_current(int Ch);
--- a/mbed.bld Tue May 09 09:37:03 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/99a22ba036c9 \ No newline at end of file