#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 |
Referenced by b_pushb1_init(), prvpushb_ISR_NonNakedBehaviour(), and v_pushb1_stop().
#define PB2_POSITION GPIO_PUSH_BUTTON_1 |
Referenced by b_pushb2_init(), prvpushb_ISR_NonNakedBehaviour(), and v_pushb2_stop().
#define PB3_POSITION GPIO_PUSH_BUTTON_2 |
Referenced by b_pushb3_init(), prvpushb_ISR_NonNakedBehaviour(), and v_pushb3_stop().
#define PUSHB_EVENT_PRESS true |
Pushbutton events.
Referenced by prvpushb_ISR_NonNakedBehaviour().
#define PUSHB_EVENT_RELEASE false |
Referenced by prvpushb_ISR_NonNakedBehaviour().
#define PUSHB_GETCONF_MAXLEN 12 |
Max string length of a get config.
#define SENSOR_PB1_CONFIG_FILE "A:/CFG/PB1.TXT" |
Referenced by b_pushb1_init(), and e_pushb1_set_config().
#define SENSOR_PB2_CONFIG_FILE "A:/CFG/PB2.TXT" |
Referenced by b_pushb2_init(), and e_pushb2_set_config().
#define SENSOR_PB3_CONFIG_FILE "A:/CFG/PB3.TXT" |
Referenced by b_pushb3_init(), and e_pushb3_set_config().
Get a pushbutton current state.
pxLog | a Log structure. The id field identifies the pushbutton. |
References acpc_pushb_events, b_pushb1, NULL, LogDef::pcStringLog, and LogDef::pfFreeStringLog.
Referenced by b_sensor_get_value().
Init the push button 1 sensor.
References bAlarm1, config_file_get_value(), Disable_global_interrupt, Enable_global_interrupt, gpio_enable_pin_interrupt(), GPIO_PIN_CHANGE, INTC_register_interrupt(), PB1_POSITION, pdTRUE, SENSOR_PB1_CONFIG_FILE, vpushb_ISR(), x_supervisor_SemaphoreGive(), and x_supervisor_SemaphoreTake().
Get a pushbutton current state.
pxLog | a Log structure. The id field identifies the pushbutton. |
References acpc_pushb_events, b_pushb2, NULL, LogDef::pcStringLog, and LogDef::pfFreeStringLog.
Referenced by b_sensor_get_value().
Init the push button 2 sensor.
References bAlarm2, config_file_get_value(), Disable_global_interrupt, Enable_global_interrupt, gpio_enable_pin_interrupt(), GPIO_PIN_CHANGE, INTC_register_interrupt(), PB2_POSITION, pdTRUE, SENSOR_PB2_CONFIG_FILE, vpushb_ISR(), x_supervisor_SemaphoreGive(), and x_supervisor_SemaphoreTake().
Get a pushbutton current state.
pxLog | a Log structure. The id field identifies the pushbutton. |
References acpc_pushb_events, b_pushb3, NULL, LogDef::pcStringLog, and LogDef::pfFreeStringLog.
Referenced by b_sensor_get_value().
Init the push button 3 sensor.
References bAlarm3, config_file_get_value(), Disable_global_interrupt, Enable_global_interrupt, gpio_enable_pin_interrupt(), GPIO_PIN_CHANGE, INTC_register_interrupt(), PB3_POSITION, pdTRUE, SENSOR_PB3_CONFIG_FILE, vpushb_ISR(), x_supervisor_SemaphoreGive(), and x_supervisor_SemaphoreTake().
eExecStatus e_pushb1_get_config | ( | signed portCHAR ** | ppcStringReply | ) |
Get the pushbutton1 sensor config.
ppcStringReply | Input/Output. The response string. NEVER NULL AS INPUT. A malloc for the response string is performed here; the caller must free this string. |
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.
ac | Input. The argument counter. For this command, should be 2. |
av | Input. The argument vector. |
ppcStringReply | Input/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. |
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.
ppcStringReply | Input/Output. The response string. NEVER NULL AS INPUT. A malloc for the response string is performed here; the caller must free this string. |
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.
ac | Input. The argument counter. For this command, should be 2. |
av | Input. The argument vector. |
ppcStringReply | Input/Output. The response string. |
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.
ppcStringReply | Input/Output. The response string. NEVER NULL AS INPUT. A malloc for the response string is performed here; the caller must free this string. |
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.
ac | Input. The argument counter. For this command, should be 2. |
av | Input. The argument vector. |
ppcStringReply | Input/Output. The response string. |
References bAlarm3, prv_e_pushb_set_config(), and SENSOR_PB3_CONFIG_FILE.
|
static |
The get config command: get the config fields value of a sensor.
bAlarm | Input. the alarm value to return. |
ppcStringReply | Input/Output. The response string. |
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 |
set push button config command: set the config fields value of a sensor.
bAlarm | Input. The flag to set or clear. |
filename | Input. The configuration filename to update. |
ppcStringReply | Input/Output. The response string. |
ac | Input. The argument counter. For this command, should be 2. |
av | Input. The argument vector. |
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().
|
static |
push button interrupt handler. Here, declarations should be done
References acpc_pushb_events, b_pushb1, b_pushb2, b_pushb3, bAlarm1, bAlarm2, bAlarm3, DATALOG_ID_PB1, DATALOG_ID_PB2, DATALOG_ID_PB3, gpio_clear_pin_interrupt_flag(), gpio_get_pin_interrupt_flag(), gpio_get_pin_value(), LogDef::id, NULL, PB1_POSITION, PB2_POSITION, PB3_POSITION, LogDef::pcStringLog, pdFALSE, pdTRUE, LogDef::pfFreeStringLog, PUSHB_EVENT_PRESS, PUSHB_EVENT_RELEASE, pxdatalog_log_alloc_init_FromISR, v_SMTP_PostFromISR, and x_datalog_AddLogFromISR().
Referenced by vpushb_ISR().
Stop the push button 1 sensor.
References gpio_disable_pin_interrupt(), and PB1_POSITION.
Stop the push button 2 sensor.
References gpio_disable_pin_interrupt(), and PB2_POSITION.
Stop the push button 3 sensor.
Stop the push button 1 sensor.
References gpio_disable_pin_interrupt(), and PB3_POSITION.
push button naked interrupt handler.
References prvpushb_ISR_NonNakedBehaviour().
Referenced by b_pushb1_init(), b_pushb2_init(), and b_pushb3_init().
const signed portCHAR* acpc_pushb_events[2] |
Pushbutton events string.
Referenced by b_pushb1_get_value(), b_pushb2_get_value(), b_pushb3_get_value(), and prvpushb_ISR_NonNakedBehaviour().
|
static |
Pushbutton events emulation.
Referenced by b_pushb1_get_value(), and prvpushb_ISR_NonNakedBehaviour().
|
static |
Referenced by b_pushb2_get_value(), and prvpushb_ISR_NonNakedBehaviour().
|
static |
Referenced by b_pushb3_get_value(), and prvpushb_ISR_NonNakedBehaviour().
Alarm upon event.
Referenced by b_pushb1_init(), e_pushb1_get_config(), e_pushb1_set_config(), and prvpushb_ISR_NonNakedBehaviour().
Referenced by b_pushb2_init(), e_pushb2_get_config(), e_pushb2_set_config(), and prvpushb_ISR_NonNakedBehaviour().
Referenced by b_pushb3_init(), e_pushb3_get_config(), e_pushb3_set_config(), and prvpushb_ISR_NonNakedBehaviour().
xSemaphoreHandle xCFGMutex |
The CFG system mutex.