![](/media/cache/profiles/3dba60a54c45c57eb920a566381e58fc.jpg.50x50_q85.jpg)
Example application for using IPS01A1
Dependencies: X_NUCLEO_IPS01A1 mbed
main.cpp@0:79edd8d5fabd, 2015-11-26 (annotated)
- Committer:
- grussian
- Date:
- Thu Nov 26 12:57:51 2015 +0000
- Revision:
- 0:79edd8d5fabd
First version of application example using X_NUCLEO_IPS01A1 library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
grussian | 0:79edd8d5fabd | 1 | /** |
grussian | 0:79edd8d5fabd | 2 | ****************************************************************************** |
grussian | 0:79edd8d5fabd | 3 | * @file main.cpp |
grussian | 0:79edd8d5fabd | 4 | * @author APG Mass Market |
grussian | 0:79edd8d5fabd | 5 | * @version V1.0.1 |
grussian | 0:79edd8d5fabd | 6 | * @date 16-Nov-2015 |
grussian | 0:79edd8d5fabd | 7 | * @brief Example application for using the X_NUCLEO_IPS01A1 |
grussian | 0:79edd8d5fabd | 8 | * Intelligent Power Switch Nucleo expansion board. |
grussian | 0:79edd8d5fabd | 9 | ****************************************************************************** |
grussian | 0:79edd8d5fabd | 10 | * @attention |
grussian | 0:79edd8d5fabd | 11 | * |
grussian | 0:79edd8d5fabd | 12 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
grussian | 0:79edd8d5fabd | 13 | * |
grussian | 0:79edd8d5fabd | 14 | * Redistribution and use in source and binary forms, with or without modification, |
grussian | 0:79edd8d5fabd | 15 | * are permitted provided that the following conditions are met: |
grussian | 0:79edd8d5fabd | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
grussian | 0:79edd8d5fabd | 17 | * this list of conditions and the following disclaimer. |
grussian | 0:79edd8d5fabd | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
grussian | 0:79edd8d5fabd | 19 | * this list of conditions and the following disclaimer in the documentation |
grussian | 0:79edd8d5fabd | 20 | * and/or other materials provided with the distribution. |
grussian | 0:79edd8d5fabd | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
grussian | 0:79edd8d5fabd | 22 | * may be used to endorse or promote products derived from this software |
grussian | 0:79edd8d5fabd | 23 | * without specific prior written permission. |
grussian | 0:79edd8d5fabd | 24 | * |
grussian | 0:79edd8d5fabd | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
grussian | 0:79edd8d5fabd | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
grussian | 0:79edd8d5fabd | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
grussian | 0:79edd8d5fabd | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
grussian | 0:79edd8d5fabd | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
grussian | 0:79edd8d5fabd | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
grussian | 0:79edd8d5fabd | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
grussian | 0:79edd8d5fabd | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
grussian | 0:79edd8d5fabd | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
grussian | 0:79edd8d5fabd | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
grussian | 0:79edd8d5fabd | 35 | * |
grussian | 0:79edd8d5fabd | 36 | ****************************************************************************** |
grussian | 0:79edd8d5fabd | 37 | */ |
grussian | 0:79edd8d5fabd | 38 | |
grussian | 0:79edd8d5fabd | 39 | /** |
grussian | 0:79edd8d5fabd | 40 | * @mainpage X_NUCLEO_IPS01A1 Intelligent Power Switch Nucleo Expansion Board Firmware Package |
grussian | 0:79edd8d5fabd | 41 | * |
grussian | 0:79edd8d5fabd | 42 | * <b>Introduction</b> |
grussian | 0:79edd8d5fabd | 43 | * |
grussian | 0:79edd8d5fabd | 44 | * This firmware package includes Components Device Drivers, Board Support Package |
grussian | 0:79edd8d5fabd | 45 | * and example application for STMicroelectronics X_NUCLEO_IPS01A1 Intelligent Power Switch |
grussian | 0:79edd8d5fabd | 46 | * Nucleo Expansion Board |
grussian | 0:79edd8d5fabd | 47 | * |
grussian | 0:79edd8d5fabd | 48 | * <b>Example Application</b> |
grussian | 0:79edd8d5fabd | 49 | * |
grussian | 0:79edd8d5fabd | 50 | */ |
grussian | 0:79edd8d5fabd | 51 | /*** Includes ----------------------------------------------------------------- ***/ |
grussian | 0:79edd8d5fabd | 52 | #include "mbed.h" |
grussian | 0:79edd8d5fabd | 53 | #include "assert.h" |
grussian | 0:79edd8d5fabd | 54 | #include "x_nucleo_ips01a1.h" |
grussian | 0:79edd8d5fabd | 55 | |
grussian | 0:79edd8d5fabd | 56 | /*** Static variables --------------------------------------------------------- ***/ |
grussian | 0:79edd8d5fabd | 57 | #ifdef DBG_MCU |
grussian | 0:79edd8d5fabd | 58 | #include "DbgMCU.h" |
grussian | 0:79edd8d5fabd | 59 | static DbgMCU enable_dbg; |
grussian | 0:79edd8d5fabd | 60 | #endif // DBG_MCU |
grussian | 0:79edd8d5fabd | 61 | |
grussian | 0:79edd8d5fabd | 62 | /* HW settings */ |
grussian | 0:79edd8d5fabd | 63 | /* Pay attention before changing HW settings, they must be coherent with you HW design */ |
grussian | 0:79edd8d5fabd | 64 | /* Power Switch Connection to Arduino connectors */ |
grussian | 0:79edd8d5fabd | 65 | #define IPS01A1_PIN_IN_0 (D5) |
grussian | 0:79edd8d5fabd | 66 | #define IPS01A1_PIN_IN_1 (D6) |
grussian | 0:79edd8d5fabd | 67 | #define IPS01A1_PIN_SEL_0 (D14) |
grussian | 0:79edd8d5fabd | 68 | #define IPS01A1_PIN_SEL_1 (D15) |
grussian | 0:79edd8d5fabd | 69 | #define IPS01A1_PIN_S_EN (D2) |
grussian | 0:79edd8d5fabd | 70 | #define IPS01A1_PIN_FAULT_RST (D4) |
grussian | 0:79edd8d5fabd | 71 | #define IPS01A1_PIN_MULTISENSE (A2) |
grussian | 0:79edd8d5fabd | 72 | #define IPS01A1_PIN_V_GND (A4) |
grussian | 0:79edd8d5fabd | 73 | |
grussian | 0:79edd8d5fabd | 74 | /* V-Ref */ |
grussian | 0:79edd8d5fabd | 75 | #define V_REF 3.3 |
grussian | 0:79edd8d5fabd | 76 | /* Rsense Value */ |
grussian | 0:79edd8d5fabd | 77 | #define R_SENSE 1e3 |
grussian | 0:79edd8d5fabd | 78 | /* R_D1 */ |
grussian | 0:79edd8d5fabd | 79 | #define R_D1 15e3 |
grussian | 0:79edd8d5fabd | 80 | /* R_D2 */ |
grussian | 0:79edd8d5fabd | 81 | #define R_D2 30e3 |
grussian | 0:79edd8d5fabd | 82 | |
grussian | 0:79edd8d5fabd | 83 | /* End of HW settings */ |
grussian | 0:79edd8d5fabd | 84 | |
grussian | 0:79edd8d5fabd | 85 | static X_NUCLEO_IPS01A1 &ips_expansion_board = X_NUCLEO_IPS01A1::Instance(IPS01A1_PIN_IN_0, |
grussian | 0:79edd8d5fabd | 86 | IPS01A1_PIN_IN_1, |
grussian | 0:79edd8d5fabd | 87 | IPS01A1_PIN_SEL_0, |
grussian | 0:79edd8d5fabd | 88 | IPS01A1_PIN_SEL_1, |
grussian | 0:79edd8d5fabd | 89 | IPS01A1_PIN_S_EN, |
grussian | 0:79edd8d5fabd | 90 | IPS01A1_PIN_FAULT_RST, |
grussian | 0:79edd8d5fabd | 91 | IPS01A1_PIN_MULTISENSE, |
grussian | 0:79edd8d5fabd | 92 | IPS01A1_PIN_V_GND, |
grussian | 0:79edd8d5fabd | 93 | V_REF, |
grussian | 0:79edd8d5fabd | 94 | R_SENSE, |
grussian | 0:79edd8d5fabd | 95 | R_D1, |
grussian | 0:79edd8d5fabd | 96 | R_D2); |
grussian | 0:79edd8d5fabd | 97 | |
grussian | 0:79edd8d5fabd | 98 | |
grussian | 0:79edd8d5fabd | 99 | |
grussian | 0:79edd8d5fabd | 100 | static Ticker ticker; |
grussian | 0:79edd8d5fabd | 101 | DigitalOut UserLed(LED1); |
grussian | 0:79edd8d5fabd | 102 | |
grussian | 0:79edd8d5fabd | 103 | /*** Main function ------------------------------------------------------------- ***/ |
grussian | 0:79edd8d5fabd | 104 | /* Generic main function/loop, interrupt based cyclic execution |
grussian | 0:79edd8d5fabd | 105 | */ |
grussian | 0:79edd8d5fabd | 106 | |
grussian | 0:79edd8d5fabd | 107 | float Multisense_Signal = 0; // Multisense pin - signal level |
grussian | 0:79edd8d5fabd | 108 | float V_GND_Signal = 0; // GND pin - signal level |
grussian | 0:79edd8d5fabd | 109 | float Temp_Signal = 0; // Device temperature (info from Device) |
grussian | 0:79edd8d5fabd | 110 | float Vcc_Level = 0; // Vcc signal level (info from device) |
grussian | 0:79edd8d5fabd | 111 | bool ButtonPressed = 0; // User Button |
grussian | 0:79edd8d5fabd | 112 | int TestSequence = 0; // Test sequence counter |
grussian | 0:79edd8d5fabd | 113 | |
grussian | 0:79edd8d5fabd | 114 | //------------------------------------ |
grussian | 0:79edd8d5fabd | 115 | // Hyperterminal configuration |
grussian | 0:79edd8d5fabd | 116 | // 9600 bauds, 8-bit data, no parity |
grussian | 0:79edd8d5fabd | 117 | //------------------------------------ |
grussian | 0:79edd8d5fabd | 118 | |
grussian | 0:79edd8d5fabd | 119 | InterruptIn UserButton(USER_BUTTON); // B1 is the User Button |
grussian | 0:79edd8d5fabd | 120 | void B1_pressed (void); |
grussian | 0:79edd8d5fabd | 121 | void LedBlink (int TestSequence); |
grussian | 0:79edd8d5fabd | 122 | void Write_Serial (void); |
grussian | 0:79edd8d5fabd | 123 | |
grussian | 0:79edd8d5fabd | 124 | |
grussian | 0:79edd8d5fabd | 125 | int main(void){ |
grussian | 0:79edd8d5fabd | 126 | UserButton.fall(&B1_pressed); //interrupt User Button |
grussian | 0:79edd8d5fabd | 127 | printf("Start test Procedure \n\n\n"); |
grussian | 0:79edd8d5fabd | 128 | |
grussian | 0:79edd8d5fabd | 129 | while (true) { |
grussian | 0:79edd8d5fabd | 130 | // wait for User button is pressed |
grussian | 0:79edd8d5fabd | 131 | while (!ButtonPressed) { |
grussian | 0:79edd8d5fabd | 132 | } |
grussian | 0:79edd8d5fabd | 133 | |
grussian | 0:79edd8d5fabd | 134 | ButtonPressed = 0; |
grussian | 0:79edd8d5fabd | 135 | |
grussian | 0:79edd8d5fabd | 136 | LedBlink(TestSequence); |
grussian | 0:79edd8d5fabd | 137 | |
grussian | 0:79edd8d5fabd | 138 | switch (TestSequence) { |
grussian | 0:79edd8d5fabd | 139 | case (1): { |
grussian | 0:79edd8d5fabd | 140 | printf("Test 1: StandBy\n\r"); |
grussian | 0:79edd8d5fabd | 141 | ips_expansion_board.vps220h1.In_0= 0; |
grussian | 0:79edd8d5fabd | 142 | ips_expansion_board.vps220h1.In_1 = 0; |
grussian | 0:79edd8d5fabd | 143 | ips_expansion_board.vps220h1.Sel_0 =0; |
grussian | 0:79edd8d5fabd | 144 | ips_expansion_board.vps220h1.Sel_1 =0; |
grussian | 0:79edd8d5fabd | 145 | ips_expansion_board.vps220h1.S_En = 0; |
grussian | 0:79edd8d5fabd | 146 | ips_expansion_board.vps220h1.FaultRST = 0; |
grussian | 0:79edd8d5fabd | 147 | wait (0.1); |
grussian | 0:79edd8d5fabd | 148 | Multisense_Signal= ips_expansion_board.GetCurrent(0); |
grussian | 0:79edd8d5fabd | 149 | Write_Serial(); |
grussian | 0:79edd8d5fabd | 150 | printf("Current Ch1 (stand by)= %2.3fA \n\n\r", Multisense_Signal); |
grussian | 0:79edd8d5fabd | 151 | } |
grussian | 0:79edd8d5fabd | 152 | break; |
grussian | 0:79edd8d5fabd | 153 | case(2):{ |
grussian | 0:79edd8d5fabd | 154 | printf("Test 2: Temperature\n\r"); |
grussian | 0:79edd8d5fabd | 155 | ips_expansion_board.vps220h1.In_0= 0; |
grussian | 0:79edd8d5fabd | 156 | ips_expansion_board.vps220h1.In_1 = 0; |
grussian | 0:79edd8d5fabd | 157 | ips_expansion_board.vps220h1.Sel_0 =0; |
grussian | 0:79edd8d5fabd | 158 | ips_expansion_board.vps220h1.Sel_1 =1; |
grussian | 0:79edd8d5fabd | 159 | ips_expansion_board.vps220h1.S_En = 1; |
grussian | 0:79edd8d5fabd | 160 | ips_expansion_board.vps220h1.FaultRST = 0; |
grussian | 0:79edd8d5fabd | 161 | wait (0.1); |
grussian | 0:79edd8d5fabd | 162 | |
grussian | 0:79edd8d5fabd | 163 | Temp_Signal= ips_expansion_board.GetTemperature(); |
grussian | 0:79edd8d5fabd | 164 | Write_Serial(); |
grussian | 0:79edd8d5fabd | 165 | printf("Temperature (equiv)= %2.3fC \n\n\r", Temp_Signal); |
grussian | 0:79edd8d5fabd | 166 | |
grussian | 0:79edd8d5fabd | 167 | } |
grussian | 0:79edd8d5fabd | 168 | break; |
grussian | 0:79edd8d5fabd | 169 | case(3):{ |
grussian | 0:79edd8d5fabd | 170 | printf("Test 3: Vcc Level\n\r"); |
grussian | 0:79edd8d5fabd | 171 | ips_expansion_board.vps220h1.In_0= 0; |
grussian | 0:79edd8d5fabd | 172 | ips_expansion_board.vps220h1.In_1 = 0; |
grussian | 0:79edd8d5fabd | 173 | ips_expansion_board.vps220h1.Sel_0 =1; |
grussian | 0:79edd8d5fabd | 174 | ips_expansion_board.vps220h1.Sel_1 =1; |
grussian | 0:79edd8d5fabd | 175 | ips_expansion_board.vps220h1.S_En = 1; |
grussian | 0:79edd8d5fabd | 176 | ips_expansion_board.vps220h1.FaultRST = 0; |
grussian | 0:79edd8d5fabd | 177 | wait (0.1); |
grussian | 0:79edd8d5fabd | 178 | Vcc_Level= ips_expansion_board.GetVcc(); |
grussian | 0:79edd8d5fabd | 179 | Write_Serial(); |
grussian | 0:79edd8d5fabd | 180 | printf("Vcc= %2.3fV \n\n\r", Vcc_Level); |
grussian | 0:79edd8d5fabd | 181 | } |
grussian | 0:79edd8d5fabd | 182 | break; |
grussian | 0:79edd8d5fabd | 183 | case(4):{ |
grussian | 0:79edd8d5fabd | 184 | printf("Test 4: Ch1=ON, CH2=OFF\n\r"); |
grussian | 0:79edd8d5fabd | 185 | ips_expansion_board.vps220h1.In_0= 1; |
grussian | 0:79edd8d5fabd | 186 | ips_expansion_board.vps220h1.In_1 = 0; |
grussian | 0:79edd8d5fabd | 187 | ips_expansion_board.vps220h1.Sel_0 =0; |
grussian | 0:79edd8d5fabd | 188 | ips_expansion_board.vps220h1.Sel_1 =0; |
grussian | 0:79edd8d5fabd | 189 | ips_expansion_board.vps220h1.S_En = 1; |
grussian | 0:79edd8d5fabd | 190 | ips_expansion_board.vps220h1.FaultRST = 0; |
grussian | 0:79edd8d5fabd | 191 | wait (0.1); |
grussian | 0:79edd8d5fabd | 192 | Write_Serial(); |
grussian | 0:79edd8d5fabd | 193 | printf("Current Ch1= %2.3fA \n\n\r",ips_expansion_board.GetCurrent(1) ); |
grussian | 0:79edd8d5fabd | 194 | wait (.5); |
grussian | 0:79edd8d5fabd | 195 | ips_expansion_board.vps220h1.In_0= 0; |
grussian | 0:79edd8d5fabd | 196 | ips_expansion_board.vps220h1.In_1 = 0; |
grussian | 0:79edd8d5fabd | 197 | } |
grussian | 0:79edd8d5fabd | 198 | break; |
grussian | 0:79edd8d5fabd | 199 | case(5):{ |
grussian | 0:79edd8d5fabd | 200 | printf("Test 5: Ch1=OFF, CH2=ON\n\r"); |
grussian | 0:79edd8d5fabd | 201 | ips_expansion_board.vps220h1.In_0= 0; |
grussian | 0:79edd8d5fabd | 202 | ips_expansion_board.vps220h1.In_1 = 1; |
grussian | 0:79edd8d5fabd | 203 | ips_expansion_board.vps220h1.Sel_0 =1; |
grussian | 0:79edd8d5fabd | 204 | ips_expansion_board.vps220h1.Sel_1 =0; |
grussian | 0:79edd8d5fabd | 205 | ips_expansion_board.vps220h1.S_En = 1; |
grussian | 0:79edd8d5fabd | 206 | ips_expansion_board.vps220h1.FaultRST = 0; |
grussian | 0:79edd8d5fabd | 207 | wait (0.1); |
grussian | 0:79edd8d5fabd | 208 | Write_Serial(); |
grussian | 0:79edd8d5fabd | 209 | printf("Current Ch1= %2.3fA \n\n\r",ips_expansion_board.GetCurrent(0)); |
grussian | 0:79edd8d5fabd | 210 | wait (.5); |
grussian | 0:79edd8d5fabd | 211 | ips_expansion_board.vps220h1.In_0= 0; |
grussian | 0:79edd8d5fabd | 212 | ips_expansion_board.vps220h1.In_1 = 0; |
grussian | 0:79edd8d5fabd | 213 | } |
grussian | 0:79edd8d5fabd | 214 | break; |
grussian | 0:79edd8d5fabd | 215 | case(6):{ |
grussian | 0:79edd8d5fabd | 216 | printf("Test 6: Ch1=ON, CH2=ON -- Current Ch1\n\r"); |
grussian | 0:79edd8d5fabd | 217 | ips_expansion_board.vps220h1.In_0= 1; |
grussian | 0:79edd8d5fabd | 218 | ips_expansion_board.vps220h1.In_1 = 1; |
grussian | 0:79edd8d5fabd | 219 | ips_expansion_board.vps220h1.Sel_0 =0; |
grussian | 0:79edd8d5fabd | 220 | ips_expansion_board.vps220h1.Sel_1 =0; |
grussian | 0:79edd8d5fabd | 221 | ips_expansion_board.vps220h1.S_En = 1; |
grussian | 0:79edd8d5fabd | 222 | ips_expansion_board.vps220h1.FaultRST = 0; |
grussian | 0:79edd8d5fabd | 223 | wait (0.1); |
grussian | 0:79edd8d5fabd | 224 | Write_Serial(); |
grussian | 0:79edd8d5fabd | 225 | printf("Current Ch1= %2.3fA \n\n\r", ips_expansion_board.GetCurrent(0) ); |
grussian | 0:79edd8d5fabd | 226 | wait (.5); |
grussian | 0:79edd8d5fabd | 227 | ips_expansion_board.vps220h1.In_0= 0; |
grussian | 0:79edd8d5fabd | 228 | ips_expansion_board.vps220h1.In_1 = 0; |
grussian | 0:79edd8d5fabd | 229 | |
grussian | 0:79edd8d5fabd | 230 | } |
grussian | 0:79edd8d5fabd | 231 | break; |
grussian | 0:79edd8d5fabd | 232 | case(7):{ |
grussian | 0:79edd8d5fabd | 233 | printf("Test 7: Ch1=ON, CH2=ON -- Current Ch2\n\r"); |
grussian | 0:79edd8d5fabd | 234 | ips_expansion_board.vps220h1.In_0= 1; |
grussian | 0:79edd8d5fabd | 235 | ips_expansion_board.vps220h1.In_1 = 1; |
grussian | 0:79edd8d5fabd | 236 | ips_expansion_board.vps220h1.Sel_0 =1; |
grussian | 0:79edd8d5fabd | 237 | ips_expansion_board.vps220h1.Sel_1 =0; |
grussian | 0:79edd8d5fabd | 238 | ips_expansion_board.vps220h1.S_En = 1; |
grussian | 0:79edd8d5fabd | 239 | ips_expansion_board.vps220h1.FaultRST = 0; |
grussian | 0:79edd8d5fabd | 240 | wait (0.1); |
grussian | 0:79edd8d5fabd | 241 | Write_Serial(); |
grussian | 0:79edd8d5fabd | 242 | printf("Current Ch2= %2.3fA \n\n\r", ips_expansion_board.GetCurrent(1)); |
grussian | 0:79edd8d5fabd | 243 | wait (.5); |
grussian | 0:79edd8d5fabd | 244 | ips_expansion_board.vps220h1.In_0= 0; |
grussian | 0:79edd8d5fabd | 245 | ips_expansion_board.vps220h1.In_1 = 0; |
grussian | 0:79edd8d5fabd | 246 | |
grussian | 0:79edd8d5fabd | 247 | } |
grussian | 0:79edd8d5fabd | 248 | break; |
grussian | 0:79edd8d5fabd | 249 | default: { |
grussian | 0:79edd8d5fabd | 250 | printf("End Test Procedure\n\n\n\r"); |
grussian | 0:79edd8d5fabd | 251 | TestSequence = 0; |
grussian | 0:79edd8d5fabd | 252 | ips_expansion_board.vps220h1.In_0= 0; |
grussian | 0:79edd8d5fabd | 253 | ips_expansion_board.vps220h1.In_1 = 0; |
grussian | 0:79edd8d5fabd | 254 | ips_expansion_board.vps220h1.Sel_0 =0; |
grussian | 0:79edd8d5fabd | 255 | ips_expansion_board.vps220h1.Sel_1 =0; |
grussian | 0:79edd8d5fabd | 256 | ips_expansion_board.vps220h1.S_En = 0; |
grussian | 0:79edd8d5fabd | 257 | ips_expansion_board.vps220h1.FaultRST = 0; |
grussian | 0:79edd8d5fabd | 258 | } |
grussian | 0:79edd8d5fabd | 259 | break; |
grussian | 0:79edd8d5fabd | 260 | } |
grussian | 0:79edd8d5fabd | 261 | } |
grussian | 0:79edd8d5fabd | 262 | |
grussian | 0:79edd8d5fabd | 263 | } |
grussian | 0:79edd8d5fabd | 264 | |
grussian | 0:79edd8d5fabd | 265 | |
grussian | 0:79edd8d5fabd | 266 | void B1_pressed (){ |
grussian | 0:79edd8d5fabd | 267 | // Interrupt procedure - User button is pressed |
grussian | 0:79edd8d5fabd | 268 | TestSequence ++; |
grussian | 0:79edd8d5fabd | 269 | |
grussian | 0:79edd8d5fabd | 270 | UserLed = 1; // LED is ON |
grussian | 0:79edd8d5fabd | 271 | wait(0.05); // 50 ms |
grussian | 0:79edd8d5fabd | 272 | UserLed = 0; // LED is OFF |
grussian | 0:79edd8d5fabd | 273 | |
grussian | 0:79edd8d5fabd | 274 | ButtonPressed = 1; |
grussian | 0:79edd8d5fabd | 275 | |
grussian | 0:79edd8d5fabd | 276 | } |
grussian | 0:79edd8d5fabd | 277 | void LedBlink (int TestSequence){ |
grussian | 0:79edd8d5fabd | 278 | // Option feedback by usingUser LED |
grussian | 0:79edd8d5fabd | 279 | for (int TestCounter =0; TestCounter<TestSequence; TestCounter++) { |
grussian | 0:79edd8d5fabd | 280 | UserLed = 1; // LED is ON |
grussian | 0:79edd8d5fabd | 281 | wait(0.05); // 50 ms |
grussian | 0:79edd8d5fabd | 282 | UserLed = 0; // LED is OFF |
grussian | 0:79edd8d5fabd | 283 | wait(0.05); // 50 msec |
grussian | 0:79edd8d5fabd | 284 | } |
grussian | 0:79edd8d5fabd | 285 | wait(1-(TestSequence*2*0.05)); |
grussian | 0:79edd8d5fabd | 286 | } |
grussian | 0:79edd8d5fabd | 287 | |
grussian | 0:79edd8d5fabd | 288 | void Write_Serial (){ |
grussian | 0:79edd8d5fabd | 289 | // This code send messages and data to the serial port |
grussian | 0:79edd8d5fabd | 290 | // send info to serial port |
grussian | 0:79edd8d5fabd | 291 | printf("Input 0= %d\t", ips_expansion_board.vps220h1.In_0.read()); |
grussian | 0:79edd8d5fabd | 292 | printf("Input 1= %d\t", ips_expansion_board.vps220h1.In_1.read()); |
grussian | 0:79edd8d5fabd | 293 | printf("SEL 0= %d\t", ips_expansion_board.vps220h1.Sel_0.read()); |
grussian | 0:79edd8d5fabd | 294 | printf("SEL 1= %d\t", ips_expansion_board.vps220h1.Sel_1.read()); |
grussian | 0:79edd8d5fabd | 295 | printf("SEL_EN= %d\t", ips_expansion_board.vps220h1.S_En.read()); |
grussian | 0:79edd8d5fabd | 296 | printf("FaultRST= %d\t", ips_expansion_board.vps220h1.FaultRST.read()); |
grussian | 0:79edd8d5fabd | 297 | } |
grussian | 0:79edd8d5fabd | 298 | |
grussian | 0:79edd8d5fabd | 299 | |
grussian | 0:79edd8d5fabd | 300 |