Simple test application for X-NUCLEO-IKA01A1 expansion board.
Dependencies: X_NUCLEO_IKA01A1 mbed
Fork of HelloWorld_IKA01A1 by
Simple test application for X-NUCLEO-IKA01A1 expansion board.
Platform compatibility issues
- NUCLEO-F302R8: use pin D5 for LED Driver configuration
- LPCXpresso11U68: use pin D3 as PWM for LED Driver configuration. Use a free Dx pin as Signal2 for Windows Comparator configuration.
main.cpp@15:edec8fd4f69c, 2016-04-12 (annotated)
- Committer:
- hemddabral
- Date:
- Tue Apr 12 07:44:10 2016 +0000
- Revision:
- 15:edec8fd4f69c
- Parent:
- 14:182526e41810
- Child:
- 16:2159a3dc888e
final draft for release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hemddabral | 0:0f16e14940d0 | 1 | #include "mbed.h" |
hemddabral | 2:af24b3afa99d | 2 | #include "x_nucleo_ika01a1_class.h" |
hemddabral | 0:0f16e14940d0 | 3 | |
hemddabral | 3:5c45cb513aaf | 4 | Serial pc(USBTX, USBRX); |
hemddabral | 0:0f16e14940d0 | 5 | |
hemddabral | 14:182526e41810 | 6 | //Serial pc(SERIAL_TX, SERIAL_RX); |
hemddabral | 14:182526e41810 | 7 | |
hemddabral | 0:0f16e14940d0 | 8 | DigitalOut myled(LED1); |
hemddabral | 0:0f16e14940d0 | 9 | |
hemddabral | 4:6ed99ea3bf33 | 10 | int main() { |
hemddabral | 11:71be8ec1ce5c | 11 | X_NUCLEO_IKA01A1 *analog_expansion_board = X_NUCLEO_IKA01A1::Instance(X_NUCLEO_IKA01A1_PIN_PHOTO_SENSOR, |
hemddabral | 11:71be8ec1ce5c | 12 | X_NUCLEO_IKA01A1_PIN_WINDOWS_COMP_SIGNAL_1, |
hemddabral | 11:71be8ec1ce5c | 13 | X_NUCLEO_IKA01A1_PIN_WINDOWS_COMP_SIGNAL_2, |
hemddabral | 11:71be8ec1ce5c | 14 | X_NUCLEO_IKA01A1_PIN_PWM_LED_DRIVER_OUTPUT, |
hemddabral | 15:edec8fd4f69c | 15 | 5000); |
hemddabral | 2:af24b3afa99d | 16 | analog_expansion_board->Init(); |
hemddabral | 2:af24b3afa99d | 17 | TSZ124 *instrAmp = analog_expansion_board->tsz124; |
hemddabral | 4:6ed99ea3bf33 | 18 | TSU104 *photoSensor_windComp = analog_expansion_board->tsu104; |
hemddabral | 2:af24b3afa99d | 19 | |
hemddabral | 9:9b48d36016c3 | 20 | TSV734 *led_Driver = analog_expansion_board->tsv734; |
hemddabral | 13:179d5044bbc1 | 21 | double dutyCycle = 0; |
hemddabral | 9:9b48d36016c3 | 22 | |
hemddabral | 4:6ed99ea3bf33 | 23 | while(1) { |
hemddabral | 3:5c45cb513aaf | 24 | pc.printf("\nwhile loop\n"); |
hemddabral | 3:5c45cb513aaf | 25 | |
hemddabral | 4:6ed99ea3bf33 | 26 | unsigned int opAmpVoltage = instrAmp->GetVoltage(); |
hemddabral | 4:6ed99ea3bf33 | 27 | unsigned int opAmpCurrent = instrAmp->GetCurrent(); |
hemddabral | 7:41935875cb26 | 28 | // pass the analog pin name on which voltage is to be read (e.g. A3 on LPCxpresso lpc11u68) |
hemddabral | 10:62f55b54ebdf | 29 | unsigned int photoSensorVoltage = photoSensor_windComp->Get_PhotoSensor_GetVoltage(); |
hemddabral | 10:62f55b54ebdf | 30 | unsigned int windComPin1 = photoSensor_windComp->WindComp_Get_Signal1(); |
hemddabral | 10:62f55b54ebdf | 31 | unsigned int windComPin2 = photoSensor_windComp->WindComp_Get_Signal2(); |
hemddabral | 4:6ed99ea3bf33 | 32 | |
hemddabral | 3:5c45cb513aaf | 33 | pc.printf("\nopAmp measured voltage(mV): %u \n", opAmpVoltage); |
hemddabral | 3:5c45cb513aaf | 34 | pc.printf("\nopAmp measured Current(mA): %u \n", opAmpCurrent); |
hemddabral | 3:5c45cb513aaf | 35 | pc.printf("\nphotodiode sensor output voltage(mV): %u \n", photoSensorVoltage); |
hemddabral | 10:62f55b54ebdf | 36 | pc.printf("\nWindows comparator: signal 1 value(pin D2): %u \n", windComPin1); |
hemddabral | 10:62f55b54ebdf | 37 | pc.printf("\nWindows comparator: signal 1 value(pin D4): %u \n", windComPin2); |
hemddabral | 15:edec8fd4f69c | 38 | |
hemddabral | 13:179d5044bbc1 | 39 | dutyCycle += 0.1; |
hemddabral | 13:179d5044bbc1 | 40 | if(dutyCycle>=1) |
hemddabral | 13:179d5044bbc1 | 41 | dutyCycle -= 1; |
hemddabral | 13:179d5044bbc1 | 42 | |
hemddabral | 13:179d5044bbc1 | 43 | pc.printf("\nLED Driver: duty cycle: %.2lf percent \n", led_Driver->SetDutyCycle(dutyCycle)); |
hemddabral | 13:179d5044bbc1 | 44 | |
hemddabral | 9:9b48d36016c3 | 45 | myled = !myled; |
hemddabral | 9:9b48d36016c3 | 46 | wait(1); |
hemddabral | 4:6ed99ea3bf33 | 47 | } |
hemddabral | 0:0f16e14940d0 | 48 | } |