Updated to match the new sensors API
This commit is contained in:
parent
d9900a474a
commit
24f28f0f1c
16 changed files with 603 additions and 429 deletions
|
@ -26,76 +26,66 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: temperature-sensor.c,v 1.1 2006/06/18 07:49:33 adamdunkels Exp $
|
||||
* $Id: temperature-sensor.c,v 1.2 2010/01/14 17:39:35 nifi Exp $
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
|
||||
* Created : 2005-11-01
|
||||
* Updated : $Date: 2006/06/18 07:49:33 $
|
||||
* $Revision: 1.1 $
|
||||
* Updated : $Date: 2010/01/14 17:39:35 $
|
||||
* $Revision: 1.2 $
|
||||
*/
|
||||
|
||||
#include "dev/temperature-sensor.h"
|
||||
#include "dev/ds1629.h"
|
||||
|
||||
const struct sensors_sensor temperature_sensor;
|
||||
static unsigned char flags;
|
||||
static int active;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
flags = 0;
|
||||
ds1629_init();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
irq(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
activate(void)
|
||||
{
|
||||
flags |= 1;
|
||||
ds1629_start();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
deactivate(void)
|
||||
{
|
||||
flags &= ~1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
active(void)
|
||||
{
|
||||
return (flags & 1);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned int
|
||||
value(int type)
|
||||
{
|
||||
unsigned int temp;
|
||||
signed int t = ds1629_temperature();
|
||||
signed int t;
|
||||
|
||||
t = ds1629_temperature();
|
||||
temp = ((t / 128) * 50);
|
||||
return temp;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, void *c)
|
||||
configure(int type, int value)
|
||||
{
|
||||
switch (type) {
|
||||
case SENSORS_HW_INIT:
|
||||
active = 0;
|
||||
ds1629_init();
|
||||
return 1;
|
||||
case SENSORS_ACTIVE:
|
||||
if (value) {
|
||||
if(!active) {
|
||||
active = 1;
|
||||
ds1629_start();
|
||||
}
|
||||
} else {
|
||||
active = 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void *
|
||||
static int
|
||||
status(int type)
|
||||
{
|
||||
return NULL;
|
||||
switch (type) {
|
||||
case SENSORS_ACTIVE:
|
||||
case SENSORS_READY:
|
||||
return active;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(temperature_sensor, TEMPERATURE_SENSOR,
|
||||
init, irq, activate, deactivate, active,
|
||||
value, configure, status);
|
||||
value, configure, status);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue