read and push
Dependencies: X_NUCLEO_IKS01A1 MLX90614 d7a_1x wizzi-utils
Fork of D7A_1x_demo_sensors_OS5 by
Revision 16:ad7842fcd376, committed 2017-02-27
- Comitter:
- shawe
- Date:
- Mon Feb 27 08:46:36 2017 +0000
- Parent:
- 15:f8e5805c696c
- Commit message:
- Add config for small nucleo;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
sensors.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Feb 17 16:41:40 2017 +0000 +++ b/main.cpp Mon Feb 27 08:46:36 2017 +0000 @@ -27,7 +27,6 @@ // ----- DEBUG ----- // Several debugging options are available in wizzi-utils/dbg/dbg.h // An ASSERT is a fatal error. By default, this error will reboot the device. - #include "mbed.h" #include "rtos.h" #include "rtos_idle.h" @@ -40,28 +39,46 @@ #include "MLX90614.h" #include "DevI2C.h" +#if defined(TARGET_STM32L152RE) + #define D7A_PIN_TX (D10) + #define D7A_PIN_RX (D2) + #define D7A_PIN_RTS (D13) + #define D7A_PIN_CTS (D9) + #define D7A_PIN_RESET (A3) + #define DEBUG_LED (LED1) + #define DEBUG_BUTTON (USER_BUTTON) + #define SENSOR_I2C_SDA (D14) + #define SENSOR_I2C_SCL (D15) + #define VOLT_PIN (A0) + +#elif defined(TARGET_STM32L432KC) + // ----------------------------------------------- + // Hardware configuration for sh2050 + // ----------------------------------------------- + #define D7A_PIN_TX (D5) + #define D7A_PIN_RX (D4) + #define D7A_PIN_RTS (D11) + #define D7A_PIN_CTS (D10) + #define D7A_PIN_RESET (D12) + #define DEBUG_LED (D13) // LED1 + #define DEBUG_BUTTON (D9) + #define SENSOR_I2C_SDA (D0) + #define SENSOR_I2C_SCL (D1) + // TODO Check which pin to use on the small board for voltage stuff + #define VOLT_PIN (A0) + +#else + #error "Please choose or add the right platform." +#endif -#define D7A_PIN_TX (D10) -#define D7A_PIN_RX (D2) -#define D7A_PIN_RTS (D13) -#define D7A_PIN_CTS (D9) -#define D7A_PIN_RESET (A3) -#define DEBUG_LED (LED1) -#define DEBUG_BUTTON (USER_BUTTON) -#define SENSOR_I2C_SDA (D14) -#define SENSOR_I2C_SCL (D15) - +#define DGB_LED_BLINK_PERIOD (500) #define _TEM1_EN_ (1) #define _VOLTAGE_EN_ (1) -MLX90614 *temp_sensor1; - -// Enable DBG led blinking (ms) -#define DGB_LED_BLINK_PERIOD (500) - #if (_VOLTAGE_EN_ == 1) - AnalogIn volt_pin(A0); +AnalogIn volt_pin(VOLT_PIN); #endif +MLX90614 *mlxSensor; Semaphore button_user(0); Semaphore thread_ready(0); @@ -253,8 +270,8 @@ #if (_TEM1_EN_ == 0) return simul_sensor_value(buf, 1, 1100, 3900); #elif (_TEM1_EN_ == 1) - float ambient = temp_sensor1->ambientTemp(); - float object = temp_sensor1->objectTemp(); + float ambient = mlxSensor->ambientTemp(); + float object = mlxSensor->objectTemp(); PRINT("Got %f || %f\r\n", ambient, object); buf[0] = float2_to_int(object); buf[1] = float2_to_int(ambient); @@ -482,7 +499,7 @@ // Open I2C and initialise the sensors DevI2C ext_i2c(SENSOR_I2C_SDA, SENSOR_I2C_SCL); ext_i2c.frequency(100000); - temp_sensor1 = new MLX90614(&ext_i2c); + mlxSensor = new MLX90614(&ext_i2c); #endif osStatus status;
--- a/sensors.h Fri Feb 17 16:41:40 2017 +0000 +++ b/sensors.h Mon Feb 27 08:46:36 2017 +0000 @@ -3,7 +3,7 @@ #include "MLX90614.h" -extern MLX90614 *temp_sensor1; +extern MLX90614 *mlxSensor; #endif // _SENSORS_H_ \ No newline at end of file