Evironmental Shield API
Diff: Envt_Shield_F4_API.cpp
- Revision:
- 1:d37d15b70bc5
- Parent:
- 0:9ac219c9a7df
--- a/Envt_Shield_F4_API.cpp Thu Aug 14 11:39:55 2014 +0000 +++ b/Envt_Shield_F4_API.cpp Tue Aug 19 07:00:40 2014 +0000 @@ -1,88 +1,191 @@ #include "nucleo-f401re.h" +#include "Envt_Shield_F4_API.h" +/*#include "x_nucleo_ike01x1_hum_temp.h" #include "x_nucleo_ike01x1_pressure.h" -#include "x_nucleo_ike01x1_uv.h" -#include "x_nucleo_ike01x1_hum_temp.h" -#include "Envt_Shield_F4_API.h" +#include "x_nucleo_ike01x1_uv.h"*/ + + +uint8_t Envt_Shield_API::Pressure_Init(void) +{ + uint8_t ret= BSP_PRESSURE_Init(); + return ret; +} + +uint8_t Envt_Shield_API::Pressure_isInitialized(void) +{ + uint8_t PressureInitialised=BSP_PRESSURE_isInitialized(); + return PressureInitialised; +} + +void Envt_Shield_API::Pressure_Reset(void) +{ + BSP_PRESSURE_Reset(); +} + +uint8_t Envt_Shield_API::Pressure_ReadID(void) +{ + uint8_t id = BSP_PRESSURE_ReadID(); + return id; +} + +void Envt_Shield_API::Pressure_ITConfig( + void/*PRESSURE_InterruptConfigTypeDef *pIntConfigStruct*/) +{ + BSP_PRESSURE_ITConfig(); +} + +void Envt_Shield_API::Pressure_EnableIT(uint8_t IntPin) +{ + BSP_PRESSURE_EnableIT(IntPin); +} + +void Envt_Shield_API::Pressure_DisableIT(uint8_t IntPin) +{ + BSP_PRESSURE_DisableIT(IntPin); +} -uint8_t PRESInit=0; -uint8_t UVInit=0; -uint8_t HumTempInit=0; -/*Global variables */ -uint8_t HumTempId=0; -uint8_t PressID=0; -int dec_precision = 2; - volatile float UVI_Value; - volatile float PRESSURE_Value; - volatile float HUMIDITY_Value; - volatile float TEMPERATURE_Value; -void floatToInt(float in, int32_t *out_int, int32_t *out_dec, int32_t dec_prec); -Serial pc(SERIAL_TX, SERIAL_RX); - -DigitalOut myled(LED1); +void Envt_Shield_API::Pressure_GetPressure(float* pfData) +{ + BSP_PRESSURE_GetPressure(pfData); +} + +void Envt_Shield_API::Pressure_GetTemperature(float* pfData) +{ + BSP_PRESSURE_GetTemperature(pfData); +} + + +uint8_t Envt_Shield_API::Hum_Temp_Init(void) +{ + uint8_t ret = BSP_HUM_TEMP_Init(); + return ret; +} + +uint8_t Envt_Shield_API::Hum_Temp_isInitialized(void) +{ + uint8_t HumpTempInitialised=BSP_HUM_TEMP_isInitialized(); + return HumpTempInitialised; +} -void Envt_Shield_API:: floatToInt(float in, int32_t *out_int, int32_t *out_dec, int32_t dec_prec) +void Envt_Shield_API::Hum_Temp_Reset(void) +{ + BSP_HUM_TEMP_Reset(); +} + +uint8_t Envt_Shield_API::Hum_Temp_ReadID(void) { - *out_int = (int32_t)in; - in = in - (float)(*out_int); - *out_dec = (int32_t)(in*dec_prec); + uint8_t id = BSP_HUM_TEMP_ReadID(); + return id; +} + +void Envt_Shield_API::Hum_Temp_ITConfig( + void/*HUM_TEMP_InterruptConfigTypeDef *pIntConfig*/) +{ + BSP_HUM_TEMP_ITConfig(); +} + +void Envt_Shield_API::Hum_Temp_EnableIT(uint8_t IntPin) +{ + BSP_HUM_TEMP_EnableIT(IntPin); +} + +void Envt_Shield_API::Hum_Temp_DisableIT(uint8_t IntPin) +{ + BSP_HUM_TEMP_DisableIT(IntPin); } -void Envt_Shield_API:: init() +void Envt_Shield_API::Hum_Temp_GetHumidity(float* pfData) +{ + BSP_HUM_TEMP_GetHumidity(pfData); +} + +void Envt_Shield_API::Hum_Temp_GetTemperature(float* pfData) +{ + BSP_HUM_TEMP_GetTemperature(pfData); +} + +void Envt_Shield_API::Hum_Temp_PowerOFF() +{ + BSP_HUM_TEMP_PowerOFF(); +} + +uint8_t Envt_Shield_API::UV_Init(void) +{ + uint8_t ret = BSP_UV_Init(); + return ret; +} + +uint8_t Envt_Shield_API::UV_isInitialized(void) +{ + uint8_t UvInitialized=BSP_UV_isInitialized(); + return UvInitialized; +} + +/** + * @brief Read ID of Uv component + * @param None + * @retval ID + */ +uint8_t Envt_Shield_API::UV_ReadID(void) { - int mul = 1; - for(int i = 0; i < dec_precision; i++) - mul = mul*10; - - if(!BSP_HUM_TEMP_isInitialized()) { - BSP_HUM_TEMP_Init(); //This also Inits I2C interface from here. - } - HumTempId = BSP_HUM_TEMP_ReadID(); - if(HumTempId==I_AM_HTS221){ - HumTempInit=1; - } - /*End Temp Sensor Init*/ - - /*Initialize the pressure sensors*/ - if(!BSP_PRESSURE_isInitialized()) { - BSP_PRESSURE_Init(); //This also Inits I2C interface from here. - PRESInit=1; - } - PressID = BSP_PRESSURE_ReadID(); - - int32_t d1, d2, d3, d4; - - pc.printf("Hello World !\n"); - while(1) { - wait(1); - - if(BSP_HUM_TEMP_isInitialized()) - { - BSP_HUM_TEMP_GetHumidity((float *)&HUMIDITY_Value); - BSP_HUM_TEMP_GetTemperature((float *)&TEMPERATURE_Value); - - floatToInt(HUMIDITY_Value, &d1, &d2, mul); - floatToInt(TEMPERATURE_Value, &d3, &d4, mul); - pc.printf("H: %d.%02d T: %d.%02d", d1, d2, d3, d4); - - } - - if(BSP_PRESSURE_isInitialized()) - { - BSP_PRESSURE_GetPressure((float *)&PRESSURE_Value); - floatToInt(PRESSURE_Value, &d1, &d2, mul); - pc.printf(" P: %d.%02d\n", d1, d2); - - } - - if(BSP_UV_isInitialized()) - { - BSP_UV_GetIndex((float *)&UVI_Value); - floatToInt(UVI_Value, &d1, &d2, mul); - pc.printf("UV: %d.%02d\n", d1, d2); - } - - pc.printf("Done"); - myled = !myled; - - } + uint8_t id = BSP_UV_ReadID(); + return id; +} + +/** + * @brief Reboot memory content of UV + * @param None + * @retval None + */ +void Envt_Shield_API::UV_Reset(void) +{ + BSP_UV_Reset(); +} + + +/** + * @brief Configure INT1 interrupt + * @param pIntConfig: pointer to a UVIS3_InterruptConfig_TypeDef + * structure that contains the configuration setting for the UVIS3 Interrupt. + * @retval None + */ +void Envt_Shield_API::UV_ITConfig(void/*UV_InterruptConfigTypeDef *pIntConfig*/) +{ + BSP_UV_ITConfig(); +} + +/** + * @brief Enable INT1 or INT2 interrupt + * @param IntPin: Interrupt pin + * This parameter can be: + * @arg UVIS3_INT1 + * @arg UVIS3_INT2 + * @retval None + */ +void Envt_Shield_API::UV_EnableIT(uint8_t IntPin) +{ + BSP_UV_EnableIT(IntPin); +} + +/** + * @brief Disable INT1 or INT2 interrupt + * @param IntPin: Interrupt pin + * This parameter can be: + * @arg UVIS3_INT1 + * @arg UVIS3_INT2 + * @retval None + */ +void Envt_Shield_API::UV_DisableIT(uint8_t IntPin) +{ + BSP_UV_DisableIT(IntPin); +} + +/** + * @brief Get Index UV + * @param pfData: pointer on floating data + * @retval None + */ +void Envt_Shield_API::UV_GetIndex(float* pfData) +{ + BSP_UV_GetIndex(pfData); } \ No newline at end of file