Fixed mbxxx platform
This commit is contained in:
parent
10f64c0ce8
commit
fcb09d5d30
107 changed files with 2018 additions and 2760 deletions
|
@ -1,3 +1,8 @@
|
|||
/**
|
||||
* \addtogroup mbxxx-platform
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
|
@ -55,32 +60,36 @@
|
|||
|
||||
#include "dev/temperature-sensor.h"
|
||||
|
||||
|
||||
#define SUPPLY_OFFSET 500
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
halGpioConfig(TEMPERATURE_SENSOR_GPIO,GPIOCFG_ANALOG);
|
||||
//halGpioConfig(TEMPERATURE_SENSOR_GPIO,GPIOCFG_ANALOG);
|
||||
halInternalInitAdc();
|
||||
halAdcSetRange(TRUE);
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
static int16u ADCvalue;
|
||||
static int16s volts;
|
||||
static uint16_t ADCvalue;
|
||||
static int16_t volts;
|
||||
uint16_t scale=1;
|
||||
|
||||
halStartAdcConversion(ADC_USER_APP, ADC_REF_INT, ADC_SOURCE(halGetADCChannelFromGPIO(TEMPERATURE_SENSOR_GPIO),ADC_MUX_VREF2), ADC_CONVERSION_TIME_US_4096);
|
||||
|
||||
halReadAdcBlocking(ADC_USER_APP, &ADCvalue); // This blocks for a while, about 4ms.
|
||||
|
||||
|
||||
|
||||
// 100 uVolts
|
||||
volts = halConvertValueToVolts(ADCvalue);
|
||||
|
||||
//return ((18641 - (int32s)volts)*100)/1171; // +- 0.23 degC in the range (-10;65) degC
|
||||
return ((18663 - (int32s)volts)*100)/1169; // +- 0.004 degC in the range (20;30) degC
|
||||
volts = boardDescription->temperatureSensor->div*halConvertValueToVolts(ADCvalue) + SUPPLY_OFFSET;
|
||||
|
||||
|
||||
//return ((18641 - (int32_t)volts)*100)/1171; // +- 0.23 degC in the range (-10;65) degC
|
||||
return ((18663 - (int32_t)volts)*100)/1169; // +- 0.004 degC in the range (20;30) degC
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
|
@ -93,7 +102,7 @@ configure(int type, int value)
|
|||
case SENSORS_ACTIVE:
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -111,3 +120,4 @@ status(int type)
|
|||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(temperature_sensor, TEMPERATURE_SENSOR,
|
||||
value, configure, status);
|
||||
/** @} */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue