This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2541DK-MINI:MMA7660 TILT register

Part Number: CC2541DK-MINI
Other Parts Discussed in Thread: CC2541, TPS62730

Hello. I'm trying to connect the CC2541 with the MMA7660 (accelerometer) to I2C. I managed to write to the MMA7660 registers, reading too. But when I try to read the TILT register,

success = accRead (MMA7660_TILT, & rTILT, sizeof (rTILT));

rTILT takes the value 0x00. If I put a checkpoint after the line success = accRead (MMA7660_TILT, & rTILT, sizeof (rTILT)); rTILT is equal to 0x00, which is not true. If I put a dot on the line success = accRead (MMA7660_TILT, & rTILT, sizeof (rTILT));  and I make a step-by-step action, then I get a value of 0c02, which is the correct value.

Help Me!

I quote the text of the program.

/*********************************************************************

* INCLUDES
*/

#include "bcomdef.h"
#include "OSAL.h"
#include "OSAL_PwrMgr.h"

#include "OnBoard.h"
#include "hal_adc.h"
#include "hal_led.h"
#include "hal_key.h"
#include "hal_i2c.h"

#include "RGB_DATA.h"
#include "mma7660.h"

#include "gatt.h"

#include "hci.h"

#include "gapgattserver.h"
#include "gattservapp.h"
#include "gatt_profile_uuid.h"

#if defined ( PLUS_BROADCASTER )
#include "peripheralBroadcaster.h"
#else
#include "peripheral.h"
#endif

#include "gapbondmgr.h"

#include "devinfoservice.h"
#include "proxreporter.h"
#include "adcservice.h"
#include "accelerometer.h"
#include "simplekeys.h"

#include "keyfobdemo.h"

/*********************************************************************
* MACROS
*/

/*********************************************************************
* CONSTANTS
*/

// Delay between power-up and starting advertising (in ms)
#define STARTDELAY 500

//Как часто обновлять данные на светодиод (в мс)
#define RGB_WRITE_PERIOD 3000

// Number of beeps before buzzer stops by itself
#define RGB_MAX_BITS 24

//Как часто проверять АЦП (в мс)
#define ADC_CHECK_PERIOD 10000

//Как часто читать акселерометр (в мс)
#define ACCEL_READ_PERIOD 2000

// Minimum change in accelerometer before sending a notification
#define ACCEL_CHANGE_THRESHOLD 5

//GAP Peripheral Role desired connection parameters

// Use limited discoverable mode to advertise for 30.72s, and then stop, or
// use general discoverable mode to advertise indefinitely
#define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_LIMITED
//#define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_GENERAL

// Minimum connection interval (units of 1.25ms, 80=100ms) if automatic parameter update request is enabled
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 80

// Maximum connection interval (units of 1.25ms, 800=1000ms) if automatic parameter update request is enabled
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 800

// Slave latency to use if automatic parameter update request is enabled
#define DEFAULT_DESIRED_SLAVE_LATENCY 0

// Supervision timeout value (units of 10ms, 1000=10s) if automatic parameter update request is enabled
#define DEFAULT_DESIRED_CONN_TIMEOUT 1000

// Whether to enable automatic parameter update request when a connection is formed
#define DEFAULT_ENABLE_UPDATE_REQUEST TRUE

// Connection Pause Peripheral time value (in seconds)
#define DEFAULT_CONN_PAUSE_PERIPHERAL 5

// keyfobProximityState values
#define KEYFOB_PROXSTATE_INITIALIZED 0 // Advertising after initialization or due to terminated link
#define KEYFOB_PROXSTATE_CONNECTED_IN_RANGE 1 // Connected and "within range" of the master, as defined by
// proximity profile
#define KEYFOB_PROXSTATE_PATH_LOSS 2 // Connected and "out of range" of the master, as defined by
// proximity profile
#define KEYFOB_PROXSTATE_LINK_LOSS 3 // Disconnected as a result of a supervision timeout

// RGB state values
#define RGB_OFF 0
#define RGB_ON 1

