Microchip® Advanced Software Framework

battery-sensor.c File Reference

Copyright (c) 2015-2018 Microchip Technology Inc.

and its subsidiaries.

#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "contiki.h"
#include "battery-sensor.h"
#include "sys/timer.h"
#include "asf.h"
#include "extint.h"
#include "trx_access.h"

Macros

#define BATMON_HR_HIGH   (1)
 Constant BATMON_HR_HIGH for sub-register SR_BATMON_HR in register BATMON. More...
 
#define BATMON_HR_LOW   (0)
 Constant BATMON_HR_LOW for sub-register SR_BATMON_HR in register BATMON. More...
 
#define BATMON_NOT_VALID   (0)
 Constant BATMON_NOT_VALID for sub-register SR_BATMON_OK in register BATMON. More...
 
#define BATMON_VALID   (1)
 Constant BATMON_VALID for sub-register SR_BATMON_OK in register BATMON. More...
 
#define SR_BATMON_HR   0x11, 0x10, 4
 Access parameters for sub-register BATMON_HR in register RG_BATMON. More...
 
#define SR_BATMON_OK   0x11, 0x20, 5
 Access parameters for sub-register BATMON_OK in register RG_BATMON. More...
 
#define SR_BATMON_VTH   0x11, 0x0F, 0
 Access parameters for sub-register BATMON_VTH in register RG_BATMON. More...
 
#define SUPPLY_VOLTAGE_ABOVE_UPPER_LIMIT   (0xFFFF)
 Supply voltage above upper limit. More...
 
#define SUPPLY_VOLTAGE_BELOW_LOWER_LIMIT   (0)
 Supply voltage below lower limit. More...
 

Functions

static int battery_sensor_configure (int type, int value)
 
void battery_sensor_init (void)
 
static int battery_sensor_status (int type)
 
static int battery_sensor_value (int type)
 
static uint16_t get_batmon_voltage (void)
 
 SENSORS_SENSOR (battery_sensor,"Battery sensor", battery_sensor_value, battery_sensor_configure, battery_sensor_status)
 

Variables

static int enabled = 0
 

#define BATMON_HR_HIGH   (1)

Constant BATMON_HR_HIGH for sub-register SR_BATMON_HR in register BATMON.

Referenced by get_batmon_voltage().

#define BATMON_HR_LOW   (0)

Constant BATMON_HR_LOW for sub-register SR_BATMON_HR in register BATMON.

Referenced by get_batmon_voltage().

#define BATMON_NOT_VALID   (0)

Constant BATMON_NOT_VALID for sub-register SR_BATMON_OK in register BATMON.

Referenced by get_batmon_voltage().

#define BATMON_VALID   (1)

Constant BATMON_VALID for sub-register SR_BATMON_OK in register BATMON.

Referenced by get_batmon_voltage().

#define SR_BATMON_HR   0x11, 0x10, 4

Access parameters for sub-register BATMON_HR in register RG_BATMON.

Referenced by get_batmon_voltage().

#define SR_BATMON_OK   0x11, 0x20, 5

Access parameters for sub-register BATMON_OK in register RG_BATMON.

Referenced by get_batmon_voltage().

#define SR_BATMON_VTH   0x11, 0x0F, 0

Access parameters for sub-register BATMON_VTH in register RG_BATMON.

Referenced by get_batmon_voltage().

#define SUPPLY_VOLTAGE_ABOVE_UPPER_LIMIT   (0xFFFF)

Supply voltage above upper limit.

Referenced by get_batmon_voltage().

#define SUPPLY_VOLTAGE_BELOW_LOWER_LIMIT   (0)

Supply voltage below lower limit.

Referenced by get_batmon_voltage().

static int battery_sensor_configure ( int  type,
int  value 
)
static

References enabled.

Referenced by battery_sensor_init().

void battery_sensor_init ( void  )

References battery_sensor_configure().

Referenced by PROCESS_THREAD().

static int battery_sensor_status ( int  type)
static

References enabled.

static int battery_sensor_value ( int  type)
static

References enabled, and get_batmon_voltage().

SENSORS_SENSOR ( battery_sensor  ,
"Battery sensor"  ,
battery_sensor_value  ,
battery_sensor_configure  ,
battery_sensor_status   
)