mbed library for STMicroelectronics' X-NUCLEO-IKA01A1 expansion board.
Dependents: HelloWorld_IKA01A1
Fork of X_NUCLEO_IKA01A1 by
Library for STMicroelectronics' X-NUCLEO-IKA01A1 multifunctional expansion board based on operational amplifiers.
Revision 14:8277ca0ab13a, committed 2016-04-08
- Comitter:
- hemddabral
- Date:
- Fri Apr 08 05:30:21 2016 +0000
- Parent:
- 13:9cecc8d66cc1
- Child:
- 15:114514787e83
- Commit message:
- updated X_NUCLEO_IKA01A1 class
Changed in this revision
--- a/Components/Interfaces/Windcomp_class.h Thu Apr 07 07:51:13 2016 +0000 +++ b/Components/Interfaces/Windcomp_class.h Fri Apr 08 05:30:21 2016 +0000 @@ -80,7 +80,7 @@ *------------------------------------------------------------------------*/ virtual unsigned int TSU104_WindComp_Get_D2(void) = 0; virtual unsigned int TSU104_WindComp_Get_D4(void) = 0; - virtual unsigned int TSU104_PhotoSensor_GetVoltage(PinName pin) = 0; + virtual unsigned int TSU104_PhotoSensor_GetVoltage(void) = 0; }; #endif /* __WINDCOMP_CLASS_H */
--- a/Components/tsu104/tsu104_class.h Thu Apr 07 07:51:13 2016 +0000
+++ b/Components/tsu104/tsu104_class.h Fri Apr 08 05:30:21 2016 +0000
@@ -90,16 +90,11 @@
/**
* @brief Constructor.
*/
- TSU104(void) : Windcomp()
+ TSU104(PinName photoSensorPin, PinName windCmpSignalPin_1,PinName windCmpSignalPin_2) : Windcomp()
{
- /* ACTION 4 ----------------------------------------------------------*
- * Initialize here the component's member variables, one variable per *
- * line. *
- * *
- * Example: *
- * measure = 0; *
- * instance_id = number_of_instances++; *
- *--------------------------------------------------------------------*/
+ photo_sensor_pin = photoSensorPin;
+ windCmp_signal_pin_1 = windCmpSignalPin_1;
+ windCmp_signal_pin_2 = windCmpSignalPin_2;
}
/**
@@ -134,7 +129,7 @@
*/
virtual unsigned int TSU104_WindComp_Get_D2(void)
{
- DigitalIn windowsCompD2(D2);
+ DigitalIn windowsCompD2(windCmp_signal_pin_1);
return windowsCompD2.read();
}
@@ -144,7 +139,7 @@
*/
virtual unsigned int TSU104_WindComp_Get_D4(void)
{
- DigitalIn windowsCompD4(D4);
+ DigitalIn windowsCompD4(windCmp_signal_pin_2);
return windowsCompD4.read();
}
@@ -154,9 +149,9 @@
* @param pin AnalogIn pin to use for detecting the voltage
* @retval voltage detected by photo sensor
*/
- virtual unsigned int TSU104_PhotoSensor_GetVoltage(PinName pin)
+ virtual unsigned int TSU104_PhotoSensor_GetVoltage(void)
{
- AnalogIn photoSensor(pin);
+ AnalogIn photoSensor(photo_sensor_pin);
double voltage = photoSensor.read();
voltage = voltage*3.3*1000.0; // voltage in mV
return voltage;
@@ -200,6 +195,21 @@
/*** Protected Component Related Methods ***/
+ /**
+ * arduino pin for photosensor output voltage
+ */
+ PinName photo_sensor_pin;
+
+ /**
+ * arduino pin for signal 1 of windows comparator configuration
+ */
+ PinName windCmp_signal_pin_1;
+
+ /**
+ * arduino pin for signal 1 of windows comparator configuration
+ */
+ PinName windCmp_signal_pin_2;
+
/* ACTION 7 --------------------------------------------------------------*
* Declare here the component's specific methods. *
* They should be: *
--- a/Components/tsv734/tsv734_class.h Thu Apr 07 07:51:13 2016 +0000
+++ b/Components/tsv734/tsv734_class.h Fri Apr 08 05:30:21 2016 +0000
@@ -88,16 +88,9 @@
/**
* @brief Constructor.
*/
- TSV734(void) : Led_driver()
+ TSV734(PinName ledDriverPin) : Led_driver()
{
- /* ACTION 4 ----------------------------------------------------------*
- * Initialize here the component's member variables, one variable per *
- * line. *
- * *
- * Example: *
- * measure = 0; *
- * instance_id = number_of_instances++; *
- *--------------------------------------------------------------------*/
+ led_driver_pin = ledDriverPin;
}
/**
@@ -132,11 +125,10 @@
* @param Configure the TSV734 operational amplifier in LED driver configuration
* @retval 0
*/
- virtual int Configure(PinName pinName, unsigned int period_us)
- {
- pwmPinName = pinName;
- PwmOut ledOut(pwmPinName);
+ virtual int Configure(unsigned int period_us)
+ {
period = period_us;
+ PwmOut ledOut(led_driver_pin);
ledOut.period_ms(period);
return 0;
}
@@ -148,7 +140,7 @@
*/
virtual int SetDutyCycle(float dc)
{
- PwmOut ledOut(pwmPinName);
+ PwmOut ledOut(led_driver_pin);
ledOut.pulsewidth_us((period*dc)/100);
return (int) dc;
}
@@ -214,7 +206,8 @@
Status_t TSV734_ConfigIT(void* a);
Status_t TSV734_SetDutyCycle(float dutyCycle);
unsigned int period;
- PinName pwmPinName;
+ PinName led_driver_pin;
+
/*** Component's I/O Methods ***/
--- a/x_nucleo_ika01a1_class.cpp Thu Apr 07 07:51:13 2016 +0000
+++ b/x_nucleo_ika01a1_class.cpp Fri Apr 08 05:30:21 2016 +0000
@@ -62,7 +62,9 @@
/**
* @brief Constructor.
*/
-X_NUCLEO_IKA01A1::X_NUCLEO_IKA01A1(void)
+X_NUCLEO_IKA01A1::X_NUCLEO_IKA01A1(PinName photoSensorPin, PinName windCmpSignalPin_1,PinName windCmpSignalPin_2,
+ PinName ledDriverPin)
+
{
/* Instantiating the components. */
/* ACTION 3 --------------------------------------------------------------*
@@ -73,20 +75,21 @@
* component_2 = new COMPONENT_2(); *
*------------------------------------------------------------------------*/
tsz124 = new TSZ124();
- tsu104 = new TSU104();
- tsv734 = new TSV734();
+ tsu104 = new TSU104(photoSensorPin, windCmpSignalPin_1, windCmpSignalPin_2);
+ tsv734 = new TSV734(ledDriverPin);
}
/**
* @brief Getting a singleton instance of X_NUCLEO_IKA01A1 class.
* @retval a singleton instance of X_NUCLEO_IKA01A1 class.
*/
-X_NUCLEO_IKA01A1 *X_NUCLEO_IKA01A1::Instance(void)
+X_NUCLEO_IKA01A1 *X_NUCLEO_IKA01A1::Instance(PinName photoSensorPin, PinName windCmpSignalPin_1,PinName windCmpSignalPin_2,
+ PinName ledDriverPin)
{
if (_instance == NULL)
{
/* Instantiating the board. */
- _instance = new X_NUCLEO_IKA01A1();
+ _instance = new X_NUCLEO_IKA01A1(photoSensorPin, windCmpSignalPin_1, windCmpSignalPin_2, ledDriverPin);
/* Initializing the components. */
if (!_instance->Init())
--- a/x_nucleo_ika01a1_class.h Thu Apr 07 07:51:13 2016 +0000 +++ b/x_nucleo_ika01a1_class.h Fri Apr 08 05:30:21 2016 +0000 @@ -94,7 +94,8 @@ * @brief Getting a singleton instance of X_NUCLEO_IKA01A1 class. * @retval a singleton instance of X_NUCLEO_IKA01A1 class. */ - static X_NUCLEO_IKA01A1 *Instance(void); + static X_NUCLEO_IKA01A1 *Instance(PinName photoSensorPin, PinName windCmpSignalPin_1,PinName windCmpSignalPin_2, + PinName ledDriverPin); /** * @brief Initialize the singleton's operational amplifiers to default settings @@ -132,7 +133,8 @@ /** * @brief Constructor. */ - X_NUCLEO_IKA01A1(void); + X_NUCLEO_IKA01A1(PinName photoSensorPin, PinName windCmpSignalPin_1,PinName windCmpSignalPin_2, + PinName ledDriverPin); /*** Protected Expansion Board Related Initialization Methods ***/

X-NUCLEO-IKA01A1 Multifunctional board based on operational amplifiers.