Simple test application for X-NUCLEO-IKA01A1 expansion board.

Dependencies:   X_NUCLEO_IKA01A1 mbed

Fork of HelloWorld_IKA01A1 by ST Expansion SW Team

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.
Committer:
hemddabral
Date:
Fri Apr 08 09:00:16 2016 +0000
Revision:
11:71be8ec1ce5c
Parent:
10:62f55b54ebdf
Child:
13:179d5044bbc1
updated main program to use macros from config.h file

Who changed what in which revision?

UserRevisionLine numberNew 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 11:71be8ec1ce5c 13 50);
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 10:62f55b54ebdf 19 double dutyCycle_us = 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 10:62f55b54ebdf 37 dutyCycle_us += 0.1;
hemddabral 9:9b48d36016c3 38 pc.printf("\nLED Driver: duty cycle: %u percent \n", led_Driver->SetDutyCycle(dutyCycle_us));
hemddabral 9:9b48d36016c3 39
hemddabral 10:62f55b54ebdf 40 if(dutyCycle_us>=1)
hemddabral 10:62f55b54ebdf 41 dutyCycle_us -= 1;
hemddabral 9:9b48d36016c3 42
hemddabral 9:9b48d36016c3 43 myled = !myled;
hemddabral 9:9b48d36016c3 44 wait(1);
hemddabral 3:5c45cb513aaf 45
hemddabral 0:0f16e14940d0 46 myled = !myled;
hemddabral 0:0f16e14940d0 47 wait(1);
hemddabral 4:6ed99ea3bf33 48 }
hemddabral 0:0f16e14940d0 49 }