Hi,
I am using the cc2540 and the Mini DK.
I am trying to add a second accelerometer with the same part number as the one that is onboard and read from it using the other USART and some pins that are not used for anything else.
My first try was to read separately from the external accelerometer. And that is working fine.
Now what I want to do is add another enable for the second accelerometer and be able to read and control both.
Is there any simple way to do this?
Please could anybody tell me the main steps to achieve my goal?
What I have done until now is
1. Change cma3000d to include acc2init(), acc2ReadAcc(), acc2ReadReg() and acc2Write().
I am able to use these functions to configure the second usart and read from the other pins.
(working)
2. I have added
// Profile UUIDs
#define ACCEL2_ENABLER_UUID 0xFFA6
#define ACCEL2_RANGE_UUID 0xFFA7
#define ACCEL2_X_UUID 0xFFA8
#define ACCEL2_Y_UUID 0xFFA9
#define ACCEL2_Z_UUID 0xFFAA
// Accelerometer Service UUID
#define ACCEL2_SERVICE_UUID
With the idea of being able to access them with Btool.
3. In keyfobdemo.h/.c I have add accel2Read() and accel2EnableChangeCB() because they were calling acc2init, acc2ReadAcc.
I have added a new event to allow me to control both accelerometers separately.
#define KFD_START_DEVICE_EVT 0x0001
#define KFD_BATTERY_CHECK_EVT 0x0002
#define KFD_ACCEL_READ_EVT 0x0004
#define KFD_TOGGLE_BUZZER_EVT 0x0008
#define KFD_ADV_IN_CONNECTION_EVT 0x0010
#define KFD_ACCEL2_READ_EVT 0x0020
As I will have a second enable attribute on my profile I have added
// Accelerometer Profile Callbacks
static accelCBs_t keyFob_Accel2CBs =
{
accel2EnablerChangeCB, // Called when Enabler attribute changes
};
and do the following calls from keyfobdemo.c
// Start the Accelerometer Profile
VOID Accel_RegisterAppCBs( &keyFob_AccelCBs );
// Start the Accelerometer2 Profile
VOID Accel2_RegisterAppCBs( &keyFob_Accel2CBs );
4. In the accelerometer profile (accelerometer.c/.h) I have included the new attributes UUID on the attributes table and declare new
static profile Attributes variables.
// If an attribute changed then callback function to notify application of change
if ( (notify != 0xFF) && accel2_AppCBs && accel2_AppCBs->pfnAccelEnabler )
accel2_AppCBs->pfnAccelEnabler();
When I use BTool to access ACCEL2_ENABLER_UUID (0xFFA6) I am getting "success" as a response but anything else.
I am also confused with the utility of the services.. is that useful in the case of two accelerometers?
Any help will be greatly appreciated.