Atmel Software Framework

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

Macros

#define PB1_POSITION   GPIO_PUSH_BUTTON_0
 
#define PB2_POSITION   GPIO_PUSH_BUTTON_1
 
#define PB3_POSITION   GPIO_PUSH_BUTTON_2
 
#define PUSHB_EVENT_PRESS   true
 
#define PUSHB_EVENT_RELEASE   false
 
#define PUSHB_GETCONF_MAXLEN   12
 
#define SENSOR_PB1_CONFIG_FILE   "A:/CFG/PB1.TXT"
 
#define SENSOR_PB2_CONFIG_FILE   "A:/CFG/PB2.TXT"
 
#define SENSOR_PB3_CONFIG_FILE   "A:/CFG/PB3.TXT"
 

Functions

bool b_pushb1_get_value (xLogDef *pxLog)
 Get a pushbutton current state. More...
 
bool b_pushb1_init (void)
 Init the push button 1 sensor. More...
 
bool b_pushb2_get_value (xLogDef *pxLog)
 Get a pushbutton current state. More...
 
bool b_pushb2_init (void)
 Init the push button 2 sensor. More...
 
bool b_pushb3_get_value (xLogDef *pxLog)
 Get a pushbutton current state. More...
 
bool b_pushb3_init (void)
 Init the push button 3 sensor. More...
 
eExecStatus e_pushb1_get_config (signed portCHAR **ppcStringReply)
 Get the pushbutton1 sensor config. More...
 
eExecStatus e_pushb1_set_config (signed portCHAR **ppcStringReply, int ac, signed portCHAR *av[])
 set push button config command: set the config fields value of a sensor. Takes one parameter, that is the sensor's name. Format: set_sensor_config sensor=name param=value More...
 
eExecStatus e_pushb2_get_config (signed portCHAR **ppcStringReply)
 Get the pushbutton2 sensor config. More...
 
eExecStatus e_pushb2_set_config (signed portCHAR **ppcStringReply, int ac, signed portCHAR *av[])
 set push button config command: set the config fields value of a sensor. Takes one parameter, that is the sensor's name. Format: set_sensor_config sensor=name param=value More...
 
eExecStatus e_pushb3_get_config (signed portCHAR **ppcStringReply)
 Get the pushbutton3 sensor config. More...
 
eExecStatus e_pushb3_set_config (signed portCHAR **ppcStringReply, int ac, signed portCHAR *av[])
 set push button config command: set the config fields value of a sensor. Takes one parameter, that is the sensor's name. Format: set_sensor_config sensor=name param=value More...
 
static eExecStatus prv_e_pushb_get_config (signed portCHAR **ppcStringReply, bool bAlarm)
 The get config command: get the config fields value of a sensor. More...
 
static eExecStatus prv_e_pushb_set_config (bool *bAlarm, portCHAR *filename, signed portCHAR **ppcStringReply, int ac, signed portCHAR *av[])
 set push button config command: set the config fields value of a sensor. More...
 
static portBASE_TYPE prvpushb_ISR_NonNakedBehaviour (void)
 push button interrupt handler. Here, declarations should be done More...
 
void v_pushb1_stop (void)
 Stop the push button 1 sensor. More...
 
void v_pushb2_stop (void)
 Stop the push button 2 sensor. More...
 
void v_pushb3_stop (void)
 Stop the push button 3 sensor. More...
 
void vpushb_ISR (void)
 push button naked interrupt handler. More...
 

Variables

const signed portCHAR * acpc_pushb_events [2]
 
static bool b_pushb1 = PUSHB_EVENT_RELEASE
 
static bool b_pushb2 = PUSHB_EVENT_RELEASE
 
static bool b_pushb3 = PUSHB_EVENT_RELEASE
 
static bool bAlarm1 = pdFALSE
 
static bool bAlarm2 = pdFALSE
 
static bool bAlarm3 = pdFALSE
 
xSemaphoreHandle xCFGMutex
 

#define PB1_POSITION   GPIO_PUSH_BUTTON_0
#define PB2_POSITION   GPIO_PUSH_BUTTON_1
#define PB3_POSITION   GPIO_PUSH_BUTTON_2
#define PUSHB_EVENT_PRESS   true

Pushbutton events.

Referenced by prvpushb_ISR_NonNakedBehaviour().

#define PUSHB_EVENT_RELEASE   false
#define PUSHB_GETCONF_MAXLEN   12

Max string length of a get config.

#define SENSOR_PB1_CONFIG_FILE   "A:/CFG/PB1.TXT"
#define SENSOR_PB2_CONFIG_FILE   "A:/CFG/PB2.TXT"
#define SENSOR_PB3_CONFIG_FILE   "A:/CFG/PB3.TXT"

bool b_pushb1_get_value ( xLogDef pxLog)

Get a pushbutton current state.

Parameters
pxLoga Log structure. The id field identifies the pushbutton.
Returns
true upon success, false if error.

References acpc_pushb_events, b_pushb1, NULL, LogDef::pcStringLog, and LogDef::pfFreeStringLog.

Referenced by b_sensor_get_value().

bool b_pushb2_get_value ( xLogDef pxLog)

Get a pushbutton current state.

Parameters
pxLoga Log structure. The id field identifies the pushbutton.
Returns
true upon success, false if error.

References acpc_pushb_events, b_pushb2, NULL, LogDef::pcStringLog, and LogDef::pfFreeStringLog.

Referenced by b_sensor_get_value().

bool b_pushb3_get_value ( xLogDef pxLog)

Get a pushbutton current state.

Parameters
pxLoga Log structure. The id field identifies the pushbutton.
Returns
true upon success, false if error.

References acpc_pushb_events, b_pushb3, NULL, LogDef::pcStringLog, and LogDef::pfFreeStringLog.

Referenced by b_sensor_get_value().

eExecStatus e_pushb1_get_config ( signed portCHAR **  ppcStringReply)

Get the pushbutton1 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 bAlarm1, and prv_e_pushb_get_config().

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

set push button config command: set the config fields value of a sensor. Takes one parameter, that is the sensor's name. Format: set_sensor_config sensor=name param=value

Set the sensor config.

Parameters
acInput. The argument counter. For this command, should be 2.
avInput. The argument vector.
ppcStringReplyInput/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns
the status of the command execution.

References bAlarm1, prv_e_pushb_set_config(), and SENSOR_PB1_CONFIG_FILE.

eExecStatus e_pushb2_get_config ( signed portCHAR **  ppcStringReply)

Get the pushbutton2 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 bAlarm2, and prv_e_pushb_get_config().

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

set push button config command: set the config fields value of a sensor. Takes one parameter, that is the sensor's name. Format: set_sensor_config sensor=name param=value

Set the sensor config.

Parameters
acInput. The argument counter. For this command, should be 2.
avInput. The argument vector.
ppcStringReplyInput/Output. The response string.
Returns
the status of the command execution.

References bAlarm2, prv_e_pushb_set_config(), and SENSOR_PB2_CONFIG_FILE.

eExecStatus e_pushb3_get_config ( signed portCHAR **  ppcStringReply)

Get the pushbutton3 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 bAlarm3, and prv_e_pushb_get_config().

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

set push button config command: set the config fields value of a sensor. Takes one parameter, that is the sensor's name. Format: set_sensor_config sensor=name param=value

Set the sensor config.

Parameters
acInput. The argument counter. For this command, should be 2.
avInput. The argument vector.
ppcStringReplyInput/Output. The response string.
Returns
the status of the command execution.

References bAlarm3, prv_e_pushb_set_config(), and SENSOR_PB3_CONFIG_FILE.

static eExecStatus prv_e_pushb_get_config ( signed portCHAR **  ppcStringReply,
bool  bAlarm 
)
static

The get config command: get the config fields value of a sensor.

Parameters
bAlarmInput. the alarm value to return.
ppcStringReplyInput/Output. The response string.
Returns
the status of the command execution.

References SENSOR_MSG_ALARM_OFF, SENSOR_MSG_ALARM_ON, and SHELL_EXECSTATUS_OK_NO_FREE.

Referenced by e_pushb1_get_config(), e_pushb2_get_config(), and e_pushb3_get_config().

static eExecStatus prv_e_pushb_set_config ( bool bAlarm,
portCHAR *  filename,
signed portCHAR **  ppcStringReply,
int  ac,
signed portCHAR *  av[] 
)
static

set push button config command: set the config fields value of a sensor.

Parameters
bAlarmInput. The flag to set or clear.
filenameInput. The configuration filename to update.
ppcStringReplyInput/Output. The response string.
acInput. The argument counter. For this command, should be 2.
avInput. The argument vector.
Returns
the status of the command execution.

References config_file_set_value(), pdFALSE, pdTRUE, SENSOR_MSG_ALARM_OFF, SENSOR_MSG_ALARM_ON, SHELL_ERRMSG_CONFIGERROR, SHELL_EXECSTATUS_KO, and SHELL_EXECSTATUS_OK_NO_FREE.

Referenced by e_pushb1_set_config(), e_pushb2_set_config(), and e_pushb3_set_config().

void v_pushb1_stop ( void  )

Stop the push button 1 sensor.

References gpio_disable_pin_interrupt(), and PB1_POSITION.

void v_pushb2_stop ( void  )

Stop the push button 2 sensor.

References gpio_disable_pin_interrupt(), and PB2_POSITION.

void v_pushb3_stop ( void  )

Stop the push button 3 sensor.

Stop the push button 1 sensor.

References gpio_disable_pin_interrupt(), and PB3_POSITION.

void vpushb_ISR ( void  )

push button naked interrupt handler.

References portENTER_SWITCHING_ISR, portEXIT_SWITCHING_ISR, and prvpushb_ISR_NonNakedBehaviour().

Referenced by b_pushb1_init(), b_pushb2_init(), and b_pushb3_init().

const signed portCHAR* acpc_pushb_events[2]
Initial value:
= {
(signed portCHAR *)"RELEASE",
(signed portCHAR *)"PRESS"
}

Pushbutton events string.

Referenced by b_pushb1_get_value(), b_pushb2_get_value(), b_pushb3_get_value(), and prvpushb_ISR_NonNakedBehaviour().

bool b_pushb1 = PUSHB_EVENT_RELEASE
static

Pushbutton events emulation.

Referenced by b_pushb1_get_value(), and prvpushb_ISR_NonNakedBehaviour().

xSemaphoreHandle xCFGMutex

The CFG system mutex.

Referenced by prvEthernetConfigureInterface().