Atmel Software Framework

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

Macros

#define JS_EVENT_DOWN   0x10
 
#define JS_EVENT_LEFT   0x02
 
#define JS_EVENT_PUSH   0x01
 
#define JS_EVENT_RIGHT   0x04
 
#define JS_EVENT_UP   0x08
 
#define JS_GETCONF_MAXLEN   16
 
#define JS_NB_EVENT   32
 
#define SENSOR_JS_CONFIG_FILE   "A:/CFG/JS.TXT"
 

Functions

bool b_joystick_get_value (xLogDef *pxLog)
 Get the current joystick state. More...
 
bool b_joystick_init (void)
 Init the joystick sensor. More...
 
eExecStatus e_joystick_get_config (signed portCHAR **ppcStringReply)
 Get the joystick sensor config. More...
 
eExecStatus e_joystick_set_config (signed portCHAR **ppcStringReply, int ac, signed portCHAR *av[])
 Set the sensor config. More...
 
static portBASE_TYPE prvjoystick_ISR_NonNakedBehaviour (void)
 joystick interrupt handler. Here, declarations should be done More...
 
void v_joystick_stop (void)
 Stop the joystick sensor. More...
 
void vjoystick_ISR (void)
 joystick naked interrupt handler. More...
 

Variables

const signed portCHAR * acpc_js_events [JS_NB_EVENT]
 
static bool bAlarm = false
 
static U32 u32LastCountValue = 0
 
static unsigned short x_joystick = 0
 
xSemaphoreHandle xCFGMutex
 

#define JS_EVENT_DOWN   0x10
#define JS_EVENT_LEFT   0x02
#define JS_EVENT_PUSH   0x01

Mask for events on joystick.

Referenced by prvjoystick_ISR_NonNakedBehaviour().

#define JS_EVENT_RIGHT   0x04
#define JS_EVENT_UP   0x08
#define JS_GETCONF_MAXLEN   16

Max string length of a get config.

#define JS_NB_EVENT   32

Max number of events on joystick.

#define SENSOR_JS_CONFIG_FILE   "A:/CFG/JS.TXT"

Path to the config file.

Referenced by b_joystick_init(), and e_joystick_set_config().

bool b_joystick_get_value ( xLogDef pxLog)

Get the current joystick state.

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

References acpc_js_events, NULL, LogDef::pcStringLog, LogDef::pfFreeStringLog, and x_joystick.

Referenced by b_sensor_get_value().

eExecStatus e_joystick_get_config ( signed portCHAR **  ppcStringReply)

Get the joystick 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 bAlarm, SENSOR_MSG_ALARM_OFF, SENSOR_MSG_ALARM_ON, and SHELL_EXECSTATUS_OK_NO_FREE.

eExecStatus e_joystick_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 bAlarm, config_file_set_value(), pdFALSE, pdTRUE, SENSOR_JS_CONFIG_FILE, SENSOR_MSG_ALARM_OFF, SENSOR_MSG_ALARM_ON, SHELL_ERRMSG_CONFIGERROR, SHELL_EXECSTATUS_KO, and SHELL_EXECSTATUS_OK_NO_FREE.

void v_joystick_stop ( void  )

Stop the joystick sensor.

References gpio_disable_pin_interrupt().

void vjoystick_ISR ( void  )

joystick naked interrupt handler.

References portENTER_SWITCHING_ISR, portEXIT_SWITCHING_ISR, and prvjoystick_ISR_NonNakedBehaviour().

Referenced by b_joystick_init().

const signed portCHAR* acpc_js_events[JS_NB_EVENT]
Initial value:
= {
(signed portCHAR *)"RELEASE",(signed portCHAR *)"PRESS",(signed portCHAR *)"LEFT",(signed portCHAR *)"LEFT/PRESS",
(signed portCHAR *)"RIGHT",(signed portCHAR *)"RIGHT/PRESS",(signed portCHAR *)"?",(signed portCHAR *)"?",
(signed portCHAR *)"UP",(signed portCHAR *)"UP/PRESS",(signed portCHAR *)"UP/LEFT",(signed portCHAR *)"UP/LEFT/PRESS",
(signed portCHAR *)"UP/RIGHT",(signed portCHAR *)"UP/RIGHT/PRESS",(signed portCHAR *)"?",(signed portCHAR *)"?",
(signed portCHAR *)"DOWN",(signed portCHAR *)"DOWN/PRESS",(signed portCHAR *)"DOWN/LEFT",(signed portCHAR *)"DOWN/LEFT/PRESS",
(signed portCHAR *)"DOWN/RIGHT",(signed portCHAR *)"DOWN/RIGHT/PRESS",(signed portCHAR *)"?",(signed portCHAR *)"?",
(signed portCHAR *)"?",(signed portCHAR *)"?",(signed portCHAR *)"?",(signed portCHAR *)"?",
(signed portCHAR *)"?",(signed portCHAR *)"?",(signed portCHAR *)"?",(signed portCHAR *)"?",
}

Joystick events string, regarding bit field value.

Referenced by b_joystick_get_value(), and prvjoystick_ISR_NonNakedBehaviour().

U32 u32LastCountValue = 0
static

Debouncing variable.

Referenced by prvjoystick_ISR_NonNakedBehaviour().

unsigned short x_joystick = 0
static

Joystick events.

Referenced by b_joystick_get_value(), and prvjoystick_ISR_NonNakedBehaviour().

xSemaphoreHandle xCFGMutex

The CFG system mutex.