// keyfobAlertState values
#define ALERT_STATE_OFF 0
#define ALERT_STATE_LOW 1
#define ALERT_STATE_HIGH 2

#define STATE_0 0
#define STATE_1 1
#define STATE_2 2

// Company Identifier: Texas Instruments Inc. (13)
#define TI_COMPANY_ID 0x000D

#define INVALID_CONNHANDLE 0xFFFF

#if defined ( PLUS_BROADCASTER )
#define ADV_IN_CONN_WAIT 500 // delay 500 ms
#endif

/*********************************************************************
* TYPEDEFS
*/

/*********************************************************************
* GLOBAL VARIABLES
*/

/*********************************************************************
* EXTERNAL VARIABLES
*/

/*********************************************************************
* EXTERNAL FUNCTIONS
*/

/*********************************************************************
* LOCAL VARIABLES
*/
static uint8 keyfobapp_TaskID; // Task ID for internal task/event processing

static gaprole_States_t gapProfileState = GAPROLE_INIT;

// GAP - SCAN RSP data (max size = 31 bytes)
static uint8 deviceName[] =
{
// complete name
0x0f, // length of first data structure (11 bytes excluding length byte)
0x09, // AD Type = Complete local name
0x4b, // 'K'
0x65, // 'e'
0x79, // 'y'
0x66, // 'f'
0x6f, // 'o'
0x62, // 'b'
0x64, // 'd'
0x65, // 'e'
0x6d, // 'm'
0x6f, // 'o'
0x5f, // '_'
0x41, // 'A'
0x44, // 'D'
0x43, // 'C'

};

// GAP - Advertisement data (max size = 31 bytes, though this is
// best kept short to conserve power while advertisting)

// GAP - Реклама данные (максимальный размер = 31 байт, хотя это
// лучше всего хранить в краткосрочной экономии энергии во время advertisting)
static uint8 advertData[] =
{
0x02, // length of first data structure (2 bytes excluding length byte)
GAP_ADTYPE_FLAGS, // AD Type = Flags
DEFAULT_DISCOVERABLE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,

// service UUID, to notify central devices what services are included
// in this peripheral
0x07, // length of second data structure (7 bytes excluding length byte)
GAP_ADTYPE_16BIT_MORE, // list of 16-bit UUID's available, but not complete list
LO_UINT16( LINK_LOSS_SERV_UUID ), // Link Loss Service (Proximity Profile)
HI_UINT16( LINK_LOSS_SERV_UUID ),
LO_UINT16( IMMEDIATE_ALERT_SERV_UUID ), // Immediate Alert Service (Proximity / Find Me Profile)
HI_UINT16( IMMEDIATE_ALERT_SERV_UUID ),
LO_UINT16( TX_PWR_LEVEL_SERV_UUID ), // Tx Power Level Service (Proximity Profile)
HI_UINT16( TX_PWR_LEVEL_SERV_UUID )
};

// GAP GATT Attributes
static uint8 attDeviceName[GAP_DEVICE_NAME_LEN] = "TI BLE Keyfob_ADC";

static uint8 state_key;
static uint8 evt = 0;

static uint8 accelEnabler = FALSE;

static uint8 MMA7660_XOUT = 0x00;
static uint8 MMA7660_YOUT = 0x01;
static uint8 MMA7660_ZOUT = 0x02;
static uint8 MMA7660_TILT = 0x03;
static uint8 MMA7660_SRST = 0x04;
static uint8 MMA7660_SPCNT = 0x05;
static uint8 MMA7660_INTSU = 0x06;
static uint8 MMA7660_MODE = 0x07;
static uint8 MMA7660_SR = 0x08;
static uint8 MMA7660_PDET = 0x09;
static uint8 MMA7660_PD = 0x0A;

static uint8 HAL_MMA7660_I2C_ADDRESS = 0x4C;

static uint8 horizon = FALSE;
static bool sysResetRequest = FALSE;
static bool long_press = FALSE;


/*********************************************************************
* LOCAL FUNCTIONS
*/
static void keyfobADC_ProcessOSALMSG( osal_event_hdr_t *pMsg );
static void keyfobADC_KEYS( uint8 keys );
static void peripheralStateNotificationCB( gaprole_States_t newState );
static void accelEnablerChangeCB( void );

void accelRead(void *hor);

/*********************************************************************
* PROFILE CALLBACKS
*/
// GAP Role Callbacks
static gapRolesCBs_t keyFob_PeripheralCBs =
{
peripheralStateNotificationCB, // Profile State Change Callbacks
NULL // When a valid RSSI is read from controller
};

// GAP Bond Manager Callbacks
static gapBondCBs_t keyFob_BondMgrCBs =
{
NULL, // Passcode callback (not used by application)
NULL // Pairing / Bonding state Callback (not used by application)
};

static accelCBs_t keyFob_AccelCBs =
{
accelEnablerChangeCB,
};
/*********************************************************************
* PUBLIC FUNCTIONS
*/

/*********************************************************************
* @fn KeyFobApp_Init
*
* @brief Initialization function for the Key Fob App Task.
* This is called during initialization and should contain
* any application specific initialization (ie. hardware
* initialization/setup, table initialization, power up
* notificaiton ... ).
*
* @param task_id - the ID assigned by OSAL. This ID should be
* used to send messages and set timers.
*
* @return none
*/
void KeyFobApp_Init( uint8 task_id )
{
keyfobapp_TaskID = task_id;

// Setup the GAP
VOID GAP_SetParamValue( TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL );

// Setup the GAP Peripheral Role Profile
{
// For the CC2540DK-MINI keyfob, device doesn't start advertising until button is pressed
uint8 initial_advertising_enable = FALSE;

// By setting this to zero, the device will go into the waiting state after
// being discoverable for 30.72 second, and will not being advertising again
// until the enabler is set back to TRUE
uint16 gapRole_AdvertOffTime = 0;

uint8 enable_update_request = DEFAULT_ENABLE_UPDATE_REQUEST;
uint16 desired_min_interval = DEFAULT_DESIRED_MIN_CONN_INTERVAL;
uint16 desired_max_interval = DEFAULT_DESIRED_MAX_CONN_INTERVAL;
uint16 desired_slave_latency = DEFAULT_DESIRED_SLAVE_LATENCY;
uint16 desired_conn_timeout = DEFAULT_DESIRED_CONN_TIMEOUT;

// Set the GAP Role Parameters
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );
GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime );

GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof ( deviceName ), deviceName );
GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );

GAPRole_SetParameter( GAPROLE_PARAM_UPDATE_ENABLE, sizeof( uint8 ), &enable_update_request );
GAPRole_SetParameter( GAPROLE_MIN_CONN_INTERVAL, sizeof( uint16 ), &desired_min_interval );
GAPRole_SetParameter( GAPROLE_MAX_CONN_INTERVAL, sizeof( uint16 ), &desired_max_interval );
GAPRole_SetParameter( GAPROLE_SLAVE_LATENCY, sizeof( uint16 ), &desired_slave_latency );
GAPRole_SetParameter( GAPROLE_TIMEOUT_MULTIPLIER, sizeof( uint16 ), &desired_conn_timeout );
}

// Set the GAP Attributes
GGS_SetParameter( GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName );

// Setup the GAP Bond Manager
{
uint8 pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
uint8 mitm = TRUE;
uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
uint8 bonding = TRUE;

GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );
GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );
GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );
GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
}

// Initialize GATT attributes
GGS_AddService( GATT_ALL_SERVICES ); // GAP
GATTServApp_AddService( GATT_ALL_SERVICES ); // GATT attributes
DevInfo_AddService(); // Device Information Service
Accel_AddService( GATT_ALL_SERVICES ); // Accelerometer Profile

accStop();

HalLedSet( (HAL_LED_1 | HAL_LED_2), HAL_LED_MODE_OFF );

P0SEL = 0; // Configure Port 0 as GPIO
P1SEL = 0; // Configure Port 1 as GPIO
P2SEL = 0; // Configure Port 2 as GPIO

P0DIR = 0x3C; // Port 0 pins P0.0 and P0.1 as input (buttons), pin P0.6, P0.7 as input (ADC)
// all others (P0.2-P0.7) as output
P1DIR = 0xFF; // All port 1 pins (P1.0-P1.7) as output
P2DIR = 0x1F; // All port 1 pins (P2.0-P2.4) as output

P0 = 0x03; // All pins on port 0 to low except for P0.0 and P0.1 (buttons)
P1 = 0; // All pins on port 1 to low
P2 = 0; // All pins on port 2 to low

// initialize the ADC
HalAdcInit();

// Register for all key events - This app will handle all key events
RegisterForKeys( keyfobapp_TaskID );

#if defined ( DC_DC_P0_7 )
// Enable stack to toggle bypass control on TPS62730 (DC/DC converter)
HCI_EXT_MapPmIoPortCmd( HCI_EXT_PM_IO_PORT_P0, HCI_EXT_PM_IO_PORT_PIN7 );

#endif //defined ( DC_DC_P0_7 )

// Setup a delayed profile startup
osal_start_timerEx( keyfobapp_TaskID, KFDA_START_DEVICE_EVT, STARTDELAY );
}

/*********************************************************************
* @fn KeyFobApp_ProcessEvent
*
* @brief Key Fob Application Task event processor. This function
* is called to process all events for the task. Events
* include timers, messages and any other user defined events.
*
* @param task_id - The OSAL assigned task ID.
* @param events - events to process. This is a bit map and can
* contain more than one event.
*
* @return none
*/
uint16 KeyFobApp_ProcessEvent( uint8 task_id, uint16 events )
{
if ( events & SYS_EVENT_MSG )
{
uint8 *pMsg;

if ( (pMsg = osal_msg_receive( keyfobapp_TaskID )) != NULL )
{

keyfobADC_ProcessOSALMSG( (osal_event_hdr_t *)pMsg );

// Release the OSAL message
VOID osal_msg_deallocate( pMsg );
}

// return unprocessed events
return (events ^ SYS_EVENT_MSG);
}

if ( events & KFDA_START_DEVICE_EVT )
{
// Start the Device
VOID GAPRole_StartDevice( &keyFob_PeripheralCBs );

// Start Bond Manager
VOID GAPBondMgr_Register( &keyFob_BondMgrCBs );

// Start the Accelerometer Profile
VOID Accel_RegisterAppCBs( &keyFob_AccelCBs );

// Set LED1 on to give feedback that the power is on, and a timer to turn off
HalLedSet( HAL_LED_1, HAL_LED_MODE_ON );
osal_pwrmgr_device( PWRMGR_ALWAYS_ON ); // To keep the LED on continuously.
osal_start_timerEx( keyfobapp_TaskID, KFDA_POWERON_LED_TIMEOUT_EVT, 1000 );

return ( events ^ KFDA_START_DEVICE_EVT );
}

if ( events & KFDA_POWERON_LED_TIMEOUT_EVT )
{
osal_pwrmgr_device( PWRMGR_BATTERY ); // Revert to battery mode after LED off
HalLedSet( HAL_LED_1, HAL_LED_MODE_OFF );
return ( events ^ KFDA_POWERON_LED_TIMEOUT_EVT );
}

if ( events & KFDA_ACCEL_READ_EVT )
{

uint8 rTILT;
uint8 rMODE;
uint8 MODE = 0;
uint8 SR = 0;
uint8 INTSU = 0;
uint8 PDET = 0;
uint8 PD = 0;
uint8 SPCNT = 0;
volatile uint32 kk = 0;

bool success;

//---------------- Инициализация MMA7660-----------------//
MODE = 0x00; // Standby Mode
SPCNT = 0x00;
INTSU = (1 << INTSU_GINT) | (1 << INTSU_SHINTZ);
PDET = (1 << PDET_XDA) | (1 << PDET_YDA) | (1 << PDET_ZDA);
SR = 0x60;
PD = 0x00;
//SR |= (1 << SR_AMSR0); // 64sample/second
//SR |= (1 << SR_AMSR0) | (1 << SR_AMSR2); // 4sample/second
//SR |= (1 << SR_FILT2) | (1 << SR_FILT1) | (1 << SR_FILT0);
//INTSU |= 1 << INTSU_SHINTZ; //Прерывание по встряске Z

//Задаем адрес устройства и частоту обмена
HalI2CInit( HAL_MMA7660_I2C_ADDRESS, i2cClock_267KHZ );

//Запись в регистр MODE значение
accWrite( MMA7660_MODE, &MODE, sizeof(MODE));
for (kk = 0; kk < 180; kk++)
{


}

//Запись в регистр SPCNT
accWrite( MMA7660_SPCNT, &SPCNT, sizeof(SPCNT));
for (kk = 0; kk < 180; kk++)
{


}

//Запись в регистр INTSU
accWrite(MMA7660_INTSU, &INTSU, sizeof(INTSU));
for (kk = 0; kk < 180; kk++)
{

}

//Запись в регистр PDET
accWrite(MMA7660_PDET, &PDET, sizeof(PDET));
for (kk = 0; kk < 180; kk++)
{

}

//Запись в регистр SR
accWrite(MMA7660_SR, &SR, sizeof(SR));
for (kk = 0; kk < 180; kk++)
{

}

//Запись в регистр PD
accWrite(MMA7660_PD, &PD, sizeof(PD));
for (kk = 0; kk < 180; kk++)
{

}


//Устанавливаем Active Mode
MODE |= (1 << MODE_MODE); // Active Mode
accWrite(MMA7660_MODE, &MODE, sizeof(MODE)); //запись в регистр MODE
for (kk = 0; kk < 254; kk++)
{

}
//----------------------------------------------------------//

//MODE = 0x00;

success = accRead(MMA7660_TILT, &rTILT, sizeof(rTILT)); //!!!!!!!!!!!!!!!!!!!!! не передается rTILT

if ( ( (rTILT & 0x01) == 0x01) || ( (rTILT & 0x02) == 0x02) )
{
osal_start_timerEx( keyfobapp_TaskID, KFDA_ADC_CHECK_EVT, 1000 );
}

return ( events ^ KFDA_ACCEL_READ_EVT );
}

//Для определния однократного или длительного нажатия кнопки
if ( events & KFDA_KEYS_EVT )
{
if (sysResetRequest)
{
long_press = TRUE;

if( gapProfileState != GAPROLE_CONNECTED )
{
uint8 current_adv_enabled_status;
uint8 new_adv_enabled_status;

//Find the current GAP advertisement status
GAPRole_GetParameter( GAPROLE_ADVERT_ENABLED, &current_adv_enabled_status );

if( current_adv_enabled_status == FALSE )
{
new_adv_enabled_status = TRUE;

}
else
{
new_adv_enabled_status = FALSE;
}

//change the GAP advertisement status to opposite of current status
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &new_adv_enabled_status );
}
}

return ( events ^ KFDA_KEYS_EVT );
}

if ( events & KFDA_ADC_CHECK_EVT )
{

Adc_MeasLevel();

return (events ^ KFDA_ADC_CHECK_EVT);

}

// Discard unknown events
return 0;
}

/*********************************************************************
* @fn keyfobADC_ProcessOSALMSG
*
* @brief Process an incoming task message.
*
* @param pMsg - message to process
*
* @return none
*/
static void keyfobADC_ProcessOSALMSG( osal_event_hdr_t *pMsg )
{
switch ( pMsg->event )
{
case KEY_CHANGE:
keyfobADC_KEYS( ((keyChange_t *)pMsg)->keys );
break;
}
}

/*********************************************************************
* @fn keyfobADC_KEYS
*
* @brief Handles all key events for this device.
*
* @param shift - true if in shift/alt.
* @param keys - bit field for key events. Valid entries:
* HAL_KEY_SW_2
* HAL_KEY_SW_1
*
* @return none
*/
static void keyfobADC_KEYS( uint8 keys )
{
uint8 SK_Keys = 0;

if ( keys & HAL_KEY_SW_1 )
{
SK_Keys |= SK_KEY_LEFT;
}


if ( keys & HAL_KEY_SW_2 )
{
sysResetRequest = TRUE;
osal_start_timerEx( keyfobapp_TaskID, KFDA_KEYS_EVT, 2000 );

SK_Keys |= SK_KEY_RIGHT;

}

if (!(keys & HAL_KEY_SW_2))
{
if (!long_press)
{
osal_start_timerEx(keyfobapp_TaskID, KFDA_ACCEL_READ_EVT, 3000);
}

sysResetRequest = FALSE;
long_press = FALSE;
}

SK_SetParameter( SK_KEY_ATTR, sizeof ( uint8 ), &SK_Keys );


}

/*********************************************************************
* @fn peripheralStateNotificationCB
*
* @brief Notification from the profile of a state change.
*
* @param newState - new state
*
* @return none
*/
static void peripheralStateNotificationCB( gaprole_States_t newState )
{
uint16 connHandle = INVALID_CONNHANDLE;
uint8 valFalse = FALSE;

if ( gapProfileState != newState )
{
switch( newState )
{
case GAPROLE_STARTED:
{
// Set the system ID from the bd addr
uint8 systemId[DEVINFO_SYSTEM_ID_LEN];
GAPRole_GetParameter(GAPROLE_BD_ADDR, systemId);

// shift three bytes up
systemId[7] = systemId[5];
systemId[6] = systemId[4];
systemId[5] = systemId[3];

// set middle bytes to zero
systemId[4] = 0;
systemId[3] = 0;

DevInfo_SetParameter(DEVINFO_SYSTEM_ID, DEVINFO_SYSTEM_ID_LEN, systemId);
}
break;

//if the state changed to connected, initially assume that keyfob is in range
case GAPROLE_ADVERTISING:
{
// Visual feedback that we are advertising.
HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );
}
break;

//if the state changed to connected, initially assume that keyfob is in range
case GAPROLE_CONNECTED:
{

GAPRole_GetParameter( GAPROLE_CONNHANDLE, &connHandle );

#if defined ( PLUS_BROADCASTER )
osal_start_timerEx( keyfobapp_TaskID, KFD_ADV_IN_CONNECTION_EVT, ADV_IN_CONN_WAIT );
#endif

// Turn off LED that shows we're advertising
HalLedSet( HAL_LED_2, HAL_LED_MODE_OFF );
}
break;

case GAPROLE_WAITING:
{
// Change attribute value of Accelerometer Enable to FALSE
Accel_SetParameter(ACCEL_ENABLER, sizeof(valFalse), &valFalse);
// Stop the acceleromter
accelEnablerChangeCB(); // SetParameter does not trigger the callback

// Turn off LED that shows we're advertising
HalLedSet( HAL_LED_2, HAL_LED_MODE_OFF );
}
break;

case GAPROLE_WAITING_AFTER_TIMEOUT:
{
// Change attribute value of Accelerometer Enable to FALSE
Accel_SetParameter(ACCEL_ENABLER, sizeof(valFalse), &valFalse);
// Stop the acceleromter
accelEnablerChangeCB(); // SetParameter does not trigger the callback
}
break;

default:
// do nothing
break;
}
}

gapProfileState = newState;
}

/*********************************************************************

* @fn accelEnablerChangeCB
*
* @brief Called by the Accelerometer Profile when the Enabler Attribute
* is changed.
*
* @param none
*
* @return none
*/
static void accelEnablerChangeCB( void )
{
bStatus_t status = Accel_GetParameter( ACCEL_ENABLER, &accelEnabler );

if (status == SUCCESS)
{
if (accelEnabler)
{
//Select accelerometer
//accelInit();
osal_start_timerEx( keyfobapp_TaskID, KFDA_ACCEL_READ_EVT, ACCEL_READ_PERIOD );
} else
{
accStop();
osal_stop_timerEx( keyfobapp_TaskID, KFDA_ACCEL_READ_EVT );
}
}
}

/*********************************************************************

*********************************************************************/