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@13:179d5044bbc1, 2016-04-11 (annotated)
- Committer:
- hemddabral
- Date:
- Mon Apr 11 05:51:59 2016 +0000
- Revision:
- 13:179d5044bbc1
- Parent:
- 11:71be8ec1ce5c
- Child:
- 14:182526e41810
updated LED driver implementation and API
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 | 0:0f16e14940d0 | 6 | DigitalOut myled(LED1); |
hemddabral | 0:0f16e14940d0 | 7 | |
hemddabral | 4:6ed99ea3bf33 | 8 | int main() { |
hemddabral | 11:71be8ec1ce5c | 9 | X_NUCLEO_IKA01A1 *analog_expansion_board = X_NUCLEO_IKA01A1::Instance(X_NUCLEO_IKA01A1_PIN_PHOTO_SENSOR, |
hemddabral | 11:71be8ec1ce5c | 10 | X_NUCLEO_IKA01A1_PIN_WINDOWS_COMP_SIGNAL_1, |
hemddabral | 11:71be8ec1ce5c | 11 | X_NUCLEO_IKA01A1_PIN_WINDOWS_COMP_SIGNAL_2, |
hemddabral | 11:71be8ec1ce5c | 12 | X_NUCLEO_IKA01A1_PIN_PWM_LED_DRIVER_OUTPUT, |
hemddabral | 13:179d5044bbc1 | 13 | 5000); |
hemddabral | 2:af24b3afa99d | 14 | analog_expansion_board->Init(); |
hemddabral | 2:af24b3afa99d | 15 | TSZ124 *instrAmp = analog_expansion_board->tsz124; |
hemddabral | 4:6ed99ea3bf33 | 16 | TSU104 *photoSensor_windComp = analog_expansion_board->tsu104; |
hemddabral | 2:af24b3afa99d | 17 | |
hemddabral | 9:9b48d36016c3 | 18 | TSV734 *led_Driver = analog_expansion_board->tsv734; |
hemddabral | 13:179d5044bbc1 | 19 | double dutyCycle = 0; |
hemddabral | 9:9b48d36016c3 | 20 | |
hemddabral | 4:6ed99ea3bf33 | 21 | while(1) { |
hemddabral | 3:5c45cb513aaf | 22 | pc.printf("\nwhile loop\n"); |
hemddabral | 3:5c45cb513aaf | 23 | |
hemddabral | 4:6ed99ea3bf33 | 24 | unsigned int opAmpVoltage = instrAmp->GetVoltage(); |
hemddabral | 4:6ed99ea3bf33 | 25 | unsigned int opAmpCurrent = instrAmp->GetCurrent(); |
hemddabral | 7:41935875cb26 | 26 | // pass the analog pin name on which voltage is to be read (e.g. A3 on LPCxpresso lpc11u68) |
hemddabral | 10:62f55b54ebdf | 27 | unsigned int photoSensorVoltage = photoSensor_windComp->Get_PhotoSensor_GetVoltage(); |
hemddabral | 10:62f55b54ebdf | 28 | unsigned int windComPin1 = photoSensor_windComp->WindComp_Get_Signal1(); |
hemddabral | 10:62f55b54ebdf | 29 | unsigned int windComPin2 = photoSensor_windComp->WindComp_Get_Signal2(); |
hemddabral | 4:6ed99ea3bf33 | 30 | |
hemddabral | 3:5c45cb513aaf | 31 | pc.printf("\nopAmp measured voltage(mV): %u \n", opAmpVoltage); |
hemddabral | 3:5c45cb513aaf | 32 | pc.printf("\nopAmp measured Current(mA): %u \n", opAmpCurrent); |
hemddabral | 3:5c45cb513aaf | 33 | pc.printf("\nphotodiode sensor output voltage(mV): %u \n", photoSensorVoltage); |
hemddabral | 10:62f55b54ebdf | 34 | pc.printf("\nWindows comparator: signal 1 value(pin D2): %u \n", windComPin1); |
hemddabral | 10:62f55b54ebdf | 35 | pc.printf("\nWindows comparator: signal 1 value(pin D4): %u \n", windComPin2); |
hemddabral | 9:9b48d36016c3 | 36 | |
hemddabral | 13:179d5044bbc1 | 37 | dutyCycle += 0.1; |
hemddabral | 13:179d5044bbc1 | 38 | if(dutyCycle>=1) |
hemddabral | 13:179d5044bbc1 | 39 | dutyCycle -= 1; |
hemddabral | 13:179d5044bbc1 | 40 | |
hemddabral | 13:179d5044bbc1 | 41 | pc.printf("\nLED Driver: duty cycle: %.2lf percent \n", led_Driver->SetDutyCycle(dutyCycle)); |
hemddabral | 13:179d5044bbc1 | 42 | |
hemddabral | 9:9b48d36016c3 | 43 | myled = !myled; |
hemddabral | 9:9b48d36016c3 | 44 | wait(1); |
hemddabral | 4:6ed99ea3bf33 | 45 | } |
hemddabral | 0:0f16e14940d0 | 46 | } |