BigW Consortium Gitlab

Commit 76fa5795 by David Frey

remove mcp9700aTemperatureSensor app

Remove the mcp9700aTemperatureSensor app because it was decided that this device would not be integrated into the mangOH Yellow.
parent 8448209b
sources:
{
mcp9700aOnWp.c
}
cflags:
{
-std=c99
}
requires:
{
api:
{
modemServices/le_adc.api
}
component:
{
${CURDIR}/../Mcp970xComponent
}
}
provides:
{
api:
{
mangOH_ambientTemperature.api
}
}
\ No newline at end of file
#include "legato.h"
#include "interfaces.h"
#include "mcp970x.h"
static int WpAdcFunction(int32_t *valueUv)
{
int32_t valueMv;
le_result_t res = le_adc_ReadValue("EXT_ADC0", &valueMv);
if (res == LE_OK)
{
*valueUv = valueMv * 1000;
}
LE_DEBUG("Read %d uV from the ADC during ambient temperature measurement", *valueUv);
return res;
}
le_result_t mangOH_ambientTemperature_Read(double *temperature)
{
int32_t tempInt;
int res = mcp970x_read_temperature(MCP970X_CHIP_9700A, WpAdcFunction, &tempInt);
if (res != 0)
{
return LE_FAULT;
}
*temperature = tempInt / 1000.0;
LE_DEBUG("Read ambient temperature %f C", *temperature);
return LE_OK;
}
COMPONENT_INIT
{
}
sources:
{
component.c
mcp970x/mcp970x.c
}
cflags:
{
-std=c99
-fvisibility=default
}
provides:
{
headerDir:
{
${CURDIR}/mcp970x
}
}
\ No newline at end of file
#include "legato.h"
// Requird to make this code a Legato component
COMPONENT_INIT
{
}
#include "mcp970x.h"
#include <errno.h>
struct mcp970x_chip_spec
{
uint32_t uv_at_zero_celcius;
// uV/degree celcius
uint32_t temperature_coefficient;
};
static const struct mcp970x_chip_spec chip_specs[] =
{
[MCP970X_CHIP_9700] = {
.uv_at_zero_celcius = 500000,
.temperature_coefficient = 10000,
},
[MCP970X_CHIP_9701] = {
.uv_at_zero_celcius = 400000,
.temperature_coefficient = 19500,
},
};
/*
* Calculate the temperature in milli-degrees celcius. Divide by 1000 to get degrees celcius.
*
* Datasheet equation 4-1:
* Vout = (Tc * Ta) + V0c
* So:
* Ta = (Vout - V0c) / Tc
*/
static int32_t calculate_temperature(const struct mcp970x_chip_spec *chip_spec, uint32_t voltage_uv)
{
return (1000L * (voltage_uv - chip_spec->uv_at_zero_celcius)) / chip_spec->temperature_coefficient;
}
int mcp970x_read_temperature(enum mcp970x_chip chip, mcp970x_adc_function adc, int32_t *temperature)
{
if (chip < 0 || chip >= MCP970X_CHIP_NUM_OF)
{
return -EINVAL;
}
const struct mcp970x_chip_spec *spec = &chip_specs[chip];
int32_t adc_uv;
int res = adc(&adc_uv);
if (res)
{
return res;
}
*temperature = calculate_temperature(spec, adc_uv);
return 0;
}
#ifndef _MCP970X_H_
#define _MCP970X_H_
#include <stdint.h>
/*
* "A" versions are the same except with better accuracy
*/
enum mcp970x_chip
{
MCP970X_CHIP_9700,
MCP970X_CHIP_9700A = MCP970X_CHIP_9700,
MCP970X_CHIP_9701,
MCP970X_CHIP_9701A = MCP970X_CHIP_9701,
MCP970X_CHIP_NUM_OF,
};
typedef int (*mcp970x_adc_function)(int32_t *val_uv);
int mcp970x_read_temperature(
enum mcp970x_chip chip, mcp970x_adc_function adc, int32_t *temperature);
#endif // _MCP970X_H_
sandboxed: true
version: 1.0.0
start: auto
executables:
{
mcp9700aTemperatureSensor = ( Mcp9700aAppComponent )
}
processes:
{
envVars:
{
LE_LOG_LEVEL = DEBUG
}
run:
{
( mcp9700aTemperatureSensor )
}
faultAction: restart
}
bindings:
{
mcp9700aTemperatureSensor.Mcp9700aAppComponent.le_adc -> modemService.le_adc
}
extern:
{
mcp9700aTemperatureSensor.Mcp9700aAppComponent.mangOH_ambientTemperature
}
\ No newline at end of file
......@@ -31,7 +31,6 @@ apps:
#elif ${MANGOH_BOARD} = yellow
${CURDIR}/apps/YellowSensorToCloud/yellowSensor
${CURDIR}/apps/Mcp9700aTemperatureSensor/mcp9700aTemperatureSensor
${CURDIR}/apps/Bme680EnvironmentalSensor/bme680EnvironmentalSensor
${CURDIR}/apps/DataHub-Buzzer/buzzer
${CURDIR}/apps/YellowOnBoardActuators/actuator
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment