Atmel Software Framework

light.c File Reference
#include <string.h>
#include "compiler.h"
#include "gpio.h"
#include "FreeRTOS.h"
#include "light.h"
#include "datalog.h"
#include "shell.h"
#include "board.h"
#include "adc.h"
#include "sensor.h"
#include "config_file.h"
#include "fsaccess.h"
#include "BasicSMTP.h"

Macros

#define LIGHT_GETCONF_MAXLEN   64
 
#define SENSOR_LIGHT_CONFIG_FILE   "A:/CFG/LIGHT.TXT"
 

Functions

bool b_light_get_value (xLogDef *pxLog)
 Get the current light value. More...
 
bool b_light_init (void)
 Init the light sensor channel. More...
 
eExecStatus e_light_get_config (signed portCHAR **ppcStringReply)
 Get the light sensor config. More...
 
eExecStatus e_light_set_config (signed portCHAR **ppcStringReply, int ac, signed portCHAR *av[])
 Set the sensor config. More...
 
int sprintf (char *out, const char *format,...)
 

Variables

static volatile avr32_adc_t * adc = (volatile avr32_adc_t *) &AVR32_ADC
 
static bool b_light_alarm = false
 
static bool b_light_alarm_max = pdFALSE
 
static bool b_light_alarm_min = pdFALSE
 
unsigned int ul_light_lograte = 5
 
static unsigned int ul_light_max = 100
 
static unsigned int ul_light_min = 0
 
xSemaphoreHandle xCFGMutex
 

#define LIGHT_GETCONF_MAXLEN   64

Max string length of a get config.

Referenced by e_light_get_config().

#define SENSOR_LIGHT_CONFIG_FILE   "A:/CFG/LIGHT.TXT"

Path to the config file.

Referenced by b_light_init(), and e_light_set_config().

bool b_light_get_value ( xLogDef pxLog)

Get the current light value.

Get the current light sensor value.

Parameters
pxLoga Log structure.
Returns
true upon success, false if error.

References adc, adc_disable(), adc_enable(), adc_get_value(), ADC_MAX_VALUE, adc_start(), b_light_alarm, b_light_alarm_max, b_light_alarm_min, NULL, LogDef::pcStringLog, pdFALSE, pdTRUE, LogDef::pfFreeStringLog, pvPortMalloc(), sprintf(), ul_light_max, ul_light_min, v_SMTP_Post, and vPortFree().

Referenced by b_sensor_get_value().

bool b_light_init ( void  )
eExecStatus e_light_get_config ( signed portCHAR **  ppcStringReply)

Get the light sensor config.

Parameters
ppcStringReplyInput/Output. The response string. NEVER NULL AS INPUT. A malloc for the response string is performed here; the caller must free this string.
Returns
the status of the command execution.

References b_light_alarm, LIGHT_GETCONF_MAXLEN, NULL, pdTRUE, pvPortMalloc(), SHELL_ERRMSG_MEMALLOC, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, sprintf(), ul_light_lograte, ul_light_max, and ul_light_min.

eExecStatus e_light_set_config ( signed portCHAR **  ppcStringReply,
int  ac,
signed portCHAR *  av[] 
)

Set the sensor config.

Parameters
ppcStringReplyInput/Output. The response string. NEVER NULL AS INPUT.
acInput. Number of args
avInput. pointer to args
Returns
the status of the command execution.

References b_light_alarm, config_file_set_value(), NULL, pdFALSE, pdTRUE, SENSOR_LIGHT_CONFIG_FILE, SENSOR_MSG_ALARM_OFF, SENSOR_MSG_ALARM_ON, SENSOR_MSG_CONFIG_SET, SHELL_ERRMSG_CONFIGERROR, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK_NO_FREE, ul_light_lograte, ul_light_max, and ul_light_min.

int sprintf ( char *  out,
const char *  format,
  ... 
)

volatile avr32_adc_t* adc = (volatile avr32_adc_t *) &AVR32_ADC
static

ADC cell.

Referenced by b_light_get_value().

bool b_light_alarm = false
static
bool b_light_alarm_max = pdFALSE
static

Alarm for max is pending ?

Referenced by b_light_get_value().

bool b_light_alarm_min = pdFALSE
static

Alarm for min is pending ?

Referenced by b_light_get_value().

unsigned int ul_light_lograte = 5
unsigned int ul_light_max = 100
static
unsigned int ul_light_min = 0
static
xSemaphoreHandle xCFGMutex

The CFG system mutex.