+
+#include "comdef.h"
+#include "OSAL_Memory.h"
+#include "OSAL_Timers.h"
+
+/*********************************************************************
+ * MACROS
+ */
+#if ( UINT_MAX == 65535 ) /* 8-bit and 16-bit devices */
+ #define osal_offsetof(type, member) ((uint16) &(((type *) 0)->member))
+#else /* 32-bit devices */
+ #define osal_offsetof(type, member) ((uint32) &(((type *) 0)->member))
+#endif
+
+#define OSAL_MSG_NEXT(msg_ptr) ((osal_msg_hdr_t *) (msg_ptr) - 1)->next
+
+#define OSAL_MSG_Q_INIT(q_ptr) *(q_ptr) = NULL
+
+#define OSAL_MSG_Q_EMPTY(q_ptr) (*(q_ptr) == NULL)
+
+#define OSAL_MSG_Q_HEAD(q_ptr) (*(q_ptr))
+
+#define OSAL_MSG_LEN(msg_ptr) ((osal_msg_hdr_t *) (msg_ptr) - 1)->len
+
+#define OSAL_MSG_ID(msg_ptr) ((osal_msg_hdr_t *) (msg_ptr) - 1)->dest_id
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*** Interrupts ***/
+#define INTS_ALL 0xFF
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+typedef struct
+{
+ void *next;
+ uint16 len;
+ uint8 dest_id;
+} osal_msg_hdr_t;
+
+typedef struct
+{
+ uint8 event;
+ uint8 status;
+} osal_event_hdr_t;
+
+typedef void * osal_msg_q_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*** Message Management ***/
+
+ /*
+ * Task Message Allocation
+ */
+ extern uint8 * osal_msg_allocate(uint16 len );
+
+ /*
+ * Task Message Deallocation
+ */
+ extern uint8 osal_msg_deallocate( uint8 *msg_ptr );
+
+ /*
+ * Send a Task Message
+ */
+ extern uint8 osal_msg_send( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern uint8 osal_msg_push_front( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Receive a Task Message
+ */
+ extern uint8 *osal_msg_receive( uint8 task_id );
+
+ /*
+ * Find in place a matching Task Message / Event.
+ */
+ extern osal_event_hdr_t *osal_msg_find(uint8 task_id, uint8 event);
+
+ /*
+ * Enqueue a Task Message
+ */
+ extern void osal_msg_enqueue( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Enqueue a Task Message Up to Max
+ */
+ extern uint8 osal_msg_enqueue_max( osal_msg_q_t *q_ptr, void *msg_ptr, uint8 max );
+
+ /*
+ * Dequeue a Task Message
+ */
+ extern void *osal_msg_dequeue( osal_msg_q_t *q_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern void osal_msg_push( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Extract and remove a Task Message from queue
+ */
+ extern void osal_msg_extract( osal_msg_q_t *q_ptr, void *msg_ptr, void *prev_ptr );
+
+
+/*** Task Synchronization ***/
+
+ /*
+ * Set a Task Event
+ */
+ extern uint8 osal_set_event( uint8 task_id, uint16 event_flag );
+
+
+ /*
+ * Clear a Task Event
+ */
+ extern uint8 osal_clear_event( uint8 task_id, uint16 event_flag );
+
+
+/*** Interrupt Management ***/
+
+ /*
+ * Register Interrupt Service Routine (ISR)
+ */
+ extern uint8 osal_isr_register( uint8 interrupt_id, void (*isr_ptr)( uint8* ) );
+
+ /*
+ * Enable Interrupt
+ */
+ extern uint8 osal_int_enable( uint8 interrupt_id );
+
+ /*
+ * Disable Interrupt
+ */
+ extern uint8 osal_int_disable( uint8 interrupt_id );
+
+
+/*** Task Management ***/
+
+ /*
+ * Initialize the Task System
+ */
+ extern uint8 osal_init_system( void );
+
+ /*
+ * System Processing Loop
+ */
+#if defined (ZBIT)
+ extern __declspec(dllexport) void osal_start_system( void );
+#else
+ extern void osal_start_system( void );
+#endif
+
+ /*
+ * One Pass Throu the OSAL Processing Loop
+ */
+ extern void osal_run_system( void );
+
+ /*
+ * Get the active task ID
+ */
+ extern uint8 osal_self( void );
+
+
+/*** Helper Functions ***/
+
+ /*
+ * String Length
+ */
+ extern int osal_strlen( char *pString );
+
+ /*
+ * Memory copy
+ */
+ extern void *osal_memcpy( void*, const void GENERIC *, unsigned int );
+
+ /*
+ * Memory Duplicate - allocates and copies
+ */
+ extern void *osal_memdup( const void GENERIC *src, unsigned int len );
+
+ /*
+ * Reverse Memory copy
+ */
+ extern void *osal_revmemcpy( void*, const void GENERIC *, unsigned int );
+
+ /*
+ * Memory compare
+ */
+ extern uint8 osal_memcmp( const void GENERIC *src1, const void GENERIC *src2, unsigned int len );
+
+ /*
+ * Memory set
+ */
+ extern void *osal_memset( void *dest, uint8 value, int len );
+
+ /*
+ * Build a uint16 out of 2 bytes (0 then 1).
+ */
+ extern uint16 osal_build_uint16( uint8 *swapped );
+
+ /*
+ * Build a uint32 out of sequential bytes.
+ */
+ extern uint32 osal_build_uint32( uint8 *swapped, uint8 len );
+
+ /*
+ * Convert long to ascii string
+ */
+ #if !defined ( ZBIT ) && !defined ( ZBIT2 ) && !defined (UBIT)
+ extern uint8 *_ltoa( uint32 l, uint8 * buf, uint8 radix );
+ #endif
+
+ /*
+ * Random number generator
+ */
+ extern uint16 osal_rand( void );
+
+ /*
+ * Buffer an uint32 value - LSB first.
+ */
+ extern uint8* osal_buffer_uint32( uint8 *buf, uint32 val );
+
+ /*
+ * Buffer an uint24 value - LSB first
+ */
+ extern uint8* osal_buffer_uint24( uint8 *buf, uint24 val );
+
+ /*
+ * Is all of the array elements set to a value?
+ */
+ extern uint8 osal_isbufset( uint8 *buf, uint8 val, uint8 len );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OSAL_H */
diff --git a/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Clock.h b/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Clock.h
new file mode 100644
index 0000000..09dce7a
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Clock.h
@@ -0,0 +1,139 @@
+/******************************************************************************
+ Filename: OSAL_Clock.h
+ Revised: $Date: 2012-02-02 12:55:32 -0800 (Thu, 02 Feb 2012) $
+ Revision: $Revision: 29143 $
+
+ Description: OSAL Clock definition and manipulation functions.
+
+
+ Copyright 2004-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+******************************************************************************/
+
+#ifndef OSAL_CLOCK_H
+#define OSAL_CLOCK_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+#define IsLeapYear(yr) (!((yr) % 400) || (((yr) % 100) && !((yr) % 4)))
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// number of seconds since 0 hrs, 0 minutes, 0 seconds, on the
+// 1st of January 2000 UTC
+typedef uint32 UTCTime;
+
+// To be used with
+typedef struct
+{
+ uint8 seconds; // 0-59
+ uint8 minutes; // 0-59
+ uint8 hour; // 0-23
+ uint8 day; // 0-30
+ uint8 month; // 0-11
+ uint16 year; // 2000+
+} UTCTimeStruct;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Updates the OSAL clock and Timers from the MAC 320us timer tick.
+ */
+ extern void osalTimeUpdate( void );
+
+ /*
+ * Set the new time. This will only set the seconds portion
+ * of time and doesn't change the factional second counter.
+ * newTime - number of seconds since 0 hrs, 0 minutes,
+ * 0 seconds, on the 1st of January 2000 UTC
+ */
+ extern void osal_setClock( UTCTime newTime );
+
+ /*
+ * Gets the current time. This will only return the seconds
+ * portion of time and doesn't include the factional second counter.
+ * returns: number of seconds since 0 hrs, 0 minutes,
+ * 0 seconds, on the 1st of January 2000 UTC
+ */
+ extern UTCTime osal_getClock( void );
+
+ /*
+ * Converts UTCTime to UTCTimeStruct
+ *
+ * secTime - number of seconds since 0 hrs, 0 minutes,
+ * 0 seconds, on the 1st of January 2000 UTC
+ * tm - pointer to breakdown struct
+ */
+ extern void osal_ConvertUTCTime( UTCTimeStruct *tm, UTCTime secTime );
+
+ /*
+ * Converts UTCTimeStruct to UTCTime (seconds since 00:00:00 01/01/2000)
+ *
+ * tm - pointer to UTC time struct
+ */
+ extern UTCTime osal_ConvertUTCSecs( UTCTimeStruct *tm );
+
+ /*
+ * Update/Adjust the osal clock and timers
+ * Msec - elapsed time in milli seconds
+ */
+ extern void osalAdjustTimer( uint32 Msec );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OSAL_CLOCK_H */
diff --git a/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Memory.h b/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Memory.h
new file mode 100644
index 0000000..c8984dd
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Memory.h
@@ -0,0 +1,145 @@
+/**************************************************************************************************
+ Filename: OSAL_Memory.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: This module defines the OSAL memory control functions.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef OSAL_MEMORY_H
+#define OSAL_MEMORY_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "comdef.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+#if !defined ( OSALMEM_METRICS )
+ #define OSALMEM_METRICS FALSE
+#endif
+
+/*********************************************************************
+ * MACROS
+ */
+
+#define osal_stack_used() OnBoard_stack_used()
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialize memory manager.
+ */
+ void osal_mem_init( void );
+
+ /*
+ * Setup efficient search for the first free block of heap.
+ */
+ void osal_mem_kick( void );
+
+ /*
+ * Allocate a block of memory.
+ */
+#ifdef DPRINTF_OSALHEAPTRACE
+ void *osal_mem_alloc_dbg( uint16 size, const char *fname, unsigned lnum );
+#define osal_mem_alloc(_size ) osal_mem_alloc_dbg(_size, __FILE__, __LINE__)
+#else /* DPRINTF_OSALHEAPTRACE */
+ void *osal_mem_alloc( uint16 size );
+#endif /* DPRINTF_OSALHEAPTRACE */
+
+ /*
+ * Free a block of memory.
+ */
+#ifdef DPRINTF_OSALHEAPTRACE
+ void osal_mem_free_dbg( void *ptr, const char *fname, unsigned lnum );
+#define osal_mem_free(_ptr ) osal_mem_free_dbg(_ptr, __FILE__, __LINE__)
+#else /* DPRINTF_OSALHEAPTRACE */
+ void osal_mem_free( void *ptr );
+#endif /* DPRINTF_OSALHEAPTRACE */
+
+#if ( OSALMEM_METRICS )
+ /*
+ * Return the maximum number of blocks ever allocated at once.
+ */
+ uint16 osal_heap_block_max( void );
+
+ /*
+ * Return the current number of blocks now allocated.
+ */
+ uint16 osal_heap_block_cnt( void );
+
+ /*
+ * Return the current number of free blocks.
+ */
+ uint16 osal_heap_block_free( void );
+
+ /*
+ * Return the current number of bytes allocated.
+ */
+ uint16 osal_heap_mem_used( void );
+#endif
+
+#if defined (ZTOOL_P1) || defined (ZTOOL_P2)
+ /*
+ * Return the highest number of bytes ever used in the heap.
+ */
+ uint16 osal_heap_high_water( void );
+#endif
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef OSAL_MEMORY_H */
diff --git a/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Nv.h b/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Nv.h
new file mode 100644
index 0000000..5532ac8
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Nv.h
@@ -0,0 +1,111 @@
+/**************************************************************************************************
+ Filename: OSAL_Nv.h
+ Revised: $Date: 2011-05-31 09:28:05 -0700 (Tue, 31 May 2011) $
+ Revision: $Revision: 26152 $
+
+ Description: This module defines the OSAL non-volatile memory functions.
+
+
+ Copyright 2004-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef OSAL_NV_H
+#define OSAL_NV_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#include "hal_types.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Initialize NV service
+ */
+extern void osal_nv_init( void *p );
+
+/*
+ * Initialize an item in NV
+ */
+extern uint8 osal_nv_item_init( uint16 id, uint16 len, void *buf );
+
+/*
+ * Read an NV attribute
+ */
+extern uint8 osal_nv_read( uint16 id, uint16 offset, uint16 len, void *buf );
+
+/*
+ * Write an NV attribute
+ */
+extern uint8 osal_nv_write( uint16 id, uint16 offset, uint16 len, void *buf );
+
+/*
+ * Get the length of an NV item.
+ */
+extern uint16 osal_nv_item_len( uint16 id );
+
+/*
+ * Delete an NV item.
+ */
+extern uint8 osal_nv_delete( uint16 id, uint16 len );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OSAL_NV.H */
diff --git a/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_PwrMgr.h b/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_PwrMgr.h
new file mode 100644
index 0000000..cdbaaf9
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_PwrMgr.h
@@ -0,0 +1,139 @@
+/**************************************************************************************************
+ Filename: OSAL_PwrMgr.h
+ Revised: $Date: 2007-10-28 18:41:49 -0700 (Sun, 28 Oct 2007) $
+ Revision: $Revision: 15799 $
+
+ Description: This file contains the OSAL Power Management API.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef OSAL_PWRMGR_H
+#define OSAL_PWRMGR_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/* These attributes define sleep beheaver. The attributes can be changed
+ * for each sleep cycle or when the device characteristic change.
+ */
+typedef struct
+{
+ uint16 pwrmgr_task_state;
+ uint16 pwrmgr_next_timeout;
+ uint16 accumulated_sleep_time;
+ uint8 pwrmgr_device;
+} pwrmgr_attribute_t;
+
+/* With PWRMGR_ALWAYS_ON selection, there is no power savings and the
+ * device is most likely on mains power. The PWRMGR_BATTERY selection allows
+ * the HAL sleep manager to enter SLEEP LITE state or SLEEP DEEP state.
+ */
+#define PWRMGR_ALWAYS_ON 0
+#define PWRMGR_BATTERY 1
+
+/* The PWRMGR_CONSERVE selection turns power savings on, all tasks have to
+ * agree. The PWRMGR_HOLD selection turns power savings off.
+ */
+#define PWRMGR_CONSERVE 0
+#define PWRMGR_HOLD 1
+
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/* This global variable stores the power management attributes.
+ */
+extern pwrmgr_attribute_t pwrmgr_attribute;
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialize the power management system.
+ * This function is called from OSAL.
+ *
+ */
+ extern void osal_pwrmgr_init( void );
+
+ /*
+ * This function is called by each task to state whether or not this
+ * task wants to conserve power. The task will call this function to
+ * vote whether it wants the OSAL to conserve power or it wants to
+ * hold off on the power savings. By default, when a task is created,
+ * its own power state is set to conserve. If the task always wants
+ * to converse power, it doesn't need to call this function at all.
+ * It is important for the task that changed the power manager task
+ * state to PWRMGR_HOLD to switch back to PWRMGR_CONSERVE when the
+ * hold period ends.
+ */
+ extern uint8 osal_pwrmgr_task_state( uint8 task_id, uint8 state );
+
+ /*
+ * This function is called on power-up, whenever the device characteristic
+ * change (ex. Battery backed coordinator). This function works with the timer
+ * to set HAL's power manager sleep state when power saving is entered.
+ * This function should be called form HAL initialization. After power up
+ * initialization, it should only be called from NWK or ZDO.
+ */
+ extern void osal_pwrmgr_device( uint8 pwrmgr_device );
+
+ /*
+ * This function is called from the main OSAL loop when there are
+ * no events scheduled and shouldn't be called from anywhere else.
+ */
+ extern void osal_pwrmgr_powerconserve( void );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OSAL_PWRMGR_H */
diff --git a/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Tasks.h b/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Tasks.h
new file mode 100644
index 0000000..ac0beaf
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Tasks.h
@@ -0,0 +1,94 @@
+/**************************************************************************************************
+ Filename: OSAL_Tasks.h
+ Revised: $Date: 2007-10-28 18:41:49 -0700 (Sun, 28 Oct 2007) $
+ Revision: $Revision: 15799 $
+
+ Description: This file contains the OSAL Task definition and manipulation functions.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef OSAL_TASKS_H
+#define OSAL_TASKS_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+#define TASK_NO_TASK 0xFF
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*
+ * Event handler function prototype
+ */
+typedef unsigned short (*pTaskEventHandlerFn)( unsigned char task_id, unsigned short event );
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+extern const pTaskEventHandlerFn tasksArr[];
+extern const uint8 tasksCnt;
+extern uint16 *tasksEvents;
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Call each of the tasks initailization functions.
+ */
+extern void osalInitTasks( void );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OSAL_TASKS_H */
diff --git a/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Timers.h b/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Timers.h
new file mode 100644
index 0000000..d4de494
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/osal/include/OSAL_Timers.h
@@ -0,0 +1,146 @@
+/**************************************************************************************************
+ Filename: OSAL_Timers.h
+ Revised: $Date: 2011-09-16 19:09:24 -0700 (Fri, 16 Sep 2011) $
+ Revision: $Revision: 27618 $
+
+ Description: This file contains the OSAL Timer definition and manipulation functions.
+
+
+ Copyright 2004-2009 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef OSAL_TIMERS_H
+#define OSAL_TIMERS_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ * the unit is chosen such that the 320us tick equivalent can fit in
+ * 32 bits.
+ */
+ #define OSAL_TIMERS_MAX_TIMEOUT 0x28f5c28e /* unit is ms*/
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialization for the OSAL Timer System.
+ */
+ extern void osalTimerInit( void );
+
+ /*
+ * Set a Timer
+ */
+ extern uint8 osal_start_timerEx( uint8 task_id, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Set a timer that reloads itself.
+ */
+ extern uint8 osal_start_reload_timer( uint8 taskID, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Stop a Timer
+ */
+ extern uint8 osal_stop_timerEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Get the tick count of a Timer.
+ */
+ extern uint32 osal_get_timeoutEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Simulated Timer Interrupt Service Routine
+ */
+
+ extern void osal_timer_ISR( void );
+
+ /*
+ * Adjust timer tables
+ */
+ extern void osal_adjust_timers( void );
+
+ /*
+ * Update timer tables
+ */
+ extern void osalTimerUpdate( uint32 updateTime );
+
+ /*
+ * Count active timers
+ */
+ extern uint8 osal_timer_num_active( void );
+
+ /*
+ * Set the hardware timer interrupts for sleep mode.
+ * These functions should only be called in OSAL_PwrMgr.c
+ */
+ extern void osal_sleep_timers( void );
+ extern void osal_unsleep_timers( void );
+
+ /*
+ * Read the system clock - returns milliseconds
+ */
+ extern uint32 osal_GetSystemClock( void );
+
+ /*
+ * Get the next OSAL timer expiration.
+ * This function should only be called in OSAL_PwrMgr.c
+ */
+ extern uint32 osal_next_timeout( void );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OSAL_TIMERS_H */
diff --git a/Firmware/Radio/Projects/Wimu/Components/osal/include/ZComDef.h b/Firmware/Radio/Projects/Wimu/Components/osal/include/ZComDef.h
new file mode 100644
index 0000000..05f4692
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/osal/include/ZComDef.h
@@ -0,0 +1,439 @@
+/**************************************************************************************************
+ Filename: ZComDef.h
+ Revised: $Date: 2012-12-07 12:34:45 -0800 (Fri, 07 Dec 2012) $
+ Revision: $Revision: 32490 $
+
+ Description: Type definitions and macros.
+
+
+ Copyright 2004-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef ZCOMDEF_H
+#define ZCOMDEF_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "comdef.h"
+#include "saddr.h"
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+#define osal_cpyExtAddr(a, b) sAddrExtCpy((a), (const uint8 *)(b))
+#define osal_ExtAddrEqual(a, b) sAddrExtCmp((const uint8 *)(a), (const uint8 *)(b))
+#define osal_copyAddress(a, b) sAddrCpy( (sAddr_t *)(a), (const sAddr_t *)(b) )
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Build Device Types - Used during compilation
+// These are the types of devices to build
+// Bit masked into ZSTACK_DEVICE_BUILD
+#define DEVICE_BUILD_COORDINATOR 0x01
+#define DEVICE_BUILD_ROUTER 0x02
+#define DEVICE_BUILD_ENDDEVICE 0x04
+
+/*** Return Values ***/
+#define ZSUCCESS SUCCESS
+
+/*** Component IDs ***/
+#define COMPID_OSAL 0
+#define COMPID_MTEL 1
+#define COMPID_MTSPCI 2
+#define COMPID_NWK 3
+#define COMPID_NWKIF 4
+#define COMPID_MACCB 5
+#define COMPID_MAC 6
+#define COMPID_APP 7
+#define COMPID_TEST 8
+
+#define COMPID_RTG 9
+#define COMPID_DATA 11
+
+/* Temp CompIDs for testing */
+#define COMPID_TEST_NWK_STARTUP 20
+#define COMPID_TEST_SCAN_CONFIRM 21
+#define COMPID_TEST_ASSOC_CONFIRM 22
+#define COMPID_TEST_REMOTE_DATA_CONFIRM 23
+
+// OSAL NV item IDs
+#define ZCD_NV_EXTADDR 0x0001
+#define ZCD_NV_BOOTCOUNTER 0x0002
+#define ZCD_NV_STARTUP_OPTION 0x0003
+#define ZCD_NV_START_DELAY 0x0004
+
+// NWK Layer NV item IDs
+#define ZCD_NV_NIB 0x0021
+#define ZCD_NV_DEVICE_LIST 0x0022
+#define ZCD_NV_ADDRMGR 0x0023
+#define ZCD_NV_POLL_RATE 0x0024
+#define ZCD_NV_QUEUED_POLL_RATE 0x0025
+#define ZCD_NV_RESPONSE_POLL_RATE 0x0026
+#define ZCD_NV_REJOIN_POLL_RATE 0x0027
+#define ZCD_NV_DATA_RETRIES 0x0028
+#define ZCD_NV_POLL_FAILURE_RETRIES 0x0029
+#define ZCD_NV_STACK_PROFILE 0x002A
+#define ZCD_NV_INDIRECT_MSG_TIMEOUT 0x002B
+#define ZCD_NV_ROUTE_EXPIRY_TIME 0x002C
+#define ZCD_NV_EXTENDED_PAN_ID 0x002D
+#define ZCD_NV_BCAST_RETRIES 0x002E
+#define ZCD_NV_PASSIVE_ACK_TIMEOUT 0x002F
+#define ZCD_NV_BCAST_DELIVERY_TIME 0x0030
+#define ZCD_NV_NWK_MODE 0x0031
+#define ZCD_NV_CONCENTRATOR_ENABLE 0x0032
+#define ZCD_NV_CONCENTRATOR_DISCOVERY 0x0033
+#define ZCD_NV_CONCENTRATOR_RADIUS 0x0034
+#define ZCD_NV_CONCENTRATOR_RC 0x0036
+#define ZCD_NV_NWK_MGR_MODE 0x0037
+#define ZCD_NV_SRC_RTG_EXPIRY_TIME 0x0038
+#define ZCD_NV_ROUTE_DISCOVERY_TIME 0x0039
+#define ZCD_NV_NWK_ACTIVE_KEY_INFO 0x003A
+#define ZCD_NV_NWK_ALTERN_KEY_INFO 0x003B
+#define ZCD_NV_ROUTER_OFF_ASSOC_CLEANUP 0x003C
+#define ZCD_NV_NWK_LEAVE_REQ_ALLOWED 0x003D
+#define ZCD_NV_NWK_CHILD_AGE_ENABLE 0x003E
+#define ZCD_NV_DEVICE_LIST_KA_TIMEOUT 0x003F
+
+// APS Layer NV item IDs
+#define ZCD_NV_BINDING_TABLE 0x0041
+#define ZCD_NV_GROUP_TABLE 0x0042
+#define ZCD_NV_APS_FRAME_RETRIES 0x0043
+#define ZCD_NV_APS_ACK_WAIT_DURATION 0x0044
+#define ZCD_NV_APS_ACK_WAIT_MULTIPLIER 0x0045
+#define ZCD_NV_BINDING_TIME 0x0046
+#define ZCD_NV_APS_USE_EXT_PANID 0x0047
+#define ZCD_NV_APS_USE_INSECURE_JOIN 0x0048
+#define ZCD_NV_COMMISSIONED_NWK_ADDR 0x0049
+
+#define ZCD_NV_APS_NONMEMBER_RADIUS 0x004B // Multicast non_member radius
+#define ZCD_NV_APS_LINK_KEY_TABLE 0x004C
+#define ZCD_NV_APS_DUPREJ_TIMEOUT_INC 0x004D
+#define ZCD_NV_APS_DUPREJ_TIMEOUT_COUNT 0x004E
+#define ZCD_NV_APS_DUPREJ_TABLE_SIZE 0x004F
+
+// Security NV Item IDs
+#define ZCD_NV_SECURITY_LEVEL 0x0061
+#define ZCD_NV_PRECFGKEY 0x0062
+#define ZCD_NV_PRECFGKEYS_ENABLE 0x0063
+#define ZCD_NV_SECURITY_MODE 0x0064
+#define ZCD_NV_SECURE_PERMIT_JOIN 0x0065
+#define ZCD_NV_APS_LINK_KEY_TYPE 0x0066
+#define ZCD_NV_APS_ALLOW_R19_SECURITY 0x0067
+
+#define ZCD_NV_IMPLICIT_CERTIFICATE 0x0069
+#define ZCD_NV_DEVICE_PRIVATE_KEY 0x006A
+#define ZCD_NV_CA_PUBLIC_KEY 0x006B
+
+#define ZCD_NV_USE_DEFAULT_TCLK 0x006D
+#define ZCD_NV_TRUSTCENTER_ADDR 0x006E
+#define ZCD_NV_RNG_COUNTER 0x006F
+#define ZCD_NV_RANDOM_SEED 0x0070
+
+// ZDO NV Item IDs
+#define ZCD_NV_USERDESC 0x0081
+#define ZCD_NV_NWKKEY 0x0082
+#define ZCD_NV_PANID 0x0083
+#define ZCD_NV_CHANLIST 0x0084
+#define ZCD_NV_LEAVE_CTRL 0x0085
+#define ZCD_NV_SCAN_DURATION 0x0086
+#define ZCD_NV_LOGICAL_TYPE 0x0087
+#define ZCD_NV_NWKMGR_MIN_TX 0x0088
+#define ZCD_NV_NWKMGR_ADDR 0x0089
+
+#define ZCD_NV_ZDO_DIRECT_CB 0x008F
+
+// ZCL NV item IDs
+#define ZCD_NV_SCENE_TABLE 0x0091
+#define ZCD_NV_MIN_FREE_NWK_ADDR 0x0092
+#define ZCD_NV_MAX_FREE_NWK_ADDR 0x0093
+#define ZCD_NV_MIN_FREE_GRP_ID 0x0094
+#define ZCD_NV_MAX_FREE_GRP_ID 0x0095
+#define ZCD_NV_MIN_GRP_IDS 0x0096
+#define ZCD_NV_MAX_GRP_IDS 0x0097
+
+// Non-standard NV item IDs
+#define ZCD_NV_SAPI_ENDPOINT 0x00A1
+
+// NV Items Reserved for Commissioning Cluster Startup Attribute Set (SAS):
+// 0x00B1 - 0x00BF: Parameters related to APS and NWK layers
+// 0x00C1 - 0x00CF: Parameters related to Security
+// 0x00D1 - 0x00DF: Current key parameters
+#define ZCD_NV_SAS_SHORT_ADDR 0x00B1
+#define ZCD_NV_SAS_EXT_PANID 0x00B2
+#define ZCD_NV_SAS_PANID 0x00B3
+#define ZCD_NV_SAS_CHANNEL_MASK 0x00B4
+#define ZCD_NV_SAS_PROTOCOL_VER 0x00B5
+#define ZCD_NV_SAS_STACK_PROFILE 0x00B6
+#define ZCD_NV_SAS_STARTUP_CTRL 0x00B7
+
+#define ZCD_NV_SAS_TC_ADDR 0x00C1
+#define ZCD_NV_SAS_TC_MASTER_KEY 0x00C2
+#define ZCD_NV_SAS_NWK_KEY 0x00C3
+#define ZCD_NV_SAS_USE_INSEC_JOIN 0x00C4
+#define ZCD_NV_SAS_PRECFG_LINK_KEY 0x00C5
+#define ZCD_NV_SAS_NWK_KEY_SEQ_NUM 0x00C6
+#define ZCD_NV_SAS_NWK_KEY_TYPE 0x00C7
+#define ZCD_NV_SAS_NWK_MGR_ADDR 0x00C8
+
+#define ZCD_NV_SAS_CURR_TC_MASTER_KEY 0x00D1
+#define ZCD_NV_SAS_CURR_NWK_KEY 0x00D2
+#define ZCD_NV_SAS_CURR_PRECFG_LINK_KEY 0x00D3
+
+// NV Items Reserved for Trust Center Link Key Table entries
+// 0x0101 - 0x01FF
+#define ZCD_NV_TCLK_TABLE_START 0x0101
+#define ZCD_NV_TCLK_TABLE_END 0x01FF
+
+// NV Items Reserved for APS Link Key Table entries
+// 0x0201 - 0x02FF
+#define ZCD_NV_APS_LINK_KEY_DATA_START 0x0201 // APS key data
+#define ZCD_NV_APS_LINK_KEY_DATA_END 0x02FF
+
+// NV Items Reserved for Master Key Table entries
+// 0x0301 - 0x03FF
+#define ZCD_NV_MASTER_KEY_DATA_START 0x0301 // Master key data
+#define ZCD_NV_MASTER_KEY_DATA_END 0x03FF
+
+// NV Items Reserved for applications (user applications)
+// 0x0401 – 0x0FFF
+
+
+// ZCD_NV_STARTUP_OPTION values
+// These are bit weighted - you can OR these together.
+// Setting one of these bits will set their associated NV items
+// to code initialized values.
+#define ZCD_STARTOPT_DEFAULT_CONFIG_STATE 0x01
+#define ZCD_STARTOPT_DEFAULT_NETWORK_STATE 0x02
+#define ZCD_STARTOPT_AUTO_START 0x04
+#define ZCD_STARTOPT_CLEAR_CONFIG ZCD_STARTOPT_DEFAULT_CONFIG_STATE
+#define ZCD_STARTOPT_CLEAR_STATE ZCD_STARTOPT_DEFAULT_NETWORK_STATE
+
+
+#define ZCL_KE_IMPLICIT_CERTIFICATE_LEN 48
+#define ZCL_KE_CA_PUBLIC_KEY_LEN 22
+#define ZCL_KE_DEVICE_PRIVATE_KEY_LEN 21
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*** Data Types ***/
+typedef uint8 byte;
+typedef uint16 UINT16;
+typedef int16 INT16;
+
+enum
+{
+ AddrNotPresent = 0,
+ AddrGroup = 1,
+ Addr16Bit = 2,
+ Addr64Bit = 3,
+ AddrBroadcast = 15
+};
+
+#define Z_EXTADDR_LEN 8
+
+typedef byte ZLongAddr_t[Z_EXTADDR_LEN];
+
+typedef struct
+{
+ union
+ {
+ uint16 shortAddr;
+ ZLongAddr_t extAddr;
+ } addr;
+ byte addrMode;
+} zAddrType_t;
+
+// Redefined Generic Status Return Values for code backwards compatibility
+#define ZSuccess SUCCESS
+#define ZFailure FAILURE
+#define ZInvalidParameter INVALIDPARAMETER
+
+// ZStack status values must start at 0x10, after the generic status values (defined in comdef.h)
+#define ZMemError 0x10
+#define ZBufferFull 0x11
+#define ZUnsupportedMode 0x12
+#define ZMacMemError 0x13
+
+#define ZSapiInProgress 0x20
+#define ZSapiTimeout 0x21
+#define ZSapiInit 0x22
+
+#define ZNotAuthorized 0x7E
+
+#define ZMalformedCmd 0x80
+#define ZUnsupClusterCmd 0x81
+
+// OTA Status values
+#define ZOtaAbort 0x95
+#define ZOtaImageInvalid 0x96
+#define ZOtaWaitForData 0x97
+#define ZOtaNoImageAvailable 0x98
+#define ZOtaRequireMoreImage 0x99
+
+// APS status values
+#define ZApsFail 0xb1
+#define ZApsTableFull 0xb2
+#define ZApsIllegalRequest 0xb3
+#define ZApsInvalidBinding 0xb4
+#define ZApsUnsupportedAttrib 0xb5
+#define ZApsNotSupported 0xb6
+#define ZApsNoAck 0xb7
+#define ZApsDuplicateEntry 0xb8
+#define ZApsNoBoundDevice 0xb9
+#define ZApsNotAllowed 0xba
+#define ZApsNotAuthenticated 0xbb
+
+ // Security status values
+#define ZSecNoKey 0xa1
+#define ZSecOldFrmCount 0xa2
+#define ZSecMaxFrmCount 0xa3
+#define ZSecCcmFail 0xa4
+
+ // NWK status values
+#define ZNwkInvalidParam 0xc1
+#define ZNwkInvalidRequest 0xc2
+#define ZNwkNotPermitted 0xc3
+#define ZNwkStartupFailure 0xc4
+#define ZNwkAlreadyPresent 0xc5
+#define ZNwkSyncFailure 0xc6
+#define ZNwkTableFull 0xc7
+#define ZNwkUnknownDevice 0xc8
+#define ZNwkUnsupportedAttribute 0xc9
+#define ZNwkNoNetworks 0xca
+#define ZNwkLeaveUnconfirmed 0xcb
+#define ZNwkNoAck 0xcc // not in spec
+#define ZNwkNoRoute 0xcd
+
+ // MAC status values
+#define ZMacSuccess 0x00
+#define ZMacBeaconLoss 0xe0
+#define ZMacChannelAccessFailure 0xe1
+#define ZMacDenied 0xe2
+#define ZMacDisableTrxFailure 0xe3
+#define ZMacFailedSecurityCheck 0xe4
+#define ZMacFrameTooLong 0xe5
+#define ZMacInvalidGTS 0xe6
+#define ZMacInvalidHandle 0xe7
+#define ZMacInvalidParameter 0xe8
+#define ZMacNoACK 0xe9
+#define ZMacNoBeacon 0xea
+#define ZMacNoData 0xeb
+#define ZMacNoShortAddr 0xec
+#define ZMacOutOfCap 0xed
+#define ZMacPANIDConflict 0xee
+#define ZMacRealignment 0xef
+#define ZMacTransactionExpired 0xf0
+#define ZMacTransactionOverFlow 0xf1
+#define ZMacTxActive 0xf2
+#define ZMacUnAvailableKey 0xf3
+#define ZMacUnsupportedAttribute 0xf4
+#define ZMacUnsupported 0xf5
+#define ZMacSrcMatchInvalidIndex 0xff
+
+typedef Status_t ZStatus_t;
+
+typedef struct
+{
+ uint8 txCounter; // Counter of transmission success/failures
+ uint8 txCost; // Average of sending rssi values if link staus is enabled
+ // i.e. NWK_LINK_STATUS_PERIOD is defined as non zero
+ uint8 rxLqi; // average of received rssi values
+ // needs to be converted to link cost (1-7) before used
+ uint8 inKeySeqNum; // security key sequence number
+ uint32 inFrmCntr; // security frame counter..
+ uint16 txFailure; // higher values indicate more failures
+} linkInfo_t;
+
+/*********************************************************************
+ * Global System Messages
+ */
+
+#define SPI_INCOMING_ZTOOL_PORT 0x21 // Raw data from ZTool Port (not implemented)
+#define SPI_INCOMING_ZAPP_DATA 0x22 // Raw data from the ZAPP port (see serialApp.c)
+#define MT_SYS_APP_MSG 0x23 // Raw data from an MT Sys message
+#define MT_SYS_APP_RSP_MSG 0x24 // Raw data output for an MT Sys message
+#define MT_SYS_OTA_MSG 0x25 // Raw data output for an MT OTA Rsp
+
+#define AF_DATA_CONFIRM_CMD 0xFD // Data confirmation
+#define AF_REFLECT_ERROR_CMD 0xFE // Reflected message error message
+#define AF_INCOMING_MSG_CMD 0x1A // Incoming MSG type message
+#define AF_INCOMING_KVP_CMD 0x1B // Incoming KVP type message
+#define AF_INCOMING_GRP_KVP_CMD 0x1C // Incoming Group KVP type message
+
+//#define KEY_CHANGE 0xC0 // Key Events
+
+#define ZDO_NEW_DSTADDR 0xD0 // ZDO has received a new DstAddr for this app
+#define ZDO_STATE_CHANGE 0xD1 // ZDO has changed the device's network state
+#define ZDO_MATCH_DESC_RSP_SENT 0xD2 // ZDO match descriptor response was sent
+#define ZDO_CB_MSG 0xD3 // ZDO incoming message callback
+#define ZDO_NETWORK_REPORT 0xD4 // ZDO received a Network Report message
+#define ZDO_NETWORK_UPDATE 0xD5 // ZDO received a Network Update message
+#define ZDO_ADDR_CHANGE_IND 0xD6 // ZDO was informed of device address change
+
+#define NM_CHANNEL_INTERFERE 0x31 // NwkMgr received a Channel Interference message
+#define NM_ED_SCAN_CONFIRM 0x32 // NwkMgr received an ED Scan Confirm message
+#define SAPS_CHANNEL_CHANGE 0x33 // Stub APS has changed the device's channel
+#define ZCL_INCOMING_MSG 0x34 // Incoming ZCL foundation message
+#define ZCL_KEY_ESTABLISH_IND 0x35 // ZCL Key Establishment Completion Indication
+#define ZCL_OTA_CALLBACK_IND 0x36 // ZCL OTA Completion Indication
+
+
+// OSAL System Message IDs/Events Reserved for applications (user applications)
+// 0xE0 – 0xFC
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ZCOMDEF_H */
diff --git a/Firmware/Radio/Projects/Wimu/Components/osal/include/comdef.h b/Firmware/Radio/Projects/Wimu/Components/osal/include/comdef.h
new file mode 100644
index 0000000..2337966
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/osal/include/comdef.h
@@ -0,0 +1,153 @@
+/**************************************************************************************************
+ Filename: comdef.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: Type definitions and macros.
+
+
+ Copyright 2004-2008 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef COMDEF_H
+#define COMDEF_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/* HAL */
+#include "hal_types.h"
+#include "hal_defs.h"
+
+/*********************************************************************
+ * Lint Keywords
+ */
+#define VOID (void)
+
+#define NULL_OK
+#define INP
+#define OUTP
+#define UNUSED
+#define ONLY
+#define READONLY
+#define SHARED
+#define KEEP
+#define RELAX
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+#ifndef false
+ #define false 0
+#endif
+
+#ifndef true
+ #define true 1
+#endif
+
+#ifndef CONST
+ #define CONST const
+#endif
+
+#ifndef GENERIC
+ #define GENERIC
+#endif
+
+/*** Generic Status Return Values ***/
+#define SUCCESS 0x00
+#define FAILURE 0x01
+#define INVALIDPARAMETER 0x02
+#define INVALID_TASK 0x03
+#define MSG_BUFFER_NOT_AVAIL 0x04
+#define INVALID_MSG_POINTER 0x05
+#define INVALID_EVENT_ID 0x06
+#define INVALID_INTERRUPT_ID 0x07
+#define NO_TIMER_AVAIL 0x08
+#define NV_ITEM_UNINIT 0x09
+#define NV_OPER_FAILED 0x0A
+#define INVALID_MEM_SIZE 0x0B
+#define NV_BAD_ITEM_LEN 0x0C
+#define INVALID_DATA_FRAME 0x0D
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Generic Status return
+typedef uint8 Status_t;
+
+// Data types
+typedef int32 int24;
+typedef uint32 uint24;
+
+/*********************************************************************
+ * Global System Events
+ */
+
+#define SYS_EVENT_MSG 0x8000 // A message is waiting event
+
+/*********************************************************************
+ * Global Generic System Messages
+ */
+
+#define KEY_CHANGE 0xC0 // Key Events
+
+// OSAL System Message IDs/Events Reserved for applications (user applications)
+// 0xE0 – 0xFC
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* COMDEF_H */
diff --git a/Firmware/Radio/Projects/Wimu/Components/osal/include/osal_bufmgr.h b/Firmware/Radio/Projects/Wimu/Components/osal/include/osal_bufmgr.h
new file mode 100644
index 0000000..fc6331e
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/osal/include/osal_bufmgr.h
@@ -0,0 +1,107 @@
+/**************************************************************************************************
+ Filename: osal_bufmgr.h
+ Revised: $Date: 2009-01-14 14:59:55 -0800 (Wed, 14 Jan 2009) $
+ Revision: $Revision: 18763 $
+
+ Description: This file contains the buffer management definitions.
+
+
+ Copyright 2008 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef OSAL_BUFMGR_H
+#define OSAL_BUFMGR_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Allocate a block of memory.
+ */
+extern void *osal_bm_alloc( uint16 size );
+
+/*
+ * Add or remove header space for the payload pointer.
+ */
+extern void *osal_bm_adjust_header( void *payload_ptr, int16 size );
+
+/*
+ * Add or remove tail space for the payload pointer.
+ */
+extern void *osal_bm_adjust_tail( void *payload_ptr, int16 size );
+
+/*
+ * Free a block of memory.
+ */
+extern void osal_bm_free( void *payload_ptr );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OSAL_BUFMGR_H */
diff --git a/Firmware/Radio/Projects/Wimu/Components/osal/include/osal_cbtimer.h b/Firmware/Radio/Projects/Wimu/Components/osal/include/osal_cbtimer.h
new file mode 100644
index 0000000..73bf724
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/osal/include/osal_cbtimer.h
@@ -0,0 +1,130 @@
+/**************************************************************************************************
+ Filename: osal_cbtimer.h
+ Revised: $Date: 2009-01-29 09:58:32 -0800 (Thu, 29 Jan 2009) $
+ Revision: $Revision: 18882 $
+
+ Description: This file contains the Callback Timer definitions.
+
+
+ Copyright 2008-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef OSAL_CBTIMER_H
+#define OSAL_CBTIMER_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+// Invalid timer id
+#define INVALID_TIMER_ID 0xFF
+
+// Timed out timer
+#define TIMEOUT_TIMER_ID 0xFE
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+#if ( OSAL_CBTIMER_NUM_TASKS == 0 )
+ #error Callback Timer module shouldn't be included (no callback timer is needed)!
+#elif ( OSAL_CBTIMER_NUM_TASKS == 1 )
+ #define OSAL_CBTIMER_PROCESS_EVENT( a ) ( a )
+#elif ( OSAL_CBTIMER_NUM_TASKS == 2 )
+ #define OSAL_CBTIMER_PROCESS_EVENT( a ) ( a ), ( a )
+#else
+ #error Maximum of 2 callback timer tasks are supported! Modify it here.
+#endif
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Callback Timer function prototype. Callback function will be called
+// when the associated timer expires.
+//
+// pData - pointer to data registered with timer
+//
+typedef void (*pfnCbTimer_t)( uint8 *pData );
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Callback Timer task initialization function.
+ */
+extern void osal_CbTimerInit( uint8 taskId );
+
+/*
+ * Callback Timer task event processing function.
+ */
+extern uint16 osal_CbTimerProcessEvent( uint8 taskId, uint16 events );
+
+/*
+ * Function to start a timer to expire in n mSecs.
+ */
+extern Status_t osal_CbTimerStart( pfnCbTimer_t pfnCbTimer, uint8 *pData,
+ uint16 timeout, uint8 *pTimerId );
+
+/*
+ * Function to update a timer that has already been started.
+ */
+extern Status_t osal_CbTimerUpdate( uint8 timerId, uint16 timeout );
+
+/*
+ * Function to stop a timer that has already been started.
+ */
+extern Status_t osal_CbTimerStop( uint8 timerId );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OSAL_CBTIMER_H */
diff --git a/Firmware/Radio/Projects/Wimu/Components/osal/include/osal_snv.h b/Firmware/Radio/Projects/Wimu/Components/osal/include/osal_snv.h
new file mode 100644
index 0000000..39082c5
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/osal/include/osal_snv.h
@@ -0,0 +1,137 @@
+/**************************************************************************************************
+ Filename: osal_snv.h
+ Revised: $Date: 2013-02-15 10:12:26 -0800 (Fri, 15 Feb 2013) $
+ Revision: $Revision: 33143 $
+
+ Description: This module defines the OSAL simple non-volatile memory functions.
+
+
+ Copyright 2009-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef OSAL_SNV_H
+#define OSAL_SNV_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#include "hal_types.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+#ifdef OSAL_SNV_UINT16_ID
+ typedef uint16 osalSnvId_t;
+ typedef uint16 osalSnvLen_t;
+#else
+ typedef uint8 osalSnvId_t;
+ typedef uint8 osalSnvLen_t;
+#endif
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn osal_snv_init
+ *
+ * @brief Initialize NV service.
+ *
+ * @return SUCCESS if initialization succeeds. FAILURE, otherwise.
+ */
+extern uint8 osal_snv_init( void );
+
+/*********************************************************************
+ * @fn osal_snv_read
+ *
+ * @brief Read data from NV.
+ *
+ * @param id - Valid NV item Id.
+ * @param len - Length of data to read.
+ * @param *pBuf - Data is read into this buffer.
+ *
+ * @return SUCCESS if successful.
+ * Otherwise, NV_OPER_FAILED for failure.
+ */
+extern uint8 osal_snv_read( osalSnvId_t id, osalSnvLen_t len, void *pBuf);
+
+/*********************************************************************
+ * @fn osal_snv_write
+ *
+ * @brief Write a data item to NV.
+ *
+ * @param id - Valid NV item Id.
+ * @param len - Length of data to write.
+ * @param *pBuf - Data to write.
+ *
+ * @return SUCCESS if successful, NV_OPER_FAILED if failed.
+ */
+extern uint8 osal_snv_write( osalSnvId_t id, osalSnvLen_t len, void *pBuf);
+
+/*********************************************************************
+ * @fn osal_snv_compact
+ *
+ * @brief Compacts NV if its usage has reached a specific threshold.
+ *
+ * @param threshold - compaction threshold
+ *
+ * @return SUCCESS if successful,
+ * NV_OPER_FAILED if failed, or
+ * INVALIDPARAMETER if threshold invalid.
+ */
+extern uint8 osal_snv_compact( uint8 threshold );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OSAL_SNV.H */
diff --git a/Firmware/Radio/Projects/Wimu/Components/osal/mcu/cc2540/osal_snv.c b/Firmware/Radio/Projects/Wimu/Components/osal/mcu/cc2540/osal_snv.c
new file mode 100644
index 0000000..c88b88e
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/osal/mcu/cc2540/osal_snv.c
@@ -0,0 +1,868 @@
+/**************************************************************************************************
+ Filename: osal_snv.c
+ Revised: $Date: 2013-02-15 10:12:26 -0800 (Fri, 15 Feb 2013) $
+ Revision: $Revision: 33143 $
+
+ Description: This module contains the OSAL simple non-volatile memory functions.
+
+
+ Copyright 2009-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#include "hal_adc.h"
+#include "hal_flash.h"
+#include "hal_types.h"
+#include "comdef.h"
+#include "OSAL.h"
+#include "osal_snv.h"
+#include "hal_assert.h"
+#include "saddr.h"
+
+#ifdef OSAL_SNV_UINT16_ID
+# error "This OSAL SNV implementation does not support the extended ID space"
+#endif
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// NV page configuration
+#define OSAL_NV_PAGE_SIZE HAL_FLASH_PAGE_SIZE
+#define OSAL_NV_PAGES_USED HAL_NV_PAGE_CNT
+#define OSAL_NV_PAGE_BEG HAL_NV_PAGE_BEG
+#define OSAL_NV_PAGE_END (OSAL_NV_PAGE_BEG + OSAL_NV_PAGES_USED - 1)
+
+// Default byte value when flash is erased
+#define OSAL_NV_ERASED 0xFF
+
+// NV page header size in bytes
+#define OSAL_NV_PAGE_HDR_SIZE 4
+
+// In case pages 0-1 are ever used, define a null page value.
+#define OSAL_NV_PAGE_NULL 0
+
+// In case item Id 0 is ever used, define a null item value.
+#define OSAL_NV_ITEM_NULL 0
+
+// Length in bytes of a flash word
+#define OSAL_NV_WORD_SIZE HAL_FLASH_WORD_SIZE
+
+// NV page header offset within a page
+#define OSAL_NV_PAGE_HDR_OFFSET 0
+
+
+// Flag in a length field of an item header to indicate validity
+// of the length field
+#define OSAL_NV_INVALID_LEN_MARK 0x8000
+
+// Flag in an ID field of an item header to indicate validity of
+// the identifier field
+#define OSAL_NV_INVALID_ID_MARK 0x8000
+
+
+// Bit difference between active page state indicator value and
+// transfer page state indicator value
+#define OSAL_NV_ACTIVE_XFER_DIFF 0x00100000
+
+// active page state indicator value
+#define OSAL_NV_ACTIVE_PAGE_STATE OSAL_NV_ACTIVE_XFER_DIFF
+
+// transfer page state indicator value
+#define OSAL_NV_XFER_PAGE_STATE (OSAL_NV_ACTIVE_PAGE_STATE ^ OSAL_NV_ACTIVE_XFER_DIFF)
+
+#define OSAL_NV_MIN_COMPACT_THRESHOLD 70 // Minimum compaction threshold
+#define OSAL_NV_MAX_COMPACT_THRESHOLD 95 // Maximum compaction threshold
+
+/*********************************************************************
+ * MACROS
+ */
+
+// Macro to check supply voltage
+#if (defined HAL_MCU_CC2530 || defined HAL_MCU_CC2531)
+# define OSAL_NV_CHECK_BUS_VOLTAGE (HalAdcCheckVdd(VDD_MIN_FLASH))
+#elif defined HAL_MCU_CC2533
+# define OSAL_NV_CHECK_BUS_VOLTAGE (HalBatMonRead( HAL_BATMON_MIN_FLASH ))
+#else
+// The radio chip does not support voltage monitoring
+# define OSAL_NV_CHECK_BUS_VOLTAGE TRUE
+#endif
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// NV item header structure
+typedef struct
+{
+ uint16 id;
+ uint16 len;
+} osalNvItemHdr_t;
+// Note that osalSnvId_t and osalSnvLen_t cannot be bigger than uint16
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+extern bool HalAdcCheckVdd(uint8 limit);
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+#ifndef OAD_KEEP_NV_PAGES
+// When NV pages are to remain intact during OAD download,
+// the image itself should not include NV pages.
+#pragma location="BLENV_ADDRESS_SPACE"
+__no_init uint8 _nvBuf[OSAL_NV_PAGES_USED * OSAL_NV_PAGE_SIZE];
+#pragma required=_nvBuf
+#endif // OAD_KEEP_NV_PAGES
+
+#if defined MAKE_CRC_SHDW
+#pragma location="CRC_SHDW"
+const CODE uint16 _crcShdw = 0xFFFF;
+#pragma required=_crcShdw
+#endif
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+// active page
+static uint8 activePg;
+
+// active page offset
+static uint16 pgOff;
+
+// flag to indicate that an error has occurred while writing to or erasing the
+// flash device. Once this flag indicates failure, it is unsafe to attempt
+// another write or erase.
+static uint8 failF;
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+
+static uint8 initNV( void );
+
+static void setActivePage( uint8 pg );
+static void setXferPage(void);
+static void erasePage( uint8 pg );
+static void cleanErasedPage( uint8 pg );
+static void findOffset( void );
+static void compactPage( uint8 pg );
+
+static void writeWord( uint8 pg, uint16 offset, uint8 *pBuf );
+static void writeWordM( uint8 pg, uint16 offset, uint8 *pBuf, osalSnvLen_t cnt );
+
+
+// NOTE: Triggering erase upon power up may cause fast aging of the flash device
+// if there is power switch debounce issue, etc.
+// Improvement of this is to add a certain delay upon power up before
+// osal_nv_init() is called.
+
+/*********************************************************************
+ * @fn initNV
+ *
+ * @brief Initialize the NV flash pages.
+ *
+ * @param none
+ *
+ * @return TRUE if initialization succeeds. FALSE, otherwise.
+ */
+static uint8 initNV( void )
+{
+ uint32 pgHdr;
+ uint8 xferPg = OSAL_NV_PAGE_NULL;
+ uint8 pg;
+
+ failF = FALSE;
+ activePg = OSAL_NV_PAGE_NULL;
+
+ // Pick active page and clean up erased page if necessary
+ for ( pg = OSAL_NV_PAGE_BEG; pg <= OSAL_NV_PAGE_END; pg++ )
+ {
+ HalFlashRead(pg, OSAL_NV_PAGE_HDR_OFFSET, (uint8 *)(&pgHdr), OSAL_NV_PAGE_HDR_SIZE);
+
+ if ( pgHdr == OSAL_NV_ACTIVE_PAGE_STATE)
+ {
+ if (activePg != OSAL_NV_PAGE_NULL)
+ {
+ // Both pages are active only when power failed during flash erase and
+ // with very low probability.
+ // As it is hard (code size intensive) to figure out which page is the real active page,
+ // and theoretically impossible as well in lowest probability, erase both pages
+ // in this case
+ cleanErasedPage(activePg);
+ cleanErasedPage(pg);
+ activePg = OSAL_NV_PAGE_NULL;
+ }
+ else
+ {
+ activePg = pg;
+ }
+ }
+ else if ( pgHdr == OSAL_NV_XFER_PAGE_STATE)
+ {
+ xferPg = pg;
+ }
+ else
+ {
+ // Erase this page if it is not erased.
+ // This is to ensure that any page that were in the middle of
+ // compacting gets erased.
+ cleanErasedPage(pg);
+ }
+ }
+
+ if (activePg == OSAL_NV_PAGE_NULL)
+ {
+ if (xferPg == OSAL_NV_PAGE_NULL)
+ {
+ // Both pages are erased. This must be initial state.
+ // Pick one page as active page.
+ setActivePage(OSAL_NV_PAGE_BEG);
+ pgOff = OSAL_NV_PAGE_HDR_SIZE;
+
+ // If setting active page from a completely erased page failed,
+ // it is not recommended to operate any further.
+ // Other cases, even if non-active page is corrupt, NV module can still read
+ // the active page content and hence this function could return TRUE.
+ return (!failF);
+ }
+ else
+ {
+ // Compacting a page hasn't completed in previous power cycle.
+ // Complete the compacting.
+ activePg = xferPg;
+ findOffset();
+
+ compactPage(xferPg);
+ }
+ }
+ else
+ {
+ if (xferPg != OSAL_NV_PAGE_NULL)
+ {
+ // Compacting has completed except for the final step of erasing
+ // the xferPage.
+ erasePage(xferPg);
+ }
+
+ // find the active page offset to write a new variable location item
+ findOffset();
+ }
+
+ return TRUE;
+}
+
+/*********************************************************************
+ * @fn setActivePage
+ *
+ * @brief Set page header active state to be active.
+ *
+ * @param pg - Valid NV page to activate.
+ *
+ * @return none
+ */
+static void setActivePage( uint8 pg )
+{
+ uint32 pgHdr;
+
+ pgHdr = OSAL_NV_ACTIVE_PAGE_STATE;
+
+ writeWord( pg, OSAL_NV_PAGE_HDR_OFFSET, (uint8*) &pgHdr );
+ if (!failF)
+ {
+ activePg = pg;
+ }
+}
+
+/*********************************************************************
+ * @fn setXferPage
+ *
+ * @brief Set active page header state to be transfer state.
+ *
+ * @param none
+ *
+ * @return none
+ */
+static void setXferPage(void)
+{
+ uint32 pgHdr;
+
+ // erase difference bit between active state and xfer state
+ pgHdr = OSAL_NV_XFER_PAGE_STATE;
+
+ writeWord( activePg, OSAL_NV_PAGE_HDR_OFFSET, (uint8*)&pgHdr );
+}
+
+/*********************************************************************
+ * @fn erasePage
+ *
+ * @brief Erases a page in Flash.
+ *
+ * @param pg - Valid NV page to erase.
+ *
+ * @return none
+ */
+static void erasePage( uint8 pg )
+{
+ if ( !OSAL_NV_CHECK_BUS_VOLTAGE || failF)
+ {
+ failF = TRUE;
+ return;
+ }
+
+ HalFlashErase(pg);
+
+ {
+ // Verify the erase operation
+ uint16 offset;
+ uint8 tmp;
+
+ for (offset = 0; offset < OSAL_NV_PAGE_SIZE; offset ++)
+ {
+ HalFlashRead(pg, offset, &tmp, 1);
+ if (tmp != OSAL_NV_ERASED)
+ {
+ failF = TRUE;
+ break;
+ }
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn cleanErasedPage
+ *
+ * @brief Erases a page in Flash if the page is not completely erased.
+ *
+ * @param pg - Valid NV page to erase.
+ *
+ * @return none
+ */
+static void cleanErasedPage( uint8 pg )
+{
+ uint8 buf;
+ uint16 offset;
+
+ for (offset = 0; offset < OSAL_NV_PAGE_SIZE; offset ++)
+ {
+ HalFlashRead(pg, offset, &buf, 1);
+ if (buf != OSAL_NV_ERASED)
+ {
+ erasePage(pg);
+ break;
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn findOffset
+ *
+ * @brief find an offset of an empty space in active page
+ * where to write a new item to.
+ *
+ * @param None
+ *
+ * @return none
+ */
+static void findOffset(void)
+{
+ uint16 offset;
+ for (offset = OSAL_NV_PAGE_SIZE - OSAL_NV_WORD_SIZE;
+ offset >= OSAL_NV_PAGE_HDR_SIZE;
+ offset -= OSAL_NV_WORD_SIZE)
+ {
+ uint32 tmp;
+
+ HalFlashRead(activePg, offset, (uint8 *)&tmp, OSAL_NV_WORD_SIZE);
+ if (tmp != 0xFFFFFFFF)
+ {
+ break;
+ }
+ }
+ pgOff = offset + OSAL_NV_WORD_SIZE;
+}
+
+/*********************************************************************
+ * @fn findItem
+ *
+ * @brief find a valid item from a designated page and offset
+ *
+ * @param pg - NV page
+ * @param offset - offset in the NV page from where to start
+ * search up.
+ * Usually this paramter is set to the empty space
+ * offset.
+ * @param id - NV item ID to search for
+ *
+ * @return offset of the item, 0 when not found
+ */
+static uint16 findItem(uint8 pg, uint16 offset, osalSnvId_t id)
+{
+ offset -= OSAL_NV_WORD_SIZE;
+
+ while (offset >= OSAL_NV_PAGE_HDR_SIZE)
+ {
+ osalNvItemHdr_t hdr;
+
+ HalFlashRead(pg, offset, (uint8 *) &hdr, OSAL_NV_WORD_SIZE);
+
+ if (hdr.id == id)
+ {
+ // item found
+ // length field could be corrupt. Mask invalid length mark.
+ uint8 len = hdr.len & ~OSAL_NV_INVALID_LEN_MARK;
+ return offset - len;
+ }
+ else if (hdr.len & OSAL_NV_INVALID_LEN_MARK)
+ {
+ offset -= OSAL_NV_WORD_SIZE;
+ }
+ else
+ {
+ // valid length field
+ if (hdr.len + OSAL_NV_WORD_SIZE <= offset)
+ {
+ // valid length
+ offset -= hdr.len + OSAL_NV_WORD_SIZE;
+ }
+ else
+ {
+ // active page is corrupt
+ // This could happen if NV initialization failed upon failure to erase
+ // page and active page is set to uncleanly erased page.
+ HAL_ASSERT_FORCED();
+ return 0;
+ }
+ }
+ }
+ return 0;
+}
+
+/*********************************************************************
+ * @fn writeItem
+ *
+ * @brief Write a data item to NV. Function can write an entire item to NV
+ *
+ * @param pg - Page number
+ * @param offset - offset within the NV page where to write the new item
+ * @param id - NV item ID
+ * @param alignedLen - Length of data to write, alinged in flash word
+ * boundary
+ * @param *pBuf - Data to write.
+ *
+ * @return none
+ */
+static void writeItem( uint8 pg, uint16 offset, osalSnvId_t id, uint16 alignedLen, uint8 *pBuf )
+{
+ osalNvItemHdr_t hdr;
+
+ hdr.id = 0xFFFF;
+ hdr.len = alignedLen | OSAL_NV_INVALID_LEN_MARK;
+
+ // Write the len portion of the header first
+ writeWord(pg, offset + alignedLen, (uint8 *) &hdr);
+
+ // remove invalid len mark
+ hdr.len &= ~OSAL_NV_INVALID_LEN_MARK;
+ writeWord(pg, offset + alignedLen, (uint8 *) &hdr);
+
+ // Copy over the data
+ writeWordM(pg, offset, pBuf, alignedLen / OSAL_NV_WORD_SIZE);
+
+ // value is valid. Write header except for the most significant bit.
+ hdr.id = id | OSAL_NV_INVALID_ID_MARK;
+ writeWord(pg, offset + alignedLen, (uint8 *) &hdr);
+
+ // write the most significant bit
+ hdr.id &= ~OSAL_NV_INVALID_ID_MARK;
+ writeWord(pg, offset + alignedLen, (uint8 *) &hdr);
+}
+
+/*********************************************************************
+ * @fn xferItem
+ *
+ * @brief Copy an NV item from the active page to a designated page.
+ *
+ * @param pg - NV page where to copy the item to.
+ * @param offset - NV page offset where to copy the item to.
+ * @param alignedLen - Length of data to write, aligned in flash word
+ * boundary.
+ * @param srcOff - NV page offset of the original data in active page
+ *
+ * @return none.
+ */
+static void xferItem( uint8 pg, uint16 offset, uint16 alignedLen, uint16 srcOff )
+{
+ uint8 tmp[OSAL_NV_WORD_SIZE];
+ uint16 i = 0;
+
+ // Copy over the data
+ while (i <= alignedLen)
+ {
+ HalFlashRead(activePg, srcOff + i, tmp, OSAL_NV_WORD_SIZE);
+ writeWord(pg, offset + i, tmp);
+
+ i += OSAL_NV_WORD_SIZE;
+ }
+}
+
+/*********************************************************************
+ * @fn compactPage
+ *
+ * @brief Compacts the page specified.
+ *
+ * @param srcPg - Valid NV page to compact from.
+ * The page must have changed its state (header) to xfer state
+ * prior to this function call. This function will not
+ * modify the state of its header to xfer state before starting
+ * to compact.
+ *
+ * @return none.
+ */
+static void compactPage( uint8 srcPg )
+{
+ uint16 srcOff, dstOff;
+ uint8 dstPg;
+ osalSnvId_t lastId = (osalSnvId_t) 0xFFFF;
+
+ dstPg = (srcPg == OSAL_NV_PAGE_BEG)? OSAL_NV_PAGE_END : OSAL_NV_PAGE_BEG;
+
+ dstOff = OSAL_NV_PAGE_HDR_SIZE;
+
+ // Read from the latest value
+ srcOff = pgOff - sizeof(osalNvItemHdr_t);
+
+ while (srcOff >= OSAL_NV_PAGE_HDR_SIZE)
+ {
+ osalNvItemHdr_t hdr;
+
+ if (failF)
+ {
+ // Failure during transfer item will make next findItem error prone.
+ return;
+ }
+
+ HalFlashRead(srcPg, srcOff, (uint8 *) &hdr, OSAL_NV_WORD_SIZE);
+
+ if (hdr.id == 0xFFFF)
+ {
+ // Invalid entry. Skip this one.
+ if (hdr.len & OSAL_NV_INVALID_LEN_MARK)
+ {
+ srcOff -= OSAL_NV_WORD_SIZE;
+ }
+ else
+ {
+ if (hdr.len + OSAL_NV_WORD_SIZE <= srcOff)
+ {
+ srcOff -= hdr.len + OSAL_NV_WORD_SIZE;
+ }
+ else
+ {
+ // invalid length. Source page must be a corrupt page.
+ // This is possible only if the NV initialization failed upon erasing
+ // what is selected as active page.
+ // This is supposed to be a very rare case, as power should be
+ // shutdown exactly during erase and then the page header is
+ // still retained as either the Xfer or the Active state.
+
+ // For production code, it might be useful to attempt to erase the page
+ // so that at next power cycle at least the device is runnable
+ // (with all entries removed).
+ // However, it might be still better not to attempt erasing the page
+ // just to see if this very rare case actually happened.
+ //erasePage(srcPg);
+
+ HAL_ASSERT_FORCED();
+ return;
+ }
+ }
+
+ continue;
+ }
+
+ // Consider only valid item
+ if (!(hdr.id & OSAL_NV_INVALID_ID_MARK) && hdr.id != lastId)
+ {
+ // lastId is used to speed up compacting in case the same item ID
+ // items were neighboring each other contiguously.
+ lastId = (osalSnvId_t) hdr.id;
+
+ // Check if the latest value of the item was already written
+ if (findItem(dstPg, dstOff, lastId) == 0)
+ {
+ // This item was not copied over yet.
+ // This must be the latest value.
+ // Write the latest value to the destination page
+
+ xferItem(dstPg, dstOff, hdr.len, srcOff - hdr.len);
+
+ dstOff += hdr.len + OSAL_NV_WORD_SIZE;
+ }
+ }
+ srcOff -= hdr.len + OSAL_NV_WORD_SIZE;
+ }
+
+ // All items copied.
+ // Activate the new page
+ setActivePage(dstPg);
+
+ if (!failF)
+ {
+ pgOff = dstOff; // update active page offset
+ }
+
+ // Erase the currently active page
+ erasePage(srcPg);
+}
+
+/*********************************************************************
+ * @fn verifyWordM
+ *
+ * @brief verify the written word.
+ *
+ * @param pg - A valid NV Flash page.
+ * @param offset - A valid offset into the page.
+ * @param pBuf - Pointer to source buffer.
+ * @param cnt - Number of 4-byte blocks to verify.
+ *
+ * @return none
+ */
+static void verifyWordM( uint8 pg, uint16 offset, uint8 *pBuf, osalSnvLen_t cnt )
+{
+ uint8 tmp[OSAL_NV_WORD_SIZE];
+
+ while (cnt--)
+ {
+ // Reading byte per byte will reduce code size but will slow down
+ // and not sure it will meet the timing requirements.
+ HalFlashRead(pg, offset, tmp, OSAL_NV_WORD_SIZE);
+ if (FALSE == osal_memcmp(tmp, pBuf, OSAL_NV_WORD_SIZE))
+ {
+ failF = TRUE;
+ return;
+ }
+ offset += OSAL_NV_WORD_SIZE;
+ pBuf += OSAL_NV_WORD_SIZE;
+ }
+}
+
+/*********************************************************************
+ * @fn writeWord
+ *
+ * @brief Writes a Flash-WORD to NV.
+ *
+ * @param pg - A valid NV Flash page.
+ * @param offset - A valid offset into the page.
+ * @param pBuf - Pointer to source buffer.
+ *
+ * @return none
+ */
+static void writeWord( uint8 pg, uint16 offset, uint8 *pBuf )
+{
+ uint16 addr = (offset >> 2) + ((uint16)pg << 9);
+
+ if ( !failF )
+ {
+ HalFlashWrite(addr, pBuf, 1);
+ verifyWordM(pg, offset, pBuf, 1);
+ }
+}
+
+/*********************************************************************
+ * @fn writeWordM
+ *
+ * @brief Writes multiple Flash-WORDs to NV.
+ *
+ * @param pg - A valid NV Flash page.
+ * @param offset - A valid offset into the page.
+ * @param buf - Pointer to source buffer.
+ * @param cnt - Number of 4-byte blocks to write.
+ *
+ * @return none
+ */
+static void writeWordM( uint8 pg, uint16 offset, uint8 *buf, osalSnvLen_t cnt )
+{
+ uint16 addr = (offset >> 2) + ((uint16)pg << 9);
+
+ if ( !failF )
+ {
+ HalFlashWrite(addr, buf, cnt);
+ verifyWordM(pg, offset, buf, cnt);
+ }
+}
+
+/*********************************************************************
+ * @fn osal_snv_init
+ *
+ * @brief Initialize NV service.
+ *
+ * @return SUCCESS if initialization succeeds. FAILURE, otherwise.
+ */
+uint8 osal_snv_init( void )
+{
+ if (!initNV())
+ {
+ // NV initialization failed
+ HAL_ASSERT_FORCED();
+
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
+/*********************************************************************
+ * @fn osal_snv_write
+ *
+ * @brief Write a data item to NV.
+ *
+ * @param id - Valid NV item Id.
+ * @param len - Length of data to write.
+ * @param *pBuf - Data to write.
+ *
+ * @return SUCCESS if successful, NV_OPER_FAILED if failed.
+ */
+uint8 osal_snv_write( osalSnvId_t id, osalSnvLen_t len, void *pBuf )
+{
+ uint16 alignedLen;
+
+ {
+ uint16 offset = findItem(activePg, pgOff, id);
+
+ if (offset > 0)
+ {
+ uint8 tmp;
+ osalSnvLen_t i;
+
+ for (i = 0; i < len; i++)
+ {
+ HalFlashRead(activePg, offset, &tmp, 1);
+ if (tmp != ((uint8 *)pBuf)[i])
+ {
+ break;
+ }
+ offset++;
+ }
+
+ if (i == len)
+ {
+ // Changed value is the same value as before.
+ // Return here instead of re-writing the same value to NV.
+ return SUCCESS;
+ }
+ }
+ }
+
+ alignedLen = ((len + OSAL_NV_WORD_SIZE - 1) / OSAL_NV_WORD_SIZE) * OSAL_NV_WORD_SIZE;
+
+ if ( pgOff + alignedLen + OSAL_NV_WORD_SIZE > OSAL_NV_PAGE_SIZE )
+ {
+ setXferPage();
+ compactPage(activePg);
+ }
+
+ // pBuf shall be referenced beyond its valid length to save code size.
+ writeItem(activePg, pgOff, id, alignedLen, pBuf);
+ if (failF)
+ {
+ return NV_OPER_FAILED;
+ }
+
+ pgOff += alignedLen + OSAL_NV_WORD_SIZE;
+
+ return SUCCESS;
+}
+
+/*********************************************************************
+ * @fn osal_snv_read
+ *
+ * @brief Read data from NV.
+ *
+ * @param id - Valid NV item Id.
+ * @param len - Length of data to read.
+ * @param *pBuf - Data is read into this buffer.
+ *
+ * @return SUCCESS if successful.
+ * Otherwise, NV_OPER_FAILED for failure.
+ */
+uint8 osal_snv_read( osalSnvId_t id, osalSnvLen_t len, void *pBuf )
+{
+ uint16 offset = findItem(activePg, pgOff, id);
+
+ if (offset != 0)
+ {
+ HalFlashRead(activePg, offset, pBuf, len);
+ return SUCCESS;
+ }
+ return NV_OPER_FAILED;
+}
+
+/*********************************************************************
+ * @fn osal_snv_compact
+ *
+ * @brief Compacts NV if its usage has reached a specific threshold.
+ *
+ * @param threshold - compaction threshold
+ *
+ * @return SUCCESS if successful,
+ * NV_OPER_FAILED if failed, or
+ * INVALIDPARAMETER if threshold invalid.
+ */
+uint8 osal_snv_compact( uint8 threshold )
+{
+ if ( ( threshold < OSAL_NV_MIN_COMPACT_THRESHOLD ) ||
+ ( threshold > OSAL_NV_MAX_COMPACT_THRESHOLD ) )
+ {
+ return INVALIDPARAMETER;
+ }
+
+ // See if NV active page usage has reached compaction threshold
+ if ( ( (uint32)pgOff * 100 ) >= ( OSAL_NV_PAGE_SIZE * (uint32)threshold ) )
+ {
+ setXferPage();
+ compactPage(activePg);
+
+ return SUCCESS;
+ }
+
+ return NV_OPER_FAILED;
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Components/services/saddr/saddr.h b/Firmware/Radio/Projects/Wimu/Components/services/saddr/saddr.h
new file mode 100644
index 0000000..0b4f646
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Components/services/saddr/saddr.h
@@ -0,0 +1,175 @@
+/**************************************************************************************************
+ Filename: saddr.h
+ Revised: $Date: 2009-12-10 08:32:15 -0800 (Thu, 10 Dec 2009) $
+ Revision: $Revision: 21311 $
+
+ Description: Zigbee and 802.15.4 device address utility functions.
+
+
+ Copyright 2005-2010 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef SADDR_H
+#define SADDR_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/****************************************************************************
+ * MACROS
+ */
+
+/* Extended address length */
+#define SADDR_EXT_LEN 8
+
+/* Address modes */
+#define SADDR_MODE_NONE 0 /* Address not present */
+#define SADDR_MODE_SHORT 2 /* Short address */
+#define SADDR_MODE_EXT 3 /* Extended address */
+
+/****************************************************************************
+ * TYPEDEFS
+ */
+
+/* Extended address */
+typedef uint8 sAddrExt_t[SADDR_EXT_LEN];
+
+/* Combined short/extended device address */
+typedef struct
+{
+ union
+ {
+ uint16 shortAddr; /* Short address */
+ sAddrExt_t extAddr; /* Extended address */
+ } addr;
+ uint8 addrMode; /* Address mode */
+} sAddr_t;
+
+/****************************************************************************
+ * @fn sAddrCmp
+ *
+ * @brief Compare two device addresses.
+ *
+ * input parameters
+ *
+ * @param pAddr1 - Pointer to first address.
+ * @param pAddr2 - Pointer to second address.
+ *
+ * output parameters
+ *
+ * @return TRUE if addresses are equal, FALSE otherwise
+ */
+extern bool sAddrCmp(const sAddr_t *pAddr1, const sAddr_t *pAddr2);
+
+/****************************************************************************
+ * @fn sAddrIden
+ *
+ * @brief Check if two device addresses are identical.
+ *
+ * This routine is virtually the same as sAddrCmp, which is used
+ * to determine if two different addresses are the same. However,
+ * this routine can be used to determine if an address is the
+ * same as a previously stored address. The key difference is in
+ * the former case, if the address mode is "none", then the
+ * assumption is that the two addresses can not be the same. But
+ * in the latter case, the address mode itself is being compared.
+ * So two addresses can be identical even if the address mode is
+ * "none", as long as the address mode of both addresses being
+ * compared is the "none".
+ *
+ * input parameters
+ *
+ * @param pAddr1 - Pointer to first address.
+ * @param pAddr2 - Pointer to second address.
+ *
+ * output parameters
+ *
+ * @return TRUE if addresses are identical, FALSE otherwise
+ */
+extern bool sAddrIden(const sAddr_t *pAddr1, const sAddr_t *pAddr2);
+
+/****************************************************************************
+ * @fn sAddrCpy
+ *
+ * @brief Copy a device address.
+ *
+ * input parameters
+ *
+ * @param pSrc - Pointer to address to copy.
+ *
+ * output parameters
+ *
+ * @param pDest - Pointer to address of copy.
+ *
+ * @return None.
+ */
+extern void sAddrCpy(sAddr_t *pDest, const sAddr_t *pSrc);
+
+/****************************************************************************
+ * @fn sAddrExtCmp
+ *
+ * @brief Compare two extended addresses.
+ *
+ * input parameters
+ *
+ * @param pAddr1 - Pointer to first address.
+ * @param pAddr2 - Pointer to second address.
+ *
+ * output parameters
+ *
+ * @return TRUE if addresses are equal, FALSE otherwise
+ */
+extern bool sAddrExtCmp(const uint8 * pAddr1, const uint8 * pAddr2);
+
+/****************************************************************************
+ * @fn sAddrExtCpy
+ *
+ * @brief Copy an extended address.
+ *
+ * input parameters
+ *
+ * @param pSrc - Pointer to address to copy.
+ *
+ * output parameters
+ *
+ * @param pDest - Pointer to address of copy.
+ *
+ * @return pDest + SADDR_EXT_LEN.
+ */
+void *sAddrExtCpy(uint8 * pDest, const uint8 * pSrc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SADDR_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Include/gapgattserver.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Include/gapgattserver.h
new file mode 100644
index 0000000..9928680
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Include/gapgattserver.h
@@ -0,0 +1,208 @@
+/**************************************************************************************************
+ Filename: gapgattserver.h
+ Revised: $Date: 2009-10-21 07:25:22 -0700 (Wed, 21 Oct 2009) $
+ Revision: $Revision: 20946 $
+
+ Description: This file contains GAP GATT attribute definitions
+ and prototypes.
+
+
+ Copyright 2009 - 2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef GAPGATTSERVER_H
+#define GAPGATTSERVER_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+#define GAP_DEVICE_NAME_LEN (20+1)
+
+// Privacy Flag States
+#define GAP_PRIVACY_DISABLED 0x00
+#define GAP_PRIVACY_ENABLED 0x01
+
+// GAP GATT Server Parameters
+#define GGS_DEVICE_NAME_ATT 0 // RW uint8[GAP_DEVICE_NAME_LEN]
+#define GGS_APPEARANCE_ATT 1 // RW uint16
+#define GGS_PERI_PRIVACY_FLAG_ATT 2 // RW uint8
+#define GGS_RECONNCT_ADDR_ATT 3 // RW uint8[B_ADDR_LEN]
+#define GGS_PERI_CONN_PARAM_ATT 4 // RW sizeof(gapPeriConnectParams_t)
+#define GGS_PERI_PRIVACY_FLAG_PROPS 5 // RW uint8
+#define GGS_W_PERMIT_DEVICE_NAME_ATT 6 // W uint8
+#define GGS_W_PERMIT_APPEARANCE_ATT 7 // W uint8
+#define GGS_W_PERMIT_PRIVACY_FLAG_ATT 8 // W uint8
+
+// GAP Services bit fields
+#define GAP_SERVICE 0x00000001
+
+// Attribute ID used with application's callback when attribute value is changed OTA
+#define GGS_DEVICE_NAME_ID 0
+#define GGS_APPEARANCE_ID 1
+
+#if defined ( TESTMODES )
+ // GGS TestModes
+ #define GGS_TESTMODE_OFF 0 // No Test mode
+ #define GGS_TESTMODE_W_PERMIT_DEVICE_NAME 1 // Make Device Name attribute writable
+ #define GGS_TESTMODE_W_PERMIT_APPEARANCE 2 // Make Appearance attribute writable
+ #define GGS_TESTMODE_W_PERMIT_PRIVACY_FLAG 3 // Make Peripheral Privacy Flag attribute writable with authentication
+#endif // TESTMODES
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+// Callback to notify when attribute value is changed over the air.
+typedef void (*ggsAttrValueChange_t)( uint8 attrId );
+
+// GAP GATT Server callback structure
+typedef struct
+{
+ ggsAttrValueChange_t pfnAttrValueChange; // When attribute value is changed OTA
+} ggsAppCBs_t;
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/**
+ * @brief Set a GAP GATT Server parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+extern bStatus_t GGS_SetParameter( uint8 param, uint8 len, void *value );
+
+/**
+ * @brief Get a GAP GATT Server parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+extern bStatus_t GGS_GetParameter( uint8 param, void *value );
+
+/**
+ * @brief Add function for the GAP GATT Service.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return SUCCESS: Service added successfully.
+ * INVALIDPARAMETER: Invalid service field.
+ * FAILURE: Not enough attribute handles available.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t GGS_AddService( uint32 services );
+
+/**
+ * @brief Delete function for the GAP GATT Service.
+ *
+ * @param services - services to delete. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return SUCCESS: Service deleted successfully.
+ * FAILURE: Service not found.
+ */
+extern bStatus_t GGS_DelService( uint32 services );
+
+/**
+ * @brief Registers the application callback function.
+ *
+ * Note: Callback registration is needed only when the
+ * Device Name is made writable. The application
+ * will be notified when the Device Name is changed
+ * over the air.
+ *
+ * @param appCallbacks - pointer to application callbacks.
+ *
+ * @return none
+ */
+extern void GGS_RegisterAppCBs( ggsAppCBs_t *appCallbacks );
+
+/**
+ * @brief Set a GGS Parameter value. Use this function to change
+ * the default GGS parameter values.
+ *
+ * @param value - new GGS param value
+ *
+ * @return void
+ */
+extern void GGS_SetParamValue( uint16 value );
+
+/**
+ * @brief Get a GGS Parameter value.
+ *
+ * @param none
+ *
+ * @return GGS Parameter value
+ */
+extern uint16 GGS_GetParamValue( void );
+
+/*********************************************************************
+ * TASK FUNCTIONS - Don't call these. These are system functions.
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GAPGATTSERVER_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Include/gattservapp.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Include/gattservapp.h
new file mode 100644
index 0000000..5b6d6fd
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Include/gattservapp.h
@@ -0,0 +1,690 @@
+/**
+ @headerfile: gattservapp.h
+ $Date: 2009-06-29 16:20:52 -0700 (Mon, 29 Jun 2009) $
+ $Revision: 20240 $
+
+ @mainpage BLE GATT Server Application API
+
+ Description: This file contains the GATT Server Application (GATTServApp)
+ definitions and prototypes.
+
+ \image html HighLevelGATTServApp.PNG
+
+
+ Functional Description
+ The GATT Server Application (GATTServApp) provides the following abilities:
+
+ - Service Registration - This API is used to register a service's
+ attribute list and callback functions with the GATT Server Application.
+ - Service Deregistration - This API is used to deregister a service's
+ attribute list and callback functions from the GATT Server Application.
+ - GATT Service Addition - This API is the add function for the GATT
+ Service. It registers the GATT Service's attribute list and callback
+ functions with the GATT Server Application.
+ - GATT Service Deletion - This API is the delete function for the
+ GATT Service. It deregisters the GATT Service's attribute list and
+ callback functions from the GATT Server Application.
+
+
+ Service Attribute List
+ A profile may support one or more services. Each of the services may support
+ characteristics or references to other services. Each characteristic contains
+ a value and may contain optional descriptors. The service, characteristic,
+ characteristic value and descriptors are all stored as attributes on the server.
+ The service attribute list to be registered with the GATT Server must start
+ with a Service attribute followed by all the attributes associated with that
+ Service attribute.
+
+
+ \image html GATTAttributeList.PNG
+
+
+ Service Callback Functions
+ The encoding of each attribute value is defined in the applicable profile.
+ The GATT Server doesn't directly access the attribute value for reading
+ or writing. It uses the Read and Write callback functions provided by the
+ registering profile to execute the incoming Attribute Protocol (ATT) Read
+ and Write request respectively.
+
+
+ Copyright 2009 - 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef GATTSERVAPP_H
+#define GATTSERVAPP_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/** @defgroup GATT_SERV_MSG_EVENT_DEFINES GATT Server Message IDs
+ * @{
+ */
+
+#define GATT_CLIENT_CHAR_CFG_UPDATED_EVENT 0x00 //!< Sent when a Client Characteristic Configuration is updated. This event is sent as an OSAL message defined as gattCharCfgUpdatedEvent_t.
+
+/** @} End GATT_SERV_MSG_EVENT_DEFINES */
+
+
+/** @defgroup GATT_PROP_BITMAPS_DEFINES GATT Characteristic Properties Bit Fields
+ * @{
+ */
+
+#define GATT_PROP_BCAST 0x01 //!< Permits broadcasts of the Characteristic Value
+#define GATT_PROP_READ 0x02 //!< Permits reads of the Characteristic Value
+#define GATT_PROP_WRITE_NO_RSP 0x04 //!< Permits writes of the Characteristic Value without response
+#define GATT_PROP_WRITE 0x08 //!< Permits writes of the Characteristic Value with response
+#define GATT_PROP_NOTIFY 0x10 //!< Permits notifications of a Characteristic Value without acknowledgement
+#define GATT_PROP_INDICATE 0x20 //!< Permits indications of a Characteristic Value with acknowledgement
+#define GATT_PROP_AUTHEN 0x40 //!< Permits signed writes to the Characteristic Value
+#define GATT_PROP_EXTENDED 0x80 //!< Additional characteristic properties are defined in the Characteristic Extended Properties Descriptor
+
+/** @} End GATT_PROP_BITMAPS_DEFINES */
+
+/** @defgroup GATT_EXT_PROP_BITMAPS_DEFINES GATT Characteristic Extended Properties Bit Fields
+ * @{
+ */
+
+#define GATT_EXT_PROP_RELIABLE_WRITE 0x0001 //!< Permits reliable writes of the Characteristic Value
+#define GATT_EXT_PROP_WRITABLE_AUX 0x0002 //!< Permits writes to the characteristic descriptor
+
+/** @} End GATT_EXT_PROP_BITMAPS_DEFINES */
+
+/** @defgroup GATT_CLIENT_CFG_BITMAPS_DEFINES GATT Client Characteristic Configuration Bit Fields
+ * @{
+ */
+
+#define GATT_CLIENT_CFG_NOTIFY 0x0001 //!< The Characteristic Value shall be notified
+#define GATT_CLIENT_CFG_INDICATE 0x0002 //!< The Characteristic Value shall be indicated
+
+/** @} End GATT_CLIENT_CFG_BITMAPS_DEFINES */
+
+/** @defgroup GATT_SERV_CFG_BITMAPS_DEFINES GATT Server Characteristic Configuration Bit Fields
+ * @{
+ */
+
+#define GATT_SERV_CFG_BCAST 0x0001 //!< The Characteristic Value shall be broadcast when the server is in the broadcast procedure if advertising data resources are available
+
+/** @} End GATT_SERV_CFG_BITMAPS_DEFINES */
+
+#define GATT_CFG_NO_OPERATION 0x0000 // No operation
+
+/** @defgroup GATT_FORMAT_TYPES_DEFINES GATT Characteristic Format Types
+ * @{
+ */
+
+#define GATT_FORMAT_BOOL 0x01 //!< Unsigned 1 bit; 0 = false, 1 = true
+#define GATT_FORMAT_2BIT 0x02 //!< Unsigned 2 bit integer
+#define GATT_FORMAT_NIBBLE 0x03 //!< Unsigned 4 bit integer
+#define GATT_FORMAT_UINT8 0x04 //!< Unsigned 8 bit integer
+#define GATT_FORMAT_UINT12 0x05 //!< Unsigned 12 bit integer
+#define GATT_FORMAT_UINT16 0x06 //!< Unsigned 16 bit integer
+#define GATT_FORMAT_UINT24 0x07 //!< Unsigned 24 bit integer
+#define GATT_FORMAT_UINT32 0x08 //!< Unsigned 32 bit integer
+#define GATT_FORMAT_UINT48 0x09 //!< Unsigned 48 bit integer
+#define GATT_FORMAT_UINT64 0x0a //!< Unsigned 64 bit integer
+#define GATT_FORMAT_UINT128 0x0b //!< Unsigned 128 bit integer
+#define GATT_FORMAT_SINT8 0x0c //!< Signed 8 bit integer
+#define GATT_FORMAT_SINT12 0x0d //!< Signed 12 bit integer
+#define GATT_FORMAT_SINT16 0x0e //!< Signed 16 bit integer
+#define GATT_FORMAT_SINT24 0x0f //!< Signed 24 bit integer
+#define GATT_FORMAT_SINT32 0x10 //!< Signed 32 bit integer
+#define GATT_FORMAT_SINT48 0x11 //!< Signed 48 bit integer
+#define GATT_FORMAT_SINT64 0x12 //!< Signed 64 bit integer
+#define GATT_FORMAT_SINT128 0x13 //!< Signed 128 bit integer
+#define GATT_FORMAT_FLOAT32 0x14 //!< IEEE-754 32 bit floating point
+#define GATT_FORMAT_FLOAT64 0x15 //!< IEEE-754 64 bit floating point
+#define GATT_FORMAT_SFLOAT 0x16 //!< IEEE-11073 16 bit SFLOAT
+#define GATT_FORMAT_FLOAT 0x17 //!< IEEE-11073 32 bit FLOAT
+#define GATT_FORMAT_DUINT16 0x18 //!< IEEE-20601 format
+#define GATT_FORMAT_UTF8S 0x19 //!< UTF-8 string
+#define GATT_FORMAT_UTF16S 0x1a //!< UTF-16 string
+#define GATT_FORMAT_STRUCT 0x1b //!< Opaque structure
+
+/** @} End GATT_FORMAT_TYPES_DEFINES */
+
+/** @defgroup GATT_NS_TYPES_DEFINES GATT Namespace Types
+ * @{
+ */
+
+#define GATT_NS_NONE 0x00 //!< No namespace
+#define GATT_NS_BT_SIG 0x01 //!< Bluetooth SIG namespace
+
+/** @} End GATT_NS_TYPES_DEFINES */
+
+/** @defgroup GATT_NS_BT_DESC_DEFINES GATT Bluetooth Namespace Descriptions
+ * @{
+ */
+
+#define GATT_NS_BT_DESC_UNKNOWN 0x0000 //!< The description is unknown
+
+/** @} End GATT_NS_BT_DESC_DEFINES */
+
+// All profile services bit fields
+#define GATT_ALL_SERVICES 0xFFFFFFFF
+
+// GATT Services bit fields
+#define GATT_SERVICE 0x00000001
+
+#if defined ( TESTMODES )
+ // GATT Test Modes
+ #define GATT_TESTMODE_OFF 0 // Test mode off
+ #define GATT_TESTMODE_NO_RSP 1 // Ignore incoming request
+ #define GATT_TESTMODE_PREPARE_WRITE 2 // Forward Prepare Write Request right away
+ #define GATT_TESTMODE_MAX_MTU_SIZE 3 // Use Max ATT MTU size with Exchange MTU Rsp
+ #define GATT_TESTMODE_CORRUPT_PW_DATA 4 // Corrupt incoming Prepare Write Request data
+#endif
+
+// GATT Server Parameters
+#define GATT_PARAM_NUM_PREPARE_WRITES 0 // RW uint8
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+// The number of attribute records in a given attribute table
+#define GATT_NUM_ATTRS( attrs ) ( sizeof( attrs ) / sizeof( gattAttribute_t ) )
+
+// The handle of a service is the handle of the first attribute
+#define GATT_SERVICE_HANDLE( attrs ) ( (attrs)[0].handle )
+
+// The handle of the first included service (i = 1) is the value of the second attribute
+#define GATT_INCLUDED_HANDLE( attrs, i ) ( *((uint16 *)((attrs)[(i)].pValue)) )
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/**
+ * @defgroup GATT_SERV_APP_CB_API GATT Server App Callback API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Callback function prototype to read an attribute value.
+ *
+ * @param connHandle - connection request was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read (to be returned)
+ * @param pLen - length of data (to be returned)
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return SUCCESS: Read was successfully.
+ * Error, otherwise: ref ATT_ERR_CODE_DEFINES.
+ */
+typedef bStatus_t (*pfnGATTReadAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset,
+ uint8 maxLen );
+/**
+ * @brief Callback function prototype to write an attribute value.
+ *
+ * @param connHandle - connection request was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param pLen - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return SUCCESS: Write was successfully.
+ * Error, otherwise: ref ATT_ERR_CODE_DEFINES.
+ */
+typedef bStatus_t (*pfnGATTWriteAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+/**
+ * @brief Callback function prototype to authorize a Read or Write operation
+ * on a given attribute.
+ *
+ * @param connHandle - connection request was received on
+ * @param pAttr - pointer to attribute
+ * @param opcode - request opcode (ATT_READ_REQ or ATT_WRITE_REQ)
+ *
+ * @return SUCCESS: Operation authorized.
+ * ATT_ERR_INSUFFICIENT_AUTHOR: Authorization required.
+ */
+typedef bStatus_t (*pfnGATTAuthorizeAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 opcode );
+/**
+ * @}
+ */
+
+/**
+ * GATT Structure for Characteristic Presentation Format Value.
+ */
+typedef struct
+{
+ uint8 format; //!< Format of the value of this characteristic
+ uint8 exponent; //!< A sign integer which represents the exponent of an integer
+ uint16 unit; //!< Unit of this attribute as defined in the data dictionary
+ uint8 nameSpace; //!< Name space of the description
+ uint16 desc; //!< Description of this attribute as defined in a higher layer profile
+} gattCharFormat_t;
+
+/**
+ * GATT Structure for Client Characteristic Configuration.
+ */
+typedef struct
+{
+ uint16 connHandle; //!< Client connection handle
+ uint8 value; //!< Characteristic configuration value for this client
+} gattCharCfg_t;
+
+/**
+ * GATT Structure for service callback functions - must be setup by the application
+ * and used when GATTServApp_RegisterService() is called.
+ */
+typedef struct
+{
+ pfnGATTReadAttrCB_t pfnReadAttrCB; //!< Read callback function pointer
+ pfnGATTWriteAttrCB_t pfnWriteAttrCB; //!< Write callback function pointer
+ pfnGATTAuthorizeAttrCB_t pfnAuthorizeAttrCB; //!< Authorization callback function pointer
+} gattServiceCBs_t;
+
+/**
+ * GATT Server App event header format.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GATT_SERV_MSG_EVENT and status
+ uint16 connHandle; //!< Connection message was received on
+ uint8 method; //!< GATT type of command. Ref: @ref GATT_SERV_MSG_EVENT_DEFINES
+} gattEventHdr_t;
+
+/**
+ * GATT_CLIENT_CHAR_CFG_UPDATED_EVENT message format. This message is sent to
+ * the app when a Client Characteristic Configuration is updated.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GATT_SERV_MSG_EVENT and status
+ uint16 connHandle; //!< Connection message was received on
+ uint8 method; //!< GATT_CLIENT_CHAR_CFG_UPDATED_EVENT
+ uint16 attrHandle; //!< attribute handle
+ uint16 value; //!< attribute new value
+} gattClientCharCfgUpdatedEvent_t;
+
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/**
+ * @defgroup GATT_SERV_APP_API GATT Server App API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Register your task ID to receive event messages
+ * from the GATT Server Application.
+ *
+ * @param taskID - Default task ID to send events.
+ *
+ * @return none
+ */
+extern void GATTServApp_RegisterForMsg( uint8 taskID );
+
+/**
+ * @brief Register a service's attribute list and callback functions with
+ * the GATT Server Application.
+ *
+ * @param pAttrs - Array of attribute records to be registered
+ * @param numAttrs - Number of attributes in array
+ * @param pServiceCBs - Service callback function pointers
+ *
+ * @return SUCCESS: Service registered successfully.
+ * INVALIDPARAMETER: Invalid service field.
+ * FAILURE: Not enough attribute handles available.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t GATTServApp_RegisterService( gattAttribute_t *pAttrs, uint16 numAttrs,
+ CONST gattServiceCBs_t *pServiceCBs );
+/**
+ * @brief Deregister a service's attribute list and callback functions from
+ * the GATT Server Application.
+ *
+ * NOTE: It's the caller's responsibility to free the service attribute
+ * list returned from this API.
+ *
+ * @param handle - handle of service to be deregistered
+ * @param p2pAttrs - pointer to array of attribute records (to be returned)
+ *
+ * @return SUCCESS: Service deregistered successfully.
+ * FAILURE: Service not found.
+ */
+bStatus_t GATTServApp_DeregisterService( uint16 handle, gattAttribute_t **p2pAttrs );
+
+/**
+ * @brief Find the attribute record within a service attribute
+ * table for a given attribute value pointer.
+ *
+ * @param pAttrTbl - pointer to attribute table
+ * @param numAttrs - number of attributes in attribute table
+ * @param pValue - pointer to attribute value
+ *
+ * @return Pointer to attribute record. NULL, if not found.
+ */
+extern gattAttribute_t *GATTServApp_FindAttr( gattAttribute_t *pAttrTbl,
+ uint16 numAttrs, uint8 *pValue );
+/**
+ * @brief Add function for the GATT Service.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return SUCCESS: Service added successfully.
+ * INVALIDPARAMETER: Invalid service field.
+ * FAILURE: Not enough attribute handles available.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t GATTServApp_AddService( uint32 services );
+
+/**
+ * @brief Delete function for the GATT Service.
+ *
+ * @param services - services to delete. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return SUCCESS: Service deleted successfully.
+ * FAILURE: Service not found.
+ */
+extern bStatus_t GATTServApp_DelService( uint32 services );
+
+/**
+ * @brief Set a GATT Server parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param pValue - pointer to data to write. This is dependent on the
+ * parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast
+ * to uint16 pointer).
+ *
+ * @return SUCCESS: Parameter set successful
+ * FAILURE: Parameter in use
+ * INVALIDPARAMETER: Invalid parameter
+ * bleInvalidRange: Invalid value
+ * bleMemAllocError: Memory allocation failed
+ */
+extern bStatus_t GATTServApp_SetParameter( uint8 param, uint8 len, void *pValue );
+
+/**
+ * @brief Get a GATT Server parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param pValue - pointer to data to put. This is dependent on the
+ * parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be
+ * cast to uint16 pointer).
+ *
+ * @return SUCCESS: Parameter get successful
+ * INVALIDPARAMETER: Invalid parameter
+ */
+extern bStatus_t GATTServApp_GetParameter( uint8 param, void *pValue );
+
+/**
+ * @brief Update the Client Characteristic Configuration for a given
+ * Client.
+ *
+ * Note: This API should only be called from the Bond Manager.
+ *
+ * @param connHandle - connection handle.
+ * @param attrHandle - attribute handle.
+ * @param value - characteristic configuration value.
+ *
+ * @return SUCCESS: Parameter get successful
+ * INVALIDPARAMETER: Invalid parameter
+ */
+extern bStatus_t GATTServApp_UpdateCharCfg( uint16 connHandle, uint16 attrHandle, uint16 value );
+
+/**
+ * @brief Initialize the client characteristic configuration table.
+ *
+ * Note: Each client has its own instantiation of the Client
+ * Characteristic Configuration. Reads/Writes of the Client
+ * Characteristic Configuration only only affect the
+ * configuration of that client.
+ *
+ * @param connHandle - connection handle (0xFFFF for all connections).
+ * @param charCfgTbl - client characteristic configuration table.
+ *
+ * @return none
+ */
+extern void GATTServApp_InitCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl );
+
+/**
+ * @brief Read the client characteristic configuration for a given
+ * client.
+ *
+ * Note: Each client has its own instantiation of the Client
+ * Characteristic Configuration. Reads of the Client
+ * Characteristic Configuration only shows the configuration
+ * for that client.
+ *
+ * @param connHandle - connection handle.
+ * @param charCfgTbl - client characteristic configuration table.
+ *
+ * @return attribute value
+ */
+extern uint16 GATTServApp_ReadCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl );
+
+/**
+ * @brief Write the client characteristic configuration for a given
+ * client.
+ *
+ * Note: Each client has its own instantiation of the Client
+ * Characteristic Configuration. Writes of the Client
+ * Characteristic Configuration only only affect the
+ * configuration of that client.
+ *
+ * @param connHandle - connection handle.
+ * @param charCfgTbl - client characteristic configuration table.
+ * @param value - attribute new value.
+ *
+ * @return Success or Failure
+ */
+extern uint8 GATTServApp_WriteCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl, uint16 value );
+
+/**
+ * @brief Process the client characteristic configuration
+ * write request for a given client.
+ *
+ * @param connHandle - connection message was received on.
+ * @param pAttr - pointer to attribute.
+ * @param pValue - pointer to data to be written.
+ * @param len - length of data.
+ * @param offset - offset of the first octet to be written.
+ * @param validCfg - valid configuration.
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t GATTServApp_ProcessCCCWriteReq( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset,
+ uint16 validCfg );
+
+/**
+ * @brief Process Client Charateristic Configuration change.
+ *
+ * @param charCfgTbl - characteristic configuration table.
+ * @param pValue - pointer to attribute value.
+ * @param authenticated - whether an authenticated link is required.
+ * @param attrTbl - attribute table.
+ * @param numAttrs - number of attributes in attribute table.
+ * @param taskId - task to be notified of confirmation.
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t GATTServApp_ProcessCharCfg( gattCharCfg_t *charCfgTbl, uint8 *pValue,
+ uint8 authenticated, gattAttribute_t *attrTbl,
+ uint16 numAttrs, uint8 taskId );
+
+/**
+ * @brief Build and send the GATT_CLIENT_CHAR_CFG_UPDATED_EVENT to
+ * the application.
+ *
+ * @param connHandle - connection handle
+ * @param attrHandle - attribute handle
+ * @param value - attribute new value
+ *
+ * @return none
+ */
+extern void GATTServApp_SendCCCUpdatedEvent( uint16 connHandle, uint16 attrHandle, uint16 value );
+
+/**
+ * @brief Send out a Service Changed Indication.
+ *
+ * @param connHandle - connection to use
+ * @param taskId - task to be notified of confirmation
+ *
+ * @return SUCCESS: Indication was sent successfully.
+ * FAILURE: Service Changed attribute not found.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A confirmation is pending with this client.
+ */
+extern bStatus_t GATTServApp_SendServiceChangedInd( uint16 connHandle, uint8 taskId );
+
+/**
+ * @brief Read an attribute. If the format of the attribute value
+ * is unknown to GATT Server, use the callback function
+ * provided by the Service.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param service - handle of owner service
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+extern uint8 GATTServApp_ReadAttr( uint16 connHandle, gattAttribute_t *pAttr,
+ uint16 service, uint8 *pValue, uint8 *pLen,
+ uint16 offset, uint8 maxLen );
+
+/**
+ * @brief Write attribute data
+ *
+ * @param connHandle - connection message was received on
+ * @param handle - attribute handle
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+extern uint8 GATTServApp_WriteAttr( uint16 connHandle, uint16 handle,
+ uint8 *pValue, uint16 len, uint16 offset );
+
+/**
+ * @}
+ */
+
+/**
+ * @brief Set a GATT Server Application Parameter value. Use this
+ * function to change the default GATT parameter values.
+ *
+ * @param value - new param value
+ *
+ * @return void
+ */
+extern void GATTServApp_SetParamValue( uint16 value );
+
+/**
+ * @brief Get a GATT Server Application Parameter value.
+ *
+ * @param none
+ *
+ * @return GATT Parameter value
+ */
+extern uint16 GATTServApp_GetParamValue( void );
+
+/*-------------------------------------------------------------------
+ * TASK API - These functions must only be called by OSAL.
+ */
+
+/**
+ * @internal
+ *
+ * @brief Initialize the GATT Server Test Application.
+ *
+ * @param taskId - Task identifier for the desired task
+ *
+ * @return void
+ *
+ */
+extern void GATTServApp_Init( uint8 taskId );
+
+/**
+ * @internal
+ *
+ * @brief GATT Server 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
+ */
+extern uint16 GATTServApp_ProcessEvent( uint8 taskId, uint16 events );
+
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GATTSERVAPP_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE.lib
new file mode 100644
index 0000000..68fdb87
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_bcast.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_bcast.lib
new file mode 100644
index 0000000..77cf135
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_bcast.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_bcast_cent.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_bcast_cent.lib
new file mode 100644
index 0000000..4f98b6c
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_bcast_cent.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_bcast_observ.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_bcast_observ.lib
new file mode 100644
index 0000000..6e0fa2d
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_bcast_observ.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_cent.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_cent.lib
new file mode 100644
index 0000000..16b72ea
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_cent.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_observ.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_observ.lib
new file mode 100644
index 0000000..c18f449
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_observ.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_peri.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_peri.lib
new file mode 100644
index 0000000..590db62
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_peri.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_peri_observ.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_peri_observ.lib
new file mode 100644
index 0000000..ea8f9e6
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2540DB/bin/CC2540_BLE_peri_observ.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE.lib
new file mode 100644
index 0000000..dbd7c5b
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_bcast.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_bcast.lib
new file mode 100644
index 0000000..fadeed3
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_bcast.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_bcast_cent.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_bcast_cent.lib
new file mode 100644
index 0000000..0558491
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_bcast_cent.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_bcast_observ.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_bcast_observ.lib
new file mode 100644
index 0000000..b3b0200
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_bcast_observ.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_cent.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_cent.lib
new file mode 100644
index 0000000..6c1abe3
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_cent.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_observ.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_observ.lib
new file mode 100644
index 0000000..dfbb1de
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_observ.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_peri.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_peri.lib
new file mode 100644
index 0000000..37a7c4c
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_peri.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_peri_observ.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_peri_observ.lib
new file mode 100644
index 0000000..f753183
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/CC2541DB/bin/CC2541_BLE_peri_observ.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/Common/bin/CC254x_BLE_HCI_TL_Full.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/Common/bin/CC254x_BLE_HCI_TL_Full.lib
new file mode 100644
index 0000000..9abd825
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/Common/bin/CC254x_BLE_HCI_TL_Full.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/Common/bin/CC254x_BLE_HCI_TL_None.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/Common/bin/CC254x_BLE_HCI_TL_None.lib
new file mode 100644
index 0000000..30dbded
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/Common/bin/CC254x_BLE_HCI_TL_None.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/Common/bin/CC254x_BLE_HCI_TL_PTM.lib b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/Common/bin/CC254x_BLE_HCI_TL_PTM.lib
new file mode 100644
index 0000000..21ded89
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/Libraries/Common/bin/CC254x_BLE_HCI_TL_PTM.lib differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Accelerometer/accelerometer.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Accelerometer/accelerometer.c
new file mode 100644
index 0000000..29e39cf
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Accelerometer/accelerometer.c
@@ -0,0 +1,728 @@
+/**************************************************************************************************
+ Filename: accelerometer.c
+ Revised: $Date: 2011-11-21 15:26:10 -0800 (Mon, 21 Nov 2011) $
+ Revision: $Revision: 28439 $
+
+ Description: Accelerometer Profile
+
+
+ Copyright 2009 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+
+#include "accelerometer.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+#define SERVAPP_NUM_ATTR_SUPPORTED 19
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// Accelerometer Service UUID
+CONST uint8 accServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(ACCEL_SERVICE_UUID), HI_UINT16(ACCEL_SERVICE_UUID)
+};
+
+// Accelerometer Enabler UUID
+CONST uint8 accEnablerUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(ACCEL_ENABLER_UUID), HI_UINT16(ACCEL_ENABLER_UUID)
+};
+
+// Accelerometer Range UUID
+CONST uint8 rangeUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(ACCEL_RANGE_UUID), HI_UINT16(ACCEL_RANGE_UUID)
+};
+
+// Accelerometer X-Axis Data UUID
+CONST uint8 xUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(ACCEL_X_UUID), HI_UINT16(ACCEL_X_UUID)
+};
+
+// Accelerometer Y-Axis Data UUID
+CONST uint8 yUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(ACCEL_Y_UUID), HI_UINT16(ACCEL_Y_UUID)
+};
+
+// Accelerometer Z-Axis Data UUID
+CONST uint8 zUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(ACCEL_Z_UUID), HI_UINT16(ACCEL_Z_UUID)
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+static accelCBs_t *accel_AppCBs = NULL;
+
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Accelerometer Service attribute
+static CONST gattAttrType_t accelService = { ATT_BT_UUID_SIZE, accServUUID };
+
+
+// Enabler Characteristic Properties
+static uint8 accelEnabledCharProps = GATT_PROP_READ | GATT_PROP_WRITE;
+
+// Enabler Characteristic Value
+static uint8 accelEnabled = FALSE;
+
+// Enabler Characteristic user description
+static uint8 accelEnabledUserDesc[14] = "Accel Enable\0";
+
+
+// Range Characteristic Properties
+static uint8 accelRangeCharProps = GATT_PROP_READ;
+
+// Range Characteristic Value
+static uint16 accelRange = ACCEL_RANGE_2G;
+
+// Range Characteristic user description
+static uint8 accelRangeUserDesc[13] = "Accel Range\0";
+
+
+// Accel Coordinate Characteristic Properties
+static uint8 accelXCharProps = GATT_PROP_NOTIFY;
+static uint8 accelYCharProps = GATT_PROP_NOTIFY;
+static uint8 accelZCharProps = GATT_PROP_NOTIFY;
+
+// Accel Coordinate Characteristics
+static int8 accelXCoordinates = 0;
+static int8 accelYCoordinates = 0;
+static int8 accelZCoordinates = 0;
+
+// Client Characteristic configuration. Each client has its own instantiation
+// of the Client Characteristic Configuration. Reads of the Client Characteristic
+// Configuration only shows the configuration for that client and writes only
+// affect the configuration of that client.
+
+// Accel Coordinate Characteristic Configs
+static gattCharCfg_t accelXConfigCoordinates[GATT_MAX_NUM_CONN];
+static gattCharCfg_t accelYConfigCoordinates[GATT_MAX_NUM_CONN];
+static gattCharCfg_t accelZConfigCoordinates[GATT_MAX_NUM_CONN];
+
+// Accel Coordinate Characteristic user descriptions
+static uint8 accelXCharUserDesc[20] = "Accel X-Coordinate\0";
+static uint8 accelYCharUserDesc[20] = "Accel Y-Coordinate\0";
+static uint8 accelZCharUserDesc[20] = "Accel Z-Coordinate\0";
+
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+static gattAttribute_t accelAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
+{
+ // Accelerometer Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&accelService /* pValue */
+ },
+
+ // Accel Enabler Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &accelEnabledCharProps
+ },
+
+ // Accelerometer Enable Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, accEnablerUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &accelEnabled
+ },
+
+ // Accelerometer Enable User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8*)&accelEnabledUserDesc
+ },
+
+ // Accel Range Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &accelRangeCharProps
+ },
+
+ // Accelerometer Range Char Value
+ {
+ { ATT_BT_UUID_SIZE, rangeUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8*)&accelRange
+ },
+
+ // Accelerometer Range User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ accelRangeUserDesc
+ },
+
+ // X-Coordinate Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &accelXCharProps
+ },
+
+ // X-Coordinate Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, xUUID },
+ 0,
+ 0,
+ (uint8 *)&accelXCoordinates
+ },
+
+ // X-Coordinate Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)accelXConfigCoordinates
+ },
+
+ // X-Coordinate Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ accelXCharUserDesc
+ },
+
+ // Y-Coordinate Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &accelYCharProps
+ },
+
+ // Y-Coordinate Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, yUUID },
+ 0,
+ 0,
+ (uint8 *)&accelYCoordinates
+ },
+
+ // Y-Coordinate Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)accelYConfigCoordinates
+ },
+
+ // Y-Coordinate Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ accelYCharUserDesc
+ },
+
+ // Z-Coordinate Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &accelZCharProps
+ },
+
+ // Z-Coordinate Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, zUUID },
+ 0,
+ 0,
+ (uint8 *)&accelZCoordinates
+ },
+
+ // Z-Coordinate Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)accelZConfigCoordinates
+ },
+
+ // Z-Coordinate Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ accelZCharUserDesc
+ },
+
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 accel_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t accel_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+
+static void accel_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Accelerometer Service Callbacks
+CONST gattServiceCBs_t accelCBs =
+{
+ accel_ReadAttrCB, // Read callback function pointer
+ accel_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Accel_AddService
+ *
+ * @brief Initializes the Accelerometer service by
+ * registering GATT attributes with the GATT server. Only
+ * call this function once.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Accel_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, accelXConfigCoordinates );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, accelYConfigCoordinates );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, accelZConfigCoordinates );
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( accel_HandleConnStatusCB );
+
+ if ( services & ACCEL_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( accelAttrTbl,
+ GATT_NUM_ATTRS( accelAttrTbl ),
+ &accelCBs );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Accel_RegisterAppCBs
+ *
+ * @brief Does the profile initialization. Only call this function
+ * once.
+ *
+ * @param callbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+bStatus_t Accel_RegisterAppCBs( accelCBs_t *appCallbacks )
+{
+ if ( appCallbacks )
+ {
+ accel_AppCBs = appCallbacks;
+
+ return ( SUCCESS );
+ }
+ else
+ {
+ return ( bleAlreadyInRequestedMode );
+ }
+}
+
+
+/*********************************************************************
+ * @fn Accel_SetParameter
+ *
+ * @brief Set an Accelerometer Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Accel_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case ACCEL_ENABLER:
+ if ( len == sizeof ( uint8 ) )
+ {
+ accelEnabled = *((uint8*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case ACCEL_RANGE:
+ if ( (len == sizeof ( uint16 )) && ((*((uint8*)value)) <= ACCEL_RANGE_8G) )
+ {
+ accelRange = *((uint16*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case ACCEL_X_ATTR:
+ if ( len == sizeof ( int8 ) )
+ {
+ accelXCoordinates = *((int8*)value);
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( accelXConfigCoordinates, (uint8 *)&accelXCoordinates,
+ FALSE, accelAttrTbl, GATT_NUM_ATTRS( accelAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case ACCEL_Y_ATTR:
+ if ( len == sizeof ( int8 ) )
+ {
+ accelYCoordinates = *((int8*)value);
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( accelYConfigCoordinates, (uint8 *)&accelYCoordinates,
+ FALSE, accelAttrTbl, GATT_NUM_ATTRS( accelAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case ACCEL_Z_ATTR:
+ if ( len == sizeof ( int8 ) )
+ {
+ accelZCoordinates = *((int8*)value);
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( accelZConfigCoordinates, (uint8 *)&accelZCoordinates,
+ FALSE, accelAttrTbl, GATT_NUM_ATTRS( accelAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Accel_GetParameter
+ *
+ * @brief Get an Accelerometer Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Accel_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case ACCEL_ENABLER:
+ *((uint8*)value) = accelEnabled;
+ break;
+
+ case ACCEL_RANGE:
+ *((uint16*)value) = accelRange;
+ break;
+
+ case ACCEL_X_ATTR:
+ *((int8*)value) = accelXCoordinates;
+ break;
+
+ case ACCEL_Y_ATTR:
+ *((int8*)value) = accelYCoordinates;
+ break;
+
+ case ACCEL_Z_ATTR:
+ *((int8*)value) = accelZCoordinates;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn accel_ReadAttr
+ *
+ * @brief Read an attribute.
+ *
+ * @param pAttr - pointer to attribute
+ * @param pLen - length of data to be read
+ * @param pValue - pointer to data to be read
+ * @param signature - whether to include Authentication Signature
+ *
+ * @return Success or Failure
+ */
+static uint8 accel_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+
+ // Make sure it's not a blob operation
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if ( pAttr->type.len == ATT_BT_UUID_SIZE )
+ {
+ // 16-bit UUID
+ uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
+ // gattserverapp handles those types for reads
+ case ACCEL_RANGE_UUID:
+ *pLen = 2;
+ pValue[0] = LO_UINT16( *((uint16 *)pAttr->pValue) );
+ pValue[1] = HI_UINT16( *((uint16 *)pAttr->pValue) );
+ break;
+
+ case ACCEL_ENABLER_UUID:
+ case ACCEL_X_UUID:
+ case ACCEL_Y_UUID:
+ case ACCEL_Z_UUID:
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ break;
+
+ default:
+ // Should never get here!
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+ }
+ else
+ {
+ // 128-bit UUID
+ *pLen = 0;
+ status = ATT_ERR_INVALID_HANDLE;
+ }
+
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn accel_WriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle – connection message was received on
+ * @param pReq - pointer to request
+ *
+ * @return Success or Failure
+ */
+static bStatus_t accel_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+ uint8 notify = 0xFF;
+
+ if ( pAttr->type.len == ATT_BT_UUID_SIZE )
+ {
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ case ACCEL_ENABLER_UUID:
+ //Validate the value
+ // Make sure it's not a blob oper
+ if ( offset == 0 )
+ {
+ if ( len > 1 )
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ else if ( pValue[0] != FALSE && pValue[0] != TRUE )
+ status = ATT_ERR_INVALID_VALUE;
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ //Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+
+ *pCurValue = pValue[0];
+ notify = ACCEL_ENABLER;
+ }
+
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ // Should never get here!
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ }
+ }
+ else
+ {
+ // 128-bit UUID
+ status = ATT_ERR_INVALID_HANDLE;
+ }
+
+ // If an attribute changed then callback function to notify application of change
+ if ( (notify != 0xFF) && accel_AppCBs && accel_AppCBs->pfnAccelEnabler )
+ accel_AppCBs->pfnAccelEnabler();
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn accel_HandleConnStatusCB
+ *
+ * @brief Accelerometer Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void accel_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, accelXConfigCoordinates );
+ GATTServApp_InitCharCfg( connHandle, accelYConfigCoordinates );
+ GATTServApp_InitCharCfg( connHandle, accelZConfigCoordinates );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Accelerometer/accelerometer.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Accelerometer/accelerometer.h
new file mode 100644
index 0000000..71b71bd
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Accelerometer/accelerometer.h
@@ -0,0 +1,153 @@
+/**************************************************************************************************
+ Filename: accelerometer.h
+ Revised: $Date: 2011-11-11 15:13:08 -0800 (Fri, 11 Nov 2011) $
+ Revision: $Revision: 28319 $
+
+ Description: This file contains Accelerometer Profile header file.
+
+
+ Copyright 2009 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef ACCELEROMETER_H
+#define ACCELEROMETER_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Profile Parameters
+#define ACCEL_ENABLER 0 // RW uint8 - Profile Attribute value
+#define ACCEL_X_ATTR 1 // RW int16 - Profile Attribute value
+#define ACCEL_Y_ATTR 2 // RW int16 - Profile Attribute value
+#define ACCEL_Z_ATTR 3 // RW int16 - Profile Attribute value
+#define ACCEL_RANGE 4 // RW uint16 - Profile Attribute value
+
+// Profile UUIDs
+#define ACCEL_ENABLER_UUID 0xFFA1
+#define ACCEL_RANGE_UUID 0xFFA2
+#define ACCEL_X_UUID 0xFFA3
+#define ACCEL_Y_UUID 0xFFA4
+#define ACCEL_Z_UUID 0xFFA5
+
+// Accelerometer Service UUID
+#define ACCEL_SERVICE_UUID 0xFFA0
+
+// Profile Range Values
+#define ACCEL_RANGE_2G 20
+#define ACCEL_RANGE_8G 80
+
+// Accelerometer Profile Services bit fields
+#define ACCEL_SERVICE 0x00000001
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+// Callback when the device has been started. Callback event to
+// the ask for a battery check.
+typedef NULL_OK void (*accelEnabler_t)( void );
+
+typedef struct
+{
+ accelEnabler_t pfnAccelEnabler; // Called when Enabler attribute changes
+} accelCBs_t;
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*
+ * Accel_AddService- Initializes the Accelerometer service by registering
+ * GATT attributes with the GATT server. Only call this function once.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+extern bStatus_t Accel_AddService( uint32 services );
+
+/*
+ * Accel_RegisterAppCBs - Registers the application callback function.
+ * Only call this function once.
+ *
+ * appCallbacks - pointer to application callbacks.
+ */
+extern bStatus_t Accel_RegisterAppCBs( accelCBs_t *appCallbacks );
+
+
+/*
+ * Accel_SetParameter - Set an Accelerometer Profile parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Accel_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * Accel_GetParameter - Get an Accelerometer Profile parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Accel_GetParameter( uint8 param, void *value );
+
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ACCELEROMETER_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Actimetry/actimetryservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Actimetry/actimetryservice.c
new file mode 100644
index 0000000..e90d96d
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Actimetry/actimetryservice.c
@@ -0,0 +1,709 @@
+/**************************************************************************************************
+ Filename: actimetryservice.c
+
+ Description: Actimetry Service (based on Sensor Profile)
+
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "linkdb.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+
+#include "actimetryservice.h"
+#include "wimu_util.h"
+#include "st_util.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// Actimetry Service UUID
+CONST uint8 actimetryServUUID[WIMU_ACTIMETRY_UUID_SIZE] =
+{
+ WIMU_ACTIMETRY_UUID(ACTIMETRY_SERV_UUID),
+};
+
+// Actimetry Characteristic value Imu UUID
+CONST uint8 actimetryImuUUID[WIMU_ACTIMETRY_UUID_SIZE] =
+{
+ WIMU_ACTIMETRY_UUID(ACTIMETRY_IMU_UUID),
+};
+
+// Actimetry Characteristic value Quaternion UUID
+CONST uint8 actimetryQuaternionUUID[WIMU_ACTIMETRY_UUID_SIZE] =
+{
+ WIMU_ACTIMETRY_UUID(ACTIMETRY_QUATERNION_UUID),
+};
+
+// Actimetry Characteristic value Configuration UUID
+CONST uint8 actimetryCfgUUID[WIMU_ACTIMETRY_UUID_SIZE] =
+{
+ WIMU_ACTIMETRY_UUID(ACTIMETRY_CONFIG_UUID),
+};
+
+// Actimetry Characteristic value Control UUID, used to start/stop recordings
+CONST uint8 actimetryControlUUID[WIMU_ACTIMETRY_UUID_SIZE] =
+{
+ WIMU_ACTIMETRY_UUID(ACTIMETRY_CONTROL_UUID),
+};
+
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static actimetryCBs_t *Actimetry_AppCBs = NULL;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+
+// Actimetry Profile Service attribute
+static CONST gattAttrType_t actimetryService = { WIMU_ACTIMETRY_UUID_SIZE, actimetryServUUID };
+
+// Accelerometer Characteristic Properties
+static uint8 actimetryImuProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+
+static uint8 actimetryImu[WIMU_ACTIMETRY_IMU_PACKET_SIZE] = {0};//{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14};//{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+// Actimetry Characteristic Configuration
+static gattCharCfg_t actimetryImuConfig[GATT_MAX_NUM_CONN];
+
+// Actimetry Characteristic User Description
+static uint8 actimetryImuUserDesp[19] = "Actimetry IMU Data\0";
+
+// Accelerometer Characteristic Properties
+static uint8 actimetryQuaternionProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+
+static uint8 actimetryQuaternion[WIMU_ACTIMETRY_QUATERNION_PACKET_SIZE] = { 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0};
+
+// Actimetry Characteristic Configuration
+static gattCharCfg_t actimetryQuaternionConfig[GATT_MAX_NUM_CONN];
+
+// Actimetry Characteristic User Description
+static uint8 actimetryQuaternionUserDesp[26] = "Actimetry Quaternion Data\0";
+
+// Actimetry Characteristic Configuration Properties
+static uint8 actimetryCfgProps = GATT_PROP_READ | GATT_PROP_WRITE | GATT_PROP_NOTIFY;
+
+// Actimetry Characteristic Configuration Value
+static uint8 actimetryCfg[sizeof(IMU_Config_t)];
+
+static gattCharCfg_t actimetryCfgConfig[GATT_MAX_NUM_CONN];
+
+// Actimetry Characteristic Configuration User Description
+static uint8 actimetryCfgUserDesp[17] = "Actimetry Config\0";
+
+
+// Actimetry Characteristic Configuration Value
+static uint8 actimetryControl[sizeof(RemControl_t)];
+
+static gattCharCfg_t actimetryControlConfig[GATT_MAX_NUM_CONN];
+
+
+// Actimetry Characteristic Configuration User Description
+static uint8 actimetryControlUserDesp[18] = "Actimetry Control\0";
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t sensorActimetryAttrTbl[] =
+{
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&actimetryService /* pValue */
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &actimetryImuProps
+ },
+
+ // Characteristic Value "Imu Data"
+ {
+ { WIMU_ACTIMETRY_UUID_SIZE, actimetryImuUUID },
+ GATT_PERMIT_READ,
+ 0,
+ actimetryImu
+ },
+
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)actimetryImuConfig
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ actimetryImuUserDesp
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &actimetryQuaternionProps
+ },
+ // Characteristic Value "Quaternion Data"
+ {
+ { WIMU_ACTIMETRY_UUID_SIZE, actimetryQuaternionUUID },
+ GATT_PERMIT_READ,
+ 0,
+ actimetryQuaternion
+ },
+
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)actimetryQuaternionConfig
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ actimetryQuaternionUserDesp
+ },
+ // Characteristic 2 Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &actimetryCfgProps
+ },
+
+ // Characteristic Value "Configuration"
+ {
+ { WIMU_ACTIMETRY_UUID_SIZE, actimetryCfgUUID },
+ GATT_PERMIT_READ/* | GATT_PERMIT_WRITE*/,
+ 0,
+ actimetryCfg
+ },
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ/* | GATT_PERMIT_WRITE*/,
+ 0,
+ (uint8 *)actimetryCfgConfig
+ },
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ actimetryCfgUserDesp
+ },
+
+ // Characteristic Value "Control"
+ {
+ { WIMU_ACTIMETRY_UUID_SIZE, actimetryControlUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ actimetryControl
+ },
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)actimetryControlConfig
+ },
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ actimetryControlUserDesp
+ },
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 Actimetry_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t Actimetry_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+static void Actimetry_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Simple Profile Service Callbacks
+CONST gattServiceCBs_t actimetryCBs =
+{
+ Actimetry_ReadAttrCB, // Read callback function pointer
+ Actimetry_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Actimetry_AddService
+ *
+ * @brief Initializes the Sensor Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Actimetry_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( Actimetry_HandleConnStatusCB );
+
+ if (services & ACTIMETRY_SERVICE )
+ {
+
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( sensorActimetryAttrTbl,
+ GATT_NUM_ATTRS( sensorActimetryAttrTbl ),
+ &actimetryCBs );
+ }
+
+ return ( status );
+}
+
+
+/*********************************************************************
+ * @fn Actimetry_RegisterAppCBs
+ *
+ * @brief Registers the application callback function. Only call
+ * this function once.
+ *
+ * @param callbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+
+bStatus_t Actimetry_RegisterAppCBs( actimetryCBs_t *appCallbacks )
+{
+ if ( Actimetry_AppCBs == NULL )
+ {
+ if ( appCallbacks != NULL )
+ {
+ Actimetry_AppCBs = appCallbacks;
+ }
+
+ return ( SUCCESS );
+ }
+
+ return ( bleAlreadyInRequestedMode );
+}
+
+/*********************************************************************
+ * @fn Actimetry_SetParameter
+ *
+ * @brief Set a Sensor Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to write
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Actimetry_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case ACTIMETRY_IMU:
+ if ( len == WIMU_ACTIMETRY_IMU_PACKET_SIZE )
+ {
+ VOID osal_memcpy( actimetryImu, value, WIMU_ACTIMETRY_IMU_PACKET_SIZE );
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( actimetryImuConfig, actimetryImu, FALSE,
+ sensorActimetryAttrTbl, GATT_NUM_ATTRS( sensorActimetryAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case ACTIMETRY_QUATERNION:
+ if ( len == WIMU_ACTIMETRY_QUATERNION_PACKET_SIZE )
+ {
+ VOID osal_memcpy( actimetryQuaternion, value, WIMU_ACTIMETRY_QUATERNION_PACKET_SIZE );
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( actimetryQuaternionConfig, actimetryQuaternion, FALSE,
+ sensorActimetryAttrTbl, GATT_NUM_ATTRS( sensorActimetryAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case ACTIMETRY_CONFIG:
+ if(len == sizeof ( IMU_Config_t ) )
+ {
+// actimetryCfg = *((uint8*)value);
+ osal_memcpy( actimetryCfg, value, len );
+
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case ACTIMETRY_CONTROL:
+ if(len == sizeof ( RemControl_t ) )
+ {
+ //actimetryControl = *((uint8*)value);
+ osal_memcpy( actimetryControl, value, len);
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( actimetryControlConfig, actimetryControl, FALSE,
+ sensorActimetryAttrTbl, GATT_NUM_ATTRS( sensorActimetryAttrTbl ),
+ INVALID_TASK_ID );
+
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Actimetry_GetParameter
+ *
+ * @brief Get a Actimetry Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Actimetry_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case ACTIMETRY_IMU:
+ VOID osal_memcpy (value, actimetryImu, WIMU_ACTIMETRY_IMU_PACKET_SIZE );
+ break;
+
+ case ACTIMETRY_QUATERNION:
+ VOID osal_memcpy (value, actimetryQuaternion, WIMU_ACTIMETRY_QUATERNION_PACKET_SIZE );
+ break;
+
+ case ACTIMETRY_CONFIG:
+ //*((uint8*)value) = actimetryCfg;
+ VOID osal_memcpy (value, actimetryCfg, sizeof(IMU_Config_t) );
+ break;
+
+ case ACTIMETRY_CONTROL:
+ //*((uint8*)value) = actimetryControl;
+ osal_memcpy (value, actimetryControl, sizeof(RemControl_t) );
+ break;
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Actimetry_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 Actimetry_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+
+ // If attribute permissions require authorization to read, return error
+ if ( gattPermitAuthorRead( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE) {
+ // Invalid handle
+ *pLen = 0;
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
+ // gattserverapp handles those reads
+ case ACTIMETRY_IMU_UUID:
+ *pLen = WIMU_ACTIMETRY_IMU_PACKET_SIZE;
+ VOID osal_memcpy( pValue, pAttr->pValue, WIMU_ACTIMETRY_IMU_PACKET_SIZE );
+ break;
+
+ case ACTIMETRY_QUATERNION_UUID:
+ *pLen = WIMU_ACTIMETRY_QUATERNION_PACKET_SIZE;
+ VOID osal_memcpy( pValue, pAttr->pValue, WIMU_ACTIMETRY_QUATERNION_PACKET_SIZE );
+ break;
+
+ case ACTIMETRY_CONFIG_UUID:
+ *pLen = sizeof(IMU_Config_t);
+ osal_memcpy( pValue, pAttr->pValue, sizeof(IMU_Config_t) );
+ break;
+
+ case ACTIMETRY_CONTROL_UUID:
+ //*pLen = 1;
+ //pValue[0] = *pAttr->pValue;
+ *pLen = sizeof(RemControl_t);
+ osal_memcpy( pValue, pAttr->pValue, sizeof(RemControl_t) );
+ break;
+
+ default:
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+* @fn Actimetry_WriteAttrCB
+*
+* @brief Validate attribute data prior to a write operation
+*
+* @param connHandle - connection message was received on
+* @param pAttr - pointer to attribute
+* @param pValue - pointer to data to be written
+* @param len - length of data
+* @param offset - offset of the first octet to be written
+* @param complete - whether this is the last packet
+* @param oper - whether to validate and/or write attribute value
+*
+* @return Success or Failure
+*/
+static bStatus_t Actimetry_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+ uint8 notifyApp = 0xFF;
+
+ // If attribute permissions require authorization to write, return error
+ if ( gattPermitAuthorWrite( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE) {
+ // Invalid handle
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ case ACTIMETRY_IMU_UUID:
+ //Should not get here
+ break;
+
+ case ACTIMETRY_QUATERNION_UUID:
+ //Should not get here
+ break;
+
+ case ACTIMETRY_CONFIG_UUID:
+ // Not done yet.
+
+ //Validate the value
+ // Make sure it's not a blob oper
+ /*if ( offset == 0 )
+ {
+ if ( len != 1 )
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ //Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+ *pCurValue = pValue[0];
+
+ if( pAttr->pValue == &actimetryCfg )
+ {
+ notifyApp = ACTIMETRY_CONF;
+ }
+ }*/
+ break;
+
+ case ACTIMETRY_CONTROL_UUID:
+ //Validate the value
+ // Make sure it's not a blob oper
+ if ( offset == 0 )
+ {
+ if ( len != sizeof(RemControl_t) )
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ //Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+
+ *pCurValue = pValue[0];
+
+ osal_set_event(/*WIMU_TaskID*/10, WIMU_CONTROL_EVT);
+
+ if( pAttr->pValue == (uint8*)(&actimetryControl) )
+ {
+ notifyApp = ACTIMETRY_CONTROL;
+ }
+ }
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ // Should never get here!
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ // If a charactersitic value changed then callback function to notify application of change
+ if ( (notifyApp != 0xFF ) && Actimetry_AppCBs && Actimetry_AppCBs->pfnActimetryChange )
+ {
+ Actimetry_AppCBs->pfnActimetryChange( notifyApp );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Actimetry_HandleConnStatusCB
+ *
+ * @brief Sensor Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void Actimetry_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, actimetryImuConfig );
+ GATTServApp_InitCharCfg( connHandle, actimetryQuaternionConfig );
+ GATTServApp_InitCharCfg( connHandle, actimetryCfgConfig );
+ GATTServApp_InitCharCfg( connHandle, actimetryControlConfig );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Actimetry/actimetryservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Actimetry/actimetryservice.h
new file mode 100644
index 0000000..780609d
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Actimetry/actimetryservice.h
@@ -0,0 +1,139 @@
+/**************************************************************************************************
+ Filename: actimetryservice.h
+
+ Description: Actimetry service definitions and prototypes. Based on
+ Gyroscope service from Sensors profile.
+
+ The service consists of one characteristic which stores
+ the 20-byte value defined by specification. It allows
+ to send this data via notifications or read it directly.
+
+**************************************************************************************************/
+
+#ifndef ACTIMETRYSERVICE_H
+#define ACTIMETRYSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// If uncommented 128 bit UUIDs are used
+//#define WIMU_LONG_UUIDS
+/*
+ 128 bit Version 1 UUIDs generated on http://www.uuidgenerator.net/
+ Macro as in Components\ble\include\bcomdef.h
+*/
+#ifdef WIMU_LONG_UUIDS
+# define WIMU_ACTIMETRY_UUID(uuid) 0x5e, 0xc0, 0xae, 0x91, 0x3c, 0xf2, 0x5b, 0x9f, 0xe2, 0x11, 0x93, 0xe3, LO_UINT16(uuid), HI_UINT16(uuid), 0xb3, 0x91
+# define WIMU_ACTIMETRY_UUID_SIZE ATT_UUID_SIZE
+#else
+# define WIMU_ACTIMETRY_UUID(uuid) LO_UINT16(uuid), HI_UINT16(uuid)
+# define WIMU_ACTIMETRY_UUID_SIZE ATT_BT_UUID_SIZE
+#endif
+
+// Service UUIDs
+#define ACTIMETRY_SERV_UUID 0x70ee //91b370ee-e393-11e2-9f5b-f23c91aec05e
+#define ACTIMETRY_IMU_UUID 0x7486 //91b37486-e393-11e2-9f5b-f23c91aec05e
+#define ACTIMETRY_QUATERNION_UUID 0X759d //91b3759d-e393-11e2-9f5b-f23c91aec05e
+#define ACTIMETRY_CONFIG_UUID 0x76ac //91b376ac-e393-11e2-9f5b-f23c91aec05e
+#define ACTIMETRY_CONTROL_UUID 0x76ad //91b376ad-e393-11e2-9f5b-f23c91aec05e
+
+// Profile Parameters
+#define ACTIMETRY_IMU 12 // RN uint8 - Profile Attribute value
+#define ACTIMETRY_QUATERNION 13 // RN uint8 - Profile Attribute value
+#define ACTIMETRY_CONFIG 14 // RW uint8 - Profile Attribute value
+#define ACTIMETRY_CONTROL 15 // RW uint8 - Profile Attribute value
+
+// Actimetry control flags
+#define ACT_CTRL_FLAG_REC 0x0001
+
+// Sensor Profile Services bit fields
+#define ACTIMETRY_SERVICE 0x00000020
+
+// Length of sensor data in bytes
+#define ACTIMETRY_IMU_LEN 20
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// Callback when a characteristic value has changed
+typedef NULL_OK void (*actimetryChange_t)( uint8 paramID );
+
+typedef struct
+{
+ actimetryChange_t pfnActimetryChange; // Called when characteristic value changes
+} actimetryCBs_t;
+
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+
+/*
+ * Actimetry_AddService- Initializes the Sensor GATT Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+extern bStatus_t Actimetry_AddService( uint32 services );
+
+/*
+ * Actimetry_RegisterAppCBs - Registers the application callback function.
+ * Only call this function once.
+ *
+ * appCallbacks - pointer to application callbacks.
+ */
+extern bStatus_t Actimetry_RegisterAppCBs( actimetryCBs_t *appCallbacks );
+
+/*
+ * Actimetry_SetParameter - Set a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to write
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Actimetry_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * Actimetry_GetParameter - Get a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Actimetry_GetParameter( uint8 param, void *value );
+
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ACTIMETRYSERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Batt/battservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Batt/battservice.c
new file mode 100644
index 0000000..d60630f
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Batt/battservice.c
@@ -0,0 +1,426 @@
+/**************************************************************************************************
+ Filename: battservice.c
+ Revised: $Date $
+ Revision: $Revision $
+
+ Description: This file contains the Battery service.
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "hal_adc.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "hid_uuid.h"
+#include "hiddev.h"
+
+#include "battservice.h"
+#include "wimu_util.h"
+#include "st_util.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// ADC voltage level
+#define BATT_ADC_LEVEL_3V 409
+#define BATT_ADC_LEVEL_2V 273
+
+#define BATT_LEVEL_VALUE_IDX 2 // Position of battery level in attribute array
+#define BATT_LEVEL_VALUE_CCCD_IDX 3 // Position of battery level CCCD in attribute array
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+// Battery service
+CONST uint8 battServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(BATT_SERVICE_UUID), HI_UINT16(BATT_SERVICE_UUID)
+};
+
+// Battery level characteristic
+CONST uint8 battLevelUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(BATT_LEVEL_UUID), HI_UINT16(BATT_LEVEL_UUID)
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+// Application callback
+//static battServiceCB_t battServiceCB;
+
+static batteryCBs_t *Battery_AppCBs = NULL;
+
+// Measurement setup callback
+//static battServiceSetupCB_t battServiceSetupCB = NULL;
+
+// Measurement teardown callback
+//static battServiceTeardownCB_t battServiceTeardownCB = NULL;
+
+// Measurement calculation callback
+//static battServiceCalcCB_t battServiceCalcCB = NULL;
+
+//static uint16 battMinLevel = BATT_ADC_LEVEL_2V; // For VDD/3 measurements
+//static uint16 battMaxLevel = BATT_ADC_LEVEL_3V; // For VDD/3 measurements*/
+
+// Critical battery level setting
+
+// ADC channel to be used for reading
+//static uint8 battServiceAdcCh = HAL_ADC_CHANNEL_VDD;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Battery Service attribute
+static CONST gattAttrType_t battService = { ATT_BT_UUID_SIZE, battServUUID };
+
+// Battery level characteristic
+static uint8 battLevelProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+static uint8 battLevel = 0;
+static gattCharCfg_t battLevelClientCharCfg[GATT_MAX_NUM_CONN];
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t battAttrTbl[] =
+{
+ // Battery Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&battService /* pValue */
+ },
+
+ // Battery Level Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &battLevelProps
+ },
+
+ // Battery Level Value
+ {
+ { ATT_BT_UUID_SIZE, battLevelUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &battLevel
+ },
+
+ // Battery Level Client Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)battLevelClientCharCfg
+ }
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 battReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t battWriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+//static void battNotifyCB( linkDBItem_t *pLinkItem );
+//static uint8 battMeasure( void );
+//static void battNotifyLevel( void );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Battery Service Callbacks
+CONST gattServiceCBs_t battCBs =
+{
+ battReadAttrCB, // Read callback function pointer
+ battWriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Batt_AddService
+ *
+ * @brief Initializes the Battery Service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Batt_AddService( void )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, battLevelClientCharCfg );
+
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( battAttrTbl,
+ GATT_NUM_ATTRS( battAttrTbl ),
+ &battCBs );
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Batt_Register
+ *
+ * @brief Register a callback function with the Battery Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return None.
+ */
+bStatus_t Batt_Register( batteryCBs_t *appCallbacks )
+{
+ if ( Battery_AppCBs == NULL )
+ {
+ if ( appCallbacks != NULL )
+ {
+ Battery_AppCBs = appCallbacks;
+ }
+
+ return ( SUCCESS );
+ }
+
+ return ( bleAlreadyInRequestedMode );
+}
+/*********************************************************************
+ * @fn Batt_SetParameter
+ *
+ * @brief Set a Battery Service parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Batt_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case BATT_PARAM_LEVEL:
+ if ( len == WIMU_BATTERY_PACKET_SIZE )
+ {
+ battLevel = *((uint8*)value);
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( battLevelClientCharCfg, &battLevel, FALSE,
+ battAttrTbl, GATT_NUM_ATTRS( battAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Batt_GetParameter
+ *
+ * @brief Get a Battery Service parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Batt_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case BATT_PARAM_LEVEL:
+ *((uint8*)value) = battLevel;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn battReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+
+static uint8 battReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ bStatus_t status = SUCCESS;
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1] );
+
+ // Measure battery level if reading level
+ if ( uuid == BATT_LEVEL_UUID )
+ {
+ *pLen = WIMU_BATTERY_PACKET_SIZE;
+ VOID osal_memcpy( pValue, pAttr->pValue, WIMU_BATTERY_PACKET_SIZE );
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn battWriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t battWriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Batt_HandleConnStatusCB
+ *
+ * @brief Battery Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+void Batt_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{/*
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, battLevelClientCharCfg );
+ }
+ }*/
+}
+
+
+/*********************************************************************
+*********************************************************************/
+
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Batt/battservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Batt/battservice.h
new file mode 100644
index 0000000..81a7a70
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Batt/battservice.h
@@ -0,0 +1,167 @@
+/**************************************************************************************************
+ Filename: battservice.h
+ Revised: $Date $
+ Revision: $Revision $
+
+ Description: This file contains the Battery service definitions and
+ prototypes.
+
+ Copyright 2011-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef BATTSERVICE_H
+#define BATTSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+// Battery Service UUIDs
+#define BATT_SERVICE_UUID 0x180F // Battery Service
+#define BATT_LEVEL_UUID 0x2A19 // Battery Level
+
+// Battery Service Get/Set Parameters
+#define BATT_PARAM_LEVEL 0
+
+// Callback events
+#define BATT_LEVEL_NOTI_ENABLED 1
+#define BATT_LEVEL_NOTI_DISABLED 2
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Battery Service callback function
+//typedef void (*battServiceCB_t)(uint8 event);
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// Callback when a characteristic value has changed
+typedef NULL_OK void (*batteryChange_t)( uint8 paramID );
+
+typedef struct
+{
+ batteryChange_t pfnBatteryChange; // Called when characteristic value changes
+} batteryCBs_t;
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Batt_AddService
+ *
+ * @brief Initializes the Battery service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t Batt_AddService( void );
+
+/*********************************************************************
+ * @fn Batt_Register
+ *
+ * @brief Register a callback function with the Battery Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return None.
+ */
+extern bStatus_t Batt_Register( batteryCBs_t *appCallbacks );
+
+/*********************************************************************
+ * @fn Batt_SetParameter
+ *
+ * @brief Set a Battery Service parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+extern bStatus_t Batt_SetParameter( uint8 param, uint8 len, void *value );
+
+/*********************************************************************
+ * @fn Batt_GetParameter
+ *
+ * @brief Get a Battery parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+extern bStatus_t Batt_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+ * @fn Batt_HandleConnStatusCB
+ *
+ * @brief Battery Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+void Batt_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BATTSERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/BloodPressure/bpservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/BloodPressure/bpservice.c
new file mode 100644
index 0000000..736fc7a
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/BloodPressure/bpservice.c
@@ -0,0 +1,577 @@
+/**************************************************************************************************
+ Filename: bpservice.c
+ Revised: $Date $
+ Revision: $Revision $
+
+ Description: This file contains the BloodPressure sample service
+ for use with the BloodPressure sample application.
+
+ Copyright 2011 - 2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "gapbondmgr.h"
+#include "bpservice.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Position of bloodPressure measurement value in attribute array
+#define BLOODPRESSURE_MEAS_VALUE_POS 2
+#define BLOODPRESSURE_MEAS_CONFIG_POS 3
+#define BLOODPRESSURE_IMEAS_VALUE_POS 6
+#define BLOODPRESSURE_IMEAS_CONFIG_POS 7
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// BloodPressure service
+CONST uint8 bloodPressureServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(BLOODPRESSURE_SERV_UUID), HI_UINT16(BLOODPRESSURE_SERV_UUID)
+};
+
+// BloodPressure temperature characteristic
+CONST uint8 bloodPressureTempUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(BLOODPRESSURE_MEAS_UUID), HI_UINT16(BLOODPRESSURE_MEAS_UUID)
+};
+
+// BloodPressure Immediate Measurement
+CONST uint8 bloodPressureImeasUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(BLOODPRESSURE_IMEAS_UUID), HI_UINT16(BLOODPRESSURE_IMEAS_UUID)
+};
+
+// BloodPressure Feature
+CONST uint8 bpFeatureUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(BLOODPRESSURE_FEATURE_UUID), HI_UINT16(BLOODPRESSURE_FEATURE_UUID)
+};
+
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static bloodPressureServiceCB_t bloodPressureServiceCB;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// BloodPressure Service attribute
+static CONST gattAttrType_t bloodPressureService = { ATT_BT_UUID_SIZE, bloodPressureServUUID };
+
+// BloodPressure Characteristic
+static uint8 bloodPressureTempProps = GATT_PROP_INDICATE;
+static gattCharCfg_t bloodPressureMeasConfig[GATT_MAX_NUM_CONN];
+static uint8 bloodPressureTemp = 0;
+static uint8 bloodPressureTempFormat = 12;
+
+// Intermediate Measurement
+static uint8 bloodPressureImeasProps = GATT_PROP_NOTIFY;
+static uint8 bloodPressureImeas=0;
+static gattCharCfg_t bloodPressureIMeasConfig[GATT_MAX_NUM_CONN];
+
+// BP Feature
+ /*
+ bit 1 Body Movement Detection Support bit
+ bit 2 Cuff Fit Detection Support bit
+ bit 3 Irregular Pulse Detection Support bit
+ bit 4 Pulse Rate Range Detection Support bit
+ bit 5 Measurement Position Detection Support bit
+ bit 6 Multiple Bond Support bit
+ bit . Reserved for Future Use
+ */
+static uint8 bpFeatureProps = GATT_PROP_READ;
+static uint16 bpFeature = 0;
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t bloodPressureAttrTbl[] =
+{
+ // BloodPressure Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&bloodPressureService /* pValue */
+ },
+
+ // 1. Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &bloodPressureTempProps
+ },
+
+ // 2. Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, bloodPressureTempUUID },
+ 0, //return READ_NOT_PERMITTED
+ 0,
+ &bloodPressureTemp
+ },
+
+ // 3.Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)&bloodPressureMeasConfig
+ },
+ // 4.Presentation Format
+ {
+ { ATT_BT_UUID_SIZE, charFormatUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *)&bloodPressureTempFormat
+ },
+
+
+ //////////////////////////////////////////////
+ // IMMEDIATE MEASUREMENT
+ //////////////////////////////////////////////
+
+ // 5.Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &bloodPressureImeasProps
+ },
+
+ // 6.Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, bloodPressureImeasUUID },
+ 0, //return READ_NOT_PERMITTED
+ 0,
+ &bloodPressureImeas
+ },
+
+ // 7.Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)&bloodPressureIMeasConfig
+ },
+
+
+ //////////////////////////////////////////////
+ // FEATURE
+ //////////////////////////////////////////////
+
+ // 8.Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &bpFeatureProps
+ },
+
+ // 9.Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, bpFeatureUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *)&bpFeature
+ },
+
+
+
+
+};
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 bloodPressure_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t bloodPressure_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+
+static void bloodPressure_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Blood Pressure Service Callbacks
+CONST gattServiceCBs_t bloodPressureCBs =
+{
+ bloodPressure_ReadAttrCB, // Read callback function pointer
+ bloodPressure_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn BloodPressure_AddService
+ *
+ * @brief Initializes the BloodPressure service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t BloodPressure_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, bloodPressureMeasConfig );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, bloodPressureIMeasConfig );
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( bloodPressure_HandleConnStatusCB );
+
+ if ( services & BLOODPRESSURE_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( bloodPressureAttrTbl,
+ GATT_NUM_ATTRS( bloodPressureAttrTbl ),
+ &bloodPressureCBs );
+
+ }
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn BloodPressure_Register
+ *
+ * @brief Register a callback function with the BloodPressure Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return None.
+ */
+extern void BloodPressure_Register( bloodPressureServiceCB_t pfnServiceCB )
+{
+ bloodPressureServiceCB = pfnServiceCB;
+}
+
+/*********************************************************************
+ * @fn BloodPressure_SetParameter
+ *
+ * @brief Set a thermomter parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t BloodPressure_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn BloodPressure_GetParameter
+ *
+ * @brief Get a BloodPressure parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t BloodPressure_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn BloodPressure_MeasIndicate
+ *
+ * @brief Send a indication containing a bloodPressure
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+bStatus_t BloodPressure_MeasIndicate( uint16 connHandle, attHandleValueInd_t *pNoti,uint8 taskId )
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, bloodPressureMeasConfig );
+
+ // If indications enabled
+ if ( value & GATT_CLIENT_CFG_INDICATE )
+ {
+ // Set the handle
+ pNoti->handle = bloodPressureAttrTbl[BLOODPRESSURE_MEAS_VALUE_POS].handle;
+
+ // Send the Indication
+ return GATT_Indication( connHandle, pNoti, FALSE, taskId );
+ }
+
+ return bleIncorrectMode;
+}
+
+
+/*********************************************************************
+ * @fn BloodPressure_IMeasNotify
+ *
+ * @brief Send a notification containing a bloodPressure
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+bStatus_t BloodPressure_IMeasNotify( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId )
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, bloodPressureIMeasConfig );
+
+ // If notifications enabled
+ if ( value & GATT_CLIENT_CFG_NOTIFY )
+ {
+ // Set the handle
+ pNoti->handle = bloodPressureAttrTbl[BLOODPRESSURE_IMEAS_VALUE_POS].handle;
+
+ // Send the Indication
+ return GATT_Notification( connHandle, pNoti, FALSE);
+
+ }
+ return bleIncorrectMode;
+
+}
+
+/*********************************************************************
+ * @fn bloodPressure_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 bloodPressure_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ bStatus_t status = SUCCESS;
+
+ // If attribute permissions require authorization to read, return error
+ if ( gattPermitAuthorRead( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if ( pAttr->type.len == ATT_BT_UUID_SIZE )
+ {
+ // 16-bit UUID
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+
+ case BLOODPRESSURE_FEATURE_UUID:
+ {
+ *pLen = 2;
+ pValue[0] = 0;
+ pValue[1] = 0;
+ }
+ break;
+ default:
+ // Should never get here! (characteristics 3 and 4 do not have read permissions)
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+ }
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn bloodPressure_WriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t bloodPressure_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ if ( pAttr->handle == bloodPressureAttrTbl[BLOODPRESSURE_MEAS_CONFIG_POS].handle )
+ {
+ // BloodPressure Indications
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_INDICATE );
+ if ( status == SUCCESS )
+ {
+ uint16 value = BUILD_UINT16( pValue[0], pValue[1] );
+
+ (*bloodPressureServiceCB)( (value == GATT_CFG_NO_OPERATION) ?
+ BLOODPRESSURE_MEAS_NOTI_DISABLED :
+ BLOODPRESSURE_MEAS_NOTI_ENABLED);
+ }
+ }
+ else if ( pAttr->handle == bloodPressureAttrTbl[BLOODPRESSURE_IMEAS_CONFIG_POS].handle )
+ {
+ // BloodPressure Notifications
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ if ( status == SUCCESS )
+ {
+ uint16 value = BUILD_UINT16( pValue[0], pValue[1] );
+
+ (*bloodPressureServiceCB)( (value == GATT_CFG_NO_OPERATION) ?
+ BLOODPRESSURE_IMEAS_NOTI_DISABLED :
+ BLOODPRESSURE_IMEAS_NOTI_ENABLED );
+ }
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_HANDLE;
+ }
+ break;
+
+ default:
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+
+}
+
+
+/*********************************************************************
+ * @fn bloodPressure_HandleConnStatusCB
+ *
+ * @brief Simple Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void bloodPressure_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, bloodPressureMeasConfig );
+ GATTServApp_InitCharCfg( connHandle, bloodPressureIMeasConfig );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/BloodPressure/bpservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/BloodPressure/bpservice.h
new file mode 100644
index 0000000..4b8b9a6
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/BloodPressure/bpservice.h
@@ -0,0 +1,205 @@
+/**************************************************************************************************
+ Filename: bpService.h
+ Revised: $Date $
+ Revision: $Revision $
+
+ Description: This file contains the BloodPressure service definitions and
+ prototypes.
+
+ Copyright 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef BLOODPRESSURESERVICE_H
+#define BLOODPRESSURESERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// BloodPressure Service Parameters
+#define BLOODPRESSURE_MEAS 0
+#define BLOODPRESSURE_MEAS_CHAR_CFG 1
+#define BLOODPRESSURE_IMEAS_CHAR_CFG 2
+#define BLOODPRESSURE_TIMESTAMP 3
+#define BLOODPRESSURE_PULSE 4
+#define BLOODPRESSURE_INTERVAL 5
+
+// Length of measurements
+#define BLOODPRESSURE_TIMESTAMP_LEN 7 //length of timestamp
+#define BLOODPRESSURE_TIME_LEN 7 //length of timestamp
+#define BLOODPRESSURE_INTERVAL_LEN 1
+
+// BloodPressure Service UUIDs
+#define BLOODPRESSURE_SERV_UUID 0x1810
+#define BLOODPRESSURE_MEAS_UUID 0x2A35 //bp measurement
+#define BLOODPRESSURE_IMEAS_UUID 0x2A36 //intermediate
+#define BLOODPRESSURE_FEATURE_UUID 0x2A49 //intermediate
+
+// Maximum length of blood pressure measurement characteristic
+#define BLOODPRESSURE_MEAS_MAX (ATT_MTU_SIZE -5)
+
+// Values for flags
+#define BLOODPRESSURE_FLAGS_MMHG 0x00
+#define BLOODPRESSURE_FLAGS_KPA 0x01
+#define BLOODPRESSURE_FLAGS_TIMESTAMP 0x02
+#define BLOODPRESSURE_FLAGS_PULSE 0x04
+#define BLOODPRESSURE_FLAGS_USER 0x08
+#define BLOODPRESSURE_FLAGS_STATUS 0x10
+
+
+// Values for sensor location
+#define BLOODPRESSURE_SITE_ARMPIT 0x01
+#define BLOODPRESSURE_SITE_BODY 0x02
+#define BLOODPRESSURE_SITE_EAR 0x03
+#define BLOODPRESSURE_SITE_FINGER 0x04
+#define BLOODPRESSURE_SITE_GASTRO 0x05
+#define BLOODPRESSURE_SITE_MOUTH 0x06
+#define BLOODPRESSURE_SITE_RECTUM 0x07
+#define BLOODPRESSURE_SITE_TOE 0x08
+#define BLOODPRESSURE_SITE_TYMPNUM 0x09
+
+// BloodPressure Service bit fields
+#define BLOODPRESSURE_SERVICE 0x00000001
+
+// Callback events
+#define BLOODPRESSURE_MEAS_NOTI_ENABLED 1
+#define BLOODPRESSURE_MEAS_NOTI_DISABLED 2
+#define BLOODPRESSURE_IMEAS_NOTI_ENABLED 3
+#define BLOODPRESSURE_IMEAS_NOTI_DISABLED 4
+#define BLOODPRESSURE_TIME_SET 5
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// BloodPressure Service callback function
+typedef void (*bloodPressureServiceCB_t)(uint8 event);
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*
+ * BloodPressure_AddService- Initializes the BloodPressure service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+
+extern bStatus_t BloodPressure_AddService( uint32 services );
+
+/*
+ * BloodPressure_Register - Register a callback function with the
+ * BloodPressure Service
+ *
+ * @param pfnServiceCB - Callback function.
+ */
+
+extern void BloodPressure_Register( bloodPressureServiceCB_t pfnServiceCB );
+
+/*
+ * BloodPressure_SetParameter - Set a BloodPressure parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t BloodPressure_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * BloodPressure_GetParameter - Get a BloodPressure parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t BloodPressure_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+ * @fn BloodPressure_MeasIndicate
+ *
+ * @brief Send a notification containing a blood pressure
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t BloodPressure_MeasIndicate( uint16 connHandle, attHandleValueInd_t *pNoti, uint8 taskId );
+
+
+
+
+/*********************************************************************
+ * @fn BloodPressure_IMeasNotify
+ *
+ * @brief Send a notification containing a blood pressure
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t BloodPressure_IMeasNotify( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BLOODPRESSURESERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/CSC/cyclingservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/CSC/cyclingservice.c
new file mode 100644
index 0000000..6636f20
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/CSC/cyclingservice.c
@@ -0,0 +1,860 @@
+/**************************************************************************************************
+ Filename: cyclingservice.c
+ Revised: $Date: 2013-04-04 15:28:09 -0700 (Thu, 04 Apr 2013) $
+ Revision: $Revision: 33765 $
+
+ Description: This file contains the Cycling Speed and Cadence (CSC) service
+ for use with the CyclingApp sample application.
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "cyclingservice.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+// Cycling Service Task Events
+#define CSC_CMD_IND_SEND_EVT 0x0001
+
+#define CSC_MEAS_VALUE_POS 2
+#define CSC_MEAS_CFG_POS 3
+#define CSC_COMMAND_VALUE_POS 9
+#define CSC_COMMAND_CFG_POS 10
+#define COMMAND_IND_LENGTH 2
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// CSC service
+CONST uint8 cyclingServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(CSC_SERV_UUID), HI_UINT16(CSC_SERV_UUID)
+};
+
+// CSC measurement characteristic
+CONST uint8 cyclingMeasUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(CSC_MEAS_UUID), HI_UINT16(CSC_MEAS_UUID)
+};
+
+// CSC feature characteristic
+CONST uint8 cyclingFeatureUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(CSC_FEATURE_UUID), HI_UINT16(CSC_FEATURE_UUID)
+};
+
+// CSC sensor location characteristic
+CONST uint8 cyclingSensLocUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(CSC_SENS_LOC_UUID), HI_UINT16(CSC_SENS_LOC_UUID)
+};
+
+// CSC command characteristic
+CONST uint8 cyclingCommandUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(CSC_COMMAND_UUID), HI_UINT16(CSC_COMMAND_UUID)
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static cyclingServiceCB_t cyclingServiceCB = NULL;
+
+static uint8 supportedSensors = 0;
+static bool scOpInProgress = FALSE;
+
+// Variables used in CSC command processing
+static uint16 connectionHandle;
+static attHandleValueInd_t cscCmdInd;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// TaskID
+uint8 cyclingService_TaskID = 0;
+
+// CSC Service attribute
+static CONST gattAttrType_t cyclingService = { ATT_BT_UUID_SIZE, cyclingServUUID };
+
+// Available sensor locations
+static uint8 supportedSensorLocations[CSC_MAX_SENSOR_LOCS];
+
+// Cycling Measurement Characteristic
+// Note: characteristic value is not stored here
+static uint8 cyclingMeasProps = GATT_PROP_NOTIFY;
+static uint8 cyclingMeas = 0;
+static gattCharCfg_t cyclingMeasClientCharCfg[GATT_MAX_NUM_CONN];
+
+// Feature Characteristic
+static uint8 cyclingFeatureProps = GATT_PROP_READ;
+static uint16 cyclingFeatures = CSC_NO_SUPPORT;
+
+
+// Sensor Location Characteristic
+static uint8 cyclingSensLocProps = GATT_PROP_READ;
+static uint8 cyclingSensLoc = CSC_SENSOR_LOC_TOP_OF_SHOE;
+
+// Command Characteristic
+static uint8 cyclingCommandProps = GATT_PROP_WRITE | GATT_PROP_INDICATE;
+static uint8 cyclingCommand = 0;
+static gattCharCfg_t cyclingCommandClientCharCfg[GATT_MAX_NUM_CONN];
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t cyclingAttrTbl[] =
+{
+ // CSC Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&cyclingService /* pValue */
+ },
+
+ // CSC Measurement Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &cyclingMeasProps
+ },
+
+ // Measurement Value
+ {
+ { ATT_BT_UUID_SIZE, cyclingMeasUUID },
+ 0,
+ 0,
+ &cyclingMeas
+ },
+
+ // Measurement Client Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &cyclingMeasClientCharCfg
+ },
+
+ // CSC Feature Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &cyclingFeatureProps
+ },
+
+ // Feature Value
+ {
+ { ATT_BT_UUID_SIZE, cyclingFeatureUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) &cyclingFeatures
+ },
+
+ // CSC Sensor Location Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &cyclingSensLocProps
+ },
+
+ // Sensor Location Value
+ {
+ { ATT_BT_UUID_SIZE, cyclingSensLocUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &cyclingSensLoc
+ },
+
+ // CSC Command Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &cyclingCommandProps
+ },
+
+ // Command Value
+ {
+ { ATT_BT_UUID_SIZE, cyclingCommandUUID },
+ GATT_PERMIT_WRITE,
+ 0,
+ &cyclingCommand
+ },
+
+ // Command Client Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &cyclingCommandClientCharCfg
+ }
+};
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+
+static uint8 cycling_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t cycling_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+static void cycling_ProcessOSALMsg( osal_event_hdr_t *pMsg );
+static void cycling_ProcessGATTMsg( gattMsgEvent_t *pMsg );
+static bool cycling_SensorLocSupported( uint8 sensorLoc );
+static void cycling_ProcessCSCCmd( uint16 attrHandle, uint8 *pValue, uint8 len );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+
+// CSC Service Callbacks
+CONST gattServiceCBs_t cyclingCBs =
+{
+ cycling_ReadAttrCB, // Read callback function pointer
+ cycling_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn CyclingService_Init
+ *
+ * @brief collect the OSAL task ID.
+ *
+ * @param task_id - OSAL task ID.
+ *
+ * @return none
+ */
+void CyclingService_Init( uint8 task_id )
+{
+ // Only purpose is to obtain task ID
+ cyclingService_TaskID = task_id;
+}
+
+/*********************************************************************
+ * @fn CyclingService_ProcessEvent
+ *
+ * @brief process incoming event.
+ *
+ * @param task_id - OSAL task id.
+ *
+ * @param events - event bit(s) set for the task(s)
+ *
+ * @return none
+ */
+uint16 CyclingService_ProcessEvent( uint8 task_id, uint16 events )
+{
+ VOID task_id;
+
+ if ( events & SYS_EVENT_MSG )
+ {
+ uint8 *pMsg;
+
+ if ( (pMsg = osal_msg_receive( cyclingService_TaskID )) != NULL )
+ {
+ cycling_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 & CSC_CMD_IND_SEND_EVT )
+ {
+ GATT_Indication( connectionHandle, &cscCmdInd, FALSE, cyclingService_TaskID );
+
+ // Set Control Point Cfg done
+ scOpInProgress = FALSE;
+
+ return ( events ^ CSC_CMD_IND_SEND_EVT );
+ }
+
+ return 0;
+}
+
+/*********************************************************************
+ * @fn cycling_ProcessOSALMsg
+ *
+ * @brief process incoming OSAL msg.
+ *
+ * @param pMsg- pointer to messag to be read.
+ *
+ * @return none
+ */
+void cycling_ProcessOSALMsg( osal_event_hdr_t *pMsg )
+{
+ switch ( pMsg->event )
+ {
+ case GATT_MSG_EVENT:
+ cycling_ProcessGATTMsg( (gattMsgEvent_t *) pMsg );
+ break;
+
+ default: // do nothing
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn cycling_ProcessGATTMsg
+ *
+ * @brief process incoming GATT msg.
+ *
+ * @param pMsg- pointer to messag to be read.
+ *
+ * @return none
+ */
+void cycling_ProcessGATTMsg( gattMsgEvent_t *pMsg )
+{
+ if ( pMsg->method == ATT_HANDLE_VALUE_CFM )
+ {
+ // Indication receipt was confirmed by the client.
+ // This is a placeholder for future.
+ }
+}
+
+/*********************************************************************
+ * @fn cycling_SensorLocSupported
+ *
+ * @brief check to see if sensor location is supported
+ *
+ * @param sensorLoc - location to check for
+ *
+ * @return TRUE if supported, FALSE otherwise
+ */
+static bool cycling_SensorLocSupported( uint8 sensorLoc )
+{
+ uint8 i;
+ for (i = 0; i <= supportedSensors; i++)
+ {
+ if (supportedSensorLocations[i] == sensorLoc)
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/*********************************************************************
+ * @fn Cycling_AddService
+ *
+ * @brief Initializes the CSC service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Cycling_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, cyclingMeasClientCharCfg );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, cyclingCommandClientCharCfg);
+
+ if ( services & CYCLING_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( cyclingAttrTbl,
+ GATT_NUM_ATTRS( cyclingAttrTbl ),
+ &cyclingCBs );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Cycling_Register
+ *
+ * @brief Register a callback function with the CSC Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return None.
+ */
+void Cycling_Register( cyclingServiceCB_t pfnServiceCB )
+{
+ cyclingServiceCB = pfnServiceCB;
+}
+
+
+/*********************************************************************
+ * @fn Cycling_SetParameter
+ *
+ * @brief Set a CSC parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Cycling_SetParameter( uint8 param, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case CSC_SENS_LOC:
+ cyclingSensLoc = *((uint8*)pValue);
+ break;
+
+ case CSC_FEATURE:
+ cyclingFeatures = *((uint8*)pValue);
+ break;
+
+ case CSC_AVAIL_SENS_LOCS:
+ if (supportedSensors < CSC_MAX_SENSOR_LOCS)
+ {
+ supportedSensorLocations[supportedSensors++] = *((uint8*)pValue);
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Cycling_GetParameter
+ *
+ * @brief Get a CSC parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Cycling_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case CSC_FEATURE:
+ *((uint8*)value) = cyclingFeatures;
+
+ case CSC_SENS_LOC:
+ *((uint8*)value) = cyclingSensLoc;
+ break;
+
+ case CSC_COMMAND:
+ *((uint8*)value) = cyclingCommand;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Cycling_MeasNotify
+ *
+ * @brief Send a notification containing a CSC
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+bStatus_t Cycling_MeasNotify( uint16 connHandle, attHandleValueNoti_t *pNoti )
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, cyclingMeasClientCharCfg );
+
+ // If notifications enabled
+ if ( value & GATT_CLIENT_CFG_NOTIFY )
+ {
+ // Set the handle
+ pNoti->handle = cyclingAttrTbl[CSC_MEAS_VALUE_POS].handle;
+
+ // Send the notification
+ return GATT_Notification( connHandle, pNoti, FALSE );
+ }
+
+ return bleIncorrectMode;
+}
+
+ /*********************************************************************
+ * @fn cycling_ProcessCSCCmd
+ *
+ * @brief process an incoming CSC command.
+ *
+ * @param attrHandle - attribute handle
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ *
+ * @return none
+ */
+static void cycling_ProcessCSCCmd( uint16 attrHandle, uint8 *pValue, uint8 len )
+{
+ uint8 cscStatus = CSC_SUCCESS;
+
+ // Set Control Point Cfg in progress
+ scOpInProgress = TRUE;
+
+ // Set indication info to be sent out
+ cscCmdInd.handle = attrHandle;
+
+ cscCmdInd.len = 3;
+ cscCmdInd.value[0] = CSC_COMMAND_RSP;
+ cscCmdInd.value[1] = pValue[0];
+
+ switch ( pValue[0] )
+ {
+ case CSC_SET_CUMM_VAL:
+ // If wheel revolutions is a feature
+ if ( ( len <= 5 ) && ( cyclingFeatures & CSC_WHEEL_REV_SUPP ) )
+ {
+ uint32 cummWheelRevolutions;
+
+ // full 32 bits were specified.
+ if (( len - 1 ) == 4)
+ {
+ cummWheelRevolutions = BUILD_UINT32( pValue[1], pValue[2], pValue[3], pValue[4]);
+ }
+ else
+ {
+ cummWheelRevolutions = 0;
+
+ // In case only lower bits were specified and upper bits remain zero.
+ for( int i = 0; i < (len - 1); ++i )
+ {
+ cummWheelRevolutions += pValue[i + 1] << (i*8);
+ }
+ }
+
+ // Notify app
+ if ( cyclingServiceCB != NULL )
+ {
+ (*cyclingServiceCB)( CSC_CMD_SET_CUMM_VAL, &cummWheelRevolutions );
+ }
+ }
+ else // characteristic not supported.
+ {
+ cscStatus = CSC_INVALID_PARAMETER;
+ }
+ break;
+
+ case CSC_UPDATE_SENS_LOC:
+ // If multiple sensor locations is supported and that this is a valid location.
+ if ( ( len == 2 ) &&
+ ( cyclingFeatures & CSC_MULTI_SENS_SUPP ) &&
+ ( cycling_SensorLocSupported( pValue[1] ) == TRUE ) )
+ {
+ // Update sensor location
+ cyclingSensLoc = pValue[1];
+
+ // Notify app
+ if ( cyclingServiceCB != NULL )
+ {
+ (*cyclingServiceCB)( CSC_CMD_UPDATE_SENS_LOC, NULL );
+ }
+ }
+ else // characteristic not supported.
+ {
+ cscStatus = CSC_INVALID_PARAMETER;
+ }
+ break;
+
+ case CSC_REQ_SUPP_SENS_LOC:
+ // If multiple sensor locations are supported and list requested
+ if ( ( len == 1 ) && ( cyclingFeatures & CSC_MULTI_SENS_SUPP ) )
+ {
+ cscCmdInd.len += supportedSensors;
+ osal_memcpy( &(cscCmdInd.value[3]), supportedSensorLocations, supportedSensors );
+ }
+ else // characteristic not supported.
+ {
+ // Send an indication with the list.
+ cscStatus = CSC_INVALID_PARAMETER;
+ }
+ break;
+
+ default:
+ // Send an indication with opcode not suported response
+ cscStatus = CSC_OPCODE_NOT_SUPPORTED;
+ break;
+ }
+
+ // Send indication of operation result
+ cscCmdInd.value[2] = cscStatus;
+
+ // Ask our task to send out indication
+ osal_set_event( cyclingService_TaskID, CSC_CMD_IND_SEND_EVT );
+}
+
+/*********************************************************************
+ * @fn Cycling_HandleConnStatusCB
+ *
+ * @brief CSC Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+void Cycling_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, cyclingMeasClientCharCfg );
+ GATTServApp_InitCharCfg( connHandle, cyclingCommandClientCharCfg );
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn cycling_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 cycling_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ bStatus_t status = SUCCESS;
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+
+ switch ( uuid )
+ {
+ case CSC_SENS_LOC_UUID:
+ {
+ // Read Sensor Location
+ *pLen = 1;
+ pValue[0] = pAttr->pValue[0];
+ }
+ break;
+
+ case CSC_FEATURE_UUID:
+ {
+ //Read Cycling Feature
+ *pLen = 2;
+ pValue[0] = LO_UINT16(pAttr->pValue[0]);
+ pValue[1] = HI_UINT16(pAttr->pValue[0]);
+ }
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ {
+ // Read Measurement or Command Configuration
+ if ( pAttr->pValue == (uint8*)cyclingMeasClientCharCfg )
+ {
+ *pLen = 1;
+ pValue[0] = GATTServApp_ReadCharCfg(connHandle, cyclingMeasClientCharCfg );
+ }
+ else if ( pAttr->pValue == (uint8*)cyclingCommandClientCharCfg )
+ {
+ *pLen = 1;
+ pValue[0] = GATTServApp_ReadCharCfg(connHandle, cyclingCommandClientCharCfg );
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ }
+ }
+ break;
+
+ default:
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ // Notify app
+ if ( cyclingServiceCB != NULL )
+ {
+ (*cyclingServiceCB)( CSC_READ_ATTR, NULL );
+ }
+
+ return ( status );
+}
+
+
+/*********************************************************************
+ * @fn cycling_WriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t cycling_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+
+ if ( offset > 0 )
+ {
+ return (ATT_ERR_ATTR_NOT_LONG);
+ }
+
+ switch ( uuid )
+ {
+ case CSC_COMMAND_UUID:
+ // Make sure Control Point Cfg is not already in progress
+ if ( scOpInProgress == TRUE )
+ {
+ status = CSC_ERR_PROC_IN_PROGRESS;
+ }
+ // Make sure Control Point Cfg is configured for Indications
+ else if ( (cyclingCommandClientCharCfg[connHandle].value & GATT_CLIENT_CFG_INDICATE) == FALSE )
+ {
+ status = CSC_ERR_CCC_IMPROPER_CFG;
+ }
+ else
+ {
+ // Process CSC command
+ cycling_ProcessCSCCmd( pAttr->handle, pValue, len );
+ connectionHandle = connHandle;
+ }
+ break;
+
+ // For Measure and Commands CCC
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ if ( pAttr->handle == cyclingAttrTbl[CSC_COMMAND_CFG_POS].handle )
+ {
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_INDICATE );
+ // Notify app
+ if ( cyclingServiceCB != NULL )
+ {
+ (*cyclingServiceCB)( CSC_WRITE_ATTR, NULL );
+ }
+ }
+ else if ( pAttr->handle == cyclingAttrTbl[CSC_MEAS_CFG_POS].handle )
+ {
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ if ( status == SUCCESS )
+ {
+ // Notify app
+ if ( cyclingServiceCB != NULL )
+ {
+ uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );
+
+ (*cyclingServiceCB)( ((charCfg == GATT_CFG_NO_OPERATION) ?
+ CSC_MEAS_NOTI_DISABLED :
+ CSC_MEAS_NOTI_ENABLED ), NULL );
+ }
+ }
+ }
+ break;
+
+ default:
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+*********************************************************************/
\ No newline at end of file
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/CSC/cyclingservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/CSC/cyclingservice.h
new file mode 100644
index 0000000..7a87319
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/CSC/cyclingservice.h
@@ -0,0 +1,269 @@
+/**************************************************************************************************
+ Filename: cyclingservice.h
+ Revised: $Date: 2013-04-04 14:51:24 -0700 (Thu, 04 Apr 2013) $
+ Revision: $Revision: 33758 $
+
+ Description: This file contains the Cycling Speed and Cadence (CSC) service
+ definitions and prototypes.
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+
+**************************************************************************************************/
+
+#ifndef CYCLINGSERVICE_H
+#define CYCLINGSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+#define CYCLING_SERVICE 0x00000001
+
+//ATT Error Codes
+#define CSC_ERR_PROC_IN_PROGRESS 0x80
+#define CSC_ERR_CCC_IMPROPER_CFG 0x81
+
+#define CSC_SUCCESS 1
+#define CSC_OPCODE_NOT_SUPPORTED 2
+#define CSC_INVALID_PARAMETER 3
+
+//CSC Service Parameters
+#define CSC_MEAS 1
+#define CSC_MEAS_CHAR_CFG 2
+#define CSC_FEATURE 3
+#define CSC_SENS_LOC 4
+#define CSC_COMMAND 5
+#define CSC_COMMAND_CHAR_CFG 6
+#define CSC_AVAIL_SENS_LOCS 7
+
+//CSC Service UUID's
+#define CSC_SERV_UUID 0x1816
+#define CSC_MEAS_UUID 0x2A5B
+#define CSC_FEATURE_UUID 0x2A5C
+#define CSC_SENS_LOC_UUID 0x2A5D
+#define CSC_COMMAND_UUID 0x2A55
+
+//CSC Fields
+#define CSC_WHEEL_REV_PRESENT 0x01
+#define CSC_CRANK_REV_PRESENT 0x02
+
+//CSC SUPPORTED FEATURES
+#define CSC_NO_SUPPORT 0x00
+#define CSC_WHEEL_REV_SUPP 0x01
+#define CSC_CRANK_REV_SUPP 0x02
+#define CSC_MULTI_SENS_SUPP 0x04
+#define CSC_FULL_SUPPORT 0x07
+
+//CSC Censor Locations
+#define CSC_SENSOR_LOC_OTHER 0
+#define CSC_SENSOR_LOC_TOP_OF_SHOE 1
+#define CSC_SENSOR_LOC_IN_SHOE 2
+#define CSC_SENSOR_LOC_HIP 3
+#define CSC_SENSOR_LOC_FRONT_WHEEL 4
+#define CSC_SENSOR_LOC_LEFT_CRANK 5
+#define CSC_SENSOR_LOC_RIGHT_CRANK 6
+#define CSC_SENSOR_LOC_LEFT_PEDAL 7
+#define CSC_SENSOR_LOC_RIGHT_PEDAL 8
+#define CSC_SENSOR_LOC_FRONT_HUB 9
+#define CSC_SENSOR_LOC_REAR_DROPOUT 10
+#define CSC_SENSOR_LOC_CHAINSTAY 11
+#define CSC_SENSOR_LOC_REAR_WHEEL 12
+#define CSC_SENSOR_LOC_REAR_HUB 13
+
+//Spec says there are 14 possible.
+#define CSC_MAX_SENSOR_LOCS 14
+
+//CSC Commands
+#define CSC_SET_CUMM_VAL 1
+#define CSC_START_SENS_CALIB 2
+#define CSC_UPDATE_SENS_LOC 3
+#define CSC_REQ_SUPP_SENS_LOC 4
+#define CSC_COMMAND_RSP 16
+
+// Values for flags
+#define CSC_FLAGS_AT_REST 0x00
+#define CSC_FLAGS_SPEED 0x01
+#define CSC_FLAGS_CADENCE 0x02
+#define CSC_FLAGS_SPEED_CADENCE 0x03
+
+
+#define DEFAULT_NOTI_INTERVAL 1000 // in milliseconds
+
+#define VALUE_ROLL_OVER 64000 // in milliseconds
+
+// Callback events
+#define CSC_CMD_SET_CUMM_VAL 1
+#define CSC_CMD_START_SENS_CALIB 2
+#define CSC_CMD_UPDATE_SENS_LOC 3
+#define CSC_MEAS_NOTI_ENABLED 4
+#define CSC_MEAS_NOTI_DISABLED 5
+#define CSC_READ_ATTR 6
+#define CSC_WRITE_ATTR 7
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// CSC service callback function
+typedef void (*cyclingServiceCB_t)( uint8 event, uint32 *pNewCummVal );
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+
+/*********************************************************************
+ * @fn CyclingService_Init
+ *
+ * @brief collect the OSAL task ID.
+ *
+ * @param task_id - OSAL task ID.
+ *
+ * @return none
+ */
+extern void CyclingService_Init( uint8 task_id );
+
+/*********************************************************************
+ * @fn CyclingService_ProcessEvent
+ *
+ * @brief process incoming event.
+ *
+ * @param task_id - OSAL task id.
+ *
+ * @param events - event bit(s) set for the task(s)
+ *
+ * @return remaining event bits
+ */
+extern uint16 CyclingService_ProcessEvent( uint8 task_id, uint16 events );
+
+/*
+ * @fn Cycling_AddService
+ *
+ * @brief Initializes the CSC service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+extern bStatus_t Cycling_AddService( uint32 services );
+
+/*
+ * @fn Cycling_Register
+ *
+ * @brief Register a callback function with the
+ * CSC Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return none
+ */
+
+extern void Cycling_Register( cyclingServiceCB_t pfnServiceCB );
+
+/*
+ * @fn Cycling_SetParameter
+ *
+ * @brief Set a CSC parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Cycling_SetParameter( uint8 param, uint8 len, void *value );
+
+/*********************************************************************
+ * @fn Cycling_GetParameter
+ *
+ * @brief Get a CSC parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Cycling_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+ * @fn Cycling_MeasNotify
+ *
+ * @brief Send a notification containing a CSC
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t Cycling_MeasNotify( uint16 connHandle, attHandleValueNoti_t *pNoti );
+
+/*********************************************************************
+ * @fn Cycling_HandleConnStatusCB
+ *
+ * @brief CSC Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+extern void Cycling_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CYCLINGSERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/DevInfo/devinfoservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/DevInfo/devinfoservice.c
new file mode 100644
index 0000000..6c19324
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/DevInfo/devinfoservice.c
@@ -0,0 +1,684 @@
+/**************************************************************************************************
+ Filename: devinfoservice.c
+ Revised: $Date $
+ Revision: $Revision $
+
+ Description: This file contains the Device Information service.
+
+
+ Copyright 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+
+#include "devinfoservice.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+// Device information service
+CONST uint8 devInfoServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(DEVINFO_SERV_UUID), HI_UINT16(DEVINFO_SERV_UUID)
+};
+
+// System ID
+CONST uint8 devInfoSystemIdUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(DEVINFO_SYSTEM_ID_UUID), HI_UINT16(DEVINFO_SYSTEM_ID_UUID)
+};
+
+// Model Number String
+CONST uint8 devInfoModelNumberUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(DEVINFO_MODEL_NUMBER_UUID), HI_UINT16(DEVINFO_MODEL_NUMBER_UUID)
+};
+
+// Serial Number String
+CONST uint8 devInfoSerialNumberUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(DEVINFO_SERIAL_NUMBER_UUID), HI_UINT16(DEVINFO_SERIAL_NUMBER_UUID)
+};
+
+// Firmware Revision String
+CONST uint8 devInfoFirmwareRevUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(DEVINFO_FIRMWARE_REV_UUID), HI_UINT16(DEVINFO_FIRMWARE_REV_UUID)
+};
+
+// Hardware Revision String
+CONST uint8 devInfoHardwareRevUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(DEVINFO_HARDWARE_REV_UUID), HI_UINT16(DEVINFO_HARDWARE_REV_UUID)
+};
+
+// Software Revision String
+CONST uint8 devInfoSoftwareRevUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(DEVINFO_SOFTWARE_REV_UUID), HI_UINT16(DEVINFO_SOFTWARE_REV_UUID)
+};
+
+// Manufacturer Name String
+CONST uint8 devInfoMfrNameUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(DEVINFO_MANUFACTURER_NAME_UUID), HI_UINT16(DEVINFO_MANUFACTURER_NAME_UUID)
+};
+
+// IEEE 11073-20601 Regulatory Certification Data List
+CONST uint8 devInfo11073CertUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(DEVINFO_11073_CERT_DATA_UUID), HI_UINT16(DEVINFO_11073_CERT_DATA_UUID)
+};
+
+// PnP ID
+CONST uint8 devInfoPnpIdUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(DEVINFO_PNP_ID_UUID), HI_UINT16(DEVINFO_PNP_ID_UUID)
+};
+
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Device Information Service attribute
+static CONST gattAttrType_t devInfoService = { ATT_BT_UUID_SIZE, devInfoServUUID };
+
+// System ID characteristic
+static uint8 devInfoSystemIdProps = GATT_PROP_READ;
+static uint8 devInfoSystemId[DEVINFO_SYSTEM_ID_LEN] = {0, 0, 0, 0, 0, 0, 0, 0};
+
+// Model Number String characteristic
+static uint8 devInfoModelNumberProps = GATT_PROP_READ;
+static const uint8 devInfoModelNumber[] = "WIMU3";
+
+// Serial Number String characteristic
+static uint8 devInfoSerialNumberProps = GATT_PROP_READ;
+static uint8 devInfoSerialNumber[DEVINFO_SERIAL_NUMBER_LEN] = {0, 0};
+
+// Firmware Revision String characteristic
+static uint8 devInfoFirmwareRevProps = GATT_PROP_READ;
+static uint8 devInfoFirmwareRev[DEVINFO_FIRMSOFT_REVISION_LEN] = {0};
+
+// Hardware Revision String characteristic
+static uint8 devInfoHardwareRevProps = GATT_PROP_READ;
+static uint8 devInfoHardwareRev[DEVINFO_HARD_REVISION_LEN] = {0, 0};
+
+// Software Revision String characteristic
+static uint8 devInfoSoftwareRevProps = GATT_PROP_READ;
+static uint8 devInfoSoftwareRev[DEVINFO_FIRMSOFT_REVISION_LEN] = {0};
+
+// Manufacturer Name String characteristic
+static uint8 devInfoMfrNameProps = GATT_PROP_READ;
+static const uint8 devInfoMfrName[] = "CDRV";
+
+// IEEE 11073-20601 Regulatory Certification Data List characteristic
+static uint8 devInfo11073CertProps = GATT_PROP_READ;
+static const uint8 devInfo11073Cert[] =
+{
+ DEVINFO_11073_BODY_EXP, // authoritative body type
+ 0x00, // authoritative body structure type
+ // authoritative body data follows below:
+ 'e', 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l'
+};
+
+// System ID characteristic
+static uint8 devInfoPnpIdProps = GATT_PROP_READ;
+static uint8 devInfoPnpId[DEVINFO_PNP_ID_LEN] =
+{
+ 1, // Vendor ID source (1=Bluetooth SIG)
+ LO_UINT16(0x000D), HI_UINT16(0x000D), // Vendor ID (Texas Instruments)
+ LO_UINT16(0x0000), HI_UINT16(0x0000), // Product ID (vendor-specific)
+ LO_UINT16(0x0110), HI_UINT16(0x0110) // Product version (JJ.M.N)
+};
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t devInfoAttrTbl[] =
+{
+ // Device Information Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&devInfoService /* pValue */
+ },
+
+ // System ID Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &devInfoSystemIdProps
+ },
+
+ // System ID Value
+ {
+ { ATT_BT_UUID_SIZE, devInfoSystemIdUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) devInfoSystemId
+ },
+
+ // Model Number String Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &devInfoModelNumberProps
+ },
+
+ // Model Number Value
+ {
+ { ATT_BT_UUID_SIZE, devInfoModelNumberUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) devInfoModelNumber
+ },
+
+ // Serial Number String Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &devInfoSerialNumberProps
+ },
+
+ // Serial Number Value
+ {
+ { ATT_BT_UUID_SIZE, devInfoSerialNumberUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) devInfoSerialNumber
+ },
+
+ // Firmware Revision String Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &devInfoFirmwareRevProps
+ },
+
+ // Firmware Revision Value
+ {
+ { ATT_BT_UUID_SIZE, devInfoFirmwareRevUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) devInfoFirmwareRev
+ },
+
+ // Hardware Revision String Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &devInfoHardwareRevProps
+ },
+
+ // Hardware Revision Value
+ {
+ { ATT_BT_UUID_SIZE, devInfoHardwareRevUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) devInfoHardwareRev
+ },
+
+ // Software Revision String Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &devInfoSoftwareRevProps
+ },
+
+ // Software Revision Value
+ {
+ { ATT_BT_UUID_SIZE, devInfoSoftwareRevUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) devInfoSoftwareRev
+ },
+
+ // Manufacturer Name String Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &devInfoMfrNameProps
+ },
+
+ // Manufacturer Name Value
+ {
+ { ATT_BT_UUID_SIZE, devInfoMfrNameUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) devInfoMfrName
+ },
+
+ // IEEE 11073-20601 Regulatory Certification Data List Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &devInfo11073CertProps
+ },
+
+ // IEEE 11073-20601 Regulatory Certification Data List Value
+ {
+ { ATT_BT_UUID_SIZE, devInfo11073CertUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) devInfo11073Cert
+ },
+
+ // PnP ID Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &devInfoPnpIdProps
+ },
+
+ // PnP ID Value
+ {
+ { ATT_BT_UUID_SIZE, devInfoPnpIdUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) devInfoPnpId
+ }
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 devInfo_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Device Info Service Callbacks
+CONST gattServiceCBs_t devInfoCBs =
+{
+ devInfo_ReadAttrCB, // Read callback function pointer
+ NULL, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * NETWORK LAYER CALLBACKS
+ */
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn DevInfo_AddService
+ *
+ * @brief Initializes the Device Information service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @return Success or Failure
+ */
+bStatus_t DevInfo_AddService( void )
+{
+ // Register GATT attribute list and CBs with GATT Server App
+ return GATTServApp_RegisterService( devInfoAttrTbl,
+ GATT_NUM_ATTRS( devInfoAttrTbl ),
+ &devInfoCBs );
+}
+
+/*********************************************************************
+ * @fn DevInfo_SetParameter
+ *
+ * @brief Set a Device Information parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to write
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t DevInfo_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case DEVINFO_SYSTEM_ID:
+ osal_memcpy(devInfoSystemId, value, len);
+ break;
+
+ case DEVINFO_SERIAL_NUMBER:
+ osal_memcpy(devInfoSerialNumber, value, len);
+ break;
+
+ case DEVINFO_FIRMWARE_REV:
+ osal_memcpy(devInfoFirmwareRev, value, len);
+ break;
+
+ case DEVINFO_HARDWARE_REV:
+ osal_memcpy(&devInfoHardwareRev, value, len);
+ break;
+
+ case DEVINFO_SOFTWARE_REV:
+ osal_memcpy(devInfoSoftwareRev, value, len);
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn DevInfo_GetParameter
+ *
+ * @brief Get a Device Information parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t DevInfo_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case DEVINFO_SYSTEM_ID:
+ osal_memcpy(value, devInfoSystemId, sizeof(devInfoSystemId));
+ break;
+
+ case DEVINFO_MODEL_NUMBER:
+ osal_memcpy(value, devInfoModelNumber, sizeof(devInfoModelNumber));
+ break;
+ case DEVINFO_SERIAL_NUMBER:
+ osal_memcpy(value, devInfoSerialNumber, sizeof(devInfoSerialNumber));
+ break;
+
+ case DEVINFO_FIRMWARE_REV:
+ osal_memcpy(value, devInfoFirmwareRev, sizeof(devInfoFirmwareRev));
+ break;
+
+ case DEVINFO_HARDWARE_REV:
+ osal_memcpy(value, &devInfoHardwareRev, sizeof(devInfoHardwareRev));
+ break;
+
+ case DEVINFO_SOFTWARE_REV:
+ osal_memcpy(value, devInfoSoftwareRev, sizeof(devInfoSoftwareRev));
+ break;
+
+ case DEVINFO_MANUFACTURER_NAME:
+ osal_memcpy(value, devInfoMfrName, sizeof(devInfoMfrName));
+ break;
+
+ case DEVINFO_11073_CERT_DATA:
+ osal_memcpy(value, devInfo11073Cert, sizeof(devInfo11073Cert));
+ break;
+
+ case DEVINFO_PNP_ID:
+ osal_memcpy(value, devInfoPnpId, sizeof(devInfoPnpId));
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn devInfo_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 devInfo_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ bStatus_t status = SUCCESS;
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+
+ switch (uuid)
+ {
+ case DEVINFO_SYSTEM_ID_UUID:
+ // verify offset
+ if (offset >= sizeof(devInfoSystemId))
+ {
+ status = ATT_ERR_INVALID_OFFSET;
+ }
+ else
+ {
+ // determine read length
+ *pLen = MIN(maxLen, (sizeof(devInfoSystemId) - offset));
+
+ // copy data
+ osal_memcpy(pValue, &devInfoSystemId[offset], *pLen);
+ }
+ break;
+
+ case DEVINFO_MODEL_NUMBER_UUID:
+ // verify offset
+ if (offset >= sizeof(devInfoModelNumber))
+ {
+ status = ATT_ERR_INVALID_OFFSET;
+ }
+ else
+ {
+ // determine read length
+ *pLen = MIN(maxLen, (sizeof(devInfoModelNumber) - offset));
+
+ // copy data
+ osal_memcpy(pValue, &devInfoModelNumber[offset], *pLen);
+ }
+ break;
+
+ case DEVINFO_SERIAL_NUMBER_UUID:
+ // verify offset
+ if (offset >= sizeof(devInfoSerialNumber))
+ {
+ status = ATT_ERR_INVALID_OFFSET;
+ }
+ else
+ {
+ // determine read length
+ *pLen = MIN(maxLen, (sizeof(devInfoSerialNumber) - offset));
+
+ // copy data
+ osal_memcpy(pValue, &devInfoSerialNumber[offset], *pLen);
+ }
+ break;
+
+ case DEVINFO_FIRMWARE_REV_UUID:
+ // verify offset
+ if (offset >= sizeof(devInfoFirmwareRev))
+ {
+ status = ATT_ERR_INVALID_OFFSET;
+ }
+ else
+ {
+ // determine read length
+ *pLen = MIN(maxLen, (sizeof(devInfoFirmwareRev) - offset));
+
+ // copy data
+ osal_memcpy(pValue, pAttr->pValue + offset, *pLen);
+ }
+ break;
+
+ case DEVINFO_HARDWARE_REV_UUID:
+ // verify offset
+ if (offset >= sizeof(devInfoHardwareRev))
+ {
+ status = ATT_ERR_INVALID_OFFSET;
+ }
+ else
+ {
+ // determine read length
+ *pLen = MIN(maxLen, (sizeof(devInfoHardwareRev) - offset));;
+
+ // copy data
+ osal_memcpy(pValue, pAttr->pValue + offset, *pLen);
+ }
+ break;
+
+ case DEVINFO_SOFTWARE_REV_UUID:
+ // verify offset
+ if (offset >= sizeof(devInfoSoftwareRev))
+ {
+ status = ATT_ERR_INVALID_OFFSET;
+ }
+ else
+ {
+ // determine read length
+ *pLen = MIN(maxLen, (sizeof(devInfoSoftwareRev) - offset));
+
+ // copy data
+ osal_memcpy(pValue, pAttr->pValue + offset, *pLen);
+ }
+ break;
+
+ case DEVINFO_MANUFACTURER_NAME_UUID:
+ // verify offset
+ if (offset >= sizeof(devInfoMfrName))
+ {
+ status = ATT_ERR_INVALID_OFFSET;
+ }
+ else
+ {
+ // determine read length
+ *pLen = MIN(maxLen, (sizeof(devInfoMfrName) - offset));
+
+ // copy data
+ osal_memcpy(pValue, &devInfoMfrName[offset], *pLen);
+ }
+ break;
+
+ case DEVINFO_11073_CERT_DATA_UUID:
+ // verify offset
+ if (offset >= sizeof(devInfo11073Cert))
+ {
+ status = ATT_ERR_INVALID_OFFSET;
+ }
+ else
+ {
+ // determine read length
+ *pLen = MIN(maxLen, (sizeof(devInfo11073Cert) - offset));
+
+ // copy data
+ osal_memcpy(pValue, &devInfo11073Cert[offset], *pLen);
+ }
+ break;
+
+ case DEVINFO_PNP_ID_UUID:
+ // verify offset
+ if (offset >= sizeof(devInfoPnpId))
+ {
+ status = ATT_ERR_INVALID_OFFSET;
+ }
+ else
+ {
+ // determine read length
+ *pLen = MIN(maxLen, (sizeof(devInfoPnpId) - offset));
+
+ // copy data
+ osal_memcpy(pValue, &devInfoPnpId[offset], *pLen);
+ }
+ break;
+
+ default:
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/DevInfo/devinfoservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/DevInfo/devinfoservice.h
new file mode 100644
index 0000000..0ac5c49
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/DevInfo/devinfoservice.h
@@ -0,0 +1,155 @@
+/**************************************************************************************************
+ Filename: devinfoservice.h
+ Revised: $Date $
+ Revision: $Revision $
+
+ Description: This file contains the Device Information service definitions and
+ prototypes.
+
+
+ Copyright 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef DEVINFOSERVICE_H
+#define DEVINFOSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Device Information Service Parameters
+#define DEVINFO_SYSTEM_ID 0
+#define DEVINFO_MODEL_NUMBER 1
+#define DEVINFO_SERIAL_NUMBER 2
+#define DEVINFO_FIRMWARE_REV 3
+#define DEVINFO_HARDWARE_REV 4
+#define DEVINFO_SOFTWARE_REV 5
+#define DEVINFO_MANUFACTURER_NAME 6
+#define DEVINFO_11073_CERT_DATA 7
+#define DEVINFO_PNP_ID 8
+
+// Device Information Service UUIDs
+#define DEVINFO_SERV_UUID 0x180A // Service UUID
+#define DEVINFO_SYSTEM_ID_UUID 0x2A23 // System ID
+#define DEVINFO_MODEL_NUMBER_UUID 0x2A24 // Model Number String
+#define DEVINFO_SERIAL_NUMBER_UUID 0x2A25 // Serial Number String
+#define DEVINFO_FIRMWARE_REV_UUID 0x2A26 // Firmware Revision String
+#define DEVINFO_HARDWARE_REV_UUID 0x2A27 // Hardware Revision String
+#define DEVINFO_SOFTWARE_REV_UUID 0x2A28 // Software Revision String
+#define DEVINFO_MANUFACTURER_NAME_UUID 0x2A29 // Manufacturer Name String
+#define DEVINFO_11073_CERT_DATA_UUID 0x2A2A // IEEE 11073-20601 Regulatory Certification Data List
+#define DEVINFO_PNP_ID_UUID 0x2A50 // PnP ID
+
+// IEEE 11073 authoritative body values
+#define DEVINFO_11073_BODY_EMPTY 0
+#define DEVINFO_11073_BODY_IEEE 1
+#define DEVINFO_11073_BODY_CONTINUA 2
+#define DEVINFO_11073_BODY_EXP 254
+
+// System ID length
+#define DEVINFO_SYSTEM_ID_LEN 8
+
+ // PnP ID length
+#define DEVINFO_PNP_ID_LEN 7
+
+
+#define DEVINFO_SERIAL_NUMBER_LEN 2
+#define DEVINFO_FIRMSOFT_REVISION_LEN 29
+#define DEVINFO_HARD_REVISION_LEN 2
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*
+ * DevInfo_AddService- Initializes the Device Information service by registering
+ * GATT attributes with the GATT server.
+ *
+ */
+
+extern bStatus_t DevInfo_AddService( void );
+
+/*********************************************************************
+ * @fn DevInfo_SetParameter
+ *
+ * @brief Set a Device Information parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t DevInfo_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * DevInfo_GetParameter - Get a Device Information parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t DevInfo_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DEVINFOSERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/GPS/gpsservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/GPS/gpsservice.c
new file mode 100644
index 0000000..182b93f
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/GPS/gpsservice.c
@@ -0,0 +1,559 @@
+/**************************************************************************************************
+ Filename: gpsprofile.c
+ Creation: Date: 2015-07-23
+
+ Description: Gps profile (based on simpleGATT Profile)
+
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "gapbondmgr.h"
+
+#include "gpsservice.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+#define SERVAPP_NUM_ATTR_SUPPORTED 11
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+// Simple GATT Profile Service UUID: 0xFFF0
+CONST uint8 gpsServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(GPS_SERV_UUID), HI_UINT16(GPS_SERV_UUID)
+};
+
+// GPS_FEATURES_UUID
+CONST uint8 gpsFeaturesUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(GPS_FEATURES_UUID), HI_UINT16(GPS_FEATURES_UUID)
+};
+
+// GPS_LOCATION_AND_SPEED_UUID
+CONST uint8 gpsLocationAndSpeedUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(GPS_LOCATION_AND_SPEED_UUID), HI_UINT16(GPS_LOCATION_AND_SPEED_UUID)
+};
+
+// GPS_DATE_TIME_UUID
+CONST uint8 gpsDateTimeUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(GPS_DATE_TIME_UUID), HI_UINT16(GPS_DATE_TIME_UUID)
+};
+
+// GPS_POSITION_QUALITY_UUID
+CONST uint8 gpsPositionQualityUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(GPS_POSITION_QUALITY_UUID), HI_UINT16(GPS_POSITION_QUALITY_UUID)
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Gps Service attribute
+static CONST gattAttrType_t gpsService = { ATT_BT_UUID_SIZE, gpsServUUID };
+
+// gpsFeatures Properties
+static uint8 gpsFeaturesProps = GATT_PROP_READ;
+
+// gpsFeatures Value
+static uint8 gpsFeatures[4] = {0x00, 0x00, 0x60, 0x5D};
+
+// gpsLocationAndSpeed Properties
+static uint8 gpsLocationAndSpeedProps = GATT_PROP_NOTIFY;
+
+// gpsLocationAndSpeed Value
+static uint8 gpsLocationAndSpeed[17] = {0x00, 0x00, // flags
+ 0x00, 0x00, // speed
+ 0x00, 0x00, 0x00, 0x00, // latitude
+ 0x00, 0x00, 0x00, 0x00, // longitude
+ 0x00, 0x00, 0x00, // elevation
+ 0x00, 0x00}; // heading
+
+static gattCharCfg_t gpsLocationAndSpeedClientCharCfg[GATT_MAX_NUM_CONN];
+
+// gpsDateTime Properties
+static uint8 gpsDateTimeProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+
+// gpsDateTime Value
+static uint8 gpsDateTime[7] = { 0x00, 0x00, // year
+ 0x00, // month
+ 0x00, // day
+ 0x00, // hours
+ 0x00, // minutes
+ 0x00}; // seconds
+
+static gattCharCfg_t gpsDateTimeClientCharCfg[GATT_MAX_NUM_CONN];
+
+// gpsPositionQuality Properties
+static uint8 gpsPositionQualityProps = GATT_PROP_READ;// | GATT_PROP_NOTIFY; notifications are excluded
+
+// gpsPositionQuality Value
+static uint8 gpsPositionQuality[16] = {0x00, 0x00, // flags
+ 0x00, // nb of Beacons in Solution
+ 0x00, // nb of Beacons in View
+ 0x00, 0x00, // Time to First Fix
+ 0x00, 0x00, 0x00, 0x00, // EHPE
+ 0x00, 0x00, 0x00, 0x00, // EVPE
+ 0x00, // HDOP
+ 0x00}; // VDOP
+
+//static gattCharCfg_t gpsPositionQualityClientCharCfg[GATT_MAX_NUM_CONN];
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t gpsAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
+{
+ // Simple Profile Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&gpsService /* pValue */
+ },
+
+ // gpsFeatures Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &gpsFeaturesProps
+ },
+
+ // gpsFeatures Value
+ {
+ { ATT_BT_UUID_SIZE, gpsFeaturesUUID },
+ GATT_PERMIT_READ,
+ 0,
+ gpsFeatures
+ },
+
+ // gpsLocationAndSpeed Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &gpsLocationAndSpeedProps
+ },
+
+ // gpsLocationAndSpeed Value
+ {
+ { ATT_BT_UUID_SIZE, gpsLocationAndSpeedUUID },
+ GATT_PERMIT_READ,
+ 0,
+ gpsLocationAndSpeed
+ },
+
+ // gpsLocationAndSpeed Client Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)gpsLocationAndSpeedClientCharCfg
+ },
+
+ // gpsDateTime Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &gpsDateTimeProps
+ },
+
+ // gpsDateTime Value
+ {
+ { ATT_BT_UUID_SIZE, gpsDateTimeUUID },
+ GATT_PERMIT_READ,
+ 0,
+ gpsDateTime
+ },
+
+ // gpsDateTime Client Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)gpsDateTimeClientCharCfg
+ },
+
+ // gpsPositionQuality Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &gpsPositionQualityProps
+ },
+
+ // gpsPositionQuality Value
+ {
+ { ATT_BT_UUID_SIZE, gpsPositionQualityUUID },
+ GATT_PERMIT_READ,
+ 0,
+ gpsPositionQuality
+ }/*, // Notifications are excluded
+
+ // gpsPositionQuality Client Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)gpsPositionQualityClientCharCfg
+ }*/
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 gps_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t gps_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+
+static void gps_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Gps Profile Service Callbacks
+CONST gattServiceCBs_t gpsCBs =
+{
+ gps_ReadAttrCB, // Read callback function pointer
+ gps_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Gps_AddService
+ *
+ * @brief Initializes the Gps Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Gps_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, gpsLocationAndSpeedClientCharCfg );
+
+ // Notifications are excluded
+ //GATTServApp_InitCharCfg( INVALID_CONNHANDLE, gpsPositionQualityClientCharCfg );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, gpsDateTimeClientCharCfg );
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( gps_HandleConnStatusCB );
+
+ if ( services & GPS_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( gpsAttrTbl,
+ GATT_NUM_ATTRS( gpsAttrTbl ),
+ &gpsCBs );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Gps_SetParameter
+ *
+ * @brief Set a Gps Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Gps_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case GPS_FEATURES:
+ if ( len == sizeof(gpsFeatures) )
+ {
+ VOID osal_memcpy( gpsFeatures, value, sizeof(gpsFeatures) );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GPS_LOCATION_AND_SPEED:
+ if ( len == WIMU_GPS_LOCATION_AND_SPEED_PACKET_SIZE )
+ {
+ VOID osal_memcpy( gpsLocationAndSpeed, value, WIMU_GPS_LOCATION_AND_SPEED_PACKET_SIZE );
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( gpsLocationAndSpeedClientCharCfg, gpsLocationAndSpeed, FALSE,
+ gpsAttrTbl, GATT_NUM_ATTRS( gpsAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GPS_DATE_TIME:
+ if ( len == WIMU_GPS_DATE_TIME_PACKET_SIZE )
+ {
+ VOID osal_memcpy( gpsDateTime, value, WIMU_GPS_DATE_TIME_PACKET_SIZE );
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( gpsDateTimeClientCharCfg, gpsDateTime, FALSE,
+ gpsAttrTbl, GATT_NUM_ATTRS( gpsAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GPS_POSITION_QUALITY:
+ if ( len == WIMU_GPS_POSITION_QUALITY_PACKET_SIZE )
+ {
+ VOID osal_memcpy( gpsPositionQuality, value, WIMU_GPS_POSITION_QUALITY_PACKET_SIZE );
+
+ // See if Notification has been enabled
+ // Notifications are excluded (https://developer.bluetooth.org)
+/* GATTServApp_ProcessCharCfg( gpsPositionQualityClientCharCfg, gpsPositionQuality, FALSE,
+ gpsAttrTbl, GATT_NUM_ATTRS( gpsAttrTbl ),
+ INVALID_TASK_ID );*/
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Gps_GetParameter
+ *
+ * @brief Get a Gps Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Gps_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case GPS_FEATURES:
+ osal_memcpy (value, gpsFeatures, sizeof(gpsFeatures) );
+ break;
+
+ case GPS_LOCATION_AND_SPEED:
+ osal_memcpy (value, gpsLocationAndSpeed, WIMU_GPS_LOCATION_AND_SPEED_PACKET_SIZE );
+ break;
+
+ case GPS_DATE_TIME:
+ osal_memcpy (value, gpsDateTime, WIMU_GPS_DATE_TIME_PACKET_SIZE );
+ break;
+
+ case GPS_POSITION_QUALITY:
+ osal_memcpy (value, gpsPositionQuality, WIMU_GPS_POSITION_QUALITY_PACKET_SIZE );
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn gps_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 gps_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ bStatus_t status = SUCCESS;
+
+ // If attribute permissions require authorization to read, return error
+ if ( gattPermitAuthorRead( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ if ( pAttr->type.len == ATT_BT_UUID_SIZE )
+ {
+ // 16-bit UUID
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ case GPS_FEATURES_UUID:
+ *pLen = 4;
+ osal_memcpy( pValue, pAttr->pValue, 4 );
+ break;
+
+ case GPS_LOCATION_AND_SPEED_UUID:
+ *pLen = WIMU_GPS_LOCATION_AND_SPEED_PACKET_SIZE;
+ osal_memcpy( pValue, pAttr->pValue, WIMU_GPS_LOCATION_AND_SPEED_PACKET_SIZE );
+ break;
+
+ case GPS_DATE_TIME_UUID:
+ *pLen = WIMU_GPS_DATE_TIME_PACKET_SIZE;
+ osal_memcpy( pValue, pAttr->pValue, WIMU_GPS_DATE_TIME_PACKET_SIZE );
+ break;
+
+ case GPS_POSITION_QUALITY_UUID:
+ *pLen = WIMU_GPS_POSITION_QUALITY_PACKET_SIZE;
+ osal_memcpy( pValue, pAttr->pValue, WIMU_GPS_POSITION_QUALITY_PACKET_SIZE );
+ break;
+
+ default:
+ // Should never get here!
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+ }
+ else
+ {
+ // 128-bit UUID
+ *pLen = 0;
+ status = ATT_ERR_INVALID_HANDLE;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn gps_WriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t gps_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn gps_HandleConnStatusCB
+ *
+ * @brief Gps Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void gps_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, gpsLocationAndSpeedClientCharCfg );
+ //GATTServApp_InitCharCfg( connHandle, gpsPositionQualityClientCharCfg );
+ GATTServApp_InitCharCfg( connHandle, gpsDateTimeClientCharCfg );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/GPS/gpsservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/GPS/gpsservice.h
new file mode 100644
index 0000000..c06a38c
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/GPS/gpsservice.h
@@ -0,0 +1,100 @@
+/**************************************************************************************************
+ Filename: gpsprofile.h
+ Creation: Date: 2015-07-23
+
+ Description: Gps profile (based on simpleGATT Profile)
+
+**************************************************************************************************/
+
+#ifndef GPSPROFILE_H
+#define GPSPROFILE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#include "wimu_util.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Profile Parameters
+#define GPS_FEATURES 0 // R uint32 - Profile gpsFeatures value
+#define GPS_LOCATION_AND_SPEED 1 // R struct - Profile locationAndSpeed value
+#define GPS_POSITION_QUALITY 2 // R struct - Profile positionQuality value
+#define GPS_DATE_TIME 3 // R struct - Profile dateTime value
+
+// Simple Profile Service UUID
+#define GPS_SERV_UUID 0x1819 // Gps service UUID
+
+#define GPS_FEATURES_UUID 0x2A6A // Gps Features
+#define GPS_LOCATION_AND_SPEED_UUID 0x2A67 // Gps Location and Speed Data
+#define GPS_DATE_TIME_UUID 0x2A08 // Gps Date Time
+#define GPS_POSITION_QUALITY_UUID 0x2A69 // Gps position quality Data
+
+// Simple Keys Profile Services bit fields
+#define GPS_SERVICE 0x00000001
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*
+ * Gps_AddService- Initializes the Gps Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+extern bStatus_t Gps_AddService( uint32 services );
+
+/*
+ * Gps_SetParameter - Set a Gps Profile parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Gps_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * Gps_GetParameter - Get a Gps Profile parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Gps_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GPSPROFILE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Glucose/glucservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Glucose/glucservice.c
new file mode 100644
index 0000000..fc49456
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Glucose/glucservice.c
@@ -0,0 +1,679 @@
+/**************************************************************************************************
+ Filename: glucservice.c
+ Revised: $Date $
+ Revision: $Revision $
+
+ Description: This file contains the Glucose sample service
+ for use with the Glucose sample application.
+
+ Copyright 2011-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "gapbondmgr.h"
+#include "glucservice.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Position of glucose measurement value in attribute array
+#define GLUCOSE_MEAS_VALUE_POS 2
+#define GLUCOSE_MEAS_CONFIG_POS 3
+#define GLUCOSE_CONTEXT_VALUE_POS 5
+#define GLUCOSE_CONTEXT_CONFIG_POS 6
+#define GLUCOSE_CTL_PNT_VALUE_POS 10
+#define GLUCOSE_CTL_PNT_CONFIG_POS 11
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// Glucose service
+CONST uint8 glucoseServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(GLUCOSE_SERV_UUID), HI_UINT16(GLUCOSE_SERV_UUID)
+};
+
+// Glucose characteristic
+CONST uint8 glucoseMeasUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(GLUCOSE_MEAS_UUID), HI_UINT16(GLUCOSE_MEAS_UUID)
+};
+
+// Glucose Measurement Context
+CONST uint8 glucoseContextUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(GLUCOSE_CONTEXT_UUID), HI_UINT16(GLUCOSE_CONTEXT_UUID)
+};
+
+// Glucose Feature
+CONST uint8 glucoseFeatureUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(GLUCOSE_FEATURE_UUID), HI_UINT16(GLUCOSE_FEATURE_UUID)
+};
+
+// Record Control Point
+CONST uint8 recordControlPointUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(RECORD_CONTROL_POINT_UUID), HI_UINT16(RECORD_CONTROL_POINT_UUID)
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/* TRUE if record transfer in progress */
+extern bool glucoseSendAllRecords;
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static glucoseServiceCB_t glucoseServiceCB;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Glucose Service attribute
+static CONST gattAttrType_t glucoseService = { ATT_BT_UUID_SIZE, glucoseServUUID };
+
+// Glucose Characteristic
+static uint8 glucoseProps = GATT_PROP_NOTIFY;
+static gattCharCfg_t glucoseMeasConfig[GATT_MAX_NUM_CONN];
+static uint8 glucoseMeas = 0;
+
+// Measurement Context
+static uint8 glucoseContextProps = GATT_PROP_NOTIFY;
+static uint8 glucoseContext=0;
+static gattCharCfg_t glucoseContextConfig[GATT_MAX_NUM_CONN];
+
+// Glucose Feature
+static uint8 glucoseFeatureProps = GATT_PROP_READ;
+static uint16 glucoseFeature = GLUCOSE_FEAT_ALL;
+
+// Glucose Control
+static uint8 glucoseControlProps = GATT_PROP_INDICATE | GATT_PROP_WRITE;
+static uint8 glucoseControl=0;
+static gattCharCfg_t glucoseControlConfig[GATT_MAX_NUM_CONN];
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t glucoseAttrTbl[] =
+{
+ // Glucose Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&glucoseService /* pValue */
+ },
+
+ // 1. Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &glucoseProps
+ },
+
+ // 2. Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, glucoseMeasUUID },
+ 0, //return READ_NOT_PERMITTED
+ 0,
+ &glucoseMeas
+ },
+
+ // 3.Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)&glucoseMeasConfig
+ },
+
+ //////////////////////////////////////////////
+ // MEASUREMENT CONTEXT
+ //////////////////////////////////////////////
+
+ // 4.Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &glucoseContextProps
+ },
+
+ // 5.Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, glucoseContextUUID },
+ 0, //return READ_NOT_PERMITTED
+ 0,
+ &glucoseContext
+ },
+
+ // 6.Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)&glucoseContextConfig
+ },
+
+ //////////////////////////////////////////////
+ // GLUCOSE FEATURE
+ //////////////////////////////////////////////
+
+ // 7.Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &glucoseFeatureProps
+ },
+
+ // 8.Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, glucoseFeatureUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) &glucoseFeature
+ },
+
+ //////////////////////////////////////////////
+ // GLUCOSE CONTROL POINT
+ //////////////////////////////////////////////
+
+ // 9.Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &glucoseControlProps
+ },
+
+ // 10.Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, recordControlPointUUID },
+ GATT_PERMIT_WRITE | GATT_PERMIT_AUTHEN_WRITE,
+ 0,
+ &glucoseControl
+ },
+
+ // 11.Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)&glucoseControlConfig
+ }
+};
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 glucose_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t glucose_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+
+static void glucose_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Service Callbacks
+CONST gattServiceCBs_t glucoseCBs =
+{
+ glucose_ReadAttrCB, // Read callback function pointer
+ glucose_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Glucose_AddService
+ *
+ * @brief Initializes the Glucose service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Glucose_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, glucoseMeasConfig );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, glucoseContextConfig );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, glucoseControlConfig );
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( glucose_HandleConnStatusCB );
+
+ if ( services & GLUCOSE_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( glucoseAttrTbl, GATT_NUM_ATTRS( glucoseAttrTbl ),
+ &glucoseCBs );
+ }
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Glucose_Register
+ *
+ * @brief Register a callback function with the Glucose Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ * pfnCtlPntCB - Callback for control point
+ *
+ * @return None.
+ */
+extern void Glucose_Register( glucoseServiceCB_t pfnServiceCB)
+{
+ glucoseServiceCB = pfnServiceCB;
+}
+
+/*********************************************************************
+ * @fn Glucose_SetParameter
+ *
+ * @brief Set a glucose parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Glucose_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case GLUCOSE_FEATURE_PARAM:
+ glucoseFeature = *((uint16*)value);
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Glucose_GetParameter
+ *
+ * @brief Get a Glucose parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Glucose_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case GLUCOSE_FEATURE_PARAM:
+ *((uint16*)value) = glucoseFeature;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Glucose_MeasSend
+ *
+ * @brief Send a glucose measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+bStatus_t Glucose_MeasSend( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId )
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, glucoseMeasConfig );
+
+ // If notifications enabled
+ if ( value & GATT_CLIENT_CFG_NOTIFY )
+ {
+ // Set the handle
+ pNoti->handle = glucoseAttrTbl[GLUCOSE_MEAS_VALUE_POS].handle;
+
+ // Send the Indication
+ return GATT_Notification( connHandle, pNoti, FALSE );
+ }
+
+ return bleNotReady;
+}
+
+
+/*********************************************************************
+ * @fn Glucose_ContextSend
+ *
+ * @brief Send a glucose measurement context.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+bStatus_t Glucose_ContextSend( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId )
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, glucoseContextConfig );
+
+ // If notifications enabled
+ if ( value & GATT_CLIENT_CFG_NOTIFY )
+ {
+ // Set the handle
+ pNoti->handle = glucoseAttrTbl[GLUCOSE_CONTEXT_VALUE_POS].handle;
+
+ // Send the Indication
+ return GATT_Notification( connHandle, pNoti, FALSE );
+ }
+
+ return bleNotReady;
+}
+
+/*********************************************************************
+ * @fn Glucose_CtlPntIndicate
+ *
+ * @brief Send an indication containing a control point
+ * message.
+ *
+ * @param connHandle - connection handle
+ * @param pInd - pointer to indication structure
+ *
+ * @return Success or Failure
+ */
+bStatus_t Glucose_CtlPntIndicate( uint16 connHandle, attHandleValueInd_t *pInd, uint8 taskId )
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, glucoseControlConfig );
+
+ // If indications enabled
+ if ( value & GATT_CLIENT_CFG_INDICATE )
+ {
+ // Set the handle
+ pInd->handle = glucoseAttrTbl[GLUCOSE_CTL_PNT_VALUE_POS].handle;
+
+ // Send the Indication
+ return GATT_Indication( connHandle, pInd, FALSE, taskId );
+ }
+
+ return bleNotReady;
+}
+
+/*********************************************************************
+ * @fn glucose_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 glucose_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ bStatus_t status = SUCCESS;
+
+ // Require security for all characteristics
+ if ( linkDB_Encrypted( connHandle ) == FALSE )
+ {
+ return ATT_ERR_INSUFFICIENT_ENCRYPT;
+ }
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if ( pAttr->type.len == ATT_BT_UUID_SIZE )
+ {
+ // 16-bit UUID
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
+ // gattserverapp handles those types for reads
+
+ case GLUCOSE_FEATURE_UUID:
+ *pLen = 2;
+ pValue[0] = LO_UINT16( glucoseFeature );
+ pValue[1] = HI_UINT16( glucoseFeature );
+ break;
+
+ default:
+ // Should never get here! (characteristics 3 and 4 do not have read permissions)
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn glucose_WriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t glucose_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+
+ // Require security for all characteristics
+ if ( linkDB_Encrypted( connHandle ) == FALSE )
+ {
+ return ATT_ERR_INSUFFICIENT_ENCRYPT;
+ }
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+
+ switch ( uuid )
+ {
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ // Glucose Notifications
+ if ((pAttr->handle == glucoseAttrTbl[GLUCOSE_MEAS_CONFIG_POS].handle ||
+ pAttr->handle == glucoseAttrTbl[GLUCOSE_CONTEXT_CONFIG_POS].handle))
+ {
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ if ( status == SUCCESS )
+ {
+ uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );
+
+ if(pAttr->handle == glucoseAttrTbl[GLUCOSE_MEAS_CONFIG_POS].handle)
+ {
+ (*glucoseServiceCB)((charCfg == 0) ? GLUCOSE_MEAS_NTF_DISABLED :
+ GLUCOSE_MEAS_NTF_ENABLED, NULL, NULL);
+ }
+ else
+ {
+ (*glucoseServiceCB)((charCfg == 0) ? GLUCOSE_CONTEXT_NTF_DISABLED :
+ GLUCOSE_CONTEXT_NTF_ENABLED, NULL, NULL);
+ }
+ }
+ }
+ // Glucose Indications
+ else if ( pAttr->handle == glucoseAttrTbl[GLUCOSE_CTL_PNT_CONFIG_POS].handle )
+ {
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_INDICATE );
+ if ( status == SUCCESS )
+ {
+ uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );
+
+ (*glucoseServiceCB)((charCfg == 0) ? GLUCOSE_CTL_PNT_IND_DISABLED :
+ GLUCOSE_CTL_PNT_IND_ENABLED, NULL, NULL);
+ }
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_VALUE;
+ }
+ break;
+
+ case RECORD_CONTROL_POINT_UUID:
+ if(len >= GLUCOSE_CTL_PNT_MIN_SIZE && len <= GLUCOSE_CTL_PNT_MAX_SIZE)
+ {
+ uint8 opcode = pValue[0];
+
+ // if transfer in progress
+ if (opcode != CTL_PNT_OP_ABORT && glucoseSendAllRecords)
+ {
+ status = GLUCOSE_ERR_IN_PROGRESS;
+ }
+ // if CCC not configured for glucose measurement
+ else if ( opcode == CTL_PNT_OP_REQ &&
+ !( GATTServApp_ReadCharCfg( connHandle, glucoseMeasConfig ) & GATT_CLIENT_CFG_NOTIFY ) )
+ {
+ status = GLUCOSE_ERR_CCC_CONFIG;
+ }
+ else
+ {
+ (*glucoseServiceCB)(GLUCOSE_CTL_PNT_CMD, pValue, len);
+ }
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ break;
+
+ default:
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn glucose_HandleConnStatusCB
+ *
+ * @brief Simple Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void glucose_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, glucoseMeasConfig );
+ GATTServApp_InitCharCfg( connHandle, glucoseContextConfig );
+ GATTServApp_InitCharCfg( connHandle, glucoseControlConfig );
+ }
+ }
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Glucose/glucservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Glucose/glucservice.h
new file mode 100644
index 0000000..2a2437d
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Glucose/glucservice.h
@@ -0,0 +1,338 @@
+/**************************************************************************************************
+ Filename: glucservice.h
+ Revised: $Date: 2011-12-16 15:46:52 -0800 (Fri, 16 Dec 2011) $
+ Revision: $Revision: 58 $
+
+ Description: This file contains the Glucose service definitions and
+ prototypes.
+
+ Copyright 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef GLUCOSESERVICE_H
+#define GLUCOSESERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "OSAL_clock.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Glucose Service Parameters
+#define GLUCOSE_FEATURE_PARAM 3
+
+// Characteristic Value sizes
+#define GLUCOSE_CTL_PNT_MIN_SIZE 2
+#define GLUCOSE_CTL_PNT_MAX_SIZE 20
+
+// Glucose Service UUIDs
+#define GLUCOSE_SERV_UUID 0x1808
+#define GLUCOSE_MEAS_UUID 0x2A18
+#define GLUCOSE_CONTEXT_UUID 0x2A34
+#define GLUCOSE_FEATURE_UUID 0x2A51
+#define RECORD_CONTROL_POINT_UUID 0x2A52
+
+// Values for meas flags
+
+#define GLUCOSE_MEAS_FLAG_TIME_OFFSET 0x01
+#define GLUCOSE_MEAS_FLAG_CONCENTRATION 0x02
+#define GLUCOSE_MEAS_FLAG_UNITS 0x04
+#define GLUCOSE_MEAS_FLAG_STATUS_ANNUNCIATION 0x08
+#define GLUCOSE_MEAS_FLAG_CONTEXT_INFO 0x10
+
+#define GLUCOSE_MEAS_FLAG_ALL (GLUCOSE_MEAS_FLAG_TIME_OFFSET | GLUCOSE_MEAS_FLAG_CONCENTRATION | GLUCOSE_MEAS_FLAG_UNITS | GLUCOSE_MEAS_FLAG_STATUS_ANNUNCIATION | GLUCOSE_MEAS_FLAG_CONTEXT_INFO)
+
+// Values for Type Nibble
+#define GLUCOSE_TYPE_CAPILLARY_WHOLE 0x1
+#define GLUCOSE_TYPE_CAPILLARY_PLASMA 0x2
+#define GLUCOSE_TYPE_VENOUS_WHOLE 0x3
+#define GLUCOSE_TYPE_VENOUS_PLASMA 0x4
+#define GLUCOSE_TYPE_ARTERIAL_WHOLE 0x5
+#define GLUCOSE_TYPE_ARTERIAL_PLASMA 0x6
+#define GLUCOSE_TYPE_UNDETER_WHOLE 0x7
+#define GLUCOSE_TYPE_UNDETER_PLASMA 0x8
+#define GLUCOSE_TYPE_ISF 0x9
+#define GLUCOSE_TYPE_CONTROL 0xA
+
+// Values for Location Nibble
+#define GLUCOSE_LOCATION_FINGER 0x10
+#define GLUCOSE_LOCATION_AST 0x20
+#define GLUCOSE_LOCATION_EARLOBE 0x30
+#define GLUCOSE_LOCATION_CONTROL 0x40
+#define GLUCOSE_LOCATION_NOT_AVAIL 0xF0
+
+// Values for Annunciation
+#define GLUCOSE_ANNUNCIATION_BATT_LOW 0x0001
+#define GLUCOSE_ANNUNCIATION_SENS_BAD 0x0002
+#define GLUCOSE_ANNUNCIATION_SAMP_SIZE 0x0004
+#define GLUCOSE_ANNUNCIATION_INSERT 0x0008
+#define GLUCOSE_ANNUNCIATION_STRIP 0x0010
+#define GLUCOSE_ANNUNCIATION_TOO_HIGH 0x0020
+#define GLUCOSE_ANNUNCIATION_TOO_LOW 0x0040
+#define GLUCOSE_ANNUNCIATION_TEMP_HIGH 0x0080
+#define GLUCOSE_ANNUNCIATION_TEMP_LOW 0x0100
+#define GLUCOSE_ANNUNCIATION_INTERRUPTED 0x0200
+#define GLUCOSE_ANNUNCIATION_GENERAL 0x0400
+#define GLUCOSE_ANNUNCIATION_TIME 0x0800
+
+// Values for context flags
+#define GLUCOSE_CONTEXT_FLAG_CARBO 0x01
+#define GLUCOSE_CONTEXT_FLAG_MEAL 0x02
+#define GLUCOSE_CONTEXT_FLAG_TESTER_HEALTH 0x04
+#define GLUCOSE_CONTEXT_FLAG_EXERCISE 0x08
+#define GLUCOSE_CONTEXT_FLAG_MEDICATION 0x10
+#define GLUCOSE_CONTEXT_FLAG_MEDICATION_UNITS 0x20
+#define GLUCOSE_CONTEXT_FLAG_HbA1c 0x40
+#define GLUCOSE_CONTEXT_FLAG_EXTENDED 0x80
+
+//We leave the extended flags out of this all, since there aren't any in the current spec
+#define GLUCOSE_CONTEXT_FLAG_ALL (GLUCOSE_CONTEXT_FLAG_CARBO | GLUCOSE_CONTEXT_FLAG_MEAL | GLUCOSE_CONTEXT_FLAG_TESTER_HEALTH | GLUCOSE_CONTEXT_FLAG_EXERCISE | GLUCOSE_CONTEXT_FLAG_MEDICATION | GLUCOSE_CONTEXT_FLAG_MEDICATION_UNITS | GLUCOSE_CONTEXT_FLAG_HbA1c)
+
+// Values for Carbohydratea
+#define GLUCOSE_CARBO_BREAKFAST 0x01
+#define GLUCOSE_CARBO_LUNCH 0x02
+#define GLUCOSE_CARBO_DINNER 0x03
+#define GLUCOSE_CARBO_SNACK 0x04
+#define GLUCOSE_CARBO_DRINK 0x05
+#define GLUCOSE_CARBO_SUPPER 0x06
+#define GLUCOSE_CARBO_BRUNCH 0x07
+
+// Values for Meal
+#define GLUCOSE_MEAL_PREPRANDIAL 0x1
+#define GLUCOSE_MEAL_POSTPRANDIAL 0x2
+#define GLUCOSE_MEAL_FASTING 0x3
+#define GLUCOSE_MEAL_CASUAL 0x4
+
+// Values for Tester Nibble
+#define GLUCOSE_TESTER_SELF 0x1
+#define GLUCOSE_TESTER_PROFESSIONAL 0x2
+#define GLUCOSE_TESTER_LAB_TEST 0x3
+#define GLUCOSE_TESTER_UNAVAILABLE 0xF
+
+// Values for Health Nibble
+#define GLUCOSE_HEALTH_MINOR 0x10
+#define GLUCOSE_HEALTH_MAJOR 0x20
+#define GLUCOSE_HEALTH_MENSES 0x30
+#define GLUCOSE_HEALTH_STRESS 0x40
+#define GLUCOSE_HEALTH_NONE 0x50
+#define GLUCOSE_HEALTH_UNAVAILABLE 0xF0
+
+// Values for Medication ID
+#define GLUCOSE_MEDICATION_RAPID 0x1
+#define GLUCOSE_MEDICATION_SHORT 0x2
+#define GLUCOSE_MEDICATION_INTERMEDIATE 0x3
+#define GLUCOSE_MEDICATION_LONG 0x4
+#define GLUCOSE_MEDICATION_PRE_MIXED 0x5
+
+// Values for Glucose Features
+#define GLUCOSE_FEAT_LOW_BAT_SUP 0x0001
+#define GLUCOSE_FEAT_MALFUNC_SUP 0x0002
+#define GLUCOSE_FEAT_SAMPLE_SIZE_SUP 0x0004
+#define GLUCOSE_FEAT_INSERT_ERR_SUP 0x0008
+#define GLUCOSE_FEAT_TYPE_ERR_SUP 0x0010
+#define GLUCOSE_FEAT_RESULT_DET_SUP 0x0020
+#define GLUCOSE_FEAT_TEMP_DET_SUP 0x0040
+#define GLUCOSE_FEAT_READ_INT_SUP 0x0080
+#define GLUCOSE_FEAT_GENERAL_FAULT_SUP 0x0100
+#define GLUCOSE_FEAT_TIME_FAULT_SUP 0x0200
+#define GLUCOSE_FEAT_MULTIPLE_BOND_SUP 0x0400
+
+#define GLUCOSE_FEAT_ALL (GLUCOSE_FEAT_LOW_BAT_SUP | GLUCOSE_FEAT_MALFUNC_SUP | GLUCOSE_FEAT_SAMPLE_SIZE_SUP | \
+ GLUCOSE_FEAT_INSERT_ERR_SUP | GLUCOSE_FEAT_TYPE_ERR_SUP | GLUCOSE_FEAT_RESULT_DET_SUP | \
+ GLUCOSE_FEAT_TEMP_DET_SUP | GLUCOSE_FEAT_READ_INT_SUP | GLUCOSE_FEAT_GENERAL_FAULT_SUP | \
+ GLUCOSE_FEAT_TIME_FAULT_SUP | GLUCOSE_FEAT_MULTIPLE_BOND_SUP)
+
+// Glucose Service bit fields
+#define GLUCOSE_SERVICE 0x00000001
+
+//Record Control Point values
+#define CTL_PNT_OP_REQ 0x01
+#define CTL_PNT_OP_CLR 0x02
+#define CTL_PNT_OP_ABORT 0x03
+#define CTL_PNT_OP_GET_NUM 0x04
+#define CTL_PNT_OP_NUM_RSP 0x05
+#define CTL_PNT_OP_REQ_RSP 0x06
+
+//Record Control Point operator
+#define CTL_PNT_OPER_NULL 0x00
+#define CTL_PNT_OPER_ALL 0x01
+#define CTL_PNT_OPER_LESS_EQUAL 0x02
+#define CTL_PNT_OPER_GREATER_EQUAL 0x03
+#define CTL_PNT_OPER_RANGE 0x04
+#define CTL_PNT_OPER_FIRST 0x05
+#define CTL_PNT_OPER_LAST 0x06
+
+//Record Control Point Response Codes
+#define CTL_PNT_RSP_SUCCESS 0x01
+#define CTL_PNT_RSP_OPCODE_NOT_SUPPORTED 0x02
+#define CTL_PNT_RSP_OPER_INVALID 0x03
+#define CTL_PNT_RSP_OPER_NOT_SUPPORTED 0x04
+#define CTL_PNT_RSP_OPERAND_INVALID 0x05
+#define CTL_PNT_RSP_NO_RECORDS 0x06
+#define CTL_PNT_RSP_ABORT_FAILED 0x07
+#define CTL_PNT_RSP_PROC_NOT_CMPL 0x08
+#define CTL_PNT_RSP_FILTER_NOT_SUPPORTED 0x09
+
+//Record Control Point Filter Types
+#define CTL_PNT_FILTER_SEQNUM 0x01
+#define CTL_PNT_FILTER_TIME 0x02
+
+// Callback events
+#define GLUCOSE_MEAS_NTF_ENABLED 1
+#define GLUCOSE_MEAS_NTF_DISABLED 2
+#define GLUCOSE_CONTEXT_NTF_ENABLED 3
+#define GLUCOSE_CONTEXT_NTF_DISABLED 4
+#define GLUCOSE_CTL_PNT_IND_ENABLED 5
+#define GLUCOSE_CTL_PNT_IND_DISABLED 6
+#define GLUCOSE_CTL_PNT_CMD 7
+
+// Procedure timeout in ms
+#define GLUCOSE_PROCEDURE_TIMEOUT 30000
+
+// ATT status values
+#define GLUCOSE_ERR_IN_PROGRESS 0x80
+#define GLUCOSE_ERR_CCC_CONFIG 0x81
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Glucose Service callback function
+typedef void (*glucoseServiceCB_t)(uint8 event, uint8* data, uint8 dataLen);
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*
+ * Glucose_AddService- Initializes the Glucose service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+
+extern bStatus_t Glucose_AddService( uint32 services );
+
+/*
+ * Glucose_Register - Register a callback function with the
+ * Glucose Service
+ *
+ * @param pfnServiceCB - Callback function.
+ */
+
+extern void Glucose_Register( glucoseServiceCB_t pfnServiceCB);
+
+/*
+ * Glucose_SetParameter - Set a Glucose parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Glucose_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * Glucose_GetParameter - Get a Glucose parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Glucose_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+ * @fn Glucose_MeasSend
+ *
+ * @brief Send a glucose measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t Glucose_MeasSend( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId );
+
+/*********************************************************************
+ * @fn Glucose_ContextSend
+ *
+ * @brief Send a glucose measurement context.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t Glucose_ContextSend( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId );
+
+/*********************************************************************
+ * @fn Glucose_CtlPntIndicate
+ *
+ * @brief Send an indication containing a glucose
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pInd - pointer to indication structure
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t Glucose_CtlPntIndicate( uint16 connHandle, attHandleValueInd_t *pInd, uint8 taskId );
+
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GLUCOSESERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDev/hid_uuid.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDev/hid_uuid.h
new file mode 100644
index 0000000..595f01f
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDev/hid_uuid.h
@@ -0,0 +1,89 @@
+/**************************************************************************************************
+ Filename: hid_uuid.h
+ Revised: $Date: 2012-01-26 13:42:33 -0800 (Thu, 26 Jan 2012) $
+ Revision: $Revision: 64 $
+
+ Description: This file contains UUIDs for the HID service.
+
+ Copyright 2011-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef HID_UUID_H
+#define HID_UUID_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/* HID service */
+#define HID_SERVICE_UUID 0x1812
+
+/* HID characteristics */
+#define HID_BOOT_KEY_INPUT_UUID 0x2A22 // HID Boot Keyboard Input Report
+#define HID_BOOT_KEY_OUTPUT_UUID 0x2A32 // HID Boot Keyboard Output Report
+#define HID_BOOT_MOUSE_INPUT_UUID 0x2A33 // HID Boot Mouse Input Report
+#define HID_INFORMATION_UUID 0x2A4A // HID Information
+#define HID_REPORT_MAP_UUID 0x2A4B // HID Report Map
+#define HID_CONTROL_POINT_UUID 0x2A4C // HID Control Point
+#define HID_REPORT_UUID 0x2A4D // HID Report
+#define HID_PROTOCOL_MODE_UUID 0x2A4E // HID Protocol Mode
+
+/* HID information flags */
+#define HID_FLAGS_REMOTE_WAKE 0x01 // RemoteWake
+#define HID_FLAGS_NORMALLY_CONNECTABLE 0x02 // NormallyConnectable
+
+/* Control point commands */
+#define HID_CMD_SUSPEND 0x00 // Suspend
+#define HID_CMD_EXIT_SUSPEND 0x01 // Exit Suspend
+
+/* HID protocol mode values */
+#define HID_PROTOCOL_MODE_BOOT 0x00 // Boot Protocol Mode
+#define HID_PROTOCOL_MODE_REPORT 0x01 // Report Protocol Mode
+
+/* Attribute value lengths */
+#define HID_PROTOCOL_MODE_LEN 1 // HID Protocol Mode
+#define HID_INFORMATION_LEN 4 // HID Information
+#define HID_REPORT_REF_LEN 2 // HID Report Reference Descriptor
+#define HID_EXT_REPORT_REF_LEN 2 // External Report Reference Descriptor
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HID_UUID_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDev/hiddev.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDev/hiddev.c
new file mode 100644
index 0000000..a575465
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDev/hiddev.c
@@ -0,0 +1,1406 @@
+/**************************************************************************************************
+ Filename: hiddev.c
+
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: This file contains the common HID Device profile
+ for use with the CC2540 Bluetooth Low Energy Protocol Stack.
+
+ Copyright 2011-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "OnBoard.h"
+#include "gatt.h"
+#include "hci.h"
+#include "gapgattserver.h"
+#include "gattservapp.h"
+#include "gatt_uuid.h"
+#include "linkdb.h"
+#include "peripheral.h"
+#include "gapbondmgr.h"
+#include "devinfoservice.h"
+#include "battservice.h"
+#include "scanparamservice.h"
+#include "hiddev.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+// Battery measurement period in ms
+#define DEFAULT_BATT_PERIOD 15000
+
+// TRUE to run scan parameters refresh notify test
+#define DEFAULT_SCAN_PARAM_NOTIFY_TEST TRUE
+
+// Advertising intervals (units of 625us, 160=100ms)
+#define HID_INITIAL_ADV_INT_MIN 48
+#define HID_INITIAL_ADV_INT_MAX 80
+#define HID_HIGH_ADV_INT_MIN 32
+#define HID_HIGH_ADV_INT_MAX 48
+#define HID_LOW_ADV_INT_MIN 1600
+#define HID_LOW_ADV_INT_MAX 1600
+
+// Advertising timeouts in sec
+#define HID_INITIAL_ADV_TIMEOUT 60
+#define HID_HIGH_ADV_TIMEOUT 5
+#define HID_LOW_ADV_TIMEOUT 0
+
+// Heart Rate Task Events
+#define START_DEVICE_EVT 0x0001
+#define BATT_PERIODIC_EVT 0x0002
+#define HID_IDLE_EVT 0x0004
+#define HID_SEND_REPORT_EVT 0x0008
+
+#define reportQEmpty() ( firstQIdx == lastQIdx )
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+#define HID_DEV_DATA_LEN 8
+
+#ifdef HID_DEV_RPT_QUEUE_LEN
+ #define HID_DEV_REPORT_Q_SIZE (HID_DEV_RPT_QUEUE_LEN+1)
+#else
+ #define HID_DEV_REPORT_Q_SIZE (10+1)
+#endif
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+typedef struct
+{
+ uint8 id;
+ uint8 type;
+ uint8 len;
+ uint8 data[HID_DEV_DATA_LEN];
+} hidDevReport_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// Task ID
+uint8 hidDevTaskId;
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+// GAP State
+static gaprole_States_t hidDevGapState = GAPROLE_INIT;
+
+// TRUE if connection is secure
+static uint8 hidDevConnSecure = FALSE;
+
+// GAP connection handle
+static uint16 gapConnHandle;
+
+// TRUE if pairing in progress
+static uint8 hidDevPairingStarted = FALSE;
+
+// Status of last pairing
+static uint8 pairingStatus = SUCCESS;
+
+static hidRptMap_t *pHidDevRptTbl;
+
+static uint8 hidDevRptTblLen;
+
+static hidDevCB_t *pHidDevCB;
+
+static hidDevCfg_t *pHidDevCfg;
+
+// Whether to change to the preferred connection parameters
+static uint8 updateConnParams = TRUE;
+
+// Pending reports
+static uint8 firstQIdx = 0;
+static uint8 lastQIdx = 0;
+static hidDevReport_t hidDevReportQ[HID_DEV_REPORT_Q_SIZE];
+
+// Last report sent out
+static attHandleValueNoti_t lastNoti = { 0 };
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+
+static void hidDev_ProcessOSALMsg( osal_event_hdr_t *pMsg );
+static void hidDevProcessGattMsg( gattMsgEvent_t *pMsg );
+static void hidDevDisconnected( void );
+static void hidDevGapStateCB( gaprole_States_t newState );
+static void hidDevPairStateCB( uint16 connHandle, uint8 state, uint8 status );
+static void hidDevPasscodeCB( uint8 *deviceAddr, uint16 connectionHandle,
+ uint8 uiInputs, uint8 uiOutputs );
+static void hidDevBattCB( uint8 event );
+static void hidDevScanParamCB( uint8 event );
+static void hidDevBattPeriodicTask( void );
+static hidRptMap_t *hidDevRptByHandle( uint16 handle );
+static hidRptMap_t *hidDevRptById( uint8 id, uint8 type );
+static hidRptMap_t *hidDevRptByCccdHandle( uint16 handle );
+static void hidDevEnqueueReport( uint8 id, uint8 type, uint8 len, uint8 *pData );
+static hidDevReport_t *hidDevDequeueReport( void );
+static void hidDevSendReport( uint8 id, uint8 type, uint8 len, uint8 *pData );
+static void hidDevHighAdvertising( void );
+static void hidDevLowAdvertising( void );
+static void hidDevInitialAdvertising( void );
+static uint8 hidDevBondCount( void );
+static void hidDevStartIdleTimer( void );
+static void hidDevStopIdleTimer( void );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+
+// GAP Role Callbacks
+static gapRolesCBs_t hidDev_PeripheralCBs =
+{
+ hidDevGapStateCB, // Profile State Change Callbacks
+ NULL // When a valid RSSI is read from controller
+};
+
+// Bond Manager Callbacks
+static const gapBondCBs_t hidDevBondCB =
+{
+ hidDevPasscodeCB,
+ hidDevPairStateCB
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn HidDev_Init
+ *
+ * @brief Initialization function for the Hid Dev 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 HidDev_Init( uint8 task_id )
+{
+ hidDevTaskId = task_id;
+
+ // Setup the GAP Bond Manager
+ {
+ uint8 syncWL = TRUE;
+
+ // If a bond is created, the HID Device should write the address of the
+ // HID Host in the HID Device controller's white list and set the HID
+ // Device controller's advertising filter policy to 'process scan and
+ // connection requests only from devices in the White List'.
+ VOID GAPBondMgr_SetParameter( GAPBOND_AUTO_SYNC_WL, sizeof( uint8 ), &syncWL );
+ }
+
+ // Set up services
+ GGS_AddService( GATT_ALL_SERVICES ); // GAP
+ GATTServApp_AddService( GATT_ALL_SERVICES ); // GATT attributes
+ DevInfo_AddService( );
+ Batt_AddService( );
+ ScanParam_AddService( );
+
+ // Register for Battery service callback
+ Batt_Register( hidDevBattCB );
+
+ // Register for Scan Parameters service callback
+ ScanParam_Register( hidDevScanParamCB );
+
+ // Setup a delayed profile startup
+ osal_set_event( hidDevTaskId, START_DEVICE_EVT );
+}
+
+/*********************************************************************
+ * @fn HidDev_ProcessEvent
+ *
+ * @brief Hid Dev 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 events not processed
+ */
+uint16 HidDev_ProcessEvent( uint8 task_id, uint16 events )
+{
+
+ VOID task_id; // OSAL required parameter that isn't used in this function
+
+ if ( events & SYS_EVENT_MSG )
+ {
+ uint8 *pMsg;
+
+ if ( (pMsg = osal_msg_receive( hidDevTaskId )) != NULL )
+ {
+ hidDev_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 & START_DEVICE_EVT )
+ {
+ // Start the Device
+ VOID GAPRole_StartDevice( &hidDev_PeripheralCBs );
+
+ // Register with bond manager after starting device
+ GAPBondMgr_Register( (gapBondCBs_t *) &hidDevBondCB );
+
+ return ( events ^ START_DEVICE_EVT );
+ }
+
+ if ( events & HID_IDLE_EVT )
+ {
+ if ( hidDevGapState == GAPROLE_CONNECTED )
+ {
+ // if pairing in progress then restart timer
+ if ( hidDevPairingStarted )
+ {
+ hidDevStartIdleTimer();
+ }
+ // else disconnect
+ else
+ {
+ GAPRole_TerminateConnection();
+ }
+ }
+
+ return ( events ^ HID_IDLE_EVT );
+ }
+
+ if ( events & BATT_PERIODIC_EVT )
+ {
+ // Perform periodic battery task
+ hidDevBattPeriodicTask();
+
+ return ( events ^ BATT_PERIODIC_EVT );
+ }
+
+ if ( events & HID_SEND_REPORT_EVT )
+ {
+ // if connection is secure
+ if ( hidDevConnSecure )
+ {
+ hidDevReport_t *pReport = hidDevDequeueReport();
+
+ if ( pReport != NULL )
+ {
+ // Send report
+ hidDevSendReport( pReport->id, pReport->type, pReport->len, pReport->data );
+ }
+
+ return ( reportQEmpty() ? events ^ HID_SEND_REPORT_EVT : events );
+ }
+
+ return ( events ^ HID_SEND_REPORT_EVT );
+ }
+
+ return 0;
+}
+
+/*********************************************************************
+ * @fn HidDev_Register
+ *
+ * @brief Register a callback function with HID Dev.
+ *
+ * @param pCfg - Parameter configuration.
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return None.
+ */
+void HidDev_Register( hidDevCfg_t *pCfg, hidDevCB_t *pCBs )
+{
+ pHidDevCB = pCBs;
+ pHidDevCfg = pCfg;
+}
+
+/*********************************************************************
+ * @fn HidDev_RegisterReports
+ *
+ * @brief Register the report table with HID Dev.
+ *
+ * @param numReports - Length of report table.
+ * @param pRpt - Report table.
+ *
+ * @return None.
+ */
+void HidDev_RegisterReports( uint8 numReports, hidRptMap_t *pRpt )
+{
+ pHidDevRptTbl = pRpt;
+ hidDevRptTblLen = numReports;
+}
+
+/*********************************************************************
+ * @fn HidDev_Report
+ *
+ * @brief Send a HID report.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param len - Length of report.
+ * @param pData - Report data.
+ *
+ * @return None.
+ */
+void HidDev_Report( uint8 id, uint8 type, uint8 len, uint8*pData )
+{
+ // if connected
+ if ( hidDevGapState == GAPROLE_CONNECTED )
+ {
+ // if connection is secure
+ if ( hidDevConnSecure )
+ {
+ // Make sure there're no pending reports
+ if ( reportQEmpty() )
+ {
+ // send report
+ hidDevSendReport( id, type, len, pData );
+
+ return; // we're done
+ }
+ }
+ }
+ // else if not already advertising
+ else if ( hidDevGapState != GAPROLE_ADVERTISING )
+ {
+ // if bonded
+ if ( hidDevBondCount() > 0 )
+ {
+ // start high duty cycle advertising
+ hidDevHighAdvertising();
+ }
+ // else not bonded
+ else
+ {
+ // start initial advertising
+ hidDevInitialAdvertising();
+ }
+ }
+
+ // hidDev task will send report when secure connection is established
+ hidDevEnqueueReport( id, type, len, pData );
+}
+
+/*********************************************************************
+ * @fn HidDev_Close
+ *
+ * @brief Close the connection or stop advertising.
+ *
+ * @return None.
+ */
+void HidDev_Close( void )
+{
+ uint8 param;
+
+ // if connected then disconnect
+ if ( hidDevGapState == GAPROLE_CONNECTED )
+ {
+ GAPRole_TerminateConnection();
+ }
+ // else stop advertising
+ else
+ {
+ param = FALSE;
+ GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), ¶m );
+ }
+}
+
+/*********************************************************************
+ * @fn HidDev_SetParameter
+ *
+ * @brief Set a HID Dev parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t HidDev_SetParameter( uint8 param, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case HIDDEV_ERASE_ALLBONDS:
+ if ( len == 0 )
+ {
+ // See if the last report sent out wasn't a release key
+ if ( osal_isbufset( lastNoti.value, 0x00, lastNoti.len ) == FALSE )
+ {
+ // Send a release report before disconnecting, otherwise
+ // the last pressed key would get 'stuck' on the HID Host.
+ osal_memset( lastNoti.value, 0x00, lastNoti.len );
+
+ GATT_Notification( gapConnHandle, &lastNoti, FALSE );
+ }
+
+ // Drop connection
+ if ( hidDevGapState == GAPROLE_CONNECTED )
+ {
+ GAPRole_TerminateConnection();
+ }
+
+ // Flush report queue
+ firstQIdx = lastQIdx = 0;
+
+ // Erase bonding info
+ GAPBondMgr_SetParameter( GAPBOND_ERASE_ALLBONDS, 0, NULL );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn HidDev_GetParameter
+ *
+ * @brief Get a HID Dev parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param pValue - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t HidDev_GetParameter( uint8 param, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn HidDev_PasscodeRsp
+ *
+ * @brief Respond to a passcode request.
+ *
+ * @param status - SUCCESS if passcode is available, otherwise
+ * see @ref SMP_PAIRING_FAILED_DEFINES.
+ * @param passcode - integer value containing the passcode.
+ *
+ * @return none
+ */
+void HidDev_PasscodeRsp( uint8 status, uint32 passcode )
+{
+ // Send passcode response
+ GAPBondMgr_PasscodeRsp( gapConnHandle, status, passcode );
+}
+
+/*********************************************************************
+ * @fn HidDev_ReadAttrCB
+ *
+ * @brief HID Dev attribute read callback.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+uint8 HidDev_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ bStatus_t status = SUCCESS;
+ hidRptMap_t *pRpt;
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+
+ // Only report map is long
+ if ( offset > 0 && uuid != HID_REPORT_MAP_UUID )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if ( uuid == HID_REPORT_UUID ||
+ uuid == HID_BOOT_KEY_INPUT_UUID ||
+ uuid == HID_BOOT_KEY_OUTPUT_UUID ||
+ uuid == HID_BOOT_MOUSE_INPUT_UUID )
+ {
+ // require encryption
+ if ( hidDevConnSecure == FALSE )
+ {
+ return ( ATT_ERR_INSUFFICIENT_ENCRYPT );
+ }
+
+ // find report ID in table
+ if ( (pRpt = hidDevRptByHandle(pAttr->handle)) != NULL )
+ {
+ // execute report callback
+ status = (*pHidDevCB->reportCB)( pRpt->id, pRpt->type, uuid,
+ HID_DEV_OPER_READ, pLen, pValue );
+ }
+ else
+ {
+ *pLen = 0;
+ }
+ }
+ else if ( uuid == HID_REPORT_MAP_UUID )
+ {
+ // verify offset
+ if ( offset >= hidReportMapLen )
+ {
+ status = ATT_ERR_INVALID_OFFSET;
+ }
+ else
+ {
+ // determine read length
+ *pLen = MIN( maxLen, (hidReportMapLen - offset) );
+
+ // copy data
+ osal_memcpy( pValue, pAttr->pValue + offset, *pLen );
+ }
+ }
+ else if ( uuid == HID_INFORMATION_UUID )
+ {
+ // require encryption
+ if ( hidDevConnSecure == FALSE )
+ {
+ return ( ATT_ERR_INSUFFICIENT_ENCRYPT );
+ }
+
+ *pLen = HID_INFORMATION_LEN;
+ osal_memcpy( pValue, pAttr->pValue, HID_INFORMATION_LEN );
+ }
+ else if ( uuid == GATT_REPORT_REF_UUID )
+ {
+ *pLen = HID_REPORT_REF_LEN;
+ osal_memcpy( pValue, pAttr->pValue, HID_REPORT_REF_LEN );
+ }
+ else if ( uuid == HID_PROTOCOL_MODE_UUID )
+ {
+ // require encryption
+ if ( hidDevConnSecure == FALSE )
+ {
+ return ( ATT_ERR_INSUFFICIENT_ENCRYPT );
+ }
+
+ *pLen = HID_PROTOCOL_MODE_LEN;
+ pValue[0] = pAttr->pValue[0];
+ }
+ else if ( uuid == GATT_EXT_REPORT_REF_UUID )
+ {
+ *pLen = HID_EXT_REPORT_REF_LEN;
+ osal_memcpy( pValue, pAttr->pValue, HID_EXT_REPORT_REF_LEN );
+ }
+
+ // restart idle timer
+ if ( status == SUCCESS )
+ {
+ hidDevStartIdleTimer();
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn HidDev_WriteAttrCB
+ *
+ * @brief HID Dev attribute read callback.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+bStatus_t HidDev_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+ hidRptMap_t *pRpt;
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+
+ if ( uuid == HID_REPORT_UUID ||
+ uuid == HID_BOOT_KEY_OUTPUT_UUID )
+ {
+ // require encryption
+ if ( hidDevConnSecure == FALSE )
+ {
+ return ( ATT_ERR_INSUFFICIENT_ENCRYPT );
+ }
+
+ // find report ID in table
+ if ((pRpt = hidDevRptByHandle(pAttr->handle)) != NULL)
+ {
+ // execute report callback
+ status = (*pHidDevCB->reportCB)( pRpt->id, pRpt->type, uuid,
+ HID_DEV_OPER_WRITE, &len, pValue );
+ }
+ }
+ else if ( uuid == HID_CONTROL_POINT_UUID )
+ {
+ // require encryption
+ if ( hidDevConnSecure == FALSE )
+ {
+ return ( ATT_ERR_INSUFFICIENT_ENCRYPT );
+ }
+
+ // Validate length and value range
+ if ( len == 1 )
+ {
+ if ( pValue[0] == HID_CMD_SUSPEND || pValue[0] == HID_CMD_EXIT_SUSPEND )
+ {
+ // execute HID app event callback
+ (*pHidDevCB->evtCB)( (pValue[0] == HID_CMD_SUSPEND) ?
+ HID_DEV_SUSPEND_EVT : HID_DEV_EXIT_SUSPEND_EVT );
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_VALUE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else if ( uuid == GATT_CLIENT_CHAR_CFG_UUID )
+ {
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ if ( status == SUCCESS )
+ {
+ uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );
+
+ // find report ID in table
+ if ( (pRpt = hidDevRptByCccdHandle(pAttr->handle)) != NULL )
+ {
+ // execute report callback
+ (*pHidDevCB->reportCB)( pRpt->id, pRpt->type, uuid,
+ (charCfg == GATT_CLIENT_CFG_NOTIFY) ?
+ HID_DEV_OPER_ENABLE : HID_DEV_OPER_DISABLE,
+ &len, pValue );
+ }
+ }
+ }
+ else if ( uuid == HID_PROTOCOL_MODE_UUID )
+ {
+ // require encryption
+ if ( hidDevConnSecure == FALSE )
+ {
+ return ( ATT_ERR_INSUFFICIENT_ENCRYPT );
+ }
+
+ if ( len == HID_PROTOCOL_MODE_LEN )
+ {
+ if ( pValue[0] == HID_PROTOCOL_MODE_BOOT ||
+ pValue[0] == HID_PROTOCOL_MODE_REPORT )
+ {
+ pAttr->pValue[0] = pValue[0];
+
+ // execute HID app event callback
+ (*pHidDevCB->evtCB)( (pValue[0] == HID_PROTOCOL_MODE_BOOT) ?
+ HID_DEV_SET_BOOT_EVT : HID_DEV_SET_REPORT_EVT );
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_VALUE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+
+ // restart idle timer
+ if (status == SUCCESS)
+ {
+ hidDevStartIdleTimer();
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn hidDev_ProcessOSALMsg
+ *
+ * @brief Process an incoming task message.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void hidDev_ProcessOSALMsg( osal_event_hdr_t *pMsg )
+{
+ switch ( pMsg->event )
+ {
+ case GATT_MSG_EVENT:
+ hidDevProcessGattMsg( (gattMsgEvent_t *) pMsg );
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn hidDevProcessGattMsg
+ *
+ * @brief Process GATT messages
+ *
+ * @return none
+ */
+static void hidDevProcessGattMsg( gattMsgEvent_t *pMsg )
+{
+
+}
+
+/*********************************************************************
+ * @fn hidDevHandleConnStatusCB
+ *
+ * @brief Reset client char config.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void hidDevHandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ uint8 i;
+ hidRptMap_t *p = pHidDevRptTbl;
+ uint16 retHandle;
+ gattAttribute_t *pAttr;
+
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ for ( i = hidDevRptTblLen; i > 0; i--, p++ )
+ {
+ if ( p->cccdHandle != 0 )
+ {
+ if ( (pAttr = GATT_FindHandle(p->cccdHandle, &retHandle)) != NULL )
+ {
+ GATTServApp_InitCharCfg( connHandle, (gattCharCfg_t *) pAttr->pValue );
+ }
+ }
+ }
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn hidDevDisconnected
+ *
+ * @brief Handle disconnect.
+ *
+ * @return none
+ */
+static void hidDevDisconnected( void )
+{
+ // Stop idle timer
+ hidDevStopIdleTimer();
+
+ // Reset client characteristic configuration descriptors
+ Batt_HandleConnStatusCB( gapConnHandle, LINKDB_STATUS_UPDATE_REMOVED );
+ ScanParam_HandleConnStatusCB( gapConnHandle, LINKDB_STATUS_UPDATE_REMOVED );
+ hidDevHandleConnStatusCB( gapConnHandle, LINKDB_STATUS_UPDATE_REMOVED );
+
+ // Reset state variables
+ hidDevConnSecure = FALSE;
+ hidProtocolMode = HID_PROTOCOL_MODE_REPORT;
+ hidDevPairingStarted = FALSE;
+
+ // Reset last report sent out
+ osal_memset( &lastNoti, 0, sizeof( attHandleValueNoti_t ) );
+
+ // if bonded and normally connectable start advertising
+ if ( ( hidDevBondCount() > 0 ) &&
+ ( pHidDevCfg->hidFlags & HID_FLAGS_NORMALLY_CONNECTABLE ) )
+ {
+ hidDevLowAdvertising();
+ }
+}
+
+/*********************************************************************
+ * @fn hidDevGapStateCB
+ *
+ * @brief Notification from the profile of a state change.
+ *
+ * @param newState - new state
+ *
+ * @return none
+ */
+static void hidDevGapStateCB( gaprole_States_t newState )
+{
+ // if connected
+ if ( newState == GAPROLE_CONNECTED )
+ {
+ // get connection handle
+ GAPRole_GetParameter( GAPROLE_CONNHANDLE, &gapConnHandle );
+
+ // connection not secure yet
+ hidDevConnSecure = FALSE;
+
+ // don't start advertising when connection is closed
+ uint8 param = FALSE;
+ GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), ¶m );
+
+ // start idle timer
+ hidDevStartIdleTimer();
+ }
+ // if disconnected
+ else if ( hidDevGapState == GAPROLE_CONNECTED &&
+ newState != GAPROLE_CONNECTED )
+ {
+ hidDevDisconnected();
+ updateConnParams = TRUE;
+
+ if ( pairingStatus == SMP_PAIRING_FAILED_CONFIRM_VALUE )
+ {
+ // bonding failed due to mismatched confirm values
+ hidDevInitialAdvertising();
+
+ pairingStatus = SUCCESS;
+ }
+ }
+ // if started
+ else if ( newState == GAPROLE_STARTED )
+ {
+ // nothing to do for now!
+ }
+
+ hidDevGapState = newState;
+}
+
+/*********************************************************************
+ * @fn hidDevPairStateCB
+ *
+ * @brief Pairing state callback.
+ *
+ * @return none
+ */
+static void hidDevPairStateCB( uint16 connHandle, uint8 state, uint8 status )
+{
+ if ( state == GAPBOND_PAIRING_STATE_STARTED )
+ {
+ hidDevPairingStarted = TRUE;
+ }
+ else if ( state == GAPBOND_PAIRING_STATE_COMPLETE )
+ {
+ hidDevPairingStarted = FALSE;
+
+ if ( status == SUCCESS )
+ {
+ hidDevConnSecure = TRUE;
+ }
+
+ pairingStatus = status;
+ }
+ else if ( state == GAPBOND_PAIRING_STATE_BONDED )
+ {
+ if ( status == SUCCESS )
+ {
+ hidDevConnSecure = TRUE;
+
+#if DEFAULT_SCAN_PARAM_NOTIFY_TEST == TRUE
+ ScanParam_RefreshNotify( gapConnHandle );
+#endif
+ }
+ }
+
+ if ( !reportQEmpty() && hidDevConnSecure )
+ {
+ // Notify our task to send out pending reports
+ osal_set_event( hidDevTaskId, HID_SEND_REPORT_EVT );
+ }
+}
+
+/*********************************************************************
+ * @fn hidDevPasscodeCB
+ *
+ * @brief Passcode callback.
+ *
+ * @param deviceAddr - address of device to pair with, and could be either public or random.
+ * @param connectionHandle - connection handle
+ * @param uiInputs - pairing User Interface Inputs - Ask user to input passcode
+ * @param uiOutputs - pairing User Interface Outputs - Display passcode
+ *
+ * @return none
+ */
+static void hidDevPasscodeCB( uint8 *deviceAddr, uint16 connectionHandle,
+ uint8 uiInputs, uint8 uiOutputs )
+{
+ if ( pHidDevCB && pHidDevCB->passcodeCB )
+ {
+ // execute HID app passcode callback
+ (*pHidDevCB->passcodeCB)( deviceAddr, connectionHandle, uiInputs, uiOutputs );
+ }
+ else
+ {
+ // Send passcode response
+ GAPBondMgr_PasscodeRsp( connectionHandle, SUCCESS, 0 );
+ }
+}
+
+/*********************************************************************
+ * @fn hidDevBattCB
+ *
+ * @brief Callback function for battery service.
+ *
+ * @param event - service event
+ *
+ * @return none
+ */
+static void hidDevBattCB( uint8 event )
+{
+ if ( event == BATT_LEVEL_NOTI_ENABLED )
+ {
+ // if connected start periodic measurement
+ if ( hidDevGapState == GAPROLE_CONNECTED )
+ {
+ osal_start_timerEx( hidDevTaskId, BATT_PERIODIC_EVT, DEFAULT_BATT_PERIOD );
+ }
+ }
+ else if ( event == BATT_LEVEL_NOTI_DISABLED )
+ {
+ // stop periodic measurement
+ osal_stop_timerEx( hidDevTaskId, BATT_PERIODIC_EVT );
+ }
+}
+
+/*********************************************************************
+ * @fn hidDevScanParamCB
+ *
+ * @brief Callback function for scan parameter service.
+ *
+ * @param event - service event
+ *
+ * @return none
+ */
+static void hidDevScanParamCB( uint8 event )
+{
+
+}
+
+/*********************************************************************
+ * @fn hidDevBattPeriodicTask
+ *
+ * @brief Perform a periodic task for battery measurement.
+ *
+ * @param none
+ *
+ * @return none
+ */
+static void hidDevBattPeriodicTask( void )
+{
+ if ( hidDevGapState == GAPROLE_CONNECTED )
+ {
+ // perform battery level check
+ Batt_MeasLevel( );
+
+ // Restart timer
+ osal_start_timerEx( hidDevTaskId, BATT_PERIODIC_EVT, DEFAULT_BATT_PERIOD );
+ }
+}
+
+/*********************************************************************
+ * @fn hidDevRptByHandle
+ *
+ * @brief Find the HID report structure for the given handle.
+ *
+ * @param handle - ATT handle
+ *
+ * @return Pointer to HID report structure
+ */
+static hidRptMap_t *hidDevRptByHandle( uint16 handle )
+{
+ uint8 i;
+ hidRptMap_t *p = pHidDevRptTbl;
+
+ for ( i = hidDevRptTblLen; i > 0; i--, p++ )
+ {
+ if ( p->handle == handle && p->mode == hidProtocolMode)
+ {
+ return p;
+ }
+ }
+
+ return NULL;
+}
+
+/*********************************************************************
+ * @fn hidDevRptByCccdHandle
+ *
+ * @brief Find the HID report structure for the given CCC handle.
+ *
+ * @param handle - ATT handle
+ *
+ * @return Pointer to HID report structure
+ */
+static hidRptMap_t *hidDevRptByCccdHandle( uint16 handle )
+{
+ uint8 i;
+ hidRptMap_t *p = pHidDevRptTbl;
+
+ for ( i = hidDevRptTblLen; i > 0; i--, p++ )
+ {
+ if ( p->cccdHandle == handle)
+ {
+ return p;
+ }
+ }
+
+ return NULL;
+}
+
+/*********************************************************************
+ * @fn hidDevRptById
+ *
+ * @brief Find the HID report structure for the Report ID and type.
+ *
+ * @param id - HID report ID
+ * @param type - HID report type
+ *
+ * @return Pointer to HID report structure
+ */
+static hidRptMap_t *hidDevRptById( uint8 id, uint8 type )
+{
+ uint8 i;
+ hidRptMap_t *p = pHidDevRptTbl;
+
+ for ( i = hidDevRptTblLen; i > 0; i--, p++ )
+ {
+ if ( p->id == id && p->type == type && p->mode == hidProtocolMode )
+ {
+ return p;
+ }
+ }
+
+ return NULL;
+}
+
+/*********************************************************************
+ * @fn hidDevSendReport
+ *
+ * @brief Send a HID report.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param len - Length of report.
+ * @param pData - Report data.
+ *
+ * @return None.
+ */
+static void hidDevSendReport( uint8 id, uint8 type, uint8 len, uint8 *pData )
+{
+ hidRptMap_t *pRpt;
+ gattAttribute_t *pAttr;
+ uint16 retHandle;
+
+ // get att handle for report
+ if ( (pRpt = hidDevRptById(id, type)) != NULL )
+ {
+ // if notifications are enabled
+ if ( (pAttr = GATT_FindHandle(pRpt->cccdHandle, &retHandle)) != NULL )
+ {
+ uint16 value;
+
+ value = GATTServApp_ReadCharCfg( gapConnHandle, (gattCharCfg_t *) pAttr->pValue );
+ if ( value & GATT_CLIENT_CFG_NOTIFY )
+ {
+ // After service discovery and encryption, the HID Device should request to
+ // change to the preferred connection parameters that best suit its use case.
+ if ( updateConnParams )
+ {
+ GAPRole_SetParameter( GAPROLE_PARAM_UPDATE_REQ, sizeof( uint8 ), &updateConnParams );
+ updateConnParams = FALSE;
+ }
+
+ // send notification
+ lastNoti.handle = pRpt->handle;
+ lastNoti.len = len;
+ osal_memcpy(lastNoti.value, pData, len);
+
+ GATT_Notification( gapConnHandle, &lastNoti, FALSE );
+
+ // start idle timer
+ hidDevStartIdleTimer();
+ }
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn hidDevEnqueueReport
+ *
+ * @brief Enqueue a HID report to be sent later.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param len - Length of report.
+ * @param pData - Report data.
+ *
+ * @return None.
+ */
+static void hidDevEnqueueReport( uint8 id, uint8 type, uint8 len, uint8 *pData )
+{
+ // Enqueue only if bonded
+ if ( hidDevBondCount() > 0 )
+ {
+ // Update last index
+ lastQIdx = ( lastQIdx + 1 ) % HID_DEV_REPORT_Q_SIZE;
+
+ if ( lastQIdx == firstQIdx )
+ {
+ // Queue overflow; discard oldest report
+ firstQIdx = ( firstQIdx + 1 ) % HID_DEV_REPORT_Q_SIZE;
+ }
+
+ // Save report
+ hidDevReportQ[lastQIdx].id = id;
+ hidDevReportQ[lastQIdx].type = type;
+ hidDevReportQ[lastQIdx].len = len;
+ osal_memcpy( hidDevReportQ[lastQIdx].data, pData, len );
+
+ if ( hidDevConnSecure )
+ {
+ // Notify our task to send out pending reports
+ osal_set_event( hidDevTaskId, HID_SEND_REPORT_EVT );
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn hidDevDequeueReport
+ *
+ * @brief Dequeue a HID report to be sent out.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param len - Length of report.
+ * @param pData - Report data.
+ *
+ * @return None.
+ */
+static hidDevReport_t *hidDevDequeueReport( void )
+{
+ if ( reportQEmpty() )
+ {
+ return NULL;
+ }
+
+ // Update first index
+ firstQIdx = ( firstQIdx + 1 ) % HID_DEV_REPORT_Q_SIZE;
+
+ return ( &(hidDevReportQ[firstQIdx]) );
+}
+
+/*********************************************************************
+ * @fn hidDevHighAdvertising
+ *
+ * @brief Start advertising at a high duty cycle.
+
+ * @param None.
+ *
+ * @return None.
+ */
+static void hidDevHighAdvertising( void )
+{
+ uint8 param;
+
+ VOID GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MIN, HID_HIGH_ADV_INT_MIN );
+ VOID GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MAX, HID_HIGH_ADV_INT_MAX );
+ VOID GAP_SetParamValue( TGAP_LIM_ADV_TIMEOUT, HID_HIGH_ADV_TIMEOUT );
+
+ // Setup adverstising filter policy first
+ param = GAP_FILTER_POLICY_WHITE;
+ VOID GAPRole_SetParameter( GAPROLE_ADV_FILTER_POLICY, sizeof( uint8 ), ¶m );
+
+ param = TRUE;
+ GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), ¶m );
+}
+
+/*********************************************************************
+ * @fn hidDevLowAdvertising
+ *
+ * @brief Start advertising at a low duty cycle.
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+static void hidDevLowAdvertising( void )
+{
+ uint8 param;
+
+ VOID GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MIN, HID_LOW_ADV_INT_MIN );
+ VOID GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MAX, HID_LOW_ADV_INT_MAX );
+ VOID GAP_SetParamValue( TGAP_LIM_ADV_TIMEOUT, HID_LOW_ADV_TIMEOUT );
+
+ // Setup adverstising filter policy first
+ param = GAP_FILTER_POLICY_WHITE;
+ VOID GAPRole_SetParameter( GAPROLE_ADV_FILTER_POLICY, sizeof( uint8 ), ¶m );
+
+ param = TRUE;
+ VOID GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), ¶m );
+}
+
+/*********************************************************************
+ * @fn hidDevInitialAdvertising
+ *
+ * @brief Start advertising for initial connection
+ *
+ * @return None.
+ */
+static void hidDevInitialAdvertising( void )
+{
+ uint8 param;
+
+ VOID GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MIN, HID_INITIAL_ADV_INT_MIN );
+ VOID GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MAX, HID_INITIAL_ADV_INT_MAX );
+ VOID GAP_SetParamValue( TGAP_LIM_ADV_TIMEOUT, HID_INITIAL_ADV_TIMEOUT );
+
+ // Setup adverstising filter policy first
+ param = GAP_FILTER_POLICY_ALL;
+ VOID GAPRole_SetParameter( GAPROLE_ADV_FILTER_POLICY, sizeof( uint8 ), ¶m );
+
+ param = TRUE;
+ VOID GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), ¶m );
+}
+
+/*********************************************************************
+ * @fn hidDevBondCount
+ *
+ * @brief Gets the total number of bonded devices.
+ *
+ * @param None.
+ *
+ * @return number of bonded devices.
+ */
+static uint8 hidDevBondCount( void )
+{
+ uint8 bondCnt = 0;
+
+ VOID GAPBondMgr_GetParameter( GAPBOND_BOND_COUNT, &bondCnt );
+
+ return ( bondCnt );
+}
+
+/*********************************************************************
+ * @fn hidDevStartIdleTimer
+ *
+ * @brief Start the idle timer.
+ *
+ * @return None.
+ */
+static void hidDevStartIdleTimer( void )
+{
+ if ( pHidDevCfg->idleTimeout > 0 )
+ {
+ osal_start_timerEx( hidDevTaskId, HID_IDLE_EVT, pHidDevCfg->idleTimeout );
+ }
+}
+
+/*********************************************************************
+ * @fn hidDevStopIdleTimer
+ *
+ * @brief Stop the idle timer.
+ *
+ * @return None.
+ */
+static void hidDevStopIdleTimer( void )
+{
+ osal_stop_timerEx( hidDevTaskId, HID_IDLE_EVT );
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDev/hiddev.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDev/hiddev.h
new file mode 100644
index 0000000..ebf6878
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDev/hiddev.h
@@ -0,0 +1,451 @@
+/**************************************************************************************************
+ Filename: hiddev.h
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: This file contains the common HID Device profile.
+
+ Copyright 2011-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef HIDDEV_H
+#define HIDDEV_H
+
+#include "hid_uuid.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// HID Device Parameters
+#define HIDDEV_ERASE_ALLBONDS 0 // Erase all of the bonded devices. Write Only. No Size.
+
+// HID read/write operation
+#define HID_DEV_OPER_WRITE 0 // Write operation
+#define HID_DEV_OPER_READ 1 // Read operation
+#define HID_DEV_OPER_ENABLE 2 // Notification enabled for report ID
+#define HID_DEV_OPER_DISABLE 3 // Notifications disabled for report ID
+
+// HID callback events
+#define HID_DEV_SUSPEND_EVT 0 // HID suspend
+#define HID_DEV_EXIT_SUSPEND_EVT 1 // HID exit suspend
+#define HID_DEV_SET_BOOT_EVT 2 // HID set boot mode
+#define HID_DEV_SET_REPORT_EVT 3 // HID set report mode
+
+/* HID Report type */
+#define HID_REPORT_TYPE_INPUT 1
+#define HID_REPORT_TYPE_OUTPUT 2
+#define HID_REPORT_TYPE_FEATURE 3
+
+// HID Keyboard/Keypad Usage IDs (subset of the codes available in the USB HID Usage Tables spec)
+#define HID_KEYBOARD_RESERVED 0 // 0x00 - No event inidicated
+#define HID_KEYBOARD_A 4 // 0x04 - Keyboard a and A
+#define HID_KEYBOARD_B 5 // 0x05 - Keyboard b and B
+#define HID_KEYBOARD_C 6 // 0x06 - Keyboard c and C
+#define HID_KEYBOARD_D 7 // 0x07 - Keyboard d and D
+#define HID_KEYBOARD_E 8 // 0x08 - Keyboard e and E
+#define HID_KEYBOARD_F 9 // 0x09 - Keyboard f and F
+#define HID_KEYBOARD_G 10 // 0x0A - Keyboard g and G
+#define HID_KEYBOARD_H 11 // 0x0B - Keyboard h and H
+#define HID_KEYBOARD_I 12 // 0x0C - Keyboard i and I
+#define HID_KEYBOARD_J 13 // 0x0D - Keyboard j and J
+#define HID_KEYBOARD_K 14 // 0x0E - Keyboard k and K
+#define HID_KEYBOARD_L 15 // 0x0F - Keyboard l and L
+#define HID_KEYBOARD_M 16 // 0x10 - Keyboard m and M
+#define HID_KEYBOARD_N 17 // 0x11 - Keyboard n and N
+#define HID_KEYBOARD_O 18 // 0x12 - Keyboard o and O
+#define HID_KEYBOARD_P 19 // 0x13 - Keyboard p and p
+#define HID_KEYBOARD_Q 20 // 0x14 - Keyboard q and Q
+#define HID_KEYBOARD_R 21 // 0x15 - Keyboard r and R
+#define HID_KEYBOARD_S 22 // 0x16 - Keyboard s and S
+#define HID_KEYBOARD_T 23 // 0x17 - Keyboard t and T
+#define HID_KEYBOARD_U 24 // 0x18 - Keyboard u and U
+#define HID_KEYBOARD_V 25 // 0x19 - Keyboard v and V
+#define HID_KEYBOARD_W 26 // 0x1A - Keyboard w and W
+#define HID_KEYBOARD_X 27 // 0x1B - Keyboard x and X
+#define HID_KEYBOARD_Y 28 // 0x1C - Keyboard y and Y
+#define HID_KEYBOARD_Z 29 // 0x1D - Keyboard z and Z
+#define HID_KEYBOARD_1 30 // 0x1E - Keyboard 1 and !
+#define HID_KEYBOARD_2 31 // 0x1F - Keyboard 2 and @
+#define HID_KEYBOARD_3 32 // 0x20 - Keyboard 3 and #
+#define HID_KEYBOARD_4 33 // 0x21 - Keyboard 4 and %
+#define HID_KEYBOARD_5 34 // 0x22 - Keyboard 5 and %
+#define HID_KEYBOARD_6 35 // 0x23 - Keyboard 6 and ^
+#define HID_KEYBOARD_7 36 // 0x24 - Keyboard 7 and &
+#define HID_KEYBOARD_8 37 // 0x25 - Keyboard 8 and *
+#define HID_KEYBOARD_9 38 // 0x26 - Keyboard 9 and (
+#define HID_KEYBOARD_0 39 // 0x27 - Keyboard 0 and )
+#define HID_KEYBOARD_RETURN 40 // 0x28 - Keyboard Return (ENTER)
+#define HID_KEYBOARD_ESCAPE 41 // 0x29 - Keyboard ESCAPE
+#define HID_KEYBOARD_DELETE 42 // 0x2A - Keyboard DELETE (Backspace)
+#define HID_KEYBOARD_TAB 43 // 0x2B - Keyboard Tab
+#define HID_KEYBOARD_SPACEBAR 44 // 0x2C - Keyboard Spacebar
+#define HID_KEYBOARD_MINUS 45 // 0x2D - Keyboard - and (underscore)
+#define HID_KEYBOARD_EQUAL 46 // 0x2E - Keyboard = and +
+#define HID_KEYBOARD_LEFT_BRKT 47 // 0x2F - Keyboard [ and {
+#define HID_KEYBOARD_RIGHT_BRKT 48 // 0x30 - Keyboard ] and }
+#define HID_KEYBOARD_BACK_SLASH 49 // 0x31 - Keyboard \ and |
+#define HID_KEYBOARD_SEMI_COLON 51 // 0x33 - Keyboard ; and :
+#define HID_KEYBOARD_SGL_QUOTE 52 // 0x34 - Keyboard ' and "
+#define HID_KEYBOARD_GRV_ACCENT 53 // 0x35 - Keyboard Grave Accent and Tilde
+#define HID_KEYBOARD_COMMA 54 // 0x36 - Keyboard , and <
+#define HID_KEYBOARD_DOT 55 // 0x37 - Keyboard . and >
+#define HID_KEYBOARD_FWD_SLASH 56 // 0x38 - Keyboard / and ?
+#define HID_KEYBOARD_CAPS_LOCK 57 // 0x39 - Keyboard Caps Lock
+#define HID_KEYBOARD_F1 58 // 0x3A - Keyboard F1
+#define HID_KEYBOARD_F2 59 // 0x3B - Keyboard F2
+#define HID_KEYBOARD_F3 60 // 0x3C - Keyboard F3
+#define HID_KEYBOARD_F4 61 // 0x3D - Keyboard F4
+#define HID_KEYBOARD_F5 62 // 0x3E - Keyboard F5
+#define HID_KEYBOARD_F6 63 // 0x3F - Keyboard F6
+#define HID_KEYBOARD_F7 64 // 0x40 - Keyboard F7
+#define HID_KEYBOARD_F8 65 // 0x41 - Keyboard F8
+#define HID_KEYBOARD_F9 66 // 0x42 - Keyboard F9
+#define HID_KEYBOARD_F10 67 // 0x43 - Keyboard F10
+#define HID_KEYBOARD_F11 68 // 0x44 - Keyboard F11
+#define HID_KEYBOARD_F12 69 // 0x45 - Keyboard F12
+#define HID_KEYBOARD_PRNT_SCREEN 70 // 0x46 - Keyboard Print Screen
+#define HID_KEYBOARD_SCROLL_LOCK 71 // 0x47 - Keyboard Scroll Lock
+#define HID_KEYBOARD_PAUSE 72 // 0x48 - Keyboard Pause
+#define HID_KEYBOARD_INSERT 73 // 0x49 - Keyboard Insert
+#define HID_KEYBOARD_HOME 74 // 0x4A - Keyboard Home
+#define HID_KEYBOARD_PAGE_UP 75 // 0x4B - Keyboard PageUp
+#define HID_KEYBOARD_DELETE_FWD 76 // 0x4C - Keyboard Delete Forward
+#define HID_KEYBOARD_END 77 // 0x4D - Keyboard End
+#define HID_KEYBOARD_PAGE_DOWN 78 // 0x4E - Keyboard PageDown
+#define HID_KEYBOARD_RIGHT_ARROW 79 // 0x4F - Keyboard RightArrow
+#define HID_KEYBOARD_LEFT_ARROW 80 // 0x50 - Keyboard LeftArrow
+#define HID_KEYBOARD_DOWN_ARROW 81 // 0x51 - Keyboard DownArrow
+#define HID_KEYBOARD_UP_ARROW 82 // 0x52 - Keyboard UpArrow
+#define HID_KEYBPAD_NUM_LOCK 83 // 0x53 - Keypad Num Lock and Clear
+#define HID_KEYBPAD_DIVIDE 84 // 0x54 - Keypad /
+#define HID_KEYBOARD_MULTIPLY 85 // 0x55 - Keypad *
+#define HID_KEYBOARD_SUBTRACT 86 // 0x56 - Keypad -
+#define HID_KEYBPAD_ADD 87 // 0x57 - Keypad +
+#define HID_KEYBPAD_ENTER 88 // 0x58 - Keypad ENTER
+#define HID_KEYBPAD_1 89 // 0x59 - Keypad 1 and End
+#define HID_KEYBPAD_2 90 // 0x5A - Keypad 2 and Down Arrow
+#define HID_KEYBPAD_3 91 // 0x5B - Keypad 3 and PageDn
+#define HID_KEYBPAD_4 92 // 0x5C - Keypad 4 and Lfet Arrow
+#define HID_KEYBPAD_5 93 // 0x5D - Keypad 5
+#define HID_KEYBPAD_6 94 // 0x5E - Keypad 6 and Right Arrow
+#define HID_KEYBPAD_7 95 // 0x5F - Keypad 7 and Home
+#define HID_KEYBPAD_8 96 // 0x60 - Keypad 8 and Up Arrow
+#define HID_KEYBPAD_9 97 // 0x61 - Keypad 9 and PageUp
+#define HID_KEYBPAD_0 98 // 0x62 - Keypad 0 and Insert
+#define HID_KEYBPAD_DOT 99 // 0x63 - Keypad . and Delete
+#define HID_KEYBOARD_MUTE 127 // 0x7F - Keyboard Mute
+#define HID_KEYBOARD_VOLUME_UP 128 // 0x80 - Keyboard Volume up
+#define HID_KEYBOARD_VOLUME_DOWN 129 // 0x81 - Keyboard Volume down
+#define HID_KEYBOARD_LEFT_CTRL 224 // 0xE0 - Keyboard LeftContorl
+#define HID_KEYBOARD_LEFT_SHIFT 225 // 0xE1 - Keyboard LeftShift
+#define HID_KEYBOARD_LEFT_ALT 226 // 0xE2 - Keyboard LeftAlt
+#define HID_KEYBOARD_LEFT_GUI 227 // 0xE3 - Keyboard LeftGUI
+#define HID_KEYBOARD_RIGHT_CTRL 228 // 0xE4 - Keyboard LeftContorl
+#define HID_KEYBOARD_RIGHT_SHIFT 229 // 0xE5 - Keyboard LeftShift
+#define HID_KEYBOARD_RIGHT_ALT 230 // 0xE6 - Keyboard LeftAlt
+#define HID_KEYBOARD_RIGHT_GUI 231 // 0xE7 - Keyboard RightGUI
+
+#define HID_MOUSE_BUTTON_LEFT 253
+#define HID_MOUSE_BUTTON_MIDDLE 254
+#define HID_MOUSE_BUTTON_RIGHT 255
+
+// HID Consumer Usage IDs (subset of the codes available in the USB HID Usage Tables spec)
+#define HID_CONSUMER_POWER 48 // 0x30 - Power
+#define HID_CONSUMER_RESET 49 // 0x31 - Reset
+#define HID_CONSUMER_SLEEP 50 // 0x32 - Sleep
+
+#define HID_CONSUMER_MENU 64 // 0x40 - Menu
+#define HID_CONSUMER_SELECTION 128 // 0x80 - Selection
+#define HID_CONSUMER_ASSIGN_SEL 129 // 0x81 - Assign Selection
+#define HID_CONSUMER_MODE_STEP 130 // 0x82 - Mode Step
+#define HID_CONSUMER_RECALL_LAST 131 // 0x83 - Recall Last
+#define HID_CONSUMER_QUIT 148 // 0x94 - Quit
+#define HID_CONSUMER_HELP 149 // 0x95 - Help
+#define HID_CONSUMER_CHANNEL_UP 156 // 0x9C - Channel Increment
+#define HID_CONSUMER_CHANNEL_DOWN 157 // 0x9D - Channel Decrement
+
+#define HID_CONSUMER_PLAY 176 // 0xB0 - Play
+#define HID_CONSUMER_PAUSE 177 // 0xB1 - Pause
+#define HID_CONSUMER_RECORD 178 // 0xB2 - Record
+#define HID_CONSUMER_FAST_FORWARD 179 // 0xB3 - Fast Forward
+#define HID_CONSUMER_REWIND 180 // 0xB4 - Rewind
+#define HID_CONSUMER_SCAN_NEXT_TRK 181 // 0xB5 - Scan Next Track
+#define HID_CONSUMER_SCAN_PREV_TRK 182 // 0xB6 - Scan Previous Track
+#define HID_CONSUMER_STOP 183 // 0xB7 - Stop
+#define HID_CONSUMER_EJECT 184 // 0xB8 - Eject
+#define HID_CONSUMER_RANDOM_PLAY 185 // 0xB9 - Random Play
+#define HID_CONSUMER_SELECT_DISC 186 // 0xBA - Select Disk
+#define HID_CONSUMER_ENTER_DISC 187 // 0xBB - Enter Disc
+#define HID_CONSUMER_REPEAT 188 // 0xBC - Repeat
+#define HID_CONSUMER_STOP_EJECT 204 // 0xCC - Stop/Eject
+#define HID_CONSUMER_PLAY_PAUSE 205 // 0xCD - Play/Pause
+#define HID_CONSUMER_PLAY_SKIP 206 // 0xCE - Play/Skip
+
+#define HID_CONSUMER_VOLUME 224 // 0xE0 - Volume
+#define HID_CONSUMER_BALANCE 225 // 0xE1 - Balance
+#define HID_CONSUMER_MUTE 226 // 0xE2 - Mute
+#define HID_CONSUMER_BASS 227 // 0xE3 - Bass
+#define HID_CONSUMER_VOLUME_UP 233 // 0xE9 - Volume Increment
+#define HID_CONSUMER_VOLUME_DOWN 234 // 0xEA - Volume Decrement
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// HID report mapping table
+typedef struct
+{
+ uint16 handle; // Handle of report characteristic
+ uint16 cccdHandle; // Handle of CCCD for report characteristic
+ uint8 id; // Report ID
+ uint8 type; // Report type
+ uint8 mode; // Protocol mode (report or boot)
+} hidRptMap_t;
+
+// HID dev configuration structure
+typedef struct
+{
+ uint32 idleTimeout; // Idle timeout in milliseconds
+ uint8 hidFlags; // HID feature flags
+
+} hidDevCfg_t;
+
+/*********************************************************************
+ * Global Variables
+ */
+
+// These variables are defined in the service .c file that uses HID Dev
+
+// HID report map length
+extern uint8 hidReportMapLen;
+
+// HID protocol mode
+extern uint8 hidProtocolMode;
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// HID Report callback
+typedef uint8 (*hidDevReportCB_t)( uint8 id, uint8 type, uint16 uuid,
+ uint8 oper, uint8 *pLen, uint8 *pData );
+
+// HID event callback
+typedef void (*hidDevEvtCB_t)( uint8 evt );
+
+// HID passcode callback
+typedef void (*hidDevPasscodeCB_t)( uint8 *deviceAddr, uint16 connectionHandle,
+ uint8 uiInputs, uint8 uiOutputs );
+
+typedef struct
+{
+ hidDevReportCB_t reportCB;
+ hidDevEvtCB_t evtCB;
+ hidDevPasscodeCB_t passcodeCB;
+} hidDevCB_t;
+
+/*********************************************************************
+ * @fn HidDev_Init
+ *
+ * @brief Initialization function for the Hid Dev 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
+ */
+extern void HidDev_Init( uint8 task_id );
+
+/*********************************************************************
+ * @fn HidDev_ProcessEvent
+ *
+ * @brief Hid Dev 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 events not processed
+ */
+extern uint16 HidDev_ProcessEvent( uint8 task_id, uint16 events );
+
+/*********************************************************************
+ * @fn HidDev_Register
+ *
+ * @brief Register a callback function with HID Dev.
+ *
+ * @param pCfg - Parameter configuration.
+ * @param pCBs - Callback function.
+ *
+ * @return None.
+ */
+extern void HidDev_Register( hidDevCfg_t *pCfg, hidDevCB_t *pCBs );
+
+/*********************************************************************
+ * @fn HidDev_RegisterReports
+ *
+ * @brief Register the report table with HID Dev.
+ *
+ * @param numReports - Length of report table.
+ * @param pRpt - Report table.
+ *
+ * @return None.
+ */
+extern void HidDev_RegisterReports( uint8 numReports, hidRptMap_t *pRpt );
+
+/*********************************************************************
+ * @fn HidDev_Report
+ *
+ * @brief Send a HID report.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param len - Length of report.
+ * @param pData - Report data.
+ *
+ * @return None.
+ */
+extern void HidDev_Report( uint8 id, uint8 type, uint8 len, uint8 *pData );
+
+/*********************************************************************
+ * @fn HidDev_Close
+ *
+ * @brief Close the connection or stop advertising.
+ *
+ * @return None.
+ */
+extern void HidDev_Close( void );
+
+/*********************************************************************
+ * @fn HidDev_SetParameter
+ *
+ * @brief Set a HID Dev parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+extern bStatus_t HidDev_SetParameter( uint8 param, uint8 len, void *pValue );
+
+/*********************************************************************
+ * @fn HidDev_GetParameter
+ *
+ * @brief Get a HID Dev parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param pValue - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+extern bStatus_t HidDev_GetParameter( uint8 param, void *pValue );
+
+/*********************************************************************
+ * @fn HidDev_PasscodeRsp
+ *
+ * @brief Respond to a passcode request.
+ *
+ * @param status - SUCCESS if passcode is available, otherwise
+ * see @ref SMP_PAIRING_FAILED_DEFINES.
+ * @param passcode - integer value containing the passcode.
+ *
+ * @return none
+ */
+extern void HidDev_PasscodeRsp( uint8 status, uint32 passcode );
+
+/*********************************************************************
+ * @fn HidDev_ReadAttrCB
+ *
+ * @brief HID Dev attribute read callback.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+extern uint8 HidDev_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+
+/*********************************************************************
+ * @fn HidDev_WriteAttrCB
+ *
+ * @brief HID Dev attribute read callback.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t HidDev_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HIDDEV_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDevKbM/hidkbmservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDevKbM/hidkbmservice.c
new file mode 100644
index 0000000..bda3761
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDevKbM/hidkbmservice.c
@@ -0,0 +1,956 @@
+/**************************************************************************************************
+ Filename: hidkbmservice.c
+ Revised: $Date: 2012-05-29 15:29:05 -0700 (Tue, 29 May 2012) $
+ Revision: $Revision: 30647 $
+
+ Description: This file contains the HID service for a keyboard/mouse.
+
+ Copyright 2011-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "linkdb.h"
+#include "gattservapp.h"
+#include "hidkbmservice.h"
+#include "hid_uuid.h"
+#include "hiddev.h"
+#include "battservice.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+// HID service
+CONST uint8 hidServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_SERVICE_UUID), HI_UINT16(HID_SERVICE_UUID)
+};
+
+// HID Boot Keyboard Input Report characteristic
+CONST uint8 hidBootKeyInputUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_BOOT_KEY_INPUT_UUID), HI_UINT16(HID_BOOT_KEY_INPUT_UUID)
+};
+
+// HID Boot Mouse Input Report characteristic
+CONST uint8 hidBootMouseInputUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_BOOT_MOUSE_INPUT_UUID), HI_UINT16(HID_BOOT_MOUSE_INPUT_UUID)
+};
+
+// HID Boot Keyboard Output Report characteristic
+CONST uint8 hidBootKeyOutputUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_BOOT_KEY_OUTPUT_UUID), HI_UINT16(HID_BOOT_KEY_OUTPUT_UUID)
+};
+
+// HID Information characteristic
+CONST uint8 hidInfoUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_INFORMATION_UUID), HI_UINT16(HID_INFORMATION_UUID)
+};
+
+// HID Report Map characteristic
+CONST uint8 hidReportMapUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_REPORT_MAP_UUID), HI_UINT16(HID_REPORT_MAP_UUID)
+};
+
+// HID Control Point characteristic
+CONST uint8 hidControlPointUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_CONTROL_POINT_UUID), HI_UINT16(HID_CONTROL_POINT_UUID)
+};
+
+// HID Report characteristic
+CONST uint8 hidReportUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_REPORT_UUID), HI_UINT16(HID_REPORT_UUID)
+};
+
+// HID Protocol Mode characteristic
+CONST uint8 hidProtocolModeUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_PROTOCOL_MODE_UUID), HI_UINT16(HID_PROTOCOL_MODE_UUID)
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+// HID Information characteristic value
+static CONST uint8 hidInfo[HID_INFORMATION_LEN] =
+{
+ LO_UINT16(0x0111), HI_UINT16(0x0111), // bcdHID (USB HID version)
+ 0x00, // bCountryCode
+ HID_KBD_FLAGS // Flags
+};
+
+// HID Report Map characteristic value
+// Keyboard report descriptor (using format for Boot interface descriptor)
+static CONST uint8 hidReportMap[] =
+{
+ 0x05, 0x01, // Usage Page (Generic Desktop)
+ 0x09, 0x02, // Usage (Mouse)
+ 0xA1, 0x01, // Collection (Application)
+ 0x85, 0x01, // Report Id (1)
+ 0x09, 0x01, // Usage (Pointer)
+ 0xA1, 0x00, // Collection (Physical)
+ 0x05, 0x09, // Usage Page (Buttons)
+ 0x19, 0x01, // Usage Minimum (01) - Button 1
+ 0x29, 0x03, // Usage Maximum (03) - Button 3
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x25, 0x01, // Logical Maximum (1)
+ 0x75, 0x01, // Report Size (1)
+ 0x95, 0x03, // Report Count (3)
+ 0x81, 0x02, // Input (Data, Variable, Absolute) - Button states
+ 0x75, 0x05, // Report Size (5)
+ 0x95, 0x01, // Report Count (1)
+ 0x81, 0x01, // Input (Constant) - Padding or Reserved bits
+ 0x05, 0x01, // Usage Page (Generic Desktop)
+ 0x09, 0x30, // Usage (X)
+ 0x09, 0x31, // Usage (Y)
+ 0x09, 0x38, // Usage (Wheel)
+ 0x15, 0x81, // Logical Minimum (-127)
+ 0x25, 0x7F, // Logical Maximum (127)
+ 0x75, 0x08, // Report Size (8)
+ 0x95, 0x03, // Report Count (3)
+ 0x81, 0x06, // Input (Data, Variable, Relative) - X & Y coordinate
+ 0xC0, // End Collection
+ 0xC0, // End Collection
+
+ 0x05, 0x01, // Usage Pg (Generic Desktop)
+ 0x09, 0x06, // Usage (Keyboard)
+ 0xA1, 0x01, // Collection: (Application)
+ 0x85, 0x02, // Report Id (2)
+ //
+ 0x05, 0x07, // Usage Pg (Key Codes)
+ 0x19, 0xE0, // Usage Min (224)
+ 0x29, 0xE7, // Usage Max (231)
+ 0x15, 0x00, // Log Min (0)
+ 0x25, 0x01, // Log Max (1)
+ //
+ // Modifier byte
+ 0x75, 0x01, // Report Size (1)
+ 0x95, 0x08, // Report Count (8)
+ 0x81, 0x02, // Input: (Data, Variable, Absolute)
+ //
+ // Reserved byte
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x08, // Report Size (8)
+ 0x81, 0x01, // Input: (Constant)
+ //
+ // LED report
+ 0x95, 0x05, // Report Count (5)
+ 0x75, 0x01, // Report Size (1)
+ 0x05, 0x08, // Usage Pg (LEDs)
+ 0x19, 0x01, // Usage Min (1)
+ 0x29, 0x05, // Usage Max (5)
+ 0x91, 0x02, // Output: (Data, Variable, Absolute)
+ //
+ // LED report padding
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x03, // Report Size (3)
+ 0x91, 0x01, // Output: (Constant)
+ //
+ // Key arrays (6 bytes)
+ 0x95, 0x06, // Report Count (6)
+ 0x75, 0x08, // Report Size (8)
+ 0x15, 0x00, // Log Min (0)
+ 0x25, 0x65, // Log Max (101)
+ 0x05, 0x07, // Usage Pg (Key Codes)
+ 0x19, 0x00, // Usage Min (0)
+ 0x29, 0x65, // Usage Max (101)
+ 0x81, 0x00, // Input: (Data, Array)
+ //
+ 0xC0, // End Collection
+ //
+ 0x05, 0x0C, // Usage Pg (Consumer Devices)
+ 0x09, 0x01, // Usage (Consumer Control)
+ 0xA1, 0x01, // Collection (Application)
+ 0x85, 0x03, // Report Id (3)
+ 0x09, 0x02, // Usage (Numeric Key Pad)
+ 0xA1, 0x02, // Collection (Logical)
+ 0x05, 0x09, // Usage Pg (Button)
+ 0x19, 0x01, // Usage Min (Button 1)
+ 0x29, 0x0A, // Usage Max (Button 10)
+ 0x15, 0x01, // Logical Min (1)
+ 0x25, 0x0A, // Logical Max (10)
+ 0x75, 0x04, // Report Size (4)
+ 0x95, 0x01, // Report Count (1)
+ 0x81, 0x00, // Input (Data, Ary, Abs)
+ 0xC0, // End Collection
+ 0x05, 0x0C, // Usage Pg (Consumer Devices)
+ 0x09, 0x86, // Usage (Channel)
+ 0x15, 0xFF, // Logical Min (-1)
+ 0x25, 0x01, // Logical Max (1)
+ 0x75, 0x02, // Report Size (2)
+ 0x95, 0x01, // Report Count (1)
+ 0x81, 0x46, // Input (Data, Var, Rel, Null)
+ 0x09, 0xE9, // Usage (Volume Up)
+ 0x09, 0xEA, // Usage (Volume Down)
+ 0x15, 0x00, // Logical Min (0)
+ 0x75, 0x01, // Report Size (1)
+ 0x95, 0x02, // Report Count (2)
+ 0x81, 0x02, // Input (Data, Var, Abs)
+ 0x09, 0xE2, // Usage (Mute)
+ 0x09, 0x30, // Usage (Power)
+ 0x09, 0x83, // Usage (Recall Last)
+ 0x09, 0x81, // Usage (Assign Selection)
+ 0x09, 0xB0, // Usage (Play)
+ 0x09, 0xB1, // Usage (Pause)
+ 0x09, 0xB2, // Usage (Record)
+ 0x09, 0xB3, // Usage (Fast Forward)
+ 0x09, 0xB4, // Usage (Rewind)
+ 0x09, 0xB5, // Usage (Scan Next)
+ 0x09, 0xB6, // Usage (Scan Prev)
+ 0x09, 0xB7, // Usage (Stop)
+ 0x15, 0x01, // Logical Min (1)
+ 0x25, 0x0C, // Logical Max (12)
+ 0x75, 0x04, // Report Size (4)
+ 0x95, 0x01, // Report Count (1)
+ 0x81, 0x00, // Input (Data, Ary, Abs)
+ 0x09, 0x80, // Usage (Selection)
+ 0xA1, 0x02, // Collection (Logical)
+ 0x05, 0x09, // Usage Pg (Button)
+ 0x19, 0x01, // Usage Min (Button 1)
+ 0x29, 0x03, // Usage Max (Button 3)
+ 0x15, 0x01, // Logical Min (1)
+ 0x25, 0x03, // Logical Max (3)
+ 0x75, 0x02, // Report Size (2)
+ 0x81, 0x00, // Input (Data, Ary, Abs)
+ 0xC0, // End Collection
+ 0x81, 0x03, // Input (Const, Var, Abs)
+ 0xC0 // End Collection
+};
+
+// HID report map length
+uint8 hidReportMapLen = sizeof(hidReportMap);
+
+// HID report mapping table
+static hidRptMap_t hidRptMap[HID_NUM_REPORTS];
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// HID Service attribute
+static CONST gattAttrType_t hidService = { ATT_BT_UUID_SIZE, hidServUUID };
+
+// Include attribute (Battery service)
+static uint16 include = GATT_INVALID_HANDLE;
+
+// HID Information characteristic
+static uint8 hidInfoProps = GATT_PROP_READ;
+
+// HID Report Map characteristic
+static uint8 hidReportMapProps = GATT_PROP_READ;
+
+// HID External Report Reference Descriptor
+static uint8 hidExtReportRefDesc[ATT_BT_UUID_SIZE] =
+ { LO_UINT16(BATT_LEVEL_UUID), HI_UINT16(BATT_LEVEL_UUID) };
+
+// HID Control Point characteristic
+static uint8 hidControlPointProps = GATT_PROP_WRITE_NO_RSP;
+static uint8 hidControlPoint;
+
+// HID Protocol Mode characteristic
+static uint8 hidProtocolModeProps = GATT_PROP_READ | GATT_PROP_WRITE_NO_RSP;
+uint8 hidProtocolMode = HID_PROTOCOL_MODE_REPORT;
+
+// HID Report characteristic, mouse input
+static uint8 hidReportMouseInProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+static uint8 hidReportMouseIn;
+static gattCharCfg_t hidReportMouseInClientCharCfg[GATT_MAX_NUM_CONN];
+
+// HID Report Reference characteristic descriptor, mouse input
+static uint8 hidReportRefMouseIn[HID_REPORT_REF_LEN] =
+ { HID_RPT_ID_MOUSE_IN, HID_REPORT_TYPE_INPUT };
+
+// HID Report characteristic, key input
+static uint8 hidReportKeyInProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+static uint8 hidReportKeyIn;
+static gattCharCfg_t hidReportKeyInClientCharCfg[GATT_MAX_NUM_CONN];
+
+// HID Report Reference characteristic descriptor, key input
+static uint8 hidReportRefKeyIn[HID_REPORT_REF_LEN] =
+ { HID_RPT_ID_KEY_IN, HID_REPORT_TYPE_INPUT };
+
+// HID Report characteristic, consumer control input
+static uint8 hidReportCCInProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+static uint8 hidReportCCIn;
+static gattCharCfg_t hidReportCCInClientCharCfg[GATT_MAX_NUM_CONN];
+
+// HID Report Reference characteristic descriptor, consumer control input
+static uint8 hidReportRefCCIn[HID_REPORT_REF_LEN] =
+ { HID_RPT_ID_CC_IN, HID_REPORT_TYPE_INPUT };
+
+// HID Report characteristic, LED output
+static uint8 hidReportLedOutProps = GATT_PROP_READ | GATT_PROP_WRITE | GATT_PROP_WRITE_NO_RSP;
+static uint8 hidReportLedOut;
+
+// HID Report Reference characteristic descriptor, LED output
+static uint8 hidReportRefLedOut[HID_REPORT_REF_LEN] =
+ { HID_RPT_ID_LED_OUT, HID_REPORT_TYPE_OUTPUT };
+
+// HID Boot Keyboard Input Report
+static uint8 hidReportBootKeyInProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+static uint8 hidReportBootKeyIn;
+static gattCharCfg_t hidReportBootKeyInClientCharCfg[GATT_MAX_NUM_CONN];
+
+// HID Boot Keyboard Output Report
+static uint8 hidReportBootKeyOutProps = GATT_PROP_READ | GATT_PROP_WRITE | GATT_PROP_WRITE_NO_RSP;
+static uint8 hidReportBootKeyOut;
+
+// HID Boot Mouse Input Report
+static uint8 hidReportBootMouseInProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+static uint8 hidReportBootMouseIn;
+static gattCharCfg_t hidReportBootMouseInClientCharCfg[GATT_MAX_NUM_CONN];
+
+// Feature Report
+static uint8 hidReportFeatureProps = GATT_PROP_READ | GATT_PROP_WRITE;
+static uint8 hidReportFeature;
+
+// HID Report Reference characteristic descriptor, Feature
+static uint8 hidReportRefFeature[HID_REPORT_REF_LEN] =
+ { HID_RPT_ID_FEATURE, HID_REPORT_TYPE_FEATURE };
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t hidAttrTbl[] =
+{
+ // HID Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *) &hidService /* pValue */
+ },
+
+ // Included service (battery)
+ {
+ { ATT_BT_UUID_SIZE, includeUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *)&include
+ },
+
+ // HID Information characteristic declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidInfoProps
+ },
+
+ // HID Information characteristic
+ {
+ { ATT_BT_UUID_SIZE, hidInfoUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) hidInfo
+ },
+
+ // HID Control Point characteristic declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidControlPointProps
+ },
+
+ // HID Control Point characteristic
+ {
+ { ATT_BT_UUID_SIZE, hidControlPointUUID },
+ GATT_PERMIT_WRITE,
+ 0,
+ &hidControlPoint
+ },
+
+ // HID Protocol Mode characteristic declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidProtocolModeProps
+ },
+
+ // HID Protocol Mode characteristic
+ {
+ { ATT_BT_UUID_SIZE, hidProtocolModeUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &hidProtocolMode
+ },
+
+
+ // HID Report Map characteristic declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportMapProps
+ },
+
+ // HID Report Map characteristic
+ {
+ { ATT_BT_UUID_SIZE, hidReportMapUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) hidReportMap
+ },
+
+ // HID External Report Reference Descriptor
+ {
+ { ATT_BT_UUID_SIZE, extReportRefUUID },
+ GATT_PERMIT_READ,
+ 0,
+ hidExtReportRefDesc
+ },
+
+ // HID Report characteristic, mouse input declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportMouseInProps
+ },
+
+ // HID Report characteristic, mouse input
+ {
+ { ATT_BT_UUID_SIZE, hidReportUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportMouseIn
+ },
+
+ // HID Report characteristic client characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &hidReportMouseInClientCharCfg
+ },
+
+ // HID Report Reference characteristic descriptor, mouse input
+ {
+ { ATT_BT_UUID_SIZE, reportRefUUID },
+ GATT_PERMIT_READ,
+ 0,
+ hidReportRefMouseIn
+ },
+
+ // HID Report characteristic, key input declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportKeyInProps
+ },
+
+ // HID Report characteristic, key input
+ {
+ { ATT_BT_UUID_SIZE, hidReportUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportKeyIn
+ },
+
+ // HID Report characteristic client characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &hidReportKeyInClientCharCfg
+ },
+
+ // HID Report Reference characteristic descriptor, key input
+ {
+ { ATT_BT_UUID_SIZE, reportRefUUID },
+ GATT_PERMIT_READ,
+ 0,
+ hidReportRefKeyIn
+ },
+
+ // HID Report characteristic, consumer control input declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportCCInProps
+ },
+
+ // HID Report characteristic, consumer control input
+ {
+ { ATT_BT_UUID_SIZE, hidReportUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportCCIn
+ },
+
+ // HID Report characteristic client characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &hidReportCCInClientCharCfg
+ },
+
+ // HID Report Reference characteristic descriptor, consumer control input
+ {
+ { ATT_BT_UUID_SIZE, reportRefUUID },
+ GATT_PERMIT_READ,
+ 0,
+ hidReportRefCCIn
+ },
+
+ // HID Report characteristic, LED output declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportLedOutProps
+ },
+
+ // HID Report characteristic, LED output
+ {
+ { ATT_BT_UUID_SIZE, hidReportUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &hidReportLedOut
+ },
+
+ // HID Report Reference characteristic descriptor, LED output
+ {
+ { ATT_BT_UUID_SIZE, reportRefUUID },
+ GATT_PERMIT_READ,
+ 0,
+ hidReportRefLedOut
+ },
+
+ // HID Boot Keyboard Input Report declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportBootKeyInProps
+ },
+
+ // HID Boot Keyboard Input Report
+ {
+ { ATT_BT_UUID_SIZE, hidBootKeyInputUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportBootKeyIn
+ },
+
+ // HID Boot Keyboard Input Report characteristic client characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &hidReportBootKeyInClientCharCfg
+ },
+
+ // HID Boot Keyboard Output Report declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportBootKeyOutProps
+ },
+
+ // HID Boot Keyboard Output Report
+ {
+ { ATT_BT_UUID_SIZE, hidBootKeyOutputUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &hidReportBootKeyOut
+ },
+
+ // HID Boot Mouse Input Report declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportBootMouseInProps
+ },
+
+ // HID Boot Mouse Input Report
+ {
+ { ATT_BT_UUID_SIZE, hidBootMouseInputUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportBootMouseIn
+ },
+
+ // HID Boot Mouse Input Report characteristic client characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &hidReportBootMouseInClientCharCfg
+ },
+
+ // Feature Report declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportFeatureProps
+ },
+
+ // Feature Report
+ {
+ { ATT_BT_UUID_SIZE, hidReportUUID},
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &hidReportFeature
+ },
+
+ // HID Report Reference characteristic descriptor, feature
+ {
+ { ATT_BT_UUID_SIZE, reportRefUUID },
+ GATT_PERMIT_READ,
+ 0,
+ hidReportRefFeature
+ },
+};
+
+// Attribute index enumeration-- these indexes match array elements above
+enum
+{
+ HID_SERVICE_IDX, // HID Service
+ HID_INCLUDED_SERVICE_IDX, // Included Service
+ HID_INFO_DECL_IDX, // HID Information characteristic declaration
+ HID_INFO_IDX, // HID Information characteristic
+ HID_CONTROL_POINT_DECL_IDX, // HID Control Point characteristic declaration
+ HID_CONTROL_POINT_IDX, // HID Control Point characteristic
+ HID_PROTOCOL_MODE_DECL_IDX, // HID Protocol Mode characteristic declaration
+ HID_PROTOCOL_MODE_IDX, // HID Protocol Mode characteristic
+ HID_REPORT_MAP_DECL_IDX, // HID Report Map characteristic declaration
+ HID_REPORT_MAP_IDX, // HID Report Map characteristic
+ HID_EXT_REPORT_REF_DESC_IDX, // HID External Report Reference Descriptor
+ HID_REPORT_MOUSE_IN_DECL_IDX, // HID Report characteristic, mouse input declaration
+ HID_REPORT_MOUSE_IN_IDX, // HID Report characteristic, mouse input
+ HID_REPORT_MOUSE_IN_CCCD_IDX, // HID Report characteristic client characteristic configuration
+ HID_REPORT_REF_MOUSE_IN_IDX, // HID Report Reference characteristic descriptor, mouse input
+ HID_REPORT_KEY_IN_DECL_IDX, // HID Report characteristic, key input declaration
+ HID_REPORT_KEY_IN_IDX, // HID Report characteristic, key input
+ HID_REPORT_KEY_IN_CCCD_IDX, // HID Report characteristic client characteristic configuration
+ HID_REPORT_REF_KEY_IN_IDX, // HID Report Reference characteristic descriptor, key input
+ HID_REPORT_CC_IN_DECL_IDX, // HID Report characteristic, consumer control input declaration
+ HID_REPORT_CC_IN_IDX, // HID Report characteristic, consumer control input
+ HID_REPORT_CC_IN_CCCD_IDX, // HID Report characteristic client characteristic configuration
+ HID_REPORT_REF_CC_IN_IDX, // HID Report Reference characteristic descriptor, consumer control input
+ HID_REPORT_LED_OUT_DECL_IDX, // HID Report characteristic, LED output declaration
+ HID_REPORT_LED_OUT_IDX, // HID Report characteristic, LED output
+ HID_REPORT_REF_LED_OUT_IDX, // HID Report Reference characteristic descriptor, LED output
+ HID_BOOT_KEY_IN_DECL_IDX, // HID Boot Keyboard Input Report declaration
+ HID_BOOT_KEY_IN_IDX, // HID Boot Keyboard Input Report
+ HID_BOOT_KEY_IN_CCCD_IDX, // HID Boot Keyboard Input Report characteristic client characteristic configuration
+ HID_BOOT_KEY_OUT_DECL_IDX, // HID Boot Keyboard Output Report declaration
+ HID_BOOT_KEY_OUT_IDX, // HID Boot Keyboard Output Report
+ HID_BOOT_MOUSE_IN_DECL_IDX, // HID Boot Mouse Input Report declaration
+ HID_BOOT_MOUSE_IN_IDX, // HID Boot Mouse Input Report
+ HID_BOOT_MOUSE_IN_CCCD_IDX, // HID Boot Mouse Input Report characteristic client characteristic configuration
+ HID_FEATURE_DECL_IDX, // Feature Report declaration
+ HID_FEATURE_IDX, // Feature Report
+ HID_REPORT_REF_FEATURE_IDX // HID Report Reference characteristic descriptor, feature
+};
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+
+// Service Callbacks
+CONST gattServiceCBs_t hidKbdMsCBs =
+{
+ HidDev_ReadAttrCB, // Read callback function pointer
+ HidDev_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn HidKbM_AddService
+ *
+ * @brief Initializes the HID Service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @return Success or Failure
+ */
+bStatus_t HidKbM_AddService( void )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, hidReportMouseInClientCharCfg );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, hidReportKeyInClientCharCfg );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, hidReportCCInClientCharCfg );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, hidReportBootKeyInClientCharCfg );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, hidReportBootMouseInClientCharCfg );
+
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( hidAttrTbl, GATT_NUM_ATTRS( hidAttrTbl ), &hidKbdMsCBs );
+
+ // Set up included service
+ Batt_GetParameter( BATT_PARAM_SERVICE_HANDLE,
+ &GATT_INCLUDED_HANDLE( hidAttrTbl, HID_INCLUDED_SERVICE_IDX ) );
+
+ // Construct map of reports to characteristic handles
+ // Each report is uniquely identified via its ID and type
+
+ // Mouse input report
+ hidRptMap[0].id = hidReportRefMouseIn[0];
+ hidRptMap[0].type = hidReportRefMouseIn[1];
+ hidRptMap[0].handle = hidAttrTbl[HID_REPORT_MOUSE_IN_IDX].handle;
+ hidRptMap[0].cccdHandle = hidAttrTbl[HID_REPORT_MOUSE_IN_CCCD_IDX].handle;
+ hidRptMap[0].mode = HID_PROTOCOL_MODE_REPORT;
+
+ // Key input report
+ hidRptMap[1].id = hidReportRefKeyIn[0];
+ hidRptMap[1].type = hidReportRefKeyIn[1];
+ hidRptMap[1].handle = hidAttrTbl[HID_REPORT_KEY_IN_IDX].handle;
+ hidRptMap[1].cccdHandle = hidAttrTbl[HID_REPORT_KEY_IN_CCCD_IDX].handle;
+ hidRptMap[1].mode = HID_PROTOCOL_MODE_REPORT;
+
+ // Consumer Control input report
+ hidRptMap[2].id = hidReportRefCCIn[0];
+ hidRptMap[2].type = hidReportRefCCIn[1];
+ hidRptMap[2].handle = hidAttrTbl[HID_REPORT_CC_IN_IDX].handle;
+ hidRptMap[2].cccdHandle = hidAttrTbl[HID_REPORT_CC_IN_CCCD_IDX].handle;
+ hidRptMap[2].mode = HID_PROTOCOL_MODE_REPORT;
+
+ // LED output report
+ hidRptMap[3].id = hidReportRefLedOut[0];
+ hidRptMap[3].type = hidReportRefLedOut[1];
+ hidRptMap[3].handle = hidAttrTbl[HID_REPORT_LED_OUT_IDX].handle;
+ hidRptMap[3].cccdHandle = 0;
+ hidRptMap[3].mode = HID_PROTOCOL_MODE_REPORT;
+
+ // Boot keyboard input report
+ // Use same ID and type as key input report
+ hidRptMap[4].id = hidReportRefKeyIn[0];
+ hidRptMap[4].type = hidReportRefKeyIn[1];
+ hidRptMap[4].handle = hidAttrTbl[HID_BOOT_KEY_IN_IDX].handle;
+ hidRptMap[4].cccdHandle = hidAttrTbl[HID_BOOT_KEY_IN_CCCD_IDX].handle;
+ hidRptMap[4].mode = HID_PROTOCOL_MODE_BOOT;
+
+ // Boot keyboard output report
+ // Use same ID and type as LED output report
+ hidRptMap[5].id = hidReportRefLedOut[0];
+ hidRptMap[5].type = hidReportRefLedOut[1];
+ hidRptMap[5].handle = hidAttrTbl[HID_BOOT_KEY_OUT_IDX].handle;
+ hidRptMap[5].cccdHandle = 0;
+ hidRptMap[5].mode = HID_PROTOCOL_MODE_BOOT;
+
+ // Boot mouse input report
+ // Use same ID and type as mouse input report
+ hidRptMap[6].id = hidReportRefMouseIn[0];
+ hidRptMap[6].type = hidReportRefMouseIn[1];
+ hidRptMap[6].handle = hidAttrTbl[HID_BOOT_MOUSE_IN_IDX].handle;
+ hidRptMap[6].cccdHandle = hidAttrTbl[HID_BOOT_MOUSE_IN_CCCD_IDX].handle;
+ hidRptMap[6].mode = HID_PROTOCOL_MODE_BOOT;
+
+ // Feature report
+ hidRptMap[7].id = hidReportRefFeature[0];
+ hidRptMap[7].type = hidReportRefFeature[1];
+ hidRptMap[7].handle = hidAttrTbl[HID_FEATURE_IDX].handle;
+ hidRptMap[7].cccdHandle = 0;
+ hidRptMap[7].mode = HID_PROTOCOL_MODE_REPORT;
+
+ // Battery level input report
+ VOID Batt_GetParameter( BATT_PARAM_BATT_LEVEL_IN_REPORT, &(hidRptMap[8]) );
+
+ // Setup report ID map
+ HidDev_RegisterReports( HID_NUM_REPORTS, hidRptMap );
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn HidKbM_SetParameter
+ *
+ * @brief Set a HID KbM parameter.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param uuid - attribute uuid.
+ * @param len - length of data to right.
+ * @param pValue - pointer to data to write. This is dependent on
+ * the input parameters and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return GATT status code.
+ */
+uint8 HidKbM_SetParameter( uint8 id, uint8 type, uint16 uuid, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( uuid )
+ {
+ case HID_REPORT_UUID:
+ if ( type == HID_REPORT_TYPE_OUTPUT )
+ {
+ if ( len == 1 )
+ {
+ hidReportLedOut = *((uint8 *)pValue);
+ }
+ else
+ {
+ ret = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else if ( type == HID_REPORT_TYPE_FEATURE )
+ {
+ if ( len == 1 )
+ {
+ hidReportFeature = *((uint8 *)pValue);
+ }
+ else
+ {
+ ret = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ ret = ATT_ERR_ATTR_NOT_FOUND;
+ }
+ break;
+
+ case HID_BOOT_KEY_OUTPUT_UUID:
+ if ( len == 1 )
+ {
+ hidReportBootKeyOut = *((uint8 *)pValue);
+ }
+ else
+ {
+ ret = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ break;
+
+ default:
+ // ignore the request
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn HidKbM_GetParameter
+ *
+ * @brief Get a HID KbM parameter.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param uuid - attribute uuid.
+ * @param pLen - length of data to be read
+ * @param pValue - pointer to data to get. This is dependent on
+ * the input parameters and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return GATT status code.
+ */
+uint8 HidKbM_GetParameter( uint8 id, uint8 type, uint16 uuid, uint8 *pLen, void *pValue )
+{
+ switch ( uuid )
+ {
+ case HID_REPORT_UUID:
+ if ( type == HID_REPORT_TYPE_OUTPUT )
+ {
+ *((uint8 *)pValue) = hidReportLedOut;
+ *pLen = 1;
+ }
+ else if ( type == HID_REPORT_TYPE_FEATURE )
+ {
+ *((uint8 *)pValue) = hidReportFeature;
+ *pLen = 1;
+ }
+ else
+ {
+ *pLen = 0;
+ }
+ break;
+
+ case HID_BOOT_KEY_OUTPUT_UUID:
+ *((uint8 *)pValue) = hidReportBootKeyOut;
+ *pLen = 1;
+ break;
+
+ default:
+ *pLen = 0;
+ break;
+ }
+
+ return ( SUCCESS );
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDevKbM/hidkbmservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDevKbM/hidkbmservice.h
new file mode 100644
index 0000000..b6cb36f
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDevKbM/hidkbmservice.h
@@ -0,0 +1,138 @@
+/**************************************************************************************************
+ Filename: hidkbmservice.h
+ Revised: $Date: 2012-05-29 15:29:05 -0700 (Tue, 29 May 2012) $
+ Revision: $Revision: 30647 $
+
+ Description: This file contains the HID service for a keyboard/mouse.
+
+ Copyright 2011-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef HIDKBMSERVICE_H
+#define HIDKBMSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Number of HID reports defined in the service
+#define HID_NUM_REPORTS 9
+
+// HID Report IDs for the service
+#define HID_RPT_ID_MOUSE_IN 1 // Mouse input report ID
+#define HID_RPT_ID_KEY_IN 2 // Keyboard input report ID
+#define HID_RPT_ID_CC_IN 3 // Consumer Control input report ID
+#define HID_RPT_ID_LED_OUT 0 // LED output report ID
+#define HID_RPT_ID_FEATURE 0 // Feature report ID
+
+// HID feature flags
+#define HID_KBD_FLAGS HID_FLAGS_REMOTE_WAKE
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn HidKbM_AddService
+ *
+ * @brief Initializes the HID service for keyboard/mouse by registering
+ * GATT attributes with the GATT server.
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t HidKbM_AddService( void );
+
+/*********************************************************************
+ * @fn HidKbM_SetParameter
+ *
+ * @brief Set a HID KbM parameter.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param uuid - attribute uuid.
+ * @param len - length of data to right.
+ * @param pValue - pointer to data to write. This is dependent on
+ * the input parameters and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return GATT status code.
+ */
+extern uint8 HidKbM_SetParameter( uint8 id, uint8 type, uint16 uuid, uint8 len, void *pValue );
+
+/*********************************************************************
+ * @fn HidKbM_GetParameter
+ *
+ * @brief Get a HID KbM parameter.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param uuid - attribute uuid.
+ * @param pLen - length of data to be read.
+ * @param pValue - pointer to data to get. This is dependent on
+ * the input parameters and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return GATT status code.
+ */
+extern uint8 HidKbM_GetParameter( uint8 id, uint8 type, uint16 uuid, uint8 *pLen, void *pValue );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HIDKBMSERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDevKbd/hidkbdservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDevKbd/hidkbdservice.c
new file mode 100644
index 0000000..4f5d3e5
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDevKbd/hidkbdservice.c
@@ -0,0 +1,761 @@
+/**************************************************************************************************
+ Filename: hidkbdservice.c
+ Revised: $Date: 2012-02-09 14:40:40 -0800 (Thu, 09 Feb 2012) $
+ Revision: $Revision: 65 $
+
+ Description: This file contains the HID service for a keyboard.
+
+ Copyright 2011-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "linkdb.h"
+#include "gattservapp.h"
+#include "hidkbdservice.h"
+#include "hid_uuid.h"
+#include "hiddev.h"
+#include "battservice.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+// HID service
+CONST uint8 hidServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_SERVICE_UUID), HI_UINT16(HID_SERVICE_UUID)
+};
+
+// HID Boot Keyboard Input Report characteristic
+CONST uint8 hidBootKeyInputUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_BOOT_KEY_INPUT_UUID), HI_UINT16(HID_BOOT_KEY_INPUT_UUID)
+};
+
+// HID Boot Mouse Input Report characteristic
+CONST uint8 hidBootMouseInputUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_BOOT_MOUSE_INPUT_UUID), HI_UINT16(HID_BOOT_MOUSE_INPUT_UUID)
+};
+
+// HID Boot Keyboard Output Report characteristic
+CONST uint8 hidBootKeyOutputUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_BOOT_KEY_OUTPUT_UUID), HI_UINT16(HID_BOOT_KEY_OUTPUT_UUID)
+};
+
+// HID Information characteristic
+CONST uint8 hidInfoUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_INFORMATION_UUID), HI_UINT16(HID_INFORMATION_UUID)
+};
+
+// HID Report Map characteristic
+CONST uint8 hidReportMapUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_REPORT_MAP_UUID), HI_UINT16(HID_REPORT_MAP_UUID)
+};
+
+// HID Control Point characteristic
+CONST uint8 hidControlPointUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_CONTROL_POINT_UUID), HI_UINT16(HID_CONTROL_POINT_UUID)
+};
+
+// HID Report characteristic
+CONST uint8 hidReportUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_REPORT_UUID), HI_UINT16(HID_REPORT_UUID)
+};
+
+// HID Protocol Mode characteristic
+CONST uint8 hidProtocolModeUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HID_PROTOCOL_MODE_UUID), HI_UINT16(HID_PROTOCOL_MODE_UUID)
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+// HID Information characteristic value
+static CONST uint8 hidInfo[HID_INFORMATION_LEN] =
+{
+ LO_UINT16(0x0111), HI_UINT16(0x0111), // bcdHID (USB HID version)
+ 0x00, // bCountryCode
+ HID_KBD_FLAGS // Flags
+};
+
+// HID Report Map characteristic value
+// Keyboard report descriptor (using format for Boot interface descriptor)
+static CONST uint8 hidReportMap[] =
+{
+ 0x05, 0x01, // Usage Pg (Generic Desktop)
+ 0x09, 0x06, // Usage (Keyboard)
+ 0xA1, 0x01, // Collection: (Application)
+ //
+ 0x05, 0x07, // Usage Pg (Key Codes)
+ 0x19, 0xE0, // Usage Min (224)
+ 0x29, 0xE7, // Usage Max (231)
+ 0x15, 0x00, // Log Min (0)
+ 0x25, 0x01, // Log Max (1)
+ //
+ // Modifier byte
+ 0x75, 0x01, // Report Size (1)
+ 0x95, 0x08, // Report Count (8)
+ 0x81, 0x02, // Input: (Data, Variable, Absolute)
+ //
+ // Reserved byte
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x08, // Report Size (8)
+ 0x81, 0x01, // Input: (Constant)
+ //
+ // LED report
+ 0x95, 0x05, // Report Count (5)
+ 0x75, 0x01, // Report Size (1)
+ 0x05, 0x08, // Usage Pg (LEDs)
+ 0x19, 0x01, // Usage Min (1)
+ 0x29, 0x05, // Usage Max (5)
+ 0x91, 0x02, // Output: (Data, Variable, Absolute)
+ //
+ // LED report padding
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x03, // Report Size (3)
+ 0x91, 0x01, // Output: (Constant)
+ //
+ // Key arrays (6 bytes)
+ 0x95, 0x06, // Report Count (6)
+ 0x75, 0x08, // Report Size (8)
+ 0x15, 0x00, // Log Min (0)
+ 0x25, 0x65, // Log Max (101)
+ 0x05, 0x07, // Usage Pg (Key Codes)
+ 0x19, 0x00, // Usage Min (0)
+ 0x29, 0x65, // Usage Max (101)
+ 0x81, 0x00, // Input: (Data, Array)
+ //
+ 0xC0 // End Collection
+};
+
+// HID report map length
+uint8 hidReportMapLen = sizeof(hidReportMap);
+
+// HID report mapping table
+static hidRptMap_t hidRptMap[HID_NUM_REPORTS];
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// HID Service attribute
+static CONST gattAttrType_t hidService = { ATT_BT_UUID_SIZE, hidServUUID };
+
+// Include attribute (Battery service)
+static uint16 include = GATT_INVALID_HANDLE;
+
+// HID Information characteristic
+static uint8 hidInfoProps = GATT_PROP_READ;
+
+// HID Report Map characteristic
+static uint8 hidReportMapProps = GATT_PROP_READ;
+
+// HID External Report Reference Descriptor
+static uint8 hidExtReportRefDesc[ATT_BT_UUID_SIZE] =
+ { LO_UINT16(BATT_LEVEL_UUID), HI_UINT16(BATT_LEVEL_UUID) };
+
+// HID Control Point characteristic
+static uint8 hidControlPointProps = GATT_PROP_WRITE_NO_RSP;
+static uint8 hidControlPoint;
+
+// HID Protocol Mode characteristic
+static uint8 hidProtocolModeProps = GATT_PROP_READ | GATT_PROP_WRITE_NO_RSP;
+uint8 hidProtocolMode = HID_PROTOCOL_MODE_REPORT;
+
+// HID Report characteristic, key input
+static uint8 hidReportKeyInProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+static uint8 hidReportKeyIn;
+static gattCharCfg_t hidReportKeyInClientCharCfg[GATT_MAX_NUM_CONN];
+
+// HID Report Reference characteristic descriptor, key input
+static uint8 hidReportRefKeyIn[HID_REPORT_REF_LEN] =
+ { HID_RPT_ID_KEY_IN, HID_REPORT_TYPE_INPUT };
+
+// HID Report characteristic, LED output
+static uint8 hidReportLedOutProps = GATT_PROP_READ | GATT_PROP_WRITE | GATT_PROP_WRITE_NO_RSP;
+static uint8 hidReportLedOut;
+
+// HID Report Reference characteristic descriptor, LED output
+static uint8 hidReportRefLedOut[HID_REPORT_REF_LEN] =
+ { HID_RPT_ID_LED_OUT, HID_REPORT_TYPE_OUTPUT };
+
+// HID Boot Keyboard Input Report
+static uint8 hidReportBootKeyInProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+static uint8 hidReportBootKeyIn;
+static gattCharCfg_t hidReportBootKeyInClientCharCfg[GATT_MAX_NUM_CONN];
+
+// HID Boot Keyboard Output Report
+static uint8 hidReportBootKeyOutProps = GATT_PROP_READ | GATT_PROP_WRITE | GATT_PROP_WRITE_NO_RSP;
+static uint8 hidReportBootKeyOut;
+
+// HID Boot Mouse Input Report
+static uint8 hidReportBootMouseInProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+static uint8 hidReportBootMouseIn;
+static gattCharCfg_t hidReportBootMouseInClientCharCfg[GATT_MAX_NUM_CONN];
+
+// Feature Report
+static uint8 hidReportFeatureProps = GATT_PROP_READ | GATT_PROP_WRITE;
+static uint8 hidReportFeature;
+
+// HID Report Reference characteristic descriptor, Feature
+static uint8 hidReportRefFeature[HID_REPORT_REF_LEN] =
+ { HID_RPT_ID_FEATURE, HID_REPORT_TYPE_FEATURE };
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t hidAttrTbl[] =
+{
+ // HID Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *) &hidService /* pValue */
+ },
+
+ // Included service (battery)
+ {
+ { ATT_BT_UUID_SIZE, includeUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *)&include
+ },
+
+ // HID Information characteristic declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidInfoProps
+ },
+
+ // HID Information characteristic
+ {
+ { ATT_BT_UUID_SIZE, hidInfoUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) hidInfo
+ },
+
+ // HID Control Point characteristic declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidControlPointProps
+ },
+
+ // HID Control Point characteristic
+ {
+ { ATT_BT_UUID_SIZE, hidControlPointUUID },
+ GATT_PERMIT_WRITE,
+ 0,
+ &hidControlPoint
+ },
+
+ // HID Protocol Mode characteristic declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidProtocolModeProps
+ },
+
+ // HID Protocol Mode characteristic
+ {
+ { ATT_BT_UUID_SIZE, hidProtocolModeUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &hidProtocolMode
+ },
+
+
+ // HID Report Map characteristic declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportMapProps
+ },
+
+ // HID Report Map characteristic
+ {
+ { ATT_BT_UUID_SIZE, hidReportMapUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *) hidReportMap
+ },
+
+ // HID External Report Reference Descriptor
+ {
+ { ATT_BT_UUID_SIZE, extReportRefUUID },
+ GATT_PERMIT_READ,
+ 0,
+ hidExtReportRefDesc
+ },
+
+ // HID Report characteristic, key input declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportKeyInProps
+ },
+
+ // HID Report characteristic, key input
+ {
+ { ATT_BT_UUID_SIZE, hidReportUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportKeyIn
+ },
+
+ // HID Report characteristic client characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &hidReportKeyInClientCharCfg
+ },
+
+ // HID Report Reference characteristic descriptor, key input
+ {
+ { ATT_BT_UUID_SIZE, reportRefUUID },
+ GATT_PERMIT_READ,
+ 0,
+ hidReportRefKeyIn
+ },
+
+ // HID Report characteristic, LED output declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportLedOutProps
+ },
+
+ // HID Report characteristic, LED output
+ {
+ { ATT_BT_UUID_SIZE, hidReportUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &hidReportLedOut
+ },
+
+ // HID Report Reference characteristic descriptor, LED output
+ {
+ { ATT_BT_UUID_SIZE, reportRefUUID },
+ GATT_PERMIT_READ,
+ 0,
+ hidReportRefLedOut
+ },
+
+ // HID Boot Keyboard Input Report declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportBootKeyInProps
+ },
+
+ // HID Boot Keyboard Input Report
+ {
+ { ATT_BT_UUID_SIZE, hidBootKeyInputUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportBootKeyIn
+ },
+
+ // HID Boot Keyboard Input Report characteristic client characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &hidReportBootKeyInClientCharCfg
+ },
+
+ // HID Boot Keyboard Output Report declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportBootKeyOutProps
+ },
+
+ // HID Boot Keyboard Output Report
+ {
+ { ATT_BT_UUID_SIZE, hidBootKeyOutputUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &hidReportBootKeyOut
+ },
+
+ // HID Boot Mouse Input Report declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportBootMouseInProps
+ },
+
+ // HID Boot Mouse Input Report
+ {
+ { ATT_BT_UUID_SIZE, hidBootMouseInputUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportBootMouseIn
+ },
+
+ // HID Boot Mouse Input Report characteristic client characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &hidReportBootMouseInClientCharCfg
+ },
+
+ // Feature Report declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &hidReportFeatureProps
+ },
+
+ // Feature Report
+ {
+ { ATT_BT_UUID_SIZE, hidReportUUID},
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &hidReportFeature
+ },
+
+ // HID Report Reference characteristic descriptor, feature
+ {
+ { ATT_BT_UUID_SIZE, reportRefUUID },
+ GATT_PERMIT_READ,
+ 0,
+ hidReportRefFeature
+ },
+};
+
+// Attribute index enumeration-- these indexes match array elements above
+enum
+{
+ HID_SERVICE_IDX, // HID Service
+ HID_INCLUDED_SERVICE_IDX, // Included Service
+ HID_INFO_DECL_IDX, // HID Information characteristic declaration
+ HID_INFO_IDX, // HID Information characteristic
+ HID_CONTROL_POINT_DECL_IDX, // HID Control Point characteristic declaration
+ HID_CONTROL_POINT_IDX, // HID Control Point characteristic
+ HID_PROTOCOL_MODE_DECL_IDX, // HID Protocol Mode characteristic declaration
+ HID_PROTOCOL_MODE_IDX, // HID Protocol Mode characteristic
+ HID_REPORT_MAP_DECL_IDX, // HID Report Map characteristic declaration
+ HID_REPORT_MAP_IDX, // HID Report Map characteristic
+ HID_EXT_REPORT_REF_DESC_IDX, // HID External Report Reference Descriptor
+ HID_REPORT_KEY_IN_DECL_IDX, // HID Report characteristic, key input declaration
+ HID_REPORT_KEY_IN_IDX, // HID Report characteristic, key input
+ HID_REPORT_KEY_IN_CCCD_IDX, // HID Report characteristic client characteristic configuration
+ HID_REPORT_REF_KEY_IN_IDX, // HID Report Reference characteristic descriptor, key input
+ HID_REPORT_LED_OUT_DECL_IDX, // HID Report characteristic, LED output declaration
+ HID_REPORT_LED_OUT_IDX, // HID Report characteristic, LED output
+ HID_REPORT_REF_LED_OUT_IDX, // HID Report Reference characteristic descriptor, LED output
+ HID_BOOT_KEY_IN_DECL_IDX, // HID Boot Keyboard Input Report declaration
+ HID_BOOT_KEY_IN_IDX, // HID Boot Keyboard Input Report
+ HID_BOOT_KEY_IN_CCCD_IDX, // HID Boot Keyboard Input Report characteristic client characteristic configuration
+ HID_BOOT_KEY_OUT_DECL_IDX, // HID Boot Keyboard Output Report declaration
+ HID_BOOT_KEY_OUT_IDX, // HID Boot Keyboard Output Report
+ HID_BOOT_MOUSE_IN_DECL_IDX, // HID Boot Mouse Input Report declaration
+ HID_BOOT_MOUSE_IN_IDX, // HID Boot Mouse Input Report
+ HID_BOOT_MOUSE_IN_CCCD_IDX, // HID Boot Mouse Input Report characteristic client characteristic configuration
+ HID_FEATURE_DECL_IDX, // Feature Report declaration
+ HID_FEATURE_IDX, // Feature Report
+ HID_REPORT_REF_FEATURE_IDX // HID Report Reference characteristic descriptor, feature
+};
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+
+// Service Callbacks
+CONST gattServiceCBs_t hidKbdCBs =
+{
+ HidDev_ReadAttrCB, // Read callback function pointer
+ HidDev_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn HidKbd_AddService
+ *
+ * @brief Initializes the HID Service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @return Success or Failure
+ */
+bStatus_t HidKbd_AddService( void )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, hidReportKeyInClientCharCfg );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, hidReportBootKeyInClientCharCfg );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, hidReportBootMouseInClientCharCfg );
+
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( hidAttrTbl, GATT_NUM_ATTRS( hidAttrTbl ), &hidKbdCBs );
+
+ // Set up included service
+ Batt_GetParameter( BATT_PARAM_SERVICE_HANDLE,
+ &GATT_INCLUDED_HANDLE( hidAttrTbl, HID_INCLUDED_SERVICE_IDX ) );
+
+ // Construct map of reports to characteristic handles
+ // Each report is uniquely identified via its ID and type
+
+ // Key input report
+ hidRptMap[0].id = hidReportRefKeyIn[0];
+ hidRptMap[0].type = hidReportRefKeyIn[1];
+ hidRptMap[0].handle = hidAttrTbl[HID_REPORT_KEY_IN_IDX].handle;
+ hidRptMap[0].cccdHandle = hidAttrTbl[HID_REPORT_KEY_IN_CCCD_IDX].handle;
+ hidRptMap[0].mode = HID_PROTOCOL_MODE_REPORT;
+
+ // LED output report
+ hidRptMap[1].id = hidReportRefLedOut[0];
+ hidRptMap[1].type = hidReportRefLedOut[1];
+ hidRptMap[1].handle = hidAttrTbl[HID_REPORT_LED_OUT_IDX].handle;
+ hidRptMap[1].cccdHandle = 0;
+ hidRptMap[1].mode = HID_PROTOCOL_MODE_REPORT;
+
+ // Boot keyboard input report
+ // Use same ID and type as key input report
+ hidRptMap[2].id = hidReportRefKeyIn[0];
+ hidRptMap[2].type = hidReportRefKeyIn[1];
+ hidRptMap[2].handle = hidAttrTbl[HID_BOOT_KEY_IN_IDX].handle;
+ hidRptMap[2].cccdHandle = hidAttrTbl[HID_BOOT_KEY_IN_CCCD_IDX].handle;
+ hidRptMap[2].mode = HID_PROTOCOL_MODE_BOOT;
+
+ // Boot keyboard output report
+ // Use same ID and type as LED output report
+ hidRptMap[3].id = hidReportRefLedOut[0];
+ hidRptMap[3].type = hidReportRefLedOut[1];
+ hidRptMap[3].handle = hidAttrTbl[HID_BOOT_KEY_OUT_IDX].handle;
+ hidRptMap[3].cccdHandle = 0;
+ hidRptMap[3].mode = HID_PROTOCOL_MODE_BOOT;
+
+ // Boot mouse input report
+ hidRptMap[4].id = HID_RPT_ID_MOUSE_IN;
+ hidRptMap[4].type = HID_REPORT_TYPE_INPUT;
+ hidRptMap[4].handle = hidAttrTbl[HID_BOOT_MOUSE_IN_IDX].handle;
+ hidRptMap[4].cccdHandle = hidAttrTbl[HID_BOOT_MOUSE_IN_CCCD_IDX].handle;
+ hidRptMap[4].mode = HID_PROTOCOL_MODE_BOOT;
+
+ // Feature report
+ hidRptMap[5].id = hidReportRefFeature[0];
+ hidRptMap[5].type = hidReportRefFeature[1];
+ hidRptMap[5].handle = hidAttrTbl[HID_FEATURE_IDX].handle;
+ hidRptMap[5].cccdHandle = 0;
+ hidRptMap[5].mode = HID_PROTOCOL_MODE_REPORT;
+
+ // Battery level input report
+ VOID Batt_GetParameter( BATT_PARAM_BATT_LEVEL_IN_REPORT, &(hidRptMap[6]) );
+
+ // Setup report ID map
+ HidDev_RegisterReports( HID_NUM_REPORTS, hidRptMap );
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn HidKbd_SetParameter
+ *
+ * @brief Set a HID Kbd parameter.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param uuid - attribute uuid.
+ * @param len - length of data to right.
+ * @param pValue - pointer to data to write. This is dependent on
+ * the input parameters and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return GATT status code.
+ */
+uint8 HidKbd_SetParameter( uint8 id, uint8 type, uint16 uuid, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( uuid )
+ {
+ case HID_REPORT_UUID:
+ if ( type == HID_REPORT_TYPE_OUTPUT )
+ {
+ if ( len == 1 )
+ {
+ hidReportLedOut = *((uint8 *)pValue);
+ }
+ else
+ {
+ ret = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else if ( type == HID_REPORT_TYPE_FEATURE )
+ {
+ if ( len == 1 )
+ {
+ hidReportFeature = *((uint8 *)pValue);
+ }
+ else
+ {
+ ret = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ ret = ATT_ERR_ATTR_NOT_FOUND;
+ }
+ break;
+
+ case HID_BOOT_KEY_OUTPUT_UUID:
+ if ( len == 1 )
+ {
+ hidReportBootKeyOut = *((uint8 *)pValue);
+ }
+ else
+ {
+ ret = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ break;
+
+ default:
+ // ignore the request
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn HidKbd_GetParameter
+ *
+ * @brief Get a HID Kbd parameter.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param uuid - attribute uuid.
+ * @param pLen - length of data to be read
+ * @param pValue - pointer to data to get. This is dependent on
+ * the input parameters and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return GATT status code.
+ */
+uint8 HidKbd_GetParameter( uint8 id, uint8 type, uint16 uuid, uint8 *pLen, void *pValue )
+{
+ switch ( uuid )
+ {
+ case HID_REPORT_UUID:
+ if ( type == HID_REPORT_TYPE_OUTPUT )
+ {
+ *((uint8 *)pValue) = hidReportLedOut;
+ *pLen = 1;
+ }
+ else if ( type == HID_REPORT_TYPE_FEATURE )
+ {
+ *((uint8 *)pValue) = hidReportFeature;
+ *pLen = 1;
+ }
+ else
+ {
+ *pLen = 0;
+ }
+ break;
+
+ case HID_BOOT_KEY_OUTPUT_UUID:
+ *((uint8 *)pValue) = hidReportBootKeyOut;
+ *pLen = 1;
+ break;
+
+ default:
+ *pLen = 0;
+ break;
+ }
+
+ return ( SUCCESS );
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDevKbd/hidkbdservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDevKbd/hidkbdservice.h
new file mode 100644
index 0000000..c054c53
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HIDDevKbd/hidkbdservice.h
@@ -0,0 +1,137 @@
+/**************************************************************************************************
+ Filename: hidkbdservice.h
+ Revised: $Date: 2012-02-09 14:40:40 -0800 (Thu, 09 Feb 2012) $
+ Revision: $Revision: 65 $
+
+ Description: This file contains the HID service for a keyboard.
+
+ Copyright 2011-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef HIDKBDSERVICE_H
+#define HIDKBDSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Number of HID reports defined in the service
+#define HID_NUM_REPORTS 7
+
+// HID Report IDs for the service
+#define HID_RPT_ID_KEY_IN 0 // Keyboard input report ID
+#define HID_RPT_ID_MOUSE_IN 1 // Mouse input report ID
+#define HID_RPT_ID_LED_OUT 0 // LED output report ID
+#define HID_RPT_ID_FEATURE 0 // Feature report ID
+
+// HID feature flags
+#define HID_KBD_FLAGS HID_FLAGS_REMOTE_WAKE
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn HidKbd_AddService
+ *
+ * @brief Initializes the HID service for keyboard by registering
+ * GATT attributes with the GATT server.
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t HidKbd_AddService( void );
+
+/*********************************************************************
+ * @fn HidKbd_SetParameter
+ *
+ * @brief Set a HID Kbd parameter.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param uuid - attribute uuid.
+ * @param len - length of data to right.
+ * @param pValue - pointer to data to write. This is dependent on
+ * the input parameters and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return GATT status code.
+ */
+extern uint8 HidKbd_SetParameter( uint8 id, uint8 type, uint16 uuid, uint8 len, void *pValue );
+
+/*********************************************************************
+ * @fn HidKbd_GetParameter
+ *
+ * @brief Get a HID Kbd parameter.
+ *
+ * @param id - HID report ID.
+ * @param type - HID report type.
+ * @param uuid - attribute uuid.
+ * @param pLen - length of data to be read.
+ * @param pValue - pointer to data to get. This is dependent on
+ * the input parameters and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return GATT status code.
+ */
+extern uint8 HidKbd_GetParameter( uint8 id, uint8 type, uint16 uuid, uint8 *pLen, void *pValue );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HIDKBDSERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HeartRate/heartrateservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HeartRate/heartrateservice.c
new file mode 100644
index 0000000..681d810
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HeartRate/heartrateservice.c
@@ -0,0 +1,502 @@
+/**************************************************************************************************
+ Filename: heartrateservice.c
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: This file contains the Heart Rate sample service
+ for use with the Heart Rate sample application.
+
+ Copyright 2011 - 2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+
+#include "heartrateservice.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Position of heart rate measurement value in attribute array
+#define HEARTRATE_MEAS_VALUE_POS 2
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+// Heart rate service
+CONST uint8 heartRateServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HEARTRATE_SERV_UUID), HI_UINT16(HEARTRATE_SERV_UUID)
+};
+
+// Heart rate measurement characteristic
+CONST uint8 heartRateMeasUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HEARTRATE_MEAS_UUID), HI_UINT16(HEARTRATE_MEAS_UUID)
+};
+
+// Sensor location characteristic
+CONST uint8 heartRateSensLocUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HEARTRATE_SENS_LOC_UUID), HI_UINT16(HEARTRATE_SENS_LOC_UUID)
+};
+
+// Command characteristic
+CONST uint8 heartRateCommandUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(HEARTRATE_COMMAND_UUID), HI_UINT16(HEARTRATE_COMMAND_UUID)
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static heartRateServiceCB_t heartRateServiceCB;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Heart Rate Service attribute
+static CONST gattAttrType_t heartRateService = { ATT_BT_UUID_SIZE, heartRateServUUID };
+
+// Heart Rate Measurement Characteristic
+// Note characteristic value is not stored here
+static uint8 heartRateMeasProps = GATT_PROP_NOTIFY;
+static uint8 heartRateMeas = 0;
+static gattCharCfg_t heartRateMeasClientCharCfg[GATT_MAX_NUM_CONN];
+
+// Sensor Location Characteristic
+static uint8 heartRateSensLocProps = GATT_PROP_READ;
+static uint8 heartRateSensLoc = 0;
+
+// Command Characteristic
+static uint8 heartRateCommandProps = GATT_PROP_WRITE;
+static uint8 heartRateCommand = 0;
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t heartRateAttrTbl[] =
+{
+ // Heart Rate Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&heartRateService /* pValue */
+ },
+
+ // Heart Rate Measurement Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &heartRateMeasProps
+ },
+
+ // Heart Rate Measurement Value
+ {
+ { ATT_BT_UUID_SIZE, heartRateMeasUUID },
+ 0,
+ 0,
+ &heartRateMeas
+ },
+
+ // Heart Rate Measurement Client Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &heartRateMeasClientCharCfg
+ },
+
+ // Sensor Location Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &heartRateSensLocProps
+ },
+
+ // Sensor Location Value
+ {
+ { ATT_BT_UUID_SIZE, heartRateSensLocUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &heartRateSensLoc
+ },
+
+ // Command Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &heartRateCommandProps
+ },
+
+ // Command Value
+ {
+ { ATT_BT_UUID_SIZE, heartRateCommandUUID },
+ GATT_PERMIT_WRITE,
+ 0,
+ &heartRateCommand
+ }
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 heartRate_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t heartRate_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Heart Rate Service Callbacks
+CONST gattServiceCBs_t heartRateCBs =
+{
+ heartRate_ReadAttrCB, // Read callback function pointer
+ heartRate_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn HeartRate_AddService
+ *
+ * @brief Initializes the Heart Rate service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t HeartRate_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, heartRateMeasClientCharCfg );
+
+ if ( services & HEARTRATE_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( heartRateAttrTbl,
+ GATT_NUM_ATTRS( heartRateAttrTbl ),
+ &heartRateCBs );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn HeartRate_Register
+ *
+ * @brief Register a callback function with the Heart Rate Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return None.
+ */
+extern void HeartRate_Register( heartRateServiceCB_t pfnServiceCB )
+{
+ heartRateServiceCB = pfnServiceCB;
+}
+
+/*********************************************************************
+ * @fn HeartRate_SetParameter
+ *
+ * @brief Set a Heart Rate parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t HeartRate_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case HEARTRATE_MEAS_CHAR_CFG:
+ // Need connection handle
+ //heartRateMeasClientCharCfg.value = *((uint16*)value);
+ break;
+
+ case HEARTRATE_SENS_LOC:
+ heartRateSensLoc = *((uint8*)value);
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn HeartRate_GetParameter
+ *
+ * @brief Get a Heart Rate parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t HeartRate_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case HEARTRATE_MEAS_CHAR_CFG:
+ // Need connection handle
+ //*((uint16*)value) = heartRateMeasClientCharCfg.value;
+ break;
+
+ case HEARTRATE_SENS_LOC:
+ *((uint8*)value) = heartRateSensLoc;
+ break;
+
+ case HEARTRATE_COMMAND:
+ *((uint8*)value) = heartRateCommand;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn HeartRate_MeasNotify
+ *
+ * @brief Send a notification containing a heart rate
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+bStatus_t HeartRate_MeasNotify( uint16 connHandle, attHandleValueNoti_t *pNoti )
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, heartRateMeasClientCharCfg );
+
+ // If notifications enabled
+ if ( value & GATT_CLIENT_CFG_NOTIFY )
+ {
+ // Set the handle
+ pNoti->handle = heartRateAttrTbl[HEARTRATE_MEAS_VALUE_POS].handle;
+
+ // Send the notification
+ return GATT_Notification( connHandle, pNoti, FALSE );
+ }
+
+ return bleIncorrectMode;
+}
+
+/*********************************************************************
+ * @fn heartRate_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 heartRate_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ bStatus_t status = SUCCESS;
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+
+ if (uuid == HEARTRATE_SENS_LOC_UUID)
+ {
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn heartRate_WriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t heartRate_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ case HEARTRATE_COMMAND_UUID:
+ if ( offset > 0 )
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+ else if (len != 1)
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ else if (*pValue != HEARTRATE_COMMAND_ENERGY_EXP)
+ {
+ status = HEARTRATE_ERR_NOT_SUP;
+ }
+ else
+ {
+ *(pAttr->pValue) = pValue[0];
+
+ (*heartRateServiceCB)(HEARTRATE_COMMAND_SET);
+
+ }
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ if ( status == SUCCESS )
+ {
+ uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );
+
+ (*heartRateServiceCB)( (charCfg == GATT_CFG_NO_OPERATION) ?
+ HEARTRATE_MEAS_NOTI_DISABLED :
+ HEARTRATE_MEAS_NOTI_ENABLED );
+ }
+ break;
+
+ default:
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn HeartRate_HandleConnStatusCB
+ *
+ * @brief Heart Rate Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+void HeartRate_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, heartRateMeasClientCharCfg );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HeartRate/heartrateservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HeartRate/heartrateservice.h
new file mode 100644
index 0000000..ba8814b
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/HeartRate/heartrateservice.h
@@ -0,0 +1,169 @@
+/**************************************************************************************************
+ Filename: heartrateservice.h
+ Revised: $Date $
+ Revision: $Revision $
+
+ Description: This file contains the Heart Rate service definitions and
+ prototypes.
+
+**************************************************************************************************/
+
+#ifndef HEARTRATESERVICE_H
+#define HEARTRATESERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+// Heart Rate Service Parameters
+#define HEARTRATE_MEAS 0
+#define HEARTRATE_MEAS_CHAR_CFG 1
+#define HEARTRATE_SENS_LOC 2
+#define HEARTRATE_COMMAND 3
+
+// Heart Rate Service UUIDs
+#define HEARTRATE_SERV_UUID 0x180D
+#define HEARTRATE_MEAS_UUID 0x2A37
+#define HEARTRATE_SENS_LOC_UUID 0x2A38
+#define HEARTRATE_COMMAND_UUID 0x2A39
+
+// Maximum length of heart rate measurement characteristic
+#define HEARTRATE_MEAS_MAX (ATT_MTU_SIZE -5)
+
+// Values for flags
+#define HEARTRATE_FLAGS_FORMAT_UINT16 0x01
+#define HEARTRATE_FLAGS_CONTACT_NOT_SUP 0x00
+#define HEARTRATE_FLAGS_CONTACT_NOT_DET 0x04
+#define HEARTRATE_FLAGS_CONTACT_DET 0x06
+#define HEARTRATE_FLAGS_ENERGY_EXP 0x08
+#define HEARTRATE_FLAGS_RR 0x10
+
+// Values for sensor location
+#define HEARTRATE_SENS_LOC_OTHER 0x00
+#define HEARTRATE_SENS_LOC_CHEST 0x01
+#define HEARTRATE_SENS_LOC_WRIST 0x02
+#define HEARTRATE_SENS_LOC_FINGER 0x03
+#define HEARTRATE_SENS_LOC_HAND 0x04
+#define HEARTRATE_SENS_LOC_EARLOBE 0x05
+#define HEARTRATE_SENS_LOC_FOOT 0x06
+
+// Value for command characteristic
+#define HEARTRATE_COMMAND_ENERGY_EXP 0x01
+
+// ATT Error code
+// Control point value not supported
+#define HEARTRATE_ERR_NOT_SUP 0x80
+
+// Heart Rate Service bit fields
+#define HEARTRATE_SERVICE 0x00000001
+
+// Callback events
+#define HEARTRATE_MEAS_NOTI_ENABLED 1
+#define HEARTRATE_MEAS_NOTI_DISABLED 2
+#define HEARTRATE_COMMAND_SET 3
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Heart Rate Service callback function
+typedef void (*heartRateServiceCB_t)(uint8 event);
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*
+ * HeartRate_AddService- Initializes the Heart Rate service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+
+extern bStatus_t HeartRate_AddService( uint32 services );
+
+/*
+ * HeartRate_Register - Register a callback function with the
+ * Heart Rate Service
+ *
+ * @param pfnServiceCB - Callback function.
+ */
+
+extern void HeartRate_Register( heartRateServiceCB_t pfnServiceCB );
+
+/*
+ * HeartRate_SetParameter - Set a Heart Rate parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t HeartRate_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * HeartRate_GetParameter - Get a Heart Rate parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t HeartRate_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+ * @fn HeartRate_MeasNotify
+ *
+ * @brief Send a notification containing a heart rate
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t HeartRate_MeasNotify( uint16 connHandle, attHandleValueNoti_t *pNoti );
+
+/*********************************************************************
+ * @fn HeartRate_HandleConnStatusCB
+ *
+ * @brief Heart Rate Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+extern void HeartRate_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HEARTRATESERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Keys/simplekeys.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Keys/simplekeys.c
new file mode 100644
index 0000000..d975768
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Keys/simplekeys.c
@@ -0,0 +1,423 @@
+/**************************************************************************************************
+ Filename: simplekey.c
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: Simple Keys Profile
+
+
+ Copyright 2010 - 2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "gapbondmgr.h"
+
+#include "simplekeys.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+#define SERVAPP_NUM_ATTR_SUPPORTED 5
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+// SK Service UUID: 0x1800
+CONST uint8 skServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(SK_SERV_UUID), HI_UINT16(SK_SERV_UUID)
+};
+
+// Key Pressed UUID: 0x1801
+CONST uint8 keyPressedUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(SK_KEYPRESSED_UUID), HI_UINT16(SK_KEYPRESSED_UUID)
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// SK Service attribute
+static CONST gattAttrType_t skService = { ATT_BT_UUID_SIZE, skServUUID };
+
+// Keys Pressed Characteristic Properties
+static uint8 skCharProps = GATT_PROP_NOTIFY;
+
+// Key Pressed State Characteristic
+static uint8 skKeyPressed = 0;
+
+// Key Pressed Characteristic Configs
+static gattCharCfg_t skConfig[GATT_MAX_NUM_CONN];
+
+// Key Pressed Characteristic User Description
+static uint8 skCharUserDesp[16] = "Key Press State\0";
+
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t simplekeysAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
+{
+ // Simple Keys Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&skService /* pValue */
+ },
+
+ // Characteristic Declaration for Keys
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &skCharProps
+ },
+
+ // Characteristic Value- Key Pressed
+ {
+ { ATT_BT_UUID_SIZE, keyPressedUUID },
+ 0,
+ 0,
+ &skKeyPressed
+ },
+
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)skConfig
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ skCharUserDesp
+ },
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 sk_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t sk_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+
+static void sk_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// SK Service Callbacks
+CONST gattServiceCBs_t skCBs =
+{
+ sk_ReadAttrCB, // Read callback function pointer
+ sk_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn SK_AddService
+ *
+ * @brief Initializes the Simple Key service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t SK_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, skConfig );
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( sk_HandleConnStatusCB );
+
+
+ if ( services & SK_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( simplekeysAttrTbl,
+ GATT_NUM_ATTRS( simplekeysAttrTbl ),
+ &skCBs );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn SK_SetParameter
+ *
+ * @brief Set a Simple Key Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t SK_SetParameter( uint8 param, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case SK_KEY_ATTR:
+ if ( len == sizeof ( uint8 ) )
+ {
+ skKeyPressed = *((uint8*)pValue);
+
+ // See if Notification/Indication has been enabled
+ GATTServApp_ProcessCharCfg( skConfig, &skKeyPressed, FALSE,
+ simplekeysAttrTbl, GATT_NUM_ATTRS( simplekeysAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn SK_GetParameter
+ *
+ * @brief Get a Simple Key Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param pValue - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t SK_GetParameter( uint8 param, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case SK_KEY_ATTR:
+ *((uint8*)pValue) = skKeyPressed;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn sk_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 sk_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ bStatus_t status = SUCCESS;
+
+ // Make sure it's not a blob operation (no attributes in the profile are long
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if ( pAttr->type.len == ATT_BT_UUID_SIZE )
+ {
+ // 16-bit UUID
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
+ // gattserverapp handles this type for reads
+
+ // simple keys characteristic does not have read permissions, but because it
+ // can be sent as a notification, it must be included here
+ case SK_KEYPRESSED_UUID:
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ break;
+
+ default:
+ // Should never get here!
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+ }
+ else
+ {
+ // 128-bit UUID
+ *pLen = 0;
+ status = ATT_ERR_INVALID_HANDLE;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn sk_WriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t sk_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+
+ if ( pAttr->type.len == ATT_BT_UUID_SIZE )
+ {
+ // 16-bit UUID
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ // Should never get here!
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+ }
+ else
+ {
+ // 128-bit UUID
+ status = ATT_ERR_INVALID_HANDLE;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn sk_HandleConnStatusCB
+ *
+ * @brief Simple Keys Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void sk_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, skConfig );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Keys/simplekeys.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Keys/simplekeys.h
new file mode 100644
index 0000000..1e6ffbb
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Keys/simplekeys.h
@@ -0,0 +1,132 @@
+/**************************************************************************************************
+ Filename: simplekeys.h
+ Revised: $Date: 2010-10-01 14:14:58 -0700 (Fri, 01 Oct 2010) $
+ Revision: $Revision: 23960 $
+
+ Description: This file contains the Simple Keys Profile header file.
+
+
+ Copyright 2010 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef SIMPLEKEYS_H
+#define SIMPLEKEYS_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Profile Parameters
+#define SK_KEY_ATTR 0 // RW uint8 - Profile Attribute value
+
+// SK Service UUID
+#define SK_SERV_UUID 0xFFE0
+
+// Key Pressed UUID
+#define SK_KEYPRESSED_UUID 0xFFE1
+
+// Key Values
+#define SK_KEY_LEFT 0x01
+#define SK_KEY_RIGHT 0x02
+
+// Simple Keys Profile Services bit fields
+#define SK_SERVICE 0x00000001
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*
+ * SK_AddService- Initializes the Simple Key service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+
+extern bStatus_t SK_AddService( uint32 services );
+
+/*
+ * SK_SetParameter - Set a Simple Key Profile parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t SK_SetParameter( uint8 param, uint8 len, void *pValue );
+
+/*
+ * SK_GetParameter - Get a Simple Key Profile parameter.
+ *
+ * param - Profile parameter ID
+ * pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t SK_GetParameter( uint8 param, void *pValue );
+
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SIMPLEKEYS_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/OAD/oad.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/OAD/oad.h
new file mode 100644
index 0000000..93bdc34
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/OAD/oad.h
@@ -0,0 +1,144 @@
+/**************************************************************************************************
+ Filename: oad.h
+ Revised: $Date: 2012-12-06 13:16:36 -0800 (Thu, 06 Dec 2012) $
+ Revision: $Revision: 32472 $
+
+ Description: This file contains OAD Profile header file.
+
+
+ Copyright 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+#ifndef OAD_H
+#define OAD_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#include "hal_aes.h"
+#include "hal_types.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+#define OAD_SERVICE_UUID 0xFFC0
+#define OAD_IMG_IDENTIFY_UUID 0xFFC1
+#define OAD_IMG_BLOCK_UUID 0xFFC2
+
+#define OAD_IMG_CRC_OSET 0x0000
+#if defined FEATURE_OAD_SECURE
+#define OAD_IMG_HDR_OSET 0x0000
+#else // crc0 is calculated and placed by the IAR linker at 0x0, so img_hdr_t is 2 bytes offset.
+#define OAD_IMG_HDR_OSET 0x0002
+#endif
+
+#define OAD_CHAR_CNT 2
+
+// OAD Characteristic Indices
+#define OAD_CHAR_IMG_IDENTIFY 0
+#define OAD_CHAR_IMG_BLOCK 1
+
+// Image Identification size
+#define OAD_IMG_ID_SIZE 4
+
+// Image header size (version + length + image id size)
+#define OAD_IMG_HDR_SIZE ( 2 + 2 + OAD_IMG_ID_SIZE )
+
+// The Image is transporte in 16-byte blocks in order to avoid using blob operations.
+#define OAD_BLOCK_SIZE 16
+#define OAD_BLOCKS_PER_PAGE (HAL_FLASH_PAGE_SIZE / OAD_BLOCK_SIZE)
+#define OAD_BLOCK_MAX (OAD_BLOCKS_PER_PAGE * OAD_IMG_D_AREA)
+
+/*********************************************************************
+ * MACROS
+ */
+
+// Macros to get Image ID (LSB) and Version Number
+#define OAD_IMG_ID( ver ) ( (ver) & 0x01 )
+#define OAD_VER_NUM( ver ) ( (ver) >> 0x01 )
+
+// Macro to set Image Version
+#if defined (HAL_IMAGE_A)
+ #define OAD_IMG_VER( ver ) ( (uint16)( (ver) << 0x01 ) ) // Clear LSB for Image A
+#else
+ #define OAD_IMG_VER( ver ) ( (uint16)( ( (ver) << 0x01 ) | 0x01 ) ) // Set LSB for Imange B
+#endif
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// The Image Header will not be encrypted, but it will be included in a Signature.
+typedef struct {
+#if defined FEATURE_OAD_SECURE
+ // Secure OAD uses the Signature for image validation instead of calculating a CRC, but the use
+ // of CRC==CRC-Shadow for quick boot-up determination of a validated image is still used.
+ uint16 crc0; // CRC must not be 0x0000 or 0xFFFF.
+#endif
+ uint16 crc1; // CRC-shadow must be 0xFFFF.
+ // User-defined Image Version Number - default logic uses simple a '!=' comparison to start an OAD.
+ uint16 ver;
+ uint16 len; // Image length in 4-byte blocks (i.e. HAL_FLASH_WORD_SIZE blocks).
+ uint8 uid[4]; // User-defined Image Identification bytes.
+ uint8 res[4]; // Reserved space for future use.
+} img_hdr_t;
+
+#if defined FEATURE_OAD_SECURE
+static_assert((sizeof(img_hdr_t) == 16), "Bad SBL_ADDR_AES_HDR definition.");
+static_assert(((sizeof(img_hdr_t) % KEY_BLENGTH) == 0),
+ "img_hdr_t is not an even multiple of KEY_BLENGTH");
+#endif
+
+// The AES Header must be encrypted and the Signature must include the Image Header.
+typedef struct {
+ uint8 signature[KEY_BLENGTH]; // The AES-128 CBC-MAC signature.
+ uint8 nonce12[12]; // The 12-byte Nonce for calculating the signature.
+ uint8 spare[4];
+} aes_hdr_t;
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OAD_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/OAD/oad_target.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/OAD/oad_target.c
new file mode 100644
index 0000000..6635e76
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/OAD/oad_target.c
@@ -0,0 +1,696 @@
+/**************************************************************************************************
+ Filename: oad_target.c
+ Revised: $Date: 2012-11-16 18:39:26 -0800 (Fri, 16 Nov 2012) $
+ Revision: $Revision: 32218 $
+
+ Description: This file contains OAD Target implementation.
+
+
+ Copyright 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#include "bcomdef.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "hal_aes.h"
+#include "hal_crc.h"
+#include "hal_flash.h"
+#if (defined HAL_LCD) && (HAL_LCD == TRUE)
+#include "hal_lcd.h"
+#endif
+#include "hal_types.h"
+#include "linkdb.h"
+#include "oad.h"
+#include "oad_target.h"
+#include "OSAL.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+#define OAD_FLASH_PAGE_MULT ((uint16)(HAL_FLASH_PAGE_SIZE / HAL_FLASH_WORD_SIZE))
+
+#if defined (FEATURE_OAD_SECURE) && defined (HAL_IMAGE_A)
+ // Enabled to ONLY build a BOOTSTRAP Encrypted Image-A (for programming over
+ // BEM, not BIM). Comment line below to build a non-bootstrap Encrypted Image-A.
+ #define BOOTP_E_IMAGE_A
+#endif
+
+#if !defined (OAD_IMAGE_VERSION)
+ #define OAD_IMAGE_VERSION 0x0000
+#endif
+
+#if !defined (OAD_IMAGE_A_USER_ID)
+ #define OAD_IMAGE_A_USER_ID {'A', 'A', 'A', 'A'}
+#endif
+
+#if !defined (OAD_IMAGE_B_USER_ID)
+ #define OAD_IMAGE_B_USER_ID {'B', 'B', 'B', 'B'}
+#endif
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// OAD Service UUID
+static CONST uint8 oadServUUID[ATT_UUID_SIZE] =
+{
+ TI_BASE_UUID_128( OAD_SERVICE_UUID )
+};
+
+static CONST uint8 oadCharUUID[OAD_CHAR_CNT][ATT_UUID_SIZE] =
+{
+ // OAD Image Identify UUID
+ TI_BASE_UUID_128( OAD_IMG_IDENTIFY_UUID ),
+
+ // OAD Image Block Request/Response UUID
+ TI_BASE_UUID_128( OAD_IMG_BLOCK_UUID )
+};
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// OAD Service attribute
+static CONST gattAttrType_t oadService = { ATT_UUID_SIZE, oadServUUID };
+
+// Place holders for the GATT Server App to be able to lookup handles.
+static uint8 oadCharVals[OAD_CHAR_CNT];
+
+// OAD Characteristic Properties
+static uint8 oadCharProps = GATT_PROP_WRITE_NO_RSP | GATT_PROP_WRITE | GATT_PROP_NOTIFY;
+
+// OAD Client Characteristic Configs
+static gattCharCfg_t oadImgIdentifyConfig[GATT_MAX_NUM_CONN];
+static gattCharCfg_t oadImgBlockConfig[GATT_MAX_NUM_CONN];
+
+// OAD Characteristic user descriptions
+static CONST uint8 oadImgIdentifyDesc[] = "Img Identify";
+static CONST uint8 oadImgBlockDesc[] = "Img Block";
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t oadAttrTbl[] =
+{
+ // OAD Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *)&oadService
+ },
+
+ // OAD Image Identify Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &oadCharProps
+ },
+
+ // OAD Image Identify Characteristic Value
+ {
+ { ATT_UUID_SIZE, oadCharUUID[0] },
+ GATT_PERMIT_WRITE,
+ 0,
+ oadCharVals+0
+ },
+
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)oadImgIdentifyConfig
+ },
+
+ // OAD Image Identify User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *)oadImgIdentifyDesc
+ },
+
+ // OAD Image Block Request/Response Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &oadCharProps
+ },
+
+ // OAD Image Block Request/Response Characteristic Value
+ {
+ { ATT_UUID_SIZE, oadCharUUID[1] },
+ GATT_PERMIT_WRITE,
+ 0,
+ oadCharVals+1
+ },
+
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)oadImgBlockConfig
+ },
+
+ // OAD Image Block Request/Response User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *)oadImgBlockDesc
+ }
+};
+
+#pragma location="IMAGE_HEADER"
+const __code img_hdr_t _imgHdr = {
+#if defined FEATURE_OAD_SECURE
+ 2012, // CRC must not be 0x0000 or 0xFFFF.
+#endif
+#if defined (BOOTP_E_IMAGE_A)
+#warning "Forcing a CRC-shadow match with the BOOTP_E_IMAGE_A flag - is this bootstrap code?"
+ 2012, // CRC-shadow forced to match CRC for a bootstrap Encrypted Image-A
+#else
+ 0xFFFF, // CRC-shadow must be 0xFFFF for everything else
+#endif
+ OAD_IMG_VER( OAD_IMAGE_VERSION ), // 15-bit Version #, left-shifted 1; OR with Image-B/Not-A bit.
+ OAD_IMG_R_AREA * OAD_FLASH_PAGE_MULT,
+#if defined HAL_IMAGE_A
+ OAD_IMAGE_A_USER_ID, // User-Id
+#else
+ OAD_IMAGE_B_USER_ID, // User-Id
+#endif
+ { 0xFF, 0xFF, 0xFF, 0xFF } // Reserved
+};
+#pragma required=_imgHdr
+
+#pragma location="AES_HEADER"
+static const __code aes_hdr_t _aesHdr = {
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
+ { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B }, // Dummy Nonce
+ { 0xFF, 0xFF, 0xFF, 0xFF } // Spare
+};
+#pragma required=_aesHdr
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static uint16 oadBlkNum = 0, oadBlkTot = 0xFFFF;
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+
+static uint8 oadReadAttrCB(uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen);
+
+static bStatus_t oadWriteAttrCB(uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset);
+
+CONST gattServiceCBs_t oadCBs =
+{
+ oadReadAttrCB, // Read callback function pointer.
+ oadWriteAttrCB, // Write callback function pointer.
+ NULL // Authorization callback function pointer.
+};
+
+static void oadImgBlockReq(uint16 connHandle, uint16 blkNum);
+
+static void oadImgIdentifyReq(uint16 connHandle, img_hdr_t *pImgHdr);
+
+static bStatus_t oadImgIdentifyWrite( uint16 connHandle, uint8 *pValue );
+
+static bStatus_t oadImgBlockWrite( uint16 connHandle, uint8 *pValue );
+
+static void oadHandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+#if !defined FEATURE_OAD_SECURE
+static uint8 checkDL(void);
+#endif
+
+/*********************************************************************
+ * @fn OADTarget_AddService
+ *
+ * @brief Initializes the OAD Service by registering GATT attributes
+ * with the GATT server. Only call this function once.
+ *
+ * @return The return value of GATTServApp_RegisterForMsg().
+ */
+bStatus_t OADTarget_AddService(void)
+{
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, oadImgIdentifyConfig );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, oadImgBlockConfig );
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( oadHandleConnStatusCB );
+
+ return GATTServApp_RegisterService(oadAttrTbl, GATT_NUM_ATTRS(oadAttrTbl), &oadCBs);
+}
+
+/*********************************************************************
+ * @fn oadReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 oadReadAttrCB(uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen)
+{
+ bStatus_t status = SUCCESS;
+
+ // TBD: is there any use for supporting reads
+ *pLen = 0;
+ status = ATT_ERR_INVALID_HANDLE;
+
+ return status;
+}
+
+/*********************************************************************
+ * @fn oadWriteAttrCB
+ *
+ * @brief Validate and Write attribute data
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t oadWriteAttrCB(uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset)
+{
+ bStatus_t status = SUCCESS;
+
+ if ( pAttr->type.len == ATT_BT_UUID_SIZE )
+ {
+ // 16-bit UUID
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ if ( uuid == GATT_CLIENT_CHAR_CFG_UUID)
+ {
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_FOUND; // Should never get here!
+ }
+ }
+ else
+ {
+ // 128-bit UUID
+ if (osal_memcmp(pAttr->type.uuid, oadCharUUID[OAD_CHAR_IMG_IDENTIFY], ATT_UUID_SIZE))
+ {
+ status = oadImgIdentifyWrite( connHandle, pValue );
+ }
+ else if (osal_memcmp(pAttr->type.uuid, oadCharUUID[OAD_CHAR_IMG_BLOCK], ATT_UUID_SIZE))
+ {
+ status = oadImgBlockWrite( connHandle, pValue );
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_FOUND; // Should never get here!
+ }
+ }
+
+ return status;
+}
+
+/*********************************************************************
+ * @fn oadImgIdentifyWrite
+ *
+ * @brief Process the Image Identify Write.
+ *
+ * @param connHandle - connection message was received on
+ * @param pValue - pointer to data to be written
+ *
+ * @return status
+ */
+static bStatus_t oadImgIdentifyWrite( uint16 connHandle, uint8 *pValue )
+{
+ img_hdr_t rxHdr;
+ img_hdr_t ImgHdr;
+
+ rxHdr.ver = BUILD_UINT16( pValue[0], pValue[1] );
+ rxHdr.len = BUILD_UINT16( pValue[2], pValue[3] );
+
+ (void)osal_memcpy(rxHdr.uid, pValue+4, sizeof(rxHdr.uid));
+
+ HalFlashRead(OAD_IMG_R_PAGE, OAD_IMG_HDR_OSET, (uint8 *)&ImgHdr, sizeof(img_hdr_t));
+
+ oadBlkTot = rxHdr.len / (OAD_BLOCK_SIZE / HAL_FLASH_WORD_SIZE);
+
+ if ( (OAD_IMG_ID( ImgHdr.ver ) != OAD_IMG_ID( rxHdr.ver )) && // TBD: add customer criteria for initiating OAD here.
+ (oadBlkTot <= OAD_BLOCK_MAX) &&
+ (oadBlkTot != 0) )
+ {
+ oadBlkNum = 0;
+ oadImgBlockReq(connHandle, 0);
+ }
+ else
+ {
+ oadImgIdentifyReq(connHandle, &ImgHdr);
+ }
+
+ return ( SUCCESS );
+}
+
+/*********************************************************************
+ * @fn oadImgBlockWrite
+ *
+ * @brief Process the Image Block Write.
+ *
+ * @param connHandle - connection message was received on
+ * @param pValue - pointer to data to be written
+ *
+ * @return status
+ */
+static bStatus_t oadImgBlockWrite( uint16 connHandle, uint8 *pValue )
+{
+ uint16 blkNum = BUILD_UINT16( pValue[0], pValue[1] );
+
+ // make sure this is the image we're expecting
+ if ( blkNum == 0 )
+ {
+ img_hdr_t ImgHdr;
+ uint16 ver = BUILD_UINT16( pValue[6], pValue[7] );
+ uint16 blkTot = BUILD_UINT16( pValue[8], pValue[9] ) / (OAD_BLOCK_SIZE / HAL_FLASH_WORD_SIZE);
+
+ HalFlashRead(OAD_IMG_R_PAGE, OAD_IMG_HDR_OSET, (uint8 *)&ImgHdr, sizeof(img_hdr_t));
+
+ if ( ( oadBlkNum != blkNum ) ||
+ ( oadBlkTot != blkTot ) ||
+ ( OAD_IMG_ID( ImgHdr.ver ) == OAD_IMG_ID( ver ) ) )
+ {
+ return ( ATT_ERR_WRITE_NOT_PERMITTED );
+ }
+ }
+
+ if (oadBlkNum == blkNum)
+ {
+ uint16 addr = oadBlkNum * (OAD_BLOCK_SIZE / HAL_FLASH_WORD_SIZE) +
+ (OAD_IMG_D_PAGE * OAD_FLASH_PAGE_MULT);
+ oadBlkNum++;
+
+#if defined FEATURE_OAD_SECURE
+ if (blkNum == 0)
+ {
+ // Stop attack with crc0==crc1 by forcing crc1=0xffff.
+ pValue[4] = 0xFF;
+ pValue[5] = 0xFF;
+ }
+#endif
+
+#if defined HAL_IMAGE_B
+ // Skip the Image-B area which lies between the lower & upper Image-A parts.
+ if (addr >= (OAD_IMG_B_PAGE * OAD_FLASH_PAGE_MULT))
+ {
+ addr += OAD_IMG_B_AREA * OAD_FLASH_PAGE_MULT;
+ }
+#endif
+ if ((addr % OAD_FLASH_PAGE_MULT) == 0)
+ {
+ HalFlashErase(addr / OAD_FLASH_PAGE_MULT);
+ }
+
+ HalFlashWrite(addr, pValue+2, (OAD_BLOCK_SIZE / HAL_FLASH_WORD_SIZE));
+ }
+
+ if (oadBlkNum == oadBlkTot) // If the OAD Image is complete.
+ {
+#if defined FEATURE_OAD_SECURE
+ HAL_SYSTEM_RESET(); // Only the secure OAD boot loader has the security key to decrypt.
+#else
+ if (checkDL())
+ {
+#if !defined HAL_IMAGE_A
+ // The BIM always checks for a valid Image-B before Image-A,
+ // so Image-A never has to invalidate itself.
+ uint16 crc[2] = { 0x0000, 0xFFFF };
+ uint16 addr = OAD_IMG_R_PAGE * OAD_FLASH_PAGE_MULT + OAD_IMG_CRC_OSET / HAL_FLASH_WORD_SIZE;
+ HalFlashWrite(addr, (uint8 *)crc, 1);
+#endif
+ HAL_SYSTEM_RESET();
+ }
+#endif
+ }
+ else // Request the next OAD Image block.
+ {
+ oadImgBlockReq(connHandle, oadBlkNum);
+ }
+
+ return ( SUCCESS );
+}
+
+/*********************************************************************
+ * @fn oadImgIdentifyReq
+ *
+ * @brief Process the Image Identify Request.
+ *
+ * @param connHandle - connection message was received on
+ * @param pImgHdr - Pointer to the img_hdr_t data to send.
+ *
+ * @return None
+ */
+static void oadImgBlockReq(uint16 connHandle, uint16 blkNum)
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, oadImgBlockConfig );
+
+ // If notifications enabled
+ if ( value & GATT_CLIENT_CFG_NOTIFY )
+ {
+ attHandleValueNoti_t noti;
+ gattAttribute_t *pAttr = GATTServApp_FindAttr(oadAttrTbl, GATT_NUM_ATTRS(oadAttrTbl),
+ oadCharVals+OAD_CHAR_IMG_BLOCK);
+ noti.handle = pAttr->handle;
+ noti.len = 2;
+ noti.value[0] = LO_UINT16(blkNum);
+ noti.value[1] = HI_UINT16(blkNum);
+
+ VOID GATT_Notification(connHandle, ¬i, FALSE);
+ }
+}
+
+/*********************************************************************
+ * @fn oadImgIdentifyReq
+ *
+ * @brief Process the Image Identify Request.
+ *
+ * @param connHandle - connection message was received on
+ * @param pImgHdr - Pointer to the img_hdr_t data to send.
+ *
+ * @return None
+ */
+static void oadImgIdentifyReq(uint16 connHandle, img_hdr_t *pImgHdr)
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, oadImgIdentifyConfig );
+
+ // If notifications enabled
+ if ( value & GATT_CLIENT_CFG_NOTIFY )
+ {
+ attHandleValueNoti_t noti;
+ gattAttribute_t *pAttr = GATTServApp_FindAttr(oadAttrTbl, GATT_NUM_ATTRS(oadAttrTbl),
+ oadCharVals+OAD_CHAR_IMG_IDENTIFY);
+ noti.handle = pAttr->handle;
+ noti.len = OAD_IMG_HDR_SIZE;
+ noti.value[0] = LO_UINT16(pImgHdr->ver);
+ noti.value[1] = HI_UINT16(pImgHdr->ver);
+
+ noti.value[2] = LO_UINT16(pImgHdr->len);
+ noti.value[3] = HI_UINT16(pImgHdr->len);
+
+ (void)osal_memcpy(noti.value+4, pImgHdr->uid, sizeof(pImgHdr->uid));
+
+ VOID GATT_Notification(connHandle, ¬i, FALSE);
+ }
+}
+
+#if !defined FEATURE_OAD_SECURE
+/**************************************************************************************************
+ * @fn crcCalcDL
+ *
+ * @brief Run the CRC16 Polynomial calculation over the DL image.
+ *
+ * input parameters
+ *
+ * None.
+ *
+ * output parameters
+ *
+ * None.
+ *
+ * @return The CRC16 calculated.
+ **************************************************************************************************
+ */
+static uint16 crcCalcDL(void)
+{
+ uint8 pageEnd = oadBlkTot / OAD_BLOCKS_PER_PAGE;
+ uint16 osetEnd = (oadBlkTot - (pageEnd * OAD_BLOCKS_PER_PAGE)) * OAD_BLOCK_SIZE;
+
+#if defined HAL_IMAGE_B
+ pageEnd += OAD_IMG_D_PAGE + OAD_IMG_B_AREA;
+#else
+ pageEnd += OAD_IMG_D_PAGE;
+#endif
+
+ HalCRCInit(0x0000); // Seed thd CRC calculation with zero.
+
+ for (uint8 page = OAD_IMG_D_PAGE; ; page++)
+ {
+#if defined HAL_IMAGE_B
+ // Skip the Image-B area which lies between the lower & upper Image-A parts.
+ if (page == OAD_IMG_B_PAGE)
+ {
+ page += OAD_IMG_B_AREA;
+ }
+#endif
+
+ for (uint16 oset = 0; oset < HAL_FLASH_PAGE_SIZE; oset += HAL_FLASH_WORD_SIZE)
+ {
+ if ((page == OAD_IMG_D_PAGE) && (oset == OAD_IMG_CRC_OSET))
+ {
+ continue; // Skip the CRC and shadow.
+ }
+ else if ((page == pageEnd) && (oset == osetEnd))
+ {
+ return HalCRCCalc();
+ }
+ else
+ {
+ uint8 buf[HAL_FLASH_WORD_SIZE];
+ HalFlashRead(page, oset, buf, HAL_FLASH_WORD_SIZE);
+
+ for (uint8 idx = 0; idx < HAL_FLASH_WORD_SIZE; idx++)
+ {
+ HalCRCExec(buf[idx]);
+ }
+ }
+ }
+ }
+}
+
+/**************************************************************************************************
+ * @fn checkDL
+ *
+ * @brief Check validity of the downloaded image.
+ *
+ * input parameters
+ *
+ * None.
+ *
+ * output parameters
+ *
+ * None.
+ *
+ * @return TRUE or FALSE for image valid.
+ **************************************************************************************************
+ */
+static uint8 checkDL(void)
+{
+ uint16 crc[2];
+
+ HalFlashRead(OAD_IMG_D_PAGE, OAD_IMG_CRC_OSET, (uint8 *)crc, sizeof(crc));
+
+ if ((crc[0] == 0xFFFF) || (crc[0] == 0x0000))
+ {
+ return FALSE;
+ }
+
+ if (crc[1] == 0xFFFF)
+ {
+ crc[1] = crcCalcDL();
+
+#if defined FEATURE_OAD_BIM // If download image is made to run in-place, enable it here.
+ uint16 addr = OAD_IMG_D_PAGE * OAD_FLASH_PAGE_MULT + OAD_IMG_CRC_OSET / HAL_FLASH_WORD_SIZE;
+ crc[0] = 0xFFFF;
+ HalFlashWrite(addr, (uint8 *)crc, 1);
+ HalFlashRead(OAD_IMG_D_PAGE, OAD_IMG_CRC_OSET, (uint8 *)crc, sizeof(crc));
+#endif
+ }
+
+ return (crc[0] == crc[1]);
+}
+#endif
+
+/*********************************************************************
+ * @fn oadHandleConnStatusCB
+ *
+ * @brief OAD Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void oadHandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, oadImgIdentifyConfig );
+ GATTServApp_InitCharCfg( connHandle, oadImgBlockConfig );
+ }
+ }
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/OAD/oad_target.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/OAD/oad_target.h
new file mode 100644
index 0000000..fb23a78
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/OAD/oad_target.h
@@ -0,0 +1,117 @@
+/**************************************************************************************************
+ Filename: oad_target.h
+ Revised: $Date: 2012-11-16 18:39:26 -0800 (Fri, 16 Nov 2012) $
+ Revision: $Revision: 32218 $
+
+ Description: This file contains OAD Target header file.
+
+
+ Copyright 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+#ifndef OAD_TARGET_H
+#define OAD_TARGET_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#include "hal_aes.h"
+#include "hal_types.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+#if !defined OAD_IMG_A_PAGE
+#define OAD_IMG_A_PAGE 1
+#define OAD_IMG_A_AREA 62
+#endif
+
+#if !defined OAD_IMG_B_PAGE
+// Image-A/B can be very differently sized areas when implementing BIM vice OAD boot loader.
+#if defined FEATURE_OAD_BIM
+#define OAD_IMG_B_PAGE 8
+#else
+#define OAD_IMG_B_PAGE 63
+#endif
+#define OAD_IMG_B_AREA (124 - OAD_IMG_A_AREA)
+#endif
+
+#if defined HAL_IMAGE_B
+#define OAD_IMG_D_PAGE OAD_IMG_A_PAGE
+#define OAD_IMG_D_AREA OAD_IMG_A_AREA
+#define OAD_IMG_R_PAGE OAD_IMG_B_PAGE
+#define OAD_IMG_R_AREA OAD_IMG_B_AREA
+#else //#elif defined HAL_IMAGE_A or a non-BIM-enabled OAD Image-A w/ constants in Bank 1 vice 5.
+#define OAD_IMG_D_PAGE OAD_IMG_B_PAGE
+#define OAD_IMG_D_AREA OAD_IMG_B_AREA
+#define OAD_IMG_R_PAGE OAD_IMG_A_PAGE
+#define OAD_IMG_R_AREA OAD_IMG_A_AREA
+#endif
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// OAD Image Header
+extern const __code img_hdr_t _imgHdr;
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * @fn OADTarget_AddService
+ *
+ * @brief Initializes the OAD Service by registering GATT attributes
+ * with the GATT server. Only call this function once.
+ *
+ * @return Success or Failure
+ */
+bStatus_t OADTarget_AddService( void );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OAD_TARGET_H */
\ No newline at end of file
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Proximity/proxreporter.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Proximity/proxreporter.c
new file mode 100644
index 0000000..1f321e5
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Proximity/proxreporter.c
@@ -0,0 +1,619 @@
+/**************************************************************************************************
+ Filename: proxreporter.c
+ Revised: $Date: 2011-11-21 15:26:10 -0800 (Mon, 21 Nov 2011) $
+ Revision: $Revision: 28439 $
+
+ Description: Proximity Profile - Reporter Role
+
+
+ Copyright 2009 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "gapbondmgr.h"
+
+#include "proxreporter.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+#define PP_DEFAULT_TX_POWER 0
+#define PP_DEFAULT_PATH_LOSS 0x7F
+
+#define SERVAPP_NUM_ATTR_SUPPORTED 5
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// Link Loss Service UUID
+CONST uint8 linkLossServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16( LINK_LOSS_SERVICE_UUID ), HI_UINT16( LINK_LOSS_SERVICE_UUID )
+};
+
+// Immediate Alert Service UUID
+CONST uint8 imAlertServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16( IMMEDIATE_ALERT_SERVICE_UUID ), HI_UINT16( IMMEDIATE_ALERT_SERVICE_UUID )
+};
+
+// Tx Power Level Service UUID
+CONST uint8 txPwrLevelServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16( TX_PWR_LEVEL_SERVICE_UUID ), HI_UINT16( TX_PWR_LEVEL_SERVICE_UUID )
+};
+
+// Alert Level Attribute UUID
+CONST uint8 alertLevelUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16( PROXIMITY_ALERT_LEVEL_UUID ), HI_UINT16( PROXIMITY_ALERT_LEVEL_UUID )
+};
+
+// Tx Power Level Attribute UUID
+CONST uint8 txPwrLevelUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16( PROXIMITY_TX_PWR_LEVEL_UUID ), HI_UINT16( PROXIMITY_TX_PWR_LEVEL_UUID )
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+static proxReporterCBs_t *pp_AppCBs = NULL;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Link Loss Service
+static CONST gattAttrType_t linkLossService = { ATT_BT_UUID_SIZE, linkLossServUUID };
+
+// Alert Level Characteristic Properties
+static uint8 llAlertLevelCharProps = GATT_PROP_READ | GATT_PROP_WRITE;
+
+// Alert Level attribute
+// This attribute enumerates the level of alert.
+static uint8 llAlertLevel = PP_ALERT_LEVEL_NO;
+
+// Immediate Alert Service
+static CONST gattAttrType_t imAlertService = { ATT_BT_UUID_SIZE, imAlertServUUID };
+
+// Alert Level Characteristic Properties
+static uint8 imAlertLevelCharProps = GATT_PROP_WRITE_NO_RSP;
+
+// Alert Level attribute
+// This attribute enumerates the level of alert.
+static uint8 imAlertLevel = PP_ALERT_LEVEL_NO;
+
+// Tx Power Level Service
+static CONST gattAttrType_t txPwrLevelService = { ATT_BT_UUID_SIZE, txPwrLevelServUUID };
+
+// Tx Power Level Characteristic Properties
+static uint8 txPwrLevelCharProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+
+// Tx Power Level attribute
+// This attribute represents the range of transmit power levels in dBm with
+// a range from -20 to +20 to a resolution of 1 dBm.
+static int8 txPwrLevel = PP_DEFAULT_TX_POWER;
+
+// Tx Power Level Characteristic Configs
+static gattCharCfg_t txPwrLevelConfig[GATT_MAX_NUM_CONN];
+
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+// Link Loss Service Atttribute Table
+static gattAttribute_t linkLossAttrTbl[] =
+{
+ // Link Loss service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&linkLossService /* pValue */
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &llAlertLevelCharProps
+ },
+
+ // Alert Level attribute
+ {
+ { ATT_BT_UUID_SIZE, alertLevelUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &llAlertLevel
+ },
+};
+
+// Immediate Alert Service Atttribute Table
+static gattAttribute_t imAlertAttrTbl[] =
+{
+ // Immediate Alert service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&imAlertService /* pValue */
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &imAlertLevelCharProps
+ },
+
+ // Alert Level attribute
+ {
+ { ATT_BT_UUID_SIZE, alertLevelUUID },
+ GATT_PERMIT_WRITE,
+ 0,
+ &imAlertLevel
+ },
+};
+
+// Tx Power Level Service Atttribute Table
+static gattAttribute_t txPwrLevelAttrTbl[] =
+{
+ // Tx Power Level service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&txPwrLevelService /* pValue */
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &txPwrLevelCharProps
+ },
+
+ // Tx Power Level attribute
+ {
+ { ATT_BT_UUID_SIZE, txPwrLevelUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *)&txPwrLevel
+ },
+
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)txPwrLevelConfig
+ },
+
+};
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 proxReporter_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t proxReporter_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+
+static void proxReporter_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Prox Reporter Service Callbacks
+CONST gattServiceCBs_t proxReporterCBs =
+{
+ proxReporter_ReadAttrCB, // Read callback function pointer
+ proxReporter_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn proxReporter_AddService
+ *
+ * @brief Initializes the Proximity Reporter service by
+ * registering GATT attributes with the GATT server.
+ * Only call this function once.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t ProxReporter_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ if ( services & PP_LINK_LOSS_SERVICE )
+ {
+ // Register Link Loss attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( linkLossAttrTbl,
+ GATT_NUM_ATTRS( linkLossAttrTbl ),
+ &proxReporterCBs );
+ }
+
+ if ( ( status == SUCCESS ) && ( services & PP_IM_ALETR_SERVICE ) )
+ {
+ // Register Link Loss attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( imAlertAttrTbl,
+ GATT_NUM_ATTRS( imAlertAttrTbl ),
+ &proxReporterCBs );
+ }
+
+ if ( ( status == SUCCESS ) && ( services & PP_TX_PWR_LEVEL_SERVICE ) )
+ {
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, txPwrLevelConfig );
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( proxReporter_HandleConnStatusCB );
+
+
+ // Register Tx Power Level attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( txPwrLevelAttrTbl,
+ GATT_NUM_ATTRS( txPwrLevelAttrTbl ),
+ &proxReporterCBs );
+ }
+
+ return ( status );
+}
+
+
+/*********************************************************************
+ * @fn proxReporter_RegisterAppCBs
+ *
+ * @brief Registers the application callback function. Only call
+ * this function once.
+ *
+ * @param callbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+bStatus_t ProxReporter_RegisterAppCBs( proxReporterCBs_t *appCallbacks )
+{
+ if ( appCallbacks )
+ {
+ pp_AppCBs = appCallbacks;
+
+ return ( SUCCESS );
+ }
+ else
+ {
+ return ( bleAlreadyInRequestedMode );
+ }
+}
+
+
+/*********************************************************************
+ * @fn proxReporter_SetParameter
+ *
+ * @brief Set a Proximity Reporter parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t ProxReporter_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+
+ case PP_LINK_LOSS_ALERT_LEVEL:
+ if ( (len == sizeof ( uint8 )) && ((*((uint8*)value) <= PP_ALERT_LEVEL_HIGH)) )
+ {
+ llAlertLevel = *((uint8*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case PP_IM_ALERT_LEVEL:
+ if ( len == sizeof ( uint8 ) )
+ {
+ imAlertLevel = *((uint8*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case PP_TX_POWER_LEVEL:
+ if ( len == sizeof ( int8 ) )
+ {
+ txPwrLevel = *((int8*)value);
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( txPwrLevelConfig, (uint8 *)&txPwrLevel, FALSE,
+ txPwrLevelAttrTbl, GATT_NUM_ATTRS( txPwrLevelAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn ProxReporter_GetParameter
+ *
+ * @brief Get a Proximity Reporter parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t ProxReporter_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case PP_LINK_LOSS_ALERT_LEVEL:
+ *((uint8*)value) = llAlertLevel;
+ break;
+
+ case PP_IM_ALERT_LEVEL:
+ *((uint8*)value) = imAlertLevel;
+ break;
+
+ case PP_TX_POWER_LEVEL:
+ *((int8*)value) = txPwrLevel;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn proxReporter_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param
+ *
+ * @return Success or Failure
+ */
+static uint8 proxReporter_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+
+ // Make sure it's not a blob operation
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if ( pAttr->type.len == ATT_BT_UUID_SIZE )
+ {
+ // 16-bit UUID
+ uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+
+ switch ( uuid )
+ {
+ // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
+ // gattserverapp handles those types for reads
+ case PROXIMITY_ALERT_LEVEL_UUID:
+ case PROXIMITY_TX_PWR_LEVEL_UUID:
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ break;
+
+ default:
+ // Should never get here!
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+ }
+ else
+ {
+ //128-bit UUID
+ *pLen = 0;
+ status = ATT_ERR_INVALID_HANDLE;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn proxReporter_WriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle – connection message was received on
+ * @param pReq - pointer to request
+ *
+ * @return Success or Failure
+ */
+static bStatus_t proxReporter_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+ uint8 notify = 0xFF;
+
+ if ( pAttr->type.len == ATT_BT_UUID_SIZE )
+ {
+ // 16-bit UUID
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ case PROXIMITY_ALERT_LEVEL_UUID:
+ // Validate the value
+ // Make sure it's not a blob operation
+ if ( offset == 0 )
+ {
+ if ( len > 1 )
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ else
+ {
+ if ( pValue[0] > PP_ALERT_LEVEL_HIGH )
+ status = ATT_ERR_INVALID_VALUE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ //Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+
+ *pCurValue = pValue[0];
+ if( pAttr->pValue == &llAlertLevel )
+ notify = PP_LINK_LOSS_ALERT_LEVEL;
+ else
+ notify = PP_IM_ALERT_LEVEL;
+ }
+
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ // Should never get here!
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+ }
+ else
+ {
+ // 128-bit UUID
+ status = ATT_ERR_INVALID_HANDLE;
+ }
+
+ // If an attribute changed then callback function to notify application of change
+ if ( (notify != 0xFF) && pp_AppCBs && pp_AppCBs->pfnAttrChange )
+ pp_AppCBs->pfnAttrChange( notify );
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn proxReporter_HandleConnStatusCB
+ *
+ * @brief Tx Power Level Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void proxReporter_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, txPwrLevelConfig );
+ }
+ }
+}
+
+
+
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Proximity/proxreporter.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Proximity/proxreporter.h
new file mode 100644
index 0000000..36406a9
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Proximity/proxreporter.h
@@ -0,0 +1,154 @@
+/**************************************************************************************************
+ Filename: proxreporter.h
+ Revised: $Date: 2011-06-27 14:14:31 -0700 (Mon, 27 Jun 2011) $
+ Revision: $Revision: 26482 $
+
+ Description: This file contains Proximity - Reporter header file.
+
+
+ Copyright 2009 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef PROXIMITYREPORTER_H
+#define PROXIMITYREPORTER_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Profile Parameters
+#define PP_LINK_LOSS_ALERT_LEVEL 0 // RW uint8 - Profile Attribute value
+#define PP_IM_ALERT_LEVEL 1 // RW uint8 - Profile Attribute value
+#define PP_TX_POWER_LEVEL 2 // RW int8 - Profile Attribute value
+
+// Proximity Profile Service UUIDs
+#define LINK_LOSS_SERVICE_UUID 0x1803
+#define IMMEDIATE_ALERT_SERVICE_UUID 0x1802
+#define TX_PWR_LEVEL_SERVICE_UUID 0x1804
+
+// Proximity Profile Attribute UUIDs
+#define PROXIMITY_ALERT_LEVEL_UUID 0x2A06
+#define PROXIMITY_TX_PWR_LEVEL_UUID 0x2A07
+
+// Alert Level Values
+#define PP_ALERT_LEVEL_NO 0x00
+#define PP_ALERT_LEVEL_LOW 0x01
+#define PP_ALERT_LEVEL_HIGH 0x02
+
+// Proximity Profile Services bit fields
+#define PP_LINK_LOSS_SERVICE 0x00000001 // Link Loss Service
+#define PP_IM_ALETR_SERVICE 0x00000002 // Immediate Alert Service
+#define PP_TX_PWR_LEVEL_SERVICE 0x00000004 // Tx Power Level Service
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// Callback when the device has been started. Callback event to
+// the Notify of an attribute change.
+typedef NULL_OK void (*ppAttrChange_t)( uint8 attrParamID );
+
+typedef struct
+{
+ ppAttrChange_t pfnAttrChange; // Whenever the Link Loss Alert attribute changes
+} proxReporterCBs_t;
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*
+ * ProxReporter_InitService- Initializes the Proximity Reporter service by
+ * registering GATT attributes with the GATT server. Only call
+ * this function once.
+
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+extern bStatus_t ProxReporter_AddService( uint32 services );
+
+/*
+ * ProxReporter_RegisterAppCBs - Registers the application callback function.
+ * Only call this function once.
+ *
+ * appCallbacks - pointer to application callbacks.
+ */
+extern bStatus_t ProxReporter_RegisterAppCBs( proxReporterCBs_t *appCallbacks );
+
+
+/*
+ * ProxReporter_SetParameter - Set a Proximity Reporter parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t ProxReporter_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * ProxReporter_GetParameter - Get a Proximity Reporter parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t ProxReporter_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PROXIMITYREPORTER_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/RSC/runningservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/RSC/runningservice.c
new file mode 100644
index 0000000..b0ed7a5
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/RSC/runningservice.c
@@ -0,0 +1,868 @@
+/**************************************************************************************************
+ Filename: runningservice.c
+ Revised: $Date: 2013-04-04 15:28:09 -0700 (Thu, 04 Apr 2013) $
+ Revision: $Revision: 33765 $
+
+ Description: This file contains the Running Speed and Cadence (RSC) service
+ for use with the RunningSensor sample application.
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "runningservice.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Running Service Task Events
+#define RSC_CMD_IND_SEND_EVT 0x0001
+
+#define RSC_MEAS_VALUE_POS 2
+#define RSC_MEAS_CFG_POS 3
+#define RSC_COMMAND_VALUE_POS 9
+#define RSC_COMMAND_CFG_POS 10
+#define COMMAND_IND_LENGTH 2
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// RSC service
+CONST uint8 runningServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(RSC_SERV_UUID), HI_UINT16(RSC_SERV_UUID)
+};
+
+// RSC measurement characteristic
+CONST uint8 runningMeasUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(RSC_MEAS_UUID), HI_UINT16(RSC_MEAS_UUID)
+};
+
+// RSC feature characteristic
+CONST uint8 runningFeatureUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(RSC_FEATURE_UUID), HI_UINT16(RSC_FEATURE_UUID)
+};
+
+// RSC sensor location characteristic
+CONST uint8 runningSensLocUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(RSC_SENS_LOC_UUID), HI_UINT16(RSC_SENS_LOC_UUID)
+};
+
+// RSC command characteristic
+CONST uint8 runningCommandUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(RSC_COMMAND_UUID), HI_UINT16(RSC_COMMAND_UUID)
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static runningServiceCB_t runningServiceCB = NULL;
+
+static uint8 supportedSensors = 0;
+static bool scOpInProgress = FALSE;
+
+// Variables used in RSC command processing
+static uint16 connectionHandle;
+static attHandleValueInd_t rscCmdInd;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// TaskID
+uint8 runningService_TaskID = 0;
+
+// RSC Service attribute
+static CONST gattAttrType_t runningService = { ATT_BT_UUID_SIZE, runningServUUID };
+
+// Available sensor locations
+static uint8 supportedSensorLocations[RSC_MAX_SENSOR_LOCS] = { RSC_NO_SENSOR_LOC };
+
+// Running Measurement Characteristic
+// Note characteristic value is not stored here
+static uint8 runningMeasProps = GATT_PROP_NOTIFY;
+static uint8 runningMeas = 0;
+static gattCharCfg_t runningMeasClientCharCfg[GATT_MAX_NUM_CONN];
+
+// Feature Characteristic
+static uint8 runningFeatureProps = GATT_PROP_READ;
+static uint16 runningFeatures = RSC_NO_SUPPORT;
+
+// Sensor Location Characteristic
+static uint8 runningSensLocProps = GATT_PROP_READ;
+static uint8 runningSensLoc = RSC_NO_SENSOR_LOC;
+
+// Command Characteristic
+static uint8 runningCommandProps = GATT_PROP_WRITE | GATT_PROP_INDICATE;
+static uint8 runningCommand = 0;
+static gattCharCfg_t runningCommandClientCharCfg[GATT_MAX_NUM_CONN];
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t runningAttrTbl[] =
+{
+ // RSC Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&runningService /* pValue */
+ },
+
+ // RSC Measurement Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &runningMeasProps
+ },
+
+ // Measurement Value
+ {
+ { ATT_BT_UUID_SIZE, runningMeasUUID },
+ 0,
+ 0,
+ &runningMeas
+ },
+
+ // Measurement Client Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &runningMeasClientCharCfg
+ },
+
+ // RSC Feature Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &runningFeatureProps
+ },
+
+ // Feature Value
+ {
+ { ATT_BT_UUID_SIZE, runningFeatureUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *)&runningFeatures
+ },
+
+ // RSC Sensor Location Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &runningSensLocProps
+ },
+
+ // Sensor Location Value
+ {
+ { ATT_BT_UUID_SIZE, runningSensLocUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &runningSensLoc
+ },
+
+ // RSC Command Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &runningCommandProps
+ },
+
+ // Command Value
+ {
+ { ATT_BT_UUID_SIZE, runningCommandUUID },
+ GATT_PERMIT_WRITE,
+ 0,
+ &runningCommand
+ },
+
+ // Command Client Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &runningCommandClientCharCfg
+ }
+};
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+
+static uint8 running_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t running_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+
+static void running_ProcessOSALMsg( osal_event_hdr_t *pMsg );
+static void running_ProcessGATTMsg( gattMsgEvent_t *pMsg );
+static bool running_SensorLocSupported( uint8 sensorLoc );
+static void running_ProcessRSCCmd( uint16 attrHandle, uint8 *pValue, uint8 len );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+
+// RSC Service Callbacks
+CONST gattServiceCBs_t runningCBs =
+{
+ running_ReadAttrCB, // Read callback function pointer
+ running_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn RunningService_Init
+ *
+ * @brief collect the OSAL task ID.
+ *
+ * @param task_id - OSAL task ID.
+ *
+ * @return none
+ */
+void RunningService_Init( uint8 task_id )
+{
+ // Only purpose is to obtain task ID
+ runningService_TaskID = task_id;
+}
+
+/*********************************************************************
+ * @fn RunningService_ProcessEvent
+ *
+ * @brief process incoming event.
+ *
+ * @param task_id - OSAL task id.
+ *
+ * @param events - event bit(s) set for the task(s)
+ *
+ * @return none
+ */
+uint16 RunningService_ProcessEvent( uint8 task_id, uint16 events )
+{
+ VOID task_id;
+
+ if ( events & SYS_EVENT_MSG )
+ {
+ uint8 *pMsg;
+
+ if ( (pMsg = osal_msg_receive( runningService_TaskID )) != NULL )
+ {
+ running_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 & RSC_CMD_IND_SEND_EVT )
+ {
+ GATT_Indication( connectionHandle, &rscCmdInd, FALSE, runningService_TaskID );
+
+ // Set Control Point Cfg done
+ scOpInProgress = FALSE;
+
+ return ( events ^ RSC_CMD_IND_SEND_EVT );
+ }
+
+ return 0;
+}
+
+/*********************************************************************
+ * @fn running_ProcessOSALMsg
+ *
+ * @brief process incoming OSAL msg.
+ *
+ * @param pMsg- pointer to messag to be read.
+ *
+ * @return none
+ */
+void running_ProcessOSALMsg( osal_event_hdr_t *pMsg )
+{
+ switch ( pMsg->event )
+ {
+ case GATT_MSG_EVENT:
+ running_ProcessGATTMsg( (gattMsgEvent_t *) pMsg );
+ break;
+
+ default: // do nothing
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn running_ProcessGATTMsg
+ *
+ * @brief process incoming GATT msg.
+ *
+ * @param pMsg- pointer to messag to be read.
+ *
+ * @return none
+ */
+void running_ProcessGATTMsg( gattMsgEvent_t *pMsg )
+{
+ if ( pMsg->method == ATT_HANDLE_VALUE_CFM )
+ {
+ // Indication receipt was confirmed by the client.
+ // This is a placeholder for future.
+ }
+}
+
+/*********************************************************************
+ * @fn running_SensorLocSupported
+ *
+ * @brief check to see if sensor location is supported
+ *
+ * @param sensorLoc - location to check for
+ *
+ * @return TRUE if supported, FALSE otherwise
+ */
+static bool running_SensorLocSupported( uint8 sensorLoc )
+{
+ uint8 i;
+
+ for (i = 0; i < supportedSensors; i++)
+ {
+ if (supportedSensorLocations[i] == sensorLoc)
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/*********************************************************************
+ * @fn Running_AddService
+ *
+ * @brief Initializes the RSC service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Running_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, runningMeasClientCharCfg );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, runningCommandClientCharCfg);
+
+ if ( services & RUNNING_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( runningAttrTbl,
+ GATT_NUM_ATTRS( runningAttrTbl ),
+ &runningCBs );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Running_Register
+ *
+ * @brief Register a callback function with the RSC Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return None.
+ */
+void Running_Register( runningServiceCB_t pfnServiceCB )
+{
+ runningServiceCB = pfnServiceCB;
+}
+
+/*********************************************************************
+ * @fn Running_SetParameter
+ *
+ * @brief Set a RSC parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Running_SetParameter( uint8 param, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case RSC_SENS_LOC:
+ {
+ runningSensLoc = *((uint8*)pValue);
+ }
+ break;
+
+ case RSC_FEATURE:
+ {
+ runningFeatures = *((uint16*)pValue);
+ }
+ break;
+
+ case RSC_AVAIL_SENS_LOCS:
+ if ( supportedSensors < RSC_MAX_SENSOR_LOCS )
+ {
+ supportedSensorLocations[supportedSensors++] = *((uint8*)pValue);
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Running_GetParameter
+ *
+ * @brief Get a RSC parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Running_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case RSC_FEATURE:
+ *((uint16*)value) = runningFeatures;
+ break;
+
+ case RSC_SENS_LOC:
+ *((uint8*)value) = runningSensLoc;
+ break;
+
+ case RSC_COMMAND:
+ *((uint8*)value) = runningCommand;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Running_MeasNotify
+ *
+ * @brief Send a notification containing a RSC
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+bStatus_t Running_MeasNotify( uint16 connHandle, attHandleValueNoti_t *pNoti )
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, runningMeasClientCharCfg );
+
+ // If notifications enabled
+ if ( value & GATT_CLIENT_CFG_NOTIFY )
+ {
+ // Set the handle
+ pNoti->handle = runningAttrTbl[RSC_MEAS_VALUE_POS].handle;
+
+ // Send the notification
+ return GATT_Notification( connHandle, pNoti, FALSE );
+ }
+
+ return bleIncorrectMode;
+}
+
+/*********************************************************************
+ * @fn running_ProcessRSCCmd
+ *
+ * @brief process an incoming RSC command.
+ *
+ * @param attrHandle - attribute handle
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ *
+ * @return none
+ */
+static void running_ProcessRSCCmd( uint16 attrHandle, uint8 *pValue, uint8 len )
+{
+ uint8 rscStatus = RSC_SUCCESS;
+
+ // Set Control Point Cfg in progress
+ scOpInProgress = TRUE;
+
+ // Set indication info to be sent out
+ rscCmdInd.handle = attrHandle;
+
+ rscCmdInd.len = 3;
+ rscCmdInd.value[0] = RSC_COMMAND_RSP;
+ rscCmdInd.value[1] = pValue[0];
+
+ switch ( pValue[0] )
+ {
+ case RSC_SET_CUMM_VAL:
+ // If total distance is a feature
+ if ( ( len <= 5 ) && ( runningFeatures & RSC_TOTAL_DIST_SUPP ) )
+ {
+ uint32 totalDistance;
+
+ // full 32 bits were specified.
+ if ( ( len - 1 ) == 4 )
+ {
+ totalDistance = BUILD_UINT32( pValue[1], pValue[2], pValue[3], pValue[4]);
+ }
+ else
+ {
+ totalDistance = 0;
+
+ // In case only lower bits were specified and upper bits remain zero.
+ for( int i = 0; i < (len - 1); ++i )
+ {
+ totalDistance += pValue[i + 1] << (i*8);
+ }
+ }
+
+ // Notify app
+ if ( runningServiceCB != NULL )
+ {
+ VOID (*runningServiceCB)( RSC_CMD_SET_CUMM_VAL, &totalDistance );
+ }
+ }
+ else // characteristic not supported.
+ {
+ rscStatus = RSC_INVALID_PARAMETER;
+ }
+ break;
+
+ case RSC_START_SENS_CALIB:
+ // If sensor calibration is supported
+ if ( ( len == 1 ) && ( runningFeatures & RSC_SENSOR_CALIB_SUPP ) )
+ {
+ // Notify app
+ if ( runningServiceCB != NULL )
+ {
+ if ( (*runningServiceCB)( RSC_CMD_START_SENS_CALIB, NULL ) != SUCCESS )
+ {
+ // Calibration wasn't started
+ rscStatus = RSC_OPERATION_FAILED;
+ }
+ }
+ }
+ else // characteristic not supported.
+ {
+ // Send an indication with the list.
+ rscStatus = RSC_INVALID_PARAMETER;
+ }
+ break;
+
+ case RSC_UPDATE_SENS_LOC:
+ // If multiple sensor locations is supported and that this is a valid location.
+ if ( ( len == 2 ) &&
+ ( runningFeatures & RSC_MULTI_SENS_SUPP ) &&
+ ( running_SensorLocSupported( pValue[1] ) == TRUE ) )
+ {
+ // Update sensor location
+ runningSensLoc = pValue[1];
+
+ // Notify app
+ if ( runningServiceCB != NULL )
+ {
+ VOID (*runningServiceCB)( RSC_CMD_UPDATE_SENS_LOC, NULL );
+ }
+ }
+ else // characteristic not supported.
+ {
+ rscStatus = RSC_INVALID_PARAMETER;
+ }
+ break;
+
+ case RSC_REQ_SUPP_SENS_LOC:
+ // If multiple sensor locations are supported and list requested
+ if ( ( len == 1 ) && ( runningFeatures & RSC_MULTI_SENS_SUPP ) )
+ {
+ rscCmdInd.len += supportedSensors;
+ osal_memcpy( &(rscCmdInd.value[3]), supportedSensorLocations, supportedSensors );
+ }
+ else // characteristic not supported.
+ {
+ // Send an indication with the list.
+ rscStatus = RSC_INVALID_PARAMETER;
+ }
+ break;
+
+ default:
+ // Send an indication with opcode not suported response
+ rscStatus = RSC_OPCODE_NOT_SUPPORTED;
+ break;
+ }
+
+ // Send indication of operation result
+ rscCmdInd.value[2] = rscStatus;
+
+ // Ask our task to send out indication
+ osal_set_event( runningService_TaskID, RSC_CMD_IND_SEND_EVT );
+}
+
+/*********************************************************************
+ * @fn Running_HandleConnStatusCB
+ *
+ * @brief RSC Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+void Running_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, runningMeasClientCharCfg );
+ GATTServApp_InitCharCfg( connHandle, runningCommandClientCharCfg );
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn running_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 running_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ bStatus_t status = SUCCESS;
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+
+ switch ( uuid )
+ {
+ // Read Sensor Location
+ case RSC_SENS_LOC_UUID:
+ {
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ }
+ break;
+
+ // Read Running Feature List
+ case RSC_FEATURE_UUID:
+ {
+ *pLen = 2;
+ pValue[0] = LO_UINT16( runningFeatures );
+ pValue[1] = HI_UINT16( runningFeatures );
+ }
+ break;
+
+ default:
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ // Notify app
+ if ( runningServiceCB != NULL )
+ {
+ VOID (*runningServiceCB)( RSC_READ_ATTR, NULL );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn running_WriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t running_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+
+ if ( offset > 0 )
+ {
+ return (ATT_ERR_ATTR_NOT_LONG);
+ }
+
+ switch ( uuid )
+ {
+ case RSC_COMMAND_UUID:
+ // Make sure Control Point Cfg is not already in progress
+ if ( scOpInProgress == TRUE )
+ {
+ status = RSC_ERR_PROC_IN_PROGRESS;
+ }
+ // Make sure Control Point Cfg is configured for Indications
+ else if ( (runningCommandClientCharCfg[connHandle].value & GATT_CLIENT_CFG_INDICATE) == FALSE )
+ {
+ status = RSC_ERR_CCC_IMPROPER_CFG;
+ }
+ else
+ {
+ // Process RSC command
+ running_ProcessRSCCmd( pAttr->handle, pValue, len );
+ connectionHandle = connHandle;
+ }
+ break;
+
+ // For Measure and Commands CCC
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ if ( pAttr->handle == runningAttrTbl[RSC_COMMAND_CFG_POS].handle )
+ {
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_INDICATE );
+ // Notify app
+ if ( runningServiceCB != NULL )
+ {
+ VOID (*runningServiceCB)( RSC_WRITE_ATTR, NULL );
+ }
+ }
+ else if ( pAttr->handle == runningAttrTbl[RSC_MEAS_CFG_POS].handle )
+ {
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ if ( status == SUCCESS )
+ {
+ // Notify app
+ if ( runningServiceCB != NULL )
+ {
+ uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );
+
+ VOID (*runningServiceCB)( ((charCfg == GATT_CFG_NO_OPERATION) ?
+ RSC_MEAS_NOTI_DISABLED :
+ RSC_MEAS_NOTI_ENABLED ), NULL );
+ }
+ }
+ }
+ break;
+
+ default:
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+*********************************************************************/
\ No newline at end of file
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/RSC/runningservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/RSC/runningservice.h
new file mode 100644
index 0000000..e6f1181
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/RSC/runningservice.h
@@ -0,0 +1,265 @@
+/**************************************************************************************************
+ Filename: runningservice.h
+ Revised: $Date: 2013-03-27 10:26:15 -0700 (Wed, 27 Mar 2013) $
+ Revision: $Revision: 33609 $
+
+ Description: This file contains the Running Speed and Cadence (RSC) service definitions and
+ prototypes.
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef RUNNINGSERVICE_H
+#define RUNNINGSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+#define RUNNING_SERVICE 0x00000001
+
+//ATT Error Codes
+#define RSC_ERR_PROC_IN_PROGRESS 0x80
+#define RSC_ERR_CCC_IMPROPER_CFG 0x81
+
+#define RSC_SUCCESS 1
+#define RSC_OPCODE_NOT_SUPPORTED 2
+#define RSC_INVALID_PARAMETER 3
+#define RSC_OPERATION_FAILED 4
+
+//RSC Service Parameters
+#define RSC_MEAS 1
+#define RSC_MEAS_CHAR_CFG 2
+#define RSC_FEATURE 3
+#define RSC_SENS_LOC 4
+#define RSC_COMMAND 5
+#define RSC_COMMAND_CHAR_CFG 6
+#define RSC_AVAIL_SENS_LOCS 7
+
+//RSC Service UUID's
+#define RSC_SERV_UUID 0x1814
+#define RSC_MEAS_UUID 0x2A53
+#define RSC_FEATURE_UUID 0x2A54
+#define RSC_SENS_LOC_UUID 0x2A5D
+#define RSC_COMMAND_UUID 0x2A55
+
+//RSC Fields
+#define RSC_INST_STRIDE_PRESENT 0x01
+#define RSC_TOTAL_DIST_PRESENT 0x02
+#define RSC_WALKING_OR_RUNNING 0x04
+
+//RSC SUPPORTED FEATURES
+#define RSC_NO_SUPPORT 0x00
+#define RSC_STRIDE_SUPP 0x01
+#define RSC_TOTAL_DIST_SUPP 0x02
+#define RSC_WALKING_RUNNING_SUPP 0x04
+#define RSC_SENSOR_CALIB_SUPP 0x08
+#define RSC_MULTI_SENS_SUPP 0x10
+#define RSC_FULL_SUPPORT 0x1F
+
+//RSC Censor Locations
+#define RSC_NO_SENSOR_LOC 0x00
+#define RSC_SENSOR_LOC_0 0x01
+#define RSC_SENSOR_LOC_1 0x02
+#define RSC_SENSOR_LOC_2 0x04
+#define RSC_SENSOR_LOC_3 0x08
+#define RSC_ALL_SENSORS 0xFF
+
+//Spec says there are 17 possible.
+#define RSC_MAX_SENSOR_LOCS 8
+
+//RSC Commands - arbitrarly assigned
+#define RSC_SET_CUMM_VAL 1
+#define RSC_START_SENS_CALIB 2
+#define RSC_UPDATE_SENS_LOC 3
+#define RSC_REQ_SUPP_SENS_LOC 4
+#define RSC_COMMAND_RSP 16
+
+// Values for flags
+#define RSC_FLAGS_AT_REST 0x00
+#define RSC_FLAGS_STRIDE 0x01
+#define RSC_FLAGS_DIST 0x02
+#define RSC_FLAGS_ALL 0x03
+
+
+#define DEFAULT_NOTI_INTERVAL 1000 // in milliseconds
+
+#define VALUE_ROLL_OVER 64000 // in milliseconds
+
+// Callback events
+#define RSC_CMD_SET_CUMM_VAL 1
+#define RSC_CMD_START_SENS_CALIB 2
+#define RSC_CMD_UPDATE_SENS_LOC 3
+#define RSC_MEAS_NOTI_ENABLED 4
+#define RSC_MEAS_NOTI_DISABLED 5
+#define RSC_READ_ATTR 6
+#define RSC_WRITE_ATTR 7
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// RSC service callback function
+typedef bStatus_t (*runningServiceCB_t)(uint8 event, uint32 *pNewCummVal);
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn RunningService_Init
+ *
+ * @brief collect the OSAL task ID.
+ *
+ * @param task_id - OSAL task ID.
+ *
+ * @return none
+ */
+extern void RunningService_Init( uint8 task_id );
+
+/*********************************************************************
+ * @fn RunningService_ProcessEvent
+ *
+ * @brief process incoming event.
+ *
+ * @param task_id - OSAL task id.
+ *
+ * @param events - event bit(s) set for the task(s)
+ *
+ * @return none
+ */
+extern uint16 RunningService_ProcessEvent( uint8 task_id, uint16 events );
+
+/*
+ * @fn Runninging_AddService
+ *
+ * @brief Initializes the RSC service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ * @return status
+ */
+extern bStatus_t Running_AddService( uint32 services );
+
+/*
+ * @fn Running_Register
+ *
+ * @brief Register a callback function with the
+ * RSC Service
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return none
+ */
+extern void Running_Register( runningServiceCB_t pfnServiceCB );
+
+/*
+ * @fn Running_SetParameter
+ *
+ * @brief Set a RSC parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return status
+ */
+extern bStatus_t Running_SetParameter( uint8 param, uint8 len, void *value );
+
+/*********************************************************************
+ * @fn Running_GetParameter
+ *
+ * @brief Get a RSC parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Running_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+ * @fn Running_MeasNotify
+ *
+ * @brief Send a notification containing a RSC
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t Running_MeasNotify( uint16 connHandle, attHandleValueNoti_t *pNoti );
+
+/*********************************************************************
+ * @fn Running_HandleConnStatusCB
+ *
+ * @brief RSC Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+extern void Running_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RUNNINGSERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/broadcaster.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/broadcaster.c
new file mode 100644
index 0000000..8f6c8c2
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/broadcaster.c
@@ -0,0 +1,637 @@
+/**************************************************************************************************
+ Filename: broadcaster.c
+ Revised: $Date: 2011-05-05 10:12:10 -0700 (Thu, 05 May 2011) $
+ Revision: $Revision: 25871 $
+
+ Description: GAP Broadcaster Role
+
+
+ Copyright 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "hci_tl.h"
+
+#include "gap.h"
+
+#include "broadcaster.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+// Profile Events
+#define START_ADVERTISING_EVT 0x0001
+
+#define DEFAULT_ADVERT_OFF_TIME 30000 // 30 seconds
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+static uint8 gapRole_TaskID; // Task ID for internal task/event processing
+
+static gaprole_States_t gapRole_state;
+
+/*********************************************************************
+ * Profile Parameters - reference GAPROLE_PROFILE_PARAMETERS for
+ * descriptions
+ */
+
+static uint8 gapRole_profileRole;
+static uint8 gapRole_bdAddr[B_ADDR_LEN];
+static uint8 gapRole_AdvEnabled = TRUE;
+static uint16 gapRole_AdvertOffTime = DEFAULT_ADVERT_OFF_TIME;
+static uint8 gapRole_AdvertDataLen = 3;
+static uint8 gapRole_AdvertData[B_MAX_ADV_LEN] =
+{
+ 0x02, // length of this data
+ GAP_ADTYPE_FLAGS, // AD Type = Flags
+ // BR/EDR not supported
+ GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+};
+static uint8 gapRole_ScanRspDataLen = 0;
+static uint8 gapRole_ScanRspData[B_MAX_ADV_LEN] = {0};
+static uint8 gapRole_AdvEventType;
+static uint8 gapRole_AdvDirectType;
+static uint8 gapRole_AdvDirectAddr[B_ADDR_LEN] = {0};
+static uint8 gapRole_AdvChanMap;
+static uint8 gapRole_AdvFilterPolicy;
+
+// Application callbacks
+static gapRolesCBs_t *pGapRoles_AppCGs = NULL;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static void gapRole_ProcessOSALMsg( osal_event_hdr_t *pMsg );
+static void gapRole_ProcessGAPMsg( gapEventHdr_t *pMsg );
+static void gapRole_SetupGAP( void );
+
+/*********************************************************************
+ * NETWORK LAYER CALLBACKS
+ */
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @brief Set a GAP Role parameter.
+ *
+ * Public function defined in broadcaster.h.
+ */
+bStatus_t GAPRole_SetParameter( uint16 param, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case GAPROLE_ADVERT_ENABLED:
+ if ( len == sizeof( uint8 ) )
+ {
+ uint8 oldAdvEnabled = gapRole_AdvEnabled;
+ gapRole_AdvEnabled = *((uint8*)pValue);
+
+ if ( (oldAdvEnabled) && (gapRole_AdvEnabled == FALSE) )
+ {
+ // Turn off Advertising
+ if ( gapRole_state == GAPROLE_ADVERTISING )
+ {
+ VOID GAP_EndDiscoverable( gapRole_TaskID );
+ }
+ }
+ else if ( (oldAdvEnabled == FALSE) && (gapRole_AdvEnabled) )
+ {
+ // Turn on Advertising
+ if ( (gapRole_state == GAPROLE_STARTED)
+ || (gapRole_state == GAPROLE_WAITING) )
+ {
+ VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );
+ }
+ }
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADVERT_OFF_TIME:
+ if ( len == sizeof ( uint16 ) )
+ {
+ gapRole_AdvertOffTime = *((uint16*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADVERT_DATA:
+ if ( len <= B_MAX_ADV_LEN )
+ {
+ VOID osal_memset( gapRole_AdvertData, 0, B_MAX_ADV_LEN );
+ VOID osal_memcpy( gapRole_AdvertData, pValue, len );
+ gapRole_AdvertDataLen = len;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_SCAN_RSP_DATA:
+ if ( len <= B_MAX_ADV_LEN )
+ {
+ VOID osal_memset( gapRole_ScanRspData, 0, B_MAX_ADV_LEN );
+ VOID osal_memcpy( gapRole_ScanRspData, pValue, len );
+ gapRole_ScanRspDataLen = len;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_EVENT_TYPE:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAP_ADTYPE_ADV_NONCONN_IND) )
+ {
+ gapRole_AdvEventType = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_DIRECT_TYPE:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= ADDRTYPE_PRIVATE_RESOLVE) )
+ {
+ gapRole_AdvDirectType = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_DIRECT_ADDR:
+ if ( len == B_ADDR_LEN )
+ {
+ VOID osal_memcpy( gapRole_AdvDirectAddr, pValue, B_ADDR_LEN ) ;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_CHANNEL_MAP:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= 0x07) )
+ {
+ gapRole_AdvChanMap = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_FILTER_POLICY:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAP_FILTER_POLICY_WHITE) )
+ {
+ gapRole_AdvFilterPolicy = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ // The param value isn't part of this profile, try the GAP.
+ if ( (param < TGAP_PARAMID_MAX) && (len == sizeof ( uint16 )) )
+ {
+ ret = GAP_SetParamValue( param, *((uint16*)pValue) );
+ }
+ else
+ {
+ ret = INVALIDPARAMETER;
+ }
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Get a GAP Role parameter.
+ *
+ * Public function defined in broadcaster.h.
+ */
+bStatus_t GAPRole_GetParameter( uint16 param, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case GAPROLE_PROFILEROLE:
+ *((uint8*)pValue) = gapRole_profileRole;
+ break;
+
+ case GAPROLE_BD_ADDR:
+ VOID osal_memcpy( pValue, gapRole_bdAddr, B_ADDR_LEN ) ;
+ break;
+
+ case GAPROLE_ADVERT_ENABLED:
+ *((uint8*)pValue) = gapRole_AdvEnabled;
+ break;
+
+ case GAPROLE_ADVERT_OFF_TIME:
+ *((uint16*)pValue) = gapRole_AdvertOffTime;
+ break;
+
+ case GAPROLE_ADVERT_DATA:
+ VOID osal_memcpy( pValue , gapRole_AdvertData, gapRole_AdvertDataLen );
+ break;
+
+ case GAPROLE_SCAN_RSP_DATA:
+ VOID osal_memcpy( pValue, gapRole_ScanRspData, gapRole_ScanRspDataLen ) ;
+ break;
+
+ case GAPROLE_ADV_EVENT_TYPE:
+ *((uint8*)pValue) = gapRole_AdvEventType;
+ break;
+
+ case GAPROLE_ADV_DIRECT_TYPE:
+ *((uint8*)pValue) = gapRole_AdvDirectType;
+ break;
+
+ case GAPROLE_ADV_DIRECT_ADDR:
+ VOID osal_memcpy( pValue, gapRole_AdvDirectAddr, B_ADDR_LEN ) ;
+ break;
+
+ case GAPROLE_ADV_CHANNEL_MAP:
+ *((uint8*)pValue) = gapRole_AdvChanMap;
+ break;
+
+ case GAPROLE_ADV_FILTER_POLICY:
+ *((uint8*)pValue) = gapRole_AdvFilterPolicy;
+ break;
+
+ default:
+ // The param value isn't part of this profile, try the GAP.
+ if ( param < TGAP_PARAMID_MAX )
+ {
+ *((uint16*)pValue) = GAP_GetParamValue( param );
+ }
+ else
+ {
+ ret = INVALIDPARAMETER;
+ }
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Does the device initialization.
+ *
+ * Public function defined in broadcaster.h.
+ */
+bStatus_t GAPRole_StartDevice( gapRolesCBs_t *pAppCallbacks )
+{
+ if ( gapRole_state == GAPROLE_INIT )
+ {
+ // Clear all of the Application callbacks
+ if ( pAppCallbacks )
+ {
+ pGapRoles_AppCGs = pAppCallbacks;
+ }
+
+ // Start the GAP
+ gapRole_SetupGAP();
+
+ return ( SUCCESS );
+ }
+ else
+ {
+ return ( bleAlreadyInRequestedMode );
+ }
+}
+
+/*********************************************************************
+ * LOCAL FUNCTION PROTOTYPES
+ */
+
+/*********************************************************************
+ * @brief Task Initialization function.
+ *
+ * Internal function defined in broadcaster.h.
+ */
+void GAPRole_Init( uint8 task_id )
+{
+ gapRole_TaskID = task_id;
+
+ gapRole_state = GAPROLE_INIT;
+
+ GAP_RegisterForHCIMsgs( gapRole_TaskID );
+
+ // Initialize the Profile Advertising and Connection Parameters
+ gapRole_profileRole = GAP_PROFILE_BROADCASTER;
+
+ gapRole_AdvEventType = GAP_ADTYPE_ADV_NONCONN_IND;
+ gapRole_AdvDirectType = ADDRTYPE_PUBLIC;
+ gapRole_AdvChanMap = GAP_ADVCHAN_ALL;
+ gapRole_AdvFilterPolicy = GAP_FILTER_POLICY_ALL;
+}
+
+/*********************************************************************
+ * @brief Task Event Processor function.
+ *
+ * Internal function defined in broadcaster.h.
+ */
+uint16 GAPRole_ProcessEvent( uint8 task_id, uint16 events )
+{
+ VOID task_id; // OSAL required parameter that isn't used in this function
+
+ if ( events & SYS_EVENT_MSG )
+ {
+ uint8 *pMsg;
+
+ if ( (pMsg = osal_msg_receive( gapRole_TaskID )) != NULL )
+ {
+ gapRole_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 & START_ADVERTISING_EVT )
+ {
+ if ( gapRole_AdvEnabled )
+ {
+ gapAdvertisingParams_t params;
+
+ // Setup advertisement parameters
+ params.eventType = gapRole_AdvEventType;
+ params.initiatorAddrType = gapRole_AdvDirectType;
+ VOID osal_memcpy( params.initiatorAddr, gapRole_AdvDirectAddr, B_ADDR_LEN );
+ params.channelMap = gapRole_AdvChanMap;
+ params.filterPolicy = gapRole_AdvFilterPolicy;
+
+ if ( GAP_MakeDiscoverable( gapRole_TaskID, ¶ms ) != SUCCESS )
+ {
+ gapRole_state = GAPROLE_ERROR;
+ if ( pGapRoles_AppCGs && pGapRoles_AppCGs->pfnStateChange )
+ {
+ pGapRoles_AppCGs->pfnStateChange( gapRole_state );
+ }
+ }
+ }
+
+ return ( events ^ START_ADVERTISING_EVT );
+ }
+
+ // Discard unknown events
+ return 0;
+}
+
+/*********************************************************************
+ * @fn gapRole_ProcessOSALMsg
+ *
+ * @brief Process an incoming task message.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void gapRole_ProcessOSALMsg( osal_event_hdr_t *pMsg )
+{
+ switch ( pMsg->event )
+ {
+ case HCI_GAP_EVENT_EVENT:
+ if ( pMsg->status == HCI_COMMAND_COMPLETE_EVENT_CODE )
+ {
+ //hciEvt_CmdComplete_t *pPkt = (hciEvt_CmdComplete_t *)pMsg;
+ }
+ break;
+
+ case GAP_MSG_EVENT:
+ gapRole_ProcessGAPMsg( (gapEventHdr_t *)pMsg );
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn gapRole_ProcessGAPMsg
+ *
+ * @brief Process an incoming task message.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void gapRole_ProcessGAPMsg( gapEventHdr_t *pMsg )
+{
+ uint8 notify = FALSE; // State changed notify the app? (default no)
+
+ switch ( pMsg->opcode )
+ {
+ case GAP_DEVICE_INIT_DONE_EVENT:
+ {
+ gapDeviceInitDoneEvent_t *pPkt = (gapDeviceInitDoneEvent_t *)pMsg;
+ bStatus_t stat = pPkt->hdr.status;
+
+ if ( stat == SUCCESS )
+ {
+ // Save off the information
+ VOID osal_memcpy( gapRole_bdAddr, pPkt->devAddr, B_ADDR_LEN );
+
+ gapRole_state = GAPROLE_STARTED;
+
+ // Update the advertising data
+ stat = GAP_UpdateAdvertisingData( gapRole_TaskID, TRUE,
+ gapRole_AdvertDataLen,
+ gapRole_AdvertData );
+ }
+
+ if ( stat != SUCCESS )
+ {
+ gapRole_state = GAPROLE_ERROR;
+ }
+
+ notify = TRUE;
+ }
+ break;
+
+ case GAP_ADV_DATA_UPDATE_DONE_EVENT:
+ {
+ gapAdvDataUpdateEvent_t *pPkt = (gapAdvDataUpdateEvent_t *)pMsg;
+
+ if ( pPkt->hdr.status == SUCCESS )
+ {
+ if ( pPkt->adType )
+ {
+ // Setup the Response Data
+ pPkt->hdr.status = GAP_UpdateAdvertisingData( gapRole_TaskID,
+ FALSE, gapRole_ScanRspDataLen, gapRole_ScanRspData );
+ }
+ else
+ {
+ // Start advertising
+ VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );
+ }
+ }
+
+ if ( pPkt->hdr.status != SUCCESS )
+ {
+ // Set into Error state
+ gapRole_state = GAPROLE_ERROR;
+ notify = TRUE;
+ }
+ }
+ break;
+
+ case GAP_MAKE_DISCOVERABLE_DONE_EVENT:
+ case GAP_END_DISCOVERABLE_DONE_EVENT:
+ {
+ gapMakeDiscoverableRspEvent_t *pPkt = (gapMakeDiscoverableRspEvent_t *)pMsg;
+
+ if ( pPkt->hdr.status == SUCCESS )
+ {
+ if ( pMsg->opcode == GAP_MAKE_DISCOVERABLE_DONE_EVENT )
+ {
+ gapRole_state = GAPROLE_ADVERTISING;
+ }
+ else // GAP_END_DISCOVERABLE_DONE_EVENT
+ {
+
+ if ( gapRole_AdvertOffTime != 0 )
+ {
+ if ( ( gapRole_AdvEnabled ) )
+ {
+ VOID osal_start_timerEx( gapRole_TaskID, START_ADVERTISING_EVT, gapRole_AdvertOffTime );
+ }
+ }
+ else
+ {
+ // Since gapRole_AdvertOffTime is set to 0, the device should not
+ // automatically become discoverable again after a period of time.
+ // Set enabler to FALSE; device will become discoverable again when
+ // this value gets set to TRUE
+ gapRole_AdvEnabled = FALSE;
+ }
+
+ // In the Advertising Off period
+ gapRole_state = GAPROLE_WAITING;
+
+ }
+ }
+ else
+ {
+ gapRole_state = GAPROLE_ERROR;
+ }
+ notify = TRUE;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if ( notify == TRUE )
+ {
+ // Notify the application
+ if ( pGapRoles_AppCGs && pGapRoles_AppCGs->pfnStateChange )
+ {
+ pGapRoles_AppCGs->pfnStateChange( gapRole_state );
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn gapRole_SetupGAP
+ *
+ * @brief Call the GAP Device Initialization function using the
+ * Profile Parameters.
+ *
+ * @param none
+ *
+ * @return none
+ */
+static void gapRole_SetupGAP( void )
+{
+ VOID GAP_DeviceInit( gapRole_TaskID,
+ gapRole_profileRole, 0,
+ NULL, NULL, NULL );
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/broadcaster.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/broadcaster.h
new file mode 100644
index 0000000..3aed6a9
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/broadcaster.h
@@ -0,0 +1,220 @@
+/**
+ @headerfile: broadcaster.h
+ $Date: 2011-02-17 12:17:30 -0800 (Thu, 17 Feb 2011) $
+ $Revision: 25119 $
+
+ @mainpage TI BLE GAP Broadcaster Role
+
+ This GAP profile only advertises.
+
+ Copyright 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*/
+
+#ifndef BROADCASTER_H
+#define BROADCASTER_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*-------------------------------------------------------------------
+ * INCLUDES
+ */
+
+/*-------------------------------------------------------------------
+ * CONSTANTS
+ */
+
+/** @defgroup GAPROLE_PROFILE_PARAMETERS GAP Role Parameters
+ * @{
+ */
+#define GAPROLE_PROFILEROLE 0x300 //!< Reading this parameter will return GAP Role type. Read Only. Size is uint8.
+#define GAPROLE_BD_ADDR 0x301 //!< Device's Address. Read Only. Size is uint8[B_ADDR_LEN]. This item is read from the controller.
+#define GAPROLE_ADVERT_ENABLED 0x302 //!< Enable/Disable Advertising. Read/Write. Size is uint8. Default is TRUE=Enabled.
+#define GAPROLE_ADVERT_OFF_TIME 0x303 //!< Advertising Off Time for Limited advertisements (in milliseconds). Read/Write. Size is uint16. Default is 30 seconds.
+#define GAPROLE_ADVERT_DATA 0x304 //!< Advertisement Data. Read/Write. Size is uint8[B_MAX_ADV_LEN]. Default is "02:01:01", which means that it is a Limited Discoverable Advertisement.
+#define GAPROLE_SCAN_RSP_DATA 0x305 //!< Scan Response Data. Read/Write. Size is uint8[B_MAX_ADV_LEN]. Defaults to all 0.
+#define GAPROLE_ADV_EVENT_TYPE 0x306 //!< Advertisement Type. Read/Write. Size is uint8. Default is GAP_ADTYPE_ADV_IND (defined in GAP.h).
+#define GAPROLE_ADV_DIRECT_TYPE 0x307 //!< Direct Advertisement Address Type. Ready/Write. Size is uint8. Default is ADDRTYPE_PUBLIC (defined in GAP.h).
+#define GAPROLE_ADV_DIRECT_ADDR 0x308 //!< Direct Advertisement Address. Read/Write. Size is uint8[B_ADDR_LEN]. Default is NULL.
+#define GAPROLE_ADV_CHANNEL_MAP 0x309 //!< Which channels to advertise on. Read/Write Size is uint8. Default is GAP_ADVCHAN_ALL (defined in GAP.h)
+#define GAPROLE_ADV_FILTER_POLICY 0x30A //!< Filter Policy. Ignored when directed advertising is used. Read/Write. Size is uint8. Default is GAP_FILTER_POLICY_ALL (defined in GAP.h).
+/** @} End GAPROLE_PROFILE_PARAMETERS */
+
+/*-------------------------------------------------------------------
+ * TYPEDEFS
+ */
+
+/**
+ * GAP Broadcaster Role States.
+ */
+typedef enum
+{
+ GAPROLE_INIT = 0, //!< Waiting to be started
+ GAPROLE_STARTED, //!< Started but not advertising
+ GAPROLE_ADVERTISING, //!< Currently Advertising
+ GAPROLE_WAITING, //!< Device is started but not advertising, is in waiting period before advertising again
+ GAPROLE_ERROR //!< Error occurred - invalid state
+} gaprole_States_t;
+
+/*-------------------------------------------------------------------
+ * MACROS
+ */
+
+/*-------------------------------------------------------------------
+ * Profile Callbacks
+ */
+
+/**
+ * Callback when the device has been started. Callback event to
+ * the Notify of a state change.
+ */
+typedef void (*gapRolesStateNotify_t)( gaprole_States_t newState );
+
+/**
+ * Callback when the device has read an new RSSI value during a connection.
+ */
+typedef void (*gapRolesRssiRead_t)( int8 newRSSI );
+
+/**
+ * Callback structure - must be setup by the application and used when gapRoles_StartDevice() is called.
+ */
+typedef struct
+{
+ gapRolesStateNotify_t pfnStateChange; //!< Whenever the device changes state
+ gapRolesRssiRead_t pfnRssiRead; //!< When a valid RSSI is read from controller
+} gapRolesCBs_t;
+
+/*-------------------------------------------------------------------
+ * API FUNCTIONS
+ */
+
+/**
+ * @defgroup GAPROLES_BROADCASTER_API GAP Broadcaster Role API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Set a GAP Role parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will set the
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also,
+ * the "len" field must be set to the size of a "uint16" and the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
+ * @param len - length of data to write
+ * @param pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPRole_SetParameter( uint16 param, uint8 len, void *pValue );
+
+/**
+ * @brief Get a GAP Role parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will get a
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also, the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
+ * @param pValue - pointer to location to get the value. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPRole_GetParameter( uint16 param, void *pValue );
+
+/**
+ * @brief Does the device initialization. Only call this function once.
+ *
+ * @param pAppCallbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+extern bStatus_t GAPRole_StartDevice( gapRolesCBs_t *pAppCallbacks );
+
+/**
+ * @} End GAPROLES_BROADCASTER_API
+ */
+
+
+/*-------------------------------------------------------------------
+ * TASK FUNCTIONS - Don't call these. These are system functions.
+ */
+
+/**
+ * @internal
+ *
+ * @brief Initialization function for the GAP Role Task.
+ * This is called during initialization and should contain
+ * any application specific initialization (ie. hardware
+ * initialization/setup, table initialization, power up
+ * notificaiton ... ).
+ *
+ * @param the ID assigned by OSAL. This ID should be
+ * used to send messages and set timers.
+ *
+ * @return void
+ */
+extern void GAPRole_Init( uint8 task_id );
+
+/**
+ * @internal
+ *
+ * @brief GAP Role 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 events not processed
+ */
+extern uint16 GAPRole_ProcessEvent( uint8 task_id, uint16 events );
+
+/*-------------------------------------------------------------------
+-------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BROADCASTER_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/central.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/central.c
new file mode 100644
index 0000000..4ce33c0
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/central.c
@@ -0,0 +1,694 @@
+/**************************************************************************************************
+ Filename: central.c
+ Revised: $Date: 2012-05-18 09:00:17 -0700 (Fri, 18 May 2012) $
+ Revision: $Revision: 30571 $
+
+ Description: GAP Central Role
+
+
+ Copyright 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "osal_cbTimer.h"
+#include "osal_snv.h"
+#include "hci_tl.h"
+#include "l2cap.h"
+#include "linkdb.h"
+#include "gap.h"
+#include "gapbondmgr.h"
+#include "central.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Profile Events
+#define START_ADVERTISING_EVT 0x0001
+#define RSSI_READ_EVT 0x0002
+#define UPDATE_PARAMS_TIMEOUT_EVT 0x0004
+
+// Profile OSAL Message IDs
+#define GAPCENTRALROLE_RSSI_MSG_EVT 0xE0
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// RSSI read data structure
+typedef struct
+{
+ uint16 period;
+ uint16 connHandle;
+ uint8 timerId;
+} gapCentralRoleRssi_t;
+
+// OSAL event structure for RSSI timer events
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ gapCentralRoleRssi_t *pRssi;
+} gapCentralRoleRssiEvent_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+// Task ID
+static uint8 gapCentralRoleTaskId;
+
+// App callbacks
+static gapCentralRoleCB_t *pGapCentralRoleCB;
+
+// Array of RSSI read structures
+static gapCentralRoleRssi_t gapCentralRoleRssi[GAPCENTRALROLE_NUM_RSSI_LINKS];
+
+/*********************************************************************
+ * Profile Parameters - reference GAPCENTRALROLE_PROFILE_PARAMETERS for
+ * descriptions
+ */
+
+static uint8 gapCentralRoleIRK[KEYLEN];
+static uint8 gapCentralRoleSRK[KEYLEN];
+static uint32 gapCentralRoleSignCounter;
+static uint8 gapCentralRoleBdAddr[B_ADDR_LEN];
+static uint8 gapCentralRoleMaxScanRes = 0;
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static void gapCentralRole_ProcessOSALMsg( osal_event_hdr_t *pMsg );
+static void gapCentralRole_ProcessGAPMsg( gapEventHdr_t *pMsg );
+static gapCentralRoleRssi_t *gapCentralRole_RssiAlloc( uint16 connHandle );
+static gapCentralRoleRssi_t *gapCentralRole_RssiFind( uint16 connHandle );
+static void gapCentralRole_RssiFree( uint16 connHandle );
+static void gapCentralRole_timerCB( uint8 *pData );
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/**
+ * @brief Start the device in Central role. This function is typically
+ * called once during system startup.
+ *
+ * Public function defined in central.h.
+ */
+bStatus_t GAPCentralRole_StartDevice( gapCentralRoleCB_t *pAppCallbacks )
+{
+ if ( pAppCallbacks )
+ {
+ pGapCentralRoleCB = pAppCallbacks;
+ }
+
+ return GAP_DeviceInit( gapCentralRoleTaskId, GAP_PROFILE_CENTRAL,
+ gapCentralRoleMaxScanRes, gapCentralRoleIRK,
+ gapCentralRoleSRK, &gapCentralRoleSignCounter );
+}
+
+/**
+ * @brief Set a parameter in the Central Profile.
+ *
+ * Public function defined in central.h.
+ */
+bStatus_t GAPCentralRole_SetParameter( uint16 param, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case GAPCENTRALROLE_IRK:
+ if ( len == KEYLEN )
+ {
+ VOID osal_memcpy( gapCentralRoleIRK, pValue, KEYLEN ) ;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPCENTRALROLE_SRK:
+ if ( len == KEYLEN )
+ {
+ VOID osal_memcpy( gapCentralRoleSRK, pValue, KEYLEN ) ;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPCENTRALROLE_SIGNCOUNTER:
+ if ( len == sizeof ( uint32 ) )
+ {
+ gapCentralRoleSignCounter = *((uint32*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPCENTRALROLE_MAX_SCAN_RES:
+ if ( len == sizeof ( uint8 ) )
+ {
+ gapCentralRoleMaxScanRes = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Get a parameter in the Central Profile.
+ *
+ * Public function defined in central.h.
+ */
+bStatus_t GAPCentralRole_GetParameter( uint16 param, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case GAPCENTRALROLE_IRK:
+ VOID osal_memcpy( pValue, gapCentralRoleIRK, KEYLEN ) ;
+ break;
+
+ case GAPCENTRALROLE_SRK:
+ VOID osal_memcpy( pValue, gapCentralRoleSRK, KEYLEN ) ;
+ break;
+
+ case GAPCENTRALROLE_SIGNCOUNTER:
+ *((uint32*)pValue) = gapCentralRoleSignCounter;
+ break;
+
+ case GAPCENTRALROLE_BD_ADDR:
+ VOID osal_memcpy( pValue, gapCentralRoleBdAddr, B_ADDR_LEN ) ;
+ break;
+
+ case GAPCENTRALROLE_MAX_SCAN_RES:
+ *((uint8*)pValue) = gapCentralRoleMaxScanRes;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Terminate a link.
+ *
+ * Public function defined in central.h.
+ */
+bStatus_t GAPCentralRole_TerminateLink( uint16 connHandle )
+{
+ return GAP_TerminateLinkReq( gapCentralRoleTaskId, connHandle ) ;
+}
+
+/**
+ * @brief Establish a link to a peer device.
+ *
+ * Public function defined in central.h.
+ */
+bStatus_t GAPCentralRole_EstablishLink( uint8 highDutyCycle, uint8 whiteList,
+ uint8 addrTypePeer, uint8 *peerAddr )
+{
+ gapEstLinkReq_t params;
+
+ params.taskID = gapCentralRoleTaskId;
+ params.highDutyCycle = highDutyCycle;
+ params.whiteList = whiteList;
+ params.addrTypePeer = addrTypePeer;
+ VOID osal_memcpy( params.peerAddr, peerAddr, B_ADDR_LEN );
+
+ return GAP_EstablishLinkReq( ¶ms );
+}
+
+/**
+ * @brief Update the link connection parameters.
+ *
+ * Public function defined in central.h.
+ */
+bStatus_t GAPCentralRole_UpdateLink( uint16 connHandle, uint16 connIntervalMin,
+ uint16 connIntervalMax, uint16 connLatency,
+ uint16 connTimeout )
+{
+ return (bStatus_t) HCI_LE_ConnUpdateCmd( connHandle, connIntervalMin,
+ connIntervalMax, connLatency,
+ connTimeout, 0, 0 );
+}
+
+/**
+ * @brief Start a device discovery scan.
+ *
+ * Public function defined in central.h.
+ */
+bStatus_t GAPCentralRole_StartDiscovery( uint8 mode, uint8 activeScan, uint8 whiteList )
+{
+ gapDevDiscReq_t params;
+
+ params.taskID = gapCentralRoleTaskId;
+ params.mode = mode;
+ params.activeScan = activeScan;
+ params.whiteList = whiteList;
+
+ return GAP_DeviceDiscoveryRequest( ¶ms );
+}
+
+/**
+ * @brief Cancel a device discovery scan.
+ *
+ * Public function defined in central.h.
+ */
+bStatus_t GAPCentralRole_CancelDiscovery( void )
+{
+ return GAP_DeviceDiscoveryCancel( gapCentralRoleTaskId );
+}
+
+/**
+ * @brief Start periodic RSSI reads on a link.
+ *
+ * Public function defined in central.h.
+ */
+bStatus_t GAPCentralRole_StartRssi( uint16 connHandle, uint16 period )
+{
+ gapCentralRoleRssi_t *pRssi;
+
+ // Verify link is up
+ if (!linkDB_Up(connHandle))
+ {
+ return bleIncorrectMode;
+ }
+
+ // If already allocated
+ if ((pRssi = gapCentralRole_RssiFind( connHandle )) != NULL)
+ {
+ // Stop timer
+ osal_CbTimerStop( pRssi->timerId );
+ }
+ // Allocate structure
+ else if ((pRssi = gapCentralRole_RssiAlloc( connHandle )) != NULL)
+ {
+ pRssi->period = period;
+ }
+ // Allocate failed
+ else
+ {
+ return bleNoResources;
+ }
+
+ // Start timer
+ osal_CbTimerStart( gapCentralRole_timerCB, (uint8 *) pRssi,
+ period, &pRssi->timerId );
+
+ return SUCCESS;
+}
+
+/**
+ * @brief Cancel periodic RSSI reads on a link.
+ *
+ * Public function defined in central.h.
+ */
+bStatus_t GAPCentralRole_CancelRssi(uint16 connHandle )
+{
+ gapCentralRoleRssi_t *pRssi;
+
+ if ((pRssi = gapCentralRole_RssiFind( connHandle )) != NULL)
+ {
+ // Stop timer
+ osal_CbTimerStop( pRssi->timerId );
+
+ // Free RSSI structure
+ gapCentralRole_RssiFree( connHandle );
+
+ return SUCCESS;
+ }
+
+ // Not found
+ return bleIncorrectMode;
+}
+
+/**
+ * @brief Central Profile Task initialization function.
+ *
+ * @param taskId - Task ID.
+ *
+ * @return void
+ */
+void GAPCentralRole_Init( uint8 taskId )
+{
+ uint8 i;
+
+ gapCentralRoleTaskId = taskId;
+
+ // Initialize internal data
+ for ( i = 0; i < GAPCENTRALROLE_NUM_RSSI_LINKS; i++ )
+ {
+ gapCentralRoleRssi[i].connHandle = GAP_CONNHANDLE_ALL;
+ gapCentralRoleRssi[i].timerId = INVALID_TIMER_ID;
+ }
+
+ // Initialize parameters
+
+ // Retore items from NV
+ VOID osal_snv_read( BLE_NVID_IRK, KEYLEN, gapCentralRoleIRK );
+ VOID osal_snv_read( BLE_NVID_CSRK, KEYLEN, gapCentralRoleSRK );
+ VOID osal_snv_read( BLE_NVID_SIGNCOUNTER, sizeof( uint32 ), &gapCentralRoleSignCounter );
+
+ // Register for HCI messages (for RSSI)
+ GAP_RegisterForHCIMsgs( taskId );
+}
+
+/**
+ * @brief Central Profile Task event processing function.
+ *
+ * @param taskId - Task ID
+ * @param events - Events.
+ *
+ * @return events not processed
+ */
+uint16 GAPCentralRole_ProcessEvent( uint8 taskId, uint16 events )
+{
+ if ( events & SYS_EVENT_MSG )
+ {
+ uint8 *pMsg;
+
+ if ( (pMsg = osal_msg_receive( gapCentralRoleTaskId )) != NULL )
+ {
+ gapCentralRole_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 & GAP_EVENT_SIGN_COUNTER_CHANGED )
+ {
+ // Sign counter changed, save it to NV
+ VOID osal_snv_write( BLE_NVID_SIGNCOUNTER, sizeof( uint32 ), &gapCentralRoleSignCounter );
+
+ return ( events ^ GAP_EVENT_SIGN_COUNTER_CHANGED );
+ }
+
+ // Discard unknown events
+ return 0;
+}
+
+/*********************************************************************
+ * @fn gapCentralRole_ProcessOSALMsg
+ *
+ * @brief Process an incoming task message.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void gapCentralRole_ProcessOSALMsg( osal_event_hdr_t *pMsg )
+{
+ switch ( pMsg->event )
+ {
+ case HCI_GAP_EVENT_EVENT:
+ if ( pMsg->status == HCI_COMMAND_COMPLETE_EVENT_CODE )
+ {
+ hciEvt_CmdComplete_t *pPkt = (hciEvt_CmdComplete_t *) pMsg;
+
+ if ( pPkt->cmdOpcode == HCI_READ_RSSI )
+ {
+ uint16 connHandle = BUILD_UINT16( pPkt->pReturnParam[1], pPkt->pReturnParam[2] );
+ int8 rssi = (int8) pPkt->pReturnParam[3];
+
+ // Report RSSI to app
+ if ( pGapCentralRoleCB && pGapCentralRoleCB->rssiCB )
+ {
+ pGapCentralRoleCB->rssiCB( connHandle, rssi );
+ }
+ }
+ }
+ break;
+
+ case GAP_MSG_EVENT:
+ gapCentralRole_ProcessGAPMsg( (gapEventHdr_t *) pMsg );
+ break;
+
+ case GAPCENTRALROLE_RSSI_MSG_EVT:
+ {
+ gapCentralRoleRssi_t *pRssi = ((gapCentralRoleRssiEvent_t *) pMsg)->pRssi;
+
+ // If link is up and RSSI reads active
+ if (pRssi->connHandle != GAP_CONNHANDLE_ALL &&
+ linkDB_Up(pRssi->connHandle))
+ {
+ // Restart timer
+ osal_CbTimerStart( gapCentralRole_timerCB, (uint8 *) pRssi,
+ pRssi->period, &pRssi->timerId );
+
+ // Read RSSI
+ VOID HCI_ReadRssiCmd( pRssi->connHandle );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn gapCentralRole_ProcessGAPMsg
+ *
+ * @brief Process an incoming task message from GAP.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void gapCentralRole_ProcessGAPMsg( gapEventHdr_t *pMsg )
+{
+ switch ( pMsg->opcode )
+ {
+ case GAP_DEVICE_INIT_DONE_EVENT:
+ {
+ gapDeviceInitDoneEvent_t *pPkt = (gapDeviceInitDoneEvent_t *) pMsg;
+
+ if ( pPkt->hdr.status == SUCCESS )
+ {
+ // Save off the generated keys
+ VOID osal_snv_write( BLE_NVID_IRK, KEYLEN, gapCentralRoleIRK );
+ VOID osal_snv_write( BLE_NVID_CSRK, KEYLEN, gapCentralRoleSRK );
+
+ // Save off the information
+ VOID osal_memcpy( gapCentralRoleBdAddr, pPkt->devAddr, B_ADDR_LEN );
+ }
+ }
+ break;
+
+ case GAP_LINK_ESTABLISHED_EVENT:
+ {
+ gapEstLinkReqEvent_t *pPkt = (gapEstLinkReqEvent_t *) pMsg;
+
+ if (pPkt->hdr.status == SUCCESS)
+ {
+ // Notify the Bond Manager of the connection
+ VOID GAPBondMgr_LinkEst( pPkt->devAddrType, pPkt->devAddr,
+ pPkt->connectionHandle, GAP_PROFILE_CENTRAL );
+ }
+ }
+ break;
+
+ case GAP_LINK_TERMINATED_EVENT:
+ {
+ uint16 connHandle = ((gapTerminateLinkEvent_t *) pMsg)->connectionHandle;
+
+ GAPBondMgr_ProcessGAPMsg( (gapEventHdr_t *)pMsg );
+
+ // Cancel RSSI reads
+ GAPCentralRole_CancelRssi( connHandle );
+ }
+ break;
+
+ // temporary workaround
+ case GAP_SLAVE_REQUESTED_SECURITY_EVENT:
+ GAPBondMgr_ProcessGAPMsg( pMsg );
+ break;
+
+ default:
+ break;
+ }
+
+ // Pass event to app
+ if ( pGapCentralRoleCB && pGapCentralRoleCB->eventCB )
+ {
+ pGapCentralRoleCB->eventCB( (gapCentralRoleEvent_t *) pMsg );
+ }
+}
+
+/*********************************************************************
+ * @fn gapCentralRole_RssiAlloc
+ *
+ * @brief Allocate an RSSI structure.
+ *
+ * @param connHandle - Connection handle
+ *
+ * @return pointer to structure or NULL if allocation failed.
+ */
+static gapCentralRoleRssi_t *gapCentralRole_RssiAlloc( uint16 connHandle )
+{
+ uint8 i;
+
+ // Find free RSSI structure
+ for ( i = 0; i < GAPCENTRALROLE_NUM_RSSI_LINKS; i++ )
+ {
+ if ( gapCentralRoleRssi[i].connHandle == GAP_CONNHANDLE_ALL )
+ {
+ gapCentralRoleRssi[i].connHandle = connHandle;
+ return &gapCentralRoleRssi[i];
+ }
+ }
+
+ // No free structure found
+ return NULL;
+}
+
+/*********************************************************************
+ * @fn gapCentralRole_RssiFind
+ *
+ * @brief Find an RSSI structure.
+ *
+ * @param connHandle - Connection handle
+ *
+ * @return pointer to structure or NULL if not found.
+ */
+static gapCentralRoleRssi_t *gapCentralRole_RssiFind( uint16 connHandle )
+{
+ uint8 i;
+
+ // Find free RSSI structure
+ for ( i = 0; i < GAPCENTRALROLE_NUM_RSSI_LINKS; i++ )
+ {
+ if ( gapCentralRoleRssi[i].connHandle == connHandle )
+ {
+ return &gapCentralRoleRssi[i];
+ }
+ }
+
+ // Not found
+ return NULL;
+}
+
+/*********************************************************************
+ * @fn gapCentralRole_RssiFree
+ *
+ * @brief Free an RSSI structure.
+ *
+ * @param connHandle - Connection handle
+ *
+ * @return none
+ */
+static void gapCentralRole_RssiFree( uint16 connHandle )
+{
+ uint8 i;
+
+ // Find RSSI structure
+ for ( i = 0; i < GAPCENTRALROLE_NUM_RSSI_LINKS; i++ )
+ {
+ if ( gapCentralRoleRssi[i].connHandle == connHandle )
+ {
+ gapCentralRoleRssi[i].connHandle = GAP_CONNHANDLE_ALL;
+ break;
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn gapCentralRole_timerCB
+ *
+ * @brief OSAL timer callback function
+ *
+ * @param pData - Data pointer
+ *
+ * @return none
+ */
+static void gapCentralRole_timerCB( uint8 *pData )
+{
+ gapCentralRoleRssiEvent_t *pMsg;
+
+ // Timer has expired so clear timer ID
+ ((gapCentralRoleRssi_t *) pData)->timerId = INVALID_TIMER_ID;
+
+ // Send OSAL message
+ pMsg = (gapCentralRoleRssiEvent_t *) osal_msg_allocate( sizeof(gapCentralRoleRssiEvent_t) );
+ if ( pMsg )
+ {
+ pMsg->hdr.event = GAPCENTRALROLE_RSSI_MSG_EVT;
+ pMsg->pRssi = (gapCentralRoleRssi_t *) pData;
+
+ osal_msg_send ( gapCentralRoleTaskId, (uint8 *) pMsg );
+ }
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/central.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/central.h
new file mode 100644
index 0000000..d7d4709
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/central.h
@@ -0,0 +1,308 @@
+/**
+ @headerfile: central.h
+ $Date: 2012-01-09 12:08:41 -0800 (Mon, 09 Jan 2012) $
+ $Revision: 28871 $
+
+ @mainpage TI BLE GAP Central Role
+
+ This GAP profile discovers and initiates connections.
+
+ Copyright 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*/
+
+#ifndef CENTRAL_H
+#define CENTRAL_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "gap.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/** @defgroup GAPCENTRALROLE_PROFILE_PARAMETERS GAP Central Role Parameters
+ * @{
+ */
+#define GAPCENTRALROLE_IRK 0x400 //!< Identity Resolving Key. Read/Write. Size is uint8[KEYLEN]. Default is all 0, which means that the IRK will be randomly generated.
+#define GAPCENTRALROLE_SRK 0x401 //!< Signature Resolving Key. Read/Write. Size is uint8[KEYLEN]. Default is all 0, which means that the SRK will be randomly generated.
+#define GAPCENTRALROLE_SIGNCOUNTER 0x402 //!< Sign Counter. Read/Write. Size is uint32. Default is 0.
+#define GAPCENTRALROLE_BD_ADDR 0x403 //!< Device's Address. Read Only. Size is uint8[B_ADDR_LEN]. This item is read from the controller.
+#define GAPCENTRALROLE_MAX_SCAN_RES 0x404 //!< Maximum number of discover scan results to receive. Default is 0 = unlimited.
+/** @} End GAPCENTRALROLE_PROFILE_PARAMETERS */
+
+/**
+ * Number of simultaneous links with periodic RSSI reads
+ */
+#ifndef GAPCENTRALROLE_NUM_RSSI_LINKS
+#define GAPCENTRALROLE_NUM_RSSI_LINKS 4
+#endif
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/**
+ * Central Event Structure
+ */
+typedef union
+{
+ gapEventHdr_t gap; //!< GAP_MSG_EVENT and status.
+ gapDeviceInitDoneEvent_t initDone; //!< GAP initialization done.
+ gapDeviceInfoEvent_t deviceInfo; //!< Discovery device information event structure.
+ gapDevDiscEvent_t discCmpl; //!< Discovery complete event structure.
+ gapEstLinkReqEvent_t linkCmpl; //!< Link complete event structure.
+ gapLinkUpdateEvent_t linkUpdate; //!< Link update event structure.
+ gapTerminateLinkEvent_t linkTerminate; //!< Link terminated event structure.
+} gapCentralRoleEvent_t;
+
+/**
+ * RSSI Read Callback Function
+ */
+typedef void (*pfnGapCentralRoleRssiCB_t)
+(
+ uint16 connHandle, //!< Connection handle.
+ int8 rssi //!< New RSSI value.
+);
+
+/**
+ * Central Event Callback Function
+ */
+typedef void (*pfnGapCentralRoleEventCB_t)
+(
+ gapCentralRoleEvent_t *pEvent //!< Pointer to event structure.
+);
+
+/**
+ * Central Callback Structure
+ */
+typedef struct
+{
+ pfnGapCentralRoleRssiCB_t rssiCB; //!< RSSI callback.
+ pfnGapCentralRoleEventCB_t eventCB; //!< Event callback.
+} gapCentralRoleCB_t;
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*-------------------------------------------------------------------
+ * Central Profile Public APIs
+ */
+
+/**
+ * @defgroup CENTRAL_PROFILE_API Central Profile API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Start the device in Central role. This function is typically
+ * called once during system startup.
+ *
+ * @param pAppCallbacks - pointer to application callbacks
+ *
+ * @return SUCCESS: Operation successful.
+ * bleAlreadyInRequestedMode: Device already started.
+ */
+extern bStatus_t GAPCentralRole_StartDevice( gapCentralRoleCB_t *pAppCallbacks );
+
+/**
+ * @brief Set a parameter in the Central Profile.
+ *
+ * @param param - profile parameter ID: @ref GAPCENTRALROLE_PROFILE_PARAMETERS
+ * @param len - length of data to write
+ * @param pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type.
+ *
+ * @return SUCCESS: Operation successful.
+ * INVALIDPARAMETER: Invalid parameter ID.
+ */
+extern bStatus_t GAPCentralRole_SetParameter( uint16 param, uint8 len, void *pValue );
+
+/**
+ * @brief Get a parameter in the Central Profile.
+ *
+ * @param param - profile parameter ID: @ref GAPCENTRALROLE_PROFILE_PARAMETERS
+ * @param pValue - pointer to buffer to contain the read data
+ *
+ * @return SUCCESS: Operation successful.
+ * INVALIDPARAMETER: Invalid parameter ID.
+ */
+extern bStatus_t GAPCentralRole_GetParameter( uint16 param, void *pValue );
+
+/**
+ * @brief Terminate a link.
+ *
+ * @param connHandle - connection handle of link to terminate
+ * or @ref GAP_CONN_HANDLE_DEFINES
+ *
+ * @return SUCCESS: Terminate started.
+ * bleIncorrectMode: No link to terminate.
+ */
+extern bStatus_t GAPCentralRole_TerminateLink( uint16 connHandle );
+
+/**
+ * @brief Establish a link to a peer device.
+ *
+ * @param highDutyCycle - TRUE to high duty cycle scan, FALSE if not
+ * @param whiteList - determines use of the white list: @ref GAP_WHITELIST_DEFINES
+ * @param addrTypePeer - address type of the peer device: @ref GAP_ADDR_TYPE_DEFINES
+ * @param peerAddr - peer device address
+ *
+ * @return SUCCESS: started establish link process.
+ * bleIncorrectMode: invalid profile role.
+ * bleNotReady: a scan is in progress.
+ * bleAlreadyInRequestedMode: can’t process now.
+ * bleNoResources: too many links.
+ */
+extern bStatus_t GAPCentralRole_EstablishLink( uint8 highDutyCycle, uint8 whiteList,
+ uint8 addrTypePeer, uint8 *peerAddr );
+
+/**
+ * @brief Update the link connection parameters.
+ *
+ * @param connHandle - connection handle
+ * @param connIntervalMin - minimum connection interval in 1.25ms units
+ * @param connIntervalMax - maximum connection interval in 1.25ms units
+ * @param connLatency - number of LL latency connection events
+ * @param connTimeout - connection timeout in 10ms units
+ *
+ * @return SUCCESS: Connection update started started.
+ * bleIncorrectMode: No connection to update.
+ */
+extern bStatus_t GAPCentralRole_UpdateLink( uint16 connHandle, uint16 connIntervalMin,
+ uint16 connIntervalMax, uint16 connLatency,
+ uint16 connTimeout );
+/**
+ * @brief Start a device discovery scan.
+ *
+ * @param mode - discovery mode: @ref GAP_DEVDISC_MODE_DEFINES
+ * @param activeScan - TRUE to perform active scan
+ * @param whiteList - TRUE to only scan for devices in the white list
+ *
+ * @return SUCCESS: Discovery scan started.
+ * bleIncorrectMode: Invalid profile role.
+ * bleAlreadyInRequestedMode: Not available.
+ */
+extern bStatus_t GAPCentralRole_StartDiscovery( uint8 mode, uint8 activeScan, uint8 whiteList );
+
+/**
+ * @brief Cancel a device discovery scan.
+ *
+ * @return SUCCESS: Cancel started.
+ * bleInvalidTaskID: Not the task that started discovery.
+ * bleIncorrectMode: Not in discovery mode.
+ */
+extern bStatus_t GAPCentralRole_CancelDiscovery( void );
+
+/**
+ * @brief Start periodic RSSI reads on a link.
+ *
+ * @param connHandle - connection handle of link
+ * @param period - RSSI read period in ms
+ *
+ * @return SUCCESS: Terminate started.
+ * bleIncorrectMode: No link.
+ * bleNoResources: No resources.
+ */
+extern bStatus_t GAPCentralRole_StartRssi( uint16 connHandle, uint16 period );
+
+/**
+ * @brief Cancel periodic RSSI reads on a link.
+ *
+ * @param connHandle - connection handle of link
+ *
+ * @return SUCCESS: Operation successful.
+ * bleIncorrectMode: No link.
+ */
+extern bStatus_t GAPCentralRole_CancelRssi(uint16 connHandle );
+
+/**
+ * @}
+ */
+
+/*-------------------------------------------------------------------
+ * TASK API - These functions must only be called by OSAL.
+ */
+
+/**
+ * @internal
+ *
+ * @brief Central Profile Task initialization function.
+ *
+ * @param taskId - Task ID.
+ *
+ * @return void
+ */
+extern void GAPCentralRole_Init( uint8 taskId );
+
+/**
+ * @internal
+ *
+ * @brief Central Profile Task event processing function.
+ *
+ * @param taskId - Task ID
+ * @param events - Events.
+ *
+ * @return events not processed
+ */
+extern uint16 GAPCentralRole_ProcessEvent( uint8 taskId, uint16 events );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CENTRAL_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gap.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gap.c
new file mode 100644
index 0000000..53f6e4d
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gap.c
@@ -0,0 +1,213 @@
+/*************************************************************************************************
+ Filename: gap.c
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: This file contains the GAP Configuration API.
+
+
+ Copyright 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#include "bcomdef.h"
+#include "gap.h"
+#include "sm.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+/*********************************************************************
+ * LOCAL FUNCTION PROTOTYPES
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*********************************************************************
+ * Called to setup the device. Call just once.
+ *
+ * Public function defined in gap.h.
+ */
+bStatus_t GAP_DeviceInit( uint8 taskID,
+ uint8 profileRole,
+ uint8 maxScanResponses,
+ uint8 *pIRK,
+ uint8 *pSRK,
+ uint32 *pSignCounter )
+{
+ bStatus_t stat = INVALIDPARAMETER; // Return status
+
+ // Valid profile roles and supported combinations
+ switch ( profileRole )
+ {
+ case GAP_PROFILE_BROADCASTER:
+ #if ( HOST_CONFIG & ( BROADCASTER_CFG | PERIPHERAL_CFG ) )
+ {
+ stat = SUCCESS;
+ }
+ #endif
+ break;
+
+ case GAP_PROFILE_OBSERVER:
+ #if ( HOST_CONFIG & ( OBSERVER_CFG | CENTRAL_CFG ) )
+ {
+ stat = SUCCESS;
+ }
+ #endif
+ break;
+
+ case GAP_PROFILE_PERIPHERAL:
+ #if ( HOST_CONFIG & PERIPHERAL_CFG )
+ {
+ stat = SUCCESS;
+ }
+ #endif
+ break;
+
+ case GAP_PROFILE_CENTRAL:
+ #if ( HOST_CONFIG & CENTRAL_CFG )
+ {
+ stat = SUCCESS;
+ }
+ #endif
+ break;
+
+ case (GAP_PROFILE_BROADCASTER | GAP_PROFILE_OBSERVER):
+ #if ( ( HOST_CONFIG & ( BROADCASTER_CFG | PERIPHERAL_CFG ) ) && \
+ ( HOST_CONFIG & ( OBSERVER_CFG | CENTRAL_CFG ) ) )
+ {
+ stat = SUCCESS;
+ }
+ #endif
+ break;
+
+ case (GAP_PROFILE_PERIPHERAL | GAP_PROFILE_OBSERVER):
+ #if ( ( HOST_CONFIG & PERIPHERAL_CFG ) && \
+ ( HOST_CONFIG & ( OBSERVER_CFG | CENTRAL_CFG ) ) )
+ {
+ stat = SUCCESS;
+ }
+ #endif
+ break;
+
+ case (GAP_PROFILE_CENTRAL | GAP_PROFILE_BROADCASTER):
+ #if ( ( HOST_CONFIG & CENTRAL_CFG ) && \
+ ( HOST_CONFIG & ( BROADCASTER_CFG | PERIPHERAL_CFG ) ) )
+ {
+ stat = SUCCESS;
+ }
+ #endif
+ break;
+
+ // Invalid profile roles
+ default:
+ stat = INVALIDPARAMETER;
+ break;
+ }
+
+ if ( stat == SUCCESS )
+ {
+ // Setup the device configuration parameters
+ stat = GAP_ParamsInit( taskID, profileRole );
+ if ( stat == SUCCESS )
+ {
+ #if ( HOST_CONFIG & ( CENTRAL_CFG | PERIPHERAL_CFG ) )
+ {
+ GAP_SecParamsInit( pIRK, pSRK, pSignCounter );
+ }
+ #endif
+
+ #if ( HOST_CONFIG & ( CENTRAL_CFG | OBSERVER_CFG ) )
+ {
+ if ( (profileRole == GAP_PROFILE_BROADCASTER) ||
+ (profileRole == GAP_PROFILE_PERIPHERAL) )
+ {
+ maxScanResponses = 0; // Can't scan, so no need for responses. Force 0.
+ }
+
+ // Initialize GAP Central Device Manager
+ VOID GAP_CentDevMgrInit( maxScanResponses );
+
+ #if ( HOST_CONFIG & CENTRAL_CFG )
+ {
+ // Register GAP Central Connection processing functions
+ GAP_CentConnRegister();
+
+ // Initialize SM Initiator
+ VOID SM_InitiatorInit();
+ }
+ #endif
+ }
+ #endif
+
+ #if ( HOST_CONFIG & ( PERIPHERAL_CFG | BROADCASTER_CFG ) )
+ {
+ // Initialize GAP Peripheral Device Manager
+ VOID GAP_PeriDevMgrInit();
+
+ #if ( HOST_CONFIG & PERIPHERAL_CFG )
+ {
+ // Initialize SM Responder
+ VOID SM_ResponderInit();
+ }
+ #endif
+ }
+ #endif
+ }
+ }
+
+ return ( stat );
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gapbondmgr.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gapbondmgr.c
new file mode 100644
index 0000000..75b456a
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gapbondmgr.c
@@ -0,0 +1,2057 @@
+/**************************************************************************************************
+ Filename: gapbondmgr.c
+ Revised: $Date: 2011-02-24 15:46:53 -0800 (Thu, 24 Feb 2011) $
+ Revision: $Revision: 10 $
+
+ Description: GAP peripheral profile manages bonded connections
+
+
+ Copyright 2011-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#if ( HOST_CONFIG & ( CENTRAL_CFG | PERIPHERAL_CFG ) )
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "osal_snv.h"
+#include "gap.h"
+#include "linkdb.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "hci.h"
+#include "gattservapp.h"
+#include "gapgattserver.h"
+#include "gapbondmgr.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+// Task event types
+#define GAP_BOND_SYNC_CC_EVT 0x0001 // Sync char config
+
+// Once NV usage reaches this percentage threshold, NV compaction gets triggered.
+#define NV_COMPACT_THRESHOLD 80
+
+// Bonded State Flags
+#define GAP_BONDED_STATE_AUTHENTICATED 0x0001
+#define GAP_BONDED_STATE_SERVICE_CHANGED 0x0002
+
+/**
+ * GAP Bond Manager NV layout
+ *
+ * The NV definitions:
+ * BLE_NVID_GAP_BOND_START - starting NV ID
+ * GAP_BONDINGS_MAX - Maximum number of bonding allowed (10 is max for number of NV IDs allocated in bcomdef.h).
+ *
+ * A single bonding entry consists of 6 components (NV items):
+ * Bond Record - defined as gapBondRec_t and uses GAP_BOND_REC_ID_OFFSET for an NV ID
+ * local LTK Info - defined as gapBondLTK_t and uses GAP_BOND_LOCAL_LTK_OFFSET for an NV ID
+ * device LTK Info - defined as gapBondLTK_t and uses GAP_BOND_DEV_LTK_OFFSET for an NV ID
+ * device IRK - defined as "uint8 devIRK[KEYLEN]" and uses GAP_BOND_DEV_IRK_OFFSET for an NV ID
+ * device CSRK - defined as "uint8 devCSRK[KEYLEN]" and uses GAP_BOND_DEV_CSRK_OFFSET for an NV ID
+ * device Sign Counter - defined as a uint32 and uses GAP_BOND_DEV_SIGN_COUNTER_OFFSET for an NV ID
+ *
+ * When the device is initialized for the first time, all (GAP_BONDINGS_MAX) NV items are created and
+ * initialized to all 0xFF's. A bonding record of all 0xFF's indicates that the bonding record is empty
+ * and free to use.
+ *
+ * The calculation for each bonding records NV IDs:
+ * mainRecordNvID = ((bondIdx * GAP_BOND_REC_IDS) + BLE_NVID_GAP_BOND_START)
+ * localLTKNvID = (((bondIdx * GAP_BOND_REC_IDS) + GAP_BOND_LOCAL_LTK_OFFSET) + BLE_NVID_GAP_BOND_START)
+ *
+ */
+#define GAP_BOND_REC_ID_OFFSET 0 //!< NV ID for the main bonding record
+#define GAP_BOND_LOCAL_LTK_OFFSET 1 //!< NV ID for the bonding record's local LTK information
+#define GAP_BOND_DEV_LTK_OFFSET 2 //!< NV ID for the bonding records' device LTK information
+#define GAP_BOND_DEV_IRK_OFFSET 3 //!< NV ID for the bonding records' device IRK
+#define GAP_BOND_DEV_CSRK_OFFSET 4 //!< NV ID for the bonding records' device CSRK
+#define GAP_BOND_DEV_SIGN_COUNTER_OFFSET 5 //!< NV ID for the bonding records' device Sign Counter
+
+#define GAP_BOND_REC_IDS 6
+
+// Macros to calculate the index/offset in to NV space
+#define calcNvID(Idx, offset) (((((Idx) * GAP_BOND_REC_IDS) + (offset))) + BLE_NVID_GAP_BOND_START)
+#define mainRecordNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_REC_ID_OFFSET))
+#define localLTKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_LOCAL_LTK_OFFSET))
+#define devLTKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_LTK_OFFSET))
+#define devIRKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_IRK_OFFSET))
+#define devCSRKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_CSRK_OFFSET))
+#define devSignCounterNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_SIGN_COUNTER_OFFSET))
+
+// Macros to calculate the GATT index/offset in to NV space
+#define gattCfgNvID(Idx) ((Idx) + BLE_NVID_GATT_CFG_START)
+
+// Key Size Limits
+#define MIN_ENC_KEYSIZE 7 //!< Minimum number of bytes for the encryption key
+#define MAX_ENC_KEYSIZE 16 //!< Maximum number of bytes for the encryption key
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Structure of NV data for the connected device's encryption information
+typedef struct
+{
+ uint8 LTK[KEYLEN]; // Long Term Key (LTK)
+ uint16 div; //lint -e754 // LTK eDiv
+ uint8 rand[B_RANDOM_NUM_SIZE]; // LTK random number
+ uint8 keySize; // LTK key size
+} gapBondLTK_t;
+
+// Structure of NV data for the connected device's address information
+typedef struct
+{
+ uint8 publicAddr[B_ADDR_LEN]; // Master's address
+ uint8 reconnectAddr[B_ADDR_LEN]; // Privacy Reconnection Address
+ uint16 stateFlags; // State flags: SM_AUTH_STATE_AUTHENTICATED & SM_AUTH_STATE_BONDING
+} gapBondRec_t;
+
+// Structure of NV data for the connected device's characteristic configuration
+typedef struct
+{
+ uint16 attrHandle; // attribute handle
+ uint8 value; // attribute value for this device
+} gapBondCharCfg_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+static uint8 gapBondMgr_TaskID; // Task ID for internal task/event processing
+
+// GAPBonding Parameters
+static uint8 gapBond_PairingMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
+static uint16 gapBond_InitiateWait = 1000; // Default to 1 second
+static uint8 gapBond_MITM = FALSE;
+static uint8 gapBond_IOCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
+static uint8 gapBond_OOBDataFlag = FALSE;
+static uint8 gapBond_OOBData[KEYLEN] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+static uint8 gapBond_Bonding = FALSE;
+static uint8 gapBond_AutoFail = FALSE;
+static uint8 gapBond_AutoFailReason = SMP_PAIRING_FAILED_NOT_SUPPORTED;
+static uint8 gapBond_KeyDistList =
+(
+ GAPBOND_KEYDIST_SENCKEY // sEncKey enabled, to send the encryption key
+ | GAPBOND_KEYDIST_SIDKEY // sIdKey enabled, to send the IRK, and BD_ADDR
+ | GAPBOND_KEYDIST_SSIGN // sSign enabled, to send the CSRK
+ | GAPBOND_KEYDIST_MENCKEY // mEncKey enabled, to get the master's encryption key
+ | GAPBOND_KEYDIST_MIDKEY // mIdKey enabled, to get the master's IRK and BD_ADDR
+ | GAPBOND_KEYDIST_MSIGN // mSign enabled, to get the master's CSRK
+);
+static uint32 gapBond_Passcode = 0;
+static uint8 gapBond_KeySize = MAX_ENC_KEYSIZE;
+
+#if ( HOST_CONFIG & CENTRAL_CFG )
+static uint8 gapBond_BondFailOption = GAPBOND_FAIL_TERMINATE_LINK;
+#endif
+
+static const gapBondCBs_t *pGapBondCB = NULL;
+
+// Local RAM shadowed bond records
+static gapBondRec_t bonds[GAP_BONDINGS_MAX] = {0};
+
+static uint8 autoSyncWhiteList = FALSE;
+
+static uint8 eraseAllBonds = FALSE;
+
+// Connection handle saved for Synch Char Config
+static uint16 connectionHandle;
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 gapBondMgrChangeState( uint8 idx, uint16 state, uint8 set );
+static uint8 gapBondMgrUpdateCharCfg( uint8 idx, uint16 attrHandle, uint16 value );
+static gapBondCharCfg_t *gapBondMgrFindCharCfgItem( uint16 attrHandle,
+ gapBondCharCfg_t *charCfgTbl );
+static void gapBondMgrInvertCharCfgItem( gapBondCharCfg_t *charCfgTbl );
+static uint8 gapBondMgrAddBond( gapBondRec_t *pBondRec,
+ gapBondLTK_t *pLocalLTK, gapBondLTK_t *pDevLTK,
+ uint8 *pIRK, uint8 *pSRK, uint32 signCounter );
+static uint8 gapBondMgrGetStateFlags( uint8 idx );
+static bStatus_t gapBondMgrGetPublicAddr( uint8 idx, uint8 *pAddr );
+static uint8 gapBondMgrFindReconnectAddr( uint8 *pReconnectAddr );
+static uint8 gapBondMgrFindAddr( uint8 *pDevAddr );
+static uint8 gapBondMgrResolvePrivateAddr( uint8 *pAddr );
+static void gapBondMgrReadBonds( void );
+static uint8 gapBondMgrFindEmpty( void );
+static uint8 gapBondMgrBondTotal( void );
+static bStatus_t gapBondMgrEraseAllBondings( void );
+static bStatus_t gapBondMgrEraseBonding( uint8 idx );
+static void gapBondMgr_ProcessOSALMsg( osal_event_hdr_t *pMsg );
+static void gapBondMgrSendServiceChange( linkDBItem_t *pLinkItem );
+static void gapBondMgr_ProcessGATTMsg( gattMsgEvent_t *pMsg );
+static void gapBondMgr_ProcessGATTServMsg( gattEventHdr_t *pMsg );
+static void gapBondSetupPrivFlag( void );
+static void gapBondMgrBondReq( uint16 connHandle, uint8 idx, uint8 stateFlags,
+ uint8 role, uint8 startEncryption );
+static void gapBondMgrAuthenticate( uint16 connHandle, uint8 addrType,
+ gapPairingReq_t *pPairReq );
+static void gapBondMgr_SyncWhiteList( void );
+static void gapBondMgr_SyncCharCfg( uint16 connHandle );
+
+#if ( HOST_CONFIG & PERIPHERAL_CFG )
+static void gapBondMgrSlaveSecurityReq( uint16 connHandle );
+#endif
+
+/*********************************************************************
+ * NETWORK LAYER CALLBACKS
+ */
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @brief Set a GAP Bond Manager parameter.
+ *
+ * Public function defined in gapbondmgr.h.
+ */
+bStatus_t GAPBondMgr_SetParameter( uint16 param, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS; // return value
+
+ switch ( param )
+ {
+ case GAPBOND_PAIRING_MODE:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAPBOND_PAIRING_MODE_INITIATE) )
+ {
+ gapBond_PairingMode = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_INITIATE_WAIT:
+ if ( len == sizeof ( uint16 ) )
+ {
+ gapBond_InitiateWait = *((uint16*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_MITM_PROTECTION:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )
+ {
+ gapBond_MITM = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_IO_CAPABILITIES:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAPBOND_IO_CAP_KEYBOARD_DISPLAY) )
+ {
+ gapBond_IOCap = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_OOB_ENABLED:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )
+ {
+ gapBond_OOBDataFlag = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_OOB_DATA:
+ if ( len == KEYLEN )
+ {
+ VOID osal_memcpy( gapBond_OOBData, pValue, KEYLEN ) ;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_BONDING_ENABLED:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )
+ {
+ gapBond_Bonding = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_KEY_DIST_LIST:
+ if ( len == sizeof ( uint8 ) )
+ {
+ gapBond_KeyDistList = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_DEFAULT_PASSCODE:
+ if ( (len == sizeof ( uint32 ))
+ && (*((uint32*)pValue) <= GAP_PASSCODE_MAX) )
+ {
+ gapBond_Passcode = *((uint32*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_ERASE_ALLBONDS:
+ if ( len == 0 )
+ {
+ // Make sure there's no active connection
+ if ( GAP_NumActiveConnections() == 0 )
+ {
+ // Erase all bonding records
+ VOID gapBondMgrEraseAllBondings();
+
+ // See if NV needs a compaction
+ VOID osal_snv_compact( NV_COMPACT_THRESHOLD );
+
+ // Make sure Bond RAM Shadow is up-to-date
+ gapBondMgrReadBonds();
+ }
+ else
+ {
+ eraseAllBonds = TRUE;
+ }
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_AUTO_FAIL_PAIRING:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )
+ {
+ gapBond_AutoFail = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_AUTO_FAIL_REASON:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= SMP_PAIRING_FAILED_REPEATED_ATTEMPTS) )
+ {
+ gapBond_AutoFailReason = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_KEYSIZE:
+ if ( (len == sizeof ( uint8 ))
+ && ((*((uint8*)pValue) >= MIN_ENC_KEYSIZE) && (*((uint8*)pValue) <= MAX_ENC_KEYSIZE)) )
+ {
+ gapBond_KeySize = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_AUTO_SYNC_WL:
+ if ( len == sizeof( uint8 ) )
+ {
+ uint8 oldVal = autoSyncWhiteList;
+
+ autoSyncWhiteList = *((uint8 *)pValue);
+
+ // only call if parameter changes from FALSE to TRUE
+ if ( ( oldVal == FALSE ) && ( autoSyncWhiteList == TRUE ) )
+ {
+ // make sure bond is updated from NV
+ gapBondMgrReadBonds();
+ }
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+#if ( HOST_CONFIG & CENTRAL_CFG )
+ case GAPBOND_BOND_FAIL_ACTION:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAPBOND_FAIL_TERMINATE_ERASE_BONDS) )
+ {
+ gapBond_BondFailOption = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+#endif
+
+ default:
+ // The param value isn't part of this profile, try the GAP.
+ if ( (param < TGAP_PARAMID_MAX) && (len == sizeof ( uint16 )) )
+ {
+ ret = GAP_SetParamValue( param, *((uint16*)pValue) );
+ }
+ else
+ {
+ ret = INVALIDPARAMETER;
+ }
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Get a GAP Bond Manager parameter.
+ *
+ * Public function defined in gapbondmgr.h.
+ */
+bStatus_t GAPBondMgr_GetParameter( uint16 param, void *pValue )
+{
+ bStatus_t ret = SUCCESS; // return value
+
+ switch ( param )
+ {
+ case GAPBOND_PAIRING_MODE:
+ *((uint8*)pValue) = gapBond_PairingMode;
+ break;
+
+ case GAPBOND_INITIATE_WAIT:
+ *((uint16*)pValue) = gapBond_InitiateWait;
+ break;
+
+ case GAPBOND_MITM_PROTECTION:
+ *((uint8*)pValue) = gapBond_MITM;
+ break;
+
+ case GAPBOND_IO_CAPABILITIES:
+ *((uint8*)pValue) = gapBond_IOCap;
+ break;
+
+ case GAPBOND_OOB_ENABLED:
+ *((uint8*)pValue) = gapBond_OOBDataFlag;
+ break;
+
+ case GAPBOND_OOB_DATA:
+ VOID osal_memcpy( pValue, gapBond_OOBData, KEYLEN ) ;
+ break;
+
+ case GAPBOND_BONDING_ENABLED:
+ *((uint8*)pValue) = gapBond_Bonding;
+ break;
+
+ case GAPBOND_KEY_DIST_LIST:
+ *((uint8*)pValue) = gapBond_KeyDistList;
+ break;
+
+ case GAPBOND_DEFAULT_PASSCODE:
+ *((uint32*)pValue) = gapBond_Passcode;
+ break;
+
+ case GAPBOND_AUTO_FAIL_PAIRING:
+ *((uint8*)pValue) = gapBond_AutoFail;
+ break;
+
+ case GAPBOND_AUTO_FAIL_REASON:
+ *((uint8*)pValue) = gapBond_AutoFailReason;
+ break;
+
+ case GAPBOND_KEYSIZE:
+ *((uint8*)pValue) = gapBond_KeySize;
+ break;
+
+ case GAPBOND_AUTO_SYNC_WL:
+ *((uint8*)pValue) = autoSyncWhiteList;
+ break;
+
+ case GAPBOND_BOND_COUNT:
+ *((uint8*)pValue) = gapBondMgrBondTotal();
+ break;
+
+ default:
+ // The param value isn't part of this profile, try the GAP.
+ if ( param < TGAP_PARAMID_MAX )
+ {
+ *((uint16*)pValue) = GAP_GetParamValue( param );
+ }
+ else
+ {
+ ret = INVALIDPARAMETER;
+ }
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Notify the Bond Manager that a connection has been made.
+ *
+ * Public function defined in gapbondmgr.h.
+ */
+bStatus_t GAPBondMgr_LinkEst( uint8 addrType, uint8 *pDevAddr, uint16 connHandle, uint8 role )
+{
+ uint8 idx; // NV Index
+ uint8 publicAddr[B_ADDR_LEN] // Place to put the public address
+ = {0, 0, 0, 0, 0, 0};
+
+ idx = GAPBondMgr_ResolveAddr( addrType, pDevAddr, publicAddr );
+ if ( idx < GAP_BONDINGS_MAX )
+ {
+ uint8 stateFlags = gapBondMgrGetStateFlags( idx );
+ smSigningInfo_t signingInfo;
+ gapBondCharCfg_t charCfg[GAP_CHAR_CFG_MAX]; // Space to read a char cfg record from NV
+
+ // On peripheral, load the key information for the bonding
+ // On central and initiaiting security, load key to initiate encyption
+ gapBondMgrBondReq( connHandle, idx, stateFlags, role,
+ ((gapBond_PairingMode == GAPBOND_PAIRING_MODE_INITIATE ) ? TRUE : FALSE) );
+
+ // Load the Signing Key
+ VOID osal_memset( &signingInfo, 0, sizeof ( smSigningInfo_t ) );
+ if ( osal_snv_read( devCSRKNvID(idx), KEYLEN, signingInfo.srk ) == SUCCESS )
+ {
+ if ( osal_isbufset( signingInfo.srk, 0xFF, KEYLEN ) == FALSE )
+ {
+ // Load the signing information for this connection
+ VOID osal_snv_read( devSignCounterNvID(idx), sizeof ( uint32 ), &(signingInfo.signCounter) );
+ VOID GAP_Signable( connHandle,
+ ((stateFlags & GAP_BONDED_STATE_AUTHENTICATED) ? TRUE : FALSE),
+ &signingInfo );
+ }
+ }
+
+ // Load the characteristic configuration
+ if ( osal_snv_read( gattCfgNvID(idx), sizeof ( charCfg ), charCfg ) == SUCCESS )
+ {
+ gapBondMgrInvertCharCfgItem( charCfg );
+
+ for ( uint8 i = 0; i < GAP_CHAR_CFG_MAX; i++ )
+ {
+ gapBondCharCfg_t *pItem = &(charCfg[i]);
+
+ // Apply the characteristic configuration for this connection
+ if ( pItem->attrHandle != GATT_INVALID_HANDLE )
+ {
+ VOID GATTServApp_UpdateCharCfg( connHandle, pItem->attrHandle,
+ (uint16)(pItem->value) );
+ }
+ }
+ }
+
+ // Has there been a service change?
+ if ( stateFlags & GAP_BONDED_STATE_SERVICE_CHANGED )
+ {
+ VOID GATTServApp_SendServiceChangedInd( connHandle, gapBondMgr_TaskID );
+ }
+ }
+#if ( HOST_CONFIG & CENTRAL_CFG )
+ else if ( role == GAP_PROFILE_CENTRAL &&
+ gapBond_PairingMode == GAPBOND_PAIRING_MODE_INITIATE )
+ {
+ // If Central and initiating and not bonded, then initiate pairing
+ gapBondMgrAuthenticate( connHandle, addrType, NULL );
+
+ // Call app state callback
+ if ( pGapBondCB && pGapBondCB->pairStateCB )
+ {
+ pGapBondCB->pairStateCB( connHandle, GAPBOND_PAIRING_STATE_STARTED, SUCCESS );
+ }
+ }
+#endif
+
+#if ( HOST_CONFIG & PERIPHERAL_CFG )
+ // If Peripheral and initiating, send a slave security request to
+ // initiate either pairing or encryption
+ if ( role == GAP_PROFILE_PERIPHERAL &&
+ gapBond_PairingMode == GAPBOND_PAIRING_MODE_INITIATE )
+ {
+ gapBondMgrSlaveSecurityReq( connHandle );
+ }
+#endif
+
+ return ( SUCCESS );
+}
+
+/*********************************************************************
+ * @brief Resolve an address from bonding information.
+ *
+ * Public function defined in gapbondmgr.h.
+ */
+uint8 GAPBondMgr_ResolveAddr( uint8 addrType, uint8 *pDevAddr, uint8 *pResolvedAddr )
+{
+ uint8 idx = GAP_BONDINGS_MAX;
+
+ switch ( addrType )
+ {
+ case ADDRTYPE_PUBLIC:
+ case ADDRTYPE_STATIC:
+ idx = gapBondMgrFindAddr( pDevAddr );
+ if ( (idx < GAP_BONDINGS_MAX) && (pResolvedAddr) )
+ {
+ VOID osal_memcpy( pResolvedAddr, pDevAddr, B_ADDR_LEN );
+ }
+ break;
+
+ case ADDRTYPE_PRIVATE_NONRESOLVE:
+ // This could be a reconnection address
+ idx = gapBondMgrFindReconnectAddr( pDevAddr );
+ if ( (idx < GAP_BONDINGS_MAX) && (pResolvedAddr) )
+ {
+ VOID gapBondMgrGetPublicAddr( idx, pResolvedAddr );
+ }
+ break;
+
+ case ADDRTYPE_PRIVATE_RESOLVE:
+ // Master's don't use Private Resolvable addresses but just in case
+ idx = gapBondMgrResolvePrivateAddr( pDevAddr );
+ if ( (idx < GAP_BONDINGS_MAX) && (pResolvedAddr) )
+ {
+ VOID gapBondMgrGetPublicAddr( idx, pResolvedAddr );
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return ( idx );
+}
+
+/*********************************************************************
+ * @brief Set/clear the service change indication in a bond record.
+ *
+ * Public function defined in gapbondmgr.h.
+ */
+bStatus_t GAPBondMgr_ServiceChangeInd( uint16 connectionHandle, uint8 setParam )
+{
+ bStatus_t ret = bleNoResources; // return value
+
+ if ( connectionHandle == 0xFFFF )
+ {
+ uint8 idx; // loop counter
+
+ // Run through the bond database and update the Service Change indication
+ for ( idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ if ( gapBondMgrChangeState( idx, GAP_BONDED_STATE_SERVICE_CHANGED, setParam ) )
+ {
+ ret = SUCCESS;
+ }
+ }
+
+ // If the service change indication is TRUE, tell the connected devices
+ if ( setParam )
+ {
+ // Run connected database
+ linkDB_PerformFunc( gapBondMgrSendServiceChange );
+ }
+ }
+ else
+ {
+ // Find connection information
+ linkDBItem_t *pLinkItem = linkDB_Find( connectionHandle );
+ if ( pLinkItem )
+ {
+ uint8 idx; // loop counter
+ idx = GAPBondMgr_ResolveAddr( pLinkItem->addrType, pLinkItem->addr, NULL );
+ if ( idx < GAP_BONDINGS_MAX )
+ {
+ // Bond found, update it.
+ VOID gapBondMgrChangeState( idx, GAP_BONDED_STATE_SERVICE_CHANGED, setParam );
+ ret = SUCCESS;
+ }
+
+ // If the service change indication is TRUE, tell the connected device
+ if ( setParam )
+ {
+ gapBondMgrSendServiceChange( pLinkItem );
+ }
+ }
+ else
+ {
+ ret = bleNotConnected;
+ }
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Update the Characteristic Configuration in a bond record.
+ *
+ * Public function defined in gapbondmgr.h.
+ */
+bStatus_t GAPBondMgr_UpdateCharCfg( uint16 connectionHandle, uint16 attrHandle, uint16 value )
+{
+ bStatus_t ret = bleNoResources; // return value
+
+ if ( connectionHandle == INVALID_CONNHANDLE )
+ {
+ uint8 idx; // loop counter
+
+ // Run through the bond database and update the Characteristic Configuration
+ for ( idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ if ( gapBondMgrUpdateCharCfg( idx, attrHandle, value ) )
+ {
+ ret = SUCCESS;
+ }
+ }
+ }
+ else
+ {
+ // Find connection information
+ linkDBItem_t *pLinkItem = linkDB_Find( connectionHandle );
+ if ( pLinkItem )
+ {
+ uint8 idx = GAPBondMgr_ResolveAddr( pLinkItem->addrType, pLinkItem->addr, NULL );
+ if ( idx < GAP_BONDINGS_MAX )
+ {
+ // Bond found, update it.
+ VOID gapBondMgrUpdateCharCfg( idx, attrHandle, value );
+ ret = SUCCESS;
+ }
+ }
+ else
+ {
+ ret = bleNotConnected;
+ }
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Register callback functions with the bond manager.
+ *
+ * Public function defined in gapbondmgr.h.
+ */
+void GAPBondMgr_Register( gapBondCBs_t *pCB )
+{
+ pGapBondCB = pCB;
+
+ // Take over the processing of Authentication messages
+ VOID GAP_SetParamValue( TGAP_AUTH_TASK_ID, gapBondMgr_TaskID );
+
+ // Register with GATT Server App for event messages
+ GATTServApp_RegisterForMsg( gapBondMgr_TaskID );
+}
+
+/*********************************************************************
+ * @brief Respond to a passcode request.
+ *
+ * Public function defined in gapbondmgr.h.
+ */
+bStatus_t GAPBondMgr_PasscodeRsp( uint16 connectionHandle, uint8 status, uint32 passcode )
+{
+ bStatus_t ret = SUCCESS;
+
+ if ( status == SUCCESS )
+ {
+ // Truncate the passcode
+ passcode = passcode % (GAP_PASSCODE_MAX + 1);
+
+ ret = GAP_PasscodeUpdate( passcode, connectionHandle );
+ if ( ret != SUCCESS )
+ {
+ VOID GAP_TerminateAuth( connectionHandle, SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED );
+ }
+ }
+ else
+ {
+ VOID GAP_TerminateAuth( connectionHandle, status );
+ }
+
+ return ret;
+}
+
+/*********************************************************************
+ * @brief This is a bypass mechanism to allow the bond manager to process
+ * GAP messages.
+ *
+ * Public function defined in gapbondmgr.h.
+ */
+void GAPBondMgr_ProcessGAPMsg( gapEventHdr_t *pMsg )
+{
+ switch ( pMsg->opcode )
+ {
+ case GAP_PASSKEY_NEEDED_EVENT:
+ {
+ gapPasskeyNeededEvent_t *pPkt = (gapPasskeyNeededEvent_t *)pMsg;
+
+ if ( pGapBondCB && pGapBondCB->passcodeCB )
+ {
+ // Ask app for a passcode
+ pGapBondCB->passcodeCB( pPkt->deviceAddr, pPkt->connectionHandle, pPkt->uiInputs, pPkt->uiOutputs );
+ }
+ else
+ {
+ // No app support, use the default passcode
+ if ( GAP_PasscodeUpdate( gapBond_Passcode, pPkt->connectionHandle ) != SUCCESS )
+ {
+ VOID GAP_TerminateAuth( pPkt->connectionHandle, SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED );
+ }
+ }
+ }
+ break;
+
+ case GAP_AUTHENTICATION_COMPLETE_EVENT:
+ {
+ gapAuthCompleteEvent_t *pPkt = (gapAuthCompleteEvent_t *)pMsg;
+
+ // Should we save bonding information
+ if ( (pPkt->hdr.status == SUCCESS) && (pPkt->authState & SM_AUTH_STATE_BONDING) )
+ {
+ gapBondRec_t bondRec;
+
+ VOID osal_memset( &bondRec, 0, sizeof ( gapBondRec_t ) ) ;
+
+ // Do we have a public address in the data?
+ if ( pPkt->pIdentityInfo )
+ {
+ VOID osal_memcpy( bondRec.publicAddr, pPkt->pIdentityInfo->bd_addr, B_ADDR_LEN );
+ }
+ else
+ {
+ linkDBItem_t *pLinkItem = linkDB_Find( pPkt->connectionHandle );
+ if ( pLinkItem )
+ {
+ VOID osal_memcpy( bondRec.publicAddr, pLinkItem->addr, B_ADDR_LEN );
+ }
+ else
+ {
+ // We don't have an address, so ignore the message.
+ break;
+ }
+ }
+
+ // Save off of the authentication state
+ bondRec.stateFlags |= (pPkt->authState & SM_AUTH_STATE_AUTHENTICATED) ? GAP_BONDED_STATE_AUTHENTICATED : 0;
+
+ VOID gapBondMgrAddBond( &bondRec,
+ (gapBondLTK_t *)pPkt->pSecurityInfo,
+ (gapBondLTK_t *)pPkt->pDevSecInfo,
+ ((uint8 *)((pPkt->pIdentityInfo) ? pPkt->pIdentityInfo->irk : NULL )),
+ ((uint8 *)((pPkt->pSigningInfo) ? pPkt->pSigningInfo->srk : NULL )),
+ ((uint32)((pPkt->pSigningInfo) ? pPkt->pSigningInfo->signCounter : GAP_INIT_SIGN_COUNTER )) );
+
+ // Notify our task to update NV with CCC values stored in GATT database
+ connectionHandle = pPkt->connectionHandle;
+ osal_set_event( gapBondMgr_TaskID, GAP_BOND_SYNC_CC_EVT );
+ }
+
+ // Call app state callback
+ if ( pGapBondCB && pGapBondCB->pairStateCB )
+ {
+ pGapBondCB->pairStateCB( pPkt->connectionHandle, GAPBOND_PAIRING_STATE_COMPLETE, pPkt->hdr.status );
+ }
+ }
+ break;
+
+ case GAP_BOND_COMPLETE_EVENT:
+ // This message is received when the bonding is complete. If hdr.status is SUCCESS
+ // then call app state callback. If hdr.status is NOT SUCCESS, the connection will be
+ // dropped at the LL because of a MIC failure, so again nothing to do.
+ {
+ gapBondCompleteEvent_t *pPkt = (gapBondCompleteEvent_t *)pMsg;
+
+#if ( HOST_CONFIG & CENTRAL_CFG )
+ if ( pPkt->hdr.status == LL_ENC_KEY_REQ_REJECTED )
+ {
+ // LTK not found on peripheral device (Pin or Key Missing). See which
+ // option was configured for unsuccessful bonding.
+ linkDBItem_t *pLinkItem = linkDB_Find( pPkt->connectionHandle );
+ if ( pLinkItem )
+ {
+ switch ( gapBond_BondFailOption )
+ {
+ case GAPBOND_FAIL_INITIATE_PAIRING:
+ // Initiate pairing
+ gapBondMgrAuthenticate( pPkt->connectionHandle, pLinkItem->addrType, NULL );
+ break;
+
+ case GAPBOND_FAIL_TERMINATE_LINK:
+ // Drop connection
+ GAP_TerminateLinkReq( pLinkItem->taskID, pPkt->connectionHandle );
+ break;
+
+ case GAPBOND_FAIL_TERMINATE_ERASE_BONDS:
+ // Set up bond manager to erase all existing bonds after connection terminates
+ VOID GAPBondMgr_SetParameter( GAPBOND_ERASE_ALLBONDS, 0, NULL );
+
+ // Drop connection
+ GAP_TerminateLinkReq( pLinkItem->taskID, pPkt->connectionHandle );
+ break;
+
+ case GAPBOND_FAIL_NO_ACTION:
+ // fall through
+ default:
+ // do nothing
+ break;
+ }
+ }
+ }
+#endif
+ if ( pGapBondCB && pGapBondCB->pairStateCB )
+ {
+ pGapBondCB->pairStateCB( pPkt->connectionHandle, GAPBOND_PAIRING_STATE_BONDED, pMsg->hdr.status );
+ }
+ }
+ break;
+
+ case GAP_SIGNATURE_UPDATED_EVENT:
+ {
+ uint8 idx;
+ gapSignUpdateEvent_t *pPkt = (gapSignUpdateEvent_t *)pMsg;
+
+ idx = GAPBondMgr_ResolveAddr( pPkt->addrType, pPkt->devAddr, NULL );
+ if ( idx < GAP_BONDINGS_MAX )
+ {
+ // Save the sign counter
+ VOID osal_snv_write( devSignCounterNvID(idx), sizeof ( uint32 ), &(pPkt->signCounter) );
+ }
+ }
+ break;
+
+#if ( HOST_CONFIG & PERIPHERAL_CFG )
+ case GAP_PAIRING_REQ_EVENT:
+ {
+ gapPairingReqEvent_t *pPkt = (gapPairingReqEvent_t *)pMsg;
+
+ if ( gapBond_AutoFail != FALSE )
+ {
+ // Auto Fail TEST MODE (DON'T USE THIS) - Sends pre-setup reason
+ VOID GAP_TerminateAuth( pPkt->connectionHandle, gapBond_AutoFailReason );
+ }
+ else if ( gapBond_PairingMode == GAPBOND_PAIRING_MODE_NO_PAIRING )
+ {
+ // No Pairing - Send error
+ VOID GAP_TerminateAuth( pPkt->connectionHandle, SMP_PAIRING_FAILED_NOT_SUPPORTED );
+ }
+ else
+ {
+ linkDBItem_t *pLinkItem = linkDB_Find( pPkt->connectionHandle );
+
+ // Requesting bonding?
+ if ( pPkt->pairReq.authReq & SM_AUTH_STATE_BONDING )
+ {
+ if ( pLinkItem )
+ {
+ if ( (pLinkItem->addrType != ADDRTYPE_PUBLIC) && (pPkt->pairReq.keyDist.mIdKey == FALSE) )
+ {
+ uint8 publicAddr[B_ADDR_LEN];
+
+ // Check if we already have the public address in NV
+ if ( GAPBondMgr_ResolveAddr(pLinkItem->addrType, pLinkItem->addr, publicAddr ) == FALSE )
+ {
+ // Can't bond to a non-public address if we don't know the public address
+ VOID GAP_TerminateAuth( pPkt->connectionHandle, SMP_PAIRING_FAILED_AUTH_REQ );
+ break;
+ }
+ }
+ }
+ else
+ {
+ // Can't find the connection, ignore the message
+ break;
+ }
+ }
+
+ // Send pairing response
+ gapBondMgrAuthenticate( pPkt->connectionHandle, pLinkItem->addrType, &(pPkt->pairReq) );
+
+ // Call app state callback
+ if ( pGapBondCB && pGapBondCB->pairStateCB )
+ {
+ pGapBondCB->pairStateCB( pPkt->connectionHandle, GAPBOND_PAIRING_STATE_STARTED, SUCCESS );
+ }
+ }
+ }
+ break;
+#endif
+
+#if ( HOST_CONFIG & CENTRAL_CFG )
+ case GAP_SLAVE_REQUESTED_SECURITY_EVENT:
+ {
+ uint16 connHandle = ((gapSlaveSecurityReqEvent_t *)pMsg)->connectionHandle;
+ uint8 idx;
+ uint8 publicAddr[B_ADDR_LEN] = {0, 0, 0, 0, 0, 0};
+ linkDBItem_t *pLink = linkDB_Find( connHandle );
+
+ // If link found and not already initiating security
+ if (pLink != NULL && gapBond_PairingMode != GAPBOND_PAIRING_MODE_INITIATE)
+ {
+ // If already bonded initiate encryption
+ idx = GAPBondMgr_ResolveAddr( pLink->addrType, pLink->addr, publicAddr );
+ if ( idx < GAP_BONDINGS_MAX )
+ {
+ gapBondMgrBondReq( connHandle, idx, gapBondMgrGetStateFlags( idx ),
+ GAP_PROFILE_CENTRAL, TRUE );
+ }
+ // Else if no pairing allowed
+ else if ( gapBond_PairingMode == GAPBOND_PAIRING_MODE_NO_PAIRING )
+ {
+ // Send error
+ VOID GAP_TerminateAuth( connHandle, SMP_PAIRING_FAILED_NOT_SUPPORTED );
+ }
+ // Else if waiting for request
+ else if (gapBond_PairingMode == GAPBOND_PAIRING_MODE_WAIT_FOR_REQ)
+ {
+ // Initiate pairing
+ gapBondMgrAuthenticate( connHandle, pLink->addrType, NULL );
+ }
+ }
+ }
+ break;
+#endif
+
+ case GAP_LINK_TERMINATED_EVENT:
+ if ( GAP_NumActiveConnections() == 0 )
+ {
+ // See if we're asked to erase all bonding records
+ if ( eraseAllBonds == TRUE )
+ {
+ VOID gapBondMgrEraseAllBondings();
+ eraseAllBonds = FALSE;
+ }
+
+ // See if NV needs a compaction
+ VOID osal_snv_compact( NV_COMPACT_THRESHOLD );
+
+ // Make sure Bond RAM Shadow is up-to-date
+ gapBondMgrReadBonds();
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*********************************************************************
+ * LOCAL FUNCTION PROTOTYPES
+ */
+
+/*********************************************************************
+ * @fn gapBondMgrChangeState
+ *
+ * @brief Change a state flag in the stateFlags field of the bond record.
+ *
+ * @param idx - Bond NV index
+ * @param state - state flage to set or clear
+ * @param set - TRUE to set the flag, FALSE to clear the flag
+ *
+ * @return TRUE if NV Record exists, FALSE if NV Record is empty
+ */
+static uint8 gapBondMgrChangeState( uint8 idx, uint16 state, uint8 set )
+{
+ gapBondRec_t bondRec; // Space to read a Bond record from NV
+
+ // Look for public address that is used (not all 0xFF's)
+ if ( (osal_snv_read( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec ) == SUCCESS)
+ && (osal_isbufset( bondRec.publicAddr, 0xFF, B_ADDR_LEN ) == FALSE) )
+ {
+ // Update the state of the bonded device.
+ uint8 stateFlags = bondRec.stateFlags;
+ if ( set )
+ {
+ stateFlags |= state;
+ }
+ else
+ {
+ stateFlags &= ~(state);
+ }
+
+ if ( stateFlags != bondRec.stateFlags )
+ {
+ bondRec.stateFlags = stateFlags;
+ VOID osal_snv_write( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec );
+ }
+ return ( TRUE );
+ }
+ return ( FALSE );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrUpdateCharCfg
+ *
+ * @brief Update the Characteristic Configuration of the bond record.
+ *
+ * @param idx - Bond NV index
+ * @param attrHandle - attribute handle (0 means all handles)
+ * @param value - characteristic configuration value
+ *
+ * @return TRUE if NV Record exists, FALSE if NV Record is empty
+ */
+static uint8 gapBondMgrUpdateCharCfg( uint8 idx, uint16 attrHandle, uint16 value )
+{
+ gapBondRec_t bondRec; // Space to read a Bond record from NV
+
+ // Look for public address that is used (not all 0xFF's)
+ if ( ( osal_snv_read( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec ) == SUCCESS )
+ && ( osal_isbufset( bondRec.publicAddr, 0xFF, B_ADDR_LEN ) == FALSE ) )
+ {
+ gapBondCharCfg_t charCfg[GAP_CHAR_CFG_MAX]; // Space to read a char cfg record from NV
+
+ if ( osal_snv_read( gattCfgNvID(idx), sizeof ( charCfg ), charCfg ) == SUCCESS )
+ {
+ uint8 update = FALSE;
+
+ gapBondMgrInvertCharCfgItem( charCfg );
+
+ if ( attrHandle == GATT_INVALID_HANDLE )
+ {
+ if ( osal_isbufset( (uint8 *)charCfg, 0x00, sizeof ( charCfg ) ) == FALSE )
+ {
+ // Clear all characteristic configuration for this device
+ VOID osal_memset( (void *)charCfg, 0x00, sizeof ( charCfg ) );
+ update = TRUE;
+ }
+ }
+ else
+ {
+ gapBondCharCfg_t *pItem = gapBondMgrFindCharCfgItem( attrHandle, charCfg );
+ if ( pItem == NULL )
+ {
+ // Must be a new item; ignore if the value is no operation (default)
+ if ( ( value == GATT_CFG_NO_OPERATION ) ||
+ ( ( pItem = gapBondMgrFindCharCfgItem( GATT_INVALID_HANDLE, charCfg ) ) == NULL ) )
+ {
+ return ( FALSE ); // No empty entry found
+ }
+
+ pItem->attrHandle = attrHandle;
+ }
+
+ if ( pItem->value != value )
+ {
+ // Update characteristic configuration
+ pItem->value = (uint8)value;
+ if ( value == GATT_CFG_NO_OPERATION )
+ {
+ // Erease the item
+ pItem->attrHandle = GATT_INVALID_HANDLE;
+ }
+
+ update = TRUE;
+ }
+ }
+
+ // Update the characteristic configuration of the bonded device.
+ if ( update )
+ {
+ gapBondMgrInvertCharCfgItem( charCfg );
+ VOID osal_snv_write( gattCfgNvID(idx), sizeof( charCfg ), charCfg );
+ }
+ }
+
+ return ( TRUE );
+ }
+
+ return ( FALSE );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrFindCharCfgItem
+ *
+ * @brief Find the Characteristic Configuration for a given attribute.
+ * Uses the attribute handle to search the charactersitic
+ * configuration table of a bonded device.
+ *
+ * @param attrHandle - attribute handle.
+ * @param charCfgTbl - characteristic configuration table.
+ *
+ * @return pointer to the found item. NULL, otherwise.
+ */
+static gapBondCharCfg_t *gapBondMgrFindCharCfgItem( uint16 attrHandle,
+ gapBondCharCfg_t *charCfgTbl )
+{
+ for ( uint8 i = 0; i < GAP_CHAR_CFG_MAX; i++ )
+ {
+ if ( charCfgTbl[i].attrHandle == attrHandle )
+ {
+ return ( &(charCfgTbl[i]) );
+ }
+ }
+
+ return ( (gapBondCharCfg_t *)NULL );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrFindCharCfgItem
+ *
+ * @brief Invert the Characteristic Configuration for a given client.
+ *
+ * @param charCfgTbl - characteristic configuration table.
+ *
+ * @return none.
+ */
+static void gapBondMgrInvertCharCfgItem( gapBondCharCfg_t *charCfgTbl )
+{
+ for ( uint8 i = 0; i < GAP_CHAR_CFG_MAX; i++ )
+ {
+ charCfgTbl[i].attrHandle = ~(charCfgTbl[i].attrHandle);
+ charCfgTbl[i].value = ~(charCfgTbl[i].value);
+ }
+}
+
+/*********************************************************************
+ * @fn gapBondMgrAddBond
+ *
+ * @brief Save a bond from a GAP Auth Complete Event
+ *
+ * @param pBondRec - basic bond record
+ * @param pLocalLTK - LTK used by this device during pairing
+ * @param pDevLTK - LTK used by the connected device during pairing
+ * @param pIRK - IRK used by the connected device during pairing
+ * @param pSRK - SRK used by the connected device during pairing
+ * @param signCounter - Sign counter used by the connected device during pairing
+ *
+ * @return bond index
+ */
+static uint8 gapBondMgrAddBond( gapBondRec_t *pBondRec,
+ gapBondLTK_t *pLocalLTK, gapBondLTK_t *pDevLTK,
+ uint8 *pIRK, uint8 *pSRK, uint32 signCounter )
+{
+ uint8 idx;
+
+ if ( pBondRec == NULL )
+ {
+ return ( GAP_BONDINGS_MAX );
+ }
+
+ // First see if we already have an existing bond for this device
+ idx = gapBondMgrFindAddr( pBondRec->publicAddr );
+ if ( idx >= GAP_BONDINGS_MAX )
+ {
+ idx = gapBondMgrFindEmpty();
+ }
+
+ if ( idx < GAP_BONDINGS_MAX )
+ {
+ gapBondCharCfg_t charCfg[GAP_CHAR_CFG_MAX];
+
+ // Save the main information
+ VOID osal_snv_write( mainRecordNvID(idx), sizeof ( gapBondRec_t ), pBondRec );
+
+ // If available, save the LTK information
+ if ( pLocalLTK )
+ {
+ VOID osal_snv_write( localLTKNvID(idx), sizeof ( gapBondLTK_t ), pLocalLTK );
+ }
+
+ // If availabe, save the connected device's LTK information
+ if ( pDevLTK )
+ {
+ VOID osal_snv_write( devLTKNvID(idx), sizeof ( gapBondLTK_t ), pDevLTK );
+ }
+
+ // If available, save the connected device's IRK
+ if ( pIRK )
+ {
+ VOID osal_snv_write( devIRKNvID(idx), KEYLEN, pIRK );
+ }
+
+ // If available, save the connected device's Signature information
+ if ( pSRK )
+ {
+ VOID osal_snv_write( devCSRKNvID(idx), KEYLEN, pSRK );
+ VOID osal_snv_write( devSignCounterNvID(idx), sizeof ( uint32 ), &signCounter );
+ }
+
+ // Write out FF's over the charactersitic configuration entry, to overwrite
+ // any previous bond data that may have been stored
+ VOID osal_memset( charCfg, 0xFF, sizeof ( charCfg ) );
+
+ VOID osal_snv_write( gattCfgNvID(idx), sizeof ( charCfg ), charCfg );
+
+ // Update Bond RAM Shadow just with the newly added bond entry
+ VOID osal_memcpy( &(bonds[idx]), pBondRec, sizeof ( gapBondRec_t ) );
+
+ if ( autoSyncWhiteList )
+ {
+ gapBondMgr_SyncWhiteList();
+ }
+
+ // Update the GAP Privacy Flag Properties
+ gapBondSetupPrivFlag();
+ }
+
+ return ( idx );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrGetStateFlags
+ *
+ * @brief Gets the state flags field of a bond record in NV
+ *
+ * @param idx
+ *
+ * @return stateFlags field
+ */
+static uint8 gapBondMgrGetStateFlags( uint8 idx )
+{
+ gapBondRec_t bondRec;
+
+ if ( osal_snv_read( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec ) == SUCCESS )
+ {
+ return ( bondRec.stateFlags );
+ }
+
+ return ( 0 );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrGetPublicAddr
+ *
+ * @brief Copy the public Address from a bonding record
+ *
+ * @param idx - Bond record index
+ * @param pAddr - a place to put the public address from NV
+ *
+ * @return SUCCESS if successful.
+ * Otherwise failure.
+ */
+static bStatus_t gapBondMgrGetPublicAddr( uint8 idx, uint8 *pAddr )
+{
+ bStatus_t stat; // return value
+ gapBondRec_t bondRec; // Work space for main bond record
+
+ // Check parameters
+ if ( (idx >= GAP_BONDINGS_MAX) || (pAddr == NULL) )
+ {
+ return ( INVALIDPARAMETER );
+ }
+
+ stat = osal_snv_read( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec );
+
+ if ( stat == SUCCESS )
+ {
+ VOID osal_memcpy( pAddr, bondRec.publicAddr, B_ADDR_LEN );
+ }
+
+ return ( stat );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrFindReconnectAddr
+ *
+ * @brief Look through the bonding entries to find a
+ * reconnection address.
+ *
+ * @param pReconnectAddr - device address to look for
+ *
+ * @return index to found bonding (0 - (GAP_BONDINGS_MAX-1),
+ * GAP_BONDINGS_MAX if no empty entries
+ */
+static uint8 gapBondMgrFindReconnectAddr( uint8 *pReconnectAddr )
+{
+ // Item doesn't exist, so create all the items
+ for ( uint8 idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ // compare reconnection address
+ if ( osal_memcmp( bonds[idx].reconnectAddr, pReconnectAddr, B_ADDR_LEN ) )
+ {
+ return ( idx ); // Found it
+ }
+ }
+
+ return ( GAP_BONDINGS_MAX );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrFindAddr
+ *
+ * @brief Look through the bonding entries to find an address.
+ *
+ * @param pDevAddr - device address to look for
+ *
+ * @return index to empty bonding (0 - (GAP_BONDINGS_MAX-1),
+ * GAP_BONDINGS_MAX if no empty entries
+ */
+static uint8 gapBondMgrFindAddr( uint8 *pDevAddr )
+{
+ // Item doesn't exist, so create all the items
+ for ( uint8 idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ // Read in NV Main Bond Record and compare public address
+ if ( osal_memcmp( bonds[idx].publicAddr, pDevAddr, B_ADDR_LEN ) )
+ {
+ return ( idx ); // Found it
+ }
+ }
+
+ return ( GAP_BONDINGS_MAX );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrResolvePrivateAddr
+ *
+ * @brief Look through the NV bonding entries to resolve a private
+ * address.
+ *
+ * @param pDevAddr - device address to look for
+ *
+ * @return index to found bonding (0 - (GAP_BONDINGS_MAX-1),
+ * GAP_BONDINGS_MAX if no entry found
+ */
+static uint8 gapBondMgrResolvePrivateAddr( uint8 *pDevAddr )
+{
+ for ( uint8 idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ uint8 IRK[KEYLEN];
+
+ // Read in NV IRK Record and compare resovable address
+ if ( osal_snv_read( devIRKNvID(idx), KEYLEN, IRK ) == SUCCESS )
+ {
+ if ( ( osal_isbufset( IRK, 0xFF, KEYLEN ) == FALSE ) &&
+ ( GAP_ResolvePrivateAddr( IRK, pDevAddr ) == SUCCESS ) )
+ {
+ return ( idx ); // Found it
+ }
+ }
+ }
+
+ return ( GAP_BONDINGS_MAX );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrReadBonds
+ *
+ * @brief Read through NV and store them in RAM.
+ *
+ * @param none
+ *
+ * @return none
+ */
+static void gapBondMgrReadBonds( void )
+{
+ for ( uint8 idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ // See if the entry exists in NV
+ if ( osal_snv_read( mainRecordNvID(idx), sizeof( gapBondRec_t ), &(bonds[idx]) ) != SUCCESS )
+ {
+ // Can't read the entry, assume that it doesn't exist
+ VOID osal_memset( bonds[idx].publicAddr, 0xFF, B_ADDR_LEN );
+ VOID osal_memset( bonds[idx].reconnectAddr, 0xFF, B_ADDR_LEN );
+ bonds[idx].stateFlags = 0;
+ }
+ }
+
+ if ( autoSyncWhiteList )
+ {
+ gapBondMgr_SyncWhiteList();
+ }
+
+ // Update the GAP Privacy Flag Properties
+ gapBondSetupPrivFlag();
+}
+
+/*********************************************************************
+ * @fn gapBondMgrFindEmpty
+ *
+ * @brief Look through the bonding NV entries to find an empty.
+ *
+ * @param none
+ *
+ * @return index to empty bonding (0 - (GAP_BONDINGS_MAX-1),
+ * GAP_BONDINGS_MAX if no empty entries
+ */
+static uint8 gapBondMgrFindEmpty( void )
+{
+ // Item doesn't exist, so create all the items
+ for ( uint8 idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ // Look for public address of all 0xFF's
+ if ( osal_isbufset( bonds[idx].publicAddr, 0xFF, B_ADDR_LEN ) )
+ {
+ return ( idx ); // Found one
+ }
+ }
+
+ return ( GAP_BONDINGS_MAX );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrBondTotal
+ *
+ * @brief Look through the bonding NV entries calculate the number
+ * entries.
+ *
+ * @param none
+ *
+ * @return total number of bonds found
+ */
+static uint8 gapBondMgrBondTotal( void )
+{
+ uint8 numBonds = 0;
+
+ // Item doesn't exist, so create all the items
+ for ( uint8 idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ // Look for public address that are not 0xFF's
+ if ( osal_isbufset( bonds[idx].publicAddr, 0xFF, B_ADDR_LEN ) == FALSE )
+ {
+ numBonds++; // Found one
+ }
+ }
+
+ return ( numBonds );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrEraseAllBondings
+ *
+ * @brief Write all 0xFF's to all of the bonding entries
+ *
+ * @param none
+ *
+ * @return SUCCESS if successful.
+ * Otherwise, NV_OPER_FAILED for failure.
+ */
+static bStatus_t gapBondMgrEraseAllBondings( void )
+{
+ bStatus_t stat = SUCCESS; // return value
+
+ // Item doesn't exist, so create all the items
+ for ( uint8 idx = 0; (idx < GAP_BONDINGS_MAX) && (stat == SUCCESS); idx++ )
+ {
+ // Erasing will write/create a bonding entry
+ stat = gapBondMgrEraseBonding( idx );
+ }
+
+ return ( stat );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrEraseBonding
+ *
+ * @brief Write all 0xFF's to the complete bonding record
+ *
+ * @param idx - bonding index
+ *
+ * @return SUCCESS if successful.
+ * Otherwise, NV_OPER_FAILED for failure.
+ */
+static bStatus_t gapBondMgrEraseBonding( uint8 idx )
+{
+ bStatus_t ret;
+ gapBondRec_t bondRec;
+
+ // First see if bonding record exists in NV, then write all 0xFF's to it
+ if ( ( osal_snv_read( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec ) == SUCCESS )
+ && (osal_isbufset( bondRec.publicAddr, 0xFF, B_ADDR_LEN ) == FALSE) )
+ {
+ gapBondLTK_t ltk;
+ gapBondCharCfg_t charCfg[GAP_CHAR_CFG_MAX];
+
+ VOID osal_memset( &bondRec, 0xFF, sizeof ( gapBondRec_t ) );
+ VOID osal_memset( <k, 0xFF, sizeof ( gapBondLTK_t ) );
+
+ VOID osal_memset( charCfg, 0xFF, sizeof ( charCfg ) );
+
+ // Write out FF's over the entire bond entry.
+ ret = osal_snv_write( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec );
+ ret |= osal_snv_write( localLTKNvID(idx), sizeof ( gapBondLTK_t ), <k );
+ ret |= osal_snv_write( devLTKNvID(idx), sizeof ( gapBondLTK_t ), <k );
+ ret |= osal_snv_write( devIRKNvID(idx), KEYLEN, ltk.LTK );
+ ret |= osal_snv_write( devCSRKNvID(idx), KEYLEN, ltk.LTK );
+ ret |= osal_snv_write( devSignCounterNvID(idx), sizeof ( uint32 ), ltk.LTK );
+
+ // Write out FF's over the charactersitic configuration entry.
+ ret |= osal_snv_write( gattCfgNvID(idx), sizeof ( charCfg ), charCfg );
+ }
+ else
+ {
+ ret = SUCCESS;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Task Initialization function.
+ *
+ * Internal function defined in gapbondmgr.h.
+ */
+void GAPBondMgr_Init( uint8 task_id )
+{
+ gapBondMgr_TaskID = task_id; // Save task ID
+
+ // Setup Bond RAM Shadow
+ gapBondMgrReadBonds();
+}
+
+/*********************************************************************
+ * @brief Task Event Processor function.
+ *
+ * Internal function defined in gapbondmgr.h.
+ */
+uint16 GAPBondMgr_ProcessEvent( uint8 task_id, uint16 events )
+{
+ VOID task_id; // OSAL required parameter that isn't used in this function
+
+ if ( events & SYS_EVENT_MSG )
+ {
+ uint8 *pMsg;
+
+ if ( (pMsg = osal_msg_receive( gapBondMgr_TaskID )) != NULL )
+ {
+ gapBondMgr_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 & GAP_BOND_SYNC_CC_EVT )
+ {
+ // Update NV to have same CCC values as GATT database
+ gapBondMgr_SyncCharCfg( connectionHandle );
+
+ return (events ^ GAP_BOND_SYNC_CC_EVT);
+ }
+
+ // Discard unknown events
+ return 0;
+}
+
+/*********************************************************************
+ * @fn gapBondMgr_ProcessOSALMsg
+ *
+ * @brief Process an incoming task message.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void gapBondMgr_ProcessOSALMsg( osal_event_hdr_t *pMsg )
+{
+ switch ( pMsg->event )
+ {
+ case GAP_MSG_EVENT:
+ GAPBondMgr_ProcessGAPMsg( (gapEventHdr_t *)pMsg );
+ break;
+
+ case GATT_MSG_EVENT:
+ gapBondMgr_ProcessGATTMsg( (gattMsgEvent_t *)pMsg );
+ break;
+
+ case GATT_SERV_MSG_EVENT:
+ gapBondMgr_ProcessGATTServMsg( (gattEventHdr_t *)pMsg );
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn GAPBondMgr_CheckNVLen
+ *
+ * @brief This function will check the length of an NV Item.
+ *
+ * @param id - NV ID.
+ * @param len - lengths in bytes of item.
+ *
+ * @return SUCCESS or FAILURE
+ */
+uint8 GAPBondMgr_CheckNVLen( uint8 id, uint8 len )
+{
+ uint8 stat = FAILURE;
+
+ // Convert to index
+ switch ( (id - BLE_NVID_GAP_BOND_START) % GAP_BOND_REC_IDS )
+ {
+ case GAP_BOND_REC_ID_OFFSET:
+ if ( len == sizeof ( gapBondRec_t ) )
+ {
+ stat = SUCCESS;
+ }
+ break;
+
+ case GAP_BOND_LOCAL_LTK_OFFSET:
+ case GAP_BOND_DEV_LTK_OFFSET:
+ if ( len == sizeof ( gapBondLTK_t ) )
+ {
+ stat = SUCCESS;
+ }
+ break;
+
+ case GAP_BOND_DEV_IRK_OFFSET:
+ case GAP_BOND_DEV_CSRK_OFFSET:
+ if ( len == KEYLEN )
+ {
+ stat = SUCCESS;
+ }
+ break;
+
+ case GAP_BOND_DEV_SIGN_COUNTER_OFFSET:
+ if ( len == sizeof ( uint32 ) )
+ {
+ stat = SUCCESS;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return ( stat );
+}
+
+/*********************************************************************
+ * @fn gapBondMgr_ProcessGATTMsg
+ *
+ * @brief Process an incoming GATT message.
+ *
+ * @param pMsg - pointer to received message
+ *
+ * @return none
+ */
+static void gapBondMgr_ProcessGATTMsg( gattMsgEvent_t *pMsg )
+{
+ // Process the GATT message
+ switch ( pMsg->method )
+ {
+ case ATT_HANDLE_VALUE_CFM:
+ // Clear Service Changed flag for this client
+ VOID GAPBondMgr_ServiceChangeInd( pMsg->connHandle, 0x00 );
+ break;
+
+ default:
+ // Unknown message
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn gapBondMgr_ProcessGATTServMsg
+ *
+ * @brief Process an incoming GATT Server App message.
+ *
+ * @param pMsg - pointer to received message
+ *
+ * @return none
+ */
+static void gapBondMgr_ProcessGATTServMsg( gattEventHdr_t *pMsg )
+{
+ // Process the GATT Server App message
+ switch ( pMsg->method )
+ {
+ case GATT_CLIENT_CHAR_CFG_UPDATED_EVENT:
+ {
+ gattClientCharCfgUpdatedEvent_t *pEvent = (gattClientCharCfgUpdatedEvent_t *)pMsg;
+
+ VOID GAPBondMgr_UpdateCharCfg( pEvent->connHandle, pEvent->attrHandle, pEvent->value );
+ }
+ break;
+
+ default:
+ // Unknown message
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn gapBondMgrSendServiceChange
+ *
+ * @brief Tell the GATT that a service change is needed.
+ *
+ * @param pLinkItem - pointer to connection information
+ *
+ * @return none
+ */
+static void gapBondMgrSendServiceChange( linkDBItem_t *pLinkItem )
+{
+ VOID GATTServApp_SendServiceChangedInd( pLinkItem->connectionHandle,
+ gapBondMgr_TaskID );
+}
+
+/*********************************************************************
+ * @fn gapBondSetupPrivFlag
+ *
+ * @brief Setup the GAP Privacy Flag properties.
+ *
+ * @param none
+ *
+ * @return none
+ */
+static void gapBondSetupPrivFlag( void )
+{
+ uint8 privFlagProp;
+
+ if ( gapBondMgrBondTotal() > 1 )
+ {
+ privFlagProp = GATT_PROP_READ;
+ }
+ else
+ {
+ privFlagProp = GATT_PROP_READ | GATT_PROP_WRITE;
+ }
+
+ // Setup the
+ VOID GGS_SetParameter( GGS_PERI_PRIVACY_FLAG_PROPS, sizeof ( uint8 ), &privFlagProp );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrAuthenticate
+ *
+ * @brief Initiate authentication
+ *
+ * @param connHandle - connection handle
+ * @param addrType - peer address type
+ * @param pPairReq - Enter these parameters if the Pairing Request was already received.
+ * NULL, if waiting for Pairing Request or if initiating.
+ *
+ * @return none
+ */
+static void gapBondMgrAuthenticate( uint16 connHandle, uint8 addrType,
+ gapPairingReq_t *pPairReq )
+{
+ gapAuthParams_t params;
+
+ VOID osal_memset( ¶ms, 0, sizeof ( gapAuthParams_t ) );
+
+ // Setup the pairing parameters
+ params.connectionHandle = connHandle;
+ params.secReqs.ioCaps = gapBond_IOCap;
+ params.secReqs.oobAvailable = gapBond_OOBDataFlag;
+ params.secReqs.maxEncKeySize = gapBond_KeySize;
+
+ params.secReqs.keyDist.sEncKey = (gapBond_KeyDistList & GAPBOND_KEYDIST_SENCKEY) ? TRUE : FALSE;
+ params.secReqs.keyDist.sIdKey = (gapBond_KeyDistList & GAPBOND_KEYDIST_SIDKEY) ? TRUE : FALSE;
+ params.secReqs.keyDist.mEncKey = (gapBond_KeyDistList & GAPBOND_KEYDIST_MENCKEY) ? TRUE : FALSE;
+ params.secReqs.keyDist.mIdKey = (gapBond_KeyDistList & GAPBOND_KEYDIST_MIDKEY) ? TRUE : FALSE;
+ params.secReqs.keyDist.mSign = (gapBond_KeyDistList & GAPBOND_KEYDIST_MSIGN) ? TRUE : FALSE;
+ params.secReqs.keyDist.sSign = (gapBond_KeyDistList & GAPBOND_KEYDIST_SSIGN) ? TRUE : FALSE;
+
+ // Is bond manager setup for OOB data?
+ if ( gapBond_OOBDataFlag )
+ {
+ VOID osal_memcpy( params.secReqs.oob, gapBond_OOBData, KEYLEN );
+ }
+
+ if ( gapBond_Bonding && addrType != ADDRTYPE_PUBLIC )
+ {
+ // Force a slave ID key
+ params.secReqs.keyDist.sIdKey = TRUE;
+ }
+
+ params.secReqs.authReq |= (gapBond_Bonding) ? SM_AUTH_STATE_BONDING : 0;
+ params.secReqs.authReq |= (gapBond_MITM) ? SM_AUTH_STATE_AUTHENTICATED : 0;
+
+ VOID GAP_Authenticate( ¶ms, pPairReq );
+}
+
+#if ( HOST_CONFIG & PERIPHERAL_CFG )
+/*********************************************************************
+ * @fn gapBondMgrSlaveSecurityReq
+ *
+ * @brief Send a slave security request
+ *
+ * @param connHandle - connection handle
+ *
+ * @return none
+ */
+static void gapBondMgrSlaveSecurityReq( uint16 connHandle )
+{
+ uint8 authReq = 0;
+
+ authReq |= (gapBond_Bonding) ? SM_AUTH_STATE_BONDING : 0;
+ authReq |= (gapBond_MITM) ? SM_AUTH_STATE_AUTHENTICATED : 0;
+
+ VOID GAP_SendSlaveSecurityRequest( connHandle, authReq );
+}
+#endif
+
+/*********************************************************************
+ * @fn gapBondMgrBondReq
+ *
+ * @brief Initiate a GAP bond request
+ *
+ * @param connHandle - connection handle
+ * @param idx - NV index of bond entry
+ * @param stateFlags - bond state flags
+ * @param role - master or slave role
+ * @param startEncryption - whether or not to start encryption
+ *
+ * @return none
+ */
+static void gapBondMgrBondReq( uint16 connHandle, uint8 idx, uint8 stateFlags,
+ uint8 role, uint8 startEncryption )
+{
+ smSecurityInfo_t ltk;
+ osalSnvId_t nvId;
+
+ if ( role == GAP_PROFILE_CENTRAL )
+ {
+ nvId = devLTKNvID( idx );
+ }
+ else
+ {
+ nvId = localLTKNvID( idx );
+ }
+
+ // Initialize the NV structures
+ VOID osal_memset( <k, 0, sizeof ( smSecurityInfo_t ) );
+
+ if ( osal_snv_read( nvId, sizeof ( smSecurityInfo_t ), <k ) == SUCCESS )
+ {
+ if ( (ltk.keySize >= MIN_ENC_KEYSIZE) && (ltk.keySize <= MAX_ENC_KEYSIZE) )
+ {
+ VOID GAP_Bond( connHandle,
+ ((stateFlags & GAP_BONDED_STATE_AUTHENTICATED) ? TRUE : FALSE),
+ <k, startEncryption );
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn gapBondMgr_SyncWhiteList
+ *
+ * @brief syncronize the White List with the bonds
+ *
+ * @param none
+ *
+ * @return none
+ */
+static void gapBondMgr_SyncWhiteList( void )
+{
+ //erase the White List
+ VOID HCI_LE_ClearWhiteListCmd();
+
+ // Write bond addresses into the White List
+ for( uint8 i = 0; i < GAP_BONDINGS_MAX; i++)
+ {
+ // Make sure empty addresses are not added to the White List
+ if ( osal_isbufset( bonds[i].publicAddr, 0xFF, B_ADDR_LEN ) == FALSE )
+ {
+ VOID HCI_LE_AddWhiteListCmd( HCI_PUBLIC_DEVICE_ADDRESS, bonds[i].publicAddr );
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn gapBondMgr_SyncCharCfg
+ *
+ * @brief Update the Bond Manager to have the same configurations as
+ * the GATT database.
+ *
+ * @param connHandle - the current connection handle to find client configurations for
+ *
+ * @return none
+ */
+static void gapBondMgr_SyncCharCfg( uint16 connHandle )
+{
+ gattAttribute_t *pAttr;
+ uint16 service;
+
+ // Only attributes with attribute handles between and including the Starting
+ // Handle parameter and the Ending Handle parameter that match the requested
+ // attribute type and the attribute value will be returned.
+
+ // All attribute types are effectively compared as 128-bit UUIDs,
+ // even if a 16-bit UUID is provided in this request or defined
+ // for an attribute.
+ pAttr = GATT_FindHandleUUID( GATT_MIN_HANDLE, GATT_MAX_HANDLE,
+ clientCharCfgUUID, ATT_BT_UUID_SIZE, &service );
+ while ( ( pAttr != NULL ) )
+ {
+ uint8 len;
+ uint8 attrVal[ATT_BT_UUID_SIZE];
+
+ // It is not possible to use this request on an attribute that has a value
+ // that is longer than 2.
+ if ( GATTServApp_ReadAttr( connHandle, pAttr, service, attrVal,
+ &len, 0, ATT_BT_UUID_SIZE ) == SUCCESS )
+ {
+ uint16 value = BUILD_UINT16(attrVal[0], attrVal[1]);
+
+ if ( value != GATT_CFG_NO_OPERATION )
+ {
+ // NV must be updated to meet configuration of the database
+ VOID GAPBondMgr_UpdateCharCfg( connHandle, pAttr->handle, value );
+ }
+ }
+
+ // Try to find the next attribute
+ pAttr = GATT_FindNextAttr( pAttr, GATT_MAX_HANDLE, service, NULL );
+ } // while
+}
+
+#endif // ( CENTRAL_CFG | PERIPHERAL_CFG )
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gapbondmgr.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gapbondmgr.h
new file mode 100644
index 0000000..abd6ee7
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gapbondmgr.h
@@ -0,0 +1,407 @@
+/**
+ @headerfile: gapbondmgr.h
+ $Date: 2011-03-03 15:46:41 -0800 (Thu, 03 Mar 2011) $
+ $Revision: 12 $
+
+ @mainpage TI BLE GAP Bond Manager
+
+ This GAP profile manages bonded connections between devices.
+
+ When operating as a slave, this profile will automatically respond
+ to SM Pairing Requests from a connected master device. When operating
+ as a master, this profile will automatically respond to SM Slave
+ Security Requests from a connected slave device.
+
+ After pairing, if keys were exchanged and bonding was specified, this
+ profile will save the device and key information of the connected device,
+ so that, on future connections, the bonded devices can establish an
+ encrypted link without pairing.
+
+ This GAP Bond Manager will handle all of the pairing and bonding actions
+ automatically and can be controlled by setting control parameters:
+ * GAPBondMgr_SetParameter()
+ * GAPBondMgr_GetParameter()
+
+ Reference: @ref GAPBOND_PROFILE_PARAMETERS
+
+
+ Copyright 2010-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*/
+
+#ifndef GAPBONDMGR_H
+#define GAPBONDMGR_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*-------------------------------------------------------------------
+ * INCLUDES
+ */
+#include "gap.h"
+
+/*-------------------------------------------------------------------
+ * CONSTANTS
+ */
+
+#if !defined ( GAP_BONDINGS_MAX )
+ #define GAP_BONDINGS_MAX 10 //!< Maximum number of bonds that can be saved in NV.
+#endif
+
+#if !defined ( GAP_CHAR_CFG_MAX )
+ #define GAP_CHAR_CFG_MAX 4 //!< Maximum number of characteristic configuration that can be saved in NV.
+#endif
+/** @defgroup GAPBOND_CONSTANTS_NAME GAP Bond Manager Constants
+ * @{
+ */
+
+/** @} End GAPBOND_CONSTANTS_NAME */
+
+/** @defgroup GAPBOND_PROFILE_PARAMETERS GAP Bond Manager Parameters
+ * @{
+ */
+#define GAPBOND_PAIRING_MODE 0x400 //!< Pairing Mode: @ref GAPBOND_PAIRING_MODE_DEFINES. Read/Write. Size is uint8. Default is GAPBOND_PAIRING_MODE_WAIT_FOR_REQ.
+#define GAPBOND_INITIATE_WAIT 0x401 //!< Pairing Mode Initiate wait timeout. This is the time it will wait for a Pairing Request before sending the Slave Initiate Request. Read/Write. Size is uint16. Default is 1000(in milliseconds).
+#define GAPBOND_MITM_PROTECTION 0x402 //!< Man-In-The-Middle (MITM) basically turns on Passkey protection in the pairing algorithm. Read/Write. Size is uint8. Default is 0(disabled).
+#define GAPBOND_IO_CAPABILITIES 0x403 //!< I/O capabilities. Read/Write. Size is uint8. Default is GAPBOND_IO_CAP_DISPLAY_ONLY @ref GAPBOND_IO_CAP_DEFINES.
+#define GAPBOND_OOB_ENABLED 0x404 //!< OOB data available for pairing algorithm. Read/Write. Size is uint8. Default is 0(disabled).
+#define GAPBOND_OOB_DATA 0x405 //!< OOB Data. Read/Write. size uint8[16]. Default is all 0's.
+#define GAPBOND_BONDING_ENABLED 0x406 //!< Request Bonding during the pairing process if enabled. Read/Write. Size is uint8. Default is 0(disabled).
+#define GAPBOND_KEY_DIST_LIST 0x407 //!< The key distribution list for bonding. size is uint8. @ref GAPBOND_KEY_DIST_DEFINES. Default is sEncKey, sIdKey, mIdKey, mSign enabled.
+#define GAPBOND_DEFAULT_PASSCODE 0x408 //!< The default passcode for MITM protection. size is uint32. Range is 0 - 999,999. Default is 0.
+#define GAPBOND_ERASE_ALLBONDS 0x409 //!< Erase all of the bonded devices. Write Only. No Size.
+#define GAPBOND_AUTO_FAIL_PAIRING 0x40A //!< TEST MODE (DO NOT USE) to automatically send a Pairing Fail when a Pairing Request is received. Read/Write. size is uint8. Default is 0 (disabled).
+#define GAPBOND_AUTO_FAIL_REASON 0x40B //!< TEST MODE (DO NOT USE) Pairing Fail reason when auto failing. Read/Write. size is uint8. Default is 0x05 (SMP_PAIRING_FAILED_NOT_SUPPORTED).
+#define GAPBOND_KEYSIZE 0x40C //!< Key Size used in pairing. Read/Write. size is uint8. Default is 16.
+#define GAPBOND_AUTO_SYNC_WL 0x40D //!< Clears the White List adds to it each unique address stored by bonds in NV. Read/Write. Size is uint8. Default is FALSE.
+#define GAPBOND_BOND_COUNT 0x40E //!< Gets the total number of bonds stored in NV. Read Only. Size is uint8. Default is 0 (no bonds).
+#define GAPBOND_BOND_FAIL_ACTION 0x40F //!< Possible actions Central may take upon an unsuccessful bonding. Write Only. Size is uint8. Default is 0x02 (Terminate link upon unsuccessful bonding).
+/** @} End GAPBOND_PROFILE_PARAMETERS */
+
+/** @defgroup GAPBOND_PAIRING_MODE_DEFINES GAP Bond Manager Pairing Modes
+ * @{
+ */
+#define GAPBOND_PAIRING_MODE_NO_PAIRING 0x00 //!< Pairing is not allowed
+#define GAPBOND_PAIRING_MODE_WAIT_FOR_REQ 0x01 //!< Wait for a pairing request or slave security request
+#define GAPBOND_PAIRING_MODE_INITIATE 0x02 //!< Don't wait, initiate a pairing request or slave security request
+/** @} End GAPBOND_PAIRING_MODE_DEFINES */
+
+/** @defgroup GAPBOND_IO_CAP_DEFINES GAP Bond Manager I/O Capabilities
+ * @{
+ */
+#define GAPBOND_IO_CAP_DISPLAY_ONLY 0x00 //!< Display Only Device
+#define GAPBOND_IO_CAP_DISPLAY_YES_NO 0x01 //!< Display and Yes and No Capable
+#define GAPBOND_IO_CAP_KEYBOARD_ONLY 0x02 //!< Keyboard Only
+#define GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT 0x03 //!< No Display or Input Device
+#define GAPBOND_IO_CAP_KEYBOARD_DISPLAY 0x04 //!< Both Keyboard and Display Capable
+/** @} End GAPBOND_IO_CAP_DEFINES */
+
+/** @defgroup GAPBOND_KEY_DIST_DEFINES GAP Bond Manager Key Distribution
+ * @{
+ */
+#define GAPBOND_KEYDIST_SENCKEY 0x01 //!< Slave Encryption Key
+#define GAPBOND_KEYDIST_SIDKEY 0x02 //!< Slave IRK and ID information
+#define GAPBOND_KEYDIST_SSIGN 0x04 //!< Slave CSRK
+#define GAPBOND_KEYDIST_MENCKEY 0x08 //!< Master Encrypton Key
+#define GAPBOND_KEYDIST_MIDKEY 0x10 //!< Master IRK and ID information
+#define GAPBOND_KEYDIST_MSIGN 0x20 //!< Master CSRK
+/** @} End GAPBOND_IO_CAP_DEFINES */
+
+
+/** @defgroup GAPBOND_PAIRING_STATE_DEFINES GAP Bond Manager Pairing States
+ * @{
+ */
+#define GAPBOND_PAIRING_STATE_STARTED 0x00 //!< Pairing started
+#define GAPBOND_PAIRING_STATE_COMPLETE 0x01 //!< Pairing complete
+#define GAPBOND_PAIRING_STATE_BONDED 0x02 //!< Devices bonded
+/** @} End GAPBOND_PAIRING_STATE_DEFINES */
+
+/** @defgroup SMP_PAIRING_FAILED_DEFINES Pairing failure status values
+ * @{
+ */
+#define SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED 0x01 //!< The user input of the passkey failed, for example, the user cancelled the operation.
+#define SMP_PAIRING_FAILED_OOB_NOT_AVAIL 0x02 //!< The OOB data is not available
+#define SMP_PAIRING_FAILED_AUTH_REQ 0x03 //!< The pairing procedure can't be performed as authentication requirements can't be met due to IO capabilities of one or both devices
+#define SMP_PAIRING_FAILED_CONFIRM_VALUE 0x04 //!< The confirm value doesn't match the calculated compare value
+#define SMP_PAIRING_FAILED_NOT_SUPPORTED 0x05 //!< Pairing isn't supported by the device
+#define SMP_PAIRING_FAILED_ENC_KEY_SIZE 0x06 //!< The resultant encryption key size is insufficient for the security requirements of this device.
+#define SMP_PAIRING_FAILED_CMD_NOT_SUPPORTED 0x07 //!< The SMP command received is not supported on this device.
+#define SMP_PAIRING_FAILED_UNSPECIFIED 0x08 //!< Pairing failed due to an unspecified reason
+#define SMP_PAIRING_FAILED_REPEATED_ATTEMPTS 0x09 //!< Pairing or authenication procedure is disallowed because too little time has elapsed since the last pairing request or security request.
+/** @} End SMP_PAIRING_FAILED_DEFINES */
+
+/** @defgroup GAPBOND_BONDING_FAILURE_DEFINES Bonding Failure Actions
+ * @{
+ */
+#define GAPBOND_FAIL_NO_ACTION 0x00 //!< Take no action upon unsuccessful bonding
+#define GAPBOND_FAIL_INITIATE_PAIRING 0x01 //!< Initiate pairing upon unsuccessful bonding
+#define GAPBOND_FAIL_TERMINATE_LINK 0x02 //!< Terminate link upon unsuccessful bonding
+#define GAPBOND_FAIL_TERMINATE_ERASE_BONDS 0x03 //!< Terminate link and erase all existing bonds on device upon unsuccessful bonding
+/** @} End GAPBOND_BONDING_FAILURE_DEFINES */
+
+/*-------------------------------------------------------------------
+ * TYPEDEFS
+ */
+
+
+/**
+ * Passcode Callback Function
+ */
+typedef void (*pfnPasscodeCB_t)
+(
+ uint8 *deviceAddr, //!< address of device to pair with, and could be either public or random.
+ uint16 connectionHandle, //!< Connection handle
+ uint8 uiInputs, //!< Pairing User Interface Inputs - Ask user to input passcode
+ uint8 uiOutputs //!< Pairing User Interface Outputs - Display passcode
+ );
+
+/**
+ * Pairing State Callback Function
+ */
+typedef void (*pfnPairStateCB_t)
+(
+ uint16 connectionHandle, //!< Connection handle
+ uint8 state, //!< Pairing state @ref GAPBOND_PAIRING_STATE_DEFINES
+ uint8 status //!< Pairing status
+);
+
+/**
+ * Callback Registration Structure
+ */
+typedef struct
+{
+ pfnPasscodeCB_t passcodeCB; //!< Passcode callback
+ pfnPairStateCB_t pairStateCB; //!< Pairing state callback
+} gapBondCBs_t;
+
+/*-------------------------------------------------------------------
+ * MACROS
+ */
+
+/*-------------------------------------------------------------------
+ * API FUNCTIONS
+ */
+
+/**
+ * @defgroup GAPROLES_BONDMGR_API GAP Bond Manager API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Set a GAP Bond Manager parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will set the
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also,
+ * the "len" field must be set to the size of a "uint16" and the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPBOND_PROFILE_PARAMETERS
+ * @param len - length of data to write
+ * @param pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPBondMgr_SetParameter( uint16 param, uint8 len, void *pValue );
+
+/**
+ * @brief Get a GAP Bond Manager parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will get a
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also, the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPBOND_PROFILE_PARAMETERS
+ * @param pValue - pointer to location to get the value. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPBondMgr_GetParameter( uint16 param, void *pValue );
+
+/**
+ * @brief Notify the Bond Manager that a connection has been made.
+ *
+ * NOTE: The GAP Peripheral/Central Role profile will
+ * call this function, if they are included in the project.
+ *
+ * @param addrType - device's address type. Reference GAP_ADDR_TYPE_DEFINES in gap.h
+ * @param pDevAddr - device's address
+ * @param connHandle - connection handle
+ * @param role - master or slave role. Reference GAP_PROFILE_ROLE_DEFINES in gap.h
+ *
+ * @return SUCCESS, otherwise failure
+ */
+extern bStatus_t GAPBondMgr_LinkEst( uint8 addrType, uint8 *pDevAddr, uint16 connHandle, uint8 role );
+
+/**
+ * @brief Resolve an address from bonding information.
+ *
+ * @param addrType - device's address type. Reference GAP_ADDR_TYPE_DEFINES in gap.h
+ * @param pDevAddr - device's address
+ * @param pResolvedAddr - pointer to buffer to put the resolved address
+ *
+ * @return bonding index (0 - (GAP_BONDINGS_MAX-1) if found,
+ * GAP_BONDINGS_MAX if not found
+ */
+extern uint8 GAPBondMgr_ResolveAddr( uint8 addrType, uint8 *pDevAddr, uint8 *pResolvedAddr );
+
+/**
+ * @brief Set/clear the service change indication in a bond record.
+ *
+ * @param connectionHandle - connection handle of the connected device or 0xFFFF
+ * if all devices in database.
+ * @param setParam - TRUE to set the service change indication, FALSE to clear it.
+ *
+ * @return SUCCESS - bond record found and changed,
+ * bleNoResources - bond record not found (for 0xFFFF connectionHandle),
+ * bleNotConnected - connection not found - connectionHandle is invalid (for non-0xFFFF connectionHandle).
+ */
+extern bStatus_t GAPBondMgr_ServiceChangeInd( uint16 connectionHandle, uint8 setParam );
+
+/**
+ * @brief Update the Characteristic Configuration in a bond record.
+ *
+ * @param connectionHandle - connection handle of the connected device or 0xFFFF
+ * if all devices in database.
+ * @param attrHandle - attribute handle.
+ * @param value - characteristic configuration value.
+ *
+ * @return SUCCESS - bond record found and changed,
+ * bleNoResources - bond record not found (for 0xFFFF connectionHandle),
+ * bleNotConnected - connection not found - connectionHandle is invalid (for non-0xFFFF connectionHandle).
+ */
+extern bStatus_t GAPBondMgr_UpdateCharCfg( uint16 connectionHandle, uint16 attrHandle, uint16 value );
+
+/**
+ * @brief Register callback functions with the bond manager.
+ *
+ * NOTE: There is no need to register a passcode callback function
+ * if the passcode will be handled with the GAPBOND_DEFAULT_PASSCODE parameter.
+ *
+ * @param pCB - pointer to callback function structure.
+ *
+ * @return none
+ */
+extern void GAPBondMgr_Register( gapBondCBs_t *pCB );
+
+/**
+ * @brief Respond to a passcode request.
+ *
+ * @param connectionHandle - connection handle of the connected device or 0xFFFF
+ * if all devices in database.
+ * @param status - SUCCESS if passcode is available, otherwise see @ref SMP_PAIRING_FAILED_DEFINES.
+ * @param passcode - integer value containing the passcode.
+ *
+ * @return SUCCESS - bond record found and changed,
+ * bleIncorrectMode - Link not found.
+ */
+extern bStatus_t GAPBondMgr_PasscodeRsp( uint16 connectionHandle, uint8 status, uint32 passcode );
+
+/**
+ * @brief This is a bypass mechanism to allow the bond manager to process
+ * GAP messages.
+ *
+ * NOTE: This is an advanced feature and shouldn't be called unless
+ * the normal GAP Bond Manager task ID registration is overridden.
+ *
+ * @param pMsg - GAP event message
+ *
+ * @return none
+ */
+extern void GAPBondMgr_ProcessGAPMsg( gapEventHdr_t *pMsg );
+
+/**
+ * @brief This function will check the length of a Bond Manager NV Item.
+ *
+ * @param id - NV ID.
+ * @param len - lengths in bytes of item.
+ *
+ * @return SUCCESS or FAILURE
+ */
+extern uint8 GAPBondMgr_CheckNVLen( uint8 id, uint8 len );
+
+/**
+ * @} End GAPROLES_BONDMGR_API
+ */
+
+
+
+/*-------------------------------------------------------------------
+ * TASK FUNCTIONS - Don't call these. These are system functions.
+ */
+
+/**
+ * @internal
+ *
+ * @brief Initialization function for the GAP Bond Manager Task.
+ * This is called during initialization and should contain
+ * any application specific initialization (ie. hardware
+ * initialization/setup, table initialization, power up
+ * notificaiton ... ).
+ *
+ * @param the ID assigned by OSAL. This ID should be
+ * used to send messages and set timers.
+ *
+ * @return void
+ */
+extern void GAPBondMgr_Init( uint8 task_id );
+
+/**
+ * @internal
+ *
+ * @brief GAP Bond Manager 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 events not processed
+ */
+extern uint16 GAPBondMgr_ProcessEvent( uint8 task_id, uint16 events );
+
+/*-------------------------------------------------------------------
+-------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GAPBONDMGR_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gapperiphbondmgr.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gapperiphbondmgr.c
new file mode 100644
index 0000000..fd05c6b
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gapperiphbondmgr.c
@@ -0,0 +1,1409 @@
+/**************************************************************************************************
+ Filename: gapperiphbondmgr.c
+ Revised: $Date: 2011-03-02 12:41:23 -0800 (Wed, 02 Mar 2011) $
+ Revision: $Revision: 25256 $
+
+ Description: GAP peripheral profile manages bonded connections
+
+
+ Copyright 2010 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "osal_snv.h"
+#include "gap.h"
+#include "linkdb.h"
+#include "gatt.h"
+
+#include "gattservapp.h"
+#include "gapgattserver.h"
+#include "gapperiphbondmgr.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+// Profile Events
+
+// Bonded State Flags
+#define GAP_BONDED_STATE_AUTHENTICATED 0x0001
+#define GAP_BONDED_STATE_SERVICE_CHANGED 0x0002
+
+/**
+ * GAP Bond Manager NV layout
+ *
+ * The NV definitions:
+ * BLE_NVID_GAP_BOND_START - starting NV ID
+ * GAP_BONDINGS_MAX - Maximum number of bonding allowed (10 is max for number of NV IDs allocated in bcomdef.h).
+ *
+ * A single bonding entry consists of 6 components (NV items):
+ * Bond Record - defined as gapBondRec_t and uses GAP_BOND_REC_ID_OFFSET for an NV ID
+ * local LTK Info - defined as gapBondLTK_t and uses GAP_BOND_LOCAL_LTK_OFFSET for an NV ID
+ * device LTK Info - defined as gapBondLTK_t and uses GAP_BOND_DEV_LTK_OFFSET for an NV ID
+ * device IRK - defined as "uint8 devIRK[KEYLEN]" and uses GAP_BOND_DEV_IRK_OFFSET for an NV ID
+ * device CSRK - defined as "uint8 devCSRK[KEYLEN]" and uses GAP_BOND_DEV_CSRK_OFFSET for an NV ID
+ * device Sign Counter - defined as a uint32 and uses GAP_BOND_DEV_SIGN_COUNTER_OFFSET for an NV ID
+ *
+ * When the device is initialized for the first time, all (GAP_BONDINGS_MAX) NV items are created and
+ * initialized to all 0xFF's. A bonding record of all 0xFF's indicates that the bonding record is empty
+ * and free to use.
+ *
+ * The calculation for each bonding records NV IDs:
+ * mainRecordNvID = ((bondIdx * GAP_BOND_REC_IDS) + BLE_NVID_GAP_BOND_START)
+ * localLTKNvID = (((bondIdx * GAP_BOND_REC_IDS) + GAP_BOND_LOCAL_LTK_OFFSET) + BLE_NVID_GAP_BOND_START)
+ *
+ */
+#define GAP_BOND_REC_ID_OFFSET 0 //!< NV ID for the main bonding record
+#define GAP_BOND_LOCAL_LTK_OFFSET 1 //!< NV ID for the bonding record's local LTK information
+#define GAP_BOND_DEV_LTK_OFFSET 2 //!< NV ID for the bonding records' device LTK information
+#define GAP_BOND_DEV_IRK_OFFSET 3 //!< NV ID for the bonding records' device IRK
+#define GAP_BOND_DEV_CSRK_OFFSET 4 //!< NV ID for the bonding records' device CSRK
+#define GAP_BOND_DEV_SIGN_COUNTER_OFFSET 5 //!< NV ID for the bonding records' device Sign Counter
+
+#define GAP_BOND_REC_IDS 6
+
+// Macros to calculate the index/offset in to NV space
+#define calcNvID(Idx, offset) (((((Idx) * GAP_BOND_REC_IDS) + (offset))) + BLE_NVID_GAP_BOND_START)
+#define mainRecordNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_REC_ID_OFFSET))
+#define localLTKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_LOCAL_LTK_OFFSET))
+#define devLTKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_LTK_OFFSET))
+#define devIRKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_IRK_OFFSET))
+#define devCSRKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_CSRK_OFFSET))
+#define devSignCounterNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_SIGN_COUNTER_OFFSET))
+
+// Key Size Limits
+#define MIN_ENC_KEYSIZE 7 //!< Minimum number of bytes for the encryption key
+#define MAX_ENC_KEYSIZE 16 //!< Maximum number of bytes for the encryption key
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Structure of NV data for the connected device's encryption information
+typedef struct
+{
+ uint8 LTK[KEYLEN]; // Long Term Key (LTK)
+ uint16 div; // LTK eDiv
+ uint8 rand[B_RANDOM_NUM_SIZE]; // LTK random number
+ uint8 keySize; // LTK key size
+} gapBondLTK_t;
+
+// Structure of NV data for the connected device's address information
+typedef struct
+{
+ uint8 publicAddr[B_ADDR_LEN]; // Master's address
+ uint8 reconnectAddr[B_ADDR_LEN]; // Privacy Reconnection Address
+ uint16 stateFlags; // State flags: SM_AUTH_STATE_AUTHENTICATED & SM_AUTH_STATE_BONDING
+} gapBondRec_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+static uint8 gapBondMgr_TaskID; // Task ID for internal task/event processing
+
+// GAPBonding Parameters
+static uint8 gapBond_PairingMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
+static uint16 gapBond_InitiateWait = 1000; // Default to 1 second
+static uint8 gapBond_MITM = FALSE;
+static uint8 gapBond_IOCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
+static uint8 gapBond_OOBDataFlag = FALSE;
+static uint8 gapBond_OOBData[KEYLEN] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+static uint8 gapBond_Bonding = FALSE;
+static uint8 gapBond_AutoFail = FALSE;
+static uint8 gapBond_AutoFailReason = SMP_PAIRING_FAILED_NOT_SUPPORTED;
+static uint8 gapBond_KeyDistList =
+(
+ GAPBOND_KEYDIST_SENCKEY // sEncKey enabled, to send the encryption key
+ | GAPBOND_KEYDIST_SIDKEY // sIdKey enabled, to send the IRK, and BD_ADDR
+ // sSign disabled,
+ // mEncKey disabled,
+ | GAPBOND_KEYDIST_MIDKEY // mIdKey enabled, to get the master's IRK and BD_ADDR
+ | GAPBOND_KEYDIST_MSIGN // mSign enabled, to get the master's CSRK
+);
+static uint32 gapBond_Passcode = 0;
+static uint8 gapBond_KeySize = MAX_ENC_KEYSIZE;
+
+static gapBondCBs_t *pGapBondCB = NULL;
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 gapBondMgrChangeState( uint8 idx, uint16 state, uint8 set );
+static uint8 gapBondMgrAddBond( gapBondRec_t *pBondRec,
+ gapBondLTK_t *pLocalLTK, gapBondLTK_t *pDevLTK,
+ uint8 *pIRK, uint8 *pSRK, uint32 signCounter );
+static uint8 gapBondMgrGetStateFlags( uint8 idx );
+static bStatus_t gapBondMgrGetPublicAddr( uint8 idx, uint8 *pAddr );
+static uint8 gapBondMgrFindReconnectAddr( uint8 *pReconnectAddr );
+static uint8 gapBondMgrFindAddr( uint8 *pDevAddr );
+static uint8 gapBondMgrFindEmpty( void );
+static uint8 gapBondMgrBondTotal( void );
+static bStatus_t gapBondMgrEraseAllBondings( void );
+static bStatus_t gapBondMgrEraseBonding( uint8 idx );
+static void gapBondMgr_ProcessOSALMsg( osal_event_hdr_t *pMsg );
+static void gapBondMgrSendServiceChange( linkDBItem_t *pLinkItem );
+static void gapBondMgr_ProcessGATTMsg( gattMsgEvent_t *pMsg );
+static void gapBondSetupPrivFlag( void );
+
+/*********************************************************************
+ * NETWORK LAYER CALLBACKS
+ */
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @brief Set a GAP Bond Manager parameter.
+ *
+ * Public function defined in gapperiphbondmgr.h.
+ */
+bStatus_t GAPBondMgr_SetParameter( uint16 param, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS; // return value
+
+ switch ( param )
+ {
+ case GAPBOND_PAIRING_MODE:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAPBOND_PAIRING_MODE_INITIATE) )
+ {
+ gapBond_PairingMode = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_INITIATE_WAIT:
+ if ( len == sizeof ( uint16 ) )
+ {
+ gapBond_InitiateWait = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_MITM_PROTECTION:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )
+ {
+ gapBond_MITM = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_IO_CAPABILITIES:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAPBOND_IO_CAP_KEYBOARD_DISPLAY) )
+ {
+ gapBond_IOCap = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_OOB_ENABLED:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )
+ {
+ gapBond_OOBDataFlag = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_OOB_DATA:
+ if ( len == KEYLEN )
+ {
+ VOID osal_memcpy( gapBond_OOBData, pValue, KEYLEN ) ;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_BONDING_ENABLED:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )
+ {
+ gapBond_Bonding = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_KEY_DIST_LIST:
+ if ( len == sizeof ( uint8 ) )
+ {
+ gapBond_KeyDistList = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_DEFAULT_PASSCODE:
+ if ( (len == sizeof ( uint32 ))
+ && (*((uint32*)pValue) <= GAP_PASSCODE_MAX) )
+ {
+ gapBond_Passcode = *((uint32*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_ERASE_ALLBONDS:
+ if ( len == 0 )
+ {
+ VOID gapBondMgrEraseAllBondings();
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_AUTO_FAIL_PAIRING:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )
+ {
+ gapBond_AutoFail = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_AUTO_FAIL_REASON:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= SMP_PAIRING_FAILED_REPEATED_ATTEMPTS) )
+ {
+ gapBond_AutoFailReason = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPBOND_KEYSIZE:
+ if ( (len == sizeof ( uint8 ))
+ && ((*((uint8*)pValue) >= MIN_ENC_KEYSIZE) && (*((uint8*)pValue) <= MAX_ENC_KEYSIZE)) )
+ {
+ gapBond_KeySize = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ // The param value isn't part of this profile, try the GAP.
+ if ( (param < TGAP_PARAMID_MAX) && (len == sizeof ( uint16 )) )
+ {
+ ret = GAP_SetParamValue( param, *((uint16*)pValue) );
+ }
+ else
+ {
+ ret = INVALIDPARAMETER;
+ }
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Get a GAP Bond Manager parameter.
+ *
+ * Public function defined in gapperiphbondmgr.h.
+ */
+bStatus_t GAPBondMgr_GetParameter( uint16 param, void *pValue )
+{
+ bStatus_t ret = SUCCESS; // return value
+
+ switch ( param )
+ {
+ case GAPBOND_PAIRING_MODE:
+ *((uint8*)pValue) = gapBond_PairingMode;
+ break;
+
+ case GAPBOND_INITIATE_WAIT:
+ *((uint16*)pValue) = gapBond_InitiateWait;
+ break;
+
+ case GAPBOND_MITM_PROTECTION:
+ *((uint8*)pValue) = gapBond_MITM;
+ break;
+
+ case GAPBOND_IO_CAPABILITIES:
+ *((uint8*)pValue) = gapBond_IOCap;
+ break;
+
+ case GAPBOND_OOB_ENABLED:
+ *((uint8*)pValue) = gapBond_OOBDataFlag;
+ break;
+
+ case GAPBOND_OOB_DATA:
+ VOID osal_memcpy( pValue, gapBond_OOBData, KEYLEN ) ;
+ break;
+
+ case GAPBOND_BONDING_ENABLED:
+ *((uint8*)pValue) = gapBond_Bonding;
+ break;
+
+ case GAPBOND_KEY_DIST_LIST:
+ *((uint8*)pValue) = gapBond_KeyDistList;
+ break;
+
+ case GAPBOND_DEFAULT_PASSCODE:
+ *((uint32*)pValue) = gapBond_Passcode;
+ break;
+
+ case GAPBOND_AUTO_FAIL_PAIRING:
+ *((uint8*)pValue) = gapBond_AutoFail;
+ break;
+
+ case GAPBOND_AUTO_FAIL_REASON:
+ *((uint8*)pValue) = gapBond_AutoFailReason;
+ break;
+
+ case GAPBOND_KEYSIZE:
+ *((uint8*)pValue) = gapBond_KeySize;
+ break;
+
+ default:
+ // The param value isn't part of this profile, try the GAP.
+ if ( param < TGAP_PARAMID_MAX )
+ {
+ *((uint16*)pValue) = GAP_GetParamValue( param );
+ }
+ else
+ {
+ ret = INVALIDPARAMETER;
+ }
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Notify the Bond Manager that a connection has been made.
+ *
+ * Public function defined in gapperiphbondmgr.h.
+ */
+bStatus_t GAPBondMgr_LinkEst( uint8 addrType, uint8 *pDevAddr, uint16 connHandle )
+{
+ uint8 idx; // NV Index
+ uint8 publicAddr[B_ADDR_LEN] // Place to put the public address
+ = {0, 0, 0, 0, 0, 0};
+
+ idx = GAPBondMgr_ResolveAddr( addrType, pDevAddr, publicAddr );
+ if ( idx < GAP_BONDINGS_MAX )
+ {
+ // Bonding found
+ uint8 stateFlags; // Bond state flags
+ smSecurityInfo_t localLTK; // LTK information
+ smSigningInfo_t signingInfo; // Signature information
+
+ // Initialize the NV structures
+ osal_memset( &localLTK, 0, sizeof ( smSecurityInfo_t ) );
+ osal_memset( &signingInfo, 0, sizeof ( smSigningInfo_t ) );
+
+ // Check if key is valid, then load the key
+ stateFlags = gapBondMgrGetStateFlags( idx );
+ if ( osal_snv_read( localLTKNvID(idx), sizeof ( smSecurityInfo_t ), &localLTK ) == SUCCESS )
+ {
+ if ( (localLTK.keySize >= MIN_ENC_KEYSIZE) && (localLTK.keySize <= MAX_ENC_KEYSIZE) )
+ {
+ // Load the key information for the bonding
+ VOID GAP_Bond( connHandle,
+ ((stateFlags & GAP_BONDED_STATE_AUTHENTICATED) ? TRUE : FALSE),
+ &localLTK );
+ }
+ }
+
+ // Load the Signing Key
+ if ( osal_snv_read( devCSRKNvID(idx), KEYLEN, signingInfo.srk ) == SUCCESS )
+ {
+ if ( osal_isbufset( signingInfo.srk, 0xFF, KEYLEN ) == FALSE )
+ {
+ // Load the signing information for this connection
+ VOID osal_snv_read( devSignCounterNvID(idx), sizeof ( uint32 ), &(signingInfo.signCounter) );
+ VOID GAP_Signable( connHandle,
+ ((stateFlags & GAP_BONDED_STATE_AUTHENTICATED) ? TRUE : FALSE),
+ &signingInfo );
+ }
+ }
+
+ // Has there been a service change?
+ if ( stateFlags & GAP_BONDED_STATE_SERVICE_CHANGED )
+ {
+ VOID GATT_ServiceChangedInd( connHandle, gapBondMgr_TaskID );
+ }
+ }
+ else
+ {
+ // Not bound
+ if ( gapBond_PairingMode == GAPBOND_PAIRING_MODE_INITIATE )
+ {
+ // Could add code to setup a timeout to initiate security
+ // with a Slave Security Request.
+ }
+ }
+
+ return ( SUCCESS );
+}
+
+/*********************************************************************
+ * @brief Resolve an address from bonding information.
+ *
+ * Public function defined in gapperiphbondmgr.h.
+ */
+uint8 GAPBondMgr_ResolveAddr( uint8 addrType, uint8 *pDevAddr, uint8 *pResolvedAddr )
+{
+ uint8 idx = GAP_BONDINGS_MAX;
+
+ switch ( addrType )
+ {
+ case ADDRTYPE_PUBLIC:
+ case ADDRTYPE_STATIC:
+ idx = gapBondMgrFindAddr( pDevAddr );
+ if ( (idx < GAP_BONDINGS_MAX) && (pResolvedAddr) )
+ {
+ VOID osal_memcpy( pResolvedAddr, pDevAddr, B_ADDR_LEN );
+ }
+ break;
+
+ case ADDRTYPE_PRIVATE_NONRESOLVE:
+ // This could be a reconnection address
+ idx = gapBondMgrFindReconnectAddr( pDevAddr );
+ if ( (idx < GAP_BONDINGS_MAX) && (pResolvedAddr) )
+ {
+ VOID gapBondMgrGetPublicAddr( idx, pResolvedAddr );
+ }
+ break;
+
+ case ADDRTYPE_PRIVATE_RESOLVE:
+ // Master's don't use Private Resolvable addresses
+ break;
+
+ default:
+ break;
+ }
+
+ return ( idx );
+}
+
+/*********************************************************************
+ * @brief Set/clear the service change indication in a bond record.
+ *
+ * Public function defined in gapperiphbondmgr.h.
+ */
+bStatus_t GAPBondMgr_ServiceChangeInd( uint16 connectionHandle, uint8 setParam )
+{
+ bStatus_t ret = bleNoResources; // return value
+
+ if ( connectionHandle == 0xFFFF )
+ {
+ uint8 idx; // loop counter
+
+ // Run through the bond database and update the Service Change indication
+ for ( idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ if ( gapBondMgrChangeState( idx, GAP_BONDED_STATE_SERVICE_CHANGED, setParam ) )
+ {
+ ret = SUCCESS;
+ }
+ }
+
+ // If the service change indication is TRUE, tell the connected devices
+ if ( setParam )
+ {
+ // Run connected database
+ linkDB_PerformFunc( gapBondMgrSendServiceChange );
+ }
+ }
+ else
+ {
+ // Find connection information
+ linkDBItem_t *pLinkItem = linkDB_Find( connectionHandle );
+ if ( pLinkItem )
+ {
+ uint8 idx; // loop counter
+ idx = GAPBondMgr_ResolveAddr( pLinkItem->addrType, pLinkItem->addr, NULL );
+ if ( idx < GAP_BONDINGS_MAX )
+ {
+ // Bond found, update it.
+ VOID gapBondMgrChangeState( idx, GAP_BONDED_STATE_SERVICE_CHANGED, setParam );
+ ret = SUCCESS;
+ }
+
+ // If the service change indication is TRUE, tell the connected device
+ if ( setParam )
+ {
+ gapBondMgrSendServiceChange( pLinkItem );
+ }
+ }
+ else
+ {
+ ret = bleNotConnected;
+ }
+ }
+
+ return ( ret );
+}
+
+/**
+ * @brief Register callback functions with the bond manager.
+ *
+ * NOTE: There is no need to register a passcode callback function
+ * if the passcode will be handled with the GAPBOND_DEFAULT_PASSCODE parameter.
+ *
+ * @param pCB - pointer to callback function structure.
+ *
+ * @return none
+ */
+void GAPBondMgr_Register( gapBondCBs_t *pCB )
+{
+ pGapBondCB = pCB;
+}
+
+/**
+ * @brief Respond to a passcode request.
+ *
+ * @param connectionHandle - connection handle of the connected device or 0xFFFF
+ * if all devices in database.
+ * @param status - SUCCESS if passcode is available, otherwise see @ref SMP_PAIRING_FAILED_DEFINES.
+ * @param passcode - integer value containing the passcode.
+ *
+ * @return SUCCESS - bond record found and changed,
+ * bleIncorrectMode - Link not found.
+ */
+bStatus_t GAPBondMgr_PasscodeRsp( uint16 connectionHandle, uint8 status, uint32 passcode )
+{
+ bStatus_t ret = SUCCESS;
+
+ if ( status == SUCCESS )
+ {
+ // Truncate the passcode
+ passcode = passcode % (GAP_PASSCODE_MAX + 1);
+
+ ret = GAP_PasscodeUpdate( passcode, connectionHandle );
+ if ( ret != SUCCESS )
+ {
+ VOID GAP_TerminateAuth( connectionHandle, SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED );
+ }
+ }
+ else
+ {
+ VOID GAP_TerminateAuth( connectionHandle, status );
+ }
+
+ return ret;
+}
+
+/*********************************************************************
+ * LOCAL FUNCTION PROTOTYPES
+ */
+
+/*********************************************************************
+ * @fn gapBondMgrChangeState
+ *
+ * @brief Change a state flag in the stateFlags field of the bond record.
+ *
+ * @param idx - Bond NV index
+ * @param state - state flage to set or clear
+ * @param set - TRUE to set the flag, FALSE to clear the flag
+ *
+ * @return TRUE if NV Record exists, FALSE if NV Record is empty
+ */
+static uint8 gapBondMgrChangeState( uint8 idx, uint16 state, uint8 set )
+{
+ gapBondRec_t bondRec; // Space to read a Bond record from NV
+
+ // Look for public address that is used (not all 0xFF's)
+ if ( (osal_snv_read( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec ) == SUCCESS)
+ && (osal_isbufset( bondRec.publicAddr, 0xFF, B_ADDR_LEN ) == FALSE) )
+ {
+ // Update the state of the bonded device.
+ uint8 stateFlags = bondRec.stateFlags;
+ if ( set )
+ {
+ stateFlags |= state;
+ }
+ else
+ {
+ stateFlags &= ~(state);
+ }
+
+ if ( stateFlags != bondRec.stateFlags )
+ {
+ bondRec.stateFlags = stateFlags;
+ VOID osal_snv_write( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec );
+ }
+ return ( TRUE );
+ }
+ return ( FALSE );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrAddBond
+ *
+ * @brief Save a bond from a GAP Auth Complete Event
+ *
+ * @param pBondRec - basic bond record
+ * @param pLocalLTK - LTK used by this device during pairing
+ * @param pDevLTK - LTK used by the connected device during pairing
+ * @param pIRK - IRK used by the connected device during pairing
+ * @param pSRK - SRK used by the connected device during pairing
+ * @param signCounter - Sign counter used by the connected device during pairing
+ *
+ * @return bond index
+ */
+static uint8 gapBondMgrAddBond( gapBondRec_t *pBondRec,
+ gapBondLTK_t *pLocalLTK, gapBondLTK_t *pDevLTK,
+ uint8 *pIRK, uint8 *pSRK, uint32 signCounter )
+{
+ uint8 idx;
+
+ if ( pBondRec == NULL )
+ {
+ return ( GAP_BONDINGS_MAX );
+ }
+
+ // First see if we already have an existing bond for this device
+ idx = gapBondMgrFindAddr( pBondRec->publicAddr );
+ if ( idx >= GAP_BONDINGS_MAX )
+ {
+ idx = gapBondMgrFindEmpty();
+ }
+
+ if ( idx < GAP_BONDINGS_MAX )
+ {
+ // Save the main information
+ VOID osal_snv_write( mainRecordNvID(idx), sizeof ( gapBondRec_t ), pBondRec );
+
+ // If available, save the LTK information
+ if ( pLocalLTK )
+ {
+ VOID osal_snv_write( localLTKNvID(idx), sizeof ( gapBondLTK_t ), pLocalLTK );
+ }
+
+
+ // If availabe, save the connected device's LTK information
+ if ( pDevLTK )
+ {
+ VOID osal_snv_write( devLTKNvID(idx), sizeof ( gapBondLTK_t ), pDevLTK );
+ }
+
+ // If available, save the connected device's IRK
+ if ( pIRK )
+ {
+ VOID osal_snv_write( devIRKNvID(idx), KEYLEN, pIRK );
+ }
+
+ // If available, save the connected device's Signature information
+ if ( pSRK )
+ {
+ VOID osal_snv_write( devCSRKNvID(idx), KEYLEN, pSRK );
+ VOID osal_snv_write( devSignCounterNvID(idx), sizeof ( uint32 ), &signCounter );
+ }
+ }
+
+ // Update the GAP Privacy Flag Properties
+ gapBondSetupPrivFlag();
+
+ return ( idx );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrGetStateFlags
+ *
+ * @brief Gets the state flags field of a bond record in NV
+ *
+ * @param idx
+ *
+ * @return stateFlags field
+ */
+static uint8 gapBondMgrGetStateFlags( uint8 idx )
+{
+ gapBondRec_t bondRec;
+
+ VOID osal_snv_read( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec );
+
+ return ( bondRec.stateFlags );
+
+}
+
+/*********************************************************************
+ * @fn gapBondMgrGetPublicAddr
+ *
+ * @brief Copy the public Address from a bonding record
+ *
+ * @param idx - Bond record index
+ * @param pAddr - a place to put the public address from NV
+ *
+ * @return SUCCESS if successful.
+ * Otherwise failure.
+ */
+static bStatus_t gapBondMgrGetPublicAddr( uint8 idx, uint8 *pAddr )
+{
+ bStatus_t stat; // return value
+ gapBondRec_t bondRec; // Work space for main bond record
+
+ // Check parameters
+ if ( (idx >= GAP_BONDINGS_MAX) || (pAddr == NULL) )
+ {
+ return ( INVALIDPARAMETER );
+ }
+
+ stat = osal_snv_read( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec );
+
+ if ( stat == SUCCESS )
+ {
+ VOID osal_memcpy( pAddr, bondRec.publicAddr, KEYLEN );
+ }
+
+ return ( stat );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrFindReconnectAddr
+ *
+ * @brief Look through the bonding NV entries to find a
+ * reconnection address.
+ *
+ * @param pReconnectAddr - device address to look for
+ *
+ * @return index to found bonding (0 - (GAP_BONDINGS_MAX-1),
+ * GAP_BONDINGS_MAX if no empty entries
+ */
+static uint8 gapBondMgrFindReconnectAddr( uint8 *pReconnectAddr )
+{
+ // Item doesn't exist, so create all the items
+ for ( uint8 idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ gapBondRec_t bondRec; // Bond record work place
+
+ // Read in NV Main Bond Record and compare reconnection address
+ if ( (osal_snv_read( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec ) == SUCCESS)
+ && (osal_memcmp( bondRec.reconnectAddr, pReconnectAddr, KEYLEN )) )
+ {
+ return ( idx ); // Found it
+ }
+ }
+
+ return ( GAP_BONDINGS_MAX );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrFindAddr
+ *
+ * @brief Look through the bonding NV entries to find an address.
+ *
+ * @param pDevAddr - device address to look for
+ *
+ * @return index to empty bonding (0 - (GAP_BONDINGS_MAX-1),
+ * GAP_BONDINGS_MAX if no empty entries
+ */
+static uint8 gapBondMgrFindAddr( uint8 *pDevAddr )
+{
+ // Item doesn't exist, so create all the items
+ for ( uint8 idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ gapBondRec_t bondRec; // Bond record work place
+
+ // Read in NV Main Bond Record and compare public address
+ if ( (osal_snv_read( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec ) == SUCCESS)
+ && (osal_memcmp( bondRec.publicAddr, pDevAddr, B_ADDR_LEN )) )
+ {
+ return ( idx ); // Found it
+ }
+ }
+
+ return ( GAP_BONDINGS_MAX );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrFindEmpty
+ *
+ * @brief Look through the bonding NV entries to find an empty.
+ *
+ * @param none
+ *
+ * @return index to empty bonding (0 - (GAP_BONDINGS_MAX-1),
+ * GAP_BONDINGS_MAX if no empty entries
+ */
+static uint8 gapBondMgrFindEmpty( void )
+{
+ // Item doesn't exist, so create all the items
+ for ( uint8 idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ gapBondRec_t bondRec; // Bond record work place
+
+ // Look for public address of all 0xFF's
+ if ( (osal_snv_read( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec ) == SUCCESS)
+ && (osal_isbufset( bondRec.publicAddr, 0xFF, B_ADDR_LEN )) )
+ {
+ return ( idx ); // Found one
+ }
+ }
+
+ return ( GAP_BONDINGS_MAX );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrBondTotal
+ *
+ * @brief Look through the bonding NV entries calculate the number
+ * entries.
+ *
+ * @param none
+ *
+ * @return total number of bonds found
+ */
+static uint8 gapBondMgrBondTotal( void )
+{
+ uint8 bonds = 0;
+
+ // Item doesn't exist, so create all the items
+ for ( uint8 idx = 0; idx < GAP_BONDINGS_MAX; idx++ )
+ {
+ gapBondRec_t bondRec; // Bond record work place
+
+ // Look for public address that are not 0xFF's
+ if ( (osal_snv_read( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec ) == SUCCESS)
+ && (osal_isbufset( bondRec.publicAddr, 0xFF, B_ADDR_LEN ) == FALSE) )
+ {
+ bonds++; // Found one
+ }
+ }
+
+ return ( bonds );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrEraseAllBondings
+ *
+ * @brief Write all 0xFF's to all of the bonding entries
+ *
+ * @param none
+ *
+ * @return SUCCESS if successful.
+ * Otherwise, NV_OPER_FAILED for failure.
+ */
+static bStatus_t gapBondMgrEraseAllBondings( void )
+{
+ bStatus_t stat = SUCCESS; // return value
+
+ // Item doesn't exist, so create all the items
+ for ( uint8 idx = 0; (idx < GAP_BONDINGS_MAX) && (stat == SUCCESS); idx++ )
+ {
+ // Erasing will write/create a bonding entry
+ stat = gapBondMgrEraseBonding( idx );
+ }
+
+ // Update the GAP Privacy Flag Properties
+ gapBondSetupPrivFlag();
+
+ return ( stat );
+}
+
+/*********************************************************************
+ * @fn gapBondMgrEraseBonding
+ *
+ * @brief Write all 0xFF's to the complete bonding record
+ *
+ * @param idx - bonding index
+ *
+ * @return SUCCESS if successful.
+ * Otherwise, NV_OPER_FAILED for failure.
+ */
+static bStatus_t gapBondMgrEraseBonding( uint8 idx )
+{
+ bStatus_t ret;
+ gapBondRec_t bondRec;
+ gapBondLTK_t ltk;
+
+ VOID osal_memset( &bondRec, 0xFF, sizeof ( gapBondRec_t ) );
+ VOID osal_memset( <k, 0xFF, sizeof ( gapBondLTK_t ) );
+
+ // Write out FF's over the entire bond entry.
+ ret = osal_snv_write( mainRecordNvID(idx), sizeof ( gapBondRec_t ), &bondRec );
+ ret |= osal_snv_write( localLTKNvID(idx), sizeof ( gapBondLTK_t ), <k );
+ ret |= osal_snv_write( devLTKNvID(idx), sizeof ( gapBondLTK_t ), <k );
+ ret |= osal_snv_write( devIRKNvID(idx), KEYLEN, ltk.LTK );
+ ret |= osal_snv_write( devCSRKNvID(idx), KEYLEN, ltk.LTK );
+ ret |= osal_snv_write( devSignCounterNvID(idx), sizeof ( uint32 ), ltk.LTK );
+
+ // Update the GAP Privacy Flag Properties
+ gapBondSetupPrivFlag();
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Task Initialization function.
+ *
+ * Internal function defined in gapperiphbondmgr.h.
+ */
+void GAPBondMgr_Init( uint8 task_id )
+{
+ gapBondRec_t bondRec; // Work space for Bond Record
+ gapBondMgr_TaskID = task_id; // Save task ID
+
+ // Initialize the NV needed for bonding
+ if ( osal_snv_read( mainRecordNvID(0), sizeof ( gapBondRec_t ), &bondRec ) != SUCCESS )
+ {
+ // Can't read the first entry, assume that NV doesn't exist and erase all
+ // Bond NV entries (initialize)
+ VOID gapBondMgrEraseAllBondings();
+ }
+
+ // Take over the processing of Authentication messages
+ VOID GAP_SetParamValue( TGAP_AUTH_TASK_ID, gapBondMgr_TaskID );
+
+ // Check the total number of bonds
+ gapBondSetupPrivFlag();
+}
+
+/*********************************************************************
+ * @brief Task Event Processor function.
+ *
+ * Internal function defined in gapperiphbondmgr.h.
+ */
+uint16 GAPBondMgr_ProcessEvent( uint8 task_id, uint16 events )
+{
+ VOID task_id; // OSAL required parameter that isn't used in this function
+
+ if ( events & SYS_EVENT_MSG )
+ {
+ uint8 *pMsg;
+
+ if ( (pMsg = osal_msg_receive( gapBondMgr_TaskID )) != NULL )
+ {
+ gapBondMgr_ProcessOSALMsg( (osal_event_hdr_t *)pMsg );
+
+ // Release the OSAL message
+ VOID osal_msg_deallocate( pMsg );
+ }
+
+ // return unprocessed events
+ return (events ^ SYS_EVENT_MSG);
+ }
+
+ // Discard unknown events
+ return 0;
+}
+
+/*********************************************************************
+ * @fn gapBondMgr_ProcessOSALMsg
+ *
+ * @brief Process an incoming task message.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void gapBondMgr_ProcessOSALMsg( osal_event_hdr_t *pMsg )
+{
+ switch ( pMsg->event )
+ {
+ case GAP_MSG_EVENT:
+ gapBondMgr_ProcessGAPMsg( (gapEventHdr_t *)pMsg );
+ break;
+
+ case GATT_MSG_EVENT:
+ gapBondMgr_ProcessGATTMsg( (gattMsgEvent_t *)pMsg );
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn gapRole_ProcessGAPMsg
+ *
+ * @brief Process an incoming task message.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+void gapBondMgr_ProcessGAPMsg( gapEventHdr_t *pMsg )
+{
+ switch ( pMsg->opcode )
+ {
+ case GAP_PASSKEY_NEEDED_EVENT:
+ {
+ gapPasskeyNeededEvent_t *pPkt = (gapPasskeyNeededEvent_t *)pMsg;
+
+ if ( pGapBondCB && pGapBondCB->passcodeCB )
+ {
+ // Ask app for a passcode
+ pGapBondCB->passcodeCB( pPkt->deviceAddr, pPkt->connectionHandle, pPkt->uiInputs, pPkt->uiOutputs );
+ }
+ else
+ {
+ // No app support, use the default passcode
+ if ( GAP_PasscodeUpdate( gapBond_Passcode, pPkt->connectionHandle ) != SUCCESS )
+ {
+ VOID GAP_TerminateAuth( pPkt->connectionHandle, SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED );
+ }
+ }
+ }
+ break;
+
+ case GAP_AUTHENTICATION_COMPLETE_EVENT:
+ {
+ gapAuthCompleteEvent_t *pPkt = (gapAuthCompleteEvent_t *)pMsg;
+
+ // Should we save bonding information
+ if ( (pPkt->hdr.status == SUCCESS) && (pPkt->authState & SM_AUTH_STATE_BONDING) )
+ {
+ gapBondRec_t bondRec;
+
+ VOID osal_memset( &bondRec, 0, sizeof ( gapBondRec_t ) ) ;
+
+ // Do we have a public address in the data?
+ if ( pPkt->pIdentityInfo )
+ {
+ VOID osal_memcpy( bondRec.publicAddr, pPkt->pIdentityInfo->bd_addr, B_ADDR_LEN );
+ }
+ else
+ {
+ linkDBItem_t *pLinkItem = linkDB_Find( pPkt->connectionHandle );
+ if ( pLinkItem )
+ {
+ VOID osal_memcpy( bondRec.publicAddr, pLinkItem->addr, B_ADDR_LEN );
+ }
+ else
+ {
+ // We don't have an address, so ignore the message.
+ break;
+ }
+ }
+
+ // Save off of the authentication state
+ bondRec.stateFlags |= (pPkt->authState & SM_AUTH_STATE_AUTHENTICATED) ? GAP_BONDED_STATE_AUTHENTICATED : 0;
+
+ VOID gapBondMgrAddBond( &bondRec,
+ (gapBondLTK_t *)pPkt->pSecurityInfo,
+ (gapBondLTK_t *)pPkt->pDevSecInfo,
+ ((uint8 *)((pPkt->pIdentityInfo) ? pPkt->pIdentityInfo->irk : NULL )),
+ ((uint8 *)((pPkt->pSigningInfo) ? pPkt->pSigningInfo->srk : NULL )),
+ ((uint32)((pPkt->pSigningInfo) ? pPkt->pSigningInfo->signCounter : GAP_INIT_SIGN_COUNTER )) );
+
+ }
+
+ // Call app state callback
+ if ( pGapBondCB && pGapBondCB->pairStateCB )
+ {
+ pGapBondCB->pairStateCB( GAPBOND_PAIRING_STATE_COMPLETE, pPkt->hdr.status );
+ }
+ }
+ break;
+
+ case GAP_BOND_COMPLETE_EVENT:
+ // This message is received when the bonding is complete. If hdr.status is SUCCESS
+ // then call app state callback. If hdr.status is NOT SUCCESS, the connection will be
+ // dropped at the LL because of a MIC failure, so again nothing to do.
+ if ( pGapBondCB && pGapBondCB->pairStateCB && pMsg->hdr.status == SUCCESS )
+ {
+ pGapBondCB->pairStateCB( GAPBOND_PAIRING_STATE_BONDED, pMsg->hdr.status );
+ }
+ break;
+
+ case GAP_SIGNATURE_UPDATED_EVENT:
+ {
+ uint8 idx;
+ gapSignUpdateEvent_t *pPkt = (gapSignUpdateEvent_t *)pMsg;
+
+ idx = GAPBondMgr_ResolveAddr( pPkt->addrType, pPkt->devAddr, NULL );
+ if ( idx < GAP_BONDINGS_MAX )
+ {
+ // Save the sign counter
+ VOID osal_snv_write( devSignCounterNvID(idx), sizeof ( uint32 ), &(pPkt->signCounter) );
+ }
+ }
+ break;
+
+ case GAP_PAIRING_REQ_EVENT:
+ {
+ gapPairingReqEvent_t *pPkt = (gapPairingReqEvent_t *)pMsg;
+
+ if ( gapBond_AutoFail != FALSE )
+ {
+ // Auto Fail TEST MODE (DON'T USE THIS) - Sends pre-setup reason
+ VOID GAP_TerminateAuth( pPkt->connectionHandle, gapBond_AutoFailReason );
+ }
+ else if ( gapBond_PairingMode == GAPBOND_PAIRING_MODE_NO_PAIRING )
+ {
+ // No Pairing - Send error
+ VOID GAP_TerminateAuth( pPkt->connectionHandle, SMP_PAIRING_FAILED_NOT_SUPPORTED );
+ }
+ else
+ {
+ gapAuthParams_t params;
+ linkDBItem_t *pLinkItem = linkDB_Find( pPkt->connectionHandle );
+
+ // Requesting bonding?
+ if ( pPkt->pairReq.authReq & SM_AUTH_STATE_BONDING )
+ {
+ if ( pLinkItem )
+ {
+ if ( (pLinkItem->addrType != ADDRTYPE_PUBLIC) && (pPkt->pairReq.keyDist.mIdKey == FALSE) )
+ {
+ uint8 publicAddr[B_ADDR_LEN];
+
+ // Check if we already have the public address in NV
+ if ( GAPBondMgr_ResolveAddr(pLinkItem->addrType, pLinkItem->addr, publicAddr ) == FALSE )
+ {
+ // Can't bond to a non-public address if we don't know the public address
+ VOID GAP_TerminateAuth( pPkt->connectionHandle, SMP_PAIRING_FAILED_AUTH_REQ );
+ break;
+ }
+ }
+ }
+ else
+ {
+ // Can't find the connection, ignore the message
+ break;
+ }
+ }
+
+ VOID osal_memset( ¶ms, 0, sizeof ( gapAuthParams_t ) );
+
+ // Setup the pairing parameters
+ params.connectionHandle = pPkt->connectionHandle;
+ params.secReqs.ioCaps = gapBond_IOCap;
+ params.secReqs.oobAvailable = gapBond_OOBDataFlag;
+ params.secReqs.maxEncKeySize = gapBond_KeySize;
+
+ // TBD - Should we distribute keys if bonding is turned off???
+ params.secReqs.keyDist.sEncKey = (gapBond_KeyDistList | GAPBOND_KEYDIST_SENCKEY) ? TRUE : FALSE;
+ params.secReqs.keyDist.sIdKey = (gapBond_KeyDistList | GAPBOND_KEYDIST_SIDKEY) ? TRUE : FALSE;
+ params.secReqs.keyDist.mEncKey = (gapBond_KeyDistList | GAPBOND_KEYDIST_MENCKEY) ? TRUE : FALSE;
+ params.secReqs.keyDist.mIdKey = (gapBond_KeyDistList | GAPBOND_KEYDIST_MIDKEY) ? TRUE : FALSE;
+ params.secReqs.keyDist.mSign = (gapBond_KeyDistList | GAPBOND_KEYDIST_MSIGN) ? TRUE : FALSE;
+ params.secReqs.keyDist.sSign = (gapBond_KeyDistList | GAPBOND_KEYDIST_SSIGN) ? TRUE : FALSE;
+
+ // Is bond manager setup for OOB data?
+ if ( gapBond_OOBDataFlag )
+ {
+ VOID osal_memcpy( params.secReqs.oob, gapBond_OOBData, KEYLEN );
+ }
+
+ if ( (pPkt->pairReq.authReq & SM_AUTH_STATE_BONDING) && (gapBond_Bonding) )
+ {
+ params.secReqs.authReq |= SM_AUTH_STATE_BONDING;
+ if ( pLinkItem->addrType != ADDRTYPE_PUBLIC )
+ {
+ // Force a master ID key
+ params.secReqs.keyDist.mIdKey = TRUE;
+ }
+ }
+
+ // Is Bond Manager setup for passkey protection?
+ if ( gapBond_MITM )
+ {
+ params.secReqs.authReq |= SM_AUTH_STATE_AUTHENTICATED;
+ }
+
+ VOID GAP_Authenticate( ¶ms, &(pPkt->pairReq) );
+ }
+
+ // Call app state callback
+ if ( pGapBondCB && pGapBondCB->pairStateCB )
+ {
+ pGapBondCB->pairStateCB( GAPBOND_PAIRING_STATE_STARTED, pPkt->hdr.status );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn GAPBondMgr_CheckNVLen
+ *
+ * @brief This function will check the length of an NV Item.
+ *
+ * @param id - NV ID.
+ * @param len - lengths in bytes of item.
+ *
+ * @return SUCCESS or FAILURE
+ */
+uint8 GAPBondMgr_CheckNVLen( uint8 id, uint8 len )
+{
+ uint8 stat = FAILURE;
+
+ // Convert to index
+ switch ( (id - BLE_NVID_GAP_BOND_START) % GAP_BOND_REC_IDS )
+ {
+ case GAP_BOND_REC_ID_OFFSET:
+ if ( len == sizeof ( gapBondRec_t ) )
+ {
+ stat = SUCCESS;
+ }
+ break;
+
+ case GAP_BOND_LOCAL_LTK_OFFSET:
+ case GAP_BOND_DEV_LTK_OFFSET:
+ if ( len == sizeof ( gapBondLTK_t ) )
+ {
+ stat = SUCCESS;
+ }
+ break;
+
+ case GAP_BOND_DEV_IRK_OFFSET:
+ case GAP_BOND_DEV_CSRK_OFFSET:
+ if ( len == KEYLEN )
+ {
+ stat = SUCCESS;
+ }
+ break;
+
+ case GAP_BOND_DEV_SIGN_COUNTER_OFFSET:
+ if ( len == sizeof ( uint32 ) )
+ {
+ stat = SUCCESS;
+ }
+ break;
+ }
+
+ return ( stat );
+}
+
+/*********************************************************************
+ * @fn gapBondMgr_ProcessGATTMsg
+ *
+ * @brief Process an incoming GATT message.
+ *
+ * @param pMsg - pointer to received message
+ *
+ * @return none
+ */
+static void gapBondMgr_ProcessGATTMsg( gattMsgEvent_t *pMsg )
+{
+ // Process the GATT message
+ switch ( pMsg->method )
+ {
+ case ATT_HANDLE_VALUE_CFM:
+ // Clear Service Changed flag for this client
+ VOID GAPBondMgr_ServiceChangeInd( pMsg->connHandle, 0x00 );
+ break;
+
+ default:
+ // Unknown message
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn gapBondMgrSendServiceChange
+ *
+ * @brief Tell the GATT that a service change is needed.
+ *
+ * @param pLinkItem - pointer to connection information
+ *
+ * @return none
+ */
+static void gapBondMgrSendServiceChange( linkDBItem_t *pLinkItem )
+{
+ VOID GATT_ServiceChangedInd( pLinkItem->connectionHandle, gapBondMgr_TaskID );
+}
+
+/*********************************************************************
+ * @fn gapBondSetupPrivFlag
+ *
+ * @brief Setup the GAP Privacy Flag properties.
+ *
+ * @param none
+ *
+ * @return none
+ */
+static void gapBondSetupPrivFlag( void )
+{
+ uint8 privFlagProp;
+
+ if ( gapBondMgrBondTotal() > 1 )
+ {
+ privFlagProp = GATT_PROP_READ;
+ }
+ else
+ {
+ privFlagProp = GATT_PROP_READ | GATT_PROP_WRITE;
+ }
+
+ // Setup the
+ GGS_SetParameter( GGS_PERI_PRIVACY_FLAG_PROPS, sizeof ( uint8 ), &privFlagProp );
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gapperiphbondmgr.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gapperiphbondmgr.h
new file mode 100644
index 0000000..d26b3ce
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/gapperiphbondmgr.h
@@ -0,0 +1,365 @@
+/**
+ @headerfile: gapperiphbondmgr.h
+ $Date: 2011-09-20 15:43:20 -0700 (Tue, 20 Sep 2011) $
+ $Revision: 27655 $
+
+ @mainpage TI BLE GAP Peripheral Bond Manager
+
+ This GAP profile manages bonded connections between this slave device and
+ connected master devices.
+
+ This profile will automatically respond to SM Pairing Requests from a
+ connected master (initiator) device. Then, after pairing, if keys were
+ exchanged and bonding was specified, save the device and key information
+ of the connected initiator, so that, on future connections, the bonded
+ devices can establish an encrypted link without pairing.
+
+ This GAP Bond Manager will handle all of the pairing and bonding actions
+ automatically and can be controlled by setting control parameters:
+ * GAPBondMgr_SetParameter()
+ * GAPBondMgr_GetParameter()
+
+ Reference: @ref GAPBOND_PROFILE_PARAMETERS
+
+
+ Copyright 2010 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*/
+
+#ifndef GAPPERIPHBONDMGR_H
+#define GAPPERIPHBONDMGR_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*-------------------------------------------------------------------
+ * INCLUDES
+ */
+#include "gap.h"
+
+/*-------------------------------------------------------------------
+ * CONSTANTS
+ */
+
+#if !defined ( GAP_BONDINGS_MAX )
+ #define GAP_BONDINGS_MAX 10 //!< Maximum number of bonds that can be saved in NV.
+#endif
+
+/** @defgroup GAPBOND_CONSTANTS_NAME GAP Bond Manager Constants
+ * @{
+ */
+
+/** @} End GAPBOND_CONSTANTS_NAME */
+
+/** @defgroup GAPBOND_PROFILE_PARAMETERS GAP Bond Manager Parameters
+ * @{
+ */
+#define GAPBOND_PAIRING_MODE 0x400 //!< Pairing Mode: @ref GAPBOND_PAIRING_MODE_DEFINES. Read/Write. Size is uint8. Default is GAPBOND_PAIRING_MODE_WAIT_FOR_REQ.
+#define GAPBOND_INITIATE_WAIT 0x401 //!< Pairing Mode Initiate wait timeout. This is the time it will wait for a Pairing Request before sending the Slave Initiate Request. Read/Write. Size is uint16. Default is 1000(in milliseconds).
+#define GAPBOND_MITM_PROTECTION 0x402 //!< Man-In-The-Middle (MITM) basically turns on Passkey protection in the pairing algorithm. Read/Write. Size is uint8. Default is 0(disabled).
+#define GAPBOND_IO_CAPABILITIES 0x403 //!< I/O capabilities. Read/Write. Size is uint8. Default is GAPBOND_IO_CAP_DISPLAY_ONLY @ref GAPBOND_IO_CAP_DEFINES.
+#define GAPBOND_OOB_ENABLED 0x404 //!< OOB data available for pairing algorithm. Read/Write. Size is uint8. Default is 0(disabled).
+#define GAPBOND_OOB_DATA 0x405 //!< OOB Data. Read/Write. size uint8[16]. Default is all 0's.
+#define GAPBOND_BONDING_ENABLED 0x406 //!< Request Bonding during the pairing process if enabled. Read/Write. Size is uint8. Default is 0(disabled).
+#define GAPBOND_KEY_DIST_LIST 0x407 //!< The key distribution list for bonding. size is uint8. @ref GAPBOND_KEY_DIST_DEFINES. Default is sEncKey, sIdKey, mIdKey, mSign enabled.
+#define GAPBOND_DEFAULT_PASSCODE 0x408 //!< The default passcode for MITM protection. size is uint32. Range is 0 - 999,999. Default is 0.
+#define GAPBOND_ERASE_ALLBONDS 0x409 //!< Erase all of the bonded devices. Write Only. No Size.
+#define GAPBOND_AUTO_FAIL_PAIRING 0x40A //!< TEST MODE (DO NOT USE) to automatically send a Pairing Fail when a Pairing Request is received. Read/Write. size is uint8. Default is 0 (disabled).
+#define GAPBOND_AUTO_FAIL_REASON 0x40B //!< TEST MODE (DO NOT USE) Pairing Fail reason when auto failing. Read/Write. size is uint8. Default is 0x05 (SMP_PAIRING_FAILED_NOT_SUPPORTED).
+#define GAPBOND_KEYSIZE 0x40C //!< Key Size used in pairing. Read/Write. size is uint8. Default is 16.
+/** @} End GAPBOND_PROFILE_PARAMETERS */
+
+/** @defgroup GAPBOND_PAIRING_MODE_DEFINES GAP Bond Manager Pairing Modes
+ * @{
+ */
+#define GAPBOND_PAIRING_MODE_NO_PAIRING 0x00 //!< Pairing is not allowed
+#define GAPBOND_PAIRING_MODE_WAIT_FOR_REQ 0x01 //!< Wait for a pairing request or slave security request
+#define GAPBOND_PAIRING_MODE_INITIATE 0x02 //!< Don't wait, initiate a pairing request or slave security request
+/** @} End GAPBOND_PAIRING_MODE_DEFINES */
+
+/** @defgroup GAPBOND_IO_CAP_DEFINES GAP Bond Manager I/O Capabilities
+ * @{
+ */
+#define GAPBOND_IO_CAP_DISPLAY_ONLY 0x00 //!< Display Only Device
+#define GAPBOND_IO_CAP_DISPLAY_YES_NO 0x01 //!< Display and Yes and No Capable
+#define GAPBOND_IO_CAP_KEYBOARD_ONLY 0x02 //!< Keyboard Only
+#define GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT 0x03 //!< No Display or Input Device
+#define GAPBOND_IO_CAP_KEYBOARD_DISPLAY 0x04 //!< Both Keyboard and Display Capable
+/** @} End GAPBOND_IO_CAP_DEFINES */
+
+/** @defgroup GAPBOND_KEY_DIST_DEFINES GAP Bond Manager Key Distribution
+ * @{
+ */
+#define GAPBOND_KEYDIST_SENCKEY 0x01 //!< Slave Encryption Key
+#define GAPBOND_KEYDIST_SIDKEY 0x02 //!< Slave IRK and ID information
+#define GAPBOND_KEYDIST_SSIGN 0x04 //!< Slave CSRK
+#define GAPBOND_KEYDIST_MENCKEY 0x08 //!< Master Encrypton Key
+#define GAPBOND_KEYDIST_MIDKEY 0x10 //!< Master IRK and ID information
+#define GAPBOND_KEYDIST_MSIGN 0x20 //!< Master CSRK
+/** @} End GAPBOND_IO_CAP_DEFINES */
+
+
+/** @defgroup GAPBOND_PAIRING_STATE_DEFINES GAP Bond Manager Pairing States
+ * @{
+ */
+#define GAPBOND_PAIRING_STATE_STARTED 0x00 //!< Pairing started
+#define GAPBOND_PAIRING_STATE_COMPLETE 0x01 //!< Pairing complete
+#define GAPBOND_PAIRING_STATE_BONDED 0x02 //!< Devices bonded
+/** @} End GAPBOND_PAIRING_STATE_DEFINES */
+
+/** @defgroup SMP_PAIRING_FAILED_DEFINES Pairing failure status values
+ * @{
+ */
+#define SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED 0x01 //!< The user input of the passkey failed, for example, the user cancelled the operation.
+#define SMP_PAIRING_FAILED_OOB_NOT_AVAIL 0x02 //!< The OOB data is not available
+#define SMP_PAIRING_FAILED_AUTH_REQ 0x03 //!< The pairing procedure can't be performed as authentication requirements can't be met due to IO capabilities of one or both devices
+#define SMP_PAIRING_FAILED_CONFIRM_VALUE 0x04 //!< The confirm value doesn't match the calculated compare value
+#define SMP_PAIRING_FAILED_NOT_SUPPORTED 0x05 //!< Pairing isn't supported by the device
+#define SMP_PAIRING_FAILED_ENC_KEY_SIZE 0x06 //!< The resultant encryption key size is insufficient for the security requirements of this device.
+#define SMP_PAIRING_FAILED_CMD_NOT_SUPPORTED 0x07 //!< The SMP command received is not supported on this device.
+#define SMP_PAIRING_FAILED_UNSPECIFIED 0x08 //!< Pairing failed due to an unspecified reason
+#define SMP_PAIRING_FAILED_REPEATED_ATTEMPTS 0x09 //!< Pairing or authenication procedure is disallowed because too little time has elapsed since the last pairing request or security request.
+/** @} End SMP_PAIRING_FAILED_DEFINES */
+
+/*-------------------------------------------------------------------
+ * TYPEDEFS
+ */
+typedef void (*pfnPasscodeCB_t)
+(
+ uint8 *deviceAddr, //!< address of device to pair with, and could be either public or random.
+ uint16 connectionHandle, //!< Connection handle
+ uint8 uiInputs, //!< Pairing User Interface Inputs - Ask user to input passcode
+ uint8 uiOutputs //!< Pairing User Interface Outputs - Display passcode
+ );
+
+typedef void (*pfnPairStateCB_t)
+(
+ uint8 state, //!< Pairing state @ref GAPBOND_PAIRING_STATE_DEFINES
+ uint8 status //!< Pairing status
+);
+
+/**
+ * GAP Bond Manager Callbacks.
+ */
+typedef struct
+{
+ pfnPasscodeCB_t passcodeCB; //!< Passcode callback
+ pfnPairStateCB_t pairStateCB; //!< Pairing state callback
+} gapBondCBs_t;
+
+/*-------------------------------------------------------------------
+ * MACROS
+ */
+
+/*-------------------------------------------------------------------
+ * API FUNCTIONS
+ */
+
+/**
+ * @defgroup GAPROLES_BONDMGR_API GAP Bond Manager API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Set a GAP Bond Manager parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will set the
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also,
+ * the "len" field must be set to the size of a "uint16" and the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPBOND_PROFILE_PARAMETERS
+ * @param len - length of data to write
+ * @param pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPBondMgr_SetParameter( uint16 param, uint8 len, void *pValue );
+
+/**
+ * @brief Get a GAP Bond Manager parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will get a
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also, the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPBOND_PROFILE_PARAMETERS
+ * @param pValue - pointer to location to get the value. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPBondMgr_GetParameter( uint16 param, void *pValue );
+
+/**
+ * @brief Notify the Bond Manager that a connection has been made.
+ *
+ * NOTE: The GAP Peripheral or Peripheral/Broadcaster Role profile will
+ * call this function, if they are included in the project.
+ *
+ * @param addrType - device's address type. Reference GAP_ADDR_TYPE_DEFINES in gap.h
+ * @param pDevAddr - device's address
+ * @param connHandle - connection handle
+ *
+ * @return SUCCESS, otherwise failure
+ */
+extern bStatus_t GAPBondMgr_LinkEst( uint8 addrType, uint8 *pDevAddr, uint16 connHandle );
+
+/**
+ * @brief Resolve an address from bonding information.
+ *
+ * @param addrType - device's address type. Reference GAP_ADDR_TYPE_DEFINES in gap.h
+ * @param pDevAddr - device's address
+ * @param pResolvedAddr - pointer to buffer to put the resolved address
+ *
+ * @return bonding index (0 - (GAP_BONDINGS_MAX-1) if found,
+ * GAP_BONDINGS_MAX if not found
+ */
+extern uint8 GAPBondMgr_ResolveAddr( uint8 addrType, uint8 *pDevAddr, uint8 *pResolvedAddr );
+
+/**
+ * @brief Set/clear the service change indication in a bond record.
+ *
+ * @param connectionHandle - connection handle of the connected device or 0xFFFF
+ * if all devices in database.
+ * @param setParam - TRUE to set the service change indication, FALSE to clear it.
+ *
+ * @return SUCCESS - bond record found and changed,
+ * bleNoResources - bond record not found (for 0xFFFF connectionHandle),
+ * bleNotConnected - connection not found - connectionHandle is invalid (for non-0xFFFF connectionHandle).
+ */
+extern bStatus_t GAPBondMgr_ServiceChangeInd( uint16 connectionHandle, uint8 setParam );
+
+/**
+ * @brief Register callback functions with the bond manager.
+ *
+ * NOTE: There is no need to register a passcode callback function
+ * if the passcode will be handled with the GAPBOND_DEFAULT_PASSCODE parameter.
+ *
+ * @param pCB - pointer to callback function structure.
+ *
+ * @return none
+ */
+extern void GAPBondMgr_Register( gapBondCBs_t *pCB );
+
+/**
+ * @brief Respond to a passcode request.
+ *
+ * @param connectionHandle - connection handle of the connected device or 0xFFFF
+ * if all devices in database.
+ * @param status - SUCCESS if passcode is available, otherwise see @ref SMP_PAIRING_FAILED_DEFINES.
+ * @param passcode - integer value containing the passcode.
+ *
+ * @return SUCCESS - bond record found and changed,
+ * bleIncorrectMode - Link not found.
+ */
+extern bStatus_t GAPBondMgr_PasscodeRsp( uint16 connectionHandle, uint8 status, uint32 passcode );
+
+/**
+ * @brief This is a bypass mechanism to allow the bond manager to process
+ * GAP messages.
+ *
+ * NOTE: This is an advanced feature and shouldn't be called unless
+ * the normal GAP Bond Manager task ID registration is overridden.
+ *
+ * @param pMsg - GAP event message
+ *
+ * @return none
+ */
+extern void gapBondMgr_ProcessGAPMsg( gapEventHdr_t *pMsg );
+
+/**
+ * @brief This function will check the length of a Bond Manager NV Item.
+ *
+ * @param id - NV ID.
+ * @param len - lengths in bytes of item.
+ *
+ * @return SUCCESS or FAILURE
+ */
+extern uint8 GAPBondMgr_CheckNVLen( uint8 id, uint8 len );
+
+/**
+ * @} End GAPROLES_BONDMGR_API
+ */
+
+
+
+/*-------------------------------------------------------------------
+ * TASK FUNCTIONS - Don't call these. These are system functions.
+ */
+
+/**
+ * @internal
+ *
+ * @brief Initialization function for the GAP Bond Manager Task.
+ * This is called during initialization and should contain
+ * any application specific initialization (ie. hardware
+ * initialization/setup, table initialization, power up
+ * notificaiton ... ).
+ *
+ * @param the ID assigned by OSAL. This ID should be
+ * used to send messages and set timers.
+ *
+ * @return void
+ */
+extern void GAPBondMgr_Init( uint8 task_id );
+
+/**
+ * @internal
+ *
+ * @brief GAP Bond Manager 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 events not processed
+ */
+extern uint16 GAPBondMgr_ProcessEvent( uint8 task_id, uint16 events );
+
+/*-------------------------------------------------------------------
+-------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GAPPERIPHBONDMGR_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/observer.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/observer.c
new file mode 100644
index 0000000..e1b647a
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/observer.c
@@ -0,0 +1,316 @@
+/**************************************************************************************************
+ Filename: observer.c
+ Revised: $Date: 2011-05-05 10:12:10 -0700 (Thu, 05 May 2011) $
+ Revision: $Revision: 25871 $
+
+ Description: GAP Observer Role
+
+
+ Copyright 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "osal_cbTimer.h"
+#include "osal_snv.h"
+#include "hci_tl.h"
+#include "gap.h"
+
+#include "observer.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+// Task ID
+static uint8 gapObserverRoleTaskId;
+
+// App callbacks
+static gapObserverRoleCB_t *pGapObserverRoleCB;
+
+/*********************************************************************
+ * Profile Parameters - reference GAPCENTRALROLE_PROFILE_PARAMETERS for
+ * descriptions
+ */
+
+static uint8 gapObserverRoleBdAddr[B_ADDR_LEN];
+static uint8 gapObserverRoleMaxScanRes = 0;
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static void gapObserverRole_ProcessOSALMsg( osal_event_hdr_t *pMsg );
+static void gapObserverRole_ProcessGAPMsg( gapEventHdr_t *pMsg );
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/**
+ * @brief Start the device in Observer role. This function is typically
+ * called once during system startup.
+ *
+ * Public function defined in observer.h.
+ */
+bStatus_t GAPObserverRole_StartDevice( gapObserverRoleCB_t *pAppCallbacks )
+{
+ if ( pAppCallbacks )
+ {
+ pGapObserverRoleCB = pAppCallbacks;
+ }
+
+ return GAP_DeviceInit( gapObserverRoleTaskId, GAP_PROFILE_OBSERVER,
+ gapObserverRoleMaxScanRes, NULL, NULL, NULL );
+}
+
+/**
+ * @brief Set a parameter in the Observer Profile.
+ *
+ * Public function defined in observer.h.
+ */
+bStatus_t GAPObserverRole_SetParameter( uint16 param, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case GAPOBSERVERROLE_MAX_SCAN_RES:
+ if ( len == sizeof ( uint8 ) )
+ {
+ gapObserverRoleMaxScanRes = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Get a parameter in the Observer Profile.
+ *
+ * Public function defined in observer.h.
+ */
+bStatus_t GAPObserverRole_GetParameter( uint16 param, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case GAPOBSERVERROLE_BD_ADDR:
+ VOID osal_memcpy( pValue, gapObserverRoleBdAddr, B_ADDR_LEN ) ;
+ break;
+
+ case GAPOBSERVERROLE_MAX_SCAN_RES:
+ *((uint8*)pValue) = gapObserverRoleMaxScanRes;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Start a device discovery scan.
+ *
+ * Public function defined in observer.h.
+ */
+bStatus_t GAPObserverRole_StartDiscovery( uint8 mode, uint8 activeScan, uint8 whiteList )
+{
+ gapDevDiscReq_t params;
+
+ params.taskID = gapObserverRoleTaskId;
+ params.mode = mode;
+ params.activeScan = activeScan;
+ params.whiteList = whiteList;
+
+ return GAP_DeviceDiscoveryRequest( ¶ms );
+}
+
+/**
+ * @brief Cancel a device discovery scan.
+ *
+ * Public function defined in observer.h.
+ */
+bStatus_t GAPObserverRole_CancelDiscovery( void )
+{
+ return GAP_DeviceDiscoveryCancel( gapObserverRoleTaskId );
+}
+
+/**
+ * @brief Observer Profile Task initialization function.
+ *
+ * @param taskId - Task ID.
+ *
+ * @return void
+ */
+void GAPObserverRole_Init( uint8 taskId )
+{
+ gapObserverRoleTaskId = taskId;
+
+ // Register for HCI messages (for RSSI)
+ GAP_RegisterForHCIMsgs( taskId );
+}
+
+/**
+ * @brief Observer Profile Task event processing function.
+ *
+ * @param taskId - Task ID
+ * @param events - Events.
+ *
+ * @return events not processed
+ */
+uint16 GAPObserverRole_ProcessEvent( uint8 taskId, uint16 events )
+{
+ if ( events & SYS_EVENT_MSG )
+ {
+ uint8 *pMsg;
+
+ if ( (pMsg = osal_msg_receive( gapObserverRoleTaskId )) != NULL )
+ {
+ gapObserverRole_ProcessOSALMsg( (osal_event_hdr_t *) pMsg );
+
+ // Release the OSAL message
+ VOID osal_msg_deallocate( pMsg );
+ }
+
+ // return unprocessed events
+ return (events ^ SYS_EVENT_MSG);
+ }
+
+ // Discard unknown events
+ return 0;
+}
+
+/*********************************************************************
+ * @fn gapObserverRole_ProcessOSALMsg
+ *
+ * @brief Process an incoming task message.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void gapObserverRole_ProcessOSALMsg( osal_event_hdr_t *pMsg )
+{
+ switch ( pMsg->event )
+ {
+ case HCI_GAP_EVENT_EVENT:
+ if ( pMsg->status == HCI_COMMAND_COMPLETE_EVENT_CODE )
+ {
+ //hciEvt_CmdComplete_t *pPkt = (hciEvt_CmdComplete_t *) pMsg;
+ }
+ break;
+
+ case GAP_MSG_EVENT:
+ gapObserverRole_ProcessGAPMsg( (gapEventHdr_t *) pMsg );
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn gapObserverRole_ProcessGAPMsg
+ *
+ * @brief Process an incoming task message from GAP.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void gapObserverRole_ProcessGAPMsg( gapEventHdr_t *pMsg )
+{
+ switch ( pMsg->opcode )
+ {
+ case GAP_DEVICE_INIT_DONE_EVENT:
+ {
+ gapDeviceInitDoneEvent_t *pPkt = (gapDeviceInitDoneEvent_t *) pMsg;
+
+ if ( pPkt->hdr.status == SUCCESS )
+ {
+ // Save off the information
+ VOID osal_memcpy( gapObserverRoleBdAddr, pPkt->devAddr, B_ADDR_LEN );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ // Pass event to app
+ if ( pGapObserverRoleCB && pGapObserverRoleCB->eventCB )
+ {
+ pGapObserverRoleCB->eventCB( (gapObserverRoleEvent_t *) pMsg );
+ }
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/observer.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/observer.h
new file mode 100644
index 0000000..8dcdf4f
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/observer.h
@@ -0,0 +1,230 @@
+/**
+ @headerfile: observer.h
+ $Date: 2011-03-11 15:48:31 -0800 (Fri, 11 Mar 2011) $
+ $Revision: 25393 $
+
+ @mainpage TI BLE GAP Observer Role
+
+ This GAP profile only discovers.
+
+ Copyright 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*/
+
+#ifndef OBSERVER_H
+#define OBSERVER_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "gap.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/** @defgroup GAPOBSERVERROLE_PROFILE_PARAMETERS GAP Observer Role Parameters
+ * @{
+ */
+#define GAPOBSERVERROLE_BD_ADDR 0x400 //!< Device's Address. Read Only. Size is uint8[B_ADDR_LEN]. This item is read from the controller.
+#define GAPOBSERVERROLE_MAX_SCAN_RES 0x401 //!< Maximum number of discover scan results to receive. Default is 0 = unlimited.
+/** @} End GAPOBSERVERROLE_PROFILE_PARAMETERS */
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/**
+ * Observer Event Structure
+ */
+typedef union
+{
+ gapEventHdr_t gap; //!< GAP_MSG_EVENT and status.
+ gapDeviceInitDoneEvent_t initDone; //!< GAP initialization done.
+ gapDeviceInfoEvent_t deviceInfo; //!< Discovery device information event structure.
+ gapDevDiscEvent_t discCmpl; //!< Discovery complete event structure.
+} gapObserverRoleEvent_t;
+
+/**
+ * RSSI Read Callback Function
+ */
+typedef void (*pfnGapObserverRoleRssiCB_t)
+(
+ uint16 connHandle, //!< Connection handle.
+ int8 rssi //!< New RSSI value.
+);
+
+/**
+ * Observer Event Callback Function
+ */
+typedef void (*pfnGapObserverRoleEventCB_t)
+(
+ gapObserverRoleEvent_t *pEvent //!< Pointer to event structure.
+);
+
+/**
+ * Observer Callback Structure
+ */
+typedef struct
+{
+ pfnGapObserverRoleRssiCB_t rssiCB; //!< RSSI callback.
+ pfnGapObserverRoleEventCB_t eventCB; //!< Event callback.
+} gapObserverRoleCB_t;
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*-------------------------------------------------------------------
+ * Observer Profile Public APIs
+ */
+
+/**
+ * @defgroup OBSERVER_PROFILE_API Observer Profile API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Start the device in Observer role. This function is typically
+ * called once during system startup.
+ *
+ * @param pAppCallbacks - pointer to application callbacks
+ *
+ * @return SUCCESS: Operation successful.
+ * bleAlreadyInRequestedMode: Device already started.
+ */
+extern bStatus_t GAPObserverRole_StartDevice( gapObserverRoleCB_t *pAppCallbacks );
+
+/**
+ * @brief Set a parameter in the Observer Profile.
+ *
+ * @param param - profile parameter ID: @ref GAPOBSERVERROLE_PROFILE_PARAMETERS
+ * @param len - length of data to write
+ * @param pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type.
+ *
+ * @return SUCCESS: Operation successful.
+ * INVALIDPARAMETER: Invalid parameter ID.
+ */
+extern bStatus_t GAPObserverRole_SetParameter( uint16 param, uint8 len, void *pValue );
+
+/**
+ * @brief Get a parameter in the Observer Profile.
+ *
+ * @param param - profile parameter ID: @ref GAPOBSERVERROLE_PROFILE_PARAMETERS
+ * @param pValue - pointer to buffer to contain the read data
+ *
+ * @return SUCCESS: Operation successful.
+ * INVALIDPARAMETER: Invalid parameter ID.
+ */
+extern bStatus_t GAPObserverRole_GetParameter( uint16 param, void *pValue );
+
+/**
+ * @brief Start a device discovery scan.
+ *
+ * @param mode - discovery mode: @ref GAP_DEVDISC_MODE_DEFINES
+ * @param activeScan - TRUE to perform active scan
+ * @param whiteList - TRUE to only scan for devices in the white list
+ *
+ * @return SUCCESS: Discovery scan started.
+ * bleIncorrectMode: Invalid profile role.
+ * bleAlreadyInRequestedMode: Not available.
+ */
+extern bStatus_t GAPObserverRole_StartDiscovery( uint8 mode, uint8 activeScan, uint8 whiteList );
+
+/**
+ * @brief Cancel a device discovery scan.
+ *
+ * @return SUCCESS: Cancel started.
+ * bleInvalidTaskID: Not the task that started discovery.
+ * bleIncorrectMode: Not in discovery mode.
+ */
+extern bStatus_t GAPObserverRole_CancelDiscovery( void );
+
+/**
+ * @}
+ */
+
+/*-------------------------------------------------------------------
+ * TASK API - These functions must only be called by OSAL.
+ */
+
+/**
+ * @internal
+ *
+ * @brief Observer Profile Task initialization function.
+ *
+ * @param taskId - Task ID.
+ *
+ * @return void
+ */
+extern void GAPObserverRole_Init( uint8 taskId );
+
+/**
+ * @internal
+ *
+ * @brief Observer Profile Task event processing function.
+ *
+ * @param taskId - Task ID
+ * @param events - Events.
+ *
+ * @return events not processed
+ */
+extern uint16 GAPObserverRole_ProcessEvent( uint8 taskId, uint16 events );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OBSERVER_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/peripheral.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/peripheral.c
new file mode 100644
index 0000000..b07e46f
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/peripheral.c
@@ -0,0 +1,1253 @@
+/**************************************************************************************************
+ Filename: peripheral.c
+ Revised: $Date: 2013-05-01 13:58:23 -0700 (Wed, 01 May 2013) $
+ Revision: $Revision: 34101 $
+
+ Description: GAP Peripheral Role
+
+
+ Copyright 2009 - 2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "hci_tl.h"
+#include "l2cap.h"
+#include "gap.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "osal_snv.h"
+
+#include "peripheral.h"
+#include "gapbondmgr.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+// Profile Events
+#define START_ADVERTISING_EVT 0x0001 // Start Advertising
+#define RSSI_READ_EVT 0x0002 // Read RSSI
+#define START_CONN_UPDATE_EVT 0x0004 // Start Connection Update Procedure
+#define CONN_PARAM_TIMEOUT_EVT 0x0008 // Connection Parameters Update Timeout
+
+#define DEFAULT_ADVERT_OFF_TIME 30000 // 30 seconds
+
+#define RSSI_NOT_AVAILABLE 127
+
+#define DEFAULT_MIN_CONN_INTERVAL 0x0006 // 100 milliseconds
+#define DEFAULT_MAX_CONN_INTERVAL 0x0C80 // 4 seconds
+
+#define MIN_CONN_INTERVAL 0x0006
+#define MAX_CONN_INTERVAL 0x0C80
+
+#define DEFAULT_TIMEOUT_MULTIPLIER 1000
+
+#define CONN_INTERVAL_MULTIPLIER 6
+
+#define MIN_SLAVE_LATENCY 0
+#define MAX_SLAVE_LATENCY 500
+
+#define MIN_TIMEOUT_MULTIPLIER 0x000a
+#define MAX_TIMEOUT_MULTIPLIER 0x0c80
+
+#define MAX_TIMEOUT_VALUE 0xFFFF
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+static uint8 gapRole_TaskID; // Task ID for internal task/event processing
+
+static gaprole_States_t gapRole_state;
+
+/*********************************************************************
+ * Profile Parameters - reference GAPROLE_PROFILE_PARAMETERS for
+ * descriptions
+ */
+
+static uint8 gapRole_profileRole;
+static uint8 gapRole_IRK[KEYLEN];
+static uint8 gapRole_SRK[KEYLEN];
+static uint32 gapRole_signCounter;
+static uint8 gapRole_bdAddr[B_ADDR_LEN];
+static uint8 gapRole_AdvEnabled = TRUE;
+static uint16 gapRole_AdvertOffTime = DEFAULT_ADVERT_OFF_TIME;
+static uint8 gapRole_AdvertDataLen = 3;
+static uint8 gapRole_AdvertData[B_MAX_ADV_LEN] =
+{
+ 0x02, // length of this data
+ GAP_ADTYPE_FLAGS, // AD Type = Flags
+ // Limited Discoverable & BR/EDR not supported
+ (GAP_ADTYPE_FLAGS_GENERAL | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED),
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+};
+static uint8 gapRole_ScanRspDataLen = 0;
+static uint8 gapRole_ScanRspData[B_MAX_ADV_LEN] = {0};
+static uint8 gapRole_AdvEventType;
+static uint8 gapRole_AdvDirectType;
+static uint8 gapRole_AdvDirectAddr[B_ADDR_LEN] = {0};
+static uint8 gapRole_AdvChanMap;
+static uint8 gapRole_AdvFilterPolicy;
+
+static uint16 gapRole_ConnectionHandle = INVALID_CONNHANDLE;
+static uint16 gapRole_RSSIReadRate = 0;
+
+static uint8 gapRole_ConnectedDevAddr[B_ADDR_LEN] = {0};
+
+static uint8 gapRole_ParamUpdateEnable = FALSE;
+static uint16 gapRole_MinConnInterval = DEFAULT_MIN_CONN_INTERVAL;
+static uint16 gapRole_MaxConnInterval = DEFAULT_MAX_CONN_INTERVAL;
+static uint16 gapRole_SlaveLatency = MIN_SLAVE_LATENCY;
+static uint16 gapRole_TimeoutMultiplier = DEFAULT_TIMEOUT_MULTIPLIER;
+
+static uint16 gapRole_ConnInterval = 0;
+static uint16 gapRole_ConnSlaveLatency = 0;
+static uint16 gapRole_ConnTimeout = 0;
+
+static uint8 paramUpdateNoSuccessOption = GAPROLE_NO_ACTION;
+
+// Application callbacks
+static gapRolesCBs_t *pGapRoles_AppCGs = NULL;
+static gapRolesParamUpdateCB_t *pGapRoles_ParamUpdateCB = NULL;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static void gapRole_ProcessOSALMsg( osal_event_hdr_t *pMsg );
+static void gapRole_ProcessGAPMsg( gapEventHdr_t *pMsg );
+static void gapRole_SetupGAP( void );
+static void gapRole_HandleParamUpdateNoSuccess( void );
+static void gapRole_startConnUpdate( uint8 handleFailure );
+
+/*********************************************************************
+ * NETWORK LAYER CALLBACKS
+ */
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @brief Set a GAP Role parameter.
+ *
+ * Public function defined in peripheral.h.
+ */
+bStatus_t GAPRole_SetParameter( uint16 param, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case GAPROLE_IRK:
+ if ( len == KEYLEN )
+ {
+ VOID osal_memcpy( gapRole_IRK, pValue, KEYLEN ) ;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_SRK:
+ if ( len == KEYLEN )
+ {
+ VOID osal_memcpy( gapRole_SRK, pValue, KEYLEN ) ;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_SIGNCOUNTER:
+ if ( len == sizeof ( uint32 ) )
+ {
+ gapRole_signCounter = *((uint32*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADVERT_ENABLED:
+ if ( len == sizeof( uint8 ) )
+ {
+ uint8 oldAdvEnabled = gapRole_AdvEnabled;
+ gapRole_AdvEnabled = *((uint8*)pValue);
+
+ if ( (oldAdvEnabled) && (gapRole_AdvEnabled == FALSE) )
+ {
+ // Turn off Advertising
+ if ( gapRole_state == GAPROLE_ADVERTISING )
+ {
+ VOID GAP_EndDiscoverable( gapRole_TaskID );
+ }
+ }
+ else if ( (oldAdvEnabled == FALSE) && (gapRole_AdvEnabled) )
+ {
+ // Turn on Advertising
+ if ( (gapRole_state == GAPROLE_STARTED)
+ || (gapRole_state == GAPROLE_WAITING)
+ || (gapRole_state == GAPROLE_WAITING_AFTER_TIMEOUT) )
+ {
+ VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );
+ }
+ }
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADVERT_OFF_TIME:
+ if ( len == sizeof ( uint16 ) )
+ {
+ gapRole_AdvertOffTime = *((uint16*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADVERT_DATA:
+ if ( len <= B_MAX_ADV_LEN )
+ {
+ VOID osal_memset( gapRole_AdvertData, 0, B_MAX_ADV_LEN );
+ VOID osal_memcpy( gapRole_AdvertData, pValue, len );
+ gapRole_AdvertDataLen = len;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_SCAN_RSP_DATA:
+ if ( len <= B_MAX_ADV_LEN )
+ {
+ VOID osal_memset( gapRole_ScanRspData, 0, B_MAX_ADV_LEN );
+ VOID osal_memcpy( gapRole_ScanRspData, pValue, len );
+ gapRole_ScanRspDataLen = len;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_EVENT_TYPE:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAP_ADTYPE_ADV_NONCONN_IND) )
+ {
+ gapRole_AdvEventType = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_DIRECT_TYPE:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= ADDRTYPE_PRIVATE_RESOLVE) )
+ {
+ gapRole_AdvDirectType = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_DIRECT_ADDR:
+ if ( len == B_ADDR_LEN )
+ {
+ VOID osal_memcpy( gapRole_AdvDirectAddr, pValue, B_ADDR_LEN ) ;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_CHANNEL_MAP:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= 0x07) )
+ {
+ gapRole_AdvChanMap = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_FILTER_POLICY:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAP_FILTER_POLICY_WHITE) )
+ {
+ gapRole_AdvFilterPolicy = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_RSSI_READ_RATE:
+ if ( len == sizeof ( uint16 ) )
+ {
+ gapRole_RSSIReadRate = *((uint16*)pValue);
+
+ if ( (gapRole_RSSIReadRate) && (gapRole_state == GAPROLE_CONNECTED) )
+ {
+ // Start the RSSI Reads
+ VOID osal_start_timerEx( gapRole_TaskID, RSSI_READ_EVT, gapRole_RSSIReadRate );
+ }
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_PARAM_UPDATE_ENABLE:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )
+ {
+ gapRole_ParamUpdateEnable = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_MIN_CONN_INTERVAL:
+ {
+ uint16 newInterval = *((uint16*)pValue);
+ if ( len == sizeof ( uint16 ) &&
+ ( newInterval >= MIN_CONN_INTERVAL ) &&
+ ( newInterval <= MAX_CONN_INTERVAL ) )
+ {
+ gapRole_MinConnInterval = newInterval;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ }
+ break;
+
+ case GAPROLE_MAX_CONN_INTERVAL:
+ {
+ uint16 newInterval = *((uint16*)pValue);
+ if ( len == sizeof ( uint16 ) &&
+ ( newInterval >= MIN_CONN_INTERVAL) &&
+ ( newInterval <= MAX_CONN_INTERVAL) )
+ {
+ gapRole_MaxConnInterval = newInterval;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ }
+ break;
+
+ case GAPROLE_SLAVE_LATENCY:
+ {
+ uint16 latency = *((uint16*)pValue);
+ if ( len == sizeof ( uint16 ) && (latency < MAX_SLAVE_LATENCY) )
+ {
+ gapRole_SlaveLatency = latency;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ }
+ break;
+
+ case GAPROLE_TIMEOUT_MULTIPLIER:
+ {
+ uint16 newTimeout = *((uint16*)pValue);
+ if ( len == sizeof ( uint16 )
+ && (newTimeout >= MIN_TIMEOUT_MULTIPLIER) && (newTimeout <= MAX_TIMEOUT_MULTIPLIER) )
+ {
+ gapRole_TimeoutMultiplier = newTimeout;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ }
+ break;
+
+ case GAPROLE_PARAM_UPDATE_REQ:
+ {
+ uint8 req = *((uint8*)pValue);
+ if ( len == sizeof ( uint8 ) && (req == TRUE) )
+ {
+ // Make sure we don't send an L2CAP Connection Parameter Update Request
+ // command within TGAP(conn_param_timeout) of an L2CAP Connection Parameter
+ // Update Response being received.
+ if ( osal_get_timeoutEx( gapRole_TaskID, CONN_PARAM_TIMEOUT_EVT ) == 0 )
+ {
+ // Start connection update procedure
+ gapRole_startConnUpdate( GAPROLE_NO_ACTION );
+
+ // Connection update requested by app, cancel such pending procedure (if active)
+ VOID osal_stop_timerEx( gapRole_TaskID, START_CONN_UPDATE_EVT );
+ }
+ else
+ {
+ ret = blePending;
+ }
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ }
+ break;
+
+ default:
+ // The param value isn't part of this profile, try the GAP.
+ if ( (param < TGAP_PARAMID_MAX) && (len == sizeof ( uint16 )) )
+ {
+ ret = GAP_SetParamValue( param, *((uint16*)pValue) );
+ }
+ else
+ {
+ ret = INVALIDPARAMETER;
+ }
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Get a GAP Role parameter.
+ *
+ * Public function defined in peripheral.h.
+ */
+bStatus_t GAPRole_GetParameter( uint16 param, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case GAPROLE_PROFILEROLE:
+ *((uint8*)pValue) = gapRole_profileRole;
+ break;
+
+ case GAPROLE_IRK:
+ VOID osal_memcpy( pValue, gapRole_IRK, KEYLEN ) ;
+ break;
+
+ case GAPROLE_SRK:
+ VOID osal_memcpy( pValue, gapRole_SRK, KEYLEN ) ;
+ break;
+
+ case GAPROLE_SIGNCOUNTER:
+ *((uint32*)pValue) = gapRole_signCounter;
+ break;
+
+ case GAPROLE_BD_ADDR:
+ VOID osal_memcpy( pValue, gapRole_bdAddr, B_ADDR_LEN ) ;
+ break;
+
+ case GAPROLE_ADVERT_ENABLED:
+ *((uint8*)pValue) = gapRole_AdvEnabled;
+ break;
+
+ case GAPROLE_ADVERT_OFF_TIME:
+ *((uint16*)pValue) = gapRole_AdvertOffTime;
+ break;
+
+ case GAPROLE_ADVERT_DATA:
+ VOID osal_memcpy( pValue , gapRole_AdvertData, gapRole_AdvertDataLen );
+ break;
+
+ case GAPROLE_SCAN_RSP_DATA:
+ VOID osal_memcpy( pValue, gapRole_ScanRspData, gapRole_ScanRspDataLen ) ;
+ break;
+
+ case GAPROLE_ADV_EVENT_TYPE:
+ *((uint8*)pValue) = gapRole_AdvEventType;
+ break;
+
+ case GAPROLE_ADV_DIRECT_TYPE:
+ *((uint8*)pValue) = gapRole_AdvDirectType;
+ break;
+
+ case GAPROLE_ADV_DIRECT_ADDR:
+ VOID osal_memcpy( pValue, gapRole_AdvDirectAddr, B_ADDR_LEN ) ;
+ break;
+
+ case GAPROLE_ADV_CHANNEL_MAP:
+ *((uint8*)pValue) = gapRole_AdvChanMap;
+ break;
+
+ case GAPROLE_ADV_FILTER_POLICY:
+ *((uint8*)pValue) = gapRole_AdvFilterPolicy;
+ break;
+
+ case GAPROLE_CONNHANDLE:
+ *((uint16*)pValue) = gapRole_ConnectionHandle;
+ break;
+
+ case GAPROLE_RSSI_READ_RATE:
+ *((uint16*)pValue) = gapRole_RSSIReadRate;
+ break;
+
+ case GAPROLE_PARAM_UPDATE_ENABLE:
+ *((uint16*)pValue) = gapRole_ParamUpdateEnable;
+ break;
+
+ case GAPROLE_MIN_CONN_INTERVAL:
+ *((uint16*)pValue) = gapRole_MinConnInterval;
+ break;
+
+ case GAPROLE_MAX_CONN_INTERVAL:
+ *((uint16*)pValue) = gapRole_MaxConnInterval;
+ break;
+
+ case GAPROLE_SLAVE_LATENCY:
+ *((uint16*)pValue) = gapRole_SlaveLatency;
+ break;
+
+ case GAPROLE_TIMEOUT_MULTIPLIER:
+ *((uint16*)pValue) = gapRole_TimeoutMultiplier;
+ break;
+
+ case GAPROLE_CONN_BD_ADDR:
+ VOID osal_memcpy( pValue, gapRole_ConnectedDevAddr, B_ADDR_LEN ) ;
+ break;
+
+ case GAPROLE_CONN_INTERVAL:
+ *((uint16*)pValue) = gapRole_ConnInterval;
+ break;
+
+ case GAPROLE_CONN_LATENCY:
+ *((uint16*)pValue) = gapRole_ConnSlaveLatency;
+ break;
+
+ case GAPROLE_CONN_TIMEOUT:
+ *((uint16*)pValue) = gapRole_ConnTimeout;
+ break;
+
+ default:
+ // The param value isn't part of this profile, try the GAP.
+ if ( param < TGAP_PARAMID_MAX )
+ {
+ *((uint16*)pValue) = GAP_GetParamValue( param );
+ }
+ else
+ {
+ ret = INVALIDPARAMETER;
+ }
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Does the device initialization.
+ *
+ * Public function defined in peripheral.h.
+ */
+bStatus_t GAPRole_StartDevice( gapRolesCBs_t *pAppCallbacks )
+{
+ if ( gapRole_state == GAPROLE_INIT )
+ {
+ // Clear all of the Application callbacks
+ if ( pAppCallbacks )
+ {
+ pGapRoles_AppCGs = pAppCallbacks;
+ }
+
+ // Start the GAP
+ gapRole_SetupGAP();
+
+ return ( SUCCESS );
+ }
+ else
+ {
+ return ( bleAlreadyInRequestedMode );
+ }
+}
+
+/*********************************************************************
+ * @brief Register application's callbacks.
+ *
+ * Public function defined in peripheral.h.
+ */
+void GAPRole_RegisterAppCBs( gapRolesParamUpdateCB_t *pParamUpdateCB )
+{
+ if ( pParamUpdateCB != NULL )
+ {
+ pGapRoles_ParamUpdateCB = pParamUpdateCB;
+ }
+}
+
+/*********************************************************************
+ * @brief Terminates the existing connection.
+ *
+ * Public function defined in peripheral.h.
+ */
+bStatus_t GAPRole_TerminateConnection( void )
+{
+ if ( gapRole_state == GAPROLE_CONNECTED )
+ {
+ return ( GAP_TerminateLinkReq( gapRole_TaskID, gapRole_ConnectionHandle ) );
+ }
+ else
+ {
+ return ( bleIncorrectMode );
+ }
+}
+
+/*********************************************************************
+ * LOCAL FUNCTION PROTOTYPES
+ */
+
+/*********************************************************************
+ * @brief Task Initialization function.
+ *
+ * Internal function defined in peripheral.h.
+ */
+void GAPRole_Init( uint8 task_id )
+{
+ gapRole_TaskID = task_id;
+
+ gapRole_state = GAPROLE_INIT;
+ gapRole_ConnectionHandle = INVALID_CONNHANDLE;
+
+ GAP_RegisterForHCIMsgs( gapRole_TaskID );
+
+ // Initialize the Profile Advertising and Connection Parameters
+ gapRole_profileRole = GAP_PROFILE_PERIPHERAL;
+ VOID osal_memset( gapRole_IRK, 0, KEYLEN );
+ VOID osal_memset( gapRole_SRK, 0, KEYLEN );
+ gapRole_signCounter = 0;
+ gapRole_AdvEventType = GAP_ADTYPE_ADV_IND;
+ gapRole_AdvDirectType = ADDRTYPE_PUBLIC;
+ gapRole_AdvChanMap = GAP_ADVCHAN_ALL;
+ gapRole_AdvFilterPolicy = GAP_FILTER_POLICY_ALL;
+
+ // Restore Items from NV
+ VOID osal_snv_read( BLE_NVID_IRK, KEYLEN, gapRole_IRK );
+ VOID osal_snv_read( BLE_NVID_CSRK, KEYLEN, gapRole_SRK );
+ VOID osal_snv_read( BLE_NVID_SIGNCOUNTER, sizeof( uint32 ), &gapRole_signCounter );
+}
+
+/*********************************************************************
+ * @brief Task Event Processor function.
+ *
+ * Internal function defined in peripheral.h.
+ */
+uint16 GAPRole_ProcessEvent( uint8 task_id, uint16 events )
+{
+ VOID task_id; // OSAL required parameter that isn't used in this function
+
+ if ( events & SYS_EVENT_MSG )
+ {
+ uint8 *pMsg;
+
+ if ( (pMsg = osal_msg_receive( gapRole_TaskID )) != NULL )
+ {
+ gapRole_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 & GAP_EVENT_SIGN_COUNTER_CHANGED )
+ {
+ // Sign counter changed, save it to NV
+ VOID osal_snv_write( BLE_NVID_SIGNCOUNTER, sizeof( uint32 ), &gapRole_signCounter );
+
+ return ( events ^ GAP_EVENT_SIGN_COUNTER_CHANGED );
+ }
+
+ if ( events & START_ADVERTISING_EVT )
+ {
+ if ( gapRole_AdvEnabled )
+ {
+ gapAdvertisingParams_t params;
+
+ // Setup advertisement parameters
+ params.eventType = gapRole_AdvEventType;
+ params.initiatorAddrType = gapRole_AdvDirectType;
+ VOID osal_memcpy( params.initiatorAddr, gapRole_AdvDirectAddr, B_ADDR_LEN );
+ params.channelMap = gapRole_AdvChanMap;
+ params.filterPolicy = gapRole_AdvFilterPolicy;
+
+ if ( GAP_MakeDiscoverable( gapRole_TaskID, ¶ms ) != SUCCESS )
+ {
+ gapRole_state = GAPROLE_ERROR;
+
+ // Notify the application with the new state change
+ if ( pGapRoles_AppCGs && pGapRoles_AppCGs->pfnStateChange )
+ {
+ pGapRoles_AppCGs->pfnStateChange( gapRole_state );
+ }
+ }
+ }
+ return ( events ^ START_ADVERTISING_EVT );
+ }
+
+ if ( events & RSSI_READ_EVT )
+ {
+ // Only get RSSI when in a connection
+ if ( gapRole_state == GAPROLE_CONNECTED )
+ {
+ // Ask for RSSI
+ VOID HCI_ReadRssiCmd( gapRole_ConnectionHandle );
+
+ // Setup next event
+ if ( gapRole_RSSIReadRate )
+ {
+ VOID osal_start_timerEx( gapRole_TaskID, RSSI_READ_EVT, gapRole_RSSIReadRate );
+ }
+ }
+ return ( events ^ RSSI_READ_EVT );
+ }
+
+ if ( events & START_CONN_UPDATE_EVT )
+ {
+ // Start connection update procedure
+ gapRole_startConnUpdate( GAPROLE_NO_ACTION );
+
+ return ( events ^ START_CONN_UPDATE_EVT );
+ }
+
+ if ( events & CONN_PARAM_TIMEOUT_EVT )
+ {
+ // Unsuccessful in updating connection parameters
+ gapRole_HandleParamUpdateNoSuccess();
+
+ return ( events ^ CONN_PARAM_TIMEOUT_EVT );
+ }
+
+ // Discard unknown events
+ return 0;
+}
+
+/*********************************************************************
+ * @fn gapRole_ProcessOSALMsg
+ *
+ * @brief Process an incoming task message.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void gapRole_ProcessOSALMsg( osal_event_hdr_t *pMsg )
+{
+ switch ( pMsg->event )
+ {
+ case HCI_GAP_EVENT_EVENT:
+ if ( pMsg->status == HCI_COMMAND_COMPLETE_EVENT_CODE )
+ {
+ hciEvt_CmdComplete_t *pPkt = (hciEvt_CmdComplete_t *)pMsg;
+
+ if ( pPkt->cmdOpcode == HCI_READ_RSSI )
+ {
+ int8 rssi = (int8)pPkt->pReturnParam[3];
+
+ if ( (gapRole_state == GAPROLE_CONNECTED) && (rssi != RSSI_NOT_AVAILABLE) )
+ {
+ // Report RSSI to app
+ if ( pGapRoles_AppCGs && pGapRoles_AppCGs->pfnRssiRead )
+ {
+ pGapRoles_AppCGs->pfnRssiRead( rssi );
+ }
+ }
+ }
+ }
+ break;
+
+ case GAP_MSG_EVENT:
+ gapRole_ProcessGAPMsg( (gapEventHdr_t *)pMsg );
+ break;
+
+ case L2CAP_SIGNAL_EVENT:
+ {
+ l2capSignalEvent_t *pPkt = (l2capSignalEvent_t *)pMsg;
+
+ // Process the Parameter Update Response
+ if ( pPkt->opcode == L2CAP_PARAM_UPDATE_RSP )
+ {
+ l2capParamUpdateRsp_t *pRsp = (l2capParamUpdateRsp_t *)&(pPkt->cmd.updateRsp);
+
+ if ( ( pRsp->result == L2CAP_CONN_PARAMS_REJECTED ) &&
+ ( paramUpdateNoSuccessOption == GAPROLE_TERMINATE_LINK ) )
+ {
+ // Cancel connection param update timeout timer
+ VOID osal_stop_timerEx( gapRole_TaskID, CONN_PARAM_TIMEOUT_EVT );
+
+ // Terminate connection immediately
+ GAPRole_TerminateConnection();
+ }
+ else
+ {
+ uint16 timeout = GAP_GetParamValue( TGAP_CONN_PARAM_TIMEOUT );
+
+ // Let's wait for Controller to update connection parameters if they're
+ // accepted. Otherwise, decide what to do based on no success option.
+ VOID osal_start_timerEx( gapRole_TaskID, CONN_PARAM_TIMEOUT_EVT, timeout );
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn gapRole_ProcessGAPMsg
+ *
+ * @brief Process an incoming task message.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void gapRole_ProcessGAPMsg( gapEventHdr_t *pMsg )
+{
+ uint8 notify = FALSE; // State changed notify the app? (default no)
+
+ switch ( pMsg->opcode )
+ {
+ case GAP_DEVICE_INIT_DONE_EVENT:
+ {
+ gapDeviceInitDoneEvent_t *pPkt = (gapDeviceInitDoneEvent_t *)pMsg;
+ bStatus_t stat = pPkt->hdr.status;
+
+ if ( stat == SUCCESS )
+ {
+ // Save off the generated keys
+ VOID osal_snv_write( BLE_NVID_IRK, KEYLEN, gapRole_IRK );
+ VOID osal_snv_write( BLE_NVID_CSRK, KEYLEN, gapRole_SRK );
+
+ // Save off the information
+ VOID osal_memcpy( gapRole_bdAddr, pPkt->devAddr, B_ADDR_LEN );
+
+ gapRole_state = GAPROLE_STARTED;
+
+ // Update the advertising data
+ stat = GAP_UpdateAdvertisingData( gapRole_TaskID,
+ TRUE, gapRole_AdvertDataLen, gapRole_AdvertData );
+ }
+
+ if ( stat != SUCCESS )
+ {
+ gapRole_state = GAPROLE_ERROR;
+ }
+
+ notify = TRUE;
+ }
+ break;
+
+ case GAP_ADV_DATA_UPDATE_DONE_EVENT:
+ {
+ gapAdvDataUpdateEvent_t *pPkt = (gapAdvDataUpdateEvent_t *)pMsg;
+
+ if ( pPkt->hdr.status == SUCCESS )
+ {
+ if ( pPkt->adType )
+ {
+ // Setup the Response Data
+ pPkt->hdr.status = GAP_UpdateAdvertisingData( gapRole_TaskID,
+ FALSE, gapRole_ScanRspDataLen, gapRole_ScanRspData );
+ }
+ else
+ {
+ // Start advertising
+ VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );
+ }
+ }
+
+ if ( pPkt->hdr.status != SUCCESS )
+ {
+ // Set into Error state
+ gapRole_state = GAPROLE_ERROR;
+ notify = TRUE;
+ }
+ }
+ break;
+
+ case GAP_MAKE_DISCOVERABLE_DONE_EVENT:
+ case GAP_END_DISCOVERABLE_DONE_EVENT:
+ {
+ gapMakeDiscoverableRspEvent_t *pPkt = (gapMakeDiscoverableRspEvent_t *)pMsg;
+
+ if ( pPkt->hdr.status == SUCCESS )
+ {
+ if ( pMsg->opcode == GAP_MAKE_DISCOVERABLE_DONE_EVENT )
+ {
+ gapRole_state = GAPROLE_ADVERTISING;
+ }
+ else // GAP_END_DISCOVERABLE_DONE_EVENT
+ {
+
+ if ( gapRole_AdvertOffTime != 0 )
+ {
+ if ( ( gapRole_AdvEnabled ) )
+ {
+ VOID osal_start_timerEx( gapRole_TaskID, START_ADVERTISING_EVT, gapRole_AdvertOffTime );
+ }
+ }
+ else
+ {
+ // Since gapRole_AdvertOffTime is set to 0, the device should not
+ // automatically become discoverable again after a period of time.
+ // Set enabler to FALSE; device will become discoverable again when
+ // this value gets set to TRUE
+ gapRole_AdvEnabled = FALSE;
+ }
+
+ // In the Advertising Off period
+ gapRole_state = GAPROLE_WAITING;
+
+ }
+ }
+ else
+ {
+ gapRole_state = GAPROLE_ERROR;
+ }
+ notify = TRUE;
+ }
+ break;
+
+ case GAP_LINK_ESTABLISHED_EVENT:
+ {
+ gapEstLinkReqEvent_t *pPkt = (gapEstLinkReqEvent_t *)pMsg;
+
+ if ( pPkt->hdr.status == SUCCESS )
+ {
+ VOID osal_memcpy( gapRole_ConnectedDevAddr, pPkt->devAddr, B_ADDR_LEN );
+ gapRole_ConnectionHandle = pPkt->connectionHandle;
+ gapRole_state = GAPROLE_CONNECTED;
+
+ if ( gapRole_RSSIReadRate )
+ {
+ // Start the RSSI Reads
+ VOID osal_start_timerEx( gapRole_TaskID, RSSI_READ_EVT, gapRole_RSSIReadRate );
+ }
+
+ // Store connection information
+ gapRole_ConnInterval = pPkt->connInterval;
+ gapRole_ConnSlaveLatency = pPkt->connLatency;
+ gapRole_ConnTimeout = pPkt->connTimeout;
+
+ // Check whether update parameter request is enabled
+ if ( gapRole_ParamUpdateEnable == TRUE )
+ {
+ // Get the minimum time upon connection establishment before the
+ // peripheral can start a connection update procedure.
+ uint16 timeout = GAP_GetParamValue( TGAP_CONN_PAUSE_PERIPHERAL );
+
+ osal_start_timerEx( gapRole_TaskID, START_CONN_UPDATE_EVT, timeout*1000 );
+ }
+
+ // Notify the Bond Manager to the connection
+ VOID GAPBondMgr_LinkEst( pPkt->devAddrType, pPkt->devAddr, pPkt->connectionHandle, GAP_PROFILE_PERIPHERAL );
+ }
+ else if ( pPkt->hdr.status == bleGAPConnNotAcceptable )
+ {
+ // Set enabler to FALSE; device will become discoverable again when
+ // this value gets set to TRUE
+ gapRole_AdvEnabled = FALSE;
+
+ // Go to WAITING state, and then start advertising
+ gapRole_state = GAPROLE_WAITING;
+ }
+ else
+ {
+ gapRole_state = GAPROLE_ERROR;
+ }
+ notify = TRUE;
+ }
+ break;
+
+ case GAP_LINK_TERMINATED_EVENT:
+ {
+ gapTerminateLinkEvent_t *pPkt = (gapTerminateLinkEvent_t *)pMsg;
+
+ GAPBondMgr_ProcessGAPMsg( (gapEventHdr_t *)pMsg );
+ osal_memset( gapRole_ConnectedDevAddr, 0, B_ADDR_LEN );
+
+ // Erase connection information
+ gapRole_ConnInterval = 0;
+ gapRole_ConnSlaveLatency = 0;
+ gapRole_ConnTimeout = 0;
+
+ // Cancel all connection parameter update timers (if any active)
+ VOID osal_stop_timerEx( gapRole_TaskID, START_CONN_UPDATE_EVT );
+ VOID osal_stop_timerEx( gapRole_TaskID, CONN_PARAM_TIMEOUT_EVT );
+
+ // Go to WAITING state, and then start advertising
+ if( pPkt->reason == LL_SUPERVISION_TIMEOUT_TERM )
+ {
+ gapRole_state = GAPROLE_WAITING_AFTER_TIMEOUT;
+ }
+ else
+ {
+ gapRole_state = GAPROLE_WAITING;
+ }
+
+ notify = TRUE;
+
+ VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );
+
+ gapRole_ConnectionHandle = INVALID_CONNHANDLE;
+ }
+ break;
+
+ case GAP_LINK_PARAM_UPDATE_EVENT:
+ {
+ gapLinkUpdateEvent_t *pPkt = (gapLinkUpdateEvent_t *)pMsg;
+
+ // Cancel connection param update timeout timer (if active)
+ VOID osal_stop_timerEx( gapRole_TaskID, CONN_PARAM_TIMEOUT_EVT );
+
+ if ( pPkt->hdr.status == SUCCESS )
+ {
+ // Store new connection parameters
+ gapRole_ConnInterval = pPkt->connInterval;
+ gapRole_ConnSlaveLatency = pPkt->connLatency;
+ gapRole_ConnTimeout = pPkt->connTimeout;
+
+ // Make sure there's no pending connection update procedure
+ if ( osal_get_timeoutEx( gapRole_TaskID, START_CONN_UPDATE_EVT ) == 0 )
+ {
+ // Notify the application with the new connection parameters
+ if ( pGapRoles_ParamUpdateCB != NULL )
+ {
+ (*pGapRoles_ParamUpdateCB)( gapRole_ConnInterval,
+ gapRole_ConnSlaveLatency,
+ gapRole_ConnTimeout );
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if ( notify == TRUE )
+ {
+ // Notify the application with the new state change
+ if ( pGapRoles_AppCGs && pGapRoles_AppCGs->pfnStateChange )
+ {
+ pGapRoles_AppCGs->pfnStateChange( gapRole_state );
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn gapRole_SetupGAP
+ *
+ * @brief Call the GAP Device Initialization function using the
+ * Profile Parameters.
+ *
+ * @param none
+ *
+ * @return none
+ */
+static void gapRole_SetupGAP( void )
+{
+ VOID GAP_DeviceInit( gapRole_TaskID,
+ gapRole_profileRole, 0,
+ gapRole_IRK, gapRole_SRK,
+ &gapRole_signCounter );
+}
+
+/*********************************************************************
+ * @fn gapRole_HandleParamUpdateNoSuccess
+ *
+ * @brief Handle unsuccessful connection parameters update.
+ *
+ * @param none
+ *
+ * @return none
+ */
+static void gapRole_HandleParamUpdateNoSuccess( void )
+{
+ // See which option was choosen for unsuccessful updates
+ switch ( paramUpdateNoSuccessOption )
+ {
+ case GAPROLE_RESEND_PARAM_UPDATE:
+ GAPRole_SendUpdateParam( gapRole_MinConnInterval, gapRole_MaxConnInterval,
+ gapRole_SlaveLatency, gapRole_TimeoutMultiplier,
+ GAPROLE_RESEND_PARAM_UPDATE );
+ break;
+
+ case GAPROLE_TERMINATE_LINK:
+ GAPRole_TerminateConnection();
+ break;
+
+ case GAPROLE_NO_ACTION:
+ // fall through
+ default:
+ //do nothing
+ break;
+ }
+}
+
+/********************************************************************
+ * @fn gapRole_startConnUpdate
+ *
+ * @brief Start the connection update procedure
+ *
+ * @param handleFailure - what to do if the update does not occur.
+ * Method may choose to terminate connection, try again, or take no action
+ *
+ * @return none
+ */
+static void gapRole_startConnUpdate( uint8 handleFailure )
+{
+ // First check the current connection parameters versus the configured parameters
+ if ( (gapRole_ConnInterval < gapRole_MinConnInterval) ||
+ (gapRole_ConnInterval > gapRole_MaxConnInterval) ||
+ (gapRole_ConnSlaveLatency != gapRole_SlaveLatency) ||
+ (gapRole_ConnTimeout != gapRole_TimeoutMultiplier) )
+ {
+ l2capParamUpdateReq_t updateReq;
+ uint16 timeout = GAP_GetParamValue( TGAP_CONN_PARAM_TIMEOUT );
+
+ updateReq.intervalMin = gapRole_MinConnInterval;
+ updateReq.intervalMax = gapRole_MaxConnInterval;
+ updateReq.slaveLatency = gapRole_SlaveLatency;
+ updateReq.timeoutMultiplier = gapRole_TimeoutMultiplier;
+
+ VOID L2CAP_ConnParamUpdateReq( gapRole_ConnectionHandle, &updateReq, gapRole_TaskID );
+
+ paramUpdateNoSuccessOption = handleFailure;
+
+ // Let's wait for L2CAP Connection Parameters Update Response
+ VOID osal_start_timerEx( gapRole_TaskID, CONN_PARAM_TIMEOUT_EVT, timeout );
+ }
+}
+
+/********************************************************************
+ * @fn GAPRole_SendUpdateParam
+ *
+ * @brief Update the parameters of an existing connection
+ *
+ * @param minConnInterval - the new min connection interval
+ * @param maxConnInterval - the new max connection interval
+ * @param latency - the new slave latency
+ * @param connTimeout - the new timeout value
+ * @param handleFailure - what to do if the update does not occur.
+ * Method may choose to terminate connection, try again, or take no action
+ *
+ * @return SUCCESS, bleNotConnected, or bleInvalidRange
+ */
+bStatus_t GAPRole_SendUpdateParam( uint16 minConnInterval, uint16 maxConnInterval,
+ uint16 latency, uint16 connTimeout, uint8 handleFailure )
+{
+ // If there is no existing connection no update need be sent
+ if ( gapRole_state != GAPROLE_CONNECTED )
+ {
+ return ( bleNotConnected );
+ }
+
+ // Check that all parameters are in range before sending request
+ if ( ( minConnInterval >= DEFAULT_MIN_CONN_INTERVAL ) &&
+ ( minConnInterval < DEFAULT_MAX_CONN_INTERVAL ) &&
+ ( maxConnInterval >= DEFAULT_MIN_CONN_INTERVAL ) &&
+ ( maxConnInterval < DEFAULT_MAX_CONN_INTERVAL ) &&
+ ( latency < MAX_SLAVE_LATENCY ) &&
+ ( connTimeout >= MIN_TIMEOUT_MULTIPLIER ) &&
+ ( connTimeout < MAX_TIMEOUT_MULTIPLIER ) )
+ {
+ gapRole_MinConnInterval = minConnInterval;
+ gapRole_MaxConnInterval = maxConnInterval;
+ gapRole_SlaveLatency = latency;
+ gapRole_TimeoutMultiplier = connTimeout;
+
+ // Start connection update procedure
+ gapRole_startConnUpdate( handleFailure );
+
+ // Connection update requested by app, cancel such pending procedure (if active)
+ VOID osal_stop_timerEx( gapRole_TaskID, START_CONN_UPDATE_EVT );
+
+ return ( SUCCESS );
+ }
+
+ return ( bleInvalidRange );
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/peripheral.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/peripheral.h
new file mode 100644
index 0000000..50b6faa
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/peripheral.h
@@ -0,0 +1,285 @@
+/**
+ @headerfile: peripheral.h
+ $Date: 2013-05-01 13:58:23 -0700 (Wed, 01 May 2013) $
+ $Revision: 34101 $
+
+ @mainpage TI BLE GAP Peripheral Role
+
+ This GAP profile advertises and allows connections.
+
+ Copyright 2009 - 2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*/
+
+#ifndef PERIPHERAL_H
+#define PERIPHERAL_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*-------------------------------------------------------------------
+ * INCLUDES
+ */
+
+/*-------------------------------------------------------------------
+ * CONSTANTS
+ */
+
+/** @defgroup GAPROLE_PROFILE_PARAMETERS GAP Role Parameters
+ * @{
+ */
+#define GAPROLE_PROFILEROLE 0x300 //!< Reading this parameter will return GAP Role type. Read Only. Size is uint8.
+#define GAPROLE_IRK 0x301 //!< Identity Resolving Key. Read/Write. Size is uint8[KEYLEN]. Default is all 0, which means that the IRK will be randomly generated.
+#define GAPROLE_SRK 0x302 //!< Signature Resolving Key. Read/Write. Size is uint8[KEYLEN]. Default is all 0, which means that the SRK will be randomly generated.
+#define GAPROLE_SIGNCOUNTER 0x303 //!< Sign Counter. Read/Write. Size is uint32. Default is 0.
+#define GAPROLE_BD_ADDR 0x304 //!< Device's Address. Read Only. Size is uint8[B_ADDR_LEN]. This item is read from the controller.
+#define GAPROLE_ADVERT_ENABLED 0x305 //!< Enable/Disable Advertising. Read/Write. Size is uint8. Default is TRUE=Enabled.
+#define GAPROLE_ADVERT_OFF_TIME 0x306 //!< Advertising Off Time for Limited advertisements (in milliseconds). Read/Write. Size is uint16. Default is 30 seconds.
+#define GAPROLE_ADVERT_DATA 0x307 //!< Advertisement Data. Read/Write. Max size is uint8[B_MAX_ADV_LEN]. Default is "02:01:01", which means that it is a Limited Discoverable Advertisement.
+#define GAPROLE_SCAN_RSP_DATA 0x308 //!< Scan Response Data. Read/Write. Max size is uint8[B_MAX_ADV_LEN]. Defaults to all 0.
+#define GAPROLE_ADV_EVENT_TYPE 0x309 //!< Advertisement Type. Read/Write. Size is uint8. Default is GAP_ADTYPE_ADV_IND (defined in GAP.h).
+#define GAPROLE_ADV_DIRECT_TYPE 0x30A //!< Direct Advertisement Address Type. Read/Write. Size is uint8. Default is ADDRTYPE_PUBLIC (defined in GAP.h).
+#define GAPROLE_ADV_DIRECT_ADDR 0x30B //!< Direct Advertisement Address. Read/Write. Size is uint8[B_ADDR_LEN]. Default is NULL.
+#define GAPROLE_ADV_CHANNEL_MAP 0x30C //!< Which channels to advertise on. Read/Write Size is uint8. Default is GAP_ADVCHAN_ALL (defined in GAP.h)
+#define GAPROLE_ADV_FILTER_POLICY 0x30D //!< Filter Policy. Ignored when directed advertising is used. Read/Write. Size is uint8. Default is GAP_FILTER_POLICY_ALL (defined in GAP.h).
+#define GAPROLE_CONNHANDLE 0x30E //!< Connection Handle. Read Only. Size is uint16.
+#define GAPROLE_RSSI_READ_RATE 0x30F //!< How often to read the RSSI during a connection. Read/Write. Size is uint16. The value is in milliseconds. Default is 0 = OFF.
+#define GAPROLE_PARAM_UPDATE_ENABLE 0x310 //!< Slave Connection Parameter Update Enable. Read/Write. Size is uint8. If TRUE then automatic connection parameter update request is sent. Default is FALSE.
+#define GAPROLE_MIN_CONN_INTERVAL 0x311 //!< Minimum Connection Interval to allow (n * 1.25ms). Range: 7.5 msec to 4 seconds (0x0006 to 0x0C80). Read/Write. Size is uint16. Default is 7.5 milliseconds (0x0006).
+#define GAPROLE_MAX_CONN_INTERVAL 0x312 //!< Maximum Connection Interval to allow (n * 1.25ms). Range: 7.5 msec to 4 seconds (0x0006 to 0x0C80). Read/Write. Size is uint16. Default is 4 seconds (0x0C80).
+#define GAPROLE_SLAVE_LATENCY 0x313 //!< Update Parameter Slave Latency. Range: 0 - 499. Read/Write. Size is uint16. Default is 0.
+#define GAPROLE_TIMEOUT_MULTIPLIER 0x314 //!< Update Parameter Timeout Multiplier (n * 10ms). Range: 100ms to 32 seconds (0x000a - 0x0c80). Read/Write. Size is uint16. Default is 1000.
+#define GAPROLE_CONN_BD_ADDR 0x315 //!< Address of connected device. Read only. Size is uint8[B_MAX_ADV_LEN]. Set to all zeros when not connected.
+#define GAPROLE_CONN_INTERVAL 0x316 //!< Current connection interval. Read only. Size is uint16. Range is 7.5ms to 4 seconds (0x0006 to 0x0C80). Default is 0 (no connection).
+#define GAPROLE_CONN_LATENCY 0x317 //!< Current slave latency. Read only. Size is uint16. Range is 0 to 499. Default is 0 (no slave latency or no connection).
+#define GAPROLE_CONN_TIMEOUT 0x318 //!< Current timeout value. Read only. size is uint16. Range is 100ms to 32 seconds. Default is 0 (no connection).
+#define GAPROLE_PARAM_UPDATE_REQ 0x319 //!< Slave Connection Parameter Update Request. Write. Size is uint8. If TRUE then connection parameter update request is sent.
+/** @} End GAPROLE_PROFILE_PARAMETERS */
+
+/*-------------------------------------------------------------------
+ * TYPEDEFS
+ */
+
+/**
+ * GAP Peripheral Role States.
+ */
+typedef enum
+{
+ GAPROLE_INIT = 0, //!< Waiting to be started
+ GAPROLE_STARTED, //!< Started but not advertising
+ GAPROLE_ADVERTISING, //!< Currently Advertising
+ GAPROLE_WAITING, //!< Device is started but not advertising, is in waiting period before advertising again
+ GAPROLE_WAITING_AFTER_TIMEOUT, //!< Device just timed out from a connection but is not yet advertising, is in waiting period before advertising again
+ GAPROLE_CONNECTED, //!< In a connection
+ GAPROLE_ERROR //!< Error occurred - invalid state
+} gaprole_States_t;
+
+/**
+ * Possible actions the peripheral device may take if an unsuccessful parameter
+ * update is received.
+ *
+ * Parameters for GAPRole_SendUpdateParam() only
+ */
+
+#define GAPROLE_NO_ACTION 0 // Take no action upon unsuccessful parameter updates
+#define GAPROLE_RESEND_PARAM_UPDATE 1 // Continue to resend request until successful update
+#define GAPROLE_TERMINATE_LINK 2 // Terminate link upon unsuccessful parameter updates
+
+/*-------------------------------------------------------------------
+ * MACROS
+ */
+
+/*-------------------------------------------------------------------
+ * Profile Callbacks
+ */
+
+/**
+ * Callback when the connection parameteres are updated.
+ */
+typedef void (*gapRolesParamUpdateCB_t)( uint16 connInterval,
+ uint16 connSlaveLatency,
+ uint16 connTimeout );
+
+/**
+ * Callback when the device has been started. Callback event to
+ * the Notify of a state change.
+ */
+typedef void (*gapRolesStateNotify_t)( gaprole_States_t newState );
+
+/**
+ * Callback when the device has read an new RSSI value during a connection.
+ */
+typedef void (*gapRolesRssiRead_t)( int8 newRSSI );
+
+/**
+ * Callback structure - must be setup by the application and used when gapRoles_StartDevice() is called.
+ */
+typedef struct
+{
+ gapRolesStateNotify_t pfnStateChange; //!< Whenever the device changes state
+ gapRolesRssiRead_t pfnRssiRead; //!< When a valid RSSI is read from controller
+} gapRolesCBs_t;
+
+/*-------------------------------------------------------------------
+ * API FUNCTIONS
+ */
+
+/**
+ * @defgroup GAPROLES_PERIPHERAL_API GAP Peripheral Role API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Set a GAP Role parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will set the
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also,
+ * the "len" field must be set to the size of a "uint16" and the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
+ * @param len - length of data to write
+ * @param pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPRole_SetParameter( uint16 param, uint8 len, void *pValue );
+
+/**
+ * @brief Get a GAP Role parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will get a
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also, the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
+ * @param pValue - pointer to location to get the value. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPRole_GetParameter( uint16 param, void *pValue );
+
+/**
+ * @brief Does the device initialization. Only call this function once.
+ *
+ * @param pAppCallbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+extern bStatus_t GAPRole_StartDevice( gapRolesCBs_t *pAppCallbacks );
+
+/**
+ * @brief Terminates the existing connection.
+ *
+ * @return SUCCESS or bleIncorrectMode
+ */
+extern bStatus_t GAPRole_TerminateConnection( void );
+
+/**
+ * @brief Update the parameters of an existing connection
+ *
+ * @param connInterval - the new connection interval
+ * @param latency - the new slave latency
+ * @param connTimeout - the new timeout value
+ * @param handleFailure - what to do if the update does not occur.
+ * Method may choose to terminate connection, try again, or take no action
+ *
+ * @return SUCCESS, bleNotConnected or bleInvalidRange
+ */
+extern bStatus_t GAPRole_SendUpdateParam( uint16 minConnInterval, uint16 maxConnInterval,
+ uint16 latency, uint16 connTimeout, uint8 handleFailure );
+
+/**
+ * @brief Register application's callbacks.
+ *
+ * @param pParamUpdateCB - pointer to param update callback.
+ *
+ * @return none
+ */
+extern void GAPRole_RegisterAppCBs( gapRolesParamUpdateCB_t *pParamUpdateCB );
+
+/**
+ * @} End GAPROLES_PERIPHERAL_API
+ */
+
+
+/*-------------------------------------------------------------------
+ * TASK FUNCTIONS - Don't call these. These are system functions.
+ */
+
+/**
+ * @internal
+ *
+ * @brief Initialization function for the GAP Role Task.
+ * This is called during initialization and should contain
+ * any application specific initialization (ie. hardware
+ * initialization/setup, table initialization, power up
+ * notificaiton ... ).
+ *
+ * @param the ID assigned by OSAL. This ID should be
+ * used to send messages and set timers.
+ *
+ * @return void
+ */
+extern void GAPRole_Init( uint8 task_id );
+
+/**
+ * @internal
+ *
+ * @brief GAP Role 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 events not processed
+ */
+extern uint16 GAPRole_ProcessEvent( uint8 task_id, uint16 events );
+
+/*-------------------------------------------------------------------
+-------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PERIPHERAL_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/peripheralBroadcaster.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/peripheralBroadcaster.c
new file mode 100644
index 0000000..a322485
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/peripheralBroadcaster.c
@@ -0,0 +1,1111 @@
+/**************************************************************************************************
+ Filename: peripheralBroadcaster.c
+ Revised: $Date: 2011-08-04 12:05:19 -0700 (Thu, 04 Aug 2011) $
+ Revision: $Revision: 27026 $
+
+ Description: GAP Peripheral + Broadcaster Role
+
+
+ Copyright 2010 - 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "hci.h"
+#include "l2cap.h"
+#include "gap.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "osal_snv.h"
+
+#include "peripheralBroadcaster.h"
+#include "gapbondmgr.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+// Profile Events
+#define START_ADVERTISING_EVT 0x0001
+#define RSSI_READ_EVT 0x0002
+#define UPDATE_PARAMS_TIMEOUT_EVT 0x0004
+
+#define DEFAULT_ADVERT_OFF_TIME 30000 // 30 seconds
+
+#define RSSI_NOT_AVAILABLE 127
+
+#define DEFAULT_MIN_CONN_INTERVAL 0x0006 // 100 milliseconds
+#define DEFAULT_MAX_CONN_INTERVAL 0x0C80 // 4 seconds
+
+#define MIN_CONN_INTERVAL 0x0006
+#define MAX_CONN_INTERVAL 0x0C80
+
+#define DEFAULT_SLAVE_LATENCY 0
+#define DEFAULT_TIMEOUT_MULTIPLIER 1000
+
+#define CONN_INTERVAL_MULTIPLIER 6
+
+#define MAX_SLAVE_LATENCY 500
+#define MIN_TIMEOUT_MULTIPLIER 0x000a
+#define MAX_TIMEOUT_MULTIPLIER 0x0c80
+
+#define MAX_TIMEOUT_VALUE 0xFFFF
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+static uint8 gapRole_TaskID; // Task ID for internal task/event processing
+
+static gaprole_States_t gapRole_state;
+
+/*********************************************************************
+ * Profile Parameters - reference GAPROLE_PROFILE_PARAMETERS for
+ * descriptions
+ */
+
+static uint8 gapRole_profileRole;
+static uint8 gapRole_IRK[KEYLEN];
+static uint8 gapRole_SRK[KEYLEN];
+static uint32 gapRole_signCounter;
+static uint8 gapRole_bdAddr[B_ADDR_LEN];
+static uint8 gapRole_AdvEnabled = TRUE;
+static uint16 gapRole_AdvertOffTime = DEFAULT_ADVERT_OFF_TIME;
+static uint8 gapRole_AdvertDataLen = 3;
+static uint8 gapRole_AdvertData[B_MAX_ADV_LEN] =
+{
+ 0x02, // length of this data
+ GAP_ADTYPE_FLAGS, // AD Type = Flags
+ // Limited Discoverable & BR/EDR not supported
+ (GAP_ADTYPE_FLAGS_GENERAL | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED),
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+};
+static uint8 gapRole_ScanRspDataLen = 0;
+static uint8 gapRole_ScanRspData[B_MAX_ADV_LEN] = {0};
+static uint8 gapRole_AdvEventType;
+static uint8 gapRole_AdvDirectType;
+static uint8 gapRole_AdvDirectAddr[B_ADDR_LEN] = {0};
+static uint8 gapRole_AdvChanMap;
+static uint8 gapRole_AdvFilterPolicy;
+
+static uint16 gapRole_ConnectionHandle = INVALID_CONNHANDLE;
+static uint16 gapRole_RSSIReadRate = 0;
+
+static gapRolesCBs_t *pGapRoles_AppCGs = NULL;
+static uint8 gapRole_ConnectedDevAddr[B_ADDR_LEN] = {0};
+
+static uint8 gapRole_ParamUpdateEnable = FALSE;
+static uint16 gapRole_MinConnInterval = DEFAULT_MIN_CONN_INTERVAL;
+static uint16 gapRole_MaxConnInterval = DEFAULT_MAX_CONN_INTERVAL;
+static uint16 gapRole_SlaveLatency = DEFAULT_SLAVE_LATENCY;
+static uint16 gapRole_TimeoutMultiplier = DEFAULT_TIMEOUT_MULTIPLIER;
+
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static void gapRole_ProcessOSALMsg( osal_event_hdr_t *pMsg );
+static void gapRole_ProcessGAPMsg( gapEventHdr_t *pMsg );
+static void gapRole_SetupGAP( void );
+static void gapRole_SendUpdateParam( uint16 connInterval, uint16 connLatency );
+
+/*********************************************************************
+ * NETWORK LAYER CALLBACKS
+ */
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @brief Set a GAP Role parameter.
+ *
+ * Public function defined in peripheral.h.
+ */
+bStatus_t GAPRole_SetParameter( uint16 param, uint8 len, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case GAPROLE_IRK:
+ if ( len == KEYLEN )
+ {
+ VOID osal_memcpy( gapRole_IRK, pValue, KEYLEN ) ;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_SRK:
+ if ( len == KEYLEN )
+ {
+ VOID osal_memcpy( gapRole_SRK, pValue, KEYLEN ) ;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_SIGNCOUNTER:
+ if ( len == sizeof ( uint32 ) )
+ {
+ gapRole_signCounter = *((uint32*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADVERT_ENABLED:
+ if ( len == sizeof( uint8 ) )
+ {
+ if ( (gapRole_state == GAPROLE_CONNECTED) || (gapRole_state == GAPROLE_CONNECTED_ADV) )
+ {
+ uint8 advEnabled = *((uint8*)pValue);
+
+ if ( (gapRole_state == GAPROLE_CONNECTED) && (advEnabled == TRUE) )
+ {
+ // Turn on advertising
+ osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );
+ }
+ else if ( (gapRole_state == GAPROLE_CONNECTED_ADV) && (advEnabled == FALSE) )
+ {
+ // Turn off Advertising
+ GAP_EndDiscoverable( gapRole_TaskID );
+ }
+ }
+ else
+ {
+ uint8 oldAdvEnabled = gapRole_AdvEnabled;
+ gapRole_AdvEnabled = *((uint8*)pValue);
+
+ if ( (oldAdvEnabled) && (gapRole_AdvEnabled == FALSE) )
+ {
+ // Turn off Advertising
+ VOID GAP_EndDiscoverable( gapRole_TaskID );
+ }
+ else if ( (oldAdvEnabled == FALSE) && (gapRole_AdvEnabled) )
+ {
+ // Turn on Advertising
+ if ( (gapRole_state == GAPROLE_STARTED)
+ || (gapRole_state == GAPROLE_WAITING )
+ || (gapRole_state == GAPROLE_WAITING_AFTER_TIMEOUT) )
+ {
+ VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );
+ }
+ }
+ }
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADVERT_OFF_TIME:
+ if ( len == sizeof ( uint16 ) )
+ {
+ gapRole_AdvertOffTime = *((uint16*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADVERT_DATA:
+ if ( len <= B_MAX_ADV_LEN )
+ {
+ VOID osal_memset( gapRole_AdvertData, 0, B_MAX_ADV_LEN );
+ VOID osal_memcpy( gapRole_AdvertData, pValue, len );
+ gapRole_AdvertDataLen = len;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_SCAN_RSP_DATA:
+ if ( len <= B_MAX_ADV_LEN )
+ {
+ VOID osal_memset( gapRole_ScanRspData, 0, B_MAX_ADV_LEN );
+ VOID osal_memcpy( gapRole_ScanRspData, pValue, len );
+ gapRole_ScanRspDataLen = len;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_EVENT_TYPE:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAP_ADTYPE_ADV_NONCONN_IND) )
+ {
+ gapRole_AdvEventType = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_DIRECT_TYPE:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= ADDRTYPE_PRIVATE_RESOLVE) )
+ {
+ gapRole_AdvDirectType = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_DIRECT_ADDR:
+ if ( len == B_ADDR_LEN )
+ {
+ VOID osal_memcpy( gapRole_AdvDirectAddr, pValue, B_ADDR_LEN ) ;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_CHANNEL_MAP:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= 0x07) )
+ {
+ gapRole_AdvChanMap = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_ADV_FILTER_POLICY:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAP_FILTER_POLICY_WHITE) )
+ {
+ gapRole_AdvFilterPolicy = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_RSSI_READ_RATE:
+ if ( len == sizeof ( uint16 ) )
+ {
+ gapRole_RSSIReadRate = *((uint16*)pValue);
+
+ if ( (gapRole_RSSIReadRate) && (gapRole_state == GAPROLE_CONNECTED) )
+ {
+ // Start the RSSI Reads
+ VOID osal_start_timerEx( gapRole_TaskID, RSSI_READ_EVT, gapRole_RSSIReadRate );
+ }
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_PARAM_UPDATE_ENABLE:
+ if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )
+ {
+ gapRole_ParamUpdateEnable = *((uint8*)pValue);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GAPROLE_MIN_CONN_INTERVAL:
+ {
+ uint16 newInterval = *((uint16*)pValue);
+ if ( len == sizeof ( uint16 ) &&
+ ( newInterval >= MIN_CONN_INTERVAL ) &&
+ ( newInterval <= MAX_CONN_INTERVAL ) )
+ {
+ gapRole_MinConnInterval = newInterval;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ }
+ break;
+
+ case GAPROLE_MAX_CONN_INTERVAL:
+ {
+ uint16 newInterval = *((uint16*)pValue);
+ if ( len == sizeof ( uint16 ) &&
+ ( newInterval >= MIN_CONN_INTERVAL) &&
+ ( newInterval <= MAX_CONN_INTERVAL) )
+ {
+ gapRole_MaxConnInterval = newInterval;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ }
+ break;
+
+ case GAPROLE_SLAVE_LATENCY:
+ {
+ uint16 latency = *((uint16*)pValue);
+ if ( len == sizeof ( uint16 ) && (latency < MAX_SLAVE_LATENCY) )
+ {
+ gapRole_SlaveLatency = latency;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ }
+ break;
+
+ case GAPROLE_TIMEOUT_MULTIPLIER:
+ {
+ uint16 newTimeout = *((uint16*)pValue);
+ if ( len == sizeof ( uint16 )
+ && (newTimeout >= MIN_TIMEOUT_MULTIPLIER) && (newTimeout <= MAX_TIMEOUT_MULTIPLIER) )
+ {
+ gapRole_TimeoutMultiplier = newTimeout;
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ }
+ break;
+
+ default:
+ // The param value isn't part of this profile, try the GAP.
+ if ( (param < TGAP_PARAMID_MAX) && (len == sizeof ( uint16 )) )
+ {
+ ret = GAP_SetParamValue( param, *((uint16*)pValue) );
+ }
+ else
+ {
+ ret = INVALIDPARAMETER;
+ }
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Get a GAP Role parameter.
+ *
+ * Public function defined in peripheral.h.
+ */
+bStatus_t GAPRole_GetParameter( uint16 param, void *pValue )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case GAPROLE_PROFILEROLE:
+ *((uint8*)pValue) = gapRole_profileRole;
+ break;
+
+ case GAPROLE_IRK:
+ VOID osal_memcpy( pValue, gapRole_IRK, KEYLEN ) ;
+ break;
+
+ case GAPROLE_SRK:
+ VOID osal_memcpy( pValue, gapRole_SRK, KEYLEN ) ;
+ break;
+
+ case GAPROLE_SIGNCOUNTER:
+ *((uint32*)pValue) = gapRole_signCounter;
+ break;
+
+ case GAPROLE_BD_ADDR:
+ VOID osal_memcpy( pValue, gapRole_bdAddr, B_ADDR_LEN ) ;
+ break;
+
+ case GAPROLE_ADVERT_ENABLED:
+ *((uint8*)pValue) = gapRole_AdvEnabled;
+ break;
+
+ case GAPROLE_ADVERT_OFF_TIME:
+ *((uint16*)pValue) = gapRole_AdvertOffTime;
+ break;
+
+ case GAPROLE_ADVERT_DATA:
+ VOID osal_memcpy( pValue , gapRole_AdvertData, gapRole_AdvertDataLen );
+ break;
+
+ case GAPROLE_SCAN_RSP_DATA:
+ VOID osal_memcpy( pValue, gapRole_ScanRspData, gapRole_ScanRspDataLen ) ;
+ break;
+
+ case GAPROLE_ADV_EVENT_TYPE:
+ *((uint8*)pValue) = gapRole_AdvEventType;
+ break;
+
+ case GAPROLE_ADV_DIRECT_TYPE:
+ *((uint8*)pValue) = gapRole_AdvDirectType;
+ break;
+
+ case GAPROLE_ADV_DIRECT_ADDR:
+ VOID osal_memcpy( pValue, gapRole_AdvDirectAddr, B_ADDR_LEN ) ;
+ break;
+
+ case GAPROLE_ADV_CHANNEL_MAP:
+ *((uint8*)pValue) = gapRole_AdvChanMap;
+ break;
+
+ case GAPROLE_ADV_FILTER_POLICY:
+ *((uint8*)pValue) = gapRole_AdvFilterPolicy;
+ break;
+
+ case GAPROLE_CONNHANDLE:
+ *((uint16*)pValue) = gapRole_ConnectionHandle;
+ break;
+
+ case GAPROLE_RSSI_READ_RATE:
+ *((uint16*)pValue) = gapRole_RSSIReadRate;
+ break;
+
+ case GAPROLE_PARAM_UPDATE_ENABLE:
+ *((uint16*)pValue) = gapRole_ParamUpdateEnable;
+ break;
+
+ case GAPROLE_MIN_CONN_INTERVAL:
+ *((uint16*)pValue) = gapRole_MinConnInterval;
+ break;
+
+ case GAPROLE_MAX_CONN_INTERVAL:
+ *((uint16*)pValue) = gapRole_MaxConnInterval;
+ break;
+
+ case GAPROLE_SLAVE_LATENCY:
+ *((uint16*)pValue) = gapRole_SlaveLatency;
+ break;
+
+ case GAPROLE_TIMEOUT_MULTIPLIER:
+ *((uint16*)pValue) = gapRole_TimeoutMultiplier;
+ break;
+
+ case GAPROLE_CONN_BD_ADDR:
+ VOID osal_memcpy( pValue, gapRole_ConnectedDevAddr, B_ADDR_LEN ) ;
+ break;
+
+ default:
+ // The param value isn't part of this profile, try the GAP.
+ if ( param < TGAP_PARAMID_MAX )
+ {
+ *((uint16*)pValue) = GAP_GetParamValue( param );
+ }
+ else
+ {
+ ret = INVALIDPARAMETER;
+ }
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @brief Does the device initialization.
+ *
+ * Public function defined in peripheral.h.
+ */
+bStatus_t GAPRole_StartDevice( gapRolesCBs_t *pAppCallbacks )
+{
+ if ( gapRole_state == GAPROLE_INIT )
+ {
+ // Clear all of the Application callbacks
+ if ( pAppCallbacks )
+ {
+ pGapRoles_AppCGs = pAppCallbacks;
+ }
+
+ // Start the GAP
+ gapRole_SetupGAP();
+
+ return ( SUCCESS );
+ }
+ else
+ {
+ return ( bleAlreadyInRequestedMode );
+ }
+}
+
+/*********************************************************************
+ * @brief Terminates the existing connection.
+ *
+ * Public function defined in peripheral.h.
+ */
+bStatus_t GAPRole_TerminateConnection( void )
+{
+ if ( (gapRole_state == GAPROLE_CONNECTED)
+ || (gapRole_state == GAPROLE_CONNECTED_ADV) )
+ {
+ return ( GAP_TerminateLinkReq( gapRole_TaskID, gapRole_ConnectionHandle ) );
+ }
+ else
+ {
+ return ( bleIncorrectMode );
+ }
+}
+
+/*********************************************************************
+ * LOCAL FUNCTION PROTOTYPES
+ */
+
+/*********************************************************************
+ * @brief Task Initialization function.
+ *
+ * Internal function defined in peripheral.h.
+ */
+void GAPRole_Init( uint8 task_id )
+{
+ gapRole_TaskID = task_id;
+
+ gapRole_state = GAPROLE_INIT;
+ gapRole_ConnectionHandle = INVALID_CONNHANDLE;
+
+ GAP_RegisterForHCIMsgs( gapRole_TaskID );
+
+ // Initialize the Profile Advertising and Connection Parameters
+ gapRole_profileRole = (GAP_PROFILE_PERIPHERAL | GAP_PROFILE_BROADCASTER);
+ VOID osal_memset( gapRole_IRK, 0, KEYLEN );
+ VOID osal_memset( gapRole_SRK, 0, KEYLEN );
+ gapRole_signCounter = 0;
+ gapRole_AdvEventType = GAP_ADTYPE_ADV_IND;
+ gapRole_AdvDirectType = ADDRTYPE_PUBLIC;
+ gapRole_AdvChanMap = GAP_ADVCHAN_ALL;
+ gapRole_AdvFilterPolicy = GAP_FILTER_POLICY_ALL;
+
+ // Restore Items from NV
+ VOID osal_snv_read( BLE_NVID_IRK, KEYLEN, gapRole_IRK );
+ VOID osal_snv_read( BLE_NVID_CSRK, KEYLEN, gapRole_SRK );
+ VOID osal_snv_read( BLE_NVID_SIGNCOUNTER, sizeof( uint32 ), &gapRole_signCounter );
+}
+
+/*********************************************************************
+ * @brief Task Event Processor function.
+ *
+ * Internal function defined in peripheral.h.
+ */
+uint16 GAPRole_ProcessEvent( uint8 task_id, uint16 events )
+{
+ VOID task_id; // OSAL required parameter that isn't used in this function
+
+ if ( events & SYS_EVENT_MSG )
+ {
+ uint8 *pMsg;
+
+ if ( (pMsg = osal_msg_receive( gapRole_TaskID )) != NULL )
+ {
+ gapRole_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 & GAP_EVENT_SIGN_COUNTER_CHANGED )
+ {
+ // Sign counter changed, save it to NV
+ VOID osal_snv_write( BLE_NVID_SIGNCOUNTER, sizeof( uint32 ), &gapRole_signCounter );
+
+ return ( events ^ GAP_EVENT_SIGN_COUNTER_CHANGED );
+ }
+
+ if ( events & START_ADVERTISING_EVT )
+ {
+ if ( gapRole_AdvEnabled )
+ {
+ gapAdvertisingParams_t params;
+
+ // Setup advertisement parameters
+ if ( gapRole_state == GAPROLE_CONNECTED )
+ {
+ // While in a connection, we can only advertise non-connectable undirected.
+ params.eventType = GAP_ADTYPE_ADV_NONCONN_IND;
+ }
+ else
+ {
+ params.eventType = gapRole_AdvEventType;
+ params.initiatorAddrType = gapRole_AdvDirectType;
+ VOID osal_memcpy( params.initiatorAddr, gapRole_AdvDirectAddr, B_ADDR_LEN );
+ }
+ params.channelMap = gapRole_AdvChanMap;
+ params.filterPolicy = gapRole_AdvFilterPolicy;
+
+ if ( GAP_MakeDiscoverable( gapRole_TaskID, ¶ms ) != SUCCESS )
+ {
+ gapRole_state = GAPROLE_ERROR;
+ if ( pGapRoles_AppCGs && pGapRoles_AppCGs->pfnStateChange )
+ {
+ pGapRoles_AppCGs->pfnStateChange( gapRole_state );
+ }
+ }
+ }
+ return ( events ^ START_ADVERTISING_EVT );
+ }
+
+ if ( events & RSSI_READ_EVT )
+ {
+ // Only get RSSI when in a connection
+ if ( (gapRole_state == GAPROLE_CONNECTED)
+ || (gapRole_state == GAPROLE_CONNECTED_ADV) )
+ {
+ // Ask for RSSI
+ VOID HCI_ReadRssiCmd( gapRole_ConnectionHandle );
+
+ // Setup next event
+ if ( gapRole_RSSIReadRate )
+ {
+ VOID osal_start_timerEx( gapRole_TaskID, RSSI_READ_EVT, gapRole_RSSIReadRate );
+ }
+ }
+ return ( events ^ RSSI_READ_EVT );
+ }
+
+ if ( events & UPDATE_PARAMS_TIMEOUT_EVT )
+ {
+ // Clear an existing timeout
+ if ( osal_get_timeoutEx( gapRole_TaskID, UPDATE_PARAMS_TIMEOUT_EVT ) )
+ {
+ VOID osal_stop_timerEx( gapRole_TaskID, UPDATE_PARAMS_TIMEOUT_EVT );
+ }
+
+ // The Update Parameters Timeout occurred - Terminate connection
+ VOID GAP_TerminateLinkReq( gapRole_TaskID, gapRole_ConnectionHandle );
+
+ return ( events ^ UPDATE_PARAMS_TIMEOUT_EVT );
+ }
+
+ // Discard unknown events
+ return 0;
+}
+
+/*********************************************************************
+ * @fn gapRole_ProcessOSALMsg
+ *
+ * @brief Process an incoming task message.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void gapRole_ProcessOSALMsg( osal_event_hdr_t *pMsg )
+{
+ switch ( pMsg->event )
+ {
+ case HCI_GAP_EVENT_EVENT:
+ if ( pMsg->status == HCI_COMMAND_COMPLETE_EVENT_CODE )
+ {
+ hciEvt_CmdComplete_t *pPkt = (hciEvt_CmdComplete_t *)pMsg;
+
+ if ( pPkt->cmdOpcode == HCI_READ_RSSI )
+ {
+ int8 rssi = (int8)pPkt->pReturnParam[3];
+
+ if ( ((gapRole_state == GAPROLE_CONNECTED)
+ || (gapRole_state == GAPROLE_CONNECTED_ADV))
+ && (rssi != RSSI_NOT_AVAILABLE) )
+ {
+ // Report RSSI to app
+ if ( pGapRoles_AppCGs && pGapRoles_AppCGs->pfnRssiRead )
+ {
+ pGapRoles_AppCGs->pfnRssiRead( rssi );
+ }
+ }
+ }
+ }
+ break;
+
+ case GAP_MSG_EVENT:
+ gapRole_ProcessGAPMsg( (gapEventHdr_t *)pMsg );
+ break;
+
+ case L2CAP_SIGNAL_EVENT:
+ {
+ l2capSignalEvent_t *pPkt = (l2capSignalEvent_t *)pMsg;
+
+ // Process the Parameter Update Response
+ if ( pPkt->opcode == L2CAP_PARAM_UPDATE_RSP )
+ {
+ l2capParamUpdateRsp_t *pRsp = (l2capParamUpdateRsp_t *)&(pPkt->cmd.updateRsp);
+ if ( pRsp->result == SUCCESS )
+ {
+ // All is good stop Update Parameters timeout
+ VOID osal_stop_timerEx( gapRole_TaskID, UPDATE_PARAMS_TIMEOUT_EVT );
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*********************************************************************
+ * @fn gapRole_ProcessGAPMsg
+ *
+ * @brief Process an incoming task message.
+ *
+ * @param pMsg - message to process
+ *
+ * @return none
+ */
+static void gapRole_ProcessGAPMsg( gapEventHdr_t *pMsg )
+{
+ uint8 notify = FALSE; // State changed notify the app? (default no)
+
+ switch ( pMsg->opcode )
+ {
+ case GAP_DEVICE_INIT_DONE_EVENT:
+ {
+ gapDeviceInitDoneEvent_t *pPkt = (gapDeviceInitDoneEvent_t *)pMsg;
+ bStatus_t stat = pPkt->hdr.status;
+
+ if ( stat == SUCCESS )
+ {
+ // Save off the generated keys
+ VOID osal_snv_write( BLE_NVID_IRK, KEYLEN, gapRole_IRK );
+ VOID osal_snv_write( BLE_NVID_CSRK, KEYLEN, gapRole_SRK );
+
+ // Save off the information
+ VOID osal_memcpy( gapRole_bdAddr, pPkt->devAddr, B_ADDR_LEN );
+
+ gapRole_state = GAPROLE_STARTED;
+
+ // Update the advertising data
+ stat = GAP_UpdateAdvertisingData( gapRole_TaskID,
+ TRUE, gapRole_AdvertDataLen, gapRole_AdvertData );
+ }
+
+ if ( stat != SUCCESS )
+ {
+ gapRole_state = GAPROLE_ERROR;
+ }
+
+ notify = TRUE;
+ }
+ break;
+
+ case GAP_ADV_DATA_UPDATE_DONE_EVENT:
+ {
+ gapAdvDataUpdateEvent_t *pPkt = (gapAdvDataUpdateEvent_t *)pMsg;
+
+ if ( pPkt->hdr.status == SUCCESS )
+ {
+ if ( pPkt->adType )
+ {
+ // Setup the Response Data
+ pPkt->hdr.status = GAP_UpdateAdvertisingData( gapRole_TaskID,
+ FALSE, gapRole_ScanRspDataLen, gapRole_ScanRspData );
+ }
+ else
+ {
+ // Start advertising
+ VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );
+ }
+ }
+
+ if ( pPkt->hdr.status != SUCCESS )
+ {
+ // Set into Error state
+ gapRole_state = GAPROLE_ERROR;
+ notify = TRUE;
+ }
+ }
+ break;
+
+ case GAP_MAKE_DISCOVERABLE_DONE_EVENT:
+ case GAP_END_DISCOVERABLE_DONE_EVENT:
+ {
+ gapMakeDiscoverableRspEvent_t *pPkt = (gapMakeDiscoverableRspEvent_t *)pMsg;
+
+ if ( pPkt->hdr.status == SUCCESS )
+ {
+ if ( pMsg->opcode == GAP_MAKE_DISCOVERABLE_DONE_EVENT )
+ {
+ if ( gapRole_state == GAPROLE_CONNECTED )
+ {
+ gapRole_state = GAPROLE_CONNECTED_ADV;
+ }
+ else
+ {
+ gapRole_state = GAPROLE_ADVERTISING;
+ }
+ }
+ else // GAP_END_DISCOVERABLE_DONE_EVENT
+ {
+
+ if ( gapRole_AdvertOffTime != 0 )
+ {
+ if ( ( gapRole_AdvEnabled ) )
+ {
+ VOID osal_start_timerEx( gapRole_TaskID, START_ADVERTISING_EVT, gapRole_AdvertOffTime );
+ }
+ }
+ else
+ {
+ // Since gapRole_AdvertOffTime is set to 0, the device should not
+ // automatically become discoverable again after a period of time.
+ // Set enabler to FALSE; device will become discoverable again when
+ // this value gets set to TRUE
+ gapRole_AdvEnabled = FALSE;
+ }
+
+ // In the Advertising Off period
+ gapRole_state = GAPROLE_WAITING;
+
+ }
+ }
+ else
+ {
+ gapRole_state = GAPROLE_ERROR;
+ }
+ notify = TRUE;
+ }
+ break;
+
+ case GAP_LINK_ESTABLISHED_EVENT:
+ {
+ gapEstLinkReqEvent_t *pPkt = (gapEstLinkReqEvent_t *)pMsg;
+
+ if ( pPkt->hdr.status == SUCCESS )
+ {
+ VOID osal_memcpy( gapRole_ConnectedDevAddr, pPkt->devAddr, B_ADDR_LEN );
+ gapRole_ConnectionHandle = pPkt->connectionHandle;
+ gapRole_state = GAPROLE_CONNECTED;
+
+ if ( gapRole_RSSIReadRate )
+ {
+ // Start the RSSI Reads
+ VOID osal_start_timerEx( gapRole_TaskID, RSSI_READ_EVT, gapRole_RSSIReadRate );
+ }
+
+ // Check whether update parameter request is enabled, and check the connection parameters
+ if ( ( gapRole_ParamUpdateEnable == TRUE ) &&
+ ( (pPkt->connInterval < gapRole_MinConnInterval) ||
+ (pPkt->connInterval > gapRole_MaxConnInterval) ||
+ (pPkt->connLatency != gapRole_SlaveLatency) ||
+ (pPkt->connTimeout != gapRole_TimeoutMultiplier) ))
+ {
+ gapRole_SendUpdateParam( pPkt->connInterval, pPkt->connLatency );
+ }
+
+ // Notify the Bond Manager to the connection
+ VOID GAPBondMgr_LinkEst( pPkt->devAddrType, pPkt->devAddr, pPkt->connectionHandle, GAP_PROFILE_PERIPHERAL );
+ }
+ else
+ {
+ gapRole_state = GAPROLE_ERROR;
+ }
+ notify = TRUE;
+ }
+ break;
+
+ case GAP_LINK_TERMINATED_EVENT:
+ {
+ GAPBondMgr_ProcessGAPMsg( (gapEventHdr_t *)pMsg );
+ osal_memset( gapRole_ConnectedDevAddr, 0, B_ADDR_LEN );
+
+ if ( gapRole_state == GAPROLE_CONNECTED_ADV )
+ {
+ // End the non-connectable advertising
+ GAP_EndDiscoverable( gapRole_TaskID );
+ gapRole_state = GAPROLE_CONNECTED;
+ }
+ else
+ {
+ gapTerminateLinkEvent_t *pPkt = (gapTerminateLinkEvent_t *)pMsg;
+ if( pPkt->reason == LL_SUPERVISION_TIMEOUT_TERM )
+ {
+ gapRole_state = GAPROLE_WAITING_AFTER_TIMEOUT;
+ }
+ else
+ {
+ gapRole_state = GAPROLE_WAITING;
+ }
+
+ notify = TRUE;
+
+ VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );
+ }
+
+ gapRole_ConnectionHandle = INVALID_CONNHANDLE;
+ }
+ break;
+
+ case GAP_LINK_PARAM_UPDATE_EVENT:
+ {
+ gapLinkUpdateEvent_t *pPkt = (gapLinkUpdateEvent_t *)pMsg;
+
+ if ( (pPkt->hdr.status != SUCCESS)
+ || (pPkt->connInterval < gapRole_MinConnInterval)
+ || (pPkt->connInterval > gapRole_MaxConnInterval) )
+ {
+ // Ask to change the interval
+ gapRole_SendUpdateParam( pPkt->connInterval, pPkt->connLatency );
+ }
+ else
+ {
+ // All is good stop Update Parameters timeout
+ VOID osal_stop_timerEx( gapRole_TaskID, UPDATE_PARAMS_TIMEOUT_EVT );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if ( notify == TRUE )
+ {
+ // Notify the application
+ if ( pGapRoles_AppCGs && pGapRoles_AppCGs->pfnStateChange )
+ {
+ pGapRoles_AppCGs->pfnStateChange( gapRole_state );
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn gapRole_SetupGAP
+ *
+ * @brief Call the GAP Device Initialization function using the
+ * Profile Parameters.
+ *
+ * @param none
+ *
+ * @return none
+ */
+static void gapRole_SetupGAP( void )
+{
+ VOID GAP_DeviceInit( gapRole_TaskID,
+ gapRole_profileRole, 0,
+ gapRole_IRK, gapRole_SRK,
+ &gapRole_signCounter );
+}
+
+/*********************************************************************
+ * @fn gapRole_SendUpdateParam
+ *
+ * @brief Send an Update Connection Parameters.
+ *
+ * @param connInterval - current connection interval
+ * @param connLatency - current connection latency
+ *
+ * @return none
+ */
+static void gapRole_SendUpdateParam( uint16 connInterval, uint16 connLatency )
+{
+ l2capParamUpdateReq_t updateReq; // Space for Conn Update parameters
+ uint32 timeout; // Calculated response timeout
+
+ // Calculate the current interval
+ uint16 effectiveOldInterval = (connInterval * (connLatency + 1));
+
+ // Calculate the interval we want
+ uint16 effectiveNewMaxInterval = (gapRole_MaxConnInterval * (gapRole_SlaveLatency + 1));
+
+ // Fill in the wanted parameters
+ updateReq.intervalMin = gapRole_MinConnInterval;
+ updateReq.intervalMax = gapRole_MaxConnInterval;
+ updateReq.slaveLatency = gapRole_SlaveLatency;
+ updateReq.timeoutMultiplier = gapRole_TimeoutMultiplier;
+
+ VOID L2CAP_ConnParamUpdateReq( gapRole_ConnectionHandle, &updateReq, gapRole_TaskID );
+
+ // Set up the timeout for expected response
+ if( effectiveOldInterval > effectiveNewMaxInterval )
+ {
+ timeout = (uint32)(effectiveOldInterval) * CONN_INTERVAL_MULTIPLIER;
+ }
+ else
+ {
+ timeout = (uint32)(effectiveNewMaxInterval) * CONN_INTERVAL_MULTIPLIER;
+ }
+
+ if( timeout > MAX_TIMEOUT_VALUE )
+ {
+ timeout = MAX_TIMEOUT_VALUE;
+ }
+
+ VOID osal_start_timerEx( gapRole_TaskID, UPDATE_PARAMS_TIMEOUT_EVT, (uint16)(timeout) );
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/peripheralBroadcaster.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/peripheralBroadcaster.h
new file mode 100644
index 0000000..2b84cef
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Roles/peripheralBroadcaster.h
@@ -0,0 +1,242 @@
+/**
+ @headerfile: peripheralBroadcaster.h
+ $Date: 2011-08-04 12:05:19 -0700 (Thu, 04 Aug 2011) $
+ $Revision: 27026 $
+
+ @mainpage TI BLE GAP Peripheral + Broadcaster Roles
+
+ This GAP profile advertises and allows connections and adds the ability to
+ advertise (non-connectable) during a connection.
+
+ Copyright 2010 - 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*/
+
+#ifndef PERIPHERAL_BROADCASTER_H
+#define PERIPHERAL_BROADCASTER_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*-------------------------------------------------------------------
+ * INCLUDES
+ */
+
+/*-------------------------------------------------------------------
+ * CONSTANTS
+ */
+
+/** @defgroup GAPROLE_PROFILE_PARAMETERS GAP Role Parameters
+ * @{
+ */
+#define GAPROLE_PROFILEROLE 0x300 //!< Reading this parameter will return GAP Role type. Read Only. Size is uint8.
+#define GAPROLE_IRK 0x301 //!< Identity Resolving Key. Read/Write. Size is uint8[KEYLEN]. Default is all 0, which means that the IRK will be randomly generated.
+#define GAPROLE_SRK 0x302 //!< Signature Resolving Key. Read/Write. Size is uint8[KEYLEN]. Default is all 0, which means that the SRK will be randomly generated.
+#define GAPROLE_SIGNCOUNTER 0x303 //!< Sign Counter. Read/Write. Size is uint32. Default is 0.
+#define GAPROLE_BD_ADDR 0x304 //!< Device's Address. Read Only. Size is uint8[B_ADDR_LEN]. This item is read from the controller.
+#define GAPROLE_ADVERT_ENABLED 0x305 //!< Enable/Disable Advertising. Read/Write. Size is uint8. Default is TRUE=Enabled. During a connection, this will enable and display advertising (non-connectable undirected). Setting this variable during a connection does not change the permanent state of the parameter.
+#define GAPROLE_ADVERT_OFF_TIME 0x306 //!< Advertising Off Time for Limited advertisements (in milliseconds). Read/Write. Size is uint16. Default is 30 seconds.
+#define GAPROLE_ADVERT_DATA 0x307 //!< Advertisement Data. Read/Write. Max size is uint8[B_MAX_ADV_LEN]. Default is "02:01:01", which means that it is a Limited Discoverable Advertisement.
+#define GAPROLE_SCAN_RSP_DATA 0x308 //!< Scan Response Data. Read/Write. Max size is uint8[B_MAX_ADV_LEN]. Defaults to all 0.
+#define GAPROLE_ADV_EVENT_TYPE 0x309 //!< Advertisement Type. Read/Write. Size is uint8. Default is GAP_ADTYPE_ADV_IND (defined in GAP.h).
+#define GAPROLE_ADV_DIRECT_TYPE 0x30A //!< Direct Advertisement Address Type. Read/Write. Size is uint8. Default is ADDRTYPE_PUBLIC (defined in GAP.h).
+#define GAPROLE_ADV_DIRECT_ADDR 0x30B //!< Direct Advertisement Address. Read/Write. Size is uint8[B_ADDR_LEN]. Default is NULL.
+#define GAPROLE_ADV_CHANNEL_MAP 0x30C //!< Which channels to advertise on. Read/Write Size is uint8. Default is GAP_ADVCHAN_ALL (defined in GAP.h)
+#define GAPROLE_ADV_FILTER_POLICY 0x30D //!< Filter Policy. Ignored when directed advertising is used. Read/Write. Size is uint8. Default is GAP_FILTER_POLICY_ALL (defined in GAP.h).
+#define GAPROLE_CONNHANDLE 0x30E //!< Connection Handle. Read Only. Size is uint16.
+#define GAPROLE_RSSI_READ_RATE 0x30F //!< How often to read the RSSI during a connection. Read/Write. Size is uint16. The value is in milliseconds. Default is 0 = OFF.
+#define GAPROLE_PARAM_UPDATE_ENABLE 0x310 //!< Slave Connection Parameter Update Enable. Read/Write. Size is uint8. If TRUE then automatic connection parameter update request is sent. Default is FALSE.
+#define GAPROLE_MIN_CONN_INTERVAL 0x311 //!< Minimum Connection Interval to allow (n * 1.25ms). Range: 7.5 msec to 4 seconds (0x0006 to 0x0C80). Read/Write. Size is uint16. Default is 7.5 milliseconds (0x0006).
+#define GAPROLE_MAX_CONN_INTERVAL 0x312 //!< Maximum Connection Interval to allow (n * 1.25ms). Range: 7.5 msec to 4 seconds (0x0006 to 0x0C80). Read/Write. Size is uint16. Default is 4 seconds (0x0C80).
+#define GAPROLE_SLAVE_LATENCY 0x313 //!< Update Parameter Slave Latency. Range: 0 - 499. Read/Write. Size is uint16. Default is 0.
+#define GAPROLE_TIMEOUT_MULTIPLIER 0x314 //!< Update Parameter Timeout Multiplier (n * 10ms). Range: 100ms to 32 seconds (0x000a - 0x0c80). Read/Write. Size is uint16. Default is 1000.
+#define GAPROLE_CONN_BD_ADDR 0x315 //!< Address of connected device. Read only. Size is uint8[B_MAX_ADV_LEN]. Set to all zeros when not connected.
+/** @} End GAPROLE_PROFILE_PARAMETERS */
+
+/*-------------------------------------------------------------------
+ * TYPEDEFS
+ */
+
+/**
+ * GAP Peripheral + Broadcaster Role States.
+ */
+typedef enum
+{
+ GAPROLE_INIT = 0, //!< Waiting to be started
+ GAPROLE_STARTED, //!< Started but not advertising
+ GAPROLE_ADVERTISING, //!< Currently Advertising
+ GAPROLE_WAITING, //!< Device is started but not advertising, is in waiting period before advertising again
+ GAPROLE_WAITING_AFTER_TIMEOUT, //!< Device just timed out from a connection but is not yet advertising, is in waiting period before advertising again
+ GAPROLE_CONNECTED, //!< In a connection
+ GAPROLE_CONNECTED_ADV, //!< In a connection and advertising
+ GAPROLE_ERROR //!< Error occurred - invalid state
+} gaprole_States_t;
+
+/*-------------------------------------------------------------------
+ * MACROS
+ */
+
+/*-------------------------------------------------------------------
+ * Profile Callbacks
+ */
+
+/**
+ * Callback when the device has been started. Callback event to
+ * the Notify of a state change.
+ */
+typedef void (*gapRolesStateNotify_t)( gaprole_States_t newState );
+
+/**
+ * Callback when the device has read an new RSSI value during a connection.
+ */
+typedef void (*gapRolesRssiRead_t)( int8 newRSSI );
+
+/**
+ * Callback structure - must be setup by the application and used when gapRoles_StartDevice() is called.
+ */
+typedef struct
+{
+ gapRolesStateNotify_t pfnStateChange; //!< Whenever the device changes state
+ gapRolesRssiRead_t pfnRssiRead; //!< When a valid RSSI is read from controller
+} gapRolesCBs_t;
+
+/*-------------------------------------------------------------------
+ * API FUNCTIONS
+ */
+
+/**
+ * @defgroup GAPROLES_PERIPHERAL_BROADCASTER_API GAP Peripheral + Broadcaster Role API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Set a GAP Role parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will set the
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also,
+ * the "len" field must be set to the size of a "uint16" and the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
+ * @param len - length of data to write
+ * @param pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPRole_SetParameter( uint16 param, uint8 len, void *pValue );
+
+/**
+ * @brief Get a GAP Role parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will get a
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also, the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
+ * @param pValue - pointer to location to get the value. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPRole_GetParameter( uint16 param, void *pValue );
+
+/**
+ * @brief Does the device initialization. Only call this function once.
+ *
+ * @param pAppCallbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+extern bStatus_t GAPRole_StartDevice( gapRolesCBs_t *pAppCallbacks );
+
+/**
+ * @brief Terminates the existing connection.
+ *
+ * @return SUCCESS or bleIncorrectMode
+ */
+extern bStatus_t GAPRole_TerminateConnection( void );
+
+/**
+ * @} End GAPROLES_PERIPHERAL_BROADCASTER_API
+ */
+
+
+/*-------------------------------------------------------------------
+ * TASK FUNCTIONS - Don't call these. These are system functions.
+ */
+
+/**
+ * @internal
+ *
+ * @brief Initialization function for the GAP Role Task.
+ * This is called during initialization and should contain
+ * any application specific initialization (ie. hardware
+ * initialization/setup, table initialization, power up
+ * notificaiton ... ).
+ *
+ * @param the ID assigned by OSAL. This ID should be
+ * used to send messages and set timers.
+ *
+ * @return void
+ */
+extern void GAPRole_Init( uint8 task_id );
+
+/**
+ * @internal
+ *
+ * @brief GAP Role 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 events not processed
+ */
+extern uint16 GAPRole_ProcessEvent( uint8 task_id, uint16 events );
+
+/*-------------------------------------------------------------------
+-------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PERIPHERAL_BROADCASTER_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/ScanParam/scanparamservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/ScanParam/scanparamservice.c
new file mode 100644
index 0000000..be9800b
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/ScanParam/scanparamservice.c
@@ -0,0 +1,449 @@
+/**************************************************************************************************
+ Filename: scanparamservice.c
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: This file contains the Scan Parameters Service.
+
+ Copyright 2011 - 2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "gapbondmgr.h"
+#include "linkdb.h"
+#include "scanparamservice.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+// Scan parameters service
+CONST uint8 scanParamServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(SCAN_PARAM_SERVICE_UUID), HI_UINT16(SCAN_PARAM_SERVICE_UUID)
+};
+
+// Scan interval window characteristic
+CONST uint8 scanIntervalWindowUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(SCAN_INTERVAL_WINDOW_UUID), HI_UINT16(SCAN_INTERVAL_WINDOW_UUID)
+};
+
+// Scan parameter refresh characteristic
+CONST uint8 scanParamRefreshUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(SCAN_PARAM_REFRESH_UUID), HI_UINT16(SCAN_PARAM_REFRESH_UUID)
+};
+
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+// Application callback
+static scanParamServiceCB_t scanParamServiceCB;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Scan Parameters Service attribute
+static CONST gattAttrType_t scanParamService = { ATT_BT_UUID_SIZE, scanParamServUUID };
+
+// Scan Interval Window characteristic
+static uint8 scanIntervalWindowProps = GATT_PROP_WRITE_NO_RSP;
+static uint8 scanIntervalWindow[SCAN_INTERVAL_WINDOW_CHAR_LEN];
+
+// Scan Parameter Refresh characteristic
+static uint8 scanParamRefreshProps = GATT_PROP_NOTIFY;
+static uint8 scanParamRefresh[SCAN_PARAM_REFRESH_LEN];
+static gattCharCfg_t scanParamRefreshClientCharCfg[GATT_MAX_NUM_CONN];
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t scanParamAttrTbl[] =
+{
+ // Scan Parameters Service attribute
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&scanParamService /* pValue */
+ },
+
+ // Scan Interval Window declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &scanIntervalWindowProps
+ },
+
+ // Scan Interval Window characteristic
+ {
+ { ATT_BT_UUID_SIZE, scanIntervalWindowUUID },
+ GATT_PERMIT_WRITE,
+ 0,
+ scanIntervalWindow
+ },
+
+ // Scan Parameter Refresh declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &scanParamRefreshProps
+ },
+
+ // Scan Parameter Refresh characteristic
+ {
+ { ATT_BT_UUID_SIZE, scanParamRefreshUUID },
+ 0,
+ 0,
+ scanParamRefresh
+ },
+
+ // Scan Parameter Refresh characteristic client characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *) &scanParamRefreshClientCharCfg
+ }
+};
+
+// Attribute index enumeration-- these indexes match array elements above
+enum
+{
+ SCAN_PARAM_SERVICE_IDX, // Scan Parameters Service
+ SCAN_PARAM_INTERVAL_DECL_IDX, // Scan Interval Window declaration
+ SCAN_PARAM_INTERVAL_IDX, // Scan Interval Window characteristic
+ SCAN_PARAM_REFRESH_DECL_IDX, // Scan Parameter Refresh declaration
+ SCAN_PARAM_REFRESH_IDX, // Scan Parameter Refresh characteristic
+ SCAN_PARAM_REFRESH_CCCD_IDX // Scan Parameter Refresh characteristic client characteristic configuration
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static bStatus_t scanParamWriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+static uint8 scanParamReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+
+// Service Callbacks
+CONST gattServiceCBs_t scanParamCBs =
+{
+ scanParamReadAttrCB, // Read callback function pointer
+ scanParamWriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn ScanParam_AddService
+ *
+ * @brief Initializes the Battery Service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @return Success or Failure
+ */
+bStatus_t ScanParam_AddService( void )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, scanParamRefreshClientCharCfg );
+
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( scanParamAttrTbl, GATT_NUM_ATTRS( scanParamAttrTbl ),
+ &scanParamCBs );
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn ScanParam_Register
+ *
+ * @brief Register a callback function with the Battery Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return None.
+ */
+extern void ScanParam_Register( scanParamServiceCB_t pfnServiceCB )
+{
+ scanParamServiceCB = pfnServiceCB;
+}
+
+/*********************************************************************
+ * @fn ScanParam_SetParameter
+ *
+ * @brief Set a Battery Service parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t ScanParam_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn ScanParam_GetParameter
+ *
+ * @brief Get a Battery Service parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t ScanParam_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case SCAN_PARAM_PARAM_INTERVAL:
+ *((uint16*)value) = BUILD_UINT16(scanIntervalWindow[0],
+ scanIntervalWindow[1]);
+ break;
+
+ case SCAN_PARAM_PARAM_WINDOW:
+ *((uint16*)value) = BUILD_UINT16(scanIntervalWindow[2],
+ scanIntervalWindow[3]);
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn ScanParam_RefreshNotify
+ *
+ * @brief Notify the peer to refresh the scan parameters.
+ *
+ * @param connHandle - connection handle
+ *
+ * @return None
+ */
+void ScanParam_RefreshNotify( uint16 connHandle )
+{
+ attHandleValueNoti_t noti;
+ uint16 value;
+
+ value = GATTServApp_ReadCharCfg( connHandle, scanParamRefreshClientCharCfg );
+
+ if ( value & GATT_CLIENT_CFG_NOTIFY )
+ {
+ // send notification
+ noti.handle = scanParamAttrTbl[SCAN_PARAM_REFRESH_CCCD_IDX].handle;
+ noti.len = SCAN_PARAM_REFRESH_LEN;
+ noti.value[0] = SCAN_PARAM_REFRESH_REQ;
+ GATT_Notification( connHandle, ¬i, FALSE );
+ }
+}
+
+/*********************************************************************
+ * @fn scanParamReadAttrCB
+ *
+ * @brief GATT read callback.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 scanParamReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ bStatus_t status = SUCCESS;
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn scanParamWriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t scanParamWriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+
+ // Only one writeable attribute
+ if ( uuid == SCAN_INTERVAL_WINDOW_UUID )
+ {
+ // require encryption
+ if ( linkDB_Encrypted( connHandle ) == FALSE )
+ {
+ return ( ATT_ERR_INSUFFICIENT_ENCRYPT );
+ }
+
+ if ( len == SCAN_INTERVAL_WINDOW_CHAR_LEN )
+ {
+ uint16 interval = BUILD_UINT16( pValue[0], pValue[1] );
+ uint16 window = BUILD_UINT16( pValue[0], pValue[1] );
+
+ // Validate values
+ if ( window <= interval )
+ {
+ osal_memcpy( pAttr->pValue, pValue, len );
+
+ (*scanParamServiceCB)( SCAN_INTERVAL_WINDOW_SET );
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_VALUE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else if ( uuid == GATT_CLIENT_CHAR_CFG_UUID )
+ {
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn ScanParam_HandleConnStatusCB
+ *
+ * @brief Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+void ScanParam_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, scanParamRefreshClientCharCfg );
+ }
+ }
+}
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/ScanParam/scanparamservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/ScanParam/scanparamservice.h
new file mode 100644
index 0000000..6f2c88b
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/ScanParam/scanparamservice.h
@@ -0,0 +1,176 @@
+/**************************************************************************************************
+ Filename: cmdenumservice.h
+ Revised: $Date: 2011-12-16 15:46:52 -0800 (Fri, 16 Dec 2011) $
+ Revision: $Revision: 58 $
+
+ Description: This file contains the Scan Parameters Service definitions and
+ prototypes.
+
+ Copyright 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef SCANPARAMSERVICE_H
+#define SCANPARAMSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Scan Parameters Service UUIDs
+#define SCAN_PARAM_SERVICE_UUID 0x1813
+#define SCAN_INTERVAL_WINDOW_UUID 0x2A4F
+#define SCAN_PARAM_REFRESH_UUID 0x2A31
+
+// Scan Characteristic Lengths
+#define SCAN_INTERVAL_WINDOW_CHAR_LEN 4
+#define SCAN_PARAM_REFRESH_LEN 1
+
+// Scan Parameter Refresh Values
+#define SCAN_PARAM_REFRESH_REQ 0x00
+
+// Callback events
+#define SCAN_INTERVAL_WINDOW_SET 1
+
+// Get/Set parameters
+#define SCAN_PARAM_PARAM_INTERVAL 0
+#define SCAN_PARAM_PARAM_WINDOW 1
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// Scan Parameters Service callback function
+typedef void (*scanParamServiceCB_t)( uint8 event );
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn ScanParam_AddService
+ *
+ * @brief Initializes the Service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t ScanParam_AddService( void );
+
+/*********************************************************************
+ * @fn ScanParam_Register
+ *
+ * @brief Register a callback function with the Scan Parameters Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return None.
+ */
+extern void ScanParam_Register( scanParamServiceCB_t pfnServiceCB );
+
+/*********************************************************************
+ * @fn ScanParam_SetParameter
+ *
+ * @brief Set a Scan Parameters Service parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+extern bStatus_t ScanParam_SetParameter( uint8 param, uint8 len, void *value );
+
+/*********************************************************************
+ * @fn ScanParam_GetParameter
+ *
+ * @brief Get a Scan Parameters Service parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+extern bStatus_t ScanParam_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+ * @fn ScanParam_RefreshNotify
+ *
+ * @brief Notify the peer to refresh the scan parameters.
+ *
+ * @param connHandle - connection handle
+ *
+ * @return None
+ */
+extern void ScanParam_RefreshNotify( uint16 connHandle );
+
+/*********************************************************************
+ * @fn ScanParam_HandleConnStatusCB
+ *
+ * @brief Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+void ScanParam_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SCANPARAMSERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/accelerometerservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/accelerometerservice.c
new file mode 100644
index 0000000..857fef4
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/accelerometerservice.c
@@ -0,0 +1,634 @@
+/**************************************************************************************************
+ Filename: accelerometerservice.c
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: Accelerometer service.
+
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "linkdb.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+
+#include "accelerometerservice.h"
+#include "st_util.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// Accelerometer Service UUID
+CONST uint8 accelServUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(ACCELEROMETER_SERV_UUID),
+};
+
+// Accelerometer Characteristic value Data UUID
+CONST uint8 accelDataUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(ACCELEROMETER_DATA_UUID),
+};
+
+// Accelerometer Characteristic value Configuration UUID
+CONST uint8 accelCfgUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(ACCELEROMETER_CONF_UUID),
+};
+
+// Accelerometer Characteristic value Configuration UUID
+CONST uint8 accelPeriodUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(ACCELEROMETER_PERI_UUID),
+};
+
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static accelCBs_t *accel_AppCBs = NULL;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Accelerometer Profile Service attribute
+static CONST gattAttrType_t accelService = { TI_UUID_SIZE, accelServUUID };
+
+// Accelerometer Characteristic Properties
+static uint8 accelDataProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+
+static uint8 accelData[ACCELEROMETER_DATA_LEN] = { 0, 0, 0};
+
+// Accelerometer Characteristic Configuration
+static gattCharCfg_t accelDataConfig[GATT_MAX_NUM_CONN];
+
+// Accelerometer Characteristic User Description
+static uint8 accelDataUserDesp[] = "Accel. Data";
+
+// Accelerometer Characteristic Configuration Properties
+static uint8 accelCfgProps = GATT_PROP_READ | GATT_PROP_WRITE;
+
+// Accelerometer Characteristic Configuration Value
+static uint8 accelCfg = 0;
+
+// Accelerometer Characteristic Configuration User Description
+static uint8 accelCfgUserDesp[] = "Accel. Conf.";
+
+// Accelerometer Characteristic Period Properties
+static uint8 accPerProps = GATT_PROP_READ | GATT_PROP_WRITE;
+
+// Accelerometer Characteristic Period Value
+static uint8 accPer = 0;
+
+// Accelerometer Characteristic Period User Description
+static uint8 accPerUserDesp[] = "Acc. Period";
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t accelAttrTbl[] =
+{
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&accelService /* pValue */
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &accelDataProps
+ },
+
+ // Characteristic Value "Data"
+ {
+ { TI_UUID_SIZE, accelDataUUID },
+ GATT_PERMIT_READ,
+ 0,
+ accelData
+ },
+
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)accelDataConfig
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ accelDataUserDesp
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &accelCfgProps
+ },
+
+ // Characteristic Value "Configuration"
+ {
+ { TI_UUID_SIZE, accelCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &accelCfg
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ accelCfgUserDesp
+ },
+ // Characteristic Declaration "Period"
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &accPerProps
+ },
+
+ // Characteristic Value "Period"
+ {
+ { TI_UUID_SIZE, accelPeriodUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &accPer
+ },
+
+ // Characteristic User Description "Period"
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ accPerUserDesp
+ },
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 acc_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t acc_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+static void acc_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Simple Profile Service Callbacks
+CONST gattServiceCBs_t accCBs =
+{
+ acc_ReadAttrCB, // Read callback function pointer
+ acc_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Accel_AddService
+ *
+ * @brief Initializes the Sensor Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Accel_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( acc_HandleConnStatusCB );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, accelDataConfig );
+
+ if (services & ACCELEROMETER_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( accelAttrTbl,
+ GATT_NUM_ATTRS( accelAttrTbl ),
+ &accCBs );
+ }
+
+ return ( status );
+}
+
+
+/*********************************************************************
+ * @fn Accel_RegisterAppCBs
+ *
+ * @brief Registers the application callback function. Only call
+ * this function once.
+ *
+ * @param callbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+bStatus_t Accel_RegisterAppCBs( accelCBs_t *appCallbacks )
+{
+ if ( accel_AppCBs == NULL )
+ {
+ if ( appCallbacks != NULL )
+ {
+ accel_AppCBs = appCallbacks;
+ }
+
+ return ( SUCCESS );
+ }
+
+ return ( bleAlreadyInRequestedMode );
+}
+
+/*********************************************************************
+ * @fn Accel_SetParameter
+ *
+ * @brief Set an Accelrometer parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Accel_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case ACCELEROMETER_DATA:
+ if ( len == ACCELEROMETER_DATA_LEN )
+ {
+ VOID osal_memcpy( accelData, value, ACCELEROMETER_DATA_LEN );
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( accelDataConfig, accelData, FALSE,
+ accelAttrTbl, GATT_NUM_ATTRS( accelAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case ACCELEROMETER_CONF:
+ if ( len == sizeof ( uint8 ) )
+ {
+ accelCfg = *((uint8*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case ACCELEROMETER_PERI:
+ if ( len == sizeof ( uint8 ) )
+ {
+ accPer = *((uint8*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Accel_GetParameter
+ *
+ * @brief Get a Sensor Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Accel_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case ACCELEROMETER_DATA:
+ VOID osal_memcpy( value, accelData, ACCELEROMETER_DATA_LEN );
+ break;
+
+ case ACCELEROMETER_CONF:
+ *((uint8*)value) = accelCfg;
+ break;
+
+ case ACCELEROMETER_PERI:
+ *((uint8*)value) = accPer;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn acc_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 acc_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+
+ // If attribute permissions require authorization to read, return error
+ if ( gattPermitAuthorRead( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE) {
+ // Invalid handle
+ *pLen = 0;
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
+ // gattserverapp handles those reads
+ case ACCELEROMETER_DATA_UUID:
+ *pLen = ACCELEROMETER_DATA_LEN;
+ VOID osal_memcpy( pValue, pAttr->pValue, ACCELEROMETER_DATA_LEN );
+ break;
+
+ case ACCELEROMETER_CONF_UUID:
+ case ACCELEROMETER_PERI_UUID:
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ break;
+
+ default:
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+* @fn acc_WriteAttrCB
+*
+* @brief Validate attribute data prior to a write operation
+*
+* @param connHandle - connection message was received on
+* @param pAttr - pointer to attribute
+* @param pValue - pointer to data to be written
+* @param len - length of data
+* @param offset - offset of the first octet to be written
+*
+* @return Success or Failure
+*/
+static bStatus_t acc_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+ uint8 notifyApp = 0xFF;
+ uint16 uuid;
+
+ // If attribute permissions require authorization to write, return error
+ if ( gattPermitAuthorWrite( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE) {
+ // Invalid handle
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ case ACCELEROMETER_DATA_UUID:
+ // Should not get here
+ break;
+
+ case ACCELEROMETER_CONF_UUID:
+ // Validate the value
+ // Make sure it's not a blob oper
+ if ( offset == 0 )
+ {
+ if ( len != 1 )
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ // Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+
+ *pCurValue = pValue[0];
+
+ if( pAttr->pValue == &accelCfg )
+ {
+ notifyApp = ACCELEROMETER_CONF;
+ }
+ }
+ break;
+
+ case ACCELEROMETER_PERI_UUID:
+ // Validate the value
+ // Make sure it's not a blob oper
+ if ( offset == 0 )
+ {
+ if ( len != 1 )
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+ // Write the value
+ if ( status == SUCCESS )
+ {
+ if (pValue[0]>=(ACCELEROMETER_MIN_PERIOD/ACCELEROMETER_TIME_UNIT))
+ {
+
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+ *pCurValue = pValue[0];
+
+ if( pAttr->pValue == &accPer )
+ {
+ notifyApp = ACCELEROMETER_PERI;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_VALUE;
+ }
+ }
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ // Should never get here!
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ // If a charactersitic value changed then callback function to notify application of change
+ if ( (notifyApp != 0xFF ) && accel_AppCBs && accel_AppCBs->pfnAccelChange )
+ {
+ accel_AppCBs->pfnAccelChange( notifyApp );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn acc_HandleConnStatusCB
+ *
+ * @brief Sensor Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void acc_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, accelDataConfig );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/accelerometerservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/accelerometerservice.h
new file mode 100644
index 0000000..6f9482b
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/accelerometerservice.h
@@ -0,0 +1,151 @@
+/**************************************************************************************************
+ Filename: accelerometerservice.h
+ Revised: $Date: 2013-02-07 05:39:50 -0800 (Thu, 07 Feb 2013) $
+ Revision: $Revision: 33009 $
+
+ Description: Accelerometer service definitions and prototypes
+
+
+ Copyright 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef ACCELEROMETERSERVICE_H
+#define ACCELEROMETERSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Profile Parameters
+#define ACCELEROMETER_DATA 2 // R uint8 - Profile Attribute value
+#define ACCELEROMETER_CONF 3 // RW uint8 - Profile Attribute value
+#define ACCELEROMETER_PERI 4 // RW uint8 - Profile Attribute Value
+
+// Service UUID
+#define ACCELEROMETER_SERV_UUID 0xAA10 // F0000000-0451-4000-B000-00000000-AA10
+#define ACCELEROMETER_DATA_UUID 0xAA11
+#define ACCELEROMETER_CONF_UUID 0xAA12
+#define ACCELEROMETER_PERI_UUID 0xAA13
+
+// Sensor Profile Services bit fields
+#define ACCELEROMETER_SERVICE 0x00000002
+
+// Length of sensor data in bytes
+#define ACCELEROMETER_DATA_LEN 3
+
+ // Minimum accelerometer period
+#define ACCELEROMETER_MIN_PERIOD 100
+#define ACCELEROMETER_TIME_UNIT 10 // resolution 10 ms
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// Callback when a characteristic value has changed
+typedef NULL_OK void (*accelChange_t)( uint8 paramID );
+
+typedef struct
+{
+ accelChange_t pfnAccelChange; // Called when characteristic value changes
+} accelCBs_t;
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+
+/*
+ * Acc_AddService- Initializes the Sensor GATT Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+extern bStatus_t Accel_AddService( uint32 services );
+
+/*
+ * Acc_RegisterAppCBs - Registers the application callback function.
+ * Only call this function once.
+ *
+ * appCallbacks - pointer to application callbacks.
+ */
+extern bStatus_t Accel_RegisterAppCBs( accelCBs_t *appCallbacks );
+
+/*
+ * Acc_SetParameter - Set a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Accel_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * Acc_GetParameter - Get a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Accel_GetParameter( uint8 param, void *value );
+
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ACCELEROMETERSERVICE_H */
+
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/barometerservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/barometerservice.c
new file mode 100644
index 0000000..4019078
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/barometerservice.c
@@ -0,0 +1,632 @@
+/**************************************************************************************************
+ Filename: barometerservice.c
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: Barometer service
+
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "gapbondmgr.h"
+
+#include "barometerservice.h"
+#include "st_util.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// Barometer Service UUID
+CONST uint8 barServUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(BAROMETER_SERV_UUID),
+};
+
+// Barometer Characteristic value Data UUID
+CONST uint8 barDataUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(BAROMETER_DATA_UUID),
+};
+
+// Barometer Characteristic value Configuration UUID
+CONST uint8 barCalUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(BAROMETER_CALI_UUID),
+};
+
+// Barometer Characteristic value Configuration UUID
+CONST uint8 barCfgUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(BAROMETER_CONF_UUID),
+};
+
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static barometerCBs_t *barometer_AppCBs = NULL;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Barometer Profile Service attribute
+static CONST gattAttrType_t barService = { TI_UUID_SIZE, barServUUID };
+
+// Barometer Characteristic Properties
+static uint8 barDataProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+
+static uint8 barData[BAROMETER_DATA_LEN] = { 0, 0, 0, 0};
+
+// Barometer Data Characteristic Configuration
+static gattCharCfg_t barDataConfig[GATT_MAX_NUM_CONN];
+
+// Barometer Characteristic User Description
+static uint8 barDataUserDesp[] = "Barometer Data";
+
+// Barometer Characteristic Configuration Properties
+static uint8 barCalProps = GATT_PROP_READ;
+
+// Barometer Calibration Characteristic Configuration Value
+static uint8 barCal[BAROMETER_CALI_LEN] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+
+// Barometer Calibration Characteristic Configuration
+static gattCharCfg_t barCalConfig[GATT_MAX_NUM_CONN];
+
+// Barometer Calibration Characteristic Configuration User Description
+static uint8 barCalUserDesp[] = "Barometer Cali.";
+
+// Barometer Characteristic Configuration Properties
+static uint8 barCfgProps = GATT_PROP_READ | GATT_PROP_WRITE;
+
+// Barometer Characteristic Configuration Value
+static uint8 barCfg = 0;
+
+// Barometer Characteristic Configuration User Description
+static uint8 barCfgUserDesp[] = "Barometer Conf.";
+
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+static gattAttribute_t sensorBarometerAttrTbl[] =
+{
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&barService /* pValue */
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &barDataProps
+ },
+
+ // Characteristic Value "Data"
+ {
+ { TI_UUID_SIZE, barDataUUID },
+ GATT_PERMIT_READ,
+ 0,
+ barData
+ },
+
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)barDataConfig
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ barDataUserDesp
+ },
+
+ // Characteristic Config Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &barCfgProps
+ },
+
+ // Characteristic Value "Configuration"
+ {
+ { TI_UUID_SIZE, barCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &barCfg
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ barCfgUserDesp
+ },
+
+
+ // Characteristic Calibration Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &barCalProps
+ },
+
+ // Characteristic Value "Calibration"
+ {
+ { TI_UUID_SIZE, barCalUUID },
+ GATT_PERMIT_READ,
+ 0,
+ barCal
+ },
+
+ // Characteristic configuration "Calibration"
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)barCalConfig
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ barCalUserDesp
+ },
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 barometer_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t barometer_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+static void barometer_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Simple Profile Service Callbacks
+CONST gattServiceCBs_t sensorProfileCBs =
+{
+ barometer_ReadAttrCB, // Read callback function pointer
+ barometer_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Barometer_AddService
+ *
+ * @brief Initializes the Sensor Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Barometer_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, barDataConfig );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, barCalConfig );
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( barometer_HandleConnStatusCB );
+
+ if ( services & BAROMETER_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( sensorBarometerAttrTbl,
+ GATT_NUM_ATTRS( sensorBarometerAttrTbl ),
+ &sensorProfileCBs );
+ }
+
+ return ( status );
+}
+
+
+/*********************************************************************
+ * @fn Barometer_RegisterAppCBs
+ *
+ * @brief Registers the application callback function. Only call
+ * this function once.
+ *
+ * @param callbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+bStatus_t Barometer_RegisterAppCBs( barometerCBs_t *appCallbacks )
+{
+ if ( barometer_AppCBs == NULL )
+ {
+ if ( appCallbacks != NULL )
+ {
+ barometer_AppCBs = appCallbacks;
+ }
+
+ return ( SUCCESS );
+ }
+
+ return ( bleAlreadyInRequestedMode );
+}
+
+/*********************************************************************
+ * @fn Barometer_SetParameter
+ *
+ * @brief Set a Barometer service parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Barometer_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case BAROMETER_DATA:
+ if ( len == BAROMETER_DATA_LEN )
+ {
+ VOID osal_memcpy( barData, value, BAROMETER_DATA_LEN );
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( barDataConfig, barData, FALSE,
+ sensorBarometerAttrTbl, GATT_NUM_ATTRS( sensorBarometerAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case BAROMETER_CALI:
+ if ( len == BAROMETER_CALI_LEN )
+ {
+ VOID osal_memcpy( barCal, value, BAROMETER_CALI_LEN );
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( barCalConfig, barCal, FALSE,
+ sensorBarometerAttrTbl, GATT_NUM_ATTRS( sensorBarometerAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case BAROMETER_CONF:
+ if ( len == sizeof ( uint8 ) )
+ {
+ barCfg = *((uint8*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Barometer_GetParameter
+ *
+ * @brief Get a Barometer parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Barometer_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case BAROMETER_DATA:
+ VOID osal_memcpy( value, barData, BAROMETER_DATA_LEN );
+ break;
+
+ case BAROMETER_CALI:
+ VOID osal_memcpy( value, barCal, BAROMETER_CALI_LEN );
+ break;
+
+ case BAROMETER_CONF:
+ *((uint8*)value) = barCfg;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn barometer_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 barometer_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+
+ // If attribute permissions require authorization to read, return error
+ if ( gattPermitAuthorRead( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE) {
+ // Invalid handle
+ *pLen = 0;
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ // 16-bit UUID
+ switch ( uuid )
+ {
+ // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
+ // gattserverapp handles those reads
+ case BAROMETER_DATA_UUID:
+ *pLen = BAROMETER_DATA_LEN;
+ VOID osal_memcpy( pValue, pAttr->pValue, BAROMETER_DATA_LEN );
+ break;
+
+ case BAROMETER_CALI_UUID:
+ *pLen = BAROMETER_CALI_LEN;
+ VOID osal_memcpy( pValue, pAttr->pValue, BAROMETER_CALI_LEN );
+ break;
+
+ case BAROMETER_CONF_UUID:
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ break;
+
+ default:
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+* @fn barometer_WriteAttrCB
+*
+* @brief Validate attribute data prior to a write operation
+*
+* @param connHandle - connection message was received on
+* @param pAttr - pointer to attribute
+* @param pValue - pointer to data to be written
+* @param len - length of data
+* @param offset - offset of the first octet to be written
+*
+* @return Success or Failure
+*/
+static bStatus_t barometer_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+ uint16 uuid;
+ uint8 notifyApp = 0xFF;
+
+ // If attribute permissions require authorization to write, return error
+ if ( gattPermitAuthorWrite( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE) {
+ // Invalid handle
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ case BAROMETER_DATA_UUID:
+ //Should not get here
+ break;
+
+ case BAROMETER_CALI_UUID:
+ //Should not get here
+ break;
+
+ case BAROMETER_CONF_UUID:
+ //Validate the value
+ // Make sure it's not a blob oper
+ if ( offset == 0 )
+ {
+ if ( len != 1 )
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ // Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+ *pCurValue = pValue[0];
+
+ if( pAttr->pValue == &barCfg )
+ {
+ notifyApp = BAROMETER_CONF;
+ }
+
+ }
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ // Should never get here!
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ // If a charactersitic value changed then callback function to notify application of change
+ if ( (notifyApp != 0xFF ) && barometer_AppCBs && barometer_AppCBs->pfnBarometerChange )
+ {
+ barometer_AppCBs->pfnBarometerChange( notifyApp );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn barometer_HandleConnStatusCB
+ *
+ * @brief Sensor Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void barometer_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, barDataConfig );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/barometerservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/barometerservice.h
new file mode 100644
index 0000000..6ca159b
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/barometerservice.h
@@ -0,0 +1,145 @@
+/**************************************************************************************************
+ Filename: barometerservice.h
+ Revised: $Date: 2012-08-15 16:57:31 -0700 (Wed, 15 Aug 2012) $
+ Revision: $Revision: 31256 $
+
+ Description: Barometer service definitions and prototypes
+
+ Copyright 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef BAROMETERSERVICE_H
+#define BAROMETERSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Profile Parameters
+#define BAROMETER_DATA 10 // R uint8 - Profile Attribute value
+#define BAROMETER_CALI 11 // RW uint8 - Profile Attribute value
+#define BAROMETER_CONF 12 // RW uint8 - Profile Attribute value
+
+// Service UUID
+#define BAROMETER_SERV_UUID 0xAA40 // F0000000-0451-4000-B000-00000000-AA40
+#define BAROMETER_DATA_UUID 0xAA41
+#define BAROMETER_CONF_UUID 0xAA42
+#define BAROMETER_CALI_UUID 0xAA43
+
+// Sensor Profile Services bit fields
+#define BAROMETER_SERVICE 0x00000010
+
+// Length of sensor data in bytes
+#define BAROMETER_DATA_LEN 4
+#define BAROMETER_CALI_LEN 16
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// Callback when a characteristic value has changed
+typedef NULL_OK void (*barometerChange_t)( uint8 paramID );
+
+typedef struct
+{
+ barometerChange_t pfnBarometerChange; // Called when characteristic value changes
+} barometerCBs_t;
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+
+/*
+ * Barometer_AddService- Initializes the Sensor GATT Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+extern bStatus_t Barometer_AddService( uint32 services );
+
+/*
+ * Barometer_RegisterAppCBs - Registers the application callback function.
+ * Only call this function once.
+ *
+ * appCallbacks - pointer to application callbacks.
+ */
+extern bStatus_t Barometer_RegisterAppCBs( barometerCBs_t *appCallbacks );
+
+/*
+ * Barometer_SetParameter - Set a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Barometer_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * Barometer_GetParameter - Get a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Barometer_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BAROMETERSERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/gyroservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/gyroservice.c
new file mode 100644
index 0000000..144fac4
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/gyroservice.c
@@ -0,0 +1,545 @@
+/**************************************************************************************************
+ Filename: gyroservice.c
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: Gyroscope Service
+
+
+ Copyright 2012 - 2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "linkdb.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+
+#include "gyroservice.h"
+#include "st_util.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// Gyroscope Service UUID
+CONST uint8 gyroServUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(GYROSCOPE_SERV_UUID),
+};
+
+// Gyroscope Characteristic value Data UUID
+CONST uint8 gyroDataUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(GYROSCOPE_DATA_UUID),
+};
+
+// Gyroscooe Characteristic value Configuration UUID
+CONST uint8 gyroCfgUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(GYROSCOPE_CONF_UUID),
+};
+
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static gyroCBs_t *gyro_AppCBs = NULL;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+
+// Gyroscope Profile Service attribute
+static CONST gattAttrType_t gyroService = { TI_UUID_SIZE, gyroServUUID };
+
+// Accelerometer Characteristic Properties
+static uint8 gyroDataProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+
+static uint8 gyroData[GYROSCOPE_DATA_LEN] = {0, 0, 0, 0, 0, 0};
+
+// Gyroscope Characteristic Configuration
+static gattCharCfg_t gyroDataConfig[GATT_MAX_NUM_CONN];
+
+// Gyroscope Characteristic User Description
+static uint8 gyroDataUserDesp[] = "Gyro. Data";
+
+// Gyroscope Characteristic Configuration Properties
+static uint8 gyroCfgProps = GATT_PROP_READ | GATT_PROP_WRITE;
+
+// Gyroscope Characteristic Configuration Value
+static uint8 gyroCfg = 0;
+
+// Gyroscope Characteristic Configuration User Description
+static uint8 gyroCfgUserDesp[] = "Gyro. Conf.";
+
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t sensorGyroscopeAttrTbl[] =
+{
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&gyroService /* pValue */
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &gyroDataProps
+ },
+
+ // Characteristic Value "Data"
+ {
+ { TI_UUID_SIZE, gyroDataUUID },
+ GATT_PERMIT_READ,
+ 0,
+ gyroData
+ },
+
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)gyroDataConfig
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ gyroDataUserDesp
+ },
+ // Characteristic 2 Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &gyroCfgProps
+ },
+
+ // Characteristic Value "Configuration"
+ {
+ { TI_UUID_SIZE, gyroCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &gyroCfg
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ gyroCfgUserDesp
+ },
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 gyro_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t gyro_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+static void gyro_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Simple Profile Service Callbacks
+CONST gattServiceCBs_t gyroCBs =
+{
+ gyro_ReadAttrCB, // Read callback function pointer
+ gyro_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Gyro_AddService
+ *
+ * @brief Initializes the Sensor Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Gyro_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( gyro_HandleConnStatusCB );
+
+ if (services & GYROSCOPE_SERVICE )
+ {
+
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( sensorGyroscopeAttrTbl,
+ GATT_NUM_ATTRS( sensorGyroscopeAttrTbl ),
+ &gyroCBs );
+ }
+
+ return ( status );
+}
+
+
+/*********************************************************************
+ * @fn Gyro_RegisterAppCBs
+ *
+ * @brief Registers the application callback function. Only call
+ * this function once.
+ *
+ * @param callbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+bStatus_t Gyro_RegisterAppCBs( gyroCBs_t *appCallbacks )
+{
+ if ( gyro_AppCBs == NULL )
+ {
+ if ( appCallbacks != NULL )
+ {
+ gyro_AppCBs = appCallbacks;
+ }
+
+ return ( SUCCESS );
+ }
+
+ return ( bleAlreadyInRequestedMode );
+}
+
+/*********************************************************************
+ * @fn Gyro_SetParameter
+ *
+ * @brief Set a Sensor Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Gyro_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case GYROSCOPE_DATA:
+ if ( len == GYROSCOPE_DATA_LEN )
+ {
+ VOID osal_memcpy( gyroData, value, GYROSCOPE_DATA_LEN );
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( gyroDataConfig, gyroData, FALSE,
+ sensorGyroscopeAttrTbl, GATT_NUM_ATTRS( sensorGyroscopeAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case GYROSCOPE_CONF:
+ if(len == sizeof ( uint8 ) )
+ {
+ gyroCfg = *((uint8*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Gyro_GetParameter
+ *
+ * @brief Get a Sensor Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Gyro_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case GYROSCOPE_DATA:
+ VOID osal_memcpy (value, gyroData, GYROSCOPE_DATA_LEN );
+ break;
+
+ case GYROSCOPE_CONF:
+ *((uint8*)value) = gyroCfg;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn gyro_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 gyro_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+
+ // If attribute permissions require authorization to read, return error
+ if ( gattPermitAuthorRead( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE) {
+ // Invalid handle
+ *pLen = 0;
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
+ // gattserverapp handles those reads
+ case GYROSCOPE_DATA_UUID:
+ *pLen = GYROSCOPE_DATA_LEN;
+ VOID osal_memcpy( pValue, pAttr->pValue, GYROSCOPE_DATA_LEN );
+ break;
+
+ case GYROSCOPE_CONF_UUID:
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ break;
+
+ default:
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+* @fn gyro_WriteAttrCB
+*
+* @brief Validate attribute data prior to a write operation
+*
+* @param connHandle - connection message was received on
+* @param pAttr - pointer to attribute
+* @param pValue - pointer to data to be written
+* @param len - length of data
+* @param offset - offset of the first octet to be written
+*
+* @return Success or Failure
+*/
+static bStatus_t gyro_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+ uint8 notifyApp = 0xFF;
+
+ // If attribute permissions require authorization to write, return error
+ if ( gattPermitAuthorWrite( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE) {
+ // Invalid handle
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ case GYROSCOPE_DATA_UUID:
+ //Should not get here
+ break;
+
+ case GYROSCOPE_CONF_UUID:
+ //Validate the value
+ // Make sure it's not a blob oper
+ if ( offset == 0 )
+ {
+ if ( len != 1 )
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ //Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+ *pCurValue = pValue[0];
+
+ if( pAttr->pValue == &gyroCfg )
+ {
+ notifyApp = GYROSCOPE_CONF;
+ }
+ }
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ // Should never get here!
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ // If a charactersitic value changed then callback function to notify application of change
+ if ( (notifyApp != 0xFF ) && gyro_AppCBs && gyro_AppCBs->pfnGyroChange )
+ {
+ gyro_AppCBs->pfnGyroChange( notifyApp );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn gyro_HandleConnStatusCB
+ *
+ * @brief Sensor Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void gyro_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, gyroDataConfig );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/gyroservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/gyroservice.h
new file mode 100644
index 0000000..97f5184
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/gyroservice.h
@@ -0,0 +1,145 @@
+/**************************************************************************************************
+ Filename: gyroservice.h
+ Revised: $Date: 2012-08-15 16:57:31 -0700 (Wed, 15 Aug 2012) $
+ Revision: $Revision: 31256 $
+
+ Description: Gyroscope service definitions and prototypes
+
+ Copyright 2012 Texas Instruments Incorporated. All rights reserved.
+
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef GYROSERVICE_H
+#define GYROSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Profile Parameters
+#define GYROSCOPE_DATA 12 // R uint8 - Profile Attribute value
+#define GYROSCOPE_CONF 13 // RW uint8 - Profile Attribute value
+
+// Service UUID
+#define GYROSCOPE_SERV_UUID 0xAA50 // F0000000-0451-4000-B000-00000000-AA50
+#define GYROSCOPE_DATA_UUID 0xAA51
+#define GYROSCOPE_CONF_UUID 0xAA52
+
+// Sensor Profile Services bit fields
+#define GYROSCOPE_SERVICE 0x00000020
+
+// Length of sensor data in bytes
+#define GYROSCOPE_DATA_LEN 6
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// Callback when a characteristic value has changed
+typedef NULL_OK void (*gyroChange_t)( uint8 paramID );
+
+typedef struct
+{
+ gyroChange_t pfnGyroChange; // Called when characteristic value changes
+} gyroCBs_t;
+
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+
+/*
+ * Gyro_AddService- Initializes the Sensor GATT Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+extern bStatus_t Gyro_AddService( uint32 services );
+
+/*
+ * Gyro_RegisterAppCBs - Registers the application callback function.
+ * Only call this function once.
+ *
+ * appCallbacks - pointer to application callbacks.
+ */
+extern bStatus_t Gyro_RegisterAppCBs( gyroCBs_t *appCallbacks );
+
+/*
+ * Gyro_SetParameter - Set a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to write
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Gyro_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * Gyro_GetParameter - Get a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Gyro_GetParameter( uint8 param, void *value );
+
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GYROSERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/humidityservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/humidityservice.c
new file mode 100644
index 0000000..a98005f
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/humidityservice.c
@@ -0,0 +1,546 @@
+/**************************************************************************************************
+ Filename: humidservice.c
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: Humidity service.
+
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "linkdb.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+
+#include "humidityservice.h"
+#include "st_util.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static humidityCBs_t *humid_AppCBs = NULL;
+
+// Humidity Service UUID
+CONST uint8 humidServUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(HUMIDITY_SERV_UUID),
+};
+
+// Humidity Characteristic value Data UUID
+CONST uint8 humidDataUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(HUMIDITY_DATA_UUID),
+};
+
+// Humidity Characteristic value Configuration UUID
+CONST uint8 humidCfgUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(HUMIDITY_CONF_UUID),
+};
+
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Humidity Profile Service attribute
+static CONST gattAttrType_t humidService = { TI_UUID_SIZE, humidServUUID };
+
+// Humidity Characteristic Properties
+static uint8 humidDataProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+
+static uint8 humidData[HUMIDITY_DATA_LEN] = { 0, 0, 0, 0};
+
+// Humidity Characteristic Configuration
+static gattCharCfg_t humidDataConfig[GATT_MAX_NUM_CONN];
+
+// Humidity Characteristic User Description
+static uint8 humidDataUserDesp[] = "Humid. Data";
+
+// Humidity Characteristic Configuration Properties
+static uint8 humidCfgProps = GATT_PROP_READ | GATT_PROP_WRITE;
+
+// Humidity Characteristic Configuration Value
+static uint8 humidCfg = 0;
+
+// Humidity Characteristic Configuration User Description
+static uint8 humidCfgUserDesp[] = "Humid. Conf.";
+
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t humidAttrTbl[] =
+{
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&humidService /* pValue */
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &humidDataProps
+ },
+
+ // Characteristic Value "Data"
+ {
+ { TI_UUID_SIZE, humidDataUUID },
+ GATT_PERMIT_READ,
+ 0,
+ humidData
+ },
+
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)humidDataConfig
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ humidDataUserDesp
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &humidCfgProps
+ },
+
+ // Characteristic Value "Configuration"
+ {
+ { TI_UUID_SIZE, humidCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &humidCfg
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ humidCfgUserDesp
+ },
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 humid_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t humid_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+static void humid_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Simple Profile Service Callbacks
+CONST gattServiceCBs_t humidCBs =
+{
+ humid_ReadAttrCB, // Read callback function pointer
+ humid_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Humidity_AddService
+ *
+ * @brief Initializes the Sensor Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Humidity_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( humid_HandleConnStatusCB );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, humidDataConfig );
+
+ if (services & HUMIDITY_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( humidAttrTbl,
+ GATT_NUM_ATTRS( humidAttrTbl ),
+ &humidCBs );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Humidity_RegisterAppCBs
+ *
+ * @brief Registers the application callback function. Only call
+ * this function once.
+ *
+ * @param callbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+bStatus_t Humidity_RegisterAppCBs( humidityCBs_t *appCallbacks )
+{
+ if ( humid_AppCBs == NULL )
+ {
+ if ( appCallbacks != NULL )
+ {
+ humid_AppCBs = appCallbacks;
+ }
+
+ return ( SUCCESS );
+ }
+
+ return ( bleAlreadyInRequestedMode );
+}
+
+/*********************************************************************
+ * @fn Humidity_SetParameter
+ *
+ * @brief Set a Sensor Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Humidity_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case HUMIDITY_DATA:
+ if ( len == HUMIDITY_DATA_LEN )
+ {
+ VOID osal_memcpy( humidData, value, HUMIDITY_DATA_LEN );
+
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( humidDataConfig, humidData, FALSE,
+ humidAttrTbl, GATT_NUM_ATTRS( humidAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case HUMIDITY_CONF:
+ if ( len == sizeof ( uint8 ) )
+ {
+ humidCfg = *((uint8*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Humidity_GetParameter
+ *
+ * @brief Get a Sensor Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Humidity_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case HUMIDITY_DATA:
+ VOID osal_memcpy( value, humidData, HUMIDITY_DATA_LEN );
+ break;
+
+ case HUMIDITY_CONF:
+ *((uint8*)value) = humidCfg;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn humid_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 humid_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+
+ // If attribute permissions require authorization to read, return error
+ if ( gattPermitAuthorRead( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE)
+ {
+ // Invalid handle
+ *pLen = 0;
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
+ // gattserverapp handles those reads
+ case HUMIDITY_DATA_UUID:
+ *pLen = HUMIDITY_DATA_LEN;
+ VOID osal_memcpy( pValue, pAttr->pValue, HUMIDITY_DATA_LEN );
+ break;
+
+ case HUMIDITY_CONF_UUID:
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ break;
+
+ default:
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+* @fn humid_WriteAttrCB
+*
+* @brief Validate attribute data prior to a write operation
+*
+* @param connHandle - connection message was received on
+* @param pAttr - pointer to attribute
+* @param pValue - pointer to data to be written
+* @param len - length of data
+* @param offset - offset of the first octet to be written
+*
+* @return Success or Failure
+*/
+static bStatus_t humid_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+ uint8 notifyApp = 0xFF;
+
+ // If attribute permissions require authorization to write, return error
+ if ( gattPermitAuthorWrite( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE)
+ {
+ // Invalid handle
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ case HUMIDITY_DATA_UUID:
+ //Should not get here
+ break;
+
+ case HUMIDITY_CONF_UUID:
+ //Validate the value
+ // Make sure it's not a blob oper
+ if ( offset == 0 )
+ {
+ if ( len != 1 )
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ //Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+
+ *pCurValue = pValue[0];
+ if( pAttr->pValue == &humidCfg )
+ {
+ notifyApp = HUMIDITY_CONF;
+ }
+ }
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ // Should never get here!
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ // If a charactersitic value changed then callback function to notify application of change
+ if ( (notifyApp != 0xFF ) && humid_AppCBs && humid_AppCBs->pfnIrTempChange )
+ {
+ humid_AppCBs->pfnIrTempChange( notifyApp );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn humid_HandleConnStatusCB
+ *
+ * @brief Sensor Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void humid_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, humidDataConfig );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/humidityservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/humidityservice.h
new file mode 100644
index 0000000..6dc2fdb
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/humidityservice.h
@@ -0,0 +1,146 @@
+/**************************************************************************************************
+ Filename: humidityservice.h
+ Revised: $Date: 2012-08-15 16:57:31 -0700 (Wed, 15 Aug 2012) $
+ Revision: $Revision: 31256 $
+
+ Description: Humidity service definitions and prototypes
+
+
+ Copyright 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef HUMIDITYSERVICE_H
+#define HUMIDITYSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Profile Parameters
+#define HUMIDITY_DATA 5 // R uint8 - Profile Attribute value
+#define HUMIDITY_CONF 6 // RW uint8 - Profile Attribute value
+
+// Service UUID
+#define HUMIDITY_SERV_UUID 0xAA20 // F0000000-0451-4000-B000-00000000-AA20
+#define HUMIDITY_DATA_UUID 0xAA21
+#define HUMIDITY_CONF_UUID 0xAA22
+
+// Sensor Profile Services bit fields
+#define HUMIDITY_SERVICE 0x00000004
+
+// Length of sensor data in bytes
+#define HUMIDITY_DATA_LEN 4
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// Callback when a characteristic value has changed
+typedef NULL_OK void (*humidityChange_t)( uint8 paramID );
+
+typedef struct
+{
+ humidityChange_t pfnIrTempChange; // Called when characteristic value changes
+} humidityCBs_t;
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+
+/*
+ * Humidity_AddService- Initializes the Sensor GATT Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+extern bStatus_t Humidity_AddService( uint32 services );
+
+/*
+ * Humidity_RegisterAppCBs - Registers the application callback function.
+ * Only call this function once.
+ *
+ * appCallbacks - pointer to application callbacks.
+ */
+extern bStatus_t Humidity_RegisterAppCBs( humidityCBs_t *appCallbacks );
+
+/*
+ * Humidity_SetParameter - Set a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Humidity_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * Humidity_GetParameter - Get a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Humidity_GetParameter( uint8 param, void *value );
+
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HUMIDITYSERVICE_H */
+
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/irtempservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/irtempservice.c
new file mode 100644
index 0000000..5ee13e9
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/irtempservice.c
@@ -0,0 +1,552 @@
+/**************************************************************************************************
+ Filename: irtempservice.c
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: IR Temperature service.
+
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "linkdb.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+
+#include "irtempservice.h"
+#include "st_util.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static irTempCBs_t *irTemp_AppCBs = NULL;
+
+// IR Temperatur Service UUID
+CONST uint8 irTempServUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(IRTEMPERATURE_SERV_UUID),
+};
+
+// IR Temp Characteristic value Data UUID
+CONST uint8 irTempDataUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(IRTEMPERATURE_DATA_UUID),
+};
+
+// IR Temp Characteristic value Configuration UUID
+CONST uint8 irTempConfUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(IRTEMPERATURE_CONF_UUID),
+};
+
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// IR Temperature Profile Service attribute
+static CONST gattAttrType_t irTempService = { TI_UUID_SIZE, irTempServUUID };
+
+// IR Temperature Characteristic Properties
+static uint8 irTempDataProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+
+// IR Temperature Characteristic Value
+static uint8 irTempData[IRTEMPERATURE_DATA_LEN] = { 0, 0, 0, 0};
+
+// IR Temperature Characteristic Configuration
+static gattCharCfg_t irTempDataConfig[GATT_MAX_NUM_CONN];
+
+// IR Temperature Characteristic User Description
+static uint8 irTempDataUserDesp[] = "IR Temp. Data";
+
+// IR Temperature Characteristic Configuration Properties
+static uint8 irTempCfgProps = GATT_PROP_READ | GATT_PROP_WRITE;
+
+// IR Temperature Characteristic Configuration Value
+static uint8 irTempCfg = 0;
+
+// IR Temperature Characteristic Configuration User Description
+static uint8 irTempCfgUserDesp[] = "IR Temp. Conf.";
+
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t irTempAttrTbl[] =
+{
+ // Sensor Profile Services
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&irTempService /* pValue */
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &irTempDataProps
+ },
+
+ // Characteristic Value "Data"
+ {
+ { TI_UUID_SIZE, irTempDataUUID },
+ GATT_PERMIT_READ,
+ 0,
+ irTempData
+ },
+
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)irTempDataConfig
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ irTempDataUserDesp
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &irTempCfgProps
+ },
+
+ // Characteristic Value "Configuration"
+ {
+ { TI_UUID_SIZE, irTempConfUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &irTempCfg
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ irTempCfgUserDesp
+ },
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 irTemp_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t irTemp_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+static void irTemp_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Simple Profile Service Callbacks
+CONST gattServiceCBs_t irTempCBs =
+{
+ irTemp_ReadAttrCB, // Read callback function pointer
+ irTemp_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn IRTemp_AddService
+ *
+ * @brief Initializes the Sensor Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t IRTemp_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( irTemp_HandleConnStatusCB );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, irTempDataConfig );
+
+ if (services & IRTEMPERATURE_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( irTempAttrTbl,
+ GATT_NUM_ATTRS( irTempAttrTbl ),
+ &irTempCBs );
+ }
+
+ return ( status );
+}
+
+
+/*********************************************************************
+ * @fn IRTemp_RegisterAppCBs
+ *
+ * @brief Registers the application callback function. Only call
+ * this function once.
+ *
+ * @param callbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+bStatus_t IRTemp_RegisterAppCBs( irTempCBs_t *appCallbacks )
+{
+ if ( irTemp_AppCBs == NULL )
+ {
+ if ( appCallbacks != NULL )
+ {
+ irTemp_AppCBs = appCallbacks;
+ }
+
+ return ( SUCCESS );
+ }
+
+ return ( bleAlreadyInRequestedMode );
+
+}
+
+
+/*********************************************************************
+ * @fn IRTemp_SetParameter
+ *
+ * @brief Set a Sensor Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t IRTemp_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case IRTEMPERATURE_DATA:
+ if ( len == IRTEMPERATURE_DATA_LEN )
+ {
+ VOID osal_memcpy( irTempData, value, IRTEMPERATURE_DATA_LEN );
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( irTempDataConfig, irTempData, FALSE,
+ irTempAttrTbl, GATT_NUM_ATTRS( irTempAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case IRTEMPERATURE_CONF:
+ if ( len == sizeof ( uint8 ) )
+ {
+ irTempCfg = *((uint8*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn IRTemp_GetParameter
+ *
+ * @brief Get a Sensor Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t IRTemp_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case IRTEMPERATURE_DATA:
+ VOID osal_memcpy (value, irTempData, IRTEMPERATURE_DATA_LEN );
+ break;
+
+ case IRTEMPERATURE_CONF:
+ *((uint8*)value) = irTempCfg;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn irTemp_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 irTemp_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+
+ // If attribute permissions require authorization to read, return error
+ if ( gattPermitAuthorRead( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE)
+ {
+ // Invalid handle
+ *pLen = 0;
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
+ // gattserverapp handles those reads
+ case IRTEMPERATURE_DATA_UUID:
+ *pLen = IRTEMPERATURE_DATA_LEN;
+ VOID osal_memcpy( pValue, pAttr->pValue, IRTEMPERATURE_DATA_LEN );
+ break;
+
+ case IRTEMPERATURE_CONF_UUID:
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ break;
+
+ default:
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+* @fn irTemp_WriteAttrCB
+*
+* @brief Validate attribute data prior to a write operation
+*
+* @param connHandle - connection message was received on
+* @param pAttr - pointer to attribute
+* @param pValue - pointer to data to be written
+* @param len - length of data
+* @param offset - offset of the first octet to be written
+*
+* @return Success or Failure
+*/
+static bStatus_t irTemp_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+ uint8 notifyApp = 0xFF;
+
+ // If attribute permissions require authorization to write, return error
+ if ( gattPermitAuthorWrite( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE)
+ {
+ // Invalid handle
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ case IRTEMPERATURE_DATA_UUID:
+ // Should not get here
+ break;
+
+ case IRTEMPERATURE_CONF_UUID:
+ // Validate the value
+ // Make sure it's not a blob oper
+ if ( offset == 0 )
+ {
+ if ( len != 1 )
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ //Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+ *pCurValue = pValue[0];
+
+ if( pAttr->pValue == &irTempCfg )
+ {
+ notifyApp = IRTEMPERATURE_CONF;
+ }
+ }
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ // Should never get here!
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ // If a charactersitic value changed then callback function to notify application of change
+ if ( (notifyApp != 0xFF ) && irTemp_AppCBs && irTemp_AppCBs->pfnIrTempChange )
+ {
+ irTemp_AppCBs->pfnIrTempChange( notifyApp );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn irTemp_HandleConnStatusCB
+ *
+ * @brief Sensor Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void irTemp_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, irTempDataConfig );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/irtempservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/irtempservice.h
new file mode 100644
index 0000000..84d9882
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/irtempservice.h
@@ -0,0 +1,145 @@
+/**************************************************************************************************
+ Filename: irtempservice.h
+ Revised: $Date: 2012-08-15 16:57:31 -0700 (Wed, 15 Aug 2012) $
+ Revision: $Revision: 31256 $
+
+ Description: IR temperature service definitions and prototypes
+
+
+ Copyright 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef IRTEMPSERVICE_H
+#define IRTEMPSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Profile Parameters
+#define IRTEMPERATURE_DATA 0 // R uint8 - Profile Attribute value
+#define IRTEMPERATURE_CONF 1 // RW uint8 - Profile Attribute value
+
+// Service UUID
+#define IRTEMPERATURE_SERV_UUID 0xAA00 // F0000000-0451-4000-B000-00000000-AA00
+#define IRTEMPERATURE_DATA_UUID 0xAA01
+#define IRTEMPERATURE_CONF_UUID 0xAA02
+
+// Sensor Profile Services bit fields
+#define IRTEMPERATURE_SERVICE 0x00000001
+
+// Length of sensor data in bytes
+#define IRTEMPERATURE_DATA_LEN 4
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// Callback when a characteristic value has changed
+typedef NULL_OK void (*irTempChange_t)( uint8 paramID );
+
+typedef struct
+{
+ irTempChange_t pfnIrTempChange; // Called when characteristic value changes
+} irTempCBs_t;
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+
+/*
+ * IRTemp_AddService- Initializes the Sensor GATT Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+extern bStatus_t IRTemp_AddService( uint32 services );
+
+/*
+ * IRTemp_RegisterAppCBs - Registers the application callback function.
+ * Only call this function once.
+ *
+ * appCallbacks - pointer to application callbacks.
+ */
+extern bStatus_t IRTemp_RegisterAppCBs( irTempCBs_t *appCallbacks );
+
+/*
+ * IRTemp_SetParameter - Set a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to write
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t IRTemp_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * IRTemp_GetParameter - Get a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t IRTemp_GetParameter( uint8 param, void *value );
+
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IRTEMPSERVICE_H */
+
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/magnetometerservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/magnetometerservice.c
new file mode 100644
index 0000000..4c48d82
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/magnetometerservice.c
@@ -0,0 +1,638 @@
+/**************************************************************************************************
+ Filename: magnetometerservice.c
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: Magnetometer Service
+
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "linkdb.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+
+#include "magnetometerservice.h"
+#include "st_util.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// Magnetometer Service UUID
+CONST uint8 magnetometerServUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(MAGNETOMETER_SERV_UUID),
+};
+
+// Magnetometer Characteristic value Data UUID
+CONST uint8 magnetometerDataUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(MAGNETOMETER_DATA_UUID),
+};
+
+// Magnetometer Characteristic value Configuration UUID
+CONST uint8 magnetometerCfgUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(MAGNETOMETER_CONF_UUID),
+};
+
+// Magnetometer Characteristic value Period UUID
+CONST uint8 magnetometerPerUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(MAGNETOMETER_PERI_UUID),
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static magnetometerCBs_t *magnetometer_AppCBs = NULL;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Magnetometer Profile Service attribute
+static CONST gattAttrType_t magnetometerService = { TI_UUID_SIZE, magnetometerServUUID };
+
+// Magnetometer Characteristic Properties
+static uint8 magnetometerDataProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
+
+static uint8 magnetometerData[MAGNETOMETER_DATA_LEN] = { 0, 0, 0, 0, 0, 0};
+
+// Magnetometer Characteristic Configuration
+static gattCharCfg_t magnetometerDataConfig[GATT_MAX_NUM_CONN];
+
+// Magnetometer Characteristic User Description
+static uint8 magnetometerDataUserDesp[] = "Mag. Data";
+
+// Magnetometer Characteristic Configuration Properties
+static uint8 magnetometerCfgProps = GATT_PROP_READ | GATT_PROP_WRITE;
+
+// Magnetometer Characteristic Configuration Value
+static uint8 magnetometerCfg = 0;
+
+// Magnetometer Characteristic Configuration User Description
+static uint8 magnetometerCfgUserDesp[] = "Mag. Conf.";
+
+// Magnetometer Characteristic Period Properties
+static uint8 magnetometerPerProps = GATT_PROP_READ | GATT_PROP_WRITE;
+
+// Magnetometer Characteristic Period Value
+static uint8 magnetometerPer = 0;
+
+// Magnetometer Characteristic Period User Description
+static uint8 magnetometerPerUserDesp[] = "Mag. Period";
+
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+
+static gattAttribute_t sensorMagnetometerAttrTbl[] =
+{
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&magnetometerService /* pValue */
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &magnetometerDataProps
+ },
+
+ // Characteristic Value "Data"
+ {
+ { TI_UUID_SIZE, magnetometerDataUUID },
+ GATT_PERMIT_READ,
+ 0,
+ magnetometerData
+ },
+
+ // Characteristic configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)magnetometerDataConfig
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ magnetometerDataUserDesp
+ },
+
+ // Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &magnetometerCfgProps
+ },
+
+ // Characteristic Value "Configuration"
+ {
+ { TI_UUID_SIZE, magnetometerCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &magnetometerCfg
+ },
+
+ // Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ magnetometerCfgUserDesp
+ },
+
+ // Characteristic Declaration "Period"
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &magnetometerPerProps
+ },
+
+ // Characteristic Value "Period"
+ {
+ { TI_UUID_SIZE, magnetometerPerUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &magnetometerPer
+ },
+
+ // Characteristic User Description "Period"
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ magnetometerPerUserDesp
+ },
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 magnetometer_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t magnetometer_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+static void magnetometer_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Magnetometer Profile Service Callbacks
+CONST gattServiceCBs_t magnetometerCBs =
+{
+ magnetometer_ReadAttrCB, // Read callback function pointer
+ magnetometer_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Magnetometer_AddService
+ *
+ * @brief Initializes the Sensor Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Magnetometer_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, magnetometerDataConfig );
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( magnetometer_HandleConnStatusCB );
+
+ if ( services & MAGNETOMETER_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( sensorMagnetometerAttrTbl,
+ GATT_NUM_ATTRS( sensorMagnetometerAttrTbl ),
+ &magnetometerCBs );
+ }
+
+ return ( status );
+}
+
+
+/*********************************************************************
+ * @fn Magnetometer_RegisterAppCBs
+ *
+ * @brief Registers the application callback function. Only call
+ * this function once.
+ *
+ * @param callbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+bStatus_t Magnetometer_RegisterAppCBs( magnetometerCBs_t *appCallbacks )
+{
+ if ( magnetometer_AppCBs == NULL )
+ {
+ if ( appCallbacks != NULL )
+ {
+ magnetometer_AppCBs = appCallbacks;
+ }
+
+ return ( SUCCESS );
+ }
+
+ return ( bleAlreadyInRequestedMode );
+}
+
+
+/*********************************************************************
+ * @fn Magnetometer_SetParameter
+ *
+ * @brief Set a Sensor Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Magnetometer_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case MAGNETOMETER_DATA:
+ if ( len == MAGNETOMETER_DATA_LEN )
+ {
+ VOID osal_memcpy( magnetometerData, value, MAGNETOMETER_DATA_LEN );
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( magnetometerDataConfig, magnetometerData, FALSE,
+ sensorMagnetometerAttrTbl, GATT_NUM_ATTRS( sensorMagnetometerAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case MAGNETOMETER_CONF:
+ if ( len == sizeof ( uint8 ) )
+ {
+ magnetometerCfg = *((uint8*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case MAGNETOMETER_PERI:
+ if ( len == sizeof ( uint8 ) )
+ {
+ magnetometerPer = *((uint8*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Magnetometer_GetParameter
+ *
+ * @brief Get a Sensor Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Magnetometer_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case MAGNETOMETER_DATA:
+ VOID osal_memcpy( value, magnetometerData, MAGNETOMETER_DATA_LEN );
+ break;
+
+ case MAGNETOMETER_CONF:
+ *((uint8*)value) = magnetometerCfg;
+ break;
+
+ case MAGNETOMETER_PERI:
+ *((uint8*)value) = magnetometerPer;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn magnetometer_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 magnetometer_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+
+ // If attribute permissions require authorization to read, return error
+ if ( gattPermitAuthorRead( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE)
+ {
+ // Invalid handle
+ *pLen = 0;
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
+ // gattserverapp handles those reads
+ case MAGNETOMETER_DATA_UUID:
+ *pLen = MAGNETOMETER_DATA_LEN;
+ VOID osal_memcpy( pValue, pAttr->pValue, MAGNETOMETER_DATA_LEN );
+ break;
+
+ case MAGNETOMETER_CONF_UUID:
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ break;
+
+ case MAGNETOMETER_PERI_UUID:
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ break;
+
+ default:
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+* @fn magnetometer_WriteAttrCB
+*
+* @brief Validate attribute data prior to a write operation
+*
+* @param connHandle - connection message was received on
+* @param pAttr - pointer to attribute
+* @param pValue - pointer to data to be written
+* @param len - length of data
+* @param offset - offset of the first octet to be written
+*
+* @return Success or Failure
+*/
+static bStatus_t magnetometer_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+ uint8 notifyApp = 0xFF;
+
+ // If attribute permissions require authorization to write, return error
+ if ( gattPermitAuthorWrite( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE)
+ {
+ // Invalid handle
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ case MAGNETOMETER_DATA_UUID:
+ //Should not get here
+ break;
+
+ case MAGNETOMETER_CONF_UUID:
+ // Validate the value
+ // Make sure it's not a blob oper
+ if ( offset == 0 )
+ {
+ if ( len != 1 )
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ // Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+ *pCurValue = pValue[0];
+
+ if( pAttr->pValue == &magnetometerCfg )
+ {
+ notifyApp = MAGNETOMETER_CONF;
+ }
+ }
+ break;
+
+ case MAGNETOMETER_PERI_UUID:
+ // Validate the value
+ // Make sure it's not a blob oper
+ if ( offset == 0 )
+ {
+ if ( len != 1 )
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ // Write the value
+ if ( status == SUCCESS )
+ {
+ if (pValue[0]>=(MAGNETOMETER_PERIOD_MIN/MAGNETOMETER_TIME_UNIT))
+ {
+
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+ *pCurValue = pValue[0];
+
+ if( pAttr->pValue == &magnetometerPer)
+ {
+ notifyApp = MAGNETOMETER_PERI;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_VALUE;
+ }
+ }
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ // Should never get here!
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ // If a charactersitic value changed then callback function to notify application of change
+ if ( (notifyApp != 0xFF ) && magnetometer_AppCBs && magnetometer_AppCBs->pfnMagnetometerChange )
+ {
+ magnetometer_AppCBs->pfnMagnetometerChange( notifyApp );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn magnetometer_HandleConnStatusCB
+ *
+ * @brief Sensor Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void magnetometer_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, magnetometerDataConfig );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/magnetometerservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/magnetometerservice.h
new file mode 100644
index 0000000..674db88
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/magnetometerservice.h
@@ -0,0 +1,150 @@
+/**************************************************************************************************
+ Filename: magnetometerservice.h
+ Revised: $Date: 2013-03-25 07:58:08 -0700 (Mon, 25 Mar 2013) $
+ Revision: $Revision: 33575 $
+
+ Description: Magnetometer service definitions and prototypes
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef MAGNETOMETERSERVICE_H
+#define MAGNETOMETERSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Profile Parameters
+#define MAGNETOMETER_DATA 7 // R uint8 - Profile Attribute value
+#define MAGNETOMETER_CONF 8 // RW uint8 - Profile Attribute value
+#define MAGNETOMETER_PERI 9 // RW uint8 - Profile Attribute value
+
+// Service UUID
+#define MAGNETOMETER_SERV_UUID 0xAA30 // F0000000-0451-4000-B000-00000000-AA30
+#define MAGNETOMETER_DATA_UUID 0xAA31
+#define MAGNETOMETER_CONF_UUID 0xAA32
+#define MAGNETOMETER_PERI_UUID 0xAA33
+
+// Sensor Profile Services bit fields
+#define MAGNETOMETER_SERVICE 0x00000008
+
+// Length of sensor data in bytes
+#define MAGNETOMETER_DATA_LEN 6
+
+// Lower limits
+#define MAGNETOMETER_PERIOD_MIN 100
+#define MAGNETOMETER_TIME_UNIT 10 // resolution 10 ms
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// Callback when a characteristic value has changed
+typedef NULL_OK void (*magnetometerChange_t)( uint8 paramID );
+
+typedef struct
+{
+ magnetometerChange_t pfnMagnetometerChange; // Called when characteristic value changes
+} magnetometerCBs_t;
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*
+ * Magnetometer_AddService- Initializes the Sensor GATT Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+extern bStatus_t Magnetometer_AddService( uint32 services );
+
+/*
+ * Magnetometer_RegisterAppCBs - Registers the application callback function.
+ * Only call this function once.
+ *
+ * appCallbacks - pointer to application callbacks.
+ */
+extern bStatus_t Magnetometer_RegisterAppCBs( magnetometerCBs_t *appCallbacks );
+
+/*
+ * Magnetometer_SetParameter - Set a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Magnetometer_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * Magnetometer_GetParameter - Get a Sensor GATT Profile parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Magnetometer_GetParameter( uint8 param, void *value );
+
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MAGNETOMETERSERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/st_util.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/st_util.c
new file mode 100644
index 0000000..036d78c
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/st_util.c
@@ -0,0 +1,87 @@
+/**************************************************************************************************
+ Filename: st_util.c
+ Revised: $Date: 2012-09-25 06:26:26 -0700 (Tue, 25 Sep 2012) $
+ Revision: $Revision: 31617 $
+
+ Description: Utilties for Sensor Tag services
+
+
+ Copyright 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*-------------------------------------------------------------------
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "gatt.h"
+#include "st_util.h"
+
+/*-------------------------------------------------------------------
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn utilExtractUuid16
+ *
+ * @brief Extracts a 16-bit UUID from a GATT attribute
+ *
+ * @param pAttr - pointer to attribute
+ *
+ * @param pUuid - pointer to UUID to be extracted
+ *
+ * @return Success or Failure
+ */
+bStatus_t utilExtractUuid16(gattAttribute_t *pAttr, uint16 *pUuid)
+{
+ bStatus_t status = SUCCESS;
+
+ if ( pAttr->type.len == ATT_BT_UUID_SIZE )
+ {
+ // 16-bit UUID direct
+ *pUuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+#ifdef GATT_TI_UUID_128_BIT
+ }
+ else if (pAttr->type.len == ATT_UUID_SIZE)
+ {
+ // 16-bit UUID extracted bytes 12 and 13
+ *pUuid = BUILD_UINT16( pAttr->type.uuid[12], pAttr->type.uuid[13]);
+#endif
+ } else {
+ *pUuid = 0xFFFF;
+ status = FAILURE;
+ }
+
+ return status;
+}
+
+/*********************************************************************
+*********************************************************************/
+
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/st_util.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/st_util.h
new file mode 100644
index 0000000..a0c3a79
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/st_util.h
@@ -0,0 +1,79 @@
+/**************************************************************************************************
+ Filename: st_util.h
+ Revised: $Date: 2012-11-27 14:16:18 -0800 (Tue, 27 Nov 2012) $
+ Revision: $Revision: 32325 $
+
+ Description: Utilties for Sensor Tag services
+
+
+ Copyright 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef ST_UTIL_H
+#define ST_UTIL_H
+
+/*********************************************************************
+ * MACROS
+ */
+#ifdef GATT_TI_UUID_128_BIT
+
+// TI Base 128-bit UUID: F000XXXX-0451-4000-B000-000000000000
+#define TI_UUID_SIZE ATT_UUID_SIZE
+#define TI_UUID(uuid) TI_BASE_UUID_128(uuid)
+
+#else
+
+// Using 16-bit UUID
+#define TI_UUID_SIZE ATT_BT_UUID_SIZE
+#define TI_UUID(uuid) LO_UINT16(uuid), HI_UINT16(uuid)
+
+#endif
+
+
+/*-------------------------------------------------------------------
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn utilExtractUuid16
+ *
+ * @brief Extracts a 16-bit UUID from a GATT attribute
+ *
+ * @param pAttr - pointer to attribute
+ *
+ * @param pValue - pointer to UUID to be extracted
+ *
+ * @return Success or Failure
+ */
+bStatus_t utilExtractUuid16(gattAttribute_t *pAttr, uint16 *pValue);
+
+#endif /* ST_UTIL_H */
+
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/testservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/testservice.c
new file mode 100644
index 0000000..4461a61
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/testservice.c
@@ -0,0 +1,537 @@
+/**************************************************************************************************
+ Filename: testservice.c
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: Test Service.
+
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "gapbondmgr.h"
+
+#include "testservice.h"
+#include "st_util.h"
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+// Test GATT Profile Service UUID
+CONST uint8 testServUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(TEST_SERV_UUID)
+};
+
+// Data Characteristic UUID
+CONST uint8 testDataUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(TEST_DATA_UUID)
+};
+
+// Config Characteristic UUID
+CONST uint8 testConfUUID[TI_UUID_SIZE] =
+{
+ TI_UUID(TEST_CONF_UUID)
+};
+
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static testCBs_t *test_AppCBs = NULL;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Test Profile Service attribute
+static CONST gattAttrType_t testService = { TI_UUID_SIZE, testServUUID };
+
+// Test Profile Data Characteristic Properties
+static uint8 testDataProps = GATT_PROP_READ;
+
+// Test Profile Data Characteristic Value
+static uint8 testData[TEST_DATA_LEN] = {0,0};
+
+// Test Characteristic Configuration
+static gattCharCfg_t testDataConfig[GATT_MAX_NUM_CONN];
+
+// Test Profile Data Characteristic User Description
+static uint8 testDataUserDesp[] = "Test Data";
+
+// Test Profile Config Characteristic Properties
+static uint8 testConfProps = GATT_PROP_READ | GATT_PROP_WRITE;
+
+// Test Profile Config Characteristic Value
+static uint8 testConf = 0x00;
+
+// Test Profile Config Characteristic User Description
+static uint8 testConfUserDesp[] = "Test Config";
+
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+static gattAttribute_t testAttrTbl[] =
+{
+ // Test Profile Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&testService /* pValue */
+ },
+
+ // Data Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &testDataProps
+ },
+
+ // Data Characteristic Value
+ {
+ { TI_UUID_SIZE, testDataUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ testData
+ },
+
+ // Data Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ testDataUserDesp
+ },
+
+ // Config Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &testConfProps
+ },
+
+ // Config Characteristic Value
+ {
+ { TI_UUID_SIZE, testConfUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ &testConf
+ },
+
+ // Config Characteristic User Description
+ {
+ { ATT_BT_UUID_SIZE, charUserDescUUID },
+ GATT_PERMIT_READ,
+ 0,
+ testConfUserDesp
+ },
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 test_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t test_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+static void test_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+
+// Test Profile Service Callbacks
+CONST gattServiceCBs_t testCBs =
+{
+ test_ReadAttrCB, // Read callback function pointer
+ test_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Test_AddService
+ *
+ * @brief Initializes the Test Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Test_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, testDataConfig );
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( test_HandleConnStatusCB );
+
+ if ( services & TEST_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( testAttrTbl,
+ GATT_NUM_ATTRS( testAttrTbl ),
+ &testCBs );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Test_RegisterAppCBs
+ *
+ * @brief Registers the application callback function. Only call
+ * this function once.
+ *
+ * @param callbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+bStatus_t Test_RegisterAppCBs( testCBs_t *appCallbacks )
+{
+ if ( test_AppCBs == NULL )
+ {
+ if ( appCallbacks != NULL )
+ {
+ test_AppCBs = appCallbacks;
+ }
+
+ return ( SUCCESS );
+ }
+
+ return ( bleAlreadyInRequestedMode );
+
+}
+
+/*********************************************************************
+ * @fn TestProfile_SetParameter
+ *
+ * @brief Set a Test Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Test_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case TEST_DATA_ATTR:
+ if ( len == TEST_DATA_LEN )
+ {
+ VOID osal_memcpy( testData, value, TEST_DATA_LEN );
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( testDataConfig, testData, FALSE,
+ testAttrTbl, GATT_NUM_ATTRS( testAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ case TEST_CONF_ATTR:
+ if(len == sizeof ( uint8 ) )
+ {
+ testConf = *((uint8*)value);
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn TestProfile_GetParameter
+ *
+ * @brief Get a Test Profile parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Test_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case TEST_DATA_ATTR:
+ VOID osal_memcpy (value, testData, TEST_DATA_LEN );
+ break;
+
+ case TEST_CONF_ATTR:
+ *((uint8*)value) = testConf;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn test_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 test_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+
+ // If attribute permissions require authorization to read, return error
+ if ( gattPermitAuthorRead( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE)
+ {
+ // Invalid handle
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
+ // gattserverapp handles those reads
+ case TEST_DATA_UUID:
+ *pLen = TEST_DATA_LEN;
+ VOID osal_memcpy( pValue, pAttr->pValue, TEST_DATA_LEN );
+ break;
+
+ case TEST_CONF_UUID:
+ *pLen = 1;
+ pValue[0] = *pAttr->pValue;
+ break;
+
+ default:
+ // Should never get here!
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn test_WriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t test_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+ uint8 notifyApp = 0xFF;
+ uint16 uuid;
+
+ // If attribute permissions require authorization to write, return error
+ if ( gattPermitAuthorWrite( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE)
+ {
+ // Invalid handle
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+ case TEST_CONF_UUID:
+ // Validate the value
+ // Make sure it's not a blob oper
+ if ( offset == 0 )
+ {
+ if ( len != 1 )
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ // Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+ *pCurValue = pValue[0];
+
+ if( pAttr->pValue == &testConf )
+ {
+ notifyApp = TEST_CONF_ATTR;
+ }
+ }
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ // Should never get here! (characteristics 2 and 4 do not have write permissions)
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ // If a charactersitic value changed then callback function to notify application of change
+ if ( (notifyApp != 0xFF ) && test_AppCBs && test_AppCBs->pfnTestChange )
+ {
+ test_AppCBs->pfnTestChange( notifyApp );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn test_HandleConnStatusCB
+ *
+ * @brief Test Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void test_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, testDataConfig );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/testservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/testservice.h
new file mode 100644
index 0000000..b253a2f
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/SensorProfile/testservice.h
@@ -0,0 +1,147 @@
+/**************************************************************************************************
+ Filename: testservice.h
+ Revised: $Date: 2013-03-25 07:58:08 -0700 (Mon, 25 Mar 2013) $
+ Revision: $Revision: 33575 $
+
+ Description: Test service definitions and prototypes
+
+
+ Copyright 2012-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef TESTSERVICE_H
+#define TESTSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Test Service Parameters
+#define TEST_DATA_ATTR 0 // RW uint8 - Profile Attribute value
+#define TEST_CONF_ATTR 1 // RW uint8 - Profile Attribute value
+
+// Service UUID
+#define TEST_SERV_UUID 0xAA60 // F0000000-0451-4000-B000-00000000-AA60
+#define TEST_DATA_UUID 0xAA61
+#define TEST_CONF_UUID 0xAA62
+
+// Test Profile Services bit fields
+#define TEST_SERVICE 0x00000001
+
+// Test Data Length
+#define TEST_DATA_LEN 2
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// Callback when a characteristic value has changed
+typedef NULL_OK void (*testChange_t)( uint8 paramID );
+
+typedef struct
+{
+ testChange_t pfnTestChange; // Called when characteristic value changes
+} testCBs_t;
+
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*
+ * Test_AddService- Initializes the Test Profile service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+extern bStatus_t Test_AddService( uint32 services );
+
+/*
+ * Test_RegisterAppCBs - Registers the application callback function.
+ * Only call this function once.
+ *
+ * appCallbacks - pointer to application callbacks.
+ */
+extern bStatus_t Test_RegisterAppCBs( testCBs_t *appCallbacks );
+
+/*
+ * Test_SetParameter - Set a Test Profile parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Test_SetParameter( uint8 param, uint8 len, void *pValue );
+
+/*
+ * Test_GetParameter - Get a Test Profile parameter.
+ *
+ * param - Profile parameter ID
+ * pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Test_GetParameter( uint8 param, void *pValue );
+
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TESTPROFILE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Thermometer/thermometerservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Thermometer/thermometerservice.c
new file mode 100644
index 0000000..5d4c109
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Thermometer/thermometerservice.c
@@ -0,0 +1,756 @@
+/**************************************************************************************************
+ Filename: thermometerService.c
+ Revised: $Date: 2013-05-06 13:33:47 -0700 (Mon, 06 May 2013) $
+ Revision: $Revision: 34153 $
+
+ Description: This file contains the Simple BLE Peripheral sample application
+ for use with the CC2540 Bluetooth Low Energy Protocol Stack.
+
+ Copyright 2011 - 2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "gapbondmgr.h"
+#include "thermometerservice.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// Thermometer service
+CONST uint8 thermometerServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(THERMOMETER_SERV_UUID), HI_UINT16(THERMOMETER_SERV_UUID)
+};
+
+// Thermometer temperature characteristic
+CONST uint8 thermometerTempUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(THERMOMETER_TEMP_UUID), HI_UINT16(THERMOMETER_TEMP_UUID)
+};
+
+// Thermometer Site
+CONST uint8 thermometerTypeUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(THERMOMETER_TYPE_UUID), HI_UINT16(THERMOMETER_TYPE_UUID)
+};
+
+// Thermometer Immediate Measurement
+CONST uint8 thermometerImeasUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(THERMOMETER_IMEAS_UUID), HI_UINT16(THERMOMETER_IMEAS_UUID)
+};
+
+// Thermometer Measurement Interval
+CONST uint8 thermometerIntervalUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(THERMOMETER_INTERVAL_UUID), HI_UINT16(THERMOMETER_INTERVAL_UUID)
+};
+
+// Thermometer Test Commands
+CONST uint8 thermometerIRangeUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(THERMOMETER_IRANGE_UUID), HI_UINT16(THERMOMETER_IRANGE_UUID)
+};
+
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static thermometerServiceCB_t thermometerServiceCB;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Thermometer Service attribute
+static CONST gattAttrType_t thermometerService = { ATT_BT_UUID_SIZE, thermometerServUUID };
+
+// Client Characteristic configuration. Each client has its own instantiation
+// of the Client Characteristic Configuration. Reads of the Client Characteristic
+// Configuration only shows the configuration for that client and writes only
+// affect the configuration of that client.
+
+// Thermometer Temperature Characteristic
+static uint8 thermometerTempProps = GATT_PROP_INDICATE;
+static uint8 thermometerTemp = 0;
+static gattCharCfg_t thermometerTempConfig[GATT_MAX_NUM_CONN];
+static uint8 thermometerTempFormat = 12;
+
+// Site
+static uint8 thermometerTypeProps = GATT_PROP_READ;
+static uint8 thermometerType = 0;
+
+// Intermediate Measurement
+static uint8 thermometerImeasProps = GATT_PROP_NOTIFY;
+static uint8 thermometerImeas=0;
+static gattCharCfg_t thermometerIMeasConfig[GATT_MAX_NUM_CONN];
+
+// Measurement Interval
+static uint8 thermometerIntervalProps = GATT_PROP_INDICATE|GATT_PROP_READ|GATT_PROP_WRITE;
+static uint8 thermometerInterval=30; //default
+static gattCharCfg_t thermometerIntervalConfig[GATT_MAX_NUM_CONN];
+
+// Measurement Interval Range
+static thermometerIRange_t thermometerIRange = {1,60};
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t thermometerAttrTbl[] =
+{
+ // Thermometer Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&thermometerService /* pValue */
+ },
+
+
+ // TEMPERATURE
+ // 1. Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &thermometerTempProps
+ },
+
+ // 2. Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, thermometerTempUUID },
+ 0,
+ 0,
+ &thermometerTemp
+ },
+
+ // 3. Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)&thermometerTempConfig
+ },
+ // 4. Presentation Format
+ {
+ { ATT_BT_UUID_SIZE, charFormatUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *)&thermometerTempFormat
+ },
+
+ // MEASUREMENT TYPE
+
+ // 5. Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &thermometerTypeProps
+ },
+
+ // 6. Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, thermometerTypeUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &thermometerType
+ },
+
+ // IMMEDIATE MEASUREMENT
+
+ // 7. Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &thermometerImeasProps
+ },
+
+ // 8. Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, thermometerImeasUUID },
+ 0,
+ 0,
+ &thermometerImeas
+ },
+
+ // 9. Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)&thermometerIMeasConfig
+ },
+
+ // INTERVAL
+
+ // 10. Characteristic Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ &thermometerIntervalProps
+ },
+
+ // 11. Characteristic Value
+ {
+ { ATT_BT_UUID_SIZE, thermometerIntervalUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_AUTHEN_WRITE,
+ 0,
+ &thermometerInterval
+ },
+ // 12. Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)&thermometerIntervalConfig
+ },
+ // 13. Interval Range
+ {
+ { ATT_BT_UUID_SIZE, thermometerIRangeUUID },
+ GATT_PERMIT_READ,
+ 0,
+ (uint8 *)&thermometerIRange
+ },
+};
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 thermometer_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t thermometer_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+
+static void thermometer_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Thermometer Service Callbacks
+CONST gattServiceCBs_t thermometerCBs =
+{
+ thermometer_ReadAttrCB, // Read callback function pointer
+ thermometer_WriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Thermometer_AddService
+ *
+ * @brief Initializes the Thermometer service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Thermometer_AddService( uint32 services )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, thermometerTempConfig );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, thermometerIMeasConfig );
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, thermometerIntervalConfig );
+
+ // Register with Link DB to receive link status change callback
+ VOID linkDB_Register( thermometer_HandleConnStatusCB );
+
+ if ( services & THERMOMETER_SERVICE )
+ {
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( thermometerAttrTbl,
+ GATT_NUM_ATTRS( thermometerAttrTbl ),
+ &thermometerCBs );
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Thermometer_Register
+ *
+ * @brief Register a callback function with the Thermometer Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return None.
+ */
+extern void Thermometer_Register( thermometerServiceCB_t pfnServiceCB )
+{
+ thermometerServiceCB = pfnServiceCB;
+}
+
+/*********************************************************************
+ * @fn Thermometer_SetParameter
+ *
+ * @brief Set a thermomter parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Thermometer_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+
+ case THERMOMETER_TYPE:
+ thermometerType = *((uint8*)value);
+ break;
+
+ case THERMOMETER_INTERVAL:
+ thermometerInterval = *((uint8*)value);
+ break;
+
+ case THERMOMETER_TEMP_CHAR_CFG:
+ // Need connection handle
+ //thermometerTempConfig.value = *((uint8*)value);
+ break;
+
+ case THERMOMETER_IMEAS_CHAR_CFG:
+ // Need connection handle
+ //thermometerIMeasConfig.value = *((uint8*)value);
+ break;
+
+ case THERMOMETER_INTERVAL_CHAR_CFG:
+ // Need connection handle
+ //thermometerIntervalConfig.value = *((uint8*)value);
+ break;
+
+ case THERMOMETER_IRANGE:
+ thermometerIRange = *((thermometerIRange_t*)value);
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Thermometer_GetParameter
+ *
+ * @brief Get a Thermometer parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Thermometer_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case THERMOMETER_TYPE:
+ *((uint8*)value) = thermometerType;
+ break;
+
+ case THERMOMETER_INTERVAL:
+ *((uint8*)value) = thermometerInterval;
+ break;
+
+ case THERMOMETER_IRANGE:
+ *((thermometerIRange_t*)value) = thermometerIRange;
+ break;
+
+ case THERMOMETER_TEMP_CHAR_CFG:
+ // Need connection handle
+ //*((uint16*)value) = thermometerTempConfig.value;
+ break;
+
+ case THERMOMETER_IMEAS_CHAR_CFG:
+ // Need connection handle
+ //*((uint16*)value) = thermometerIMeasConfig.value;
+ break;
+
+ case THERMOMETER_INTERVAL_CHAR_CFG:
+ // Need connection handle
+ //*((uint16*)value) = thermometerIntervalConfig.value;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Thermometer_TempIndicate
+ *
+ * @brief Send a indication containing a thermometer
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+bStatus_t Thermometer_TempIndicate( uint16 connHandle, attHandleValueInd_t *pNoti,uint8 taskId )
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, thermometerTempConfig );
+
+ // If indications enabled
+ if ( value & GATT_CLIENT_CFG_INDICATE )
+ {
+ // Set the handle (uses stored relative handle to lookup actual handle)
+ pNoti->handle = thermometerAttrTbl[pNoti->handle].handle;
+
+ // Send the Indication
+ return GATT_Indication( connHandle, pNoti, FALSE, taskId );
+ }
+
+ return bleIncorrectMode;
+}
+
+/*********************************************************************
+ * @fn Thermometer_IntervalIndicate
+ *
+ * @brief Send a interval change indication
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+bStatus_t Thermometer_IntervalIndicate( uint16 connHandle, attHandleValueInd_t *pNoti,uint8 taskId )
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, thermometerIntervalConfig );
+
+ // If indications enabled
+ if ( value & GATT_CLIENT_CFG_INDICATE )
+ {
+ // Set the handle (uses stored relative handle to lookup actual handle)
+ pNoti->handle = thermometerAttrTbl[pNoti->handle].handle;
+
+ // Send the Indication
+ return GATT_Indication( connHandle, pNoti, FALSE, taskId );
+ }
+
+ return bleIncorrectMode;
+}
+
+/*********************************************************************
+ * @fn Thermometer_IMeasNotify
+ *
+ * @brief Send a notification containing a thermometer
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+bStatus_t Thermometer_IMeasNotify( uint16 connHandle, attHandleValueNoti_t *pNoti)
+{
+ uint16 value = GATTServApp_ReadCharCfg( connHandle, thermometerIMeasConfig );
+
+ // If notifications enabled
+ if ( value & GATT_CLIENT_CFG_NOTIFY )
+ {
+ // Set the handle
+ pNoti->handle = thermometerAttrTbl[THERMOMETER_IMEAS_VALUE_POS].handle;
+
+ // Send the Notification
+ return GATT_Notification( connHandle, pNoti, FALSE );
+ }
+
+ return bleIncorrectMode;
+}
+
+/*********************************************************************
+ * @fn thermometer_ReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+static uint8 thermometer_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ bStatus_t status = SUCCESS;
+
+ // If attribute permissions require authorization to read, return error
+ if ( gattPermitAuthorRead( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ if ( pAttr->type.len == ATT_BT_UUID_SIZE )
+ {
+ // 16-bit UUID
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ case THERMOMETER_TYPE_UUID:
+ *pLen = THERMOMETER_TYPE_LEN;
+ VOID osal_memcpy( pValue, &thermometerType, THERMOMETER_TYPE_LEN ) ;
+ break;
+
+ case THERMOMETER_INTERVAL_UUID:
+ *pLen = THERMOMETER_INTERVAL_LEN;
+ VOID osal_memcpy( pValue, &thermometerInterval, THERMOMETER_INTERVAL_LEN ) ;
+ break;
+
+ case THERMOMETER_IRANGE_UUID:
+ *pLen = THERMOMETER_IRANGE_LEN;
+ VOID osal_memcpy( pValue, &thermometerIRange, THERMOMETER_IRANGE_LEN ) ;
+ break;
+
+ default:
+ *pLen = 0;
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn thermometer_WriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t thermometer_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ bStatus_t status = SUCCESS;
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ // Validate/Write Temperature measurement setting
+ if ( pAttr->handle == thermometerAttrTbl[THERMOMETER_TEMP_CHAR_CONFIG_POS].handle )
+ {
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_INDICATE );
+ if ( status == SUCCESS )
+ {
+ uint16 value = BUILD_UINT16( pValue[0], pValue[1] );
+
+ (*thermometerServiceCB)( (value == GATT_CFG_NO_OPERATION) ?
+ THERMOMETER_TEMP_IND_DISABLED :
+ THERMOMETER_TEMP_IND_ENABLED );
+ }
+ }
+ // Validate/Write Intermediate measurement setting
+ else if ( pAttr->handle == thermometerAttrTbl[THERMOMETER_IMEAS_CHAR_CONFIG_POS].handle )
+ {
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ if ( status == SUCCESS )
+ {
+ uint16 value = BUILD_UINT16( pValue[0], pValue[1] );
+
+ // Notify application
+ (*thermometerServiceCB)( (value == GATT_CFG_NO_OPERATION) ?
+ THERMOMETER_IMEAS_NOTI_DISABLED :
+ THERMOMETER_IMEAS_NOTI_ENABLED);
+ }
+ }
+ // Validate/Write Interval Client Char Config
+ else if ( pAttr->handle == thermometerAttrTbl[THERMOMETER_INTERVAL_CHAR_CONFIG_POS].handle )
+ {
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_INDICATE );
+ if ( status == SUCCESS )
+ {
+ uint16 value = BUILD_UINT16( pValue[0], pValue[1] );
+
+ // Notify application
+ (*thermometerServiceCB)( (value == GATT_CFG_NO_OPERATION) ?
+ THERMOMETER_INTERVAL_IND_DISABLED :
+ THERMOMETER_INTERVAL_IND_ENABLED);
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_HANDLE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ break;
+
+ case THERMOMETER_INTERVAL_UUID:
+ // Validate the value
+ // Make sure it's not a blob oper
+ if ( offset == 0 )
+ {
+ if ( len != THERMOMETER_INTERVAL_LEN )
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ //validate range
+ if ((*pValue >= thermometerIRange.high) | ((*pValue <= thermometerIRange.low) & (*pValue != 0)))
+ {
+ status = ATT_ERR_INVALID_VALUE;
+ }
+
+ //Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+ // *pCurValue = *pValue;
+ VOID osal_memcpy( pCurValue, pValue, THERMOMETER_INTERVAL_LEN ) ;
+
+ //notify application of write
+ (*thermometerServiceCB)(THERMOMETER_INTERVAL_SET);
+
+ }
+ break;
+
+ default:
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ return ( status );
+}
+
+
+/*********************************************************************
+ * @fn thermometer_HandleConnStatusCB
+ *
+ * @brief Simple Profile link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+static void thermometer_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, thermometerTempConfig );
+ GATTServApp_InitCharCfg( connHandle, thermometerIMeasConfig );
+ GATTServApp_InitCharCfg( connHandle, thermometerIntervalConfig );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Thermometer/thermometerservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Thermometer/thermometerservice.h
new file mode 100644
index 0000000..a9f4a6f
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/Thermometer/thermometerservice.h
@@ -0,0 +1,238 @@
+/**************************************************************************************************
+ Filename: ThermomterService.h
+ Revised: $Date $
+ Revision: $Revision $
+
+ Description: This file contains the Thermometer service definitions and
+ prototypes.
+
+ Copyright 2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+#ifndef THERMOMETERSERVICE_H
+#define THERMOMETERSERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Thermometer Service Parameters
+#define THERMOMETER_TEMP 0
+#define THERMOMETER_TEMP_CHAR_CFG 1
+#define THERMOMETER_TYPE 2
+#define THERMOMETER_INTERVAL 3
+#define THERMOMETER_INTERVAL_CHAR_CFG 4
+#define THERMOMETER_IMEAS_CHAR_CFG 5
+#define THERMOMETER_IRANGE 6
+
+
+// Position in attribute array
+#define THERMOMETER_TEMP_VALUE_POS 2
+#define THERMOMETER_TEMP_CHAR_CONFIG_POS 3
+#define THERMOMETER_IMEAS_VALUE_POS 8
+#define THERMOMETER_IMEAS_CHAR_CONFIG_POS 9
+#define THERMOMETER_INTERVAL_VALUE_POS 11
+#define THERMOMETER_INTERVAL_CHAR_CONFIG_POS 12
+
+ // Length of bytes
+#define THERMOMETER_INTERVAL_LEN 1
+#define THERMOMETER_TYPE_LEN 1
+#define THERMOMETER_IRANGE_LEN 2
+
+// Thermometer Service UUIDs
+#define THERMOMETER_SERV_UUID 0x1809 //thermometer service
+#define THERMOMETER_TEMP_UUID 0x2A1C //temperature
+#define THERMOMETER_TYPE_UUID 0x2A1D //meas site, type
+#define THERMOMETER_IMEAS_UUID 0x2A1E //immediate meas
+#define THERMOMETER_INTERVAL_UUID 0x2A21 //meas interval
+#define THERMOMETER_IRANGE_UUID 0x2906 //valid range UUID
+
+// Maximum length of thermometer
+// measurement characteristic
+#define THERMOMETER_MEAS_MAX (ATT_MTU_SIZE -5)
+
+// Values for flags
+#define THERMOMETER_FLAGS_CELCIUS 0x00
+#define THERMOMETER_FLAGS_FARENHEIT 0x01
+#define THERMOMETER_FLAGS_TIMESTAMP 0x02
+#define THERMOMETER_FLAGS_TYPE 0x04
+
+// Values for sensor location
+#define THERMOMETER_TYPE_ARMPIT 0x01
+#define THERMOMETER_TYPE_BODY 0x02
+#define THERMOMETER_TYPE_EAR 0x03
+#define THERMOMETER_TYPE_FINGER 0x04
+#define THERMOMETER_TYPE_GASTRO 0x05
+#define THERMOMETER_TYPE_MOUTH 0x06
+#define THERMOMETER_TYPE_RECTUM 0x07
+#define THERMOMETER_TYPE_TOE 0x08
+#define THERMOMETER_TYPE_TYMPNUM 0x09
+
+// Thermometer Service bit fields
+#define THERMOMETER_SERVICE 0x00000001
+
+// Callback events
+#define THERMOMETER_TEMP_IND_ENABLED 1
+#define THERMOMETER_TEMP_IND_DISABLED 2
+#define THERMOMETER_IMEAS_NOTI_ENABLED 3
+#define THERMOMETER_IMEAS_NOTI_DISABLED 4
+#define THERMOMETER_INTERVAL_IND_ENABLED 5
+#define THERMOMETER_INTERVAL_IND_DISABLED 6
+#define THERMOMETER_INTERVAL_SET 7
+#define THERMOMETER_TESTCMD_C 8
+#define THERMOMETER_TESTCMD_F 9
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Thermometer Service callback function
+typedef void (*thermometerServiceCB_t)(uint8 event);
+
+/**
+ * Thermometer Interval Range
+ */
+typedef struct
+{
+ uint8 low;
+ uint8 high;
+} thermometerIRange_t;
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*
+ * Thermometer_AddService- Initializes the Thermometer service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ */
+
+extern bStatus_t Thermometer_AddService( uint32 services );
+
+/*
+ * Thermometer_Register - Register a callback function with the
+ * Thermometer Service
+ *
+ * @param pfnServiceCB - Callback function.
+ */
+
+extern void Thermometer_Register( thermometerServiceCB_t pfnServiceCB );
+
+/*
+ * Thermometer_SetParameter - Set a Thermometer parameter.
+ *
+ * param - Profile parameter ID
+ * len - length of data to right
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Thermometer_SetParameter( uint8 param, uint8 len, void *value );
+
+/*
+ * Thermometer_GetParameter - Get a Thermometer parameter.
+ *
+ * param - Profile parameter ID
+ * value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ */
+extern bStatus_t Thermometer_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+ * @fn Thermometer_TempIndicate
+ *
+ * @brief Send a notification containing a thermometer
+ * measurement.
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t Thermometer_TempIndicate( uint16 connHandle, attHandleValueInd_t *pNoti, uint8 taskId );
+
+/*********************************************************************
+ * @fn Thermometer_IntervalIndicate
+ *
+ * @brief Send a interval change indication
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t Thermometer_IntervalIndicate( uint16 connHandle, attHandleValueInd_t *pNoti,uint8 taskId );
+
+/*********************************************************************
+ * @fn Thermometer_IMeasNotify
+ *
+ * @brief Send a intermediate temperature notification
+ *
+ * @param connHandle - connection handle
+ * @param pNoti - pointer to notification structure
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t Thermometer_IMeasNotify( uint16 connHandle, attHandleValueNoti_t *pNoti );
+
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* THERMOMETERSERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/TimeService/timeservice.c b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/TimeService/timeservice.c
new file mode 100644
index 0000000..b22c72e
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/TimeService/timeservice.c
@@ -0,0 +1,436 @@
+/**************************************************************************************************
+ Filename: timeservice.c
+ Revised: $Date $
+ Revision: $Revision $
+
+ Description: This file contains the Current Time service.
+
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#include "bcomdef.h"
+#include "OSAL.h"
+#include "hal_adc.h"
+#include "linkdb.h"
+#include "att.h"
+#include "gatt.h"
+#include "gatt_uuid.h"
+#include "gattservapp.h"
+#include "hid_uuid.h"
+#include "hiddev.h"
+
+#include "timeservice.h"
+#include "wimu_util.h"
+#include "st_util.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+// Current Time service
+CONST uint8 timeServUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(TIME_SERVICE_UUID), HI_UINT16(TIME_SERVICE_UUID)
+};
+
+// Current Time characteristic
+CONST uint8 currentTimeUUID[ATT_BT_UUID_SIZE] =
+{
+ LO_UINT16(CURRENT_TIME_UUID), HI_UINT16(CURRENT_TIME_UUID)
+};
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+static timeCBs_t *Time_AppCBs = NULL;
+
+/*********************************************************************
+ * Profile Attributes - variables
+ */
+
+// Time Service attribute
+static CONST gattAttrType_t timeService = { ATT_BT_UUID_SIZE, timeServUUID };
+
+// Current Time characteristic
+static uint8 currentTimeProps = GATT_PROP_READ | GATT_PROP_NOTIFY | GATT_PROP_WRITE;
+static uint8 currentTime[WIMU_GPS_CURRENT_TIME_PACKET_SIZE];
+static gattCharCfg_t currentTimeClientCharCfg[GATT_MAX_NUM_CONN];
+
+/*********************************************************************
+ * Profile Attributes - Table
+ */
+
+static gattAttribute_t timeAttrTbl[] =
+{
+ // Current Time Service
+ {
+ { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
+ GATT_PERMIT_READ, /* permissions */
+ 0, /* handle */
+ (uint8 *)&timeService /* pValue */
+ },
+
+ // Current Time Declaration
+ {
+ { ATT_BT_UUID_SIZE, characterUUID },
+ GATT_PERMIT_READ,
+ 0,
+ ¤tTimeProps
+ },
+
+ // Current Time Value
+ {
+ { ATT_BT_UUID_SIZE, currentTimeUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8*)¤tTime
+ },
+
+ // Current Time Client Characteristic Configuration
+ {
+ { ATT_BT_UUID_SIZE, clientCharCfgUUID },
+ GATT_PERMIT_READ | GATT_PERMIT_WRITE,
+ 0,
+ (uint8 *)currentTimeClientCharCfg
+ }
+};
+
+
+/*********************************************************************
+ * LOCAL FUNCTIONS
+ */
+static uint8 timeReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
+static bStatus_t timeWriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+//static void battNotifyCB( linkDBItem_t *pLinkItem );
+//static uint8 battMeasure( void );
+//static void battNotifyLevel( void );
+
+/*********************************************************************
+ * PROFILE CALLBACKS
+ */
+// Current Time Service Callbacks
+CONST gattServiceCBs_t timeCBs =
+{
+ timeReadAttrCB, // Read callback function pointer
+ timeWriteAttrCB, // Write callback function pointer
+ NULL // Authorization callback function pointer
+};
+
+/*********************************************************************
+ * PUBLIC FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Time_AddService
+ *
+ * @brief Initializes the Current Time Service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @return Success or Failure
+ */
+bStatus_t Time_AddService( void )
+{
+ uint8 status = SUCCESS;
+
+ // Initialize Client Characteristic Configuration attributes
+ GATTServApp_InitCharCfg( INVALID_CONNHANDLE, currentTimeClientCharCfg );
+
+ // Register GATT attribute list and CBs with GATT Server App
+ status = GATTServApp_RegisterService( timeAttrTbl,
+ GATT_NUM_ATTRS( timeAttrTbl ),
+ &timeCBs );
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Time_Register
+ *
+ * @brief Register a callback function with the Current Time Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return None.
+ */
+bStatus_t Time_Register( timeCBs_t *appCallbacks )
+{
+ if ( Time_AppCBs == NULL )
+ {
+ if ( appCallbacks != NULL )
+ {
+ Time_AppCBs = appCallbacks;
+ }
+
+ return ( SUCCESS );
+ }
+
+ return ( bleAlreadyInRequestedMode );
+}
+/*********************************************************************
+ * @fn Time_SetParameter
+ *
+ * @brief Set a Current Time Service parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Time_SetParameter( uint8 param, uint8 len, void *value )
+{
+ bStatus_t ret = SUCCESS;
+
+ switch ( param )
+ {
+ case CURRENT_TIME_PARAM:
+ if ( len == WIMU_GPS_CURRENT_TIME_PACKET_SIZE )
+ {
+ osal_memcpy( currentTime, value, WIMU_GPS_CURRENT_TIME_PACKET_SIZE );
+ // See if Notification has been enabled
+ GATTServApp_ProcessCharCfg( currentTimeClientCharCfg, currentTime, FALSE,
+ timeAttrTbl, GATT_NUM_ATTRS( timeAttrTbl ),
+ INVALID_TASK_ID );
+ }
+ else
+ {
+ ret = bleInvalidRange;
+ }
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn Time_GetParameter
+ *
+ * @brief Get a Current Time Service parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+bStatus_t Time_GetParameter( uint8 param, void *value )
+{
+ bStatus_t ret = SUCCESS;
+ switch ( param )
+ {
+ case CURRENT_TIME_PARAM:
+
+ osal_memcpy( value, currentTime, WIMU_GPS_CURRENT_TIME_PACKET_SIZE );
+ //*((uint8*)value) = currentTime;
+ break;
+
+ default:
+ ret = INVALIDPARAMETER;
+ break;
+ }
+
+ return ( ret );
+}
+
+/*********************************************************************
+ * @fn timeReadAttrCB
+ *
+ * @brief Read an attribute.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+
+static uint8 timeReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
+{
+ bStatus_t status = SUCCESS;
+
+ // Make sure it's not a blob operation (no attributes in the profile are long)
+ if ( offset > 0 )
+ {
+ return ( ATT_ERR_ATTR_NOT_LONG );
+ }
+
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1] );
+
+ if ( uuid == CURRENT_TIME_UUID )
+ {
+ *pLen = WIMU_GPS_CURRENT_TIME_PACKET_SIZE;
+ VOID osal_memcpy( pValue, pAttr->pValue, WIMU_GPS_CURRENT_TIME_PACKET_SIZE );
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ }
+
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn timeWriteAttrCB
+ *
+ * @brief Validate attribute data prior to a write operation
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+static bStatus_t timeWriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset )
+{
+ uint16 uuid;
+ bStatus_t status = SUCCESS;
+ uint8 notifyApp = 0xFF;
+
+ // If attribute permissions require authorization to write, return error
+ if ( gattPermitAuthorWrite( pAttr->permissions ) )
+ {
+ // Insufficient authorization
+ return ( ATT_ERR_INSUFFICIENT_AUTHOR );
+ }
+
+ if (utilExtractUuid16(pAttr,&uuid) == FAILURE) {
+ // Invalid handle
+ return ATT_ERR_INVALID_HANDLE;
+ }
+
+ switch ( uuid )
+ {
+
+ case CURRENT_TIME_UUID:
+ //Validate the value
+ if ( offset == 0 )
+ {
+ if ( len != WIMU_GPS_CURRENT_TIME_PACKET_SIZE )
+ {
+ status = ATT_ERR_INVALID_VALUE_SIZE;
+ }
+ }
+ else
+ {
+ status = ATT_ERR_ATTR_NOT_LONG;
+ }
+
+ //Write the value
+ if ( status == SUCCESS )
+ {
+ uint8 *pCurValue = (uint8 *)pAttr->pValue;
+
+ //*pCurValue = pValue[0];
+ osal_memcpy( pCurValue, pValue, WIMU_GPS_CURRENT_TIME_PACKET_SIZE );
+
+ osal_set_event(/*WIMU_TaskID*/10, WIMU_TIME_EVT);
+
+ /*if( pAttr->pValue == ¤tTime )
+ {*/
+ notifyApp = CURRENT_TIME_PARAM;
+ //}
+ }
+ break;
+
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ // Should never get here!
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+
+ // If a charactersitic value changed then callback function to notify application of change
+ if ( (notifyApp != 0xFF ) && Time_AppCBs && Time_AppCBs->pfnTimeChange )
+ {
+ Time_AppCBs->pfnTimeChange( notifyApp );
+ }
+/*
+ uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
+ switch ( uuid )
+ {
+ case GATT_CLIENT_CHAR_CFG_UUID:
+ status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
+ offset, GATT_CLIENT_CFG_NOTIFY );
+ break;
+
+ default:
+ status = ATT_ERR_ATTR_NOT_FOUND;
+ break;
+ }
+ */
+ return ( status );
+}
+
+/*********************************************************************
+ * @fn Time_HandleConnStatusCB
+ *
+ * @brief Current Time link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+void Time_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
+{
+ // Make sure this is not loopback connection
+ if ( connHandle != LOOPBACK_CONNHANDLE )
+ {
+ // Reset Client Char Config if connection has dropped
+ if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
+ ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
+ ( !linkDB_Up( connHandle ) ) ) )
+ {
+ GATTServApp_InitCharCfg( connHandle, currentTimeClientCharCfg );
+ }
+ }
+}
+
+
+/*********************************************************************
+*********************************************************************/
+
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/TimeService/timeservice.h b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/TimeService/timeservice.h
new file mode 100644
index 0000000..1983be4
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/Profiles/TimeService/timeservice.h
@@ -0,0 +1,134 @@
+/**************************************************************************************************
+ Filename: timeservice.h
+ Revised: $Date $
+ Revision: $Revision $
+
+ Description: This file contains the Current Time service definitions and
+ prototypes according to the BLE standard
+
+**************************************************************************************************/
+
+#ifndef TIMESERVICE_H
+#define TIMESERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+// Service UUIDs
+#define TIME_SERVICE_UUID 0x1805 // Current Time Service
+#define CURRENT_TIME_UUID 0x2A2B // Current Time Characteristics
+
+// Parameters
+#define CURRENT_TIME_PARAM 0
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Service callback function
+//typedef void (*battServiceCB_t)(uint8 event);
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+// Callback when a characteristic value has changed
+typedef NULL_OK void (*timeChange_t)( uint8 paramID );
+
+typedef struct
+{
+ timeChange_t pfnTimeChange; // Called when characteristic value changes
+} timeCBs_t;
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*********************************************************************
+ * @fn Time_AddService
+ *
+ * @brief Initializes the Current Time service by registering
+ * GATT attributes with the GATT server.
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t Time_AddService( void );
+
+/*********************************************************************
+ * @fn Time_Register
+ *
+ * @brief Register a callback function with the Current Time Service.
+ *
+ * @param pfnServiceCB - Callback function.
+ *
+ * @return None.
+ */
+extern bStatus_t Time_Register( timeCBs_t *appCallbacks );
+
+/*********************************************************************
+ * @fn Time_SetParameter
+ *
+ * @brief Set a Current Time Service parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+extern bStatus_t Time_SetParameter( uint8 param, uint8 len, void *value );
+
+/*********************************************************************
+ * @fn Time_GetParameter
+ *
+ * @brief Get a Current Time parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to get. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+extern bStatus_t Time_GetParameter( uint8 param, void *value );
+
+/*********************************************************************
+ * @fn Time_HandleConnStatusCB
+ *
+ * @brief Current Time Service link status change handler function.
+ *
+ * @param connHandle - connection handle
+ * @param changeType - type of change
+ *
+ * @return none
+ */
+void Time_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
+
+/*********************************************************************
+*********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TIMESERVICE_H */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/Exe/WIMU.d51 b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/Exe/WIMU.d51
new file mode 100644
index 0000000..f872039
Binary files /dev/null and b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/Exe/WIMU.d51 differ
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/Exe/WIMU.hex b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/Exe/WIMU.hex
new file mode 100644
index 0000000..dbafd86
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/Exe/WIMU.hex
@@ -0,0 +1,6950 @@
+:020000040000FA
+:0600000002010A02264A7B
+:03002B00022A7432
+:03004300022A4E40
+:030053000226C0C2
+:03007300022A8DD1
+:1000830002253BE5C754F84401F5C7790122000076
+:100093000080FB120086B900030200F4E4792178A2
+:1000A30008B800028004F709D8FCE479297802B87B
+:1000B30000028004F709D8FCE4900301782D790C41
+:1000C3008002F0A3D8FCD9FA900E2DAA82AB8390BC
+:1000D300013A78B679048015E493A3AC82AD838AA0
+:1000E300828B83F0A3AA82AB838C828D83D8E9D9D8
+:1000F300E775822B7583B1740312011C75829175A8
+:100103008300740012011C75D00075812A751801D3
+:10011300751903759F00020096C09FF59FE473D085
+:100123009F22D083D082C09FE493C0E0740193C028
+:10013300E0740293F59F22FF0000B400002800281A
+:1001430000283075A000A000A000A000000800084F
+:10015300E001F0001000100010001000100010006B
+:1001630050005000500010001000D00700000000A5
+:1001730000000F00010005003075070010000100AA
+:1001830081FF0000FFED060B07F306FF02020208E2
+:10019300025000A0000000E80302B18F01000093A9
+:1001A3008F02B58F010000820E02E58F010000323D
+:1001B3000302B58F010000830E02BD8F01000048CA
+:1001C3000302B58F010000840E02BF8F0100004AB5
+:1001D3000302B58F010000850E02C18F0800004B9A
+:1001E3000302B58F010000860E02C38F0100008752
+:1001F3000EFF0100FF2002B18F0100008A8F02B5BC
+:100203008F010000EB0E02C58F000000000002B951
+:100213008F0300009803110D110D110D110D110D18
+:10022300110D110D110D110D110D110D110D110DDB
+:10023300E10FF90FDB0FFFFF12416374696D657402
+:10024300727920494D5520446174610012416374F1
+:10025300696D65747279205175617465726E696F29
+:100263006E2044617461001A416374696D65747230
+:100273007920436F6E66696700416374696D6574C5
+:10028300727920436F6E74726F6C0002B18F01003C
+:1002930000968F02B58F0100002E0F02DF8F010041
+:1002A30000FA0702B98F0300000E0802B78F01009E
+:1002B300002F0F02B58F010000420F02D78F0100FC
+:1002C300001A0802B98F0300002A0802B78F010041
+:1002D30000430F02B58F0100005D0F02D58F0100AF
+:1002E30000360802B98F0100003C0802B78F0100F5
+:1002F300005E0F02D38F030000480802B98F03008A
+:10030300004B0802B78F0100006F0F1202B18F017B
+:100313000000998F02B58F010000011002A78F0121
+:100323000000570802B98F030000580802020202B6
+:100333000202020202010D000000100102B18F014E
+:1003430000009C8F02B58F010000221002A38F01D1
+:100353000000640802B58F010000231002A18F0181
+:100363000000F48E02B58F0100002410029F8F015C
+:1003730000006C0802B58F010000251002E78F0111
+:1003830000006E0802B58F010000261002DD8F0108
+:1003930000008B0802B58F010000271002D18F01E6
+:1003A30000008D0802B58F010000281002BB8F01E9
+:1003B3000000008F02B58F010000291002AB8F01EE
+:1003C3000000AD8E02B58F0100002A1002A58F0137
+:1003D30000002B1001053F10020000605D101202A7
+:1003E30002B18F010000908F02B58F010000CE1083
+:1003F30002C98F010000CF1002B58F010000D31096
+:1004030002CB8F010000560902B98F030000670970
+:1004130002B58F010000D41002CD8F0100007309D3
+:1004230002B98F0300007A0902B58F010000D510CD
+:1004330002CF8F0100008609FF000130750302011E
+:1004430006000000000000000000000000000000A3
+:1004530000000000000000000000000000FFFF0695
+:1004630000800CE8031A02B18F0100008D8F02B5E2
+:100473008F0100005B1102DB8F030000070D02B93F
+:100483008F030000110D0B0957494D55332D787813
+:1004930078780201060702EE7019180F180518572D
+:1004A300494D55333031323334353637383941429B
+:1004B3004344454600286E756C6C20706F696E74FA
+:1004C300657229003F3F3F000000807F0000803FAE
+:1004D300F9021550B743BA510000204100E7DB2E63
+:1004E3000000A0401000000008000000120125A435
+:1004F300A303120125BBA303120125EAA3031201DF
+:100503002523A4031201254BA40312012579A40377
+:1005130012012590A403120125A7A403120125BDEE
+:10052300A403120125E4A403120125F7A403120175
+:10053300250DA50312012520A50312012545A503B9
+:1005430012012506A30212012505A4021201253A70
+:10055300A4021201255BA4021201256BA40212015D
+:10056300258CA40212012598A50212012565A60275
+:10057300120125D8A6021201255EA702120125A1A8
+:10058300A702120125D8A7021201255EA8021201B3
+:100593002530A9021201258EA902120125A6A9025E
+:1005A30012012520AA0212012523AA0212012526DF
+:1005B300AA02120125CDAA02120125E5AA021201FF
+:1005C3002515AB0212012535AB0212012523AC021E
+:1005D300120125D9AC0212012594F302120125BCA4
+:1005E300F302120125EAF30212012521F40212019A
+:1005F3002589F402120125D2F4021201251DF50208
+:100603001201255BF50212012598F502120125C698
+:10061300F5021201256DF60212012577F602120189
+:100623002584F602120125B7F60212012579F70295
+:1006330012012585F7021201259DF702120125A754
+:10064300F70212012594AD03120125A2AD03120195
+:1006530025BAAD03120125D2AD0312012596BE01C1
+:1006630012012534BF01120125ACBF01120125C1BE
+:10067300C001120125FBC001120125A4C101120111
+:100683002579C201120125DDC30112012534C401FC
+:10069300120125BBC401120125A2C501120125EFD8
+:1006A300C5011201257DC601120125A1C601120152
+:1006B3002576C801120125B7C801120125D9C80141
+:1006C3001201255AC90112012544CA011201250A42
+:1006D300CB011201254ED70212012520D8021201A7
+:1006E30025C9D8021201250CD90212012599D90274
+:1006F30012012525DA0212012506DB021201253536
+:10070300DB0212012531DC0212012579DC02120120
+:10071300257BDD02120125BFDD02120125E5DD0285
+:100723001201250BAF03120125ED900312012503DE
+:1007330091031201252991031201255192031201FC
+:10074300255B9203120125B49303120125B494038C
+:10075300120125ACE902120125E1EA021201251476
+:10076300EB021201255EEB021201251CED021201C0
+:10077300253BA0011201259EA001120125E3A10141
+:10078300120125F3A10112012516A201120125610F
+:10079300A20112012506A301120125FCA3011201E6
+:1007A30025C6A4011201253EA60112012580A6013A
+:1007B3001201251EA7011201256BA7011201259124
+:1007C300A7011201257FA90112012584A9011201A4
+:1007D3002565AB01120125B9AB011201251BAC0143
+:1007E30012012543AC01120125E7AC01120125A931
+:1007F300AD01120125DAAD01120125DDAD011201B2
+:100803002525AE0112012567AE01120125CEAE01E9
+:10081300120125A49D03120125B79D03120125D0C2
+:100823009D031201251B9E03120125F69E0312014F
+:1008330025859F03120125D09F03120125F72A0066
+:10084300120125032B001201253C2B0012012581E7
+:100853002B00120125382C00120125BE2C00120199
+:1008630025232D001201254F2D00120125882D006F
+:100873001201259C2F0012012578310012012563F6
+:1008830033001201259A3400120125FA36001201B1
+:1008930025E637001201252C3900120125393A00CB
+:1008A300120125563A001201258E3A00120125A89D
+:1008B3003A00120125103B00120125AA3F00120144
+:1008C300254B40001201259C4000120125C3400026
+:1008D3001201251141001201252F41001201258328
+:1008E30041001201255C4200120125E3430012017D
+:1008F300256B44001201250080031201250A8003A1
+:10090300120125D58003120125F08003120125165B
+:1009130081031201255A81031201259281031201D9
+:1009230025BB810312012534820312012549820369
+:100933001201255E8203120125958203120125A966
+:100943008203120125DA82031201251483031201A3
+:1009530025408303120125B7830312012500840375
+:100963001201252A84031201254F84031201250154
+:100973008D03120125CB8D03120125AE8E031201C7
+:1009830025248F03120125668F03120125939003FB
+:10099300120125008002120125298002120125423D
+:1009A300800212012587810212012565820212014C
+:1009B3002584820212012511830212012554830228
+:1009C300120125A18402120125408502120125BFCF
+:1009D30087021201255688021201252A8902120173
+:1009E300250C8A02120125788B021201250B8C0239
+:1009F300120125A9A90312012512AA0312012566D2
+:100A0300AA031201258DAA0312012577840312017B
+:100A130025E484031201252F85031201252486036F
+:100A23001201252087031201250A88031201258D4F
+:100A3300BF02120125CFBF02120125A9C002120174
+:100A43002582C1021201257DC2021201255CC30267
+:100A5300120125C8C3021201258FC402120125FA0F
+:100A6300C40212012561C5021201258CC5021201BF
+:100A730025FDC50212012590C602120125F9C60201
+:100A83001201250EC70212012556C7021201256F56
+:100A9300C702120125D4C702120125D7C7021201CA
+:100AA30025F67C001201251E7D001201255C7D00C8
+:100AB3001201251A7E00120125857E00120125A14F
+:100AC3007E00120125C97E00120125F97E00120164
+:100AD30025087F00120125827F00120125A87F00CF
+:100AE30012012598AF0112012535B1011201251B11
+:100AF300B301120125E5B3011201252CB401120142
+:100B03002573B40112012585B401120125C5B40171
+:100B1300120125F4B40112012540B5011201257813
+:100B2300B501120125A6B501120125F7B501120180
+:100B33002586B60112012574B9011201254EBB01A8
+:100B43001201258ABB01120125E4BC011201252BE8
+:100B5300BD01120125A0BD01120125EEBD01120147
+:100B6300258AB602120125A7B60212012541BC024D
+:100B730012012543BD02120125BDBE021201256BE0
+:100B8300BF02120125D244001201251B45001201A8
+:100B9300254845001201257B4500120125884500A3
+:100BA300120125944500120125A645001201257B5B
+:100BB3004600120125D946001201250E47001201F5
+:100BC30025AA4800120125F748001201251B4900F8
+:100BD3001201258849001201252D4A00120125E939
+:100BE3004A00120125684B001201252C4C0012010A
+:100BF300253B4C00120125BC4C001201255B4D0026
+:100C03001201258D4D00120125284E001201258663
+:100C13004E00120125C04E00120125414F00120162
+:100C2300250A5000120125B350001201253A510044
+:100C3300120125925100120125F351001201251CC6
+:100C43005200120125D252001201251C5400120138
+:100C5300255F54001201257C54001201259B54008A
+:100C6300120125E654001201250B5500120125340B
+:100C73005500120125A35500120125E55500120167
+:100C830025E956001201258357001201254F58000C
+:100C930012012568580012012532F601120125853B
+:100CA300F60112012591F60112012566F7011201E1
+:100CB300258DF701120125C8F70112012534F8012A
+:100CC30012012568F801120125A1F801120125B9C5
+:100CD300F80112012512F9011201252BF901120164
+:100CE3002574F90112012587F901120125A1F901E2
+:100CF300120125B7F901120125D3FA01120125E4E6
+:100D0300FB0112012531FD0112012516FE0112011D
+:100D130025F4FF021201254CE90112012580E901A6
+:100D2300120125EBEC0112012535EE01120125FF1D
+:100D3300EE0112012589F00112012564F10112016E
+:100D4300259EF101120125C1F10112012503F201D2
+:100D53001201250CF20112012556F2011201256040
+:100D6300F2011201250CF301120125E0F301120136
+:100D73002534F40112012596F401120125E9F40149
+:100D830012012518F50112012557F5011201259AC3
+:100D93005800120125F46000120125FA60001201C7
+:100DA30025B566001201259B6A00120125BE940336
+:100DB3001201253495031201254A95031201258753
+:100DC3009503120125BF95031201253C96031201D9
+:100DD30025779603120125F296031201252E970318
+:100DE3001201253797031201254397031201255D4D
+:100DF3009703120125829703120125989703120185
+:100E030025DC9703120125D2EE02120125E5EE023D
+:100E1300120125FFEE0212012528EF021201256BB4
+:100E2300EF02120125AAEF02120125E8EF021201D7
+:100E3300254DF00212012562F0021201256DF00228
+:100E43001201257AF00212012591F0021201259F69
+:100E5300F002120125AAF002120125B6F0021201D6
+:100E630025C9F002120125D4F002120125F7F00280
+:100E7300120125A0F102120125B0F102120125CAC7
+:100E8300F102120125E7F10212012503F202120118
+:100E93002528F20212012532F20212012546F2023E
+:100EA30012012565F202120125C6F202120125CCB8
+:100EB300F202120125D2F202120125D8F202120126
+:100EC30025E4F20212012517F302120125C2DB0108
+:100ED30012012544DC01120125EDDC011201253547
+:100EE300DE0112012543E00112012529E10112016E
+:100EF300255EE10112012580E10112012529E201AC
+:100F0300120125F9E30112012522E4011201259AB8
+:100F1300E401120125CCE401120125D9E4011201F7
+:100F23002524E50112012548E50112012599E70170
+:100F3300120125A3E801120125FFE8011201253F53
+:100F4300CD0112012550CE0112012534CF0112012A
+:100F5300253ECF0112012560CF011201256CCF017F
+:100F630012012510D1011201253DD1011201255392
+:100F7300D201120125A8D201120125F7D3011201D2
+:100F830025CCD40112012528D50112012593D501C1
+:100F9300120125C8D5011201250BD601120125D551
+:100FA300D801120125EDD8011201257ED9011201C4
+:100FB300258CD901120125D9D901120125E7D901BF
+:100FC30012012553DA01120125CEDA01120125257A
+:100FD300DB01120125E897021201250A980212018A
+:100FE300251B9A02120125DA9C02120125049E0296
+:100FF300120125C29E02120125AE9F02120125EBAA
+:10100300A10312012510A20312012586A2031201D6
+:101013002531D0021201253AD00212012543D00214
+:101023001201251BD102120125CCD202120125FC8B
+:10103300D20212012527D30212012557D30212012E
+:101043002582D302120125B6D302120125E2D3026F
+:1010530012012525D40212012550D402120125972D
+:10106300D402120125ECD4021201252ED50212015D
+:101073002588D502120125B3D50212012502D60215
+:1010830012012532D6021201255DD6021201258BEB
+:10109300D602120125AED60212012594AF03120126
+:1010A30025C0AF03120125EDAF03120125F7AF03EE
+:1010B30012012507B0031201252AE4021201253487
+:1010C300E40212012575E402120125BEE4021201B5
+:1010D30025F8E4021201254EE5021201256FE5020F
+:1010E30012012578E502120125CCE502120125F54E
+:1010F300E502120125FFE5021201256DE602120148
+:1011030025FDE60212012558E70212012586E702B2
+:101113001201250EE8021201254DE8021201258273
+:10112300E80212012594E802120125B3E802120134
+:1011330025BCE8021201257EE902120125C0AB039A
+:10114300120125FA9F0312012530A0031201256421
+:10115300A003120125B1A10312012511B00312014D
+:101163002527B00312012531B003120125CC8803D2
+:10117300120125DF8803120125A38903120125E249
+:101183008903120125FF8903120125388A031201FD
+:1011930025858A03120125B78A03120125EE8A03E6
+:1011A3001201257BB003120125B7AC03120125DA26
+:1011B300AC0312012509AD031201254BAD03120146
+:1011C300255ADE02120125A2DE021201251EE002CB
+:1011D300120125DAE0021201256EE202120125CC8A
+:1011E300E302120125EFA6031201251FA703120133
+:1011F3002578A703120125F2A7031201250C9803F2
+:10120300120125319803120125999803120125D55E
+:10121300B003120125F46A00120125936C00120138
+:10122300253E6D00120125BE6D00120125436E009F
+:101233001201256C6E00120125477200120125BEB2
+:101243007200120125D573001201250F74001201DB
+:1012530025507400120125977500120125ED7500C4
+:10126300120125367600120125A5760012012511FB
+:1012730077001201254277001201255A77001201E7
+:1012830025737800120125837800120125397A002D
+:10129300120125507A00120125827A0012012524B9
+:1012A3007C00120125B87C00120125DEFC0212012C
+:1012B300252EFD0212012511FE02120125D6FE0282
+:1012C30012012541FF0212012531B2031201257ECD
+:1012D300B103120125BDB1031201251EB203120190
+:1012E3002585FF0212012595FF02120125A7FF02A2
+:1012F300120125EBFF02120125BEAA0312012543A9
+:10130300AB03120125A7AB03120125F7FF0212015C
+:1013130025F07F001201253CF802120125D3F802C3
+:101323001201257FF90212012509FA02120125A5EE
+:10133300FA021201258BFB021201256CFC02120139
+:101343002576FC0212012589FC02120125A3FC0269
+:10135300120125BAFC02120125C4FC02120125DB8D
+:10136300FC0212012557A503120125A9A5031201A9
+:10137300251CA60312012589A6031201255BA803D8
+:1013830012012537A903120125FBC702120125C744
+:10139300C80212012508C90212012542C90212011D
+:1013A30025A0C902120125F4C90212012552CA025D
+:1013B300120125E8CA02120125F0CB021201257A97
+:1013C300CD0212012518CE021201257FCE02120191
+:1013D3002592CE0212012586CF02120125CFCF021C
+:1013E300120125828C02120125BC8F0212012513E2
+:1013F3009002120125309002120125B090021201D1
+:10140300252C9202120125FB9202120125689602F5
+:10141300120125529702120125C7B1031201254576
+:101423009B031201257F9B03120125E19B031201FC
+:1014330025089C03120125879C0312012544AD0254
+:10144300120125C7AD0212012521AE021201259D0D
+:10145300AE0212012512AF021201259AB002120147
+:101463002581B10212012593B1021201253DB50276
+:1014730012012572B502120125FAB502120125D314
+:10148300FF011201256BAE0312012595AE03120174
+:101493002500B203120125EC8F011201250A9501E3
+:1014A300E066701008A3E066700A08A3E0667004A3
+:1014B30008A3E06622C008C3E096F50808A3E096F7
+:1014C300420808A3E096420808A3E0964208A2D285
+:1014D30065D033E5087001D3D00822C3E796080925
+:1014E300E7960809E7960809E79622C3E09608A35A
+:1014F300E09608A3E09608A3E09622C008C3E0960E
+:10150300F50808A3E096420808A3E096420808A35A
+:10151300E09645087001D3D00822080808E630E7B2
+:1015230011121DD9121535080808C64480C61818AB
+:101533001822181818E9799EC608CAC608CBC60827
+:10154300CCC6C370207996CACBCC7019798ECBCC1C
+:1015530070137986CC700EF9802ACA33CACB33CB89
+:10156300CC33CC331930E7F2CCCBCA3350147004EC
+:10157300EA30E00DE4CA3ACACB3BCBCC3CCC5002B8
+:1015830009C3E913C6CC182313C6CB18C6CA18C699
+:10159300F9221215D520F01430E72B74FFFCFBFA67
+:1015A300747F8022E4FCFBFA7480801AB48008BC48
+:1015B30000F2BB00EF800F50EBF9E4C39AFAE49B0F
+:1015C300FBE49CFCE499C6CC18C6CB18C6CA18C663
+:1015D300F922E4C9C608CAC608CBC6D3330308CC6C
+:1015E300C63392F0C3947F402E94184019C9B907AB
+:1015F30004CACBCC225025C309CA33CACB33CBCCC4
+:1016030033CC33D9F422F4600DC9CCC313CB13CB41
+:10161300CA13CAD9F6CC22E4FCFBFA2214FCFBFA67
+:1016230022E6C33318461846184622E7C333194740
+:101633001947194722181818E6084608700AE608D9
+:10164300C3337005E633F4220822191919E7094751
+:1016530009700AE709C3337005E733F4220922E668
+:10166300084608C3134608336002E633F422E70949
+:101673004709C3134709336002E733F422121662A2
+:1016830060251216716020121624700302162E08AC
+:101693000808E76670101819E766700A1819E766F4
+:1016A30070041819E76622F422121662601C1216DF
+:1016B300716017121624700712162E7001D322C000
+:1016C300D012162E7006D0D0B322C32233D0D050FE
+:1016D3001430E0F6C3E7960809E7960809E7960889
+:1016E30009E796B32220E0D5E6970809E6970809AB
+:1016F300E6970809E697B322121662601B12167169
+:101703006016121624700712162E600CB322C0D076
+:1017130012162E7005D0D022C32233D0D0501330EE
+:10172300E0EBC3E7960809E7960809E7960809E797
+:10173300962220E0E4E6970809E6970809E6970869
+:1017430009E6972200121662604F1216716012E7C3
+:10175300548066F6121638701112162E703B090962
+:1017630009F4F618F618F618F62212164D7015122B
+:10177300162408080860EAE6447FF618768018E421
+:10178300F618F622121624601612162E7012E4F6BC
+:1017930008F608F608E65480F6090909181818220D
+:1017A300EAC0E0EBC0E0ECC0E0EDC0E0E687F0A407
+:1017B300FBACF008E687F0A42CFCE435F0FA18093A
+:1017C300E687F0A42C4B60027401CA35F0FCE433C5
+:1017D300FB09E687F0D2F7A42CCB35F0FC1908E619
+:1017E30087F0A42BCC35F0FBE433FD0819E687F032
+:1017F300D2E7A42C4ACB35F0CD3400FC09E687F0C0
+:10180300D2E7A42DCC35F0FDE433FA0918E687F0CE
+:10181300D2F7A42CCD35F0CA3400FC08E687F0D209
+:10182300E7D2F7A42ACC35F07A7E20E70B0ACB3334
+:10183300CBCD33CDCC33CC33CB3350147004ED301C
+:10184300E00ED2F1E4CD3DCDCC3CCC3B5005DA05E6
+:10185300C2F1EB547FC63308E63392F0FBE733095A
+:10186300E733C39A502D2B70190C0D4C4D7015187E
+:1018730006E608C333700D20F10AA2F013F6E4184C
+:10188300800B4024E4F630F002768018F618F61840
+:10189300F68024D33B14501074FFA2F013F618768D
+:1018A30080E418F618F6800FA2F013F618E6330357
+:1018B300F618ECF618EDF6D0E0FDD0E0FCD0E0FB36
+:1018C300D0E0FA221216716046121662603DE96892
+:1018D3007008F618F618F618F622748067F71218CF
+:1018E300FB090909748067F722121662601D12163C
+:1018F300717005191919801A121638701F12164DB6
+:10190300C37003E66733191919400718181822081A
+:10191300080874FFF618F618F618F62212164D602A
+:101923001712162E702192F01216247019501720D8
+:10193300F014080808090909E7F61819E7F6181951
+:10194300E7F61819E7F62212162460E6E869701F15
+:101953000808E62480F608E436F618547FB47F0CB2
+:10196300E654806007F6E418F618F622181822E900
+:10197300C6CC08C6CD08C6CE08C6CFC0E0E8C0E0D6
+:10198300EAC0E0EBC0E009E9F809E7FA09E7FBE69A
+:10199300F918E6F8C3EC98ED99EE9AEBC2E7F5F087
+:1019A300EFC2E795F0500E600CEBCFFBEACEFAE9FD
+:1019B300CDF9E8CCF8EAA2E7D2E7FAEB33FB13F56B
+:1019C300F0EEA2E7D2E7FEEF33FFC5F013A2E73054
+:1019D300E601B313C5F0C3C0E0C0F07F00C39BFBB7
+:1019E300605B9418600C401AD0E023F9D0E0F80251
+:1019F3001ACA8AF0E9486003D2F0E4AFF0FAF9F8C2
+:101A0300803BEB30E40D89F0EA6003D2F0E4AFF001
+:101A1300F9CAF8EB30E30D88F0EF6002D2F0AFF0D3
+:101A2300E4CAC9F8EB54076014FBC3EA13FAE913D9
+:101A3300F9E813F8EF135002D2E0FFDBEDD0E0C07A
+:101A4300E030E739C3E49FFFF5F0EC98FC42F0ED9A
+:101A530099FD42F0EE9AFE42F0D0E0F9D0E0F8E5CD
+:101A6300F0607AE923F9EE20E742D8028067C3EFFA
+:101A730033FFEC33FCED33FDEE33FE80EAEC28FC60
+:101A8300ED39FDEE3AFED0E023F9D0E0F8400280D4
+:101A93001BC3EE13FEED13FDEC13FCEF135002D248
+:101AA300E0FF08B800067F7F74FF802EEF335017E6
+:101AB3008CF020F00260100CBC000C0DBD00080E71
+:101AC300BE000408E860DFE933E813FFEE2313FEEA
+:101AD3004F4D4C8008E95480FFE4FEFDFCEE33EFEC
+:101AE30033F47004FCFD7E80D0E0FBD0E0FAD0E05C
+:101AF300F8D0E0CFC618CEC618CDC618CCC6F9228A
+:101B0300121662700418181822121671700D74FFE1
+:101B1300F61819F61819F61819F622E7548066F61E
+:101B2300121624700F12162E70F014F608F608F62B
+:101B330008F680D112162E700CF608F60876800887
+:101B4300E6447F80EC121650700C12163B60BFE621
+:101B53005480F6E480BB12163B700519191980A551
+:101B6300E869700C763F18768018F618F6E8F922C3
+:101B7300E6CDC0E018ECC0E0E633CD33CDD313F6A9
+:101B8300E719FCE7191933CC33C3947F400ECD9D7D
+:101B9300502408E65480F6E418F6800FF4043D144C
+:101BA300501408E6447FF6187680E418F618F6D049
+:101BB300E0FCD0E0FD22CCD313CCFD18E4C6CBC0AF
+:101BC300E018E4C6CAC0E00808ED08C633E613F619
+:101BD30018E433C675F003C3CA97CA09CB97CB1968
+:101BE3009C40047D08802EBD0003021CAC16B6FF8A
+:101BF300050606081618C3CA33CACB33CB33CA2724
+:101C0300CA09CB37CB193CC37D08803E187D082019
+:101C1300E75CC633C6CA33CACB33CB33DDF1D5F069
+:101C2300EB30E77BCA97CA09CB974ACB199C406F25
+:101C33004B7025E620E0218066187D08C3CA97CA49
+:101C430009CB97CB199CD3C633C6CA33CACB33CB84
+:101C53003350C9DDE7D5F0E1D3E4C636C608C6364E
+:101C6300C608C636C608C636C61818188031C3CA91
+:101C730097CA09CB97CB199CB34097C633C6CA33CF
+:101C8300CACB33CB33DD34D5F02EC6A2E0C640C871
+:101C9300CA27CA09CB37194A70BECB3CB480B908EE
+:101CA30008E63308E633601F181818D0E0FAD0E0CE
+:101CB300FBD0E0FCD0E0FD22187D08CA27CA09CB7F
+:101CC30037CB193CD3808013F618E4B67F11F6188E
+:101CD300B6FF0EF618C60470D20808768080CAF6DE
+:101CE30018F618F680C5080808EAC0E0EBC0E086DD
+:101CF300F0E7A4FA180986F0E7A42AFA180986F08F
+:101D0300E7A42AFA180986F0E7A42AFA1986F0E765
+:101D1300A4FBE5F02AFA190886F0E7A42BFBE5F00B
+:101D23003AFA190886F0E7A42BFBE5F03AFA1818FB
+:101D33000986F0E7A4C5F02BFBE43AFA1908E7C5D6
+:101D4300F0C6A426F6E5F03BFBE43AFA1886F0E782
+:101D5300A4F6E5F00826F6E43B08F6E43A08F6D0E4
+:101D6300E0FBD0E0FA22E4CFC0E0E4CEC0E0E4CD73
+:101D7300C0E0E4CCC0E075F020C3E633F608E633F8
+:101D8300F608E633F608E633F6181818EC33FCEDDC
+:101D930033FDEE33FEEF33FFC3EC9709ED9709EE06
+:101DA3009709EF97191919400FFFEC97FC09ED9765
+:101DB300FD09EE97FE191906D5F0BEECF709EDF70C
+:101DC30009EEF709EFF7191919D0E0FCD0E0FDD0BF
+:101DD300E0FED0E0FF22181818E4C396F608E49654
+:101DE300F608E496F608E496F6226016080808C694
+:101DF300C313C618C613C618C613C618C613C6D54A
+:101E0300E0EA227009080808226016181818C6C3E9
+:101E130033C608C633C608C633C608C633C6D5E0BC
+:101E2300EA22E627F60809E637F60809E637F60850
+:101E330009E637F622E026F608A3E036F608A3E023
+:101E430036F608A3E036F622E026F008A3E036F0E3
+:101E530008A3E036F008A3E036F022C3E697F608BD
+:101E630009E697F60809E697F60809E697F622C306
+:101E7300E096F008A3E096F008A3E096F008A3E04C
+:101E830096F022E056F608A3E056F608A3E056F6CD
+:101E930008A3E056F622E056F008A3E056F008A3A4
+:101EA300E056F008A3E056F022E0F608A3E0F608B7
+:101EB300A3E0F608A3E0F622E6F008A3E6F008A301
+:101EC300E6F008A3E6F022E0FAA3E0FBA3E0FCA31C
+:101ED300E0FD22EAF0A3EBF0A3ECF0A3EDF022CABD
+:101EE300C0E0E6F0A308DAFAD0E0FA22CAC0E0E0E4
+:101EF300A3C582CCC582C583CDC583F0A3C582CCDF
+:101F0300C582C583CDC583DAE6D0E0CA22C3E4988F
+:101F1300F8E499F9121F518026C3E49AFAE49BFB73
+:101F2300E920E7E9121F51E498F8E499F922C3E4A0
+:101F330098F8E499F9121F51E498F8E499F9C3E485
+:101F43009AFAE49BFB22EB20E7CFE920E7E0B90014
+:101F530010BB0008E88AF084F8AAF022E4FBC8FA70
+:101F630022EB70227B10C833C8C933C9335007C36F
+:101F73009AC3DBF280069A50012ADBEAC833F4C81D
+:101F8300C933F4C9FA2275F008E4C833C8C933C9A0
+:101F930033C99AC99B5004C92AC93BD5F0ECFBC885
+:101FA30033F4C8E4C9FA22600D08C6A2E713C618C1
+:101FB300C613C6D5E0F322600C08C6C313C618C601
+:101FC30013C6D5E0F422700422600D18C6C333C6CD
+:101FD30008C633C6D5E0F41822251810AF08F51843
+:101FE300400215198008F51840021519D2AF22C016
+:101FF300D0251810AF08F518500205198008F518F8
+:1020030050020519D2AFD0D0222518F58210AF089F
+:10201300F518400215198008F51840021519D2AFBA
+:1020230085198322C5822518C582C583351910AF4A
+:1020330007F5198582188007F519858218D2AFC56F
+:1020430083222518F582E43519F58322E4732518D4
+:10205300C582C0E0E51934FFC583C0E0E518C39528
+:102063008224F810AF088583198582188008858338
+:1020730019858218D2AFCEF0A3E520F0A37808E645
+:1020830008F0A3DEFAEFF0A3E58124FAF8E608F0FE
+:10209300A3E608F0A3E608F0A30808E608F0A3E621
+:1020A30008F0A315811581D0E0FED0E0F815811565
+:1020B300811581E8C0E0EEC0E0222518C582C0E0AA
+:1020C300E51934FFC583C0E0E518C3958224F910F0
+:1020D300AF0885831985821880088583198582183E
+:1020E300D2AFCEF0A3E520F0A37808E608F0A3DE94
+:1020F300FAEFF0A3E58124FBF8E608F0A3E608F085
+:10210300A30808E608F0A3E608F0A315811581D01B
+:10211300E0FED0E0F815811581E8C0E0EEC0E022D2
+:10212300851983851882E0A3FEE0A3F5207808E0F3
+:10213300A3F608DFFAE0A3FFE0A3C0E0E0A3C0E05A
+:10214300E0A3C0E0E0A3C0E0E0A3C0E010AF0885D7
+:1021530082188583198008858218858319D2AFD0A8
+:1021630083D082020122851983851882E0A3FEE0D1
+:10217300A3F5207808E0A3F608DFFAE0A3FFE0A3C5
+:10218300C0E0E0A3C0E0E0A3C0E0E0A3C0E010AF84
+:10219300088582188583198008858218858319D25A
+:1021A300AFD083D08222C0D02518C582C0E0E51904
+:1021B30034FFC583C0E0E518C3958224F310AF084C
+:1021C3008583198582188008858319858218D2AF83
+:1021D300C8F0A3E9F0A3EAF0A3EBF0A37908E709B9
+:1021E300F0A3D8FAECF0A3EDF0A3EEF0A3EFF0A385
+:1021F300D0E0F0A3D0E0F0A3D0E0F0A3E520F0A37B
+:10220300E5F0F0A322851983851882E0C0E0A3E0FE
+:10221300F9A3E0FAA3E0FBA37808E0F608A3DFFA4A
+:10222300E0FCA3E0FDA3E0FEA3E0FFA3E0C0E0A386
+:10223300E0C0E0A3E0F5D0A3E0F520A3E0A3F5F030
+:1022430010AF0885831985821880088583198582D4
+:1022530018D2AFD082D083D0E0F8D0E032740480BB
+:1022630006740280027401C0E0F40412200CD0E072
+:10227300121EE2227404800474028000CCC0E0EDDC
+:10228300C0E0E518C39CCCAD1950011D10AF068CFE
+:10229300188D1980068C188D19D2AF121EEFD0E05D
+:1022A300FDD0E0FC22D083D082E9C0E0E493A3C355
+:1022B30086F0C5F095F0F908E493A386F0C5F09590
+:1022C300F0700BE493A3C3994005E9048002A3E4EF
+:1022D30075F002A42582F582E5F03583F583D0E01D
+:1022E300F9E493A3C0E0E493C0E022D083D082EC6E
+:1022F300C0E0EDC0E0E493A3FCE493A3FDED4C60E8
+:102303000D12233AEC24FFFCED34FFFD80EFE49340
+:10231300A3FCE493A3FDED4C600D122379EC24FFA1
+:10232300FCED34FFFD80EFD0E0FDD0E0FCE493A3AF
+:10233300C0E0E493C0E022C0E0C3E49396087401D4
+:10234300939618400FE49366700808740193661817
+:1023530070007019A3A3C3E49396087401939618AD
+:10236300A3A3400DD0E0D0E0D0E002232AA3A3A38F
+:10237300A3A3A3D0E022C0E0C0F088F0E49366708A
+:10238300080874019366187000A8F0A3A3700BD01B
+:10239300F0D0E0D0E0D0E002232AA3A3D0F0D0E035
+:1023A30022FFFFFFFFFFFFFFFF74F51220BDEAFED0
+:1023B300EBFFEE2434F8EF3400F988088909EE24A2
+:1023C300351224E4F8EE24371224E4F50AEC850AE6
+:1023D300F0A4FCAAF0850AF0EDA42AFDE82CF8E4A9
+:1023E3003DF97A257B00121F51EA8508828509830E
+:1023F300F05407F87401B800028004C333D8FCC05A
+:10240300E0E0131313541FF8EE28F8EF3400F9E853
+:10241300245DF582E93400F583D0E0F8E0586008E4
+:10242300850882850983801DEE24361224E4F5F0A5
+:10243300EA84A8F0EE28F8EF3400F9E82438F582AE
+:10244300E93400F583E0F97F0402216974F5122071
+:10245300BDEAFEEBFFEE24341224E4C0E0EE2435A3
+:10246300F582EF3400F583D0E0F08E828F83A3A34F
+:10247300A3A3A3E0FAA3E0FB8E828F83A3A3A3A36A
+:10248300A3A3A3E0FCA3E0FDECC39AF50AED9BF53F
+:102493000BEE2480F508EF3400F509850882F583F7
+:1024A300E06401702BEE2481F582EF3400F5831292
+:1024B300227B1224ED7402121FF2E960137C7D7DEE
+:1024C30005EEFAEFFB120C3F850882850983E4F0E1
+:1024D300AC0AAD0BEEFAEFFB1223AC122A40022436
+:1024E3004AF582EF3400F583E022C082C083851869
+:1024F30082851983E0F8A3E0F9C3EA9CEB9D5012AF
+:10250300C3EC98ED994019C3EA98EB9950127901FD
+:102513008010C3EA98EB9940F5C3EC98ED9950EE1F
+:102523007900D083D08222EAC39CFAEB9DFB220080
+:10253300008521878522C622C0E074EF1221A97588
+:102543009B00906182E0A2E640030225FCE591A294
+:10255300E640030225FC7591BF900442E0640570D8
+:1025630008120DDD120DE98003120DE3752100122F
+:102573000E4FE9900443F07900120E43120BA97A2F
+:10258300017B00900441E0F9121113907803E06499
+:102593004260030226459005DFE014F06003022643
+:1025A30045C2AF1225A900782AD0E0F618D0E0F68C
+:1025B300E59F5407F97005908F828003908F2678EA
+:1025C30008121EACE9C4C0E07829E65508F50808EE
+:1025D300E65509F509740B7808121FBAD0E02508EF
+:1025E300F8906270E0A2E740F8E8C333906272F0BB
+:1025F300906270E0D2E0F08049E0A2E55024E591DA
+:10260300A2E5501E7591DF900442E0640D701390B3
+:102613000464E004F064287002E4F07A00E0F91244
+:102623000EC1906181E0A2E35009E5E9A2E3500302
+:1026330075E9F7A3E0A2E75009E591A2E750037516
+:10264300917F7F04022208C0E0C0D0C082C0839083
+:102653006183E0A2E05009E5BFA2E0500375BFFE2D
+:10266300E0A2E15009E5BFA2E1500375BFFDE0A27E
+:10267300E25009E5BFA2E2500375BFFBE0A2E350BD
+:1026830009E5BFA2E3500375BFF7E0A2E45009E5F3
+:10269300BFA2E4500375BFEFE0A2E55009E5BFA276
+:1026A300E5500375BFDFE0A2E65009E5BFA2E6509F
+:1026B3000375BFBFD083D082D0D0D0E032C0E074E6
+:1026C300F21221A9E5A7A2E4500FE5A1A2E4500963
+:1026D30053A7EF75A1EF122714E5A7A2E5500CE568
+:1026E300A1A2E5500653A7DF75A1DFE5A7A2E1503C
+:1026F30009E5A1A2E1500375A1FDE5A7A2E2500CF3
+:10270300E5A1A2E2500653A7FB75A1FB7F010222BC
+:102713000874F81220BD752101900442E06406702C
+:10272300077A007B00120DC5A2AFE433FED2AF904F
+:102733000448E0640170187A207B00900441E0F9BA
+:102743001211917A207B00900441E0F91211199043
+:102753006182E0D2E6F09005DEE0602185C622804A
+:1027630016900447E064017008E5C654F84405F583
+:10277300C653BEFC1225347401652160E4EEA2E069
+:1027830092AF7F0102216900008E238F2485822866
+:10279300858327851882851983E0CEA3E0CF85281A
+:1027A30082852783EBC9EAC8EDCBECCA75F010C369
+:1027B300E833C8E933C9EA33CAEB33CBC3EA9EF53E
+:1027C30026EB9FF525B35004AB25AA26EC33CCEDBD
+:1027D30033CDD5F0DAAE23AF242274F11220BD8AB3
+:1027E300088B098C0A8D0B740F122045780C121E6E
+:1027F300AC908F367808121E86908F36780C121E96
+:10280300867808790C1214DE50157808790C121E9C
+:102813005E908F2278081214FE4015790180137898
+:102823000C7908121E5E908F22780C1214FE40EB76
+:1028330079007F0802216974ED1220BD8A088B0993
+:102843008C0A8D0B7413122045780C121EAC908FDA
+:10285300367808121E86908F36780C121E86780CF6
+:1028630079081214DE40117808790C121E5EAA084A
+:10287300AB09AC0AAD0B80227510007511007512FF
+:10288300007513017810790C121E5E781079081206
+:102893001E25AA10AB11AC12AD137F0C0221699057
+:1028A3008F367808121EAC8A828B837808121E99A1
+:1028B3007F0402216974F51220BD8C828D83780810
+:1028C300121EAC8A828B837808121E7212290CC3E3
+:1028D300E098F0A3E0991228FE401E908F627808DA
+:1028E300121EAC8A828B837808121E4B8E828F83D2
+:1028F300E02420F0A3E0344EF080A4F08E828F8396
+:10290300C3E09420A3E0944E22EA2404F8EB3400BD
+:10291300F9E8FEE9FF8C828D83A3A3A3A3E0F8A3C8
+:10292300E0F98E828F832274F51220BDE9FE9005B3
+:1029330094E0FAA3E0FBEEC333F8E433F9749D2883
+:10294300F582748E39F583E02AF508A3E03BF50997
+:102953007808122264908F6A121ECA12278C74029E
+:10296300121FF28A088B098C0A8D0B7410780812D7
+:102973001DEDAA08AB097F0402216974F11220BD81
+:102983008A0C8B0D8C0E8D0F740F122045E0FAA369
+:10299300E0FB7411122045E0F508A3E0F509741378
+:1029A300122045E0FEA3E0FF7808122264EA240126
+:1029B300F508EB3400F509E4F50AF50B780C790812
+:1029C300121CE9908F2E7808121EAC780C7908122D
+:1029D3001CE9AA0CAB0DAC0EAD0F12278C740212BE
+:1029E3001FF28B09EA450960047A0180027A00EC40
+:1029F3002AFCED3400FDECF8EDF97A717B02121F2D
+:102A03005188088909E4F50AF50B8E828F837808CB
+:102A1300121EBBECF8EDF97A717B02121F518A0882
+:102A23008B0974057808121FC98E828F83A3A3A311
+:102A3300A3E508F0A3E509F07F08022169C082C07D
+:102A430083E9906000F0D083D08222C0E074F21258
+:102A530021A9A2AFE433FED2AFC2C0E5D1A2E450B4
+:102A63000653D1EF12135FEEA2E092AF7F01022271
+:102A730008C0E0C0D0E8C0E0E5A8D2AFC2C7A2E773
+:102A830092AFD0E0F8D0D0D0E032C0E0C0D0E8C000
+:102A9300E0E9C0E0C008C009C082C083A2AFE4334C
+:102AA300F9D2AF900C4FE0F8A3E0687008539AF79F
+:102AB300A374018026C2EA900C4FE0F50874012547
+:102AC30008F0741D2508F582740C3400F583E0F5D5
+:102AD300F9900C4FE0C394324002E4F0E9A2E09293
+:102AE300AFD083D082D009D008D0E0F9D0E0F8D0BD
+:102AF300D0D0E032C082C083E9900EEAF0022D7B91
+:102B030074F7122051E9900360F07C987D037AFFFB
+:102B13007BFF1208CD90036174FFF0A3F0A3E4F0F0
+:102B2300A3F07905120855900360E0F912077D7A46
+:102B3300EB7B08120AA7023A8974F41220518A081F
+:102B43008B09EB54806030900360E0F91210FB8A2C
+:102B53000A8B0BAE0AAF0BEE4F60138E828F83E0AE
+:102B630064B0700312086DEEFAEFFB1210E9AA08C5
+:102B7300E5096480FB80047A007B00022D4A74F22D
+:102B830012205174FC121FDCEAFEEBFF74121220B8
+:102B930045123F70EE4F7003022C2474021220453D
+:102BA300EEF0A3EF122F85ECF0A3ED122F85AA828E
+:102BB300AB83120777E9F50A706AE5084509606493
+:102BC3008E828F83123F56EE4F60567A067B001239
+:102BD300114F8A0C8B0DA80CA90DE8497005750AD5
+:102BE30013804188828983E4122C31EEF0A3EF1223
+:102BF3003F81E508F0A3E509F0900366122CB89035
+:102C030003667005123A33801B123A218003EAFCF3
+:102C1300EBFD8C828D83122CB870F38C828D8380B4
+:102C2300E3750A02A90A7404121FF2024170F0A3A9
+:102C3300123F27A32274F2122051890AE975F01773
+:102C4300A4FEAFF0900365E4F0900363122CB86028
+:102C53000A121155900363E4F0A3F0EEFAEFFB12AE
+:102C6300114F8A088B09EA4509602FEEFCEFFD79C5
+:102C7300001210D7900363E508F0A3E509F07B0089
+:102C83008008122CA2E4F0A3F00BEBC3950A40F2E8
+:102C9300E50A900365F0790080027913024170EB35
+:102CA30075F017A4F8A9F0900363E028FAA3E039BC
+:102CB3008A82F583221236C5EA4B2274F41220511C
+:102CC300740C122045123F4BFEE9FF75080075098D
+:102CD30000800CE5082401F508E5093400F509C373
+:102CE300E5089CE5099D503285080A85090B7403A4
+:102CF300780A121FC9EA250AF8EB350BF98882898D
+:102D030083A3A3A3A3A3A3123B08EE650A7003EF57
+:102D1300650B70BFE8FAE9FB80047A007B0080272B
+:102D230074F41220517900EAA2E0501B7508DC7597
+:102D3300098E78081222647C047D007AEC7B0E12E3
+:102D4300084F7402121FF27F04022123C082C08342
+:102D5300900366122D82601C88828983A3A3E06A94
+:102D63007003A3E06B8882898370E8A3A3A3A312F3
+:102D730036C180047A007B00D083D0820201221204
+:102D83004256E8492274EE12205174FC121FDCEA09
+:102D9300FEEBFF851882851983E4F0A3F0EE24028D
+:102DA300123A13EE2405123F2EEE2404F50EEF1211
+:102DB300333AE024FE603924FC604624FE6052244A
+:102DC300FE605E24FE7003022E9B24FE7003022E1F
+:102DD300FF24FE7003022F0E24FE7003022F1D2416
+:102DE300FC7003022F2C24FE7003022F3B022F786A
+:102DF30090037F7417F0A3E4122F8D1204F5022FB2
+:102E030078851882851983AC82AD83120873022FEB
+:102E130048851882851983AC82AD83120879022F05
+:102E230048850C08850D097402122045AC82AD83D8
+:102E33008508828509831236C112079B8A0C8B0D84
+:102E4300AC0CAD0DEC4D603BE4F50CF50D780C12BC
+:102E53002264750C7F750D03780C122264750C8047
+:102E6300750D03780C122264740812204512227B1C
+:102E73001243D2121FF2E9F50C700B1236B712058A
+:102E83000D800F750C01850882850983122F7B1233
+:102E93003A33850C08022F4B7402122045AC82ADE5
+:102EA30083850C82850D8312348C603C850C82856E
+:102EB3000D83A3A312227B75107F75110378101263
+:102EC300226475108075110378101222647408123D
+:102ED300204512227B1243D2121FF2E9F509700B2F
+:102EE3001236B7120513800F750901850C82850D03
+:102EF30083122F7B123A33850908804C851882850B
+:102F03001983AC82AD8312087F803A8518828519B4
+:102F130083AC82AD83120885802B85188285198343
+:102F2300AC82AD8312088B801C851882851983AC13
+:102F330082AD83120891800D851882851983AC8236
+:102F4300AD83120897E9F508E50860298E828F831F
+:102F5300A3E06414601F850E82850F83E090037FD6
+:102F6300122F85124252900380123A33E508A312BE
+:102F73002F8D1204EF0239221242568518828519C9
+:102F83008322F085188285198322F07C7F7D038557
+:102F93000A82850B831236C52274EE12205174FC0B
+:102FA300121FDC8A0A8B0B8C0E8D0FEA2405F508A1
+:102FB300EB3400F5097C157D0079007A7F7B0312E1
+:102FC30010D7E5082402F50CE509123F3185188274
+:102FD30085198385821085831178101222648508F0
+:102FE30082850983A3A3A3A3123483122264E50871
+:102FF3002405F510E5093400F511781012226485D3
+:103003000C82850D831237D81207957406121FF2AE
+:103013008A108B11AE10AF11E50A2402F50AE50BF5
+:10302300123A16EE4F700302315A801774021220BF
+:10303300451236C188828983EAF0A3EBF090037FBF
+:10304300E004F090037FE0C39405400302315AE4A7
+:10305300F510F51178101222647510687511037854
+:1030630010122264751069751103781012226474AA
+:103073000612204512227B7910EEFCEFFD1243D499
+:10308300121FF2E9705E850882850983A3A3A3A3B7
+:10309300A3A3A3E0F8900368E06870481234831296
+:1030A30022647C697D03E5082408FAE5093400FB02
+:1030B3001210D17402121FF2E960298E828F83A34A
+:1030C300A3A3A31236C190037FE0F5107402781016
+:1030D300121FC974802510F58274033511F583EA34
+:1030E300F0A3EBF0740212204585821085831178DA
+:1030F30010122264740212204512227B850C8285F1
+:103103000D831236E7121FF28A108B11AE10AF1126
+:1031130090037FE0F51075110074027810121FC937
+:10312300747F2510F874033511F988828983A312FB
+:103133002CB87003023026E82403080808E9340099
+:10314300F9EE4F600302302F8882898374FFF0A366
+:10315300F090037FE004F090037FE0600A1236B73B
+:103163001205017900800B850882850983123A2AAA
+:10317300790A02392274EA12205174FE121FDC8C80
+:10318300128D13EA2405F50CEB1243BC123F5A755A
+:103193000800750900EA2402F510EB3400F51185E7
+:1031A300188285198385820A85830B780A12226423
+:1031B300850C82850D83A3A3A3A31233501222642B
+:1031C300E50C2405F50AE50D123A16780A12226475
+:1031D300850C82850D831233541207957406121FD2
+:1031E300F28A0A8B0BEA450B70030232F5EA2404D8
+:1031F300F50EEB12333A123F5A8A828B83A3A3A3B1
+:10320300E0F98510828511831236CB60030232F513
+:10321300E4F514F515781412226475146875150312
+:1032230078141222647514697515037814122264D4
+:10323300740612204512227B7913AC0AAD0B85105C
+:10324300828511831243DA121FF2E9F50960030242
+:1032530032F5900368E0F8E5087009E02402900372
+:1032630080F08014900380E0FCE82402FAE4340048
+:10327300FBEA6C7001EB707E850882AA8212347AB5
+:103283009414123472506B850E82850F83E0C0E074
+:1032930074812A123331D0E0F00508850E82850F40
+:1032A30083A3E0C0E085080A7481250A123331D074
+:1032B300E0F005089003681233501222647C697DA4
+:1032C3000385080A7481250A123344121FF29003FE
+:1032D30068E02508F50874FF6E700374FF6F6012D1
+:1032E300EE24010EEF3400FFE508C39414500302EB
+:1032F30031A2E50860131236D58510828511831239
+:1033030036C112050779008014E509700375090AAF
+:10331300851282851383EEF0A3EFF0A909740212DC
+:103323001FF27F0E02212385080C7481250CF58280
+:1033330074033400F583223400F50F850E82F58380
+:1033430022FA74033400FB1210BF740222123F905E
+:1033530022A3A312335A22123A21FDEEFAEFFB22E3
+:1033630074EE12205174FE121FDC8C0E8D0FEA24B2
+:1033730005F50CEB123F31750B0090037FE4F0F57C
+:103383000AEA2402F508EB3400F509804490037F30
+:10339300E0FA900368E0F812347A9417123472401A
+:1033A3000D90037FE0F87416C398900368F012340D
+:1033B300831222647C697D0374802AFA74031233B6
+:1033C30047121FF2900368E0F890037FE028F005AE
+:1033D3000AE50C2416F582E50D123335E0F8E50A0B
+:1033E300C398507490037FE0C39416506BE50AC3EF
+:1033F30033F8E433F9E50C28FEE50D39FF8518822F
+:10340300851983AC82AD838E828F8312348C7008CE
+:10341300750B01123A268050E4F510F5117810125D
+:10342300226475106875110378101222647510698F
+:103433007511037810122264740612204512227B40
+:1034430079168508828509831243DA121FF2E9F59A
+:103453000B700302339080BB7C7F7D0385088285DC
+:1034630009831236C1120519A90B7402023924E922
+:103473009400C365D03322EA28F8E43400F9E82243
+:10348300E0F5107511007810221239198A108B118A
+:10349300AC10AD11EC4D2274EA12205174FC121FD2
+:1034A300DC8A0C8B0D8C128D13EA2405F50AEB12C2
+:1034B3003A16750800750900E50A2402F510E50BB4
+:1034C3003400F511740212204585820E85830F782E
+:1034D3000E122264850A82850B83A3A3A3A3123F42
+:1034E30036122264E50A2405F50EE50B3400F50FC8
+:1034F300780E122264851082851183123A1C1236CB
+:10350300BB1207957406121FF28A0E8B0FAE0EAF15
+:103513000FE50C2402F50EE50D3400F50F80388815
+:1035230082898374FFF0050812332A74FFF00508BB
+:10353300900368E0F50C750D00780C1222647C6929
+:103543007D0385080C7481250C123344121FF290FD
+:103553000368E02508F508EE4F60278E828F83A36A
+:10356300A3A3E0F9850E82850F831236CBEE2404E4
+:10357300123F2EE96027850C82850D831236AD122A
+:103583003A33E50870030236931236D5850E8285E9
+:103593000F831236C112051F79000236A8E4F51411
+:1035A300F5157814122264751468751503781412CE
+:1035B3002264751469751503781412226474081251
+:1035C300204512227B7911EEFCEFFD850E82850FDB
+:1035D300831243DA121FF2E9F509709A850882AA69
+:1035E30082EA9003687009E02404900380F0802548
+:1035F300E0F8900380E0F514E82404FCE43400FDD3
+:10360300EC65147001ED708112347A9412123472E5
+:10361300400302358C850C82850D83E0C0E0748104
+:103623002A123331D0E0F00508850C82850D83A37F
+:10363300E0C0E012332AD0E01236F085820C858395
+:103643000D780C122264740412204512227B85101B
+:10365300828511831236E7121FF28A0C8B0DAE0C92
+:10366300AF0D85080C7481250CF874033400F9EE52
+:103673004F7003023522851882851983E088828979
+:10368300831236F0A3E0C0E012332AD0E0023530D3
+:10369300E509700375090A850A82850B831236AD25
+:1036A300123A33A909740402332212425685128254
+:1036B300851383227C7F7D03850A82850B831236E3
+:1036C300C522E0FAA3E0FB221236C5120783E9F50F
+:1036D3000922900380E0F5F0E5088490037FF07CF5
+:1036E3007F7D032212335A1207A1740422F00508C6
+:1036F3008518828519832274EC12205174FE121FDF
+:10370300DC8A088B098C0E8D0FEA2405FEEB34004E
+:10371300FF123903EE2418123F2EEA450B70030201
+:1037230037A61238EC50291237CB8A108B11EA4591
+:1037330011606B7912AC0AAD0B850882850983127F
+:1037430036C185108285118312204FE9F50A70581E
+:10375300E4F50AF50B780A1222648E828F83A3A301
+:10376300E0F50A780A122264EE2403123A13780A67
+:103773001222648E828F831237D81208BB7406120A
+:103783001FF2E9F50A7021850C82850D83E0701F15
+:103793008508828509831236C11205258011750AB1
+:1037A3000E8009750A018004E50A6003123A268532
+:1037B3000C82850D83E0600479008002A90A7402FB
+:1037C300121FF27F0C02212385188285198312367A
+:1037D300C51208A922123A21FD85088285098312A0
+:1037E30036C52274EE12205174FE121FDC8A088B38
+:1037F300098C0C8D0DEA2405FEEB3400FF750E00D9
+:10380300123903EA450B70030238CA1238EC502C04
+:103813001237CB8A0E8B0FEA450F604A7912AC0A36
+:10382300AD0B8508828509831236C1850E82850F0B
+:103833008312204FE9F50E60030238CD8508828597
+:103843000983123B08AA0AFB1238DE70147AFF7B45
+:10385300FF1238DE606C88828983E50AF0A3E50BEA
+:10386300F0750A008007750E0E805F050A900365E8
+:10387300E0FAE50AC39A504AE50A75F017A4FAABD1
+:10388300F088828983A3A3E02AFAA3E03BFB8A8220
+:103893008B83123A1CEC4D70D2750A17750B0078A6
+:1038A3000A122264EEFCEFFD1210BF7402121FF223
+:1038B300EEFCEFFD8508828509831236C112052BC4
+:1038C3008014750E098003750E0112424E850C8219
+:1038D300850D83123A33A90E02346D12089D8A10A6
+:1038E3008B11A810A911E84922E5082402F508E57F
+:1038F300093400F5098A828B83A3A3A3E0A2E522FE
+:10390300851882851983AC82AD838E828F831239A9
+:10391300198A0A8B0B22E0FAA3E0FB12079B22749D
+:1039230004121FF27F0A02212374EC1220518C101F
+:103933008D11EA2405F50CEB123F31750F00EA24D3
+:1039430002F50AEB123A16850A82F5831236C11282
+:1039530044607003023A08750E008071850C8285FD
+:103963000D83E06401704F8E828F83A3A312227BA9
+:103973008E828F83A3A3A3A3E0F51275130078129D
+:10398300122264EE2405F512EF3400F513781212B7
+:1039930022641236BB1208BB7406121FF2E9F50F3C
+:1039A3006014850C82850D83E4F012424E851082EB
+:1039B300851183123A337C177D007900EEFAEFFB11
+:1039C3001210D78E828F83E4F0A3F0050E90036567
+:1039D300E0F8E50EC398501EE50E75F017A4F8A99C
+:1039E300F0850882850983A3A31243C6123A1CEC0F
+:1039F3004D600302395F85088285098374FFF0A354
+:103A0300F0E50F70061236BB120531A90F0237C657
+:103A1300F50AEF3400F50B22A3123A21FD22E0FC54
+:103A2300A3E0228E828F83124256850E82850F83F6
+:103A3300E8F0A3E9F022C082C083900361E06A70DA
+:103A430003A3E06B70067A617B0380047A007B003A
+:103A5300022D7B74F71220517F00EF75F003A4F859
+:103A6300A9F0EC28F8ED39F988828983E06A7003BC
+:103A7300A3E06B7006E8FAE9FB800B0FEFC3940237
+:103A830040D87A007B007F0102212374F612205173
+:103A930012403F70067A007B008007A3A3A3A31202
+:103AA30036C102410074F2122051E9FE740E122055
+:103AB30045123B087410122045123F708C828D838F
+:103AC300E06402703BA312425288828983E0F50CC2
+:103AD300A3E0F9A80C740268700374296970217556
+:103AE3000C02750D00780C12226478081222647897
+:103AF3000A122264EEF91208DF7406121FF2800222
+:103B03007901024170E0F50AA3E0F50B2274E81293
+:103B1300205174FB121FDCE9851882851983F08A12
+:103B2300168B178C0E8D0F741F122045123F707465
+:103B330021122045123B087423122045123F5A7567
+:103B430010008C828D83A3A3A3E0A2E4502A741DEA
+:103B53001220451237D18A828B83E5824583700315
+:103B6300023C1C790AAC0EAD0FAA16AB1712204FFC
+:103B7300E9F5106003023C1F850E82850F83E06424
+:103B8300026003023ED5A31242528508828509834F
+:103B9300A3858212858313E50E2406F50CE50F1227
+:103BA3003F3188828983E0FAA3E0F9EA2400F5141F
+:103BB300E439F51578141222EE010000280128E4F7
+:103BC3003B07000228BB3C03282B3C0029E53D01B1
+:103BD300290D3E0229B43D0329E53D0429763ED54E
+:103BE3003EEE4F703E850C82850D83123F4BFAE902
+:103BF300FB8A828B83E0850A82850B83123F8712BF
+:103C030022648A828B83A3123A21FDAA08AB09128C
+:103C130010BF7402121FF2800375100EA9107405F1
+:103C23000243B475100B80F4EE4F70F7850A82855A
+:103C33000B837401F0123F60850882850983F07C51
+:103C4300007D00850E82850F83A3A3A3A3E0240137
+:103C5300FAA3E03400FB12079BEA4B60418A828B94
+:103C630083E02402F8850A82850B83E028F0EA24A6
+:103C730004F8EB3400F988828983E0851282851386
+:103C830083123F99123F871222648A828B83123AEE
+:103C93001BE5082403FAE5093400FB023C12850AFC
+:103CA30082850B83E02404F07C047D007900AA1252
+:103CB300AB131210D7023C1FEE4F6003023C2612D7
+:103CC3003F60FEA3E0FF850A82850B837404F0EE58
+:103CD300850882850983F0EF851282851383F0744A
+:103CE30003122045AC82AD83EEFAEFFB12402D7038
+:103CF30003023D918A828B83A3A3123F5674011260
+:103D0300204585820E85830F780E12226474051276
+:103D1300204512227B7CFF7DFF1207A17404121F32
+:103D2300F28B0FEA450F7033850C82850D83123FAA
+:103D330036122264850C82850D83A312227B7C02BA
+:103D43007D007AB37B8F1205CD7404121FF2E970E4
+:103D53000A740112204574FFF0A3F08E828F83E072
+:103D630064027034750C02750D00780C1222648E97
+:103D7300828F83123A1BE5082404FAE509123347BC
+:103D8300121FF2850A82850B83E0240280097401E5
+:103D9300122045EEF0A3EFF07401122045123F47C5
+:103DA300F07401122045A3123F3FA3A3A3F0023CEA
+:103DB3001FEE4F6003023C26850C82850D83123A69
+:103DC3001CAA16AB171208D3850A82850B837402CB
+:103DD300F0EA850882850983F0851282851383EBD7
+:103DE30080CBEE4F6003023C26123F60F8A3E0F95C
+:103DF300850A82850B837402F0E88508828509832E
+:103E0300F0E985128285138380A3850C82850D8357
+:103E13001236C11210B9EAFC8C82A882C39EE49FB9
+:103E2300404BE86E7001EF70047C00801F851882A0
+:103E3300851983E0FAEE2AFAEF3400FBC3EA98EB24
+:103E430094005003E08004EECCC39CFCEC850A8212
+:103E5300850B83F08C0A750B00780A122264850C9B
+:103E630082850D83E02EFCA3E03F023C0D75100715
+:103E7300023C1FEE4F6003023C26850C82850D83B6
+:103E8300124252850A82850B837407F088828983E4
+:103E9300123F3F123F27E0851282851383F0E82407
+:103EA30002FAE93400FB8A828B83123F3F123F7888
+:103EB300123F47A3123F81123F50F0E82405F8E96F
+:103EC3003400F988828983123F50A3123F99A302D9
+:103ED3003DAD741D1220451240387003023C1C1284
+:103EE3004252880C890DE8450D7003023C1C8E106C
+:103EF3008F117810122264780A1222647808122231
+:103F0300647406122045E0F9AC0EAD0FAA16AB1788
+:103F1300850C82850D8312204F7406121FF2E9F57A
+:103F230010023C1FF088828983A322F50CEF340032
+:103F3300F50D22E0F50E750F00780E22E08508825C
+:103F430085098322123FA022124256E822123FA083
+:103F5300A3A322A3A3A3A3E0FEA3E0FF22850C82D5
+:103F6300850D83E0F8A3E0F5838882E022E0F5087D
+:103F7300A3E0F50922A3A3F08A828B83A322122C48
+:103F830033A3A322F08A828B83123F9022E0F50AA7
+:103F9300750B00780A22123F27123FA022E0850802
+:103FA30082850983A3A32274EE12205174FE121F8B
+:103FB300DC8A0A8B0BECFAEDFB7414122045E0F556
+:103FC30010A3E0F5117416122045E0FE74181220B8
+:103FD30045E0F50EA3E0F50F851882851983AC82C1
+:103FE300AD8312402D603E851882851983124038B7
+:103FF300602FA3A3123F70E50845096024780E12D1
+:1040030022647810122264EEF9AC0CAD0DAA0AAB4F
+:104013000B85088285098312204F7404121FF280D6
+:1040230006790E8002790102346D12079B8A0C8B8C
+:104033000DEA450D221236C512403F221208678A47
+:10404300828B83E58245832274F612205174FE121B
+:104053001FDC740C122045123F4B8518828519838F
+:10406300F07401122045E9F0E4F508F50978081227
+:1040730022647508027808122264740412204585AC
+:10408300820885830978081222641208BB74061219
+:104093001FF27402121FF2806474F7122051EAFEB9
+:1040A300EBFF89087C987D031208D3EA5402600B66
+:1040B300A908EEFAEFFB12078F80027901023A8911
+:1040C30074F612205174FF6A700374FF6B701C7BCB
+:1040D30000EB75F003A4F8A9F0EC28F8ED39F91218
+:1040E30041050BEBC39402501480E61208A38A081F
+:1040F3008B09A808A909E84960031241057F020258
+:1041030021238882898374FF122C31E4F02274F610
+:104113001220511208A38A828B83E58245836006AD
+:10412300A3A3E0FA80027A007B0080D174F212200C
+:10413300518A088B09ECFEEDFF740E122045E0F561
+:104143000A124175701CEEFCEFFD7AFF7BFF1241F2
+:104153007570047911801688828983E508F0A3E5D8
+:1041630009F088828983A3A3E50AF079007F060218
+:1041730021231208A38A0C8B0DA80CA90DE8492250
+:1041830074EE122051EAFEEBFF8C088D09890C7442
+:10419300121220451242527414122045123A1C7412
+:1041A300161220451236C1750D00EC4D6003024214
+:1041B300467402650C600302424188828983123A85
+:1041C30021F9EC2400F50EE439F50FEAF4F8EBF4E9
+:1041D300F9EC58F8E50F59F9E849705DE50824064C
+:1041E300F8E5093400F9880A890B8882F5831233CC
+:1041F300561208D38A108B11E50E65107004E50F73
+:1042030065116042780E122264850A82850B83123F
+:1042130033561208D97402121FF2E9F50D7027788C
+:104223000E122264850882850983A3A312335412D4
+:1042330008F17402121FF2800D750D808008750D50
+:104243000D8003750D0BA90D0239278E828F831202
+:10425300425622E0F8A3E0F92274E812205174E7F1
+:10426300121FDC851882851983EAF0A3EBF08C1604
+:104273008D17890E7431122045E0F512A3E0F51372
+:104283007433122045E0F514A3E0F51574351220BC
+:1042930045E0F50F750800750900E50975F003A4FD
+:1042A300F8A9F08518828519831243C6E0F47003D8
+:1042B300A3E0F470030243A4EE2402F50CEF1243CF
+:1042C300BCE070030243A485160A85170B780A1213
+:1042D3002264AC14AD15AA12AB1312085B7402125C
+:1042E3001FF28A0A8B0BEA450B70030243A4E4F521
+:1042F30010F511781012226474061220458582107D
+:104303008583117810122264740912204585821066
+:104313008583117810122264851282851383A3A3E7
+:10432300A3A312227B7914AC0AAD0B8E828F831266
+:1043330043DA121FF2E97069850A82850B83A3A30E
+:10434300A3A31242527402122045123A33850C82FF
+:10435300850D83E0A2E05018A90E7402122045AC2B
+:1043630082AD838E828F831236C11207B3E942086E
+:10437300850C82850D83E0A2E15026E50FF50A78CE
+:104383000A122268A90E7403122045AC82AD838EF3
+:10439300828F831236C11207AD7401121FF2E942F4
+:1043A300080509E509C39402500302429DA9087454
+:1043B30019121FF27F100221233400F50D850C82A0
+:1043C300F58322E028FEA3E039FF8E828F832279D2
+:1043D30016850A82850B831236C51208B574082226
+:1043E30074F2122051EAFEEBFF890B7401650B6036
+:1043F3000E7402650B70637901120AC5E9705BEEF6
+:10440300FAEFFB1244606047750A00800B7C177D4E
+:104413000079001210D7050A900365E0F8E50AC396
+:10442300985021E50A75F017A4F8A9F0850882854C
+:104433000983A3A3E028FAA3E039FB8A828B8312C2
+:104443002D8270C985088285098374FFF0A3F07CEF
+:10445300987D03EEFAEFFB1208CD02417012089D1E
+:104463008A088B09EA45092274F21220518A088BC3
+:1044730009ECFEEDFF740E122045123B08900EEA84
+:10448300E0F4603D7A097B001210E3EA4B60328A64
+:10449300828B8374B1F0A3E4123F7AA3123F78A313
+:1044A300E508F0A3E5091244C7EEF0A3EF1244C7F1
+:1044B300A3A3E50AF0A3E50BF0900EEAE0F91210CE
+:1044C300EF024170F08A828B83A3A3A3A3A322C02C
+:1044D30082C0839061907404F0A37448F0A3E4F065
+:1044E3009061807440F09061BC7407F090618774B0
+:1044F30069F09061B67416F07900120BAF7902126D
+:104503000BB59023A8E493F46006E493F9120B8BA4
+:104513007905120EA3024914C082C083E9540FF92E
+:10452300906185E0696012E5C654804449F5C6E5AB
+:104533009E547F644970F8E9F053C680E59E547F2A
+:1045430070FA02491474F7122051E5A8FE53A87EAD
+:10455300120B97C2BA539AFEC289759B00C2C2124C
+:104563000B9D75A91175B905120BA3D2BA439A0114
+:1045730074805E42A8024EA1C082C083906181E430
+:10458300F0A302491175E90075910075BF0002019E
+:1045930022C082C083906181E4F0A374C0F0A3E4DD
+:1045A300024913C082C08374F8121FDC90044412C2
+:1045B3004D83E849700302465D900444E054406033
+:1045C300237908851882851983AA82AB83120CA5E7
+:1045D300851882851983AA82AB83120957900444F4
+:1045E300E054BFF0E054806010790C7A007B06122F
+:1045F3000CA5900444E0547FF0E0A2E05008790059
+:1046030012466554FEF0E0540260087901124665D3
+:1046130054FDF0E054046008790012467054FBF036
+:10462300E054086008790112467054F7F0E0541022
+:104633006008790212467054EFF0E0542060087964
+:104643000312467054DFF0A3E05401600D120BC156
+:10465300120969900445E054FEF07408121FF20237
+:104663004914120BAF12095D900444E022120BB5FA
+:10467300120963900444E022C082C083E9600514F8
+:10468300602A804F90619A7433F0A37455F090615F
+:10469300A0743AF09005DCE064017009C2919004C3
+:1046A300467467802D9004467461802690619A74E5
+:1046B3003FF0A3745AF09061A0747FF09005DCE0A2
+:1046C30064017009D2919004467471800590044688
+:1046D300746AF0024914C082C083E9600B14600D50
+:1046E30014600F14601180209023A480159023A5DB
+:1046F30080109023A6800B9005DCE0640160F390AA
+:1047030023A7E493906186F002491474EE122051BA
+:1047130074F4121FDC851882851983AC82AD83750E
+:10472300838F7582327404121EEF9023A493F46076
+:10473300030248A0907808E0C39402500302488023
+:104743007404122045AC82AD8375838E7582BB746D
+:1047530008121EEFF97AFF7BFF7FFF7E00898285B7
+:104763008210801874086E700302483574096E70E5
+:1047730003024835740A6E7003024835E510C333EB
+:10478300FCE433FD7404122045E5822CF582E583B5
+:104793003DF583E0F50EA3E0F50F8E08750900746F
+:1047A300027808121FC974482508FC74783509FD7E
+:1047B3008C828D837808121EAC74087808121DED64
+:1047C30085080C85090D8C828D837808121EAC74C4
+:1047D300187808121DEDE50C4508F508E50DF509F7
+:1047E300C3E50E9508E50F95098C828D8378081231
+:1047F3001EAC8C828D837808121EAC741878084026
+:1048030014121DEDE50C4508FCAD0DE50EC39CFC33
+:10481300E50F9D800F121DEDE50C4508C3950EFCB9
+:10482300E50D950FFDC3EC9AED9B5006ECFAEDFBFD
+:10483300EEFF0EEEC39413500302476774FF6A70D2
+:104843000374FF6B602D8F0874027808121FC974FC
+:104853004812552F74783509F5837808121EAC85F4
+:104863001882851983E5822510F582E5831252BCEF
+:10487300E508F009E9C39404500302475875080199
+:1048830075090078081222647402122045AC82ADC7
+:10489300837AE97B081212FF7402121FF2740C125E
+:1048A3001FF27F0A022123C082C083906186E0F851
+:1048B3009023A7E4936870099023A6E493906186FC
+:1048C300F09061AE7468F0A3746AF090624574FB73
+:1048D300F0A304F053F4FD43FE029005DC7401F0F1
+:1048E3009061A0E0643A7004790080027901120BB0
+:1048F300AF024914C082C08390058EE06401700A40
+:10490300900593E06004790C800279008003F0A3A2
+:10491300F0D083D082020122C082C08375E1F1907E
+:104923000591E0604D146008146051146049805192
+:10493300120BD3900587E0F97A887B05120E259038
+:104943008F2A121ECA120E5B908F46121ECA120EB7
+:1049530031900592E0F9120E3D7901120E97900500
+:1049630085E02416124AA974EBF0A3740BF07900C6
+:10497300809F120BD980BC120BDF80B7120BE5802E
+:10498300B2791280EB74F412205175D90D9005762B
+:10499300E0A2E0E4331313F8124A15484401F5D9B1
+:1049A3007800124A9340FB78008808747712552FD9
+:1049B3007405124A9D40F275E195900576E0F97A07
+:1049C300777B05120E2B900F0C7461F0A3740B12FE
+:1049D3004AB8124AD8124ACF124C10124A1F78080A
+:1049E300121EAC908F4A7808121E38908F367808C2
+:1049F300121E86124AA37808121EBB900585E02476
+:104A030014124AA97413F09004427402F07F040252
+:104A13002123900587E0C4333354C022900585E0F9
+:104A2300F8A3E0F5838882A3A32274F6122051121F
+:104A33004BE18AD97800124A9340FB780080061232
+:104A43004B47124C93E8C39940F5124BD3124A9348
+:104A530040FB7800800812552B7405124C93E8C371
+:104A63009940F375E195900F0C746DF0A3740B12DC
+:104A73004AB8124AC2121ECA124AA3121ED690057F
+:104A830085E02414124AA97412F0900442024E7E67
+:104A9300880874882508F5827405124DEF94062260
+:104AA300900585E0240EF8A3E0124AB0223400F901
+:104AB3008882898322124BF97467F0A3740B221244
+:104AC3004AD8124ACF124C14908F6222F0A3747FFB
+:104AD300F0A3740B22124ADC22124AE022F0A374E0
+:104AE30011F0A3740D2274F6122051124B3C124A9A
+:104AF300154402F5D97800124A9340FB78008006EA
+:104B0300124B47124C93E8C39940F575E195900F0A
+:104B13000C124B52F0A3124B52124AC5121ECA1268
+:104B23004AA3121ED6900585E02414124AA97414D0
+:104B3300F09004427404024E80900597E0F97407E4
+:104B430029F5D922880874982508F58274052274FA
+:104B530079124B5F124B5FF0A3740B22F0A3740B1B
+:104B6300F0A374792274F6122051124BE174064AB1
+:104B7300F5D97800124A9340FB78008006124B4720
+:104B8300124C93E8C39940F5124BD3124A9340FB5E
+:104B93007800800812552B7405124C93E8C3994092
+:104BA300F375E195900F0C7473F0A3740B124BEF34
+:104BB300124AC2121ECA124AA3121ED6900585E0DB
+:104BC3002414124AA97415F09004427403024E800F
+:104BD3009005B7124B3F74044AF5D9780022124B63
+:104BE3003C900587E0C4333354C0FA22124BF97466
+:104BF30011F0A3740D22124BFD22124C0A7411F012
+:104C0300A3740D124C0A22124AE0F0A322124C1490
+:104C130022F0900F1A7411F0A3740D124BFD74114E
+:104C2300F0A3740D124ADCF022C082C083124A1F23
+:104C3300A3A3A3A3E402491174F7122051125771DD
+:104C4300F8740439F9E82405FAE93400FB8A828B05
+:104C5300831254E088828983A3A3A3A3A3A3A3A35A
+:104C6300A3ECF0A3EDF088828983A3A3A3A3A3A35A
+:104C7300A3E024FFF8A3E034FFF98A828B83E8F0F2
+:104C8300A3E9F0024EA1880874E02508F5827405B3
+:104C9300125407F5D90822EAFEEBFF9061D0E0F841
+:104CA3007480C398FAEE248322124CB29404221225
+:104CB30052CAE0F5D90AEAC32274F6122051EAFE79
+:104CC300EBFF9061D0E0707575D90E75D90375D976
+:104CD300047A008A08EE250812583F248C124D5599
+:104CE30040F17A008A08EE250812583F2484124CBA
+:104CF300AC40F175E1957908EE248C124D4E248475
+:104D0300124D457C008C82AA82C3E49AF895E0F99F
+:104D1300EE28F8EF39F9E8248BF582E9125403C041
+:104D2300E0EE2A12583F24ABF582E91252BCD0E0E0
+:104D3300F00CECC3940840CD124E0B8002790002B4
+:104D43004E81FAEF3400FB120C9922124D4579047F
+:104D5300EE22124CB2940822C082C08375D9027528
+:104D6300D90375D90575E195EA2470F582EB124DE7
+:104D730080EA2472F582EB124E1D0249141252CDC1
+:104D8300124D8722E0F8A3E0F92274F6122051EACB
+:104D9300FEEBFF9005E07406124DF91222647C01CC
+:104DA3007903125125121FF275D90675D9037800BC
+:104DB300124DDF40FB75E195900442E064087017E3
+:104DC300EE2470F582EF124D80EE2472F582EF121D
+:104DD30052BCE8F0A3E9F07901024E81880874E03F
+:104DE3002508F5827405124DEF9405221252CDE089
+:104DF300F5D908E8C322F07508E07509057808229B
+:104E030075E1957904120E61EE2470F582EF12526A
+:104E1300CD124D87EE2472F582EF1252CDE8F0A346
+:104E2300E9F079012274F6122051EAFEEBFF90615A
+:104E3300D0E0704379019005E0740BF0900442E0F8
+:104E4300640770177508E075090578081222647CF9
+:104E5300010909125125121FF27905740129F5D9A7
+:104E630075D90378008003124C89E8C39940F8751B
+:104E7300E195124E0B8002790080037401F07F02EA
+:104E830002212374F7122051EAFEEBFF75D9037553
+:104E9300D90375D90DEE24DE124EA6124E037F01FF
+:104EA300022123F582EF125407F5D9227F03022151
+:104EB300237401250AF5D975D90378002274F512F4
+:104EC3002051124F356004780480027800E8240BE7
+:104ED300F8EAC3984041750A099005E07409F0792E
+:104EE30008124F1E60147508E07509057808122230
+:104EF3006412511D121FF2750A0D124EB480031273
+:104F03004C89E8C3950A40F775E1957904120E615F
+:104F130012509A7901800279008091EE24E3FCEF2C
+:104F23003400FD7AE17B05120C93850882850983A1
+:104F3300E022124C9AF8EF1254D4F583E02274F372
+:104F43001220518A088B09125130FAE5082483F59F
+:104F53000AEB124FFF6004780480027800E824080B
+:104F6300F8EAC3985003024FF8750C069005E074F5
+:104F73000CF090045FE09005E1F07402C0E0F97C6E
+:104F8300607D047AE27B05120C93D0E0F97C627DAC
+:104F930004120C93850A82850B83E0601C750AE07A
+:104FA300750B05780A1222647C067903AA08AB09FB
+:104FB300125125121FF2750C0A7401250CF5D975CF
+:104FC300D90378008009880A74E0250A124C8FE817
+:104FD300C3950C40F175E1957904120E61E508243F
+:104FE30070F582E509124D80E5082472F582E50922
+:104FF300124E1D800279007F050221233400F50B38
+:10500300850A82F583E02274F6122051EAFEEBFF53
+:10501300125130FCEE2483F8EF12512B60047A0412
+:1050230080027A00EA2404FAECC39A405E7A029082
+:1050330005E0EAF0EE24F5F582EF1250A66019754B
+:1050430008E075090578081222647C027903EEFAF8
+:10505300125125121FF27A0674012AF5D975D90364
+:1050630078008003124C89E8C39A40F875E195EE05
+:105073002474125093EE248012509312509A7904A0
+:10508300120E61EE240D124E0E80027900024E8143
+:10509300F582EF12521622EE241DF582EF125216FC
+:1050A300A3F0221254079005E1F088828983E0225D
+:1050B30074F6122051125130FEEA2483F8EB125198
+:1050C3002B60047C0480027C00EC2404FCEEC39C73
+:1050D30040437C029005E07407F0EA24F6F582EB86
+:1050E3001250A660157508E0750905780812226448
+:1050F3007903125125121FF27C0674012CF5D97520
+:10510300D90378008003124C89E8C39C40F875E109
+:1051130095790180027900024E817C097903EEFAC8
+:10512300EFFB120D05740222124AB0E0229061D007
+:10513300E0F87480C3982274F5122051E9FEA2AFFF
+:10514300E433F50AC2AF7F00EA246FF8EB3400F9C9
+:1051530080010F88828983E0FCEFC39C50188F087D
+:10516300EA2508FCEB3400FDEC246BF582ED1254C8
+:10517300036E70DE8010EA2CFAEB3400FB1252B699
+:10518300EE1250AC04F0E50AA2E092AF024EAF7407
+:10519300F6122051A2AFE433FFC2AFEA246FF8EB5B
+:1051A300125841FCE9FD8C828D83E014F07E00806F
+:1051B300218E08EA2508F8EB125841246CF582E9A0
+:1051C300125403C0E0E8246BF582E91252BCD0E02C
+:1051D300F00E8C828D83E0F8EEC39840D4EA246EFF
+:1051E3001252B974FF12520BEFA2E092AF024E813A
+:1051F300C082C083E5A8F8C2AF1252B6E912520BBF
+:10520300E8A2E792AF024914F0EA246AF582EB12AE
+:105213005216221252CDE4F02274F21220518C82E3
+:105223008D83A3A3A3A3E0541FF0EA243612557879
+:105233008E828F83E4F0F50C850C8285820AEC253F
+:105243000AF8ED1254D0F583E0C0E0EA250AF8EB42
+:105253001252C0D0E0F0750D00850882850983E005
+:10526300F50A750B00E50D780A121FAAE50AA2E0FC
+:10527300502AE50C33333354F8250DC0E08E828F6A
+:1052830083E0F8EA28F8EB1258412438F582E91252
+:1052930052BCD0E0F08E828F83E004F0050DE50D63
+:1052A300C3940840B4050CE50CC39405408A7F06FB
+:1052B300022123EA246BF582EB1252CD223400F94A
+:1052C300E8245D1252CA22F582E93400F583227480
+:1052D300F612205190046EE0640170077A007B009F
+:1052E3000253FD7E00900474E070F17401F0A3E4B6
+:1052F300F0A3F09004D404F09004D7E4F0A3F0906A
+:1053030004DA04F0900477E412541490048104F056
+:105313009004A7E4F0908F42121ECA90048A121ED2
+:10532300D690048EE4F0A3F0A3F09004F2F090047E
+:10533300E6F09004DB7480F0A3E4F09004E1F090D5
+:1053430004D9F090055D12540C900566F09004F5B5
+:10535300F0900545F0A3F0908F42121ECA900547C6
+:10536300121ED6908F42121ECA90054B121ED69063
+:105373000551E4F0900553F090054FF09005691244
+:10538300540C8E0874DD12552F74041252BC74FF32
+:10539300F00EEEC3940440EA7E008E82A882747DF0
+:1053A30028F5827405125403C0E074CF28F5827483
+:1053B300041252BCD0E0F00EEEC3940540DC7E0034
+:1053C3008E82A882745628F5827404125403C0E0B6
+:1053D300745528F58274051252BCD0E0F00EEEC36A
+:1053E300940840DC90046EE004F0640170089004BB
+:1053F30076E0900470F07A727B04024E81F582EFBE
+:10540300125407221252CDE022125414A312541440
+:1054130022F0A3F0A3F0A3F022C082C083EA240306
+:10542300F582EB1254036008E4F090046FE014F08B
+:1054330090046EE014F0700690047074FFF08A829A
+:105443008B83A3A3E4F0900582E0700D90046FE0DA
+:10545300640170057900120E43024914C082C083AF
+:10546300900475E4F0900474F090046EF0A3F0A33C
+:1054730074FFF075E1F1024914C082C083780079AA
+:1054830000900475E060047872790488828983A3AC
+:10549300A3A3A3E0F902491474F6122051EAFEEB28
+:1054A300FF120C4BEE2465F8EF1254D01254DEECCD
+:1054B3004D6010900470125769850882850983E452
+:1054C300F0A3F0EEFAEFFB120D3B024E811254D41F
+:1054D300223400F988088909888222F583E0FCA335
+:1054E300E0FD2274F7122051EAFEEBFF8E828F83D8
+:1054F300A3A3A3A3E0FA7B001209CFEEFAEFFB12FA
+:105503000C5D120D1D024EA174F612205178008815
+:1055130008745612552F740412509608E8C3940861
+:1055230040ED900456024E7E880874B82508F58233
+:105533002274F6122051EA240D125578EC2403F854
+:10554300ED3400F988088909EC2407F8ED12584175
+:10555300FCE9FD125582121F518E828F83E8F0A35E
+:10556300E9F0125582121F518B09EA4509600312B3
+:105573005595024E81F8EB3400F9E8FEE9FF228CE1
+:10558300828D83124D87850882850983E0FAA3E023
+:10559300FB228E828F83E02401F0A3E03400F0220B
+:1055A30074F6122051EA242EF582EB34001254DEF5
+:1055B300EA2470125578780079FAECFAEDFB121FA1
+:1055C300518E828F83E8F0A3E9F0780079FAECFA40
+:1055D300EDFB121F518B09EA450960031255950231
+:1055E3004E8174F0122051EAFEEBFF741012204535
+:1055F3007808121EAC120DF58A0C8B0D8C0E8D0FD4
+:10560300908F1E780C121E38908F36780C121E86DF
+:10561300780C1222608E828F83124A22121ECA12C3
+:1056230027DD7404121FF2E960030256CD8E828FC8
+:1056330083E02402F8A3E0125841FAE9FB8A828B43
+:10564300837808121E4B908F367808121EAC8A821C
+:105653008B837808121E99EE240BF582EF1252BC4D
+:10566300C082C0838E828F83A3A3A3A3A3E024015C
+:10567300F8A3E03400F9D083D082E0687003A3E09C
+:1056830069700479018045EE2407F8EF124AB012DD
+:105693005599EE24741258467014EE24751256D49C
+:1056A3007003A3E06D70078A828B83125599EE24F1
+:1056B300801258467014EE24811256D47003A3E06E
+:1056C3006D70078A828B8312559979007F080221B6
+:1056D30023FAEF3400FB8A828B83E0FCA3E0FD888E
+:1056E300828983E06C2274F3122051125771FE7485
+:1056F3000439FFEE2404F50AEF3400F50BEE2465BC
+:10570300F508EF3400F50980101254E0850882850E
+:105713000983E4F0A3F01257638508828509831295
+:1057230054E0EC4D6030EE2464125400F50C780C18
+:10573300122268EE2463125400F9EEFAEFFB120C06
+:10574300877401121FF2E985088285098360BA1202
+:105753004D83E84970077C007D00125763024FFABE
+:10576300850A82850B83E0FA7B0012098D2290045F
+:1057730070E0F875F004A4C8AAF02AF9747228221C
+:1057830074F2122051EAFEEBFF890A740E122045CF
+:10579300E0FAEE2462125846600302583A1251307E
+:1057A300F50CEE2483125400FB6004780480027825
+:1057B300008908E928F8E412584124020808E9346A
+:1057C30000F9E50C98E499A2D265D0334065EA70FC
+:1057D30005750B028003750B01EB603375090078C7
+:1057E300081222647AE07B05120CCF7402121FF2B6
+:1057F3007508E07509057808122264AC0AA90B1232
+:105803005121121FF27404250AF50A7CE07D057408
+:1058130001250AF5D9850BD97800800A8808EC128E
+:10582300552FED124C93E8C3950A40F075E1957935
+:105833000080067907800279FF0252B1F8EF340045
+:10584300F9E822F582EF125407640122C082C08373
+:10585300800312587DE9F874FF28190470F4ECFAF8
+:10586300EDFB024914C082C083800312587DE9F81E
+:1058730074FF28190470F40249148C828D83E08A22
+:10588300828B83F08C828D83A3AC82AD838A828BDF
+:1058930083A3AA82AB832274E8122051907803E099
+:1058A3006442705E9005DFE014F07056C2AF125888
+:1058B300B400782AD0E0F618D0E0F6E59F5407F953
+:1058C3007005908F828003908F267808121EACE9B2
+:1058D300C4C0E07829E65508F50808E65509F50936
+:1058E300740B7808121FBAD0E02508F8906270E0B4
+:1058F300A2E740F8E8C333906272F0906270E0D29E
+:10590300E0F0900470E0F874FF687003025BCCE889
+:105913001266252402F8EF3401F98882898312661E
+:105923009FEA4B600FEE2401F582EF3401F583E02B
+:10593300F9121113EE2405F514EF3400F5158E82D8
+:105943008F83A3A3A3A3A3A3A31260B112663B9067
+:105953006054E0900449F0906055E090044AF09060
+:105963006056E090044BF0906057E090044CF09048
+:105973006058E090044DF0906059E090044EF09030
+:10598300605AE090044FF090605BE0900450F09018
+:10599300605CE0FC900451F090605DE0FD90045287
+:1059A300F090605EE0F50C900453F090605FE0F5DA
+:1059B3000D900454F090044FE0F5108C082508F87E
+:1059C300E43400F9850C0812605C8D0812605C8574
+:1059D3000D0812605CEE24F71265E71266918C8263
+:1059E30085820AEE24F9F582EF1260A5EE24FB12FC
+:1059F3006099EE24FFFAEF3400FB8A828B83E0F593
+:105A030008A3E0F509E5084509603A906000E0C3A2
+:105A130033F508E433F5098A828B83E02508F50E14
+:105A2300A3E03509850E82F583126691906000E04C
+:105A3300C333F8E433F98A828B8312664C244AF524
+:105A430082E91260A5EE240BF8EF3400F9EE241D71
+:105A5300F50EEF3400F50FEE2420FAEF3400FBEEE1
+:105A6300241C1265CFEE240FF50AEF3400F50BE585
+:105A730010700BED7008E50C7004E50D607985146A
+:105A830082851583126667EE240D1265F12CFCA343
+:105A9300E03DFD88828983ECF0A3EDF0126076701F
+:105AA300031260DC90044AE0602485088285098340
+:105AB3007401F0EE246A1265F17013EE247412651A
+:105AC300F1700BEE24801265F170031260DC9060BC
+:105AD30062E08E828F837003025B5FE02406FCA387
+:105AE300E03400FD12667E120DEF8E828F83E02478
+:105AF30012126641E48079EC601812607670238A92
+:105B0300828B83126667850E82850F83ECF0A3ED8B
+:105B1300800FEE24FD126099850E82850F83E4F0D9
+:105B2300A3F0888289831260B1E0687003A3E069FF
+:105B33006003025AA7850A82850B83E0600F8514F0
+:105B430082851583E064057002A3E0600B7908EE9B
+:105B5300FAEFFB120C638071793E80F3E0F8A3E067
+:105B6300F5838882A3A3A3A3A3A3E4F0A3126A3AB1
+:105B7300F0A3F0906060E0C0E0EE24691265E7D026
+:105B8300E0F090044FE0F81265EE28F0EE247AF589
+:105B930016EF3400F517025CB89005DDE064017080
+:105BA3002B120EAF1265EE70069060607480F0EEFB
+:105BB300FAEFFB120DA1E96401600E120C81120DC4
+:105BC3009BE964016003120D1D0260EFEE24831252
+:105BD30065F16004780480027800E50CC398F9123B
+:105BE30009818A0A8B0BEA450B60B6EE24831265A2
+:105BF300F170048A088B0978008015E5D9C0E08824
+:105C030010E5082510F582E5091265EAD0E0F008F1
+:105C1300E8C3950C40E5EE24831265F1603774FC0C
+:105C2300250CF50C7808122264AC0CA90DEEFAEFE2
+:105C3300FB120D0B7402121FF2E970197403650D48
+:105C43007003025CF2E50A24FBFAE50B34FFFB1256
+:105C53001155025CF27403650D7003025CF7850C49
+:105C6300107511007810122264AC08AD09AA0AABB2
+:105C73000B120CCF7402121FF2EE24691265F16449
+:105C8300807004747F8001E0F5087808122268E5CB
+:105C93000DF5087808122268A90CAC0AAD0B900424
+:105CA30070E0FA7B001209877402121FF2120EBB16
+:105CB3001265EE14F0E07003025BAC7508E0750941
+:105CC30005750A00750B00E5D914F50CE5D95403E5
+:105CD300F50D601B7403650D7003025BFAE50C7030
+:105CE30003025B9CEE24681265F16003025B9C79FE
+:105CF3003D025B52850882850983E0FAA385820809
+:105D0300858309A3A882A9836038147003025E4ABD
+:105D1300147003026000147003025E8B24FD700391
+:105D2300025F2E146087147003025F5524FE700314
+:105D3300025F37147003025F50147003025FA802FE
+:105D43005FAD850882850983E0C0E0EE24771265A4
+:105D5300E7D0E0F0880889097902AC08AD09EE24A0
+:105D63007812601D7902AC08AD09AA16AB17120CA4
+:105D73008D8A088B097902AC08AD09EE247C126088
+:105D830042247E12601DEE24771265F1C333F0EED8
+:105D930024781265E71260D1EE2478126638126017
+:105DA300CB85168285178312663BEE247E1265F13E
+:105DB300F50AA3E0F50B7404780A121FC9EE247EDA
+:105DC3001265E7E50AF0A3E50BF07902AC08AD092B
+:105DD300EE247512602E24751265E7C082C0838598
+:105DE3001482851583126658D083D0821260BB401B
+:105DF300057928025B52EE247C1265F12401F50833
+:105E0300A3E01265D2E4F50AF50B1260CB88108982
+:105E130011E4F512F51378087910121CE9EE247ECB
+:105E23001265F1F510A3E0F511781079081214DE6C
+:105E33004005793B025B52EE2474126A18126A3AE7
+:105E4300E4F0A3F0025CB07402C0E07905AC08ADE5
+:105E5300097A7D7B05120C8DEAFCEBFDD0E0F9EEAF
+:105E6300248112602E24811265E7C082C0838514C9
+:105E730082851583126658D083D0821260BB40039B
+:105E8300025DF4EE248080B2EE24E21265F1701418
+:105E93007A0012604DC0E0126065D0E0F00AEAC3F8
+:105EA300940840EEEE24E31265F1A2E0EE401424E0
+:105EB300DE1265E7741AF0790DEEFAEFFB120C2D82
+:105EC300025CB012608C24E11266167908AC08AD4E
+:105ED30009EE249C12604224A412603CAC08AD0974
+:105EE300EE249412603CEE2494FAEF3400FB120C7F
+:105EF300997904AC08AD09EE24881260337904EE75
+:105F03002488FAEF3400FB120C99EE248CFAEF3458
+:105F130000FB120CABEE2484FAEF3400FB120CB13D
+:105F2300900444E04480F07904808EEE24DF126A0A
+:105F330018025E46EE12608C24D3126608EE24DD4E
+:105F4300126A2624D4126608790B025EBCEE24E0A2
+:105F530080DC7A0012604DC0E0126065D0E0F00A88
+:105F6300EAC3940840EE7A008A82A882745628F520
+:105F73008274041265EAC082C0838508828509831E
+:105F8300E0D083D082FBE05BC0E0126065D0E0121A
+:105F93006084A38582088583090AEAC3940840C8FC
+:105FA3007909025EBC126A2C700DEE24F61265E7C5
+:105FB300EAF07907025EBC850882850983E0C0E0C8
+:105FC300EE24EE1265E7D0E0F0880889097402C078
+:105FD300E0F9AC08AD09EE24EF126033EAFCEBFD07
+:105FE300D0E0F9EE24F112602E24EB126A2624EDA0
+:105FF3001265F16003025CB0790C025EBCEE24F51D
+:10600300F8EF12661BE088828983F0EE24F41266AF
+:106013001688828983E0F9025B5212602122FAEF2B
+:106023003400FB120C8D8A088B0922126033EE2296
+:10603300FAEF3400FB120C8D221260217908221230
+:1060430060217902AC08AD09EE228A82A8827456D7
+:1060530028F58274041265F822E82508F8E934006B
+:10606300F922EE28F8EF3400F9E824E3F582E91287
+:10607300661122850A82850B83E4126084E0640141
+:1060830022F085088285098322246212660EE412B7
+:106093006A49E4F0EE221265F52401F0A3E034002E
+:1060A300F0221265F8250AF0A3E03400F02212660C
+:1060B3005C85148285158322E0C398F8A3E099F9DF
+:1060C300C3E894FFE9947F228516828517831266BD
+:1060D3005CE8C333F8E933F9228A828B8312665C66
+:1060E300850E82850F83E8F0A3E9F0227F10022159
+:1060F3002353BFEF02012274E8122051900470E091
+:10610300F81266252420F50EEF3400F50FEE241C5B
+:10611300F50CEF3400F50DEE241DF510EF3400F50A
+:10612300119061D0E0600B851082851183E4F0A3A8
+:106133008030EE246A1265F17029EE24741265F141
+:106143007021EE24801265F17019850C82850D8310
+:10615300E06401700E850E82850F8312666DE8F090
+:10616300A3E9F0EE24071265CF8E828F83A3A3A346
+:10617300A3A312666D12664C240108E912661B1272
+:10618300663BEEFAEFFB120DA7E964016008900588
+:1061930084E06401701F851082851183E4F0A3F00D
+:1061A3008E828F83A3A3A3A3A3E02401F8A3E01209
+:1061B300661B12663BEE2474126A2F60030263614E
+:1061C300EE24751265D712227B8508828509831216
+:1061D30066678E828F83A3A3A3A3A312669F122451
+:1061E300ED7402121FF2E97003026361850A82856E
+:1061F3000B831266A52477FCEF3400FDEEFAEFFB68
+:10620300120C6F1265E41260E0850C82850D83E445
+:10621300F0851082851183F0A3F0EE240F12661629
+:10622300850882850983126662240D1265F128F8B8
+:10623300A3E039F9EE240B1266388E828F83A3A371
+:10624300A3A3A3126667850A82850B8312669F1236
+:10625300252A8A088B09EE242E126699E4F50AF59D
+:106263000B8A0C8B0DF50EF50F7808790C121CE9CF
+:10627300EE24781265FE7808790C121E2585080C29
+:1062830085090D850A0E850B0FEE247EF516EF3476
+:1062930000F517851682F583126662247AF512EFEC
+:1062A3003400F513851282F583126667EE2430F508
+:1062B3000AEF3400F50BEE24321265CFEA6C70025C
+:1062C300EB6D7024850882850983E0687003A3E081
+:1062D300697015EE247C126699850A82850B83E02A
+:1062E3006A7003A3E06B6031881489157404781411
+:1062F300121FBA78141222641265E412227BEDC3D2
+:1063030013FDEC13FC8E828F83A3A3A3A3E0FA7B7C
+:10631300001209D57404121FF2EE24771265F1C03E
+:10632300E0EE242B1265E7D0E0F08512828513831B
+:10633300126662242E126638EE247C126655850A94
+:1063430082850B8312663B8516828517831266A5A9
+:10635300FAEFFB120C75EE2474126608800BEE2420
+:106363002E1265FEE4F50EF50F851082851183E08C
+:10637300F514A3E0F515EE24121265CFEE241FF5F4
+:1063830012EF3400F513EE24181265D7780C1214AB
+:10639300A37011851282851383E0F8E514687002F7
+:1063A300E51560237808122264EE24101265E712C3
+:1063B300227B7814122264AA0CAB0DAC0EAD0F1223
+:1063C300297E7406121FF2850A82850B83780C12CC
+:1063D3001EBB851082851183E0851282851383F0AD
+:1063E300AC08AD09126677906062E060077CC47DFB
+:1063F3008E1266778E828F8312665888828983A372
+:10640300A3E82408FCE93400FD7406121EEF85108E
+:106413008285118312669F8E828F83E02402F8A304
+:10642300E03400F9E8FCE9FD8A108B11E4F512F57C
+:1064330013908F767810121E387810790C121CE99D
+:106443008C828D837810121E4B908F367810121E1B
+:10645300AC8C828D837810121E99900582E06401C2
+:10646300600302654F7901120E438E828F83E0F53C
+:106473000AA3E0F50B908F62121ECAE50A240EF5FB
+:1064830082E50B1265EA121ED6E50A2412F8E50B23
+:106493003400F9E8FCE9FD850882850983780C124C
+:1064A3001EAC850C08850D09E50875F0E2A4C50846
+:1064B300A8F075F004A428F875F0E2E509A428F51E
+:1064C300098C828D83E02508F0A3E03509F0EE24E2
+:1064D300161265F1F508A3E0F50974047808121F94
+:1064E300BAE5082401F8E509340012668C9060626D
+:1064F300E08C828D8370030265A7E02410F0A3E093
+:106503003401F0EE240F1265F16016EE242B1265B0
+:10651300F1F875F071A4C8AAF075F002A42A126606
+:106523008CE50A2414F582E50B1265EA7410F08EEB
+:10653300828F83E0241612664174F1F0A3740BF08A
+:10654300EEFAEFFB12244F79000260EF908F86780A
+:106553000C1214FE500302646DEA4B600302646D77
+:10656300780C122260EEFAEFFB120C7B7404121FFC
+:10657300F2E96401600302646DEE240F1265F160B9
+:10658300128E828F83A3A3A3A3A3E064057002A347
+:10659300E0600479088002793EEEFAEFFB120C63A7
+:1065A300790180A5E02410F8A3E034FFF97A717B28
+:1065B30002121F5188088909EE242E126655C3E57D
+:1065C3000898E50999500302650680C7F508EF347A
+:1065D30000F50922F50AEF3400F50B850A82F583ED
+:1065E30022EE247CF582EF12661122EE24671265F7
+:1065F300F522F582EF3400F583E0221265F5F50C00
+:10660300A3E0F50D2212660EE4F022F582EF3400CA
+:10661300F58322126A1CF0223400F9850882850969
+:10662300832275F004A4C8AAF02AF9747228FE74B0
+:106633000439FFEE2212660EE8F0A3E9F022F8A374
+:10664300E03400F98882898322E028F8A3E039F94D
+:10665300E82212660E12665C22E0F8A3E0F9221229
+:10666300665CEE22E0FCA3E0FD2212665C851082EC
+:106673008511832212667E1228B8228E828F83E0D0
+:106683002402FAA3E03400FB22F98C828D83E028F4
+:10669300F0A3E039F022F582EF126611E0FAA3E0ED
+:1066A300FB2212665C850882850983E8F0A3E9F082
+:1066B300EE2274E8122051EAFEEBFFEE24DFF51020
+:1066C300EF3400F511EE24E0F50EEF3400F50FEE94
+:1066D3002462F516EF3400F517EE2483F50CEF343E
+:1066E30000F50DEE241DF512EF3400F513EE24042E
+:1066F300F50AEF3400F50BEE246A1265CF8039906A
+:10670300044CE07003026952EEFAEFFB120C33EE15
+:1067130024A4F514EF3400F5157814122264EE2442
+:106723009CFCEF3400FD850A82850B83E0FA7B0035
+:106733001209E17402121FF2EE246F1265F1606A0E
+:10674300EE246B1265F124FE602F24FE606014605A
+:106753007414700302687A147003026A0624FE70CC
+:106763000302696924FE70030268E6147003026978
+:106773009014700302692980BF850882850983E02C
+:106783006401701790044BE070030269527916EEAE
+:10679300FAEFFB120C6379010260EFEEFAEFFB12E2
+:1067A3000C21E9850882850983F0790080EA850850
+:1067B30082850983E064017003026702EEFAEFFB4E
+:1067C300120BF780DD850882850983E06401704739
+:1067D30090044CE06027850C82850D837401F09052
+:1067E3008F42121ECAEE24D51265E7121ED6908F71
+:1067F30042121ECAEE24D91265E7121ED6851082F4
+:10680300851183E0640160030269527906EEFAEFB1
+:10681300FB120C3902673BEE24D3126A2F701CEE75
+:10682300FAEFFB120BFDE9640160030267AD85100B
+:1068330082851183E4126A350267ACEE24D41265B3
+:10684300F170030267ADEE24B3F514EF3400F515D0
+:106853007814122264EE248CFCEF3400FDEE24C382
+:10686300FAEF3400FB120CBD7402121FF2EE24D3B4
+:10687300126A18F002673B850882850983E0640188
+:10688300705790044CE07003026952126A67EEFA83
+:10689300EFFB120C338516828517837401126A424B
+:1068A300850A82850B83E0FA7B00EE24DD126A2FD2
+:1068B300700779001209ED80077C0179001209E75E
+:1068C300EE24DD126608EE24E11265E7E4126A3A6B
+:1068D300F0851082851183809AEEFAEFFB120C0388
+:1068E3000267A5850882850983E064017015850E1A
+:1068F30082850F83E064017056EEFAEFFB120C33CE
+:1069030002673BEEFAEFFB120C09E9640160030234
+:1069130067AD850E82850F83E4F0850C82850D8338
+:10692300126A35026876850882850983E0640170FE
+:106933002B90044CE06012850C82850D83E4F08576
+:10694300168285178304126A4290044BE070AA12E0
+:106953006A7C60030267AD7922026792EEFAEFFB6D
+:10696300120C0F0267A5850882850983E064017014
+:106973001290044CE060D8EE24E2126616126A67A5
+:106983000268FCEEFAEFFB120C150267A58508827C
+:10699300850983E06401705C126A2C702DEE24EC8F
+:1069A300126A2F60030268FCEE24F11265E71222DB
+:1069B3007BEE24EF1265E712227B126A55790012EF
+:1069C30009DB7404121FF20268FC126A7C60030282
+:1069D30067ADEE24F11265E712227BEE24EF126518
+:1069E300E712227B126A5579221209DB7404121F03
+:1069F300F202695AEE24ED126A26FAEFFB120C1B1F
+:106A03000267A5EEFAEFFB120C27E96401600302AB
+:106A130067AD0268FC126A1C22F582EF3400F5832D
+:106A2300740122126A1CF0EE22EE24EB1265F56467
+:106A330001221260840422F0850E82850F832212C4
+:106A43006A497401F022F0EE2468F582EF3400F510
+:106A53008322EE24EE1265F5FC850A82850B83E022
+:106A6300FA7B0022EE242012660E12665C851282E7
+:106A7300851383E8F0A3E9F022EE2472F8EF3400E3
+:106A8300F988828983E024FFF0A3E034FFF0888251
+:106A9300898312665CE84922C082C0838A828B8321
+:106AA300A3A3A3A3A3A3A3126658EA240BF582EB23
+:106AB30012669CC3EA98EB995014E8C39AF8E99BD1
+:106AC300F9C3E894AAE99410501479018012EAC337
+:106AD30098F8EB99F9C3E894ABE9941050EC79007A
+:106AE300D083D082020122740E121FF27F0402218E
+:106AF3002374F012205174CC121FDC8C0A8D0B749A
+:106B030044122045E0FE7420122045AC82AD83750B
+:106B1300838E7582E27406121EEF7420122045AC38
+:106B230082AD8312121BE9F508C3940A4003026C79
+:106B33005875F006E9A4F5097426122045AC82AD18
+:106B4300837A0E7420250912769F700974321220FD
+:106B530045E0FF80027F009010CAE0640270047475
+:106B6300018001E4F50D780D122268EEFDEFFCA91A
+:106B730008AA0AAB0B12129F7401121FF27C147D38
+:106B8300007900740C122045AA82AB831210D774CB
+:106B93000C122045AC82AD837A1074242509127639
+:106BA3009F70377C1079FF740C1220451273CC70E0
+:106BB30029741C122045AC82AD837A0474252509FF
+:106BC300F91213D7740C122045AC82AD83EFA2E007
+:106BD300E433F9AA0AAB0B1206638518828519837D
+:106BE300AC82AD837A0C7470250812769F7055853C
+:106BF3001882851983AA82AB8312124B750800E5AC
+:106C03000875F003A4F8A9F0851882851983E58235
+:106C130028F8E58312740812721DEC4D601D8882FA
+:106C23008983A3A3E0F50E750F00780E122264AAE0
+:106C33000AAB0B1208C17402121FF20508E508C360
+:106C4300940440BBEFA2E1500C9008AAE0F9AA0A11
+:106C5300AB0B1208C774046E702A9010CAE064026A
+:106C630070229008BEE060047A0180027A009008E6
+:106C7300ABE06004780480027800E84AF9AA0AAB22
+:106C83000B12072379007434121FF27F08022123A9
+:106C930074F0122051EAFEEBFF8C088D09750A0A85
+:106CA300E9600C14600914602E14607F026D3912C0
+:106CB300125DE9F50AC3940A507CE508450960763C
+:106CC300750E06750F00780E122264EEFCEFFD12AE
+:106CD30075E3121FF2805F750B00750E06750F00CA
+:106CE300780E122264EEFCEFFDE50B75F00EA4F8AE
+:106CF300A9F074CC28FA740839FB1210D17402126B
+:106D03001FF2E9601B850B0AE50AC3940A5027E5C5
+:106D13000845096021AA08AB09A90A12125780166F
+:106D2300050BE50BC3940A500D80AF121263E9F50E
+:106D33000AC3940A40D9A90A026C8E74F412205132
+:106D4300890875091574FF6A700374FF6B70277ED9
+:106D530000AC087A027B00EEF9121239E960037580
+:106D630009000EEEC3940A40E8E50860497A8D7B7A
+:106D730012120AD78040120AB98A0A8B0BAE0AAFE5
+:106D83000BEE4F602E7C007D00EE2405FAEF3400FD
+:106D9300FB8E828F83126E35500CAC087A027B0017
+:106DA300121239750900E508600CEEFAEFFB1212B6
+:106DB3008D8003750914A909026AEF74F212205138
+:106DC300ECFEEDFF740E1220451272107508157457
+:106DD300FF6A700374FF6B7021750900AC0AAD0B79
+:106DE300EEFAEFFBA90912123FE9600375080005EB
+:106DF30009E509C3940A503580E2120AB98A828BE5
+:106E030083E582458360237C007D00E5822405FAC7
+:106E1300E5833400FB126E355013AC0AAD0BEEFA6A
+:106E2300EFFB12123F7508008003750814A90802CE
+:106E33007C0EA3A3A3A3E0F912121BE9C3940A22B5
+:106E4300C082C0839008C4EAF0A3EBF09008AAE0E4
+:106E5300FC7D007A257B001205D99008AAE0F9127F
+:106E6300083DD083D08202012274EA12205174ECCF
+:106E7300121FDCEAFEEBFFEE240CF514EF3400F5F1
+:106E830015EE240AF510EF3400F511EE2405F50E86
+:106E9300EF3400F50FEE2409F50AEF3400F50BEE9D
+:106EA3002403F508EF3400F5098E828F83A3A3E052
+:106EB30024FA70030271D924FD700302710814705F
+:106EC30003026F5714601024FD70030270D914700D
+:106ED3000302713D0271F712723C604AE0F5838848
+:106EE30082127223880C890DE8450D60398514825E
+:106EF300851583E0F50E780E122268EE240BF582D9
+:106F0300EF3400F583E0F9850A82850B8312721D45
+:106F13000A0A0AAB09850C82850D8312204F74017E
+:106F2300121FF20271F7850A82850B8312227B906E
+:106F330008C0121ECA1206757402121FF2E970030A
+:106F43000271F77901850A82850B83127A3312065F
+:106F53006F0271F78E828F83A3858212858313E07C
+:106F630060030270B2850E82850F83E0A2E04003C6
+:106F73000270B27C0E7D007900851882851983AA80
+:106F830082AB831210D7EE2408F50AEF3400F50B19
+:106F9300850A82F58312723F6019750C06750D0020
+:106FA300780C122264850A82850B83E02410FCA3EB
+:106FB300E0801A127201EA4B70030271F7750C0636
+:106FC300750D00780C122264EA2405FCEB3400FDF5
+:106FD3007402122045AA82AB831275E7121FF28551
+:106FE3000E82850F83E0A2E25004D2F08002C2F049
+:106FF300A2F0E433F8740C122045E048F0851082C7
+:1070030085118312723F6015851082851183E024F8
+:1070130010F8A3E03400F9888289838003908F629B
+:10702300780C121EAC85108285118312723F600F9B
+:10703300851082851183E0F510A3E0F511800675B4
+:107043001000751100850A82850B8312723F600B55
+:10705300850A82850B831272108006750A00750BF0
+:1070630000780C1222607810122264780A122264CB
+:1070730085148285158312227B8E828F83A31272DD
+:1070830018740A122045AA82AB83121251740A1291
+:107093001FF2850882850983127223900954E8F050
+:1070A300A3E9F07A017B009008AAE0F91211131208
+:1070B300723C70030271F712722970030271F78533
+:1070C3001282851383E0FC7901127A2D8E828F83DD
+:1070D30012204F0271F712723C70030271F7E0F550
+:1070E300838882A3A3127223890BE8450B700302E2
+:1070F30071F78E828F83A3E0FC7902127A2D888246
+:10710300850B8380CB7C007D00EE2404FAEF3400F2
+:10711300FB850882850983E0F912121BE9F8C39401
+:107123000A40030271F7AC10AD117A0475F006E85A
+:10713300A42425F91213D10271F79008BFE0600E61
+:107143009010CBE0F9850882850983026F4E901079
+:10715300CAE07004790580ED1272018A0C8B0DA8C8
+:107163000CA90DE82404F50CE93400F50D8E828F8B
+:1071730083A3A3A3A3A3A3A3E0A2E05036E849609B
+:1071830073850C82850D83E0FE6028850A82850B5A
+:1071930083E05410701D740E122045AC82AD83E859
+:1071A3002405FAE93400FBEEF912121BE9700479A5
+:1071B300038092AC0EAD0F850C82850D83E0F9122E
+:1071C3007A2D12129912723C602A12722960257C60
+:1071D3000079000270CC12073BE97018900953E064
+:1071E30064017008121275900953E4F07950121378
+:1071F300DD1212697414121FF27F0E022123850817
+:1072030082850983E0FAA3E0FB120AB922E0F50ABA
+:10721300A3E0F50B22A3A3A3A3A3E0FCA3E0FD2219
+:10722300E0F8A3E0F922E0F5838882A3A3E0F8A3C2
+:10723300E0F9E8FEE9FFEE4F229008C4E0F8A3E08E
+:10724300F9E8492274F412205174F2121FDCEAFEA9
+:107253008C0B75F006E9A42420F50885188285199E
+:1072630083AC82AD837A0E12769F704A7C061273CA
+:10727300C47043740C122045127223E8F509E50B20
+:107283006005EE42098004EEF45209850982AA8260
+:10729300E86A7001E9601B740C122045EAF0A3E46C
+:1072A300F0851882851983AC82AD837A0EA9081202
+:1072B30013D1790180027900026AEA74F212205133
+:1072C30074E6121FDC890A8A088B09ECFEEDFF7451
+:1072D3000C12204512769260030273787C0679FFC4
+:1072E300740C1220451273CC6003027378747025FA
+:1072F3000AF50B851882851983AC82AD837A0C124B
+:10730300769F60030273BD851882851983AA82ABB9
+:107313008312124BE508450970217C0C7900127326
+:10732300C660030273BD7C0C7D00790085188285DD
+:107333001983AA82AB831210D780618518828519BD
+:1073430083AC82AD83AA08AB091212458A0C8B0D5C
+:10735300A80CA90DE849702CEE4F60198518828599
+:107363001983AC82AD837A007B00121245EAF8EBF5
+:10737300F9EA4B70047900804388828983E508F039
+:10738300A3E509F0127444FAEE6A7001EF602BEE84
+:10739300F04F700888828983E4F0A3F08518828512
+:1073A3001983AA82AB8312124B851882851983AC89
+:1073B30082AD837A0CA90B1213D17901741A027C62
+:1073C3000B79FF851882851983AA82AB8312113743
+:1073D300E92274F71220517F00EF75F003A4F8A996
+:1073E300F0EC28F8ED127408E06A7003A3E06B7008
+:1073F30006E8FAE9FB800B0FEFC3940440DB7A0045
+:107403007B0002773D39F9888289832274F7122041
+:10741300517E00EE75F003A4F8A9F0EA28F8EB1208
+:107423007408E0F4FCA3E0F4FD88828983ECF0A304
+:10743300EDF0127444F4F00EEEC3940440D50277D9
+:107443003DE82402F582E93400F583E02274EE126C
+:10745300205174F4121FDCEAFEEBFF8C0A8D0B74CF
+:107463001E122045E0F50CA3E0F50D742012204513
+:10747300E0F508A3E0F5097422122045E0F510A316
+:10748300E0F511EE4F7005790A02757512125DE988
+:10749300F50EC3940A4023750F007C0679FFE50FB0
+:1074A30075F00EA4FAABF074C62AFA74083BFB120B
+:1074B30073D0700302757F850F0EE50EC3940A40E7
+:1074C3000302757375F006E50EA4F50FEEFCEFFDF0
+:1074D3007A0E7420127590E50A450B600BAC0AAD69
+:1074E3000B7A1B7421127590E50C450D600BAC0CE7
+:1074F300AD0D7A1B7422127590E5084509600BAC3B
+:1075030008AD097A107423127590E5104511601BBC
+:10751300AC10AD117A1074241275907424122045A6
+:10752300AC82AD837A0474251275907C0C7D00794E
+:10753300FF127C9C7A0C7470250EF91213D1750816
+:107543000E7509007808122264EEFCEFFDE50E7556
+:10755300F00EA4F8A9F074C628FA740839FB127562
+:10756300E7121FF2900952E060031212A512129360
+:10757300A90E740C121FF27F0A022123050FE50FD7
+:10758300C3940A500302749D750E0A80E3250FF914
+:107593001213D12274F412205174F2121FDCEAFE8A
+:1075A300EBFFE9C3940A5004EE4F70047902802D77
+:1075B300851882851983127692F508701E750A065E
+:1075C300750B00780A1222647402122045AC82AD56
+:1075D30083EEFAEFFB1275E7121FF2A908026AEABB
+:1075E300AA08AB091210BF74022274F4122051EAE4
+:1075F300FEEBFF750800750A06750B00780A122268
+:1076030064EEFCEFFDE50875F00EA4F8A9F074C66E
+:1076130028FA740839FB1210D17402121FF2E960C0
+:1076230004A908800B0508E508C3940A40C8790A31
+:10763300026AEF74F712205174F0121FDCEAFEEBBA
+:10764300FF750800851882851983AC82AD837A1093
+:1076530075F006E508A4242312769F701F7C101290
+:1076630073C47018EEFCEFFD851882851983AA8216
+:10767300AB83120645E97004A908800B0508E508E9
+:10768300C3940A40BF790A7410121FF202773DAC0B
+:1076930082AD837A0E75F006E9A42420F91213D77C
+:1076A300E92274F7122051750800E50875F00EA45D
+:1076B300F8A9F074C628FE740839FFEEFCEFFD7AD2
+:1076C3000E75F006E50812769C602C7C067D007929
+:1076D300FFEEFAEFFB1210D77C067D0079FFEE2454
+:1076E30006FAEF3400FB1210D7EE240CF582EF34C8
+:1076F30000F583E4F0A3F00508E508C3940A40AA63
+:10770300900952E060031212A5121293802C74F7B1
+:107713001220517E007F007C0679FFEF75F00EA4E6
+:10772300FAABF074C62AFA74083BFB1273D07001EB
+:107733000E0FEFC3940A40DFEEF97F010221237499
+:10774300F71220517E00EEF912127B0EEEC3940A5B
+:107753005003E960F180E374F312205174CB121FDC
+:10776300DCE9FF75F006A4F50874202508FE7427EC
+:10777300122045AC82AD837A0EEE12769F6003022F
+:10778300785C7C0679FF74271220451273CC600362
+:1077930002785C7C0E7D0079FF7427122045AA8253
+:1077A300AB831210D77C1B7D0079FF740C1220452C
+:1077B300AA82AB831210D77C0C7D0079FF851882D7
+:1077C300851983AA82AB831210D77427122045AC84
+:1077D30082AD837A0EEEF91213D1E9F509740C1216
+:1077E3002045AC82AD837A1B742112786BFE740C36
+:1077F300122045AC82AD837A1B742212786BF50A92
+:10780300740C122045AC82AD837A10742312786B0A
+:10781300F50B740C122045AC82AD837A10742412DC
+:10782300786BF50C740C122045AC82AD837A04742A
+:107833002512786BF508851882851983AC82AD8390
+:107843007A0C74702FF91213D1E9F8EE450A450B3F
+:10785300450C45084842098003750900A909743598
+:10786300121FF27F050221232508F91213D1E92201
+:1078730074F7122051E99008AAF012126902773DB9
+:1078830074F212205174FB121FDC8A088B09EB542B
+:107893008070030279279008AAE0F91210FB8A0A84
+:1078A3008B0BA80AA90BE8FEE9FFE849606CEE24FC
+:1078B30004F8EF3400F98E828F83E024506038148B
+:1078C300600624E1604A804B88828983E070448E9D
+:1078D300828F83A3A3A3A3A3A3A312227B8E828F4E
+:1078E300831272188E828F83A3A3127A3312122704
+:1078F3007402121FF2801C88828983E0641E701355
+:1079030079008E828F83A3A3127A3312122180030C
+:10791300121233EEFAEFFB1210E9AA08E5096480AC
+:10792300FB027A28EAA2E04003027A249009541267
+:107933007210740312204585820C85830D780C1216
+:107943002264750C02750D00780C122264750CB953
+:10795300750D8F780C1222647CFF7DFF7A017B000A
+:107963001207957406121FF2027A0CE4F50CF50D5A
+:10797300780C122264740412204585820C85830DD1
+:10798300780C122264740412204585820C85830DC1
+:10799300780C122264740912204512227B7902EEBC
+:1079A300FCEFFDAA0AAB0B1208B57408121FF2E92B
+:1079B3007035851882851983E0FA7401122045E039
+:1079C300F9EA2400F50CE439F50DEA450D60187861
+:1079D3000C1222648E828F83127219AA0AAB0B12C5
+:1079E30012277402121FF2E4F50CF50D780C122223
+:1079F30064740512204512227B7CFF7DFFEEFAEFB3
+:107A0300FB1207A17404121FF28A0C8B0DAE0CAF8C
+:107A13000DEE4F600302796EE5086401FAAB09804D
+:107A2300047A007B007405027C0B85088285098338
+:107A3300E0FAA3E0FB22C082C0839008AAE0F98A9F
+:107A4300828B83A3127A331208C7026E65C082C089
+:107A53008374FF121FDC12126FE9C394028518822C
+:107A6300851983400474028002740AF0AC82AD83EA
+:107A73007A0179051207537401121FF2026E6574BD
+:107A8300F212205174E8121FDCEAFEEBFF890A8C24
+:107A9300088D097C187D007900127CA4EEF0A3EF19
+:107AA300F09008ACE0C0E07402122045D0E0F09002
+:107AB30008ADE0C0E07403122045D0E0F09010CD93
+:107AC300E0C0E07417122045D0E0F0741512204591
+:107AD300E054FEF8A3E0F99010CCE0A2E0E433FA1E
+:107AE300E84AF87415122045127C1AA2E15004D218
+:107AF300F08002C2F0E854FDFAA2F0E43333F8EA6E
+:107B030048F87415122045127C1AA2E35004D2F0EF
+:107B13008002C2F0E854F7FAA2F0E433F50C750DD5
+:107B2300007403780C121FC9127C13122045127CB7
+:107B33001AA2E45004D2F08002C2F0E854EFFAA291
+:107B4300F0E433F50C7404780C121FC9127C131281
+:107B53002045127C1AA2E55004D2F08002C2F0E85C
+:107B630054DFFAA2F0E433F50C7405780C121FC944
+:107B7300127C13122045127C1AA2E25004D2F08028
+:107B830002C2F0E854FBFAA2F0E433F50C74027875
+:107B93000C121FC9127C13122045E8F0A3E9F090E0
+:107BA30008ADE0601B750C10780C1222647CAE7D6E
+:107BB300087406122045AA82AB831275E7121FF2DE
+:107BC3009008BEE06011E50A60097415122045E0D3
+:107BD3004402F07801800278007414122045E048D2
+:107BE300F09008ABE060047804800278007414120B
+:107BF3002045E048F0AC08AD09851882851983AAB1
+:107C030082AB831206697418121FF27F06022123C6
+:107C1300EA450CF8741522E8F0A3E9F09010CCE0E3
+:107C23002274F312205174E5121FDCEAFEEBFF8C81
+:107C3300098D0A7428122045E0F50C75F006E9A4B5
+:107C4300F87408650A700474228002742128F50B05
+:107C53007C1B7D007900127C9C7A1BA90B1276A0F9
+:107C63007032741A122045E024F9C3940A5025E5B2
+:107C73000CF50B780B1222687401122045AC82AD0F
+:107C830083E509A2E0E433F9EEFAEFFB12067B7415
+:107C930001121FF2741B027863127CA4AC82AD83C1
+:107CA30022851882851983AA82AB831210D785187F
+:107CB300828519832274F71220511209397508003D
+:107CC300E50875F00EA4F8A9F074C628FE74083907
+:107CD300FF7C0679FFEEFAEFFB1273D07009EEFA20
+:107CE300EFFB790012093F0508E508C3940A40D069
+:107CF30002773DC082C0839003F574FFF0A3F0A325
+:107D0300E4F0900415F0A3F0FAEA127FDFE4F0A3A5
+:107D1300F00AEAC3940C40F1027EC274F7122051B8
+:107D23007E00EEC333F8E433F9741728F87404398A
+:107D3300F988828983E0FCA3E0FDEC4D700D888215
+:107D43008983EAF0A3EBF0790080090EEEC3940C6B
+:107D530040D079137F0102212374EC122051890C46
+:107D6300EAFEEBFF8C0D8D0E7414122045E0F51026
+:107D7300A3E0F5117416122045E0F50AA3E0F50B14
+:107D8300120AB98B09EA450960057911027E157A51
+:107D9300FF7BFF120AB98A088B09EA450960718AD9
+:107DA300828B83A3A3A3A3E50EF0751206751300BC
+:107DB3007812122264AC10AD11EA2405FAEB3400F8
+:107DC300FB1210BF7402121FF2850882850983A378
+:107DD300EEF0A3EFF0850882850983A3A3A3E50D45
+:107DE300F0850882850983E50CF0E5082421127FDC
+:107DF30079E4F0A3F0E508240B127F79E50AF0A3F8
+:107E0300E50BF07900EEFAEFFB120ADD7900800250
+:107E130079157F0C02212374F6122051120AB98AB4
+:107E2300088B09AE08AF09EE4F60498E828F83A39A
+:107E33008582088583097901127E7CEE2421F582EF
+:107E4300EF127F7DE0FAA3E0FBEA4B6003121155CA
+:107E53007C237D007900EEFAEFFB1210D7850882B0
+:107E630085098374FFF0A3F08E828F83A3A3A3E419
+:107E7300F0F980027902027EF4E0FAA3E0FB120A31
+:107E8300DD22C082C0839003F5E06A7003A3E06B38
+:107E930070067AF47B0380047A007B008021C08221
+:107EA300C0839003F5E0F47003A3E0F4600D900346
+:107EB300F4E06970067AF47B0380047A007B00D0D7
+:107EC30083D08202012274F6122051E9FE74FE6A05
+:107ED300700374FF6B700479018016120AB98A82E9
+:107EE3008B83E58245836007A3A3A3E05E70E879F3
+:107EF300007F02022123C082C08379009003F7E050
+:107F030060010980BA74F4122051EAFEEBFF89087C
+:107F1300120AB9EA4B701274FE6E700374FF6F702D
+:107F2300047900804C79148048EA2421F582EB120D
+:107F33007F7DE0F8A3E0F9EA2403F582EB127F7D6D
+:107F4300E849700FE0A2E4500654126410701179EE
+:107F530005801EE0A2E150F7A2E44004790F8011EE
+:107F6300E8241AF582E9127F7DE0C3950850B279BF
+:107F73000C7F04022123F582E5093400F58322C036
+:107F830082C083EAF8EBF9E84960179003F5E0F45F
+:107F93007003A3E0F4600B7AF47B03888289831275
+:107FA300204F027EC274F6122051EAFEEBFF8908CD
+:107FB300750900E509127FDFE0F8A3E0F9888289FB
+:107FC30083E58245836009A908EEFAEFFB12204F8F
+:107FD3000509E509C3940C40DA027EF4C333F8E4DF
+:107FE30033F9741728F582740439F58322C082C0EB
+:0D7FF300839009C0E0F9D083D08202012202
+:10800000033F0000030004280D9808900790019496
+:10801000011B0195111B08F00939821F0EA4FECD2A
+:1080200082210622FB381818162118F0EF3818F2B2
+:10803000ED3828F2EB3868F003392A1FE73F08F0E3
+:108040000428C33868F0393C08F1053C88F1173C36
+:10805000A8F10E3CE09F2C1F0128104A291FD63F93
+:1080600015D0033827D0093800900428A83F0128EC
+:10807000154101980128014A25D01F38041F831F8C
+:108080000EA4FECD042205381421202807A0083FA5
+:108090000628711527D0E939202807D0F238832126
+:1080A00078F10238042188F1083D0628A14001F04A
+:1080B00004288D38042807A00528561528F1163CF9
+:1080C00068F1143D77CF1240599202D80F3912D07F
+:1080D0000739699222D00439799242D004380528B0
+:1080E000F8151E3FC09F0428753F08F1233C88F116
+:1080F000203D094028F1103D4540F7C759F2083DA1
+:108100009303131183E1B9F00F3C23E00D3F09D82D
+:10811000EA38F9C30B3F68F1033D59F2F23C09D844
+:10812000F9390528C6150528F91501900128214AB5
+:10813000051F48F00C3C08F10A3868F1033C98F13F
+:1081400006390C96062802150228843F47A00C9693
+:108150000528FC15531F0528EC1507288CED05286C
+:10816000F51501280195711B01280CE40528EE1571
+:10817000511F88F10B3808F1073868F109390128D7
+:10818000214201F00B3947D009383521063F28F14B
+:10819000033838F10339351F341F04280CE047D069
+:1081A000033903280CE80528D115571F28F0063895
+:1081B000561F811F021F38F0063930215B900528B9
+:1081C0004415FD3F88F1033D0528001505288A1553
+:1081D00047D0133808F10F392C470CF00C38C40382
+:1081E000B4125C110C3E04F00A38C103802801A0CF
+:1081F000411B063F3021043F07284CED4C1B5B9090
+:1082000047D0173827D00328F1390EA4FECD02221B
+:108210000D39002208381021002914E00328E63C1B
+:108220004C1BF13F0528A715EE3F46181221033FCE
+:1082300005280B1588F1303905281A150128FB414E
+:10824000302100291BE00A3D0428FF1505281015E0
+:10825000F6C35192166A3B906B080428F615052860
+:1082600007150BF0FB3917D004382D1F0128C43F28
+:108270000328214701F008390328314701F0043968
+:10828000A2958090033FC29500920328BF15201B42
+:1082900054900128B33F08F10539052111900128B8
+:1082A000214A38F103390021023F302110216A03AD
+:1082B0000428CB156B033141224128F1093D02F01E
+:1082C0000239F29101F00B39FF28F191083F02F0D9
+:1082D0000239529201F00339FF28F193F7CB1B06C4
+:1082E000023907A4B20C073D47D003287738249001
+:1082F00003287E3F1690B6080428BA15A603042862
+:10830000B7153BE0F7CE28F1703C012807A0F090AC
+:10831000A00668F1323D149030F0053938F1032899
+:108320006738073F50F00328633958F10328603855
+:1083300038F104380328B415033F032892150328A5
+:108340007E15012807D0033907A1563F424130F07E
+:108350000C3907A112D0033807D84E3887A0C14086
+:1083600041D04A38F7CE483F38F1033822D044385C
+:1083700007D8423907A1403F78F1123847D02D384D
+:1083800000F0033860F00639C14011D0073887A0EB
+:10839000113F10F0033820F0AB3977CF0B3F00F0DE
+:1083A000033810F0A539414181D00439032859150B
+:1083B000093F0328751568F10539414141D002395B
+:1083C00007B810F0063903283A15012807D00338FA
+:1083D00007D8123907A1103F40F0032805390328B8
+:1083E0001D1507D8F838083FA10383403112310525
+:1083F00011D0023907A14BF0063C042826150428A9
+:108400003715FA3F042821151BF0FD3D38F10338DC
+:108410000328AA15F7CD0328214701F005390328C1
+:10842000314701F0033807A2F7CE224082D00A3844
+:10843000060304281D1506937606261196040428C3
+:10844000171571034112002871C021070438E7CFC6
+:108450004198043F17D0043951980728214817D074
+:108460000538F295202800901D3F07D20438C295A8
+:108470000092183F07D10438D2950094133F07D4D7
+:108480000438E29500980E3F809028F10A3D319023
+:10849000A10631F0063903A4B2950228B31500A154
+:1084A000A2950228AF15201B28F1633D08F10A3977
+:1084B000012807D00739072851411128C14A01284E
+:1084C00007A017D20539E3CF8AD0023813A007D20C
+:1084D0000539B3CF4AD0023843A083D01E393103C7
+:1084E0001112310521D00739319907282148002977
+:1084F00015E0133F529502288515454003D10D39EB
+:10850000429502287F15281F21990728214803D268
+:10851000043862950228761573CF834808F109392B
+:1085200077CF17D0063907D203390AD1023887A08E
+:10853000349007D2073807D803383090543F07A843
+:10854000023FF7C718F15A3927D04C39314011D0C2
+:10855000493987D0073917D0453907D203390AD1AD
+:10856000413805F04B39414001F0483850903B3FCD
+:1085700068F1153878F13938149017D03D3907D2A1
+:108580003D3987D003383490393F07D137391190BE
+:108590000128214A409003287715253F47D01C38F1
+:1085A000249007D30C3911900128214A87D008382C
+:1085B0005144002911E0043A514C023877CF17D0CA
+:1085C0001B3987D003383490193F07D31739C1407E
+:1085D00021D01438073F17D00F3907D30338309014
+:1085E000023F009044900A3F249017D0053907D3EA
+:1085F00005393490033FA09F44900221C190511B44
+:108600008121342124F0083927D004390C9CFD2B1A
+:10861000AE3F10904490B7CF34F00E395321032869
+:10862000E195711B541F0F28CC9506282141F1C0FC
+:1086300081111C09143F0190511B0728F19F711BE8
+:10864000802114F001288F3854F0FD2B0A380128BE
+:10865000B63F541F03286D151028CCED032876155E
+:1086600076217821501F0128A29A217001B2218021
+:1086700001B221802CE30328691574210128ACE4A0
+:1086800008F1073C88F1033D0228A01503282A15AC
+:10869000011F0128349D03285915201F002168F06F
+:1086A000093D069058F003390728364102289C15E9
+:1086B000FA3F0728504078F10439331F321F042154
+:1086C000500000DC0128853828F1103D8340F7CBAD
+:1086D00031031112310521D0033903D1033900D8F8
+:1086E000103807A41B901A90163F00D80128713942
+:1086F00098F107394B700128E2412B0800288E3F82
+:10870000102807A04B701BF0FC2BED3C4A70224157
+:1087100028F1303D02F00239F29112E0B20CFC2B4C
+:10872000E23C419031061111FF2BE29F32045200CE
+:1087300022111A042A043240002862C018F10339B9
+:1087400027D00D3922F0093907280141B109002944
+:1087500021E0093A0AA1073F42F00339FACE033F6C
+:1087600062F0F93818F1253977CF0AD1223887A07D
+:10877000203F02F00239529212E0B20CFC2BB33CC3
+:1087800068F1123D38F1153887D01339012831428C
+:1087900001F00F38402807A00728914231C0C1A03E
+:1087A0000728914A063F02280190710621121A04F7
+:1087B000FF2BF29FB2084BE0A603022815152603F3
+:1087C0000228121568F1293CFBF0273C62904670A4
+:1087D00002280A15D2370428609662904670062D4A
+:1087E00002280215C23778F11839D04000D8153860
+:1087F000DBF0133C829046700128F615D2377644A0
+:1088000000D40338060E023F060D41700128EC1516
+:10881000417086120128E8153290B20C053D467071
+:108820000128E215FB3F08F1063941721128C14ABF
+:10883000012807A0EF28F7CF28F11E3D8340309094
+:10884000A00631031112310521D003398295043F6E
+:1088500030F0043972950028D51553C843D002383A
+:1088600023A007D4023803A130F0023903A28348C1
+:1088700092950028C71506900BF005380128B4150D
+:10888000591FFB3F0EA4FECD0122043902287315A7
+:10889000FA3F551F1121031F249008F10F390AD107
+:1088A000033987D02438314011D0213905F02139DE
+:1088B000414001F01E3850901B3F48F1073828F125
+:1088C000033858F1063987D0143877CF1490113F08
+:1088D00078F1053911900128214A093F98F10939A9
+:1088E000829500289315281F5490033F00904490D0
+:1088F0000EA4FECD0322043902283D15FA3F1321B0
+:108900002C1801210321741FD1900000F13724F0AD
+:10891000093800000190511B0728F19F711B80212D
+:10892000063F4190511B0328E195711B3221072816
+:10893000914231C00728914ABF28F7CF28F1063C61
+:1089400088F1043D92955E15281F44F0383814F0E4
+:108950000A3854F0FB2B853801280CE40128F61561
+:10896000FB2BF93F01289015009027D0283902D819
+:10897000083838F12439329001289215E237193F2E
+:1089800019E089F2043C38F11A39599238F1033967
+:108990000128861512409103002951E2120E12D0CF
+:1089A000F038012886150128B915124001289115C3
+:1089B0003199072821482C18FE2B4C3F0128104ADA
+:1089C0000028A915FB2B223FF09F043FD09F023FB8
+:1089D000B09F0028D0152C1FF23F28F1053C68F10C
+:1089E000033D1490053F2090023F10904490419821
+:1089F0000728214838F1FE2B01380028B515FD2B3A
+:108A0000FD3F217011E0218002000128214107284B
+:108A10002148217811E021880200F7C776157103FB
+:108A20003112A10501D4023907A804286496311532
+:108A30000238F7C70428C4F6FB3C0200FE28F7CF33
+:108A4000641551417111A10501D80339012807A00E
+:108A500064911F150338FE28F7CFC4F1FB3C0200D8
+:108A6000F7C753155141022807A00AD40339FD283E
+:108A7000F7CF5111A10501D4023907A8C4910428E8
+:108A8000659607150238F7C7563124F2FB3C020001
+:108A90000028DB150028EC15412D160C0200F7C745
+:108AA0003415D032D332234268F109394141904024
+:108AB00041D0043850000306023F0303314202282C
+:108AC00007A00AD404395100FD28F7CF13064492B9
+:108AD000042865960028B9150028CA155631FF28C4
+:108AE000E19F4070060C023813068EA0810064E0FE
+:108AF00044F5F83C0029F4E2A4F2ED3C03F002381E
+:108B000007A8D32FD02F02009BF0023C020007A140
+:108B10002DE0020098F10938102807D0033908F138
+:108B2000043831990728214808F10C39012807D069
+:108B30000938072851411128C042010C0338072881
+:108B400050491190082807D005380628B148F72861
+:108B5000F7CF042807D005380628A148FB28F7CF0F
+:108B60003021291F0200311FFF28F19F411B301FB8
+:108B70003121020002210121032153230938062853
+:108B8000D14001D112384198072821480B3F542386
+:108B90000C385021F1910000F137741FF190000062
+:108BA000F13768F0023C2B1F0190511B81210728EF
+:108BB000F19F711B80210728914231C00728914AFB
+:108BC000BF28F7CF322134210200082807D0073907
+:108BD0000628B14001F00438082807A00200042844
+:108BE0000D98FE2BF43F402807D00D390EA4FECD82
+:108BF000012204390028BF15FA3F661B1121002904
+:108C00001BE002000728A64A0EA4FECD012204396B
+:108C10000028B115FA3F01283142B10941E0053A77
+:108C200008384BF00C38EA3D0728A142611BE73FAA
+:108C30000728914271CF0728914AF73F07289142B0
+:108C400081A20728914ADA3F0EA4FECD0222043900
+:108C500000289115FA3F4618122100291BE01BF04D
+:108C60000639581F0628E0400128004A020017D0A4
+:108C70000A393122063817A0419807282148033FB6
+:108C80000728A6480200124038F1093802D80739EF
+:108C90009103002941E2120E120D1248020047A072
+:108CA0007B280C9C10215215FF2B5E15B7CF0200BC
+:108CB00059F203396391083F69F20339E392043FA3
+:108CC00079F203394396020004280D98FA2B0B3FE2
+:108CD00002D407389103002901E211700628614887
+:108CE000020088F10A3C012831410728814AB14637
+:108CF0000328314FA1460F3F0728894A28F1063D36
+:108D000031440328314F5140053F552851950328E0
+:108D1000314F81110328214F0200E3F3033CF1900E
+:108D2000033F23E051920628614A06284348020087
+:108D30007B21772141900000F137702175217A2144
+:108D40008CEE0415521F801F02004C1B001F47D0E1
+:108D5000033827D009390EA4FECD002203390B15A4
+:108D6000F73F1021020004280D9838F1FE2B273818
+:108D7000FE2B3C3FD23202180119210601D41A38C9
+:108D80001218162162F003392A1F2D3F12F21538EE
+:108D900022F22838FE2BEF1568F0063C619001287E
+:108DA000114AFE2BB8153021280304280D98F92B01
+:108DB0002E3F01D114381421202807D00D3878F126
+:108DC000123904231038714401F00239814400291A
+:108DD00011E0714C083F202807A0053F01D205385B
+:108DE000152127A0D22F020011D006381021042807
+:108DF0000D98FD2BF33FF2CE5200121BF43F4F05AE
+:108E0000C5075B05CB076705D1077305D7077F0546
+:108E1000DD079105DD079D05E3077305E9078B0570
+:108E2000EF0700000000AF05EF07BB05F5070000E6
+:108E30000000000000000000000000000000000032
+:108E40000000000000000000000000000000010120
+:108E500002010201010201020303040103010101F5
+:108E600001010303020103E90AED12A110110A3501
+:108E7000071F080510FB13871249085B14FB349B7E
+:108E80005F80000080001000000000000000000073
+:108E900000000000000000000000000087F401FA5C
+:108EA00000960064004B0032001E001400FE0065B6
+:108EB00078706572696D656E74616C7869E0AB504D
+:108EC000C3F0D20000000000001B65076B07000024
+:108ED000091200000000F111F71100000000AF08B6
+:108EE0000000000000000000D311D9110000B712EB
+:108EF000BD12000057494D5533003114371400009E
+:108F000043445256003030255800F1FFFFFF1A004D
+:108F10000000E7FFFFFF07000000F6FFFFFF020071
+:108F2000000001C80000FF7FFFFFD6BE898E7102DE
+:108F300000000595D5F5FFFFFF0006000000F401D5
+:108F4000000000000000555555000008000000001A
+:108F50000000900100006400000000001000030009
+:108F60000000FFFFFFFF0500000040420F00E80384
+:108F700000000A000000010000000C00000060EA90
+:108F80000000FFFF00005000000002AF8F02D98FE9
+:108F900002C78F02AD8F02E38F02A98F02E98F25EE
+:108FA0002A242A232A502A192A0F182A2A001801AB
+:108FB0001800280128032801290229292A012A0248
+:108FC0002A032A042A052A19186A2A672A082A69FC
+:108FD0002A282AAD76AC769D7505182B2A272A8675
+:108FE000740400EE70002A262A0A180B74F012206E
+:108FF0005174FD121FDC7402122045E9F08A088BBF
+:10900000098C0A8D0B7415122045E0FEA3E0FF8544
+:109010001882851983E4F0A3F08E828F83A3AA823D
+:10902000AB839011BE780C121EAC7808790C121626
+:109030008070188E828F8374691294CB746EF0A343
+:109040007466F0A30A0AAB83029466780879081262
+:10905000168060118E828F83746E1294CB7461F0CF
+:10906000A3746E80DD9011C2780C121EAC78087962
+:109070000C1216AC5003029116908F42780C121EFF
+:10908000AC7808790C121680600302916A7417128A
+:109090002045E070030291AC851882851983C08257
+:1090A000C0837413122045129F09D083D08212947A
+:1090B000A4502C851882851983C3E094FCA3E09406
+:1090C000FFA2D265D03340177402122045E4129FEC
+:1090D000DDF97413122045C3E098F0A3E099F07411
+:1090E000131220451294C17418122045E070030237
+:1090F00091A97417122045E40291AB9011C6780C27
+:10910000121EAC7808790C121B038518828519830E
+:10911000E0240A12A01A9011CA780C121EAC78082A
+:10912000790C1216AC40D49011CE780C121EAC788B
+:1091300008790C1216AC400302908D9011CE780C79
+:10914000121EAC7808790C121B0312A01180D89063
+:1091500011C6780C121EAC7808790C1217478518C6
+:1091600082851983E024F61294C49011D2780C12EF
+:109170001EAC7808790C1216FB40D49011C2780C02
+:10918000121EAC7808790C1216FB400302908D90E9
+:1091900011CE780C121EAC7808790C12174785187E
+:1091A000828519831294C180D27401F07402122056
+:1091B00045E060077A007B000292B81294B0507DBF
+:1091C0008E828F837430F0EAFEEBFF741312204519
+:1091D000E0FCA3E0FDEC4D70087418122045E0603F
+:1091E0000B8E828F83742EF0A30EAF837A007B00E8
+:1091F00080118E828F8374301294EC741312204588
+:109200001294C1EA24FF1AEB34FFFB8518828519FA
+:1092100083129498500B7413122045129F0D4970BD
+:10922000D185188285198374FFC39CF874FF9DF95A
+:109230001294A450030293867A010291B685188293
+:10924000851983129F09C3E498FAE499FB80698524
+:10925000080C85090D850A0E850B0F780C121595E3
+:10926000AC0CE50D3395E0F50EF50F780C12151DDD
+:109270007808790C1218C79011CE780C121EAC78B1
+:1092800008790C121747EC1294E6EAF8EBF9E82497
+:10929000010AE93400FBE849701E741312204512DC
+:1092A0009F0D4970087418122045E0600B8E828F64
+:1092B00083742EF0A30EAF8374131220451294987A
+:1092C000508D9011D6780C121EAC7808790C1216BD
+:1092D000AC40030293867C01EE24FFF8EF34FFF9E3
+:1092E0007415122045E0F508A3E0F509888289830A
+:1092F000E0642E6010E02CF0643A70077430F07C6B
+:109300000180027C00E8FAE9FBEA24FF18EB34FF55
+:10931000F9C3E5089AE5099B40D2ECA2E0506774D6
+:1093200002122045E06036EEF8EF800A129483E8DE
+:1093300024FF18E934FFF9C3E50898E509995018A6
+:10934000129470E0642E70E4E824FEF582E934FFA4
+:10935000F58312947DF980D712A011801E8E828F22
+:1093600083A3AE82AF83EEF8EF800612947012945E
+:109370007DF9C3E50898E5099940F0741512204578
+:10938000129F287431F07417122045E07005801A7E
+:109390001EAF83EE24FFF582EF34FFF583E06430E7
+:1093A00060EEE0642E70031EAF837402122045E06D
+:1093B00070030294621294E8A3A9831294B08E827F
+:1093C0008F835014742DF00EE9FF85188285198360
+:1093D000129F511294D98006742BF00EE9FF7C0085
+:1093E0007D00EE240AFEEF3400FFEC24010CED3486
+:1093F00000FD12948A121F49EA1294E612948A120E
+:109400001F491294F34970E2C3EC9402ED129EBA24
+:1094100040D8ECFAEDFBC3E49CF8E49DF9EE28F5A6
+:1094200082EF39F583E0C0E0C3E49AF8E49BF9EEFB
+:1094300028F8EF39F9E82CF8E93DF9E824F5F58248
+:10944000E934FFF583D0E0F0EC24FF1CED34FFFDA0
+:10945000C3EC9401ED129EBA50BCEE24F6FEEF343C
+:10946000FFFFEEFAEFFB7403121FF27F08022123C5
+:10947000E824FFFAE934FFFB8A828B83221294836B
+:1094800018EB22E088828983F0228518828519836F
+:10949000129F5E7A0A7B0022C3E09AA3E09BA2D2CD
+:1094A00065D03322C3E098A3E099A2D265D03322DD
+:1094B000851882851983C3A3E09400A2D265D033B6
+:1094C00022E024FFF0A3E034FFF022F0EAFEEBFFFD
+:1094D0008E828F8322A3E03400F985188285198358
+:1094E000E8F0A3E9F02224308E828F83F0A3AE82CD
+:1094F000AF83228518828519831294FD22E8F0A398
+:10950000E9F0851882851983E02274F012205174E5
+:10951000B0121FDC851882851983129FC37418123C
+:109520002045ECF0A3EDF0740F122045E4F0A38089
+:10953000227460122045129EF97404122045E0F94D
+:109540007418122045129F2812204F740F122045C4
+:10955000129EC2F0129F3CFA129FFC122045EAF0C4
+:1095600074256A6010E070C9740F122045129EF9CC
+:109570007450029468129F3C642570198518828586
+:109580001983E02401081294D57460122045129EBC
+:10959000F9792580AB740E122045E4F0740D122089
+:1095A00045E4F0740C122045E4F07405122045E403
+:1095B000F0741E122045A882A983740212204580EF
+:1095C000157405122045E070077405122045EAF075
+:1095D0008518828519831294F9129EF0129F83FADE
+:1095E00024E060DD24FD601724F860DD24FE6006C1
+:1095F00024FD600F8011740C122045E00480D074AB
+:109600000D80F5740E80F1129F83642A705B746282
+:10961000122045129F8EFB8A828B83E0FCA3E0FD23
+:10962000740A122045ECF0A3EDF0EA24020A0AEBDA
+:109630003400FB7462122045129FBB740A1220454D
+:109640001294B6501F740A122045129EF9C3E49A70
+:10965000FAE49BFB740A122045129FC3740C12207B
+:1096600045E004F01294DA804A740A122045E4F0CE
+:10967000A3802D740A122045129F0D75F00AA4F8DC
+:10968000AAF075F00AE9A42AF9E50828F8E439F9FE
+:10969000E824D0F8E934FFF9740A12204512A02119
+:1096A000129FDDF5838882E0F50874D02508C39405
+:1096B0000A40C0740C122045E06007740E12204569
+:1096C000E4F0129F3C642E60030297558518828552
+:1096D0001983E0240108A3E03400F91294F3129FE7
+:1096E0002DE0642A702C7462122045129F42F8A368
+:1096F000E0F988828983E0FEA3E0FFE824020808FD
+:10970000E93400F97462122045129F7612A021F00C
+:1097100080477E007F00851882851983129F4B74D5
+:10972000D02508C3940A5031EE75F00AA4FEA8F0C3
+:1097300075F00AEFA428FFE5082EF8E43FF9E824C5
+:10974000D0FEE934FFFF851882851983E02401F8F3
+:109750001294D580C17EFF7FFF7A0085188285191B
+:1097600083129EEB851882851983E0FBA3E0F583C5
+:109770008B82E024B4600824E4600524FC70040AB1
+:109780001294DA129F3CFB129FFC122045EBF07002
+:1097900003029D6024BB7003029C2624FE7003021A
+:1097A0009C0824EF700302995224F5700302985725
+:1097B0001470030299F7147003029C2614700302BC
+:1097C0009C24147003029C0824FE70030299F72461
+:1097D000FB6024147003029942147003029952240E
+:1097E000FD700302989024FE700302995224FD70CC
+:1097F00003029952029D6C7462122045129FB512A9
+:1098000020451294E0EAA2E0740F5033122045E0A4
+:10981000FCA3E0FD3395E0FE7406122045129F96EE
+:10982000ECF0A3EDF0A3EEF0A3F074621220451269
+:109830009F9D122045129F76E8F0A3E902955312EE
+:109840002045129F097406122045129F8EF5838AC7
+:1098500082E8F0A3E980D27462122045129F96E05C
+:10986000C0E0741E122045D0E0F074621220451250
+:109870009F9D122045129F761294E0741F1220457E
+:10988000A882A9837412122045E8F0A3E9029D83FF
+:109890007462122045129FB51220451294E074069E
+:1098A000122045129FB5122045E02402FAA3E034AD
+:1098B00000FB7462122045129FBB740212204512F5
+:1098C00094E0E849700C740212204574ABF0A37464
+:1098D00011F0129EB850047E107F277408122045A4
+:1098E000E4F0A380087408122045129EC2F07402AE
+:1098F000122045129F0988828983A3AA82AB8374B0
+:1099000002122045129FC388828983E0600A74088E
+:10991000122045129F1240CD7402122045129ED98A
+:1099200074121220451294E07408122045129F51BF
+:10993000F97412122045E028F8A3E039F974020204
+:109940009886740D122045E06008EE4F70047E0189
+:109950007F007462122045129FB512204512A009A3
+:10996000122045E0647070387406122045129FABD7
+:10997000122045129FE4122045E02402129F6D122E
+:109980002045129F761294E09011DA121ECA741AC2
+:10999000122045121ED67405122045E4F0029A8763
+:1099A000EAA2E07406501B122045129F28121ECA1C
+:1099B0007414122045121ED67406122045E02404A9
+:1099C0008012122045129FAB122045129FE41220F4
+:1099D00045E02402129F6D122045129F7612A009C5
+:1099E000122045E0646F70059011DE809EE0647582
+:1099F0007096908F7280947462122045129FB512F7
+:109A000020451294E0EAA2E0740650161220451296
+:109A10009F287808121EAC7406122045E02404F832
+:109A2000801B122045129F4BA3E0F5093395E0F50A
+:109A30000AF50B7406122045E024020808129F6EF6
+:109A4000122045129FF11220457808121EBB908FFC
+:109A50004278081214B840217405122045742DF084
+:109A600074141220457808121EAC7808121DDC749C
+:109A7000141220457808121EBB908F72121ECA74F1
+:109A80001A122045121ED6744F122045A882A983AF
+:109A900074021220451294E07412122045129FF4B1
+:109AA0001220457808121EACE5084509450A450B09
+:109AB000600974111220457401800674111220454A
+:109AC000E4F0EE4F7008E0A2E04003029B7B7402DA
+:109AD000122045129F22122045129FF41220457831
+:109AE0000C121EAC741A1220457808121EAC780CA9
+:109AF0007908121D69749A2508F58274113509F5E3
+:109B000083E0C0E07402122045129F28D0E0F07478
+:109B100014122045780C121EAC741A1220457808D5
+:109B2000121EAC780C7908121D6974141220457845
+:109B30000C121EBB74141220457808121EACE508E6
+:109B40004509450A450B7086129EB8502E740E12B8
+:109B50002045E060267405122045E06004D2F080C4
+:109B600002C2F0740A122045129ECB800E740212BB
+:109B70002045129FD5122045129F357402122045B0
+:109B8000129ED9744F122045C082C08374021220E5
+:109B900045129EF9D083D082E582C39AFAE5839B71
+:109BA000FBC3EA9EEB129F1B40C3740D122045E0DD
+:109BB0007003029D847411122045E0A2E04003026C
+:109BC0009D847404122045E064786005E064587058
+:109BD0001E129483E824FF18E934FFF9740212205E
+:109BE00045129FD5122045129F287430029D83E0B4
+:109BF000646F6003029D847402122045129F896481
+:109C0000307003029D8480D474081220457401F0E2
+:109C1000A3E4F07404122045E024FEF0EE4F700F30
+:109C20007E018012E4F07408122045E4F0A3F012E3
+:109C30009EB850047E067F007462122045129FB5C4
+:109C40001220451294E07406122045129F28780CC9
+:109C5000121EAC7406122045E02404129F6D1220DF
+:109C600045129FF1122045780C121EBB908F42784E
+:109C700008121EAC780C79081216FB5022740512DB
+:109C80002045742DF074141220457808121EACE59E
+:109C90000BB2E7F50B74141220457808121EBB7442
+:109CA0000A122045129F09741E122045E58228F8E9
+:109CB000E58339F974021220451294E0740D1220E4
+:109CC00045E0F50878081222687409122045E0F58D
+:109CD000087808122268740412204512227B8E082C
+:109CE0008F097808122264740A122045E0F9741A68
+:109CF000122045121ECA1214977406121FF2741213
+:109D0000122045129FC3740E122045E06076740540
+:109D1000122045E06004D2F08002C2F0740A1220E2
+:109D200045129ECB7412122045C082C08374021269
+:109D30002045129F09D083D082E0C398F8A3E09910
+:109D4000F9C3E89EE9129F1B503A74021220451293
+:109D50009F22122045129FD5122045129F3580C4A4
+:109D6000851882851983129EE21294D974021220FA
+:109D70004574BAF0A37411F0741212204574BDF04A
+:109D8000A37411F07412122045C082C083740212B1
+:109D90002045129F09D083D082E0C398FEA3E099AA
+:109DA000FF740A122045129F12500A7408122045AF
+:109DB000E4F0A380307405122045E06004D2F08006
+:109DC00002C2F0740A122045E0C39EF8A3E09FF996
+:109DD000A2F0E433FAE89AF8E99400F97408122042
+:109DE00045E8F0A3E9F0740C122045E0702B8019CF
+:109DF0007460122045129EFF122045129F281220E7
+:109E00004F740F12204512A0177408122045129F9C
+:109E1000C91220451294B650D77405122045E0604F
+:109E2000507460122045129EF97405122045E0F925
+:109E30007418122045129F2812204F802C74601233
+:109E40002045129EF97402122045129F42F974189F
+:109E5000122045129F2812204F7402122045129E94
+:109E6000EB74021220451294E0740F12204512A0E8
+:109E700017EE24FF1EEF34FFFFC3129EBA50BE74CC
+:109E80000C122045E070030295547408122045120C
+:109E90009FC91220451294B6500302955474601263
+:109EA0002045129EFF122045129F2812204F740F4A
+:109EB00012204512A01780D2C3EF9400A2D265D021
+:109EC0003322E02401F0A3E0340022A2F0E433F8CE
+:109ED000E098FEA3E09400FF22129EDD22129EE293
+:109EE000F922E024FFF8A3E034FF22E0129EF022E2
+:109EF0002401F8A3E03400F922E0FAA3E0FB22E019
+:109F0000FAA3E0FB7920741822129F5E22129F5E52
+:109F1000E822C3E09EA3E0129F1B229FA2D265D03D
+:109F20003322129EDD740222129F2C22E0F8A3E05D
+:109F3000F583888222129F2C7430F0228518828546
+:109F40001983129F4622129F64E022129F46F50851
+:109F500022129F5EC3E498F8E49922129F64E0F80D
+:109F6000A3E0F922E0F8A3E0F583888222F8A3E0D9
+:109F70003400F9746222129F7A22E0FAA3E0F5839A
+:109F80008A8222851882851983129F7AE022129F85
+:109F90007AE0FAA3E022129F46129F2D22129F46DA
+:109FA0002402F8A3E03400F9746222129F5BE8FAFD
+:109FB000E9FB741422129F5B740622E0FCA3E0F517
+:109FC000838C82EAF0A3EBF022E024FFF0A3E034DC
+:109FD000FFF0740822E8F0A3E9F074022212950160
+:109FE000F8A3E022EAF0A3EBF0A3E4F0A3F07406F8
+:109FF00022129F7AE8F0A3E9F07414228518828572
+:10A000001983E024010812A02FE8F0A3E9F07404FA
+:10A0100022851882851983E02401F0A3E03400F042
+:10A02000221294FD2401F812A02FE8F0A3E922A344
+:10A03000E03400F98518828519832274F6122051C4
+:10A0400090035174FEF0A304F0900354F090035376
+:10A05000F07A018A0875090074027808121FC91283
+:10A06000AE5CEA88828983700774FEF0A3048004E2
+:10A0700074FFF0A3F088828983A3A3A3F088828968
+:10A0800083A3A3F00AEAC3940240C87ABF7B0712F5
+:10A0900008137A0D7B08120AA7790002ABFE74F24E
+:10A0A000122051EAFEEBFF8E828F8312A678604663
+:10A0B00012AD8E12A1D8750B00780A1222648A8222
+:10A0C0008B83A312227B12A630121FF2E9702C851B
+:10A0D000088285098312A1D8780A1222648A828BA9
+:10A0E00083A312227B7C027D007AB37B8F12A63879
+:10A0F000121FF2E97005790202A1C4900EE812A6BF
+:10A1000078600CC3E498FAE499FB12A1C950057970
+:10A110000102A1C47A067B0012114F8A0A8B0BEA56
+:10A12000450B7005791302A1C47A007B0080409032
+:10A130000EE812AB4C8A0C8B0D7403780C121FC9FD
+:10A14000850882850983E0250CF8A3E0350D888217
+:10A15000F583A3A3A3A3ECF0A3EDF0900EE8E02415
+:10A1600001F0A3E03400F0EA24010AEB3400FB1212
+:10A17000A1C940BB850A82850B83E4F0A3F0750872
+:10A1800004F5097808122264EEFCEFFDE50A2402CA
+:10A19000FAE50B12AB3F121FF290035912A678900A
+:10A1A00003596017E0FAA3E08003E8FAE9FB8A822A
+:10A1B0008B8312A67870F38A828B83E50AF0A3E57D
+:10A1C0000BF079007F060221238E828F83E0F8A3B3
+:10A1D000E0F9C3EA98EB992212ADA38A828B83E05F
+:10A1E000F50A22C082C083E9900EE7F0D083D082C6
+:10A1F00002012274F7122051E9FE74145E6007799F
+:10A2000010120AD1800BEEA2E0400479028002799C
+:10A21000007F0102212374F7122051ECFEEDFFE9CB
+:10A22000A2E550077910120AD18034A2E3502679B2
+:10A2300010120AD1E96026EE2418F582EF3400F5F9
+:10A2400083E0601BEE2417F582EF3400F583E064B1
+:10A2500001600A800AA2E14004790380027900804B
+:10A26000B074F412205174E9121FDCEAFEEBFF898E
+:10A2700008E4F50AF50B780A122264750A02780AD6
+:10A28000122264750AC5750B8F780A1222647CFF4E
+:10A290007DFF7A017B0012AD88121FF28A828B83C8
+:10A2A000E5824583605412ACC685188285198312F5
+:10A2B000AE1F74021220457404F01412204574017C
+:10A2C000F07404122045E4F0740512204574FFF088
+:10A2D000740612204574FFF0E508F509780912228A
+:10A2E0006879007401122045AC82AD83EEFAEFFB71
+:10A2F0001207AD7401121FF2800279017417121F48
+:10A30000F27F0402212374E81220518A168B178CE5
+:10A31000128D137418122045E0F514A3E0F515749E
+:10A320001A122045E0F50AA3E0F50B741C12204533
+:10A33000E0F510A3E0F511900359800685088285A9
+:10A340000983E0F508A3E0F509E508450970030273
+:10A35000A3F37E007F00E5082404F50EE509340030
+:10A36000F50F8008EE24010EEF3400FF850882858A
+:10A37000098312ACC8C3EE98EF9950C08E0C8F0DB4
+:10A380007403780C121FC9850E82850F83E0250C9B
+:10A39000F50CA3E0350DF50D850C82F58312ACC6E6
+:10A3A000C3E89516E9951740BBC3E51298E51399E4
+:10A3B00040B2E50A450B6020780A12226478141234
+:10A3C0002264850C82850D83E0FC7D0012AD9E1217
+:10A3D000A638121FF2E9608CE5104511600F850E5A
+:10A3E00082850F8312A97612ACC612AE19AA0CABE5
+:10A3F0000D80047A007B007F1002212374EE12206E
+:10A4000051ECFEEDFF900359E0FCA3E0800A8C8242
+:10A410008D8312ACCAE8FCE9FDEC4D700302A4BDCB
+:10A420008C828D8312ACC6880889098882F583A343
+:10A43000A3A3A3E0F50CA3E0F50DC3EA950CEB95FF
+:10A440000D40CB8C828D83A3A3E0F50EA3E0F50F26
+:10A45000E50C250EF8E50D350FF9C3EA98EB995098
+:10A46000AD750A00750B00800CE50A2401F50AE5BC
+:10A470000B3400F50BC3E50A950EE50B950F508ED6
+:10A48000850A10850B1174037810121FC9E5082581
+:10A4900010F8E5093511F988828983A3A3A3A3E005
+:10A4A0006A7003A3E06B70C1EE4F600B8E828F83E6
+:10A4B000E50CF0A3E50DF0E8FAE9FB80047A007BF7
+:10A4C000007F0A02212374EC12205174FE121FDC5B
+:10A4D000EAFEEBFF7416122045E0F50EA3E0F50F3F
+:10A4E0007418122045E0F510A3E0F5117508007509
+:10A4F0000900851882851983E4F0A3F0EE2404F5A1
+:10A500000CEF3400F50D850C82F58312ACBEA385EB
+:10A51000820A85830B74FF6A700374FF6B603B854E
+:10A520001882851983858208858309780812226438
+:10A530008E828F83E0F50875090078081222648501
+:10A540000A82850B8312227BEA24010AEB3400FB8A
+:10A5500012AD88121FF28A088B098E828F83E0F574
+:10A56000127513007812122264850A82850B8312F9
+:10A57000227B12A630121FF2E970268E828F83E0B2
+:10A58000F5127812122264850A82850B8312227BCF
+:10A590007C027D007AB37B8F12A638121FF2E9602D
+:10A5A00016850C82850D8312AD9F1207B98A0A8B1E
+:10A5B0000BA80AA90B80628E828F83E0F5127812B5
+:10A5C000122264850A82850B8312227B7C027D0025
+:10A5D0007AB57B8F12A638121FF2E96031E5084583
+:10A5E000096011851882851983E0650E7004A3E067
+:10A5F000650F6006AA0EAB0F80B0850882850983BF
+:10A60000A3A3A3A3E024FFF8A3E034FF800A850CF2
+:10A6100082850D83E0F8A3E0F9E51045116003128F
+:10A62000AE19AA08AB097402121FF27F0C02212393
+:10A630007C027D007AB17B8F1205CD740422C0822A
+:10A64000C08390035912A678602788828983A3A3C8
+:10A65000A3A3E0FCA3E0F5838C82A3A3A3A3E06AF9
+:10A660007003A3E06B8882898370DAA312AD9E80A9
+:10A67000047A007B0002A1ECE0F8A3E0F9E84922AB
+:10A6800074F312205174FE121FDCEAFEEBFF8C08FB
+:10A690008D09890A740F122045E0F50B8518828513
+:10A6A0001983AC82AD831207FBE9F50C7064E50AEF
+:10A6B000600E7910EEFAEFFB120AD1E9F50C705238
+:10A6C000AC08AD09EEFAEFFB12053DE9F50C70425E
+:10A6D000851882851983E0FEA3E0FF74FF650B6097
+:10A6E00031EE2402F508EF12ABB212226475081E97
+:10A6F0007509007808122264EEFCEFFD7A077B08EA
+:10A700001208317404121FF28E828F83A3A3A3E573
+:10A710000BF0A90C7402121FF27F0502212374F5BD
+:10A7200012205174FE121FDCEAFEEBFF8C088D092B
+:10A73000890A851882851983AC82AD831207FB7460
+:10A7400017696010E50A60167910EEFAEFFB120A3D
+:10A75000D1E9600A7402121FF27F03022123AC08C0
+:10A76000AD09EEFAEFFB12053780E974F6122051BD
+:10A77000EAFEEBFF1207A7EA4B600FEE24FFF8EFAB
+:10A7800034FFF9EA28FAEB398003EEFAEFFB02AB6B
+:10A79000FE74F012205174E3121FDC8A088B09EC5E
+:10A7A0002402FEED12AEB7F50E741E650E70531244
+:10A7B00008018A0A8B0BEA450B6042EA2403F50C78
+:10A7C000EB3400F50DE4F50EF50F780E1222648ED1
+:10A7D000828F83E0FD7C00AA08AB09850C82850D81
+:10A7E0008312AEC6121FF2E50A2402FAE50B34000A
+:10A7F000FB120837850C82850D8374FFF079000207
+:10A80000A971900EE7E0F46065E50EC39419505EFF
+:10A81000E50EC333F8E433F9E854FCF874FE28F885
+:10A82000748D39F9E824FCFAE934FFFB8A0C8B0DAE
+:10A830008A82F58312AD9FEA4B6033E824FEF582ED
+:10A84000E934FFF58312A67860248C828D83A3857A
+:10A85000820A85830B8C828D83E0F9700B850A82D6
+:10A86000850B83E06401700B7412650E6005790638
+:10A8700002A971740412204585820E85830F780E1B
+:10A880001222648C828D83A3A3A312227B8C828DDF
+:10A8900083A3A3A3A3A312AB4C850A82850B83E0F9
+:10A8A000FA850C82850D8312A97612204F7404124A
+:10A8B0001FF2E9F50C600302A96F7404122045AC85
+:10A8C00082AD83AA08AB098E828F83E0C333F8E49C
+:10A8D00033F9E854FCF874FC28F582748D39F5835B
+:10A8E00012A97612204FE9F50C702C8E828F83E02E
+:10A8F000FD74046D6079740412204585820A858395
+:10A900000B780A1222647C00AA08AB09900EE712A9
+:10A91000AEC6121FF28058850A82850B83E0704F05
+:10A920008E828F83E0851882851983F0740312204C
+:10A9300045E9F08E828F83E0F8740468600D740638
+:10A940006860087408686003741068740412204515
+:10A9500012ACCA740112204512AE1F8518828519E7
+:10A9600083AC82AD83AA08AB091204EF750C00A971
+:10A970000C741D02ACDFE0F8A3E0F5838882227935
+:10A980000002012274F012205174EA121FDC8A0CBA
+:10A990008B0D8C828D8312AD9F750A00EC2402FE14
+:10A9A000ED3400FF8E828F83C3E09AA3E09B4004C6
+:10A9B000EA4B7005790102AB34851882851983E46E
+:10A9C000F0E4F508F5097808122264780812226488
+:10A9D00078081222648E828F8312AB4C12AD8812DB
+:10A9E0001FF28A088B09A808A909E849700302AB7D
+:10A9F0001A88828983A3AA82AB83E82404F508E934
+:10AA00003400F509851882851983E0707188828980
+:10AA100083E06402700A74011220457401F08068BA
+:10AA200074011220457402F012AB5275F012A4F8B2
+:10AA300085F00BA90BE58228F582E58339F583A320
+:10AA4000A3ECF0A3EDF0750E10750F00780E122236
+:10AA50006412AB487402122045E075F012A4F8A904
+:10AA6000F0E58228F8E5833912AB39121FF2851818
+:10AA700082851983E004F0600302AAFF80727401EA
+:10AA8000122045E0640170A088828983E06402603E
+:10AA90000302AB1A12AB52F50E750F007402780E5A
+:10AAA000121FC9E582250EF582E583350FF583A3D4
+:10AAB000A3ECF0A3EDF0750E02750F00780E1222D4
+:10AAC0006412AB487402122045E0F50E7402780E51
+:10AAD000121FC9E582250EF8E583350F12AB391236
+:10AAE0001FF2851882851983E004F0C39405500F86
+:10AAF000850882850983E0F47003A3E0F470037590
+:10AB00000A01850882850983E02401FAA3E0340064
+:10AB1000FBE50AA2E0400302A9C1851882851983DA
+:10AB2000E07004790A800DAC82AD83AA0CAB0D12E3
+:10AB300004FB7900741602ACDFF9E82404FAE93466
+:10AB400000FB1210BF7402228A828B83E0FCA3E018
+:10AB5000FD22850882850983E0FCA3E0FD8518823B
+:10AB6000851983E02274F612205112AC034004EAE6
+:10AB70004B700479018033E4F508F5097808122256
+:10AB8000648C828D83A3A3A3A3E0F5087808122226
+:10AB90006412ABAC12226412AD84121FF28B09EA6C
+:10ABA00045097004790A800279008052EC2405F589
+:10ABB00008ED3400F50978082274F612205112AC21
+:10ABC000034004EA4B700479018033E4F508F50989
+:10ABD00078081222648C828D83A3A3A3A3E0F508D6
+:10ABE000780812226412ABAC12226412AD84121FD8
+:10ABF000F28B09EA45097004790A800279007F0224
+:10AC00000221238C828D83A3A3E0FEA3E0FF8C822C
+:10AC10008D8312ADA3C3EE9AEF9B2274F6122051DE
+:10AC2000EAFEEBFF8C828D837C007D0012ACD0703D
+:10AC3000047901800CA3A3A3E0F9EEFAEFFB12075D
+:10AC40008380BB74F01220518A0A8B0BECFEEDFF5F
+:10AC5000750C008002050CEE2416F582EF3400F529
+:10AC600083E0F8E50CC3985051E50CC333F8E433A6
+:10AC7000F9EE28F508EF39F5097C007D008508829A
+:10AC8000F58312ACD0701485088285098312ACCA92
+:10AC90008E828F8312AE1F79018021A3A3A3E0F9D6
+:10ACA000AA0AAB0B120783E960AB8508828509838A
+:10ACB00012ACBEEAF0A3EBF080027900802412AD62
+:10ACC000A38E828F8322A3A3A3A3E0F8A3E0F9229B
+:10ACD00012ADA312079B8A828B83E58245832212E1
+:10ACE0001FF27F0802212374F0122051ECFEEDFFC9
+:10ACF0008E828F8312ACCA12AD8EC3E098A3E09906
+:10AD00004004E849700479018077EE2405F50CEFE2
+:10AD10003400F50DEE2404F50AEF3400F50B850A36
+:10AD200082F583E0F50E750F00780E122264780C20
+:10AD300012226412A630121FF2E9700479108041C9
+:10AD4000E4F50E780E122264850A82850B83E0F505
+:10AD50000A750B00780A122264780C1222648508A6
+:10AD60008285098312AB4C8E828F8312AD9F12AD08
+:10AD700088121FF28B09EA45097004790A8002796A
+:10AD80000002ACE2EEFCEFFD120795740622EE2401
+:10AD900002F508EF3400F509850882F58322A31235
+:10ADA000ADA322E0FAA3E0FB2274F41220518A083A
+:10ADB0008B09ECFEEDFF7C007D008E828F8312AC50
+:10ADC000D0700479018010EEFCEFFDA3A3A3E0F99D
+:10ADD000AA08AB0912078902A30102A97F74F6121F
+:10ADE0002051ECFEEDFF12AF8A6029EE4F60078E16
+:10ADF000828F8312AE1F88828983A3A3E0F874FE3A
+:10AE00006870047917800F74FF68700479008006F9
+:10AE100079168002790202ABFE851082851183E8E3
+:10AE2000F0A3E9F02274F61220517C008C08750919
+:10AE30000074027808121FC912AE5C88828983E010
+:10AE40006A7003A3E06B7006E8FAE9FB800B0CEC78
+:10AE5000C3940240D77A007B0002ABFE74512508F0
+:10AE6000F874033509F92274F4122051EA4B604456
+:10AE7000EA2402FEEB12AEB7F46039E064FE6034FF
+:10AE8000EA2403F508EB3400F509E4F50AF50B783C
+:10AE90000A1222647D1E7C178A828B8312AD9F1258
+:10AEA000AEC0121FF28E828F8374FEF085088285F9
+:10AEB000098304F002A3013400FF8E828F83E02215
+:10AEC000850882850983E0F912082B74022274F048
+:10AED0001220518A0A8B0B890C74FE650A70047467
+:10AEE000FF650B700302AF87E970251208018B091B
+:10AEF000EA4509600302AF877AFF7BFF12AF8A70D1
+:10AF00000302AF8788828983E50AF0A3E50B807688
+:10AF10007401650C701012AF8A606C88828983742A
+:10AF2000FFF0A3F080177402650C705B7901120AC0
+:10AF3000C5E97053AA0AAB0B12AF8A604AE8240233
+:10AF4000FEE912AEB7FA74FF6A603CE82403F50824
+:10AF5000E93400F50974FE6A6018E4F50EF50F781F
+:10AF60000E1222647D1E7C14AA0AAB0B12AEC01214
+:10AF70001FF2EEFAEFFB1208378508828509837409
+:10AF8000FFF08E828F83F002ACE21208018A088BF8
+:10AF900009A808A909E8492274F4122051E990048B
+:10AFA00041F0120E07907800E0C4540F5407640378
+:10AFB0007004793F8002797F75080675090078086A
+:10AFC0001222647C2F7D047AEA7B071212F9740244
+:10AFD000121FF290042FE0F47049A3E0F47044A330
+:10AFE000E0F4703FA3E0F4703AA3E0F47035A3E01E
+:10AFF000F4703090780EE090042FF090780FE0908D
+:10B000000430F0907810E0900431F0907811E090E6
+:10B010000432F0907812E0900433F0907813E090CE
+:10B020000434F090043512B12C12BE2F90045F74DA
+:10B0300006F0A3740D12B95F7432F0A37401F0909E
+:10B04000058812B12C900587E4F090058EF0A3746A
+:10B05000A012B95F7403F0A3740712B95F742812C9
+:10B06000B95F04F0A3E4F09005B7F09005DA74FF3F
+:10B07000F0A3E4F09005DCF09005DE04F0120BBBC9
+:10B08000120AEF120DAD79017ADF7B05120CA59043
+:10B0900005DFE075F01484E5F004F0790C7A007BAC
+:10B0A00006120CA5120CC37A00900441E0F91211AB
+:10B0B00067907803E06442705E9005DFE014F07002
+:10B0C00056C2AF12B0C600782AD0E0F618D0E0F62B
+:10B0D000E59F5407F97005908F828003908F267842
+:10B0E00008121EACE9C4C0E07829E65508F5080846
+:10B0F000E65509F509740B7808121FBAD0E0250847
+:10B10000F8906270E0A2E740F8E8C333906272F012
+:10B11000906270E0D2E0F090046CE4F0A3F07A80EA
+:10B12000FB900441E0F912111302BCC074FF12B38A
+:10B13000DCF0A3F02274F6122051EAFEEBFFEEA23F
+:10B14000E05043900443E0C39480E0500FC333F8D1
+:10B15000E433F9740C28F582740F800EF4C333F8CD
+:10B16000E433F9741A28F582740F39F58312BCDBC5
+:10B1700012204F7A00900441E0F9121167EE640149
+:10B18000FAEFFB02B2F35402603775080078081238
+:10B190002268E4F50978081222647808122264789B
+:10B1A000081222647508777509057808122264125E
+:10B1B000B30F793C1209C97409121FF2EE640280C0
+:10B1C000BFEE5404607B900470E0F875F004A4C8EE
+:10B1D000AAF012B59BEA242A12BD99F50878081244
+:10B1E0002268EA243212B2FEF50974047808121FAC
+:10B1F000BA7808122264EA242012B2F612227BEAFC
+:10B20000242E12B2FEC313F509E50813F5087808D9
+:10B210001222647508777509057808122264900572
+:10B2200076E0FD7C018A828B83A3A3A3A3E0FA7B53
+:10B230000079001209C97409121FF2EE640402B108
+:10B2400080EE544060387508007808122268E4F5F2
+:10B25000097808122264780812226478081222649D
+:10B26000750877750905780812226412B30F793BC7
+:10B270001209C97409121FF2EE644002B180EE5443
+:10B280008060217900121161908F521222777A002A
+:10B290007B01900441E0F91211857404121FF2EE53
+:10B2A0006480809AEF5401600D7901121161EEFA09
+:10B2B000EF640102B182900448E064017031EE5401
+:10B2C00020602C900442E024F9600314701B793F45
+:10B2D000900470E0FA75F004A4CAA8F028FB747218
+:10B2E0002AFA74043BFB120C63EE642002B1807AEC
+:10B2F000007B0002BD1DF582EB3400F5832212B302
+:10B3000006F508A3E022F582EB3400F583E02290F5
+:10B310000576E0FD7C017A007B0022C082C083C2FA
+:10B32000AF120DE3E5E170FC75E10112B96A120E8E
+:10B330001F7907120E917901120E977902120E49A8
+:10B34000120E67120E857900120E8B7901120E8B88
+:10B35000908F46121ECA120E31900576E412B12E5D
+:10B36000A3F090058EF0A3F0A3F09005927407F07F
+:10B370009005917403F0900597E4F0900596F09095
+:10B3800005B7F0120C51120D17120C697900120E4C
+:10B390009D90057D74FF12B3DC741FF0906012E481
+:10B3A000F0A3F0906063F0752100900442F09004E7
+:10B3B00044F0A3F0900582F090058304F09005849A
+:10B3C000E4F0900447F090044804F090045E7403A5
+:10B3D000F09005DDE4F0D2AFF902BE1EF0A3F0A3B9
+:10B3E000F0A3F0A322C082C08390042F12B426F0F1
+:10B3F00090043012B419F090043112B419A3F090F3
+:10B40000043212B419A3A3F090043312B41EF090C6
+:10B41000043412B41EA302BE1B12B426A32212B41B
+:10B4200026A3A3A3A322E08A828B8322C082C083A7
+:10B430008A828B83E090043512B462E09004361265
+:10B44000B462A3E090043712B462A3A3E09004387E
+:10B4500012B469E090043912B469A3E090043A028E
+:10B46000BE1BF08A828B83A322F08A828B83A3A3E4
+:10B47000A3A322C082C083120BC7E97005120E6716
+:10B48000790002BE1E74F7122051EAFEEBFF890814
+:10B49000120BC7E9702CE508600A74016508600AA0
+:10B4A0007912801E7C00790080047C007901EEFA1C
+:10B4B000EFFB120E6DE9F8740368700479078002DF
+:10B4C000790002B96574F6122051740A12204512EF
+:10B4D000BE25600AEC4D6006E50845097004791246
+:10B4E000800F7808122264120CBD7402121FF279C8
+:10B4F0000002BD1D74F4122051EAFEEBFF89089092
+:10B500000442E064096014E0640A600FE0640B60C8
+:10B510000AE0640C6005E0640D7004790C801E1272
+:10B520000D418B0BEA450B700BA908EEFAEFFB12ED
+:10B530000CA58009900444E04440F0790D02BCC0A1
+:10B5400074F4122051EAFEEBFF890BEE4F6003E921
+:10B5500070047912801F750A00120C9F850A08EE8C
+:10B560002508F582EF12B2F9E9F0050AE50AC3955C
+:10B570000B40E6790002BCC0C082C083E9F87401C8
+:10B5800068700B9005DD7401F0790002BE1EE87052
+:10B59000069005DDE480F1791280F02AF9747228B2
+:10B5A000FA740439FB2274F6122051EAFEEBFF8C88
+:10B5B000088D09900442E0640C700590618E801241
+:10B5C00012BDE4702F12BE7074DB2EF58274043F3E
+:10B5D000F583E0F9748069700A85088285098374AF
+:10B5E0007F800E900446E0F8E9C3988508828509BB
+:10B5F00083F0790002BD1D74F7122051EAFEEBFFC3
+:10B60000890874056508602874136508602274143D
+:10B610006508601C741565086016741A650860106A
+:10B6200074296508600A743B650860047912803DDE
+:10B6300012BDE4703812BDE9241DF8EB3400F9EABC
+:10B6400024F5FCEB3400FDEA246A12B6707016EAA9
+:10B65000246B12BD9964027004793A801012B67698
+:10B66000120C39800612B676120C2D790002B965DB
+:10B6700012B3066401228C828D83E50812BB48E474
+:10B68000F0A3F079022274E812205174FE121FDC3C
+:10B69000E9851882851983F08A0C8B0D8C0A8D0B35
+:10B6A000741A122045E0F508EC450B6016851882E7
+:10B6B000851983E0C3941C500AE508600B7401658A
+:10B6C000086005791202B94D12BDE4600302B94D5C
+:10B6D000A80CE875F004A4C8AAF02AFA75F004E5ED
+:10B6E0000DA42AF9747228FE740439FFEE2465F55E
+:10B6F00010EF3400F51185108212B957E84970C374
+:10B70000A2AFE433C0E07401122045D0E0F0C2AF34
+:10B71000120D418A148B158A828B83E0F87440687D
+:10B720006017748068600302B913900470E0650CC0
+:10B730007002E50D600302B913120DFB8A0C8B0D2C
+:10B74000120DFBEA650C7003EB650D700302B91373
+:10B7500012BE86E5142402F516E5153400F517909F
+:10B760008F76780C121E38780C122260851682852E
+:10B770001783121ECA12BE15121FF2E9640160037C
+:10B7800002B913E508F5097809122268740112203C
+:10B7900045E0F9AC0AAD0BEEFAEFFB120C87740131
+:10B7A000121FF2E9600302B913900583E06401609F
+:10B7B0000302B905EE241DF582EF340012B957E8F3
+:10B7C00049700302B90512BE86EE242EF508EF3447
+:10B7D00000F509850882F583E0F510A3E0F511E492
+:10B7E000F512F513780C7910121E25908F3A780C0B
+:10B7F000121E38780C122260851682851783121E5D
+:10B80000CA12BE15121FF2E96401600302B905E510
+:10B81000142408F50AE5153400F50B850A82F58332
+:10B82000122277AA0CAB0DAC0EAD0F12BE0F121F79
+:10B83000F285088285098312227B12278C740212FA
+:10B840001FF28A0C8B0D8C0E8D0F7410780C121D4C
+:10B85000ED8E828F83A3A3A3A3A3A3A3A3A312B953
+:10B86000598E828F83A3A3A3A3A3E8F0A3E9F0E8F2
+:10B87000250CF8E9350DF98E828F83A3A3A3A3A32A
+:10B88000A3A3E8F0A3E9F0850A82850B83C082C0F8
+:10B8900083850882850983E0F508A3E0F509E4F5CE
+:10B8A0000AF50B780C7908121CE9D083D082780C49
+:10B8B000121E38908F36780C121E868516828517D8
+:10B8C00083E50CF0A3E50DF0A3E50EF0A3E50FF082
+:10B8D000851482851583A3A3A3A3A3A3E4F0A3F0F7
+:10B8E000EE2435F582EF12BD9CC0E0EE2434F582E3
+:10B8F000EF12B2F9D0E0F0EEFAEFFB12244FAA14E7
+:10B90000AB15120D237401122045E0A2E092AF792D
+:10B9100000803A851082851183E50AF0A3E50BF0DB
+:10B92000851882851983E0C0E0EE2463F582EF126A
+:10B93000B2F9D0E0F0EE2464F582EF12B2F9E50836
+:10B94000F07401122045E0A2E092AF790774021270
+:10B950001FF27F10022123F583E0F8A3E0F922F023
+:10B96000A3E4F0A3227F01022123120B91120B8585
+:10B9700075E1F12274F3122051EAFEEBFF8908749D
+:10B980000D122045E0F509740E122045E0F50A7409
+:10B990000F12204512B9597411122045E0F50B74AD
+:10B9A00012122045E0F50CE5086038740165086066
+:10B9B00022740365086006740265087068EE2460EE
+:10B9C000FAEF12BB30505EEC2460FAED12BB30404F
+:10B9D000268052E849604EE50A601C7401650A70D1
+:10B9E000448014EE24E0FAEF12BB255038EC24E03A
+:10B9F000FAED12BB25502EC3EC9EED9F4027E509C2
+:10BA0000600674016509701DE50C60127401650C17
+:10BA1000600C7402650C60067403650C7007740793
+:10BA2000550BFA7005791202BB2090058EE0640177
+:10BA30007005790C02BB20E508900591F0EAA3F0AF
+:10BA4000E50CA3F0E509900587702FE4F090042F32
+:10BA5000E0900588F0900430E0900589F090043182
+:10BA6000E090058AF0900432E090058BF09004336A
+:10BA7000E090058CF0900434802E7401F090043531
+:10BA8000E0900588F0900436E0900589F090043746
+:10BA9000E090058AF0900438E090058BF09004392E
+:10BAA000E090058CF090043AE090058DF07401650B
+:10BAB00008703CE50A90057612BB48E090057712C5
+:10BAC000BB3BE090057812BB3BA3E090057912BB2D
+:10BAD0003BA3A3E090057A12BB40E090057B12BB2C
+:10BAE00040A3E090057CF090058FE4F0A3802EE564
+:10BAF0000C70047900801C7401650C70047901805D
+:10BB0000127402650C7004790280087403650C706D
+:10BB1000057903120E7390058FEEF0A3EFF0790014
+:10BB20007F0502212334FFFBC3EA94E1EB943F221B
+:10BB300034FFFBC3EA9461EB943F2212BB48A3227B
+:10BB400012BB48A3A3A3A322F0888289832274F6A0
+:10BB5000122051E9FEC39420400479128029EE900E
+:10BB60000597F0601AEA4B60F112BD22122264EAD6
+:10BB7000FCEBFD7A987B051210BF7402121FF29045
+:10BB800005967401F0790002BD1D74F4122051E98C
+:10BB9000FE900442E064096014E0640A600FE0640F
+:10BBA0000B600AE0640C6005E0640D700579210209
+:10BBB000BCC0900591E0F8600F740168600A7403DE
+:10BBC0006860057402687023900587E0F960057469
+:10BBD000016970177403686005740268701290053B
+:10BBE0008FC3E094A0A3E094005005791202BCC07A
+:10BBF000EE60761470F590058EE0640160AFE86049
+:10BC0000057401687008120D4DE954FD709F7901AB
+:10BC1000120D35900585EAF0A3EBF090058E7401C6
+:10BC2000F0900442E0600302BCBE120DF58A088B5E
+:10BC3000098C0A8D0B908F5E7808121E38908F3613
+:10BC40007808121E8612BCD27808121EBB12BCD213
+:10BC5000A3A3A3A3E4F0A3F0120BCDE9600612BCEA
+:10BC6000C502BBAD120D1D805590058EE07003021C
+:10BC7000BBADA2AFE433FFC2AF12BCC5120D59E990
+:10BC80007037120DE3906182E0C2E6F0E5E170FCEE
+:10BC900075E1017591BF75E1F1900448E0640170B0
+:10BCA000187A207B00900441E0F91211917A207BF0
+:10BCB00000900441E0F9121119EFA2E092AF79006F
+:10BCC0007F040221237A857B05120D3B90058EE4CB
+:10BCD000F02290058512BCDBA3A322E0F8A3E0F5D7
+:10BCE0008388822274F6122051E9FEC39420400416
+:10BCF00079128029EE9005B7F0601AEA4B60F112D4
+:10BD0000BD22122264EAFCEBFD7AB87B051210BF5B
+:10BD10007402121FF29005967401F079007F0202FE
+:10BD20002123E0F50875090078082274F6122051E5
+:10BD3000EAFEEBFF8C088D09900442E06407600482
+:10BD4000790C8053EC450970047912804A12BDE4E5
+:10BD5000704512BE607E008E82AC82E5082CF582B2
+:10BD6000E50912BD9CC0E0C3E49CF895E0F9EA281F
+:10BD7000F8EB39F9E824D2F582E912B2F9D0E0F013
+:10BD80000EEEC3941040D0EA24D412B2F67401F03F
+:10BD90007905120C2D79008084F582EB12B309220B
+:10BDA00074F7122051EAFEEBFF900442E064076052
+:10BDB00004790C802C12BDE4702712BDE924DD1239
+:10BDC000B670700DEA24F512B2F67406F0790280AE
+:10BDD0000BEA24DE12B2F67406F0790D120C2D79FE
+:10BDE0000002B965120B5BE92212BE64EA22C0822E
+:10BDF000C083C3EB940F5004EA4B60047912800CAB
+:10BE0000900475E0700479028002790002BE1E126F
+:10BE1000283A7404221227DD740422F07900D083BA
+:10BE2000D082020122E0F508A3E0F509EA4B229056
+:10BE3000042FE090043BF0900430E090043CF0903C
+:10BE40000431E090043DF0900432E090043EF09024
+:10BE50000433E090043FF0900434E0900440F0227A
+:10BE600012BE642212BE7474722EFA74043FFB2256
+:10BE700012BE7422EE75F004A4CEA8F028F875F076
+:10BE800004EFA428FF2212BE8A22120DF58A0C8B21
+:10BE90000D8C0E8D0F2274F41220518908EAFEEBEE
+:10BEA000FF75091274FE6E700374FF6F701B9003B0
+:10BEB0002212C4B3606412BF21605F7AFE7BFFA9C7
+:10BEC0000812204FE9F509805174FF6E700374FF6A
+:10BED0006F702F90032212C4B3601B12BF21601633
+:10BEE0007AFF7BFFA90812204FE9F5097008E508E1
+:10BEF000900324F08024A9081206A5E9F509701A18
+:10BF000080EC12C6716013E06508700B7913EEFACD
+:10BF1000EFFB12090380AD750903A9097F04022113
+:10BF200023E0F5838882E0F8A3E0F988828983E53D
+:10BF30008245832274F2122051890AECFEEDFF90B3
+:10BF40000301E064026005E064017004791280502E
+:10BF5000EE4F70047902804812C94570047914804C
+:10BF60003FE50A600B8A828B83A3A3A3E0D2E1F0B2
+:10BF7000750C10750D00780C122264EEFCEFFDEAD2
+:10BF8000240DFAEB12BFA3121FF212C597121ECA9C
+:10BF9000E508241DF582E50912CCF0121ED67900C1
+:10BFA00002C4A43400FB1210BF74022274F21220E7
+:10BFB000518A088B09ECFEEDFF900301E0640260FA
+:10BFC0000EE064016009E064087009EE4F600579D5
+:10BFD0001202C0A6EA45097005790202C0A612C481
+:10BFE000B06005791102C0A68A828B8312C4A98A27
+:10BFF0000A8B0BEA450B7005791402C0A67A1F7BE9
+:10C000000012114F900320EAF0A3EBF012C4B070BD
+:10C0100005791302C0A67C1F7D0079001210D7128B
+:10C02000C84A12C0A9A3EAF0A3EBF0750C16750D6F
+:10C0300000780C122264E5082402FCE5093400FDB6
+:10C04000900320E02403FAA3E012BFA3121FF21210
+:10C05000C0A97402F0900301E0A2E35004D2F08082
+:10C0600002C2F0900320E02403F50CA3E03400F5B5
+:10C070000D780C12226412C0B590032BE0FAA2F0E6
+:10C08000E433F9120F3F7402121FF2E9F508EE4F84
+:10C09000600BEEFCEFFDAA0AAB0B120F7BE508600C
+:10C0A000031206B1A90802C4A4900320E0F8A3E09B
+:10C0B000F583888222850882850983E0FCA3E0FD60
+:10C0C0002274F412205174FF121FDCEAFEEBFF8988
+:10C0D00008120AB98B0BEA450B7004791480148599
+:10C0E0001882851983E508F0AC82AD83EEFAEFFB88
+:10C0F000120F637401121FF202BF1C74F012205160
+:10C1000074F0121FDC8A0C8B0D8C0E8D0F742012B4
+:10C110002045E0FEA3E0FFEEFAEFFB120AB98B091F
+:10C12000EA4509700479128071908F6A780C1214B4
+:10C13000FE5004790280637C107D007900851882AE
+:10C14000851983AA82AB831210D78518828519833B
+:10C15000E50CF0850D09E509F5087401122045E5A7
+:10C1600008F0850C08850E0A850F0B7410780812EC
+:10C170001DED7402122045E508F07418780C121DAC
+:10C18000ED7403122045E50CF0EEFCEFFD851882FE
+:10C19000851983AA82AB83120F457410121FF27F98
+:10C1A0000802212374F01220518A0A8B0B890E8C0D
+:10C1B0000C8D0D7410122045E0F50F900301E06422
+:10C1C000026005E064017005791202C276EC450D4B
+:10C1D0007005790202C276120AB98A088B09AE0884
+:10C1E000AF09EE4F7005791402C276EE2421F508EE
+:10C1F000EF12C3D2850882F58312CCFB60031211C3
+:10C20000557C1B7D00AA0CAB0D1210CB85088285D6
+:10C210000983EAF0A3EBF012C0B5EC4D700479137A
+:10C220008054900301E0A2E35036E50F6032EC2425
+:10C2300012F508ED12C3D27808122264EC2410F52E
+:10C2400082ED12CCF012227BEC241AF582ED12C39F
+:10C25000D7F9AA0AAB0B120F817404121FF28002E5
+:10C260007900EE2403F582EF12C3D7D2E2F0E50E97
+:10C270006004E0D2E1F002C19F74EA1220518A0EFC
+:10C280008B0FEA450F700302C3C990031E12C4B39B
+:10C29000600512C0AF8003900E2DE0F50C90032CCA
+:10C2A00012C4B3600F12C0AFA3A312BF26600579FA
+:10C2B0000012204FE50E2407F50AE50F3400F50BB8
+:10C2C000E50E2408F508E50F12C3D2AA08FB850A7B
+:10C2D00082850B83E0F9120609E9FB850A82850B4A
+:10C2E00083F0E50E2403FEE50F3400FFE50E240481
+:10C2F000F512E50F3400F513E50E240EF510E50FE9
+:10C300003400F511E50E2414F582E50F12C3D7F5BC
+:10C31000147515007814122264E50E2412F582E5D6
+:10C320000F12CCF012227BE50E2410F582E50F12DD
+:10C33000CCF012227B85108285118312227B85121C
+:10C340008285138312227BAC08AD09AA0C8E828FE2
+:10C3500083E0F9120693740A121FF28E828F83E033
+:10C36000703185108285118312227B780812226435
+:10C37000850A82850B83E0FD7C018512828513830B
+:10C3800012C850A90C120AAD7404121FF2E98E8271
+:10C390008F83F090031E12C4B3602E1206B7900371
+:10C3A00024E06025F91206A5E9601E8E828F83E0E5
+:10C3B000FB85128285138312C0BB900324E0FAEB45
+:10C3C000F9120699900324E4F07F0E022123F50868
+:10C3D000E5093400F509223400F583E02274F712F0
+:10C3E0002051EAF8EBF988828983A3A3A3A3A3A32E
+:10C3F000A3A3A3A312227B88828983A3A3A3A3A3BD
+:10C40000A3A3A312227B88828983A3A3A3A3A3A3AC
+:10C4100012C0BB88828983A3A3A3A312C8508882B9
+:10C420008983A3A3A3E0F912069F7404121FF27F6D
+:10C430000102212374F2122051EAFEEBFF750A007B
+:10C44000EE2403F8EF3400F9880889098882F5831F
+:10C4500012C4A98A828B83E58245836009E0F50ACC
+:10C4600012C84A120AB3900324E06011650A700DE5
+:10C47000E0F91206A5E96024900324E4F0E50A60DF
+:10C480001B8E828F83A3A3A3A3A3E0FB12C0B5AA34
+:10C490000A8E828F83A3A3E0F912069912C4B060BA
+:10C4A000031206B17F0602212312C854120AB922D0
+:10C4B000900320E0F8A3E0F9E8492274E812205143
+:10C4C000890B8A0E8B0A8C0C8D0D741A122045E094
+:10C4D000F516A3E0F517741C122045E0F514A3E04F
+:10C4E000F515741E122045E0F510A3E0F511742037
+:10C4F000122045E0F5087A1312C661700302C59256
+:10C500008E828F8374D0F0A3E50B12CA0F740512CC
+:10C51000CA17E50AF0EE2404FAEF3400FBE50C45F7
+:10C520000D60177512067513007812122264AC0C98
+:10C53000AD0D12BFA6121FF280097C067D007900A6
+:10C540001210D77418122045E0F8A3E0F98E828FFC
+:10C5500083A3A3A3A3A3A3A3A3A3A3E8F0A3E91284
+:10C56000CAFEE516F0A3E517F0EE240E12CCEDE5B9
+:10C5700014F0A3E515F012C597E510F0A3E511F04E
+:10C58000EE241212CCEDE508F0EEFAEFFBA90E1244
+:10C5900010EF7F10022123EE2410F582EF3400F516
+:10C5A000832274F212205189098A08ECFEEDFF8B78
+:10C5B0000A7A067B001210E3EA4B60278A828B839B
+:10C5C00074D0F0A3E509F08A828B83A3A3740612CA
+:10C5D000C5E6EEF0A3EF12C5E6A3A3E50AF0A908AD
+:10C5E0001210EF02C4A4F08A828B83A3A3A3227447
+:10C5F000EC12205189108A088B098C0A8D0B741457
+:10C6000012204512C85A7416122045E0F50EA3E018
+:10C61000F50F7A0C12C6616045AA08AB0912C67103
+:10C620007003900E2DE0F98E828F8374D0F0A3E515
+:10C630001012CA0F740712CA28E508F012CA2DA3F7
+:10C64000E50B12CA37E50CF0A3E50D12CA37A3A318
+:10C65000E50EF0A3E50FF0EEFAEFFB1210EF02C8C3
+:10C660001A7B001210E38A128B13AE12AF13EE4F37
+:10C6700022120AB98A828B83E58245832274F612DC
+:10C680002051120ABF8A828B83E5824583600B7931
+:10C6900013A312C850120903800279127F020221EB
+:10C6A0002374EC12205189118A088B098C107414A0
+:10C6B00012204512C85A120AB98A0E8B0FEA450F8A
+:10C6C000700302C81A12C4B0700302C81A7A0E7B33
+:10C6D0000012CD2F60027A29900320E0241B12CD96
+:10C6E000356008EA2416FAE43400FB900320E024C5
+:10C6F0001D12CD356008EA2414FAEB3400FBE50C7A
+:10C70000450D6008EA241BFAEB3400FB1210E38AA3
+:10C710000A8B0BEA450B700302C81A7C0E12CA0082
+:10C720008A128B13AE12AF13EE4F7008850E8285FE
+:10C730000F83E0FE850A82850B8374D0F0A3E51198
+:10C7400012C824740A12C81FE508F0A3E50912C82C
+:10C750001FA3A3E510F0E50A240EF508E50B12C3AC
+:10C76000D212CD2F6023E50A240612C82E241B12F4
+:10C77000C3CE750E1B750F00780E12226490032035
+:10C78000E0241912C862121FF2900320E0241B1249
+:10C79000CD356023E50A240812C82E241612C3CE14
+:10C7A000750E16750F00780E122264900320E02497
+:10C7B0001B12C862121FF2900320E0241D12CD3517
+:10C7C0006023E50A240A12C82E241412C3CE750E63
+:10C7D00014750F00780E122264900320E0241D12BD
+:10C7E000C862121FF2E50C450D6023E50A240C1205
+:10C7F000C83475081B7509007808122264AC0CADAA
+:10C800000D8A828B8312C85012BFA6121FF2AA0A89
+:10C81000AB0BEEF91210EF1206B17F0C02212312BE
+:10C82000C824A322F0850A82850B83A3A32212C801
+:10C8300034E50822F8E50B3400F9E8FAE9FB8A82CE
+:10C840008B83E508F0A3E509F0228508828509833A
+:10C8500012C85422E0FAA3E0FB22E0F50CA3E0F5B5
+:10C860000D2212CD23FCA3E0FD8A828B8312C854D3
+:10C870001210BF740222C082C08312C4B060311291
+:10C88000CD136003121155900320E0241B12CD1923
+:10C890006003121155900320E0241D12CD1960038E
+:10C8A00012115590032012C8D2900320E4F0A3F097
+:10C8B000D083D082020122C082C08390031E12C4A2
+:10C8C000B3600D90031E12C8D290031EE4F0A3F0D3
+:10C8D00080DE12C8541211552274F0122051890CB6
+:10C8E0008A0A8B0B12C94560597A257B001205DF35
+:10C8F0008A0E8B0FAE0EAF0FEE4F70088508828543
+:10C900000983E0FE7A057B001210E38A088B09EAAE
+:10C910004509602E7C057D0079001210D7850882BC
+:10C9200085098374D0F0A3E50C12C950740E12C9A6
+:10C9300050A3E50AF0A3E50BF0AA08AB09EEF91243
+:10C9400010EF02C19F120AB98A088B09EA45092231
+:10C95000F0850882850983A3A32274EC12205189F3
+:10C96000088A0E8B0F8C098D0A7414122045E0F58D
+:10C970000C7415122045E0F50B120AB98A128B13BC
+:10C98000EA451360787A0B7B001210E38A108B1152
+:10C99000AE10AF11EE4F60657C0B12CA008A108B8F
+:10C9A00011A810A911E8497008851282851383E047
+:10C9B000F88E828F8374D0F0A3E50812CA0F740F2B
+:10C9C00012CA17E50EF0A3E50F12CA2812CA2D8E5F
+:10C9D000828F83A3A3A3A3A3A3A3E50C12CA37E565
+:10C9E0000BF07416122045EE2409FCEF3400FD74A0
+:10C9F00002121EEFEEFAEFFBE8F91210EF02C81A6E
+:10CA00007D0079001210D77A257B001205DF22F015
+:10CA10008E828F83A3A32212CA1B2212CA1F22F066
+:10CA20008E828F83A3A3A32212CA1BA322A3E5098C
+:10CA300012CA3DE50AF02212CA3DA3A32212CA1F60
+:10CA4000A3A3A32274EE1220518A0A8B0B890E1223
+:10CA50000AB98A0C8B0DEA450D700302CAF97A0DEA
+:10CA60007B001210E38A088B09AE08AF09EE4F7005
+:10CA70000302CAF97A257B001205DF8A088B09EACE
+:10CA800045097009850C82850D83E0F5088E828F3B
+:10CA90008374D0F0A3E412CA0F740BF075100675FE
+:10CAA00011007810122264E50C2405FCE50D340019
+:10CAB000FDEE2403FAEF12BFA3121FF28E828F83C2
+:10CAC000A3A3A3A3A3A3A3A3A3E50AF0A3E50BF049
+:10CAD000EE240B12CCEDE50EA2E0500474018001AF
+:10CAE000E412CAFEE50EA2E1500474018001E4F0F4
+:10CAF000EEFAEFFBA9081210EF7F0A022123F0EEF5
+:10CB0000240CF582EF3400F5832274E81220518959
+:10CB1000148A118C088D098B10741812204512C8C4
+:10CB20005A741A122045E0F50EA3E0F50F741C129A
+:10CB30002045E0F516A3E0F517741E122045E0FE2F
+:10CB4000A3E0FFAA08AB09120AB98A0A8B0BEA45CF
+:10CB50000B700302CC1CE514600302CC1CEA240316
+:10CB6000F582EB12C3D7D2E4F0E510A2E2E0500464
+:10CB7000D2E18002C2E1F0E50C450D7010E50E45F2
+:10CB80000F700AE51645177004EE4F6060E0D2E2C0
+:10CB9000F0EE4F603012C597121ECAE50A241DF54B
+:10CBA00082E50B12CCF0121ED675121075130078A8
+:10CBB00012122264EEFCEFFDE50A240DFAE50B12D9
+:10CBC000BFA3121FF2E50A2421F50AE50B3400F594
+:10CBD0000BE50C450D601BE511701712CCF56003D9
+:10CBE0001211557C1B7D00AA0CAB0D8021E0C2E226
+:10CBF0008029E50E450F602474016511701E12CC6A
+:10CC0000F560031211557C1B7D00AA0EAB0F1210AC
+:10CC1000CB850A82850B83EAF0A3EBF012C4B070D7
+:10CC20000302CCDCE50C450D602912CD2F700A7A89
+:10CC30001B12CCDF241912CD0112CD136015750A19
+:10CC40001B750B00780A122264AC0CAD0D12BFA646
+:10CC5000121FF2E51645176035900320E0241B12E1
+:10CC6000CD35700A7A1612CCDF241B12CD01900349
+:10CC700020E0241B12CD196015750A16750B00787B
+:10CC80000A122264AC16AD1712BFA6121FF2EE4FA5
+:10CC90006035900320E0241D12CD35700A7A1412FD
+:10CCA000CCDF241D12CD01900320E0241D12CD19EC
+:10CCB0006015750A14750B00780A122264EEFCEFF9
+:10CCC000FD12BFA6121FF2780E122264AC10AA0841
+:10CCD000AB09A9141206AB7402121FF202C5927BB3
+:10CCE0000012114F8A0A8B0B900320E022F582EF8D
+:10CCF0003400F58322850A82850B8312C854EA4BDF
+:10CD000022FAA3E03400FB8A828B83E50AF0A3E5D4
+:10CD10000BF022900320E0241912CD23FAA3E0FBAC
+:10CD2000EA4B22F8A3E03400F988828983E022905C
+:10CD30000320E0241912CD23F8A3E0F9E849227476
+:10CD4000EE122051890B8A0C8C0E8D0F741212205A
+:10CD500045E0F508A3E0F509750A0012CE45600527
+:10CD6000791102CE23E5084509603C7A217B001247
+:10CD700005DF8A108B11A810A911E5082415FEE51E
+:10CD8000093400FF8E828F83E0C398E49940187ABB
+:10CD9000227B001205DF8A108E828F83E0FAC3E5C2
+:10CDA000109AEB94005004790280787A637B001229
+:10CDB000114F9007CEEAF0A3EBF012CE4570047944
+:10CDC0001380607C637D0079001210D712CE28E4B6
+:10CDD000F09007CEE012DBB1E50B12CE3DE50C1270
+:10CDE000CE3DA3E50EF0A3E50FF09007CE12D523BC
+:10CDF000A3E508F0A3E509F012D8ABE4F0A3F090A6
+:10CE000007CEE0241A12DAB2E4F0E50B6006120F46
+:10CE100087E9F50A12CE287401F0E50A6003120FC3
+:10CE2000BDA90A7F0A02212312CE2C229007CE121E
+:10CE3000CE3322E0F8A3E0F5838882A322F012CE5D
+:10CE40002CA322E9FE9007CEE0F8A3E0F9E84922FE
+:10CE500074F61220517E0012CE457005791202CF71
+:10CE6000189007CEE0241A12DAC5F8740268600A36
+:10CE7000740368600574046870E212CF296C700353
+:10CE8000A3E06D6005790202CF187508108E09784D
+:10CE900008122264EAFCEB12CF1B12D5F9121FF222
+:10CEA00079109007CEE0242BFAA3E03400FB120F98
+:10CEB0000F9007CEE0241BF508A3E03400F50978B5
+:10CEC0000812226412D5FF12CF1B120F75740212C2
+:10CED0001FF29007CEE0240112DAC5FA9007CEE0E7
+:10CEE000FBA3E0F5838B82E0600D74036A702788F2
+:10CEF0008289837402801974046A70098882898324
+:10CF00007402F0801174036A700C8882898374053E
+:10CF1000F0120F8DE9FEEEF902D96FFD9007CEE019
+:10CF20002407FAA3E03400FB229007CEE0F8A31216
+:10CF3000D8CCE022C082C0839007D002D29C74F784
+:10CF400012205112CE43601312CF2F6A7003A3E058
+:10CF50006B700874016E7003120FBD7F01022123F4
+:10CF6000C082C0837917120FC302D2A174F41220B9
+:10CF70005174ED121FDCEAF8EBF9851882851983EC
+:10CF8000E4F088828983A3A3A3A3A3A312D94B8A25
+:10CF9000828B83E0F50AE824020808E93400F9E806
+:10CFA000FEE9FFE50A14603614603314604F146024
+:10CFB0007A14700302D03914700302D0471470033E
+:10CFC00002D05514700302D06314700302D07114A0
+:10CFD000700302D07F14700302D08E02D09D7401C2
+:10CFE000122045AC82AD83121023E9F874126870E8
+:10CFF0001A8518828519837406F002D0F67401121E
+:10D000002045AC82AD8312102FE9F8E8600302D00E
+:10D01000ED750B078E828F8312D94B120AB9EA4B3A
+:10D02000600302D0A875080802D0E47401122045FC
+:10D03000AC82AD8312103B80D07401122045AC82CB
+:10D04000AD8312104780C27401122045AC82AD83BB
+:10D0500012105380B47401122045AC82AD831210BB
+:10D060005F80A67401122045AC82AD8312107180DE
+:10D07000987401122045AC82AD83121077808A74B7
+:10D0800001122045AC82AD8312108302D0097401D5
+:10D09000122045AC82AD8312108F02D00985188210
+:10D0A000851983740702CFF9900301E0A2E35005CC
+:10D0B0009007D280039007D012CE48602412D57C0E
+:10D0C000F8A3E0F98909E8450960167401122045C2
+:10D0D000AC82AD83A90A888285098312204FE9F5C5
+:10D0E0000B850B08851882851983E508F085188261
+:10D0F000851983E0600DAC82AD838E828F8312D45C
+:10D10000C38003120EEB7413121FF27F040221235B
+:10D1100074F6122051ECFEEDFF7508417509107888
+:10D1200008122264790212D978121FF2E9F5088EEA
+:10D13000828F83E0F9120FC3A90802D96F74F41229
+:10D140002051EAFEEBFF890812CE45700302D22976
+:10D1500012CF2F6E7003A3E06F600302D2299007F5
+:10D16000CEE0240108A3E03400F9E8FAE9FB8A8262
+:10D170008B83E0F8740668600302D21912D3EC6066
+:10D180007C9007CF12D8C5F8A3E0F99007CEE02431
+:10D1900018FCA3E03400FD8C828D83E0FCA3E0FD4D
+:10D1A000E8241312DBA8F8A2E050178C828D83A329
+:10D1B000A3A3A3A3E0A2E050098A828B837407F0A3
+:10D1C000804BE8540260168C828D83A3A3A3A3A393
+:10D1D000E0540260088A828B83740980E2E8540478
+:10D1E00060168C828D83A3A3A3A3A3E054046008DC
+:10D1F0008A828B83740B80C79007D280039007D0FC
+:10D2000012CE48600812D289600312204F12D282D7
+:10D21000703C7900120FC38035741168700BE508FB
+:10D220006003750832A90880EBE5087018EEFAEF84
+:10D23000FB120AB98A828B83E58245836007A3A328
+:10D24000A3E0D2E4F0EEFAEFFBA9081206BD7901E3
+:10D2500002D10BC082C08312CE45602412D57C70EF
+:10D26000059007D080039007D212CE48600812D2F2
+:10D2700089600312204F12D28270057900120FC309
+:10D28000801F12CE2CE064122212DBB7A3A3E0F8B9
+:10D29000A3E0F988828983E582458322EAF0A3EB43
+:10D2A000F0D083D08202012274E812205174E91276
+:10D2B0001FDC851882851983EAF0A3EBF08C168DAC
+:10D2C00017742F122045E0F514A3E0F51512CE4592
+:10D2D0007005791202D3E212D581120AB98A088B3D
+:10D2E00009AE08AF09EE4F7005791402D3E274025B
+:10D2F000122045AA82AB83120FCF12D8B5FAA3E051
+:10D30000FBEE2405F512EF3400F513EE2404F510BE
+:10D31000EF3400F51112D3EC602F74021220458512
+:10D32000820C85830DEAFEEBFF12062DE9F50E79DE
+:10D33000001206338A0A8B0B851082851183E0F573
+:10D340000F851208851309802B8A0C8B0D7402122D
+:10D350002045AE82AF8312062DE9F50F7900120643
+:10D36000338A088B09851082851183E0F50E8512BA
+:10D370000A85130B7410122045AC82AD83EEFAEFD0
+:10D38000FB1210177409122045AC82AD83AA0CABB6
+:10D390000D12101178141222647808122264E50F1D
+:10D3A000F5087808122268780A1222647410122094
+:10D3B0004585820885830978081222647419122031
+:10D3C000458582088583097808122264A90EAC1667
+:10D3D000AD17740B12204512D94B120EFD740B12AF
+:10D3E0001FF27417121FF27F100221239007CEE064
+:10D3F000F8A312DBB7E02274F612205174F7121F63
+:10D40000DCEAFEEBFF8C088D099007D012CE487045
+:10D410000302D4BE12DBB312CE48700302D4BE8C1A
+:10D42000828D83E0C0E07402122045D0E0F08C824F
+:10D430008D83A3E0C0E07403122045D0E0F08C821D
+:10D440008D83A3A3E0F97404122045AA82AB831252
+:10D450000F1B850882850983A3A3A3E0C0E074069F
+:10D46000122045D0E0F0850882850983A3A3A3A3F9
+:10D47000C082C0837407122045AC82AD83D083D0B4
+:10D48000827402121EEF7402122045AC82AD8379C1
+:10D4900001EEFAEFFB9007D012D3EF12DBB11220AE
+:10D4A0004FE9851882851983F060137401122045B5
+:10D4B000E9F0AC82AD838E828F83A312D4C374094A
+:10D4C00002D96CE0FAA3E0FB120F632274F212207F
+:10D4D000518908740E122045E0F50AA3E0F50B749B
+:10D4E00010122045E0F50CA3E0F50D9007D212CE06
+:10D4F0004860299007D212D523E0FEA3E0FFEE4F4B
+:10D50000601A780C122264780A122264A9088E82AA
+:10D510008F8312204F7404121FF2800279027F065B
+:10D5200002212312D58DA32274F612205174F91210
+:10D530001FDC12CE45603B851882851983AA82AB19
+:10D5400083120FCF12D58112D579601E750811751F
+:10D55000091078081222647402122045AC82AD834F
+:10D56000790712D978121FF2800A75081775091009
+:10D5700080E07901740702D96C9007CF12DBB7E025
+:10D58000229007CE12D58DE0FAA3E0FB2212CE3313
+:10D59000A3A32274F612205174F0121FDC75081038
+:10D5A00075090078081222649007CEE0241BFCA3C2
+:10D5B000E03400FD740212204512D5F5121FF275F9
+:10D5C000082975091002D95174F612205174F0120D
+:10D5D0001FDC750810750900780812226412D5FF47
+:10D5E000FD740212204512D5F5121FF2750835752B
+:10D5F000091002D951AA82AB831210BF7402229083
+:10D6000007CEE0242BFCA3E034002274F01220515A
+:10D610008A088B09750A007A077B0012114F12D80D
+:10D62000ABEAF0A3EBF088828983E0FA4B70030247
+:10D63000D87D12D8BFFEA3E0FF750C07750D0078EA
+:10D640000C122264AC08AD0912D5F9121FF212D3E4
+:10D65000EC600302D7DCEE2413FCEF3400FD12D89B
+:10D66000B52405F50CA3E03400F50D8C828D83E024
+:10D67000F8A3E0F9850C82850D83E0A2E092F0E842
+:10D68000A2E020F001B35007A2E0E433FA80027A6E
+:10D6900000E854FE4AF88C828D8312D899C313A2F5
+:10D6A000E092F0E8C313A2E020F001B35012E85476
+:10D6B000026004D2F08002C2F0A2F0E433FA8002E9
+:10D6C0007A00E854FDF8EAC333FAE433FBE84AF899
+:10D6D000E94B12D8A5543FA2E092F0E81313543F4F
+:10D6E000A2E020F001B35013E854046004D2F080AB
+:10D6F00002C2F0A2F0E433F50E8003750E00750F40
+:10D7000000E854FBFAE9FB7402780E121FC9EA45DF
+:10D710000EF8EB450F12D8A513541FA2E092F0E8C3
+:10D72000131313541FA2E020F001B35013E8540860
+:10D730006004D2F08002C2F0A2F0E433F50E800360
+:10D74000750E00750F00E854F7FAE9FB7403780EC4
+:10D75000121FC912D887540FA2E092F0E8C4540FE8
+:10D76000A2E020F001B35013E854106004D2F0801E
+:10D7700002C2F0A2F0E433F50E8003750E00750FBF
+:10D7800000E854EFFAE9FB7404780E121FC912D8AE
+:10D7900087135407A2E092F0E8C4135407A2E020D4
+:10D7A000F001B35013E854206004D2F08002C2F0BC
+:10D7B000A2F0E433F50C8003750C00750D00E854FD
+:10D7C000DFFAE9FB7405780C121FC9EA450CF8EB87
+:10D7D000450DF98C828D83E8F0A3E9F09007CEE047
+:10D7E000241AF8A3E03400F9850882850983A3E0B0
+:10D7F00060118E828F83A3E060098882898374051B
+:10D80000F0807D850882850983A3A3E05404701508
+:10D81000EE2412F582EF12DBABA2E2400888828987
+:10D8200083740180DB850882850983E0FA8E828F0C
+:10D8300083E0FB9007CEE0FCA3E0F5838C82E06000
+:10D8400006EBFEEAFD8004EBFDEAFEEEC394055014
+:10D8500027EDC3940550218E08ED75F005A4FAABB1
+:10D86000F0744E2AFA748E3BFBEA2508F582EB121F
+:10D87000DBAB888289838088750A188003750A1358
+:10D88000A90A7F08022123EA450EF8EB450F12D8BA
+:10D8900093C422F98C828D83E8F0A3E9F0850C8291
+:10D8A000850D83E02212D8931313229007CEE02433
+:10D8B0001812DAB6229007CEE0241812DAC92290A4
+:10D8C00007CEE0F8A312D8CCA3A3E022E0F583882A
+:10D8D00082A3A3A32274F612205175084D75091076
+:10D8E0007808122264791112D97802D96C74F61270
+:10D8F000205174EE121FDCEAFEEBFF741C1220456F
+:10D9000012D94B851882851983ECF0A3EDF07508C8
+:10D91000087509007808122264EAFCEBFD74041211
+:10D92000204512D5F5121FF27508597509107808AF
+:10D930001222647402122045AC82AD83790B12D995
+:10D9400074121FF2741280249007CEE0FAA3E0FB59
+:10D950002278081222647402122045AC82AD8379C9
+:10D960001112D58112D978121FF27410121FF27F92
+:10D9700002022123EEFAEFFB12109574022274F6D4
+:10D9800012205175086575091002D8E074F4122050
+:10D990005174F9121FDCEAFEEBFF851882851983AA
+:10D9A000E9F0750A06750B00780A122264740312F6
+:10D9B000204512D5F5121FF2750A6B750B10780A07
+:10D9C0001222647402122045AC82AD83790812D908
+:10D9D00074121FF2740702D10874F61220517508F0
+:10D9E0007D75091002D8E0C082C08312CE45605315
+:10D9F0009007CEE0241812DA4960031211559007FF
+:10DA0000CEE0245B12DA4960031211559007CEE094
+:10DA1000245D12DA4960031211559007CEE0245FAD
+:10DA200012DA4960031211559007CEE0246112DA30
+:10DA300049600312115512D9481211559007CEE4CE
+:10DA4000F0A3F0120EF102D2A112DAC9FAA3E0FBA0
+:10DA5000EA4B2274F712205112CE4360529007CE47
+:10DA6000E0246112DAB212227B9007CEE0245F122A
+:10DA7000DAB212227B9007CEE0245D12DAB21222D3
+:10DA80007B9007CEE0245B12DAB212227B9007CEA5
+:10DA9000E0241712DAC5FB12CF29FCA3E0FD12D552
+:10DAA00079FAEEF91206CF7408121FF2120FBD02B6
+:10DAB000CF5B12DAB62212DABA22F8A3E03400F908
+:10DAC000888289832212DAC92212DABAE022C0825D
+:10DAD000C083791012D948EA4B60479007CEE02402
+:10DAE00018FAA3E03400FB8A828B8312D94BEA4BED
+:10DAF000603012D8BFFCA3E0FDEC4D6025EC24158E
+:10DB0000F8ED3400F9EA2404FAEB3400FB8882894A
+:10DB100083E0FC8A828B83E0C39C400488828983F3
+:10DB2000E0F902D2A174F6122051EAFEEBFF12CE08
+:10DB300045606912DBB3A3A3A3A3A312CE48605C24
+:10DB40008808890988828983E08E828F83F08882A1
+:10DB50008983A3E08E828F83A3F0E8241212DBA8CE
+:10DB6000F9EE24020A0AEF3400FB120F1BE5082429
+:10DB700015F582E50912DBAB8E828F83A3A3A3A3E5
+:10DB8000F0E5082413F582E5093400F583EE240559
+:10DB9000FCEF3400FD7402121EEF80097C077D004B
+:10DBA00079001210D702D96FF582E93400F583E0CD
+:10DBB00022F8A312DBB722E0F5838882227F0102DC
+:10DBC000212374F412205174FD121FDCEAFEEBFFD6
+:10DBD0008C088D09EE4F6005EC45097004790280D0
+:10DBE0005E7903851882851983AA82AB83120F0F91
+:10DBF0007402122045E0543F4440F0780812226439
+:10DC00007402122045AC82AD83EEFAEFFB120EF7E0
+:10DC10007402121FF2E9FE7024750A03750B007876
+:10DC20000A1222647402122045AC82AD83E50824F6
+:10DC300003FAE5093400FB12E789121FF2EEF974CA
+:10DC40000302DCE574F412205174FA121FDC8A0816
+:10DC50008B09ECFEEDFFEA45096004EE4F70047994
+:10DC600002807E750A03750B00780A122264EE2486
+:10DC7000030C0C0CEF3400FD740212204512E785F2
+:10DC8000121FF27402122045E0543F4440F0740326
+:10DC900012204585820A85830B780A122264740259
+:10DCA000122045AC82AD83AA08AB09120EF77402AC
+:10DCB000121FF2E9702B750803750900780812220B
+:10DCC00064EEFCEFFD7405122045AA82AB831210AE
+:10DCD000D17402121FF2E9640170047900800279A4
+:10DCE0000174068000121FF27F0402212374E812DF
+:10DCF000205174E8121FDC8A0A8B0B89178C088D5F
+:10DD000009EA450B6005EC45097005790202DE263B
+:10DD100074042517F51612E032700302DE21120694
+:10DD20001B8A0C8B0D8C0E8D0F85171075110078CA
+:10DD300010122264AC0AAD0BEE2404FAEF3400FB9F
+:10DD400012E3EB121FF28E828F83A3A3A3E50CF0E4
+:10DD5000E50DF5158E828F83A3A3F0850C10F511C8
+:10DD6000850E12850F1374107810121DEDE510F555
+:10DD7000148E828F83A3F0850C10850D11F512850A
+:10DD80000F1374187810121DEDE510F50A8E828FAE
+:10DD900083F07510107810122264120615EAFCEB5D
+:10DDA000FD740A12204512E3E7121FF285188285DE
+:10DDB00019838582108583117810122264A916EECA
+:10DDC000FCEFFD740A122045AA82AB83120F277460
+:10DDD00002121FF2E9F50B703F850882850983E581
+:10DDE0000CF0A3E51512DE2BE51412DE2BA3E50AD9
+:10DDF000F0750C08750D00780C1222647402122064
+:10DE000045AC82AD83E5082404FAE5093400FB1231
+:10DE1000E3EB121FF2120621EEFAEFFB121155800E
+:10DE200003750B13A90B741802E3DFF085088285D4
+:10DE30000983A3A32274E812205174DD121FDC743D
+:10DE400001122045EAF0A3EB12E78F8C168D1774B0
+:10DE50003B122045E0F50B743C12204512E3F1EC37
+:10DE600045176006E50845097005790202E02D7442
+:10DE70000112204512E117120AB98A148B15EA45DE
+:10DE8000157005791402E02D850882850983E0F577
+:10DE900010E4F511F512F513A3E0F50CE4F50DF51A
+:10DEA0000EF50F7408780C121E067810790C121EED
+:10DEB00025850882850983A3A3E0F50CE4F50D749C
+:10DEC00010780C121E067810790C121E2585088217
+:10DED000850983A3A3A3E0F50CE4F50E7418780C70
+:10DEE000121E067810790C121E25EA241DF582EB0D
+:10DEF00012E8FA780C121EAC7810790C1214DE407D
+:10DF00000D908F62780C1214A3600302DE6A8518EC
+:10DF100082851983E060118A828B83A3A3A3E0A288
+:10DF2000E14005790102E02D7C087D007900740351
+:10DF3000122045AA82AB831210D77404250BF50A70
+:10DF400012E0327005791302E02D850B0C750D007F
+:10DF5000780C122264AC16AD17EE2404FAEF3400EC
+:10DF6000FB12E3EB121FF2750C04780C122264AC66
+:10DF700008AD09EEFAEFFB12E3EB121FF2750C107D
+:10DF8000780C122264E514240DFCE5153400FD74B0
+:10DF90001512204512E3E7121FF274031220458583
+:10DFA000820C85830D780C122264A90AEEFCEFFD29
+:10DFB0007415122045AA82AB83120F277402121F18
+:10DFC000F2E9F50A705E750C08750D00780C1222E6
+:10DFD000647405122045AC82AD83740D1220451285
+:10DFE000E3E7121FF2780C122264E5082404FCE532
+:10DFF000093400FD740D122045AA82AB831210D1A2
+:10E000007402121FF2E964016005750A0180157837
+:10E0100010122260740512204512E11712062774AF
+:10E0200004121FF2EEFAEFFB121155A90A74230233
+:10E03000E3DFFA7B0012114F8A0C8B0DAE0CAF0D93
+:10E04000EE4F2274F4122051890812E17570030218
+:10E05000E106E508704B12E123E0750A08750B0034
+:10E06000780A7025122264EAFCEBFD9007CCE024CC
+:10E070000212E10B121FF2120945E9700712E11DAD
+:10E080007401807D7508018013122264EAFCEBFDA7
+:10E090009007CCE0240A12E10B121FF212E1756026
+:10E0A000617A127B001210E38A0A8B0BAE0AAF0B67
+:10E0B000EE4F603E8E828F8374C1F0A3E508F07549
+:10E0C0000A10750B00780A1222649007CCE0240233
+:10E0D000FCA3E03400FDEE24020A0AEF3400FB1238
+:10E0E000E789121FF2EEFAEFFB12E11DA3E0F9122D
+:10E0F00010EF9007CC12E1171211559007CCE4F005
+:10E10000A3F079018002790002DCE8FAA3E0340090
+:10E11000FB1210BF740222E0FAA3E0FB229007CCAE
+:10E12000E0F8A3E0F58388822274F21220517A206D
+:10E130007B001205DF8A088B09E4F50AF50B8B0DCD
+:10E14000EA450D601678081222607A017B0090077C
+:10E15000D4E0F91211857404121FF202E224C08285
+:10E16000C0837A017B009007D4E0F9121191D0832B
+:10E17000D0820201229007CCE0F8A3E0F9E849221E
+:10E1800074F212205174D0121FDC8A0A8B0BECFE41
+:10E19000EDFF743E12204512E1E2122264AC0AAD9A
+:10E1A0000B740212204512E3E7121FF2750A037581
+:10E1B0000B00780A122264EEFCEFFD741F1220455A
+:10E1C00012E3E7121FF212E1D2780A122264742FCE
+:10E1D000803A851882851983AA82AB83120F21E9C0
+:10E1E000FE22E0F508A3E0F5097C307D007900858A
+:10E1F0001882851983AA82AB831210D7750C10750B
+:10E200000D00780C22780A1222647422122045AC88
+:10E2100082AD83AA08AB0912E3EB121FF2EEF97488
+:10E2200030121FF27F0602212374E812205174B0CD
+:10E23000121FDCEAFEEBFF8C168D17890A74681238
+:10E24000204512E3F1746A122045E0F50CA3E0F5D5
+:10E250000D746C122045E0F510A3E0F511746E12F8
+:10E260002045E0F50B746F122045E0F514A3E0F5AE
+:10E27000157471122045E0F50EA3E0F50F7C307D9A
+:10E280000079007420122045AA82AB831210D77542
+:10E2900012107513007812122264EEFCEFFD742246
+:10E2A00012204512E3E7121FF27C107D00790085F1
+:10E2B0001882851983AA82AB831210D7751207784A
+:10E2C00012122264AC08AD09740212204512E3E771
+:10E2D000121FF27508077509007808122264AC0C49
+:10E2E000AD0D740912204512E3E7121FF2E50B6031
+:10E2F00009740E12204574018006740E122045E444
+:10E30000F0E50A6009740F12204574018006740F4D
+:10E31000122045E4F07C107D007900EC122045AA23
+:10E3200082AB831210D77508067808122264AC10ED
+:10E33000AD11741612204512E3E7121FF27808128D
+:10E340002264AC14AD15741C12204512E3E7121FB1
+:10E35000F27508107808122264AC16AD17743212E8
+:10E36000204512E3E7121FF2851882851983AC82DB
+:10E37000AD837430122045AA82AB83120F03742040
+:10E3800012204512E1D87808122264744212204506
+:10E39000AC82AD83743212204512E785121FF274ED
+:10E3A00010122045AC82AD837430122045AA82AB96
+:10E3B00083120F037420122045AA82AB83120F210F
+:10E3C000E9FF78081222647442122045AC82AD83C2
+:10E3D000AA0EAB0F12E3EB121FF2EE4FF9745012BC
+:10E3E0001FF27F10022123AA82AB831210C5740290
+:10E3F00022E0F508A3E0F5092274F7122051791004
+:10E400008C828D83E0F88A828B83E068F0A3AA82F5
+:10E41000AB838C828D83A3AC82AD8319E970E1025A
+:10E42000DBBD74F212205174D0121FDC8C0A8D0BEC
+:10E43000743E122045E0FEA3E0FF74401220451216
+:10E44000E3F1750C10750D00780C122264EAFCEBF8
+:10E45000FD740212204512E3E7121FF2750C0878D2
+:10E460000C122264AC0AAD0B741212204512E3E7C1
+:10E47000121FF2750A08750B00780A122264EEFC6E
+:10E48000EFFD741A12204512E3E7121FF212E49313
+:10E4900002E20512E1D2750A102274F4122051EA48
+:10E4A000FEEBFF890B750A0080181210DD12E8F1EF
+:10E4B000EBF0050AE50AC3950B500712E8F1EAF004
+:10E4C000050AE50AC3950B40E102DCE8C082C0837F
+:10E4D0008A828B83E0F902E16E74F6122051898200
+:10E4E000AE82E9A2E25004D2F08002C2F08A828BAE
+:10E4F00083E054FCFCA3E0FDEC4E5403FCA2F0E4EA
+:10E5000033F50875090074027808121FC9EC450834
+:10E51000FEE954F8FCEE4C8A828B83F0A3EDF07F89
+:10E520000202212374F6122051EA2420F508EB346C
+:10E5300000F5097808122264EA2410FCEB3400FD8F
+:10E5400012E87C121FF280D774E812205174ED1289
+:10E550001FDC7401122045ECF0A3ED12E78F8A1640
+:10E560008B177A107B0012114F8A128B137A107B53
+:10E570000012114F8A108B11E5124513700302E748
+:10E5800061EA4511700302E7617810122264AC124F
+:10E59000AD13AA16AB17120F2D7402121FF2E9F574
+:10E5A0000A600302E76A12E8908A0E8B0FE50C45B9
+:10E5B0000D700302E742EA450F700302E742851837
+:10E5C00082851983E0240FF8E43400F97A107B0087
+:10E5D000121F4988088909AE08AF09E0540FFCEE04
+:10E5E0004F70067E017F008007EC70047801800286
+:10E5F0007800EE14C454F0FA7401122045E02AFAAF
+:10E60000A3E03400FBE8A2E0500B780E122264ACC9
+:10E6100012AD1380588C0B750800850882AC82748B
+:10E6200003122045E5822CF8E5833400F9ECC3950C
+:10E630000B500FEA2CF582EB12E8FAE0888289830E
+:10E64000800FE50B650888828983700474808001DF
+:10E65000E4F00508E508C3941040BF780E12226468
+:10E66000AC10AD117405122045AA82AB8312E88A62
+:10E67000121FF27C107D007900AA0CAB0D1210D78E
+:10E68000750800750900804C7403122045858214BA
+:10E690008583157814122264E508C454F0F87403D5
+:10E6A000122045E028FCA3E03400FDAA0CAB0D12BB
+:10E6B000E88A121FF2780C122264740512204512A7
+:10E6C000E874121FF2E9F50AE5082401F508E509E6
+:10E6D0003400F509EE24FFF8EF34FFF9C3E508989C
+:10E6E000E50999A2D265D0335004E50A609AE50A9B
+:10E6F00070597403122045858208858309780812B1
+:10E700002264AC0EAD0FAA0CAB0D12E88A121FF2F8
+:10E71000780C122264740512204512E874121FF25C
+:10E72000E9F50A7508087509007808122264AC0C2E
+:10E73000AD0D742D12204512E11712E789121FF258
+:10E740008009750A13E50C450D6007AA0CAB0D1284
+:10E750001155E50E450F6012AA0EAB0F1211558030
+:10E7600009750A13E51245136007AA12AB131211BB
+:10E7700055E51045116007AA10AB11121155A90AF1
+:10E78000741302E3DFAA82AB831210BF740222F07B
+:10E79000E9851882851983F02274EE1220518A08C7
+:10E7A0008B098C0E8D0F7412122045E0F510A3E03A
+:10E7B000F51112E8908A0A8B0BAE0AAF0BE50C45F7
+:10E7C0000D700302E852EE4F700302E8527C107D98
+:10E7D0000079001210D7780C122264EEFCEFFDAA2B
+:10E7E00008AB0912E87C121FF2E9F50A706D750892
+:10E7F0008D75098E850C82850D83E0A2E7400DACF6
+:10E800000EAD0FAA0CAB0D120F398016EEFCEFFD0A
+:10E81000AA0CAB0D120F39780E12226412E8821284
+:10E820001FF2850E82850F83E0A2E7400DAC10AD8C
+:10E8300011AA0EAB0F120F398021EEFCEFFDAA0ECC
+:10E84000AB0F120F39781012226412E882121FF2F5
+:10E850008009750A13E50C450D6007AA0CAB0D1273
+:10E860001155EE4F6007EEFAEFFB121155A90A7F22
+:10E870000A022123AC82AD83AA16AB17120B0D74CA
+:10E880000222AC08AD09EEFAEFFB120F337402223C
+:10E890007A107B0012114F8A0C8B0D7A107B0012BC
+:10E8A000114F2274F6122051740A122045E0F8A389
+:10E8B000E0F9750900850982AE82EC2EF582ED1231
+:10E8C000E8FAC082C083EA2EF582EB12E8FAE0D0C3
+:10E8D00083D082F508E06508C0E0E82EF582E912F1
+:10E8E000E8FAD0E0F00509E509C3941040C702E555
+:10E8F0001F850A08EE2508F582EF3400F58322749F
+:10E90000F512205175090075080FE508F83395E0F8
+:10E91000F9EC28FEED39FFEA28F8EB39F98882890D
+:10E9200083E0C3338E828F83F04509F08882898328
+:10E93000E0A2E7E433F50974FF2508F508C3940065
+:10E94000A2D265D03350C37F03022123C082C0838B
+:10E950007B0012F1E9A3E412EE22A3A3A3A374FFA8
+:10E96000F00BEBC3940240EA90060E74FFF09006A1
+:10E970000DE4F090060CF090060FF0A3F002F1BA4F
+:10E9800074EC12205190060FE0F50AA3E0F50BE5B8
+:10E990000A450B7006120BA902EC88850A82850BCA
+:10E9A00083E0F914601814601524FE601124C4700B
+:10E9B0000302EAFB24C0700302EAFB02EC8812ECBB
+:10E9C0009AEE240EF512EF3400F513EE2402F5084A
+:10E9D000EF3400F50990046FE0700302EA6512EC71
+:10E9E000CCF510A3E0F511AC10FDEEFAEFFB120D23
+:10E9F00029E9F50E7402650E60618E828F83E064F2
+:10EA000001600302EC88EE650A7003EF650B60039A
+:10EA1000120BCDE50E701912ECA6121E38908F362F
+:10EA2000780C121E86850882850983780C121EBB1D
+:10EA3000851082851183A3A37808121EAC908F0ADB
+:10EA40007808121E38908F367808121E868512823A
+:10EA50008513837808121EBB02EC7B12ECAFAA1060
+:10EA6000AB1102EC85EE650A7003EF650B700302D3
+:10EA7000EC858E828F83E06401600302EC8812EEE5
+:10EA8000EC908F72780C121E38780C122260850878
+:10EA900082850983121ECA12EEE6121FF2E970582F
+:10EAA00012ECA6121E38908F36780C121E8685083E
+:10EAB00082850983780C121EBB900442E0640270C8
+:10EAC000288508828509837808121EAC908F4A78C1
+:10EAD00008121E38908F367808121E86851282859D
+:10EAE00013837808121EBB800F908F62121ECA8596
+:10EAF0001282851383121ED602EC7B90046FE070A5
+:10EB00000302EBDB12ECCCF508A3E0F509900470EE
+:10EB1000E0F875F004A4C8AAF02AF9747228F50A7E
+:10EB2000740439F50BE50A2404F50EE50B3400F501
+:10EB30000F90060DE054076075A3E0F9120D2F8ABF
+:10EB4000108B11AE10AF11AC08AD09120D29E9F50B
+:10EB500010740265106057850E82850F83E0F912EC
+:10EB60000D838E828F83E064017043120BCDE5101C
+:10EB7000701912ECA6121E38908F36780C121E8671
+:10EB80008E828F83A3A3780C121EBB850882850911
+:10EB900083A3A37808121EAC908F0A7808121E383F
+:10EBA000908F367808121E8612EE1B02EA53E50C8F
+:10EBB000650A7004E50D650B601A850A82850B8372
+:10EBC000A3A3A3E0600B850E82850F83E0F9120DED
+:10EBD0008312ECAFAA08AB0902EC8590060DE05455
+:10EBE00007700302EC88A3E0F912EC9A8E828F83FF
+:10EBF000E06401600302EC8812EEEC12EC8D908F61
+:10EC000072780C121E38780C122260850882898373
+:10EC1000121ECA12EEE6121FF2E9705F12ECA61283
+:10EC20001E38908F36780C121E86850882850983DF
+:10EC3000780C121EBBEE240EF8EF3400F9880A900F
+:10EC40000442E064027027850882850983780C12EB
+:10EC50001EAC908F4A780C121E38908F36780C12AA
+:10EC60001E86850A828983780C121EBB800D908FC8
+:10EC700062121ECA88828983121ED690060E740103
+:10EC8000F0EEFAEFFB120D237F0C022123EE24029B
+:10EC9000F8EF3400F98808890922120D2F8A088BB1
+:10ECA00009AE08AF092212EEF3908F5E780C22E5D0
+:10ECB0000C2404FEE50D3400FF8E828F83E0F912F0
+:10ECC0000D898E828F83E0900470F022120C57E938
+:10ECD000F875F004A4C8AAF02AF9747228F50C7427
+:10ECE0000439F50D850C82F583E02274F012205171
+:10ECF000EAFEEBFF8E828F83A3A3A3A3A3A3E0FA74
+:10ED0000A3E0FB120DD712EC8D8882F583121ECA88
+:10ED1000120DCB850882850983121ECA120DBF12FF
+:10ED2000EE1B121ECA120DD18E828F83E0644070DA
+:10ED300019EE2412F8EF3400F988828983E090609C
+:10ED40006412EE22E09060658006906064E4F0A3B7
+:10ED5000F090060FEEF0A3EF12F15C12F5E812202E
+:10ED60004F906054E412EE29A312EE29906182E0E4
+:10ED7000C2E6F07591BFEE2415F8EF3400F9880A69
+:10ED8000890B8882F583E064017003120E0DE5E1C2
+:10ED900070FC12F14DE0F874FF68600288E1850AAA
+:10EDA00082850B837401F0900448E064017067125F
+:10EDB000EEEF780C122260850882850983121ECA44
+:10EDC00012283A7404121FF28A088B098C0A8D0BE0
+:10EDD000908F66780C121EAC7808790C121CE974BE
+:10EDE000037808121DEDE50824F4F508E50934015F
+:10EDF000F5099005DEE0600312113DE4F50AF50B1C
+:10EE000078081222607A207B00900441E0F9121108
+:10EE1000857404121FF27F08022123EE240E12F1E2
+:10EE20005422F088828983A322F0A3F0A3F0A3F0F8
+:10EE3000A3F0A3F02274EC122051EAFEEBFF8C0841
+:10EE40008D09EE4F7005790202EEE312EEEF908F1E
+:10EE500076780C121E38908F36780C121E86E508D4
+:10EE60002402F8E50912EC92780C122260850882DF
+:10EE70008983121ECA12283A7404121FF28A108B58
+:10EE8000118C128D13908F0E78101214FE50B7EE65
+:10EE90002402EF34000E0EFF85088285098378086E
+:10EEA000121EAC908F127808121E38780812226059
+:10EEB0008E828F83121ECA12EEE6121FF2E970864E
+:10EEC000908F16780C121E38780C1222608E828F6A
+:10EED00083121ECA12EEE6121FF2E9700479008056
+:10EEE00002790102EC881227DD740422120BCD1284
+:10EEF000EEF322120DF58A0C8B0D8C0E8D0F227401
+:10EF0000EE122051890874FF6508702E90060DE0FE
+:10EF10005407602312F08070087904120D5302F038
+:10EF20006B790112F0827004790180EF790212F09E
+:10EF3000827007790280E402F067A908120D538AF3
+:10EF4000108B11A90812F0827005750901800375F4
+:10EF50000900E5102402F50AE5113400F50BE50877
+:10EF600014600F14700302EFFF24FE700302F04CD4
+:10EF700080C5790212F0827038790212F070506701
+:10EF80008E828F83A3A3780C121EAC908F1A780CFC
+:10EF9000121E38780C122260850A82850B83121E9D
+:10EFA000CA12EEE6121FF2E9703DAA10AB1102F090
+:10EFB0006B12F0807037790412F070502A8E828FB5
+:10EFC00083A3A3780C121EAC908F1A780C121E38F3
+:10EFD000780C122260850A82850B83121ECA12EEFB
+:10EFE000E6121FF2E960C3EEFAEFFB807EE509A2AC
+:10EFF000E05006AA10AB1180727A007B00806C1280
+:10F00000F0807034790412F07050DC8E828F83A30C
+:10F01000A3780C121EAC908F1A780C121E38780C44
+:10F02000122260850A82850B83121ECA12EEE61236
+:10F030001FF2E970B202EFAA790112F0827004792E
+:10F040000180C3E509A2E0501E02EFAA790112F087
+:10F050008260EC790212F0827004790280A8E509DE
+:10F06000A2E0500302EFAA7A007B007F0A0221236C
+:10F07000120D538A0C8B0DAE0CAF0DE509A2E022E8
+:10F080007904120D47E964012274F5122051890AAE
+:10F090007C00EC75F018A4FAABF0740C2AF8740636
+:10F0A0003BF9880889098882F583A3A3A3A3A3A3B6
+:10F0B000E0600302F13A74112AFE74063BFF8E826F
+:10F0C0008F83A37401F08E828F83E50AF0120DF511
+:10F0D0008E828F83A3A3121ED68E828F83A3A3A3B7
+:10F0E000A3A3A3E4F0A3F0908F62121ECA12EE1B3A
+:10F0F000121ED612F14D7401F0EE241512F1547463
+:10F100000112F15CE4F0A3F090060DE0450AF090E6
+:10F11000060CE004F0E5082405FAE5093400FBE0FC
+:10F120006401600C7480650A60067440650A70189A
+:10F1300090060FEAF0A3EBF0800E0CECC3940250A3
+:10F140000302F0927A007B007F03022123EE241455
+:10F1500012F15422F582EF3400F58322F0EE2416EA
+:10F1600012F15422C082C0838A828B83E0F8A3E02C
+:10F17000F98A828B83E4F0A312EE22F088828983DD
+:10F18000E0F4F890060DE058F090060CE014F070F2
+:10F190000B90060FE4F0A3F0900442F0801CC082B4
+:10F1A000C08390060CE0600A90060FE0FAA3E0FB33
+:10F1B00080047A007B008002E0F9D083D0820201D3
+:10F1C00022C082C083E9FC7B0012F1E9E06C700E82
+:10F1D00088828983A3A3A3A3A3A3E0F980090BEBEF
+:10F1E000C3940240E4790080D1EB75F018A4F8A92B
+:10F1F000F0740C28F8740639F988828983A3A3A3D4
+:10F20000A3A322C082C08390060D80AC74F71220A5
+:10F21000517E00EE75F018A4FAABF0740C2AFA7463
+:10F22000063BFBEAFCEBFDEC2405FAED3400FB8A1F
+:10F23000828B83E069700F8C828D83A3A3A3A3A329
+:10F24000A3E06401600B0EEEC3940240C67A007B1B
+:10F25000007F01022123C082C08390060C02F1B816
+:10F2600074F2122051EAFEEBFFEE2400F8EF3401B5
+:10F27000F989099061D0E088828983F09061D7E0B4
+:10F28000FAEE240108EF3401F9880A890B9061D560
+:10F2900012F3CA240208EF3401F9880C890D906139
+:10F2A000D612F3BB70149061C5E0A2E4500CE0A24A
+:10F2B000E75007888289837480F0120EA9850A823C
+:10F2C000850B83E07019850C82850D83E0701090AA
+:10F2D00061C5E0A2E45008E0A2E7500312F3CF7545
+:10F2E000E195780080129061D3E0C0E0880AEE25B5
+:10F2F0000A12F154D0E0F0088E82850983E0F9E823
+:10F30000C39940E275E1917F0602212374F2122035
+:10F3100051EAFEEBFFEE2403F8EF3401F988088987
+:10F32000099061C8E088828983F09061CFE0FAEEAD
+:10F33000240408EF3401F9880A890B9061CD12F397
+:10F34000CA240508EF3401F9880C890D9061CE12AA
+:10F35000F3BB70149061C5E0A2E0500CE0A2E35052
+:10F3600007888289837480F0120EAF850A82850B2C
+:10F3700083E07019850C82850D83E070109061C563
+:10F38000E0A2E05008E0A2E3500312F3CF120EB562
+:10F390007A0080149061CBE0C0E08A0AEE250AF87A
+:10F3A000EF12F489D0E0F00A850882850983E0F83D
+:10F3B000EAC39840DF75E18102F30712F3BF22E050
+:10F3C000C39A547F88828983F02212F3BFEE22858C
+:10F3D0000C82850D837480F0850A82850B83F02270
+:10F3E00074F61220519061C6E0FCE0540FF075E114
+:10F3F00091780080118808EA2508F582EB12F15710
+:10F40000E09061D2F008EA240012F480F9E8C39990
+:10F4100040E3EA240212F48060049061D6F0EA240A
+:10F420000112F48060049061D5F0EC9061C6F07F29
+:10F430000202212374F61220519061C6E0FDE054CF
+:10F44000F0F075E1817C0080108C08EA2508F8EB6B
+:10F4500012F489E09061CAF00CEA240312F480F8F7
+:10F46000ECC39840E4EA240512F48060049061CE75
+:10F47000F0EA240412F48060049061CDF0ED80ABDA
+:10F48000F582EB3401F583E0223400F9E82480F5BD
+:10F4900082E912F15722C082C083906195E0C0E0FA
+:10F4A000EA2486F582EB3401F583D0E0F090619692
+:10F4B000E0C0E0EA2487F582EB3401F583D0E0F088
+:10F4C000906197E0C0E0EA2488F582EB3401F5838F
+:10F4D000D0E0F0906198E0C0E0EA2489F582EB3456
+:10F4E00001F583D0E0F002F1BAC082C083EA24863D
+:10F4F00012F480906195F0EA248712F4809061966E
+:10F50000F0EA248812F480906197F0EA248912F4DA
+:10F5100080906198F002F1BA74F4122051890812B7
+:10F52000F619120D65EEFAEFFB120D5F750A807584
+:10F530000B00780A1222647C007D60EE2406FAEF4C
+:10F540003401FB120CCF7402121FF2EEFAEFFB1221
+:10F550000D777F0402212374F21220518982858263
+:10F560000812F619120D71EEFAEFFB120D6B750C05
+:10F5700080750D00780C122264EE2406FCEF340135
+:10F58000FD7A007B60120CCF7402121FF2EEFAEFCC
+:10F59000FB120D7DE50875F004A4C508A8F028F558
+:10F5A0000974722508F58274043509F58312F5E8AB
+:10F5B000E0648070079004427408801E900F0C1263
+:10F5C000F5F112F5F17411F0A3740D12F5F77495BD
+:10F5D000F0A3740DF09004427407F0900F1A12F625
+:10F5E00002A312F60202F307E0F8A3E0F583888293
+:10F5F00022748FF0A3740DF0A3748FF0A3740DF038
+:10F60000A322741112F61012F610F0A3740DF0225A
+:10F61000F0A3740DF0A3741122A808E875F08AA471
+:10F62000C8AAF02AF9744128FE740639FFEEFAEFF1
+:10F63000FB2274F4122051E9FE74FF2EF50B04C373
+:10F6400013FE7F0080358F82AC82EA2CF8EB340009
+:10F65000F988828983E0F50A850B08E508C39CFCDC
+:10F6600095E0FDEA2CFCEB3DFD8C828D83E08882E9
+:10F670008983F08C828D83E50AF00FEFC39E40C62C
+:10F680007F04022123C082C08390618FE0F902F7DA
+:10F69000C174F512205174FE121FDC890AE970054D
+:10F6A000791202F75153B4F390619A743FF0A37446
+:10F6B0005AF09061A0E4F0906184F0E5E170FC758F
+:10F6C000E1027C009061BFE070070CECC394FA404B
+:10F6D000F374FA6C7004791F80777C009061BF121C
+:10F6E000FFCA9061BFE0FD7401122045EDF085185E
+:10F6F00082851983E0FEEDF9EEF849600A7403682B
+:10F70000700374806970070CECC394FA40CE74FAED
+:10F710006C60C37C00801D9061BF12F75912F759CD
+:10F72000E5BCC0E08C08EA2508F582EB3400F583DF
+:10F73000D0E0F00CECC3950A40DDE5E170FC75E12A
+:10F74000018DBC851882851983E0F5BC120B857983
+:10F75000007402121FF202F853E0F5BDE0F5BDE0BF
+:10F76000F5BDE0F5BD22C082C0837C008C82A882FA
+:10F77000740028F58274063400F583E0C0E012F7C7
+:10F78000B4D0E0F00CECC3940840E18034C082C0F7
+:10F79000837C008C82A882740828F5827406340069
+:10F7A000F583E0C0E012F7B4D0E0F00CECC39404B1
+:10F7B00040E1800DEA28F582EB3400F58322120C3B
+:10F7C000E1D083D082020122C082C08374FC121F68
+:10F7D000DC851882851983EAF0A3EBF0A3ECF0A393
+:10F7E000EDF07404122045E0FAA3E0FB8518828551
+:10F7F0001983E08A828B83F0740112204512F82D60
+:10F80000F0740212204512F82DA3F0740312204563
+:10F8100012F82DA3A3F0E9A2E0E43313138A828B3C
+:10F8200083A3A3A3A3F07404121FF28094E08A823E
+:10F830008B83A32274F5122051ECFEEDFF740B12A2
+:10F84000204512F85812226812FCEB121FF27900C0
+:10F85000120CE17F03022123E0F508A3E0F5091271
+:10F860000CED750A10780A22C082C0839009A17439
+:10F8700070F0A374B1F0A3E0541FF09009A5741DBB
+:10F88000F0A37442F0A37470F0A374B2F09009ABCB
+:10F89000E0541FF09009AD741EF0A37412F002F74B
+:10F8A000C1C082C08390099BE0541FF090099D74F1
+:10F8B00020F0A37452F002F7C174F41220518A08A8
+:10F8C0008B09ECFEEDFF740C122045E0F50AA3E075
+:10F8D000F50BEA6E7002EB6F6035120CC9EF900900
+:10F8E00097F0EEA3F0E509A3F0E508A3F0E50A9090
+:10F8F000099CF0E50BF50A90099BE054E0450AF0FD
+:10F9000053D1FE75D60175D701E5D1A2E050FA02B8
+:10F91000F680C082C083EB90099FF0EAA3F0E91261
+:10F92000F96853D1FD75D60202F7C174F712205160
+:10F930007409122045E0F8ED90099FF0ECA3F0E87F
+:10F9400012F968EB9009A9F0EAA3F0E99009ACF08C
+:10F950009009ABE054E0F053D1FD53D1FB75D602D2
+:10F9600075D6047F010221239009A4F09009A3E039
+:10F9700054E0F022E5B354F849F5B343B301E5B3DD
+:10F98000A2E350FA020122C082C083E5B3548F443F
+:10F9900050F5B379107A2E7B8E120CD5790602F7CA
+:10F9A000BEC082C083E5B3548F4440F5B3791012D2
+:10F9B0000CD5790402F7BE74F012205174E0121FC6
+:10F9C000DC8A0A8B0B8908ECFEEDFF7430122045AF
+:10F9D000E0F50CA3E0F50D740F5508600478018084
+:10F9E000027800E9C4540F28F509750E10750F0050
+:10F9F000780E1222647C2E7D8E741212204512FA2B
+:10FA0000C2121FF274101220457401F0750E0D78A9
+:10FA10000E122264AC0AAD0B741312204512FAC206
+:10FA2000121FF212FBC012204512FBCC122268AC4E
+:10FA30000CAD0D79107401122045AA82AB8312FC23
+:10FA4000F5121FF27900120CE1741F12204512FB0F
+:10FA5000D512204512FBAFE509C454F0F9F50A7838
+:10FA60000A122268EEFCEFFDEEFAEFFB12FCF51233
+:10FA70001FF280057900120CE1AA0974FF2AF5092A
+:10FA80000470F185080AEE250AF8EF3400F98518AC
+:10FA900082851983E088828983F0740112204512DF
+:10FAA000FACCF0740212204512FACCA3F0740312BF
+:10FAB000204512FACCA3A3F07420121FF27F080293
+:10FAC0002123AA82AB83120CCF740222E0888289A0
+:10FAD00083A32274F012205174E0121FDC8A0A8B77
+:10FAE0000B89098C0C8D0D743012204512FD1F609E
+:10FAF00004780180027800E9C4540F28F508750ED7
+:10FB000010750F00780E1222647C2E7D8E741212F6
+:10FB1000204512FAC2121FF274101220457401F02F
+:10FB2000750E0D780E122264AC0AAD0B7413122000
+:10FB30004512FAC2121FF212FBC012204512FBCC72
+:10FB4000122268EEFCEFFD79107401122045AA82A2
+:10FB5000AB8312FCF5121FF27900120CE112FCFBD0
+:10FB600012204512FD1112204512FD2912204512C6
+:10FB7000FD0A741F12204512FBD512204512FBAF5F
+:10FB8000E508C454F0F9F50A780A122268AC0CAD05
+:10FB90000DAA0CAB0D12FCF5121FF28005790212B2
+:10FBA0000CE1A80874FF28F5080470F102FAB812F5
+:10FBB000FBB322AA82AB83120CD57906120CE12288
+:10FBC000E5B3548F4410F5B37910E92212FBB375F5
+:10FBD0000A10780A227401F0E5B3548F4430F5B36B
+:10FBE0007910E92274EE12205174E0121FDC8A0CA5
+:10FBF0008B0D890A8C097432122045E0F50EA3E0C2
+:10FC0000F50F743412204512FD1F60047801800244
+:10FC10007800ECC4540F28F508120CE77510207515
+:10FC2000110078101222647C2E7D8E740212204501
+:10FC300012FAC2121FF28518828519837449F07571
+:10FC4000100D7810122264AC0CAD0D740312204517
+:10FC500012FAC2121FF2740F122045E509F0741156
+:10FC60001220457401F07412122045E50AF0792043
+:10FC7000851882851983AA82AB83120CD57900126C
+:10FC80000CE17900120CE1E508C454F0F50B780B97
+:10FC9000122268AC0EAD0F79107401122045AA82B1
+:10FCA000AB8312FCF5121FF2800D7800748F5A4856
+:10FCB000F5B37900120CE1AB0874FF2BF508046072
+:10FCC0000BE5B3FAE50860E2785080E012FCFB1225
+:10FCD000204512FD1112204512FD2912204512FD6A
+:10FCE0000A7420121FF27F0A022123EEFCEFFD7935
+:10FCF00010AA08AB09120CDB740122851882851941
+:10FD000083E08E828F83F074012212FD18A3A3F08A
+:10FD10002212FD18F0740222E08E828F83A322E06B
+:10FD2000FEA3E0FF740F55092212FD18A3F074031F
+:10FD30002274EC12205174FC121FDCEAFEEBFF89E6
+:10FD40000D8C0C7418122045E0F50EA3E0F50F128F
+:10FD5000FFB324D5F510EF3400F511851082F5833B
+:10FD60007808121EACEE24A6F512EF3400F51390BD
+:10FD70000442E06408781270071222647901800559
+:10FD80001222647900AA08AB09AC0AAD0B120CB7B9
+:10FD90007402121FF2850C82AA827420C39AF5089D
+:10FDA00095E0F50978081222647C2E7D8EE50E2AF6
+:10FDB000FAE50F3400FB12FAC6121FF2851882858D
+:10FDC00019838582088583097808122264780E12C7
+:10FDD0002264AC0CA90DAA12AB13120CFF7404120E
+:10FDE0001FF27808122264AC0EAD0FA90CAA12AB58
+:10FDF00013120CF37402121FF2908F767808121E01
+:10FE0000AC8510828511837808121E4B7404121F72
+:10FE1000F27F0C02212374E812205174F8121FDCC7
+:10FE2000EAFEEBFF890B8C0A7420122045E0F514E2
+:10FE3000A3E0F51512FFB324D9F516EF3400F5173A
+:10FE4000851682F583780C121EAC850C10850D1179
+:10FE5000850E12850F13EE24A6F50CEF3400F50D78
+:10FE6000900442E06408780C7007122264790080E4
+:10FE7000051222647901AA10AB11AC12AD13120C59
+:10FE8000B77402121FF2850A82A882E51428F508C9
+:10FE9000E5153400F509850882F58312FFCA850847
+:10FEA00082850983A3E0C0E07401122045D0E012EE
+:10FEB000FFC0E0C0E07402122045D0E012FFC0A3F2
+:10FEC000E0C0E07403122045D0E0F07420C398FE37
+:10FED00095E0FF750E2E750F8E8E108F1178101213
+:10FEE0002264AC0EAD0FAA08AB0912FAC6121FF2BB
+:10FEF00085188285198385821085831178101222D6
+:10FF000064AC14AD15A90AAA0CAB0D120CF974025D
+:10FF1000121FF28E108F117810122264AC0EAD0FEA
+:10FF2000AA08AB0912FAC6121FF274041220458502
+:10FF3000820885830978081222647814122264AC3E
+:10FF40000AA90BAA0CAB0D120CFF7404121FF28548
+:10FF50001882851983E0F87404122045E068703037
+:10FF60007401122045E0F87405122045E068702005
+:10FF70007402122045E0F87406122045E068701003
+:10FF80007403122045E0F87407122045E06860040D
+:10FF900079008015908F76780C121EAC85168285BC
+:10FFA0001783780C121E4B79017408121FF27F1010
+:10FFB000022123EE24B3FAEF3400FB120CEDEE2203
+:10FFC000F0850882850983A3A322E085188285191C
+:10FFD00083F02274F71220517409122045E0F8A32F
+:10FFE000E0F98A828B838003ECF0A3E8FEE9FFEE60
+:10FFF00024FF18EF34FFF9EE4F70ED7F010221234B
+:020000040001F9
+:10000000C082C0839003C674FFF0A3F0A3F0A3F0F6
+:10001000A3F0A3749FF0A3E4F0A37420F09003C5B1
+:1000200014F0D083D08202012274F6122051E9FE2E
+:10003000128BCE60081282F5741A1282DF7F0202E0
+:10004000212374EE122051890AEAFEEBFF8C088D01
+:10005000099007D8E06003028155E9333354FC046A
+:10006000F50B7407250BFA7B001210E38A0C8B0D3D
+:10007000AC0CAD0DEC4D70030281558C828D8374F8
+:1000800001F0A374FFF0EC2402F8ED3400F9880CC1
+:10009000890DEC24040808ED3400F9850C82850DE7
+:1000A00083E8F0A3E91281767404128176A37413B5
+:1000B000128181E50B128181A3E50AF0750B000224
+:1000C0008145850B8285820E750F00E50EC333FADC
+:1000D000E433FBEE2AF8EF3BF988108911740278BB
+:1000E0000E121FC9A80EA90F851082851183E0F595
+:1000F0000EC00E12815FD0E0F0851082851183A3BF
+:10010000E0F50EC00E12815AD0E0F0E5082AFAE5BB
+:10011000093BFB8A828B83E0F50EC00E12815AA345
+:10012000D0E01284FEA3E0C0E0850C82850D83E060
+:1001300028FAA3E0398A82F583A3A3A3A3A3A3A3E8
+:10014000D0E0F0050BE50BC3950A50030280C2EC2A
+:10015000FAED128BC47F0A02212312815FA322854C
+:100160000C82850D83E028F50EA3E039850E82F51B
+:1001700083A3A3A3A32212817A2212845B1289C8CB
+:100180002212817AA3A32274EE1220518A088B09CD
+:10019000890B8C0E8D0F9007D7E070099007D9E07E
+:1001A000700302825190039EE060030282518982B3
+:1001B00085820C750D00E92407FAE43400FB121067
+:1001C000E38A108B11AE10AF11EE4F700302826202
+:1001D00074186508700474206509600C741765084C
+:1001E00070047420650970109007D9E0600AF50A60
+:1001F0008E828F837492800C9007D7E0F50A8E82EE
+:100200008F837491F0A3740E12834E8E828F83A31A
+:10021000A3F08E828F8312891FEE2405F8EF34003D
+:10022000F9E8FAE9FBEE24070808EF128515F078E3
+:100230000C122264AC0EAD0F8A828B83E0FAA3E02D
+:1002400012847F121FF2EEFAEFFBA90A1210EF8060
+:1002500011780E122264AC0B790E1209BD740212D1
+:100260001FF202815574F6122051E9FE8C088D09A7
+:100270007808122264EEFC79FF1209BD7402121F85
+:10028000F202803D74F5122051890AEAFEEBFF90DC
+:1002900007D7E0603690039EE070307A06128BD06C
+:1002A00060388A828B837491F0A3740F12883BE5C7
+:1002B0000A12834E8A828B83A3A3A3128900EEF0D5
+:1002C000A3EFF09007D7128BC8800FEEFCEFFD89EB
+:1002D00008AA087B00790F1209B77F0302212312B5
+:1002E0008843740112830D12846DEEF09007D5E0FF
+:1002F000F91210EF22128BE8FCA3E0F5838C8274D4
+:100300000412830DFCA3E0F5838C82A322128C04DB
+:100310002274F712205174FC121FDCEA85188285C2
+:10032000198312834EC0E07401122045D0E0F074AE
+:1003300002122045ECF07403122045ED128C767AFF
+:10034000041209C37404121FF27F01022123F090EA
+:1003500003A2E02274F012205189098A0A8B0B8CC7
+:10036000087410122045E0F50CA3E0F50D74072584
+:1003700008FA74FF65096004780380027802E82AAD
+:10038000FA7B001210E38A0E8B0FAE0EAF0FEE4F0A
+:1003900070030284568E828F837401F0A374FFF081
+:1003A000EE24020A0AEF3400FBEE2404F8EF128573
+:1003B00008E5091284FEE02402128728A90B74FFC5
+:1003C000650960317403250812834EC0E01284640D
+:1003D000D0E012848FE50A12848FA3E9F085080A21
+:1003E000750B00780A122264AC0CAD0D8A828B83E7
+:1003F000E0240680557402250812845BC0E0128454
+:1004000064D0E0128486E0C0E0128471D0E01284EF
+:1004100086A3E0C0E0128471A3D0E012849BE50AB9
+:1004200012849BA3E9F085080AE50A24FDF50AE495
+:1004300034FFF50B780A122264E50C2403FCE50D69
+:100440003400FD8A828B83E02408128476121FF226
+:10045000EEFAEF128BC47F08022123F0850C82850F
+:100460000D83E022128468228A828B83E012853910
+:1004700022128468A322FAA3E0340012847F22FBB4
+:100480001210BF740222F0850C82850D83A3221204
+:10049000849322128525A3A3A3A322128493A3A34A
+:1004A0002274F2122051890A8A0BECFEEDFF7407C8
+:1004B000250BFA128B586041128B700A0AFBE50873
+:1004C00024040808E509128508E50A1284FE12854D
+:1004D00033A3E50BF0601BF50C750D00780C1222B0
+:1004E00064EEFCEFFD8A828B83E024031284761293
+:1004F0001FF2AA08AB09128BC57F060221231285C1
+:100500000222F08A828B83221285151285217404BF
+:10051000128521A3223400F98A828B83E8F0A3E9B3
+:100520002212852522F08A828B831289C7227F10AE
+:100530000221231289C3A322E01289C8A3A3A32204
+:1005400074E812205189158A0C8B0D8C148D13744C
+:1005500018122045E0F516A3E0F517741A1220458D
+:10056000E0FEA3E0FF741C122045E0F508A3E0F5CF
+:1005700009741E1220451289D07420122045E0F51E
+:10058000129007D7E0700302862E7A157B001210B6
+:10059000E38A0E8B0FEA450F70030287251287A4AA
+:1005A0007401F0EA2408FAEB3400FBE50E24031290
+:1005B0008B4FE5157018E4F0751006F511781012E0
+:1005C0002264AC16AD17128480121FF2800C7431B5
+:1005D000F07C067D0079001210D7850E82850F838E
+:1005E000A3A3A3A3E50CF0A3E50D128768E51412FD
+:1005F0008768A3E513F0E50E240E128B4FEEF0A3EF
+:10060000EFF0E50E2410128B4F128922E50E241212
+:10061000128B4FE50AF0A3E50BF0E50E2414128BC4
+:100620004FE512F0AA0EAB0F9007D7028722900376
+:10063000CDE0A2E540030287259003C5E0A2E0409B
+:10064000030287257A1A7B001210E38A108B11EAC5
+:1006500045117003028725128751F50EEB3400F522
+:100660000F128748850E82850F83E8F0A3E9128771
+:10067000837404128783A3743E12879274131287C3
+:1006800092A37401128798E515128798A3E50CF0E0
+:10069000E50DF50C850E82850F83128830E50C126E
+:1006A00087B8E5141287B8A3E513F0750C06750D2D
+:1006B00000780C122264AC16AD17850E82850F836C
+:1006C000E02409128476121FF2850E82850F83E0E2
+:1006D000240F1287371287762410128728EF12878B
+:1006E000762411128742F0E509F508850E82850F00
+:1006F00083E02412128742128776241312873CF07B
+:10070000E50BF50A850E82850F83E0241412873CE1
+:100710001287762415128728E512F0AA10AB1190E3
+:1007200007D5128BC802852E12872C22F8A3E0343D
+:1007300000F9888289832212872CEE2212872CE509
+:100740000A2212872CE50822EA2404F8EB3400F987
+:100750002212875522128759228A828B837401F0D4
+:10076000A374FFF0EA240222F0850E82850F83A392
+:10077000A3A3A3A3A32212877A22F0850E82850F5A
+:1007800083E0221287872212878B2212877A1289AE
+:10079000C822128787A3A32212879C2212878BA3C9
+:1007A000A3A3A3228A828B8374911287AE22F0A323
+:1007B000743E128502A3A32212879CA3A3A32274D2
+:1007C000F4122051EAFEEBFF89089007D7E060237E
+:1007D0007A06128BD060548A828B837491F0A37452
+:1007E0000512883BE41284FE128906E508F09007A2
+:1007F000D780359003C6E0A2E450307A0B128BD03C
+:1008000060291282F5740512883F740412883FA390
+:10081000E4128850EE128850A3EFF0888289831288
+:100820008830E508F09007D5128BC87F0402212399
+:1008300012883422128538A3A3A3221287B222126F
+:10084000884322128C04FCA3E0F5838C82A3A322AC
+:10085000128843A3A32274F01220518A088B09EC5A
+:10086000FEEDFF74101220451289D074121220453B
+:10087000E0F50CA3E0F50D9007D7E0603E9003C5CE
+:10088000E0A2E250787A0C128BD060711287A474C7
+:100890000312883BA3E4F012891A8A828B83A3A3F4
+:1008A000A3128906A3A3A3E50AF0A3E50B1289000E
+:1008B000A3A3A3128B659007D7803F9003CDE0A23E
+:1008C000E5503A9003C5E0A2E250327A11128BD083
+:1008D000602B128BD8743EF0A3740AF0A37403F05B
+:1008E000A3E4F0128921A3EEF0A3EFF0A3E50AF050
+:1008F000A3E50BF0128B679007D5128BC8028456C4
+:100900001287B2A3A32212890A22A3A3A3EEF0A303
+:10091000EF128502A3A3A3A3A3228A828B83A3A39E
+:10092000A3A3E508F0A3E509F02274F01220518991
+:100930000DEAFEEBFF8C0C7410122045E0F508A3C5
+:10094000E0F50974121220451289D09003C7E0A285
+:10095000E350677A0F128BD06060128751FCEB3442
+:1009600000FD1287488C828D83E8F0A3E9F08C8229
+:100970008D831289BD1289E2740C1289E2A3740876
+:100980001289F4E50D1289F4A3EE1289FAEF1289A7
+:10099000FAA3E50C128A06E508F0E509F5081289C4
+:1009A000D8E508128A06A3A3E50AF0E50BF50A12BA
+:1009B00089D8A3A3E50AF0128BC50284561289C315
+:1009C0007404221289C722E0F8A3E0F5838882220A
+:1009D000E0F50AA3E0F50B228C828D83128834A304
+:1009E000A3221289E6221289EA22F08C828D8312D8
+:1009F00089C7A3221289E6A3A3221289FE221289A3
+:100A0000EAA3A3A3A3221289FEA3A32274EC1220BB
+:100A1000518A0C8B0D8C0E8D0F7414122045128987
+:100A2000D0850A82F583A38582108583119007D92A
+:100A3000E060757A0F7B001210E38A088B09AE081C
+:100A4000AF09EE4F7003028B4A8E828F837492F04F
+:100A5000A3743EF08E828F83A3A37405F08E828FE1
+:100A600083128B657508087509007808122264AC3A
+:100A70000EAD0FEE2405FAEF128479121FF2850AEB
+:100A800082850B83E0FA851082851183E0F9EAF80C
+:100A9000EE240DF582EF128B53E8F0A3E9F0EEFAA5
+:100AA000EFFB9007D9028B479003CDE0A2E55008F9
+:100AB0009003C5E0A2E44006120B55028B4A7A145B
+:100AC000128B587003028B4A128B70F9EA2404FAD5
+:100AD000EB3400FB88828983EAF0A3EB12830DFEDE
+:100AE000A3E0FF8E828F837404F0A3743EF0A3749E
+:100AF0000DF0A37405F0128B67A3AE82AF83750C63
+:100B000008750D00780C122264AC0EAD0FEEFAEFF2
+:100B100012847F121FF2EE2408FEEF3400FF850AD4
+:100B200082850B83E08E828F83F085100A85110BFE
+:100B3000A30EAF83850A82850B83E08E828F83F0BC
+:100B4000AA08AB099007D5128BC87F0C022123F5A8
+:100B500082E50F3400F583227B001210E38A088BB4
+:100B600009EA450922A3A3A3E50CF0A3E50DF022B1
+:100B7000128755F8EB34002274F4122051EAFEEB90
+:100B8000FF89088C099007D9E060127A07128BD090
+:100B9000602F128C5EE509F09007D980219003C682
+:100BA000E0A2E7501C7A0B128BD06015128BD87420
+:100BB00008F0A37404128C531289249007D5128B69
+:100BC000C802882BFB9007D5E0F91210EF227A08B3
+:100BD0007B001210E3EA4B22128BE8F8A3E0F988BD
+:100BE0008289837404F0A322128759F8EB3400F948
+:100BF000EA2404FCEB3400FD88828983ECF0A3ED49
+:100C0000128C0422F088828983E02274F41220512D
+:100C1000EAFEEBFF89089007D9E060127A07128B91
+:100C2000D0602D128C5E7401F09007D9801F900364
+:100C3000CBE0A2E7501A7A0A128BD06013128BD83D
+:100C40007430F0A37403128C53F09007D5128BC844
+:100C500002882BF0A3E508F0A3EEF0A3EF228A822E
+:100C60008B8374921287AE740812850212890AE58A
+:100C700008128911A322F0851882851983AC82ADF0
+:100C8000832274F2122051E9FE8C088D097F008EB8
+:100C90008285820A8F0B8A0C8B0D780C1222A80198
+:100CA00003185E8FD68CF58C088D5E8F1D8D708D30
+:100CB000868DB58DE48DFF8D1A8E318E4D8E5E8FB3
+:100CC000698EA08EBC8ED68EEB8E088F5E8F5E8F67
+:100CD0005E8F5E8F258F74106E7015750A10780AFE
+:100CE0001222647A9B7B0C129226121FF2028F7CD6
+:100CF0007F18028F7C74106E70F6750A10780A12D5
+:100D000022647AAB7B0C80DF74046E70E38C828D7E
+:100D100083121ECA900CBB121ED6028F7C74016E09
+:100D200070CE901130E0F88C828D83E0901130F01D
+:100D3000E8601CE06003028F7C900C99E064026024
+:100D400003028F7C900C98E0F91206E1028F7CE0A0
+:100D50007003028F7C900C99E06401600DE06403E5
+:100D60006008E064046003028F7C129609028F7CA5
+:100D700074026E6003028CF0129735901131E8F026
+:100D8000A3E9F0028F7CEEC394204003028CF07C38
+:100D90001F7D0079007A347B111210D7780A122255
+:100DA00064AC08AD097A347B11129226121FF2EE60
+:100DB00090113380CDEEC394204003028CF07C1F51
+:100DC0007D0079007AC67B0C1210D7780A12226453
+:100DD000AC08AD097AC67B0C129226121FF2EE9077
+:100DE0000CC5809E74016E6003028CF08C828D8332
+:100DF000E0C394044003028CF0E0900CE58083741F
+:100E0000016E6003028CF08C828D83E0C3940440F9
+:100E100003028CF0E0900CE680C874066E6003025A
+:100E20008CF0750A06780A1222647AE77B0C028C31
+:100E3000E774016E6003028CF08C828D83E0C394B2
+:100E4000084003028CF0E0900CED028D8274016E7C
+:100E50006003028CF08C828D83E0C3940440030213
+:100E60008CF0E0900CEE028D8274026E6003028CB6
+:100E7000F0129735900CEF129603E8497003028F39
+:100E80007C900C99E064056003028F7C900CEF125B
+:100E900096547808122260129743121FF2028F7C38
+:100EA00074016E6003028CF08C828D83E0C3940227
+:100EB0004003028CF0E0900CF7028D82128F976055
+:100EC00003028CF0128F8B4003028CF0901155EAD4
+:100ED000F0A3EB028D82128F976003028CF0128FC9
+:100EE0008B4003028CF090115780E4129735740206
+:100EF0006E6003028CF0C3E894F4E99401400302AD
+:100F00008CF0900CF8028D7E128F976003028CF0AB
+:100F1000EA24F6128F839477E9940C4003028CF054
+:100F200090115980AA74016E6003028CF08C828D3E
+:100F300083E064016003028CF07A087B00900C98D7
+:100F4000E0F9121197EAF8EBF9ECFAEDFBE8494AFF
+:100F50004B70077900128FA480227F16801EC3EA8F
+:100F60009426EB9400501374026E700E8C828D8365
+:100F70001292201205D9E9FF80020F0FEFF97F06C8
+:100F8000022123F8EB34FFF9C3E822EA24FA128F96
+:100F900083947BE9940C228C828D83E0FAA3E0FB9E
+:100FA00074026E2212140D7A047B00900C98E0F902
+:100FB00012119122121FF27F0402212374F61220D3
+:100FC00051900C99E0703EEA4B6008900D01EAF0F8
+:100FD000A3EBF07508BB75090C780812226475083C
+:100FE000AB75090C78081222647C9B7D0C7B009009
+:100FF0000C9AE0FA900C98E0F912120F7404121F88
+:10100000F27900800279117F02022123D083D082FD
+:10101000020122C082C083900C99E06405700D1219
+:10102000961F900C98E0F912065D8002791280DC20
+:1010300074F7122051E9900C98F0900C99E4F0901C
+:10104000115374FFF0A3F0120729900C9A7404F066
+:101050007C107D0079007A9B7B0C1210D77C107D70
+:101060000079007AAB7B0C1210D7908F42121ECA07
+:10107000900CBB121ED6900CE5E4F0900CE6F090BC
+:101080000CED7407F0900CEEE4F07C9B7D0C7A1074
+:1010900079021213D77CAB7D0C7A1079031213D727
+:1010A0007CBB7D0C7A0479041213D77F01022123C3
+:1010B00074F412205174F6121FDCEAFEEBFF548028
+:1010C0006025900C98E0F91210FB8A088B09A90999
+:1010D000EA49600A121401AA08AB091210E9EEFAF3
+:1010E000EF6480FB02921BEF544060127CBB7D0CCE
+:1010F0007A0479041213D1EEFAEF644080E5EEA28F
+:10110000E0400302919F901130E0700302919790AC
+:101110000CE5E0851882851983F0900CE6E0C0E0CC
+:101120007401122045D0E0F07508067509007808B2
+:101130001222647CE77D0C7404122045AA82AB83E2
+:10114000129226121FF2900CEDE0C0E074081220FB
+:1011500045D0E0F0900CEEE0C0E07409122045D0DC
+:10116000E0F0851882851983AA82AB83900C98E001
+:10117000F91206D5E96020900C997406F012965F7A
+:10118000601512961912973988828983E582458302
+:101190006005790612204FEE6401FAEF0290E354E5
+:1011A00002602A900C99E06405701D12961F1209C6
+:1011B0000F900CEF129662600F900CEF12964C128B
+:1011C0002260129743121FF2EE640280CDEE5404A7
+:1011D000600A790012140DEE640480BEEE540860BB
+:1011E00036900D00E01460081470271213EF80226F
+:1011F00090115912227B900CF812227B79019011E8
+:101200005712922090115512962212141374041240
+:101210001FF2EE640880837A007B00740A028FB4A8
+:10122000E0FCA3E0FD221210BF74022274F412202D
+:1012300051EA2405F8EB3400F98A828B83E0246FAD
+:10124000600B24EF606724D2605E0292F8A3E06432
+:101250000E60030292F88A828B83A3A3A3E0640545
+:101260007004A3E0641460030292F88882898312F8
+:101270009616A3A3A3E0F9900C99E0640570797425
+:101280007F696074900D01129622EA4B606A900D9E
+:1012900001129616A3A31296228A828B83E58245B9
+:1012A00083605512204F8050121407804B8882892A
+:1012B00083E0641370428A828B83A3A3A3A3A3A3B6
+:1012C000E064017002A3E07012900D00E06402700F
+:1012D0000A7A08128FA91213EF801D7A057B00127B
+:1012E00005DF8A088B09E4F50AF50B7808122260FD
+:1012F0007A08129745121FF2028FB774EE1220512E
+:10130000EAFEEBFF8E828F83A3A3E0F8EE2403F5C1
+:1013100008EF3400F509EE240AF50AEF3400F50B66
+:101320008E828F83A385820C85830DE8602724FE3F
+:1013300070030293CD14700302940414700302949A
+:101340000414700302943E14700302953414700365
+:101350000295878073E070497C9B7D0C7A1079023E
+:101360001213D17CAB7D0C7A1079031213D1750A5C
+:1013700006750B00780A122264AC08AD097ABF7BAF
+:101380000C129226121FF2900C997401F07C347D9D
+:1013900011901133E0FB7A01900C98E0F91206DB12
+:1013A000E96006900C997406F012965F601A129626
+:1013B00019129739E8FAE9FBEA4B600C900C99E0B6
+:1013C000F98A828B8312204F7F0A022123E0702941
+:1013D000850882850983E0601D7CC67D0C900CC564
+:1013E000E0FB7A00900C98E0F91206DBE9850C82AC
+:1013F000850D83F08003129609850C82850D83E0AC
+:1014000070A180C4E0709C7403687007900C99749C
+:101410000280959011311296629011306016E06052
+:101420001590113112964C1222607A0112974512D2
+:101430001FF28002E4F0900C9974030293A8E0601C
+:1014400003029527EE2404F510EF3400F511750C16
+:1014500006750D00780C122264AC10AD117AF17B88
+:101460000C129226121FF2850A82850B831297397D
+:10147000901153129603900C997405F0900CEF1292
+:101480009662601A900CEFE0F50CA3E0F50DE4F520
+:101490000EF50F780C122260129743121FF2EE2401
+:1014A0000CF582EF3400F583129640EE240EF5829F
+:1014B000EF3400F583129634EE2410F582EF3400F9
+:1014C000F583129628900CF7E0640170327A1F7B46
+:1014D000001205DF8A0CEA75F0E8A4C50CA8F075C7
+:1014E000F003A428F875F0E8EBA428F50DE4F50E58
+:1014F000F50F780C1222607A04129745121FF275CC
+:101500000C04780C122268850A82850B83129220C3
+:10151000AA10AB11850882850983E0F912121574AF
+:1015200001121FF20293A9643160030293A3901188
+:10153000300294341212337C067D0079007AF17BFC
+:101540000C1210D7900CFAE4F0A3F0900CFCF0A36E
+:10155000F0900CFEF0A3F07A04FB128FAB7A081225
+:101560008FA98E828F83A3A3A3A3A3E06408900C0A
+:10157000997004740480027403F012960990115358
+:1015800074FFF0A30293A87A08128FA9850C8285B4
+:101590000D83E060030293C88E828F83A3A3A3A36D
+:1015A000A3A31296408E828F83A3A3A3A3A3A3A376
+:1015B000A3129634850A82850B831296287A047BBF
+:1015C00000900C98E0F9121197EA4B4C4D60030221
+:1015D00093C8900D0312966270030293C8900CFE9C
+:1015E00012227B900CFC129220900CFA1296229000
+:1015F0000D0312961612961612204F7402121FF245
+:101600000293C8E8F0A3E9F0227A017B00900C98DD
+:10161000E0F912111322E0F8A3E0F583888222900A
+:101620001153E0FAA3E0FB2212973D900CFEE8F084
+:10163000A3E9F02212973D900CFCE8F0A3E9F02218
+:1016400012973D900CFAE8F0A3E9F022129654F5B7
+:101650000B780822E0F508A3E0F509E4F50A2290EA
+:101660000D0112973DE8492274F412205174F812CA
+:101670001FDCE9FE90115512973975830C7582FABB
+:10168000C3E098A3E0994038900CFA12973975831B
+:1016900011758257C3E098A3E0994024900CFC1286
+:1016A0009739900CF8E0687003A3E0697012900C11
+:1016B000FE129739901159E0687003A3E0696070D9
+:1016C0007A057B001205DF8A088B09901155129765
+:1016D000398518828519831296039011571297390C
+:1016E0007402122045129603900CF8129739740474
+:1016F0001220451296039011591297397406122040
+:1017000045129603900C98E0F9851882851983ACF0
+:1017100082AD8312961F120A05EE900D00F0E4F5DB
+:101720000AF50B78081222607A08129745121FF208
+:101730007408028FB48C828D8312973D22E0F8A347
+:10174000E0F9227A027B00900C98E0F9121185747E
+:10175000042274F4122051E9FE740C122045E0F5C5
+:101760000AA3E0F50B740E122045E0F508A3E0F59E
+:1017700009900C99E0640560047914805FEA24FA0A
+:10178000F8EB1297DF5053EC24FAF8ED1297DF5084
+:1017900049C3E50A94F4E50B9401503EE50824F6AC
+:1017A000F8E509128F859476E9940C502D90115527
+:1017B000EAF0A3EBF0901157ECF0A3EDF0900CF8E9
+:1017C000E50AF0A3E50BF0901159E508F0A3E5094F
+:1017D000F0EEF9128FA4790080027918028FB71207
+:1017E0008F85947AE9940C22C082C083900301E033
+:1017F000A2E250067A267B0F80047A007B00120F4B
+:101800004B7900D083D08202012274F212205174ED
+:10181000E0121FDCEAFEEBFF8C0A8D0B742E122007
+:1018200045E0F508A3E0F5097C107D0079008518F6
+:1018300082851983AA82AB831210D712A2BDE84910
+:1018400070030298F8129CBDE06E7003A3E06F6015
+:10185000030298F89007CF129CCD60030298F8120B
+:101860009A03FC74066C704F741012204585820C2C
+:1018700085830D780C1222649007CEE0244BF50C82
+:10188000A3E03400F50D780C1222649007CEE0241A
+:101890002BFCA3E03400FD129DB7120F0974041253
+:1018A0001FF2E970531299D7122264741212204564
+:1018B000AC82AD83029968129A0B603C129F7B74D4
+:1018C000116C600302998AE065087004A3E0650961
+:1018D0007021750C08750D00780C1222641299E3C2
+:1018E000121FF2E96401700B1299D7122264129947
+:1018F000F580757932120FC3EEFAEFFB120AB98A3E
+:101900000C8B0DA80CA90DE84970030299C4E824BA
+:1019100021F50CE93400F50D850C82F58312A30046
+:10192000EA4B70030299C412A2A765087004A3E0F1
+:10193000650960030299C4750808750900780812E2
+:1019400022641299E3121FF2E964017077850C8218
+:10195000850D83E0FCA3E0FDEC241AF582ED12A2D4
+:10196000ADF50878081222647402122045AA82ABF1
+:1019700083129DB1121FF2EEFAEFFB8518828519D2
+:1019800083AC82AD8312094B8041E065087004A3EB
+:10199000E0650960030298F8750C08750D00780C75
+:1019A0001222641299E3121FF2E9640160030298A3
+:1019B000F81299F5EC241AF582ED12A2ADF508752E
+:1019C0000900809FEEFAEFFB120951790174201291
+:1019D0001FF27F06022123120FC9E9F508750900DD
+:1019E000780822EA2412FCEB3400FDAA0AAB0B12A1
+:1019F00010D17402229007CEE0245B129DE9FCA373
+:101A0000E0FD229007CF129EACE0229007CEE024AA
+:101A10005B129DE9FAA3E0FBEA4B2274F21220511B
+:101A2000890DECFEEDFF750C008A828B83A3858205
+:101A30000A85830B8E828F83A38582088583091292
+:101A4000A2BDE849705D7401650D7052EE2402FA82
+:101A5000EF3400FB120F158E828F83A3A3A3A3A3E1
+:101A6000740212227F8E828F83A3A3A3A3E0F50CBE
+:101A7000780C122268E9F50C780C1222688508822D
+:101A8000850983E0FD8E828F83E0FC850A82850BC9
+:101A90008312A30079001206C37404121FF27900A6
+:101AA000029CBA129CBD12A2C0850A82850B83E0FB
+:101AB000687003A3E06960057908029CBA129CC7AC
+:101AC000640170057907029CBAE50D14603124FEAB
+:101AD000603A147003029B6B147003029CAD147087
+:101AE00003029B74147003029BCF147003029BD9F2
+:101AF000147003029C1B147003029C5C029CB5EEE4
+:101B0000FAEFFB120FE7E9F50C029CB875080075B7
+:101B10000A10750B00780A1222649007CEE0243B6D
+:101B2000129E91121FF29007CEE02401129DDB64F9
+:101B30000470047403802D9007CEE0241BF50AA3E3
+:101B4000E03400F50B780A1222649007CEE0242BD3
+:101B5000129EB3121FF2120F8DE96003750808126E
+:101B60009E9E7405F085080C029CB8EEFAEFFB12FD
+:101B70000FED8092129A03640C6003029CB59007EB
+:101B8000CEE0245D12A2E2700812A297245D12A298
+:101B9000C69007CEE0245D129A117003029CB575C1
+:101BA00008107509007808122264129DAD121FF208
+:101BB000120FC9E9C0E09007CEE0245D129DDB243E
+:101BC0001A129DC8D0E0129E9D740DF0029CB8EED2
+:101BD000FAEFFB120FF3029B06129A03640E6003E6
+:101BE000029CB59007CEE0245F12A2E2700A7A163A
+:101BF00012A299245F12A2C69007CEE0245F129A27
+:101C00001160117508107509007808122264129D80
+:101C1000AD121FF2129E9E740F80B0129A03640FD1
+:101C20006003029CB5750A06750B00780A122264DF
+:101C3000AC08AD099007CEE0245F129CD4129E91AF
+:101C4000121FF2129F8688828983E0542060571207
+:101C50009F9F6052129E9E7410029BCB12A2DC705A
+:101C6000147A1412A299246112A2C612A2DC700581
+:101C7000750C0880439007CEE02461129A1160260B
+:101C80007508107509007808122264129DAD121FA4
+:101C9000F2908F62121ECA9007CEE02461129CD48B
+:101CA000129DC8121ED67900120FC3800B8E828F30
+:101CB00083E0F980F3750C07A90C0299D2129CC13C
+:101CC00022129EACA3A3229007CEE0F8A3E0F583F6
+:101CD0008882E022129DE924102274F61220517E9F
+:101CE00000120F99E9F86003029D9A120F87129D66
+:101CF000FA2412129DDBA2E050209007CEE02418B7
+:101D0000129DC8129EA1A3E054036401700C9007B9
+:101D1000CEE02417129DDBD2E0F0129DDFF87402B2
+:101D200068601D7403686005740468701779011297
+:101D3000A2F41206C9129DEE129E9D7404F08066F4
+:101D4000790280EB74016860057405687058129E12
+:101D50009E7402F0129DB7129DDF6401700B7C101F
+:101D60007D0079001210D7801E7508108E09780842
+:101D7000122264129DFA2402FCA3E03400129DB0EA
+:101D8000121FF2129DEEF079109007CEE0242BFA8C
+:101D9000A3E03400FB120F0F800C74186870050E5E
+:101DA0000E0E80027E08EEF97F02022123EEFCEF88
+:101DB000FD1210BF740222129DBB229007CEE024B8
+:101DC00007FAA3E03400FB22129DCC22129DD02200
+:101DD000F8A3E03400F98882898322129DE92290D9
+:101DE00007CEE0241A129DE922129DD0E02290072E
+:101DF000CEE02417129DE9D2E2229007CEE0F8A3AC
+:101E0000129F982274F612205174F0121FDC7E008B
+:101E10007508108E097808122264EAFCEBFD900721
+:101E2000CEE0244B129E91121FF2851882851983F1
+:101E300085820885830978081222649007CEE02401
+:101E40004B129EB3121FF27508108E0978081222E9
+:101E5000649007CEE0243BFCA3E03400FD74021242
+:101E60002045AA82AB831210D17402121FF2E964DA
+:101E7000017012120F93E960047E08800A129E9E80
+:101E80007406F080027E04EEF97410121FF2029DB7
+:101E9000A8FAA3E03400FB1210BF740222F09007EE
+:101EA000CE129EA522E0F8A3129EAC22E0F5838814
+:101EB00082A322FCA3E03400FD129DBB120F7574B7
+:101EC000022274F6122051EAFCEBFD9007CEE024CA
+:101ED0005D129A117003029F769007CEE0F8A3126C
+:101EE0009A06640D6003029F768C828D8312A2C0D5
+:101EF000129F7BE8F0A3E9F07508087509007808DF
+:101F0000122264EC24020C0CED3400FDEA2412FAD7
+:101F1000EB3400FB129DB1121FF2129F869007CE88
+:101F2000E02401FAA3E03400FB88828983E05410A6
+:101F300060259007CEE02418FCA3E03400FD8C82DD
+:101F40008D8312A2B3A3A3A3A3E0541060098A82D5
+:101F50008B83740EF0801B88828983E05420600D8F
+:101F6000129F9F60088A828B83741080E779001229
+:101F70000FC3790080027907029DA8EA2410F58238
+:101F8000EB3400F583229007CE129F952413F8A31B
+:101F9000E03400F922E0F8A3129CC1A3A3E0229050
+:101FA00007CEE02418129DCC129F9554202274F085
+:101FB000122051129CC7600302A2929007CF129E7A
+:101FC00000F8A3E0F99007CEE0241812A2D112A3E2
+:101FD000009007CE12A2B3E0F50AEA2405FEEB3426
+:101FE00000FFE82413F508E93400F5097406650AD2
+:101FF000707F850882850983E0F8A2E0500C8E820C
+:102000008F83E0A2E0500302A08CE8540260408E6F
+:10201000828F83E054026037750A0912063912A2D2
+:10202000EC120FAB7408650A600302A22F850882C8
+:10203000850983E05402700302A15D8E828F83E0E4
+:102040005402700302A15D129E9E740902A18CE8E5
+:102050005404700302A2468E828F83E054047003FE
+:1020600002A246750A0B12061512A2EC120FB780D7
+:10207000B3E50A24F9601514700302A10514609BEE
+:1020800014700302A1311460DD02A17E9007CEE03E
+:10209000245B12A2E2700812A297245B12A2C690DF
+:1020A00007CEE0245B129DDBFEA3E0FFEE4F700342
+:1020B00002A1877C107D007900EEFAEFFB1210D7A9
+:1020C000120FC9EEFAEFFB120F0F1210DDEE241003
+:1020D000F582EF3400F583EAF0A3EBF07908EE2403
+:1020E00012FAEF3400FB120F0F120FC9EE241AF58B
+:1020F00082EF3400F583E9F0EEFCEFFD12A2F4125A
+:102100000F9F02A187129A0B700302A02DEA2412DE
+:10211000F50AEB3400F50B780A12226412A2A7FC30
+:10212000A3E0FD12A2F4120FA57402121FF202A086
+:102130002D750B0112062DE9F50A7401650A70056B
+:10214000750B008003750A00A90B1206338A0C8BED
+:102150000DAC0CAD0DA90A12A2F4120FB1850882C4
+:10216000850983E05404700302A2468E828F83E0C7
+:102170005404700302A246129E9E740B800E7407D4
+:10218000650A600302A024129E9E7408F09007CE98
+:10219000E0F8A3129A06F87407686017740868607C
+:1021A00012740968600D740A686008740B68600333
+:1021B00002A29212A2F4120AB98A088B09A808A9ED
+:1021C00009E849700302A274E8240BF582E934009F
+:1021D000F58312A2C0880C890DE4F50EF50FE9C352
+:1021E00013F9E813F888088909E4F50AF50B780C67
+:1021F0007908121E2502A27CE8541060128E828F8C
+:1022000083E0541060098A828B83740E02A18CE8EB
+:10221000542060128E828F83E0542060098A828B62
+:1022200083741002A18C8A828B83741202A18C7435
+:1022300009650A7008129E9E740A02A18C740A65D0
+:102240000A700302A15D9007CEE02401F8A3E034F8
+:1022500000F9E8FAE9FB850882850983E0F854086B
+:1022600060968E828F83E05408608D8A828B83749F
+:102270000C02A18C908F3E780C121EAC780C1222AE
+:10228000607A027B009007D4E0F912118574041281
+:102290001FF27F080221237A1B7B0012114F8A084C
+:1022A0008B099007CEE022EA2410F582EB3400F58A
+:1022B00083E022E0FCA3E0F5838C82A3229007CE8A
+:1022C000E0F8A3E0F92212A2D1E508F0A3E509F0B5
+:1022D00022FAA3E03400FB8A828B83229007CEE0AF
+:1022E0002461129DE9F8A3E0F9E849228A0C8B0DDC
+:1022F000AC0CAD0D9007CE129EA5A3A312A3002295
+:10230000E0FAA3E0FB2274F2122051ECFEEDFF8A0A
+:10231000828B83A3A3A3A3A3A3A3A3E0F50A6027AF
+:10232000EA2406F8EB3400F9880889098882F583E5
+:10233000E0FCA3E0FD8C828D83E0F50BA2E7504E1C
+:10234000E50AC3940D5005790102A40074F4250A2E
+:10235000F50AF50CEC250CF50CED3400F50D780CB8
+:10236000122264E50AF50C780C12226879018A823F
+:102370008B83A3A312A8E1120EDF7403121FF2E9EC
+:102380008E828F83700474018009740280058E82AE
+:102390008F83E4F0E50BA2E65004D2F08002C2F095
+:1023A000A2F0E433A3F0743F550B8E828F83A3A376
+:1023B000F0EE2403F8EF3400F9E50A24FFFAE434E0
+:1023C000FFFB88828983EAF0A3EBF0EE2405FAEFA5
+:1023D0003400FB8882898312A6C949601985088266
+:1023E000850983E02401F8A3E03400F98A828B8315
+:1023F000E8F0A3E980078A828B83E4F0A3F07900F8
+:102400007F0602212374F712205112AAD9A3AA82AF
+:10241000AB838C828D83A3A882A98312A6C18C82F0
+:102420008D83A3A3A312AADD7A047B0002A466C055
+:1024300082C08312A9107A02802374F7122051748B
+:102440000912204512A7CA12204512A7C37001EB3A
+:10245000700512A7D280027904800B80D27B00D055
+:1024600083D0820201227F0102212374F7122051BE
+:10247000740912204512A7CA12204512A9527001F0
+:10248000EB700512A9598002790480DA74EE1220EB
+:1024900051EAFEEBFF8C0C8D0D7508017509008C5F
+:1024A000828D83A385820E85830F12A58F750A0006
+:1024B0008036E51075F012A4F510E5F0F51112A5BF
+:1024C0004C751010751100781012226412A53E127E
+:1024D0001FF2EE2410FEEF3400FFE5082412F50889
+:1024E000E5093400F509050A850C82850D83E0F8BD
+:1024F000E50AC39850418E828F83A3AA82AB83855D
+:102500000A82858210751100850E82850F83E06432
+:1025100001709F74027810121FC912A54C75100229
+:10252000751100781012226412A53E121FF212A536
+:1025300085E508240480A7AA08AB0902AC1EEC2498
+:1025400004FCED3400FD0AEF12AAAD22E50C2510C3
+:10255000FCE50D3511FD12A56812A57EEAFEEBFF24
+:102560008882898312A57522EC2402F8ED3400F9E3
+:102570008882898322A312A57EA30EAF8322E08ED8
+:10258000828F83F022EE24020E0EEF3400FF22121F
+:10259000A57EA3AE82AF832274F2122051ECFEED31
+:1025A000FF740E122045E0F50AA3E0F50B7410123B
+:1025B000204512A65DC3E50A9406E50B940050037E
+:1025C00002A6588E828F83E0FAA3E0F9EA8508829A
+:1025D000850983F0A3E9F08E828F83A3A3E0FA8EAE
+:1025E000828F83A3A3A3E0F8E4C8F9EA8508828573
+:1025F0000983A3A3F0A3E912AD37A3A3A37402F048
+:10260000F50C880D780C122264EE2404FCEF3400E3
+:10261000FDE5082405FAE50912AA9D121FF2E50A54
+:1026200024FAF50A850882850983A3A3A3A3A3A39B
+:10263000A3F0C394115021750B00780A122264EEA6
+:102640002406FCEF3400FDE5082408FAE50912AA87
+:102650009D121FF279008002790402A400E0F508BF
+:10266000A3E0F5092274F5122051750A0080308527
+:102670000A0875090074027808121FC9EC2508F8C9
+:10268000ED3509F988828983A3AE82AF8312A991BF
+:10269000E82403080808E912A56D12A6C1050A8CF2
+:1026A000828D83E0F8E50AC39840C4E0F508750917
+:1026B0000074027808121FC9AA08AB097F0302211F
+:1026C0002312A84FA30AAB832212AA1AE82274107D
+:1026D000121FF27F0402212374F6122051740A1291
+:1026E000204512AAC512204512A8E1EA2404F8EBFD
+:1026F0003400F974066E7001EF7046888289837425
+:1027000002F08C828D8312A7558A828B83F0A3EF0F
+:1027100012AAB4A3E0FEE4CEFFE5088A828B83A36D
+:10272000A3F0A3EFF088828983E0F5088E0978088A
+:1027300012226412AA8612AA9C121FF2790002A821
+:102740002A74146E7001EF70088882898374108077
+:10275000B0790480E9E0F508A3E0FFE5082274F60B
+:102760001220518C828D83A3E0F8F5F08C828D834A
+:10277000E0A4FEE88A828B83F0A3AA82AB838E0852
+:102780007509007808122264EC240212A797121F20
+:10279000F2EE240102A8250C0CED3400FD12AAAEC5
+:1027A0002274F7122051740912204512A7CA122070
+:1027B0004512A7C37001EB700512A7D280027904FD
+:1027C00002A46612AA1A74026A22E0FAA3E0FB7459
+:1027D0000B2212A97B79002274F6122051ECFEED37
+:1027E00012A8331222648E828F83A3AC82AD83122F
+:1027F000AD40121FF28E828F83E0FA7B00802B7433
+:10280000F612205112A841A30AAB83EC240412A8AB
+:102810002F122264EC2405FC12A799121FF28E825B
+:102820008F83E02404FAE43400FB7F02022123FEBC
+:10283000ED3400FF8E828F83E0F50875090078087B
+:102840002212A914A30AAB8312A56812A84F221260
+:10285000A929A30AAB838882898312A9282274F448
+:1028600012205189088A09740C12204512AA167484
+:102870000E12204512A8E1C3E89402E994004054E6
+:102880008C828D83E0F50AA3E0FFE50A8A828B83C0
+:10289000F0A3EFF0EA241712A8D9E508F0EA24180B
+:1028A00012A8D9E509F0E50870047E1480027E08BC
+:1028B000E824FEF50A8A828B83A3A3F0EEC3950A6F
+:1028C0004012750B00780A12226412AA93121FF2AA
+:1028D00079008002790402A6D3F582EB3400F583F7
+:1028E00022E0FAA3E0FB2274F612205112A910A3F1
+:1028F0000AAB83EC240212A82F122264EC24030CEE
+:1029000012A797121FF28E828F83E0240202A8255D
+:1029100012A914228C828D8312A929A3AA82AB83C7
+:102920008C828D8312A92822A3E08A828B83F022D5
+:1029300074F7122051740912204512A7CA122045BB
+:1029400012A9527001EB700512A959800279040294
+:10295000A46612AA1A74046A2212A97B8C828D833F
+:10296000A3A3E0FE8C828D83A3A3A3E0FBEE888269
+:102970008983A3A3F0A3EBF07900228C828D83E0FE
+:10298000FEA3E0FBEE88828983F0A3EBF02202A78E
+:10299000D812AAE1A3AA82AB838E828F83A312AA44
+:1029A000E1A30AAB832274F6122051740A12204567
+:1029B00012AA16740C12204512A8E1E8A2E04051B8
+:1029C000E9C313E813F50974FE2509C3940A5041BD
+:1029D000EA241612A8D9E509F075080080288C822F
+:1029E0008D83E0FEA3E0F9EE2400E439FFE508332F
+:1029F000F8E433F9EA28F582EB39F583EEF0A3EF3A
+:102A0000F012AAA30508E508C3950940D179008012
+:102A100002790402A82A12AA1A22E0F8A3E0F922F5
+:102A200002A7D802A75E74F6122051740A1220453C
+:102A300012AAC512204512AB259404EF9400404120
+:102A40008C828D8312AAD08A828B83F0A3E912AA8A
+:102A5000B412AB18A3A3F0A3E9F0EE24FCF5088AA6
+:102A6000828B83A3A3A3A3F0C39413501488097883
+:102A70000812226412AA8612AA9C121FF279008000
+:102A800002790402A82AEC2404FCED3400FDEA24B7
+:102A900005FA2212AAA3EA24030A0A0AEB34001256
+:102AA000AAAD22EC24020C0CED3400FD22FB121026
+:102AB000BF740222F08C828D83A3A3E0F5088C8280
+:102AC0008D83A3A322E0FEA3E0FF740C2202A7FFE4
+:102AD000E0F508A3E0F9E508228C828D8312AAE1D3
+:102AE0002212A92922C082C08385188285198312E7
+:102AF000A8E1740212204512AA1674016A7001EB53
+:102B0000700E8C828D83E088828983F07900800248
+:102B1000790402A45F02A8E7A3E0F8E4C8F9E50895
+:102B20008A828B832212AB2AEE22E0F8A3E0F9E836
+:102B3000FAE9FBC32274EE12205174FA121FDC8AE8
+:102B40000E8B0F8C0A8D0B890C7418122045E0F542
+:102B500010A3E0F5117A177B00120A9B8A088B09F3
+:102B6000AE08AF09EE4F700302AC148E828F8375EE
+:102B70000801750900E50CF0A3E50A450B601BACE4
+:102B800010AD11AA82AB83850A82850B8312204F78
+:102B9000EA2401F508EB3400F509E50CA2E7502E14
+:102BA0007910AA0EAB0F120AC5E97063EE2508FC76
+:102BB000EF3509FDA908EEFAEFFB120ED9E9F50A87
+:102BC0007044E508240CF508E5093400F50985187A
+:102BD000828519837404F0A3E4F07402122045EE98
+:102BE000F0A3EFF07404122045E508F0A3E509F026
+:102BF000851882851983AC82AD83AA0EAB0F1209AA
+:102C0000F9E9F50A6011EEFAEFFB12136B80087513
+:102C10000A1980F2750A13A90A7406121FF27F0AB4
+:102C200002212374F412205174F0121FDCEAFEEB2F
+:102C3000FF741C12204512A65D741E12204512ACB2
+:102C4000D27001ED600C74106C7001ED60047900BD
+:102C5000807D7402687001E960087410687001E991
+:102C600070ECE86C7002E96D700F8C0A8D0B780ABD
+:102C7000122264AC08AD09804E74106C7001ED85B1
+:102C80001882851983AC82AD837021AA08AB091222
+:102C900005D37508107509007808122264740212B1
+:102CA0002045AC82AD83EEFAEFFB801B1205D37595
+:102CB0000A10750B00780A1222647402122045ACC7
+:102CC00082AD83AA08AB091210D17402121FF2025E
+:102CD000A6CE12AA1A74026C2274F41220518A0829
+:102CE0008B09ECFEEDFFEA45096047EE4F60437546
+:102CF0000A10750B00780A1222647C7D7D8EEEFA34
+:102D0000EFFB12AD40121FF2850882850983E0C0F7
+:102D1000E0EE240CF582EF12A8DCD0E012AD37E033
+:102D2000C0E0EE240DF582EF12A8DCD0E0F07901CE
+:102D30008002790002A6D3F0850882850983A32248
+:102D400012AAAE22C082C08374E3121FDC7C007D15
+:102D50000179FF7A1E7B0D1210D7851882851983A1
+:102D60007401F0122045740AF07402122045E4F058
+:102D700074031220457480F0A3E4F074051220451A
+:102D80007406F0740A122045E4F0A304F0741212E1
+:102D900020457432F0A3E4F074161220457401F05B
+:102DA000741B1220457461F0A37414F08518828599
+:102DB0001983AA82AB837901121341741D121FF289
+:102DC000D083D082020122C082C08374FA121FDC39
+:102DD0007404122045AC82AD8375838F7582E174D3
+:102DE00002121EEF908F5E1222777404122045ACFF
+:102DF00082AD837408122045AA82AB8312147374C7
+:102E000004121FF27403122045E4F07C04FD8518BF
+:102E100082851983AA82AB83790112134D740680CF
+:102E20009C74F612205174F4121FDC8518828519E7
+:102E3000837405F07401122045740312AF09122245
+:102E400064EAFCEBFD740412204512AE93121FF2EB
+:102E5000740B122045E4F0908F66122277740912E9
+:102E60002045AC82AD837404122045AA82AB831244
+:102E700014737404121FF27C077D00740512204540
+:102E8000AA82AB83790112134D740C121FF27F02D8
+:102E9000022123AA82AB831210BF74022274F6129D
+:102EA000205174E6121FDC8518828519837406F0A0
+:102EB0007401122045740A12AF09122264EAFCEB75
+:102EC000FD740412204512AE93121FF274191220E1
+:102ED00045E4F0908F7A1222777410122045AC826C
+:102EE000AD837404122045AA82AB83121473740458
+:102EF000121FF27C0E7D00740C122045AA82AB8357
+:102F0000790112134D741A8082F0F5087509007862
+:102F1000082274F712205174F3121FDCE9900D1D82
+:102F2000F074021220457401F0740B122045E4F095
+:102F3000A3F004122045E4F074091220457404F053
+:102F4000A3E4F074071220457404F0A3E4F07405C0
+:102F5000122045E4F0A3F074031220457440F0A35E
+:102F60007406F07402122045AC82AD8379017A05B3
+:102F70007B031213E3740B122045AC82AD837902FC
+:102F80007A067B031213E37C7C7D11790C7A087B33
+:102F9000031213E37C887D11790D7A077B031213EA
+:102FA000E37401122045AC82AD8379017A107B0372
+:102FB0001213E37409122045AC82AD8379027A11B1
+:102FC0007B031213E37407122045AC82AD837902B0
+:102FD0007A127B031213E37405122045AC82AD8391
+:102FE00079027A137B031213E37403122045AC8237
+:102FF000AD8379027A147B031213E3851882851955
+:10300000837403F0AC82AD837A0179061207537C96
+:10301000957D117A1579001207537CA07D007A0600
+:1030200012B0907A0712B0907A0812B0907A097BA9
+:10303000001205D9908F62121ECA120759908F6232
+:10304000121ECA120861908F62121ECA1211C1129A
+:1030500011FD1211E5908F62121ECA1212AB1214EA
+:103060001F12133B7C007D0112B52712143D7A011B
+:103070007B00900D1DE0F91211137A057B03900D72
+:103080001DE0F9121113740D121FF27F01022123AA
+:103090007B001205D97CA07D002274F612205174A9
+:1030A000F3121FDCEAFEEBFF54806018900D1DE068
+:1030B000F91210FBEA4B60031210E9EEFAEF64809C
+:1030C000FB02B17CEEA2E0502C7A227B0E1213E9B7
+:1030D0007A267B0E12122D908F661222777A027B4F
+:1030E00000900D1DE0F91211857404121FF2EE64B8
+:1030F00001FAEF80CB5402601C908F661222777A1F
+:10310000027B00900D1DE0F91211857404121FF26C
+:10311000EE640280DCEE5405F8EF5403F9E84960F0
+:103120000C121443EE6405FAEF64038093EE540826
+:103130006021851882851983AA82AB83790F1211C9
+:10314000CD851882851983AA82AB83121449EE6457
+:1031500008809EEE541060207403122045AA82ABB2
+:1031600083790012142B7403122045AA82AB8312B8
+:10317000144FEE641002B0F17A007B00740D02AEC1
+:103180008B74F7122051E9FE74016E7003121467FC
+:1031900002B08B74F21220517582FC7583FE1220EE
+:1031A000277901121359900E2AEAF0A3EBF0900E42
+:1031B0002AC3E09401A3E094014008900E2AE4F0B1
+:1031C000A304F0900E1EE0F8A3E0F9900E2AE02888
+:1031D000F8A3E039F9C3E89401E994014007900E9F
+:1031E0001EE4F0A3F0900E2AE0FCA3E0FD12B5303F
+:1031F0007901121347900E2AE0F8A3E0F9900E1E11
+:10320000E028F0A3E039F0807D75080378081222E9
+:10321000647488122045AC82AD8374071220451275
+:10322000AE93121FF27405122045AC82AD837A036F
+:10323000790F1211C7850C82AE82900E1EE0C395E5
+:103240000CF508A3E09400F5097808122264741FB5
+:103250002EFC740D3400FD7A1E7B0D12AE97121FEA
+:10326000F2EE2401F8E43400F9900E1EE098F0A389
+:10327000E099F0900E1EE0F8A3E0F974FFC398FC0B
+:10328000E499FD12B52712146DE9F50CE50C7003F5
+:1032900002B519F508E4F509F50AF50B78081222CC
+:1032A000607488122045AC82AD837A1E7B0D1214A7
+:1032B000797404121FF27485122045E0900E20F0FC
+:1032C000A3E4F0900E2CE004F07484122045E01486
+:1032D000700302B41714700302B46F14700302B3C6
+:1032E000E714601514700302B20914700302B4BE2F
+:1032F00014700302B4ED02B235750820780812226A
+:10330000647488122045AC82AD8374661220451225
+:10331000AE93121FF27464122045AC82AD837A0220
+:1033200079021212037466122045AC82AD837A01D1
+:1033300079041212037467122045AC82AD837A1DA2
+:1033400079031212037467122045AC82AD837A1D93
+:103350007905121203901184E06478600302B2359B
+:10336000A3E06478600302B235A3E06478600302EE
+:10337000B235A3E06478600302B2357401122045CF
+:10338000AC82AD8375838F75824E7404121EEF7408
+:103390006412204512227B7C057D8F740312204528
+:1033A000AA82AB8312148B7402121FF274011220D2
+:1033B00045E0901184F07402122045E0901185F0F0
+:1033C0007403122045E0901186F07404122045E049
+:1033D000901187F07C7C7D117B0C7A00900D1DE0B4
+:1033E000F91206DB02B235750801780812226474FE
+:1033F00088122045AC82AD83740212204512AE9330
+:10340000121FF2851882851983AC82AD837A017907
+:10341000001211EB02B23575081478081222647498
+:1034200088122045AC82AD83745212204512AE93AF
+:10343000121FF27508107808122264749C1220453D
+:10344000AC82AD83744212204512AE93121FF27407
+:1034500050122045AC82AD837A14790C1211C774D6
+:1034600040122045AC82AD837A10790D02B23275DC
+:10347000082878081222647488122045AC82AD8333
+:10348000741A12204512AE93121FF2741F122045B7
+:10349000AC82AD837A1179011212B17430122045D9
+:1034A000AC82AD837A1079021212B17418122045E1
+:1034B000AC82AD837A0779031212B102B235750876
+:1034C0000A78081222647488122045AC82AD837495
+:1034D0001012204512AE93121FF2740E122045AC4A
+:1034E00082AD837A0A790012142502B23575080676
+:1034F00078081222647488122045AC82AD83740A65
+:1035000012204512AE93121FF27408122045AC82AD
+:10351000AD837A06790E02B2327582047583011288
+:1035200020277F0602212379FF12B5301210D722FF
+:10353000900E1EE0241EFAA3E0340DFB22C082C0D0
+:103540008379007A007B008008EA24010AEB3400CA
+:10355000FB900E1EE0FCA3E0FDC3EA9CEB9D500F28
+:10356000741E2AF582740D3BF583E070DCEAF902E3
+:10357000ADC074F412205174FF121FDC740D1220C0
+:10358000457808121EACEA2508FEEB3509FFECF879
+:10359000EDF98C828D83A3AC82AD83750801801B0D
+:1035A0008C828D83F0A3AC82AD83050874FF65081F
+:1035B000601E8A828B83A3AA82AB83C3EA9EEB9FA1
+:1035C00050278A828B83E0851882851983F070D01A
+:1035D00088828983E508F0ECF8EDF98C828D83A36D
+:1035E000AC82AD8375080180C988828983E508F0C3
+:1035F0007401121FF27F0402212374F3122051740C
+:103600000D1220457808121EACEA2508F8EB3509A2
+:10361000F98808890980528A828B83E08C828D83A5
+:10362000F08A828B83A3AA82AB83E8FCE9FDE50ADA
+:103630002401F50AE50B3400F50B8C828D83A3A8D9
+:1036400082A983C3EA9508EB9509500FC3E50A9E4A
+:10365000E50B9400A2D265D03340BCEEF4600A8C36
+:10366000828D83E4F0E8FCE9FDC3EA9508EB950957
+:1036700050138A828B83E0FEA3AA82AB83750A0172
+:10368000750B0080B57F05022123C082C083120D17
+:10369000E312BF8075E1F17A02FB12BF62120D1DC9
+:1036A000D083D08202012274EA12205190058EE468
+:1036B000F07A857B05120D3B120C458A088B09AE0A
+:1036C00008AF098E828F83A3A3A37401F090046FC7
+:1036D000E004F07940120D358E828F83EAF0A3EB7F
+:1036E00012BC122406FCA3E03400FD12BBD3120D61
+:1036F000EFE5D9E5D9A2E6E433900576F07800E568
+:10370000D9C0E0880874772508F582740512BB9942
+:10371000D0E0F008E8C3940640E57806E5D918E85B
+:1037200070FAEE242212BB8F49700A7A04E5D91A86
+:10373000EA601D80F87C00E5D9C0E012BB7E24223F
+:10374000F582EB12BB99D0E0F00CECC3940440E797
+:1037500088828983121ECA120E5BEE242612BB8F4A
+:1037600049700A7A03E5D91AEA601D80F87C00E501
+:10377000D9C0E012BB7E2426F582EB12BB99D0E0C3
+:10378000F00CECC3940340E7888289837808121E0A
+:10379000AC908F367808121E86AA08AB09AC0AAD29
+:1037A0000B120E31EE242BF514EF3400F515E5D98C
+:1037B000851482851583F0EE242CF50AEF3400F58C
+:1037C0000BE50A450B700A7802E5D918E8601F80FE
+:1037D000F87A00E5D9C0E08A08EE250812BB8F24EC
+:1037E0002CF582E912BB99D0E012BC0B40E5EE2427
+:1037F0002EF508EF3400F509E5084509700A78024E
+:10380000E5D918E8601A80F87A00E5D9C0E012BB63
+:103810008A242EF582E912BB99D0E012BC0B40EA53
+:10382000851482851583E0C333F0850A82850B8376
+:1038300012BBFA850A82850B83E8F0A3E9F012BB7C
+:10384000F4850882850983E8F0A3E9F0EE242012CC
+:10385000BB8FFCE9FDEC4D700A7802E5D918E860F1
+:103860001A80F87A00E5D9C0E012BB8A2420F582DC
+:10387000E912BB99D0E012BC0B40EAEE2432FAEF19
+:103880003400FBEA4B700A7802E5D918E86023801F
+:10389000F8750E00E5D9C0E0850E0C12BB8C243201
+:1038A000F582E912BB99D0E0F0050EE50EC3940253
+:1038B00040E212BBAD7404780C121FC98A828B835C
+:1038C000E50CF0A3E50DF08C828D83E02401F5106A
+:1038D000A3E03400F511E4F512F51312BBF4880CE3
+:1038E000890DE4F50EF50F7810790C121CE912BB66
+:1038F000AD780C79101214DE500C8508828509838E
+:1039000012BC0449700F7A4012BF60EEFAEFFB124E
+:103910000C5D02BB76AC14AD15EEFAEFFB120C6F2A
+:10392000EE240B12BB967405F0A3E4F0EEFAEFFB65
+:10393000120C75EE245DF510EF3400F511E510451D
+:1039400011700A7805E5D918E8601D80F87A00E55D
+:10395000D9C0E012BB8A245DF582E912BB99D0E0A0
+:10396000F00AEAC3940540E7E5D9F8880CEE242A6A
+:1039700012BB96E8C4135407F0EE2410F512EF348E
+:1039800000F513E0F912292A851282851383EAF0E3
+:10399000A3EBF0E50C541FC0E0EE243712BB96D029
+:1039A000E0F0AC10AD11EEFAEFFB120C3F120EBBC3
+:1039B000120E557904120E617901120E9790606013
+:1039C0007480F075E1F1900F0C12BC1912BC1974DF
+:1039D00011F0A3740D12BC1F7495F0A3740DF09038
+:1039E0000F1A12BC2AA312BC2A7A0412BF60850ADD
+:1039F00082850B8312BBB1908F1E780C121E388506
+:103A00000A82850B8312BC0449600F850A82850BEC
+:103A100083E064027002A3E0702C8508828509832C
+:103A200012BE45121E257C027D00EEFAEFFB12232A
+:103A3000AC122A408E828F8312BB9E8E828F83A30C
+:103A4000A312BB9E800E7C017D00EEFAEFFB1223D9
+:103A5000AC122A4012BBE1780C121E4B908F3678C4
+:103A600008121EAC12BBE17808121E99EE2412F562
+:103A700008EF3400F5097808122264851282851354
+:103A80008312227BEE241D12BB9612227BAA0CAB62
+:103A90000DAC0EAD0F12297E7406121FF2EE241823
+:103AA00012BB96780C121EBBAC08AD0912BBCC7CC5
+:103AB000C47D8E12BBCC12BBE1C082C0838E828FCC
+:103AC00083E02408FCA3E03400FDD083D082740698
+:103AD000121EEF908F62121ECA8E828F8312BE5901
+:103AE000121ED6851482851583E0FA850882850921
+:103AF000837808121EAC74017808121FC9EA2508E1
+:103B0000F8E43509F9E875F071A4C8AAF075F00277
+:103B1000A42AFA75F071E9A42A12BBB9E8F0A3E966
+:103B2000F0EE241612BB96E0F508A3E0F509740444
+:103B30007808121FBAE5082401F8E509340012BB21
+:103B4000B9E028F0A3E03912BC12241212BE5CE0E6
+:103B50002410F0A3E0340112BC12241412BE5C74D1
+:103B60001012BC12241612BE5C74F1F0A3740BF098
+:103B70009004427407F0120D1D7F0E0221238C0861
+:103B8000EE2508FAEF3400FBEA228A0CEE250CF849
+:103B9000EF3400F9E822F582EF3400F58322A3A385
+:103BA000A3A3A3E02401F0A3E03400F0228A828BD7
+:103BB00083E0F50CA3E0F50D22F98E828F83E024DB
+:103BC00012FAA3E03400FB8A828B832212BBD31249
+:103BD00028B8228E828F83E02402FAA3E03400FB0F
+:103BE000228E828F8312BBE922E0F8A3E0F583885E
+:103BF00082A3A32285088285098312BC04C333F8FB
+:103C0000E933F922E0F8A3E0F9E822F00AEAC394E4
+:103C10000222F08E828F83E022748FF0A3740DF065
+:103C2000A3748FF0A3740DF0A322741112BC381288
+:103C3000BC38F0A3740DF022F0A3740DF0A374113E
+:103C40002274F0122051120E37E9700312BE05756E
+:103C5000E181907803E06442705E9005DFE014F04B
+:103C60007056C2AF12BC6700782AD0E0F618D0E0D8
+:103C7000F6E59F5407F97005908F828003908F2698
+:103C80007808121EACE9C4C0E07829E65508F508AA
+:103C900008E65509F509740B7808121FBAD0E0251B
+:103CA00008F8906270E0A2E740F8E8C333906272CF
+:103CB000F0906270E0D2E0F012BF57707E12BE0E3C
+:103CC00060069005D712BF65900596E064017034D8
+:103CD00012BE2B8AD9780012BE3040FB78008003D8
+:103CE00012BDEEE8C39940F812BE1912BE3040FB77
+:103CF0007800800312BDE0E8C39940F875E1959023
+:103D00000596E4F012BE6B121E3812BE42121E253A
+:103D1000908F36780C121E868A828B83780C121E46
+:103D2000BB12BE99121ECA12BE56121ED69005852F
+:103D3000E0241412BE5C741212BEAB120D1D7F087B
+:103D400002212374F012205175E181120E37E970BF
+:103D50000312BE0512BF57600302BDDD12BE0E6026
+:103D6000069005D712BF65900596E0640170371282
+:103D7000BE2B74064AF5D9780012BE3040FB78009D
+:103D8000800312BDEEE8C39940F812BE1912BE308E
+:103D900040FB7800800312BDE0E8C39940F875E16C
+:103DA00095900596E4F012BE6B121E3812BE4212B8
+:103DB0001E25908F36780C121E868A828B83780C93
+:103DC000121EBB12BE99121ECA12BE56121ED690E9
+:103DD0000585E0241412BE5C741512BEAB02BD3B17
+:103DE000880874B82508F582740512BDFC2288087D
+:103DF00074982508F582740512BDFC223400F58301
+:103E0000E0F5D90822900592E0F9120E3D229005C6
+:103E1000D8E0FAA3E0FBEA4B229005B7E0F974077B
+:103E200029F5D974044AF5D978002212BF42FA2242
+:103E3000880874882508F582740512BDFCE8C394CF
+:103E4000062290058FE0F508A3E0F509E4F50AF5F0
+:103E50000B780C790822900585E0240E12BE6022B2
+:103E6000F8A3E03400F98882898322120C9FE9FCD0
+:103E7000900585E02402F8A3E03400F9E8FAE9FBB4
+:103E80008A828B83EC75F0118485F00885080CE438
+:103E9000F50DF50EF50F780C2290058512BBE9A300
+:103EA000A3A3A3E4F0A3F0908F6222F0900585E035
+:103EB000241612BE6074EBF0A3740BF02274F0129F
+:103EC000205175E181120E37E9700312BE0512BF51
+:103ED00057706C12BE0E60069005D712BF65900534
+:103EE00096E06401702212BF424402F5D9780012B4
+:103EF000BE3040FB7800800312BDEEE8C39940F865
+:103F000075E195900596E4F012BE6B121E3812BE54
+:103F100042121E25908F36780C121E868A828B8361
+:103F2000780C121EBB12BE99121ECA12BE56121E69
+:103F3000D6900585E0241412BE5C741412BEAB0248
+:103F4000BD3B75E191A3E0F9740729F5D990058788
+:103F5000E0C4333354C0227901120D47E9640122D1
+:103F60007B00900441E0F912111322C082C08353F8
+:103F7000BFEF12BF57700312BF8075E1F102B69D0B
+:103F80007A857B05120D3B90058EE4F02274F712C2
+:103F900020518C828D8312C2618C828D83A3E08A32
+:103FA000828B8312BFB5E0FE8C828D8312BFBEF080
+:103FB000A3E902C4F4A3F08C828D83A3A322A3A35C
+:103FC00012BFC422A3E0F9EE8A828B83A3A32274DA
+:103FD000EE1220518A088B09890A8C0E8D0F7412FB
+:103FE00012204512C17A7414122045E0F50B7415A5
+:103FF000122045E0FE7901120AC5E96039EEF91296
+:104000000A778A108B11AE10AF11EE4F60238E82AB
+:104010008F83A3A3A3A3E508F0A3E509F08E828F05
+:1040200083E50BF09003F3E004F0700F7401F0806F
+:104030000A750815806C7508148067F8EE24030A69
+:104040000A0AEF3400FBE88A828B83F0780C122294
+:1040500064780E1222648A828B83E0FCA90AAA0883
+:10406000AB09120A3B7404121FF2E9F508702CEE3A
+:104070002407F50CEF3400F50D780C122264750C52
+:1040800030750D75780C122264EEFCEFFD7A8F7B93
+:104090000A12137D7404121FF28007EEFAEFFB126E
+:1040A0000A7DA9087F0A02212374EE12205174FAB6
+:1040B000121FDC8A0E8B0F890A8C0B741812204594
+:1040C00012C17A741A12204512C4877A177B001223
+:1040D0000A9B8A108B11AE10AF11EE4F700302C114
+:1040E0006DE5084509601FAC0CAD0DEE2404FAEF38
+:1040F0003400FB85088285098312204F8A088B09CA
+:10410000A808A9098004780079008E828F83E50AC7
+:10411000F0A3E50BF0E88E828F83A3A3F0E98E82F3
+:104120008F83A3A3A3F08518828519837405F0A358
+:10413000E4F07402122045EEF0A3EFF0E82404F856
+:10414000E93400F97404122045E8F0A3E9F0851879
+:1041500082851983AC82AD83AA0EAB0F120A41E9A6
+:10416000F508600CEEFAEFFB12136B800375081371
+:10417000A9087406121FF202C0A4E0F50CA3E0F532
+:104180000D2274F21220518A0A8B0BECFEEDFF7C9B
+:10419000047D008E828F83A3A3E0FAA3E0FB1213B9
+:1041A000718A0C8B0DEE2404F8EF12C45612C26112
+:1041B000A385820885830988828983A312C2651238
+:1041C000C265A312C27488828983E02404F8C39470
+:1041D0001C400302C25A8882AE8274FE650A7004D3
+:1041E00074FF650B70467A097B001210E3EA4B609E
+:1041F000378A828B837490F0A3A3A3A37402F08AFE
+:10420000828B83A3A374FEF0A30412C6E9A3E50C7A
+:10421000F0A3E50D12C6EEEEF0A3E4F09003CEE0BD
+:10422000F91210EF7900803479138030780C122263
+:1042300064EEFC7D007900AA0AAB0B1208FD740243
+:10424000121FF2E924FE600A24FB600A24F5600ACA
+:10425000800A791480067904800279027F0602219F
+:104260002312C3C42212C274A38582088583098ED7
+:10427000828F8322E0850882850983F02274F212FE
+:1042800020518A088B09EA240212C352E4F012BFBB
+:10429000B5A3A3E06402600302C31F8C828D83A3D5
+:1042A000A3A3A3A3E0F50AA3E0F50BC3E50A9404D6
+:1042B000E50B940040698C828D83A3A3A3A3A3A3E1
+:1042C000A3E0FAA3E0FB8A828B83E0FCA3E0F9EC95
+:1042D0002400E439FD8A828B83A3A3E0F50C8A8253
+:1042E0008B83A3A3A3E0F9A80CEC2404F50CED3414
+:1042F00000F50DE50A650C7004E50B650D70207482
+:1043000007687001E9601C7405687001E960147445
+:1043100004687001E9600C7406687001E960047952
+:1043200001802C850882850983A3A3A3A3ECF0A3B5
+:10433000EDF0850882850983E8F0A3E9F07CFC7D37
+:10434000FF1213718E828F83EAF0A3EBF0790002E3
+:10435000C25CFEEB3400FF8E828F832274F5122044
+:104360005175080275090012C4D5A3A983EC240273
+:10437000FEED3400FF8C828D83E064017002A3E0C7
+:10438000700812C3B1750804801E8C828D83E064AE
+:10439000027002A3E0701112C3B1A30AAB83EC2434
+:1043A00004F812C4B2750806AA08AB097F030221FB
+:1043B000238E828F8312C3C40AE9FB8E828F83A36C
+:1043C00012C3C42212C4C52274F6122051740A12F8
+:1043D000204512C532C3E89402E99400406712C533
+:1043E0004AEA2402F8EB3400F98A828B83E0640104
+:1043F0007002A3E070148C828D8312C44AA3E0FB88
+:10440000EE88828983F0A3EB80368A828B83E06416
+:10441000027002A3E0702A8C828D83A3A3E0F508CA
+:104420008C828D83A3A3A3E0FFE50888828983F0B3
+:10443000A3EF12BFB612C44A12BFBEA3A3F0A3E9F2
+:10444000F079008002790102C46EA3A3E0FE8C82A1
+:104450008D83A3A322ED3400F98882898322D0833F
+:10446000D08202012212C4C5A3AA82AB83227F029A
+:104470000221237F04022123F012C47D22EC2402B6
+:104480000C0CED3400FD22E0F508A3E0F5092274E0
+:10449000F712205112C4D5EC2402F812C4CC240423
+:1044A000080812C4CC2406080812C4B27A087B009B
+:1044B000804312C4B62212C45512C4E9888289838B
+:1044C000A312C4C522E08A828B83F02212C4B6A351
+:1044D0000AAB83EC228C828D8312C4658C828D831F
+:1044E000A312C4E52212C4E922E08A828B83F0A3DE
+:1044F0000AAB8322F07F0102212374F7122051744A
+:104500000912204512C5327408687001E9701F1243
+:10451000C54A12C47D8C828D83E0FE12BFC012C5D5
+:104520003812C538A3A3F0A3E9F07900800279011D
+:1045300080C3E0F8A3E0F922F0A3E912C4788C82EA
+:104540008D83E0FE12BFC4A3A32212C54E228C822B
+:104550008D83E0FEA3E0F9EE8A828B83F0A3E9F07D
+:104560002274F7122051740912204512C57D700182
+:10457000E9700512C5868002790102C4F5E0F8A34E
+:10458000E0F97402682212C54E79002274F01220FC
+:1045900051890A8A0C8B0D8C088D097A0A7B0012CE
+:1045A00010E38A0E8B0FAE0EAF0FEE4F60488E8277
+:1045B0008F8374A0F0A3E412C682E50CF0A3E50D8E
+:1045C000F0EE2404FAEF3400FBE50845096011859C
+:1045D0000882850983EAFCEBFD7406121EEF800950
+:1045E0007C067D0079001210D7EEFAEFFBA90A12C3
+:1045F00010EF7900800279017F0802212374EE1206
+:104600002051890E8A0A8B0B8C0C8D0D741212208E
+:1046100045E0F50F741312204512C4877A127B000F
+:104620001210E38A108B11AE10AF11EE4F60508E56
+:10463000828F8374A2F0A3E50C12C682E50AF0A370
+:10464000E50B12C68AE50F12C68AA3E50DF0EE242B
+:1046500006FAEF3400FBE5084509601185088285FC
+:104660000983EAFCEBFD740C121EEF80097C0C7DC3
+:104670000079001210D7EEFAEFFBA90E1210EF022C
+:10468000C0A4F08E828F83A3A32212C682A3A3228A
+:1046900074F4122051890A750B00850B82AC828C50
+:1046A0000875090074037808121FC912C746A8824A
+:1046B000A983E0FEA3E0FFEE4F701E8A828B83E4A5
+:1046C000F0EC2440FCE43400FD88828983ECF0A304
+:1046D000ED12C6E9E50AF0800D050BE50BC3940366
+:1046E00040B87A007B0002C47312C6EEA322F08A9F
+:1046F000828B83A3A3A3A3A322C082C0838A828BBD
+:1047000083A3E4F0A3F08A828B83F002C45E74F684
+:104710001220517E008E0875090074037808121F5C
+:10472000C912C746E0FCA3E0FDEC4D600B8A828B0A
+:1047300083A3A3A3E069600B0EEEC3940340D67A73
+:10474000007B0002C46E74DB2508FA74033509FB94
+:104750008A828B83A32274F7122051EA240712C3A2
+:1047600052E0F91213838E828F8374FF02C4F474B3
+:10477000F6122051EAFEEBFFEE4F60558E828F83DA
+:10478000A312C532E8496049E4F508F50978081232
+:10479000226478081222687D137C178E828F83A38F
+:1047A000A3A3A3E0FAA3E0FB8E828F83A3A3A3A31A
+:1047B000A3A3E0F9120A717403121FF28E828F8391
+:1047C000A3A3A3A3A3A3A374FFF0EEFAEFFB120A23
+:1047D0007D02C46E02012274F6122051EA2404FA0A
+:1047E000EB3400FB1208F7EA4B60097CFC7DFF12FA
+:1047F000137180047A007B0002C46E74F41220519D
+:1048000074FC121FDC7E00900C97E4F0900C94F086
+:104810007F7D7508047509007808122264740212FD
+:104820002045AC82AD837A007B00EF12CE11121FBF
+:10483000F2851882851983C082C083908F5A7808C8
+:10484000121EACD083D08278081214A37019900C79
+:1048500094E06010F91213A1EFF91213A1900C94D7
+:10486000E4F08021EF80FA85188285198378081298
+:104870001EACE5084509450A450B7004EFFE8005AE
+:10488000EFF91213A10FEFC3947F4086900C94E0D0
+:104890007026EE7018797D12138F900C957404F0C9
+:1048A000A3E4F0900C97E0601979008017F01213E0
+:1048B000A7EEF91213B9800AEE6004F912139B12E5
+:1048C00013A7790102C99674F712205174FC121FC4
+:1048D000DCE9FE908F5A121ECA8518828519831250
+:1048E0001ED6851882851983AC82AD837A007B0041
+:1048F0001213C5900C97E07005EE900C94F07404C0
+:10490000121FF27F01022123C082C08374FC121F98
+:10491000DC908F42121ECA851882851983121ED61A
+:10492000851882851983AC82AD837A007B00900C58
+:1049300094E0F91213C57404121FF2D083D08202DE
+:10494000012274F412205174FF121FDC8908900CAC
+:1049500097E06008900C977401F080361213057E82
+:10496000007F00750A01750B00780A122264740238
+:10497000122045AC82AD83EEFAEFFBA90812CE12ED
+:10498000121FF2851882851983E0F470C712C9E8F6
+:1049900040D1740180027404121FF27F04022123AB
+:1049A00074F412205174FF121FDC89087E007F000E
+:1049B000750A01750B00780A1222647402122045F0
+:1049C000AC82AD83EEFAEFFBA90812CE12121FF2F1
+:1049D000851882851983E0F46007A90812139B806B
+:1049E0000512C9E840CA80AAEE24010EEF3400FF88
+:1049F000C394082274F412205174FC121FDC7EFC54
+:104A00007F07750804750900780812226474021281
+:104A1000204512CE05121FF2851882851983C082A7
+:104A2000C083908F627808121EACD083D082780841
+:104A30001214A3700AEE24FCFEEF12CADD50C3EE7E
+:104A40002404F8EF3400F9900C95E8F0A3E9F002A3
+:104A5000C99674F412205174FC121FDC8909EAFE15
+:104A6000EBFF8C08EE24FCFEEF12CADD4068750AED
+:104A700004750B00780A1222647402122045AC827D
+:104A8000AD83EEFAEFFBA90912CE12121FF27402E7
+:104A9000122045E0F8A3E0F985188285198385087E
+:104AA0000AE0650A7002A3E0700AEEC398FAEF9478
+:104AB00000FB8026E9548070ABE82404FAE9340056
+:104AC000FBC3EE9AEF9B400EEEC398F8EF99F9E81E
+:104AD00024FCFEE980937A007B0002C99634FFFF34
+:104AE000C3EE9404EF94002274EC12205174FC1273
+:104AF0001FDC890AEAFEEBFF8C0B7418122045E0DC
+:104B0000F50EA3E0F50F741A122045E0F50CA3E0B2
+:104B1000F50D85188285198374FFF0A3F0E50F4425
+:104B200080F97402122045E50EF0A3E9F0EE250E9F
+:104B3000F508EF350FF509851882851983AC82AD2C
+:104B400083AA08FBA90A1213C5740212204512CBCE
+:104B5000D77402780E121FBAE50EF510900C97E08C
+:104B60007050750F00780E122264AC0CAD0D8E0ED5
+:104B70008F0F7402780E121FBA850A12F51374098A
+:104B80007812121FC9E50E2400FAE50F3513FB1247
+:104B900012FF7402121FF2E510F50E780E12226851
+:104BA000AC0CAD0DEEFAEFFBA90A1213BF740112A3
+:104BB0001FF2850B0CE50C851882851983F0A37410
+:104BC0008012CBDB85188285198312CBD77404122F
+:104BD0001FF27F0C022123A3E0547FF08518828509
+:104BE0001983AC82AD83AA08AB09A90A1213C522A6
+:104BF00074EA12205174F8121FDC8910750DFF74CD
+:104C00007D65107005750C7E8003750C7D750A043A
+:104C1000750B00900C95E024FCFEA3E08005EE24CB
+:104C2000FCFEEF12CADD500302CD4D900C97E06000
+:104C30000302CD67750804750900780812226474B0
+:104C400002122045AC82AD83EEFAEFFBA91012CE22
+:104C500012121FF2851882851983E0F47003A3E015
+:104C6000F4702D7402122045E0F8A3E0F95480702E
+:104C7000AD12CF7CEE98EF99500302CD677402120B
+:104C8000204512CD71F8EF99F9E824FCFEE98093F4
+:104C9000851882851983A3E0548070E18518828588
+:104CA0001983850D08E065087002A3E060CF8518C0
+:104CB00082851983E0F50DFCAA0AAB0BA90C12132F
+:104CC000AD8B09EA450970B5740212204512CD7109
+:104CD000F508EF99F50988148915750E00750F0010
+:104CE000751204751300781212226474061220459E
+:104CF000AC82AD83E508250EFAE509350F12CE0C1E
+:104D0000121FF27404122045AC82AD83E50A250E11
+:104D1000FAE50B350FFBA90C1213C5E50E2404F5BB
+:104D20000EE50F3400F50FC3E514950EE515950F4C
+:104D300050AE7402122045E02404F8A3E03400F9D8
+:104D4000E50A28F50AE50B39F50B02CC7DA90C1212
+:104D5000138F900C97E0700A900C95E50AF0A3E58C
+:104D60000BF0A91012139B7408121FF27F0E022180
+:104D700023E0F8A3E0F9EEC3982274F012205174F6
+:104D8000FC121FDC890B8A088B09ECFEEDFF741402
+:104D9000122045E0F50A8014E5082404F508E50929
+:104DA0003400F509EE2404FEEF3400FF850A0C748C
+:104DB000FF250CF50A046043750E04750F00780E8C
+:104DC0001222647402122045AC82AD83AA08AB099A
+:104DD000A90B12CE12121FF2780E122264EEFCEF13
+:104DE000FD7402122045AA82AB831210D174021204
+:104DF0001FF2E970A3900C977401F07404121FF273
+:104E00007F08022123AC82AD83EEFAEFFB900C9475
+:104E1000E0F91212F974022274F1122051890E8AFB
+:104E2000088B09ECFEEDFF900C97E0704D750A01C0
+:104E3000750B00780A1222648A0A8B0B7402780AB6
+:104E4000121FBA890CF50D7409780C121FC9E50AF6
+:104E50002400FAE50B350DFB1212FF7402121FF24B
+:104E6000750A01780A122268EEFCEFFDAA08AB0968
+:104E7000A90E1213BF7401121FF27F07022123C073
+:104E800082C083121389E9700479018002790002DB
+:104E9000C93B74F012205174FF121FDC89088A0983
+:104EA0008C0A8D0BAC0812CFBA8A0C8B0DAE0CAFEE
+:104EB0000DEE4F604D750E00803B750C01750D00B9
+:104EC000780C122264740212204512CE05121FF2D1
+:104ED000851882851983E0F8850E0CE50A250CF506
+:104EE00082E50B3400F583E0687017EE24010EEFC5
+:104EF0003400FF050EE50EC3950940BEE509650EB9
+:104F0000607385090CE50C2403F8E43400F97A0495
+:104F10007B00121F49880E890F7402780E121FC978
+:104F2000850E0C850F0D900C95E0250CF8A3E0354F
+:104F30000DF912CF7CE89401E99408400312D025C2
+:104F4000780A122264780C122264AC0812CFC112C3
+:104F500013B37404121FF2900C97E06004790A8076
+:104F600016E50C2404F8E50D3400F9900C95E028C2
+:104F7000F0A3E039F07900740102CDFDE82404F8D3
+:104F8000E93400F9C32274F4122051890A8A0BEC27
+:104F9000FEEDFFAC0A12CFBAEA4B6019850B08751B
+:104FA00009007808122264EEFCEFFD12CE0D121FEC
+:104FB000F279008002790A02C99B12CFC11213ADA7
+:104FC00022900C95E0FAA3E0FB900C94E0F9227497
+:104FD000F0122051E9FE74BA2EC3941A40047902EB
+:104FE0008040900C95E0F508A3E0F509E4F50AF59A
+:104FF0000B908F56780C121EAC7808790C121CE9B5
+:105000008E0CE4F50DF50EF50F740B780C121E06E0
+:10501000780C79081214DE400712D025790080023E
+:10502000790A02CE00121395900C94E0F91213B98C
+:1050300022C082C083790102D3ACC082C0837902CE
+:1050400002D3AC74F51220518A088B09ECFEEDFFF7
+:10505000EE4F6005EA45097005790202D0FD8E82A7
+:105060008F83E912D41E8A828B8312D1038A828BAA
+:105070008312D102EA24020A0AEB3400FB120F1554
+:10508000E912D104850882850983A3A3A312D10262
+:1050900012D2B788828983E054086004D2F080027B
+:1050A000C2F0A2F012D10E541060047A0280027A8B
+:1050B000008E828F83E04A12D114542060047A0457
+:1050C00080027A008E828F83E04A12D1088882891A
+:1050D00083E0A2E012D10E540260047A0280027AC8
+:1050E000008E828F83E04A12D11454046004780445
+:1050F000800278008E828F83E048F079007F03027F
+:105100002123A3E08E828F83F0A30EAF8322E433AA
+:105110008E828F83F088828983E02274ED12205181
+:10512000EAFEEBFF8C088D09EE4F6005EC45097037
+:1051300005790202D2B28E828F83A3AE82AF83E062
+:105140008C828D8312D2C28C828D83A385820A8544
+:10515000830B8E828F83E0850A82850B8312D2C2F5
+:10516000E0F9EC2402FAED3400FB120F1B8E828F63
+:1051700083A30EAF83E5082404F50CE5093400F59C
+:105180000DE0850C82850D83F08E828F83A3E0F580
+:1051900012A30E0EAF83A2E0E433F50E750F00E507
+:1051A00012A2E15004D2F08002C2F0A2F0E433F582
+:1051B00010751100E512A2E25004D2F08002C2F094
+:1051C00012D2B7E8FAE9FB8A828B83E054F7FCA39A
+:1051D000E0FD7403780E121FC9EC450E54EFFC7409
+:1051E000047810121FC9EC451054DFFCA2F0E43320
+:1051F000F50E7405780E121FC9EC450EFC8A828BE1
+:1052000083F0A3EDF08E828F83E0F512A2E0E43309
+:10521000FEE512A2E15004D2F08002C2F0A2F0E456
+:1052200033F8E512A2E25004D2F08002C2F0EC544E
+:10523000FE4E54FDFCE8C333F8EC48F8EDF9E854B1
+:105240003BFCA2F0E433F50E7402780E121FC9EC99
+:10525000450E8A828B83F0A3E9F07A217B00120548
+:10526000DF8A0E8B0FA80EA90F850C82850D83E0B7
+:10527000C398E499401A7A227B001205DF8A0E85D2
+:105280000C82850D83E0FAC3E50E9AEB940050047E
+:105290007912801E850882850983E0C39405500C2D
+:1052A000850A82850B83E0C394024004791880024A
+:1052B00079007F0B022123E5082405F8E509340075
+:1052C000F922F08E828F83A30EAF832274F6122010
+:1052D00051ECFEEDFFEE4F6004EA4B700479028062
+:1052E000188E828F83740312D412122264EAFCEBAC
+:1052F000FD12D524121FF2790002D4E774F61220B1
+:1053000051ECFEEDFFEA4B6004EE4F700479028031
+:1053100013750810750900780812226412D51B1243
+:105320001FF2790002D4E774F6122051ECFEEDFF73
+:10533000EE4F6004EA4B7004790280188E828F83EE
+:10534000740412D412122264EAFCEBFD12D524126A
+:105350001FF2790002D4E774F6122051ECFEEDFF43
+:10536000EA4B6004EE4F70047902801375081075E3
+:105370000900780812226412D51B121FF27900026C
+:10538000D4E7C082C083EC4D6004EA4B700479021C
+:1053900080188C828D837405F0A3AC82AD838A82E1
+:1053A0008B83E08C828D83F07900800312101DD0F6
+:1053B00083D082020122C082C083EA4B6004EC4D9C
+:1053C00070047902801A8A828B83A3E0F88C828D24
+:1053D00083F0C3940A5003E87004791880027900BE
+:1053E00080CD74F6122051ECFEEDFFEE4F6004EA22
+:1053F0004B7004790280188E828F83740612D41247
+:10540000122264EAFCEBFD12D524121FF27900028D
+:10541000D4E712D41E750810750900780822F0A38D
+:10542000AE82AF832274F6122051ECFEEDFFEA4B00
+:105430006004EE4F7004790280137508107509003E
+:10544000780812226412D51B121FF2790002D4E7E9
+:1054500074F6122051EAFEEBFFECFAEDFBEA4B602A
+:1054600004EE4F70047902802C8A828B83740712B9
+:10547000D56F8E828F83A312D57D750808750900BC
+:105480007808122264EE2402FCEF3400FD12D528C5
+:10549000121FF27900805074F6122051ECFEEDFFDD
+:1054A000EA4B6004EE4F70047902803B8A828B8362
+:1054B000A3AA82AB83E0FCA3E0F8E4C8F9EC8E82F7
+:1054C0008F83F0A3E9F07508088809780812226430
+:1054D000EA2402FCEB3400FDEE2402FAEF34001261
+:1054E000D527121FF279007F0202212374F61220C1
+:1054F00051ECFEEDFFEE4F6004EA4B700479028040
+:10550000188E828F83740812D412122264EAFCEB84
+:10551000FD12D524121FF2790080CC8A828B83A3DE
+:10552000AC82AD83EEFAEFFB1210BF74022274F668
+:10553000122051EAFEEBFFECFAEDFBEA4B6004EEC1
+:105540004F7004790280258A828B83740912D56F8B
+:1055500075080675090078081222648E828F83A36D
+:10556000AC82AD8312D528121FF2790002D4E7F085
+:10557000A3AA82AB838E828F8312D57D22E08A829A
+:105580008B83F0A30AAB832274F6122051ECFEED5C
+:10559000FFEA4B6004EE4F70047902801375081027
+:1055A000750900780812226412D51B121FF27900C7
+:1055B00002D4E774F6122051ECFEEDFFEA4B6004D2
+:1055C000EE4F7004790280378A828B83A3AA82AB64
+:1055D00083E08E828F83F08A828B83A30AAB8375EC
+:1055E00008067509007808122264EAFCEBFD8E8239
+:1055F0008F83A3AA82AB8312D528121FF2790002EF
+:10560000D4E774F6122051ECFEEDFFEE4F6004EA91
+:105610004B7004790280188E828F83740A12D41220
+:10562000122264EAFCEBFD12D524121FF27900026B
+:10563000D4E774F6122051ECFEEDFFEA4B6004EE65
+:105640004F700479028013750810750900780812EC
+:10565000226412D51B121FF2790002D4E774F712EC
+:105660002051ECFEEDFFEE4F6004EA4B700479022E
+:1056700080148E828F83740B12D41E120F15E98E44
+:10568000828F83F079007F01022123C082C083EAE8
+:105690004B6004EC4D7004790280108A828B83A3E6
+:1056A000E0F9ECFAEDFB120F1B790002D3AF74F3B3
+:1056B00012205174FA121FDC8A088B09890CECFE47
+:1056C000EDFF7413122045E0F8A3E0F9880A890B76
+:1056D0008518828519837406F0A3E4F0850C82AAEC
+:1056E00082FB7404122045EAF0A3E4F0120A9B74D2
+:1056F00002122045EAF0A3EBF07402122045E0FC10
+:10570000A3E0FDEC4D6036EEFAEFFB850A82850BD7
+:105710008312204FE9FE7013851882851983AC82AD
+:10572000AD83AA08AB091209F9E9FEEE6011740213
+:10573000122045E0FAA3E0FB12136B80027E1312E5
+:105740000EEBEEF97406121FF27F0502212374F4AA
+:1057500012205112DE4B6005791102D81D90030111
+:10576000E054057005791202D81D90032512DE540D
+:10577000600512DE467005791002D81D900301E025
+:10578000A2E0400612073BE960108E828F83E0F8AA
+:10579000740368600574026870CB7A0C7B00121188
+:1057A0004F90031CEAF0A3EBF012DE51606B12DCA9
+:1057B0002BE50812DC1FE4F0750A0AF50B780A12D3
+:1057C0002264EEFCEFFD90031CE02402FAA3E01239
+:1057D000DD43121FF21206F3E9FE6005120717807F
+:1057E0003A900302E0640370327A1D7B001205DFF9
+:1057F000900303EAF0A3EBF090030312DE54601B66
+:10580000908F7E1222777A047B0090032BE0F912AE
+:10581000118B7404121FF280027E13EEF902DD2F49
+:1058200074EE122051890C8A0A8B0B8C0E8D0F900E
+:105830000301E05405700302D8C27401650A700DBB
+:1058400090032512DE54607A900325800B90032785
+:1058500012DE54606D900327E0FEA3E0FFEBC394DB
+:105860002040047902805DEB6005EC450F60F4E5B3
+:105870000C900E7AF08E828F83A38582088583092F
+:105880007C1F7D007900AA08AB091210D7850B1088
+:105890007511007810122264AC0EAD0FAA08AB0986
+:1058A0001210BF7402121FF28E828F83E50BF0F983
+:1058B000E50AAA08AB096005120927800712092D1D
+:1058C000800279127F0A02212374F7122051E9FE27
+:1058D00012DE5170047912802912DE466E6004795E
+:1058E00003801F12DD177A04FB90032BE0F91211DD
+:1058F00091900303E4F0A312DC1F7403F07900120B
+:10590000093302D986D083D08202012274F7122093
+:105910005190032512DE54600312D98B9003271295
+:10592000DE54600D90032712DDD8900327E4F0A326
+:10593000F0900301E0540560447A7B7B0E12074D22
+:105940007E00900301E05405602F12DD5C9003257A
+:1059500012DE5460227C207D0079001210D712DD07
+:105960004C90032712DE54600B7C207D00790012DE
+:1059700010D7800512D98B7E13EEF980097A007B4F
+:105980000012074D79007F0102212390032512DDCB
+:10599000DC900325E4F0A3F02274F61220517E017E
+:1059A0008A828B83A3A3A3E0FCA3E0FD8C088D096E
+:1059B00078081222A80620041FDAC4D91FDAFFD9FA
+:1059C000FFD9D7D98A828B83A3A3A3A3A312DD6CAB
+:1059D0001206F9E9FE80498A828B83A3A3A3A3A3BD
+:1059E00012DD3D88828983A3E0FC88828983A3A39A
+:1059F000E0FBECFA88828983E0F91206FF80D47418
+:105A0000086C700374206D70047901800279008A3B
+:105A1000828B83A3A3A312DE41FA12070580011E25
+:105A2000EEF902DC6C74F212205112DE51700302A6
+:105A3000DAE412DC26A3E0F50A12073BE960097AF2
+:105A40000A12DAEB7A0B801612071DE960097A0652
+:105A500012DAEB7A0780077A0812DAEB7A097B0010
+:105A60001205DF8A088B09900302E07005750B00B0
+:105A70008003750B0190031CE02404FAA3E03400BA
+:105A8000FB12DAF9E0F9120603E9FA90031CE024AC
+:105A90000BF8A3E012DD34F50C780C12226812DA50
+:105AA000F9A3A3A3A3A3A3A3E0F50C780C12226887
+:105AB00090031CE02404F50CA3E03400F50D780CF1
+:105AC000122264EAF50C780C122268780B12226814
+:105AD000A90AAC08AD09EEFAEFFB1209217406120F
+:105AE0001FF2800279017F060221237B001205DF6D
+:105AF0008A088B09AE08AF092290031CE0F8A312B4
+:105B0000DC2BA3A3A32274F7122051E9FE12DE516D
+:105B1000601EEE700C12DC267401F0F9120933E9F4
+:105B2000FEEE60087A007B00F9120711790180020D
+:105B3000790002D98674EC122051890A12DE4D7068
+:105B40000302DC0912DC26E06401600302DBDF12E1
+:105B5000071DE9604A7A0112DC10C3EA9442EB9413
+:105B600000402B908F7E1222777A027B0090032BCD
+:105B7000E0F912118B7404121FF2E50C24C4F8E54D
+:105B80000D34FFF9900329E8F0A3E9F08036908FF7
+:105B90006E7810121EAC780C7910121CE980057A10
+:105BA0000012DC10E50C450D450E450F6016780C13
+:105BB0001222607A027B0090032BE0F912118574A7
+:105BC00004121FF212DC207402F0900305E0700B47
+:105BD000EEFAEFFBA90A120711802AE4F080269062
+:105BE0000305E070207A037B001210E3EA4B601299
+:105BF0008A828B8374D0F0A3E50A12DC71740412DC
+:105C0000DDB41207177901800279007F0C0221238D
+:105C10007B001205DF8A0C8B0DE4F50EF50F22F0E8
+:105C200090031CE0F8A312DC2BA322E0F58388820A
+:105C30002274F6122051E9FEEAFF900E7AE0F46039
+:105C40002B7A047B001210E3EA4B60208A828B835C
+:105C500074D0F0EFA312DC717402F0EE8A828B83B1
+:105C6000A3A3A3F0900E7AE0F91210EF7F020221B5
+:105C700023F08A828B83A3A32274F4122051E9FEBD
+:105C800074016E707D90032912DE54600690030546
+:105C9000E0600E12DE51607D12DE46F91206E180F0
+:105CA00074900329C3E0943CA3E09400400E900359
+:105CB00029E024C4F0A3E034FFF0805912DD1FE096
+:105CC000F508A3E0F509E50875F0E8A4C508A8F013
+:105CD00075F003A428F875F0E8E509A428F509E4AF
+:105CE000F50AF50B78081222607A027B0090032BEC
+:105CF000E0F91211857404121FF2900329E4F0A355
+:105D000080B712DE51600E900301E0A2E25006124D
+:105D1000DD17120717801812DD1FE4F0A3F0227AB6
+:105D2000027B0090032BE0F9121191900329227F4E
+:105D3000040221233400F988828983E022E0F8A359
+:105D4000E0F9223400FB1210BF7402227A207B009B
+:105D500012114F900327EAF0A3EBF0227A207B0088
+:105D600012114F900325EAF0A3EBF02212DD70220E
+:105D7000E0F8A3E0F5838882E0F92274F412205160
+:105D800012DE4B602C7A057B001210E3EA4B601A9E
+:105D90008A828B8374D0F0A3E50812DC717403123D
+:105DA000DC71A3EEF0A3EF12DDB4E5086003120787
+:105DB0001702DD2FF090031C12DD701210EF22C0CD
+:105DC00082C08312DE51600D90031C12DDD8900357
+:105DD0001CE4F0A3F002D90512DDDC22E0FAA3E016
+:105DE000FB1211552274F612205174FF121FDC9021
+:105DF000032512DE546040900325E02401F508A33A
+:105E0000E03400F509780812226490032512DE437D
+:105E1000FC7402122045AA82AB83790112065774E2
+:105E200002121FF28A828B83E58245836009E0A219
+:105E3000E050047901800279007401121FF202DC43
+:105E40006CA3A3E0F8A312DC2BE0228908EAFEEBA6
+:105E5000FF90031C12DD3DE8492274F01220518AA4
+:105E60000C8B0D8C0E8D0F7E007ADF7B11120AA732
+:105E7000E9F8850C08850D09E5085420601D7508B2
+:105E8000E875098E78081222647C107D007A817B87
+:105E90000F12084F7402121FF2E9FEEEF97F08029A
+:105EA000212374F0122051890A8A09ECFEEDFF7556
+:105EB0000800E50A24F4601214607314700302DF12
+:105EC0009314700302DFBB02E01474146509705868
+:105ED000750C14750D00780C122264EEFCEFFD7A3F
+:105EE000FA7B071210BF7402121FF28A0E8B0F8505
+:105EF0000E0C850F0D750BFF780B122268750E10B6
+:105F0000750F00780E122264750E81750F0F780ED2
+:105F100012226479007CFA7D077A0E7B081208E56C
+:105F20007405121FF2E9800375081802E017741057
+:105F300065097059750C10750D00780C122264EE0D
+:105F4000FCEFFD7A1A7B081210BF7402121FF28A4E
+:105F50000E8B0F850E0C850F0D750BFF780B122223
+:105F600068750E10750F00780E122264750E81751B
+:105F70000F0F780E12226479007C1A7D087A2A7B32
+:105F8000081208E57405121FF2E902E017750818F7
+:105F900002E01774066509701D85090C750D0078FF
+:105FA0000C122264EEFCEFFD7A367B081210BF74EF
+:105FB00002121FF28061750818805C740365097015
+:105FC0004E85090C750D00780C122264EEFCEFFD75
+:105FD0007A487B081210BF7402121FF2750BFF780B
+:105FE0000B122268750C10750D00780C1222647566
+:105FF0000C81750D0F780C12226479007C487D08A5
+:106000007A4B7B081208E57405121FF2E9800875C7
+:1060100008188003750802A9087F0802212374F478
+:106020001220518909EAFEEBFF750800E50924F406
+:10603000600C14603014605414607802E0D0750A6B
+:1060400014750B00780A1222647CFA7D07EEFAEFD1
+:10605000FB1210BF7402121FF28A0A8B0B850A8290
+:10606000850B83806E750A10750B00780A12226406
+:106070007C1A7D08EEFAEFFB1210BF7402121FF2B9
+:106080008A0A8B0B850A82850B838047750A067501
+:106090000B00780A1222647C367D08EEFAEFFB12C0
+:1060A00010BF7402121FF28A0A8B0B850A82850BBD
+:1060B000838020750A03750B00780A1222647C48DD
+:1060C0007D08EEFAEFFB1210BF7402121FF280037C
+:1060D000750802A9087F0402212374EC1220517470
+:1060E000FE121FDC8A108B11ECFEEDFF890B74167B
+:1060F000122045E0F50CA3E0F50D7418122045E0E0
+:10610000F508A3E0F509741A122045E0F50EA3E0A6
+:10611000F50F750A008E828F83A3A3A3E0A2E4503B
+:1061200005790802E264E50E450F6005790B02E28D
+:1061300064851882851983AC82AD83EEFAEFFB1279
+:106140001419E96401700E8508828509837400F0D2
+:10615000790102E264851882851983E0F512A3E0D3
+:10616000F51378121222EE0000040086747DE19D82
+:1061700075B9E1AC76F4E1AD7625E256E2850882A8
+:106180008509837414F075121475130078121222A5
+:10619000648E828F83A3A3A3A3A3A3E0FCA3E0FD4B
+:1061A000AA0CAB0D1210BF7402121FF28A128B13CD
+:1061B00085128285138302E26285088285098374D1
+:1061C00010F075121075130078121222648E828FEF
+:1061D00083A3A3A3A3A3A3E0FCA3E0FDAA0CAB0DA0
+:1061E0001210BF7402121FF28A128B13851282855D
+:1061F0001383806E8508828509837406F075120604
+:1062000075130078121222648E828F83A3A3A3A336
+:10621000A3A3E0FCA3E0FDAA0CAB0D1210BF740217
+:10622000121FF2803D8508828509837403F0751280
+:106230000375130078121222648E828F83A3A3A3A6
+:10624000A3A3A3E0FCA3E0FDAA0CAB0D1210BF7446
+:1062500002121FF2800C8508828509837400F07594
+:106260000A0AA90A7402121FF27F0C02212374EC9D
+:1062700012205174FE121FDC8A0E8B0FECFEEDFF14
+:1062800089087416122045E0F512A3E0F51374187E
+:10629000122045E0F510A3E0F511750900750AFF1D
+:1062A0008E828F83A3A3A3E0A2E55005790802E3C1
+:1062B000C2851882851983AC82AD83EEFAEFFB129A
+:1062C0001419E964017005790102E3C28518828519
+:1062D0001983E0F50CA3E0F50D780C1222EE000016
+:1062E0000500022953E3867482E39D7582E3AC7650
+:1062F00082E3AD76F8E27FE3E5104511700B74039D
+:106300006508600875090D800375090BE509707251
+:106310008E828F83A3A3A3A3A3A3E0F50CA3E0F530
+:106320000D851282851383E0850C82850D83F07ABA
+:10633000087B00790A121113E98E828F83A3A3A32D
+:10634000A3A3A3E064487004A3E064087034750A52
+:106350000F802F750C01750D00780C1222647810D7
+:106360001222647812122264A908EEFCEFFDAA0E34
+:10637000AB0F1208DF7406121FF2E9F509800375EE
+:10638000090A74FF650A60389007F8E0F8A3E0F99D
+:10639000E849602C9007F8E0F8A3E0F5838882E0F4
+:1063A000F8A3E0F9E8496018A90A9007F8E0F8A313
+:1063B000E0F5838882E0F8A3E0F583888212204F1D
+:1063C000A9097402121FF27F0C02212374F7122014
+:1063D00051EAFEEBFF890874FE6E700374FF6F6074
+:1063E000447401650860127402650870387901EE22
+:1063F000FAEFFB120AC5E9702C7C0E7D08EEFAEF6D
+:10640000FB1208CD7C2A7D08EEFAEFFB1208CD7C4A
+:106410003C7D08EEFAEFFB1208CD7C4B7D08EEFACE
+:10642000EFFB1208CD7F01022123C082C08312142A
+:106430009102E5EE74F7122051ECF8EDF9740912AF
+:106440002045E0FCA3E0FD801988828983E08A82F0
+:106450008B8312E5C5A882A9838A828B83A3AA8233
+:10646000AB83ECFEEDFFEE24FF1CEF34FFFDEE4F9F
+:1064700070D702E74E74F71220517409122045E0DC
+:10648000FEA3E0FFEC2EF8ED3FF9E824FF18E93415
+:10649000FFF9801788828983E08A828B83F0E82461
+:1064A000FF18E934FFF9A3AA82AB83EEFCEFFDEC01
+:1064B00024FF1EED34FFFFEC4D70D902E74E74F25D
+:1064C0001220518A088B098C0A8D0BAA0AAB0B1279
+:1064D000114F8A0C8B0DAE0CAF0DEE4F6011780A88
+:1064E000122264AC08AD091210BF7402121FF2EE42
+:1064F000FAEFFB7F0602212374F5122051ECF8ED30
+:10650000F9740B12204512E6F5AC08AD09EC24FF36
+:10651000F508ED34FFF509EC4D602CEAFCEBFD8C41
+:10652000828D83A3AA82AB83E8FEE9FF8E828F83EC
+:10653000A3A882A9838C828D83E0FC8E828F83E066
+:106540006C60C67900800279017F0302212374F612
+:10655000122051E9FE8C088D0978081222648E08F9
+:10656000AC087D0012147F7402121FF202E753C0C0
+:1065700082C0831211AF807674F6122051EAFEEBCE
+:10658000FFEE4F70067A007B008037EE2405FAEFAD
+:106590003400FB12114F8A088B09A808A909E849A1
+:1065A00060E388828983E4F0A312E5C5A3EEF0A33B
+:1065B000EF12E5C5A3A3A374FFF0E82405FAE934BC
+:1065C00000FB02E753F088828983A322C082C08344
+:1065D000EA4B70047905801612E660600479048045
+:1065E0000DEA24FBFAEB34FFFB1211557900D0833E
+:1065F000D08202012274F71220517C0002E74B7412
+:10660000F7122051E9FEECFFEA4B70047905804D4A
+:10661000908FEBE0F8EEC39840071210E979038001
+:106620003C12E7F312E976700512E660600512107D
+:10663000E980D9EEF074016F700DEAFCEBFD7ADBB6
+:106640007B07121107800BEAFCEBFD7ADB7B07125C
+:1066500011017A007B80EEF9121113790002E74EE6
+:10666000EA24FFF582EB34FFF583E0F42274F212A2
+:106670002051890B750C00750D007E007F00A2AFC4
+:10668000E433F50AC2AF9007DB8015EE4F70068544
+:10669000080C85090DE50824FBF582E50912E7F9E8
+:1066A00012E6F5E50845096023E50824FFF582E5D3
+:1066B0000912E7F9E0650B70D2EE4F7006AE08AF35
+:1066C0000980D27A007B80121113800B7A007B80C4
+:1066D000121119EE4F6015780C122264EEFCEFFDDA
+:1066E0007ADB7B0712110D7402121FF2E50AA2E099
+:1066F00092AF02E4EFE0F508A3E0F5092274F71287
+:106700002051A2AFE433FEC2AFEC24FBF582ED12C0
+:10671000E7F9E4F0A3F012E97270098A828B8380B2
+:106720000C12E80812E7398882898370F4ECF0A330
+:10673000EDF0EEA2E092AF8015E824FBF8E934FF1B
+:10674000F98882898312E802EA4B221210F57F0150
+:106750000221237F0202212374F7122051E5A8FEB3
+:10676000C2AF8A828B8312E808EC24FBF582ED121B
+:10677000E7F9E8F0A3E9F08A828B83ECF0A3EDF06F
+:10678000EEA2E702E73574F5122051740B12204592
+:1067900012E808A2AFE433F50AC2AFEC24FBFEED29
+:1067A00034FFFF8A828B8312E6F5EC65087003EDF7
+:1067B00065098E828F83700D12E8088A828B83E8C8
+:1067C000F0A3E9801012E7FEE824FBF582E912E766
+:1067D000F9EAF0A3EBF08E828F83E4F0A3F0EC24CF
+:1067E000FFF582ED12E7F974FFF0E50AA2E092AF3F
+:1067F00002E549EA24FBF582EB34FFF5832212E837
+:106800000222E0FAA3E0FB22E0F8A3E0F92274F709
+:10681000122051E9FD908FEBE0F8EDC3985029E587
+:10682000A8FEC2AFEDC333F8E433F99007F5E028D2
+:10683000FCA3E0398C82F583E04AF0A3E04BF0EE54
+:10684000A2E792AF79008002790302E74E74F71253
+:106850002051E9FE908FEBE0F8EEC398501FE5A8B9
+:10686000FFC2AFEAF4FCEBF4FDEE12E95EE05CF08F
+:10687000A3E05DF0EFA2E792AF7900800279030216
+:10688000E74EE9F874FF687006C2AF7900800279BC
+:1068900007020122C082C0831211439007DBE4F09B
+:1068A000A3F012116D12115B1211A312114979009C
+:1068B00002E5EEC082C08312113180FB74F6122013
+:1068C0005175080012113D1212F3E50812E95E122B
+:1068D000E976700D0508908FEBE0F8E508C3984065
+:1068E000E9908FEBE0F8E508C3985066E5A8FCC294
+:1068F000AFE508C333FEE433FF9007F5E02EF8A3BD
+:10690000E03FF98882898312E7FE88828983E4F078
+:10691000A3F0ECA2E792AFE508900F2CF0F97467B2
+:106920002EF582748E3FF58312E95512204F900F99
+:106930002C74FFF0E5A8F9C2AF9007F5E02EF8A39C
+:10694000E03F8882F583E04AF0A3E04BF0E9A2E75C
+:1069500092AF02E753E0F8A3E0F583888222C333C5
+:10696000F8E433F99007F5E028FAA3E0398A82F5D4
+:1069700083228A828B83E0F8A3E0F9E8492274F647
+:10698000122051E9FDEA4B70047900801C780080E8
+:10699000118808EA2508F582EB3400F583E06D7074
+:1069A000E808E8C39C40EA790102E75374F2122038
+:1069B000518A09ECFEEDFF750800E9602714605963
+:1069C00014606E14700302EA7214700302EA8914F0
+:1069D000606F14700302EA9E14700302EAB9146037
+:1069E0007202EAD7EAC3941650297C167D0079001A
+:1069F0007A327B031210D785090C750D00780C12C2
+:106A00002264EEFCEFFD7A327B0312ED16121FF2C8
+:106A100002EADA75081802EADA7402650970F48E7F
+:106A2000828F8312ED0F900348E8F0A3E9F002EAA9
+:106A3000DA7401650970DC8E828F83E090034A80EE
+:106A4000EC7401650970CC8E828F83E0900E84F027
+:106A500002EADA7401650970BA8E828F83E0F9A2C6
+:106A6000E140B0900EBD12ECF37AC27B0E12075FCC
+:106A7000806874066509709B750C06750D00780CAE
+:106A80001222647A4B7B0380817408650970848EBE
+:106A9000828F837C877D0E7408121EEF803C740108
+:106AA0006509600302EA13900E9D12ECF37AA27B53
+:106AB0000E8E828F83E0F980B47401650960030251
+:106AC000EA13900EAD12ECF37AB27B0E8E828F83B6
+:106AD000E0F912075F8003750802A9087F0602210A
+:106AE0002374F41220517900EAA2E0501B7508CA01
+:106AF00075098E78081222647C0B7D007A8F7B0EDC
+:106B000012084F7402121FF27F04022123D083D097
+:106B100082020122C082C083E9A2E18A828B83E0E3
+:106B20005004D2E18002C2E1F0E9A2E3E05004D2D5
+:106B3000E38002C2E3F0E9A2E5E05004D2E580027E
+:106B4000C2E5F0742A5960098C828D83E0440C8080
+:106B50000AE970088C828D83E054F3F080AF74EE04
+:106B6000122051890E7412122045E0FEA3E0FF743A
+:106B700014122045E0F50AA3E0F50B741612204527
+:106B800012ED0F750900E8496005790B02ECDA8C0B
+:106B9000828D83E06402600302ECCD12ED0E8E82E2
+:106BA0008F83A3AA82AB83EC2406F50CED3400F5A9
+:106BB0000D88828983E0FCA3E0F9EC2400F510E461
+:106BC00039F51178101222A8002A04CDECD7EB1465
+:106BD000EC3CEC32EC4DEC850C82850D8312EEAA78
+:106BE000F508E50EC395085003850E08850A8285D1
+:106BF0000B83E508F0F50A750B00780A122264850C
+:106C00000C82850D8312ECF3EEFAEF12ED15121FD4
+:106C1000F202ECD812ECFF12ED0F850A82850B838D
+:106C20007402F0E88E828F83F0E98A828B83F0020F
+:106C3000ECD8850A82850B83740680B8850A828524
+:106C40000B837401F012ECFF12ECDF80E1850C8203
+:106C5000850D8312EEB7850A82850B83606B7408FD
+:106C6000F08882898312ECDFF088828983A3E08A2E
+:106C7000828B83F0E82402FAE93400FB8A828B835A
+:106C800012ECDFA3A3F08A828B83A312ECDFA3A311
+:106C9000A3F0E824040A0AE93400FB8A828B8312F9
+:106CA000ECE5F08A828B83A312ECE5A3F0E82406DE
+:106CB000F8E93400F98882898312ECF9F088828936
+:106CC00083A312ECF9A302EC2EE402EC2E850A82D7
+:106CD000850B83E4F0750901A9097F0A022123E0ED
+:106CE0008E828F832212ECE922E08E828F83A3A30F
+:106CF000A3A322E0FCA3E0FD2212ECE9A3A32285DA
+:106D00000C82850D83E0F8A3E0F583888222A3E05E
+:106D1000F8A3E0F922FB1210BF74022274EE1220D5
+:106D200051890F7412122045E0F50CA3E0F50D74A3
+:106D300014122045E0FEA3E0FF750E008C828D83C7
+:106D4000E06402600302EE9712ED0E88828983EC04
+:106D50002406F50AED3400F50B12EEA5F9EA24003D
+:106D6000F508E439F50978081222A8002A0397EEFD
+:106D700078EDF7ED5DEE2BEE850A82850B8312EE42
+:106D8000AAC39EE49F4024850F828582107511005E
+:106D9000EE2510F508EF3400F509C3E5089416E573
+:106DA000099400400C750E0D02EE9A750E0702EE66
+:106DB0009A7810122264AC0CAD0D850A82850B8383
+:106DC000E02EFAA3E03F12ED15121FF2850A82852C
+:106DD0000B83E02508F8A3E035098882F583E412E7
+:106DE000EEB3700302EE9A12EEBF700302EE9A79D0
+:106DF0000012204F02EE9AEE4F702B7402650F7056
+:106E0000A4850C82850D8312EEA5F9EAF812EE9F97
+:106E1000F5838A82E8F0A3E912EEB3607D12EEBF3B
+:106E20006078790180CB750E0B806F90034AE0701B
+:106E300005750E038064EE4F70EC7406650F6003F9
+:106E400002EDA57508067509007808122264AC0CDD
+:106E5000AD0D12EE9F12ED15121FF2803D900E84C3
+:106E6000E0A2E350CCEE4F70BD7401650F600302E9
+:106E7000EDA5850C82850D83E0F8600A74016860D9
+:106E800005750E808014E8C0E0850A82850B8312A8
+:106E9000ED05D0E0F08003750E01A90E02ECDA8555
+:106EA0000A82850B83E0FAA3E02212EEA5FB121002
+:106EB000B9EA22F0900330E0F8A3E0F9E84922E0D3
+:106EC000F5838882E0F8A3E0F988828983E582452A
+:106ED0008322C082C083120E13120E19120E1F12CB
+:106EE0000E0D02F25EC082C0839061B1E0C2E0F09C
+:106EF000E0D2E0F0906188E0640470F802F25EC0D5
+:106F000082C0839061B1E0C2E0F09061F3E4F09060
+:106F100061F2F0F8F912EF5F9061F012EF9A94FECF
+:106F2000E9940D40F002F25EC082C0839061F3E408
+:106F3000F09061F2F0F8F99061F0E0FA12EF5F6A18
+:106F4000700A12EF9F94FEE9940D40EB74FE687096
+:106F500003740D69700479008002790102F25E7495
+:106F60000028F582748039F583E022C082C08390C6
+:106F700061C0E0FAE4F0F8F9E82400F582E9346051
+:106F8000F583E412EF9A9480E9940140EBEA906172
+:106F9000C0F090618A740102F259F012EF9F22E86A
+:106FA000240108E93400F9C3E822C082C0838A8240
+:106FB0008B83E090601612F1FDA3E090601712F051
+:106FC0002690601812F02F90601912F03490601A19
+:106FD00012F03990601BF0E99060157005E0C2E096
+:106FE0008003E0D2E002F25DC082C0838A828B839C
+:106FF000E090601C12F1FDA3E090601D12F026905D
+:10700000601E12F02F90601F12F03490602012F07A
+:1070100039906021F0E99060157005E0C2E18003CD
+:10702000E0D2E102F25DF08A828B83A3A3E0221218
+:10703000F044E02212F03FE02212F03FA3E02212DF
+:10704000F044A322F08A828B83A3A3A32274F012BC
+:107050002051EA906005F0EBA3F0ECA3F07F08026A
+:107060002123C082C083906001E002F0F3C082C09F
+:107070008374075990600102F25DC082C08374017D
+:10708000699060037005E0D2E08003E0C2E002F2A4
+:107090005DC082C083906003E054F94902F25DC094
+:1070A00082C083906061E002F0F3C082C083906090
+:1070B00008740B02F25D74F01220519061947420F8
+:1070C000F0EAA312F25002F05BC082C083E9906044
+:1070D0000402F25DC082C0839007CBE4F09060228E
+:1070E000F0A3F0A37830F0A3D8FC02F25EF07F02A8
+:1070F000022123F902F25E74F4122051EAFEEBFF42
+:1071000089088C099007CBE0640870047903807EBD
+:10711000120EC7E9F46004790080737900750A01E2
+:10712000750B00E9780A121FC9AC0A906022E05C76
+:107130007053E04C12F193FA74603BFB78068E8238
+:107140008F8312F21F8E828F83A3AE82AF838A82D7
+:107150008B83A3AA82AB8318E870E3E508700AEC7E
+:10716000F4F8906023E0588005906023E04CF090A4
+:1071700007CBE004F0740165097005120E79809761
+:10718000120E7F809209E9C39408409179017F042F
+:10719000022123F0E975F006A4FAABF074242A2248
+:1071A000C082C083906014E054FCF0E04902F25DBC
+:1071B00074F6122051750801750900E97808121F4C
+:1071C000C9906009E0450802F0ED74F6122051758F
+:1071D0000801750900E97808121FC9E508F4F8905C
+:1071E0006009E05802F0EDC082C083906009E402BB
+:1071F000F25D3400F583E0229061C07401F08A8270
+:107200008B8322C082C0837A007B60E970027A336C
+:1072100012F1F8E4F0A3F0A3F09061C002F25D1265
+:10722000F2232212F2DEF022C082C083E9906002D3
+:10723000802BC082C083E99060027005E0D2E380B9
+:1072400003E0C2E38017C082C083E99061C6800D6D
+:10725000F0EBA3F0ECA3F0ED22F0A3F0A3F0D083C9
+:10726000D082020122C082C083E9601714601C141E
+:10727000602114602614602B146030146036146092
+:107280003C80419061E9E054FC80389061E9E0D2B3
+:10729000E080309061E9E0C2E080289061E9E0D2CE
+:1072A000E180209061E9E0C2E180189061E9E0C2EC
+:1072B000E1F080DA9061E9E0C2E0F080E19061E91C
+:1072C000E04403F0809875E19302012275E18302A6
+:1072D000012275E18502012275E182020122E08A24
+:1072E000828B8322C082C083E9C3332417906184D8
+:1072F000F074016A70079061A6740A8017E9C3945C
+:1073000014E0500904F09061A67425800714F090F1
+:1073100061A6740F02F25D74F5122051890A79009A
+:10732000750801750900E97808121FC9906022E00C
+:1073300055086052E975F006A4FCADF074242CFCED
+:1073400074603DFD750800850882AE82EC2EF582E2
+:10735000ED12F1F2F8EA2EF582EB12F1F268700903
+:107360000508E508C3940640DE74066508701790AA
+:107370006023E0F508750900E97808121FAAE508FE
+:107380005401650A600909E9C39408409379FF7FB5
+:1073900003022123C082C083C3EA9426EB940050E9
+:1073A0001674FF6C700374FF6D600C12F3D8ECF070
+:1073B000A3EDF079008002790202F591C082C083CA
+:1073C000C3EA9426EB9400500812F3D812F4838099
+:1073D000047AFF7BFF02F591EAC333FAEB33FB74C7
+:1073E0002E2AF582740E3BF5832274F7122051E9A0
+:1073F000FEEAFF7C107D0079007A067B031210D72D
+:10740000EE900E2DF0EF900301F0120909E99003C0
+:107410000670057401F08004E4F079127F01022106
+:107420002374F7122051EAFEEBFFECFAEDFB74092E
+:1074300012204512F65590030BE8F0A3E9F09003F3
+:1074400009EAF0A3EBF0900307EEF0A3EFF07C1055
+:107450007900121137E9640170087910900309125C
+:10746000F47C7C107900EEFAEFFB121137E964012D
+:107470007008791090030712F47C80A012F4831234
+:107480000F0F22E0FAA3E0FB2274F6122051E9FF6D
+:107490007E00701CEA4B60187508068E0978081289
+:1074A0002264EAFCEBFD7A0D7B0312F82D121FF229
+:1074B000900306E0640170130EEF70087402F0127E
+:1074C00009158007E4F0EFF912063FEEF97F02029A
+:1074D000212374F71220517E00EA4B603B8A828B95
+:1074E00083E0701212F654900313E8F0A3E912F847
+:1074F00033E0900315F0900306E06402701A0E8AE0
+:10750000828B83E0900306700474038001E4F08AA8
+:10751000828B83E0F912063FEEF902F41C74F61236
+:107520002051900302E0602E750806750900780866
+:10753000122264EAFCEBFD7A167B0312F82D121F6F
+:10754000F27A167B03900302E0F91206037A167BA7
+:107550000312091B8002790002F4CDC082C083E9C6
+:10756000F87900EA4B6025E86022EA2405F582EB11
+:107570003400F5837401687005E044C0800CE05469
+:107580003FF07403687004E0D2E6F009800312F45F
+:1075900083D083D082020122C082C083EA4B602460
+:1075A000E960218A828B83A3A3A3A3A3E054C0F83C
+:1075B00074C06870047901800B74406870047903AA
+:1075C0008002790280CB74F41220518908900E2D2C
+:1075D000E0F4603A7A0A12F815603312F65B740828
+:1075E000F0900302E08E828F83A3A3A3F0750A06B6
+:1075F000750B00780A1222647C167D0312F825129E
+:107600001FF2EEFAEFFB900E2DE0F91210EF90034F
+:1076100005E06401703990032C12F655E8496018B2
+:10762000E0F5838882A3A3A312F65488828983E5B8
+:10763000824583600312204F908F7E1222777A0456
+:107640007B0090032BE0F912118B7404121FF27F60
+:1076500004022123A3E0F8A3E0F9228E828F837431
+:10766000D0F0A3E508F08E828F83A3A322C082C04E
+:107670008390030902F58EC082C08312F6AB121EFE
+:10768000CA02F59174F4122051908F767808121E78
+:10769000AC12F6AB7808121E4B900E2DE0F4600988
+:1076A0007A007B40E0F912111380A490030BE0F8FC
+:1076B000A3E0F58388822274EE1220517412122006
+:1076C00045780C121EAC120AB98A088B09EA4509E2
+:1076D000700302F774EA241DF8EB3400F9E8FEE9C0
+:1076E000FF8E828F83780C121EBB7A257B001205D9
+:1076F000DFEAF50A7009850882850983E0F50A8EBC
+:10770000828F83780C121EAC850882850983A3A31F
+:10771000A3A3E0F50B7A0E7B001210E38A108B1105
+:10772000AE10AF11EE4F604C8E828F8374D0F0A3F9
+:10773000E412F665740912F665A3E50BF075100600
+:107740007511007810122264E5082405FCE509345F
+:1077500000FD12F825121FF28E828F83A3A3A3A32C
+:10776000A3A3A3A3A3A3780C121EBBEEFAEFFBA95D
+:107770000A1210EF7F0A022123C082C08390030205
+:10778000E0F902F591C082C0837A0D7B03E9700AAB
+:10779000900302E060047A167B0302F591C082C078
+:1077A0008390030702F58E74F41220518908900E1D
+:1077B0002DE0F4605D7A0C12F815605612F65BE469
+:1077C000F0750A06F50B780A1222647C0D7D03EE33
+:1077D00024030A0A0A12F829121FF290031312F660
+:1077E000558E828F83A3A3A3A3A3A3A3A3A3E8F08F
+:1077F000A3E9F0900315E0C0E0EE240BF582EF342E
+:1078000000F583D0E0F0EEFAEFFB900E2DE0F912D8
+:1078100010EF02F64F7B001210E38A0A8B0BAE0AC0
+:10782000AF0BEE4F22EE2404FAEF3400FB1210BF30
+:10783000740222F08A828B83A3A3A32274F61220FF
+:107840005174FF121FDC43F10243F4C075F88075D8
+:10785000FB8053FF3F43FF4075D6889009AF74709B
+:10786000F0A374F9F09009B3E0541FF09009B574D7
+:10787000D0F0A3E0540F4410F074099009B1F0A3C4
+:1078800074C1F09009B4742CF09009B37401F090B5
+:1078900009B67412F09070F9E0851882851983F0AA
+:1078A00053D1F775D6087508587509027808122261
+:1078B00064E5FAF4FC7D007AC17B0912147F74023E
+:1078C000121FF27401121FF28004EEFAEFFB7F0226
+:1078D000022123C082C083EA241BF582EB3400F529
+:1078E0008312FB5A900C52E8F0A3E9F08A828B8352
+:1078F000A3E0F87407686014740868600F74036884
+:10790000600A7404686005740A68700575FAD880A6
+:107910000375FA3BE0602614602814602A1460277F
+:1079200024FE600F14601114601314601524FE60AF
+:1079300020801975FC06801C75FC07801775FC08F3
+:10794000801275FC09800D75FC0A800875FC0B809F
+:107950000375FC0C8A828B83A3A3E0600875FB424D
+:1079600043F410800375FB0275F8C0E5FBA2E650F6
+:1079700005C29543FE20D2EAD083D0820201227450
+:10798000F61220517E007F00803888828983E08A49
+:10799000828B83F0A3AA82AB83E5FAF4F50912F98E
+:1079A000F2F582740939F583E4F0A3E509F012FBDE
+:1079B000604007900C19E4F0A3F0EE24010EEF34C0
+:1079C00000FFC3EE9CEF9D501212F9F2F8740939D2
+:1079D000F988828983A3E065FA60AFE5FBA2E650EF
+:1079E0000E121335C3EA942BEB94015002C2950298
+:1079F000F8CA900C1912F9F922E0F8A3E0F9E8C3EB
+:107A000033F8E933F974C1282274F7122051900C2D
+:107A100050E0FF8F82A882900C4FE0FEEFC39EE003
+:107A20005018C398F895E0F9E824FF18E934FFF9F5
+:107A3000E849701B780079008029C398F895E0F92F
+:107A4000E82431F8E93400F9C3E89CE99D50E57A6F
+:107A5000007B00804DE004F0439A08E8240108E927
+:107A60003400F9C3E89CE99D50348A828B83E0C0DE
+:107A7000E0900C50E0FE741D2EF582740C3400F57D
+:107A800083D0E0F08A828B83A3AA82AB83900C51CF
+:107A9000E4F0900C50E0C3943140BAE480B9ECFAC1
+:107AA000EDFB02FC9E74F61220517E00900C191220
+:107AB000FB7C604F900C5412FB7C702D12FB6040DD
+:107AC00007900C19E4F0A3F0900C19E0FAA3E0FB86
+:107AD000EAF8EBF912FC5670E3900C54EAF0A3EBD1
+:107AE000F0900C1BEAF0A3EBF0900C5412FB729098
+:107AF0000C54C3E0942CA3E094014007900C54E490
+:107B0000F0A3F01213358A088B09A808A909E849DF
+:107B100060217E04C3E8941CE9940140030E8013A5
+:107B2000C3E8942BE99401400A0E0EE5FBA2E6504F
+:107B300002D295900C51E06006E4F0EED2E4FEEE45
+:107B40006015A312FB5A88828983E582458360070A
+:107B5000EEFA790112204F02F8CEE0F8A3E0F92204
+:107B6000900C1912FB72900C19C3E0942CA3E094B2
+:107B70000122E02401F0A3E03400F02212F9F9F52B
+:107B800082740939F583A3E065FA2274F612205154
+:107B9000900C1B12FB5A900C19E0FCA3E0FDE8FAD4
+:107BA000E9FBEAC333FAEB33FB74C12AF5827409AB
+:107BB0003BF583A3E065FA701DE8240108E9340071
+:107BC000F9C3E8942CE99401400478007900EC684A
+:107BD0007002ED6970C8900C1BE8F0A3E9F0E8C3EF
+:107BE0009CFEE99DFFEE4F705912FC567065ECFA51
+:107BF000EDFBEA24FFF8EB34FFF9EA4B7004782B35
+:107C0000790112FC5670357508587509027808120A
+:107C10002264E5FAF4FC7D007AC17B0912147F74BA
+:107C200002121FF2900C1912FB5A900C54E8F0A3A8
+:107C3000E9F0900C1BE8F0A3E9F080177E017F00CB
+:107C40008011C3EE942DEF94014008EE242CFEEF3A
+:107C50003401FF02F8CAE8C333F8E933F974C128E4
+:107C6000F582740939F583A3E065FA22C082C083E6
+:107C700012131702F97874F7122051E9FE74016E9D
+:107C8000700312131D7900801574F7122051E9FE5C
+:107C900074016E700512132380047A007B007F014B
+:107CA00002212374F7122051E9FE74016E7005124F
+:107CB000132980047A007B0080E4C082C083121301
+:107CC0002F02F97874F7122051E9FE74016E7005E5
+:107CD00012133580047A007B0080C302012274F401
+:107CE0001220518A087E007C677D097AFF7BFF1293
+:107CF00008CD7C7A7D097AFF7BFF1208CD7AC37BA1
+:107D000012120AA7E508A2E0501D7508EE75098E4B
+:107D100078081222647C0B7D007AD67B1012084F03
+:107D20007402121FF2E9FEEEF97F0402212374F4BB
+:107D3000122051EAFF7E00E9600F146027147003DF
+:107D400002FDEC14606602FE0874046F7011750A7F
+:107D5000048E0B780A1222647ACF7B1002FE027E18
+:107D60001802FE0874116F70F6750A118E0B780AEE
+:107D70001222647A567B0912FE0B121FF27509FF5C
+:107D80007809122268750A0B780A122264750AD6DD
+:107D9000750B10780A12226479007C567D097A6787
+:107DA0007B091208E57405121FF2805C74076F707E
+:107DB000AE750A078E0B780A1222647A737B091259
+:107DC000FE0B121FF27509FF7809122268750A0B63
+:107DD000780A122264750AD6750B10780A1222648A
+:107DE00079007C737D097A7A7B0980B674106F60A4
+:107DF0000302FD5F750A108E0B780A1222647A86E0
+:107E00007B0912FE0B121FF202FD271210BF740233
+:107E10002274F4122051740C122045E0FAA3E0FB06
+:107E2000740E122045E0F8A3E0F9E8FEE9FF7508BA
+:107E3000008C828D83A3A3A3E0A2E45005790802FD
+:107E4000FED38C828D83E06402707D12FF36EC24B9
+:107E500006F8ED3400F9E8FCE9FDE0F50AA3E0F9E5
+:107E6000E50A2400E439F50B780A1222EE0000043A
+:107E700000082AADFE672AA5FE692AB5FE6A2A8394
+:107E8000FEBDFE8E828F837404F0F50A750B0078B8
+:107E90000A1222648C828D83E0FCA3E0FD12FE0BAB
+:107EA000121FF2802C8E828F83741180DC8E828F61
+:107EB00083740780D48E828F83741080CC8E828FDF
+:107EC00083E4F075080A80098E828F83E4F07508D8
+:107ED00001A90802FD2974F2122051E9FE740E1264
+:107EE0002045E0F50AA3E0F50B7410122045E0F5FB
+:107EF00008A3E0F5098C828D8312FF36E0F50CA310
+:107F0000E0F9A80C74026870037429697021750C7B
+:107F100001750D00780C1222647808122264780A28
+:107F2000122264EEF91208DF7406121FF280027941
+:107F30000A7F06022123A3E0F8A3E0F9888289835F
+:107F40002274F7122051EAFEEBFF890874FE6E706E
+:107F50000374FF6F602A74016508600E740265087F
+:107F6000701E7901120AC5E970167C677D09EEFA68
+:107F7000EFFB1208CD7C7A7D09EEFAEFFB1208CDFB
+:107F80007F01022123C082C083E99009BFF0D08322
+:107F9000D082020122C082C0831212C91212DB12E7
+:107FA00012D512133B80E774F6122051EAFEEBFF64
+:107FB0005480601980031210E99009BFE0F9121093
+:107FC000FBEA4B70F1EEFAEF6480FB8019EE54206F
+:107FD0006006EE6420FA800EEE54106005EE641028
+:107FE00080F37A007B007F02022123C082C08312CB
+:0A7FF0001353809A020122020122BD
+:10800000C082C08312136502837E74F512205174FE
+:10801000FC121FDC851882851983EAF0A3EBF08936
+:108020000AECFEEDFF740F122045E0F508A3E0F521
+:108030000990039EE064017005790C0280CB8518DD
+:1080400082851983E0FA120B5BE960277402122023
+:10805000457401F0A3E4F07402122045AC82AD83B4
+:10806000851882851983AA82AB83790112099F79C9
+:10807000028058EE4F602FE5084509602985188277
+:10808000851983A3E0701F7808122264EEFCEFFDCF
+:10809000A90A7402122045E0FAA3E0FB12096F74EA
+:1080A00002121FF2802574021220457401F0A3E42D
+:1080B000F07402122045AC82AD8385188285198345
+:1080C000AA82AB83790112099F79127404121FF2FC
+:1080D0007F0302212374F7122051120B2B7A067BA7
+:1080E000041209B179000283917900740902837B3B
+:1080F000C082C08374F9121FDC7401122045AA8269
+:10810000AB83120AF512828879077A097B101282F2
+:1081100082740702837B74F712205174FC121FDCF7
+:10812000EAFEEBFF7403122045AC82AD83120B25EF
+:10813000E9851882851983F07401122045EEF074E8
+:108140000212204512814E7A057B1402836EEF12D3
+:1081500082C27904227B20028378C082C08374FCAF
+:10816000121FDC851882851983E4F00412204574FF
+:108170001BF07402122045E4F074031220457404CD
+:108180001282BEF97A027B201209A57900740402DA
+:10819000837BC082C08374FF121FDCEA4B600C1229
+:1081A0000AFBE9851882851983800885188285195C
+:1081B00083741212827A7A0502815574F412205166
+:1081C00074FF121FDCE9FE740D122045E0F9740EF5
+:1081D000122045E0FF740F122045E0F508A3E0F5FA
+:1081E000097411122045E0F50A7412122045E0F5D9
+:1081F0000B780B122268780A12226878081222641F
+:10820000EFF5087808122268E9F508780812226864
+:10821000EEF9120B377406121FF21282737A067B84
+:108220002012822C121FF27F040221231209A57949
+:108230000074012274F712205174FF121FDC120B1C
+:108240003D1282737A0802838574F712205174FFFD
+:10825000121FDC120B491282737A0902838574F7AC
+:1082600012205174FF121FDC120B431282737A0A20
+:10827000028385E9851882851983F0AC82AD837904
+:1082800001221209A5790022E9851882851983F057
+:10829000AC82AD8322C082C08374FF121FDC120B3C
+:1082A000011282737A1002815574F712205174FF03
+:1082B000121FDC120B071282737A1102838512825D
+:1082C000C2221282C622F0851882851983AC82AD43
+:1082D0008322121FF27F02022123C082C08374F71F
+:1082E000121FDC79087401122045AA82AB83120B9D
+:1082F00013E9851882851983F0640D6014E0AC825F
+:10830000AD8370047909800279017A187B20120903
+:10831000A50280E974F712205174FD121FDCEAFEF9
+:10832000EBFF120B4FE9851882851983F074011257
+:108330002045EEF07402122045EF1283AC0283A0B8
+:1083400074F712205174FD121FDCEAFEEBFF120BD2
+:1083500055E9851882851983F07401122045EEF0E5
+:108360007402122045EF1283967A1B0283A0120931
+:10837000A57900740402838E12822C121FF2D0831E
+:10838000D0820201227B201209A579007401121FFC
+:10839000F27F0102212312839A221282C6790322DC
+:1083A0007B201209A57900740302838E12839A7AC6
+:1083B0001A22740302837B74F612205174F7121F81
+:1083C000DC851882851983E4F0750808F5097808BA
+:1083D000122264EAFCEBFD7403122045AA82AB83EF
+:1083E0001210BF7402121FF2851882851983AC82A5
+:1083F000AD8379097A187B201209A574090282D20B
+:10840000C082C08374FD121FDC851882851983E445
+:10841000F0041220457404F07402122045E4128323
+:1084200096FA7BFC1209AB0283B2C082C08374FD52
+:10843000121FDC8518828519837401F0122045749F
+:1084400004F07402122045E41283967A0180D3C0AE
+:1084500082C08374FD121FDC85188285198374160F
+:10846000F074011220457404F07402122045E412E5
+:1084700083967A1602842274F6122051E99003CE74
+:10848000F07A00EA75F003A4F8A9F074CF28F58219
+:10849000740339F583E4F0A3F00AEAC3940440E3DB
+:1084A0007A008A0875090074037808121FC974DB02
+:1084B0002508F874033509F988828983A3E4F0A3B9
+:1084C000F088828983F0A3A3A3A3A3A3A374FFF0DE
+:1084D0000AEAC3940340CB9003CEE0F91210AD7FBB
+:1084E0000202212374F41220518A088B09EB548074
+:1084F00060349003CEE0F91210FB8A0A8B0BA80AB5
+:10850000A90BE8FEE9FFE84960138E828F83E064DF
+:10851000907003120A17EEFAEFFB1210E9AA08E5B1
+:10852000096480FB80047A007B007F0402212374AD
+:10853000F712205174FA121FDCEAFEEBFFEEFCEF9B
+:10854000FD851882851983AA82AB83120A47E9FA4E
+:1085500074021220451288C54970030285FE8E827E
+:108560008F83A3A3E0FAA3E0FB851882851983E03B
+:1085700064057002A3E08518828519837009AC82B6
+:10858000AD83120A1D807CE064047002A3E0601ECB
+:10859000851882851983E064067002A3E0600F8568
+:1085A0001882851983E064077002A3E0705585186E
+:1085B000828519831288C575F003A4F8ACF075F0B4
+:1085C00003E9A42CF974CF28F8740339F9E824F4EA
+:1085D000F582E934FFF583E0FCA3E0FDEC4D602378
+:1085E000851882851983AC82AD83E824F6F582E98B
+:1085F00034FFF583E0F9120A6BE97007801C7401FF
+:108600006A70178E828F83A3A3A3A3A3A3A3E0FA08
+:10861000A3E0FBEA4B600312136B7406121FF27F98
+:108620000102212374F412205174F6121FDC8A0A0D
+:108630008B0BEC2404FEED3400FF8E828F83C3E0AD
+:108640009404A3E0940050030286D4EC2402F508BD
+:10865000ED3400F509850882F583E0FCA3E0FD8593
+:108660001882851983AA82AB83120A2F7402122002
+:1086700045E0F8A3E0F9C3E89418E9940050728E3D
+:10868000828F83E82404F8E93400F9E0687003A3DA
+:10869000E0697039850882850983E02404F508A320
+:1086A000E03400F509851882851983E0A2E0780896
+:1086B000502A1222647402122045AC82AD83AA0AA9
+:1086C000AB0B120A237402121FF2E96007AA0AAB6D
+:1086D0000B120A95740A121FF202852A1222647480
+:1086E00002122045AC82AD83AA0AAB0B120A298084
+:1086F000D474041220457401F0A3E4F0740612202F
+:10870000457417F0A3E4F07404122045AC82AD83E5
+:108710007401122045E0F9AA0AAB0B1209FF80B4DC
+:1087200074F012205174F4121FDC8A0A8B0B8C082F
+:108730008D09741C122045E0F50CA3E0F50D8C8228
+:108740008D83A3E0F9120A838A0E8B0FAE0EAF0F52
+:10875000EE4F700579000288008E828F83A3A3A359
+:10876000E4F0850882850983E014600624EE601930
+:1087700080E2A3A312227BAC0CAD0D740212204543
+:10878000AA82AB83120A5380248E828F83E0640313
+:1087900070C2850882850983A3A312227BAC0CAD2D
+:1087A0000D7402122045AA82AB83120A657402126C
+:1087B0001FF2E9F50CEEFAEFFB120A8985188285A3
+:1087C000198385820E85830F780E122264750D0041
+:1087D000780D122268850882850983E0FDAC0CAA19
+:1087E0000AAB0B8E828F83A3A3A3A3A3A3E0F912EA
+:1087F0000A717403121FF2EEFAEFFB120A7DA90C44
+:10880000740C121FF27F0802212374F1122051749C
+:10881000EE121FDC8A0A8B0BECFEEDFF7421122096
+:1088200045E0FCA3E0FD750E008E828F83A3858258
+:10883000088583098E828F83E06412705DA3A31282
+:10884000227B7408122045AA82AB83120A5F74024D
+:10885000121FF2E9F50E70619003D21288C54960CB
+:1088600058740612204585820C85830D780C1222DF
+:1088700064850882850983E0F50878081222688EED
+:10888000828F83E0FD7C00AA0AAB0B9003D4E0F951
+:10889000120A717403121FF2801F851882851983D2
+:1088A000E4F0A3F0851882851983AC82AD83850836
+:1088B00082850983E0F91209FFA90E7412121FF2D2
+:1088C0007F07022123E0F8A3E0F9E822C082C083F9
+:1088D000908F42121ECA9007F1121ED60289F874B8
+:1088E000EE12205189088A0A8B0B741212204578E7
+:1088F0000C121EAC1211798A108B11AE10AF11EE52
+:108900004F600E8E828F83A3A3780C121EBB028948
+:108910009E7A0D7B0012114F8A108B11AE10AF1191
+:10892000EE4F60768E828F83A3A3A3A3A3A3A3A3FA
+:10893000E508F08E828F83A3A3A3A3A3A3E50AF087
+:10894000A3E50BF08E828F83A3A3780C121EBB8E3F
+:10895000828F83E4F0A3F0908F42121ECA8E828F22
+:1089600083A3A3A3A3A3A3A3A3A3121ED69007EF3D
+:10897000128CF99007EF6017E0FAA3E08003E8FAA1
+:10898000E9FB8A828B83128CF970F38A828B83EEE7
+:10899000F0A3EFF0EEFAEFFB80047A007B007F0A91
+:1089A000022123C082C0839007EF80048C828D83D4
+:1089B000E0FCA3E0FDEC4D60238C828D83A3A3A398
+:1089C000A3A3A3E06A7003A3E06B70E08C828D83A5
+:1089D000A3A3A3A3A3A3A3A3E06970D0ECFAEDFB28
+:1089E0008016C082C083EA4B600E8A828B83A3A369
+:1089F000A3A3A3A3E4F0A3F0D083D0820201227446
+:108A0000F4122051740C1220457808121EACE5A80F
+:108A1000FFC2AF78081222601211737404121FF2A1
+:108A20008B09A909EFA2E792AFEA496004790080B7
+:108A30000279087F0402212374F2122051740E126D
+:108A400020457808121EACA2AFE433FFC2AF78080D
+:108A50001222601211737404121FF2EA4B60128A20
+:108A6000828B83A3A3A3A3A3A3A3A3A37808121E0B
+:108A7000BBEFA2E092AFEA4B600479008002790874
+:108A80007F0602212374F4122051A2AFE433F509CA
+:108A9000C2AF1211798A0A8B0BAE0AAF0BEE4F6090
+:108AA0000312117FE509A2E092AFEE4F6004790056
+:108AB00080027906028A3374F2122051908F427834
+:108AC00008121EACA2AFE433FFC2AF1211798A8242
+:108AD0008B83E58245836007A3A37808121EACEF61
+:108AE000A2E092AFAA08AB09AC0AAD0B809274E881
+:108AF00012205174FB121FDC8A088B098C0A8D0B23
+:108B000074011220457808121EBBE5A8F9C2AF9087
+:108B100007F17808121E4BE9A2E792AF9007EF1217
+:108B20008CF97003028CE99007EFE0FEA3E0FF757B
+:108B30001200751300750800750900A2AFE43385B3
+:108B40001882851983F0C2AFEE2402F510EF3400CD
+:108B5000F511EE2402F50AEF3400F50B7403122030
+:108B600045128CF970207402122045E070187401CF
+:108B7000122045E0F8850A82850B83E0C398400601
+:108B8000E0C398F080457401122045C082C08385FF
+:108B90001082851183780C121EACD083D082780CA1
+:108BA0001214EE50177401122045780C121EAC8579
+:108BB0001082851183780C121E72800F908F4212E2
+:108BC0001ECA851082851183121ED6EE2404F51666
+:108BD000EF3400F517128CF3705F851682851783CA
+:108BE000128CF97059EE2409F514EF3400F515854F
+:108BF0001482F583780C121EACE50C450D450E452C
+:108C00000F60558E828F83A3A3A3A3A3A3E0FAA32F
+:108C1000E0FBEA4B60428E828F83A3A3A3A3A3A3AE
+:108C2000A3A3E0F9121113851482851583121ECABD
+:108C3000851082851183121ED6128CF3700B851657
+:108C400082851783128CF9600F8E828F83A3A3A372
+:108C5000A3A3A3128CF970258E828F83E0F8A3E082
+:108C6000F9E512451370059007EF8006851282859D
+:108C70001383E8F0A3E9F08E088F0980048E128F29
+:108C8000138E828F83E0FEA3E0FF8518828519830F
+:108C9000E0A2E092AFE508450960478508828509B2
+:108CA00083A3A3128CF97033850882850983A3A35B
+:108CB000A3A3128CF97024850882850983A3A3A33A
+:108CC000A3A3A3E0FAA3E0FB850882850983A3A3FD
+:108CD000A3A3A3A3A3A3E0F9121113AA08AB09123B
+:108CE0001155EE4F6003028B357405121FF27F1091
+:108CF000022123850A82850B83E0F8A3E0F9E84985
+:108D00002274F11220518A0A8B0B8908ECFEEDFFC8
+:108D1000740F122045E0FCA3E0FD9003C4E0F50EC3
+:108D2000FA8A0C750D007403780C121FC974A32500
+:108D30000CF87403350DF9880C890D8882F583E0F1
+:108D40007072EA128EF7121F49EA9003C4F0850E82
+:108D50000974FF6509605D850C82850D837401F0DF
+:108D6000A3E50AF0A3E50B128DC0E508128DC0A3A0
+:108D7000EEF0A3EFF0ECF8EDF9850C82850D83A3FE
+:108D8000A3A3A3A3A3E8F0A3E9F09003C3E0F50A2B
+:108D9000750B007403780A121FC974A3250AF582A3
+:108DA0007403350BF583E06402600579FF120975E1
+:108DB00079008007790112099979077F0702212339
+:108DC000F0850C82850D83A3A3A32274F612205193
+:108DD00074FE121FDCE9FE802385188285198374D6
+:108DE00001F0A3E4F0851882851983AC82AD837904
+:108DF0000112099F9003C3E0F912097B128E9112B0
+:108E00001FC9128E9FE8FCE9FD8C828D83E064010E
+:108E10007074A3AA82AB8374FF6E600B8E08E0654A
+:108E2000087002A3E0705F8C828D83A3A3A3E0F59A
+:108E30000878081222688C828D83A3A3A3A3E0F98B
+:108E40008C828D83A3A3A3A3A3A3E0FCA3E0FD8A4C
+:108E5000828B83E0FAA3E0FB120B317401121FF244
+:108E6000E9FC128E91121FC9128E9F88828983A3FA
+:108E7000AA82AB83EC7003028DD974076C700F88E3
+:108E80008289837402F07402121FF2028F61028DD4
+:108E9000D99003C3E0F5087509007403780822121D
+:108EA0008EA32274A32508F874033509F92274F5FA
+:108EB000122051890875090074037808121FC9121D
+:108EC0008F03E82406F8E93400F9E8FEE9FF8E8212
+:108ED0008F83E0FAA3E0FBEA4B600B12136B8E82E8
+:108EE0008F83E4F0A3F09003C3E0128EF7121F49C2
+:108EF000EAF07F030221232401F8E43400F97A0424
+:108F00007B0022128EA388828983E4F0A374FF126F
+:108F10008F19A3E4128F19F022F0A3F088828983BD
+:108F2000A3A3A32274F6122051E9FE9007D8E060B3
+:108F30000B8E08AA087B001208F78025E92405FAA1
+:108F4000E43400FB12114F8A088B09A808A909E82C
+:108F50004970067A007B008008E82405FAE93400AD
+:108F6000FB7F0202212374F21220518A088B09EC44
+:108F7000FEEDFF890A740E122045E0F50B90039F69
+:108F8000E06401701D9003A0E024FFF0A3E034FF33
+:108F9000F09003A0E0F8A3E0F9E849700579011228
+:108FA0000B1F9007D8E0604C7A097B001210E3EAAF
+:108FB0004B60388A828B837490F0A374FFF08A82AE
+:108FC0008B83A3A3E508F0A3E509129082E50B12B9
+:108FD000907DE50AF0A3E412907DA3A3EEF0A3EF49
+:108FE000F09007D8E0F91210EF807BEEFAEFFB1259
+:108FF000136B80727A047B001210E38A0C8B0DA82D
+:109000000CA90DEE24FBFAEF34FFFBE8496054880D
+:109010008289837401F0A374FFF0E82402FCE93430
+:1090200000FD8C828D83EAF0A3EBF08A828B83743F
+:1090300002F012906BE508F0E50BC454F0C0E0E5D7
+:1090400009F508D0E04508C0E012906BA3D0E0120B
+:10905000908CE50A12908CA3E4F0E8FAE9FB900703
+:10906000D580811211557F0602212312906F228C28
+:10907000828D83E0FAA3E0F5838A82A32212908294
+:10908000A322F08A828B83A3A3A3A322F012906F62
+:10909000A3A322C082C08374FC121FDC85188285C2
+:1090A0001983EAF0A3EBF074021220457401F0A3D7
+:1090B000E4F0EC4D60209003C3E0F912097B7402E8
+:1090C000122045AC82AD83851882851983AA82ABB4
+:1090D00083790112099F851882851983E0F91209A5
+:1090E000757404121FF2D083D082020122C082C0A4
+:1090F00083E9900E818004EAF0A3EBF0D083D08264
+:1091000002012274F7122051E990032BF0120AA1F8
+:1091100090032BE0F91210A77A057B0090032BE057
+:10912000F91209F37F0102212374F412205174FA19
+:10913000121FDC8A088B09EB5480604490032BE0FB
+:10914000F91210FB8A0A8B0BA80AA90BE8FEE9FFAB
+:10915000E8496019120741E9701D900E81E0F46042
+:1091600016EEFAEFFBE0F91210EFE9700AAA08E533
+:10917000096480FB029247EEFAEFFB1210E980EDE2
+:10918000EAA2E0501E90032E1293A3600C1293AB40
+:1091900060077A007B0012204FE5086401FAAB09F2
+:1091A0000292475402601890032C1293A3600A1293
+:1091B00093AB6005790112204FE508640280DEEA76
+:1091C0005404607F9003031293A36062900303E052
+:1091D00024FFF0A3E034FFF018F9E849705C1206B0
+:1091E0004BE960189003057401F090032C1293A3CF
+:1091F000600A1293AB6005790112204F85188285B1
+:109200001983AE82AF83120639EEFCEFFD120ECD4C
+:10921000851882851983AA82AB831205FD7A1D7B8E
+:10922000001205DF900303EAF0A3EBF0800C7A0450
+:109230007B0090032BE0F9121191E5086404FAAB6E
+:109240000980047A007B007406121FF27F04022159
+:1092500023C082C083120ACB0290FC74F612205104
+:1092600074FA121FDCEAFCEBFD7E01EC2402F8ED3F
+:109270003400F988088909EC24040808ED3400F961
+:10928000E8FAE9FB8C828D83E0246F600A24EF709A
+:1092900003029348029345A3E024FB601A24F7607D
+:1092A0000A14601D24D1605E029345ECFAEDFB12B6
+:1092B0000747E9FE029392ECFAEDFB12068D02934A
+:1092C000927F018A828B83E0F508A3E0F509780894
+:1092D0001222EE000002000D20E1921320E1920222
+:1092E000939003221293A3601A12939E60158A82B0
+:1092F0008B83E0FAA3E0FB8882898312204FE9FF89
+:1093000080011FEF80AD7F01850882850983E0140D
+:10931000600F146015147028ECFAEDFB12068780BC
+:1093200020ECFAEDFB120681801790032E1293A316
+:10933000600F1293AB600AECFAEDFB12204F800134
+:109340001FEFFE804D1E804A900301E0A2E2502AEA
+:10935000851882851983E4F0A3F085188285198326
+:10936000AC82AD838A828B83E0F98508828509838C
+:10937000E0FAA3E0FB1209FF80189003221293A3E6
+:10938000601012939E600B7AFF7BFF8882898312A4
+:10939000204FEEF97406121FF27F0202212312946D
+:1093A00095A3A3E0F8A3E0F9E84922129495A3A3BA
+:1093B0001294A22274F41220517508018A828B83C0
+:1093C000A3A3A3E0FEA3E0FF8E0A8F0B780A12226C
+:1093D000EE010008200A206A940700091018940280
+:1093E0002002940520F99306206A940B2039940CEE
+:1093F0002034940E2053947C94129484F912060F16
+:10940000807D8A828B83A3A3A3A3A3E0FAA3E0FBBE
+:109410001205F7E9F50880678A828B83A3A3A3A3CB
+:10942000A31294AAA3AA82AB8388828983E0F9124B
+:1094300005F180DF129484604690032E1293A3609E
+:109440003E12949B6039EAFCEBFDEEFAEFFB122032
+:109450004F80C09003221293A360241293AB601F2D
+:10946000EAFCEBFD7A0E7B2080E490032C1293A3A0
+:10947000600D12949B600812204F8097750800A918
+:109480000802924C8A828B83A3A3A3A3A3E0F8A330
+:10949000129495E022E0F58388822212949512942A
+:1094A000A2221294AAE582458322E0F8A3E0F9887B
+:1094B00082898322C082C08390032C0290F7C082ED
+:1094C000C083120DB375A70075A100759C7775C395
+:1094D0000075A20075A30075A40075A50075A6000F
+:1094E00075C31175A20075A30075A40075A500755C
+:1094F000A60075C33375A20075A30075A40075A5F9
+:109500000075A60075C34475A20075A30075A4007C
+:1095100075A50075A60075C32275A22075A34E75AA
+:10952000A40075A50075A600759408120DB94394A2
+:1095300002029635A2AFE433F8C2AF5394FEE5942D
+:10954000A2E240FAE8A2E0029758A2AFE433F8C2E0
+:10955000AF439401E594A2E250FA80E8E8A2E792D2
+:10956000AF801F75C303851882851983E0F5A27447
+:109570000122E8A2E792AF851882851983E0FAA359
+:10958000E0FB7402029632C082C08374FC121FDCBE
+:1095900012966B1295B0122045129665122045E086
+:1095A000F5A675A1EF43A710E8A2E792AF029630A7
+:1095B00075C330851882851983E0F5A4740122C033
+:1095C00082C08374FE121FDC1295E275A1FD129514
+:1095D00063122045E0F5A3E59C54F04401F59C029C
+:1095E000955C1295E953A7FD22851882851983EAB7
+:1095F000F0A3EBF0E5A8F8C2AF22E5A485188285B8
+:109600001983F0E5A5C0E07401122045D0E0F0E533
+:10961000A6C0E07402122045D0E0F0740312204589
+:10962000E4F0E8A2E792AF851882851983121ECA7A
+:109630007404121FF2D083D082020122C082C08340
+:1096400074FC121FDC12966B75A1EF1295B01220FC
+:1096500045129665122045E0F5A6E59C54F04404B9
+:10966000F59C0295A8E0F5A57402221296E0E5A803
+:10967000F8C2AF53A7EF2274F412205174FC121FEA
+:10968000DC1296DCA2AFE433F9C2AF53A7DF75A1B9
+:10969000DF851882851983C082C083908F62780825
+:1096A000121EACD083D08278081214A37005439C9C
+:1096B00070801A75C3401295B31220451296651238
+:1096C0002045E0F5A6E59C540F4450F59CE9A2E046
+:1096D00092AF7404121FF27F040221231296E0223B
+:1096E000851882851983EAF0A3EBF0A3ECF0A3EDD3
+:1096F000F022C082C08374FE121FDC851882851997
+:1097000083EAF0A3EBF0851882851983E0F8A3E0E3
+:10971000F9E8496016E5A8F8C2AF75C3001295666E
+:10972000122045E0F5A3E8A2E792AF029582E5A8F2
+:10973000C2AF53A7C9801CE5A8C2AF53A7C9759C87
+:10974000778010E5A8F8C2AFE59C54F04407F59C7B
+:10975000E8800375A1C9A2E792AF020122C082C0CE
+:1097600083E5A8F8C2AF75C311E5A28C828D83F0A2
+:10977000E5A31297C1A3A3A3E4F0E8A2E792AF0286
+:109780009635C082C08374FC121FDCE5A8F8C2AF16
+:1097900075C300E5A20295FAC082C08374FE121F51
+:1097A000DCE5A8F8C2AF75C300E5A285188285196B
+:1097B00083F0E5A3C0E07401122045D0E0F00295EB
+:1097C00072A3F0E5A48A828B83F0E5A5A3F0E5A659
+:1097D0008A828B83A3A3F08A828B8322C082C08378
+:1097E00074FE121FDCE5A8F8C2AFE5C3F975C3002B
+:1097F000E5A2E5A4851882851983F0E5A5C0E0748B
+:1098000001122045D0E0F089C302957274F612204F
+:10981000517508D075098E78081222647C137D007A
+:109820007A327B1012084F7402121FF27F0202215B
+:109830002374F4122051E97E008A8285820A8E0BFD
+:10984000600F24FE601E14602614602E14603680A3
+:109850003F780A1222647A647B081210BF740212E5
+:109860001FF2802E780A1222647A6C7B0880EB78D3
+:109870000A1222647A6E7B0880E0780A1222647AE7
+:109880008B7B0880D5780A1222647A8D7B0880CA87
+:109890000E0EEEF97F0402212374E81220518C0A87
+:1098A0008D0BE9FE7418122045E0FAA3E0FB741A50
+:1098B000122045E0F50EA3E0F50F741C122045E0E0
+:1098C000FCA3E0FD751600ECF87402C398FF741D4C
+:1098D000C398F9850A82850B83A3E0F510A3E0F510
+:1098E000117402C39CF508E49DF509E50A2406F508
+:1098F00012E50B3400F513741DC39CF50CE49DF5C3
+:109900000D8E8285820A851082851183E0F514A36D
+:10991000E0F511E5142400F51078101222EE000095
+:109920000900232A4899242A8A99252ABB99262A9C
+:10993000E899272A1E9A282A539A292A759A2A2AA8
+:10994000AA9A502ADF9A159BEC9408ED94004006E1
+:10995000751607029B207408129B3950048E1780DD
+:1099600008ECF87408C398F517850E82850F83E517
+:1099700017129B3012226474642CFC74083DFD1293
+:1099800010BF7402121FF2029B20EC9406ED9400AB
+:1099900050BE7406129B3950048E158008ECF87482
+:1099A00006C398F515850E82850F83E515129B3049
+:1099B00012226474F42CFC748E80C2EC9402ED9438
+:1099C00000508DC3EE9508E4950950048E14800272
+:1099D0008F14850E82850F83E514129B301222644A
+:1099E000746C2CFC74088095EC941DED940040037D
+:1099F000029950C3EE950CE4950D50048E1180022F
+:109A00008911850E82850F83E511129B3012226425
+:109A1000851282851383E02CFCA3E002997DEC94EF
+:109A200002ED94004003029950C3EE9508E49509B5
+:109A300050048E1080028F10850E82850F83E510F2
+:109A4000129B30122264851282851383E02CFCA3C2
+:109A5000E08093EC941DED94004003029950C3EE16
+:109A6000950CE4950D5003EE8001E9FFEF850E8221
+:109A7000850F838095EC9405ED9400400302995086
+:109A80007405129B3950048E088008ECF87405C3E5
+:109A900098F508850E82850F83E508129B27122210
+:109AA0006474002CFC748F02997DEC940EED94008C
+:109AB0004003029950740E129B3950048E0980089D
+:109AC000ECF8740EC398F509850E82850F83E509BD
+:109AD000129B2712226474AD2CFC748E02997DECCB
+:109AE0009407ED940040030299507407129B39408B
+:109AF00008ECF87407C398F50A850E82850F83E594
+:109B00000AF0F50C750D00780C122264742B2CFCF5
+:109B1000741002997D850E82850F83E4F075160A14
+:109B2000A9167F10022123F0F50A750B00780A228E
+:109B3000F0F508750900780822C39CF8E49DF9C384
+:109B4000EE98E4992274F61220517C117D0D7AFF73
+:109B50007BFF1208CD7508FA75098E780812226409
+:109B60007C047D007A5C7B1112084F7402121FF294
+:109B70007F02022123900D05E0F8A3E0F9E82274AA
+:109B8000F4122051E98A087E00704D740A6508704D
+:109B900043750A0A8E0B780A1222647A077B0D122B
+:109BA0009C81121FF27509FF7809122268750A0458
+:109BB000780A122264750A5C750B11780A12226405
+:109BC00079007C077D0D7A117B0D1208E574051272
+:109BD0001FF280067E1880020E0EEEF97F0402212D
+:109BE0002374F6122051E97E00701675080A8E095A
+:109BF00078081222647C077D0D129C81121FF2806E
+:109C0000020E0EEEF9029B7074F4122051740C12C5
+:109C10002045E0FAA3E0FB740E122045129B78FE6B
+:109C2000E9FF7410122045E0F8A3E0F9750800E898
+:109C3000496004790B80478C828D83A3129D9AE042
+:109C4000F50AA3E0F9A80A742B687003742A6970F6
+:109C5000288E828F83740AF0F50A750B00780A1239
+:109C600022648C828D83A3A3A3A3A3A3E0FCA3E01F
+:109C7000FD129C81121FF2800375080AA908029B3D
+:109C8000DC1210BF74022274EE12205174FE121FF7
+:109C9000DC8A088B09ECFEEDFF890A74141220455A
+:109CA000E0F50CA3E0F50D7416122045E0F50EA3C7
+:109CB000E0F50F750B008E828F83A3A3A3E0A2E5CE
+:109CC00050057908029D5F851882851983AC82ADA5
+:109CD00083EEFAEFFB121419E96401700479018034
+:109CE0007E851882851983E0F510A3E0F5117810C0
+:109CF0001222EE000002000229699D2B2A019D9587
+:109D00009DE50E450F700B740A650A600A750B0D10
+:109D1000804B750B0B804675080A75090078081290
+:109D20002264AC0CAD0D8E828F83A3A3A3A3A3A347
+:109D3000E0FAA3E0FB129C81121FF27A107B0079FB
+:109D40000A121113129B75496013E0F58388821281
+:109D50009D9AE58245836005790012204FA90B7416
+:109D600002121FF27F0A022123751001751100787B
+:109D700010122264780E122264780C122264A90A4E
+:109D8000EEFCEFFDAA08AB091208DF7406121FF201
+:109D9000E9F50B80C8750B0A80C3E0F8A3E0F988E9
+:109DA00082898322C082C08390035CEAF0A3EBF037
+:109DB000D083D08202012274F7122051E990035B14
+:109DC000F07A047B001209F31207717F010221234C
+:109DD00074F41220518A088B09EB5480603490038C
+:109DE0005BE0F91210FB8A0A8B0BA80AA90BE8FEAC
+:109DF000E9FFE84960138E828F83E064A07003124C
+:109E00000825EEFAEFFB1210E9AA08E5096480FBC9
+:109E100080047A007B007F0402212374F612205113
+:109E200074F5121FDCEAFEEBFF7404122045AC82CD
+:109E3000AD83120543E96003029EC8EE2402F508D3
+:109E4000EF3400F5097406122045E0A2E05021909D
+:109E5000035EE0F8A3E0F9E849606D740412204560
+:109E6000129EE690035FE0F583888212204F8058AF
+:109E700090035CE0F8A3E0F9E8496019740412204B
+:109E800045129EE690035DE0F583888212204FE93B
+:109E9000F87004803378067405122045E070297448
+:109EA00006122045E0851882851983F0740112207E
+:109EB00045E4F0A3F07403122045E8F0851882858C
+:109EC0001983129EE61204EF8E828F83A3A3A3A3AD
+:109ED000A3A3129EF0EA4B600312136B740B121FC4
+:109EE000F27F02022123AC82AD838508828509833B
+:109EF000E0FAA3E0FB2274EE122051890E8A0C8B4B
+:109F00000D8C0A8D0B7412122045E0F508A3E0F5C4
+:109F1000097A1E7B001210E38A108B11AE10AF116C
+:109F2000EE4F605C8E828F8374B0F0A3E50AF08EF2
+:109F3000828F83A3A3E50CF0A3E50DF08E828F83BF
+:109F4000A3A3A3A3E50BF0EE2405FAEF3400FBE591
+:109F50000845096019750C19750D00780C122264FA
+:109F6000AC08AD091210BF7402121FF280097C19EF
+:109F70007D0079001210D7EEFAEFFBA90E1210EF58
+:109F80007F0A02212374F4122051740C122045E040
+:109F9000F508A3E0F509740E122045E0F50AA3E0E8
+:109FA000F50B780A122264E50875F0E8A4C508A844
+:109FB000F075F003A428F875F0E8E509A428F50980
+:109FC000780812226412137D7404121FF2029E1686
+:109FD00074F7122051EAFEEBFFEE4F601A8E828F6B
+:109FE00083E0F974FF69600F74FE69600A121383DD
+:109FF0008E828F8374FFF0029DCBC082C083901D40
+:10A00000E0E4F0A3F0901DE274E2F0A37411F0908C
+:10A0100011E27448F0A37402F090142AF0A3748043
+:10A02000F0A374B4F0A37409F0D083D082020122AB
+:10A0300074F61220517A017B0012114FE5A8FEC27E
+:10A04000AFEA24FEF8EB34FFF9901DE2E8F0A3E953
+:10A05000F01211559007E77401F0EEA2E792AF7F7E
+:10A060000202212374F21220517C007D008C09EA47
+:10A0700024020A0AEB3400FBA2AFE433F508C2AFB6
+:10A080009007E7E06008EA9411EB9400500A901DF5
+:10A09000E2E0F8A3E0F98004782C791488828983BF
+:10A0A000E0FEA3E0FF5480600675090002A13AE5D6
+:10A0B00009A2E050718C828D83E0F50AA3E0F50BD4
+:10A0C0005480F50DE50A2EFEE50B3F547FFFE50DAC
+:10A0D0004FFF8C828D83EEF0A3EFF0547FFFC3EE31
+:10A0E0009AEF9B4055ECF8EDF9E849700302A1A204
+:10A0F00088828983E0FCA3E0547FFDECC39AFCEDE9
+:10A100009BFDC3EC9404ED94004056E82AF582E9E7
+:10A110003BF583ECF0A3EDF0EB4480FB8882898370
+:10A12000EAF0A3EB8043EEFCEF547FFDC3EC9AED25
+:10A130009B50B6750901E8FCE9FD88828983E0FE41
+:10A14000A3E0547FFFE82EF8E93FF988828983E095
+:10A15000FEA3E0FFEE4F600302A09C780079008030
+:10A160004188828983A3E04480F09007E7E060297A
+:10A17000901DE2E0FAA3E0FBE86A7002E96B701957
+:10A1800088828983E0FAA3E0547FFBE82AFAE93B5E
+:10A19000FB901DE2EAF0A3EBF0E824020808E934A2
+:10A1A00000F9E508A2E092AFE8FAE9FB7F06022198
+:10A1B00023C082C083EA24FEF8EB34FFF9A2AFE4A7
+:10A1C00033FCC2AF88828983A3E0547FF0901DE204
+:10A1D000E0FAA3E0FBE89AE99B5008901DE2E8F062
+:10A1E000A3E9F0ECA2E092AF02A02974F71220518B
+:10A1F000E99007D4F01210B37A067B009007D4E000
+:10A20000F91209F37A517B0F120AA77F0102212369
+:10A2100074F41220518A088B09EB54806041900736
+:10A22000D4E0F91210FB8A0A8B0BA80AA90BE8FEEE
+:10A23000E9FFE849602012100BE97013900E81E0ED
+:10A24000F4600CEEFAEFFBE0F91210EFE96007EEB4
+:10A25000FAEFFB1210E9AA08E5096480FB8022EA04
+:10A26000A2E0500C120F57E5086401FAAB09801107
+:10A2700054026009120F6FE508640280EE7A007BD9
+:10A28000007F0402212374F6122051EAFEEBFF75D1
+:10A2900008018E828F83E0246E600A24F27003022C
+:10A2A000A37E02A379A3E024F2600724D0603D02DC
+:10A2B000A3798E828F83A3A3A3E064187004A3E024
+:10A2C00064207022EE240512A3992401FAA3E0343D
+:10A2D00000FB88828983E0F8A3E0F5838882E0F9B7
+:10A2E000120EE5E98001E4F50802A392750901EE7A
+:10A2F0002403EF34000A0A0AFBEE2405FCEF3400C5
+:10A30000FD8E828F83A3A3E024FB601B24FD70617C
+:10A310008C828D83E0F98A828B83E0FAA3E0FB12C2
+:10A320000F69E9F509804D900301E0A2E2504590E4
+:10A3300007D0E0F8A3E0F9E8496039E0F5838882C6
+:10A34000A3A3A3A3E0F8A3E0F9E8496027EE240D56
+:10A35000F582EF3400F58312227B8A828B83E0FA48
+:10A36000A3E0FB8882898312204F7402121FF280BF
+:10A37000B175090085090880197508008014120F4D
+:10A380005DEE240612A399FAA3E0FBEA4B600312E8
+:10A39000136BA9087F02022123F8EF3400F98882A9
+:10A3A0008983E02274F61220518C088D09780812F6
+:10A3B000226479017C497D0502A53A74F612205188
+:10A3C0008C828D83C3E09417A3E0940040178C081F
+:10A3D0008D09780812226479037C557D0512A473D7
+:10A3E000121FF28002790202A54074F61220518CED
+:10A3F000828D83A3E0F87401686005740268701EA2
+:10A400008C828D83E060178C088D09780812226495
+:10A4100079057C617D0512A473121FF28002790216
+:10A4200002A54074F61220518C828D83E060178C57
+:10A43000088D09780812226479077C6D7D0512A4C5
+:10A4400073121FF28002790202A54074F6122051A5
+:10A450008C828D83E060178C088D09780812226445
+:10A4600079097C797D0512A473121FF280027902AA
+:10A4700002A5401205C774022274F61220518C08FE
+:10A480008D097808122264790B7C857D0502A53A36
+:10A4900074F61220518C088D097808122264790D07
+:10A4A0007C977D0502A53A74F61220518C088D091F
+:10A4B0007808122264790F7CA37D05807D74F612E2
+:10A4C00020518C828D83E060178C088D09780812EA
+:10A4D000226479117CA97D0512A473121FF28002F7
+:10A4E0007902805C74F6122051E4F508F5097808C9
+:10A4F0001222647913803F74F61220518C088D0962
+:10A50000780812226479177CB57D05802D74F612C7
+:10A510002051E4F508F509780812226479198016AB
+:10A5200074F61220518C088D097808122264791B68
+:10A530007CC17D0580047C007D0012A473121FF293
+:10A540007F0202212374F61220518C088D097808AD
+:10A55000122264791D80D974F6122051EAFEEBFFB5
+:10A56000EE2404FAEF3400FB12114F8A088B09A87D
+:10A5700008A909E849602988828983A3A3EEF0A38A
+:10A58000EFF012A6E688828983EAF0A3EBF0900C44
+:10A5900056E8F0A3E9F0E82404FAE93400FB80046B
+:10A5A0007A007B007F0202212374F7122051EAF81F
+:10A5B000EBF97C007D0012A6E6E8FEE9FF800BEADD
+:10A5C000FCEBFD8A828B8312A6E9EA4B6049EA2400
+:10A5D00004F8EB3400F9C3EE98EF9940E28A828BDD
+:10A5E00083A3A312A6CEEA28F582EB39F583A3A3B1
+:10A5F000A3A3C3E5829EE5839F40C48A828B831216
+:10A60000A6CEEC4D7005900C5680048C828D83E8AC
+:10A61000F0A3E9F01211557F0102212374F41220F6
+:10A620005112A6736044C3E49508FAE49509FBEE61
+:10A630002AFAEF3BFB8A088B09E82404FCE9340082
+:10A64000FDC3EA9CEB9D402288828983A3A3E0FCA2
+:10A65000A3E0FDE82CF582E93DF583A3A3A3A3C302
+:10A66000E5829508E58395095004EEFAEFFB7F0437
+:10A67000022123EAFEEBFF8C088D091213778A0A68
+:10A680008B0BA80AA90BE84922C082C083900C5604
+:10A6900012A6CEEAFCEBFD80078882898312A6CE43
+:10A6A000E849601FE82404FAE93400FBC3EC9AEDA2
+:10A6B0009B40E612A6D4A3A3A3A3C3E5829CE58393
+:10A6C0009D40D6E8FAE9FBD083D082020122E0F86F
+:10A6D000A3E0F92288828983A3A312A6E9E82AF5D8
+:10A6E00082E93BF58322900C56E0FAA3E0FB22744A
+:10A6F000F61220517C587D087AFF7BFF1208CD7539
+:10A7000008D675098E78081222647C047D007A02CE
+:10A710007B1012084F7402121FF27F020221237471
+:10A72000F4122051E98A087E0070447401650870B3
+:10A730003A8C828D83E0900857F07509FF780912F2
+:10A740002268750A048E0B780A122264750A027553
+:10A750000B10780A12226479007C577D087A587BA6
+:10A76000081208E57405121FF280067E1880020E9A
+:10A770000EEEF97F0402212374F4122051740C129E
+:10A780002045E0FAA3E0FB740E12204512A7ECE886
+:10A79000FEE9FF741012204512A7EC750800E84985
+:10A7A0006004790B804312A84DF50AA3E0F9A80ACA
+:10A7B0007419687003742A69702A8E828F837401F9
+:10A7C000F0F50A750B00780A1222648C828D83A33F
+:10A7D000A3A3A3A3A3E0FCA3E0FD1210BF74021285
+:10A7E0001FF2800375080AA90802A773E0F8A3E026
+:10A7F000F92274F2122051E9FE740E122045E0F5A0
+:10A800000AA3E0F50B7410122045E0F508A3E0F56B
+:10A810000912A84DF50CA3E0F9A80C7402687003A6
+:10A820007429697021750C01750D00780C12226471
+:10A830007808122264780A122264EEF91208DF7492
+:10A8400006121FF28002790A7F060221238C828D74
+:10A8500083A312A7EC88828983E02274EB12205133
+:10A860008A108B118C128D137415122045E0F50A95
+:10A87000A3E0F50B7417122045E0FEA3E0FFEA45C4
+:10A88000117005790202A91B751400851408750959
+:10A890000074027808121FC912A92085088212A923
+:10A8A0002D706A850A0C850B0DE4F50EF50F780CFA
+:10A8B000122260750C01750D00E51475F00F84E52A
+:10A8C000F0780C121FC9AA0CAB0D90112EE0F87590
+:10A8D000F00FE5148428F91211857404121FF2E9AF
+:10A8E000702B850882850983E510F0A3E511F085BA
+:10A8F0000882850983A3A3E512F0A3E513F0EE4FC8
+:10A9000060078E828F83E514F07900800E0514E5D0
+:10A9100014C3940F500302A88B79087F0D022123E2
+:10A9200074582508F508740C3509F50922F583E0FB
+:10A93000F8A3E0F9E8492274F5122051890AE9C325
+:10A94000940F505E890875090074027808121FC9B7
+:10A9500074582508F8740C3509F9E8FEE9FF8E8271
+:10A960008F8312A92F603B750801750900E50A75F0
+:10A97000F00F84E5F07808121FC9AA08AB099011FE
+:10A980002EE0F875F00FE50A8428F91211918E82F5
+:10A990008F83E4F0A3F08E828F83A3A3F0A3F0F95A
+:10A9A000800279027F03022123C082C083E9FD7403
+:10A9B000076A7001EB601874056A7001EB6010742F
+:10A9C000046A7001EB600874066A7001EB703AEA81
+:10A9D000F8EBF9E875F003A4F8ACF075F003E9A41E
+:10A9E0002CF974CF28F8740339F9E824F4F582E9D6
+:10A9F00034FFF583EAF0A3EBF0E824F6F582E934BE
+:10AA0000FFF583EDF0790080027902D083D08202D5
+:10AA1000012274F6122051EAFEEBFF8C088D098C9E
+:10AA2000828D83E0F8A3E0F97407687001E9601C87
+:10AA30007405687001E960147404687001E9600CC1
+:10AA40007406687001E96004790280177901120ABE
+:10AA5000C5E970047914800BAC08AD09EEFAEFFB80
+:10AA6000120A4102AAB974F6122051E9FE75084D86
+:10AA700075090A78081222648C088D097808122258
+:10AA800064EEFC790102AAB1120A35802774F6122D
+:10AA90002051E9F508780812226875080378081231
+:10AAA000226875085975090A78081222647912809B
+:10AAB000D7120A3B7404121FF27F0202212374F49E
+:10AAC0001220518908740C122045E0FEA3E0FF74A7
+:10AAD0000F5508F50A750B00740B780A121FC9EAA6
+:10AAE0002400F8EB3480F9E82400E9350BF9E5C7D8
+:10AAF000F509A2AFE433F50AC2AFE508C4540FFA72
+:10AB0000E5C754F84AF5C7801C88828983E08C82A7
+:10AB10008D83F088828983A3A882A9838C828D8308
+:10AB2000A3AC82AD83EEFAEFFBEA24FF1EEB34FF09
+:10AB3000FFEA4B70D48509C7E50AA2E092AF7F0413
+:10AB400002212374F6122051740A122045E0F50800
+:10AB5000A3E0F509ED900997F0ECA3F0A37462F07F
+:10AB6000A37473F0A3E0541FF0E508333354FCA33F
+:10AB7000F074067808121FBAE50890099BF0900956
+:10AB80009D7412F0A37442F053D1FE75D601EA9081
+:10AB90006271F0EBA3F0906270E0D2E1F0E0A2E726
+:10ABA00040FB7F02022123C082C083E9C33390624D
+:10ABB00072F0906270E0D2E0F0D083D08202012285
+:10ABC00074F2122051750C00750D00120E019007E1
+:10ABD000DDE06A7003A3E06B700302ACA59007DDB3
+:10ABE000E0F8A3E0F9EAC398F8EB99F99007DDEAF9
+:10ABF000F0A3EB801E24CFF8E934CCF9E50C24FE59
+:10AC0000F50CE50D341FF50D9007DFE02405F0A3EA
+:10AC1000E03400F0C3E89432E99433E850D775F09B
+:10AC200005A4F8AAF075F005E9A42AF99007DFE079
+:10AC300028FAA3E039FB8A088B0974037808121FED
+:10AC4000BAE50C2508F50CE50D3509F50DEA5407B4
+:10AC50009007DFF0A3E4F0E50C450D60489007E1B4
+:10AC6000E0250CF0A3E0350DF09007E1C3E094E897
+:10AC7000A3E09403402512ACAA121F518808890949
+:10AC8000E4F50AF50B9007E37808121E4B12ACAA04
+:10AC9000121F519007E1EAF0A3EBF0AA0CAB0DE410
+:10ACA000FCFD12119D7F060221239007E1E0F8A32D
+:10ACB000E0F97AE87B032274F7122051E9700E79EB
+:10ACC000FF12111F7A00790F12131180089007F7F5
+:10ACD000740112AD8A7F01022123C082C08374FEF9
+:10ACE000121FDC7902851882851983AA82AB831230
+:10ACF0000B19851882851983E0FAA3E0FB74021210
+:10AD00001FF2D083D08202012274F6122051E9FE94
+:10AD1000EAFF900F2DE0F4602B7A047B001210E321
+:10AD2000EA4B601C8A828B8374C0F0EFA3A3F0EE21
+:10AD30008A828B83A3A3A3F0900F2DE0F91210EF6A
+:10AD40007900800279017F0202212374F7122051D9
+:10AD5000E9FE9007F7E0640170047A008010EEA22B
+:10AD6000E55004D2F08002C2F0A2F0E433FA1211EE
+:10AD7000B5EE9007F76008E06401700BE48005E031
+:10AD80007005740112AD8A02ACD5F07ABB7B11F963
+:10AD900012130B22C082C083120ED3D083D0820242
+:10ADA0000122C082C08390031CE0F8A3E0F9E849C7
+:10ADB000600479018002790080E1E9F874FF28C31A
+:10ADC0009416400574FF68700479018002790002CE
+:10ADD000012274EE122051890C8A088B098C0D74A3
+:10ADE00012122045E0FEA3E0FF7510008A828B83DB
+:10ADF000E4F08005E82510F510E510C3950D5046E8
+:10AE000085100AEE250AF582EF3400F583E0F5118E
+:10AE100005106032851082A882850D0EF50AE8259E
+:10AE20000AFAE43400FBE50E9AE49BC365D0334094
+:10AE300015EE28F582EF3400F583E0F50A0510F9E8
+:10AE4000120651E970067A007B00801A74FF251102
+:10AE5000F8850882850983F0E50C650A7096EE2571
+:10AE600010FAEF3400FB7F0A022123C082C0838ADC
+:10AE7000828B8312AF02E9F08A828B83E02401FC8B
+:10AE8000A3E03400FD8A828B83ECF0A3EDF0D08345
+:10AE9000D08202012274F612205174FC121FDC745D
+:10AEA00002122045EAF0A3EBF0ECFAEDFB740E126F
+:10AEB0002045A882A983851882851983E8F0A3E933
+:10AEC000F0851882851983858208858309780812A0
+:10AED000226474041220458582088583097808124B
+:10AEE00022647C857D1412149D7404121FF2740276
+:10AEF00012204512AF02E4F07404121FF27F020226
+:10AF00002123E0F8A3E0F58388822274F412205113
+:10AF100074FE121FDCEAFEEBFF8909900301E0A238
+:10AF2000E2400479128063120AB98B0BEA450B6088
+:10AF300057900320E0F8A3E0F9E84960159003205A
+:10AF4000E02415F8A3E03400F988828983E0F5084D
+:10AF50008003850908A908851882851983AA82AB10
+:10AF600083120F1B750A89750B10780A12226474FC
+:10AF700002122045AC82AD837902EEFAEFFB12108B
+:10AF8000957402121FF2800279147402121FF27F6C
+:10AF90000402212374F7122051E99007D5F090079D
+:10AFA000D6E4F09007D7F09007D8F09007D9F0904A
+:10AFB00007DAF012099390039EE4F07F0102212347
+:10AFC00074F6122051EAFEEBFF548060179007D50B
+:10AFD000E0F91210FBEA4B60031210E9EEFAEF649D
+:10AFE00080FB80047A007B007F02022123C082C0A4
+:10AFF00083E99007D78008C082C083E99007D8F022
+:10B00000D083D082020122C082C083E99007D98018
+:10B01000EEC082C0839007EEE4F09007E8F0A3F062
+:10B02000D083D082020122C082C083E99007EE80E3
+:10B03000EE74F6122051E9FB908FEBE0F8EBC39829
+:10B04000400479038030750801750900EB78081217
+:10B050001FC9AC08AD09EA7011ECF4F8EDF4F990F1
+:10B0600007E8E058F0A3E05980099007E8E04CF0C9
+:10B07000A3E04DF079007F02022123C082C0837AD1
+:10B08000167B0012114F9007F5EAF0A3EBF07C1647
+:10B090007D0079001210D77900120AE379011212AB
+:10B0A000E1790212109B7903120A0B790412072F1F
+:10B0B00079051208197906120FFF79071213F5792D
+:10B0C000081212817909120843790A121455D083A3
+:10B0D000D08202012274F1122051ECFEEDFF740FB8
+:10B0E000122045E0F508A3E0F5097411122045E0AF
+:10B0F000F50CA3E0F50D750E02EA14600424FD7052
+:10B10000231205E5E9F50E701B780C122264AC08D9
+:10B11000AD09EEFAEFFB1205EB7402121FF21206F4
+:10B12000E7120FD5A90E7F0702212353BEFBE59D31
+:10B13000A2E650FAE5C654804449F5C6E59E547F20
+:10B14000644970F853C67FE59EA2E740FA53C68073
+:10B15000E59E547F70FA43BE049062707408F079E3
+:10B16000001211A91212E71213CB121125D2AF79D6
+:10B17000021211A912112B7A007B00020122C08257
+:10B18000C0839009A17470F0A374B1F0A3E0541FC0
+:10B19000F09009A5741DF0A37442F0A37470F0A39D
+:10B1A00074B2F09009ABE0541FF09009AD741EF03A
+:10B1B000A37412F08000D083D082020122C082C02A
+:10B1C000831212CF02B1B674F71220518A828B8398
+:10B1D0007900E06402701AA3E0FAA3E0FB8A828B94
+:10B1E00083E0FEA3E0FBEE8C828D83F0A3EBF08086
+:10B1F0000A8C828D8374FFF0A3F0097F0102212362
+:10B20000C082C0838A828B838001A3E070FCE582C8
+:10B21000C39AFAE5839BFBD083D082020122740992
+:10B22000F5D575D4977409F5D375D29FD2B80201BC
+:10B2300022C082C0839009967480F0D083D08202AD
+:02B240000122E9
+:040000050000010AEC
+:00000001FF
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL.i b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL.i
new file mode 100644
index 0000000..7c7c09a
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL.i
@@ -0,0 +1,3948 @@
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL.c"
+/**************************************************************************************************
+ Filename: OSAL.c
+ Revised: $Date: 2012-02-02 12:55:32 -0800 (Thu, 02 Feb 2012) $
+ Revision: $Revision: 29143 $
+
+ Description: This API allows the software components in the Z-stack to be written
+ independently of the specifics of the operating system, kernel or tasking
+ environment (including control loops or connect-to-interrupt systems).
+
+
+ Copyright 2004-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\string.h"
+/* - STRING.H -
+
+ The ANSI 'string' function declarations.
+
+ $Revision: 38615 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+/* - SYSMAC.H -
+
+ Defines system macros to maintain source compatibility
+ with different IAR compilers.
+
+ $Revision: 6040 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 65 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+#line 73 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+
+
+
+
+
+
+/* Macro for frmwri and frmrd */
+
+
+/* Typedefs put here to appear only once */
+typedef unsigned int size_t;
+typedef signed int ptrdiff_t;
+
+#line 18 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\string.h"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+__intrinsic void *memcpy(void *, const void *, size_t);
+
+__intrinsic void *memmove(void *, const void *, size_t);
+
+__intrinsic void *memchr(const void *, int, size_t);
+
+__intrinsic void *memset(void *, int, size_t);
+
+__intrinsic int memcmp(const void *, const void *, size_t);
+
+__intrinsic char *strchr(const char *, int);
+
+__intrinsic int strcmp(const char *, const char *);
+
+__intrinsic int strncmp(const char *, const char *, size_t);
+
+__intrinsic int strcoll(const char *, const char *);
+
+__intrinsic size_t strlen(const char *);
+
+__intrinsic size_t strcspn(const char *, const char *);
+
+__intrinsic size_t strspn(const char *, const char *);
+
+__intrinsic char *strpbrk(const char *, const char *);
+
+__intrinsic char *strrchr(const char *, int);
+
+__intrinsic char *strstr(const char *, const char *);
+
+__intrinsic char *strcat(char *, const char *);
+
+__intrinsic char *strncat(char *, const char *, size_t);
+
+__intrinsic char *strcpy(char *, const char *);
+
+__intrinsic char *strncpy(char *, const char *, size_t);
+
+__intrinsic char *strerror(int);
+
+__intrinsic char *strtok(char *, const char *);
+
+__intrinsic size_t strxfrm(char *, const char *, size_t);
+
+
+
+
+
+
+
+#line 47 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL.c"
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+/**************************************************************************************************
+ Filename: comdef.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: Type definitions and macros.
+
+
+ Copyright 2004-2008 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/* HAL */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+/**
+ @headerfile: hal_types.h
+
+
+**************************************************************************************************/
+
+
+
+
+/* Texas Instruments CC2540 */
+
+/* ------------------------------------------------------------------------------------------------
+ * Types
+ * ------------------------------------------------------------------------------------------------
+ */
+/** @defgroup HAL_TYPES HAL Types
+ * @{
+ */
+typedef signed char int8; //!< Signed 8 bit integer
+typedef unsigned char uint8; //!< Unsigned 8 bit integer
+
+typedef signed short int16; //!< Signed 16 bit integer
+typedef unsigned short uint16; //!< Unsigned 16 bit integer
+
+typedef signed long int32; //!< Signed 32 bit integer
+typedef unsigned long uint32; //!< Unsigned 32 bit integer
+
+typedef unsigned char bool; //!< Boolean data type
+
+typedef uint8 halDataAlign_t; //!< Used for byte alignment
+/** @} End HAL_TYPES */
+
+/* ------------------------------------------------------------------------------------------------
+ * Memory Attributes and Compiler Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ----------- IAR Compiler ----------- */
+#line 82 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+/* ----------- KEIL Compiler ----------- */
+#line 105 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Standard Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************************************************
+ */
+#line 55 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+/**************************************************************************************************
+ Filename: hal_defs.h
+ Revised: $Date: 2012-08-17 16:28:43 -0700 (Fri, 17 Aug 2012) $
+ Revision: $Revision: 31295 $
+
+ Description: This file contains useful macros and data types
+
+
+ Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* takes a byte out of a uint32 : var - uint32, ByteNum - byte to take out (0 - 3) */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 101 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+
+/*
+ * This macro is for use by other macros to form a fully valid C statement.
+ * Without this, the if/else conditionals could show unexpected behavior.
+ *
+ * For example, use...
+ * #define SET_REGS() st( ioreg1 = 0; ioreg2 = 0; )
+ * instead of ...
+ * #define SET_REGS() { ioreg1 = 0; ioreg2 = 0; }
+ * or
+ * #define SET_REGS() ioreg1 = 0; ioreg2 = 0;
+ * The last macro would not behave as expected in the if/else construct.
+ * The second to last macro will cause a compiler error in certain uses
+ * of if/else construct
+ *
+ * It is not necessary, or recommended, to use this macro where there is
+ * already a valid C statement. For example, the following is redundant...
+ * #define CALL_FUNC() st( func(); )
+ * This should simply be...
+ * #define CALL_FUNC() func()
+ *
+ * (The while condition below evaluates false without generating a
+ * constant-controlling-loop type of warning on most compilers.)
+ */
+
+
+
+/**************************************************************************************************
+ */
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * Lint Keywords
+ */
+
+
+#line 71 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*** Generic Status Return Values ***/
+#line 107 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Generic Status return
+typedef uint8 Status_t;
+
+// Data types
+typedef int32 int24;
+typedef uint32 uint24;
+
+/*********************************************************************
+ * Global System Events
+ */
+
+
+
+/*********************************************************************
+ * Global Generic System Messages
+ */
+
+
+
+// OSAL System Message IDs/Events Reserved for applications (user applications)
+// 0xE0 – 0xFC
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 49 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_board.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+/*******************************************************************************
+ Filename: hal_board_cfg.h
+ Revised: $Date: 2013-02-27 11:32:02 -0800 (Wed, 27 Feb 2013) $
+ Revision: $Revision: 33315 $
+
+ Description:
+
+ Abstract board-specific registers, addresses, & initialization for H/W based on the
+ Texas Instruments CC254x (8051 core).
+
+
+ Copyright 2006-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+ * INCLUDES
+ */
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+/**************************************************************************************************
+ Filename: hal_mcu.h
+ Revised: $Date: 2012-07-13 06:58:11 -0700 (Fri, 13 Jul 2012) $
+ Revision: $Revision: 30922 $
+
+ Description: Describe the purpose and contents of the file.
+
+
+ Copyright 2006-2010 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+/*
+ * Target : Texas Instruments CC2540 (8051 core)
+ *
+ */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Includes
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Target Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ---------------------- IAR Compiler ---------------------- */
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/**************************************************************************************************
+ * - ioCC2540.h -
+ *
+ * Header file with definitions for the Texas Instruments CC2540 low-power System-on-Chip:
+ * an 8051-based MCU with 2.4 GHz Bluetooth low energy RF transceiver, and up to 256 kB FLASH.
+ *
+ * This file supports the IAR Embedded Workbench for 8051.
+ *
+ **************************************************************************************************
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+#pragma language=extended
+#line 41 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 77 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Vectors
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 101 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * SFR Bit Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* USBIE P2IE , not in a bit addressable register */
+
+/* ------------------------------------------------------------------------------------------------
+ * SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * SFRs with an address ending with 0 or 8 are bit accessible.
+ * They are defined with the SFRBIT() macro that sets the name of each bit.
+ */
+
+/* Port 0 */
+__sfr __no_init volatile union { unsigned char P0; struct { unsigned char P0_0 : 1; unsigned char P0_1 : 1; unsigned char P0_2 : 1; unsigned char P0_3 : 1; unsigned char P0_4 : 1; unsigned char P0_5 : 1; unsigned char P0_6 : 1; unsigned char P0_7 : 1; }; } @ 0x80;
+__sfr __no_init volatile unsigned char SP @ 0x81; /* Stack Pointer */
+__sfr __no_init volatile unsigned char DPL0 @ 0x82; /* Data Pointer 0 Low Byte */
+__sfr __no_init volatile unsigned char DPH0 @ 0x83; /* Data Pointer 0 High Byte */
+__sfr __no_init volatile unsigned char DPL1 @ 0x84; /* Data Pointer 1 Low Byte */
+__sfr __no_init volatile unsigned char DPH1 @ 0x85; /* Data Pointer 1 High Byte */
+__sfr __no_init volatile unsigned char U0CSR @ 0x86; /* USART 0 Control and Status */
+__sfr __no_init volatile unsigned char PCON @ 0x87; /* Power Mode Control */
+
+/* Interrupt Flags */
+__sfr __no_init volatile union { unsigned char TCON; struct { unsigned char IT0 : 1; unsigned char RFERRIF : 1; unsigned char IT1 : 1; unsigned char URX0IF : 1; unsigned char _TCON4 : 1; unsigned char ADCIF : 1; unsigned char _TCON6 : 1; unsigned char URX1IF : 1; }; } @ 0x88;
+__sfr __no_init volatile unsigned char P0IFG @ 0x89; /* Port 0 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P1IFG @ 0x8A; /* Port 1 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P2IFG @ 0x8B; /* Port 2 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char PICTL @ 0x8C; /* Port Interrupt Control */
+__sfr __no_init volatile unsigned char P1IEN @ 0x8D; /* Port 1 Interrupt Mask */
+__sfr __no_init volatile unsigned char _SFR8E @ 0x8E; /* not used */
+__sfr __no_init volatile unsigned char P0INP @ 0x8F; /* Port 0 Input Mode */
+
+/* Port 1 */
+__sfr __no_init volatile union { unsigned char P1; struct { unsigned char P1_0 : 1; unsigned char P1_1 : 1; unsigned char P1_2 : 1; unsigned char P1_3 : 1; unsigned char P1_4 : 1; unsigned char P1_5 : 1; unsigned char P1_6 : 1; unsigned char P1_7 : 1; }; } @ 0x90;
+__sfr __no_init volatile unsigned char _SFR91 @ 0x91; /* reserved */
+__sfr __no_init volatile unsigned char DPS @ 0x92; /* Data Pointer Select */
+__sfr __no_init volatile unsigned char MPAGE @ 0x93; /* Memory Page Select */
+__sfr __no_init volatile unsigned char T2CTRL @ 0x94; /* Timer2 Control Register */
+__sfr __no_init volatile unsigned char ST0 @ 0x95; /* Sleep Timer 0 */
+__sfr __no_init volatile unsigned char ST1 @ 0x96; /* Sleep Timer 1 */
+__sfr __no_init volatile unsigned char ST2 @ 0x97; /* Sleep Timer 2 */
+
+/* Interrupt Flags 2 */
+__sfr __no_init volatile union { unsigned char S0CON; struct { unsigned char ENCIF_0 : 1; unsigned char ENCIF_1 : 1; unsigned char _S0CON2 : 1; unsigned char _S0CON3 : 1; unsigned char _S0CON4 : 1; unsigned char _S0CON5 : 1; unsigned char _S0CON6 : 1; unsigned char _S0CON7 : 1; }; } @ 0x98;
+__sfr __no_init volatile unsigned char _SFR99 @ 0x99; /* reserved */
+__sfr __no_init volatile unsigned char IEN2 @ 0x9A; /* Interrupt Enable 2 */
+__sfr __no_init volatile unsigned char S1CON @ 0x9B; /* Interrupt Flags 3 */
+__sfr __no_init volatile unsigned char T2CSPCFG @ 0x9C; /* Timer2 CSP Interface Configuration (legacy name) */
+__sfr __no_init volatile unsigned char T2EVTCFG @ 0x9C; /* Timer2 Event Output Configuration */
+__sfr __no_init volatile unsigned char SLEEPSTA @ 0x9D; /* Sleep Status */
+__sfr __no_init volatile unsigned char CLKCONSTA @ 0x9E; /* Clock Control Status */
+__sfr __no_init volatile unsigned char FMAP @ 0x9F; /* Flash Bank Map */
+
+/* Port 2 */
+__sfr __no_init volatile union { unsigned char P2; struct { unsigned char P2_0 : 1; unsigned char P2_1 : 1; unsigned char P2_2 : 1; unsigned char P2_3 : 1; unsigned char P2_4 : 1; unsigned char _P2_5 : 1; unsigned char _P2_6 : 1; unsigned char _P2_7 : 1; }; } @ 0xA0;
+__sfr __no_init volatile unsigned char T2IRQF @ 0xA1; /* Timer2 Interrupt Flags */
+__sfr __no_init volatile unsigned char T2M0 @ 0xA2; /* Timer2 Multiplexed Register 0 */
+__sfr __no_init volatile unsigned char T2M1 @ 0xA3; /* Timer2 Multiplexed Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF0 @ 0xA4; /* Timer2 Multiplexed Overflow Register 0 */
+__sfr __no_init volatile unsigned char T2MOVF1 @ 0xA5; /* Timer2 Multiplexed Overflow Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF2 @ 0xA6; /* Timer2 Multiplexed Overflow Register 2 */
+__sfr __no_init volatile unsigned char T2IRQM @ 0xA7; /* Timer2 Interrupt Mask */
+
+/* Interrupt Enable 0 */
+__sfr __no_init volatile union { unsigned char IEN0; struct { unsigned char RFERRIE : 1; unsigned char ADCIE : 1; unsigned char URX0IE : 1; unsigned char URX1IE : 1; unsigned char ENCIE : 1; unsigned char STIE : 1; unsigned char _IEN06 : 1; unsigned char EA : 1; }; } @ 0xA8;
+__sfr __no_init volatile unsigned char IP0 @ 0xA9; /* Interrupt Priority 0 */
+__sfr __no_init volatile unsigned char _SFRAA @ 0xAA; /* not used */
+__sfr __no_init volatile unsigned char P0IEN @ 0xAB; /* Port 0 Interrupt Mask */
+__sfr __no_init volatile unsigned char P2IEN @ 0xAC; /* Port 2 Interrupt Mask */
+__sfr __no_init volatile unsigned char STLOAD @ 0xAD; /* Sleep Timer Load Status */
+__sfr __no_init volatile unsigned char PMUX @ 0xAE; /* Power Down Signal MUX */
+__sfr __no_init volatile unsigned char T1STAT @ 0xAF; /* Timer 1 Status */
+
+__sfr __no_init volatile unsigned char _SFRB0 @ 0xB0; /* not used */
+__sfr __no_init volatile unsigned char ENCDI @ 0xB1; /* Encryption/Decryption Input Data */
+__sfr __no_init volatile unsigned char ENCDO @ 0xB2; /* Encryption/Decryption Output Data */
+__sfr __no_init volatile unsigned char ENCCS @ 0xB3; /* Encryption/Decryption Control and Status */
+__sfr __no_init volatile unsigned char ADCCON1 @ 0xB4; /* ADC Control 1 */
+__sfr __no_init volatile unsigned char ADCCON2 @ 0xB5; /* ADC Control 2 */
+__sfr __no_init volatile unsigned char ADCCON3 @ 0xB6; /* ADC Control 3 */
+__sfr __no_init volatile unsigned char _SFRB7 @ 0xB7; /* reserved */
+
+/* Interrupt Enable 1 */
+__sfr __no_init volatile union { unsigned char IEN1; struct { unsigned char DMAIE : 1; unsigned char T1IE : 1; unsigned char T2IE : 1; unsigned char T3IE : 1; unsigned char T4IE : 1; unsigned char P0IE : 1; unsigned char _IEN16 : 1; unsigned char _IEN17 : 1; }; } @ 0xB8;
+__sfr __no_init volatile unsigned char IP1 @ 0xB9; /* Interrupt Priority 1 */
+__sfr __no_init volatile unsigned char ADCL @ 0xBA; /* ADC Data Low */
+__sfr __no_init volatile unsigned char ADCH @ 0xBB; /* ADC Data High */
+__sfr __no_init volatile unsigned char RNDL @ 0xBC; /* Random Number Generator Low Byte */
+__sfr __no_init volatile unsigned char RNDH @ 0xBD; /* Random Number Generator High Byte */
+__sfr __no_init volatile unsigned char SLEEPCMD @ 0xBE; /* Sleep Mode Control Command */
+__sfr __no_init volatile unsigned char _SFRBF @ 0xBF; /* reserved */
+
+/* Interrupt Flags 4 */
+__sfr __no_init volatile union { unsigned char IRCON; struct { unsigned char DMAIF : 1; unsigned char T1IF : 1; unsigned char T2IF : 1; unsigned char T3IF : 1; unsigned char T4IF : 1; unsigned char P0IF : 1; unsigned char _IRCON6 : 1; unsigned char STIF : 1; }; } @ 0xC0;
+__sfr __no_init volatile unsigned char U0DBUF @ 0xC1; /* USART 0 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U0BAUD @ 0xC2; /* USART 0 Baud Rate Control */
+__sfr __no_init volatile unsigned char T2MSEL @ 0xC3; /* Timer2 Multiplex Select */
+__sfr __no_init volatile unsigned char U0UCR @ 0xC4; /* USART 0 UART Control */
+__sfr __no_init volatile unsigned char U0GCR @ 0xC5; /* USART 0 Generic Control */
+__sfr __no_init volatile unsigned char CLKCONCMD @ 0xC6; /* Clock Control Command */
+__sfr __no_init volatile unsigned char MEMCTR @ 0xC7; /* Memory System Control */
+
+__sfr __no_init volatile unsigned char _SFRC8 @ 0xC8; /* not used */
+__sfr __no_init volatile unsigned char WDCTL @ 0xC9; /* Watchdog Timer Control */
+__sfr __no_init volatile unsigned char T3CNT @ 0xCA; /* Timer 3 Counter */
+__sfr __no_init volatile unsigned char T3CTL @ 0xCB; /* Timer 3 Control */
+__sfr __no_init volatile unsigned char T3CCTL0 @ 0xCC; /* Timer 3 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC0 @ 0xCD; /* Timer 3 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T3CCTL1 @ 0xCE; /* Timer 3 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC1 @ 0xCF; /* Timer 3 Channel 1 Capture/Compare Value */
+
+ /* Program Status Word */
+__sfr __no_init volatile union { unsigned char PSW; struct { unsigned char P : 1; unsigned char F1 : 1; unsigned char OV : 1; unsigned char RS0 : 1; unsigned char RS1 : 1; unsigned char F0 : 1; unsigned char AC : 1; unsigned char CY : 1; }; } @ 0xD0;
+__sfr __no_init volatile unsigned char DMAIRQ @ 0xD1; /* DMA Interrupt Flag */
+__sfr __no_init volatile unsigned char DMA1CFGL @ 0xD2; /* DMA Channel 1-4 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA1CFGH @ 0xD3; /* DMA Channel 1-4 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMA0CFGL @ 0xD4; /* DMA Channel 0 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA0CFGH @ 0xD5; /* DMA Channel 0 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMAARM @ 0xD6; /* DMA Channel Arm */
+__sfr __no_init volatile unsigned char DMAREQ @ 0xD7; /* DMA Channel Start Request and Status */
+
+/* Timers 1/3/4 Interrupt Mask/Flag */
+__sfr __no_init volatile union { unsigned char TIMIF; struct { unsigned char T3OVFIF : 1; unsigned char T3CH0IF : 1; unsigned char T3CH1IF : 1; unsigned char T4OVFIF : 1; unsigned char T4CH0IF : 1; unsigned char T4CH1IF : 1; unsigned char T1OVFIM : 1; unsigned char _TIMIF7 : 1; }; } @ 0xD8;
+__sfr __no_init volatile unsigned char _SFRD9 @ 0xD9; /* reserved */
+__sfr __no_init volatile unsigned char T1CC0L @ 0xDA; /* Timer 1 Channel 0 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC0H @ 0xDB; /* Timer 1 Channel 0 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC1L @ 0xDC; /* Timer 1 Channel 1 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC1H @ 0xDD; /* Timer 1 Channel 1 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC2L @ 0xDE; /* Timer 1 Channel 2 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC2H @ 0xDF; /* Timer 1 Channel 2 Capture/Compare Value High Byte */
+
+__sfr __no_init volatile unsigned char ACC @ 0xE0; /* Accumulator */
+__sfr __no_init volatile unsigned char _SFRE1 @ 0xE1; /* reserved */
+__sfr __no_init volatile unsigned char T1CNTL @ 0xE2; /* Timer 1 Counter Low */
+__sfr __no_init volatile unsigned char T1CNTH @ 0xE3; /* Timer 1 Counter High */
+__sfr __no_init volatile unsigned char T1CTL @ 0xE4; /* Timer 1 Control And Status */
+__sfr __no_init volatile unsigned char T1CCTL0 @ 0xE5; /* Timer 1 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL1 @ 0xE6; /* Timer 1 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL2 @ 0xE7; /* Timer 1 Channel 2 Capture/Compare Control */
+
+/* Interrupt Flags 5 */
+__sfr __no_init volatile union { unsigned char IRCON2; struct { unsigned char P2IF : 1; unsigned char UTX0IF : 1; unsigned char UTX1IF : 1; unsigned char P1IF : 1; unsigned char WDTIF : 1; unsigned char _IRCON25 : 1; unsigned char _IRCON26 : 1; unsigned char _IRCON27 : 1; }; } @ 0xE8;
+__sfr __no_init volatile unsigned char _SFRE9 @ 0xE9; /* reserved */
+__sfr __no_init volatile unsigned char T4CNT @ 0xEA; /* Timer 4 Counter */
+__sfr __no_init volatile unsigned char T4CTL @ 0xEB; /* Timer 4 Control */
+__sfr __no_init volatile unsigned char T4CCTL0 @ 0xEC; /* Timer 4 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC0 @ 0xED; /* Timer 4 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T4CCTL1 @ 0xEE; /* Timer 4 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC1 @ 0xEF; /* Timer 4 Channel 1 Capture/Compare Value */
+
+__sfr __no_init volatile unsigned char B @ 0xF0; /* B Register */
+__sfr __no_init volatile unsigned char PERCFG @ 0xF1; /* Peripheral I/O Control */
+__sfr __no_init volatile unsigned char ADCCFG @ 0xF2; /* ADC Input Configuration (legacy name) */
+__sfr __no_init volatile unsigned char APCFG @ 0xF2; /* Analog Periferal I/O Configuration */
+__sfr __no_init volatile unsigned char P0SEL @ 0xF3; /* Port 0 Function Select */
+__sfr __no_init volatile unsigned char P1SEL @ 0xF4; /* Port 1 Function Select */
+__sfr __no_init volatile unsigned char P2SEL @ 0xF5; /* Port 2 Function Select */
+__sfr __no_init volatile unsigned char P1INP @ 0xF6; /* Port 1 Input Mode */
+__sfr __no_init volatile unsigned char P2INP @ 0xF7; /* Port 2 Input Mode */
+
+/* USART 1 Control and Status */
+__sfr __no_init volatile union { unsigned char U1CSR; struct { unsigned char U1ACTIVE : 1; unsigned char U1TX_BYTE : 1; unsigned char U1RX_BYTE : 1; unsigned char U1ERR : 1; unsigned char U1FE : 1; unsigned char U1SLAVE : 1; unsigned char U1RE : 1; unsigned char U1MODE : 1; }; } @ 0xF8;
+__sfr __no_init volatile unsigned char U1DBUF @ 0xF9; /* USART 1 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U1BAUD @ 0xFA; /* USART 1 Baud Rate Control */
+__sfr __no_init volatile unsigned char U1UCR @ 0xFB; /* USART 1 UART Control */
+__sfr __no_init volatile unsigned char U1GCR @ 0xFC; /* USART 1 Generic Control */
+__sfr __no_init volatile unsigned char P0DIR @ 0xFD; /* Port 0 Direction */
+__sfr __no_init volatile unsigned char P1DIR @ 0xFE; /* Port 1 Direction */
+__sfr __no_init volatile unsigned char P2DIR @ 0xFF; /* Port 2 Direction */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Radio Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Radio Control Registers */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata USB Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 329 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Observability Control */
+#line 345 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Identification */
+
+
+
+/* Debug Interface DMA Write to Flash */
+
+
+/* Flash Controller */
+#line 360 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Information */
+
+
+
+/* IR Generation Control */
+
+
+/* Clock Loss Detector */
+
+
+/* Timer 1 Channels (only mapped as XREG) */
+#line 378 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Definition which includes channels represented in SFR (additional XREG mapping of SFR) */
+#line 394 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Pointers for array access */
+
+
+
+/* Sleep Timer Capture Control */
+
+
+
+
+
+
+/* Op.Amp. Control */
+
+
+
+
+/* Analog Comparator Control */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Mapped SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * Most SFRs are also accessible through XDATA address space. The register definitions for
+ * this type of access are listed below. The register names are identical to the SFR names
+ * but with the prefix X_ to denote an XDATA register.
+ *
+ * Some SFRs are not accessible through XDATA space. For clarity, entries are included for these
+ * registers. They have a prefix of _NA to denote "not available."
+ *
+ * For register descriptions, refer to the actual SFR declartions elsewhere in this file.
+ */
+
+#line 437 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 446 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 455 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 465 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 474 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 483 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 492 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 501 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 510 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 519 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 528 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 537 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 546 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 555 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 565 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 574 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Flash
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ */
+
+
+#pragma language=default
+
+
+/**************************************************************************************************
+ */
+#line 76 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+#line 84 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ---------------------- Keil Compiler ---------------------- */
+#line 104 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+typedef unsigned char halIntState_t;
+
+
+
+
+
+ /* IAR library uses XCH instruction with EA. It may cause the higher priority interrupt to be
+ * locked out, therefore, may increase interrupt latency. It may also create a lockup condition.
+ * This workaround should only be used with 8051 using IAR compiler. When IAR fixes this by
+ * removing XCH usage in its library, compile the following macros to null to disable them.
+ */
+#line 131 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Reset Macro
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 142 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* disable interrupts, set watchdog timer, wait for reset */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 rev numbers
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 sleep common code
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* PCON bit definitions */
+
+
+/* SLEEPCMD bit definitions */
+
+
+
+/* SLEEPSTA bit definitions */
+
+
+
+/* SLEEPCMD and SLEEPSTA bit definitions */
+
+
+
+/* CLKCONCMD bit definitions */
+
+
+
+
+
+
+/* STLOAD */
+
+
+
+
+#line 199 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/**************************************************************************************************
+ */
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+
+
+/*******************************************************************************
+ * CONSTANTS
+ */
+
+/* Board Identifier */
+
+
+
+
+
+/* Clock Speed */
+
+
+
+/* Sleep Clock */
+
+
+
+
+// For non-USB, assume external, unless an internal crystal is explicitly indicated.
+
+
+
+
+
+
+// Minimum Time for Stable External 32kHz Clock (in ms)
+
+
+/* LCD Max Chars and Buffer */
+
+
+
+/* LED Configuration */
+
+#line 101 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+
+
+/* 1 - Green */
+
+
+
+
+
+
+ /* 2 - Red */
+
+
+
+
+
+ /* 3 - Yellow */
+
+
+
+
+
+
+/* Push Button Configuration */
+
+
+
+
+/* S1 */
+
+
+
+#line 140 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Joystick Center Press */
+
+
+
+
+/* OSAL NV implemented by internal flash pages. */
+
+// Flash is partitioned into 8 banks of 32 KB or 16 pages.
+
+
+// Flash is constructed of 128 pages of 2 KB.
+
+
+// SNV can use a larger logical page size to accomodate more or bigger items or extend lifetime.
+
+
+
+// CODE banks get mapped into the XDATA range 8000-FFFF.
+
+
+// The last 16 bytes of the last available page are reserved for flash lock bits.
+
+
+// NV page definitions must coincide with segment declaration in project *.xcl file.
+#line 172 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+// Re-defining Z_EXTADDR_LEN here so as not to include a Z-Stack .h file.
+
+
+
+
+
+
+
+
+// Used by DMA macros to shift 1 to create a mask for DMA registers.
+
+
+
+
+
+
+
+/* Critical Vdd Monitoring to prevent flash damage or radio lockup. */
+
+// Vdd/3 / Internal Reference X ENOB --> (Vdd / 3) / 1.15 X 127
+
+
+
+
+
+
+
+/*******************************************************************************
+ * MACROS
+ */
+
+/* Cache Prefetch Control */
+
+
+
+
+/* Setting Clocks */
+
+// switch to the 16MHz HSOSC and wait until it is stable
+
+
+
+
+
+
+// switch to the 32MHz XOSC and wait until it is stable
+
+
+
+
+
+
+// set 32kHz OSC and wait until it is stable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* Board Initialization */
+#line 256 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Debounce */
+
+
+/* ----------- Push Buttons ---------- */
+#line 267 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* LED's */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 315 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* XNV */
+
+
+
+
+
+
+
+// The TI reference design uses UART1 Alt. 2 in SPI mode.
+#line 356 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Driver Configuration */
+
+/* Set to TRUE enable H/W TIMER usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable ADC usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable DMA usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable Flash access, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable AES usage, FALSE disable it */
+
+
+
+
+
+
+
+
+/* Set to TRUE enable LCD usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable LED usage, FALSE disable it */
+#line 400 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Set to TRUE enable KEY usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable UART usage, FALSE disable it */
+#line 414 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+
+ // Always prefer to use DMA over ISR.
+#line 444 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+ // Used to set P2 priority - USART0 over USART1 if both are defined.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+*/
+#line 2 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_board.h"
+#line 50 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+/******************************************************************************
+ Filename: OSAL.h
+ Revised: $Date: 2012-02-17 15:07:16 -0800 (Fri, 17 Feb 2012) $
+ Revision: $Revision: 29376 $
+
+ Description: This API allows the software components in the Z-Stack to be
+ written independently of the specifics of the operating system,
+ kernel, or tasking environment (including control loops or
+ connect-to-interrupt systems).
+
+
+ Copyright 2004-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+/* - LIMITS.H -
+
+ Integral ANSI element sizes.
+
+ $Revision: 38615 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 80 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+/**************************************************************************************************
+ Filename: OSAL_Memory.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: This module defines the OSAL memory control functions.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialize memory manager.
+ */
+ void osal_mem_init( void );
+
+ /*
+ * Setup efficient search for the first free block of heap.
+ */
+ void osal_mem_kick( void );
+
+ /*
+ * Allocate a block of memory.
+ */
+
+
+
+
+ void *osal_mem_alloc( uint16 size );
+
+
+ /*
+ * Free a block of memory.
+ */
+
+
+
+
+ void osal_mem_free( void *ptr );
+
+
+#line 130 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+#line 137 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 59 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Timers.h"
+/**************************************************************************************************
+ Filename: OSAL_Timers.h
+ Revised: $Date: 2011-09-16 19:09:24 -0700 (Fri, 16 Sep 2011) $
+ Revision: $Revision: 27618 $
+
+ Description: This file contains the OSAL Timer definition and manipulation functions.
+
+
+ Copyright 2004-2009 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ * the unit is chosen such that the 320us tick equivalent can fit in
+ * 32 bits.
+ */
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialization for the OSAL Timer System.
+ */
+ extern void osalTimerInit( void );
+
+ /*
+ * Set a Timer
+ */
+ extern uint8 osal_start_timerEx( uint8 task_id, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Set a timer that reloads itself.
+ */
+ extern uint8 osal_start_reload_timer( uint8 taskID, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Stop a Timer
+ */
+ extern uint8 osal_stop_timerEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Get the tick count of a Timer.
+ */
+ extern uint32 osal_get_timeoutEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Simulated Timer Interrupt Service Routine
+ */
+
+ extern void osal_timer_ISR( void );
+
+ /*
+ * Adjust timer tables
+ */
+ extern void osal_adjust_timers( void );
+
+ /*
+ * Update timer tables
+ */
+ extern void osalTimerUpdate( uint32 updateTime );
+
+ /*
+ * Count active timers
+ */
+ extern uint8 osal_timer_num_active( void );
+
+ /*
+ * Set the hardware timer interrupts for sleep mode.
+ * These functions should only be called in OSAL_PwrMgr.c
+ */
+ extern void osal_sleep_timers( void );
+ extern void osal_unsleep_timers( void );
+
+ /*
+ * Read the system clock - returns milliseconds
+ */
+ extern uint32 osal_GetSystemClock( void );
+
+ /*
+ * Get the next OSAL timer expiration.
+ * This function should only be called in OSAL_PwrMgr.c
+ */
+ extern uint32 osal_next_timeout( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 60 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*** Interrupts ***/
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+typedef struct
+{
+ void *next;
+ uint16 len;
+ uint8 dest_id;
+} osal_msg_hdr_t;
+
+typedef struct
+{
+ uint8 event;
+ uint8 status;
+} osal_event_hdr_t;
+
+typedef void * osal_msg_q_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*** Message Management ***/
+
+ /*
+ * Task Message Allocation
+ */
+ extern uint8 * osal_msg_allocate(uint16 len );
+
+ /*
+ * Task Message Deallocation
+ */
+ extern uint8 osal_msg_deallocate( uint8 *msg_ptr );
+
+ /*
+ * Send a Task Message
+ */
+ extern uint8 osal_msg_send( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern uint8 osal_msg_push_front( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Receive a Task Message
+ */
+ extern uint8 *osal_msg_receive( uint8 task_id );
+
+ /*
+ * Find in place a matching Task Message / Event.
+ */
+ extern osal_event_hdr_t *osal_msg_find(uint8 task_id, uint8 event);
+
+ /*
+ * Enqueue a Task Message
+ */
+ extern void osal_msg_enqueue( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Enqueue a Task Message Up to Max
+ */
+ extern uint8 osal_msg_enqueue_max( osal_msg_q_t *q_ptr, void *msg_ptr, uint8 max );
+
+ /*
+ * Dequeue a Task Message
+ */
+ extern void *osal_msg_dequeue( osal_msg_q_t *q_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern void osal_msg_push( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Extract and remove a Task Message from queue
+ */
+ extern void osal_msg_extract( osal_msg_q_t *q_ptr, void *msg_ptr, void *prev_ptr );
+
+
+/*** Task Synchronization ***/
+
+ /*
+ * Set a Task Event
+ */
+ extern uint8 osal_set_event( uint8 task_id, uint16 event_flag );
+
+
+ /*
+ * Clear a Task Event
+ */
+ extern uint8 osal_clear_event( uint8 task_id, uint16 event_flag );
+
+
+/*** Interrupt Management ***/
+
+ /*
+ * Register Interrupt Service Routine (ISR)
+ */
+ extern uint8 osal_isr_register( uint8 interrupt_id, void (*isr_ptr)( uint8* ) );
+
+ /*
+ * Enable Interrupt
+ */
+ extern uint8 osal_int_enable( uint8 interrupt_id );
+
+ /*
+ * Disable Interrupt
+ */
+ extern uint8 osal_int_disable( uint8 interrupt_id );
+
+
+/*** Task Management ***/
+
+ /*
+ * Initialize the Task System
+ */
+ extern uint8 osal_init_system( void );
+
+ /*
+ * System Processing Loop
+ */
+
+
+
+ extern void osal_start_system( void );
+
+
+ /*
+ * One Pass Throu the OSAL Processing Loop
+ */
+ extern void osal_run_system( void );
+
+ /*
+ * Get the active task ID
+ */
+ extern uint8 osal_self( void );
+
+
+/*** Helper Functions ***/
+
+ /*
+ * String Length
+ */
+ extern int osal_strlen( char *pString );
+
+ /*
+ * Memory copy
+ */
+ extern void *osal_memcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory Duplicate - allocates and copies
+ */
+ extern void *osal_memdup( const void *src, unsigned int len );
+
+ /*
+ * Reverse Memory copy
+ */
+ extern void *osal_revmemcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory compare
+ */
+ extern uint8 osal_memcmp( const void *src1, const void *src2, unsigned int len );
+
+ /*
+ * Memory set
+ */
+ extern void *osal_memset( void *dest, uint8 value, int len );
+
+ /*
+ * Build a uint16 out of 2 bytes (0 then 1).
+ */
+ extern uint16 osal_build_uint16( uint8 *swapped );
+
+ /*
+ * Build a uint32 out of sequential bytes.
+ */
+ extern uint32 osal_build_uint32( uint8 *swapped, uint8 len );
+
+ /*
+ * Convert long to ascii string
+ */
+
+ extern uint8 *_ltoa( uint32 l, uint8 * buf, uint8 radix );
+
+
+ /*
+ * Random number generator
+ */
+ extern uint16 osal_rand( void );
+
+ /*
+ * Buffer an uint32 value - LSB first.
+ */
+ extern uint8* osal_buffer_uint32( uint8 *buf, uint32 val );
+
+ /*
+ * Buffer an uint24 value - LSB first
+ */
+ extern uint8* osal_buffer_uint24( uint8 *buf, uint24 val );
+
+ /*
+ * Is all of the array elements set to a value?
+ */
+ extern uint8 osal_isbufset( uint8 *buf, uint8 val, uint8 len );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 51 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL_Tasks.h"
+/**************************************************************************************************
+ Filename: OSAL_Tasks.h
+ Revised: $Date: 2007-10-28 18:41:49 -0700 (Sun, 28 Oct 2007) $
+ Revision: $Revision: 15799 $
+
+ Description: This file contains the OSAL Task definition and manipulation functions.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*
+ * Event handler function prototype
+ */
+typedef unsigned short (*pTaskEventHandlerFn)( unsigned char task_id, unsigned short event );
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+extern const pTaskEventHandlerFn tasksArr[];
+extern const uint8 tasksCnt;
+extern uint16 *tasksEvents;
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Call each of the tasks initailization functions.
+ */
+extern void osalInitTasks( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 52 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL_PwrMgr.h"
+/**************************************************************************************************
+ Filename: OSAL_PwrMgr.h
+ Revised: $Date: 2007-10-28 18:41:49 -0700 (Sun, 28 Oct 2007) $
+ Revision: $Revision: 15799 $
+
+ Description: This file contains the OSAL Power Management API.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/* These attributes define sleep beheaver. The attributes can be changed
+ * for each sleep cycle or when the device characteristic change.
+ */
+typedef struct
+{
+ uint16 pwrmgr_task_state;
+ uint16 pwrmgr_next_timeout;
+ uint16 accumulated_sleep_time;
+ uint8 pwrmgr_device;
+} pwrmgr_attribute_t;
+
+/* With PWRMGR_ALWAYS_ON selection, there is no power savings and the
+ * device is most likely on mains power. The PWRMGR_BATTERY selection allows
+ * the HAL sleep manager to enter SLEEP LITE state or SLEEP DEEP state.
+ */
+
+
+
+/* The PWRMGR_CONSERVE selection turns power savings on, all tasks have to
+ * agree. The PWRMGR_HOLD selection turns power savings off.
+ */
+
+
+
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/* This global variable stores the power management attributes.
+ */
+extern pwrmgr_attribute_t pwrmgr_attribute;
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialize the power management system.
+ * This function is called from OSAL.
+ *
+ */
+ extern void osal_pwrmgr_init( void );
+
+ /*
+ * This function is called by each task to state whether or not this
+ * task wants to conserve power. The task will call this function to
+ * vote whether it wants the OSAL to conserve power or it wants to
+ * hold off on the power savings. By default, when a task is created,
+ * its own power state is set to conserve. If the task always wants
+ * to converse power, it doesn't need to call this function at all.
+ * It is important for the task that changed the power manager task
+ * state to PWRMGR_HOLD to switch back to PWRMGR_CONSERVE when the
+ * hold period ends.
+ */
+ extern uint8 osal_pwrmgr_task_state( uint8 task_id, uint8 state );
+
+ /*
+ * This function is called on power-up, whenever the device characteristic
+ * change (ex. Battery backed coordinator). This function works with the timer
+ * to set HAL's power manager sleep state when power saving is entered.
+ * This function should be called form HAL initialization. After power up
+ * initialization, it should only be called from NWK or ZDO.
+ */
+ extern void osal_pwrmgr_device( uint8 pwrmgr_device );
+
+ /*
+ * This function is called from the main OSAL loop when there are
+ * no events scheduled and shouldn't be called from anywhere else.
+ */
+ extern void osal_pwrmgr_powerconserve( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 54 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL_Clock.h"
+/******************************************************************************
+ Filename: OSAL_Clock.h
+ Revised: $Date: 2012-02-02 12:55:32 -0800 (Thu, 02 Feb 2012) $
+ Revision: $Revision: 29143 $
+
+ Description: OSAL Clock definition and manipulation functions.
+
+
+ Copyright 2004-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// number of seconds since 0 hrs, 0 minutes, 0 seconds, on the
+// 1st of January 2000 UTC
+typedef uint32 UTCTime;
+
+// To be used with
+typedef struct
+{
+ uint8 seconds; // 0-59
+ uint8 minutes; // 0-59
+ uint8 hour; // 0-23
+ uint8 day; // 0-30
+ uint8 month; // 0-11
+ uint16 year; // 2000+
+} UTCTimeStruct;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Updates the OSAL clock and Timers from the MAC 320us timer tick.
+ */
+ extern void osalTimeUpdate( void );
+
+ /*
+ * Set the new time. This will only set the seconds portion
+ * of time and doesn't change the factional second counter.
+ * newTime - number of seconds since 0 hrs, 0 minutes,
+ * 0 seconds, on the 1st of January 2000 UTC
+ */
+ extern void osal_setClock( UTCTime newTime );
+
+ /*
+ * Gets the current time. This will only return the seconds
+ * portion of time and doesn't include the factional second counter.
+ * returns: number of seconds since 0 hrs, 0 minutes,
+ * 0 seconds, on the 1st of January 2000 UTC
+ */
+ extern UTCTime osal_getClock( void );
+
+ /*
+ * Converts UTCTime to UTCTimeStruct
+ *
+ * secTime - number of seconds since 0 hrs, 0 minutes,
+ * 0 seconds, on the 1st of January 2000 UTC
+ * tm - pointer to breakdown struct
+ */
+ extern void osal_ConvertUTCTime( UTCTimeStruct *tm, UTCTime secTime );
+
+ /*
+ * Converts UTCTimeStruct to UTCTime (seconds since 00:00:00 01/01/2000)
+ *
+ * tm - pointer to UTC time struct
+ */
+ extern UTCTime osal_ConvertUTCSecs( UTCTimeStruct *tm );
+
+ /*
+ * Update/Adjust the osal clock and timers
+ * Msec - elapsed time in milli seconds
+ */
+ extern void osalAdjustTimer( uint32 Msec );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 55 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL.c"
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+/**************************************************************************************************
+ Filename: OnBoard.h
+ Revised: $Date: 2008-07-25 17:36:14 -0700 (Fri, 25 Jul 2008) $
+ Revision: $Revision: 17620 $
+
+ Description: Defines stuff for EVALuation boards
+ This file targets the Chipcon CC2540DB/CC2540EB
+
+
+ Copyright 2008-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_sleep.h"
+/**************************************************************************************************
+ Filename: hal_sleep.h
+ Revised: $Date: 2013-02-27 11:32:02 -0800 (Wed, 27 Feb 2013) $
+ Revision: $Revision: 33315 $
+
+ Description: This file contains the interface to the power management service.
+
+
+ Copyright 2006-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Execute power management procedure
+ */
+extern void halSleep( uint32 osal_timer );
+
+/*
+ * Used in mac_mcu
+ */
+extern void halSleepWait(uint16 duration);
+
+/*
+ * Used in hal_drivers, AN044 - DELAY EXTERNAL INTERRUPTS
+ */
+extern void halRestoreSleepLevel( void );
+
+/*
+ * Used by the interrupt routines to exit from sleep.
+ */
+extern void halSleepExit(void);
+
+/*
+ * Set the max sleep loop time lesser than the T2 rollover period.
+ */
+extern void halSetMaxSleepLoopTime(uint32 rolloverTime);
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 46 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+
+
+/*********************************************************************
+ */
+// Internal (MCU) RAM addresses
+
+
+
+
+// Internal (MCU) heap size
+
+
+
+
+// Memory Allocation Heap
+
+
+
+
+
+
+// Initialization levels
+
+
+
+
+
+
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 state; // shift
+ uint8 keys; // keys
+} keyChange_t;
+
+// Timer clock and power-saving definitions
+
+
+
+/* OSAL timer defines */
+
+
+
+
+
+extern void _itoa(uint16 num, uint8 *buf, uint8 radix);
+
+
+
+
+
+
+/* Tx and Rx buffer size defines used by SPIMgr.c */
+
+
+
+
+
+/* system restart and boot loader used from MTEL.c */
+// Restart system from absolute beginning
+// Disables interrupts, forces WatchDog reset
+
+
+
+
+
+
+
+
+/* Reset reason for reset indication */
+
+
+/* port definition stuff used by MT */
+#line 133 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+
+/* sleep macros required by OSAL_PwrMgr.c */
+
+
+
+
+
+/* used by MTEL.c */
+uint8 OnBoard_SendKeys( uint8 keys, uint8 state );
+
+/*
+ * Board specific random number generator
+ */
+extern uint16 Onboard_rand( void );
+
+/*
+ * Get elapsed timer clock counts
+ * reset: reset count register if TRUE
+ */
+extern uint32 TimerElapsed( void );
+
+/*
+ * Initialize the Peripherals
+ * level: 0=cold, 1=warm, 2=ready
+ */
+extern void InitBoard( uint8 level );
+
+/*
+ * Register for all key events
+ */
+extern uint8 RegisterForKeys( uint8 task_id );
+
+/* Keypad Control Functions */
+
+/*
+ * Send "Key Pressed" message to application
+ */
+extern uint8 OnBoard_SendKeys( uint8 keys, uint8 shift);
+
+/*
+ * Callback routine to handle keys
+ */
+extern void OnBoard_KeyCallback ( uint8 keys, uint8 state );
+
+/*
+ * Perform a soft reset - jump to 0x0
+ */
+extern __near_func void Onboard_soft_reset( void );
+
+
+/*********************************************************************
+ */
+
+#line 57 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL.c"
+
+/* HAL */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_drivers.h"
+/**************************************************************************************************
+ Filename: hal_drivers.h
+ Revised: $Date: 2012-07-09 13:23:30 -0700 (Mon, 09 Jul 2012) $
+ Revision: $Revision: 30873 $
+
+ Description: This file contains the interface to the Drivers service.
+
+
+ Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+/**************************************************************************************************
+ * INCLUDES
+ **************************************************************************************************/
+
+
+
+/**************************************************************************************************
+ * CONSTANTS
+ **************************************************************************************************/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************************************************
+ * GLOBAL VARIABLES
+ **************************************************************************************************/
+
+extern uint8 Hal_TaskID;
+
+/**************************************************************************************************
+ * FUNCTIONS - API
+ **************************************************************************************************/
+
+extern void Hal_Init ( uint8 task_id );
+
+/*
+ * Process Serial Buffer
+ */
+extern uint16 Hal_ProcessEvent ( uint8 task_id, uint16 events );
+
+/*
+ * Process Polls
+ */
+extern void Hal_ProcessPoll (void);
+
+/*
+ * Initialize HW
+ */
+extern void HalDriverInit (void);
+
+
+
+
+
+
+
+/**************************************************************************************************
+**************************************************************************************************/
+#line 60 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL.c"
+
+
+
+
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// Message Pool Definitions
+osal_msg_q_t osal_qHead;
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+// Index of active task
+static uint8 activeTaskID = 0xFF;
+
+/*********************************************************************
+ * LOCAL FUNCTION PROTOTYPES
+ */
+
+static uint8 osal_msg_enqueue_push( uint8 destination_task, uint8 *msg_ptr, uint8 urgent );
+
+/*********************************************************************
+ * HELPER FUNCTIONS
+ */
+/* very ugly stub so Keil can compile */
+#line 116 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL.c"
+
+/*********************************************************************
+ * @fn osal_strlen
+ *
+ * @brief
+ *
+ * Calculates the length of a string. The string must be null
+ * terminated.
+ *
+ * @param char *pString - pointer to text string
+ *
+ * @return int - number of characters
+ */
+int osal_strlen( char *pString )
+{
+ return (int)( strlen( pString ) );
+}
+
+/*********************************************************************
+ * @fn osal_memcpy
+ *
+ * @brief
+ *
+ * Generic memory copy.
+ *
+ * Note: This function differs from the standard memcpy(), since
+ * it returns the pointer to the next destination uint8. The
+ * standard memcpy() returns the original destination address.
+ *
+ * @param dst - destination address
+ * @param src - source address
+ * @param len - number of bytes to copy
+ *
+ * @return pointer to end of destination buffer
+ */
+void *osal_memcpy( void *dst, const void *src, unsigned int len )
+{
+ uint8 *pDst;
+ const uint8 *pSrc;
+
+ pSrc = src;
+ pDst = dst;
+
+ while ( len-- )
+ *pDst++ = *pSrc++;
+
+ return ( pDst );
+}
+
+/*********************************************************************
+ * @fn osal_revmemcpy
+ *
+ * @brief Generic reverse memory copy. Starts at the end of the
+ * source buffer, by taking the source address pointer and moving
+ * pointer ahead "len" bytes, then decrementing the pointer.
+ *
+ * Note: This function differs from the standard memcpy(), since
+ * it returns the pointer to the next destination uint8. The
+ * standard memcpy() returns the original destination address.
+ *
+ * @param dst - destination address
+ * @param src - source address
+ * @param len - number of bytes to copy
+ *
+ * @return pointer to end of destination buffer
+ */
+void *osal_revmemcpy( void *dst, const void *src, unsigned int len )
+{
+ uint8 *pDst;
+ const uint8 *pSrc;
+
+ pSrc = src;
+ pSrc += (len-1);
+ pDst = dst;
+
+ while ( len-- )
+ *pDst++ = *pSrc--;
+
+ return ( pDst );
+}
+
+/*********************************************************************
+ * @fn osal_memdup
+ *
+ * @brief Allocates a buffer [with osal_mem_alloc()] and copies
+ * the src buffer into the newly allocated space.
+ *
+ * @param src - source address
+ * @param len - number of bytes to copy
+ *
+ * @return pointer to the new allocated buffer, or NULL if
+ * allocation problem.
+ */
+void *osal_memdup( const void *src, unsigned int len )
+{
+ uint8 *pDst;
+
+ pDst = osal_mem_alloc( len );
+ if ( pDst )
+ {
+ (void) osal_memcpy( pDst, src, len );
+ }
+
+ return ( (void *)pDst );
+}
+
+/*********************************************************************
+ * @fn osal_memcmp
+ *
+ * @brief
+ *
+ * Generic memory compare.
+ *
+ * @param src1 - source 1 addrexx
+ * @param src2 - source 2 address
+ * @param len - number of bytes to compare
+ *
+ * @return TRUE - same, FALSE - different
+ */
+uint8 osal_memcmp( const void *src1, const void *src2, unsigned int len )
+{
+ const uint8 *pSrc1;
+ const uint8 *pSrc2;
+
+ pSrc1 = src1;
+ pSrc2 = src2;
+
+ while ( len-- )
+ {
+ if( *pSrc1++ != *pSrc2++ )
+ return 0;
+ }
+ return 1;
+}
+
+
+/*********************************************************************
+ * @fn osal_memset
+ *
+ * @brief
+ *
+ * Set memory buffer to value.
+ *
+ * @param dest - pointer to buffer
+ * @param value - what to set each uint8 of the message
+ * @param size - how big
+ *
+ * @return pointer to destination buffer
+ */
+void *osal_memset( void *dest, uint8 value, int len )
+{
+ return memset( dest, value, len );
+}
+
+/*********************************************************************
+ * @fn osal_build_uint16
+ *
+ * @brief
+ *
+ * Build a uint16 out of 2 bytes (0 then 1).
+ *
+ * @param swapped - 0 then 1
+ *
+ * @return uint16
+ */
+uint16 osal_build_uint16( uint8 *swapped )
+{
+ return ( ((uint16)(((swapped[0]) & 0x00FF) + (((swapped[1]) & 0x00FF) << 8))) );
+}
+
+/*********************************************************************
+ * @fn osal_build_uint32
+ *
+ * @brief
+ *
+ * Build a uint32 out of sequential bytes.
+ *
+ * @param swapped - sequential bytes
+ * @param len - number of bytes in the uint8 array
+ *
+ * @return uint32
+ */
+uint32 osal_build_uint32( uint8 *swapped, uint8 len )
+{
+ if ( len == 2 )
+ return ( ((uint32)((uint32)((swapped[0]) & 0x00FF) + ((uint32)((swapped[1]) & 0x00FF) << 8) + ((uint32)((0L) & 0x00FF) << 16) + ((uint32)((0L) & 0x00FF) << 24))) );
+ else if ( len == 3 )
+ return ( ((uint32)((uint32)((swapped[0]) & 0x00FF) + ((uint32)((swapped[1]) & 0x00FF) << 8) + ((uint32)((swapped[2]) & 0x00FF) << 16) + ((uint32)((0L) & 0x00FF) << 24))) );
+ else if ( len == 4 )
+ return ( ((uint32)((uint32)((swapped[0]) & 0x00FF) + ((uint32)((swapped[1]) & 0x00FF) << 8) + ((uint32)((swapped[2]) & 0x00FF) << 16) + ((uint32)((swapped[3]) & 0x00FF) << 24))) );
+ else
+ return ( (uint32)swapped[0] );
+}
+
+
+/*********************************************************************
+ * @fn _ltoa
+ *
+ * @brief
+ *
+ * convert a long unsigned int to a string.
+ *
+ * @param l - long to convert
+ * @param buf - buffer to convert to
+ * @param radix - 10 dec, 16 hex
+ *
+ * @return pointer to buffer
+ */
+unsigned char * _ltoa(unsigned long l, unsigned char *buf, unsigned char radix)
+{
+
+
+
+ unsigned char tmp1[10] = "", tmp2[10] = "", tmp3[10] = "";
+ unsigned short num1, num2, num3;
+ unsigned char i;
+
+ buf[0] = '\0';
+
+ if ( radix == 10 )
+ {
+ num1 = l % 10000;
+ num2 = (l / 10000) % 10000;
+ num3 = (unsigned short)(l / 100000000);
+
+ if (num3) _itoa(num3, tmp3, 10);
+ if (num2) _itoa(num2, tmp2, 10);
+ if (num1) _itoa(num1, tmp1, 10);
+
+ if (num3)
+ {
+ strcpy((char*)buf, (char const*)tmp3);
+ for (i = 0; i < 4 - strlen((char const*)tmp2); i++)
+ strcat((char*)buf, "0");
+ }
+ strcat((char*)buf, (char const*)tmp2);
+ if (num3 || num2)
+ {
+ for (i = 0; i < 4 - strlen((char const*)tmp1); i++)
+ strcat((char*)buf, "0");
+ }
+ strcat((char*)buf, (char const*)tmp1);
+ if (!num3 && !num2 && !num1)
+ strcpy((char*)buf, "0");
+ }
+ else if ( radix == 16 )
+ {
+ num1 = l & 0x0000FFFF;
+ num2 = l >> 16;
+
+ if (num2) _itoa(num2, tmp2, 16);
+ if (num1) _itoa(num1, tmp1, 16);
+
+ if (num2)
+ {
+ strcpy((char*)buf,(char const*)tmp2);
+ for (i = 0; i < 4 - strlen((char const*)tmp1); i++)
+ strcat((char*)buf, "0");
+ }
+ strcat((char*)buf, (char const*)tmp1);
+ if (!num2 && !num1)
+ strcpy((char*)buf, "0");
+ }
+ else
+ return ((void*)0);
+
+ return buf;
+
+}
+
+
+/*********************************************************************
+ * @fn osal_rand
+ *
+ * @brief Random number generator
+ *
+ * @param none
+ *
+ * @return uint16 - new random number
+ */
+uint16 osal_rand( void )
+{
+ return ( Onboard_rand() );
+}
+
+/*********************************************************************
+ * API FUNCTIONS
+ *********************************************************************/
+
+/*********************************************************************
+ * @fn osal_msg_allocate
+ *
+ * @brief
+ *
+ * This function is called by a task to allocate a message buffer
+ * into which the task will encode the particular message it wishes
+ * to send. This common buffer scheme is used to strictly limit the
+ * creation of message buffers within the system due to RAM size
+ * limitations on the microprocessor. Note that all message buffers
+ * are a fixed size (at least initially). The parameter len is kept
+ * in case a message pool with varying fixed message sizes is later
+ * created (for example, a pool of message buffers of size LARGE,
+ * MEDIUM and SMALL could be maintained and allocated based on request
+ * from the tasks).
+ *
+ *
+ * @param uint8 len - wanted buffer length
+ *
+ *
+ * @return pointer to allocated buffer or NULL if allocation failed.
+ */
+uint8 * osal_msg_allocate( uint16 len )
+{
+ osal_msg_hdr_t *hdr;
+
+ if ( len == 0 )
+ return ( ((void*)0) );
+
+ hdr = (osal_msg_hdr_t *) osal_mem_alloc( (short)(len + sizeof( osal_msg_hdr_t )) );
+ if ( hdr )
+ {
+ hdr->next = ((void*)0);
+ hdr->len = len;
+ hdr->dest_id = 0xFF;
+ return ( (uint8 *) (hdr + 1) );
+ }
+ else
+ return ( ((void*)0) );
+}
+
+/*********************************************************************
+ * @fn osal_msg_deallocate
+ *
+ * @brief
+ *
+ * This function is used to deallocate a message buffer. This function
+ * is called by a task (or processing element) after it has finished
+ * processing a received message.
+ *
+ *
+ * @param uint8 *msg_ptr - pointer to new message buffer
+ *
+ * @return SUCCESS, INVALID_MSG_POINTER
+ */
+uint8 osal_msg_deallocate( uint8 *msg_ptr )
+{
+ uint8 *x;
+
+ if ( msg_ptr == ((void*)0) )
+ return ( 0x05 );
+
+ // don't deallocate queued buffer
+ if ( ((osal_msg_hdr_t *) (msg_ptr) - 1)->dest_id != 0xFF )
+ return ( 0x04 );
+
+ x = (uint8 *)((uint8 *)msg_ptr - sizeof( osal_msg_hdr_t ));
+
+ osal_mem_free( (void *)x );
+
+ return ( 0x00 );
+}
+
+/*********************************************************************
+ * @fn osal_msg_send
+ *
+ * @brief
+ *
+ * This function is called by a task to send a command message to
+ * another task or processing element. The sending_task field must
+ * refer to a valid task, since the task ID will be used
+ * for the response message. This function will also set a message
+ * ready event in the destination tasks event list.
+ *
+ *
+ * @param uint8 destination_task - Send msg to Task ID
+ * @param uint8 *msg_ptr - pointer to new message buffer
+ *
+ * @return SUCCESS, INVALID_TASK, INVALID_MSG_POINTER
+ */
+uint8 osal_msg_send( uint8 destination_task, uint8 *msg_ptr )
+{
+ return ( osal_msg_enqueue_push( destination_task, msg_ptr, 0 ) );
+}
+
+/*********************************************************************
+ * @fn osal_msg_push_front
+ *
+ * @brief
+ *
+ * This function is called by a task to push a command message
+ * to the head of the OSAL queue. The destination_task field
+ * must refer to a valid task, since the task ID will be used to
+ * send the message to. This function will also set a message
+ * ready event in the destination task's event list.
+ *
+ * @param uint8 destination_task - Send msg to Task ID
+ * @param uint8 *msg_ptr - pointer to message buffer
+ *
+ * @return SUCCESS, INVALID_TASK, INVALID_MSG_POINTER
+ */
+uint8 osal_msg_push_front( uint8 destination_task, uint8 *msg_ptr )
+{
+ return ( osal_msg_enqueue_push( destination_task, msg_ptr, 1 ) );
+}
+
+/*********************************************************************
+ * @fn osal_msg_enqueue_push
+ *
+ * @brief
+ *
+ * This function is called by a task to either enqueue (append to
+ * queue) or push (prepend to queue) a command message to the OSAL
+ * queue. The destination_task field must refer to a valid task,
+ * since the task ID will be used to send the message to. This
+ * function will also set a message ready event in the destination
+ * task's event list.
+ *
+ * @param uint8 destination_task - Send msg to Task ID
+ * @param uint8 *msg_ptr - pointer to message buffer
+ * @param uint8 push - TRUE to push, otherwise enqueue
+ *
+ * @return SUCCESS, INVALID_TASK, INVALID_MSG_POINTER
+ */
+static uint8 osal_msg_enqueue_push( uint8 destination_task, uint8 *msg_ptr, uint8 push )
+{
+ if ( msg_ptr == ((void*)0) )
+ {
+ return ( 0x05 );
+ }
+
+ if ( destination_task >= tasksCnt )
+ {
+ osal_msg_deallocate( msg_ptr );
+ return ( 0x03 );
+ }
+
+ // Check the message header
+ if ( ((osal_msg_hdr_t *) (msg_ptr) - 1)->next != ((void*)0) ||
+ ((osal_msg_hdr_t *) (msg_ptr) - 1)->dest_id != 0xFF )
+ {
+ osal_msg_deallocate( msg_ptr );
+ return ( 0x05 );
+ }
+
+ ((osal_msg_hdr_t *) (msg_ptr) - 1)->dest_id = destination_task;
+
+ if ( push == 1 )
+ {
+ // prepend the message
+ osal_msg_push( &osal_qHead, msg_ptr );
+ }
+ else
+ {
+ // append the message
+ osal_msg_enqueue( &osal_qHead, msg_ptr );
+ }
+
+ // Signal the task that a message is waiting
+ osal_set_event( destination_task, 0x8000 );
+
+ return ( 0x00 );
+}
+
+/*********************************************************************
+ * @fn osal_msg_receive
+ *
+ * @brief
+ *
+ * This function is called by a task to retrieve a received command
+ * message. The calling task must deallocate the message buffer after
+ * processing the message using the osal_msg_deallocate() call.
+ *
+ * @param uint8 task_id - receiving tasks ID
+ *
+ * @return *uint8 - message information or NULL if no message
+ */
+uint8 *osal_msg_receive( uint8 task_id )
+{
+ osal_msg_hdr_t *listHdr;
+ osal_msg_hdr_t *prevHdr = ((void*)0);
+ osal_msg_hdr_t *foundHdr = ((void*)0);
+ halIntState_t intState;
+
+ // Hold off interrupts
+ do { intState = EA; do { EA = 0; } while (600 == -1); } while (600 == -1);
+
+ // Point to the top of the queue
+ listHdr = osal_qHead;
+
+ // Look through the queue for a message that belongs to the asking task
+ while ( listHdr != ((void*)0) )
+ {
+ if ( (listHdr - 1)->dest_id == task_id )
+ {
+ if ( foundHdr == ((void*)0) )
+ {
+ // Save the first one
+ foundHdr = listHdr;
+ }
+ else
+ {
+ // Second msg found, stop looking
+ break;
+ }
+ }
+ if ( foundHdr == ((void*)0) )
+ {
+ prevHdr = listHdr;
+ }
+ listHdr = ((osal_msg_hdr_t *) (listHdr) - 1)->next;
+ }
+
+ // Is there more than one?
+ if ( listHdr != ((void*)0) )
+ {
+ // Yes, Signal the task that a message is waiting
+ osal_set_event( task_id, 0x8000 );
+ }
+ else
+ {
+ // No more
+ osal_clear_event( task_id, 0x8000 );
+ }
+
+ // Did we find a message?
+ if ( foundHdr != ((void*)0) )
+ {
+ // Take out of the link list
+ osal_msg_extract( &osal_qHead, foundHdr, prevHdr );
+ }
+
+ // Release interrupts
+ do { EA = intState; } while (648 == -1);
+
+ return ( (uint8*) foundHdr );
+}
+
+/**************************************************************************************************
+ * @fn osal_msg_find
+ *
+ * @brief This function finds in place an OSAL message matching the task_id and event
+ * parameters.
+ *
+ * input parameters
+ *
+ * @param task_id - The OSAL task id that the enqueued OSAL message must match.
+ * @param event - The OSAL event id that the enqueued OSAL message must match.
+ *
+ * output parameters
+ *
+ * None.
+ *
+ * @return NULL if no match, otherwise an in place pointer to the matching OSAL message.
+ **************************************************************************************************
+ */
+osal_event_hdr_t *osal_msg_find(uint8 task_id, uint8 event)
+{
+ osal_msg_hdr_t *pHdr;
+ halIntState_t intState;
+
+ do { intState = EA; do { EA = 0; } while (676 == -1); } while (676 == -1); // Hold off interrupts.
+
+ pHdr = osal_qHead; // Point to the top of the queue.
+
+ // Look through the queue for a message that matches the task_id and event parameters.
+ while (pHdr != ((void*)0))
+ {
+ if (((pHdr-1)->dest_id == task_id) && (((osal_event_hdr_t *)pHdr)->event == event))
+ {
+ break;
+ }
+
+ pHdr = ((osal_msg_hdr_t *) (pHdr) - 1)->next;
+ }
+
+ do { EA = intState; } while (691 == -1); // Release interrupts.
+
+ return (osal_event_hdr_t *)pHdr;
+}
+
+/*********************************************************************
+ * @fn osal_msg_enqueue
+ *
+ * @brief
+ *
+ * This function enqueues an OSAL message into an OSAL queue.
+ *
+ * @param osal_msg_q_t *q_ptr - OSAL queue
+ * @param void *msg_ptr - OSAL message
+ *
+ * @return none
+ */
+void osal_msg_enqueue( osal_msg_q_t *q_ptr, void *msg_ptr )
+{
+ void *list;
+ halIntState_t intState;
+
+ // Hold off interrupts
+ do { intState = EA; do { EA = 0; } while (714 == -1); } while (714 == -1);
+
+ ((osal_msg_hdr_t *) (msg_ptr) - 1)->next = ((void*)0);
+ // If first message in queue
+ if ( *q_ptr == ((void*)0) )
+ {
+ *q_ptr = msg_ptr;
+ }
+ else
+ {
+ // Find end of queue
+ for ( list = *q_ptr; ((osal_msg_hdr_t *) (list) - 1)->next != ((void*)0); list = ((osal_msg_hdr_t *) (list) - 1)->next );
+
+ // Add message to end of queue
+ ((osal_msg_hdr_t *) (list) - 1)->next = msg_ptr;
+ }
+
+ // Re-enable interrupts
+ do { EA = intState; } while (732 == -1);
+}
+
+/*********************************************************************
+ * @fn osal_msg_dequeue
+ *
+ * @brief
+ *
+ * This function dequeues an OSAL message from an OSAL queue.
+ *
+ * @param osal_msg_q_t *q_ptr - OSAL queue
+ *
+ * @return void * - pointer to OSAL message or NULL of queue is empty.
+ */
+void *osal_msg_dequeue( osal_msg_q_t *q_ptr )
+{
+ void *msg_ptr = ((void*)0);
+ halIntState_t intState;
+
+ // Hold off interrupts
+ do { intState = EA; do { EA = 0; } while (752 == -1); } while (752 == -1);
+
+ if ( *q_ptr != ((void*)0) )
+ {
+ // Dequeue message
+ msg_ptr = *q_ptr;
+ *q_ptr = ((osal_msg_hdr_t *) (msg_ptr) - 1)->next;
+ ((osal_msg_hdr_t *) (msg_ptr) - 1)->next = ((void*)0);
+ ((osal_msg_hdr_t *) (msg_ptr) - 1)->dest_id = 0xFF;
+ }
+
+ // Re-enable interrupts
+ do { EA = intState; } while (764 == -1);
+
+ return msg_ptr;
+}
+
+/*********************************************************************
+ * @fn osal_msg_push
+ *
+ * @brief
+ *
+ * This function pushes an OSAL message to the head of an OSAL
+ * queue.
+ *
+ * @param osal_msg_q_t *q_ptr - OSAL queue
+ * @param void *msg_ptr - OSAL message
+ *
+ * @return none
+ */
+void osal_msg_push( osal_msg_q_t *q_ptr, void *msg_ptr )
+{
+ halIntState_t intState;
+
+ // Hold off interrupts
+ do { intState = EA; do { EA = 0; } while (787 == -1); } while (787 == -1);
+
+ // Push message to head of queue
+ ((osal_msg_hdr_t *) (msg_ptr) - 1)->next = *q_ptr;
+ *q_ptr = msg_ptr;
+
+ // Re-enable interrupts
+ do { EA = intState; } while (794 == -1);
+}
+
+/*********************************************************************
+ * @fn osal_msg_extract
+ *
+ * @brief
+ *
+ * This function extracts and removes an OSAL message from the
+ * middle of an OSAL queue.
+ *
+ * @param osal_msg_q_t *q_ptr - OSAL queue
+ * @param void *msg_ptr - OSAL message to be extracted
+ * @param void *prev_ptr - OSAL message before msg_ptr in queue
+ *
+ * @return none
+ */
+void osal_msg_extract( osal_msg_q_t *q_ptr, void *msg_ptr, void *prev_ptr )
+{
+ halIntState_t intState;
+
+ // Hold off interrupts
+ do { intState = EA; do { EA = 0; } while (816 == -1); } while (816 == -1);
+
+ if ( msg_ptr == *q_ptr )
+ {
+ // remove from first
+ *q_ptr = ((osal_msg_hdr_t *) (msg_ptr) - 1)->next;
+ }
+ else
+ {
+ // remove from middle
+ ((osal_msg_hdr_t *) (prev_ptr) - 1)->next = ((osal_msg_hdr_t *) (msg_ptr) - 1)->next;
+ }
+ ((osal_msg_hdr_t *) (msg_ptr) - 1)->next = ((void*)0);
+ ((osal_msg_hdr_t *) (msg_ptr) - 1)->dest_id = 0xFF;
+
+ // Re-enable interrupts
+ do { EA = intState; } while (832 == -1);
+}
+
+/*********************************************************************
+ * @fn osal_msg_enqueue_max
+ *
+ * @brief
+ *
+ * This function enqueues an OSAL message into an OSAL queue if
+ * the length of the queue is less than max.
+ *
+ * @param osal_msg_q_t *q_ptr - OSAL queue
+ * @param void *msg_ptr - OSAL message
+ * @param uint8 max - maximum length of queue
+ *
+ * @return TRUE if message was enqueued, FALSE otherwise
+ */
+uint8 osal_msg_enqueue_max( osal_msg_q_t *q_ptr, void *msg_ptr, uint8 max )
+{
+ void *list;
+ uint8 ret = 0;
+ halIntState_t intState;
+
+ // Hold off interrupts
+ do { intState = EA; do { EA = 0; } while (856 == -1); } while (856 == -1);
+
+ // If first message in queue
+ if ( *q_ptr == ((void*)0) )
+ {
+ *q_ptr = msg_ptr;
+ ret = 1;
+ }
+ else
+ {
+ // Find end of queue or max
+ list = *q_ptr;
+ max--;
+ while ( (((osal_msg_hdr_t *) (list) - 1)->next != ((void*)0)) && (max > 0) )
+ {
+ list = ((osal_msg_hdr_t *) (list) - 1)->next;
+ max--;
+ }
+
+ // Add message to end of queue if max not reached
+ if ( max != 0 )
+ {
+ ((osal_msg_hdr_t *) (list) - 1)->next = msg_ptr;
+ ret = 1;
+ }
+ }
+
+ // Re-enable interrupts
+ do { EA = intState; } while (884 == -1);
+
+ return ret;
+}
+
+/*********************************************************************
+ * @fn osal_set_event
+ *
+ * @brief
+ *
+ * This function is called to set the event flags for a task. The
+ * event passed in is OR'd into the task's event variable.
+ *
+ * @param uint8 task_id - receiving tasks ID
+ * @param uint8 event_flag - what event to set
+ *
+ * @return SUCCESS, INVALID_TASK
+ */
+uint8 osal_set_event( uint8 task_id, uint16 event_flag )
+{
+ if ( task_id < tasksCnt )
+ {
+ halIntState_t intState;
+ do { intState = EA; do { EA = 0; } while (907 == -1); } while (907 == -1); // Hold off interrupts
+ tasksEvents[task_id] |= event_flag; // Stuff the event bit(s)
+ do { EA = intState; } while (909 == -1); // Release interrupts
+ return ( 0x00 );
+ }
+ else
+ {
+ return ( 0x03 );
+ }
+}
+
+/*********************************************************************
+ * @fn osal_clear_event
+ *
+ * @brief
+ *
+ * This function is called to clear the event flags for a task. The
+ * event passed in is masked out of the task's event variable.
+ *
+ * @param uint8 task_id - receiving tasks ID
+ * @param uint8 event_flag - what event to clear
+ *
+ * @return SUCCESS, INVALID_TASK
+ */
+uint8 osal_clear_event( uint8 task_id, uint16 event_flag )
+{
+ if ( task_id < tasksCnt )
+ {
+ halIntState_t intState;
+ do { intState = EA; do { EA = 0; } while (936 == -1); } while (936 == -1); // Hold off interrupts
+ tasksEvents[task_id] &= ~(event_flag); // Clear the event bit(s)
+ do { EA = intState; } while (938 == -1); // Release interrupts
+ return ( 0x00 );
+ }
+ else
+ {
+ return ( 0x03 );
+ }
+}
+
+/*********************************************************************
+ * @fn osal_isr_register
+ *
+ * @brief
+ *
+ * This function is called to register a service routine with an
+ * interrupt. When the interrupt occurs, this service routine is called.
+ *
+ * @param uint8 interrupt_id - Interrupt number
+ * @param void (*isr_ptr)( uint8* ) - function pointer to ISR
+ *
+ * @return SUCCESS, INVALID_INTERRUPT_ID,
+ */
+uint8 osal_isr_register( uint8 interrupt_id, void (*isr_ptr)( uint8* ) )
+{
+ // Remove these statements when functionality is complete
+ (void)interrupt_id;
+ (void)isr_ptr;
+ return ( 0x00 );
+}
+
+/*********************************************************************
+ * @fn osal_int_enable
+ *
+ * @brief
+ *
+ * This function is called to enable an interrupt. Once enabled,
+ * occurrence of the interrupt causes the service routine associated
+ * with that interrupt to be called.
+ *
+ * If INTS_ALL is the interrupt_id, interrupts (in general) are enabled.
+ * If a single interrupt is passed in, then interrupts still have
+ * to be enabled with another call to INTS_ALL.
+ *
+ * @param uint8 interrupt_id - Interrupt number
+ *
+ * @return SUCCESS or INVALID_INTERRUPT_ID
+ */
+uint8 osal_int_enable( uint8 interrupt_id )
+{
+
+ if ( interrupt_id == 0xFF )
+ {
+ do { EA = 1; } while (990 == -1);
+ return ( 0x00 );
+ }
+ else
+ {
+ return ( 0x07 );
+ }
+}
+
+/*********************************************************************
+ * @fn osal_int_disable
+ *
+ * @brief
+ *
+ * This function is called to disable an interrupt. When a disabled
+ * interrupt occurs, the service routine associated with that
+ * interrupt is not called.
+ *
+ * If INTS_ALL is the interrupt_id, interrupts (in general) are disabled.
+ * If a single interrupt is passed in, then just that interrupt is disabled.
+ *
+ * @param uint8 interrupt_id - Interrupt number
+ *
+ * @return SUCCESS or INVALID_INTERRUPT_ID
+ */
+uint8 osal_int_disable( uint8 interrupt_id )
+{
+
+ if ( interrupt_id == 0xFF )
+ {
+ do { EA = 0; } while (1020 == -1);
+ return ( 0x00 );
+ }
+ else
+ {
+ return ( 0x07 );
+ }
+}
+
+/*********************************************************************
+ * @fn osal_init_system
+ *
+ * @brief
+ *
+ * This function initializes the "task" system by creating the
+ * tasks defined in the task table (OSAL_Tasks.h).
+ *
+ * @param void
+ *
+ * @return SUCCESS
+ */
+uint8 osal_init_system( void )
+{
+ // Initialize the Memory Allocation System
+ osal_mem_init();
+
+ // Initialize the message queue
+ osal_qHead = ((void*)0);
+
+ // Initialize the timers
+ osalTimerInit();
+
+ // Initialize the Power Management System
+ osal_pwrmgr_init();
+
+ // Initialize the system tasks.
+ osalInitTasks();
+
+ // Setup efficient search for the first free block of heap.
+ osal_mem_kick();
+
+ return ( 0x00 );
+}
+
+/*********************************************************************
+ * @fn osal_start_system
+ *
+ * @brief
+ *
+ * This function is the main loop function of the task system (if
+ * ZBIT and UBIT are not defined). This Function doesn't return.
+ *
+ * @param void
+ *
+ * @return none
+ */
+void osal_start_system( void )
+{
+
+ for(;;) // Forever Loop
+
+ {
+ osal_run_system();
+ }
+}
+
+/*********************************************************************
+ * @fn osal_run_system
+ *
+ * @brief
+ *
+ * This function will make one pass through the OSAL taskEvents table
+ * and call the task_event_processor() function for the first task that
+ * is found with at least one event pending. If there are no pending
+ * events (all tasks), this function puts the processor into Sleep.
+ *
+ * @param void
+ *
+ * @return none
+ */
+void osal_run_system( void )
+{
+ uint8 idx = 0;
+
+
+ osalTimeUpdate();
+
+
+ Hal_ProcessPoll();
+
+ do {
+ if (tasksEvents[idx]) // Task is highest priority that is ready.
+ {
+ break;
+ }
+ } while (++idx < tasksCnt);
+
+ if (idx < tasksCnt)
+ {
+ uint16 events;
+ halIntState_t intState;
+
+ do { intState = EA; do { EA = 0; } while (1122 == -1); } while (1122 == -1);
+ events = tasksEvents[idx];
+ tasksEvents[idx] = 0; // Clear the Events for this task.
+ do { EA = intState; } while (1125 == -1);
+
+ activeTaskID = idx;
+ events = (tasksArr[idx])( idx, events );
+ activeTaskID = 0xFF;
+
+ do { intState = EA; do { EA = 0; } while (1131 == -1); } while (1131 == -1);
+ tasksEvents[idx] |= events; // Add back unprocessed events to the current task.
+ do { EA = intState; } while (1133 == -1);
+ }
+#line 1141 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL.c"
+
+ /* Yield in case cooperative scheduling is being used. */
+
+
+
+
+
+}
+
+/*********************************************************************
+ * @fn osal_buffer_uint32
+ *
+ * @brief
+ *
+ * Buffer an uint32 value - LSB first.
+ *
+ * @param buf - buffer
+ * @param val - uint32 value
+ *
+ * @return pointer to end of destination buffer
+ */
+uint8* osal_buffer_uint32( uint8 *buf, uint32 val )
+{
+ *buf++ = (uint8)((uint32)(((val) >>((0) * 8)) & 0x00FF));
+ *buf++ = (uint8)((uint32)(((val) >>((1) * 8)) & 0x00FF));
+ *buf++ = (uint8)((uint32)(((val) >>((2) * 8)) & 0x00FF));
+ *buf++ = (uint8)((uint32)(((val) >>((3) * 8)) & 0x00FF));
+
+ return buf;
+}
+
+/*********************************************************************
+ * @fn osal_buffer_uint24
+ *
+ * @brief
+ *
+ * Buffer an uint24 value - LSB first. Note that type uint24 is
+ * typedef to uint32 in comdef.h
+ *
+ * @param buf - buffer
+ * @param val - uint24 value
+ *
+ * @return pointer to end of destination buffer
+ */
+uint8* osal_buffer_uint24( uint8 *buf, uint24 val )
+{
+ *buf++ = (uint8)((uint32)(((val) >>((0) * 8)) & 0x00FF));
+ *buf++ = (uint8)((uint32)(((val) >>((1) * 8)) & 0x00FF));
+ *buf++ = (uint8)((uint32)(((val) >>((2) * 8)) & 0x00FF));
+
+ return buf;
+}
+
+/*********************************************************************
+ * @fn osal_isbufset
+ *
+ * @brief
+ *
+ * Is all of the array elements set to a value?
+ *
+ * @param buf - buffer to check
+ * @param val - value to check each array element for
+ * @param len - length to check
+ *
+ * @return TRUE if all "val"
+ * FALSE otherwise
+ */
+uint8 osal_isbufset( uint8 *buf, uint8 val, uint8 len )
+{
+ uint8 x;
+
+ if ( buf == ((void*)0) )
+ {
+ return ( 0 );
+ }
+
+ for ( x = 0; x < len; x++ )
+ {
+ // Check for non-initialized value
+ if ( buf[x] != val )
+ {
+ return ( 0 );
+ }
+ }
+ return ( 1 );
+}
+
+/*********************************************************************
+ * @fn osal_self
+ *
+ * @brief
+ *
+ * This function returns the task ID of the current (active) task.
+ *
+ * @param void
+ *
+ * @return active task ID or TASK_NO_TASK if no task is active
+ */
+uint8 osal_self( void )
+{
+ return ( activeTaskID );
+}
+
+/*********************************************************************
+ */
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_ClockBLE.i b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_ClockBLE.i
new file mode 100644
index 0000000..8b3151c
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_ClockBLE.i
@@ -0,0 +1,2282 @@
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_ClockBLE.c"
+/**************************************************************************************************
+ Filename: OSAL_ClockBLE.c
+ Revised: $Date: 2008-12-15 15:42:47 -0800 (Mon, 15 Dec 2008) $
+ Revision: $Revision: 18616 $
+
+ Description: OSAL Clock definition and manipulation functions for BLE projects.
+
+ Copyright 2008-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+/**************************************************************************************************
+ Filename: comdef.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: Type definitions and macros.
+
+
+ Copyright 2004-2008 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/* HAL */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+/**
+ @headerfile: hal_types.h
+
+
+**************************************************************************************************/
+
+
+
+
+/* Texas Instruments CC2540 */
+
+/* ------------------------------------------------------------------------------------------------
+ * Types
+ * ------------------------------------------------------------------------------------------------
+ */
+/** @defgroup HAL_TYPES HAL Types
+ * @{
+ */
+typedef signed char int8; //!< Signed 8 bit integer
+typedef unsigned char uint8; //!< Unsigned 8 bit integer
+
+typedef signed short int16; //!< Signed 16 bit integer
+typedef unsigned short uint16; //!< Unsigned 16 bit integer
+
+typedef signed long int32; //!< Signed 32 bit integer
+typedef unsigned long uint32; //!< Unsigned 32 bit integer
+
+typedef unsigned char bool; //!< Boolean data type
+
+typedef uint8 halDataAlign_t; //!< Used for byte alignment
+/** @} End HAL_TYPES */
+
+/* ------------------------------------------------------------------------------------------------
+ * Memory Attributes and Compiler Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ----------- IAR Compiler ----------- */
+#line 82 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+/* ----------- KEIL Compiler ----------- */
+#line 105 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Standard Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************************************************
+ */
+#line 55 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+/**************************************************************************************************
+ Filename: hal_defs.h
+ Revised: $Date: 2012-08-17 16:28:43 -0700 (Fri, 17 Aug 2012) $
+ Revision: $Revision: 31295 $
+
+ Description: This file contains useful macros and data types
+
+
+ Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* takes a byte out of a uint32 : var - uint32, ByteNum - byte to take out (0 - 3) */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 101 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+
+/*
+ * This macro is for use by other macros to form a fully valid C statement.
+ * Without this, the if/else conditionals could show unexpected behavior.
+ *
+ * For example, use...
+ * #define SET_REGS() st( ioreg1 = 0; ioreg2 = 0; )
+ * instead of ...
+ * #define SET_REGS() { ioreg1 = 0; ioreg2 = 0; }
+ * or
+ * #define SET_REGS() ioreg1 = 0; ioreg2 = 0;
+ * The last macro would not behave as expected in the if/else construct.
+ * The second to last macro will cause a compiler error in certain uses
+ * of if/else construct
+ *
+ * It is not necessary, or recommended, to use this macro where there is
+ * already a valid C statement. For example, the following is redundant...
+ * #define CALL_FUNC() st( func(); )
+ * This should simply be...
+ * #define CALL_FUNC() func()
+ *
+ * (The while condition below evaluates false without generating a
+ * constant-controlling-loop type of warning on most compilers.)
+ */
+
+
+
+/**************************************************************************************************
+ */
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * Lint Keywords
+ */
+
+
+#line 71 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*** Generic Status Return Values ***/
+#line 107 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Generic Status return
+typedef uint8 Status_t;
+
+// Data types
+typedef int32 int24;
+typedef uint32 uint24;
+
+/*********************************************************************
+ * Global System Events
+ */
+
+
+
+/*********************************************************************
+ * Global Generic System Messages
+ */
+
+
+
+// OSAL System Message IDs/Events Reserved for applications (user applications)
+// 0xE0 – 0xFC
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 44 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_ClockBLE.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+/**************************************************************************************************
+ Filename: OnBoard.h
+ Revised: $Date: 2008-07-25 17:36:14 -0700 (Fri, 25 Jul 2008) $
+ Revision: $Revision: 17620 $
+
+ Description: Defines stuff for EVALuation boards
+ This file targets the Chipcon CC2540DB/CC2540EB
+
+
+ Copyright 2008-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+/**************************************************************************************************
+ Filename: hal_mcu.h
+ Revised: $Date: 2012-07-13 06:58:11 -0700 (Fri, 13 Jul 2012) $
+ Revision: $Revision: 30922 $
+
+ Description: Describe the purpose and contents of the file.
+
+
+ Copyright 2006-2010 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+/*
+ * Target : Texas Instruments CC2540 (8051 core)
+ *
+ */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Includes
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Target Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ---------------------- IAR Compiler ---------------------- */
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/**************************************************************************************************
+ * - ioCC2540.h -
+ *
+ * Header file with definitions for the Texas Instruments CC2540 low-power System-on-Chip:
+ * an 8051-based MCU with 2.4 GHz Bluetooth low energy RF transceiver, and up to 256 kB FLASH.
+ *
+ * This file supports the IAR Embedded Workbench for 8051.
+ *
+ **************************************************************************************************
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+#pragma language=extended
+#line 41 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 77 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Vectors
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 101 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * SFR Bit Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* USBIE P2IE , not in a bit addressable register */
+
+/* ------------------------------------------------------------------------------------------------
+ * SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * SFRs with an address ending with 0 or 8 are bit accessible.
+ * They are defined with the SFRBIT() macro that sets the name of each bit.
+ */
+
+/* Port 0 */
+__sfr __no_init volatile union { unsigned char P0; struct { unsigned char P0_0 : 1; unsigned char P0_1 : 1; unsigned char P0_2 : 1; unsigned char P0_3 : 1; unsigned char P0_4 : 1; unsigned char P0_5 : 1; unsigned char P0_6 : 1; unsigned char P0_7 : 1; }; } @ 0x80;
+__sfr __no_init volatile unsigned char SP @ 0x81; /* Stack Pointer */
+__sfr __no_init volatile unsigned char DPL0 @ 0x82; /* Data Pointer 0 Low Byte */
+__sfr __no_init volatile unsigned char DPH0 @ 0x83; /* Data Pointer 0 High Byte */
+__sfr __no_init volatile unsigned char DPL1 @ 0x84; /* Data Pointer 1 Low Byte */
+__sfr __no_init volatile unsigned char DPH1 @ 0x85; /* Data Pointer 1 High Byte */
+__sfr __no_init volatile unsigned char U0CSR @ 0x86; /* USART 0 Control and Status */
+__sfr __no_init volatile unsigned char PCON @ 0x87; /* Power Mode Control */
+
+/* Interrupt Flags */
+__sfr __no_init volatile union { unsigned char TCON; struct { unsigned char IT0 : 1; unsigned char RFERRIF : 1; unsigned char IT1 : 1; unsigned char URX0IF : 1; unsigned char _TCON4 : 1; unsigned char ADCIF : 1; unsigned char _TCON6 : 1; unsigned char URX1IF : 1; }; } @ 0x88;
+__sfr __no_init volatile unsigned char P0IFG @ 0x89; /* Port 0 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P1IFG @ 0x8A; /* Port 1 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P2IFG @ 0x8B; /* Port 2 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char PICTL @ 0x8C; /* Port Interrupt Control */
+__sfr __no_init volatile unsigned char P1IEN @ 0x8D; /* Port 1 Interrupt Mask */
+__sfr __no_init volatile unsigned char _SFR8E @ 0x8E; /* not used */
+__sfr __no_init volatile unsigned char P0INP @ 0x8F; /* Port 0 Input Mode */
+
+/* Port 1 */
+__sfr __no_init volatile union { unsigned char P1; struct { unsigned char P1_0 : 1; unsigned char P1_1 : 1; unsigned char P1_2 : 1; unsigned char P1_3 : 1; unsigned char P1_4 : 1; unsigned char P1_5 : 1; unsigned char P1_6 : 1; unsigned char P1_7 : 1; }; } @ 0x90;
+__sfr __no_init volatile unsigned char _SFR91 @ 0x91; /* reserved */
+__sfr __no_init volatile unsigned char DPS @ 0x92; /* Data Pointer Select */
+__sfr __no_init volatile unsigned char MPAGE @ 0x93; /* Memory Page Select */
+__sfr __no_init volatile unsigned char T2CTRL @ 0x94; /* Timer2 Control Register */
+__sfr __no_init volatile unsigned char ST0 @ 0x95; /* Sleep Timer 0 */
+__sfr __no_init volatile unsigned char ST1 @ 0x96; /* Sleep Timer 1 */
+__sfr __no_init volatile unsigned char ST2 @ 0x97; /* Sleep Timer 2 */
+
+/* Interrupt Flags 2 */
+__sfr __no_init volatile union { unsigned char S0CON; struct { unsigned char ENCIF_0 : 1; unsigned char ENCIF_1 : 1; unsigned char _S0CON2 : 1; unsigned char _S0CON3 : 1; unsigned char _S0CON4 : 1; unsigned char _S0CON5 : 1; unsigned char _S0CON6 : 1; unsigned char _S0CON7 : 1; }; } @ 0x98;
+__sfr __no_init volatile unsigned char _SFR99 @ 0x99; /* reserved */
+__sfr __no_init volatile unsigned char IEN2 @ 0x9A; /* Interrupt Enable 2 */
+__sfr __no_init volatile unsigned char S1CON @ 0x9B; /* Interrupt Flags 3 */
+__sfr __no_init volatile unsigned char T2CSPCFG @ 0x9C; /* Timer2 CSP Interface Configuration (legacy name) */
+__sfr __no_init volatile unsigned char T2EVTCFG @ 0x9C; /* Timer2 Event Output Configuration */
+__sfr __no_init volatile unsigned char SLEEPSTA @ 0x9D; /* Sleep Status */
+__sfr __no_init volatile unsigned char CLKCONSTA @ 0x9E; /* Clock Control Status */
+__sfr __no_init volatile unsigned char FMAP @ 0x9F; /* Flash Bank Map */
+
+/* Port 2 */
+__sfr __no_init volatile union { unsigned char P2; struct { unsigned char P2_0 : 1; unsigned char P2_1 : 1; unsigned char P2_2 : 1; unsigned char P2_3 : 1; unsigned char P2_4 : 1; unsigned char _P2_5 : 1; unsigned char _P2_6 : 1; unsigned char _P2_7 : 1; }; } @ 0xA0;
+__sfr __no_init volatile unsigned char T2IRQF @ 0xA1; /* Timer2 Interrupt Flags */
+__sfr __no_init volatile unsigned char T2M0 @ 0xA2; /* Timer2 Multiplexed Register 0 */
+__sfr __no_init volatile unsigned char T2M1 @ 0xA3; /* Timer2 Multiplexed Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF0 @ 0xA4; /* Timer2 Multiplexed Overflow Register 0 */
+__sfr __no_init volatile unsigned char T2MOVF1 @ 0xA5; /* Timer2 Multiplexed Overflow Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF2 @ 0xA6; /* Timer2 Multiplexed Overflow Register 2 */
+__sfr __no_init volatile unsigned char T2IRQM @ 0xA7; /* Timer2 Interrupt Mask */
+
+/* Interrupt Enable 0 */
+__sfr __no_init volatile union { unsigned char IEN0; struct { unsigned char RFERRIE : 1; unsigned char ADCIE : 1; unsigned char URX0IE : 1; unsigned char URX1IE : 1; unsigned char ENCIE : 1; unsigned char STIE : 1; unsigned char _IEN06 : 1; unsigned char EA : 1; }; } @ 0xA8;
+__sfr __no_init volatile unsigned char IP0 @ 0xA9; /* Interrupt Priority 0 */
+__sfr __no_init volatile unsigned char _SFRAA @ 0xAA; /* not used */
+__sfr __no_init volatile unsigned char P0IEN @ 0xAB; /* Port 0 Interrupt Mask */
+__sfr __no_init volatile unsigned char P2IEN @ 0xAC; /* Port 2 Interrupt Mask */
+__sfr __no_init volatile unsigned char STLOAD @ 0xAD; /* Sleep Timer Load Status */
+__sfr __no_init volatile unsigned char PMUX @ 0xAE; /* Power Down Signal MUX */
+__sfr __no_init volatile unsigned char T1STAT @ 0xAF; /* Timer 1 Status */
+
+__sfr __no_init volatile unsigned char _SFRB0 @ 0xB0; /* not used */
+__sfr __no_init volatile unsigned char ENCDI @ 0xB1; /* Encryption/Decryption Input Data */
+__sfr __no_init volatile unsigned char ENCDO @ 0xB2; /* Encryption/Decryption Output Data */
+__sfr __no_init volatile unsigned char ENCCS @ 0xB3; /* Encryption/Decryption Control and Status */
+__sfr __no_init volatile unsigned char ADCCON1 @ 0xB4; /* ADC Control 1 */
+__sfr __no_init volatile unsigned char ADCCON2 @ 0xB5; /* ADC Control 2 */
+__sfr __no_init volatile unsigned char ADCCON3 @ 0xB6; /* ADC Control 3 */
+__sfr __no_init volatile unsigned char _SFRB7 @ 0xB7; /* reserved */
+
+/* Interrupt Enable 1 */
+__sfr __no_init volatile union { unsigned char IEN1; struct { unsigned char DMAIE : 1; unsigned char T1IE : 1; unsigned char T2IE : 1; unsigned char T3IE : 1; unsigned char T4IE : 1; unsigned char P0IE : 1; unsigned char _IEN16 : 1; unsigned char _IEN17 : 1; }; } @ 0xB8;
+__sfr __no_init volatile unsigned char IP1 @ 0xB9; /* Interrupt Priority 1 */
+__sfr __no_init volatile unsigned char ADCL @ 0xBA; /* ADC Data Low */
+__sfr __no_init volatile unsigned char ADCH @ 0xBB; /* ADC Data High */
+__sfr __no_init volatile unsigned char RNDL @ 0xBC; /* Random Number Generator Low Byte */
+__sfr __no_init volatile unsigned char RNDH @ 0xBD; /* Random Number Generator High Byte */
+__sfr __no_init volatile unsigned char SLEEPCMD @ 0xBE; /* Sleep Mode Control Command */
+__sfr __no_init volatile unsigned char _SFRBF @ 0xBF; /* reserved */
+
+/* Interrupt Flags 4 */
+__sfr __no_init volatile union { unsigned char IRCON; struct { unsigned char DMAIF : 1; unsigned char T1IF : 1; unsigned char T2IF : 1; unsigned char T3IF : 1; unsigned char T4IF : 1; unsigned char P0IF : 1; unsigned char _IRCON6 : 1; unsigned char STIF : 1; }; } @ 0xC0;
+__sfr __no_init volatile unsigned char U0DBUF @ 0xC1; /* USART 0 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U0BAUD @ 0xC2; /* USART 0 Baud Rate Control */
+__sfr __no_init volatile unsigned char T2MSEL @ 0xC3; /* Timer2 Multiplex Select */
+__sfr __no_init volatile unsigned char U0UCR @ 0xC4; /* USART 0 UART Control */
+__sfr __no_init volatile unsigned char U0GCR @ 0xC5; /* USART 0 Generic Control */
+__sfr __no_init volatile unsigned char CLKCONCMD @ 0xC6; /* Clock Control Command */
+__sfr __no_init volatile unsigned char MEMCTR @ 0xC7; /* Memory System Control */
+
+__sfr __no_init volatile unsigned char _SFRC8 @ 0xC8; /* not used */
+__sfr __no_init volatile unsigned char WDCTL @ 0xC9; /* Watchdog Timer Control */
+__sfr __no_init volatile unsigned char T3CNT @ 0xCA; /* Timer 3 Counter */
+__sfr __no_init volatile unsigned char T3CTL @ 0xCB; /* Timer 3 Control */
+__sfr __no_init volatile unsigned char T3CCTL0 @ 0xCC; /* Timer 3 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC0 @ 0xCD; /* Timer 3 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T3CCTL1 @ 0xCE; /* Timer 3 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC1 @ 0xCF; /* Timer 3 Channel 1 Capture/Compare Value */
+
+ /* Program Status Word */
+__sfr __no_init volatile union { unsigned char PSW; struct { unsigned char P : 1; unsigned char F1 : 1; unsigned char OV : 1; unsigned char RS0 : 1; unsigned char RS1 : 1; unsigned char F0 : 1; unsigned char AC : 1; unsigned char CY : 1; }; } @ 0xD0;
+__sfr __no_init volatile unsigned char DMAIRQ @ 0xD1; /* DMA Interrupt Flag */
+__sfr __no_init volatile unsigned char DMA1CFGL @ 0xD2; /* DMA Channel 1-4 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA1CFGH @ 0xD3; /* DMA Channel 1-4 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMA0CFGL @ 0xD4; /* DMA Channel 0 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA0CFGH @ 0xD5; /* DMA Channel 0 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMAARM @ 0xD6; /* DMA Channel Arm */
+__sfr __no_init volatile unsigned char DMAREQ @ 0xD7; /* DMA Channel Start Request and Status */
+
+/* Timers 1/3/4 Interrupt Mask/Flag */
+__sfr __no_init volatile union { unsigned char TIMIF; struct { unsigned char T3OVFIF : 1; unsigned char T3CH0IF : 1; unsigned char T3CH1IF : 1; unsigned char T4OVFIF : 1; unsigned char T4CH0IF : 1; unsigned char T4CH1IF : 1; unsigned char T1OVFIM : 1; unsigned char _TIMIF7 : 1; }; } @ 0xD8;
+__sfr __no_init volatile unsigned char _SFRD9 @ 0xD9; /* reserved */
+__sfr __no_init volatile unsigned char T1CC0L @ 0xDA; /* Timer 1 Channel 0 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC0H @ 0xDB; /* Timer 1 Channel 0 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC1L @ 0xDC; /* Timer 1 Channel 1 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC1H @ 0xDD; /* Timer 1 Channel 1 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC2L @ 0xDE; /* Timer 1 Channel 2 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC2H @ 0xDF; /* Timer 1 Channel 2 Capture/Compare Value High Byte */
+
+__sfr __no_init volatile unsigned char ACC @ 0xE0; /* Accumulator */
+__sfr __no_init volatile unsigned char _SFRE1 @ 0xE1; /* reserved */
+__sfr __no_init volatile unsigned char T1CNTL @ 0xE2; /* Timer 1 Counter Low */
+__sfr __no_init volatile unsigned char T1CNTH @ 0xE3; /* Timer 1 Counter High */
+__sfr __no_init volatile unsigned char T1CTL @ 0xE4; /* Timer 1 Control And Status */
+__sfr __no_init volatile unsigned char T1CCTL0 @ 0xE5; /* Timer 1 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL1 @ 0xE6; /* Timer 1 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL2 @ 0xE7; /* Timer 1 Channel 2 Capture/Compare Control */
+
+/* Interrupt Flags 5 */
+__sfr __no_init volatile union { unsigned char IRCON2; struct { unsigned char P2IF : 1; unsigned char UTX0IF : 1; unsigned char UTX1IF : 1; unsigned char P1IF : 1; unsigned char WDTIF : 1; unsigned char _IRCON25 : 1; unsigned char _IRCON26 : 1; unsigned char _IRCON27 : 1; }; } @ 0xE8;
+__sfr __no_init volatile unsigned char _SFRE9 @ 0xE9; /* reserved */
+__sfr __no_init volatile unsigned char T4CNT @ 0xEA; /* Timer 4 Counter */
+__sfr __no_init volatile unsigned char T4CTL @ 0xEB; /* Timer 4 Control */
+__sfr __no_init volatile unsigned char T4CCTL0 @ 0xEC; /* Timer 4 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC0 @ 0xED; /* Timer 4 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T4CCTL1 @ 0xEE; /* Timer 4 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC1 @ 0xEF; /* Timer 4 Channel 1 Capture/Compare Value */
+
+__sfr __no_init volatile unsigned char B @ 0xF0; /* B Register */
+__sfr __no_init volatile unsigned char PERCFG @ 0xF1; /* Peripheral I/O Control */
+__sfr __no_init volatile unsigned char ADCCFG @ 0xF2; /* ADC Input Configuration (legacy name) */
+__sfr __no_init volatile unsigned char APCFG @ 0xF2; /* Analog Periferal I/O Configuration */
+__sfr __no_init volatile unsigned char P0SEL @ 0xF3; /* Port 0 Function Select */
+__sfr __no_init volatile unsigned char P1SEL @ 0xF4; /* Port 1 Function Select */
+__sfr __no_init volatile unsigned char P2SEL @ 0xF5; /* Port 2 Function Select */
+__sfr __no_init volatile unsigned char P1INP @ 0xF6; /* Port 1 Input Mode */
+__sfr __no_init volatile unsigned char P2INP @ 0xF7; /* Port 2 Input Mode */
+
+/* USART 1 Control and Status */
+__sfr __no_init volatile union { unsigned char U1CSR; struct { unsigned char U1ACTIVE : 1; unsigned char U1TX_BYTE : 1; unsigned char U1RX_BYTE : 1; unsigned char U1ERR : 1; unsigned char U1FE : 1; unsigned char U1SLAVE : 1; unsigned char U1RE : 1; unsigned char U1MODE : 1; }; } @ 0xF8;
+__sfr __no_init volatile unsigned char U1DBUF @ 0xF9; /* USART 1 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U1BAUD @ 0xFA; /* USART 1 Baud Rate Control */
+__sfr __no_init volatile unsigned char U1UCR @ 0xFB; /* USART 1 UART Control */
+__sfr __no_init volatile unsigned char U1GCR @ 0xFC; /* USART 1 Generic Control */
+__sfr __no_init volatile unsigned char P0DIR @ 0xFD; /* Port 0 Direction */
+__sfr __no_init volatile unsigned char P1DIR @ 0xFE; /* Port 1 Direction */
+__sfr __no_init volatile unsigned char P2DIR @ 0xFF; /* Port 2 Direction */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Radio Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Radio Control Registers */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata USB Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 329 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Observability Control */
+#line 345 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Identification */
+
+
+
+/* Debug Interface DMA Write to Flash */
+
+
+/* Flash Controller */
+#line 360 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Information */
+
+
+
+/* IR Generation Control */
+
+
+/* Clock Loss Detector */
+
+
+/* Timer 1 Channels (only mapped as XREG) */
+#line 378 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Definition which includes channels represented in SFR (additional XREG mapping of SFR) */
+#line 394 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Pointers for array access */
+
+
+
+/* Sleep Timer Capture Control */
+
+
+
+
+
+
+/* Op.Amp. Control */
+
+
+
+
+/* Analog Comparator Control */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Mapped SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * Most SFRs are also accessible through XDATA address space. The register definitions for
+ * this type of access are listed below. The register names are identical to the SFR names
+ * but with the prefix X_ to denote an XDATA register.
+ *
+ * Some SFRs are not accessible through XDATA space. For clarity, entries are included for these
+ * registers. They have a prefix of _NA to denote "not available."
+ *
+ * For register descriptions, refer to the actual SFR declartions elsewhere in this file.
+ */
+
+#line 437 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 446 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 455 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 465 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 474 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 483 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 492 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 501 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 510 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 519 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 528 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 537 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 546 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 555 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 565 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 574 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Flash
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ */
+
+
+#pragma language=default
+
+
+/**************************************************************************************************
+ */
+#line 76 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+#line 84 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ---------------------- Keil Compiler ---------------------- */
+#line 104 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+typedef unsigned char halIntState_t;
+
+
+
+
+
+ /* IAR library uses XCH instruction with EA. It may cause the higher priority interrupt to be
+ * locked out, therefore, may increase interrupt latency. It may also create a lockup condition.
+ * This workaround should only be used with 8051 using IAR compiler. When IAR fixes this by
+ * removing XCH usage in its library, compile the following macros to null to disable them.
+ */
+#line 131 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Reset Macro
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 142 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* disable interrupts, set watchdog timer, wait for reset */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 rev numbers
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 sleep common code
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* PCON bit definitions */
+
+
+/* SLEEPCMD bit definitions */
+
+
+
+/* SLEEPSTA bit definitions */
+
+
+
+/* SLEEPCMD and SLEEPSTA bit definitions */
+
+
+
+/* CLKCONCMD bit definitions */
+
+
+
+
+
+
+/* STLOAD */
+
+
+
+
+#line 199 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/**************************************************************************************************
+ */
+#line 45 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_sleep.h"
+/**************************************************************************************************
+ Filename: hal_sleep.h
+ Revised: $Date: 2013-02-27 11:32:02 -0800 (Wed, 27 Feb 2013) $
+ Revision: $Revision: 33315 $
+
+ Description: This file contains the interface to the power management service.
+
+
+ Copyright 2006-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Execute power management procedure
+ */
+extern void halSleep( uint32 osal_timer );
+
+/*
+ * Used in mac_mcu
+ */
+extern void halSleepWait(uint16 duration);
+
+/*
+ * Used in hal_drivers, AN044 - DELAY EXTERNAL INTERRUPTS
+ */
+extern void halRestoreSleepLevel( void );
+
+/*
+ * Used by the interrupt routines to exit from sleep.
+ */
+extern void halSleepExit(void);
+
+/*
+ * Set the max sleep loop time lesser than the T2 rollover period.
+ */
+extern void halSetMaxSleepLoopTime(uint32 rolloverTime);
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 46 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+/******************************************************************************
+ Filename: OSAL.h
+ Revised: $Date: 2012-02-17 15:07:16 -0800 (Fri, 17 Feb 2012) $
+ Revision: $Revision: 29376 $
+
+ Description: This API allows the software components in the Z-Stack to be
+ written independently of the specifics of the operating system,
+ kernel, or tasking environment (including control loops or
+ connect-to-interrupt systems).
+
+
+ Copyright 2004-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+/* - LIMITS.H -
+
+ Integral ANSI element sizes.
+
+ $Revision: 38615 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+/* - SYSMAC.H -
+
+ Defines system macros to maintain source compatibility
+ with different IAR compilers.
+
+ $Revision: 6040 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 65 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+#line 73 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+
+
+
+
+
+
+/* Macro for frmwri and frmrd */
+
+
+/* Typedefs put here to appear only once */
+typedef unsigned int size_t;
+typedef signed int ptrdiff_t;
+
+#line 18 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 80 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+/**************************************************************************************************
+ Filename: OSAL_Memory.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: This module defines the OSAL memory control functions.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialize memory manager.
+ */
+ void osal_mem_init( void );
+
+ /*
+ * Setup efficient search for the first free block of heap.
+ */
+ void osal_mem_kick( void );
+
+ /*
+ * Allocate a block of memory.
+ */
+
+
+
+
+ void *osal_mem_alloc( uint16 size );
+
+
+ /*
+ * Free a block of memory.
+ */
+
+
+
+
+ void osal_mem_free( void *ptr );
+
+
+#line 130 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+#line 137 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 59 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Timers.h"
+/**************************************************************************************************
+ Filename: OSAL_Timers.h
+ Revised: $Date: 2011-09-16 19:09:24 -0700 (Fri, 16 Sep 2011) $
+ Revision: $Revision: 27618 $
+
+ Description: This file contains the OSAL Timer definition and manipulation functions.
+
+
+ Copyright 2004-2009 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ * the unit is chosen such that the 320us tick equivalent can fit in
+ * 32 bits.
+ */
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialization for the OSAL Timer System.
+ */
+ extern void osalTimerInit( void );
+
+ /*
+ * Set a Timer
+ */
+ extern uint8 osal_start_timerEx( uint8 task_id, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Set a timer that reloads itself.
+ */
+ extern uint8 osal_start_reload_timer( uint8 taskID, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Stop a Timer
+ */
+ extern uint8 osal_stop_timerEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Get the tick count of a Timer.
+ */
+ extern uint32 osal_get_timeoutEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Simulated Timer Interrupt Service Routine
+ */
+
+ extern void osal_timer_ISR( void );
+
+ /*
+ * Adjust timer tables
+ */
+ extern void osal_adjust_timers( void );
+
+ /*
+ * Update timer tables
+ */
+ extern void osalTimerUpdate( uint32 updateTime );
+
+ /*
+ * Count active timers
+ */
+ extern uint8 osal_timer_num_active( void );
+
+ /*
+ * Set the hardware timer interrupts for sleep mode.
+ * These functions should only be called in OSAL_PwrMgr.c
+ */
+ extern void osal_sleep_timers( void );
+ extern void osal_unsleep_timers( void );
+
+ /*
+ * Read the system clock - returns milliseconds
+ */
+ extern uint32 osal_GetSystemClock( void );
+
+ /*
+ * Get the next OSAL timer expiration.
+ * This function should only be called in OSAL_PwrMgr.c
+ */
+ extern uint32 osal_next_timeout( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 60 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*** Interrupts ***/
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+typedef struct
+{
+ void *next;
+ uint16 len;
+ uint8 dest_id;
+} osal_msg_hdr_t;
+
+typedef struct
+{
+ uint8 event;
+ uint8 status;
+} osal_event_hdr_t;
+
+typedef void * osal_msg_q_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*** Message Management ***/
+
+ /*
+ * Task Message Allocation
+ */
+ extern uint8 * osal_msg_allocate(uint16 len );
+
+ /*
+ * Task Message Deallocation
+ */
+ extern uint8 osal_msg_deallocate( uint8 *msg_ptr );
+
+ /*
+ * Send a Task Message
+ */
+ extern uint8 osal_msg_send( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern uint8 osal_msg_push_front( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Receive a Task Message
+ */
+ extern uint8 *osal_msg_receive( uint8 task_id );
+
+ /*
+ * Find in place a matching Task Message / Event.
+ */
+ extern osal_event_hdr_t *osal_msg_find(uint8 task_id, uint8 event);
+
+ /*
+ * Enqueue a Task Message
+ */
+ extern void osal_msg_enqueue( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Enqueue a Task Message Up to Max
+ */
+ extern uint8 osal_msg_enqueue_max( osal_msg_q_t *q_ptr, void *msg_ptr, uint8 max );
+
+ /*
+ * Dequeue a Task Message
+ */
+ extern void *osal_msg_dequeue( osal_msg_q_t *q_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern void osal_msg_push( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Extract and remove a Task Message from queue
+ */
+ extern void osal_msg_extract( osal_msg_q_t *q_ptr, void *msg_ptr, void *prev_ptr );
+
+
+/*** Task Synchronization ***/
+
+ /*
+ * Set a Task Event
+ */
+ extern uint8 osal_set_event( uint8 task_id, uint16 event_flag );
+
+
+ /*
+ * Clear a Task Event
+ */
+ extern uint8 osal_clear_event( uint8 task_id, uint16 event_flag );
+
+
+/*** Interrupt Management ***/
+
+ /*
+ * Register Interrupt Service Routine (ISR)
+ */
+ extern uint8 osal_isr_register( uint8 interrupt_id, void (*isr_ptr)( uint8* ) );
+
+ /*
+ * Enable Interrupt
+ */
+ extern uint8 osal_int_enable( uint8 interrupt_id );
+
+ /*
+ * Disable Interrupt
+ */
+ extern uint8 osal_int_disable( uint8 interrupt_id );
+
+
+/*** Task Management ***/
+
+ /*
+ * Initialize the Task System
+ */
+ extern uint8 osal_init_system( void );
+
+ /*
+ * System Processing Loop
+ */
+
+
+
+ extern void osal_start_system( void );
+
+
+ /*
+ * One Pass Throu the OSAL Processing Loop
+ */
+ extern void osal_run_system( void );
+
+ /*
+ * Get the active task ID
+ */
+ extern uint8 osal_self( void );
+
+
+/*** Helper Functions ***/
+
+ /*
+ * String Length
+ */
+ extern int osal_strlen( char *pString );
+
+ /*
+ * Memory copy
+ */
+ extern void *osal_memcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory Duplicate - allocates and copies
+ */
+ extern void *osal_memdup( const void *src, unsigned int len );
+
+ /*
+ * Reverse Memory copy
+ */
+ extern void *osal_revmemcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory compare
+ */
+ extern uint8 osal_memcmp( const void *src1, const void *src2, unsigned int len );
+
+ /*
+ * Memory set
+ */
+ extern void *osal_memset( void *dest, uint8 value, int len );
+
+ /*
+ * Build a uint16 out of 2 bytes (0 then 1).
+ */
+ extern uint16 osal_build_uint16( uint8 *swapped );
+
+ /*
+ * Build a uint32 out of sequential bytes.
+ */
+ extern uint32 osal_build_uint32( uint8 *swapped, uint8 len );
+
+ /*
+ * Convert long to ascii string
+ */
+
+ extern uint8 *_ltoa( uint32 l, uint8 * buf, uint8 radix );
+
+
+ /*
+ * Random number generator
+ */
+ extern uint16 osal_rand( void );
+
+ /*
+ * Buffer an uint32 value - LSB first.
+ */
+ extern uint8* osal_buffer_uint32( uint8 *buf, uint32 val );
+
+ /*
+ * Buffer an uint24 value - LSB first
+ */
+ extern uint8* osal_buffer_uint24( uint8 *buf, uint24 val );
+
+ /*
+ * Is all of the array elements set to a value?
+ */
+ extern uint8 osal_isbufset( uint8 *buf, uint8 val, uint8 len );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 47 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+
+/*********************************************************************
+ */
+// Internal (MCU) RAM addresses
+
+
+
+
+// Internal (MCU) heap size
+
+
+
+
+// Memory Allocation Heap
+
+
+
+
+
+
+// Initialization levels
+
+
+
+
+
+
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 state; // shift
+ uint8 keys; // keys
+} keyChange_t;
+
+// Timer clock and power-saving definitions
+
+
+
+/* OSAL timer defines */
+
+
+
+
+
+extern void _itoa(uint16 num, uint8 *buf, uint8 radix);
+
+
+
+
+
+
+/* Tx and Rx buffer size defines used by SPIMgr.c */
+
+
+
+
+
+/* system restart and boot loader used from MTEL.c */
+// Restart system from absolute beginning
+// Disables interrupts, forces WatchDog reset
+
+
+
+
+
+
+
+
+/* Reset reason for reset indication */
+
+
+/* port definition stuff used by MT */
+#line 133 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+
+/* sleep macros required by OSAL_PwrMgr.c */
+
+
+
+
+
+/* used by MTEL.c */
+uint8 OnBoard_SendKeys( uint8 keys, uint8 state );
+
+/*
+ * Board specific random number generator
+ */
+extern uint16 Onboard_rand( void );
+
+/*
+ * Get elapsed timer clock counts
+ * reset: reset count register if TRUE
+ */
+extern uint32 TimerElapsed( void );
+
+/*
+ * Initialize the Peripherals
+ * level: 0=cold, 1=warm, 2=ready
+ */
+extern void InitBoard( uint8 level );
+
+/*
+ * Register for all key events
+ */
+extern uint8 RegisterForKeys( uint8 task_id );
+
+/* Keypad Control Functions */
+
+/*
+ * Send "Key Pressed" message to application
+ */
+extern uint8 OnBoard_SendKeys( uint8 keys, uint8 shift);
+
+/*
+ * Callback routine to handle keys
+ */
+extern void OnBoard_KeyCallback ( uint8 keys, uint8 state );
+
+/*
+ * Perform a soft reset - jump to 0x0
+ */
+extern __near_func void Onboard_soft_reset( void );
+
+
+/*********************************************************************
+ */
+
+#line 45 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_ClockBLE.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL_Clock.h"
+/******************************************************************************
+ Filename: OSAL_Clock.h
+ Revised: $Date: 2012-02-02 12:55:32 -0800 (Thu, 02 Feb 2012) $
+ Revision: $Revision: 29143 $
+
+ Description: OSAL Clock definition and manipulation functions.
+
+
+ Copyright 2004-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// number of seconds since 0 hrs, 0 minutes, 0 seconds, on the
+// 1st of January 2000 UTC
+typedef uint32 UTCTime;
+
+// To be used with
+typedef struct
+{
+ uint8 seconds; // 0-59
+ uint8 minutes; // 0-59
+ uint8 hour; // 0-23
+ uint8 day; // 0-30
+ uint8 month; // 0-11
+ uint16 year; // 2000+
+} UTCTimeStruct;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Updates the OSAL clock and Timers from the MAC 320us timer tick.
+ */
+ extern void osalTimeUpdate( void );
+
+ /*
+ * Set the new time. This will only set the seconds portion
+ * of time and doesn't change the factional second counter.
+ * newTime - number of seconds since 0 hrs, 0 minutes,
+ * 0 seconds, on the 1st of January 2000 UTC
+ */
+ extern void osal_setClock( UTCTime newTime );
+
+ /*
+ * Gets the current time. This will only return the seconds
+ * portion of time and doesn't include the factional second counter.
+ * returns: number of seconds since 0 hrs, 0 minutes,
+ * 0 seconds, on the 1st of January 2000 UTC
+ */
+ extern UTCTime osal_getClock( void );
+
+ /*
+ * Converts UTCTime to UTCTimeStruct
+ *
+ * secTime - number of seconds since 0 hrs, 0 minutes,
+ * 0 seconds, on the 1st of January 2000 UTC
+ * tm - pointer to breakdown struct
+ */
+ extern void osal_ConvertUTCTime( UTCTimeStruct *tm, UTCTime secTime );
+
+ /*
+ * Converts UTCTimeStruct to UTCTime (seconds since 00:00:00 01/01/2000)
+ *
+ * tm - pointer to UTC time struct
+ */
+ extern UTCTime osal_ConvertUTCSecs( UTCTimeStruct *tm );
+
+ /*
+ * Update/Adjust the osal clock and timers
+ * Msec - elapsed time in milli seconds
+ */
+ extern void osalAdjustTimer( uint32 Msec );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 47 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_ClockBLE.c"
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// (MAXCALCTICKS * 5) + (max remainder) must be <= (uint16 max),
+// so: (13105 * 5) + 7 <= 65535
+
+
+
+
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+extern uint16 ll_McuPrecisionCount(void);
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+static uint16 previousLLTimerTick = 0;
+static uint16 remUsTicks = 0;
+static uint16 timeMSec = 0;
+
+// number of seconds since 0 hrs, 0 minutes, 0 seconds, on the
+// 1st of January 2000 UTC
+UTCTime OSAL_timeSeconds = 0;
+
+/*********************************************************************
+ * LOCAL FUNCTION PROTOTYPES
+ */
+static uint8 monthLength( uint8 lpyr, uint8 mon );
+
+static void osalClockUpdate( uint16 elapsedMSec );
+
+/*********************************************************************
+ * FUNCTIONS
+ *********************************************************************/
+
+/*********************************************************************
+ * @fn osalTimeUpdate
+ *
+ * @brief Uses the free running rollover count of the MAC backoff timer;
+ * this timer runs freely with a constant 320 usec interval. The
+ * count of 320-usec ticks is converted to msecs and used to update
+ * the OSAL clock and Timers by invoking osalClockUpdate() and
+ * osalTimerUpdate(). This function is intended to be invoked
+ * from the background, not interrupt level.
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+void osalTimeUpdate( void )
+{
+ uint16 tmp;
+ uint16 ticks625us;
+ uint16 elapsedMSec = 0;
+
+ // Get the free-running count of 625us timer ticks
+ tmp = ll_McuPrecisionCount();
+
+ if ( tmp != previousLLTimerTick )
+ {
+ // Calculate the elapsed ticks of the free-running timer.
+ ticks625us = tmp - previousLLTimerTick;
+
+ // Store the LL Timer tick count for the next time through this function.
+ previousLLTimerTick = tmp;
+
+ /* It is necessary to loop to convert the usecs to msecs in increments so as
+ * not to overflow the 16-bit variables.
+ */
+ while ( ticks625us > ((uint16)(13105)) )
+ {
+ ticks625us -= ((uint16)(13105));
+ elapsedMSec += ((uint16)(13105)) * 5 / 8;
+ remUsTicks += ((uint16)(13105)) * 5 % 8;
+ }
+
+ // update converted number with remaining ticks from loop and the
+ // accumulated remainder from loop
+ tmp = (ticks625us * 5) + remUsTicks;
+
+ // Convert the 625 us ticks into milliseconds and a remainder
+ elapsedMSec += tmp / 8;
+ remUsTicks = tmp % 8;
+
+ // Update OSAL Clock and Timers
+ if ( elapsedMSec )
+ {
+ osalClockUpdate( elapsedMSec );
+ osalTimerUpdate( elapsedMSec );
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn osalClockUpdate
+ *
+ * @brief Updates the OSAL Clock time with elapsed milliseconds.
+ *
+ * @param elapsedMSec - elapsed milliseconds
+ *
+ * @return none
+ */
+static void osalClockUpdate( uint16 elapsedMSec )
+{
+ // Add elapsed milliseconds to the saved millisecond portion of time
+ timeMSec += elapsedMSec;
+
+ // Roll up milliseconds to the number of seconds
+ if ( timeMSec >= 1000 )
+ {
+ OSAL_timeSeconds += timeMSec / 1000;
+ timeMSec = timeMSec % 1000;
+ }
+}
+
+/*********************************************************************
+ * @fn osal_setClock
+ *
+ * @brief Set the new time. This will only set the seconds portion
+ * of time and doesn't change the factional second counter.
+ *
+ * @param newTime - number of seconds since 0 hrs, 0 minutes,
+ * 0 seconds, on the 1st of January 2000 UTC
+ *
+ * @return none
+ */
+void osal_setClock( UTCTime newTime )
+{
+ OSAL_timeSeconds = newTime;
+}
+
+/*********************************************************************
+ * @fn osal_getClock
+ *
+ * @brief Gets the current time. This will only return the seconds
+ * portion of time and doesn't include the factional second
+ * counter.
+ *
+ * @param none
+ *
+ * @return number of seconds since 0 hrs, 0 minutes, 0 seconds,
+ * on the 1st of January 2000 UTC
+ */
+UTCTime osal_getClock( void )
+{
+ return ( OSAL_timeSeconds );
+}
+
+/*********************************************************************
+ * @fn osal_ConvertUTCTime
+ *
+ * @brief Converts UTCTime to UTCTimeStruct
+ *
+ * @param tm - pointer to breakdown struct
+ *
+ * @param secTime - number of seconds since 0 hrs, 0 minutes,
+ * 0 seconds, on the 1st of January 2000 UTC
+ *
+ * @return none
+ */
+void osal_ConvertUTCTime( UTCTimeStruct *tm, UTCTime secTime )
+{
+ // calculate the time less than a day - hours, minutes, seconds
+ {
+ uint32 day = secTime % 86400UL;
+ tm->seconds = day % 60UL;
+ tm->minutes = (day % 3600UL) / 60UL;
+ tm->hour = day / 3600UL;
+ }
+
+ // Fill in the calendar - day, month, year
+ {
+ uint16 numDays = secTime / 86400UL;
+ tm->year = 2000;
+ while ( numDays >= ((!((tm->year) % 400) || (((tm->year) % 100) && !((tm->year) % 4))) ? 366 : 365) )
+ {
+ numDays -= ((!((tm->year) % 400) || (((tm->year) % 100) && !((tm->year) % 4))) ? 366 : 365);
+ tm->year++;
+ }
+
+ tm->month = 0;
+ while ( numDays >= monthLength( (!((tm->year) % 400) || (((tm->year) % 100) && !((tm->year) % 4))), tm->month ) )
+ {
+ numDays -= monthLength( (!((tm->year) % 400) || (((tm->year) % 100) && !((tm->year) % 4))), tm->month );
+ tm->month++;
+ }
+
+ tm->day = numDays;
+ }
+}
+
+/*********************************************************************
+ * @fn monthLength
+ *
+ * @param lpyr - 1 for leap year, 0 if not
+ *
+ * @param mon - 0 - 11 (jan - dec)
+ *
+ * @return number of days in specified month
+ */
+static uint8 monthLength( uint8 lpyr, uint8 mon )
+{
+ uint8 days = 31;
+
+ if ( mon == 1 ) // feb
+ {
+ days = ( 28 + lpyr );
+ }
+ else
+ {
+ if ( mon > 6 ) // aug-dec
+ {
+ mon--;
+ }
+
+ if ( mon & 1 )
+ {
+ days = 30;
+ }
+ }
+
+ return ( days );
+}
+
+/*********************************************************************
+ * @fn osal_ConvertUTCSecs
+ *
+ * @brief Converts a UTCTimeStruct to UTCTime
+ *
+ * @param tm - pointer to provided struct
+ *
+ * @return number of seconds since 00:00:00 on 01/01/2000 (UTC)
+ */
+UTCTime osal_ConvertUTCSecs( UTCTimeStruct *tm )
+{
+ uint32 seconds;
+
+ /* Seconds for the partial day */
+ seconds = (((tm->hour * 60UL) + tm->minutes) * 60UL) + tm->seconds;
+
+ /* Account for previous complete days */
+ {
+ /* Start with complete days in current month */
+ uint16 days = tm->day;
+
+ /* Next, complete months in current year */
+ {
+ int8 month = tm->month;
+ while ( --month >= 0 )
+ {
+ days += monthLength( (!((tm->year) % 400) || (((tm->year) % 100) && !((tm->year) % 4))), month );
+ }
+ }
+
+ /* Next, complete years before current year */
+ {
+ uint16 year = tm->year;
+ while ( --year >= 2000 )
+ {
+ days += ((!((year) % 400) || (((year) % 100) && !((year) % 4))) ? 366 : 365);
+ }
+ }
+
+ /* Add total seconds before partial day */
+ seconds += (days * 86400UL);
+ }
+
+ return ( seconds );
+}
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_Memory.i b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_Memory.i
new file mode 100644
index 0000000..567acd8
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_Memory.i
@@ -0,0 +1,2356 @@
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+/**************************************************************************************************
+ Filename: OSAL_Memory.c
+ Revised: $Date: 2013-03-14 17:58:51 -0700 (Thu, 14 Mar 2013) $
+ Revision: $Revision: 33490 $
+
+ Description: OSAL Heap Memory management functions. There is an Application Note that
+ should be read before studying and/or modifying this module:
+ SWRA204 "Heap Memory Management"
+
+ Copyright 2004-2010 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/* ------------------------------------------------------------------------------------------------
+ * Includes
+ * ------------------------------------------------------------------------------------------------
+ */
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+/**************************************************************************************************
+ Filename: comdef.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: Type definitions and macros.
+
+
+ Copyright 2004-2008 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/* HAL */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+/**
+ @headerfile: hal_types.h
+
+
+**************************************************************************************************/
+
+
+
+
+/* Texas Instruments CC2540 */
+
+/* ------------------------------------------------------------------------------------------------
+ * Types
+ * ------------------------------------------------------------------------------------------------
+ */
+/** @defgroup HAL_TYPES HAL Types
+ * @{
+ */
+typedef signed char int8; //!< Signed 8 bit integer
+typedef unsigned char uint8; //!< Unsigned 8 bit integer
+
+typedef signed short int16; //!< Signed 16 bit integer
+typedef unsigned short uint16; //!< Unsigned 16 bit integer
+
+typedef signed long int32; //!< Signed 32 bit integer
+typedef unsigned long uint32; //!< Unsigned 32 bit integer
+
+typedef unsigned char bool; //!< Boolean data type
+
+typedef uint8 halDataAlign_t; //!< Used for byte alignment
+/** @} End HAL_TYPES */
+
+/* ------------------------------------------------------------------------------------------------
+ * Memory Attributes and Compiler Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ----------- IAR Compiler ----------- */
+#line 82 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+/* ----------- KEIL Compiler ----------- */
+#line 105 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Standard Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************************************************
+ */
+#line 55 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+/**************************************************************************************************
+ Filename: hal_defs.h
+ Revised: $Date: 2012-08-17 16:28:43 -0700 (Fri, 17 Aug 2012) $
+ Revision: $Revision: 31295 $
+
+ Description: This file contains useful macros and data types
+
+
+ Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* takes a byte out of a uint32 : var - uint32, ByteNum - byte to take out (0 - 3) */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 101 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+
+/*
+ * This macro is for use by other macros to form a fully valid C statement.
+ * Without this, the if/else conditionals could show unexpected behavior.
+ *
+ * For example, use...
+ * #define SET_REGS() st( ioreg1 = 0; ioreg2 = 0; )
+ * instead of ...
+ * #define SET_REGS() { ioreg1 = 0; ioreg2 = 0; }
+ * or
+ * #define SET_REGS() ioreg1 = 0; ioreg2 = 0;
+ * The last macro would not behave as expected in the if/else construct.
+ * The second to last macro will cause a compiler error in certain uses
+ * of if/else construct
+ *
+ * It is not necessary, or recommended, to use this macro where there is
+ * already a valid C statement. For example, the following is redundant...
+ * #define CALL_FUNC() st( func(); )
+ * This should simply be...
+ * #define CALL_FUNC() func()
+ *
+ * (The while condition below evaluates false without generating a
+ * constant-controlling-loop type of warning on most compilers.)
+ */
+
+
+
+/**************************************************************************************************
+ */
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * Lint Keywords
+ */
+
+
+#line 71 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*** Generic Status Return Values ***/
+#line 107 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Generic Status return
+typedef uint8 Status_t;
+
+// Data types
+typedef int32 int24;
+typedef uint32 uint24;
+
+/*********************************************************************
+ * Global System Events
+ */
+
+
+
+/*********************************************************************
+ * Global Generic System Messages
+ */
+
+
+
+// OSAL System Message IDs/Events Reserved for applications (user applications)
+// 0xE0 – 0xFC
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 47 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+/******************************************************************************
+ Filename: OSAL.h
+ Revised: $Date: 2012-02-17 15:07:16 -0800 (Fri, 17 Feb 2012) $
+ Revision: $Revision: 29376 $
+
+ Description: This API allows the software components in the Z-Stack to be
+ written independently of the specifics of the operating system,
+ kernel, or tasking environment (including control loops or
+ connect-to-interrupt systems).
+
+
+ Copyright 2004-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+/* - LIMITS.H -
+
+ Integral ANSI element sizes.
+
+ $Revision: 38615 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+/* - SYSMAC.H -
+
+ Defines system macros to maintain source compatibility
+ with different IAR compilers.
+
+ $Revision: 6040 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 65 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+#line 73 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+
+
+
+
+
+
+/* Macro for frmwri and frmrd */
+
+
+/* Typedefs put here to appear only once */
+typedef unsigned int size_t;
+typedef signed int ptrdiff_t;
+
+#line 18 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 80 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+/**************************************************************************************************
+ Filename: OSAL_Memory.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: This module defines the OSAL memory control functions.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialize memory manager.
+ */
+ void osal_mem_init( void );
+
+ /*
+ * Setup efficient search for the first free block of heap.
+ */
+ void osal_mem_kick( void );
+
+ /*
+ * Allocate a block of memory.
+ */
+
+
+
+
+ void *osal_mem_alloc( uint16 size );
+
+
+ /*
+ * Free a block of memory.
+ */
+
+
+
+
+ void osal_mem_free( void *ptr );
+
+
+#line 130 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+#line 137 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 59 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Timers.h"
+/**************************************************************************************************
+ Filename: OSAL_Timers.h
+ Revised: $Date: 2011-09-16 19:09:24 -0700 (Fri, 16 Sep 2011) $
+ Revision: $Revision: 27618 $
+
+ Description: This file contains the OSAL Timer definition and manipulation functions.
+
+
+ Copyright 2004-2009 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ * the unit is chosen such that the 320us tick equivalent can fit in
+ * 32 bits.
+ */
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialization for the OSAL Timer System.
+ */
+ extern void osalTimerInit( void );
+
+ /*
+ * Set a Timer
+ */
+ extern uint8 osal_start_timerEx( uint8 task_id, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Set a timer that reloads itself.
+ */
+ extern uint8 osal_start_reload_timer( uint8 taskID, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Stop a Timer
+ */
+ extern uint8 osal_stop_timerEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Get the tick count of a Timer.
+ */
+ extern uint32 osal_get_timeoutEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Simulated Timer Interrupt Service Routine
+ */
+
+ extern void osal_timer_ISR( void );
+
+ /*
+ * Adjust timer tables
+ */
+ extern void osal_adjust_timers( void );
+
+ /*
+ * Update timer tables
+ */
+ extern void osalTimerUpdate( uint32 updateTime );
+
+ /*
+ * Count active timers
+ */
+ extern uint8 osal_timer_num_active( void );
+
+ /*
+ * Set the hardware timer interrupts for sleep mode.
+ * These functions should only be called in OSAL_PwrMgr.c
+ */
+ extern void osal_sleep_timers( void );
+ extern void osal_unsleep_timers( void );
+
+ /*
+ * Read the system clock - returns milliseconds
+ */
+ extern uint32 osal_GetSystemClock( void );
+
+ /*
+ * Get the next OSAL timer expiration.
+ * This function should only be called in OSAL_PwrMgr.c
+ */
+ extern uint32 osal_next_timeout( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 60 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*** Interrupts ***/
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+typedef struct
+{
+ void *next;
+ uint16 len;
+ uint8 dest_id;
+} osal_msg_hdr_t;
+
+typedef struct
+{
+ uint8 event;
+ uint8 status;
+} osal_event_hdr_t;
+
+typedef void * osal_msg_q_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*** Message Management ***/
+
+ /*
+ * Task Message Allocation
+ */
+ extern uint8 * osal_msg_allocate(uint16 len );
+
+ /*
+ * Task Message Deallocation
+ */
+ extern uint8 osal_msg_deallocate( uint8 *msg_ptr );
+
+ /*
+ * Send a Task Message
+ */
+ extern uint8 osal_msg_send( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern uint8 osal_msg_push_front( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Receive a Task Message
+ */
+ extern uint8 *osal_msg_receive( uint8 task_id );
+
+ /*
+ * Find in place a matching Task Message / Event.
+ */
+ extern osal_event_hdr_t *osal_msg_find(uint8 task_id, uint8 event);
+
+ /*
+ * Enqueue a Task Message
+ */
+ extern void osal_msg_enqueue( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Enqueue a Task Message Up to Max
+ */
+ extern uint8 osal_msg_enqueue_max( osal_msg_q_t *q_ptr, void *msg_ptr, uint8 max );
+
+ /*
+ * Dequeue a Task Message
+ */
+ extern void *osal_msg_dequeue( osal_msg_q_t *q_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern void osal_msg_push( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Extract and remove a Task Message from queue
+ */
+ extern void osal_msg_extract( osal_msg_q_t *q_ptr, void *msg_ptr, void *prev_ptr );
+
+
+/*** Task Synchronization ***/
+
+ /*
+ * Set a Task Event
+ */
+ extern uint8 osal_set_event( uint8 task_id, uint16 event_flag );
+
+
+ /*
+ * Clear a Task Event
+ */
+ extern uint8 osal_clear_event( uint8 task_id, uint16 event_flag );
+
+
+/*** Interrupt Management ***/
+
+ /*
+ * Register Interrupt Service Routine (ISR)
+ */
+ extern uint8 osal_isr_register( uint8 interrupt_id, void (*isr_ptr)( uint8* ) );
+
+ /*
+ * Enable Interrupt
+ */
+ extern uint8 osal_int_enable( uint8 interrupt_id );
+
+ /*
+ * Disable Interrupt
+ */
+ extern uint8 osal_int_disable( uint8 interrupt_id );
+
+
+/*** Task Management ***/
+
+ /*
+ * Initialize the Task System
+ */
+ extern uint8 osal_init_system( void );
+
+ /*
+ * System Processing Loop
+ */
+
+
+
+ extern void osal_start_system( void );
+
+
+ /*
+ * One Pass Throu the OSAL Processing Loop
+ */
+ extern void osal_run_system( void );
+
+ /*
+ * Get the active task ID
+ */
+ extern uint8 osal_self( void );
+
+
+/*** Helper Functions ***/
+
+ /*
+ * String Length
+ */
+ extern int osal_strlen( char *pString );
+
+ /*
+ * Memory copy
+ */
+ extern void *osal_memcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory Duplicate - allocates and copies
+ */
+ extern void *osal_memdup( const void *src, unsigned int len );
+
+ /*
+ * Reverse Memory copy
+ */
+ extern void *osal_revmemcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory compare
+ */
+ extern uint8 osal_memcmp( const void *src1, const void *src2, unsigned int len );
+
+ /*
+ * Memory set
+ */
+ extern void *osal_memset( void *dest, uint8 value, int len );
+
+ /*
+ * Build a uint16 out of 2 bytes (0 then 1).
+ */
+ extern uint16 osal_build_uint16( uint8 *swapped );
+
+ /*
+ * Build a uint32 out of sequential bytes.
+ */
+ extern uint32 osal_build_uint32( uint8 *swapped, uint8 len );
+
+ /*
+ * Convert long to ascii string
+ */
+
+ extern uint8 *_ltoa( uint32 l, uint8 * buf, uint8 radix );
+
+
+ /*
+ * Random number generator
+ */
+ extern uint16 osal_rand( void );
+
+ /*
+ * Buffer an uint32 value - LSB first.
+ */
+ extern uint8* osal_buffer_uint32( uint8 *buf, uint32 val );
+
+ /*
+ * Buffer an uint24 value - LSB first
+ */
+ extern uint8* osal_buffer_uint24( uint8 *buf, uint24 val );
+
+ /*
+ * Is all of the array elements set to a value?
+ */
+ extern uint8 osal_isbufset( uint8 *buf, uint8 val, uint8 len );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 48 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+/**************************************************************************************************
+ Filename: OnBoard.h
+ Revised: $Date: 2008-07-25 17:36:14 -0700 (Fri, 25 Jul 2008) $
+ Revision: $Revision: 17620 $
+
+ Description: Defines stuff for EVALuation boards
+ This file targets the Chipcon CC2540DB/CC2540EB
+
+
+ Copyright 2008-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+/**************************************************************************************************
+ Filename: hal_mcu.h
+ Revised: $Date: 2012-07-13 06:58:11 -0700 (Fri, 13 Jul 2012) $
+ Revision: $Revision: 30922 $
+
+ Description: Describe the purpose and contents of the file.
+
+
+ Copyright 2006-2010 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+/*
+ * Target : Texas Instruments CC2540 (8051 core)
+ *
+ */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Includes
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Target Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ---------------------- IAR Compiler ---------------------- */
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/**************************************************************************************************
+ * - ioCC2540.h -
+ *
+ * Header file with definitions for the Texas Instruments CC2540 low-power System-on-Chip:
+ * an 8051-based MCU with 2.4 GHz Bluetooth low energy RF transceiver, and up to 256 kB FLASH.
+ *
+ * This file supports the IAR Embedded Workbench for 8051.
+ *
+ **************************************************************************************************
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+#pragma language=extended
+#line 41 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 77 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Vectors
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 101 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * SFR Bit Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* USBIE P2IE , not in a bit addressable register */
+
+/* ------------------------------------------------------------------------------------------------
+ * SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * SFRs with an address ending with 0 or 8 are bit accessible.
+ * They are defined with the SFRBIT() macro that sets the name of each bit.
+ */
+
+/* Port 0 */
+__sfr __no_init volatile union { unsigned char P0; struct { unsigned char P0_0 : 1; unsigned char P0_1 : 1; unsigned char P0_2 : 1; unsigned char P0_3 : 1; unsigned char P0_4 : 1; unsigned char P0_5 : 1; unsigned char P0_6 : 1; unsigned char P0_7 : 1; }; } @ 0x80;
+__sfr __no_init volatile unsigned char SP @ 0x81; /* Stack Pointer */
+__sfr __no_init volatile unsigned char DPL0 @ 0x82; /* Data Pointer 0 Low Byte */
+__sfr __no_init volatile unsigned char DPH0 @ 0x83; /* Data Pointer 0 High Byte */
+__sfr __no_init volatile unsigned char DPL1 @ 0x84; /* Data Pointer 1 Low Byte */
+__sfr __no_init volatile unsigned char DPH1 @ 0x85; /* Data Pointer 1 High Byte */
+__sfr __no_init volatile unsigned char U0CSR @ 0x86; /* USART 0 Control and Status */
+__sfr __no_init volatile unsigned char PCON @ 0x87; /* Power Mode Control */
+
+/* Interrupt Flags */
+__sfr __no_init volatile union { unsigned char TCON; struct { unsigned char IT0 : 1; unsigned char RFERRIF : 1; unsigned char IT1 : 1; unsigned char URX0IF : 1; unsigned char _TCON4 : 1; unsigned char ADCIF : 1; unsigned char _TCON6 : 1; unsigned char URX1IF : 1; }; } @ 0x88;
+__sfr __no_init volatile unsigned char P0IFG @ 0x89; /* Port 0 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P1IFG @ 0x8A; /* Port 1 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P2IFG @ 0x8B; /* Port 2 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char PICTL @ 0x8C; /* Port Interrupt Control */
+__sfr __no_init volatile unsigned char P1IEN @ 0x8D; /* Port 1 Interrupt Mask */
+__sfr __no_init volatile unsigned char _SFR8E @ 0x8E; /* not used */
+__sfr __no_init volatile unsigned char P0INP @ 0x8F; /* Port 0 Input Mode */
+
+/* Port 1 */
+__sfr __no_init volatile union { unsigned char P1; struct { unsigned char P1_0 : 1; unsigned char P1_1 : 1; unsigned char P1_2 : 1; unsigned char P1_3 : 1; unsigned char P1_4 : 1; unsigned char P1_5 : 1; unsigned char P1_6 : 1; unsigned char P1_7 : 1; }; } @ 0x90;
+__sfr __no_init volatile unsigned char _SFR91 @ 0x91; /* reserved */
+__sfr __no_init volatile unsigned char DPS @ 0x92; /* Data Pointer Select */
+__sfr __no_init volatile unsigned char MPAGE @ 0x93; /* Memory Page Select */
+__sfr __no_init volatile unsigned char T2CTRL @ 0x94; /* Timer2 Control Register */
+__sfr __no_init volatile unsigned char ST0 @ 0x95; /* Sleep Timer 0 */
+__sfr __no_init volatile unsigned char ST1 @ 0x96; /* Sleep Timer 1 */
+__sfr __no_init volatile unsigned char ST2 @ 0x97; /* Sleep Timer 2 */
+
+/* Interrupt Flags 2 */
+__sfr __no_init volatile union { unsigned char S0CON; struct { unsigned char ENCIF_0 : 1; unsigned char ENCIF_1 : 1; unsigned char _S0CON2 : 1; unsigned char _S0CON3 : 1; unsigned char _S0CON4 : 1; unsigned char _S0CON5 : 1; unsigned char _S0CON6 : 1; unsigned char _S0CON7 : 1; }; } @ 0x98;
+__sfr __no_init volatile unsigned char _SFR99 @ 0x99; /* reserved */
+__sfr __no_init volatile unsigned char IEN2 @ 0x9A; /* Interrupt Enable 2 */
+__sfr __no_init volatile unsigned char S1CON @ 0x9B; /* Interrupt Flags 3 */
+__sfr __no_init volatile unsigned char T2CSPCFG @ 0x9C; /* Timer2 CSP Interface Configuration (legacy name) */
+__sfr __no_init volatile unsigned char T2EVTCFG @ 0x9C; /* Timer2 Event Output Configuration */
+__sfr __no_init volatile unsigned char SLEEPSTA @ 0x9D; /* Sleep Status */
+__sfr __no_init volatile unsigned char CLKCONSTA @ 0x9E; /* Clock Control Status */
+__sfr __no_init volatile unsigned char FMAP @ 0x9F; /* Flash Bank Map */
+
+/* Port 2 */
+__sfr __no_init volatile union { unsigned char P2; struct { unsigned char P2_0 : 1; unsigned char P2_1 : 1; unsigned char P2_2 : 1; unsigned char P2_3 : 1; unsigned char P2_4 : 1; unsigned char _P2_5 : 1; unsigned char _P2_6 : 1; unsigned char _P2_7 : 1; }; } @ 0xA0;
+__sfr __no_init volatile unsigned char T2IRQF @ 0xA1; /* Timer2 Interrupt Flags */
+__sfr __no_init volatile unsigned char T2M0 @ 0xA2; /* Timer2 Multiplexed Register 0 */
+__sfr __no_init volatile unsigned char T2M1 @ 0xA3; /* Timer2 Multiplexed Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF0 @ 0xA4; /* Timer2 Multiplexed Overflow Register 0 */
+__sfr __no_init volatile unsigned char T2MOVF1 @ 0xA5; /* Timer2 Multiplexed Overflow Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF2 @ 0xA6; /* Timer2 Multiplexed Overflow Register 2 */
+__sfr __no_init volatile unsigned char T2IRQM @ 0xA7; /* Timer2 Interrupt Mask */
+
+/* Interrupt Enable 0 */
+__sfr __no_init volatile union { unsigned char IEN0; struct { unsigned char RFERRIE : 1; unsigned char ADCIE : 1; unsigned char URX0IE : 1; unsigned char URX1IE : 1; unsigned char ENCIE : 1; unsigned char STIE : 1; unsigned char _IEN06 : 1; unsigned char EA : 1; }; } @ 0xA8;
+__sfr __no_init volatile unsigned char IP0 @ 0xA9; /* Interrupt Priority 0 */
+__sfr __no_init volatile unsigned char _SFRAA @ 0xAA; /* not used */
+__sfr __no_init volatile unsigned char P0IEN @ 0xAB; /* Port 0 Interrupt Mask */
+__sfr __no_init volatile unsigned char P2IEN @ 0xAC; /* Port 2 Interrupt Mask */
+__sfr __no_init volatile unsigned char STLOAD @ 0xAD; /* Sleep Timer Load Status */
+__sfr __no_init volatile unsigned char PMUX @ 0xAE; /* Power Down Signal MUX */
+__sfr __no_init volatile unsigned char T1STAT @ 0xAF; /* Timer 1 Status */
+
+__sfr __no_init volatile unsigned char _SFRB0 @ 0xB0; /* not used */
+__sfr __no_init volatile unsigned char ENCDI @ 0xB1; /* Encryption/Decryption Input Data */
+__sfr __no_init volatile unsigned char ENCDO @ 0xB2; /* Encryption/Decryption Output Data */
+__sfr __no_init volatile unsigned char ENCCS @ 0xB3; /* Encryption/Decryption Control and Status */
+__sfr __no_init volatile unsigned char ADCCON1 @ 0xB4; /* ADC Control 1 */
+__sfr __no_init volatile unsigned char ADCCON2 @ 0xB5; /* ADC Control 2 */
+__sfr __no_init volatile unsigned char ADCCON3 @ 0xB6; /* ADC Control 3 */
+__sfr __no_init volatile unsigned char _SFRB7 @ 0xB7; /* reserved */
+
+/* Interrupt Enable 1 */
+__sfr __no_init volatile union { unsigned char IEN1; struct { unsigned char DMAIE : 1; unsigned char T1IE : 1; unsigned char T2IE : 1; unsigned char T3IE : 1; unsigned char T4IE : 1; unsigned char P0IE : 1; unsigned char _IEN16 : 1; unsigned char _IEN17 : 1; }; } @ 0xB8;
+__sfr __no_init volatile unsigned char IP1 @ 0xB9; /* Interrupt Priority 1 */
+__sfr __no_init volatile unsigned char ADCL @ 0xBA; /* ADC Data Low */
+__sfr __no_init volatile unsigned char ADCH @ 0xBB; /* ADC Data High */
+__sfr __no_init volatile unsigned char RNDL @ 0xBC; /* Random Number Generator Low Byte */
+__sfr __no_init volatile unsigned char RNDH @ 0xBD; /* Random Number Generator High Byte */
+__sfr __no_init volatile unsigned char SLEEPCMD @ 0xBE; /* Sleep Mode Control Command */
+__sfr __no_init volatile unsigned char _SFRBF @ 0xBF; /* reserved */
+
+/* Interrupt Flags 4 */
+__sfr __no_init volatile union { unsigned char IRCON; struct { unsigned char DMAIF : 1; unsigned char T1IF : 1; unsigned char T2IF : 1; unsigned char T3IF : 1; unsigned char T4IF : 1; unsigned char P0IF : 1; unsigned char _IRCON6 : 1; unsigned char STIF : 1; }; } @ 0xC0;
+__sfr __no_init volatile unsigned char U0DBUF @ 0xC1; /* USART 0 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U0BAUD @ 0xC2; /* USART 0 Baud Rate Control */
+__sfr __no_init volatile unsigned char T2MSEL @ 0xC3; /* Timer2 Multiplex Select */
+__sfr __no_init volatile unsigned char U0UCR @ 0xC4; /* USART 0 UART Control */
+__sfr __no_init volatile unsigned char U0GCR @ 0xC5; /* USART 0 Generic Control */
+__sfr __no_init volatile unsigned char CLKCONCMD @ 0xC6; /* Clock Control Command */
+__sfr __no_init volatile unsigned char MEMCTR @ 0xC7; /* Memory System Control */
+
+__sfr __no_init volatile unsigned char _SFRC8 @ 0xC8; /* not used */
+__sfr __no_init volatile unsigned char WDCTL @ 0xC9; /* Watchdog Timer Control */
+__sfr __no_init volatile unsigned char T3CNT @ 0xCA; /* Timer 3 Counter */
+__sfr __no_init volatile unsigned char T3CTL @ 0xCB; /* Timer 3 Control */
+__sfr __no_init volatile unsigned char T3CCTL0 @ 0xCC; /* Timer 3 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC0 @ 0xCD; /* Timer 3 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T3CCTL1 @ 0xCE; /* Timer 3 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC1 @ 0xCF; /* Timer 3 Channel 1 Capture/Compare Value */
+
+ /* Program Status Word */
+__sfr __no_init volatile union { unsigned char PSW; struct { unsigned char P : 1; unsigned char F1 : 1; unsigned char OV : 1; unsigned char RS0 : 1; unsigned char RS1 : 1; unsigned char F0 : 1; unsigned char AC : 1; unsigned char CY : 1; }; } @ 0xD0;
+__sfr __no_init volatile unsigned char DMAIRQ @ 0xD1; /* DMA Interrupt Flag */
+__sfr __no_init volatile unsigned char DMA1CFGL @ 0xD2; /* DMA Channel 1-4 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA1CFGH @ 0xD3; /* DMA Channel 1-4 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMA0CFGL @ 0xD4; /* DMA Channel 0 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA0CFGH @ 0xD5; /* DMA Channel 0 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMAARM @ 0xD6; /* DMA Channel Arm */
+__sfr __no_init volatile unsigned char DMAREQ @ 0xD7; /* DMA Channel Start Request and Status */
+
+/* Timers 1/3/4 Interrupt Mask/Flag */
+__sfr __no_init volatile union { unsigned char TIMIF; struct { unsigned char T3OVFIF : 1; unsigned char T3CH0IF : 1; unsigned char T3CH1IF : 1; unsigned char T4OVFIF : 1; unsigned char T4CH0IF : 1; unsigned char T4CH1IF : 1; unsigned char T1OVFIM : 1; unsigned char _TIMIF7 : 1; }; } @ 0xD8;
+__sfr __no_init volatile unsigned char _SFRD9 @ 0xD9; /* reserved */
+__sfr __no_init volatile unsigned char T1CC0L @ 0xDA; /* Timer 1 Channel 0 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC0H @ 0xDB; /* Timer 1 Channel 0 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC1L @ 0xDC; /* Timer 1 Channel 1 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC1H @ 0xDD; /* Timer 1 Channel 1 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC2L @ 0xDE; /* Timer 1 Channel 2 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC2H @ 0xDF; /* Timer 1 Channel 2 Capture/Compare Value High Byte */
+
+__sfr __no_init volatile unsigned char ACC @ 0xE0; /* Accumulator */
+__sfr __no_init volatile unsigned char _SFRE1 @ 0xE1; /* reserved */
+__sfr __no_init volatile unsigned char T1CNTL @ 0xE2; /* Timer 1 Counter Low */
+__sfr __no_init volatile unsigned char T1CNTH @ 0xE3; /* Timer 1 Counter High */
+__sfr __no_init volatile unsigned char T1CTL @ 0xE4; /* Timer 1 Control And Status */
+__sfr __no_init volatile unsigned char T1CCTL0 @ 0xE5; /* Timer 1 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL1 @ 0xE6; /* Timer 1 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL2 @ 0xE7; /* Timer 1 Channel 2 Capture/Compare Control */
+
+/* Interrupt Flags 5 */
+__sfr __no_init volatile union { unsigned char IRCON2; struct { unsigned char P2IF : 1; unsigned char UTX0IF : 1; unsigned char UTX1IF : 1; unsigned char P1IF : 1; unsigned char WDTIF : 1; unsigned char _IRCON25 : 1; unsigned char _IRCON26 : 1; unsigned char _IRCON27 : 1; }; } @ 0xE8;
+__sfr __no_init volatile unsigned char _SFRE9 @ 0xE9; /* reserved */
+__sfr __no_init volatile unsigned char T4CNT @ 0xEA; /* Timer 4 Counter */
+__sfr __no_init volatile unsigned char T4CTL @ 0xEB; /* Timer 4 Control */
+__sfr __no_init volatile unsigned char T4CCTL0 @ 0xEC; /* Timer 4 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC0 @ 0xED; /* Timer 4 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T4CCTL1 @ 0xEE; /* Timer 4 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC1 @ 0xEF; /* Timer 4 Channel 1 Capture/Compare Value */
+
+__sfr __no_init volatile unsigned char B @ 0xF0; /* B Register */
+__sfr __no_init volatile unsigned char PERCFG @ 0xF1; /* Peripheral I/O Control */
+__sfr __no_init volatile unsigned char ADCCFG @ 0xF2; /* ADC Input Configuration (legacy name) */
+__sfr __no_init volatile unsigned char APCFG @ 0xF2; /* Analog Periferal I/O Configuration */
+__sfr __no_init volatile unsigned char P0SEL @ 0xF3; /* Port 0 Function Select */
+__sfr __no_init volatile unsigned char P1SEL @ 0xF4; /* Port 1 Function Select */
+__sfr __no_init volatile unsigned char P2SEL @ 0xF5; /* Port 2 Function Select */
+__sfr __no_init volatile unsigned char P1INP @ 0xF6; /* Port 1 Input Mode */
+__sfr __no_init volatile unsigned char P2INP @ 0xF7; /* Port 2 Input Mode */
+
+/* USART 1 Control and Status */
+__sfr __no_init volatile union { unsigned char U1CSR; struct { unsigned char U1ACTIVE : 1; unsigned char U1TX_BYTE : 1; unsigned char U1RX_BYTE : 1; unsigned char U1ERR : 1; unsigned char U1FE : 1; unsigned char U1SLAVE : 1; unsigned char U1RE : 1; unsigned char U1MODE : 1; }; } @ 0xF8;
+__sfr __no_init volatile unsigned char U1DBUF @ 0xF9; /* USART 1 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U1BAUD @ 0xFA; /* USART 1 Baud Rate Control */
+__sfr __no_init volatile unsigned char U1UCR @ 0xFB; /* USART 1 UART Control */
+__sfr __no_init volatile unsigned char U1GCR @ 0xFC; /* USART 1 Generic Control */
+__sfr __no_init volatile unsigned char P0DIR @ 0xFD; /* Port 0 Direction */
+__sfr __no_init volatile unsigned char P1DIR @ 0xFE; /* Port 1 Direction */
+__sfr __no_init volatile unsigned char P2DIR @ 0xFF; /* Port 2 Direction */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Radio Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Radio Control Registers */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata USB Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 329 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Observability Control */
+#line 345 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Identification */
+
+
+
+/* Debug Interface DMA Write to Flash */
+
+
+/* Flash Controller */
+#line 360 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Information */
+
+
+
+/* IR Generation Control */
+
+
+/* Clock Loss Detector */
+
+
+/* Timer 1 Channels (only mapped as XREG) */
+#line 378 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Definition which includes channels represented in SFR (additional XREG mapping of SFR) */
+#line 394 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Pointers for array access */
+
+
+
+/* Sleep Timer Capture Control */
+
+
+
+
+
+
+/* Op.Amp. Control */
+
+
+
+
+/* Analog Comparator Control */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Mapped SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * Most SFRs are also accessible through XDATA address space. The register definitions for
+ * this type of access are listed below. The register names are identical to the SFR names
+ * but with the prefix X_ to denote an XDATA register.
+ *
+ * Some SFRs are not accessible through XDATA space. For clarity, entries are included for these
+ * registers. They have a prefix of _NA to denote "not available."
+ *
+ * For register descriptions, refer to the actual SFR declartions elsewhere in this file.
+ */
+
+#line 437 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 446 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 455 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 465 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 474 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 483 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 492 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 501 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 510 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 519 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 528 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 537 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 546 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 555 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 565 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 574 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Flash
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ */
+
+
+#pragma language=default
+
+
+/**************************************************************************************************
+ */
+#line 76 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+#line 84 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ---------------------- Keil Compiler ---------------------- */
+#line 104 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+typedef unsigned char halIntState_t;
+
+
+
+
+
+ /* IAR library uses XCH instruction with EA. It may cause the higher priority interrupt to be
+ * locked out, therefore, may increase interrupt latency. It may also create a lockup condition.
+ * This workaround should only be used with 8051 using IAR compiler. When IAR fixes this by
+ * removing XCH usage in its library, compile the following macros to null to disable them.
+ */
+#line 131 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Reset Macro
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 142 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* disable interrupts, set watchdog timer, wait for reset */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 rev numbers
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 sleep common code
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* PCON bit definitions */
+
+
+/* SLEEPCMD bit definitions */
+
+
+
+/* SLEEPSTA bit definitions */
+
+
+
+/* SLEEPCMD and SLEEPSTA bit definitions */
+
+
+
+/* CLKCONCMD bit definitions */
+
+
+
+
+
+
+/* STLOAD */
+
+
+
+
+#line 199 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/**************************************************************************************************
+ */
+#line 45 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_sleep.h"
+/**************************************************************************************************
+ Filename: hal_sleep.h
+ Revised: $Date: 2013-02-27 11:32:02 -0800 (Wed, 27 Feb 2013) $
+ Revision: $Revision: 33315 $
+
+ Description: This file contains the interface to the power management service.
+
+
+ Copyright 2006-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Execute power management procedure
+ */
+extern void halSleep( uint32 osal_timer );
+
+/*
+ * Used in mac_mcu
+ */
+extern void halSleepWait(uint16 duration);
+
+/*
+ * Used in hal_drivers, AN044 - DELAY EXTERNAL INTERRUPTS
+ */
+extern void halRestoreSleepLevel( void );
+
+/*
+ * Used by the interrupt routines to exit from sleep.
+ */
+extern void halSleepExit(void);
+
+/*
+ * Set the max sleep loop time lesser than the T2 rollover period.
+ */
+extern void halSetMaxSleepLoopTime(uint32 rolloverTime);
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 46 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+
+
+/*********************************************************************
+ */
+// Internal (MCU) RAM addresses
+
+
+
+
+// Internal (MCU) heap size
+
+
+
+
+// Memory Allocation Heap
+
+
+
+
+
+
+// Initialization levels
+
+
+
+
+
+
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 state; // shift
+ uint8 keys; // keys
+} keyChange_t;
+
+// Timer clock and power-saving definitions
+
+
+
+/* OSAL timer defines */
+
+
+
+
+
+extern void _itoa(uint16 num, uint8 *buf, uint8 radix);
+
+
+
+
+
+
+/* Tx and Rx buffer size defines used by SPIMgr.c */
+
+
+
+
+
+/* system restart and boot loader used from MTEL.c */
+// Restart system from absolute beginning
+// Disables interrupts, forces WatchDog reset
+
+
+
+
+
+
+
+
+/* Reset reason for reset indication */
+
+
+/* port definition stuff used by MT */
+#line 133 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+
+/* sleep macros required by OSAL_PwrMgr.c */
+
+
+
+
+
+/* used by MTEL.c */
+uint8 OnBoard_SendKeys( uint8 keys, uint8 state );
+
+/*
+ * Board specific random number generator
+ */
+extern uint16 Onboard_rand( void );
+
+/*
+ * Get elapsed timer clock counts
+ * reset: reset count register if TRUE
+ */
+extern uint32 TimerElapsed( void );
+
+/*
+ * Initialize the Peripherals
+ * level: 0=cold, 1=warm, 2=ready
+ */
+extern void InitBoard( uint8 level );
+
+/*
+ * Register for all key events
+ */
+extern uint8 RegisterForKeys( uint8 task_id );
+
+/* Keypad Control Functions */
+
+/*
+ * Send "Key Pressed" message to application
+ */
+extern uint8 OnBoard_SendKeys( uint8 keys, uint8 shift);
+
+/*
+ * Callback routine to handle keys
+ */
+extern void OnBoard_KeyCallback ( uint8 keys, uint8 state );
+
+/*
+ * Perform a soft reset - jump to 0x0
+ */
+extern __near_func void Onboard_soft_reset( void );
+
+
+/*********************************************************************
+ */
+
+#line 50 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_assert.h"
+/**************************************************************************************************
+ Filename: hal_assert.h
+ Revised: $Date: 2009-02-16 18:03:22 -0800 (Mon, 16 Feb 2009) $
+ Revision: $Revision: 19172 $
+
+ Description: Describe the purpose and contents of the file.
+
+
+ Copyright 2006-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * HAL_ASSERT( expression ) - The given expression must evaluate as "true" or else the assert
+ * handler is called. From here, the call stack feature of the debugger can pinpoint where
+ * the problem occurred.
+ *
+ * HAL_ASSERT_FORCED( ) - If asserts are in use, immediately calls the assert handler.
+ *
+ * HAL_ASSERT_STATEMENT( statement ) - Inserts the given C statement but only when asserts
+ * are in use. This macros allows debug code that is not part of an expression.
+ *
+ * HAL_ASSERT_DECLARATION( declaration ) - Inserts the given C declaration but only when asserts
+ * are in use. This macros allows debug code that is not part of an expression.
+ *
+ * Asserts can be disabled for optimum performance and minimum code size (ideal for
+ * finalized, debugged production code). To disable, define the preprocessor
+ * symbol HALNODEBUG at the project level.
+ */
+
+
+#line 78 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_assert.h"
+
+
+/*
+ * This macro compares the size of the first parameter to the integer value
+ * of the second parameter. If they do not match, a compile time error for
+ * negative array size occurs (even gnu chokes on negative array size).
+ *
+ * This compare is done by creating a typedef for an array. No variables are
+ * created and no memory is consumed with this check. The created type is
+ * used for checking only and is not for use by any other code. The value
+ * of 10 in this macro is arbitrary, it just needs to be a value larger
+ * than one to result in a positive number for the array size.
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Prototypes
+ * ------------------------------------------------------------------------------------------------
+ */
+void halAssertHandler(void);
+
+
+/**************************************************************************************************
+ */
+
+/**************************************************************************************************
+ * FUNCTIONS - API
+ **************************************************************************************************/
+
+
+extern void halAssertHazardLights(void);
+#line 52 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+
+/* ------------------------------------------------------------------------------------------------
+ * Constants
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+// Round a value up to the ceiling of OSALMEM_HDRSZ for critical dependencies on even multiples.
+
+
+/* Minimum wasted bytes to justify splitting a block before allocation.
+ * Adjust accordingly to attempt to balance the tradeoff of wasted space and runtime throughput
+ * spent splitting blocks into sizes that may not be practically usable when sandwiched between
+ * two blocks in use (and thereby not able to be coalesced.)
+ * Ensure that this size is an even multiple of OSALMEM_HDRSZ.
+ */
+
+
+
+
+
+
+
+
+/*
+ * Profiling the sample apps with default settings shows the following long-lived allocations
+ * which should live at the bottom of the small-block bucket so that they are never iterated over
+ * by osal_mem_alloc/free(), nor ever considered for coalescing, etc. This saves significant
+ * run-time throughput (on 8051 SOC if not also MSP). This is dynamic "dead space" and is not
+ * available to the small-block bucket heap.
+ *
+ * Adjust this size accordingly to accomodate application-specific changes including changing the
+ * size of long-lived objects profiled by sample apps and long-lived objects added by application.
+ */
+#line 103 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+
+/* Adjust accordingly to attempt to accomodate the block sizes of the vast majority of
+ * very high frequency allocations/frees by profiling the system runtime.
+ * This default of 16 accomodates the OSAL timers block, osalTimerRec_t, and many others.
+ * Ensure that this size is an even multiple of OSALMEM_MIN_BLKSZ for run-time efficiency.
+ */
+#line 115 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+
+/*
+ * These numbers setup the size of the small-block bucket which is reserved at the front of the
+ * heap for allocations of OSALMEM_SMALL_BLKSZ or smaller.
+ */
+
+// Size of the heap bucket reserved for small block-sized allocations.
+// Adjust accordingly to attempt to accomodate the vast majority of very high frequency operations.
+
+// Index of the first available osalMemHdr_t after the small-block heap which will be set in-use in
+// order to prevent the small-block bucket from being coalesced with the wilderness.
+
+// Index of the first available osalMemHdr_t after the small-block heap which will be set in-use in
+
+// The size of the wilderness after losing the small-block heap, the wasted header to block the
+// small-block heap from being coalesced, and the wasted header to mark the end of the heap.
+
+// Index of the last available osalMemHdr_t at the end of the heap which will be set to zero for
+// fast comparisons with zero to determine the end of the heap.
+
+
+// For information about memory profiling, refer to SWRA204 "Heap Memory Management", section 1.5.
+#line 143 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+
+
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Typedefs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+typedef struct {
+ // The 15 LSB's of 'val' indicate the total item size, including the header, in 8-bit bytes.
+ unsigned len : 15;
+ // The 1 MSB of 'val' is used as a boolean to indicate in-use or freed.
+ unsigned inUse : 1;
+} osalMemHdrHdr_t;
+
+typedef union {
+ /* Dummy variable so compiler forces structure to alignment of largest element while not wasting
+ * space on targets when the halDataAlign_t is smaller than a UINT16.
+ */
+ halDataAlign_t alignDummy;
+ uint16 val;
+ osalMemHdrHdr_t hdr;
+} osalMemHdr_t;
+
+/* ------------------------------------------------------------------------------------------------
+ * Local Variables
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+static __no_init osalMemHdr_t theHeap[3072 / sizeof(osalMemHdr_t)];
+static __no_init osalMemHdr_t *ff1; // First free block in the small-block bucket.
+
+
+
+
+
+static uint8 osalMemStat; // Discrete status flags: 0x01 = kicked.
+
+#line 193 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+
+#line 207 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+
+/* ------------------------------------------------------------------------------------------------
+ * Global Variables
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+/**************************************************************************************************
+ * @fn osal_mem_init
+ *
+ * @brief This function is the OSAL heap memory management initialization callback.
+ *
+ * input parameters
+ *
+ * None.
+ *
+ * output parameters
+ *
+ * None.
+ *
+ * @return None.
+ */
+void osal_mem_init(void)
+{
+ ;
+ ;
+ ;
+
+
+
+
+
+ // Setup a NULL block at the end of the heap for fast comparisons with zero.
+ theHeap[((3072 / sizeof(osalMemHdr_t)) - 1)].val = 0;
+
+ // Setup the small-block bucket.
+ ff1 = theHeap;
+ ff1->val = (((((((16) + sizeof(osalMemHdr_t) - 1) / sizeof(osalMemHdr_t)) * sizeof(osalMemHdr_t))) * 8) + (((((417) + sizeof(osalMemHdr_t) - 1) / sizeof(osalMemHdr_t)) * sizeof(osalMemHdr_t)) + (19 * sizeof(osalMemHdr_t)))); // Set 'len' & clear 'inUse' field.
+ // Set 'len' & 'inUse' fields - this is a 'zero data bytes' lifetime allocation to block the
+ // small-block bucket from ever being coalesced with the wilderness.
+ theHeap[((((((((16) + sizeof(osalMemHdr_t) - 1) / sizeof(osalMemHdr_t)) * sizeof(osalMemHdr_t))) * 8) + (((((417) + sizeof(osalMemHdr_t) - 1) / sizeof(osalMemHdr_t)) * sizeof(osalMemHdr_t)) + (19 * sizeof(osalMemHdr_t)))) / sizeof(osalMemHdr_t))].val = (sizeof(osalMemHdr_t) | 0x8000);
+
+ // Setup the wilderness.
+ theHeap[(((((((((16) + sizeof(osalMemHdr_t) - 1) / sizeof(osalMemHdr_t)) * sizeof(osalMemHdr_t))) * 8) + (((((417) + sizeof(osalMemHdr_t) - 1) / sizeof(osalMemHdr_t)) * sizeof(osalMemHdr_t)) + (19 * sizeof(osalMemHdr_t)))) / sizeof(osalMemHdr_t)) + 1)].val = (3072 - (((((((16) + sizeof(osalMemHdr_t) - 1) / sizeof(osalMemHdr_t)) * sizeof(osalMemHdr_t))) * 8) + (((((417) + sizeof(osalMemHdr_t) - 1) / sizeof(osalMemHdr_t)) * sizeof(osalMemHdr_t)) + (19 * sizeof(osalMemHdr_t)))) - sizeof(osalMemHdr_t)*2); // Set 'len' & clear 'inUse' field.
+
+#line 261 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+}
+
+/**************************************************************************************************
+ * @fn osal_mem_kick
+ *
+ * @brief This function is the OSAL task initialization callback.
+ * @brief Kick the ff1 pointer out past the long-lived OSAL Task blocks.
+ * Invoke this once after all long-lived blocks have been allocated -
+ * presently at the end of osal_init_system().
+ *
+ * input parameters
+ *
+ * None.
+ *
+ * output parameters
+ *
+ * None.
+ *
+ * @return None.
+ */
+void osal_mem_kick(void)
+{
+ halIntState_t intState;
+ osalMemHdr_t *tmp = osal_mem_alloc(1);
+
+ ;
+ do { intState = EA; do { EA = 0; } while (287 == -1); } while (287 == -1); // Hold off interrupts.
+
+ /* All long-lived allocations have filled the LL block reserved in the small-block bucket.
+ * Set 'osalMemStat' so searching for memory in this bucket from here onward will only be done
+ * for sizes meeting the OSALMEM_SMALL_BLKSZ criteria.
+ */
+ ff1 = tmp - 1; // Set 'ff1' to point to the first available memory after the LL block.
+ osal_mem_free(tmp);
+ osalMemStat = 0x01; // Set 'osalMemStat' after the free because it enables memory profiling.
+
+ do { EA = intState; } while (297 == -1); // Re-enable interrupts.
+}
+
+/**************************************************************************************************
+ * @fn osal_mem_alloc
+ *
+ * @brief This function implements the OSAL dynamic memory allocation functionality.
+ *
+ * input parameters
+ *
+ * @param size - the number of bytes to allocate from the HEAP.
+ *
+ * output parameters
+ *
+ * None.
+ *
+ * @return None.
+ */
+
+
+
+void *osal_mem_alloc( uint16 size )
+
+{
+ osalMemHdr_t *prev = 0;
+ osalMemHdr_t *hdr;
+ halIntState_t intState;
+ uint8 coal = 0;
+
+ size += sizeof(osalMemHdr_t);
+
+ // Calculate required bytes to add to 'size' to align to halDataAlign_t.
+ if ( sizeof( halDataAlign_t ) == 2 )
+ {
+ size += (size & 0x01);
+ }
+ else if ( sizeof( halDataAlign_t ) != 1 )
+ {
+ const uint8 mod = size % sizeof( halDataAlign_t );
+
+ if ( mod != 0 )
+ {
+ size += (sizeof( halDataAlign_t ) - mod);
+ }
+ }
+
+ do { intState = EA; do { EA = 0; } while (343 == -1); } while (343 == -1); // Hold off interrupts.
+
+ // Smaller allocations are first attempted in the small-block bucket, and all long-lived
+ // allocations are channeled into the LL block reserved within this bucket.
+ if ((osalMemStat == 0) || (size <= (((((16) + sizeof(osalMemHdr_t) - 1) / sizeof(osalMemHdr_t)) * sizeof(osalMemHdr_t)))))
+ {
+ hdr = ff1;
+ }
+ else
+ {
+ hdr = (theHeap + (((((((((16) + sizeof(osalMemHdr_t) - 1) / sizeof(osalMemHdr_t)) * sizeof(osalMemHdr_t))) * 8) + (((((417) + sizeof(osalMemHdr_t) - 1) / sizeof(osalMemHdr_t)) * sizeof(osalMemHdr_t)) + (19 * sizeof(osalMemHdr_t)))) / sizeof(osalMemHdr_t)) + 1));
+ }
+
+ do
+ {
+ if ( hdr->hdr.inUse )
+ {
+ coal = 0;
+ }
+ else
+ {
+ if ( coal != 0 )
+ {
+
+
+
+
+
+ prev->hdr.len += hdr->hdr.len;
+
+ if ( prev->hdr.len >= size )
+ {
+ hdr = prev;
+ break;
+ }
+ }
+ else
+ {
+ if ( hdr->hdr.len >= size )
+ {
+ break;
+ }
+
+ coal = 1;
+ prev = hdr;
+ }
+ }
+
+ hdr = (osalMemHdr_t *)((uint8 *)hdr + hdr->hdr.len);
+
+ if ( hdr->val == 0 )
+ {
+ hdr = 0;
+ break;
+ }
+ } while (1);
+
+ if ( hdr != 0 )
+ {
+ uint16 tmp = hdr->hdr.len - size;
+
+ // Determine whether the threshold for splitting is met.
+ if ( tmp >= ((((((sizeof(osalMemHdr_t) * 2)) + sizeof(osalMemHdr_t) - 1) / sizeof(osalMemHdr_t)) * sizeof(osalMemHdr_t))) )
+ {
+ // Split the block before allocating it.
+ osalMemHdr_t *next = (osalMemHdr_t *)((uint8 *)hdr + size);
+ next->val = tmp; // Set 'len' & clear 'inUse' field.
+ hdr->val = (size | 0x8000); // Set 'len' & 'inUse' field.
+
+#line 420 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+ }
+ else
+ {
+
+
+
+
+
+ hdr->hdr.inUse = 1;
+ }
+
+#line 437 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+
+#line 475 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+
+ if ((osalMemStat != 0) && (ff1 == hdr))
+ {
+ ff1 = (osalMemHdr_t *)((uint8 *)hdr + hdr->hdr.len);
+ }
+
+ hdr++;
+ }
+
+ do { EA = intState; } while (484 == -1); // Re-enable interrupts.
+
+
+#pragma diag_suppress=Pe767
+ ;
+#pragma diag_default=Pe767
+#line 496 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+ return (void *)hdr;
+}
+
+/**************************************************************************************************
+ * @fn osal_mem_free
+ *
+ * @brief This function implements the OSAL dynamic memory de-allocation functionality.
+ *
+ * input parameters
+ *
+ * @param ptr - A valid pointer (i.e. a pointer returned by osal_mem_alloc()) to the memory to free.
+ *
+ * output parameters
+ *
+ * None.
+ *
+ * @return None.
+ */
+
+
+
+void osal_mem_free(void *ptr)
+
+{
+ osalMemHdr_t *hdr = (osalMemHdr_t *)ptr - 1;
+ halIntState_t intState;
+
+
+
+
+
+ ;
+ ;
+
+ do { intState = EA; do { EA = 0; } while (530 == -1); } while (530 == -1); // Hold off interrupts.
+ hdr->hdr.inUse = 0;
+
+ if (ff1 > hdr)
+ {
+ ff1 = hdr;
+ }
+
+#line 562 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+
+ do { EA = intState; } while (563 == -1); // Re-enable interrupts.
+}
+
+#line 623 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+
+#line 643 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Memory.c"
+
+/**************************************************************************************************
+*/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_PwrMgr.i b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_PwrMgr.i
new file mode 100644
index 0000000..e03cd55
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_PwrMgr.i
@@ -0,0 +1,2194 @@
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\common\\OSAL_PwrMgr.c"
+/**************************************************************************************************
+ Filename: OSAL_pwrmgr.c
+ Revised: $Date: 2011-09-16 19:09:24 -0700 (Fri, 16 Sep 2011) $
+ Revision: $Revision: 27618 $
+
+ Description: This file contains the OSAL Power Management API.
+
+
+ Copyright 2004-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+/**************************************************************************************************
+ Filename: comdef.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: Type definitions and macros.
+
+
+ Copyright 2004-2008 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/* HAL */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+/**
+ @headerfile: hal_types.h
+
+
+**************************************************************************************************/
+
+
+
+
+/* Texas Instruments CC2540 */
+
+/* ------------------------------------------------------------------------------------------------
+ * Types
+ * ------------------------------------------------------------------------------------------------
+ */
+/** @defgroup HAL_TYPES HAL Types
+ * @{
+ */
+typedef signed char int8; //!< Signed 8 bit integer
+typedef unsigned char uint8; //!< Unsigned 8 bit integer
+
+typedef signed short int16; //!< Signed 16 bit integer
+typedef unsigned short uint16; //!< Unsigned 16 bit integer
+
+typedef signed long int32; //!< Signed 32 bit integer
+typedef unsigned long uint32; //!< Unsigned 32 bit integer
+
+typedef unsigned char bool; //!< Boolean data type
+
+typedef uint8 halDataAlign_t; //!< Used for byte alignment
+/** @} End HAL_TYPES */
+
+/* ------------------------------------------------------------------------------------------------
+ * Memory Attributes and Compiler Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ----------- IAR Compiler ----------- */
+#line 82 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+/* ----------- KEIL Compiler ----------- */
+#line 105 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Standard Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************************************************
+ */
+#line 55 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+/**************************************************************************************************
+ Filename: hal_defs.h
+ Revised: $Date: 2012-08-17 16:28:43 -0700 (Fri, 17 Aug 2012) $
+ Revision: $Revision: 31295 $
+
+ Description: This file contains useful macros and data types
+
+
+ Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* takes a byte out of a uint32 : var - uint32, ByteNum - byte to take out (0 - 3) */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 101 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+
+/*
+ * This macro is for use by other macros to form a fully valid C statement.
+ * Without this, the if/else conditionals could show unexpected behavior.
+ *
+ * For example, use...
+ * #define SET_REGS() st( ioreg1 = 0; ioreg2 = 0; )
+ * instead of ...
+ * #define SET_REGS() { ioreg1 = 0; ioreg2 = 0; }
+ * or
+ * #define SET_REGS() ioreg1 = 0; ioreg2 = 0;
+ * The last macro would not behave as expected in the if/else construct.
+ * The second to last macro will cause a compiler error in certain uses
+ * of if/else construct
+ *
+ * It is not necessary, or recommended, to use this macro where there is
+ * already a valid C statement. For example, the following is redundant...
+ * #define CALL_FUNC() st( func(); )
+ * This should simply be...
+ * #define CALL_FUNC() func()
+ *
+ * (The while condition below evaluates false without generating a
+ * constant-controlling-loop type of warning on most compilers.)
+ */
+
+
+
+/**************************************************************************************************
+ */
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * Lint Keywords
+ */
+
+
+#line 71 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*** Generic Status Return Values ***/
+#line 107 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Generic Status return
+typedef uint8 Status_t;
+
+// Data types
+typedef int32 int24;
+typedef uint32 uint24;
+
+/*********************************************************************
+ * Global System Events
+ */
+
+
+
+/*********************************************************************
+ * Global Generic System Messages
+ */
+
+
+
+// OSAL System Message IDs/Events Reserved for applications (user applications)
+// 0xE0 – 0xFC
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 45 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\common\\OSAL_PwrMgr.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+/**************************************************************************************************
+ Filename: OnBoard.h
+ Revised: $Date: 2008-07-25 17:36:14 -0700 (Fri, 25 Jul 2008) $
+ Revision: $Revision: 17620 $
+
+ Description: Defines stuff for EVALuation boards
+ This file targets the Chipcon CC2540DB/CC2540EB
+
+
+ Copyright 2008-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+/**************************************************************************************************
+ Filename: hal_mcu.h
+ Revised: $Date: 2012-07-13 06:58:11 -0700 (Fri, 13 Jul 2012) $
+ Revision: $Revision: 30922 $
+
+ Description: Describe the purpose and contents of the file.
+
+
+ Copyright 2006-2010 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+/*
+ * Target : Texas Instruments CC2540 (8051 core)
+ *
+ */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Includes
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Target Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ---------------------- IAR Compiler ---------------------- */
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/**************************************************************************************************
+ * - ioCC2540.h -
+ *
+ * Header file with definitions for the Texas Instruments CC2540 low-power System-on-Chip:
+ * an 8051-based MCU with 2.4 GHz Bluetooth low energy RF transceiver, and up to 256 kB FLASH.
+ *
+ * This file supports the IAR Embedded Workbench for 8051.
+ *
+ **************************************************************************************************
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+#pragma language=extended
+#line 41 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 77 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Vectors
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 101 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * SFR Bit Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* USBIE P2IE , not in a bit addressable register */
+
+/* ------------------------------------------------------------------------------------------------
+ * SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * SFRs with an address ending with 0 or 8 are bit accessible.
+ * They are defined with the SFRBIT() macro that sets the name of each bit.
+ */
+
+/* Port 0 */
+__sfr __no_init volatile union { unsigned char P0; struct { unsigned char P0_0 : 1; unsigned char P0_1 : 1; unsigned char P0_2 : 1; unsigned char P0_3 : 1; unsigned char P0_4 : 1; unsigned char P0_5 : 1; unsigned char P0_6 : 1; unsigned char P0_7 : 1; }; } @ 0x80;
+__sfr __no_init volatile unsigned char SP @ 0x81; /* Stack Pointer */
+__sfr __no_init volatile unsigned char DPL0 @ 0x82; /* Data Pointer 0 Low Byte */
+__sfr __no_init volatile unsigned char DPH0 @ 0x83; /* Data Pointer 0 High Byte */
+__sfr __no_init volatile unsigned char DPL1 @ 0x84; /* Data Pointer 1 Low Byte */
+__sfr __no_init volatile unsigned char DPH1 @ 0x85; /* Data Pointer 1 High Byte */
+__sfr __no_init volatile unsigned char U0CSR @ 0x86; /* USART 0 Control and Status */
+__sfr __no_init volatile unsigned char PCON @ 0x87; /* Power Mode Control */
+
+/* Interrupt Flags */
+__sfr __no_init volatile union { unsigned char TCON; struct { unsigned char IT0 : 1; unsigned char RFERRIF : 1; unsigned char IT1 : 1; unsigned char URX0IF : 1; unsigned char _TCON4 : 1; unsigned char ADCIF : 1; unsigned char _TCON6 : 1; unsigned char URX1IF : 1; }; } @ 0x88;
+__sfr __no_init volatile unsigned char P0IFG @ 0x89; /* Port 0 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P1IFG @ 0x8A; /* Port 1 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P2IFG @ 0x8B; /* Port 2 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char PICTL @ 0x8C; /* Port Interrupt Control */
+__sfr __no_init volatile unsigned char P1IEN @ 0x8D; /* Port 1 Interrupt Mask */
+__sfr __no_init volatile unsigned char _SFR8E @ 0x8E; /* not used */
+__sfr __no_init volatile unsigned char P0INP @ 0x8F; /* Port 0 Input Mode */
+
+/* Port 1 */
+__sfr __no_init volatile union { unsigned char P1; struct { unsigned char P1_0 : 1; unsigned char P1_1 : 1; unsigned char P1_2 : 1; unsigned char P1_3 : 1; unsigned char P1_4 : 1; unsigned char P1_5 : 1; unsigned char P1_6 : 1; unsigned char P1_7 : 1; }; } @ 0x90;
+__sfr __no_init volatile unsigned char _SFR91 @ 0x91; /* reserved */
+__sfr __no_init volatile unsigned char DPS @ 0x92; /* Data Pointer Select */
+__sfr __no_init volatile unsigned char MPAGE @ 0x93; /* Memory Page Select */
+__sfr __no_init volatile unsigned char T2CTRL @ 0x94; /* Timer2 Control Register */
+__sfr __no_init volatile unsigned char ST0 @ 0x95; /* Sleep Timer 0 */
+__sfr __no_init volatile unsigned char ST1 @ 0x96; /* Sleep Timer 1 */
+__sfr __no_init volatile unsigned char ST2 @ 0x97; /* Sleep Timer 2 */
+
+/* Interrupt Flags 2 */
+__sfr __no_init volatile union { unsigned char S0CON; struct { unsigned char ENCIF_0 : 1; unsigned char ENCIF_1 : 1; unsigned char _S0CON2 : 1; unsigned char _S0CON3 : 1; unsigned char _S0CON4 : 1; unsigned char _S0CON5 : 1; unsigned char _S0CON6 : 1; unsigned char _S0CON7 : 1; }; } @ 0x98;
+__sfr __no_init volatile unsigned char _SFR99 @ 0x99; /* reserved */
+__sfr __no_init volatile unsigned char IEN2 @ 0x9A; /* Interrupt Enable 2 */
+__sfr __no_init volatile unsigned char S1CON @ 0x9B; /* Interrupt Flags 3 */
+__sfr __no_init volatile unsigned char T2CSPCFG @ 0x9C; /* Timer2 CSP Interface Configuration (legacy name) */
+__sfr __no_init volatile unsigned char T2EVTCFG @ 0x9C; /* Timer2 Event Output Configuration */
+__sfr __no_init volatile unsigned char SLEEPSTA @ 0x9D; /* Sleep Status */
+__sfr __no_init volatile unsigned char CLKCONSTA @ 0x9E; /* Clock Control Status */
+__sfr __no_init volatile unsigned char FMAP @ 0x9F; /* Flash Bank Map */
+
+/* Port 2 */
+__sfr __no_init volatile union { unsigned char P2; struct { unsigned char P2_0 : 1; unsigned char P2_1 : 1; unsigned char P2_2 : 1; unsigned char P2_3 : 1; unsigned char P2_4 : 1; unsigned char _P2_5 : 1; unsigned char _P2_6 : 1; unsigned char _P2_7 : 1; }; } @ 0xA0;
+__sfr __no_init volatile unsigned char T2IRQF @ 0xA1; /* Timer2 Interrupt Flags */
+__sfr __no_init volatile unsigned char T2M0 @ 0xA2; /* Timer2 Multiplexed Register 0 */
+__sfr __no_init volatile unsigned char T2M1 @ 0xA3; /* Timer2 Multiplexed Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF0 @ 0xA4; /* Timer2 Multiplexed Overflow Register 0 */
+__sfr __no_init volatile unsigned char T2MOVF1 @ 0xA5; /* Timer2 Multiplexed Overflow Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF2 @ 0xA6; /* Timer2 Multiplexed Overflow Register 2 */
+__sfr __no_init volatile unsigned char T2IRQM @ 0xA7; /* Timer2 Interrupt Mask */
+
+/* Interrupt Enable 0 */
+__sfr __no_init volatile union { unsigned char IEN0; struct { unsigned char RFERRIE : 1; unsigned char ADCIE : 1; unsigned char URX0IE : 1; unsigned char URX1IE : 1; unsigned char ENCIE : 1; unsigned char STIE : 1; unsigned char _IEN06 : 1; unsigned char EA : 1; }; } @ 0xA8;
+__sfr __no_init volatile unsigned char IP0 @ 0xA9; /* Interrupt Priority 0 */
+__sfr __no_init volatile unsigned char _SFRAA @ 0xAA; /* not used */
+__sfr __no_init volatile unsigned char P0IEN @ 0xAB; /* Port 0 Interrupt Mask */
+__sfr __no_init volatile unsigned char P2IEN @ 0xAC; /* Port 2 Interrupt Mask */
+__sfr __no_init volatile unsigned char STLOAD @ 0xAD; /* Sleep Timer Load Status */
+__sfr __no_init volatile unsigned char PMUX @ 0xAE; /* Power Down Signal MUX */
+__sfr __no_init volatile unsigned char T1STAT @ 0xAF; /* Timer 1 Status */
+
+__sfr __no_init volatile unsigned char _SFRB0 @ 0xB0; /* not used */
+__sfr __no_init volatile unsigned char ENCDI @ 0xB1; /* Encryption/Decryption Input Data */
+__sfr __no_init volatile unsigned char ENCDO @ 0xB2; /* Encryption/Decryption Output Data */
+__sfr __no_init volatile unsigned char ENCCS @ 0xB3; /* Encryption/Decryption Control and Status */
+__sfr __no_init volatile unsigned char ADCCON1 @ 0xB4; /* ADC Control 1 */
+__sfr __no_init volatile unsigned char ADCCON2 @ 0xB5; /* ADC Control 2 */
+__sfr __no_init volatile unsigned char ADCCON3 @ 0xB6; /* ADC Control 3 */
+__sfr __no_init volatile unsigned char _SFRB7 @ 0xB7; /* reserved */
+
+/* Interrupt Enable 1 */
+__sfr __no_init volatile union { unsigned char IEN1; struct { unsigned char DMAIE : 1; unsigned char T1IE : 1; unsigned char T2IE : 1; unsigned char T3IE : 1; unsigned char T4IE : 1; unsigned char P0IE : 1; unsigned char _IEN16 : 1; unsigned char _IEN17 : 1; }; } @ 0xB8;
+__sfr __no_init volatile unsigned char IP1 @ 0xB9; /* Interrupt Priority 1 */
+__sfr __no_init volatile unsigned char ADCL @ 0xBA; /* ADC Data Low */
+__sfr __no_init volatile unsigned char ADCH @ 0xBB; /* ADC Data High */
+__sfr __no_init volatile unsigned char RNDL @ 0xBC; /* Random Number Generator Low Byte */
+__sfr __no_init volatile unsigned char RNDH @ 0xBD; /* Random Number Generator High Byte */
+__sfr __no_init volatile unsigned char SLEEPCMD @ 0xBE; /* Sleep Mode Control Command */
+__sfr __no_init volatile unsigned char _SFRBF @ 0xBF; /* reserved */
+
+/* Interrupt Flags 4 */
+__sfr __no_init volatile union { unsigned char IRCON; struct { unsigned char DMAIF : 1; unsigned char T1IF : 1; unsigned char T2IF : 1; unsigned char T3IF : 1; unsigned char T4IF : 1; unsigned char P0IF : 1; unsigned char _IRCON6 : 1; unsigned char STIF : 1; }; } @ 0xC0;
+__sfr __no_init volatile unsigned char U0DBUF @ 0xC1; /* USART 0 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U0BAUD @ 0xC2; /* USART 0 Baud Rate Control */
+__sfr __no_init volatile unsigned char T2MSEL @ 0xC3; /* Timer2 Multiplex Select */
+__sfr __no_init volatile unsigned char U0UCR @ 0xC4; /* USART 0 UART Control */
+__sfr __no_init volatile unsigned char U0GCR @ 0xC5; /* USART 0 Generic Control */
+__sfr __no_init volatile unsigned char CLKCONCMD @ 0xC6; /* Clock Control Command */
+__sfr __no_init volatile unsigned char MEMCTR @ 0xC7; /* Memory System Control */
+
+__sfr __no_init volatile unsigned char _SFRC8 @ 0xC8; /* not used */
+__sfr __no_init volatile unsigned char WDCTL @ 0xC9; /* Watchdog Timer Control */
+__sfr __no_init volatile unsigned char T3CNT @ 0xCA; /* Timer 3 Counter */
+__sfr __no_init volatile unsigned char T3CTL @ 0xCB; /* Timer 3 Control */
+__sfr __no_init volatile unsigned char T3CCTL0 @ 0xCC; /* Timer 3 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC0 @ 0xCD; /* Timer 3 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T3CCTL1 @ 0xCE; /* Timer 3 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC1 @ 0xCF; /* Timer 3 Channel 1 Capture/Compare Value */
+
+ /* Program Status Word */
+__sfr __no_init volatile union { unsigned char PSW; struct { unsigned char P : 1; unsigned char F1 : 1; unsigned char OV : 1; unsigned char RS0 : 1; unsigned char RS1 : 1; unsigned char F0 : 1; unsigned char AC : 1; unsigned char CY : 1; }; } @ 0xD0;
+__sfr __no_init volatile unsigned char DMAIRQ @ 0xD1; /* DMA Interrupt Flag */
+__sfr __no_init volatile unsigned char DMA1CFGL @ 0xD2; /* DMA Channel 1-4 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA1CFGH @ 0xD3; /* DMA Channel 1-4 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMA0CFGL @ 0xD4; /* DMA Channel 0 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA0CFGH @ 0xD5; /* DMA Channel 0 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMAARM @ 0xD6; /* DMA Channel Arm */
+__sfr __no_init volatile unsigned char DMAREQ @ 0xD7; /* DMA Channel Start Request and Status */
+
+/* Timers 1/3/4 Interrupt Mask/Flag */
+__sfr __no_init volatile union { unsigned char TIMIF; struct { unsigned char T3OVFIF : 1; unsigned char T3CH0IF : 1; unsigned char T3CH1IF : 1; unsigned char T4OVFIF : 1; unsigned char T4CH0IF : 1; unsigned char T4CH1IF : 1; unsigned char T1OVFIM : 1; unsigned char _TIMIF7 : 1; }; } @ 0xD8;
+__sfr __no_init volatile unsigned char _SFRD9 @ 0xD9; /* reserved */
+__sfr __no_init volatile unsigned char T1CC0L @ 0xDA; /* Timer 1 Channel 0 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC0H @ 0xDB; /* Timer 1 Channel 0 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC1L @ 0xDC; /* Timer 1 Channel 1 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC1H @ 0xDD; /* Timer 1 Channel 1 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC2L @ 0xDE; /* Timer 1 Channel 2 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC2H @ 0xDF; /* Timer 1 Channel 2 Capture/Compare Value High Byte */
+
+__sfr __no_init volatile unsigned char ACC @ 0xE0; /* Accumulator */
+__sfr __no_init volatile unsigned char _SFRE1 @ 0xE1; /* reserved */
+__sfr __no_init volatile unsigned char T1CNTL @ 0xE2; /* Timer 1 Counter Low */
+__sfr __no_init volatile unsigned char T1CNTH @ 0xE3; /* Timer 1 Counter High */
+__sfr __no_init volatile unsigned char T1CTL @ 0xE4; /* Timer 1 Control And Status */
+__sfr __no_init volatile unsigned char T1CCTL0 @ 0xE5; /* Timer 1 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL1 @ 0xE6; /* Timer 1 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL2 @ 0xE7; /* Timer 1 Channel 2 Capture/Compare Control */
+
+/* Interrupt Flags 5 */
+__sfr __no_init volatile union { unsigned char IRCON2; struct { unsigned char P2IF : 1; unsigned char UTX0IF : 1; unsigned char UTX1IF : 1; unsigned char P1IF : 1; unsigned char WDTIF : 1; unsigned char _IRCON25 : 1; unsigned char _IRCON26 : 1; unsigned char _IRCON27 : 1; }; } @ 0xE8;
+__sfr __no_init volatile unsigned char _SFRE9 @ 0xE9; /* reserved */
+__sfr __no_init volatile unsigned char T4CNT @ 0xEA; /* Timer 4 Counter */
+__sfr __no_init volatile unsigned char T4CTL @ 0xEB; /* Timer 4 Control */
+__sfr __no_init volatile unsigned char T4CCTL0 @ 0xEC; /* Timer 4 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC0 @ 0xED; /* Timer 4 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T4CCTL1 @ 0xEE; /* Timer 4 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC1 @ 0xEF; /* Timer 4 Channel 1 Capture/Compare Value */
+
+__sfr __no_init volatile unsigned char B @ 0xF0; /* B Register */
+__sfr __no_init volatile unsigned char PERCFG @ 0xF1; /* Peripheral I/O Control */
+__sfr __no_init volatile unsigned char ADCCFG @ 0xF2; /* ADC Input Configuration (legacy name) */
+__sfr __no_init volatile unsigned char APCFG @ 0xF2; /* Analog Periferal I/O Configuration */
+__sfr __no_init volatile unsigned char P0SEL @ 0xF3; /* Port 0 Function Select */
+__sfr __no_init volatile unsigned char P1SEL @ 0xF4; /* Port 1 Function Select */
+__sfr __no_init volatile unsigned char P2SEL @ 0xF5; /* Port 2 Function Select */
+__sfr __no_init volatile unsigned char P1INP @ 0xF6; /* Port 1 Input Mode */
+__sfr __no_init volatile unsigned char P2INP @ 0xF7; /* Port 2 Input Mode */
+
+/* USART 1 Control and Status */
+__sfr __no_init volatile union { unsigned char U1CSR; struct { unsigned char U1ACTIVE : 1; unsigned char U1TX_BYTE : 1; unsigned char U1RX_BYTE : 1; unsigned char U1ERR : 1; unsigned char U1FE : 1; unsigned char U1SLAVE : 1; unsigned char U1RE : 1; unsigned char U1MODE : 1; }; } @ 0xF8;
+__sfr __no_init volatile unsigned char U1DBUF @ 0xF9; /* USART 1 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U1BAUD @ 0xFA; /* USART 1 Baud Rate Control */
+__sfr __no_init volatile unsigned char U1UCR @ 0xFB; /* USART 1 UART Control */
+__sfr __no_init volatile unsigned char U1GCR @ 0xFC; /* USART 1 Generic Control */
+__sfr __no_init volatile unsigned char P0DIR @ 0xFD; /* Port 0 Direction */
+__sfr __no_init volatile unsigned char P1DIR @ 0xFE; /* Port 1 Direction */
+__sfr __no_init volatile unsigned char P2DIR @ 0xFF; /* Port 2 Direction */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Radio Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Radio Control Registers */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata USB Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 329 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Observability Control */
+#line 345 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Identification */
+
+
+
+/* Debug Interface DMA Write to Flash */
+
+
+/* Flash Controller */
+#line 360 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Information */
+
+
+
+/* IR Generation Control */
+
+
+/* Clock Loss Detector */
+
+
+/* Timer 1 Channels (only mapped as XREG) */
+#line 378 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Definition which includes channels represented in SFR (additional XREG mapping of SFR) */
+#line 394 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Pointers for array access */
+
+
+
+/* Sleep Timer Capture Control */
+
+
+
+
+
+
+/* Op.Amp. Control */
+
+
+
+
+/* Analog Comparator Control */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Mapped SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * Most SFRs are also accessible through XDATA address space. The register definitions for
+ * this type of access are listed below. The register names are identical to the SFR names
+ * but with the prefix X_ to denote an XDATA register.
+ *
+ * Some SFRs are not accessible through XDATA space. For clarity, entries are included for these
+ * registers. They have a prefix of _NA to denote "not available."
+ *
+ * For register descriptions, refer to the actual SFR declartions elsewhere in this file.
+ */
+
+#line 437 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 446 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 455 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 465 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 474 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 483 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 492 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 501 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 510 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 519 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 528 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 537 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 546 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 555 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 565 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 574 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Flash
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ */
+
+
+#pragma language=default
+
+
+/**************************************************************************************************
+ */
+#line 76 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+#line 84 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ---------------------- Keil Compiler ---------------------- */
+#line 104 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+typedef unsigned char halIntState_t;
+
+
+
+
+
+ /* IAR library uses XCH instruction with EA. It may cause the higher priority interrupt to be
+ * locked out, therefore, may increase interrupt latency. It may also create a lockup condition.
+ * This workaround should only be used with 8051 using IAR compiler. When IAR fixes this by
+ * removing XCH usage in its library, compile the following macros to null to disable them.
+ */
+#line 131 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Reset Macro
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 142 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* disable interrupts, set watchdog timer, wait for reset */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 rev numbers
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 sleep common code
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* PCON bit definitions */
+
+
+/* SLEEPCMD bit definitions */
+
+
+
+/* SLEEPSTA bit definitions */
+
+
+
+/* SLEEPCMD and SLEEPSTA bit definitions */
+
+
+
+/* CLKCONCMD bit definitions */
+
+
+
+
+
+
+/* STLOAD */
+
+
+
+
+#line 199 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/**************************************************************************************************
+ */
+#line 45 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_sleep.h"
+/**************************************************************************************************
+ Filename: hal_sleep.h
+ Revised: $Date: 2013-02-27 11:32:02 -0800 (Wed, 27 Feb 2013) $
+ Revision: $Revision: 33315 $
+
+ Description: This file contains the interface to the power management service.
+
+
+ Copyright 2006-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Execute power management procedure
+ */
+extern void halSleep( uint32 osal_timer );
+
+/*
+ * Used in mac_mcu
+ */
+extern void halSleepWait(uint16 duration);
+
+/*
+ * Used in hal_drivers, AN044 - DELAY EXTERNAL INTERRUPTS
+ */
+extern void halRestoreSleepLevel( void );
+
+/*
+ * Used by the interrupt routines to exit from sleep.
+ */
+extern void halSleepExit(void);
+
+/*
+ * Set the max sleep loop time lesser than the T2 rollover period.
+ */
+extern void halSetMaxSleepLoopTime(uint32 rolloverTime);
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 46 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+/******************************************************************************
+ Filename: OSAL.h
+ Revised: $Date: 2012-02-17 15:07:16 -0800 (Fri, 17 Feb 2012) $
+ Revision: $Revision: 29376 $
+
+ Description: This API allows the software components in the Z-Stack to be
+ written independently of the specifics of the operating system,
+ kernel, or tasking environment (including control loops or
+ connect-to-interrupt systems).
+
+
+ Copyright 2004-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+/* - LIMITS.H -
+
+ Integral ANSI element sizes.
+
+ $Revision: 38615 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+/* - SYSMAC.H -
+
+ Defines system macros to maintain source compatibility
+ with different IAR compilers.
+
+ $Revision: 6040 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 65 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+#line 73 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+
+
+
+
+
+
+/* Macro for frmwri and frmrd */
+
+
+/* Typedefs put here to appear only once */
+typedef unsigned int size_t;
+typedef signed int ptrdiff_t;
+
+#line 18 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 80 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+/**************************************************************************************************
+ Filename: OSAL_Memory.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: This module defines the OSAL memory control functions.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialize memory manager.
+ */
+ void osal_mem_init( void );
+
+ /*
+ * Setup efficient search for the first free block of heap.
+ */
+ void osal_mem_kick( void );
+
+ /*
+ * Allocate a block of memory.
+ */
+
+
+
+
+ void *osal_mem_alloc( uint16 size );
+
+
+ /*
+ * Free a block of memory.
+ */
+
+
+
+
+ void osal_mem_free( void *ptr );
+
+
+#line 130 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+#line 137 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 59 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Timers.h"
+/**************************************************************************************************
+ Filename: OSAL_Timers.h
+ Revised: $Date: 2011-09-16 19:09:24 -0700 (Fri, 16 Sep 2011) $
+ Revision: $Revision: 27618 $
+
+ Description: This file contains the OSAL Timer definition and manipulation functions.
+
+
+ Copyright 2004-2009 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ * the unit is chosen such that the 320us tick equivalent can fit in
+ * 32 bits.
+ */
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialization for the OSAL Timer System.
+ */
+ extern void osalTimerInit( void );
+
+ /*
+ * Set a Timer
+ */
+ extern uint8 osal_start_timerEx( uint8 task_id, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Set a timer that reloads itself.
+ */
+ extern uint8 osal_start_reload_timer( uint8 taskID, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Stop a Timer
+ */
+ extern uint8 osal_stop_timerEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Get the tick count of a Timer.
+ */
+ extern uint32 osal_get_timeoutEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Simulated Timer Interrupt Service Routine
+ */
+
+ extern void osal_timer_ISR( void );
+
+ /*
+ * Adjust timer tables
+ */
+ extern void osal_adjust_timers( void );
+
+ /*
+ * Update timer tables
+ */
+ extern void osalTimerUpdate( uint32 updateTime );
+
+ /*
+ * Count active timers
+ */
+ extern uint8 osal_timer_num_active( void );
+
+ /*
+ * Set the hardware timer interrupts for sleep mode.
+ * These functions should only be called in OSAL_PwrMgr.c
+ */
+ extern void osal_sleep_timers( void );
+ extern void osal_unsleep_timers( void );
+
+ /*
+ * Read the system clock - returns milliseconds
+ */
+ extern uint32 osal_GetSystemClock( void );
+
+ /*
+ * Get the next OSAL timer expiration.
+ * This function should only be called in OSAL_PwrMgr.c
+ */
+ extern uint32 osal_next_timeout( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 60 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*** Interrupts ***/
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+typedef struct
+{
+ void *next;
+ uint16 len;
+ uint8 dest_id;
+} osal_msg_hdr_t;
+
+typedef struct
+{
+ uint8 event;
+ uint8 status;
+} osal_event_hdr_t;
+
+typedef void * osal_msg_q_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*** Message Management ***/
+
+ /*
+ * Task Message Allocation
+ */
+ extern uint8 * osal_msg_allocate(uint16 len );
+
+ /*
+ * Task Message Deallocation
+ */
+ extern uint8 osal_msg_deallocate( uint8 *msg_ptr );
+
+ /*
+ * Send a Task Message
+ */
+ extern uint8 osal_msg_send( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern uint8 osal_msg_push_front( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Receive a Task Message
+ */
+ extern uint8 *osal_msg_receive( uint8 task_id );
+
+ /*
+ * Find in place a matching Task Message / Event.
+ */
+ extern osal_event_hdr_t *osal_msg_find(uint8 task_id, uint8 event);
+
+ /*
+ * Enqueue a Task Message
+ */
+ extern void osal_msg_enqueue( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Enqueue a Task Message Up to Max
+ */
+ extern uint8 osal_msg_enqueue_max( osal_msg_q_t *q_ptr, void *msg_ptr, uint8 max );
+
+ /*
+ * Dequeue a Task Message
+ */
+ extern void *osal_msg_dequeue( osal_msg_q_t *q_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern void osal_msg_push( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Extract and remove a Task Message from queue
+ */
+ extern void osal_msg_extract( osal_msg_q_t *q_ptr, void *msg_ptr, void *prev_ptr );
+
+
+/*** Task Synchronization ***/
+
+ /*
+ * Set a Task Event
+ */
+ extern uint8 osal_set_event( uint8 task_id, uint16 event_flag );
+
+
+ /*
+ * Clear a Task Event
+ */
+ extern uint8 osal_clear_event( uint8 task_id, uint16 event_flag );
+
+
+/*** Interrupt Management ***/
+
+ /*
+ * Register Interrupt Service Routine (ISR)
+ */
+ extern uint8 osal_isr_register( uint8 interrupt_id, void (*isr_ptr)( uint8* ) );
+
+ /*
+ * Enable Interrupt
+ */
+ extern uint8 osal_int_enable( uint8 interrupt_id );
+
+ /*
+ * Disable Interrupt
+ */
+ extern uint8 osal_int_disable( uint8 interrupt_id );
+
+
+/*** Task Management ***/
+
+ /*
+ * Initialize the Task System
+ */
+ extern uint8 osal_init_system( void );
+
+ /*
+ * System Processing Loop
+ */
+
+
+
+ extern void osal_start_system( void );
+
+
+ /*
+ * One Pass Throu the OSAL Processing Loop
+ */
+ extern void osal_run_system( void );
+
+ /*
+ * Get the active task ID
+ */
+ extern uint8 osal_self( void );
+
+
+/*** Helper Functions ***/
+
+ /*
+ * String Length
+ */
+ extern int osal_strlen( char *pString );
+
+ /*
+ * Memory copy
+ */
+ extern void *osal_memcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory Duplicate - allocates and copies
+ */
+ extern void *osal_memdup( const void *src, unsigned int len );
+
+ /*
+ * Reverse Memory copy
+ */
+ extern void *osal_revmemcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory compare
+ */
+ extern uint8 osal_memcmp( const void *src1, const void *src2, unsigned int len );
+
+ /*
+ * Memory set
+ */
+ extern void *osal_memset( void *dest, uint8 value, int len );
+
+ /*
+ * Build a uint16 out of 2 bytes (0 then 1).
+ */
+ extern uint16 osal_build_uint16( uint8 *swapped );
+
+ /*
+ * Build a uint32 out of sequential bytes.
+ */
+ extern uint32 osal_build_uint32( uint8 *swapped, uint8 len );
+
+ /*
+ * Convert long to ascii string
+ */
+
+ extern uint8 *_ltoa( uint32 l, uint8 * buf, uint8 radix );
+
+
+ /*
+ * Random number generator
+ */
+ extern uint16 osal_rand( void );
+
+ /*
+ * Buffer an uint32 value - LSB first.
+ */
+ extern uint8* osal_buffer_uint32( uint8 *buf, uint32 val );
+
+ /*
+ * Buffer an uint24 value - LSB first
+ */
+ extern uint8* osal_buffer_uint24( uint8 *buf, uint24 val );
+
+ /*
+ * Is all of the array elements set to a value?
+ */
+ extern uint8 osal_isbufset( uint8 *buf, uint8 val, uint8 len );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 47 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+
+/*********************************************************************
+ */
+// Internal (MCU) RAM addresses
+
+
+
+
+// Internal (MCU) heap size
+
+
+
+
+// Memory Allocation Heap
+
+
+
+
+
+
+// Initialization levels
+
+
+
+
+
+
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 state; // shift
+ uint8 keys; // keys
+} keyChange_t;
+
+// Timer clock and power-saving definitions
+
+
+
+/* OSAL timer defines */
+
+
+
+
+
+extern void _itoa(uint16 num, uint8 *buf, uint8 radix);
+
+
+
+
+
+
+/* Tx and Rx buffer size defines used by SPIMgr.c */
+
+
+
+
+
+/* system restart and boot loader used from MTEL.c */
+// Restart system from absolute beginning
+// Disables interrupts, forces WatchDog reset
+
+
+
+
+
+
+
+
+/* Reset reason for reset indication */
+
+
+/* port definition stuff used by MT */
+#line 133 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+
+/* sleep macros required by OSAL_PwrMgr.c */
+
+
+
+
+
+/* used by MTEL.c */
+uint8 OnBoard_SendKeys( uint8 keys, uint8 state );
+
+/*
+ * Board specific random number generator
+ */
+extern uint16 Onboard_rand( void );
+
+/*
+ * Get elapsed timer clock counts
+ * reset: reset count register if TRUE
+ */
+extern uint32 TimerElapsed( void );
+
+/*
+ * Initialize the Peripherals
+ * level: 0=cold, 1=warm, 2=ready
+ */
+extern void InitBoard( uint8 level );
+
+/*
+ * Register for all key events
+ */
+extern uint8 RegisterForKeys( uint8 task_id );
+
+/* Keypad Control Functions */
+
+/*
+ * Send "Key Pressed" message to application
+ */
+extern uint8 OnBoard_SendKeys( uint8 keys, uint8 shift);
+
+/*
+ * Callback routine to handle keys
+ */
+extern void OnBoard_KeyCallback ( uint8 keys, uint8 state );
+
+/*
+ * Perform a soft reset - jump to 0x0
+ */
+extern __near_func void Onboard_soft_reset( void );
+
+
+/*********************************************************************
+ */
+
+#line 46 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\common\\OSAL_PwrMgr.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL_Tasks.h"
+/**************************************************************************************************
+ Filename: OSAL_Tasks.h
+ Revised: $Date: 2007-10-28 18:41:49 -0700 (Sun, 28 Oct 2007) $
+ Revision: $Revision: 15799 $
+
+ Description: This file contains the OSAL Task definition and manipulation functions.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*
+ * Event handler function prototype
+ */
+typedef unsigned short (*pTaskEventHandlerFn)( unsigned char task_id, unsigned short event );
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+extern const pTaskEventHandlerFn tasksArr[];
+extern const uint8 tasksCnt;
+extern uint16 *tasksEvents;
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Call each of the tasks initailization functions.
+ */
+extern void osalInitTasks( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 48 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\common\\OSAL_PwrMgr.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL_PwrMgr.h"
+/**************************************************************************************************
+ Filename: OSAL_PwrMgr.h
+ Revised: $Date: 2007-10-28 18:41:49 -0700 (Sun, 28 Oct 2007) $
+ Revision: $Revision: 15799 $
+
+ Description: This file contains the OSAL Power Management API.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/* These attributes define sleep beheaver. The attributes can be changed
+ * for each sleep cycle or when the device characteristic change.
+ */
+typedef struct
+{
+ uint16 pwrmgr_task_state;
+ uint16 pwrmgr_next_timeout;
+ uint16 accumulated_sleep_time;
+ uint8 pwrmgr_device;
+} pwrmgr_attribute_t;
+
+/* With PWRMGR_ALWAYS_ON selection, there is no power savings and the
+ * device is most likely on mains power. The PWRMGR_BATTERY selection allows
+ * the HAL sleep manager to enter SLEEP LITE state or SLEEP DEEP state.
+ */
+
+
+
+/* The PWRMGR_CONSERVE selection turns power savings on, all tasks have to
+ * agree. The PWRMGR_HOLD selection turns power savings off.
+ */
+
+
+
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/* This global variable stores the power management attributes.
+ */
+extern pwrmgr_attribute_t pwrmgr_attribute;
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialize the power management system.
+ * This function is called from OSAL.
+ *
+ */
+ extern void osal_pwrmgr_init( void );
+
+ /*
+ * This function is called by each task to state whether or not this
+ * task wants to conserve power. The task will call this function to
+ * vote whether it wants the OSAL to conserve power or it wants to
+ * hold off on the power savings. By default, when a task is created,
+ * its own power state is set to conserve. If the task always wants
+ * to converse power, it doesn't need to call this function at all.
+ * It is important for the task that changed the power manager task
+ * state to PWRMGR_HOLD to switch back to PWRMGR_CONSERVE when the
+ * hold period ends.
+ */
+ extern uint8 osal_pwrmgr_task_state( uint8 task_id, uint8 state );
+
+ /*
+ * This function is called on power-up, whenever the device characteristic
+ * change (ex. Battery backed coordinator). This function works with the timer
+ * to set HAL's power manager sleep state when power saving is entered.
+ * This function should be called form HAL initialization. After power up
+ * initialization, it should only be called from NWK or ZDO.
+ */
+ extern void osal_pwrmgr_device( uint8 pwrmgr_device );
+
+ /*
+ * This function is called from the main OSAL loop when there are
+ * no events scheduled and shouldn't be called from anywhere else.
+ */
+ extern void osal_pwrmgr_powerconserve( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 50 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\common\\OSAL_PwrMgr.c"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/* This global variable stores the power management attributes.
+ */
+pwrmgr_attribute_t pwrmgr_attribute;
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+/*********************************************************************
+ * LOCAL FUNCTION PROTOTYPES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ *********************************************************************/
+
+/*********************************************************************
+ * @fn osal_pwrmgr_init
+ *
+ * @brief Initialize the power management system.
+ *
+ * @param none.
+ *
+ * @return none.
+ */
+void osal_pwrmgr_init( void )
+{
+ pwrmgr_attribute.pwrmgr_device = 0; // Default to no power conservation.
+ pwrmgr_attribute.pwrmgr_task_state = 0; // Cleared. All set to conserve
+}
+
+/*********************************************************************
+ * @fn osal_pwrmgr_device
+ *
+ * @brief Sets the device power characteristic.
+ *
+ * @param pwrmgr_device - type of power devices. With PWRMGR_ALWAYS_ON
+ * selection, there is no power savings and the device is most
+ * likely on mains power. The PWRMGR_BATTERY selection allows the
+ * HAL sleep manager to enter sleep.
+ *
+ * @return none
+ */
+void osal_pwrmgr_device( uint8 pwrmgr_device )
+{
+ pwrmgr_attribute.pwrmgr_device = pwrmgr_device;
+}
+
+/*********************************************************************
+ * @fn osal_pwrmgr_task_state
+ *
+ * @brief This function is called by each task to state whether or
+ * not this task wants to conserve power.
+ *
+ * @param task_id - calling task ID.
+ * state - whether the calling task wants to
+ * conserve power or not.
+ *
+ * @return SUCCESS if task complete
+ */
+uint8 osal_pwrmgr_task_state( uint8 task_id, uint8 state )
+{
+ if ( task_id >= tasksCnt )
+ return ( 0x03 );
+
+ if ( state == 0 )
+ {
+ // Clear the task state flag
+ pwrmgr_attribute.pwrmgr_task_state &= ~(1 << task_id );
+ }
+ else
+ {
+ // Set the task state flag
+ pwrmgr_attribute.pwrmgr_task_state |= (1 << task_id);
+ }
+
+ return ( 0x00 );
+}
+
+#line 191 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\common\\OSAL_PwrMgr.c"
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_Timers.i b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_Timers.i
new file mode 100644
index 0000000..5f713db
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_Timers.i
@@ -0,0 +1,2888 @@
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Timers.c"
+/**************************************************************************************************
+ Filename: OSAL_Timers.c
+ Revised: $Date: 2012-11-28 00:37:02 -0800 (Wed, 28 Nov 2012) $
+ Revision: $Revision: 32329 $
+
+ Description: OSAL Timer definition and manipulation functions.
+
+
+ Copyright 2004-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+/**************************************************************************************************
+ Filename: comdef.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: Type definitions and macros.
+
+
+ Copyright 2004-2008 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/* HAL */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+/**
+ @headerfile: hal_types.h
+
+
+**************************************************************************************************/
+
+
+
+
+/* Texas Instruments CC2540 */
+
+/* ------------------------------------------------------------------------------------------------
+ * Types
+ * ------------------------------------------------------------------------------------------------
+ */
+/** @defgroup HAL_TYPES HAL Types
+ * @{
+ */
+typedef signed char int8; //!< Signed 8 bit integer
+typedef unsigned char uint8; //!< Unsigned 8 bit integer
+
+typedef signed short int16; //!< Signed 16 bit integer
+typedef unsigned short uint16; //!< Unsigned 16 bit integer
+
+typedef signed long int32; //!< Signed 32 bit integer
+typedef unsigned long uint32; //!< Unsigned 32 bit integer
+
+typedef unsigned char bool; //!< Boolean data type
+
+typedef uint8 halDataAlign_t; //!< Used for byte alignment
+/** @} End HAL_TYPES */
+
+/* ------------------------------------------------------------------------------------------------
+ * Memory Attributes and Compiler Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ----------- IAR Compiler ----------- */
+#line 82 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+/* ----------- KEIL Compiler ----------- */
+#line 105 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Standard Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************************************************
+ */
+#line 55 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+/**************************************************************************************************
+ Filename: hal_defs.h
+ Revised: $Date: 2012-08-17 16:28:43 -0700 (Fri, 17 Aug 2012) $
+ Revision: $Revision: 31295 $
+
+ Description: This file contains useful macros and data types
+
+
+ Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* takes a byte out of a uint32 : var - uint32, ByteNum - byte to take out (0 - 3) */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 101 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+
+/*
+ * This macro is for use by other macros to form a fully valid C statement.
+ * Without this, the if/else conditionals could show unexpected behavior.
+ *
+ * For example, use...
+ * #define SET_REGS() st( ioreg1 = 0; ioreg2 = 0; )
+ * instead of ...
+ * #define SET_REGS() { ioreg1 = 0; ioreg2 = 0; }
+ * or
+ * #define SET_REGS() ioreg1 = 0; ioreg2 = 0;
+ * The last macro would not behave as expected in the if/else construct.
+ * The second to last macro will cause a compiler error in certain uses
+ * of if/else construct
+ *
+ * It is not necessary, or recommended, to use this macro where there is
+ * already a valid C statement. For example, the following is redundant...
+ * #define CALL_FUNC() st( func(); )
+ * This should simply be...
+ * #define CALL_FUNC() func()
+ *
+ * (The while condition below evaluates false without generating a
+ * constant-controlling-loop type of warning on most compilers.)
+ */
+
+
+
+/**************************************************************************************************
+ */
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * Lint Keywords
+ */
+
+
+#line 71 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*** Generic Status Return Values ***/
+#line 107 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Generic Status return
+typedef uint8 Status_t;
+
+// Data types
+typedef int32 int24;
+typedef uint32 uint24;
+
+/*********************************************************************
+ * Global System Events
+ */
+
+
+
+/*********************************************************************
+ * Global Generic System Messages
+ */
+
+
+
+// OSAL System Message IDs/Events Reserved for applications (user applications)
+// 0xE0 – 0xFC
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 45 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Timers.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+/**************************************************************************************************
+ Filename: OnBoard.h
+ Revised: $Date: 2008-07-25 17:36:14 -0700 (Fri, 25 Jul 2008) $
+ Revision: $Revision: 17620 $
+
+ Description: Defines stuff for EVALuation boards
+ This file targets the Chipcon CC2540DB/CC2540EB
+
+
+ Copyright 2008-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+/**************************************************************************************************
+ Filename: hal_mcu.h
+ Revised: $Date: 2012-07-13 06:58:11 -0700 (Fri, 13 Jul 2012) $
+ Revision: $Revision: 30922 $
+
+ Description: Describe the purpose and contents of the file.
+
+
+ Copyright 2006-2010 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+/*
+ * Target : Texas Instruments CC2540 (8051 core)
+ *
+ */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Includes
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Target Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ---------------------- IAR Compiler ---------------------- */
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/**************************************************************************************************
+ * - ioCC2540.h -
+ *
+ * Header file with definitions for the Texas Instruments CC2540 low-power System-on-Chip:
+ * an 8051-based MCU with 2.4 GHz Bluetooth low energy RF transceiver, and up to 256 kB FLASH.
+ *
+ * This file supports the IAR Embedded Workbench for 8051.
+ *
+ **************************************************************************************************
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+#pragma language=extended
+#line 41 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 77 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Vectors
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 101 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * SFR Bit Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* USBIE P2IE , not in a bit addressable register */
+
+/* ------------------------------------------------------------------------------------------------
+ * SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * SFRs with an address ending with 0 or 8 are bit accessible.
+ * They are defined with the SFRBIT() macro that sets the name of each bit.
+ */
+
+/* Port 0 */
+__sfr __no_init volatile union { unsigned char P0; struct { unsigned char P0_0 : 1; unsigned char P0_1 : 1; unsigned char P0_2 : 1; unsigned char P0_3 : 1; unsigned char P0_4 : 1; unsigned char P0_5 : 1; unsigned char P0_6 : 1; unsigned char P0_7 : 1; }; } @ 0x80;
+__sfr __no_init volatile unsigned char SP @ 0x81; /* Stack Pointer */
+__sfr __no_init volatile unsigned char DPL0 @ 0x82; /* Data Pointer 0 Low Byte */
+__sfr __no_init volatile unsigned char DPH0 @ 0x83; /* Data Pointer 0 High Byte */
+__sfr __no_init volatile unsigned char DPL1 @ 0x84; /* Data Pointer 1 Low Byte */
+__sfr __no_init volatile unsigned char DPH1 @ 0x85; /* Data Pointer 1 High Byte */
+__sfr __no_init volatile unsigned char U0CSR @ 0x86; /* USART 0 Control and Status */
+__sfr __no_init volatile unsigned char PCON @ 0x87; /* Power Mode Control */
+
+/* Interrupt Flags */
+__sfr __no_init volatile union { unsigned char TCON; struct { unsigned char IT0 : 1; unsigned char RFERRIF : 1; unsigned char IT1 : 1; unsigned char URX0IF : 1; unsigned char _TCON4 : 1; unsigned char ADCIF : 1; unsigned char _TCON6 : 1; unsigned char URX1IF : 1; }; } @ 0x88;
+__sfr __no_init volatile unsigned char P0IFG @ 0x89; /* Port 0 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P1IFG @ 0x8A; /* Port 1 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P2IFG @ 0x8B; /* Port 2 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char PICTL @ 0x8C; /* Port Interrupt Control */
+__sfr __no_init volatile unsigned char P1IEN @ 0x8D; /* Port 1 Interrupt Mask */
+__sfr __no_init volatile unsigned char _SFR8E @ 0x8E; /* not used */
+__sfr __no_init volatile unsigned char P0INP @ 0x8F; /* Port 0 Input Mode */
+
+/* Port 1 */
+__sfr __no_init volatile union { unsigned char P1; struct { unsigned char P1_0 : 1; unsigned char P1_1 : 1; unsigned char P1_2 : 1; unsigned char P1_3 : 1; unsigned char P1_4 : 1; unsigned char P1_5 : 1; unsigned char P1_6 : 1; unsigned char P1_7 : 1; }; } @ 0x90;
+__sfr __no_init volatile unsigned char _SFR91 @ 0x91; /* reserved */
+__sfr __no_init volatile unsigned char DPS @ 0x92; /* Data Pointer Select */
+__sfr __no_init volatile unsigned char MPAGE @ 0x93; /* Memory Page Select */
+__sfr __no_init volatile unsigned char T2CTRL @ 0x94; /* Timer2 Control Register */
+__sfr __no_init volatile unsigned char ST0 @ 0x95; /* Sleep Timer 0 */
+__sfr __no_init volatile unsigned char ST1 @ 0x96; /* Sleep Timer 1 */
+__sfr __no_init volatile unsigned char ST2 @ 0x97; /* Sleep Timer 2 */
+
+/* Interrupt Flags 2 */
+__sfr __no_init volatile union { unsigned char S0CON; struct { unsigned char ENCIF_0 : 1; unsigned char ENCIF_1 : 1; unsigned char _S0CON2 : 1; unsigned char _S0CON3 : 1; unsigned char _S0CON4 : 1; unsigned char _S0CON5 : 1; unsigned char _S0CON6 : 1; unsigned char _S0CON7 : 1; }; } @ 0x98;
+__sfr __no_init volatile unsigned char _SFR99 @ 0x99; /* reserved */
+__sfr __no_init volatile unsigned char IEN2 @ 0x9A; /* Interrupt Enable 2 */
+__sfr __no_init volatile unsigned char S1CON @ 0x9B; /* Interrupt Flags 3 */
+__sfr __no_init volatile unsigned char T2CSPCFG @ 0x9C; /* Timer2 CSP Interface Configuration (legacy name) */
+__sfr __no_init volatile unsigned char T2EVTCFG @ 0x9C; /* Timer2 Event Output Configuration */
+__sfr __no_init volatile unsigned char SLEEPSTA @ 0x9D; /* Sleep Status */
+__sfr __no_init volatile unsigned char CLKCONSTA @ 0x9E; /* Clock Control Status */
+__sfr __no_init volatile unsigned char FMAP @ 0x9F; /* Flash Bank Map */
+
+/* Port 2 */
+__sfr __no_init volatile union { unsigned char P2; struct { unsigned char P2_0 : 1; unsigned char P2_1 : 1; unsigned char P2_2 : 1; unsigned char P2_3 : 1; unsigned char P2_4 : 1; unsigned char _P2_5 : 1; unsigned char _P2_6 : 1; unsigned char _P2_7 : 1; }; } @ 0xA0;
+__sfr __no_init volatile unsigned char T2IRQF @ 0xA1; /* Timer2 Interrupt Flags */
+__sfr __no_init volatile unsigned char T2M0 @ 0xA2; /* Timer2 Multiplexed Register 0 */
+__sfr __no_init volatile unsigned char T2M1 @ 0xA3; /* Timer2 Multiplexed Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF0 @ 0xA4; /* Timer2 Multiplexed Overflow Register 0 */
+__sfr __no_init volatile unsigned char T2MOVF1 @ 0xA5; /* Timer2 Multiplexed Overflow Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF2 @ 0xA6; /* Timer2 Multiplexed Overflow Register 2 */
+__sfr __no_init volatile unsigned char T2IRQM @ 0xA7; /* Timer2 Interrupt Mask */
+
+/* Interrupt Enable 0 */
+__sfr __no_init volatile union { unsigned char IEN0; struct { unsigned char RFERRIE : 1; unsigned char ADCIE : 1; unsigned char URX0IE : 1; unsigned char URX1IE : 1; unsigned char ENCIE : 1; unsigned char STIE : 1; unsigned char _IEN06 : 1; unsigned char EA : 1; }; } @ 0xA8;
+__sfr __no_init volatile unsigned char IP0 @ 0xA9; /* Interrupt Priority 0 */
+__sfr __no_init volatile unsigned char _SFRAA @ 0xAA; /* not used */
+__sfr __no_init volatile unsigned char P0IEN @ 0xAB; /* Port 0 Interrupt Mask */
+__sfr __no_init volatile unsigned char P2IEN @ 0xAC; /* Port 2 Interrupt Mask */
+__sfr __no_init volatile unsigned char STLOAD @ 0xAD; /* Sleep Timer Load Status */
+__sfr __no_init volatile unsigned char PMUX @ 0xAE; /* Power Down Signal MUX */
+__sfr __no_init volatile unsigned char T1STAT @ 0xAF; /* Timer 1 Status */
+
+__sfr __no_init volatile unsigned char _SFRB0 @ 0xB0; /* not used */
+__sfr __no_init volatile unsigned char ENCDI @ 0xB1; /* Encryption/Decryption Input Data */
+__sfr __no_init volatile unsigned char ENCDO @ 0xB2; /* Encryption/Decryption Output Data */
+__sfr __no_init volatile unsigned char ENCCS @ 0xB3; /* Encryption/Decryption Control and Status */
+__sfr __no_init volatile unsigned char ADCCON1 @ 0xB4; /* ADC Control 1 */
+__sfr __no_init volatile unsigned char ADCCON2 @ 0xB5; /* ADC Control 2 */
+__sfr __no_init volatile unsigned char ADCCON3 @ 0xB6; /* ADC Control 3 */
+__sfr __no_init volatile unsigned char _SFRB7 @ 0xB7; /* reserved */
+
+/* Interrupt Enable 1 */
+__sfr __no_init volatile union { unsigned char IEN1; struct { unsigned char DMAIE : 1; unsigned char T1IE : 1; unsigned char T2IE : 1; unsigned char T3IE : 1; unsigned char T4IE : 1; unsigned char P0IE : 1; unsigned char _IEN16 : 1; unsigned char _IEN17 : 1; }; } @ 0xB8;
+__sfr __no_init volatile unsigned char IP1 @ 0xB9; /* Interrupt Priority 1 */
+__sfr __no_init volatile unsigned char ADCL @ 0xBA; /* ADC Data Low */
+__sfr __no_init volatile unsigned char ADCH @ 0xBB; /* ADC Data High */
+__sfr __no_init volatile unsigned char RNDL @ 0xBC; /* Random Number Generator Low Byte */
+__sfr __no_init volatile unsigned char RNDH @ 0xBD; /* Random Number Generator High Byte */
+__sfr __no_init volatile unsigned char SLEEPCMD @ 0xBE; /* Sleep Mode Control Command */
+__sfr __no_init volatile unsigned char _SFRBF @ 0xBF; /* reserved */
+
+/* Interrupt Flags 4 */
+__sfr __no_init volatile union { unsigned char IRCON; struct { unsigned char DMAIF : 1; unsigned char T1IF : 1; unsigned char T2IF : 1; unsigned char T3IF : 1; unsigned char T4IF : 1; unsigned char P0IF : 1; unsigned char _IRCON6 : 1; unsigned char STIF : 1; }; } @ 0xC0;
+__sfr __no_init volatile unsigned char U0DBUF @ 0xC1; /* USART 0 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U0BAUD @ 0xC2; /* USART 0 Baud Rate Control */
+__sfr __no_init volatile unsigned char T2MSEL @ 0xC3; /* Timer2 Multiplex Select */
+__sfr __no_init volatile unsigned char U0UCR @ 0xC4; /* USART 0 UART Control */
+__sfr __no_init volatile unsigned char U0GCR @ 0xC5; /* USART 0 Generic Control */
+__sfr __no_init volatile unsigned char CLKCONCMD @ 0xC6; /* Clock Control Command */
+__sfr __no_init volatile unsigned char MEMCTR @ 0xC7; /* Memory System Control */
+
+__sfr __no_init volatile unsigned char _SFRC8 @ 0xC8; /* not used */
+__sfr __no_init volatile unsigned char WDCTL @ 0xC9; /* Watchdog Timer Control */
+__sfr __no_init volatile unsigned char T3CNT @ 0xCA; /* Timer 3 Counter */
+__sfr __no_init volatile unsigned char T3CTL @ 0xCB; /* Timer 3 Control */
+__sfr __no_init volatile unsigned char T3CCTL0 @ 0xCC; /* Timer 3 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC0 @ 0xCD; /* Timer 3 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T3CCTL1 @ 0xCE; /* Timer 3 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC1 @ 0xCF; /* Timer 3 Channel 1 Capture/Compare Value */
+
+ /* Program Status Word */
+__sfr __no_init volatile union { unsigned char PSW; struct { unsigned char P : 1; unsigned char F1 : 1; unsigned char OV : 1; unsigned char RS0 : 1; unsigned char RS1 : 1; unsigned char F0 : 1; unsigned char AC : 1; unsigned char CY : 1; }; } @ 0xD0;
+__sfr __no_init volatile unsigned char DMAIRQ @ 0xD1; /* DMA Interrupt Flag */
+__sfr __no_init volatile unsigned char DMA1CFGL @ 0xD2; /* DMA Channel 1-4 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA1CFGH @ 0xD3; /* DMA Channel 1-4 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMA0CFGL @ 0xD4; /* DMA Channel 0 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA0CFGH @ 0xD5; /* DMA Channel 0 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMAARM @ 0xD6; /* DMA Channel Arm */
+__sfr __no_init volatile unsigned char DMAREQ @ 0xD7; /* DMA Channel Start Request and Status */
+
+/* Timers 1/3/4 Interrupt Mask/Flag */
+__sfr __no_init volatile union { unsigned char TIMIF; struct { unsigned char T3OVFIF : 1; unsigned char T3CH0IF : 1; unsigned char T3CH1IF : 1; unsigned char T4OVFIF : 1; unsigned char T4CH0IF : 1; unsigned char T4CH1IF : 1; unsigned char T1OVFIM : 1; unsigned char _TIMIF7 : 1; }; } @ 0xD8;
+__sfr __no_init volatile unsigned char _SFRD9 @ 0xD9; /* reserved */
+__sfr __no_init volatile unsigned char T1CC0L @ 0xDA; /* Timer 1 Channel 0 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC0H @ 0xDB; /* Timer 1 Channel 0 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC1L @ 0xDC; /* Timer 1 Channel 1 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC1H @ 0xDD; /* Timer 1 Channel 1 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC2L @ 0xDE; /* Timer 1 Channel 2 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC2H @ 0xDF; /* Timer 1 Channel 2 Capture/Compare Value High Byte */
+
+__sfr __no_init volatile unsigned char ACC @ 0xE0; /* Accumulator */
+__sfr __no_init volatile unsigned char _SFRE1 @ 0xE1; /* reserved */
+__sfr __no_init volatile unsigned char T1CNTL @ 0xE2; /* Timer 1 Counter Low */
+__sfr __no_init volatile unsigned char T1CNTH @ 0xE3; /* Timer 1 Counter High */
+__sfr __no_init volatile unsigned char T1CTL @ 0xE4; /* Timer 1 Control And Status */
+__sfr __no_init volatile unsigned char T1CCTL0 @ 0xE5; /* Timer 1 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL1 @ 0xE6; /* Timer 1 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL2 @ 0xE7; /* Timer 1 Channel 2 Capture/Compare Control */
+
+/* Interrupt Flags 5 */
+__sfr __no_init volatile union { unsigned char IRCON2; struct { unsigned char P2IF : 1; unsigned char UTX0IF : 1; unsigned char UTX1IF : 1; unsigned char P1IF : 1; unsigned char WDTIF : 1; unsigned char _IRCON25 : 1; unsigned char _IRCON26 : 1; unsigned char _IRCON27 : 1; }; } @ 0xE8;
+__sfr __no_init volatile unsigned char _SFRE9 @ 0xE9; /* reserved */
+__sfr __no_init volatile unsigned char T4CNT @ 0xEA; /* Timer 4 Counter */
+__sfr __no_init volatile unsigned char T4CTL @ 0xEB; /* Timer 4 Control */
+__sfr __no_init volatile unsigned char T4CCTL0 @ 0xEC; /* Timer 4 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC0 @ 0xED; /* Timer 4 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T4CCTL1 @ 0xEE; /* Timer 4 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC1 @ 0xEF; /* Timer 4 Channel 1 Capture/Compare Value */
+
+__sfr __no_init volatile unsigned char B @ 0xF0; /* B Register */
+__sfr __no_init volatile unsigned char PERCFG @ 0xF1; /* Peripheral I/O Control */
+__sfr __no_init volatile unsigned char ADCCFG @ 0xF2; /* ADC Input Configuration (legacy name) */
+__sfr __no_init volatile unsigned char APCFG @ 0xF2; /* Analog Periferal I/O Configuration */
+__sfr __no_init volatile unsigned char P0SEL @ 0xF3; /* Port 0 Function Select */
+__sfr __no_init volatile unsigned char P1SEL @ 0xF4; /* Port 1 Function Select */
+__sfr __no_init volatile unsigned char P2SEL @ 0xF5; /* Port 2 Function Select */
+__sfr __no_init volatile unsigned char P1INP @ 0xF6; /* Port 1 Input Mode */
+__sfr __no_init volatile unsigned char P2INP @ 0xF7; /* Port 2 Input Mode */
+
+/* USART 1 Control and Status */
+__sfr __no_init volatile union { unsigned char U1CSR; struct { unsigned char U1ACTIVE : 1; unsigned char U1TX_BYTE : 1; unsigned char U1RX_BYTE : 1; unsigned char U1ERR : 1; unsigned char U1FE : 1; unsigned char U1SLAVE : 1; unsigned char U1RE : 1; unsigned char U1MODE : 1; }; } @ 0xF8;
+__sfr __no_init volatile unsigned char U1DBUF @ 0xF9; /* USART 1 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U1BAUD @ 0xFA; /* USART 1 Baud Rate Control */
+__sfr __no_init volatile unsigned char U1UCR @ 0xFB; /* USART 1 UART Control */
+__sfr __no_init volatile unsigned char U1GCR @ 0xFC; /* USART 1 Generic Control */
+__sfr __no_init volatile unsigned char P0DIR @ 0xFD; /* Port 0 Direction */
+__sfr __no_init volatile unsigned char P1DIR @ 0xFE; /* Port 1 Direction */
+__sfr __no_init volatile unsigned char P2DIR @ 0xFF; /* Port 2 Direction */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Radio Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Radio Control Registers */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata USB Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 329 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Observability Control */
+#line 345 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Identification */
+
+
+
+/* Debug Interface DMA Write to Flash */
+
+
+/* Flash Controller */
+#line 360 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Information */
+
+
+
+/* IR Generation Control */
+
+
+/* Clock Loss Detector */
+
+
+/* Timer 1 Channels (only mapped as XREG) */
+#line 378 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Definition which includes channels represented in SFR (additional XREG mapping of SFR) */
+#line 394 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Pointers for array access */
+
+
+
+/* Sleep Timer Capture Control */
+
+
+
+
+
+
+/* Op.Amp. Control */
+
+
+
+
+/* Analog Comparator Control */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Mapped SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * Most SFRs are also accessible through XDATA address space. The register definitions for
+ * this type of access are listed below. The register names are identical to the SFR names
+ * but with the prefix X_ to denote an XDATA register.
+ *
+ * Some SFRs are not accessible through XDATA space. For clarity, entries are included for these
+ * registers. They have a prefix of _NA to denote "not available."
+ *
+ * For register descriptions, refer to the actual SFR declartions elsewhere in this file.
+ */
+
+#line 437 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 446 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 455 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 465 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 474 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 483 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 492 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 501 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 510 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 519 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 528 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 537 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 546 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 555 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 565 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 574 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Flash
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ */
+
+
+#pragma language=default
+
+
+/**************************************************************************************************
+ */
+#line 76 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+#line 84 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ---------------------- Keil Compiler ---------------------- */
+#line 104 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+typedef unsigned char halIntState_t;
+
+
+
+
+
+ /* IAR library uses XCH instruction with EA. It may cause the higher priority interrupt to be
+ * locked out, therefore, may increase interrupt latency. It may also create a lockup condition.
+ * This workaround should only be used with 8051 using IAR compiler. When IAR fixes this by
+ * removing XCH usage in its library, compile the following macros to null to disable them.
+ */
+#line 131 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Reset Macro
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 142 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* disable interrupts, set watchdog timer, wait for reset */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 rev numbers
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 sleep common code
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* PCON bit definitions */
+
+
+/* SLEEPCMD bit definitions */
+
+
+
+/* SLEEPSTA bit definitions */
+
+
+
+/* SLEEPCMD and SLEEPSTA bit definitions */
+
+
+
+/* CLKCONCMD bit definitions */
+
+
+
+
+
+
+/* STLOAD */
+
+
+
+
+#line 199 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/**************************************************************************************************
+ */
+#line 45 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_sleep.h"
+/**************************************************************************************************
+ Filename: hal_sleep.h
+ Revised: $Date: 2013-02-27 11:32:02 -0800 (Wed, 27 Feb 2013) $
+ Revision: $Revision: 33315 $
+
+ Description: This file contains the interface to the power management service.
+
+
+ Copyright 2006-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Execute power management procedure
+ */
+extern void halSleep( uint32 osal_timer );
+
+/*
+ * Used in mac_mcu
+ */
+extern void halSleepWait(uint16 duration);
+
+/*
+ * Used in hal_drivers, AN044 - DELAY EXTERNAL INTERRUPTS
+ */
+extern void halRestoreSleepLevel( void );
+
+/*
+ * Used by the interrupt routines to exit from sleep.
+ */
+extern void halSleepExit(void);
+
+/*
+ * Set the max sleep loop time lesser than the T2 rollover period.
+ */
+extern void halSetMaxSleepLoopTime(uint32 rolloverTime);
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 46 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+/******************************************************************************
+ Filename: OSAL.h
+ Revised: $Date: 2012-02-17 15:07:16 -0800 (Fri, 17 Feb 2012) $
+ Revision: $Revision: 29376 $
+
+ Description: This API allows the software components in the Z-Stack to be
+ written independently of the specifics of the operating system,
+ kernel, or tasking environment (including control loops or
+ connect-to-interrupt systems).
+
+
+ Copyright 2004-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+/* - LIMITS.H -
+
+ Integral ANSI element sizes.
+
+ $Revision: 38615 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+/* - SYSMAC.H -
+
+ Defines system macros to maintain source compatibility
+ with different IAR compilers.
+
+ $Revision: 6040 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 65 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+#line 73 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+
+
+
+
+
+
+/* Macro for frmwri and frmrd */
+
+
+/* Typedefs put here to appear only once */
+typedef unsigned int size_t;
+typedef signed int ptrdiff_t;
+
+#line 18 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 80 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+/**************************************************************************************************
+ Filename: OSAL_Memory.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: This module defines the OSAL memory control functions.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialize memory manager.
+ */
+ void osal_mem_init( void );
+
+ /*
+ * Setup efficient search for the first free block of heap.
+ */
+ void osal_mem_kick( void );
+
+ /*
+ * Allocate a block of memory.
+ */
+
+
+
+
+ void *osal_mem_alloc( uint16 size );
+
+
+ /*
+ * Free a block of memory.
+ */
+
+
+
+
+ void osal_mem_free( void *ptr );
+
+
+#line 130 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+#line 137 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 59 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Timers.h"
+/**************************************************************************************************
+ Filename: OSAL_Timers.h
+ Revised: $Date: 2011-09-16 19:09:24 -0700 (Fri, 16 Sep 2011) $
+ Revision: $Revision: 27618 $
+
+ Description: This file contains the OSAL Timer definition and manipulation functions.
+
+
+ Copyright 2004-2009 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ * the unit is chosen such that the 320us tick equivalent can fit in
+ * 32 bits.
+ */
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialization for the OSAL Timer System.
+ */
+ extern void osalTimerInit( void );
+
+ /*
+ * Set a Timer
+ */
+ extern uint8 osal_start_timerEx( uint8 task_id, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Set a timer that reloads itself.
+ */
+ extern uint8 osal_start_reload_timer( uint8 taskID, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Stop a Timer
+ */
+ extern uint8 osal_stop_timerEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Get the tick count of a Timer.
+ */
+ extern uint32 osal_get_timeoutEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Simulated Timer Interrupt Service Routine
+ */
+
+ extern void osal_timer_ISR( void );
+
+ /*
+ * Adjust timer tables
+ */
+ extern void osal_adjust_timers( void );
+
+ /*
+ * Update timer tables
+ */
+ extern void osalTimerUpdate( uint32 updateTime );
+
+ /*
+ * Count active timers
+ */
+ extern uint8 osal_timer_num_active( void );
+
+ /*
+ * Set the hardware timer interrupts for sleep mode.
+ * These functions should only be called in OSAL_PwrMgr.c
+ */
+ extern void osal_sleep_timers( void );
+ extern void osal_unsleep_timers( void );
+
+ /*
+ * Read the system clock - returns milliseconds
+ */
+ extern uint32 osal_GetSystemClock( void );
+
+ /*
+ * Get the next OSAL timer expiration.
+ * This function should only be called in OSAL_PwrMgr.c
+ */
+ extern uint32 osal_next_timeout( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 60 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*** Interrupts ***/
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+typedef struct
+{
+ void *next;
+ uint16 len;
+ uint8 dest_id;
+} osal_msg_hdr_t;
+
+typedef struct
+{
+ uint8 event;
+ uint8 status;
+} osal_event_hdr_t;
+
+typedef void * osal_msg_q_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*** Message Management ***/
+
+ /*
+ * Task Message Allocation
+ */
+ extern uint8 * osal_msg_allocate(uint16 len );
+
+ /*
+ * Task Message Deallocation
+ */
+ extern uint8 osal_msg_deallocate( uint8 *msg_ptr );
+
+ /*
+ * Send a Task Message
+ */
+ extern uint8 osal_msg_send( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern uint8 osal_msg_push_front( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Receive a Task Message
+ */
+ extern uint8 *osal_msg_receive( uint8 task_id );
+
+ /*
+ * Find in place a matching Task Message / Event.
+ */
+ extern osal_event_hdr_t *osal_msg_find(uint8 task_id, uint8 event);
+
+ /*
+ * Enqueue a Task Message
+ */
+ extern void osal_msg_enqueue( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Enqueue a Task Message Up to Max
+ */
+ extern uint8 osal_msg_enqueue_max( osal_msg_q_t *q_ptr, void *msg_ptr, uint8 max );
+
+ /*
+ * Dequeue a Task Message
+ */
+ extern void *osal_msg_dequeue( osal_msg_q_t *q_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern void osal_msg_push( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Extract and remove a Task Message from queue
+ */
+ extern void osal_msg_extract( osal_msg_q_t *q_ptr, void *msg_ptr, void *prev_ptr );
+
+
+/*** Task Synchronization ***/
+
+ /*
+ * Set a Task Event
+ */
+ extern uint8 osal_set_event( uint8 task_id, uint16 event_flag );
+
+
+ /*
+ * Clear a Task Event
+ */
+ extern uint8 osal_clear_event( uint8 task_id, uint16 event_flag );
+
+
+/*** Interrupt Management ***/
+
+ /*
+ * Register Interrupt Service Routine (ISR)
+ */
+ extern uint8 osal_isr_register( uint8 interrupt_id, void (*isr_ptr)( uint8* ) );
+
+ /*
+ * Enable Interrupt
+ */
+ extern uint8 osal_int_enable( uint8 interrupt_id );
+
+ /*
+ * Disable Interrupt
+ */
+ extern uint8 osal_int_disable( uint8 interrupt_id );
+
+
+/*** Task Management ***/
+
+ /*
+ * Initialize the Task System
+ */
+ extern uint8 osal_init_system( void );
+
+ /*
+ * System Processing Loop
+ */
+
+
+
+ extern void osal_start_system( void );
+
+
+ /*
+ * One Pass Throu the OSAL Processing Loop
+ */
+ extern void osal_run_system( void );
+
+ /*
+ * Get the active task ID
+ */
+ extern uint8 osal_self( void );
+
+
+/*** Helper Functions ***/
+
+ /*
+ * String Length
+ */
+ extern int osal_strlen( char *pString );
+
+ /*
+ * Memory copy
+ */
+ extern void *osal_memcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory Duplicate - allocates and copies
+ */
+ extern void *osal_memdup( const void *src, unsigned int len );
+
+ /*
+ * Reverse Memory copy
+ */
+ extern void *osal_revmemcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory compare
+ */
+ extern uint8 osal_memcmp( const void *src1, const void *src2, unsigned int len );
+
+ /*
+ * Memory set
+ */
+ extern void *osal_memset( void *dest, uint8 value, int len );
+
+ /*
+ * Build a uint16 out of 2 bytes (0 then 1).
+ */
+ extern uint16 osal_build_uint16( uint8 *swapped );
+
+ /*
+ * Build a uint32 out of sequential bytes.
+ */
+ extern uint32 osal_build_uint32( uint8 *swapped, uint8 len );
+
+ /*
+ * Convert long to ascii string
+ */
+
+ extern uint8 *_ltoa( uint32 l, uint8 * buf, uint8 radix );
+
+
+ /*
+ * Random number generator
+ */
+ extern uint16 osal_rand( void );
+
+ /*
+ * Buffer an uint32 value - LSB first.
+ */
+ extern uint8* osal_buffer_uint32( uint8 *buf, uint32 val );
+
+ /*
+ * Buffer an uint24 value - LSB first
+ */
+ extern uint8* osal_buffer_uint24( uint8 *buf, uint24 val );
+
+ /*
+ * Is all of the array elements set to a value?
+ */
+ extern uint8 osal_isbufset( uint8 *buf, uint8 val, uint8 len );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 47 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+
+/*********************************************************************
+ */
+// Internal (MCU) RAM addresses
+
+
+
+
+// Internal (MCU) heap size
+
+
+
+
+// Memory Allocation Heap
+
+
+
+
+
+
+// Initialization levels
+
+
+
+
+
+
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 state; // shift
+ uint8 keys; // keys
+} keyChange_t;
+
+// Timer clock and power-saving definitions
+
+
+
+/* OSAL timer defines */
+
+
+
+
+
+extern void _itoa(uint16 num, uint8 *buf, uint8 radix);
+
+
+
+
+
+
+/* Tx and Rx buffer size defines used by SPIMgr.c */
+
+
+
+
+
+/* system restart and boot loader used from MTEL.c */
+// Restart system from absolute beginning
+// Disables interrupts, forces WatchDog reset
+
+
+
+
+
+
+
+
+/* Reset reason for reset indication */
+
+
+/* port definition stuff used by MT */
+#line 133 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\common\\cc2540\\OnBoard.h"
+
+/* sleep macros required by OSAL_PwrMgr.c */
+
+
+
+
+
+/* used by MTEL.c */
+uint8 OnBoard_SendKeys( uint8 keys, uint8 state );
+
+/*
+ * Board specific random number generator
+ */
+extern uint16 Onboard_rand( void );
+
+/*
+ * Get elapsed timer clock counts
+ * reset: reset count register if TRUE
+ */
+extern uint32 TimerElapsed( void );
+
+/*
+ * Initialize the Peripherals
+ * level: 0=cold, 1=warm, 2=ready
+ */
+extern void InitBoard( uint8 level );
+
+/*
+ * Register for all key events
+ */
+extern uint8 RegisterForKeys( uint8 task_id );
+
+/* Keypad Control Functions */
+
+/*
+ * Send "Key Pressed" message to application
+ */
+extern uint8 OnBoard_SendKeys( uint8 keys, uint8 shift);
+
+/*
+ * Callback routine to handle keys
+ */
+extern void OnBoard_KeyCallback ( uint8 keys, uint8 state );
+
+/*
+ * Perform a soft reset - jump to 0x0
+ */
+extern __near_func void Onboard_soft_reset( void );
+
+
+/*********************************************************************
+ */
+
+#line 46 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Timers.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_timer.h"
+/**************************************************************************************************
+ Filename: hal_timer.h
+ Revised: $Date: 2007-07-06 10:42:24 -0700 (Fri, 06 Jul 2007) $
+ Revision: $Revision: 13579 $
+
+ Description: This file contains the interface to the Timer Service.
+
+
+ Copyright 2005-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/***************************************************************************************************
+ * INCLUDES
+ ***************************************************************************************************/
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\include\\hal_board.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+/*******************************************************************************
+ Filename: hal_board_cfg.h
+ Revised: $Date: 2013-02-27 11:32:02 -0800 (Wed, 27 Feb 2013) $
+ Revision: $Revision: 33315 $
+
+ Description:
+
+ Abstract board-specific registers, addresses, & initialization for H/W based on the
+ Texas Instruments CC254x (8051 core).
+
+
+ Copyright 2006-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+ * INCLUDES
+ */
+
+
+
+
+
+/*******************************************************************************
+ * CONSTANTS
+ */
+
+/* Board Identifier */
+
+
+
+
+
+/* Clock Speed */
+
+
+
+/* Sleep Clock */
+
+
+
+
+// For non-USB, assume external, unless an internal crystal is explicitly indicated.
+
+
+
+
+
+
+// Minimum Time for Stable External 32kHz Clock (in ms)
+
+
+/* LCD Max Chars and Buffer */
+
+
+
+/* LED Configuration */
+
+#line 101 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+
+
+/* 1 - Green */
+
+
+
+
+
+
+ /* 2 - Red */
+
+
+
+
+
+ /* 3 - Yellow */
+
+
+
+
+
+
+/* Push Button Configuration */
+
+
+
+
+/* S1 */
+
+
+
+#line 140 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Joystick Center Press */
+
+
+
+
+/* OSAL NV implemented by internal flash pages. */
+
+// Flash is partitioned into 8 banks of 32 KB or 16 pages.
+
+
+// Flash is constructed of 128 pages of 2 KB.
+
+
+// SNV can use a larger logical page size to accomodate more or bigger items or extend lifetime.
+
+
+
+// CODE banks get mapped into the XDATA range 8000-FFFF.
+
+
+// The last 16 bytes of the last available page are reserved for flash lock bits.
+
+
+// NV page definitions must coincide with segment declaration in project *.xcl file.
+#line 172 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+// Re-defining Z_EXTADDR_LEN here so as not to include a Z-Stack .h file.
+
+
+
+
+
+
+
+
+// Used by DMA macros to shift 1 to create a mask for DMA registers.
+
+
+
+
+
+
+
+/* Critical Vdd Monitoring to prevent flash damage or radio lockup. */
+
+// Vdd/3 / Internal Reference X ENOB --> (Vdd / 3) / 1.15 X 127
+
+
+
+
+
+
+
+/*******************************************************************************
+ * MACROS
+ */
+
+/* Cache Prefetch Control */
+
+
+
+
+/* Setting Clocks */
+
+// switch to the 16MHz HSOSC and wait until it is stable
+
+
+
+
+
+
+// switch to the 32MHz XOSC and wait until it is stable
+
+
+
+
+
+
+// set 32kHz OSC and wait until it is stable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* Board Initialization */
+#line 256 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Debounce */
+
+
+/* ----------- Push Buttons ---------- */
+#line 267 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* LED's */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 315 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* XNV */
+
+
+
+
+
+
+
+// The TI reference design uses UART1 Alt. 2 in SPI mode.
+#line 356 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Driver Configuration */
+
+/* Set to TRUE enable H/W TIMER usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable ADC usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable DMA usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable Flash access, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable AES usage, FALSE disable it */
+
+
+
+
+
+
+
+
+/* Set to TRUE enable LCD usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable LED usage, FALSE disable it */
+#line 400 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Set to TRUE enable KEY usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable UART usage, FALSE disable it */
+#line 414 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+
+ // Always prefer to use DMA over ISR.
+#line 444 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+ // Used to set P2 priority - USART0 over USART1 if both are defined.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+*/
+#line 2 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\include\\hal_board.h"
+#line 52 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_timer.h"
+
+/***************************************************************************************************
+ * MACROS
+ ***************************************************************************************************/
+
+
+
+/***************************************************************************************************
+ * CONSTANTS
+ ***************************************************************************************************/
+/* Timer ID definitions */
+
+
+
+
+
+
+/* Operation Modes for timer */
+
+
+
+
+/* Timer1 channels */
+
+
+
+
+
+
+/* Channel definitions */
+#line 95 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_timer.h"
+
+/* Timer 1 Channel 0 Channel compare mode definitions */
+#line 103 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_timer.h"
+
+/* Timer 1 Channel 1-5 channel compare mode definitions */
+
+
+
+
+ // compare, clear on 0.
+
+ // on compare, set on 0
+
+
+
+
+
+/* Timer 1 Capture mode */
+
+
+
+
+
+
+/* Channel mode definitions */
+#line 131 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_timer.h"
+
+/* Error Code */
+#line 140 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_timer.h"
+
+/* Timer clock pre-scaler definitions for 16bit timer1 and timer3 */
+#line 150 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_timer.h"
+
+/* Timer clock pre-scaler definitions for 8bit timer0 and timer2 */
+#line 160 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_timer.h"
+
+/* Timer clock pre-scaler definitions for 8bit timer2 */
+#line 170 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_timer.h"
+
+
+/***************************************************************************************************
+ * TYPEDEFS
+ ***************************************************************************************************/
+typedef void (*halTimerCBack_t) (uint8 timerId, uint8 channel, uint8 channelMode);
+
+/***************************************************************************************************
+ * GLOBAL VARIABLES
+ ***************************************************************************************************/
+
+
+/***************************************************************************************************
+ * FUNCTIONS - API
+ ***************************************************************************************************/
+
+/*
+ * Initialize Timer Service
+ */
+extern void HalTimerInit ( void );
+
+/*
+ * Configure channel in different modes
+ */
+extern uint8 HalTimerConfig ( uint8 timerId,
+ uint8 opMode,
+ uint8 channel,
+ uint8 channelMode,
+ bool intEnable,
+ halTimerCBack_t cback );
+
+/*
+ * Start a Timer
+ */
+extern uint8 HalTimerStart ( uint8 timerId, uint32 timePerTick );
+
+/*
+ * Stop a Timer
+ */
+extern uint8 HalTimerStop ( uint8 timerId );
+
+
+/*
+ * This is used for polling, provide the tick increment
+ */
+extern void HalTimerTick ( void );
+
+/*
+ * Enable and disable particular timer
+ */
+extern uint8 HalTimerInterruptEnable (uint8 timerId, uint8 channelMode, bool enable);
+
+/*
+ * Configures timer 1 to control 4 PWM outputs
+ */
+void HalTimer1Init (halTimerCBack_t cBack);
+
+
+/*
+ * Set dutycycle on timer 1 PWM output channel
+ */
+void halTimer1SetChannelDuty (uint8 channel, uint16 promill);
+
+/***************************************************************************************************
+***************************************************************************************************/
+
+
+
+
+
+#line 49 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Timers.c"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+typedef union {
+ uint32 time32;
+ uint16 time16[2];
+ uint8 time8[4];
+} osalTime_t;
+
+typedef struct
+{
+ void *next;
+ osalTime_t timeout;
+ uint16 event_flag;
+ uint8 task_id;
+ uint32 reloadTimeout;
+} osalTimerRec_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+osalTimerRec_t *timerHead;
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+// Milliseconds since last reboot
+static uint32 osal_systemClock;
+
+/*********************************************************************
+ * LOCAL FUNCTION PROTOTYPES
+ */
+osalTimerRec_t *osalAddTimer( uint8 task_id, uint16 event_flag, uint32 timeout );
+osalTimerRec_t *osalFindTimer( uint8 task_id, uint16 event_flag );
+void osalDeleteTimer( osalTimerRec_t *rmTimer );
+
+/*********************************************************************
+ * FUNCTIONS
+ *********************************************************************/
+
+/*********************************************************************
+ * @fn osalTimerInit
+ *
+ * @brief Initialization for the OSAL Timer System.
+ *
+ * @param none
+ *
+ * @return
+ */
+void osalTimerInit( void )
+{
+ osal_systemClock = 0;
+}
+
+/*********************************************************************
+ * @fn osalAddTimer
+ *
+ * @brief Add a timer to the timer list.
+ * Ints must be disabled.
+ *
+ * @param task_id
+ * @param event_flag
+ * @param timeout
+ *
+ * @return osalTimerRec_t * - pointer to newly created timer
+ */
+osalTimerRec_t * osalAddTimer( uint8 task_id, uint16 event_flag, uint32 timeout )
+{
+ osalTimerRec_t *newTimer;
+ osalTimerRec_t *srchTimer;
+
+ // Look for an existing timer first
+ newTimer = osalFindTimer( task_id, event_flag );
+ if ( newTimer )
+ {
+ // Timer is found - update it.
+ newTimer->timeout.time32 = timeout;
+
+ return ( newTimer );
+ }
+ else
+ {
+ // New Timer
+ newTimer = osal_mem_alloc( sizeof( osalTimerRec_t ) );
+
+ if ( newTimer )
+ {
+ // Fill in new timer
+ newTimer->task_id = task_id;
+ newTimer->event_flag = event_flag;
+ newTimer->timeout.time32 = timeout;
+ newTimer->next = (void *)0;
+ newTimer->reloadTimeout = 0;
+
+ // Does the timer list already exist
+ if ( timerHead == 0 )
+ {
+ // Start task list
+ timerHead = newTimer;
+ }
+ else
+ {
+ // Add it to the end of the timer list
+ srchTimer = timerHead;
+
+ // Stop at the last record
+ while ( srchTimer->next )
+ srchTimer = srchTimer->next;
+
+ // Add to the list
+ srchTimer->next = newTimer;
+ }
+
+ return ( newTimer );
+ }
+ else
+ {
+ return ( (osalTimerRec_t *)0 );
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn osalFindTimer
+ *
+ * @brief Find a timer in a timer list.
+ * Ints must be disabled.
+ *
+ * @param task_id
+ * @param event_flag
+ *
+ * @return osalTimerRec_t *
+ */
+osalTimerRec_t *osalFindTimer( uint8 task_id, uint16 event_flag )
+{
+ osalTimerRec_t *srchTimer;
+
+ // Head of the timer list
+ srchTimer = timerHead;
+
+ // Stop when found or at the end
+ while ( srchTimer )
+ {
+ if ( srchTimer->event_flag == event_flag &&
+ srchTimer->task_id == task_id )
+ {
+ break;
+ }
+
+ // Not this one, check another
+ srchTimer = srchTimer->next;
+ }
+
+ return ( srchTimer );
+}
+
+/*********************************************************************
+ * @fn osalDeleteTimer
+ *
+ * @brief Delete a timer from a timer list.
+ *
+ * @param table
+ * @param rmTimer
+ *
+ * @return none
+ */
+void osalDeleteTimer( osalTimerRec_t *rmTimer )
+{
+ // Does the timer list really exist
+ if ( rmTimer )
+ {
+ // Clear the event flag and osalTimerUpdate() will delete
+ // the timer from the list.
+ rmTimer->event_flag = 0;
+ }
+}
+
+/*********************************************************************
+ * @fn osal_start_timerEx
+ *
+ * @brief
+ *
+ * This function is called to start a timer to expire in n mSecs.
+ * When the timer expires, the calling task will get the specified event.
+ *
+ * @param uint8 taskID - task id to set timer for
+ * @param uint16 event_id - event to be notified with
+ * @param uint32 timeout_value - in milliseconds.
+ *
+ * @return SUCCESS, or NO_TIMER_AVAIL.
+ */
+uint8 osal_start_timerEx( uint8 taskID, uint16 event_id, uint32 timeout_value )
+{
+ halIntState_t intState;
+ osalTimerRec_t *newTimer;
+
+ do { intState = EA; do { EA = 0; } while (264 == -1); } while (264 == -1); // Hold off interrupts.
+
+ // Add timer
+ newTimer = osalAddTimer( taskID, event_id, timeout_value );
+
+ do { EA = intState; } while (269 == -1); // Re-enable interrupts.
+
+ return ( (newTimer != 0) ? 0x00 : 0x08 );
+}
+
+/*********************************************************************
+ * @fn osal_start_reload_timer
+ *
+ * @brief
+ *
+ * This function is called to start a timer to expire in n mSecs.
+ * When the timer expires, the calling task will get the specified event
+ * and the timer will be reloaded with the timeout value.
+ *
+ * @param uint8 taskID - task id to set timer for
+ * @param uint16 event_id - event to be notified with
+ * @param UNINT16 timeout_value - in milliseconds.
+ *
+ * @return SUCCESS, or NO_TIMER_AVAIL.
+ */
+uint8 osal_start_reload_timer( uint8 taskID, uint16 event_id, uint32 timeout_value )
+{
+ halIntState_t intState;
+ osalTimerRec_t *newTimer;
+
+ do { intState = EA; do { EA = 0; } while (294 == -1); } while (294 == -1); // Hold off interrupts.
+
+ // Add timer
+ newTimer = osalAddTimer( taskID, event_id, timeout_value );
+ if ( newTimer )
+ {
+ // Load the reload timeout value
+ newTimer->reloadTimeout = timeout_value;
+ }
+
+ do { EA = intState; } while (304 == -1); // Re-enable interrupts.
+
+ return ( (newTimer != 0) ? 0x00 : 0x08 );
+}
+
+/*********************************************************************
+ * @fn osal_stop_timerEx
+ *
+ * @brief
+ *
+ * This function is called to stop a timer that has already been started.
+ * If ZSUCCESS, the function will cancel the timer and prevent the event
+ * associated with the timer from being set for the calling task.
+ *
+ * @param uint8 task_id - task id of timer to stop
+ * @param uint16 event_id - identifier of the timer that is to be stopped
+ *
+ * @return SUCCESS or INVALID_EVENT_ID
+ */
+uint8 osal_stop_timerEx( uint8 task_id, uint16 event_id )
+{
+ halIntState_t intState;
+ osalTimerRec_t *foundTimer;
+
+ do { intState = EA; do { EA = 0; } while (328 == -1); } while (328 == -1); // Hold off interrupts.
+
+ // Find the timer to stop
+ foundTimer = osalFindTimer( task_id, event_id );
+ if ( foundTimer )
+ {
+ osalDeleteTimer( foundTimer );
+ }
+
+ do { EA = intState; } while (337 == -1); // Re-enable interrupts.
+
+ return ( (foundTimer != 0) ? 0x00 : 0x06 );
+}
+
+/*********************************************************************
+ * @fn osal_get_timeoutEx
+ *
+ * @brief
+ *
+ * @param uint8 task_id - task id of timer to check
+ * @param uint16 event_id - identifier of timer to be checked
+ *
+ * @return Return the timer's tick count if found, zero otherwise.
+ */
+uint32 osal_get_timeoutEx( uint8 task_id, uint16 event_id )
+{
+ halIntState_t intState;
+ uint32 rtrn = 0;
+ osalTimerRec_t *tmr;
+
+ do { intState = EA; do { EA = 0; } while (358 == -1); } while (358 == -1); // Hold off interrupts.
+
+ tmr = osalFindTimer( task_id, event_id );
+
+ if ( tmr )
+ {
+ rtrn = tmr->timeout.time32;
+ }
+
+ do { EA = intState; } while (367 == -1); // Re-enable interrupts.
+
+ return rtrn;
+}
+
+/*********************************************************************
+ * @fn osal_timer_num_active
+ *
+ * @brief
+ *
+ * This function counts the number of active timers.
+ *
+ * @return uint8 - number of timers
+ */
+uint8 osal_timer_num_active( void )
+{
+ halIntState_t intState;
+ uint8 num_timers = 0;
+ osalTimerRec_t *srchTimer;
+
+ do { intState = EA; do { EA = 0; } while (387 == -1); } while (387 == -1); // Hold off interrupts.
+
+ // Head of the timer list
+ srchTimer = timerHead;
+
+ // Count timers in the list
+ while ( srchTimer != 0 )
+ {
+ num_timers++;
+ srchTimer = srchTimer->next;
+ }
+
+ do { EA = intState; } while (399 == -1); // Re-enable interrupts.
+
+ return num_timers;
+}
+
+/*********************************************************************
+ * @fn osalTimerUpdate
+ *
+ * @brief Update the timer structures for a timer tick.
+ *
+ * @param none
+ *
+ * @return none
+ *********************************************************************/
+void osalTimerUpdate( uint32 updateTime )
+{
+ halIntState_t intState;
+ osalTimerRec_t *srchTimer;
+ osalTimerRec_t *prevTimer;
+
+ osalTime_t timeUnion;
+ timeUnion.time32 = updateTime;
+
+ do { intState = EA; do { EA = 0; } while (422 == -1); } while (422 == -1); // Hold off interrupts.
+ // Update the system time
+ osal_systemClock += updateTime;
+ do { EA = intState; } while (425 == -1); // Re-enable interrupts.
+
+ // Look for open timer slot
+ if ( timerHead != 0 )
+ {
+ // Add it to the end of the timer list
+ srchTimer = timerHead;
+ prevTimer = (void *)0;
+
+ // Look for open timer slot
+ while ( srchTimer )
+ {
+ osalTimerRec_t *freeTimer = 0;
+
+ do { intState = EA; do { EA = 0; } while (439 == -1); } while (439 == -1); // Hold off interrupts.
+
+ // To minimize time in this critical section, avoid 32-bit math
+ if ((timeUnion.time16[1] == 0) && (timeUnion.time8[1] == 0))
+ {
+ // If upper 24 bits are zero, check lower 8 bits for roll over
+ if (srchTimer->timeout.time8[0] >= timeUnion.time8[0])
+ {
+ // 8-bit math
+ srchTimer->timeout.time8[0] -= timeUnion.time8[0];
+ }
+ else
+ {
+ // 32-bit math
+ if (srchTimer->timeout.time32 > timeUnion.time32)
+ {
+ srchTimer->timeout.time32 -= timeUnion.time32;
+ }
+ else
+ {
+ srchTimer->timeout.time32 = 0;
+ }
+ }
+ }
+ else
+ {
+ // 32-bit math
+ if (srchTimer->timeout.time32 > timeUnion.time32)
+ {
+ srchTimer->timeout.time32 -= timeUnion.time32;
+ }
+ else
+ {
+ srchTimer->timeout.time32 = 0;
+ }
+ }
+
+ // Check for reloading
+ if ( (srchTimer->timeout.time16[0] == 0) && (srchTimer->timeout.time16[1] == 0) &&
+ (srchTimer->reloadTimeout) && (srchTimer->event_flag) )
+ {
+ // Notify the task of a timeout
+ osal_set_event( srchTimer->task_id, srchTimer->event_flag );
+
+ // Reload the timer timeout value
+ srchTimer->timeout.time32 = srchTimer->reloadTimeout;
+ }
+
+ // When timeout or delete (event_flag == 0)
+ if ( ((srchTimer->timeout.time16[0] == 0) && (srchTimer->timeout.time16[1] == 0)) ||
+ (srchTimer->event_flag == 0) )
+ {
+ // Take out of list
+ if ( prevTimer == 0 )
+ {
+ timerHead = srchTimer->next;
+ }
+ else
+ {
+ prevTimer->next = srchTimer->next;
+ }
+
+ // Setup to free memory
+ freeTimer = srchTimer;
+
+ // Next
+ srchTimer = srchTimer->next;
+ }
+ else
+ {
+ // Get next
+ prevTimer = srchTimer;
+ srchTimer = srchTimer->next;
+ }
+
+ do { EA = intState; } while (514 == -1); // Re-enable interrupts.
+
+ if ( freeTimer )
+ {
+ if ( (freeTimer->timeout.time16[0] == 0) && (freeTimer->timeout.time16[1] == 0) )
+ {
+ osal_set_event( freeTimer->task_id, freeTimer->event_flag );
+ }
+ osal_mem_free( freeTimer );
+ }
+ }
+ }
+}
+
+#line 597 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\COMPONENTS\\osal\\common\\OSAL_Timers.c"
+
+/*********************************************************************
+ * @fn osal_GetSystemClock()
+ *
+ * @brief Read the local system clock.
+ *
+ * @param none
+ *
+ * @return local clock in milliseconds
+ */
+uint32 osal_GetSystemClock( void )
+{
+ return ( osal_systemClock );
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_WIMU.i b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_WIMU.i
new file mode 100644
index 0000000..30d76e3
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OSAL_WIMU.i
@@ -0,0 +1,14519 @@
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+/**************************************************************************************************
+ Filename: OSAL_WIMU.c
+
+ Description: This file contains function that allows user setup tasks
+
+**************************************************************************************************/
+
+/**************************************************************************************************
+ * INCLUDES
+ **************************************************************************************************/
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+/**
+ @headerfile: hal_types.h
+
+
+**************************************************************************************************/
+
+
+
+
+/* Texas Instruments CC2540 */
+
+/* ------------------------------------------------------------------------------------------------
+ * Types
+ * ------------------------------------------------------------------------------------------------
+ */
+/** @defgroup HAL_TYPES HAL Types
+ * @{
+ */
+typedef signed char int8; //!< Signed 8 bit integer
+typedef unsigned char uint8; //!< Unsigned 8 bit integer
+
+typedef signed short int16; //!< Signed 16 bit integer
+typedef unsigned short uint16; //!< Unsigned 16 bit integer
+
+typedef signed long int32; //!< Signed 32 bit integer
+typedef unsigned long uint32; //!< Unsigned 32 bit integer
+
+typedef unsigned char bool; //!< Boolean data type
+
+typedef uint8 halDataAlign_t; //!< Used for byte alignment
+/** @} End HAL_TYPES */
+
+/* ------------------------------------------------------------------------------------------------
+ * Memory Attributes and Compiler Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ----------- IAR Compiler ----------- */
+#line 82 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+/* ----------- KEIL Compiler ----------- */
+#line 105 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Standard Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************************************************
+ */
+#line 12 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+/******************************************************************************
+ Filename: OSAL.h
+ Revised: $Date: 2012-02-17 15:07:16 -0800 (Fri, 17 Feb 2012) $
+ Revision: $Revision: 29376 $
+
+ Description: This API allows the software components in the Z-Stack to be
+ written independently of the specifics of the operating system,
+ kernel, or tasking environment (including control loops or
+ connect-to-interrupt systems).
+
+
+ Copyright 2004-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+/* - LIMITS.H -
+
+ Integral ANSI element sizes.
+
+ $Revision: 38615 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+/* - SYSMAC.H -
+
+ Defines system macros to maintain source compatibility
+ with different IAR compilers.
+
+ $Revision: 6040 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 65 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+#line 73 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+
+
+
+
+
+
+/* Macro for frmwri and frmrd */
+
+
+/* Typedefs put here to appear only once */
+typedef unsigned int size_t;
+typedef signed int ptrdiff_t;
+
+#line 18 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 80 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\comdef.h"
+/**************************************************************************************************
+ Filename: comdef.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: Type definitions and macros.
+
+
+ Copyright 2004-2008 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/* HAL */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+/**************************************************************************************************
+ Filename: hal_defs.h
+ Revised: $Date: 2012-08-17 16:28:43 -0700 (Fri, 17 Aug 2012) $
+ Revision: $Revision: 31295 $
+
+ Description: This file contains useful macros and data types
+
+
+ Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* takes a byte out of a uint32 : var - uint32, ByteNum - byte to take out (0 - 3) */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 101 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+
+/*
+ * This macro is for use by other macros to form a fully valid C statement.
+ * Without this, the if/else conditionals could show unexpected behavior.
+ *
+ * For example, use...
+ * #define SET_REGS() st( ioreg1 = 0; ioreg2 = 0; )
+ * instead of ...
+ * #define SET_REGS() { ioreg1 = 0; ioreg2 = 0; }
+ * or
+ * #define SET_REGS() ioreg1 = 0; ioreg2 = 0;
+ * The last macro would not behave as expected in the if/else construct.
+ * The second to last macro will cause a compiler error in certain uses
+ * of if/else construct
+ *
+ * It is not necessary, or recommended, to use this macro where there is
+ * already a valid C statement. For example, the following is redundant...
+ * #define CALL_FUNC() st( func(); )
+ * This should simply be...
+ * #define CALL_FUNC() func()
+ *
+ * (The while condition below evaluates false without generating a
+ * constant-controlling-loop type of warning on most compilers.)
+ */
+
+
+
+/**************************************************************************************************
+ */
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * Lint Keywords
+ */
+
+
+#line 71 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*** Generic Status Return Values ***/
+#line 107 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Generic Status return
+typedef uint8 Status_t;
+
+// Data types
+typedef int32 int24;
+typedef uint32 uint24;
+
+/*********************************************************************
+ * Global System Events
+ */
+
+
+
+/*********************************************************************
+ * Global Generic System Messages
+ */
+
+
+
+// OSAL System Message IDs/Events Reserved for applications (user applications)
+// 0xE0 – 0xFC
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 58 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+/**************************************************************************************************
+ Filename: OSAL_Memory.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: This module defines the OSAL memory control functions.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialize memory manager.
+ */
+ void osal_mem_init( void );
+
+ /*
+ * Setup efficient search for the first free block of heap.
+ */
+ void osal_mem_kick( void );
+
+ /*
+ * Allocate a block of memory.
+ */
+
+
+
+
+ void *osal_mem_alloc( uint16 size );
+
+
+ /*
+ * Free a block of memory.
+ */
+
+
+
+
+ void osal_mem_free( void *ptr );
+
+
+#line 130 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+#line 137 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 59 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Timers.h"
+/**************************************************************************************************
+ Filename: OSAL_Timers.h
+ Revised: $Date: 2011-09-16 19:09:24 -0700 (Fri, 16 Sep 2011) $
+ Revision: $Revision: 27618 $
+
+ Description: This file contains the OSAL Timer definition and manipulation functions.
+
+
+ Copyright 2004-2009 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ * the unit is chosen such that the 320us tick equivalent can fit in
+ * 32 bits.
+ */
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialization for the OSAL Timer System.
+ */
+ extern void osalTimerInit( void );
+
+ /*
+ * Set a Timer
+ */
+ extern uint8 osal_start_timerEx( uint8 task_id, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Set a timer that reloads itself.
+ */
+ extern uint8 osal_start_reload_timer( uint8 taskID, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Stop a Timer
+ */
+ extern uint8 osal_stop_timerEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Get the tick count of a Timer.
+ */
+ extern uint32 osal_get_timeoutEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Simulated Timer Interrupt Service Routine
+ */
+
+ extern void osal_timer_ISR( void );
+
+ /*
+ * Adjust timer tables
+ */
+ extern void osal_adjust_timers( void );
+
+ /*
+ * Update timer tables
+ */
+ extern void osalTimerUpdate( uint32 updateTime );
+
+ /*
+ * Count active timers
+ */
+ extern uint8 osal_timer_num_active( void );
+
+ /*
+ * Set the hardware timer interrupts for sleep mode.
+ * These functions should only be called in OSAL_PwrMgr.c
+ */
+ extern void osal_sleep_timers( void );
+ extern void osal_unsleep_timers( void );
+
+ /*
+ * Read the system clock - returns milliseconds
+ */
+ extern uint32 osal_GetSystemClock( void );
+
+ /*
+ * Get the next OSAL timer expiration.
+ * This function should only be called in OSAL_PwrMgr.c
+ */
+ extern uint32 osal_next_timeout( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 60 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*** Interrupts ***/
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+typedef struct
+{
+ void *next;
+ uint16 len;
+ uint8 dest_id;
+} osal_msg_hdr_t;
+
+typedef struct
+{
+ uint8 event;
+ uint8 status;
+} osal_event_hdr_t;
+
+typedef void * osal_msg_q_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*** Message Management ***/
+
+ /*
+ * Task Message Allocation
+ */
+ extern uint8 * osal_msg_allocate(uint16 len );
+
+ /*
+ * Task Message Deallocation
+ */
+ extern uint8 osal_msg_deallocate( uint8 *msg_ptr );
+
+ /*
+ * Send a Task Message
+ */
+ extern uint8 osal_msg_send( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern uint8 osal_msg_push_front( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Receive a Task Message
+ */
+ extern uint8 *osal_msg_receive( uint8 task_id );
+
+ /*
+ * Find in place a matching Task Message / Event.
+ */
+ extern osal_event_hdr_t *osal_msg_find(uint8 task_id, uint8 event);
+
+ /*
+ * Enqueue a Task Message
+ */
+ extern void osal_msg_enqueue( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Enqueue a Task Message Up to Max
+ */
+ extern uint8 osal_msg_enqueue_max( osal_msg_q_t *q_ptr, void *msg_ptr, uint8 max );
+
+ /*
+ * Dequeue a Task Message
+ */
+ extern void *osal_msg_dequeue( osal_msg_q_t *q_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern void osal_msg_push( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Extract and remove a Task Message from queue
+ */
+ extern void osal_msg_extract( osal_msg_q_t *q_ptr, void *msg_ptr, void *prev_ptr );
+
+
+/*** Task Synchronization ***/
+
+ /*
+ * Set a Task Event
+ */
+ extern uint8 osal_set_event( uint8 task_id, uint16 event_flag );
+
+
+ /*
+ * Clear a Task Event
+ */
+ extern uint8 osal_clear_event( uint8 task_id, uint16 event_flag );
+
+
+/*** Interrupt Management ***/
+
+ /*
+ * Register Interrupt Service Routine (ISR)
+ */
+ extern uint8 osal_isr_register( uint8 interrupt_id, void (*isr_ptr)( uint8* ) );
+
+ /*
+ * Enable Interrupt
+ */
+ extern uint8 osal_int_enable( uint8 interrupt_id );
+
+ /*
+ * Disable Interrupt
+ */
+ extern uint8 osal_int_disable( uint8 interrupt_id );
+
+
+/*** Task Management ***/
+
+ /*
+ * Initialize the Task System
+ */
+ extern uint8 osal_init_system( void );
+
+ /*
+ * System Processing Loop
+ */
+
+
+
+ extern void osal_start_system( void );
+
+
+ /*
+ * One Pass Throu the OSAL Processing Loop
+ */
+ extern void osal_run_system( void );
+
+ /*
+ * Get the active task ID
+ */
+ extern uint8 osal_self( void );
+
+
+/*** Helper Functions ***/
+
+ /*
+ * String Length
+ */
+ extern int osal_strlen( char *pString );
+
+ /*
+ * Memory copy
+ */
+ extern void *osal_memcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory Duplicate - allocates and copies
+ */
+ extern void *osal_memdup( const void *src, unsigned int len );
+
+ /*
+ * Reverse Memory copy
+ */
+ extern void *osal_revmemcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory compare
+ */
+ extern uint8 osal_memcmp( const void *src1, const void *src2, unsigned int len );
+
+ /*
+ * Memory set
+ */
+ extern void *osal_memset( void *dest, uint8 value, int len );
+
+ /*
+ * Build a uint16 out of 2 bytes (0 then 1).
+ */
+ extern uint16 osal_build_uint16( uint8 *swapped );
+
+ /*
+ * Build a uint32 out of sequential bytes.
+ */
+ extern uint32 osal_build_uint32( uint8 *swapped, uint8 len );
+
+ /*
+ * Convert long to ascii string
+ */
+
+ extern uint8 *_ltoa( uint32 l, uint8 * buf, uint8 radix );
+
+
+ /*
+ * Random number generator
+ */
+ extern uint16 osal_rand( void );
+
+ /*
+ * Buffer an uint32 value - LSB first.
+ */
+ extern uint8* osal_buffer_uint32( uint8 *buf, uint32 val );
+
+ /*
+ * Buffer an uint24 value - LSB first
+ */
+ extern uint8* osal_buffer_uint24( uint8 *buf, uint24 val );
+
+ /*
+ * Is all of the array elements set to a value?
+ */
+ extern uint8 osal_isbufset( uint8 *buf, uint8 val, uint8 len );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 13 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\OSAL_Tasks.h"
+/**************************************************************************************************
+ Filename: OSAL_Tasks.h
+ Revised: $Date: 2007-10-28 18:41:49 -0700 (Sun, 28 Oct 2007) $
+ Revision: $Revision: 15799 $
+
+ Description: This file contains the OSAL Task definition and manipulation functions.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*
+ * Event handler function prototype
+ */
+typedef unsigned short (*pTaskEventHandlerFn)( unsigned char task_id, unsigned short event );
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+extern const pTaskEventHandlerFn tasksArr[];
+extern const uint8 tasksCnt;
+extern uint16 *tasksEvents;
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Call each of the tasks initailization functions.
+ */
+extern void osalInitTasks( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 14 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+
+/* HAL */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_drivers.h"
+/**************************************************************************************************
+ Filename: hal_drivers.h
+ Revised: $Date: 2012-07-09 13:23:30 -0700 (Mon, 09 Jul 2012) $
+ Revision: $Revision: 30873 $
+
+ Description: This file contains the interface to the Drivers service.
+
+
+ Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+/**************************************************************************************************
+ * INCLUDES
+ **************************************************************************************************/
+
+
+
+/**************************************************************************************************
+ * CONSTANTS
+ **************************************************************************************************/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************************************************
+ * GLOBAL VARIABLES
+ **************************************************************************************************/
+
+extern uint8 Hal_TaskID;
+
+/**************************************************************************************************
+ * FUNCTIONS - API
+ **************************************************************************************************/
+
+extern void Hal_Init ( uint8 task_id );
+
+/*
+ * Process Serial Buffer
+ */
+extern uint16 Hal_ProcessEvent ( uint8 task_id, uint16 events );
+
+/*
+ * Process Polls
+ */
+extern void Hal_ProcessPoll (void);
+
+/*
+ * Initialize HW
+ */
+extern void HalDriverInit (void);
+
+
+
+
+
+
+
+/**************************************************************************************************
+**************************************************************************************************/
+#line 17 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+
+/* LL */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+/*******************************************************************************
+ Filename: ll.h
+ Revised: $Date: 2013-05-15 05:57:26 -0700 (Wed, 15 May 2013) $
+ Revision: $Revision: 34287 $
+
+ Description: This file contains the Link Layer (LL) API for the Bluetooth
+ Low Energy (BLE) Controller. It provides the defines, types,
+ and functions for all supported Bluetooth Low Energy (BLE)
+ commands.
+
+ This API is based on the Bluetooth Core Specification,
+ V4.0.0, Vol. 6.
+
+ Copyright 2009-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+ * INCLUDES
+ */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\bcomdef.h"
+/**
+ @headerfile: bcomdef.h
+
+
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+ // Set the Controller Configuration
+#line 92 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\bcomdef.h"
+
+#line 102 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\bcomdef.h"
+
+/** @defgroup BLE_COMMON_DEFINES BLE Common Defines
+ * @{
+ */
+//! Default Public and Random Address Length
+
+
+//! Default key length
+
+
+//! BLE Channel Map length
+
+
+//! BLE Event mask length
+
+
+//! BLE Local Name length
+
+
+//! BLE Maximum Advertising Packet Length
+
+
+//! BLE Random Number Size
+
+
+//! BLE Feature Supported length
+
+
+/** @defgroup BLE_STATUS_VALUES BLE Default BLE Status Values
+ * returned as bStatus_t
+ * @{
+ */
+#line 146 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\bcomdef.h"
+
+// GAP Status Return Values - returned as bStatus_t
+
+
+
+
+// ATT Status Return Values - returned as bStatus_t
+
+
+
+
+
+// L2CAP Status Return Values - returned as bStatus_t
+
+
+/** @} End BLE_STATUS_VALUES */
+
+/** @defgroup BLE_NV_IDS BLE Non-volatile IDs
+ * @{
+ */
+// Device NV Items - Range 0 - 0x1F
+
+
+
+
+// Bonding NV Items - Range 0x20 - 0x5F - This allows for 10 bondings
+
+
+
+// GATT Configuration NV Items - Range 0x70 - 0x79 - This must match the number of Bonding entries
+
+
+/** @} End BLE_NV_IDS */
+
+/*********************************************************************
+ * BLE OSAL GAP GLOBAL Events
+ */
+
+
+
+/** @defgroup BLE_MSG_IDS BLE OSAL Message ID Events
+ * Reserved Message ID Event Values:
+ * 0xC0 - Key Presses
+ * 0xE0 to 0xFC - App
+ * @{
+ */
+// GAP - Messages IDs (0xD0 - 0xDF)
+
+
+// SM - Messages IDs (0xC1 - 0xCF)
+
+
+// GATT - Messages IDs (0xB0 - 0xBF)
+
+
+
+// L2CAP - Messages IDs (0xA0 - 0xAF)
+
+
+
+// HCI - Messages IDs (0x90 - 0x9F)
+
+
+
+
+/** @} End BLE_MSG_IDS */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+ //! BLE Generic Status return: @ref BLE_STATUS_VALUES
+typedef Status_t bStatus_t;
+
+/** @} End GAP_MSG_EVENT_DEFINES */
+
+
+/*********************************************************************
+ * System Events
+ */
+
+/*********************************************************************
+ * Global System Messages
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+// TI Base 128-bit UUID: F000XXXX-0451-4000-B000-000000000000
+
+
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 57 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+
+/*******************************************************************************
+ * MACROS
+ */
+
+// check if connection parameter ranges for CI (min/max), SL, and LSTO are valid
+#line 72 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+
+// check if the CI/SL/LSTO combination is valid
+// based on: LSTO > (1 + Slave Latency) * (Connection Interval * 2)
+// Note: The CI * 2 requirement based on ESR05 V1.0, Erratum 3904.
+// Note: LSTO time is normalized to units of 1.25ms (i.e. 10ms = 8 * 1.25ms).
+
+
+
+/*******************************************************************************
+ * CONSTANTS
+ */
+
+/*
+** LL API Status Codes
+**
+** Note: These status values map directly to the HCI Error Codes.
+** Per the Bluetooth Core Specification, V4.0.0, Vol. 2, Part D.
+*/
+#line 137 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+// Internal
+
+
+
+// Encryption Key Request Reason Codes
+
+
+
+
+// Disconnect Reason Codes
+#line 161 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+
+// Disconnect API Parameter
+#line 170 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+
+/*
+** LL API Parameters
+*/
+
+// LL Parameter Limits
+#line 195 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+
+// LL Advertiser Channels
+
+
+
+
+
+// LL Advertiser Events
+
+
+
+
+
+// LL Address Type
+
+
+
+// Advertiser White List Policy
+
+
+
+
+
+// Scanner White List Policy
+
+
+
+// Initiator White List Policy
+
+
+
+// Black List Control
+
+
+
+// Advertiser Commands
+
+
+
+
+// LL Scan Commands
+
+
+
+// LL Scan Filtering
+
+
+
+// LL Scan Types
+
+
+
+// LL Tx Power Types
+
+
+
+// Data Fragmentation Flag
+
+
+
+
+// Connection Complete Role
+
+
+
+// Encryption Related
+
+
+
+// Feature Set Related
+
+//
+
+
+
+// Receive Flow Control
+
+
+
+// Direct Test Mode
+
+
+//
+#line 287 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+//
+
+
+//
+
+
+// Vendor Specific
+
+
+//
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//
+
+
+//
+
+
+//
+
+
+//
+
+
+//
+
+
+//
+
+
+//
+
+
+//
+
+
+
+
+
+//
+#line 348 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+//
+
+
+//
+
+
+//
+
+
+
+// Packet Lengths
+#line 365 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+
+/*
+** Event Parameters
+*/
+
+// Advertising Report Data
+#line 377 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+//
+
+
+// Sleep Clock Accuracy (SCA)
+#line 389 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+
+/*
+** Miscellaneous
+*/
+
+
+
+/*******************************************************************************
+ * TYPEDEFS
+ */
+
+typedef uint8 llStatus_t;
+
+// Packet Error Rate Information By Channel
+typedef struct
+{
+ uint16 numPkts[ 37 ];
+ uint16 numCrcErr[ 37 ];
+} perByChan_t;
+
+/*******************************************************************************
+ * LOCAL VARIABLES
+ */
+
+/*******************************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*******************************************************************************
+ * LL OSAL Functions
+ */
+
+/*******************************************************************************
+ * @fn LL_Init
+ *
+ * @brief This is the Link Layer task initialization called by OSAL. It
+ * must be called once when the software system is started and
+ * before any other function in the LL API is called.
+ *
+ * input parameters
+ *
+ * @param taskId - Task identifier assigned by OSAL.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_Init( uint8 taskId );
+
+
+/*******************************************************************************
+ * @fn LL_ProcessEvent
+ *
+ * @brief This is the Link Layer process event handler called by OSAL.
+ *
+ * input parameters
+ *
+ * @param taskId - Task identifier assigned by OSAL.
+ * events - Event flags to be processed by this task.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return Unprocessed event flags.
+ */
+extern uint16 LL_ProcessEvent( uint8 task_id, uint16 events );
+
+
+/*******************************************************************************
+ * LL API for HCI
+ */
+
+/*******************************************************************************
+ * @fn LL_Reset API
+ *
+ * @brief This function is used by the HCI to reset and initialize the
+ * LL Controller.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_Reset( void );
+
+
+/*******************************************************************************
+ * @fn LL_ReadBDADDR API
+ *
+ * @brief This API is called by the HCI to read the controller's
+ * own public device address.
+ *
+ * Note: The device's address is stored in NV memory.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param bdAddr - A pointer to a buffer to hold this device's address.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_ReadBDADDR( uint8 *bdAddr );
+
+
+/*******************************************************************************
+ *
+ * @fn LL_SetRandomAddress API
+ *
+ * @brief This function is used to save this device's random address. It
+ * is provided by the Host for devices that are unable to store a
+ * IEEE assigned public address in NV memory.
+ *
+ * input parameters
+ *
+ * @param devAddr - Pointer to a random address (LSO..MSO).
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS
+ *
+ */
+extern llStatus_t LL_SetRandomAddress( uint8 *devAddr );
+
+
+/*******************************************************************************
+ * @fn LL_ClearWhiteList API
+ *
+ * @brief This API is called by the HCI to clear the White List.
+ *
+ * Note: If Scanning is enabled using filtering, and the white
+ * list policy is "Any", then this command will be
+ * disallowed.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_ClearWhiteList( void );
+
+
+/*******************************************************************************
+ * @fn LL_AddWhiteListDevice API
+ *
+ * @brief This API is called by the HCI to add a device address and its
+ * type to the White List.
+ *
+ * input parameters
+ *
+ * @param devAddr - Pointer to a 6 byte device address.
+ * @param addrType - Public or Random device address.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_WL_TABLE_FULL
+ */
+extern llStatus_t LL_AddWhiteListDevice( uint8 *devAddr,
+ uint8 addrType );
+
+/*******************************************************************************
+ * @fn LL_RemoveWhiteListDevice API
+ *
+ * @brief This API is called by the HCI to remove a device address and
+ * it's type from the White List.
+ *
+ * input parameters
+ *
+ * @param devAddr - Pointer to a 6 byte device address.
+ * @param addrType - Public or Random device address.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_WL_TABLE_EMPTY,
+ * LL_STATUS_ERROR_WL_ENTRY_NOT_FOUND
+ */
+extern llStatus_t LL_RemoveWhiteListDevice( uint8 *devAddr,
+ uint8 addrType );
+
+
+/*******************************************************************************
+ * @fn LL_ReadWlSize API
+ *
+ * @brief This API is called by the HCI to get the total number of white
+ * list entries that can be stored in the Controller.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param *numEntries - Total number of available White List entries.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_ReadWlSize( uint8 *numEntries );
+
+
+/*******************************************************************************
+ * @fn LL_NumEmptyWlEntries API
+ *
+ * @brief This API is called by the HCI to get the number of White List
+ * entries that are empty.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param *numEmptyEntries - number of empty entries in the White List.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_NumEmptyWlEntries( uint8 *numEmptyEntries );
+
+
+/*******************************************************************************
+ * @fn LL_Encrypt API
+ *
+ * @brief This API is called by the HCI to request the LL to encrypt the
+ * data in the command using the key given in the command.
+ *
+ * Note: The parameters are byte ordered MSO to LSO.
+ *
+ * input parameters
+ *
+ * @param *key - A 128 bit key to be used to calculate the
+ * session key.
+ * @param *plaintextData - A 128 bit block that is to be encrypted.
+ *
+ * output parameters
+ *
+ * @param *encryptedData - A 128 bit block that is encrypted.
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_Encrypt( uint8 *key,
+ uint8 *plaintextData,
+ uint8 *encryptedData );
+
+
+/*******************************************************************************
+ * @fn LL_Rand API
+ *
+ * @brief This API is called by the HCI to request the LL Controller to
+ * provide a data block with random content.
+ *
+ * Note: If the radio is in use, then this operation has to be
+ * delayed until the radio finishes.
+ *
+ * input parameters
+ *
+ * @param *randData - Pointer to buffer to place a random block of data.
+ * @param dataLen - The length of the random data block, from 1-255.
+ *
+ * output parameters
+ *
+ * @param *randData - Pointer to buffer containing a block of true random
+ * data.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_DUE_TO_LIMITED_RESOURCES,
+ * LL_STATUS_ERROR_COMMAND_DISALLOWED,
+ * LL_STATUS_ERROR_BAD_PARAMETER, LL_STATUS_ERROR_RNG_FAILURE
+ */
+extern llStatus_t LL_Rand( uint8 *randData,
+ uint8 dataLen );
+
+
+/*******************************************************************************
+ * @fn LL_ReadSupportedStates API
+ *
+ * @brief This function is used to provide the HCI with the Link Layer
+ * supported states and supported state/role combinations.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param *states - Eight byte Bit map of supported states/combos.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_ReadSupportedStates( uint8 *states );
+
+
+/*******************************************************************************
+ * @fn LL_ReadLocalSupportedFeatures API
+ *
+ * @brief This API is called by the HCI to read the controller's
+ * Features Set. The Controller indicates which features it
+ * supports.
+ *
+ * input parameters
+ *
+ * @param featureSet - A pointer to the Feature Set where each bit:
+ * 0: Feature not supported.
+ * 1: Feature supported by controller.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_ReadLocalSupportedFeatures( uint8 *featureSet );
+
+
+/*******************************************************************************
+ * @fn LL_ReadLocalVersionInfo API
+ *
+ * @brief This API is called by the HCI to read the controller's
+ * Version information.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param verNum - Version of the Bluetooth Controller specification.
+ * @param comId - Company identifier of the manufacturer of the
+ * Bluetooth Controller.
+ * @param subverNum - A unique value for each implementation or revision
+ * of an implementation of the Bluetooth Controller.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_ReadLocalVersionInfo( uint8 *verNum,
+ uint16 *comId,
+ uint16 *subverNum );
+
+
+
+/*******************************************************************************
+ * @fn LL_CtrlToHostFlowControl API
+ *
+ * @brief This function is used to indicate if the LL enable/disable
+ * receive FIFO processing. This function provides support for
+ * Controller to Host flow control.
+ *
+ * input parameters
+ *
+ * @param mode: LL_ENABLE_RX_FLOW_CONTROL, LL_DISABLE_RX_FLOW_CONTROL
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_CtrlToHostFlowControl( uint8 mode );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_ReadRemoteVersionInfo API
+ *
+ * @brief This API is called by the HCI to read the peer controller's
+ * Version Information. If the peer's Version Information has
+ * already been received by its request for our Version
+ * Information, then this data is already cached and can be
+ * directly returned to the Host. If the peer's Version Information
+ * is not already cached, then it will be requested from the peer,
+ * and when received, returned to the Host via the
+ * LL_ReadRemoteVersionInfoCback callback.
+ *
+ * Note: Only one Version Indication is allowed for a connection.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param connId - The LL connection ID on which to send this data.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_VER_IND_ALREADY_SENT
+ */
+extern llStatus_t LL_ReadRemoteVersionInfo( uint16 connId );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_ReadTxPowerLevel
+ *
+ * @brief This function is used to read a connection's current transmit
+ * power level or the maximum transmit power level.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection handle.
+ * @param type - LL_READ_CURRENT_TX_POWER_LEVEL or
+ * LL_READ_MAX_TX_POWER_LEVEL
+ * @param *txPower - A signed value from -30..+20, in dBm.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_PARAM_OUT_OF_RANGE,
+ * LL_STATUS_ERROR_INACTIVE_CONNECTION
+ */
+llStatus_t LL_ReadTxPowerLevel( uint8 connId,
+ uint8 type,
+ int8 *txPower );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_ReadChanMap API
+ *
+ * @brief This API is called by the HCI to read the channel map that the
+ * LL controller is using for the LL connection.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection handle.
+ *
+ * output parameters
+ *
+ * @param chanMap - A five byte array containing one bit per data channel
+ * where a 1 means the channel is "used" and a 0 means
+ * the channel is "unused".
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_INACTIVE_CONNECTION
+ */
+extern llStatus_t LL_ReadChanMap( uint8 connId,
+ uint8 *chanMap );
+
+
+
+/*******************************************************************************
+ * @fn LL_ReadRssi API
+ *
+ * @brief This API is called by the HCI to request RSSI. If there is an
+ * active connection for the given connection ID, then the RSSI of
+ * the last received data packet in the LL will be returned. If a
+ * receiver Modem Test is running, then the RF RSSI for the last
+ * received data will be returned. If no valid RSSI value is
+ * available, then LL_RSSI_NOT_AVAILABLE will be returned.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID on which to read last RSSI.
+ *
+ * output parameters
+ *
+ * @param *lastRssi - The last data RSSI received.
+ * Range: -127dBm..+20dBm, 127=Not Available.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_INACTIVE_CONNECTION
+ */
+extern llStatus_t LL_ReadRssi( uint16 connId,
+ int8 *lastRssi );
+
+
+
+/*******************************************************************************
+ * @fn LL_Disconnect API
+ *
+ * @brief This API is called by the HCI to terminate a LL connection.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID on which to send this data.
+ * @param reason - The reason for the Host connection termination.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_INACTIVE_CONNECTION
+ * LL_STATUS_ERROR_CTRL_PROC_ALREADY_ACTIVE
+ */
+extern llStatus_t LL_Disconnect( uint16 connId,
+ uint8 reason );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_TxData API
+ *
+ * @brief This API is called by the HCI to transmit a buffer of data on a
+ * given LL connection. If fragmentation is supported, the HCI must
+ * also indicate whether this is the first Host packet, or a
+ * continuation Host packet. When fragmentation is not supported,
+ * then a start packet should always specified. If the device is in
+ * a connection as a Master and the current connection ID is the
+ * connection for this data, or is in a connection as a Slave, then
+ * the data is written to the TX FIFO (even if the radio is
+ * curerntly active). If this is a Slave connection, and Fast TX is
+ * enabled and Slave Latency is being used, then the amount of time
+ * to the next event is checked. If there's at least a connection
+ * interval plus some overhead, then the next event is re-aligned
+ * to the next event boundary. Otherwise, in all cases, the buffer
+ * pointer will be retained for transmission, and the callback
+ * event LL_TxDataCompleteCback will be generated to the HCI when
+ * the buffer pointer is no longer needed by the LL.
+ *
+ * Note: If the return status is LL_STATUS_ERROR_OUT_OF_TX_MEM,
+ * then the HCI must not release the buffer until it receives
+ * the LL_TxDataCompleteCback callback, which indicates the
+ * LL has copied the transmit buffer.
+ *
+ * Note: The HCI should not call this routine if a buffer is still
+ * pending from a previous call. This is fatal!
+ *
+ * Note: If the connection should be terminated within the LL
+ * before the Host knows, attempts by the HCI to send more
+ * data (after receiving a LL_TxDataCompleteCback) will
+ * fail (LL_STATUS_ERROR_INACTIVE_CONNECTION).
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID on which to send this data.
+ * @param *pBuf - A pointer to the data buffer to transmit.
+ * @param len - The number of bytes to transmit on this connection.
+ * @param fragFlag - LL_DATA_FIRST_PKT_HOST_TO_CTRL:
+ * Indicates buffer is the start of a
+ * Host-to-Controller packet.
+ * LL_DATA_CONTINUATION_PKT:
+ * Indicates buffer is a continuation of a
+ * Host-to-Controller packet.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_INACTIVE_CONNECTION,
+ * LL_STATUS_ERROR_OUT_OF_TX_MEM,
+ * LL_STATUS_ERROR_UNEXPECTED_PARAMETER
+ */
+extern llStatus_t LL_TxData( uint16 connId,
+ uint8 *pBuf,
+ uint8 len,
+ uint8 fragFlag );
+
+
+
+/*******************************************************************************
+ * @fn LL_DirectTestTxTest API
+ *
+ * @brief This function is used to initiate a BLE PHY level Transmit Test
+ * in Direct Test Mode where the DUT generates test reference
+ * packets at fixed intervals. This test will make use of the
+ * nanoRisc Raw Data Transmit and Receive task.
+ *
+ * Note: The BLE device is to transmit at maximum power.
+ * Note: A LL reset should be issued when done using DTM!
+ *
+ * input parameters
+ *
+ * @param txFreq - Tx RF frequency k=0..39, where F=2402+(k*2MHz).
+ * @param payloadLen - Number of bytes (0..37)in payload for each packet.
+ * @param payloadType - The type of pattern to transmit.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_UNEXPECTED_STATE_ROLE
+ */
+extern llStatus_t LL_DirectTestTxTest( uint8 txFreq,
+ uint8 payloadLen,
+ uint8 payloadType );
+
+
+/*******************************************************************************
+ * @fn LL_DirectTestRxTest API
+ *
+ * @brief This function is used to initiate a BLE PHY level Receive Test
+ * in Direct Test Mode where the DUT receives test reference
+ * packets at fixed intervals. This test will make use of the
+ * nanoRisc Raw Data Transmit and Receive task. The received
+ * packets are verified based on the CRC, and metrics are kept.
+ *
+ * Note: A LL reset should be issued when done using DTM!
+ *
+ * input parameters
+ *
+ * @param rxFreq - Rx RF frequency k=0..39, where F=2402+(k*2MHz).
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_UNEXPECTED_STATE_ROLE
+ */
+extern llStatus_t LL_DirectTestRxTest( uint8 rxFreq );
+
+
+/*******************************************************************************
+ * @fn LL_DirectTestEnd API
+ *
+ * @brief This function is used to end the Direct Test Transmit or Direct
+ * Test Receive tests executing in Direct Test mode. When the raw
+ * task is ended, the LL_DirectTestEndDoneCback callback is called.
+ * If a Direct Test mode operation is not currently active, an
+ * error is returned.
+ *
+ * Note: A LL reset is issued upon completion!
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_UNEXPECTED_STATE_ROLE
+ */
+extern llStatus_t LL_DirectTestEnd( void );
+
+
+
+/*******************************************************************************
+ * @fn LL_SetAdvParam API
+ *
+ * @brief This API is called by the HCI to set the Advertiser's
+ * parameters.
+ *
+ * input parameters
+ * @param advIntervalMin - The minimum Adv interval.
+ * @param advIntervalMax - The maximum Adv interval.
+ * @param advEvtType - The type of advertisment event.
+ * @param ownAddrType - The Adv's address type of public or random.
+ * @param directAddrType - Only used for directed advertising.
+ * @param *directAddr - Only used for directed advertising (NULL otherwise).
+ * @param advChanMap - A byte containing 1 bit per advertising
+ * channel. A bit set to 1 means the channel is
+ * used. The bit positions define the advertising
+ * channels as follows:
+ * Bit 0: 37, Bit 1: 38, Bit 2: 39.
+ * @param advWlPolicy - The Adv white list filter policy.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_NO_ADV_CHAN_FOUND
+ */
+extern llStatus_t LL_SetAdvParam( uint16 advIntervalMin,
+ uint16 advIntervalMax,
+ uint8 advEvtType,
+ uint8 ownAddrType,
+ uint8 directAddrType,
+ uint8 *directAddr,
+ uint8 advChanMap,
+ uint8 advWlPolicy );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_SetAdvData API
+ *
+ * @brief This API is called by the HCI to set the Advertiser's data.
+ *
+ * Note: If the Advertiser is restarted without intervening calls
+ * to this routine to make updates, then the previously
+ * defined data will be reused.
+ *
+ * Note: If the data happens to be changed while advertising, then
+ * the new data will be sent on the next advertising event.
+ *
+ * input parameters
+ *
+ * @param advDataLen - The number of scan response bytes: 0..31.
+ * @param advData - Pointer to the advertiser data, or NULL.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_SetAdvData( uint8 advDataLen,
+ uint8 *advData );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_SetScanRspData API
+ *
+ * @brief This API is called by the HCI to set the Advertiser's Scan
+ * Response data.
+ *
+ * Note: If the Advertiser is restarted without intervening calls
+ * to this routine to make updates, then the previously
+ * defined data will be reused.
+ *
+ * input parameters
+ *
+ * @param scanRspLen - The number of scan response bytes: 0..31.
+ * @param *scanRspData - Pointer to the scan response data.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_SetScanRspData( uint8 scanRspLen,
+ uint8 *scanRspData );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_SetAdvControl API
+ *
+ * @brief This API is called by the HCI to request the Controller to start
+ * or stop advertising.
+ *
+ * input parameters
+ *
+ * @param advMode - LL_ADV_MODE_ON or LL_ADV_MODE_OFF.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_UNEXPECTED_PARAMETER,
+ * LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_UNEXPECTED_STATE_ROLE,
+ * LL_STATUS_ERROR_COMMAND_DISALLOWED
+ */
+extern llStatus_t LL_SetAdvControl( uint8 advMode );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_ReadAdvChanTxPower
+ *
+ * @brief This function is used to read the transmit power level used
+ * for BLE advertising channel packets. Currently, only two
+ * settings are possible, a standard setting of 0 dBm, and a
+ * maximum setting of 4 dBm.
+ *
+ * input parameters
+ *
+ * @param *txPower - A non-null pointer.
+ *
+ * output parameters
+ *
+ * @param *txPower - A signed value from -20..+10, in dBm.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_PARAM_OUT_OF_RANGE
+ */
+extern llStatus_t LL_ReadAdvChanTxPower( int8 *txPower );
+
+
+
+#line 1215 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+
+
+#line 1244 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+
+
+
+/*******************************************************************************
+ * @fn LL_EncLtkReply API
+ *
+ * @brief This API is called by the HCI to provide the controller with
+ * the Long Term Key (LTK) for encryption. This command is
+ * actually a reply to the link layer's LL_EncLtkReqCback, which
+ * provided the random number and encryption diversifier received
+ * from the Master during an encryption setup.
+ *
+ * Note: The key parameter is byte ordered LSO to MSO.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID on which to send this data.
+ * @param *key - A 128 bit key to be used to calculate the session key.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_EncLtkReply( uint16 connId,
+ uint8 *key );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_EncLtkNegReply API
+ *
+ * @brief This API is called by the HCI to indicate to the controller
+ * that the Long Term Key (LTK) for encryption can not be provided.
+ * This command is actually a reply to the link layer's
+ * LL_EncLtkReqCback, which provided the random number and
+ * encryption diversifier received from the Master during an
+ * encryption setup. How the LL responds to the negative reply
+ * depends on whether this is part of a start encryption or a
+ * re-start encryption after a pause. For the former, an
+ * encryption request rejection is sent to the peer device. For
+ * the latter, the connection is terminated.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID on which to send this data.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_EncLtkNegReply( uint16 connId );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_CreateConn API
+ *
+ * @brief This API is called by the HCI to create a connection.
+ *
+ * input parameters
+ *
+ * @param scanInterval - The scan interval.
+ * @param scanWindow - The scan window.
+ * @param initWlPolicy - Filter Adv address directly or using WL.
+ * @param peerAddrType - Peer address is Public or Random.
+ * @param *peerAddr - The Adv address, or NULL for WL policy.
+ * @param ownAddrType - This device's address is Public or Random.
+ * @param connIntervalMin - Defines minimum connection interval value.
+ * @param connIntervalMax - Defines maximum connection interval value.
+ * @param connLatency - The connection's Slave Latency.
+ * @param connTimeout - The connection's Supervision Timeout.
+ * @param minLength - Info parameter about min length of connection.
+ * @param maxLength - Info parameter about max length of connection.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_UNEXPECTED_STATE_ROLE,
+ * LL_STATUS_ERROR_ILLEGAL_PARAM_COMBINATION,
+ * LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_CreateConn( uint16 scanInterval,
+ uint16 scanWindow,
+ uint8 initWlPolicy,
+ uint8 peerAddrType,
+ uint8 *peerAddr,
+ uint8 ownAddrType,
+ uint16 connIntervalMin,
+ uint16 connIntervalMax,
+ uint16 connLatency,
+ uint16 connTimeout,
+ uint16 minLength,
+ uint16 maxLength );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_CreateConnCancel API
+ *
+ * @brief This API is called by the HCI to cancel a previously given LL
+ * connection creation command that is still pending. This command
+ * should only be used after the LL_CreateConn command as been
+ * issued, but before the LL_ConnComplete callback.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_COMMAND_DISALLOWED
+ */
+extern llStatus_t LL_CreateConnCancel( void );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_ConnActive
+ *
+ * @brief This API is called by the HCI to check if a connection
+ * given by the connection handle is active.
+ *
+ * input parameters
+ *
+ * @param connId - Connection handle.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_INACTIVE_CONNECTION
+ */
+extern llStatus_t LL_ConnActive( uint16 connId );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_ConnUpdate API
+ *
+ * @brief This API is called by the HCI to update the connection
+ * parameters by initiating a connection update control procedure.
+ *
+ * input parameters
+ *
+ * @param connId - The connection ID on which to send this data.
+ * @param connIntervalMin - Defines minimum connection interval value.
+ * @param connIntervalMax - Defines maximum connection interval value.
+ * @param connLatency - The connection's Slave Latency.
+ * @param connTimeout - The connection's Supervision Timeout.
+ * @param minLength - Info parameter about min length of connection.
+ * @param maxLength - Info parameter about max length of connection.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_INACTIVE_CONNECTION
+ * LL_STATUS_ERROR_CTRL_PROC_ALREADY_ACTIVE,
+ * LL_STATUS_ERROR_ILLEGAL_PARAM_COMBINATION
+ */
+extern llStatus_t LL_ConnUpdate( uint16 connId,
+ uint16 connIntervalMin,
+ uint16 connIntervalMax,
+ uint16 connLatency,
+ uint16 connTimeout,
+ uint16 minLength,
+ uint16 maxLength );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_ChanMapUpdate API
+ *
+ * @brief This API is called by the HCI to update the Host data channels
+ * initiating an Update Data Channel control procedure.
+ *
+ * Note: While it isn't specified, it is assumed that the Host
+ * expects an update channel map on all active connections.
+ *
+ * Note: This LL currently only supports one connection.
+ *
+ * input parameters
+ *
+ * @param chanMap - A five byte array containing one bit per data channel
+ * where a 1 means the channel is "used".
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_ILLEGAL_PARAM_COMBINATION
+ */
+extern llStatus_t LL_ChanMapUpdate( uint8 *chanMap );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_StartEncrypt API
+ *
+ * @brief This API is called by the Master HCI to setup encryption and to
+ * update encryption keys in the LL connection. If the connection
+ * is already in encryption mode, then this command will first
+ * pause the encryption before subsequently running the encryption
+ * setup.
+ *
+ * Note: The parameters are byte ordered LSO to MSO.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID on which to send this data.
+ * @param *rand - Random vector used in device identification.
+ * @param *eDiv - Encrypted diversifier.
+ * @param *key - A 128 bit key to be used to calculate the session key.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_FEATURE_NOT_SUPPORTED
+ */
+extern llStatus_t LL_StartEncrypt( uint16 connId,
+ uint8 *rand,
+ uint8 *eDiv,
+ uint8 *ltk );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_ReadRemoteUsedFeatures API
+ *
+ * @brief This API is called by the Master HCI to initiate a feature
+ * setup control process.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID on which to send this data.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_ReadRemoteUsedFeatures( uint16 connId );
+
+
+
+/*
+** Vendor Specific Command API
+*/
+
+/*******************************************************************************
+ * @fn LL_EXT_SetRxGain Vendor Specific API
+ *
+ * @brief This function is used to to set the RF RX gain.
+ *
+ * input parameters
+ *
+ * @param rxGain - LL_EXT_RX_GAIN_STD, LL_EXT_RX_GAIN_HIGH
+ *
+ * output parameters
+ *
+ * @param cmdComplete - Boolean to indicate the command is still pending.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_EXT_SetRxGain( uint8 rxGain,
+ uint8 *cmdComplete );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_SetTxPower Vendor Specific API
+ *
+ * @brief This function is used to to set the RF TX power.
+ *
+ * input parameters
+ *
+ * @param txPower - LL_EXT_TX_POWER_0_DBM, LL_EXT_TX_POWER_4_DBM
+ *
+ * output parameters
+ *
+ * @param cmdComplete - Boolean to indicate the command is still pending.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_EXT_SetTxPower( uint8 txPower,
+ uint8 *cmdComplete );
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_OnePacketPerEvent Vendor Specific API
+ *
+ * @brief This function is used to enable or disable allowing only one
+ * packet per event.
+ *
+ * input parameters
+ *
+ * @param control - LL_EXT_ENABLE_ONE_PKT_PER_EVT,
+ * LL_EXT_DISABLE_ONE_PKT_PER_EVT
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_EXT_OnePacketPerEvent( uint8 control );
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_ClkDivOnHalt Vendor Specific API
+ *
+ * @brief This function is used to enable or disable dividing down the
+ * system clock while halted.
+ *
+ * Note: This command is disallowed if haltDuringRf is not defined.
+ *
+ * input parameters
+ *
+ * @param control - LL_EXT_ENABLE_CLK_DIVIDE_ON_HALT,
+ * LL_EXT_DISABLE_CLK_DIVIDE_ON_HALT
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_COMMAND_DISALLOWED
+ */
+extern llStatus_t LL_EXT_ClkDivOnHalt( uint8 control );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_DeclareNvUsage Vendor Specific API
+ *
+ * @brief This HCI Extension API is used to indicate to the Controller
+ * whether or not the Host will be using the NV memory during BLE
+ * operations.
+ *
+ * input parameters
+ *
+ * @param mode - HCI_EXT_NV_IN_USE, HCI_EXT_NV_NOT_IN_USE
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_COMMAND_DISALLOWED
+ */
+extern llStatus_t LL_EXT_DeclareNvUsage( uint8 mode );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_Decrypt API
+ *
+ * @brief This API is called by the HCI to request the LL to decrypt the
+ * data in the command using the key given in the command.
+ *
+ * Note: The parameters are byte ordered MSO to LSO.
+ *
+ * input parameters
+ *
+ * @param *key - A 128 bit key to be used to calculate the
+ * session key.
+ * @param *encryptedData - A 128 bit block that is encrypted.
+ *
+ * output parameters
+ *
+ * @param *plaintextData - A 128 bit block that is to be encrypted.
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_EXT_Decrypt( uint8 *key,
+ uint8 *encryptedData,
+ uint8 *plaintextData );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_SetLocalSupportedFeatures API
+ *
+ * @brief This API is called by the HCI to indicate to the Controller
+ * which features can or can not be used.
+ *
+ * Note: Not all features indicated by the Host to the Controller
+ * are valid. If invalid, they shall be ignored.
+ *
+ * input parameters
+ *
+ * @param featureSet - A pointer to the Feature Set where each bit:
+ * 0: Feature shall not be used.
+ * 1: Feature can be used.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_EXT_SetLocalSupportedFeatures( uint8 *featureSet );
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_SetFastTxResponseTime API
+ *
+ * @brief This API is used to enable or disable the fast TX response
+ * time feature. This can be helpful when a short connection
+ * interval is used in combination with slave latency. In such
+ * a scenario, the response time for sending the TX data packet
+ * can effectively shorten or eliminate slave latency, thereby
+ * increasing power consumption. By disabling, this feature
+ * trades fast response time for less power consumption.
+ *
+ * input parameters
+ *
+ * @param control - LL_EXT_ENABLE_FAST_TX_RESP_TIME,
+ * LL_EXT_DISABLE_FAST_TX_RESP_TIME
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_COMMAND_DISALLOWED,
+ * LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_EXT_SetFastTxResponseTime( uint8 control );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_SetSlaveLatencyOverride API
+ *
+ * @brief This API is used to enable or disable the suspention of slave
+ * latency. This can be helpful when the Slave application knows
+ * it will soon receive something that needs to be handled without
+ * delay.
+ *
+ * input parameters
+ *
+ * @param control - LL_EXT_DISABLE_SL_OVERRIDE,
+ * LL_EXT_ENABLE_SL_OVERRIDE
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_COMMAND_DISALLOWED,
+ * LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_EXT_SetSlaveLatencyOverride( uint8 control );
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_ModemTestTx
+ *
+ * @brief This API is used start a continuous transmitter modem test,
+ * using either a modulated or unmodulated carrier wave tone, at
+ * the frequency that corresponds to the specified RF channel. Use
+ * LL_EXT_EndModemTest command to end the test.
+ *
+ * Note: A LL reset will be issued by LL_EXT_EndModemTest!
+ * Note: The BLE device will transmit at maximum power.
+ * Note: This API can be used to verify this device meets Japan's
+ * TELEC regulations.
+ *
+ * input parameters
+ *
+ * @param cwMode - LL_EXT_TX_MODULATED_CARRIER,
+ * LL_EXT_TX_UNMODULATED_CARRIER
+ * txFreq - Transmit RF channel k=0..39, where BLE F=2402+(k*2MHz).
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_UNEXPECTED_STATE_ROLE
+ */
+extern llStatus_t LL_EXT_ModemTestTx( uint8 cwMode,
+ uint8 txFreq );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_ModemHopTestTx
+ *
+ * @brief This API is used to start a continuous transmitter direct test
+ * mode test using a modulated carrier wave and transmitting a
+ * 37 byte packet of Pseudo-Random 9-bit data. A packet is
+ * transmitted on a different frequency (linearly stepping through
+ * all RF channels 0..39) every 625us. Use LL_EXT_EndModemTest
+ * command to end the test.
+ *
+ * Note: A LL reset will be issued by LL_EXT_EndModemTest!
+ * Note: The BLE device will transmit at maximum power.
+ * Note: This API can be used to verify this device meets Japan's
+ * TELEC regulations.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_UNEXPECTED_STATE_ROLE
+ */
+extern llStatus_t LL_EXT_ModemHopTestTx( void );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_ModemTestRx
+ *
+ * @brief This API is used to start a continuous receiver modem test
+ * using a modulated carrier wave tone, at the frequency that
+ * corresponds to the specific RF channel. Any received data is
+ * discarded. Receiver gain may be adjusted using the
+ * LL_EXT_SetRxGain command. RSSI may be read during this test by
+ * using the LL_ReadRssi command. Use LL_EXT_EndModemTest command
+ * to end the test.
+ *
+ * Note: A LL reset will be issued by LL_EXT_EndModemTest!
+ * Note: The BLE device will transmit at maximum power.
+ *
+ * input parameters
+ *
+ * @param rxFreq - Receiver RF channel k=0..39, where BLE F=2402+(k*2MHz).
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_UNEXPECTED_STATE_ROLE
+ */
+extern llStatus_t LL_EXT_ModemTestRx( uint8 rxFreq );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_EndModemTest
+ *
+ * @brief This API is used to shutdown a modem test. A complete link
+ * layer reset will take place.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_UNEXPECTED_STATE_ROLE
+ */
+extern llStatus_t LL_EXT_EndModemTest( void );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_SetBDADDR
+ *
+ * @brief This API is used to set this device's BLE address (BDADDR).
+ *
+ * Note: This command is only allowed when the device's state is
+ * Standby.
+ *
+ * input parameters
+ *
+ * @param bdAddr - A pointer to a buffer to hold this device's address.
+ * An invalid address (i.e. all FF's) will restore this
+ * device's address to the address set at initialization.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_COMMAND_DISALLOWED
+ */
+extern llStatus_t LL_EXT_SetBDADDR( uint8 *bdAddr );
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_SetSCA
+ *
+ * @brief This API is used to set this device's Sleep Clock Accuracy.
+ *
+ * Note: For a slave device, this value is directly used, but only
+ * if power management is enabled. For a master device, this
+ * value is converted into one of eight ordinal values
+ * representing a SCA range, as specified in Table 2.2,
+ * Vol. 6, Part B, Section 2.3.3.1 of the Core specification.
+ *
+ * Note: This command is only allowed when the device is not in a
+ * connection.
+ *
+ * Note: The device's SCA value remains unaffected by a HCI_Reset.
+ *
+ * input parameters
+ *
+ * @param scaInPPM - This device's SCA in PPM from 0..500.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_COMMAND_DISALLOWED
+ */
+extern llStatus_t LL_EXT_SetSCA( uint16 scaInPPM );
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_SetFreqTune
+ *
+ * @brief This API is used to set the Frequncy Tuning up or down. If the
+ * current setting is already at the max/min value, then no
+ * update is performed.
+ *
+ * Note: This is a Production Test Mode only command!
+ *
+ * input parameters
+ *
+ * @param step - LL_EXT_SET_FREQ_TUNE_UP or LL_EXT_SET_FREQ_TUNE_DOWN
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_EXT_SetFreqTune( uint8 step );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_SaveFreqTune
+ *
+ * @brief This API is used to save the current Frequency Tuning value to
+ * flash memory. It is restored on reboot or wake from sleep.
+ *
+ * Note: This is a Production Test Mode only command!
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_COMMAND_DISALLOWED
+ */
+extern llStatus_t LL_EXT_SaveFreqTune( void );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_SetMaxDtmTxPower Vendor Specific API
+ *
+ * @brief This function is used to set the max RF TX power to be used
+ * when using Direct Test Mode.
+ *
+ * input parameters
+ *
+ * @param txPower - LL_EXT_TX_POWER_MINUS_23_DBM,
+ * LL_EXT_TX_POWER_MINUS_6_DBM,
+ * LL_EXT_TX_POWER_0_DBM,
+ * LL_EXT_TX_POWER_4_DBM
+ *
+ * output parameters
+ *
+ * @param cmdComplete - Boolean to indicate the command is still pending.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_EXT_SetMaxDtmTxPower( uint8 txPower );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_MapPmIoPort Vendor Specific API
+ *
+ * @brief This function is used to configure and map a CC254x I/O Port as
+ * a General Purpose I/O (GPIO) output signal that reflects the
+ * Power Management (PM) state of the CC254x device. The GPIO
+ * output will be High on Wake, and Low upon entering Sleep. This
+ * feature can be disabled by specifying LL_EXT_PM_IO_PORT_NONE for
+ * the ioPort (ioPin is then ignored). The system default value
+ * upon hardware reset is disabled. This command can be used to
+ * control an external DC-DC Converter (its actual intent) such has
+ * the TI TPS62730 (or any similar converter that works the same
+ * way). This command should be used with extreme care as it will
+ * override how the Port/Pin was previously configured! This
+ * includes the mapping of Port 0 pins to 32kHz clock output,
+ * Analog I/O, UART, Timers; Port 1 pins to Observables, Digital
+ * Regulator status, UART, Timers; Port 2 pins to an external 32kHz
+ * XOSC. The selected Port/Pin will be configured as an output GPIO
+ * with interrupts masked. Careless use can result in a
+ * reconfiguration that could disrupt the system. It is therefore
+ * the user's responsibility to ensure the selected Port/Pin does
+ * not cause any conflicts in the system.
+ *
+ * Note: Only Pins 0, 3 and 4 are valid for Port 2 since Pins 1
+ * and 2 are mapped to debugger signals DD and DC.
+ *
+ * Note: Port/Pin signal change will only occur when Power Savings
+ * is enabled.
+ *
+ * input parameters
+ *
+ * @param ioPort - LL_EXT_PM_IO_PORT_P0,
+ * LL_EXT_PM_IO_PORT_P1,
+ * LL_EXT_PM_IO_PORT_P2,
+ * LL_EXT_PM_IO_PORT_NONE
+ *
+ * @param ioPin - LL_EXT_PM_IO_PORT_PIN0,
+ * LL_EXT_PM_IO_PORT_PIN1,
+ * LL_EXT_PM_IO_PORT_PIN2,
+ * LL_EXT_PM_IO_PORT_PIN3,
+ * LL_EXT_PM_IO_PORT_PIN4,
+ * LL_EXT_PM_IO_PORT_PIN5,
+ * LL_EXT_PM_IO_PORT_PIN6,
+ * LL_EXT_PM_IO_PORT_PIN7
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER,
+ * LL_STATUS_ERROR_COMMAND_DISALLOWED
+ */
+extern llStatus_t LL_EXT_MapPmIoPort( uint8 ioPort, uint8 ioPin );
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_DisconnectImmed Vendor Specific API
+ *
+ * @brief This function is used to disconnect the connection immediately.
+ *
+ * Note: The connection (if valid) is immediately terminated
+ * without notifying the remote device. The Host is still
+ * notified.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID on which to send this data.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_INACTIVE_CONNECTION
+ */
+extern llStatus_t LL_EXT_DisconnectImmed( uint16 connId );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_PacketErrorRate Vendor Specific API
+ *
+ * @brief This function is used to Reset or Read the Packet Error Rate
+ * counters for a connection. When Reset, the counters are cleared;
+ * when Read, the total number of packets received, the number of
+ * packets received with a CRC error, the number of events, and the
+ * number of missed events are returned via a callback.
+ *
+ * Note: The counters are only 16 bits. At the shortest connection
+ * interval, this provides a bit over 8 minutes of data.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID on which to send this data.
+ * @param command - LL_EXT_PER_RESET, LL_EXT_PER_READ
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_INACTIVE_CONNECTION
+ */
+extern llStatus_t LL_EXT_PacketErrorRate( uint16 connId, uint8 command );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_PERbyChan Vendor Specific API
+ *
+ * @brief This API is called by the HCI to start or end Packet Error Rate
+ * by Channel counter accumulation for a connection. If the
+ * pointer is not NULL, it is assumed there is sufficient memory
+ * for the PER data, per the type perByChan_t. If NULL, then
+ * the operation is considered disabled.
+ *
+ * Note: It is the user's responsibility to make sure there is
+ * sufficient memory for the data, and that the counters
+ * are cleared prior to first use.
+ *
+ * Note: The counters are only 16 bits. At the shortest connection
+ * interval, this provides a bit over 8 minutes of data.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID on which to send this data.
+ * @param perByChan - Pointer to PER by Channel data, or NULL.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_INACTIVE_CONNECTION
+ */
+extern llStatus_t LL_EXT_PERbyChan( uint16 connId, perByChan_t *perByChan );
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_ExtendRfRange Vendor Specific API
+ *
+ * @brief This function is used to Extend Rf Range using the TI CC2590
+ * 2.4 GHz RF Front End device.
+ *
+ * input parameters
+ *
+ * @param cmdComplete - Pointer to get indicatin if command is done.
+ *
+ * output parameters
+ *
+ * @param cmdComplete - Boolean to indicate the command is still pending.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern llStatus_t LL_EXT_ExtendRfRange( uint8 *cmdComplete );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_HaltDuringRf Vendor Specfic API
+ *
+ * @brief This function is used to enable or disable halting the
+ * CPU during RF. The system defaults to enabled.
+ *
+ * input parameters
+ *
+ * @param mode - LL_EXT_HALT_DURING_RF_ENABLE,
+ * LL_EXT_HALT_DURING_RF_DISABLE
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_COMMAND_DISALLOWED,
+ * LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_EXT_HaltDuringRf( uint8 mode );
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_AdvEventNotice Vendor Specific API
+ *
+ * @brief This API is called to enable or disable a notification to the
+ * specified task using the specified task event whenever a Adv
+ * event ends. A non-zero taskEvent value is taken to be "enable",
+ * while a zero valued taskEvent is taken to be "disable".
+ *
+ * input parameters
+ *
+ * @param taskID - User's task ID.
+ * @param taskEvent - User's task event.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_EXT_AdvEventNotice( uint8 taskID, uint16 taskEvent );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_ConnEventNotice Vendor Specific API
+ *
+ * @brief This API is called to enable or disable a notification to the
+ * specified task using the specified task event whenever a
+ * Connection event ends. A non-zero taskEvent value is taken to
+ * be "enable", while a zero valued taskEvent is taken to be
+ * "disable".
+ *
+ * Note: Currently, only a Slave connection is supported.
+ *
+ * input parameters
+ *
+ * @param taskID - User's task ID.
+ * @param taskEvent - User's task event.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_INACTIVE_CONNECTION,
+ * LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_EXT_ConnEventNotice( uint8 taskID, uint16 taskEvent );
+
+
+
+/*******************************************************************************
+ * @fn LL_EXT_BuildRevision Vendor Specific API
+ *
+ * @brief This API is used to to set a user revision number or read the
+ * build revision number.
+ *
+ * input parameters
+ *
+ * @param mode - LL_EXT_SET_USER_REVISION |
+ * LL_EXT_READ_BUILD_REVISION
+ * @param userRevNum - A 16 bit value the user can set as their own
+ * revision number
+ *
+ * output parameters
+ *
+ * @param buildRev - Pointer to returned build revision, if any.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_BAD_PARAMETER
+ */
+extern llStatus_t LL_EXT_BuildRevision( uint8 mode, uint16 userRevNum, uint8 *buildRev );
+
+
+/*
+** LL Callbacks to HCI
+*/
+
+
+/*******************************************************************************
+ * @fn LL_ConnectionCompleteCback Callback
+ *
+ * @brief This Callback is used by the LL to indicate to the Host that
+ * a new connection has been created. For the Slave, this means
+ * a CONNECT_REQ message was received from an Initiator. For the
+ * Master, this means a CONNECT_REQ message was sent in response
+ * to a directed or undirected message addressed to the Initiator.
+ *
+ * input parameters
+ *
+ * @param reasonCode - LL_STATUS_SUCCESS or ?
+ * @param connId - The LL connection ID for new connection.
+ * @param role - LL_LINK_CONNECT_COMPLETE_MASTER or
+ * LL_LINK_CONNECT_COMPLETE_SLAVE.
+ * @param peerAddrType - Peer address type (public or random).
+ * @param peerAddr - Peer address.
+ * @param connInterval - Connection interval.
+ * @param slaveLatency - The connection's Slave Latency.
+ * @param connTimeout - The connection's Supervision Timeout.
+ * @param clockAccuracy - The sleep clock accurracy of the Master. Only
+ * valid on the Slave. Set to 0x00 for the Master.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_ConnectionCompleteCback( uint8 reasonCode,
+ uint16 connId,
+ uint8 role,
+ uint8 peerAddrType,
+ uint8 *peerAddr,
+ uint16 connInterval,
+ uint16 slaveLatency,
+ uint16 connTimeout,
+ uint8 clockAccuracy );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_DisconnectCback Callback
+ *
+ * @brief This Callback is used by the LL to indicate to the Host that
+ * the connection has been terminated. The cause is given by the
+ * reason code.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID.
+ * @param reason - The reason the connection was terminated.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_DisconnectCback( uint16 connId,
+ uint8 reason );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_ConnParamUpdateCback Callback
+ *
+ * @brief This Callback is used by the LL to indicate to the Host that
+ * the update parameters control procedure has completed. It is
+ * always made to the Master's Host when the update request has
+ * been sent. It is only made to the Slave's Host when the update
+ * results in a change to the connection interval, and/or the
+ * connection latency, and/or the connection timeout.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID.
+ * @param connInterval - Connection interval.
+ * @param connLatency - The connection's Slave Latency.
+ * @param connTimeout - The connection's Supervision Timeout.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_ConnParamUpdateCback( uint16 connId,
+ uint16 connInterval,
+ uint16 connLatency,
+ uint16 connTimeout );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_ReadRemoteVersionInfoCback Callback
+ *
+ * @brief This Callback is used by the LL to indicate to the Host the
+ * requested peer's Version information.
+ *
+ * input parameters
+ *
+ * @param status - Status of callback.
+ * @param connId - The LL connection ID.
+ * @param verNum - Version of the Bluetooth Controller specification.
+ * @param comId - Company identifier of the manufacturer of the
+ * Bluetooth Controller.
+ * @param subverNum - A unique value for each implementation or revision
+ * of an implementation of the Bluetooth Controller.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_ReadRemoteVersionInfoCback( uint8 status,
+ uint16 connId,
+ uint8 verNum,
+ uint16 comId,
+ uint16 subverNum );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_EncChangeCback Callback
+ *
+ * @brief This Callback is used by the LL to indicate to the Host that
+ * an encryption change has taken place. This results when
+ * the host performs a LL_StartEncrypt when encryption is not
+ * already enabled.
+ *
+ * Note: If the key request was rejected, then encryption will
+ * remain off.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID for new connection.
+ * @param reason - LL_ENC_KEY_REQ_ACCEPTED or LL_ENC_KEY_REQ_REJECTED.
+ * @param encEnab - LL_ENCRYPTION_OFF or LL_ENCRYPTION_ON.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_EncChangeCback( uint16 connId,
+ uint8 reason,
+ uint8 encEnab );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_EncKeyRefreshCback Callback
+ *
+ * @brief This Callback is used by the LL to indicate to the Host that
+ * an encryption key change has taken place. This results when
+ * the host performs a LL_StartEncrypt when encryption is already
+ * enabled.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID for new connection.
+ * @param reason - LL_ENC_KEY_REQ_ACCEPTED.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_EncKeyRefreshCback( uint16 connId,
+ uint8 reason );
+
+
+
+#line 2416 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\controller\\include\\ll.h"
+
+
+
+/*******************************************************************************
+ * @fn LL_ReadRemoteUsedFeaturesCompleteCback Callback
+ *
+ * @brief This Callback is used by the LL to indicate to the Host that
+ * the Read Remote Feature Support command as completed.
+ *
+ * input parameters
+ *
+ * @param status - SUCCESS or control procedure timeout.
+ * @param connId - The LL connection ID for new connection.
+ * @param featureSet - A pointer to the Feature Set.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_ReadRemoteUsedFeaturesCompleteCback( uint8 status,
+ uint16 connId,
+ uint8 *featureSet );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_EncLtkReqCback Callback
+ *
+ * @brief This Callback is used by the LL to provide to the Host the
+ * Master's random number and encryption diversifier, and to
+ * request the Host's Long Term Key (LTK).
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID for new connection.
+ * @param randNum - Random vector used in device identification.
+ * @param encDiv - Encrypted diversifier.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_EncLtkReqCback( uint16 connId,
+ uint8 *randNum,
+ uint8 *encDiv );
+
+
+
+/*******************************************************************************
+ * @fn LL_DirectTestEndDone Callback
+ *
+ * @brief This Callback is used by the LL to notify the HCI that the
+ * Direct Test End command has completed.
+ *
+ *
+ * input parameters
+ *
+ * @param numPackets - The number of packets received. Zero for transmit.
+ * @param mode - LL_DIRECT_TEST_MODE_TX or LL_DIRECT_TEST_MODE_RX.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS
+ */
+extern void LL_DirectTestEndDoneCback( uint16 numPackets,
+ uint8 mode );
+
+
+
+/*******************************************************************************
+ * @fn LL_TxDataCompleteCback Callback
+ *
+ * @brief This Callback is used by the LL to indicate to the HCI that
+ * the HCI's buffer is free for its own use again.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID on which to send this data.
+ * @param *pBuf - A pointer to the data buffer to transmit, or NULL.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ ******************************************************************************/
+extern void LL_TxDataCompleteCback( uint16 connId,
+ uint8 *pBuf );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_RxReqDataBufCback Callback
+ *
+ * @brief This Callback is used by the LL to indicate to the HCI that a
+ * receive data buffer of a given size is needed.
+ *
+ * input parameters
+ *
+ * @param size - Number of bytes in the payload.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return Pointer to allocated buffer, or NULL.
+ */
+extern uint8 *LL_RxReqDataBufCback( uint8 size );
+
+
+
+
+/*******************************************************************************
+ * @fn LL_RxDataCompleteCback Callback
+ *
+ * @brief This Callback is used by the LL to indicate to the HCI that
+ * data has been received and placed in the buffer provided by
+ * the HCI.
+ *
+ * input parameters
+ *
+ * @param connId - The LL connection ID on which data was received.
+ * @param *pBuf - A pointer to the receive data buffer provided by
+ * the HCI.
+ * @param len - The number of bytes received on this connection.
+ * @param fragFlag - LL_DATA_FIRST_PKT indicates buffer is the start of
+ * a Host packet.
+ * LL_DATA_CONTINUATION_PKT: Indicates buffer is a
+ * continuation of a Host packet.
+ * @param rssi - The RSSI of this received packet as a signed byte.
+ * Range: -127dBm..+20dBm, 127=Not Available.
+ *
+ * output parameters
+ *
+ * @param **pBuf - A double pointer updated to the next receive data
+ * buffer, or NULL if no next buffer is available.
+ *
+ * @return None.
+ */
+extern void LL_RxDataCompleteCback( uint16 connId,
+ uint8 *ppBuf,
+ uint8 len,
+ uint8 fragFlag,
+ int8 rssi );
+
+
+
+/*******************************************************************************
+ * @fn LL_RandCback API
+ *
+ * @brief This Callback is used by the LL to notify the HCI that the true
+ * random number command has been completed.
+ *
+ * Note: The length is always given by B_RANDOM_NUM_SIZE.
+ *
+ * input parameters
+ *
+ * @param *randData - Pointer to buffer to place a random block of data.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_RandCback( uint8 *randData );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_SetRxGainCback Callback
+ *
+ * @brief This Callback is used by the LL to notify the HCI that the set
+ * RX gain command has been completed.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_EXT_SetRxGainCback( void );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_SetTxPowerCback Callback
+ *
+ * @brief This Callback is used by the LL to notify the HCI that the set
+ * TX power command has been completed.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_EXT_SetTxPowerCback( void );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_PacketErrorRateCback Callback
+ *
+ * @brief This Callback is used by the LL to notify the HCI that the
+ * Packet Error Rate Read command has been completed.
+ *
+ * Note: The counters are only 16 bits. At the shortest connection
+ * interval, this provides a bit over 8 minutes of data.
+ *
+ * input parameters
+ *
+ * @param numPkts - Number of Packets received.
+ * @param numCrcErr - Number of Packets received with a CRC error.
+ * @param numEvents - Number of Connection Events.
+ * @param numPkts - Number of Missed Connection Events.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_EXT_PacketErrorRateCback( uint16 numPkts,
+ uint16 numCrcErr,
+ uint16 numEvents,
+ uint16 numMissedEvts );
+
+
+/*******************************************************************************
+ * @fn LL_EXT_ExtendRfRangeCback Callback
+ *
+ * @brief This Callback is used by the LL to notify the HCI that the
+ * Extend Rf Range command has been completed.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void LL_EXT_ExtendRfRangeCback( void );
+
+
+
+
+
+
+
+
+#line 20 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+
+/* HCI */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\hci\\hci_tl.h"
+/*******************************************************************************
+ Filename: hci_tl.h
+ Revised: $Date: 2012-04-20 15:24:45 -0700 (Fri, 20 Apr 2012) $
+ Revision: $Revision: 30292 $
+
+ Description: This file contains the types, contants, external functions
+ etc. for the BLE HCI Transport Layer.
+
+ Copyright 2009-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+ * INCLUDES
+ */
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\hci.h"
+/*******************************************************************************
+ Filename: hci.h
+ Revised: $Date: 2013-05-14 12:23:59 -0700 (Tue, 14 May 2013) $
+ Revision: $Revision: 34279 $
+
+ Description: This file contains the Host Controller Interface (HCI) API.
+ It provides the defines, types, and functions for all
+ supported Bluetooth Low Energy (BLE) commands.
+
+ All Bluetooth and BLE commands are based on:
+ Bluetooth Core Specification, V4.0.0, Vol. 2, Part E.
+
+ Copyright 2009-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+ * INCLUDES
+ */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_assert.h"
+/**************************************************************************************************
+ Filename: hal_assert.h
+ Revised: $Date: 2009-02-16 18:03:22 -0800 (Mon, 16 Feb 2009) $
+ Revision: $Revision: 19172 $
+
+ Description: Describe the purpose and contents of the file.
+
+
+ Copyright 2006-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * HAL_ASSERT( expression ) - The given expression must evaluate as "true" or else the assert
+ * handler is called. From here, the call stack feature of the debugger can pinpoint where
+ * the problem occurred.
+ *
+ * HAL_ASSERT_FORCED( ) - If asserts are in use, immediately calls the assert handler.
+ *
+ * HAL_ASSERT_STATEMENT( statement ) - Inserts the given C statement but only when asserts
+ * are in use. This macros allows debug code that is not part of an expression.
+ *
+ * HAL_ASSERT_DECLARATION( declaration ) - Inserts the given C declaration but only when asserts
+ * are in use. This macros allows debug code that is not part of an expression.
+ *
+ * Asserts can be disabled for optimum performance and minimum code size (ideal for
+ * finalized, debugged production code). To disable, define the preprocessor
+ * symbol HALNODEBUG at the project level.
+ */
+
+
+#line 78 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_assert.h"
+
+
+/*
+ * This macro compares the size of the first parameter to the integer value
+ * of the second parameter. If they do not match, a compile time error for
+ * negative array size occurs (even gnu chokes on negative array size).
+ *
+ * This compare is done by creating a typedef for an array. No variables are
+ * created and no memory is consumed with this check. The created type is
+ * used for checking only and is not for use by any other code. The value
+ * of 10 in this macro is arbitrary, it just needs to be a value larger
+ * than one to result in a positive number for the array size.
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Prototypes
+ * ------------------------------------------------------------------------------------------------
+ */
+void halAssertHandler(void);
+
+
+/**************************************************************************************************
+ */
+
+/**************************************************************************************************
+ * FUNCTIONS - API
+ **************************************************************************************************/
+
+
+extern void halAssertHazardLights(void);
+#line 59 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\hci.h"
+
+/*******************************************************************************
+ * MACROS
+ */
+
+/*******************************************************************************
+ * CONSTANTS
+ */
+
+/*
+** HCI Status
+**
+** Per the Bluetooth Core Specification, V4.0.0, Vol. 2, Part D.
+*/
+#line 137 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\hci.h"
+
+/*
+** HCI Command API Parameters
+*/
+
+// Send Data Packet Boundary Flags
+
+
+
+
+// Receive Data Packet
+
+
+// Disconnect Reasons
+#line 158 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\hci.h"
+
+// Tx Power Types
+
+
+
+// Host Flow Control
+
+
+
+
+
+// Device Address Type
+
+
+
+// Advertiser Events
+
+
+
+
+
+// Advertiser Channels
+
+
+
+
+
+// Advertiser White List Policy
+
+
+
+
+
+// Advertiser Commands
+
+
+
+// Scan Types
+
+
+
+// Scan White List Policy
+
+
+
+// Scan Filtering
+
+
+
+// Scan Commands
+
+
+
+// Initiator White List Policy
+
+
+
+// Encryption Related
+
+
+
+// Direct Test Mode
+
+
+//
+#line 231 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\hci.h"
+
+// Vendor Specific
+
+
+//
+
+
+
+
+//
+
+
+//
+
+
+//
+
+
+//
+
+
+//
+
+
+//
+
+
+//
+
+
+//
+
+
+
+
+//
+#line 275 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\hci.h"
+//
+
+
+//
+
+
+//
+
+
+
+/*
+** HCI Event Parameters
+*/
+
+// HCI Link Type for Buffer Overflow
+
+
+
+/*******************************************************************************
+ * TYPEDEFS
+ */
+
+typedef uint8 hciStatus_t;
+
+/*
+** LE Events
+*/
+
+// LE Connection Complete Event
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 BLEEventCode;
+ uint8 status;
+ uint16 connectionHandle;
+ uint8 role;
+ uint8 peerAddrType;
+ uint8 peerAddr[6];
+ uint16 connInterval;
+ uint16 connLatency;
+ uint16 connTimeout;
+ uint8 clockAccuracy;
+} hciEvt_BLEConnComplete_t;
+
+// LE Advertising Report Event
+typedef struct
+{
+ uint8 eventType; // advertisment or scan response event type
+ uint8 addrType; // public or random address type
+ uint8 addr[6]; // device address
+ uint8 dataLen; // length of report data
+ uint8 rspData[31]; // report data given by dataLen
+ int8 rssi; // report RSSI
+} hciEvt_DevInfo_t;
+
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 BLEEventCode;
+ uint8 numDevices;
+ hciEvt_DevInfo_t* devInfo; // pointer to the array of devInfo
+} hciEvt_BLEAdvPktReport_t;
+
+// LE Connection Update Complete Event
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 BLEEventCode;
+ uint8 status;
+ uint16 connectionHandle;
+ uint16 connInterval;
+ uint16 connLatency;
+ uint16 connTimeout;
+} hciEvt_BLEConnUpdateComplete_t;
+
+// LE Read Remote Used Features Complete Event
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 BLEEventCode;
+ uint8 status;
+ uint16 connectionHandle;
+ uint8 features[8];
+} hciEvt_BLEReadRemoteFeatureComplete_t;
+
+// LE Encryption Change Event
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 BLEEventCode;
+ uint16 connHandle;
+ uint8 reason;
+ uint8 encEnable;
+} hciEvt_EncryptChange_t;
+
+// LE Long Term Key Requested Event
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 BLEEventCode;
+ uint16 connHandle;
+ uint8 random[8];
+ uint16 encryptedDiversifier;
+} hciEvt_BLELTKReq_t;
+
+// Number of Completed Packets Event
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 numHandles;
+ uint16 *pConnectionHandle; // pointer to the connection handle array
+ uint16 *pNumCompletedPackets; // pointer to the number of completed packets array
+} hciEvt_NumCompletedPkt_t;
+
+// Command Complete Event
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 numHciCmdPkt; // number of HCI Command Packet
+ uint16 cmdOpcode;
+ uint8 *pReturnParam; // pointer to the return parameter
+} hciEvt_CmdComplete_t;
+
+// Command Status Event
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 cmdStatus;
+ uint8 numHciCmdPkt;
+ uint16 cmdOpcode;
+} hciEvt_CommandStatus_t;
+
+// Hardware Error Event
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 hardwareCode;
+} hciEvt_HardwareError_t;
+
+// Disconnection Complete Event
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 status;
+ uint16 connHandle; // connection handle
+ uint8 reason;
+} hciEvt_DisconnComplete_t;
+
+// Data Buffer Overflow Event
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 linkType; // synchronous or asynchronous buffer overflow
+} hciEvt_BufferOverflow_t;
+
+// Data structure for HCI Command Complete Event Return Parameter
+typedef struct
+{
+ uint8 status;
+ uint16 dataPktLen;
+ uint8 numDataPkts;
+} hciRetParam_LeReadBufSize_t;
+
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 *pData;
+} hciPacket_t;
+
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 pktType;
+ uint16 connHandle;
+ uint8 pbFlag;
+ uint16 pktLen;
+ uint8 *pData;
+} hciDataPacket_t;
+
+// OSAL HCI_DATA_EVENT message format. This message is used to forward incoming
+// data messages up to an application
+typedef struct
+{
+ osal_event_hdr_t hdr; // OSAL event header
+ uint16 connHandle; // connection handle
+ uint8 pbFlag; // data packet boundary flag
+ uint16 len; // length of data packet
+ uint8 *pData; // data packet given by len
+} hciDataEvent_t;
+
+/*******************************************************************************
+ * LOCAL VARIABLES
+ */
+
+/*******************************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*
+** HCI Support Functions
+*/
+
+/*******************************************************************************
+ * @fn HCI_bm_alloc API
+ *
+ * @brief This API is used to allocate memory using buffer management.
+ *
+ * Note: This function should never be called by the application.
+ * It is only used by HCI and L2CAP_bm_alloc.
+ *
+ * input parameters
+ *
+ * @param size - Number of bytes to allocate from the heap.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return Pointer to buffer, or NULL.
+ */
+extern void *HCI_bm_alloc( uint16 size );
+
+
+/*******************************************************************************
+ * @fn HCI_ValidConnTimeParams API
+ *
+ * @brief This API is used to check that the connection time parameter
+ * ranges are valid, and that the connection time parameter
+ * combination is valid.
+ *
+ * Note: Only connIntervalMax is used as part of the time parameter
+ * combination check.
+ *
+ * input parameters
+ *
+ * @param connIntervalMin - Minimum connection interval.
+ * @param connIntervalMax - Maximum connection interval.
+ * @param connLatency - Connection slave latency.
+ * @param connTimeout - Connection supervision timeout.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return TRUE: Connection time parameter check is valid.
+ * FALSE: Connection time parameter check is invalid.
+ */
+extern uint8 HCI_ValidConnTimeParams( uint16 connIntervalMin,
+ uint16 connIntervalMax,
+ uint16 connLatency,
+ uint16 connTimeout );
+
+
+/*******************************************************************************
+ * @fn HCI_TestAppTaskRegister
+ *
+ * @brief HCI vendor specific registration for HCI Test Application.
+ *
+ * input parameters
+ *
+ * @param taskID - The HCI Test Application OSAL task identifer.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_TestAppTaskRegister( uint8 taskID );
+
+
+/*******************************************************************************
+ * @fn HCI_GAPTaskRegister
+ *
+ * @brief HCI vendor specific registration for Host GAP.
+ *
+ * input parameters
+ *
+ * @param taskID - The Host GAP OSAL task identifer.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_GAPTaskRegister( uint8 taskID );
+
+
+/*******************************************************************************
+ *
+ * @fn HCI_L2CAPTaskRegister
+ *
+ * @brief HCI vendor specific registration for Host L2CAP.
+ *
+ * input parameters
+ *
+ * @param taskID - The Host L2CAP OSAL task identifer.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ *
+ */
+extern void HCI_L2CAPTaskRegister( uint8 taskID );
+
+
+/*******************************************************************************
+ * @fn HCI_SMPTaskRegister
+ *
+ * @brief HCI vendor specific registration for Host SMP.
+ *
+ * input parameters
+ *
+ * @param taskID - The Host SMP OSAL task identifer.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_SMPTaskRegister( uint8 taskID );
+
+
+/*******************************************************************************
+ * @fn HCI_ExtTaskRegister
+ *
+ * @brief HCI vendor specific registration for Host extended commands.
+ *
+ * input parameters
+ *
+ * @param taskID - The Host Extended Command OSAL task identifer.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_ExtTaskRegister( uint8 taskID );
+
+
+
+/*******************************************************************************
+ * @fn HCI_SendDataPkt API
+ *
+ * @brief This API is used to send a ACL data packet over a connection.
+ *
+ * Note: Empty packets are not sent.
+ *
+ * Related Events: HCI_NumOfCompletedPacketsEvent
+ *
+ * input parameters
+ *
+ * @param connHandle - Connection ID (handle).
+ * @param pbFlag - Packet Boundary Flag.
+ * @param pktLen - Number of bytes of data to transmit.
+ * @param *pData - Pointer to data buffer to transmit.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return HCI_SUCCESS, HCI_ERROR_CODE_MEM_CAP_EXCEEDED,
+ * HCI_ERROR_CODE_INVALID_HCI_CMD_PARAMS,
+ * HCI_ERROR_CODE_UNKNOWN_CONN_ID
+ */
+extern hciStatus_t HCI_SendDataPkt( uint16 connHandle,
+ uint8 pbFlag,
+ uint16 pktLen,
+ uint8 *pData );
+
+
+
+/*
+** HCI API
+*/
+
+
+/*******************************************************************************
+ * @fn HCI_DisconnectCmd API
+ *
+ * @brief This BT API is used to terminate a connection.
+ *
+ * Related Events: HCI_CommandStatusEvent,
+ * DisconnectEvent
+ *
+ * input parameters
+ *
+ * @param connHandle - Connection handle.
+ * @param reason - Reason for disconnection:
+ * HCI_DISCONNECT_AUTH_FAILURE,
+ * HCI_DISCONNECT_REMOTE_USER_TERM,
+ * HCI_DISCONNECT_REMOTE_DEV_POWER_OFF,
+ * HCI_DISCONNECT_UNSUPPORTED_REMOTE_FEATURE,
+ * HCI_DISCONNECT_KEY_PAIRING_NOT_SUPPORTED
+ * HCI_DISCONNECT_UNACCEPTABLE_CONN_INTERVAL
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return HCI_SUCCESS
+ */
+extern hciStatus_t HCI_DisconnectCmd( uint16 connHandle,
+ uint8 reason );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_ReadRemoteVersionInfoCmd API
+ *
+ * @brief This BT API is used to request version information from the
+ * the remote device in a connection.
+ *
+ * Related Events: HCI_CommandStatusEvent,
+ * ReadRemoteVersionInfoEvent
+ *
+ * input parameters
+ *
+ * @param connHandle - Connection handle.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_ReadRemoteVersionInfoCmd( uint16 connHandle );
+
+
+
+/*******************************************************************************
+ * @fn HCI_SetEventMaskCmd API
+ *
+ * @brief This BT API is used to set the HCI event mask, which is used to
+ * determine which events are supported.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param pMask - Pointer to an eight byte event mask.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_SetEventMaskCmd( uint8 *pMask );
+
+
+/*******************************************************************************
+ * @fn HCI_Reset API
+ *
+ * @brief This BT API is used to reset the Link Layer.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_ResetCmd( void );
+
+
+
+/*******************************************************************************
+ * @fn HCI_ReadTransmitPowerLevelCmd API
+ *
+ * @brief This BT API is used to read the transmit power level.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param connHandle - Connection handle.
+ * @param txPwrType - HCI_READ_CURRENT_TX_POWER_LEVEL,
+ * HCI_READ_MAXIMUM_TX_POWER_LEVEL
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_ReadTransmitPowerLevelCmd( uint16 connHandle,
+ uint8 txPwrType );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_SetControllerToHostFlowCtrlCmd API
+ *
+ * @brief This BT API is used by the Host to turn flow control on or off
+ * for data sent from the Controller to Host.
+ *
+ * Note: This command is currently not supported.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param flowControlEnable - HCI_CTRL_TO_HOST_FLOW_CTRL_OFF,
+ * HCI_CTRL_TO_HOST_FLOW_CTRL_ACL_ON_SYNCH_OFF,
+ * HCI_CTRL_TO_HOST_FLOW_CTRL_ACL_OFF_SYNCH_ON,
+ * HCI_CTRL_TO_HOST_FLOW_CTRL_ACL_ON_SYNCH_ON
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_SetControllerToHostFlowCtrlCmd( uint8 flowControlEnable );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_HostBufferSizeCmd API
+ *
+ * @brief This BT API is used by the Host to notify the Controller of the
+ * maximum size ACL buffer size the Controller can send to the
+ * Host.
+ *
+ * Note: This command is currently ignored by the Controller. It
+ * is assumed that the Host can always handle the maximum
+ * BLE data packet size.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param hostAclPktLen - Host ACL data packet length.
+ * @param hostSyncPktLen - Host SCO data packet length .
+ * @param hostTotalNumAclPkts - Host total number of ACL data packets.
+ * @param hostTotalNumSyncPkts - Host total number of SCO data packets.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_HostBufferSizeCmd( uint16 hostAclPktLen,
+ uint8 hostSyncPktLen,
+ uint16 hostTotalNumAclPkts,
+ uint16 hostTotalNumSyncPkts );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_HostNumCompletedPktCmd API
+ *
+ * @brief This BT API is used by the Host to notify the Controller of the
+ * number of HCI data packets that have been completed for each
+ * connection handle since this command was previously sent to the
+ * controller.
+ *
+ * The Host_Number_Of_Conpleted_Packets command is a special
+ * command. No event is normally generated after the command
+ * has completed. The command should only be issued by the
+ * Host if flow control in the direction from controller to
+ * the host is on and there is at least one connection, or
+ * if the controller is in local loopback mode.
+ *
+ * Note: The current version of BLE stack does not support
+ * controller to host flow control. Hence, the command is
+ * ignored if received.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param numHandles - Number of connection handles.
+ * @param connHandles - Array of connection handles.
+ * @param numCompletedPkts - Array of number of completed packets.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_HostNumCompletedPktCmd( uint8 numHandles,
+ uint16 *connHandles,
+ uint16 *numCompletedPkts );
+
+
+
+/*******************************************************************************
+ * @fn HCI_ReadLocalVersionInfoCmd API
+ *
+ * @brief This BT API is used to read the local version information.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_ReadLocalVersionInfoCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_ReadLocalSupportedCommandsCmd API
+ *
+ * @brief This BT API is used to read the locally supported commands.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_ReadLocalSupportedCommandsCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_ReadLocalSupportedFeaturesCmd API
+ *
+ * @brief This BT API is used to read the locally supported features.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_ReadLocalSupportedFeaturesCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_ReadBDADDRCmd API
+ *
+ * @brief This BT API is used to read this device's BLE address (BDADDR).
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_ReadBDADDRCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_ReadRssiCmd API
+ *
+ * @brief This BT API is used to read the RSSI of the last packet
+ * received on a connection given by the connection handle. If
+ * the Receiver Modem test is running (HCI_EXT_ModemTestRx), then
+ * the RF RSSI for the last received data will be returned. If
+ * there is no RSSI value, then HCI_RSSI_NOT_AVAILABLE will be
+ * returned.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param connHandle - Connection handle.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_ReadRssiCmd( uint16 connHandle );
+
+/*
+** HCI Low Energy Commands
+*/
+
+/*******************************************************************************
+ * @fn HCI_LE_SetEventMaskCmd API
+ *
+ * @brief This LE API is used to set the HCI LE event mask, which is used
+ * to determine which LE events are supported.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param pEventMask - Pointer to LE event mask of 8 bytes.
+
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_SetEventMaskCmd( uint8 *pEventMask );
+
+
+/*******************************************************************************
+ * @fn HCI_LE_ReadBufSizeCmd API
+ *
+ * @brief This LE API is used by the Host to determine the maximum ACL
+ * data packet size allowed by the Controller.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_ReadBufSizeCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_LE_ReadLocalSupportedFeaturesCmd API
+ *
+ * @brief This LE API is used to read the LE locally supported features.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_ReadLocalSupportedFeaturesCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_LE_SetRandomAddressCmd API
+ *
+ * @brief This LE API is used to set this device's Random address.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param pRandAddr - Pointer to random address.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_SetRandomAddressCmd( uint8 *pRandAddr );
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_SetAdvParamCmd API
+ *
+ * @brief This LE API is used to set the Advertising parameters.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param advIntervalMin - Minimum allowed advertising interval.
+ * @param advIntervalMax - Maximum allowed advertising interval.
+ * @param advType - HCI_CONNECTABLE_UNDIRECTED_ADV,
+ * HCI_CONNECTABLE_DIRECTED_ADV,
+ * HCI_SCANNABLE_UNDIRECTED,
+ * HCI_NONCONNECTABLE_UNDIRECTED_ADV
+ * @param ownAddrType - HCI_PUBLIC_DEVICE_ADDRESS,
+ * HCI_RANDOM_DEVICE_ADDRESS
+ * @param directAddrType - HCI_PUBLIC_DEVICE_ADDRESS,
+ * HCI_RANDOM_DEVICE_ADDRESS
+ * @param directAddr - Pointer to address of device when using
+ * directed advertising.
+ * @param advChannelMap - HCI_ADV_CHAN_37,
+ * HCI_ADV_CHAN_38
+ * HCI_ADV_CHAN_39
+ * HCI_ADV_CHAN_ALL
+ * @param advFilterPolicy - HCI_ADV_WL_POLICY_ANY_REQ,
+ * HCI_ADV_WL_POLICY_WL_SCAN_REQ,
+ * HCI_ADV_WL_POLICY_WL_CONNECT_REQ,
+ * HCI_ADV_WL_POLICY_WL_ALL_REQ
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_SetAdvParamCmd( uint16 advIntervalMin,
+ uint16 advIntervalMax,
+ uint8 advType,
+ uint8 ownAddrType,
+ uint8 directAddrType,
+ uint8 *directAddr,
+ uint8 advChannelMap,
+ uint8 advFilterPolicy );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_SetAdvDataCmd API
+ *
+ * @brief This LE API is used to set the Advertising data.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param dataLen - Length of Advertising data.
+ * @param pData - Pointer to Advertising data.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_SetAdvDataCmd( uint8 dataLen,
+ uint8 *pData );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_SetScanRspDataCmd API
+ *
+ * @brief This LE API is used to set the Advertising Scan Response data.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param dataLen - Length of Scan Response data.
+ * @param pData - Pointer to Scan Response data.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_SetScanRspDataCmd( uint8 dataLen,
+ uint8 *pData );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_SetAdvEnableCmd API
+ *
+ * @brief This LE API is used to turn Advertising on or off.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param advEnable - HCI_ENABLE_ADV, HCI_DISABLE_ADV
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_SetAdvEnableCmd( uint8 advEnable );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_ReadAdvChanTxPowerCmd API
+ *
+ * @brief This LE API is used to read transmit power when Advertising.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_ReadAdvChanTxPowerCmd( void );
+
+
+
+#line 1240 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\hci.h"
+
+
+#line 1266 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\hci.h"
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_CreateConnCmd API
+ *
+ * @brief This LE API is used to create a connection.
+ *
+ * Related Events: HCI_CommandStatusEvent,
+ * ConnectionCompleteEvent
+ *
+ * input parameters
+ *
+ * @param scanInterval - Time between Init scan events.
+ * @param scanWindow - Time of scan before Init scan event ends.
+ * Note: When the scanWindow equals the
+ * scanInterval then scanning is
+ * continuous.
+ * @param initFilterPolicy - HCI_INIT_WL_POLICY_USE_PEER_ADDR,
+ * HCI_INIT_WL_POLICY_USE_WHITE_LIST
+ * @param addrTypePeer - HCI_PUBLIC_DEVICE_ADDRESS,
+ * HCI_RANDOM_DEVICE_ADDRESS
+ * @param peerAddr - Pointer to peer device's address.
+ * @param ownAddrType - HCI_PUBLIC_DEVICE_ADDRESS,
+ * HCI_RANDOM_DEVICE_ADDRESS
+ * @param connIntervalMin - Minimum allowed connection interval.
+ * @param connIntervalMax - Maximum allowed connection interval.
+ * @param connLatency - Number of skipped events (slave latency).
+ * @param connTimeout - Connection supervision timeout.
+ * @param minLen - Info parameter about min length of conn.
+ * @param maxLen - Info parameter about max length of conn.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_CreateConnCmd( uint16 scanInterval,
+ uint16 scanWindow,
+ uint8 initFilterPolicy,
+ uint8 addrTypePeer,
+ uint8 *peerAddr,
+ uint8 ownAddrType,
+ uint16 connIntervalMin,
+ uint16 connIntervalMax,
+ uint16 connLatency,
+ uint16 connTimeout,
+ uint16 minLen,
+ uint16 maxLen );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_CreateConnCancelCmd API
+ *
+ * @brief This LE API is used to cancel a create connection.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_CreateConnCancelCmd( void );
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_ReadWhiteListSizeCmd API
+ *
+ * @brief This LE API is used to read the white list.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_ReadWhiteListSizeCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_LE_ClearWhiteListCmd API
+ *
+ * @brief This LE API is used to clear the white list.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_ClearWhiteListCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_LE_AddWhiteListCmd API
+ *
+ * @brief This LE API is used to add a white list entry.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param addrType - HCI_PUBLIC_DEVICE_ADDRESS, HCI_RANDOM_DEVICE_ADDRESS
+ * @param devAddr - Pointer to address of device to put in white list.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_AddWhiteListCmd( uint8 addrType,
+ uint8 *devAddr );
+
+
+/*******************************************************************************
+ * @fn HCI_LE_RemoveWhiteListCmd API
+ *
+ * @brief This LE API is used to remove a white list entry.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param addrType - HCI_PUBLIC_DEVICE_ADDRESS, HCI_RANDOM_DEVICE_ADDRESS
+ * @param devAddr - Pointer to address of device to remove from the
+ * white list.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_RemoveWhiteListCmd( uint8 addrType,
+ uint8 *devAddr );
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_ConnUpdateCmd API
+ *
+ * @brief This LE API is used to update the connection parameters.
+ *
+ * Related Events: HCI_CommandStatusEvent,
+ * ConnectionUpdateCompleteEvent
+ *
+ * input parameters
+ *
+ * @param connHandle - Time between Init scan events.
+ * @param connIntervalMin - Minimum allowed connection interval.
+ * @param connIntervalMax - Maximum allowed connection interval.
+ * @param connLatency - Number of skipped events (slave latency).
+ * @param connTimeout - Connection supervision timeout.
+ * @param minLen - Info parameter about min length of conn.
+ * @param maxLen - Info parameter about max length of conn.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_ConnUpdateCmd( uint16 connHandle,
+ uint16 connIntervalMin,
+ uint16 connIntervalMax,
+ uint16 connLatency,
+ uint16 connTimeout,
+ uint16 minLen,
+ uint16 maxLen );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_SetHostChanClassificationCmd API
+ *
+ * @brief This LE API is used to update the current data channel map.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param chanMap - Pointer to the new channel map.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_SetHostChanClassificationCmd( uint8 *chanMap );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_ReadChannelMapCmd API
+ *
+ * @brief This LE API is used to read a connection's data channel map.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param connHandle - Connection handle.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_ReadChannelMapCmd( uint16 connHandle );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_ReadRemoteUsedFeaturesCmd API
+ *
+ * @brief This LE API is used to read the remote device's used features.
+ *
+ * Related Events: HCI_CommandStatusEvent,
+ * ReadRemoteUsedFeaturesCompleteEvent
+ *
+ * input parameters
+ *
+ * @param connHandle - Connection handle.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_ReadRemoteUsedFeaturesCmd( uint16 connHandle );
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_EncryptCmd API
+ *
+ * @brief This LE API is used to perform an encryption using AES128.
+ *
+ * Note: Input parameters are ordered MSB..LSB.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param key - Pointer to 16 byte encryption key.
+ * @param plainText - Pointer to 16 byte plaintext data.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_EncryptCmd( uint8 *key,
+ uint8 *plainText );
+
+
+/*******************************************************************************
+ * @fn HCI_LE_RandCmd API
+ *
+ * @brief This LE API is used to generate a random number.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_RandCmd( void );
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_StartEncyptCmd API
+ *
+ * @brief This LE API is used to start encryption in a connection.
+ *
+ * Related Events: HCI_CommandStatusEvent,
+ * EncChangeEvent or
+ * EncKeyRefreshEvent
+ *
+ * input parameters
+ *
+ * @param connHandle - Connection handle.
+ * @param random - Pointer to eight byte Random number.
+ * @param encDiv - Pointer to two byte Encrypted Diversifier.
+ * @param ltk - Pointer to 16 byte Long Term Key.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_StartEncyptCmd( uint16 connHandle,
+ uint8 *random,
+ uint8 *encDiv,
+ uint8 *ltk );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_LtkReqReplyCmd API
+ *
+ * @brief This LE API is used by the Host to send to the Controller a
+ * positive LTK reply.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param connHandle - Connection handle.
+ * @param ltk - Pointer to 16 byte Long Term Key.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_LtkReqReplyCmd( uint16 connHandle,
+ uint8 *ltk );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_LtkReqNegReplyCmd API
+ *
+ * @brief This LE API is used by the Host to send to the Controller a
+ * negative LTK reply.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param connHandle - Connectin handle.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_LtkReqNegReplyCmd( uint16 connHandle );
+
+
+
+/*******************************************************************************
+ * @fn HCI_LE_ReadSupportedStatesCmd API
+ *
+ * @brief This LE API is used to read the Controller's supported states.
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_ReadSupportedStatesCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_LE_ReceiverTestCmd API
+ *
+ * @brief This LE API is used to start the receiver Direct Test Mode test.
+ *
+ * Note: A HCI reset should be issued when done using DTM!
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param rxFreq - Rx RF frequency:
+ * k=0..HCI_DTM_NUMBER_RF_CHANS-1, where: F=2402+(k*2MHz)
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_ReceiverTestCmd( uint8 rxFreq );
+
+
+/*******************************************************************************
+ * @fn HCI_LE_TransmitterTestCmd API
+ *
+ * @brief This LE API is used to start the transmit Direct Test Mode test.
+ *
+ * Note: The BLE device is to transmit at maximum power!
+ *
+ * Note: A HCI reset should be issued when done using DTM!
+ *
+ * input parameters
+ *
+ * @param txFreq - Tx RF frequency:
+ * k=0..HCI_DTM_NUMBER_RF_CHANS-1, where:
+ * F=2402+(k*2MHz)
+ * @param dataLen - Test data length in bytes:
+ * 0..HCI_DIRECT_TEST_MAX_PAYLOAD_LEN
+ * @param payloadType - Type of packet payload, per Direct Test Mode spec:
+ * HCI_DIRECT_TEST_PAYLOAD_PRBS9,
+ * HCI_DIRECT_TEST_PAYLOAD_0x0F,
+ * HCI_DIRECT_TEST_PAYLOAD_0x55,
+ * HCI_DIRECT_TEST_PAYLOAD_PRBS15,
+ * HCI_DIRECT_TEST_PAYLOAD_0xFF,
+ * HCI_DIRECT_TEST_PAYLOAD_0x00,
+ * HCI_DIRECT_TEST_PAYLOAD_0xF0,
+ * HCI_DIRECT_TEST_PAYLOAD_0xAA
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_TransmitterTestCmd( uint8 txFreq,
+ uint8 dataLen,
+ uint8 pktPayload );
+
+
+/*******************************************************************************
+ * @fn HCI_LE_TestEndCmd API
+ *
+ * @brief This LE API is used to end the Direct Test Mode test.
+ *
+ * Note: A HCI reset should be issued when done using DTM!
+ *
+ * Related Events: HCI_CommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_LE_TestEndCmd( void );
+
+/*
+** HCI Vendor Specific Comamnds: Link Layer Extensions
+*/
+
+/*******************************************************************************
+ * @fn HCI_EXT_SetRxGainCmd API
+ *
+ * @brief This HCI Extension API is used to set the receiver gain.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param rxGain - HCI_EXT_RX_GAIN_STD, HCI_EXT_RX_GAIN_HIGH
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_SetRxGainCmd( uint8 rxGain );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_SetTxPowerCmd API
+ *
+ * @brief This HCI Extension API is used to set the transmit power.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param txPower - LL_EXT_TX_POWER_MINUS_23_DBM,
+ * LL_EXT_TX_POWER_MINUS_6_DBM,
+ * LL_EXT_TX_POWER_0_DBM,
+ * LL_EXT_TX_POWER_4_DBM
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_SetTxPowerCmd( uint8 txPower );
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_OnePktPerEvtCmd API
+ *
+ * @brief This HCI Extension API is used to set whether a connection will
+ * be limited to one packet per event.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param control - HCI_EXT_ENABLE_ONE_PKT_PER_EVT,
+ * HCI_EXT_DISABLE_ONE_PKT_PER_EVT
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_OnePktPerEvtCmd( uint8 control );
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_ClkDivOnHaltCmd API
+ *
+ * @brief This HCI Extension API is used to set whether the system clock
+ * will be divided when the MCU is halted.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param control - HCI_EXT_ENABLE_CLK_DIVIDE_ON_HALT,
+ * HCI_EXT_DISABLE_CLK_DIVIDE_ON_HALT
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_ClkDivOnHaltCmd( uint8 control );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_DeclareNvUsageCmd API
+ *
+ * @brief This HCI Extension API is used to indicate to the Controller
+ * whether or not the Host will be using the NV memory during BLE
+ * operations.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param mode - HCI_EXT_NV_IN_USE, HCI_EXT_NV_NOT_IN_USE
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_DeclareNvUsageCmd( uint8 mode );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_DecryptCmd API
+ *
+ * @brief This HCI Extension API is used to decrypt encrypted data using
+ * AES128.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param key - Pointer to 16 byte encryption key.
+ * @param encText - Pointer to 16 byte encrypted data.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_DecryptCmd( uint8 *key,
+ uint8 *encText );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_SetLocalSupportedFeaturesCmd API
+ *
+ * @brief This HCI Extension API is used to write this devie's supported
+ * features.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param localFeatures - Pointer to eight bytes of local features.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_SetLocalSupportedFeaturesCmd( uint8 *localFeatures );
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_SetFastTxResponseTimeCmd API
+ *
+ * @brief This HCI Extension API is used to set whether transmit data is
+ * sent as soon as possible even when slave latency is used.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param control - HCI_EXT_ENABLE_FAST_TX_RESP_TIME,
+ * HCI_EXT_DISABLE_FAST_TX_RESP_TIME
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_SetFastTxResponseTimeCmd( uint8 control );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_SetSlaveLatencyOverrideCmd API
+ *
+ * @brief This HCI Extension API is used to to enable or disable
+ * suspending slave latency.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param control - HCI_EXT_ENABLE_SL_OVERRIDE,
+ * HCI_EXT_DISABLE_SL_OVERRIDE
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_SetSlaveLatencyOverrideCmd( uint8 control );
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_ModemTestTxCmd
+ *
+ * @brief This API is used start a continuous transmitter modem test,
+ * using either a modulated or unmodulated carrier wave tone, at
+ * the frequency that corresponds to the specified RF channel. Use
+ * HCI_EXT_EndModemTest command to end the test.
+ *
+ * Note: A Controller reset will be issued by HCI_EXT_EndModemTest!
+ * Note: The BLE device will transmit at maximum power.
+ * Note: This API can be used to verify this device meets Japan's
+ * TELEC regulations.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param cwMode - HCI_EXT_TX_MODULATED_CARRIER,
+ * HCI_EXT_TX_UNMODULATED_CARRIER
+ * txFreq - Transmit RF channel k=0..39, where BLE F=2402+(k*2MHz).
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_ModemTestTxCmd( uint8 cwMode,
+ uint8 txFreq );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_ModemHopTestTxCmd
+ *
+ * @brief This API is used to start a continuous transmitter direct test
+ * mode test using a modulated carrier wave and transmitting a
+ * 37 byte packet of Pseudo-Random 9-bit data. A packet is
+ * transmitted on a different frequency (linearly stepping through
+ * all RF channels 0..39) every 625us. Use HCI_EXT_EndModemTest
+ * command to end the test.
+ *
+ * Note: A Controller reset will be issued by HCI_EXT_EndModemTest!
+ * Note: The BLE device will transmit at maximum power.
+ * Note: This API can be used to verify this device meets Japan's
+ * TELEC regulations.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_ModemHopTestTxCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_ModemTestRxCmd
+ *
+ * @brief This API is used to start a continuous receiver modem test
+ * using a modulated carrier wave tone, at the frequency that
+ * corresponds to the specific RF channel. Any received data is
+ * discarded. Receiver gain may be adjusted using the
+ * HCI_EXT_SetRxGain command. RSSI may be read during this test
+ * by using the HCI_ReadRssi command. Use HCI_EXT_EndModemTest
+ * command to end the test.
+ *
+ * Note: A Controller reset will be issued by HCI_EXT_EndModemTest!
+ * Note: The BLE device will transmit at maximum power.
+ *
+ * input parameters
+ *
+ * @param rxFreq - Receiver RF channel k=0..39, where BLE F=2402+(k*2MHz).
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_ModemTestRxCmd( uint8 rxFreq );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_EndModemTestCmd
+ *
+ * @brief This API is used to shutdown a modem test. A complete Controller
+ * reset will take place.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_EndModemTestCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_SetBDADDRCmd
+ *
+ * @brief This API is used to set this device's BLE address (BDADDR).
+ *
+ * Note: This command is only allowed when the device's state is
+ * Standby.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param bdAddr - A pointer to a buffer to hold this device's address.
+ * An invalid address (i.e. all FF's) will restore this
+ * device's address to the address set at initialization.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_SetBDADDRCmd( uint8 *bdAddr );
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_SetSCACmd
+ *
+ * @brief This API is used to set this device's Sleep Clock Accuracy.
+ *
+ * Note: For a slave device, this value is directly used, but only
+ * if power management is enabled. For a master device, this
+ * value is converted into one of eight ordinal values
+ * representing a SCA range, as specified in Table 2.2,
+ * Vol. 6, Part B, Section 2.3.3.1 of the Core specification.
+ *
+ * Note: This command is only allowed when the device is not in a
+ * connection.
+ *
+ * Note: The device's SCA value remains unaffected by a HCI_Reset.
+ *
+ * input parameters
+ *
+ * @param scaInPPM - A SCA value in PPM from 0..500.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_SetSCACmd( uint16 scaInPPM );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_EnablePTMCmd
+ *
+ * @brief This HCI Extension API is used to enable Production Test Mode.
+ *
+ * Note: This function can only be directly called from the
+ * application and is not available via an external transport
+ * interface such as RS232. Also, no vendor specific
+ * command complete will be returned.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_EnablePTMCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_SetFreqTuneCmd
+ *
+ * @brief This HCI Extension API is used to set the frequency tuning up
+ * or down. Setting the mode up/down decreases/increases the amount
+ * of capacitance on the external crystal oscillator.
+ *
+ * Note: This is a Production Test Mode only command!
+ *
+ * input parameters
+ *
+ * @param step - HCI_PTM_SET_FREQ_TUNE_UP, HCI_PTM_SET_FREQ_TUNE_DOWN
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_SetFreqTuneCmd( uint8 step );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_SaveFreqTuneCmd
+ *
+ * @brief This HCI Extension API is used to save the frequency tuning
+ * value to flash.
+ *
+ * Note: This is a Production Test Mode only command!
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_SaveFreqTuneCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_SetMaxDtmTxPowerCmd API
+ *
+ * @brief This HCI Extension API is used to set the maximum transmit
+ * output power for Direct Test Mode.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param txPower - LL_EXT_TX_POWER_MINUS_23_DBM,
+ * LL_EXT_TX_POWER_MINUS_6_DBM,
+ * LL_EXT_TX_POWER_0_DBM,
+ * LL_EXT_TX_POWER_4_DBM
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_SetMaxDtmTxPowerCmd( uint8 txPower );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_MapPmIoPortCmd Vendor Specific API
+ *
+ * @brief This HCI Extension API is used to configure and map a CC254x I/O
+ * Port as a General Purpose I/O (GPIO) output signal that reflects
+ * the Power Management (PM) state of the CC254x device. The GPIO
+ * output will be High on Wake, and Low upon entering Sleep. This
+ * feature can be disabled by specifying HCI_EXT_PM_IO_PORT_NONE
+ * for the ioPort (ioPin is then ignored). The system default value
+ * upon hardware reset is disabled. This command can be used to
+ * control an external DC-DC Converter (its actual intent) such has
+ * the TI TPS62730 (or any similar converter that works the same
+ * way). This command should be used with extreme care as it will
+ * override how the Port/Pin was previously configured! This
+ * includes the mapping of Port 0 pins to 32kHz clock output,
+ * Analog I/O, UART, Timers; Port 1 pins to Observables, Digital
+ * Regulator status, UART, Timers; Port 2 pins to an external 32kHz
+ * XOSC. The selected Port/Pin will be configured as an output GPIO
+ * with interrupts masked. Careless use can result in a
+ * reconfiguration that could disrupt the system. It is therefore
+ * the user's responsibility to ensure the selected Port/Pin does
+ * not cause any conflicts in the system.
+ *
+ * Note: Only Pins 0, 3 and 4 are valid for Port 2 since Pins 1
+ * and 2 are mapped to debugger signals DD and DC.
+ *
+ * Note: Port/Pin signal change will only occur when Power Savings
+ * is enabled.
+ *
+ * input parameters
+ *
+ * @param ioPort - HCI_EXT_PM_IO_PORT_P0,
+ * HCI_EXT_PM_IO_PORT_P1,
+ * HCI_EXT_PM_IO_PORT_P2,
+ * HCI_EXT_PM_IO_PORT_NONE
+ *
+ * @param ioPin - HCI_EXT_PM_IO_PORT_PIN0,
+ * HCI_EXT_PM_IO_PORT_PIN1,
+ * HCI_EXT_PM_IO_PORT_PIN2,
+ * HCI_EXT_PM_IO_PORT_PIN3,
+ * HCI_EXT_PM_IO_PORT_PIN4,
+ * HCI_EXT_PM_IO_PORT_PIN5,
+ * HCI_EXT_PM_IO_PORT_PIN6,
+ * HCI_EXT_PM_IO_PORT_PIN7
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern llStatus_t HCI_EXT_MapPmIoPortCmd( uint8 ioPort, uint8 ioPin );
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_DisconnectImmedCmd API
+ *
+ * @brief This HCI Extension API is used to disconnect the connection
+ * immediately.
+ *
+ * Note: The connection (if valid) is immediately terminated
+ * without notifying the remote device. The Host is still
+ * notified.
+ *
+ * input parameters
+ *
+ * @param connHandle - Connection handle.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return HCI_SUCCESS
+ */
+extern hciStatus_t HCI_EXT_DisconnectImmedCmd( uint16 connHandle );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_PacketErrorRate Vendor Specific API
+ *
+ * @brief This function is used to Reset or Read the Packet Error Rate
+ * counters for a connection.
+ *
+ * Note: The counters are only 16 bits. At the shortest connection
+ * interval, this provides a bit over 8 minutes of data.
+ *
+ * input parameters
+ *
+ * @param connHandle - The LL connection ID on which to send this data.
+ * @param command - HCI_EXT_PER_RESET, HCI_EXT_PER_READ
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_INACTIVE_CONNECTION
+ */
+extern hciStatus_t HCI_EXT_PacketErrorRateCmd( uint16 connHandle, uint8 command );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_PERbyChanCmd Vendor Specific API
+ *
+ * @brief This HCI Extension API is used to start or end Packet Error Rate
+ * by Channel counter accumulation for a connection. If the
+ * pointer is not NULL, it is assumed there is sufficient memory
+ * for the PER data, per the type perByChan_t. If NULL, then
+ * the operation is considered disabled.
+ *
+ * Note: It is the user's responsibility to make sure there is
+ * sufficient memory for the data, and that the counters
+ * are cleared prior to first use.
+ *
+ * Note: The counters are only 16 bits. At the shortest connection
+ * interval, this provides a bit over 8 minutes of data.
+ *
+ * input parameters
+ *
+ * @param connHandle - The LL connection ID on which to send this data.
+ * @param perByChan - Pointer to PER by Channel data, or NULL.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, LL_STATUS_ERROR_INACTIVE_CONNECTION
+ */
+extern hciStatus_t HCI_EXT_PERbyChanCmd( uint16 connHandle, perByChan_t *perByChan );
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_ExtendRfRangeCmd API
+ *
+ * @brief This HCI Extension API is used to Extend Rf Range using the TI
+ * CC2590 2.4 GHz RF Front End device.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_ExtendRfRangeCmd( void );
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_HaltDuringRfCmd API
+ *
+ * @brief This HCI Extension API is used to enable or disable halting the
+ * CPU during RF. The system defaults to enabled.
+ *
+ * Related Events: HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * input parameters
+ *
+ * @param mode - HCI_EXT_HALT_DURING_RF_ENABLE,
+ * HCI_EXT_HALT_DURING_RF_DISABLE
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_HaltDuringRfCmd( uint8 mode );
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_AdvEventNoticeCmd Vendor Specific API
+ *
+ * @brief This HCI Extension API is used to enable or disable a
+ * notification to the specified task using the specified task
+ * event whenever a Adv event ends. A non-zero taskEvent value is
+ * taken to be "enable", while a zero valued taskEvent is taken
+ * to be "disable".
+ *
+ * input parameters
+ *
+ * @param taskID - User's task ID.
+ * @param taskEvent - User's task event.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_AdvEventNoticeCmd( uint8 taskID, uint16 taskEvent );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_ConnEventNoticeCmd Vendor Specific API
+ *
+ * @brief This HCI Extension API is used to enable or disable a
+ * notification to the specified task using the specified task
+ * event whenever a Connection event ends. A non-zero taskEvent
+ * value is taken to be "enable", while a zero valued taskEvent
+ * taken to be "disable".
+ *
+ * Note: Currently, only a Slave connection is supported.
+ *
+ * input parameters
+ *
+ * @param taskID - User's task ID.
+ * @param taskEvent - User's task event.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return hciStatus_t
+ */
+extern hciStatus_t HCI_EXT_ConnEventNoticeCmd( uint8 taskID, uint16 taskEvent );
+
+
+
+/*******************************************************************************
+ * @fn HCI_EXT_BuildRevisionCmd Vendor Specific API
+ *
+ * @brief This HCI Extension API is used set a user revision number or
+ * read the build revision number.
+ *
+ * input parameters
+ *
+ * @param mode - HCI_EXT_SET_USER_REVISION | HCI_EXT_READ_BUILD_REVISION
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return LL_STATUS_SUCCESS, HCI_ERROR_CODE_INVALID_HCI_CMD_PARAMS
+ */
+extern hciStatus_t HCI_EXT_BuildRevisionCmd( uint8 mode, uint16 userRevNum );
+
+
+
+
+
+
+#line 53 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\hci\\hci_tl.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_uart.h"
+/**************************************************************************************************
+ Filename: hal_uart.h
+ Revised: $Date: 2012-10-17 09:45:25 -0700 (Wed, 17 Oct 2012) $
+ Revision: $Revision: 31844 $
+
+ Description: This file contains the interface to the UART Service.
+
+
+ Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/***************************************************************************************************
+ * INCLUDES
+ ***************************************************************************************************/
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\include\\hal_board.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+/*******************************************************************************
+ Filename: hal_board_cfg.h
+ Revised: $Date: 2013-02-27 11:32:02 -0800 (Wed, 27 Feb 2013) $
+ Revision: $Revision: 33315 $
+
+ Description:
+
+ Abstract board-specific registers, addresses, & initialization for H/W based on the
+ Texas Instruments CC254x (8051 core).
+
+
+ Copyright 2006-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+ * INCLUDES
+ */
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+/**************************************************************************************************
+ Filename: hal_mcu.h
+ Revised: $Date: 2012-07-13 06:58:11 -0700 (Fri, 13 Jul 2012) $
+ Revision: $Revision: 30922 $
+
+ Description: Describe the purpose and contents of the file.
+
+
+ Copyright 2006-2010 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+/*
+ * Target : Texas Instruments CC2540 (8051 core)
+ *
+ */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Includes
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Target Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ---------------------- IAR Compiler ---------------------- */
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/**************************************************************************************************
+ * - ioCC2540.h -
+ *
+ * Header file with definitions for the Texas Instruments CC2540 low-power System-on-Chip:
+ * an 8051-based MCU with 2.4 GHz Bluetooth low energy RF transceiver, and up to 256 kB FLASH.
+ *
+ * This file supports the IAR Embedded Workbench for 8051.
+ *
+ **************************************************************************************************
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+#pragma language=extended
+#line 41 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 77 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Vectors
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 101 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * SFR Bit Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* USBIE P2IE , not in a bit addressable register */
+
+/* ------------------------------------------------------------------------------------------------
+ * SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * SFRs with an address ending with 0 or 8 are bit accessible.
+ * They are defined with the SFRBIT() macro that sets the name of each bit.
+ */
+
+/* Port 0 */
+__sfr __no_init volatile union { unsigned char P0; struct { unsigned char P0_0 : 1; unsigned char P0_1 : 1; unsigned char P0_2 : 1; unsigned char P0_3 : 1; unsigned char P0_4 : 1; unsigned char P0_5 : 1; unsigned char P0_6 : 1; unsigned char P0_7 : 1; }; } @ 0x80;
+__sfr __no_init volatile unsigned char SP @ 0x81; /* Stack Pointer */
+__sfr __no_init volatile unsigned char DPL0 @ 0x82; /* Data Pointer 0 Low Byte */
+__sfr __no_init volatile unsigned char DPH0 @ 0x83; /* Data Pointer 0 High Byte */
+__sfr __no_init volatile unsigned char DPL1 @ 0x84; /* Data Pointer 1 Low Byte */
+__sfr __no_init volatile unsigned char DPH1 @ 0x85; /* Data Pointer 1 High Byte */
+__sfr __no_init volatile unsigned char U0CSR @ 0x86; /* USART 0 Control and Status */
+__sfr __no_init volatile unsigned char PCON @ 0x87; /* Power Mode Control */
+
+/* Interrupt Flags */
+__sfr __no_init volatile union { unsigned char TCON; struct { unsigned char IT0 : 1; unsigned char RFERRIF : 1; unsigned char IT1 : 1; unsigned char URX0IF : 1; unsigned char _TCON4 : 1; unsigned char ADCIF : 1; unsigned char _TCON6 : 1; unsigned char URX1IF : 1; }; } @ 0x88;
+__sfr __no_init volatile unsigned char P0IFG @ 0x89; /* Port 0 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P1IFG @ 0x8A; /* Port 1 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P2IFG @ 0x8B; /* Port 2 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char PICTL @ 0x8C; /* Port Interrupt Control */
+__sfr __no_init volatile unsigned char P1IEN @ 0x8D; /* Port 1 Interrupt Mask */
+__sfr __no_init volatile unsigned char _SFR8E @ 0x8E; /* not used */
+__sfr __no_init volatile unsigned char P0INP @ 0x8F; /* Port 0 Input Mode */
+
+/* Port 1 */
+__sfr __no_init volatile union { unsigned char P1; struct { unsigned char P1_0 : 1; unsigned char P1_1 : 1; unsigned char P1_2 : 1; unsigned char P1_3 : 1; unsigned char P1_4 : 1; unsigned char P1_5 : 1; unsigned char P1_6 : 1; unsigned char P1_7 : 1; }; } @ 0x90;
+__sfr __no_init volatile unsigned char _SFR91 @ 0x91; /* reserved */
+__sfr __no_init volatile unsigned char DPS @ 0x92; /* Data Pointer Select */
+__sfr __no_init volatile unsigned char MPAGE @ 0x93; /* Memory Page Select */
+__sfr __no_init volatile unsigned char T2CTRL @ 0x94; /* Timer2 Control Register */
+__sfr __no_init volatile unsigned char ST0 @ 0x95; /* Sleep Timer 0 */
+__sfr __no_init volatile unsigned char ST1 @ 0x96; /* Sleep Timer 1 */
+__sfr __no_init volatile unsigned char ST2 @ 0x97; /* Sleep Timer 2 */
+
+/* Interrupt Flags 2 */
+__sfr __no_init volatile union { unsigned char S0CON; struct { unsigned char ENCIF_0 : 1; unsigned char ENCIF_1 : 1; unsigned char _S0CON2 : 1; unsigned char _S0CON3 : 1; unsigned char _S0CON4 : 1; unsigned char _S0CON5 : 1; unsigned char _S0CON6 : 1; unsigned char _S0CON7 : 1; }; } @ 0x98;
+__sfr __no_init volatile unsigned char _SFR99 @ 0x99; /* reserved */
+__sfr __no_init volatile unsigned char IEN2 @ 0x9A; /* Interrupt Enable 2 */
+__sfr __no_init volatile unsigned char S1CON @ 0x9B; /* Interrupt Flags 3 */
+__sfr __no_init volatile unsigned char T2CSPCFG @ 0x9C; /* Timer2 CSP Interface Configuration (legacy name) */
+__sfr __no_init volatile unsigned char T2EVTCFG @ 0x9C; /* Timer2 Event Output Configuration */
+__sfr __no_init volatile unsigned char SLEEPSTA @ 0x9D; /* Sleep Status */
+__sfr __no_init volatile unsigned char CLKCONSTA @ 0x9E; /* Clock Control Status */
+__sfr __no_init volatile unsigned char FMAP @ 0x9F; /* Flash Bank Map */
+
+/* Port 2 */
+__sfr __no_init volatile union { unsigned char P2; struct { unsigned char P2_0 : 1; unsigned char P2_1 : 1; unsigned char P2_2 : 1; unsigned char P2_3 : 1; unsigned char P2_4 : 1; unsigned char _P2_5 : 1; unsigned char _P2_6 : 1; unsigned char _P2_7 : 1; }; } @ 0xA0;
+__sfr __no_init volatile unsigned char T2IRQF @ 0xA1; /* Timer2 Interrupt Flags */
+__sfr __no_init volatile unsigned char T2M0 @ 0xA2; /* Timer2 Multiplexed Register 0 */
+__sfr __no_init volatile unsigned char T2M1 @ 0xA3; /* Timer2 Multiplexed Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF0 @ 0xA4; /* Timer2 Multiplexed Overflow Register 0 */
+__sfr __no_init volatile unsigned char T2MOVF1 @ 0xA5; /* Timer2 Multiplexed Overflow Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF2 @ 0xA6; /* Timer2 Multiplexed Overflow Register 2 */
+__sfr __no_init volatile unsigned char T2IRQM @ 0xA7; /* Timer2 Interrupt Mask */
+
+/* Interrupt Enable 0 */
+__sfr __no_init volatile union { unsigned char IEN0; struct { unsigned char RFERRIE : 1; unsigned char ADCIE : 1; unsigned char URX0IE : 1; unsigned char URX1IE : 1; unsigned char ENCIE : 1; unsigned char STIE : 1; unsigned char _IEN06 : 1; unsigned char EA : 1; }; } @ 0xA8;
+__sfr __no_init volatile unsigned char IP0 @ 0xA9; /* Interrupt Priority 0 */
+__sfr __no_init volatile unsigned char _SFRAA @ 0xAA; /* not used */
+__sfr __no_init volatile unsigned char P0IEN @ 0xAB; /* Port 0 Interrupt Mask */
+__sfr __no_init volatile unsigned char P2IEN @ 0xAC; /* Port 2 Interrupt Mask */
+__sfr __no_init volatile unsigned char STLOAD @ 0xAD; /* Sleep Timer Load Status */
+__sfr __no_init volatile unsigned char PMUX @ 0xAE; /* Power Down Signal MUX */
+__sfr __no_init volatile unsigned char T1STAT @ 0xAF; /* Timer 1 Status */
+
+__sfr __no_init volatile unsigned char _SFRB0 @ 0xB0; /* not used */
+__sfr __no_init volatile unsigned char ENCDI @ 0xB1; /* Encryption/Decryption Input Data */
+__sfr __no_init volatile unsigned char ENCDO @ 0xB2; /* Encryption/Decryption Output Data */
+__sfr __no_init volatile unsigned char ENCCS @ 0xB3; /* Encryption/Decryption Control and Status */
+__sfr __no_init volatile unsigned char ADCCON1 @ 0xB4; /* ADC Control 1 */
+__sfr __no_init volatile unsigned char ADCCON2 @ 0xB5; /* ADC Control 2 */
+__sfr __no_init volatile unsigned char ADCCON3 @ 0xB6; /* ADC Control 3 */
+__sfr __no_init volatile unsigned char _SFRB7 @ 0xB7; /* reserved */
+
+/* Interrupt Enable 1 */
+__sfr __no_init volatile union { unsigned char IEN1; struct { unsigned char DMAIE : 1; unsigned char T1IE : 1; unsigned char T2IE : 1; unsigned char T3IE : 1; unsigned char T4IE : 1; unsigned char P0IE : 1; unsigned char _IEN16 : 1; unsigned char _IEN17 : 1; }; } @ 0xB8;
+__sfr __no_init volatile unsigned char IP1 @ 0xB9; /* Interrupt Priority 1 */
+__sfr __no_init volatile unsigned char ADCL @ 0xBA; /* ADC Data Low */
+__sfr __no_init volatile unsigned char ADCH @ 0xBB; /* ADC Data High */
+__sfr __no_init volatile unsigned char RNDL @ 0xBC; /* Random Number Generator Low Byte */
+__sfr __no_init volatile unsigned char RNDH @ 0xBD; /* Random Number Generator High Byte */
+__sfr __no_init volatile unsigned char SLEEPCMD @ 0xBE; /* Sleep Mode Control Command */
+__sfr __no_init volatile unsigned char _SFRBF @ 0xBF; /* reserved */
+
+/* Interrupt Flags 4 */
+__sfr __no_init volatile union { unsigned char IRCON; struct { unsigned char DMAIF : 1; unsigned char T1IF : 1; unsigned char T2IF : 1; unsigned char T3IF : 1; unsigned char T4IF : 1; unsigned char P0IF : 1; unsigned char _IRCON6 : 1; unsigned char STIF : 1; }; } @ 0xC0;
+__sfr __no_init volatile unsigned char U0DBUF @ 0xC1; /* USART 0 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U0BAUD @ 0xC2; /* USART 0 Baud Rate Control */
+__sfr __no_init volatile unsigned char T2MSEL @ 0xC3; /* Timer2 Multiplex Select */
+__sfr __no_init volatile unsigned char U0UCR @ 0xC4; /* USART 0 UART Control */
+__sfr __no_init volatile unsigned char U0GCR @ 0xC5; /* USART 0 Generic Control */
+__sfr __no_init volatile unsigned char CLKCONCMD @ 0xC6; /* Clock Control Command */
+__sfr __no_init volatile unsigned char MEMCTR @ 0xC7; /* Memory System Control */
+
+__sfr __no_init volatile unsigned char _SFRC8 @ 0xC8; /* not used */
+__sfr __no_init volatile unsigned char WDCTL @ 0xC9; /* Watchdog Timer Control */
+__sfr __no_init volatile unsigned char T3CNT @ 0xCA; /* Timer 3 Counter */
+__sfr __no_init volatile unsigned char T3CTL @ 0xCB; /* Timer 3 Control */
+__sfr __no_init volatile unsigned char T3CCTL0 @ 0xCC; /* Timer 3 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC0 @ 0xCD; /* Timer 3 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T3CCTL1 @ 0xCE; /* Timer 3 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC1 @ 0xCF; /* Timer 3 Channel 1 Capture/Compare Value */
+
+ /* Program Status Word */
+__sfr __no_init volatile union { unsigned char PSW; struct { unsigned char P : 1; unsigned char F1 : 1; unsigned char OV : 1; unsigned char RS0 : 1; unsigned char RS1 : 1; unsigned char F0 : 1; unsigned char AC : 1; unsigned char CY : 1; }; } @ 0xD0;
+__sfr __no_init volatile unsigned char DMAIRQ @ 0xD1; /* DMA Interrupt Flag */
+__sfr __no_init volatile unsigned char DMA1CFGL @ 0xD2; /* DMA Channel 1-4 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA1CFGH @ 0xD3; /* DMA Channel 1-4 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMA0CFGL @ 0xD4; /* DMA Channel 0 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA0CFGH @ 0xD5; /* DMA Channel 0 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMAARM @ 0xD6; /* DMA Channel Arm */
+__sfr __no_init volatile unsigned char DMAREQ @ 0xD7; /* DMA Channel Start Request and Status */
+
+/* Timers 1/3/4 Interrupt Mask/Flag */
+__sfr __no_init volatile union { unsigned char TIMIF; struct { unsigned char T3OVFIF : 1; unsigned char T3CH0IF : 1; unsigned char T3CH1IF : 1; unsigned char T4OVFIF : 1; unsigned char T4CH0IF : 1; unsigned char T4CH1IF : 1; unsigned char T1OVFIM : 1; unsigned char _TIMIF7 : 1; }; } @ 0xD8;
+__sfr __no_init volatile unsigned char _SFRD9 @ 0xD9; /* reserved */
+__sfr __no_init volatile unsigned char T1CC0L @ 0xDA; /* Timer 1 Channel 0 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC0H @ 0xDB; /* Timer 1 Channel 0 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC1L @ 0xDC; /* Timer 1 Channel 1 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC1H @ 0xDD; /* Timer 1 Channel 1 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC2L @ 0xDE; /* Timer 1 Channel 2 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC2H @ 0xDF; /* Timer 1 Channel 2 Capture/Compare Value High Byte */
+
+__sfr __no_init volatile unsigned char ACC @ 0xE0; /* Accumulator */
+__sfr __no_init volatile unsigned char _SFRE1 @ 0xE1; /* reserved */
+__sfr __no_init volatile unsigned char T1CNTL @ 0xE2; /* Timer 1 Counter Low */
+__sfr __no_init volatile unsigned char T1CNTH @ 0xE3; /* Timer 1 Counter High */
+__sfr __no_init volatile unsigned char T1CTL @ 0xE4; /* Timer 1 Control And Status */
+__sfr __no_init volatile unsigned char T1CCTL0 @ 0xE5; /* Timer 1 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL1 @ 0xE6; /* Timer 1 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL2 @ 0xE7; /* Timer 1 Channel 2 Capture/Compare Control */
+
+/* Interrupt Flags 5 */
+__sfr __no_init volatile union { unsigned char IRCON2; struct { unsigned char P2IF : 1; unsigned char UTX0IF : 1; unsigned char UTX1IF : 1; unsigned char P1IF : 1; unsigned char WDTIF : 1; unsigned char _IRCON25 : 1; unsigned char _IRCON26 : 1; unsigned char _IRCON27 : 1; }; } @ 0xE8;
+__sfr __no_init volatile unsigned char _SFRE9 @ 0xE9; /* reserved */
+__sfr __no_init volatile unsigned char T4CNT @ 0xEA; /* Timer 4 Counter */
+__sfr __no_init volatile unsigned char T4CTL @ 0xEB; /* Timer 4 Control */
+__sfr __no_init volatile unsigned char T4CCTL0 @ 0xEC; /* Timer 4 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC0 @ 0xED; /* Timer 4 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T4CCTL1 @ 0xEE; /* Timer 4 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC1 @ 0xEF; /* Timer 4 Channel 1 Capture/Compare Value */
+
+__sfr __no_init volatile unsigned char B @ 0xF0; /* B Register */
+__sfr __no_init volatile unsigned char PERCFG @ 0xF1; /* Peripheral I/O Control */
+__sfr __no_init volatile unsigned char ADCCFG @ 0xF2; /* ADC Input Configuration (legacy name) */
+__sfr __no_init volatile unsigned char APCFG @ 0xF2; /* Analog Periferal I/O Configuration */
+__sfr __no_init volatile unsigned char P0SEL @ 0xF3; /* Port 0 Function Select */
+__sfr __no_init volatile unsigned char P1SEL @ 0xF4; /* Port 1 Function Select */
+__sfr __no_init volatile unsigned char P2SEL @ 0xF5; /* Port 2 Function Select */
+__sfr __no_init volatile unsigned char P1INP @ 0xF6; /* Port 1 Input Mode */
+__sfr __no_init volatile unsigned char P2INP @ 0xF7; /* Port 2 Input Mode */
+
+/* USART 1 Control and Status */
+__sfr __no_init volatile union { unsigned char U1CSR; struct { unsigned char U1ACTIVE : 1; unsigned char U1TX_BYTE : 1; unsigned char U1RX_BYTE : 1; unsigned char U1ERR : 1; unsigned char U1FE : 1; unsigned char U1SLAVE : 1; unsigned char U1RE : 1; unsigned char U1MODE : 1; }; } @ 0xF8;
+__sfr __no_init volatile unsigned char U1DBUF @ 0xF9; /* USART 1 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U1BAUD @ 0xFA; /* USART 1 Baud Rate Control */
+__sfr __no_init volatile unsigned char U1UCR @ 0xFB; /* USART 1 UART Control */
+__sfr __no_init volatile unsigned char U1GCR @ 0xFC; /* USART 1 Generic Control */
+__sfr __no_init volatile unsigned char P0DIR @ 0xFD; /* Port 0 Direction */
+__sfr __no_init volatile unsigned char P1DIR @ 0xFE; /* Port 1 Direction */
+__sfr __no_init volatile unsigned char P2DIR @ 0xFF; /* Port 2 Direction */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Radio Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Radio Control Registers */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata USB Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 329 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Observability Control */
+#line 345 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Identification */
+
+
+
+/* Debug Interface DMA Write to Flash */
+
+
+/* Flash Controller */
+#line 360 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Information */
+
+
+
+/* IR Generation Control */
+
+
+/* Clock Loss Detector */
+
+
+/* Timer 1 Channels (only mapped as XREG) */
+#line 378 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Definition which includes channels represented in SFR (additional XREG mapping of SFR) */
+#line 394 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Pointers for array access */
+
+
+
+/* Sleep Timer Capture Control */
+
+
+
+
+
+
+/* Op.Amp. Control */
+
+
+
+
+/* Analog Comparator Control */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Mapped SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * Most SFRs are also accessible through XDATA address space. The register definitions for
+ * this type of access are listed below. The register names are identical to the SFR names
+ * but with the prefix X_ to denote an XDATA register.
+ *
+ * Some SFRs are not accessible through XDATA space. For clarity, entries are included for these
+ * registers. They have a prefix of _NA to denote "not available."
+ *
+ * For register descriptions, refer to the actual SFR declartions elsewhere in this file.
+ */
+
+#line 437 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 446 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 455 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 465 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 474 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 483 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 492 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 501 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 510 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 519 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 528 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 537 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 546 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 555 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 565 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 574 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Flash
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ */
+
+
+#pragma language=default
+
+
+/**************************************************************************************************
+ */
+#line 76 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+#line 84 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ---------------------- Keil Compiler ---------------------- */
+#line 104 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+typedef unsigned char halIntState_t;
+
+
+
+
+
+ /* IAR library uses XCH instruction with EA. It may cause the higher priority interrupt to be
+ * locked out, therefore, may increase interrupt latency. It may also create a lockup condition.
+ * This workaround should only be used with 8051 using IAR compiler. When IAR fixes this by
+ * removing XCH usage in its library, compile the following macros to null to disable them.
+ */
+#line 131 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Reset Macro
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 142 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* disable interrupts, set watchdog timer, wait for reset */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 rev numbers
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 sleep common code
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* PCON bit definitions */
+
+
+/* SLEEPCMD bit definitions */
+
+
+
+/* SLEEPSTA bit definitions */
+
+
+
+/* SLEEPCMD and SLEEPSTA bit definitions */
+
+
+
+/* CLKCONCMD bit definitions */
+
+
+
+
+
+
+/* STLOAD */
+
+
+
+
+#line 199 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/**************************************************************************************************
+ */
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+
+
+/*******************************************************************************
+ * CONSTANTS
+ */
+
+/* Board Identifier */
+
+
+
+
+
+/* Clock Speed */
+
+
+
+/* Sleep Clock */
+
+
+
+
+// For non-USB, assume external, unless an internal crystal is explicitly indicated.
+
+
+
+
+
+
+// Minimum Time for Stable External 32kHz Clock (in ms)
+
+
+/* LCD Max Chars and Buffer */
+
+
+
+/* LED Configuration */
+
+#line 101 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+
+
+/* 1 - Green */
+
+
+
+
+
+
+ /* 2 - Red */
+
+
+
+
+
+ /* 3 - Yellow */
+
+
+
+
+
+
+/* Push Button Configuration */
+
+
+
+
+/* S1 */
+
+
+
+#line 140 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Joystick Center Press */
+
+
+
+
+/* OSAL NV implemented by internal flash pages. */
+
+// Flash is partitioned into 8 banks of 32 KB or 16 pages.
+
+
+// Flash is constructed of 128 pages of 2 KB.
+
+
+// SNV can use a larger logical page size to accomodate more or bigger items or extend lifetime.
+
+
+
+// CODE banks get mapped into the XDATA range 8000-FFFF.
+
+
+// The last 16 bytes of the last available page are reserved for flash lock bits.
+
+
+// NV page definitions must coincide with segment declaration in project *.xcl file.
+#line 172 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+// Re-defining Z_EXTADDR_LEN here so as not to include a Z-Stack .h file.
+
+
+
+
+
+
+
+
+// Used by DMA macros to shift 1 to create a mask for DMA registers.
+
+
+
+
+
+
+
+/* Critical Vdd Monitoring to prevent flash damage or radio lockup. */
+
+// Vdd/3 / Internal Reference X ENOB --> (Vdd / 3) / 1.15 X 127
+
+
+
+
+
+
+
+/*******************************************************************************
+ * MACROS
+ */
+
+/* Cache Prefetch Control */
+
+
+
+
+/* Setting Clocks */
+
+// switch to the 16MHz HSOSC and wait until it is stable
+
+
+
+
+
+
+// switch to the 32MHz XOSC and wait until it is stable
+
+
+
+
+
+
+// set 32kHz OSC and wait until it is stable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* Board Initialization */
+#line 256 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Debounce */
+
+
+/* ----------- Push Buttons ---------- */
+#line 267 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* LED's */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 315 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* XNV */
+
+
+
+
+
+
+
+// The TI reference design uses UART1 Alt. 2 in SPI mode.
+#line 356 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Driver Configuration */
+
+/* Set to TRUE enable H/W TIMER usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable ADC usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable DMA usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable Flash access, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable AES usage, FALSE disable it */
+
+
+
+
+
+
+
+
+/* Set to TRUE enable LCD usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable LED usage, FALSE disable it */
+#line 400 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Set to TRUE enable KEY usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable UART usage, FALSE disable it */
+#line 414 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+
+ // Always prefer to use DMA over ISR.
+#line 444 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+ // Used to set P2 priority - USART0 over USART1 if both are defined.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+*/
+#line 2 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\include\\hal_board.h"
+#line 52 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_uart.h"
+
+/***************************************************************************************************
+ * MACROS
+ ***************************************************************************************************/
+
+/***************************************************************************************************
+ * CONSTANTS
+ ***************************************************************************************************/
+
+
+/* UART Ports */
+
+/*
+ Serial Port Baudrate Settings
+ Have to match with baudrate table
+*/
+#line 79 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_uart.h"
+
+/* Frame Format constant */
+
+/* Stop Bits */
+
+
+
+/* Parity settings */
+
+
+
+
+/* Character Size */
+
+
+
+/* Flow control */
+
+
+
+/* Ports */
+
+
+
+
+/* UART Status */
+
+
+
+
+
+
+/* UART Events */
+
+
+
+
+
+
+/***************************************************************************************************
+ * TYPEDEFS
+ ***************************************************************************************************/
+
+typedef void (*halUARTCBack_t) (uint8 port, uint8 event);
+
+typedef struct
+{
+ // The head or tail is updated by the Tx or Rx ISR respectively, when not polled.
+ volatile uint16 bufferHead;
+ volatile uint16 bufferTail;
+ uint16 maxBufSize;
+ uint8 *pBuffer;
+} halUARTBufControl_t;
+
+typedef struct
+{
+ bool configured;
+ uint8 baudRate;
+ bool flowControl;
+ uint16 flowControlThreshold;
+ uint8 idleTimeout;
+ halUARTBufControl_t rx;
+ halUARTBufControl_t tx;
+ bool intEnable;
+ uint32 rxChRvdTime;
+ halUARTCBack_t callBackFunc;
+}halUARTCfg_t;
+
+typedef union
+{
+ bool paramCTS;
+ bool paramRTS;
+ bool paramDSR;
+ bool paramDTR;
+ bool paramCD;
+ bool paramRI;
+ uint16 baudRate;
+ bool flowControl;
+ bool flushControl;
+}halUARTIoctl_t;
+
+
+/***************************************************************************************************
+ * GLOBAL VARIABLES
+ ***************************************************************************************************/
+
+
+/***************************************************************************************************
+ * FUNCTIONS - API
+ ***************************************************************************************************/
+/*
+ * Initialize UART at the startup
+ */
+extern void HalUARTInit ( void );
+
+/*
+ * Open a port based on the configuration
+ */
+extern uint8 HalUARTOpen ( uint8 port, halUARTCfg_t *config );
+
+/*
+ * Close a port
+ */
+extern void HalUARTClose ( uint8 port );
+
+/*
+ * Read a buffer from the UART
+ */
+extern uint16 HalUARTRead ( uint8 port, uint8 *pBuffer, uint16 length );
+
+/*
+ * Write a buff to the uart *
+ */
+extern uint16 HalUARTWrite ( uint8 port, uint8 *pBuffer, uint16 length );
+
+/*
+ * Write a buffer to the UART
+ */
+extern uint8 HalUARTIoctl ( uint8 port, uint8 cmd, halUARTIoctl_t *pIoctl );
+
+/*
+ * This to support polling
+ */
+extern void HalUARTPoll( void );
+
+/*
+ * Return the number of bytes in the Rx buffer
+ */
+extern uint16 Hal_UART_RxBufLen ( uint8 port );
+
+/*
+ * Return the number of bytes in the Tx buffer
+ */
+extern uint16 Hal_UART_TxBufLen ( uint8 port );
+
+/*
+ * This enable/disable flow control
+ */
+extern void Hal_UART_FlowControlSet ( uint8 port, bool status );
+
+/*
+ * Initialize hardware for UART
+ */
+extern uint8 HalUART_HW_Init(uint8 port);
+
+/*
+ * Abort UART when entering sleep mode
+ */
+extern void HalUARTSuspend(void);
+
+/*
+ * Resume UART after wakeup from sleep
+ */
+extern void HalUARTResume(void);
+
+/***************************************************************************************************
+***************************************************************************************************/
+
+
+
+
+
+#line 55 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\hci\\hci_tl.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\ble\\hci\\hci_data.h"
+/*******************************************************************************
+ Filename: hci_c_data.h
+ Revised: $Date: 2011-08-22 08:41:40 -0700 (Mon, 22 Aug 2011) $
+ Revision: $Revision: 27235 $
+
+ Description: This file handles HCI data for the BLE Controller.
+
+ Copyright 2009-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+ * INCLUDES
+ */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal_bufmgr.h"
+/**************************************************************************************************
+ Filename: osal_bufmgr.h
+ Revised: $Date: 2009-01-14 14:59:55 -0800 (Wed, 14 Jan 2009) $
+ Revision: $Revision: 18763 $
+
+ Description: This file contains the buffer management definitions.
+
+
+ Copyright 2008 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Allocate a block of memory.
+ */
+extern void *osal_bm_alloc( uint16 size );
+
+/*
+ * Add or remove header space for the payload pointer.
+ */
+extern void *osal_bm_adjust_header( void *payload_ptr, int16 size );
+
+/*
+ * Add or remove tail space for the payload pointer.
+ */
+extern void *osal_bm_adjust_tail( void *payload_ptr, int16 size );
+
+/*
+ * Free a block of memory.
+ */
+extern void osal_bm_free( void *payload_ptr );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 51 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\ble\\hci\\hci_data.h"
+
+/*******************************************************************************
+ * MACROS
+ */
+
+
+
+/*******************************************************************************
+ * CONSTANTS
+ */
+
+
+
+// Data State
+
+
+
+
+/*******************************************************************************
+ * TYPEDEFS
+ */
+
+typedef struct
+{
+ uint8 state; // DATA_BUF_FREE, DATA_BUF_IN_USE, DATA_BUF_PENDING
+ uint16 connHandle; // Connection Handle
+ uint8 fragFlag; // Packet Boundary Flag
+ uint16 len; // Data Length
+ uint8 *pData; // Pointer to Packet Payload
+} hciTxData_t;
+
+/*******************************************************************************
+ * LOCAL VARIABLES
+ */
+
+/*******************************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*
+** HCI Data API
+*/
+
+/*******************************************************************************
+ * This function will initialize the buffers for transmit data.
+ *
+ * input parameters
+ *
+ * @param None.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_TxDataBufferInit( void );
+
+
+
+/*******************************************************************************
+ * @fn HCI_TxDataBufferInsert
+ *
+ * @brief This function will insert a transmit data packet into the free
+ * buffers.
+ *
+ * input parameters
+ *
+ * @param connHandle - Connection handle.
+ * @param pbFlag - Packet Boundary Flag.
+ * @param pktLen - Number of bytes of data to transmit.
+ * @param *pData - Pointer to data buffer to transmit.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return HCI_SUCCESS, HCI_ERROR_CODE_MEM_CAP_EXCEEDED
+ */
+extern hciStatus_t HCI_TxDataBufferInsert( uint16 connHandle,
+ uint8 pbFlag,
+ uint16 pktLen,
+ uint8 *pData );
+
+
+
+
+/*******************************************************************************
+ * @fn HCI_TxDataSend
+ *
+ * @brief This function sends an ACL transmit data packet to the LL. If
+ * the packet is successfully transferred to the TX FIFO by the
+ * LL, then the buffer can be freed. Otherwise, the packet is
+ * still pending in the LL, so it can't be released. If any error
+ * occurs (due to parametric checks), then the buffer is freed
+ * and a Number of Completed Packets event is generated with the
+ * number of completed packets set to zero.
+ *
+ * input parameters
+ *
+ * @param connHandle - Connection handle, or HCI_TX_DATA_ANY_CONNECTION.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_TxDataSend( uint8 connHandle );
+
+
+
+/*******************************************************************************
+ * @fn HCI_ReverseBytes
+ *
+ * @brief This function is used to reverse the order of the bytes in
+ * an array in place.
+ *
+ * input parameters
+ *
+ * @param *buf - Pointer to buffer containing bytes to be reversed.
+ * @param len - Number of bytes in buffer.
+ *
+ * Note: The length must be even.
+ *
+ * Note: The maximum length is 128 bytes.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_ReverseBytes( uint8 *buf,
+ uint8 len );
+
+
+
+
+
+
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\hci\\hci_tl.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\ble\\hci\\hci_event.h"
+/*******************************************************************************
+ Filename: hci_c_event.h
+ Revised: $Date: 2012-05-01 12:13:50 -0700 (Tue, 01 May 2012) $
+ Revision: $Revision: 30418 $
+
+ Description: This file contains the HCI Event types, contants,
+ external functions etc. for the BLE Controller.
+
+ Copyright 2009-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+ * INCLUDES
+ */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\ble\\hci\\hci_tl.h"
+/*******************************************************************************
+ Filename: hci_tl.h
+ Revised: $Date: 2012-04-20 15:24:45 -0700 (Fri, 20 Apr 2012) $
+ Revision: $Revision: 30292 $
+
+ Description: This file contains the types, contants, external functions
+ etc. for the BLE HCI Transport Layer.
+
+ Copyright 2009-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*******************************************************************************/
+
+#line 52 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\ble\\hci\\hci_event.h"
+
+extern uint8 bleEvtMask;
+extern uint8 pHciEvtMask[];
+
+/*******************************************************************************
+ * MACROS
+ */
+
+/*******************************************************************************
+ * CONSTANTS
+ */
+
+// Event Mask Default Values
+#line 73 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\ble\\hci\\hci_event.h"
+//
+
+
+/*******************************************************************************
+ * TYPEDEFS
+ */
+
+/*******************************************************************************
+ * LOCAL VARIABLES
+ */
+
+/*******************************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*
+** Internal Functions
+*/
+
+extern void hciInitEventMasks( void );
+
+/*
+** HCI Controller Events
+*/
+
+/*******************************************************************************
+ * @fn HCI_DataBufferOverflowEvent
+ *
+ * @brief This function sends the Data Buffer Overflow Event to the Host.
+ *
+ * input parameters
+ *
+ * @param linkType - HCI_LINK_TYPE_SCO_BUFFER_OVERFLOW,
+ * HCI_LINK_TYPE_ACL_BUFFER_OVERFLOW
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_DataBufferOverflowEvent( uint8 linkType );
+
+
+/*******************************************************************************
+ * @fn HCI_NumOfCompletedPacketsEvent
+ *
+ * @brief This function sends the Number of Completed Packets Event to
+ * the Host.
+ *
+ * Note: Currently, the number of handles is always one.
+ *
+ * input parameters
+ *
+ * @param numHandles - Number of handles.
+ * @param handlers - Array of connection handles.
+ * @param numCompletedPkts - Array of number of completed packets for
+ * each handle.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_NumOfCompletedPacketsEvent( uint8 numHandles,
+ uint16 *handlers,
+ uint16 *numCompletedPackets );
+
+
+/*******************************************************************************
+ * @fn HCI_CommandCompleteEvent
+ *
+ * @brief This function sends a Command Complete Event to the Host.
+ *
+ * input parameters
+ *
+ * @param opcode - The opcode of the command that generated this event.
+ * @param numParam - The number of parameters in the event.
+ * @param param - The event parameters associated with the command.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_CommandCompleteEvent( uint16 opcode,
+ uint8 numParam,
+ uint8 *param );
+
+
+/*******************************************************************************
+ * @fn HCI_VendorSpecifcCommandCompleteEvent
+ *
+ * @brief This function sends a Vendor Specific Command Complete Event to
+ * the Host.
+ *
+ * input parameters
+ *
+ * @param opcode - The opcode of the command that generated this event.
+ * @param numParam - The number of parameters in the event.
+ * @param param - The event parameters associated with the command.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_VendorSpecifcCommandCompleteEvent( uint16 opcode,
+ uint8 len,
+ uint8 *param );
+
+
+/*******************************************************************************
+ * @fn HCI_CommandStatusEvent
+ *
+ * @brief This function sends a Command Status Event to the Host.
+ *
+ * input parameters
+ *
+ * @param status - The resulting status of the comamnd.
+ * @param opcode - The opcode of the command that generated this event.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_CommandStatusEvent( uint8 status,
+ uint16 opcode );
+
+
+/*******************************************************************************
+ * @fn HCI_HardwareErrorEvent
+ *
+ * @brief This function sends a Hardware Error Event to the Host.
+ *
+ * input parameters
+ *
+ * @param hwErrorCode - The hardware error code.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_HardwareErrorEvent( uint8 hwErrorCode );
+
+
+/*******************************************************************************
+ * @fn HCI_SendCommandStatusEvent
+ *
+ * @brief This generic function sends a Command Status event to the Host.
+ * It is provided as a direct call so the Host can use it directly.
+ *
+ * input parameters
+ *
+ * @param eventCode - The event code.
+ * @param status - The resulting status of the comamnd.
+ * @param opcode - The opcode of the command that generated this event.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_SendCommandStatusEvent ( uint8 eventCode,
+ uint16 status,
+ uint16 opcode );
+
+
+/*******************************************************************************
+ * @fn HCI_SendCommandCompleteEvent
+ *
+ * @brief This generic function sends a Command Complete or a Vendor
+ * Specific Command Complete Event to the Host.
+ *
+ * input parameters
+ *
+ * @param eventCode - The event code.
+ * @param opcode - The opcode of the command that generated this event.
+ * @param numParam - The number of parameters in the event.
+ * @param param - The event parameters associated with the command.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_SendCommandCompleteEvent ( uint8 eventCode,
+ uint16 opcode,
+ uint8 numParam,
+ uint8 *param );
+
+
+/*******************************************************************************
+ * @fn HCI_SendControllerToHostEvent
+ *
+ * @brief This generic function sends a Controller to Host Event.
+ *
+ * input parameters
+ *
+ * @param eventCode - Bluetooth event code.
+ * @param dataLen - Length of dataField.
+ * @param pData - Pointer to data.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_SendControllerToHostEvent( uint8 eventCode,
+ uint8 dataLen,
+ uint8 *pData );
+
+
+
+
+
+#line 57 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\hci\\hci_tl.h"
+
+extern uint8 hciTaskID;
+//
+extern uint8 hciTestTaskID;
+extern uint8 hciGapTaskID;
+extern uint8 hciL2capTaskID;
+extern uint8 hciSmpTaskID;
+
+/*******************************************************************************
+ * MACROS
+ */
+
+
+
+/*******************************************************************************
+ * CONSTANTS
+ */
+
+// OSAL Task Events
+
+
+
+
+
+// OSAL Message Header Events
+
+
+
+
+
+
+// Max Buffers Supported
+
+
+
+// Max Allowed HCI Packet
+
+
+
+// Max Data Length in Packet
+
+
+//
+// Minimum length for CMD packet is 1+2+1
+// | Packet Type (1) | OPCode(2) | Length(1) |
+//
+
+
+//
+// Minimum length for EVENT packet is 1+1+1
+// | Packet Type (1) | Event Code(1) | Length(1) |
+//
+
+
+//
+// Minimum length for DATA packet is 1+2+2
+// | Packet Type (1) | Handler(2) | Length(2) |
+//
+
+
+// Max Number of Connections
+
+//
+
+
+// HCI Packet Types
+
+
+
+
+
+/*
+** HCI Command Opcodes
+*/
+
+// Link Control Commands
+
+
+
+// Controller and Baseband Commands
+#line 143 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\hci\\hci_tl.h"
+
+// Information Parameters
+
+
+
+
+
+// Status Parameters
+
+
+// LE Commands
+#line 184 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\hci\\hci_tl.h"
+
+// LE Vendor Specific LL Extension Commands
+#line 214 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\hci\\hci_tl.h"
+
+/*
+** HCI Event Codes
+*/
+
+// BT Events
+#line 229 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\hci\\hci_tl.h"
+
+// LE Event Code (for LE Meta Events)
+
+
+// LE Meta Event Codes
+
+
+
+
+
+
+// Vendor Specific Event Code
+
+
+// LE Vendor Specific LL Extension Events
+#line 272 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\hci\\hci_tl.h"
+
+/*******************************************************************************
+ * TYPEDEFS
+ */
+
+/*******************************************************************************
+ * LOCAL VARIABLES
+ */
+
+/*******************************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*
+** HCI OSAL API
+*/
+
+/*******************************************************************************
+ * @fn HCI_Init
+ *
+ * @brief This is the HCI OSAL task initialization routine.
+ *
+ * input parameters
+ *
+ * @param taskID - The HCI OSAL task identifer.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return None.
+ */
+extern void HCI_Init( uint8 taskID );
+
+
+/*******************************************************************************
+ * @fn HCI_ProcessEvent
+ *
+ * @brief This is the HCI OSAL task process event handler.
+ *
+ * input parameters
+ *
+ * @param taskID - The HCI OSAL task identifer.
+ * @param events - HCI OSAL task events.
+ *
+ * output parameters
+ *
+ * @param None.
+ *
+ * @return Unprocessed events.
+ */
+extern uint16 HCI_ProcessEvent( uint8 task_id,
+ uint16 events );
+
+
+
+
+
+
+#line 23 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal_cbTimer.h"
+/**************************************************************************************************
+ Filename: osal_cbtimer.h
+ Revised: $Date: 2009-01-29 09:58:32 -0800 (Thu, 29 Jan 2009) $
+ Revision: $Revision: 18882 $
+
+ Description: This file contains the Callback Timer definitions.
+
+
+ Copyright 2008-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+// Invalid timer id
+
+
+// Timed out timer
+
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+#line 77 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal_cbTimer.h"
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Callback Timer function prototype. Callback function will be called
+// when the associated timer expires.
+//
+// pData - pointer to data registered with timer
+//
+typedef void (*pfnCbTimer_t)( uint8 *pData );
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Callback Timer task initialization function.
+ */
+extern void osal_CbTimerInit( uint8 taskId );
+
+/*
+ * Callback Timer task event processing function.
+ */
+extern uint16 osal_CbTimerProcessEvent( uint8 taskId, uint16 events );
+
+/*
+ * Function to start a timer to expire in n mSecs.
+ */
+extern Status_t osal_CbTimerStart( pfnCbTimer_t pfnCbTimer, uint8 *pData,
+ uint16 timeout, uint8 *pTimerId );
+
+/*
+ * Function to update a timer that has already been started.
+ */
+extern Status_t osal_CbTimerUpdate( uint8 timerId, uint16 timeout );
+
+/*
+ * Function to stop a timer that has already been started.
+ */
+extern Status_t osal_CbTimerStop( uint8 timerId );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 26 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+
+
+/* L2CAP */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\l2cap.h"
+/**************************************************************************************************
+ Filename: l2cap.h
+ Revised: $Date: 2012-01-04 14:47:09 -0800 (Wed, 04 Jan 2012) $
+ Revision: $Revision: 28826 $
+
+ Description: This file contains the L2CAP definitions.
+
+
+ Copyright 2009-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Minimum supported information payload for the Basic information frame (B-frame)
+
+
+// Minimum supported information payload for the Control frame (C-frame)
+
+
+// Basic L2CAP header: Length (2 bytes) + Channel ID (2 bytes)
+
+
+// Minimum size of PDU received from lower layer protocol (incoming
+// packet), or delivered to lower layer protocol (outgoing packet).
+
+
+// L2CAP Channel Identifiers. Identifiers from 0x0001 to 0x003F are
+// reserved for specific L2CAP functions. Identifiers 0x0001-0x0003
+// are reserved by BR/EDR.
+
+
+
+
+
+
+// L2CAP Dynamic Channel Identifiers
+
+
+
+// Number of Fixed channels: one for each of ATT, Signaling, SMP channels and one Generic Channel
+
+
+// Number of Protocols supported -- for future use
+
+
+// Number of Auxiliary channels: one for each of Echo Request, Information
+// Request and Connection Parameter Update Request
+
+
+// Number of Dynamic channels: one per each protocol supported on each physical connection
+
+
+// Total number of L2CAP channels: Dynamic channels plus Auxiliary channels
+
+
+// L2CAP Response Timeout expired (RTX) value for Signaling commands (in seconds).
+// The RTX timer is used for response timeout or to terminate a dynamic channel
+// when the remote device is unresponsive to signaling requests. Its value may
+// range from 1 to 60 seconds.
+
+
+// L2CAP Signaling Codes (type of commands)
+#line 114 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\l2cap.h"
+
+/*********************************************************************
+ * Command Reject: Reason Codes
+ */
+ // Command not understood
+
+
+ // Signaling MTU exceeded
+
+
+ // Invalid CID in request
+
+
+/*********************************************************************
+ * Information Request/Response: Info Type
+ */
+ // Connectionless MTU
+
+
+ // Extended features supported
+
+
+ // Fixed channels supported
+
+
+/*********************************************************************
+ * Information Response: Extended Features Mask Values
+ */
+ // Fixed channels are supported
+
+
+ // Length of Extended Features bit mask
+
+
+/*********************************************************************
+ * Information Response: Fixed Channels Mask Values
+ */
+ // Fixed Channel ATT is supported
+
+
+ // Fixed Channel L2CAP Signaling is supported
+
+
+ // Fixed Channel SMP is supported
+
+
+ // Length of Fixed Channels bit mask
+
+
+/*********************************************************************
+ * Information Response: Result Values
+ */
+ // Success
+
+
+ // Not supported
+
+
+/*********************************************************************
+ * Connection Parameter Update Response: Result values
+ */
+ // Connection Parameters accepted
+
+
+ // Connection Parameters rejected
+
+
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Invalid CID in Request format
+typedef struct
+{
+ uint16 localCID; // Destination CID from the rejected command
+ uint16 remoteCID; // Source CID from the rejected command
+} l2capInvalidCID_t;
+
+// Command Reject Reason Data format
+typedef union
+{
+ uint16 signalMTU; // Maximum Signaling MTU
+ l2capInvalidCID_t invalidCID; // Invalid CID in Request
+} l2capReasonData_t;
+
+// Command Reject format
+typedef struct
+{
+ uint16 reason; // Reason
+ l2capReasonData_t reasonData; // Reason Data
+
+ // Shorthand access for union members
+
+
+
+} l2capCmdReject_t;
+
+// Echo Request format
+typedef struct
+{
+ uint8 *pData; // Optional data field
+ uint16 len; // Length of data
+} l2capEchoReq_t;
+
+// Echo Response format
+typedef struct
+{
+ uint8 *pData; // Optional data field -- must be freed by the application
+ uint16 len; // Length of data
+} l2capEchoRsp_t;
+
+// Information Request format
+typedef struct
+{
+ uint16 infoType; // Information type
+} l2capInfoReq_t;
+
+// Information Response Data field
+typedef union
+{
+ uint16 connectionlessMTU; // Connectionless MTU
+ uint32 extendedFeatures; // Extended features supported
+ uint8 fixedChannels[8]; // Fixed channels supported
+} l2capInfo_t;
+
+// Information Response format
+typedef struct
+{
+ uint16 result; // Result
+ uint16 infoType; // Information type
+ l2capInfo_t info; // Content of Info field depends on infoType
+} l2capInfoRsp_t;
+
+// Connection Parameter Update Request format
+typedef struct
+{
+ uint16 intervalMin; // Minimum Interval
+ uint16 intervalMax; // Maximum Interval
+ uint16 slaveLatency; // Slave Latency
+ uint16 timeoutMultiplier; // Timeout Multiplier
+} l2capParamUpdateReq_t;
+
+// Connection Parameter Update Response format
+typedef struct
+{
+ uint16 result; // Result
+} l2capParamUpdateRsp_t;
+
+// Union of all L2CAP Signaling commands
+typedef union
+{
+ // Requests
+ l2capEchoReq_t echoReq;
+ l2capInfoReq_t infoReq;
+ l2capParamUpdateReq_t updateReq;
+
+ // Responses
+ l2capCmdReject_t cmdReject;
+ l2capEchoRsp_t echoRsp;
+ l2capInfoRsp_t infoRsp;
+ l2capParamUpdateRsp_t updateRsp;
+} l2capSignalCmd_t;
+
+// OSAL L2CAP_SIGNAL_EVENT message format. This message is used to deliver an
+// incoming Signaling command up to an upper layer application.
+typedef struct
+{
+ osal_event_hdr_t hdr; // L2CAP_SIGNAL_EVENT and status
+ uint16 connHandle; // connection message was received on
+ uint8 id; // identifier to match responses with requests
+ uint8 opcode; // type of command
+ l2capSignalCmd_t cmd; // command data
+} l2capSignalEvent_t;
+
+// L2CAP packet structure
+typedef struct
+{
+ uint16 CID; // local channel id
+ uint8 *pPayload; // pointer to information payload. This contains the payload
+ // received from the upper layer protocol (outgoing packet),
+ // or delivered to the upper layer protocol (incoming packet).
+ uint16 len; // length of information payload
+} l2capPacket_t;
+
+// OSAL L2CAP_DATA_EVENT message format. This message is used to forward an
+// incoming data packet up to an upper layer application.
+typedef struct
+{
+ osal_event_hdr_t hdr; // L2CAP_DATA_EVENT and status
+ uint16 connHandle; // connection packet was received on
+ l2capPacket_t pkt; // received packet
+} l2capDataEvent_t;
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Initialize L2CAP layer.
+ */
+extern void L2CAP_Init( uint8 taskId );
+
+/*
+ * L2CAP Task event processing function.
+ */
+extern uint16 L2CAP_ProcessEvent( uint8 taskId, uint16 events );
+
+/*
+ * Register a protocol/application with an L2CAP channel.
+ */
+extern bStatus_t L2CAP_RegisterApp( uint8 taskId, uint16 CID );
+
+/*
+ * Send L2CAP Data Packet.
+ */
+extern bStatus_t L2CAP_SendData( uint16 connHandle, l2capPacket_t *pPkt );
+
+/*
+ * Send Command Reject.
+ */
+extern bStatus_t L2CAP_CmdReject( uint16 connHandle, uint8 id, l2capCmdReject_t *pCmdReject );
+
+/*
+ * Build Command Reject.
+ */
+extern uint16 L2CAP_BuildCmdReject( uint8 *pBuf, uint8 *pCmd );
+
+/*
+ * Send L2CAP Echo Request.
+ */
+extern bStatus_t L2CAP_EchoReq( uint16 connHandle, l2capEchoReq_t *pEchoReq, uint8 taskId );
+
+/*
+ * Send L2CAP Information Request.
+ */
+extern bStatus_t L2CAP_InfoReq( uint16 connHandle, l2capInfoReq_t *pInfoReq, uint8 taskId );
+
+/*
+ * Build Information Response.
+ */
+extern uint16 L2CAP_BuildInfoRsp( uint8 *pBuf, uint8 *pCmd );
+
+/*
+ * Parse Information Request.
+ */
+extern bStatus_t L2CAP_ParseInfoReq( l2capSignalCmd_t *pCmd, uint8 *pData, uint16 len );
+
+/*
+ * Send L2CAP Connection Parameter Update Request.
+ */
+extern bStatus_t L2CAP_ConnParamUpdateReq( uint16 connHandle, l2capParamUpdateReq_t *pUpdateReq, uint8 taskId );
+
+/*
+ * Parse Connection Parameter Update Request.
+ */
+extern bStatus_t L2CAP_ParseParamUpdateReq( l2capSignalCmd_t *pCmd, uint8 *pData, uint16 len );
+
+/*
+ * Send L2CAP Connection Parameter Update Response.
+ */
+extern bStatus_t L2CAP_ConnParamUpdateRsp( uint16 connHandle, uint8 id, l2capParamUpdateRsp_t *pUpdateRsp );
+
+/*
+ * Build Connection Parameter Update Response.
+ */
+extern uint16 L2CAP_BuildParamUpdateRsp( uint8 *pBuf, uint8 *pData );
+
+/*
+ * Allocate a block of memory at the L2CAP layer.
+ */
+extern void *L2CAP_bm_alloc( uint16 size );
+
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 30 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+
+/* gap */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gap.h"
+/**
+ @headerfile: gap.h
+ $Date: 2013-05-01 13:58:23 -0700 (Wed, 01 May 2013) $
+ $Revision: 34101 $
+
+ @mainpage BLE GAP API
+
+ This file contains the interface to the GAP.
+
+ \image html HighLevelGAP.PNG
+
+ \htmlinclude GAPDesc.html
+
+ \image html CentralDeviceDiscoveryProcess.PNG
+
+ A central device can scan for advertising peripheral and broadcaster devices. The Observer process
+ is similar to the central process except that will not receive the SCAN_RSP data.
+
+ The central device will initialize the device, then ask for a device discovery. The GAP will
+ setup the link layer to scan and it will filter incoming advertisements and SCAN_RSPs
+ based on the type of device discovery parameters passed in when GAP_DeviceDiscoveryRequest() was called.
+ Then, when the scan is complete, it will return an array of devices that pass through its filter.
+
+
+ \image html CentralLinkEstablishmentProcess.PNG
+
+ After the Device Discovery Process, the central device can establish a connection with a peripheral
+ device by calling GAP_EstablishLinkRequest(). When the link has been established the GAP will send
+ back the @ref GAP_LINK_ESTABLISHED_EVENT [GAP_LinkEstablished].
+
+
+ \image html CentralPairingProcess.PNG
+
+ After a link is established, the central device can initiate a pairing process to either encrypt the
+ link or exchange keys for bonding.
+
+
+ Copyright 2009 - 2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*/
+
+
+
+
+
+
+
+
+
+
+/*-------------------------------------------------------------------
+ * INCLUDES
+ */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\ble\\include\\sm.h"
+/**
+ @headerfile: sm.h
+ $Date: 2012-10-29 13:32:07 -0700 (Mon, 29 Oct 2012) $
+ $Revision: 31951 $
+
+ @mainpage BLE SM API
+
+ This file contains the interface to the SM.
+
+
+ Copyright 2009 - 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*/
+
+
+
+
+
+
+
+
+
+/*-------------------------------------------------------------------
+ * INCLUDES
+ */
+
+
+
+/*-------------------------------------------------------------------
+ * MACROS
+ */
+
+/*-------------------------------------------------------------------
+ * CONSTANTS
+ */
+/** @defgroup SM_IO_CAP_DEFINES SM I/O Capabilities
+ * @{
+ */
+
+
+
+
+
+/** @} End SM_IO_CAP_DEFINES */
+
+
+
+/** @defgroup SM_PASSKEY_TYPE_DEFINES SM Passkey Types (Bit Masks)
+ * @{
+ */
+
+
+/** @} End SM_PASSKEY_TYPE_DEFINES */
+
+/** @defgroup SM_BONDING_FLAGS_DEFINES SM AuthReq Bonding Flags
+ * Bonding flags 0x02 and 0x03 are reserved.
+ * @{
+ */
+
+
+/** @} End SM_BONDING_FLAGS_DEFINES */
+
+
+
+
+
+
+/*-------------------------------------------------------------------
+ * General TYPEDEFS
+ */
+
+/**
+ * SM_NEW_RAND_KEY_EVENT message format. This message is sent to the
+ * requesting task.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< SM_NEW_RAND_KEY_EVENT and status
+ uint8 newKey[16]; //!< New key value - if status is SUCCESS
+} smNewRandKeyEvent_t;
+
+/**
+ * Key Distribution field - True or False fields
+ */
+typedef struct
+{
+ unsigned int sEncKey:1; //!< Set to distribute slave encryption key
+ unsigned int sIdKey:1; //!< Set to distribute slave identity key
+ unsigned int sSign:1; //!< Set to distribute slave signing key
+ unsigned int mEncKey:1; //!< Set to distribute master encryption key
+ unsigned int mIdKey:1; //!< Set to distribute master identity key
+ unsigned int mSign:1; //!< Set to distribute master signing key
+ unsigned int reserved:2; //!< Reserved - not to be used
+} keyDist_t;
+
+/**
+ * Link Security Requirements
+ */
+typedef struct
+{
+ uint8 ioCaps; //!< I/O Capabilities (ie.
+ uint8 oobAvailable; //!< True if Out-of-band key available
+ uint8 oob[16]; //!< Out-Of-Bounds key
+ uint8 authReq; //!< Authentication Requirements
+ keyDist_t keyDist; //!< Key Distribution mask
+ uint8 maxEncKeySize; //!< Maximum Encryption Key size (7-16 bytes)
+} smLinkSecurityReq_t;
+
+/**
+ * Link Security Information
+ */
+typedef struct
+{
+ uint8 ltk[16]; //!< Long Term Key (LTK)
+ uint16 div; //!< LTK Diversifier
+ uint8 rand[8]; //!< LTK random number
+ uint8 keySize; //!< LTK Key Size (7-16 bytes)
+} smSecurityInfo_t;
+
+/**
+ * Link Identity Information
+ */
+typedef struct
+{
+ uint8 irk[16]; //!< Identity Resolving Key (IRK)
+ uint8 bd_addr[6]; //!< The advertiser may set this to zeroes to not disclose its BD_ADDR (public address).
+} smIdentityInfo_t;
+
+/**
+ * Signing Information
+ */
+typedef struct
+{
+ uint8 srk[16]; //!< Signature Resolving Key (CSRK)
+ uint32 signCounter; //!< Sign Counter
+} smSigningInfo_t;
+
+/**
+ * Pairing Request & Response - authReq field
+ */
+typedef struct
+{
+ unsigned int bonding:2; //!< Bonding flags
+ unsigned int mitm:1; //!< Man-In-The-Middle (MITM)
+ unsigned int reserved:5; //!< Reserved - don't use
+} authReq_t;
+
+/*-------------------------------------------------------------------
+ * GLOBAL VARIABLES
+ */
+
+/**
+ * @defgroup SM_API Security Manager API Functions
+ *
+ * @{
+ */
+
+/*-------------------------------------------------------------------
+ * FUNCTIONS - MASTER API - Only use these in a master device
+ */
+
+/**
+ * @brief Initialize SM Initiator on a master device.
+ *
+ * @return SUCCESS
+ */
+extern bStatus_t SM_InitiatorInit( void );
+
+/**
+ * @brief Start the pairing process. This function is also
+ * called if the device is already bound.
+ *
+ * NOTE: Only one pairing process at a time per device.
+ *
+ * @param initiator - TRUE to start pairing as Initiator.
+ * @param taskID - task ID to send results.
+ * @param connectionHandle - Link's connection handle
+ * @param pSecReqs - Security parameters for pairing
+ *
+ * @return SUCCESS,
+ * INVALIDPARAMETER,
+ * bleAlreadyInRequestedMode
+ */
+extern bStatus_t SM_StartPairing( uint8 initiator,
+ uint8 taskID,
+ uint16 connectionHandle,
+ smLinkSecurityReq_t *pSecReqs );
+
+/**
+ * @brief Send Start Encrypt through HCI
+ *
+ * @param connHandle - Connection Handle
+ * @param pLTK - pointer to 16 byte lkt
+ * @param div - div or ediv
+ * @param pRandNum - pointer to 8 byte random number
+ * @param keyLen - length of LTK (bytes)
+ *
+ * @return SUCCESS,
+ * INVALIDPARAMETER,
+ * other from HCI/LL
+ */
+extern bStatus_t SM_StartEncryption( uint16 connHandle, uint8 *pLTK,
+ uint16 div, uint8 *pRandNum, uint8 keyLen );
+
+
+/*-------------------------------------------------------------------
+ * FUNCTIONS - SLAVE API - Only use these in a slave device
+ */
+
+/**
+ * @brief Initialize SM Responder on a slave device.
+ *
+ * @return SUCCESS
+ */
+extern bStatus_t SM_ResponderInit( void );
+
+/*-------------------------------------------------------------------
+ * FUNCTIONS - GENERAL API - both master and slave
+ */
+
+/**
+ * @brief Generate a key with a random value.
+ *
+ * @param taskID - task ID to send results.
+ *
+ * @return SUCCESS,
+ * bleNotReady,
+ * bleMemAllocError,
+ * FAILURE
+ */
+extern bStatus_t SM_NewRandKey( uint8 taskID );
+
+/**
+ * @brief Calculate a new Private Resolvable address.
+ *
+ * @param pIRK - Identity Root Key.
+ * @param pNewAddr - pointer to place to put new calc'd address
+ *
+ * @return SUCCESS - if started,
+ * INVALIDPARAMETER
+ */
+extern bStatus_t SM_CalcRandomAddr( uint8 *pIRK, uint8 *pNewAddr );
+
+/**
+ * @brief Resolve a Private Resolveable Address.
+ *
+ * @param pIRK - pointer to the IRK
+ * @param pAddr - pointer to the random address
+ *
+ * @return SUCCESS - match,
+ * FAILURE - don't match,
+ * INVALIDPARAMETER - parameters invalid
+ */
+extern bStatus_t SM_ResolveRandomAddrs( uint8 *pIRK, uint8 *pAddr );
+
+/**
+ * @brief Encrypt the plain text data with the key..
+ *
+ * @param pKey - key data
+ * @param pPlainText - Plain text data
+ * @param pResult - place to put the encrypted result
+ *
+ * @return SUCCESS - if started,
+ * INVALIDPARAMETER - one of the parameters are NULL,
+ * bleAlreadyInRequestedMode,
+ * bleMemAllocError
+ */
+extern bStatus_t SM_Encrypt( uint8 *pKey, uint8 *pPlainText, uint8 *pResult );
+
+/**
+ * @brief Generate an outgoing Authentication Signature.
+ *
+ * @param pData - message data
+ * @param len - length of pData
+ * @param pAuthenSig - place to put new signature
+ *
+ * @return SUCCESS - signature authentication generated,
+ * INVALIDPARAMETER - pData or pAuthenSig is NULL,
+ * bleMemAllocError
+ */
+extern bStatus_t SM_GenerateAuthenSig( uint8 *pData, uint8 len, uint8 *pAuthenSig );
+
+/**
+ * @brief Verify an Authentication Signature.
+ *
+ * @param connHandle - connection to verify against.
+ * @param authentication - TRUE if requires an authenticated CSRK, FALSE if not
+ * @param pData - message data
+ * @param len - length of pData
+ * @param pAuthenSig - message signature to verify
+ *
+ * @return SUCCESS - signature authentication verified,
+ * FAILURE - if not verified,
+ * bleNotConnected - Connection not found,
+ * INVALIDPARAMETER - pData or pAuthenSig is NULL, or signCounter is invalid,
+ * bleMemAllocError
+ */
+extern bStatus_t SM_VerifyAuthenSig( uint16 connHandle,
+ uint8 authentication,
+ uint8 *pData,
+ uint8 len,
+ uint8 *pAuthenSig );
+
+/**
+ * @brief Update the passkey for the pairing process.
+ *
+ * @param pPasskey - pointer to the 6 digit passkey
+ * @param connectionHandle - connection handle to link.
+ *
+ * @return SUCCESS,
+ * bleIncorrectMode - Not pairing,
+ * INVALIDPARAMETER - link is incorrect
+ */
+extern bStatus_t SM_PasskeyUpdate( uint8 *pPasskey, uint16 connectionHandle );
+
+/**
+ * @} End SM_API
+ */
+
+/*-------------------------------------------------------------------
+ * TASK API - These functions must only be called OSAL.
+ */
+
+ /**
+ * @internal
+ *
+ * @brief SM Task Initialization Function.
+ *
+ * @param taskID - SM task ID.
+ *
+ * @return void
+ */
+ extern void SM_Init( uint8 task_id );
+
+ /**
+ * @internal
+ *
+ * @brief SM Task event processing function.
+ *
+ * @param taskID - SM task ID
+ * @param events - SM events.
+ *
+ * @return events not processed
+ */
+ extern uint16 SM_ProcessEvent( uint8 task_id, uint16 events );
+
+/*-------------------------------------------------------------------
+-------------------------------------------------------------------*/
+
+
+
+
+
+#line 84 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gap.h"
+
+/*-------------------------------------------------------------------
+ * MACROS
+ */
+
+/*-------------------------------------------------------------------
+ * CONSTANTS
+ */
+
+/** @defgroup BLE_GAP_DEFINES BLE GAP Constants and Structures
+ * @{
+ */
+
+/** @defgroup GAP_MSG_EVENT_DEFINES GAP Message IDs
+ * @{
+ */
+#line 116 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gap.h"
+/** @} End GAP_MSG_EVENT_DEFINES */
+
+/** @defgroup GAP_CONN_HANDLE_DEFINES GAP Special Connection Handles
+ * Used by GAP_TerminateLinkReq()
+ * @{
+ */
+
+
+/** @} End GAP_CONN_HANDLE_DEFINES */
+
+/** @defgroup GAP_PROFILE_ROLE_DEFINES GAP Profile Roles
+ * Bit mask values
+ * @{
+ */
+
+
+
+
+/** @} End GAP_PROFILE_ROLE_DEFINES */
+
+/**
+ * @defgroup GAP_PARAMETER_ID_DEFINES GAP Parameter IDs
+ * Used in place of gapParamIDs_t.
+ * @{
+ */
+// Timers
+#line 148 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gap.h"
+
+// Constants
+#line 176 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gap.h"
+
+// Proprietary
+
+
+
+
+
+
+#line 197 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gap.h"
+
+/** @} End GAP_PARAMETER_ID_DEFINES */
+
+/** @defgroup GAP_DEVDISC_MODE_DEFINES GAP Device Discovery Modes
+ * @{
+ */
+
+
+
+
+/** @} End GAP_DEVDISC_MODE_DEFINES */
+
+/** @defgroup GAP_ADDR_TYPE_DEFINES GAP Address Types
+ * @{
+ */
+
+
+
+
+/** @} End GAP_ADDR_TYPE_DEFINES */
+
+/** @defgroup GAP_ADVERTISEMENT_TYPE_DEFINES GAP Advertiser Event Types
+ * for eventType field in gapAdvertisingParams_t, gapDevRec_t and gapDeviceInfoEvent_t
+ * @{
+ */
+
+
+
+
+
+/** @} End GAP_ADVERTISEMENT_TYPE_DEFINES */
+
+/** @defgroup GAP_FILTER_POLICY_DEFINES GAP Advertiser Filter Scan Parameters
+ * @{
+ */
+
+
+
+
+/** @} End GAP_FILTER_POLICY_DEFINES */
+
+//! Advertiser Channel Map
+
+
+//! Maximum Pairing Passcode/Passkey value. Range of a passkey can be 0 - 999,999.
+
+
+/** Sign Counter Initialized - Sign counter hasn't been used yet. Used when setting up
+ * a connection's signing information.
+ */
+
+
+/** @defgroup GAP_ADVCHAN_DEFINES GAP Advertisement Channel Map
+ * @{
+ */
+
+
+
+
+/** @} End GAP_ADVCHAN_DEFINES */
+
+/** @defgroup GAP_WHITELIST_DEFINES GAP White List Options
+ * @{
+ */
+
+
+/** @} End GAP_WHITELIST_DEFINES */
+
+/** @defgroup GAP_ADTYPE_DEFINES GAP Advertisment Data Types
+ * These are the data type identifiers for the data tokens in the advertisement data field.
+ * @{
+ */
+#line 291 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gap.h"
+/** @} End GAP_ADTYPE_DEFINES */
+
+/** @defgroup GAP_ADTYPE_FLAGS_MODES GAP ADTYPE Flags Discovery Modes
+ * @{
+ */
+
+
+
+/** @} End GAP_ADTYPE_FLAGS_MODES */
+
+/** @defgroup GAP_APPEARANCE_VALUES GAP Appearance Values
+ * @{
+ */
+#line 333 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gap.h"
+/** @} End GAP_APPEARANCE_VALUES */
+
+/*-------------------------------------------------------------------
+ * TYPEDEFS - Initialization and Configuration
+ */
+
+/**
+ * GAP Parameters IDs: @ref GAP_PARAMETER_ID_DEFINES
+ */
+typedef uint16 gapParamIDs_t;
+
+/**
+ * GAP event header format.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP type of command. Ref: @ref GAP_MSG_EVENT_DEFINES
+} gapEventHdr_t;
+
+/**
+ * GAP_RANDOM_ADDR_CHANGED_EVENT message format. This message is sent to the
+ * app when the random address changes.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_RANDOM_ADDR_CHANGED_EVENT
+ uint8 addrType; //!< Address type: @ref GAP_ADDR_TYPE_DEFINES
+ uint8 newRandomAddr[6]; //!< the new calculated private addr
+} gapRandomAddrEvent_t;
+
+/**
+ * Connection parameters for the peripheral device. These numbers are used
+ * to compare against connection events and request connection parameter
+ * updates with the master.
+ */
+typedef struct
+{
+ /** Minimum value for the connection event (interval. 0x0006 - 0x0C80 * 1.25 ms) */
+ uint16 intervalMin;
+ /** Maximum value for the connection event (interval. 0x0006 - 0x0C80 * 1.25 ms) */
+ uint16 intervalMax;
+ /** Number of LL latency connection events (0x0000 - 0x03e8) */
+ uint16 latency;
+ /** Connection Timeout (0x000A - 0x0C80 * 10 ms) */
+ uint16 timeout;
+} gapPeriConnectParams_t;
+
+/**
+ * GAP_DEVICE_INIT_DONE_EVENT message format. This message is sent to the
+ * app when the Device Initialization is done [initiated by calling
+ * GAP_DeviceInit()].
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_DEVICE_INIT_DONE_EVENT
+ uint8 devAddr[6]; //!< Device's BD_ADDR
+ uint16 dataPktLen; //!< HC_LE_Data_Packet_Length
+ uint8 numDataPkts; //!< HC_Total_Num_LE_Data_Packets
+} gapDeviceInitDoneEvent_t;
+
+/**
+ * GAP_SIGNATURE_UPDATED_EVENT message format. This message is sent to the
+ * app when the signature counter has changed. This message is to inform the
+ * application in case it wants to save it to be restored on reboot or reconnect.
+ * This message is sent to update a connection's signature counter and to update
+ * this device's signature counter. If devAddr == BD_ADDR, then this message pertains
+ * to this device.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_SIGNATURE_UPDATED_EVENT
+ uint8 addrType; //!< Device's address type for devAddr
+ uint8 devAddr[6]; //!< Device's BD_ADDR, could be own address
+ uint32 signCounter; //!< new Signed Counter
+} gapSignUpdateEvent_t;
+
+/**
+ * GAP_DEVICE_INFO_EVENT message format. This message is sent to the
+ * app during a Device Discovery Request, when a new advertisement or scan
+ * response is received.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_DEVICE_INFO_EVENT
+ uint8 eventType; //!< Advertisement Type: @ref GAP_ADVERTISEMENT_TYPE_DEFINES
+ uint8 addrType; //!< address type: @ref GAP_ADDR_TYPE_DEFINES
+ uint8 addr[6]; //!< Address of the advertisement or SCAN_RSP
+ int8 rssi; //!< Advertisement or SCAN_RSP RSSI
+ uint8 dataLen; //!< Length (in bytes) of the data field (evtData)
+ uint8 *pEvtData; //!< Data field of advertisement or SCAN_RSP
+} gapDeviceInfoEvent_t;
+
+/*-------------------------------------------------------------------
+ * TYPEDEFS - Device Discovery
+ */
+
+/**
+ * Type of device discovery (Scan) to perform.
+ */
+typedef struct
+{
+ uint8 taskID; //!< Requesting App's Task ID, used to return results
+ uint8 mode; //!< Discovery Mode: @ref GAP_DEVDISC_MODE_DEFINES
+ uint8 activeScan; //!< TRUE for active scanning
+ uint8 whiteList; //!< TRUE to only allow advertisements from devices in the white list.
+} gapDevDiscReq_t;
+
+/**
+ * Type of device discovery (Scan) to perform.
+ */
+typedef struct
+{
+ uint8 eventType; //!< Indicates advertising event type used by the advertiser: @ref GAP_ADVERTISEMENT_TYPE_DEFINES
+ uint8 addrType; //!< Address Type: @ref GAP_ADDR_TYPE_DEFINES
+ uint8 addr[6]; //!< Device's Address
+} gapDevRec_t;
+
+/**
+ * GAP_DEVICE_DISCOVERY_EVENT message format. This message is sent to the
+ * Application after a scan is performed.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_DEVICE_DISCOVERY_EVENT
+ uint8 numDevs; //!< Number of devices found during scan
+ gapDevRec_t *pDevList; //!< array of device records
+} gapDevDiscEvent_t;
+
+/**
+ * Advertising Parameters
+ */
+typedef struct
+{
+ uint8 eventType; //!< Advertise Event Type: @ref GAP_ADVERTISEMENT_TYPE_DEFINES
+ uint8 initiatorAddrType; //!< Initiator's address type: @ref GAP_ADDR_TYPE_DEFINES
+ uint8 initiatorAddr[6]; //!< Initiator's addr - used only with connectable directed eventType (ADV_EVTTYPE_CONNECTABLE_DIRECTED).
+ uint8 channelMap; //!< Channel Map: Bit mask @ref GAP_ADVCHAN_DEFINES
+ uint8 filterPolicy; //!< Filer Policy: @ref GAP_FILTER_POLICY_DEFINES. Ignored when directed advertising is used.
+} gapAdvertisingParams_t;
+
+/**
+ * GAP_MAKE_DISCOVERABLE_DONE_EVENT message format. This message is sent to the
+ * app when the Advertise config is complete.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_MAKE_DISCOVERABLE_DONE_EVENT
+ uint16 interval; //!< actual advertising interval selected by controller
+} gapMakeDiscoverableRspEvent_t;
+
+/**
+ * GAP_END_DISCOVERABLE_DONE_EVENT message format. This message is sent to the
+ * app when the Advertising has stopped.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_END_DISCOVERABLE_DONE_EVENT
+} gapEndDiscoverableRspEvent_t;
+
+/**
+ * GAP_ADV_DATA_UPDATE_DONE_EVENT message format. This message is sent to the
+ * app when Advertising Data Update is complete.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_ADV_DATA_UPDATE_DONE_EVENT
+ uint8 adType; //!< TRUE if advertising data, FALSE if SCAN_RSP
+} gapAdvDataUpdateEvent_t;
+
+/*-------------------------------------------------------------------
+ * TYPEDEFS - Link Establishment
+ */
+
+/**
+ * Establish Link Request parameters
+ */
+typedef struct
+{
+ uint8 taskID; //!< Requesting App/Profile's Task ID
+ uint8 highDutyCycle; //!< TRUE to high duty cycle scan, FALSE if not.
+ uint8 whiteList; //!< Determines use of the white list: @ref GAP_WHITELIST_DEFINES
+ uint8 addrTypePeer; //!< Address type of the advertiser: @ref GAP_ADDR_TYPE_DEFINES
+ uint8 peerAddr[6]; //!< Advertiser's address
+} gapEstLinkReq_t;
+
+/**
+ * Update Link Parameters Request parameters
+ */
+typedef struct
+{
+ uint16 connectionHandle; //!< Connection handle of the update
+ uint16 intervalMin; //!< Minimum Connection Interval
+ uint16 intervalMax; //!< Maximum Connection Interval
+ uint16 connLatency; //!< Connection Latency
+ uint16 connTimeout; //!< Connection Timeout
+} gapUpdateLinkParamReq_t;
+
+/**
+ * GAP_LINK_ESTABLISHED_EVENT message format. This message is sent to the app
+ * when the link request is complete.
+ *
+ * For an Observer, this message is sent to complete the Establish Link Request.
+ * For a Peripheral, this message is sent to indicate that a link has been created.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_LINK_ESTABLISHED_EVENT
+ uint8 devAddrType; //!< Device address type: @ref GAP_ADDR_TYPE_DEFINES
+ uint8 devAddr[6]; //!< Device address of link
+ uint16 connectionHandle; //!< Connection Handle from controller used to ref the device
+ uint16 connInterval; //!< Connection Interval
+ uint16 connLatency; //!< Conenction Latency
+ uint16 connTimeout; //!< Connection Timeout
+ uint8 clockAccuracy; //!< Clock Accuracy
+} gapEstLinkReqEvent_t;
+
+/**
+ * GAP_LINK_PARAM_UPDATE_EVENT message format. This message is sent to the app
+ * when the connection parameters update request is complete.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_LINK_PARAM_UPDATE_EVENT
+ uint8 status; //!< bStatus_t
+ uint16 connectionHandle; //!< Connection handle of the update
+ uint16 connInterval; //!< Requested connection interval
+ uint16 connLatency; //!< Requested connection latency
+ uint16 connTimeout; //!< Requested connection timeout
+} gapLinkUpdateEvent_t;
+
+/**
+ * GAP_LINK_TERMINATED_EVENT message format. This message is sent to the
+ * app when a link to a device is terminated.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_LINK_TERMINATED_EVENT
+ uint16 connectionHandle; //!< connection Handle
+ uint8 reason; //!< termination reason from LL
+} gapTerminateLinkEvent_t;
+
+/*-------------------------------------------------------------------
+ * TYPEDEFS - Authentication, Bounding and Pairing
+ */
+
+/**
+ * GAP_PASSKEY_NEEDED_EVENT message format. This message is sent to the
+ * app when a Passkey is needed from the app's user interface.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_PASSKEY_NEEDED_EVENT
+ uint8 deviceAddr[6]; //!< address of device to pair with, and could be either public or random.
+ uint16 connectionHandle; //!< Connection handle
+ uint8 uiInputs; //!< Pairing User Interface Inputs - Ask user to input passcode
+ uint8 uiOutputs; //!< Pairing User Interface Outputs - Display passcode
+} gapPasskeyNeededEvent_t;
+
+/**
+ * GAP_AUTHENTICATION_COMPLETE_EVENT message format. This message is sent to the app
+ * when the authentication request is complete.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_AUTHENTICATION_COMPLETE_EVENT
+ uint16 connectionHandle; //!< Connection Handle from controller used to ref the device
+ uint8 authState; //!< TRUE if the pairing was authenticated (MITM)
+ smSecurityInfo_t *pSecurityInfo; //!< BOUND - security information from this device
+ smIdentityInfo_t *pIdentityInfo; //!< BOUND - identity information
+ smSigningInfo_t *pSigningInfo; //!< Signing information
+ smSecurityInfo_t *pDevSecInfo; //!< BOUND - security information from connected device
+} gapAuthCompleteEvent_t;
+
+/**
+ * securityInfo and identityInfo are only used if secReqs.bondable == BOUND, which means that
+ * the device is already bound and we should use the security information and keys.
+ */
+typedef struct
+{
+ uint16 connectionHandle; //!< Connection Handle from controller,
+ smLinkSecurityReq_t secReqs; //!< Pairing Control info
+} gapAuthParams_t;
+
+/**
+ * GAP_SLAVE_REQUESTED_SECURITY_EVENT message format. This message is sent to the app
+ * when a Slave Security Request is received.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_SLAVE_REQUESTED_SECURITY_EVENT
+ uint16 connectionHandle; //!< Connection Handle
+ uint8 deviceAddr[6]; //!< address of device requesting security
+ uint8 authReq; //!< Authentication Requirements: Bit 2: MITM, Bits 0-1: bonding (0 - no bonding, 1 - bonding)
+
+} gapSlaveSecurityReqEvent_t;
+
+/**
+ * GAP_BOND_COMPLETE_EVENT message format. This message is sent to the
+ * app when a bonding is complete. This means that a key is loaded and the link is encrypted.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_BOND_COMPLETE_EVENT
+ uint16 connectionHandle; //!< connection Handle
+} gapBondCompleteEvent_t;
+
+/**
+ * Pairing Request fields - the parsed fields of the SMP Pairing Request command.
+ */
+typedef struct
+{
+ uint8 ioCap; //!< Pairing Request ioCap field
+ uint8 oobDataFlag; //!< Pairing Request OOB Data Flag field
+ uint8 authReq; //!< Pairing Request Auth Req field
+ uint8 maxEncKeySize; //!< Pairing Request Maximum Encryption Key Size field
+ keyDist_t keyDist; //!< Pairing Request Key Distribution field
+} gapPairingReq_t;
+
+/**
+ * GAP_PAIRING_REQ_EVENT message format.
+ *
+ * This message is sent to the
+ * app when an unexpected Pairing Request is received. The application is
+ * expected to setup for a Security Manager pairing/bonding.
+ *
+ * To setup an SM Pairing, the application should call GAP_Authenticate() with these "pairReq" fields.
+ *
+* NOTE: This message should only be sent to peripheral devices.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
+ uint8 opcode; //!< GAP_PAIRING_REQ_EVENT
+ uint16 connectionHandle; //!< connection Handle
+ gapPairingReq_t pairReq; //!< The Pairing Request fields received.
+} gapPairingReqEvent_t;
+
+/**
+ * GAP Advertisement/Scan Response Data Token - These data items are stored as low byte first (OTA
+ * format). The data space for these items are passed in and maintained by
+ * the calling application
+ */
+typedef struct
+{
+ uint8 adType; //!< ADTYPE value: @ref GAP_ADTYPE_DEFINES
+ uint8 attrLen; //!< Number of bytes in the attribute data
+ uint8 *pAttrData; //!< pointer to Attribute data
+} gapAdvDataToken_t;
+
+/** @} End BLE_GAP_DEFINES */
+
+/*-------------------------------------------------------------------
+ * GLOBAL VARIABLES
+ */
+
+/**
+ * @defgroup GAP_API GAP API Functions
+ *
+ * @{
+ */
+
+/*-------------------------------------------------------------------
+ * FUNCTIONS - Initialization and Configuation
+ */
+
+ /**
+ * @brief Called to setup the device. Call just once on initialization.
+ *
+ * NOTE: When initialization is complete, the calling app will be
+ * sent the GAP_DEVICE_INIT_DONE_EVENT
+ *
+ * @param taskID - Default task ID to send events.
+ * @param profileRole - GAP Profile Roles: @ref GAP_PROFILE_ROLE_DEFINES
+ * @param maxScanResponses - maximum number to scan responses
+ * we can receive during a device discovery.
+ * @param pIRK - pointer to Identity Root Key, NULLKEY (all zeroes) if the app
+ * wants the GAP to generate the key.
+ * @param pSRK - pointer to Sign Resolving Key, NULLKEY if the app
+ * wants the GAP to generate the key.
+ * @param pSignCounter - 32 bit value used in the SM Signing
+ * algorithm that shall be initialized to zero and incremented
+ * with every new signing. This variable must also be maintained
+ * by the application.
+ *
+ * @return SUCCESS - Processing, expect GAP_DEVICE_INIT_DONE_EVENT,
+ * INVALIDPARAMETER - for invalid profile role or role combination,
+ * bleIncorrectMode - trouble communicating with HCI
+ */
+ extern bStatus_t GAP_DeviceInit( uint8 taskID,
+ uint8 profileRole,
+ uint8 maxScanResponses,
+ uint8 *pIRK,
+ uint8 *pSRK,
+ uint32 *pSignCounter );
+
+ /**
+ * @brief Called to setup a GAP Advertisement/Scan Response data token.
+ *
+ * NOTE: The data in these items are stored as low byte first (OTA format).
+ * The passed in structure "token" should be allocated by the calling app/profile
+ * and not released until after calling GAP_RemoveAdvToken().
+ *
+ * @param pToken - Advertisement/Scan response token to write.
+ *
+ * @return SUCCESS - advertisement token added to the GAP list
+ * INVALIDPARAMETER - Invalid Advertisement Type or pAttrData is NULL
+ * INVALID_MEM_SIZE - The tokens take up too much space and don't fit into Advertisment data and Scan Response Data
+ * bleInvalidRange - token ID already exists.
+ * bleIncorrectMode - not a peripheral device
+ * bleMemAllocError - memory allocation failure,
+ */
+ extern bStatus_t GAP_SetAdvToken( gapAdvDataToken_t *pToken );
+
+ /**
+ * @brief Called to read a GAP Advertisement/Scan Response data token.
+ *
+ * @param adType - Advertisement type to get
+ *
+ * @return pointer to the advertisement data token structure, NULL if not found.
+ */
+ extern gapAdvDataToken_t *GAP_GetAdvToken( uint8 adType );
+
+ /**
+ * @brief Called to remove a GAP Advertisement/Scan Response data token.
+ *
+ * @param adType - Advertisement type to remove
+ *
+ * @return pointer to the token structure removed from the GAP ADType list
+ * NULL if the requested adType wasn't found.
+ */
+ extern gapAdvDataToken_t *GAP_RemoveAdvToken( uint8 adType );
+
+ /**
+ * @brief Called to rebuild and load Advertisement and Scan Response data from existing
+ * GAP Advertisement Tokens.
+ *
+ * @return SUCCESS or bleIncorrectMode
+ */
+ extern bStatus_t GAP_UpdateAdvTokens( void );
+
+ /**
+ * @brief Set a GAP Parameter value. Use this function to change
+ * the default GAP parameter values.
+ *
+ * @param paramID - parameter ID: @ref GAP_PARAMETER_ID_DEFINES
+ * @param paramValue - new param value
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+ extern bStatus_t GAP_SetParamValue( gapParamIDs_t paramID, uint16 paramValue );
+
+ /**
+ * @brief Get a GAP Parameter value.
+ *
+ * @param paramID - parameter ID: @ref GAP_PARAMETER_ID_DEFINES
+ *
+ * @return GAP Parameter value or 0xFFFF if invalid
+ */
+ extern uint16 GAP_GetParamValue( gapParamIDs_t paramID );
+
+ /**
+ * @brief Setup the device's address type. If ADDRTYPE_PRIVATE_RESOLVE
+ * is selected, the address will change periodically.
+ *
+ * @param addrType - @ref GAP_ADDR_TYPE_DEFINES
+ * @param pStaticAddr - Only used with ADDRTYPE_STATIC
+ * or ADDRTYPE_PRIVATE_NONRESOLVE type.
+ * NULL to auto generate otherwise the application
+ * can specify the address value
+ *
+ * @return SUCCESS: address type updated,
+ * bleNotReady: Can't be called until GAP_DeviceInit() is called
+ * and the init process is completed,
+ * bleIncorrectMode: can't change with an active connection,
+ * or INVALIDPARAMETER.
+ *
+ * If return value isn't SUCCESS, the address type remains
+ * the same as before this call.
+ */
+ extern bStatus_t GAP_ConfigDeviceAddr( uint8 addrType, uint8 *pStaticAddr );
+
+ /**
+ * @brief Register your task ID to receive extra (unwanted)
+ * HCI status and complete events.
+ *
+ * @param taskID - Default task ID to send events.
+ *
+ * @return none
+ */
+ extern void GAP_RegisterForHCIMsgs( uint8 taskID );
+
+/*-------------------------------------------------------------------
+ * FUNCTIONS - Device Discovery
+ */
+
+ /**
+ * @brief Start a device discovery scan.
+ *
+ * @param pParams - Device Discovery parameters
+ *
+ * @return SUCCESS: scan started,
+ * bleIncorrectMode: invalid profile role,
+ * bleAlreadyInRequestedMode: not available
+ */
+ extern bStatus_t GAP_DeviceDiscoveryRequest( gapDevDiscReq_t *pParams );
+
+ /**
+ * @brief Cancel an existing device discovery request.
+ *
+ * @param taskID - used to return GAP_DEVICE_DISCOVERY_EVENT
+ *
+ * @return SUCCESS: cancel started,
+ * bleInvalidTaskID: Not the task that started discovery,
+ * bleIncorrectMode: not in discovery mode
+ */
+ extern bStatus_t GAP_DeviceDiscoveryCancel( uint8 taskID );
+
+ /**
+ * @brief Setup or change advertising. Also starts advertising.
+ *
+ * @param taskID - used to return GAP_DISCOVERABLE_RESPONSE_EVENT
+ * @param pParams - advertising parameters
+ *
+ * @return SUCCESS: advertising started,
+ * bleIncorrectMode: invalid profile role,
+ * bleAlreadyInRequestedMode: not available at this time,
+ * bleNotReady: advertising data isn't set up yet.
+ */
+ extern bStatus_t GAP_MakeDiscoverable( uint8 taskID, gapAdvertisingParams_t *pParams );
+
+ /**
+ * @brief Setup or change advertising and scan response data.
+ *
+ * NOTE: if the return status from this function is SUCCESS,
+ * the task isn't complete until the GAP_ADV_DATA_UPDATE_DONE_EVENT
+ * is sent to the calling application task.
+ *
+ * @param taskID - task ID of the app requesting the change
+ * @param adType - TRUE - advertisement data, FALSE - scan response data
+ * @param dataLen - Octet length of advertData
+ * @param pAdvertData - advertising or scan response data
+ *
+ * @return SUCCESS: data accepted,
+ * bleIncorrectMode: invalid profile role,
+ */
+ extern bStatus_t GAP_UpdateAdvertisingData( uint8 taskID, uint8 adType,
+ uint8 dataLen, uint8 *pAdvertData );
+
+ /**
+ * @brief Stops advertising.
+ *
+ * @param taskID - of task that called GAP_MakeDiscoverable
+ *
+ * @return SUCCESS: stopping discoverable mode,
+ * bleIncorrectMode: not in discoverable mode,
+ * bleInvalidTaskID: not correct task
+ */
+ extern bStatus_t GAP_EndDiscoverable( uint8 taskID );
+
+ /**
+ * @brief Resolves a private address against an IRK.
+ *
+ * @param pIRK - pointer to the IRK
+ * @param pAddr - pointer to the Resovable Private address
+ *
+ * @return SUCCESS: match,
+ * FAILURE: don't match,
+ * INVALIDPARAMETER: parameters invalid
+ */
+ extern bStatus_t GAP_ResolvePrivateAddr( uint8 *pIRK, uint8 *pAddr );
+
+/*-------------------------------------------------------------------
+ * FUNCTIONS - Link Establishment
+ */
+
+ /**
+ * @brief Establish a link to a slave device.
+ *
+ * @param pParams - link establishment parameters
+ *
+ * @return SUCCESS: started establish link process,
+ * bleIncorrectMode: invalid profile role,
+ * bleNotReady: a scan is in progress,
+ * bleAlreadyInRequestedMode: can’t process now,
+ * bleNoResources: Too many links
+ */
+ extern bStatus_t GAP_EstablishLinkReq( gapEstLinkReq_t *pParams );
+
+ /**
+ * @brief Terminate a link connection.
+ *
+ * @param taskID - requesting app's task id.
+ * @param connectionHandle - connection handle of link to terminate
+ * or @ref GAP_CONN_HANDLE_DEFINES
+ *
+ * @return SUCCESS: Terminate started,
+ * bleIncorrectMode: No Link to terminate,
+ * bleInvalidTaskID: not app that established link
+ */
+ extern bStatus_t GAP_TerminateLinkReq( uint8 taskID, uint16 connectionHandle );
+
+ /**
+ * @brief Update the link parameters to a slave device.
+ *
+ * @param pParams - link update parameters
+ *
+ * @return SUCCESS: started update link process,
+ * bleIncorrectMode: invalid profile role,
+ * bleNotConnected: not in a connection
+ */
+ extern bStatus_t GAP_UpdateLinkParamReq( gapUpdateLinkParamReq_t *pParams );
+
+ /**
+ * @brief Returns the number of active connections.
+ *
+ * @return Number of active connections.
+ */
+ extern uint8 GAP_NumActiveConnections( void );
+
+/*-------------------------------------------------------------------
+ * FUNCTIONS - Pairing
+ */
+
+ /**
+ * @brief Start the Authentication process with the requested device.
+ * This function is used to Initiate/Allow pairing.
+ * Called by both master and slave device (Central and Peripheral).
+ *
+ * NOTE: This function is called after the link is established.
+ *
+ * @param pParams - Authentication parameters
+ * @param pPairReq - Enter these parameters if the Pairing Request was already received.
+ * NULL, if waiting for Pairing Request or if initiating.
+ *
+ * @return SUCCESS,
+ * bleIncorrectMode: Not correct profile role,
+ * INVALIDPARAMETER,
+ * bleNotConnected,
+ * bleAlreadyInRequestedMode,
+ * FAILURE - not workable.
+ */
+ extern bStatus_t GAP_Authenticate( gapAuthParams_t *pParams, gapPairingReq_t *pPairReq );
+
+ /**
+ * @brief Send a Pairing Failed message and end any existing pairing.
+ *
+ * @param connectionHandle - connection handle.
+ * @param reason - Pairing Failed reason code.
+ *
+ * @return SUCCESS - function was successful,
+ * bleMemAllocError - memory allocation error,
+ * INVALIDPARAMETER - one of the parameters were invalid,
+ * bleNotConnected - link not found,
+ * bleInvalidRange - one of the parameters were not within range.
+ */
+ extern bStatus_t GAP_TerminateAuth( uint16 connectionHandle, uint8 reason );
+
+ /**
+ * @brief Update the passkey in string format. This function is called by the
+ * application/profile in response to receiving the
+ * GAP_PASSKEY_NEEDED_EVENT message.
+ *
+ * NOTE: This function is the same as GAP_PasscodeUpdate(), except that
+ * the passkey is passed in as a string format.
+ *
+ * @param pPasskey - new passkey - pointer to numeric string (ie. "019655" ).
+ * This string's range is "000000" to "999999".
+ * @param connectionHandle - connection handle.
+ *
+ * @return SUCCESS: will start pairing with this entry,
+ * bleIncorrectMode: Link not found,
+ * INVALIDPARAMETER: passkey == NULL or passkey isn't formatted properly.
+ */
+ extern bStatus_t GAP_PasskeyUpdate( uint8 *pPasskey, uint16 connectionHandle );
+
+ /**
+ * @brief Update the passkey in a numeric value (not string).
+ * This function is called by the application/profile in response
+ * to receiving the GAP_PASSKEY_NEEDED_EVENT message.
+ *
+ * NOTE: This function is the same as GAP_PasskeyUpdate(), except that
+ * the passkey is passed in as a non-string format.
+ *
+ * @param passcode - not string - range: 0 - 999,999.
+ * @param connectionHandle - connection handle.
+ *
+ * @return SUCCESS: will start pairing with this entry,
+ * bleIncorrectMode: Link not found,
+ * INVALIDPARAMETER: passkey == NULL or passkey isn't formatted properly.
+ */
+ extern bStatus_t GAP_PasscodeUpdate( uint32 passcode, uint16 connectionHandle );
+
+ /**
+ * @brief Generate a Slave Requested Security message to the master.
+ *
+ * @param connectionHandle - connection handle.
+ * @param authReq - Authentication Requirements: Bit 2: MITM, Bits 0-1: bonding (0 - no bonding, 1 - bonding)
+ *
+ * @return SUCCESS: will send,
+ * bleNotConnected: Link not found,
+ * bleIncorrectMode: wrong GAP role, must be a Peripheral Role
+ */
+ extern bStatus_t GAP_SendSlaveSecurityRequest( uint16 connectionHandle, uint8 authReq );
+
+ /**
+ * @brief Set up the connection to accept signed data.
+ *
+ * NOTE: This function is called after the link is established.
+ *
+ * @param connectionHandle - connection handle of the signing information
+ * @param authenticated - TRUE if the signing information is authenticated, FALSE otherwise
+ * @param pParams - signing parameters
+ *
+ * @return SUCCESS,
+ * bleIncorrectMode: Not correct profile role,
+ * INVALIDPARAMETER,
+ * bleNotConnected,
+ * FAILURE: not workable.
+ */
+ extern bStatus_t GAP_Signable( uint16 connectionHandle, uint8 authenticated, smSigningInfo_t *pParams );
+
+ /**
+ * @brief Set up the connection's bound paramaters.
+ *
+ * NOTE: This function is called after the link is established.
+ *
+ * @param connectionHandle - connection handle of the signing information
+ * @param authenticated - this connection was previously authenticated
+ * @param pParams - the connected device's security parameters
+ * @param startEncryption - whether or not to start encryption
+ *
+ * @return SUCCESS,
+ * bleIncorrectMode: Not correct profile role,
+ * INVALIDPARAMETER,
+ * bleNotConnected,
+ * FAILURE: not workable.
+ */
+ extern bStatus_t GAP_Bond( uint16 connectionHandle, uint8 authenticated,
+ smSecurityInfo_t *pParams, uint8 startEncryption );
+
+/**
+ * @} End GAP_API
+ */
+
+/*-------------------------------------------------------------------
+ * Internal API - These functions are only called from gap.c module.
+ */
+
+ /**
+ * @internal
+ *
+ * @brief Setup the device configuration parameters.
+ *
+ * @param taskID - Default task ID to send events.
+ * @param profileRole - GAP Profile Roles
+ *
+ * @return SUCCESS or bleIncorrectMode
+ */
+ extern bStatus_t GAP_ParamsInit( uint8 taskID, uint8 profileRole );
+
+ /**
+ * @internal
+ *
+ * @brief Setup the device security configuration parameters.
+ *
+ * @param pIRK - pointer to Identity Root Key, NULLKEY (all zeroes) if the app
+ * wants the GAP to generate the key.
+ * @param pSRK - pointer to Sign Resolving Key, NULLKEY if the app
+ * wants the GAP to generate the key.
+ * @param pSignCounter - 32 bit value used in the SM Signing
+ * algorithm that shall be initialized to zero and incremented
+ * with every new signing. This variable must also be maintained
+ * by the application.
+ *
+ * @return none
+ */
+ extern void GAP_SecParamsInit( uint8 *pIRK, uint8 *pSRK, uint32 *pSignCounter );
+
+ /**
+ * @internal
+ *
+ * @brief Initialize the GAP Peripheral Dev Manager.
+ *
+ * @param none
+ *
+ * @return SUCCESS or bleMemAllocError
+ */
+ extern bStatus_t GAP_PeriDevMgrInit( void );
+
+ /**
+ * @internal
+ *
+ * @brief Initialize the GAP Central Dev Manager.
+ *
+ * @param maxScanResponses - maximum number to scan responses
+ * we can receive during a device discovery.
+ *
+ * @return SUCCESS or bleMemAllocError
+ */
+ extern bStatus_t GAP_CentDevMgrInit( uint8 maxScanResponses );
+
+ /**
+ * @internal
+ *
+ * @brief Register the GAP Central Connection processing functions.
+ *
+ * @param none
+ *
+ * @return none
+ */
+ extern void GAP_CentConnRegister( void );
+
+
+/*-------------------------------------------------------------------
+ * TASK API - These functions must only be called OSAL.
+ */
+
+ /**
+ * @internal
+ *
+ * @brief GAP Task initialization function.
+ *
+ * @param taskID - GAP task ID.
+ *
+ * @return void
+ */
+ extern void GAP_Init( uint8 task_id );
+
+ /**
+ * @internal
+ *
+ * @brief GAP Task event processing function.
+ *
+ * @param taskID - GAP task ID
+ * @param events - GAP events.
+ *
+ * @return events not processed
+ */
+ extern uint16 GAP_ProcessEvent( uint8 task_id, uint16 events );
+
+
+/*-------------------------------------------------------------------
+-------------------------------------------------------------------*/
+
+
+
+
+
+#line 33 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\include\\gapgattserver.h"
+/**************************************************************************************************
+ Filename: gapgattserver.h
+ Revised: $Date: 2009-10-21 07:25:22 -0700 (Wed, 21 Oct 2009) $
+ Revision: $Revision: 20946 $
+
+ Description: This file contains GAP GATT attribute definitions
+ and prototypes.
+
+
+ Copyright 2009 - 2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+// Privacy Flag States
+
+
+
+// GAP GATT Server Parameters
+#line 73 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\include\\gapgattserver.h"
+
+// GAP Services bit fields
+
+
+// Attribute ID used with application's callback when attribute value is changed OTA
+
+
+
+#line 88 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\include\\gapgattserver.h"
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+// Callback to notify when attribute value is changed over the air.
+typedef void (*ggsAttrValueChange_t)( uint8 attrId );
+
+// GAP GATT Server callback structure
+typedef struct
+{
+ ggsAttrValueChange_t pfnAttrValueChange; // When attribute value is changed OTA
+} ggsAppCBs_t;
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * Profile Callbacks
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/**
+ * @brief Set a GAP GATT Server parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param value - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+extern bStatus_t GGS_SetParameter( uint8 param, uint8 len, void *value );
+
+/**
+ * @brief Get a GAP GATT Server parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param value - pointer to data to put. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return bStatus_t
+ */
+extern bStatus_t GGS_GetParameter( uint8 param, void *value );
+
+/**
+ * @brief Add function for the GAP GATT Service.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return SUCCESS: Service added successfully.
+ * INVALIDPARAMETER: Invalid service field.
+ * FAILURE: Not enough attribute handles available.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t GGS_AddService( uint32 services );
+
+/**
+ * @brief Delete function for the GAP GATT Service.
+ *
+ * @param services - services to delete. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return SUCCESS: Service deleted successfully.
+ * FAILURE: Service not found.
+ */
+extern bStatus_t GGS_DelService( uint32 services );
+
+/**
+ * @brief Registers the application callback function.
+ *
+ * Note: Callback registration is needed only when the
+ * Device Name is made writable. The application
+ * will be notified when the Device Name is changed
+ * over the air.
+ *
+ * @param appCallbacks - pointer to application callbacks.
+ *
+ * @return none
+ */
+extern void GGS_RegisterAppCBs( ggsAppCBs_t *appCallbacks );
+
+/**
+ * @brief Set a GGS Parameter value. Use this function to change
+ * the default GGS parameter values.
+ *
+ * @param value - new GGS param value
+ *
+ * @return void
+ */
+extern void GGS_SetParamValue( uint16 value );
+
+/**
+ * @brief Get a GGS Parameter value.
+ *
+ * @param none
+ *
+ * @return GGS Parameter value
+ */
+extern uint16 GGS_GetParamValue( void );
+
+/*********************************************************************
+ * TASK FUNCTIONS - Don't call these. These are system functions.
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 34 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\Profiles\\Roles\\gapbondmgr.h"
+/**
+ @headerfile: gapbondmgr.h
+ $Date: 2011-03-03 15:46:41 -0800 (Thu, 03 Mar 2011) $
+ $Revision: 12 $
+
+ @mainpage TI BLE GAP Bond Manager
+
+ This GAP profile manages bonded connections between devices.
+
+ When operating as a slave, this profile will automatically respond
+ to SM Pairing Requests from a connected master device. When operating
+ as a master, this profile will automatically respond to SM Slave
+ Security Requests from a connected slave device.
+
+ After pairing, if keys were exchanged and bonding was specified, this
+ profile will save the device and key information of the connected device,
+ so that, on future connections, the bonded devices can establish an
+ encrypted link without pairing.
+
+ This GAP Bond Manager will handle all of the pairing and bonding actions
+ automatically and can be controlled by setting control parameters:
+ * GAPBondMgr_SetParameter()
+ * GAPBondMgr_GetParameter()
+
+ Reference: @ref GAPBOND_PROFILE_PARAMETERS
+
+
+ Copyright 2010-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*/
+
+
+
+
+
+
+
+
+
+/*-------------------------------------------------------------------
+ * INCLUDES
+ */
+
+
+/*-------------------------------------------------------------------
+ * CONSTANTS
+ */
+
+
+
+
+
+
+
+
+/** @defgroup GAPBOND_CONSTANTS_NAME GAP Bond Manager Constants
+ * @{
+ */
+
+/** @} End GAPBOND_CONSTANTS_NAME */
+
+/** @defgroup GAPBOND_PROFILE_PARAMETERS GAP Bond Manager Parameters
+ * @{
+ */
+#line 108 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\Profiles\\Roles\\gapbondmgr.h"
+/** @} End GAPBOND_PROFILE_PARAMETERS */
+
+/** @defgroup GAPBOND_PAIRING_MODE_DEFINES GAP Bond Manager Pairing Modes
+ * @{
+ */
+
+
+
+/** @} End GAPBOND_PAIRING_MODE_DEFINES */
+
+/** @defgroup GAPBOND_IO_CAP_DEFINES GAP Bond Manager I/O Capabilities
+ * @{
+ */
+
+
+
+
+
+/** @} End GAPBOND_IO_CAP_DEFINES */
+
+/** @defgroup GAPBOND_KEY_DIST_DEFINES GAP Bond Manager Key Distribution
+ * @{
+ */
+#line 137 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\Profiles\\Roles\\gapbondmgr.h"
+/** @} End GAPBOND_IO_CAP_DEFINES */
+
+
+/** @defgroup GAPBOND_PAIRING_STATE_DEFINES GAP Bond Manager Pairing States
+ * @{
+ */
+
+
+
+/** @} End GAPBOND_PAIRING_STATE_DEFINES */
+
+/** @defgroup SMP_PAIRING_FAILED_DEFINES Pairing failure status values
+ * @{
+ */
+#line 160 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\Profiles\\Roles\\gapbondmgr.h"
+/** @} End SMP_PAIRING_FAILED_DEFINES */
+
+/** @defgroup GAPBOND_BONDING_FAILURE_DEFINES Bonding Failure Actions
+ * @{
+ */
+
+
+
+
+/** @} End GAPBOND_BONDING_FAILURE_DEFINES */
+
+/*-------------------------------------------------------------------
+ * TYPEDEFS
+ */
+
+
+/**
+ * Passcode Callback Function
+ */
+typedef void (*pfnPasscodeCB_t)
+(
+ uint8 *deviceAddr, //!< address of device to pair with, and could be either public or random.
+ uint16 connectionHandle, //!< Connection handle
+ uint8 uiInputs, //!< Pairing User Interface Inputs - Ask user to input passcode
+ uint8 uiOutputs //!< Pairing User Interface Outputs - Display passcode
+ );
+
+/**
+ * Pairing State Callback Function
+ */
+typedef void (*pfnPairStateCB_t)
+(
+ uint16 connectionHandle, //!< Connection handle
+ uint8 state, //!< Pairing state @ref GAPBOND_PAIRING_STATE_DEFINES
+ uint8 status //!< Pairing status
+);
+
+/**
+ * Callback Registration Structure
+ */
+typedef struct
+{
+ pfnPasscodeCB_t passcodeCB; //!< Passcode callback
+ pfnPairStateCB_t pairStateCB; //!< Pairing state callback
+} gapBondCBs_t;
+
+/*-------------------------------------------------------------------
+ * MACROS
+ */
+
+/*-------------------------------------------------------------------
+ * API FUNCTIONS
+ */
+
+/**
+ * @defgroup GAPROLES_BONDMGR_API GAP Bond Manager API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Set a GAP Bond Manager parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will set the
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also,
+ * the "len" field must be set to the size of a "uint16" and the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPBOND_PROFILE_PARAMETERS
+ * @param len - length of data to write
+ * @param pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPBondMgr_SetParameter( uint16 param, uint8 len, void *pValue );
+
+/**
+ * @brief Get a GAP Bond Manager parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will get a
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also, the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPBOND_PROFILE_PARAMETERS
+ * @param pValue - pointer to location to get the value. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPBondMgr_GetParameter( uint16 param, void *pValue );
+
+/**
+ * @brief Notify the Bond Manager that a connection has been made.
+ *
+ * NOTE: The GAP Peripheral/Central Role profile will
+ * call this function, if they are included in the project.
+ *
+ * @param addrType - device's address type. Reference GAP_ADDR_TYPE_DEFINES in gap.h
+ * @param pDevAddr - device's address
+ * @param connHandle - connection handle
+ * @param role - master or slave role. Reference GAP_PROFILE_ROLE_DEFINES in gap.h
+ *
+ * @return SUCCESS, otherwise failure
+ */
+extern bStatus_t GAPBondMgr_LinkEst( uint8 addrType, uint8 *pDevAddr, uint16 connHandle, uint8 role );
+
+/**
+ * @brief Resolve an address from bonding information.
+ *
+ * @param addrType - device's address type. Reference GAP_ADDR_TYPE_DEFINES in gap.h
+ * @param pDevAddr - device's address
+ * @param pResolvedAddr - pointer to buffer to put the resolved address
+ *
+ * @return bonding index (0 - (GAP_BONDINGS_MAX-1) if found,
+ * GAP_BONDINGS_MAX if not found
+ */
+extern uint8 GAPBondMgr_ResolveAddr( uint8 addrType, uint8 *pDevAddr, uint8 *pResolvedAddr );
+
+/**
+ * @brief Set/clear the service change indication in a bond record.
+ *
+ * @param connectionHandle - connection handle of the connected device or 0xFFFF
+ * if all devices in database.
+ * @param setParam - TRUE to set the service change indication, FALSE to clear it.
+ *
+ * @return SUCCESS - bond record found and changed,
+ * bleNoResources - bond record not found (for 0xFFFF connectionHandle),
+ * bleNotConnected - connection not found - connectionHandle is invalid (for non-0xFFFF connectionHandle).
+ */
+extern bStatus_t GAPBondMgr_ServiceChangeInd( uint16 connectionHandle, uint8 setParam );
+
+/**
+ * @brief Update the Characteristic Configuration in a bond record.
+ *
+ * @param connectionHandle - connection handle of the connected device or 0xFFFF
+ * if all devices in database.
+ * @param attrHandle - attribute handle.
+ * @param value - characteristic configuration value.
+ *
+ * @return SUCCESS - bond record found and changed,
+ * bleNoResources - bond record not found (for 0xFFFF connectionHandle),
+ * bleNotConnected - connection not found - connectionHandle is invalid (for non-0xFFFF connectionHandle).
+ */
+extern bStatus_t GAPBondMgr_UpdateCharCfg( uint16 connectionHandle, uint16 attrHandle, uint16 value );
+
+/**
+ * @brief Register callback functions with the bond manager.
+ *
+ * NOTE: There is no need to register a passcode callback function
+ * if the passcode will be handled with the GAPBOND_DEFAULT_PASSCODE parameter.
+ *
+ * @param pCB - pointer to callback function structure.
+ *
+ * @return none
+ */
+extern void GAPBondMgr_Register( gapBondCBs_t *pCB );
+
+/**
+ * @brief Respond to a passcode request.
+ *
+ * @param connectionHandle - connection handle of the connected device or 0xFFFF
+ * if all devices in database.
+ * @param status - SUCCESS if passcode is available, otherwise see @ref SMP_PAIRING_FAILED_DEFINES.
+ * @param passcode - integer value containing the passcode.
+ *
+ * @return SUCCESS - bond record found and changed,
+ * bleIncorrectMode - Link not found.
+ */
+extern bStatus_t GAPBondMgr_PasscodeRsp( uint16 connectionHandle, uint8 status, uint32 passcode );
+
+/**
+ * @brief This is a bypass mechanism to allow the bond manager to process
+ * GAP messages.
+ *
+ * NOTE: This is an advanced feature and shouldn't be called unless
+ * the normal GAP Bond Manager task ID registration is overridden.
+ *
+ * @param pMsg - GAP event message
+ *
+ * @return none
+ */
+extern void GAPBondMgr_ProcessGAPMsg( gapEventHdr_t *pMsg );
+
+/**
+ * @brief This function will check the length of a Bond Manager NV Item.
+ *
+ * @param id - NV ID.
+ * @param len - lengths in bytes of item.
+ *
+ * @return SUCCESS or FAILURE
+ */
+extern uint8 GAPBondMgr_CheckNVLen( uint8 id, uint8 len );
+
+/**
+ * @} End GAPROLES_BONDMGR_API
+ */
+
+
+
+/*-------------------------------------------------------------------
+ * TASK FUNCTIONS - Don't call these. These are system functions.
+ */
+
+/**
+ * @internal
+ *
+ * @brief Initialization function for the GAP Bond Manager Task.
+ * This is called during initialization and should contain
+ * any application specific initialization (ie. hardware
+ * initialization/setup, table initialization, power up
+ * notificaiton ... ).
+ *
+ * @param the ID assigned by OSAL. This ID should be
+ * used to send messages and set timers.
+ *
+ * @return void
+ */
+extern void GAPBondMgr_Init( uint8 task_id );
+
+/**
+ * @internal
+ *
+ * @brief GAP Bond Manager 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 events not processed
+ */
+extern uint16 GAPBondMgr_ProcessEvent( uint8 task_id, uint16 events );
+
+/*-------------------------------------------------------------------
+-------------------------------------------------------------------*/
+
+
+
+
+
+#line 35 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+
+/* GATT */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gatt.h"
+/**
+ @headerfile: gatt.h
+ $Date: 2009-06-29 16:20:52 -0700 (Mon, 29 Jun 2009) $
+ $Revision: 20240 $
+
+ @mainpage BLE GATT API
+
+ Description: This file contains Generic Attribute Profile (GATT)
+ definitions and prototypes.
+
+ \image html HighLevelGATT.PNG
+
+ \htmlinclude GATTDesc.html
+
+ Copyright 2009-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\ble\\include\\att.h"
+/**
+ @headerfile: att.h
+
+
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// The Exchanging MTU Size is defined as the maximum size of any packet
+// transmitted between a client and a server. A higher layer specification
+// defines the default ATT MTU value. The ATT MTU value should be within
+// the range 23 to 517 inclusive.
+
+
+
+/** @defgroup ATT_METHOD_DEFINES ATT Methods
+ * @{
+ */
+
+#line 101 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\ble\\include\\att.h"
+
+
+
+
+/** @} End ATT_METHOD_DEFINES */
+
+/*** Opcode fields: bitmasks ***/
+// Method (bits 5-0)
+
+
+// Command Flag (bit 6)
+
+
+// Authentication Signature Flag (bit 7)
+
+
+// Size of 16-bit Bluetooth UUID
+
+
+// Size of 128-bit UUID
+
+
+// ATT Response or Confirmation timeout
+
+
+// Authentication Signature status for received PDU; it's TRUE or FALSE for PDU to be sent
+
+
+
+
+/*********************************************************************
+ * Error Response: Error Code
+ */
+
+/** @defgroup ATT_ERR_CODE_DEFINES ATT Error Codes
+ * @{
+ */
+
+#line 156 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\ble\\include\\att.h"
+
+/*** Reserved for future use: 0x12 - 0x7F ***/
+
+/*** Application error code defined by a higher layer specification: 0x80-0x9F ***/
+
+
+
+/** @} End ATT_ERR_CODE_DEFINES */
+
+/*********************************************************************
+ * Find Information Response: UUID Format
+ */
+ // Handle and 16-bit Bluetooth UUID
+
+
+ // Handle and 128-bit UUID
+
+
+// Maximum number of handle and 16-bit UUID pairs in a single Find Info Response
+
+
+// Maximum number of handle and 128-bit UUID pairs in a single Find Info Response
+
+
+/*********************************************************************
+ * Find By Type Value Response: Handles Infomation (Found Attribute Handle and Group End Handle)
+ */
+ // Maximum number of handles info in a single Find By Type Value Response
+
+
+/*********************************************************************
+ * Read Multiple Request: Handles
+ */
+ // Maximum number of handles in a single Read Multiple Request
+
+
+ // Minimum number of handles in a single Read Multiple Request
+
+
+/*********************************************************************
+ * Execute Write Request: Flags
+ */
+ // Cancel all prepared writes
+
+
+ // Immediately write all pending prepared values
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * Size of mandatory fields of ATT requests
+ */
+// Length of Read By Type Request's fixed fields: First handle number (2) + Last handle number (2)
+
+
+// Length of Prepare Write Request's fixed size: Attribute Handle (2) + Value Offset (2)
+
+
+/*********************************************************************
+ * VARIABLES
+ */
+extern const uint8 btBaseUUID[16];
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/**
+ * Attribute Protocol PDU format.
+ */
+typedef struct
+{
+ uint8 sig; //!< Authentication Signature status (not included (0), valid (1), invalid (2))
+ uint8 cmd; //!< Command Flag
+ uint8 method; //!< Method
+ uint16 len; //!< Length of Attribute Parameters
+ uint8 *pParams; //!< Attribute Parameters
+} attPacket_t;
+
+/**
+ * Attribute Type format (2 or 16 octet UUID).
+ */
+typedef struct
+{
+ uint8 len; //!< Length of UUID
+ uint8 uuid[16]; //!< 16 or 128 bit UUID
+} attAttrType_t;
+
+/**
+ * Attribute Type format (2-octet Bluetooth UUID).
+ */
+typedef struct
+{
+ uint8 len; //!< Length of UUID
+ uint8 uuid[2]; //!< 16 bit UUID
+} attAttrBtType_t;
+
+/**
+ * Error Response format.
+ */
+typedef struct
+{
+ uint8 reqOpcode; //!< Request that generated this error response
+ uint16 handle; //!< Attribute handle that generated error response
+ uint8 errCode; //!< Reason why the request has generated error response
+} attErrorRsp_t;
+
+/**
+ * Exchange MTU Request format.
+ */
+typedef struct
+{
+ uint16 clientRxMTU; //!< Client receive MTU size
+} attExchangeMTUReq_t;
+
+/**
+ * Exchange MTU Response format.
+ */
+typedef struct
+{
+ uint16 serverRxMTU; //!< Server receive MTU size
+} attExchangeMTURsp_t;
+
+/**
+ * Find Information Request format.
+ */
+typedef struct
+{
+ uint16 startHandle; //!< First requested handle number (must be first field)
+ uint16 endHandle; //!< Last requested handle number
+} attFindInfoReq_t;
+
+/**
+ * Handle and its 16-bit Bluetooth UUIDs.
+ */
+typedef struct
+{
+ uint16 handle; //!< Handle
+ uint8 uuid[2]; //!< 2-octet Bluetooth UUID
+} attHandleBtUUID_t;
+
+/**
+ * Handle and its 128-bit UUID.
+ */
+typedef struct
+{
+ uint16 handle; //!< Handle
+ uint8 uuid[16]; //!< 16-octect UUID
+} attHandleUUID_t;
+
+/**
+ * Info data format for Find Information Response (handle-UUID pair).
+ */
+typedef union
+{
+ attHandleBtUUID_t btPair[( ( 23 - 2 ) / ( 2 + 2 ) )]; //!< A list of 1 or more handles with their 16-bit Bluetooth UUIDs
+ attHandleUUID_t pair[( ( 23 - 2 ) / ( 2 + 16 ) )]; //!< A list of 1 or more handles with their 128-bit UUIDs
+} attFindInfo_t;
+
+/**
+ * Find Information Response format.
+ */
+typedef struct
+{
+ uint8 numInfo; //!< Number of attribute handle-UUID pairs found
+ uint8 format; //!< Format of information data
+ attFindInfo_t info; //!< Information data whose format is determined by format field
+} attFindInfoRsp_t;
+
+/**
+ * Find By Type Value Request format.
+ */
+typedef struct
+{
+ uint16 startHandle; //!< First requested handle number (must be first field)
+ uint16 endHandle; //!< Last requested handle number
+ attAttrBtType_t type; //!< 2-octet UUID to find
+ uint8 len; //!< Length of value
+ uint8 value[23-7]; //!< Attribute value to find
+} attFindByTypeValueReq_t;
+
+/**
+ * Handles Infomation format.
+ */
+typedef struct
+{
+ uint16 handle; //!< Found attribute handle
+ uint16 grpEndHandle; //!< Group end handle
+} attHandlesInfo_t;
+
+/**
+ * Find By Type Value Response format.
+ */
+typedef struct
+{
+ uint8 numInfo; //!< Number of handles information found
+ attHandlesInfo_t handlesInfo[( ( 23 - 1 ) / 4 )]; //!< List of 1 or more handles information
+} attFindByTypeValueRsp_t;
+
+/**
+ * Read By Type Request format.
+ */
+typedef struct
+{
+ uint16 startHandle; //!< First requested handle number (must be first field)
+ uint16 endHandle; //!< Last requested handle number
+ attAttrType_t type; //!< Requested type (2 or 16 octet UUID)
+} attReadByTypeReq_t;
+
+/**
+ * Read By Type Response format.
+ */
+typedef struct
+{
+ uint8 numPairs; //!< Number of attribute handle-UUID pairs found
+ uint8 len; //!< Size of each attribute handle-value pair
+ uint8 dataList[23-2]; //!< List of 1 or more attribute handle-value pairs
+} attReadByTypeRsp_t;
+
+/**
+ * Read Request format.
+ */
+typedef struct
+{
+ uint16 handle; //!< Handle of the attribute to be read (must be first field)
+} attReadReq_t;
+
+/**
+ * Read Response format.
+ */
+typedef struct
+{
+ uint8 len; //!< Length of value
+ uint8 value[23-1]; //!< Value of the attribute with the handle given
+} attReadRsp_t;
+
+/**
+ * Read Blob Req format.
+ */
+typedef struct
+{
+ uint16 handle; //!< Handle of the attribute to be read (must be first field)
+ uint16 offset; //!< Offset of the first octet to be read
+} attReadBlobReq_t;
+
+/**
+ * Read Blob Response format.
+ */
+typedef struct
+{
+ uint8 len; //!< Length of value
+ uint8 value[23-1]; //!< Part of the value of the attribute with the handle given
+} attReadBlobRsp_t;
+
+/**
+ * Read Multiple Request format.
+ */
+typedef struct
+{
+ uint16 handle[( ( 23 - 1 ) / 2 )]; //!< Set of two or more attribute handles (must be first field)
+ uint8 numHandles; //!< Number of attribute handles
+} attReadMultiReq_t;
+
+/**
+ * Read Multiple Response format.
+ */
+typedef struct
+{
+ uint8 len; //!< Length of values
+ uint8 values[23-1]; //!< Set of two or more values
+} attReadMultiRsp_t;
+
+/**
+ * Read By Group Type Request format.
+ */
+typedef struct
+{
+ uint16 startHandle; //!< First requested handle number (must be first field)
+ uint16 endHandle; //!< Last requested handle number
+ attAttrType_t type; //!< Requested group type (2 or 16 octet UUID)
+} attReadByGrpTypeReq_t;
+
+/**
+ * Read By Group Type Response format.
+ */
+typedef struct
+{
+ uint8 numGrps; //!< Number of attribute handle, end group handle and value sets found
+ uint8 len; //!< Length of each attribute handle, end group handle and value set
+ uint8 dataList[23-2]; //!< List of 1 or more attribute handle, end group handle and value
+} attReadByGrpTypeRsp_t;
+
+/**
+ * Write Request format.
+ */
+typedef struct
+{
+ uint16 handle; //!< Handle of the attribute to be written (must be first field)
+ uint8 len; //!< Length of value
+ uint8 value[23-3]; //!< Value of the attribute to be written
+ uint8 sig; //!< Authentication Signature status (not included (0), valid (1), invalid (2))
+ uint8 cmd; //!< Command Flag
+} attWriteReq_t;
+
+/**
+ * Prepare Write Request format.
+ */
+typedef struct
+{
+ uint16 handle; //!< Handle of the attribute to be written (must be first field)
+ uint16 offset; //!< Offset of the first octet to be written
+ uint8 len; //!< Length of value
+ uint8 value[23-5]; //!< Part of the value of the attribute to be written
+} attPrepareWriteReq_t;
+
+/**
+ * Prepare Write Response format.
+ */
+typedef struct
+{
+ uint16 handle; //!< Handle of the attribute that has been read
+ uint16 offset; //!< Offset of the first octet to be written
+ uint8 len; //!< Length of value
+ uint8 value[23-5]; //!< Part of the value of the attribute to be written
+} attPrepareWriteRsp_t;
+
+/**
+ * Execute Write Request format.
+ */
+typedef struct
+{
+ uint8 flags; //!< 0x00 - cancel all prepared writes.
+ //!< 0x01 - immediately write all pending prepared values.
+} attExecuteWriteReq_t;
+
+/**
+ * Handle Value Notification format.
+ */
+typedef struct
+{
+ uint16 handle; //!< Handle of the attribute that has been changed (must be first field)
+ uint8 len; //!< Length of value
+ uint8 value[23-3]; //!< New value of the attribute
+} attHandleValueNoti_t;
+
+/**
+ * Handle Value Indication format.
+ */
+typedef struct
+{
+ uint16 handle; //!< Handle of the attribute that has been changed (must be first field)
+ uint8 len; //!< Length of value
+ uint8 value[23-3]; //!< New value of the attribute
+} attHandleValueInd_t;
+
+/**
+ * ATT Message format. It's a union of all attribute protocol messages used
+ * between the attribute protocol and upper layer profile/application.
+ */
+typedef union
+{
+ // Request messages
+ attExchangeMTUReq_t exchangeMTUReq; //!< ATT Exchange MTU Request
+ attFindInfoReq_t findInfoReq; //!< ATT Find Information Request
+ attFindByTypeValueReq_t findByTypeValueReq; //!< ATT Find By Type Vaue Request
+ attReadByTypeReq_t readByTypeReq; //!< ATT Read By Type Request
+ attReadReq_t readReq; //!< ATT Read Request
+ attReadBlobReq_t readBlobReq; //!< ATT Read Blob Request
+ attReadMultiReq_t readMultiReq; //!< ATT Read Multiple Request
+ attReadByGrpTypeReq_t readByGrpTypeReq; //!< ATT Read By Group Type Request
+ attWriteReq_t writeReq; //!< ATT Write Request
+ attPrepareWriteReq_t prepareWriteReq; //!< ATT Prepare Write Request
+ attExecuteWriteReq_t executeWriteReq; //!< ATT Execute Write Request
+
+ // Response messages
+ attErrorRsp_t errorRsp; //!< ATT Error Response
+ attExchangeMTURsp_t exchangeMTURsp; //!< ATT Exchange MTU Response
+ attFindInfoRsp_t findInfoRsp; //!< ATT Find Information Response
+ attFindByTypeValueRsp_t findByTypeValueRsp; //!< ATT Find By Type Vaue Response
+ attReadByTypeRsp_t readByTypeRsp; //!< ATT Read By Type Response
+ attReadRsp_t readRsp; //!< ATT Read Response
+ attReadBlobRsp_t readBlobRsp; //!< ATT Read Blob Response
+ attReadMultiRsp_t readMultiRsp; //!< ATT Read Multiple Response
+ attReadByGrpTypeRsp_t readByGrpTypeRsp; //!< ATT Read By Group Type Response
+ attPrepareWriteRsp_t prepareWriteRsp; //!< ATT Prepare Write Response
+
+ // Indication and Notification messages
+ attHandleValueNoti_t handleValueNoti; //!< ATT Handle Value Notification
+ attHandleValueInd_t handleValueInd; //!< ATT Handle Value Indication
+} attMsg_t;
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*-------------------------------------------------------------------
+ * General Utility APIs
+ */
+
+/*
+ * Parse an attribute protocol message.
+ */
+extern uint8 ATT_ParsePacket( l2capDataEvent_t *pL2capMsg, attPacket_t *pPkt );
+
+/*
+ * Compare two UUIDs. The UUIDs are converted if necessary.
+ */
+extern uint8 ATT_CompareUUID( const uint8 *pUUID1, uint16 len1,
+ const uint8 *pUUID2, uint16 len2 );
+/*
+ * Convert a 16-bit UUID to 128-bit UUID.
+ */
+extern uint8 ATT_ConvertUUIDto128( const uint8 *pUUID16, uint8 *pUUID128 );
+
+/*
+ * Convert a 128-bit UUID to 16-bit UUID.
+ */
+extern uint8 ATT_ConvertUUIDto16( const uint8 *pUUID128, uint8 *pUUID16 );
+
+
+/*-------------------------------------------------------------------
+ * Attribute Client Utility APIs
+ */
+
+/*
+ * Build Error Response.
+ */
+extern uint16 ATT_BuildErrorRsp( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Error Response.
+ */
+extern bStatus_t ATT_ParseErrorRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Build Exchange MTU Request.
+ */
+extern uint16 ATT_BuildExchangeMTUReq( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Build Exchange MTU Respnose.
+ */
+extern uint16 ATT_BuildExchangeMTURsp( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Exchange MTU Response.
+ */
+extern bStatus_t ATT_ParseExchangeMTURsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Build Find Information Request.
+ */
+extern uint16 ATT_BuildFindInfoReq( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Find Information Response.
+ */
+extern bStatus_t ATT_ParseFindInfoRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Build Find Information Response.
+ */
+extern uint16 ATT_BuildFindInfoRsp( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Build Find By Type Value Request.
+ */
+extern uint16 ATT_BuildFindByTypeValueReq( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Build Find By Type Value Response.
+ */
+extern uint16 ATT_BuildFindByTypeValueRsp( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Find By Type Value Response.
+ */
+extern bStatus_t ATT_ParseFindByTypeValueRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Build Read By Type Request.
+ */
+extern uint16 ATT_BuildReadByTypeReq( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Build Read By Type Response.
+ */
+extern uint16 ATT_BuildReadByTypeRsp( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Read By Type Response.
+ */
+extern bStatus_t ATT_ParseReadByTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Build Read Request.
+ */
+extern uint16 ATT_BuildReadReq( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Build Read Response.
+ */
+extern uint16 ATT_BuildReadRsp( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Read Response.
+ */
+extern bStatus_t ATT_ParseReadRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Build Read Blob Request.
+ */
+extern uint16 ATT_BuildReadBlobReq( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Build Read Blob Response.
+ */
+extern uint16 ATT_BuildReadBlobRsp( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Read Blob Response.
+ */
+extern bStatus_t ATT_ParseReadBlobRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Build Read Multiple Request.
+ */
+extern uint16 ATT_BuildReadMultiReq( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Build Read Multiple Response.
+ */
+extern uint16 ATT_BuildReadMultiRsp( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Read Multiple Response.
+ */
+extern bStatus_t ATT_ParseReadMultiRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Build Read By Group Type Response.
+ */
+extern uint16 ATT_BuildReadByGrpTypeRsp( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Read By Group Type Response.
+ */
+extern bStatus_t ATT_ParseReadByGrpTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Build Write Request.
+ */
+extern uint16 ATT_BuildWriteReq( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Write Response.
+ */
+extern bStatus_t ATT_ParseWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Build Prepare Write Request.
+ */
+extern uint16 ATT_BuildPrepareWriteReq( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Build Prepare Write Response.
+ */
+extern uint16 ATT_BuildPrepareWriteRsp( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Prepare Write Response.
+ */
+extern bStatus_t ATT_ParsePrepareWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Build Execute Write Request.
+ */
+extern uint16 ATT_BuildExecuteWriteReq( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Execute Write Response.
+ */
+extern bStatus_t ATT_ParseExecuteWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Build Handle Value Indication.
+ */
+extern uint16 ATT_BuildHandleValueInd( uint8 *pBuf, uint8 *pMsg );
+
+/*
+ * Parse Handle Value Indication.
+ */
+extern bStatus_t ATT_ParseHandleValueInd( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+
+/*-------------------------------------------------------------------
+ * Attribute Server Utility APIs
+ */
+
+/*
+ * Parse Exchange MTU Request.
+ */
+extern bStatus_t ATT_ParseExchangeMTUReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Parse Find Information Request.
+ */
+extern bStatus_t ATT_ParseFindInfoReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Parse Find By Type Value Request.
+ */
+extern bStatus_t ATT_ParseFindByTypeValueReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Parse Read By Type Request.
+ */
+extern bStatus_t ATT_ParseReadByTypeReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Parse Read Request.
+ */
+extern bStatus_t ATT_ParseReadReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Parse Write Blob Request.
+ */
+extern bStatus_t ATT_ParseReadBlobReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Parse Read Multiple Request.
+ */
+extern bStatus_t ATT_ParseReadMultiReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Parse Write Request.
+ */
+extern bStatus_t ATT_ParseWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Parse Execute Write Request.
+ */
+extern bStatus_t ATT_ParseExecuteWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Parse Prepare Write Request.
+ */
+extern bStatus_t ATT_ParsePrepareWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+/*
+ * Parse Handle Value Confirmation.
+ */
+extern bStatus_t ATT_ParseHandleValueCfm( uint8 *pParams, uint16 len, attMsg_t *pMsg );
+
+
+/*-------------------------------------------------------------------
+ * Attribute Client Public APIs
+ */
+
+/**
+ * @defgroup ATT_CLIENT_API ATT Client API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Send Exchange MTU Request.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ExchangeMTUReq( uint16 connHandle, attExchangeMTUReq_t *pReq );
+
+/**
+ * @brief Send Find Information Request.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_FindInfoReq( uint16 connHandle, attFindInfoReq_t *pReq );
+
+/**
+ * @brief Send Find By Type Value Request.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_FindByTypeValueReq( uint16 connHandle, attFindByTypeValueReq_t *pReq );
+
+/**
+ * @brief Send Read By Type Request.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ReadByTypeReq( uint16 connHandle, attReadByTypeReq_t *pReq );
+
+/**
+ * @brief Send Read Request.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ReadReq( uint16 connHandle, attReadReq_t *pReq );
+
+/**
+ * @brief Send Read Blob Request.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ReadBlobReq( uint16 connHandle, attReadBlobReq_t *pReq );
+
+/**
+ * @brief Send Read Multiple Request.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ReadMultiReq( uint16 connHandle, attReadMultiReq_t *pReq );
+
+/**
+ * @brief Send Read By Group Type Request.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ReadByGrpTypeReq( uint16 connHandle, attReadByGrpTypeReq_t *pReq );
+
+/**
+ * @brief Send Write Request.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleLinkEncrypted: Connection is already encrypted.
+ */
+extern bStatus_t ATT_WriteReq( uint16 connHandle, attWriteReq_t *pReq );
+
+/**
+ * @brief Send Prepare Write Request.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_PrepareWriteReq( uint16 connHandle, attPrepareWriteReq_t *pReq );
+
+/**
+ * @brief Send Execute Write Request.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ExecuteWriteReq( uint16 connHandle, attExecuteWriteReq_t *pReq );
+
+/**
+ * @brief Send Handle Value Confirmation.
+ *
+ * @param connHandle - connection to use
+ *
+ * @return SUCCESS: Confirmation was sent successfully.
+ * INVALIDPARAMETER: Invalid confirmation field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_HandleValueCfm( uint16 connHandle );
+
+/**
+ * @}
+ */
+
+/*-------------------------------------------------------------------
+ * Attribute Server Public APIs
+ */
+
+/**
+ * @defgroup ATT_SERVER_API ATT Server API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Send Error Response.
+ *
+ * @param connHandle - connection to use
+ * @param pRsp - pointer to error response to be sent
+ *
+ * @return SUCCESS: Response was sent successfully.
+ * INVALIDPARAMETER: Invalid response field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ErrorRsp( uint16 connHandle, attErrorRsp_t *pRsp );
+
+/**
+ * @brief Send Exchange MTU Response.
+ *
+ * @param connHandle - connection to use
+ * @param pRsp - pointer to request to be sent
+ *
+ * @return SUCCESS: Response was sent successfully.
+ * INVALIDPARAMETER: Invalid response field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ExchangeMTURsp( uint16 connHandle, attExchangeMTURsp_t *pRsp );
+
+/**
+ * @brief Send Find Information Response.
+ *
+ * @param connHandle - connection to use
+ * @param pRsp - pointer to response to be sent
+ *
+ * @return SUCCESS: Response was sent successfully.
+ * INVALIDPARAMETER: Invalid response field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_FindInfoRsp( uint16 connHandle, attFindInfoRsp_t *pRsp );
+
+/**
+ * @brief Send Find By Tyep Value Response.
+ *
+ * @param connHandle - connection to use
+ * @param pRsp - pointer to response to be sent
+ *
+ * @return SUCCESS: Response was sent successfully.
+ * INVALIDPARAMETER: Invalid response field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_FindByTypeValueRsp( uint16 connHandle, attFindByTypeValueRsp_t *pRsp );
+
+/**
+ * @brief Send Read By Type Respond.
+ *
+ * @param connHandle - connection to use
+ * @param pRsp - pointer to response to be sent
+ *
+ * @return SUCCESS: Response was sent successfully.
+ * INVALIDPARAMETER: Invalid response field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ReadByTypeRsp( uint16 connHandle, attReadByTypeRsp_t *pRsp );
+
+/**
+ * @brief Send Read Response.
+ *
+ * @param connHandle - connection to use
+ * @param pRsp - pointer to response to be sent
+ *
+ * @return SUCCESS: Response was sent successfully.
+ * INVALIDPARAMETER: Invalid response field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ReadRsp( uint16 connHandle, attReadRsp_t *pRsp );
+
+/**
+ * @brief Send Read Blob Response.
+ *
+ * @param connHandle - connection to use
+ * @param pRsp - pointer to response to be sent
+ *
+ * @return SUCCESS: Response was sent successfully.
+ * INVALIDPARAMETER: Invalid response field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ReadBlobRsp( uint16 connHandle, attReadBlobRsp_t *pRsp );
+
+/**
+ * @brief Send Read Multiple Response.
+ *
+ * @param connHandle - connection to use
+ * @param pRsp - pointer to response to be sent
+ *
+ * @return SUCCESS: Response was sent successfully.
+ * INVALIDPARAMETER: Invalid response field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ReadMultiRsp( uint16 connHandle, attReadMultiRsp_t *pRsp ) ;
+
+/**
+ * @brief Send Read By Group Type Respond.
+ *
+ * @param connHandle - connection to use
+ * @param pRsp - pointer to response to be sent
+ *
+ * @return SUCCESS: Response was sent successfully.
+ * INVALIDPARAMETER: Invalid response field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ReadByGrpTypeRsp( uint16 connHandle, attReadByGrpTypeRsp_t *pRsp );
+
+/**
+ * @brief Send Write Response.
+ *
+ * @param connHandle - connection to use
+ *
+ * @return SUCCESS: Response was sent successfully.
+ * INVALIDPARAMETER: Invalid response field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_WriteRsp( uint16 connHandle );
+
+/**
+ * @brief Send Prepare Write Response.
+ *
+ * @param connHandle - connection to use
+ * @param pRsp - pointer to response to be sent
+ *
+ * @return SUCCESS: Response was sent successfully.
+ * INVALIDPARAMETER: Invalid response field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_PrepareWriteRsp( uint16 connHandle, attPrepareWriteRsp_t *pRsp );
+
+/**
+ * @brief Send Execute Write Response.
+ *
+ * @param connHandle - connection to use
+ *
+ * @return SUCCESS: Response was sent successfully.
+ * INVALIDPARAMETER: Invalid response field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_ExecuteWriteRsp( uint16 connHandle );
+
+/**
+ * @brief Send Handle Value Notification.
+ *
+ * @param connHandle - connection to use
+ * @param pNoti - pointer to notification to be sent
+ *
+ * @return SUCCESS: Notification was sent successfully.
+ * INVALIDPARAMETER: Invalid notification field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_HandleValueNoti( uint16 connHandle, attHandleValueNoti_t *pNoti );
+
+/**
+ * @brief Send Handle Value Indication.
+ *
+ * @param connHandle - connection to use
+ * @param pInd - pointer to indication to be sent
+ *
+ * @return SUCCESS: Indication was sent successfully.
+ * INVALIDPARAMETER: Invalid indication field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t ATT_HandleValueInd( uint16 connHandle, attHandleValueInd_t *pInd );
+
+/**
+ * @}
+ */
+
+/**
+ * @brief Set a ATT Parameter value. Use this function to change
+ * the default ATT parameter values.
+ *
+ * @param value - new param value
+ *
+ * @return void
+ */
+extern void ATT_SetParamValue( uint16 value );
+
+/**
+ * @brief Get a ATT Parameter value.
+ *
+ * @param none
+ *
+ * @return ATT Parameter value
+ */
+extern uint16 ATT_GetParamValue( void );
+
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 61 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gatt.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/** @defgroup GATT_PERMIT_BITMAPS_DEFINES GATT Attribute Access Permissions Bit Fields
+ * @{
+ */
+
+#line 76 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gatt.h"
+
+/** @} End GATT_PERMIT_BITMAPS_DEFINES */
+
+
+/** @defgroup GATT_NUM_PREPARE_WRITES_DEFINES GATT Maximum Number of Prepare Writes
+ * @{
+ */
+
+
+
+
+
+/** @} End GATT_NUM_PREPARE_WRITES_DEFINES */
+
+
+/** @defgroup GATT_ENCRYPT_KEY_SIZE_DEFINES GATT Encryption Key Size
+ * @{
+ */
+
+
+
+/** @} End GATT_ENCRYPT_KEY_SIZE_DEFINES */
+
+
+/** @defgroup GATT_MAX_ATTR_SIZE_DEFINES GATT Maximum Attribute Value Length
+ * @{
+ */
+
+
+
+/** @} End GATT_MAX_ATTR_SIZE_DEFINES */
+
+// GATT Maximum number of connections (including loopback)
+
+
+ // GATT Base Method
+
+
+// Attribute handle defintions
+
+
+
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+// Attribute Access Permissions
+#line 134 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gatt.h"
+
+// Check for different UUID types
+#line 146 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\gatt.h"
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/**
+ * GATT Read By Type Request format.
+ */
+typedef struct
+{
+ uint8 discCharsByUUID; //!< Whether this is a GATT Discover Characteristics by UUID sub-procedure
+ attReadByTypeReq_t req; //!< Read By Type Request
+} gattReadByTypeReq_t;
+
+/**
+ * GATT Prepare Write Request format.
+ */
+typedef struct
+{
+ uint16 handle; //!< Handle of the attribute to be written (must be first field)
+ uint16 offset; //!< Offset of the first octet to be written
+ uint8 len; //!< Length of value
+ uint8 *pValue; //!< Part of the value of the attribute to be written (must be allocated)
+} gattPrepareWriteReq_t;
+
+/**
+ * GATT Write Long Request format. Do not change the order of the members.
+ */
+typedef struct
+{
+ uint8 reliable; //!< Whether reliable writes requested (always FALSE for Write Long)
+ gattPrepareWriteReq_t req; //!< GATT Prepare Write Request
+ uint16 lastOffset; //!< Offset of last Prepare Write Request sent
+} gattWriteLongReq_t;
+
+/**
+ * GATT Reliable Writes Request format. Do not change the order of the members.
+ */
+typedef struct
+{
+ uint8 reliable; //!< Whether reliable writes requested (always TRUE for Reliable Writes)
+ attPrepareWriteReq_t *pReqs; //!< Arrary of Prepare Write Requests (must be allocated)
+ uint8 numReqs; //!< Number of Prepare Write Requests
+ uint8 index; //!< Index of last Prepare Write Request sent
+ uint8 flags; //!< 0x00 - cancel all prepared writes.
+ //!< 0x01 - immediately write all pending prepared values.
+} gattReliableWritesReq_t;
+
+/**
+ * GATT Message format. It's a union of all attribute protocol/profile messages
+ * used between the attribute protocol/profile and upper layer application.
+ */
+typedef union
+{
+ // Request messages
+ attExchangeMTUReq_t exchangeMTUReq; //!< ATT Exchange MTU Request
+ attFindInfoReq_t findInfoReq; //!< ATT Find Information Request
+ attFindByTypeValueReq_t findByTypeValueReq; //!< ATT Find By Type Vaue Request
+ attReadByTypeReq_t readByTypeReq; //!< ATT Read By Type Request
+ attReadReq_t readReq; //!< ATT Read Request
+ attReadBlobReq_t readBlobReq; //!< ATT Read Blob Request
+ attReadMultiReq_t readMultiReq; //!< ATT Read Multiple Request
+ attReadByGrpTypeReq_t readByGrpTypeReq; //!< ATT Read By Group Type Request
+ attWriteReq_t writeReq; //!< ATT Write Request
+ attPrepareWriteReq_t prepareWriteReq; //!< ATT Prepare Write Request
+ attExecuteWriteReq_t executeWriteReq; //!< ATT Execute Write Request
+ gattReadByTypeReq_t gattReadByTypeReq; //!< GATT Read By Type Request
+ gattWriteLongReq_t gattWriteLongReq; //!< GATT Long Write Request
+ gattReliableWritesReq_t gattReliableWritesReq; //!< GATT Reliable Writes Request
+
+ // Response messages
+ attErrorRsp_t errorRsp; //!< ATT Error Response
+ attExchangeMTURsp_t exchangeMTURsp; //!< ATT Exchange MTU Response
+ attFindInfoRsp_t findInfoRsp; //!< ATT Find Information Response
+ attFindByTypeValueRsp_t findByTypeValueRsp; //!< ATT Find By Type Vaue Response
+ attReadByTypeRsp_t readByTypeRsp; //!< ATT Read By Type Response
+ attReadRsp_t readRsp; //!< ATT Read Response
+ attReadBlobRsp_t readBlobRsp; //!< ATT Read Blob Response
+ attReadMultiRsp_t readMultiRsp; //!< ATT Read Multiple Response
+ attReadByGrpTypeRsp_t readByGrpTypeRsp; //!< ATT Read By Group Type Response
+ attPrepareWriteRsp_t prepareWriteRsp; //!< ATT Prepare Write Response
+
+ // Indication and Notification messages
+ attHandleValueNoti_t handleValueNoti; //!< ATT Handle Value Notification
+ attHandleValueInd_t handleValueInd; //!< ATT Handle Value Indication
+} gattMsg_t;
+
+/**
+ * GATT OSAL GATT_MSG_EVENT message format. This message is used to forward an
+ * incoming attribute protocol/profile message up to upper layer application.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GATT_MSG_EVENT and status
+ uint16 connHandle; //!< Connection message was received on
+ uint8 method; //!< Type of message
+ gattMsg_t msg; //!< Attribute protocol/profile message
+} gattMsgEvent_t;
+
+/**
+ * GATT Attribute Type format.
+ */
+typedef struct
+{
+ uint8 len; //!< Length of UUID
+ const uint8 *uuid; //!< Pointer to UUID
+} gattAttrType_t;
+
+/**
+ * GATT Attribute format.
+ */
+typedef struct attAttribute_t
+{
+ gattAttrType_t type; //!< Attribute type (2 or 16 octet UUIDs)
+ uint8 permissions; //!< Attribute permissions
+ uint16 handle; //!< Attribute handle - assigned internally by attribute server
+ uint8* const pValue; //!< Attribute value - encoding of the octet array is defined in
+ //!< the applicable profile. The maximum length of an attribute
+ //!< value shall be 512 octets.
+} gattAttribute_t;
+
+/**
+ * GATT Service format.
+ */
+typedef struct
+{
+ uint16 numAttrs; //!< Number of attributes in attrs
+
+ /** Array of attribute records.
+ * NOTE: The list must start with a Service attribute followed by
+ * all attributes associated with this Service attribute.
+ */
+ gattAttribute_t *attrs;
+} gattService_t;
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/*-------------------------------------------------------------------
+ * GATT Client Public APIs
+ */
+
+/**
+ * @defgroup GATT_CLIENT_API GATT Client API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Initialize the Generic Attribute Profile Client.
+ *
+ * @return SUCCESS
+ */
+extern bStatus_t GATT_InitClient( void );
+
+/**
+ * @brief Register to receive incoming ATT Indications or Notifications
+ * of attribute values.
+ *
+ * @param taskId – task to forward indications or notifications to
+ *
+ * @return void
+ */
+extern void GATT_RegisterForInd( uint8 taskId );
+
+/**
+ * @brief The Prepare Write Request is used to request the server to
+ * prepare to write the value of an attribute.
+ *
+ * Note: This function is needed only for GATT testing.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_PrepareWriteReq( uint16 connHandle, attPrepareWriteReq_t *pReq, uint8 taskId );
+
+/**
+ * @brief The Execute Write Request is used to request the server to
+ * write or cancel the write of all the prepared values currently
+ * held in the prepare queue from this client.
+ *
+ * Note: This function is needed only for GATT testing.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_ExecuteWriteReq( uint16 connHandle, attExecuteWriteReq_t *pReq, uint8 taskId );
+
+/**
+ * @}
+ */
+
+/*-------------------------------------------------------------------
+ * GATT Server Public APIs
+ */
+
+/**
+ * @defgroup GATT_SERVER_API GATT Server API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Initialize the Generic Attribute Profile Server.
+ *
+ * @return SUCCESS
+ */
+extern bStatus_t GATT_InitServer( void );
+
+/**
+ * @brief Register a service attribute list with the GATT Server. A service
+ * is composed of characteristics or references to other services.
+ * Each characteristic contains a value and may contain optional
+ * information about the value. There are two types of services:
+ * primary service and secondary service.
+ *
+ * A service definition begins with a service declaration and ends
+ * before the next service declaration or the maximum Attribute Handle.
+ *
+ * A characteristic definition begins with a characteristic declaration
+ * and ends before the next characteristic or service declaration or
+ * maximum Attribute Handle.
+ *
+ * The attribute server will only keep a pointer to the attribute
+ * list, so the calling application will have to maintain the code
+ * and RAM associated with this list.
+ *
+ * @param pService - pointer to service attribute list to be registered
+ *
+ * @return SUCCESS: Service registered successfully.
+ * INVALIDPARAMETER: Invalid service field.
+ * FAILURE: Not enough attribute handles available.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t GATT_RegisterService( gattService_t *pService );
+
+/**
+ * @brief Deregister a service attribute list with the GATT Server.
+ *
+ * NOTE: It's the caller's responsibility to free the service attribute
+ * list returned from this API.
+ *
+ * @param handle - handle of service to be deregistered
+ * @param pService - pointer to deregistered service (to be returned)
+ *
+ * @return SUCCESS: Service deregistered successfully.
+ * FAILURE: Service not found.
+ */
+extern bStatus_t GATT_DeregisterService( uint16 handle, gattService_t *pService );
+
+/**
+ * @brief Register to receive incoming ATT Requests.
+ *
+ * @param taskId – task to forward requests to
+ *
+ * @return void
+ */
+extern void GATT_RegisterForReq( uint8 taskId );
+
+/**
+ * @brief Verify the permissions of an attribute for reading.
+ *
+ * @param connHandle - connection to use
+ * @param permissions - attribute permissions
+ *
+ * @return SUCCESS: Attribute can be read.
+ * ATT_ERR_READ_NOT_PERMITTED: Attribute cannot be read.
+ * ATT_ERR_INSUFFICIENT_AUTHEN: Attribute requires authentication.
+ * ATT_ERR_INSUFFICIENT_KEY_SIZE: Key Size used for encrypting is insufficient.
+ * ATT_ERR_INSUFFICIENT_ENCRYPT: Attribute requires encryption.
+ */
+extern bStatus_t GATT_VerifyReadPermissions( uint16 connHandle, uint8 permissions );
+
+/**
+ * @brief Verify the permissions of an attribute for writing.
+ *
+ * @param connHandle - connection to use
+ * @param permissions - attribute permissions
+ * @param pReq - pointer to write request
+ *
+ * @return SUCCESS: Attribute can be written.
+ * ATT_ERR_READ_NOT_PERMITTED: Attribute cannot be written.
+ * ATT_ERR_INSUFFICIENT_AUTHEN: Attribute requires authentication.
+ * ATT_ERR_INSUFFICIENT_KEY_SIZE: Key Size used for encrypting is insufficient.
+ * ATT_ERR_INSUFFICIENT_ENCRYPT: Attribute requires encryption.
+ */
+extern bStatus_t GATT_VerifyWritePermissions( uint16 connHandle, uint8 permissions, attWriteReq_t *pReq );
+
+/**
+ * @brief Send out a Service Changed Indication.
+ *
+ * @param connHandle - connection to use
+ * @param taskId - task to be notified of confirmation
+ *
+ * @return SUCCESS: Indication was sent successfully.
+ * FAILURE: Service Changed attribute not found.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A confirmation is pending with this client.
+ */
+extern uint8 GATT_ServiceChangedInd( uint16 connHandle, uint8 taskId );
+
+/**
+ * @brief Find the attribute record for a given handle and UUID.
+ *
+ * @param startHandle - first handle to look for
+ * @param endHandle - last handle to look for
+ * @param pUUID - pointer to UUID to look for
+ * @param len - length of UUID
+ * @param pHandle - handle of owner of attribute (to be returned)
+ *
+ * @return Pointer to attribute record. NULL, otherwise.
+ */
+extern gattAttribute_t *GATT_FindHandleUUID( uint16 startHandle, uint16 endHandle, const uint8 *pUUID,
+ uint16 len, uint16 *pHandle );
+/**
+ * @brief Find the attribute record for a given handle
+ *
+ * @param handle - handle to look for
+ * @param pHandle - handle of owner of attribute (to be returned)
+ *
+ * @return Pointer to attribute record. NULL, otherwise.
+ */
+extern gattAttribute_t *GATT_FindHandle( uint16 handle, uint16 *pHandle );
+
+/**
+ * @brief Find the next attribute of the same type for a given attribute.
+ *
+ * @param pAttr - pointer to attribute to find a next for
+ * @param endHandle - last handle to look for
+ * @param service - handle of owner service
+ * @param pLastHandle - handle of last attribute (to be returned)
+ *
+ * @return Pointer to next attribute record. NULL, otherwise.
+ */
+extern gattAttribute_t *GATT_FindNextAttr( gattAttribute_t *pAttr, uint16 endHandle,
+ uint16 service, uint16 *pLastHandle );
+/**
+ * @brief Get the number of attributes for a given service
+ *
+ * @param handle - service handle to look for
+ *
+ * @return Number of attributes. 0, otherwise.
+ */
+extern uint16 GATT_ServiceNumAttrs( uint16 handle );
+
+/**
+ * @}
+ */
+
+/*-------------------------------------------------------------------
+ * GATT Server Sub-Procedure APIs
+ */
+
+/**
+ * @defgroup GATT_SERVER_SUB_PROCEDURE_API GATT Server Sub-Procedure API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief This sub-procedure is used when a server is configured to
+ * indicate a characteristic value to a client and expects an
+ * attribute protocol layer acknowledgement that the indication
+ * was successfully received.
+ *
+ * The ATT Handle Value Indication is used in this sub-procedure.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive an OSAL GATT_MSG_EVENT message.
+ * The type of the message will be ATT_HANDLE_VALUE_CFM.
+ *
+ * Note: This sub-procedure is complete when ATT_HANDLE_VALUE_CFM
+ * (with SUCCESS or bleTimeout status) is received by the
+ * calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param pInd - pointer to indication to be sent
+ * @param authenticated - whether an authenticated link is required
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Indication was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A confirmation is pending with this client.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_Indication( uint16 connHandle, attHandleValueInd_t *pInd,
+ uint8 authenticated, uint8 taskId );
+/**
+ * @brief This sub-procedure is used when a server is configured to
+ * notify a characteristic value to a client without expecting
+ * any attribute protocol layer acknowledgement that the
+ * notification was successfully received.
+ *
+ * The ATT Handle Value Notification is used in this sub-procedure.
+ *
+ * Note: A notification may be sent at any time and does not
+ * invoke a confirmation.
+ *
+ * No confirmation will be sent to the calling application task for
+ * this sub-procedure.
+ *
+ * @param connHandle - connection to use
+ * @param pNoti - pointer to notification to be sent
+ * @param authenticated - whether an authenticated link is required
+ *
+ * @return SUCCESS: Notification was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_Notification( uint16 connHandle, attHandleValueNoti_t *pNoti,
+ uint8 authenticated );
+/**
+ * @}
+ */
+
+/*-------------------------------------------------------------------
+ * GATT Client Sub-Procedure APIs
+ */
+
+/**
+ * @defgroup GATT_CLIENT_SUB_PROCEDURE_API GATT Client Sub-Procedure API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief This sub-procedure is used by the client to set the ATT_MTU
+ * to the maximum possible value that can be supported by both
+ * devices when the client supports a value greater than the
+ * default ATT_MTU for the Attribute Protocol. This sub-procedure
+ * shall only be initiated once during a connection.
+ *
+ * The ATT Exchange MTU Request is used by this sub-procedure.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive an OSAL GATT_MSG_EVENT message.
+ * The type of the message will be either ATT_EXCHANGE_MTU_RSP or
+ * ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_EXCHANGE_MTU_RSP
+ * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
+ * SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_ExchangeMTU( uint16 connHandle, attExchangeMTUReq_t *pReq, uint8 taskId );
+
+/**
+ * @brief This sub-procedure is used by a client to discover all
+ * the primary services on a server.
+ *
+ * The ATT Read By Group Type Request is used with the Attribute
+ * Type parameter set to the UUID for "Primary Service". The
+ * Starting Handle is set to 0x0001 and the Ending Handle is
+ * set to 0xFFFF.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive multiple OSAL GATT_MSG_EVENT messages.
+ * The type of the messages will be either ATT_READ_BY_GRP_TYPE_RSP
+ * or ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_READ_BY_GRP_TYPE_RSP
+ * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
+ * (with SUCCESS status) is received by the calling application
+ * task.
+ *
+ * @param connHandle - connection to use
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_DiscAllPrimaryServices( uint16 connHandle, uint8 taskId );
+
+/**
+ * @brief This sub-procedure is used by a client to discover a specific
+ * primary service on a server when only the Service UUID is
+ * known. The primary specific service may exist multiple times
+ * on a server. The primary service being discovered is identified
+ * by the service UUID.
+ *
+ * The ATT Find By Type Value Request is used with the Attribute
+ * Type parameter set to the UUID for "Primary Service" and the
+ * Attribute Value set to the 16-bit Bluetooth UUID or 128-bit
+ * UUID for the specific primary service. The Starting Handle shall
+ * be set to 0x0001 and the Ending Handle shall be set to 0xFFFF.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive multiple OSAL GATT_MSG_EVENT messages.
+ * The type of the messages will be either ATT_FIND_BY_TYPE_VALUE_RSP
+ * or ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_FIND_BY_TYPE_VALUE_RSP
+ * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
+ * (with SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param pValue - pointer to value to look for
+ * @param len - length of value
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_DiscPrimaryServiceByUUID( uint16 connHandle, uint8 *pValue,
+ uint8 len, uint8 taskId );
+/**
+ * @brief This sub-procedure is used by a client to find include
+ * service declarations within a service definition on a
+ * server. The service specified is identified by the service
+ * handle range.
+ *
+ * The ATT Read By Type Request is used with the Attribute
+ * Type parameter set to the UUID for "Included Service". The
+ * Starting Handle is set to starting handle of the specified
+ * service and the Ending Handle is set to the ending handle
+ * of the specified service.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive multiple OSAL GATT_MSG_EVENT messages.
+ * The type of the messages will be either ATT_READ_BY_TYPE_RSP
+ * or ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_READ_BY_TYPE_RSP
+ * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
+ * (with SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param startHandle - starting handle
+ * @param endHandle - end handle
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_FindIncludedServices( uint16 connHandle, uint16 startHandle,
+ uint16 endHandle, uint8 taskId );
+/**
+ * @brief This sub-procedure is used by a client to find all the
+ * characteristic declarations within a service definition on
+ * a server when only the service handle range is known. The
+ * service specified is identified by the service handle range.
+ *
+ * The ATT Read By Type Request is used with the Attribute Type
+ * parameter set to the UUID for "Characteristic". The Starting
+ * Handle is set to starting handle of the specified service and
+ * the Ending Handle is set to the ending handle of the specified
+ * service.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive multiple OSAL GATT_MSG_EVENT messages.
+ * The type of the messages will be either ATT_READ_BY_TYPE_RSP
+ * or ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_READ_BY_TYPE_RSP
+ * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
+ * (with SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param startHandle - starting handle
+ * @param endHandle - end handle
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_DiscAllChars( uint16 connHandle, uint16 startHandle,
+ uint16 endHandle, uint8 taskId );
+/**
+ * @brief This sub-procedure is used by a client to discover service
+ * characteristics on a server when only the service handle
+ * ranges are known and the characteristic UUID is known.
+ * The specific service may exist multiple times on a server.
+ * The characteristic being discovered is identified by the
+ * characteristic UUID.
+ *
+ * The ATT Read By Type Request is used with the Attribute Type
+ * is set to the UUID for "Characteristic" and the Starting
+ * Handle and Ending Handle parameters is set to the service
+ * handle range.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive multiple OSAL GATT_MSG_EVENT messages.
+ * The type of the messages will be either ATT_READ_BY_TYPE_RSP
+ * or ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_READ_BY_TYPE_RSP
+ * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
+ * (with SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_DiscCharsByUUID( uint16 connHandle, attReadByTypeReq_t *pReq, uint8 taskId );
+
+/**
+ * @brief This sub-procedure is used by a client to find all the
+ * characteristic descriptor’s Attribute Handles and Attribute
+ * Types within a characteristic definition when only the
+ * characteristic handle range is known. The characteristic
+ * specified is identified by the characteristic handle range.
+ *
+ * The ATT Find Information Request is used with the Starting
+ * Handle set to starting handle of the specified characteristic
+ * and the Ending Handle set to the ending handle of the specified
+ * characteristic. The UUID Filter parameter is NULL (zero length).
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive multiple OSAL GATT_MSG_EVENT messages.
+ * The type of the messages will be either ATT_FIND_INFO_RSP or
+ * ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_FIND_INFO_RSP
+ * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
+ * (with SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param startHandle - starting handle
+ * @param endHandle - end handle
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_DiscAllCharDescs( uint16 connHandle, uint16 startHandle,
+ uint16 endHandle, uint8 taskId );
+/**
+ * @brief This sub-procedure is used to read a Characteristic Value
+ * from a server when the client knows the Characteristic Value
+ * Handle. The ATT Read Request is used with the Attribute Handle
+ * parameter set to the Characteristic Value Handle. The Read
+ * Response returns the Characteristic Value in the Attribute
+ * Value parameter.
+ *
+ * The Read Response only contains a Characteristic Value that
+ * is less than or equal to (ATT_MTU – 1) octets in length. If
+ * the Characteristic Value is greater than (ATT_MTU – 1) octets
+ * in length, the Read Long Characteristic Value procedure may
+ * be used if the rest of the Characteristic Value is required.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive an OSAL GATT_MSG_EVENT message.
+ * The type of the message will be either ATT_READ_RSP or
+ * ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_READ_RSP
+ * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
+ * SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_ReadCharValue( uint16 connHandle, attReadReq_t *pReq, uint8 taskId );
+
+/**
+ * @brief This sub-procedure is used to read a Characteristic Value
+ * from a server when the client only knows the characteristic
+ * UUID and does not know the handle of the characteristic.
+ *
+ * The ATT Read By Type Request is used to perform the sub-procedure.
+ * The Attribute Type is set to the known characteristic UUID and
+ * the Starting Handle and Ending Handle parameters shall be set
+ * to the range over which this read is to be performed. This is
+ * typically the handle range for the service in which the
+ * characteristic belongs.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive an OSAL GATT_MSG_EVENT messages.
+ * The type of the message will be either ATT_READ_BY_TYPE_RSP
+ * or ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_READ_BY_TYPE_RSP
+ * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
+ * SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_ReadUsingCharUUID( uint16 connHandle, attReadByTypeReq_t *pReq, uint8 taskId );
+/**
+ * @brief This sub-procedure is used to read a Characteristic Value from
+ * a server when the client knows the Characteristic Value Handle
+ * and the length of the Characteristic Value is longer than can
+ * be sent in a single Read Response Attribute Protocol message.
+ *
+ * The ATT Read Blob Request is used in this sub-procedure.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive multiple OSAL GATT_MSG_EVENT messages.
+ * The type of the messages will be either ATT_READ_BLOB_RSP or
+ * ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_READ_BLOB_RSP
+ * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
+ * (with SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_ReadLongCharValue( uint16 connHandle, attReadBlobReq_t *pReq, uint8 taskId );
+
+/**
+ * @brief This sub-procedure is used to read multiple Characteristic Values
+ * from a server when the client knows the Characteristic Value
+ * Handles. The Attribute Protocol Read Multiple Requests is used
+ * with the Set Of Handles parameter set to the Characteristic Value
+ * Handles. The Read Multiple Response returns the Characteristic
+ * Values in the Set Of Values parameter.
+ *
+ * The ATT Read Multiple Request is used in this sub-procedure.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive an OSAL GATT_MSG_EVENT message.
+ * The type of the message will be either ATT_READ_MULTI_RSP
+ * or ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_READ_MULTI_RSP
+ * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
+ * SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_ReadMultiCharValues( uint16 connHandle, attReadMultiReq_t *pReq, uint8 taskId );
+
+/**
+ * @brief This sub-procedure is used to write a Characteristic Value
+ * to a server when the client knows the Characteristic Value
+ * Handle and the client does not need an acknowledgement that
+ * the write was successfully performed. This sub-procedure
+ * only writes the first (ATT_MTU – 3) octets of a Characteristic
+ * Value. This sub-procedure can not be used to write a long
+ * characteristic; instead the Write Long Characteristic Values
+ * sub-procedure should be used.
+ *
+ * The ATT Write Command is used for this sub-procedure. The
+ * Attribute Handle parameter shall be set to the Characteristic
+ * Value Handle. The Attribute Value parameter shall be set to
+ * the new Characteristic Value.
+ *
+ * No response will be sent to the calling application task for this
+ * sub-procedure. If the Characteristic Value write request is the
+ * wrong size, or has an invalid value as defined by the profile,
+ * then the write will not succeed and no error will be generated
+ * by the server.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to command to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_WriteNoRsp( uint16 connHandle, attWriteReq_t *pReq );
+
+/**
+ * @brief This sub-procedure is used to write a Characteristic Value
+ * to a server when the client knows the Characteristic Value
+ * Handle and the ATT Bearer is not encrypted. This sub-procedure
+ * shall only be used if the Characteristic Properties authenticated
+ * bit is enabled and the client and server device share a bond as
+ * defined in the GAP.
+ *
+ * This sub-procedure only writes the first (ATT_MTU – 15) octets
+ * of an Attribute Value. This sub-procedure cannot be used to
+ * write a long Attribute.
+ *
+ * The ATT Write Command is used for this sub-procedure. The
+ * Attribute Handle parameter shall be set to the Characteristic
+ * Value Handle. The Attribute Value parameter shall be set to
+ * the new Characteristic Value authenticated by signing the
+ * value, as defined in the Security Manager.
+ *
+ * No response will be sent to the calling application task for this
+ * sub-procedure. If the authenticated Characteristic Value that is
+ * written is the wrong size, or has an invalid value as defined by
+ * the profile, or the signed value does not authenticate the client,
+ * then the write will not succeed and no error will be generated by
+ * the server.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to command to be sent
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleLinkEncrypted: Connection is already encrypted.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_SignedWriteNoRsp( uint16 connHandle, attWriteReq_t *pReq );
+
+/**
+ * @brief This sub-procedure is used to write a characteristic value
+ * to a server when the client knows the characteristic value
+ * handle. This sub-procedure only writes the first (ATT_MTU-3)
+ * octets of a characteristic value. This sub-procedure can not
+ * be used to write a long attribute; instead the Write Long
+ * Characteristic Values sub-procedure should be used.
+ *
+ * The ATT Write Request is used in this sub-procedure. The
+ * Attribute Handle parameter shall be set to the Characteristic
+ * Value Handle. The Attribute Value parameter shall be set to
+ * the new characteristic.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive an OSAL GATT_MSG_EVENT message.
+ * The type of the message will be either ATT_WRITE_RSP
+ * or ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_WRITE_RSP
+ * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
+ * SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_WriteCharValue( uint16 connHandle, attWriteReq_t *pReq, uint8 taskId );
+
+/**
+ * @brief This sub-procedure is used to write a Characteristic Value to
+ * a server when the client knows the Characteristic Value Handle
+ * but the length of the Characteristic Value is longer than can
+ * be sent in a single Write Request Attribute Protocol message.
+ *
+ * The ATT Prepare Write Request and Execute Write Request are
+ * used to perform this sub-procedure.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive multiple OSAL GATT_MSG_EVENT messages.
+ * The type of the messages will be either ATT_PREPARE_WRITE_RSP,
+ * ATT_EXECUTE_WRITE_RSP or ATT_ERROR_RSP (if an error occurred on
+ * the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_PREPARE_WRITE_RSP
+ * (with bleTimeout status), ATT_EXECUTE_WRITE_RSP (with SUCCESS
+ * or bleTimeout status), or ATT_ERROR_RSP (with SUCCESS status)
+ * is received by the calling application task.
+ *
+ * Note: The 'pReq->pValue' pointer will be freed when the sub-procedure
+ * is complete.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_WriteLongCharValue( uint16 connHandle, gattPrepareWriteReq_t *pReq, uint8 taskId );
+
+/**
+ * @brief This sub-procedure is used to write a Characteristic Value to
+ * a server when the client knows the Characteristic Value Handle,
+ * and assurance is required that the correct Characteristic Value
+ * is going to be written by transferring the Characteristic Value
+ * to be written in both directions before the write is performed.
+ * This sub-procedure can also be used when multiple values must
+ * be written, in order, in a single operation.
+ *
+ * The sub-procedure has two phases, the first phase prepares the
+ * characteristic values to be written. Once this is complete,
+ * the second phase performs the execution of all of the prepared
+ * characteristic value writes on the server from this client.
+ *
+ * In the first phase, the ATT Prepare Write Request is used.
+ * In the second phase, the attribute protocol Execute Write
+ * Request is used.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive multiple OSAL GATT_MSG_EVENT messages.
+ * The type of the messages will be either ATT_PREPARE_WRITE_RSP,
+ * ATT_EXECUTE_WRITE_RSP or ATT_ERROR_RSP (if an error occurred on
+ * the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_PREPARE_WRITE_RSP
+ * (with bleTimeout status), ATT_EXECUTE_WRITE_RSP (with SUCCESS
+ * or bleTimeout status), or ATT_ERROR_RSP (with SUCCESS status)
+ * is received by the calling application task.
+ *
+ * Note: The 'pReqs' pointer will be freed when the sub-procedure is
+ * complete.
+ *
+ * @param connHandle - connection to use
+ * @param pReqs - pointer to requests to be sent (must be allocated)
+ * @param numReqs - number of requests in pReq
+ * @param flags - execute write request flags
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_ReliableWrites( uint16 connHandle, attPrepareWriteReq_t *pReqs,
+ uint8 numReqs, uint8 flags, uint8 taskId );
+/**
+ * @brief This sub-procedure is used to read a characteristic descriptor
+ * from a server when the client knows the characteristic descriptor
+ * declaration’s Attribute handle.
+ *
+ * The ATT Read Request is used for this sub-procedure. The Read
+ * Request is used with the Attribute Handle parameter set to the
+ * characteristic descriptor handle. The Read Response returns the
+ * characteristic descriptor value in the Attribute Value parameter.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive an OSAL GATT_MSG_EVENT message.
+ * The type of the message will be either ATT_READ_RSP or
+ * ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_READ_RSP
+ * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
+ * SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_ReadCharDesc( uint16 connHandle, attReadReq_t *pReq, uint8 taskId );
+
+/**
+ * @brief This sub-procedure is used to read a characteristic descriptor
+ * from a server when the client knows the characteristic descriptor
+ * declaration’s Attribute handle and the length of the characteristic
+ * descriptor declaration is longer than can be sent in a single Read
+ * Response attribute protocol message.
+ *
+ * The ATT Read Blob Request is used to perform this sub-procedure.
+ * The Attribute Handle parameter shall be set to the characteristic
+ * descriptor handle. The Value Offset parameter shall be the offset
+ * within the characteristic descriptor to be read.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive multiple OSAL GATT_MSG_EVENT messages.
+ * The type of the messages will be either ATT_READ_BLOB_RSP or
+ * ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_READ_BLOB_RSP
+ * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
+ * (with SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_ReadLongCharDesc( uint16 connHandle, attReadBlobReq_t *pReq, uint8 taskId );
+
+/**
+ * @brief This sub-procedure is used to write a characteristic
+ * descriptor value to a server when the client knows the
+ * characteristic descriptor handle.
+ *
+ * The ATT Write Request is used for this sub-procedure. The
+ * Attribute Handle parameter shall be set to the characteristic
+ * descriptor handle. The Attribute Value parameter shall be
+ * set to the new characteristic descriptor value.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive an OSAL GATT_MSG_EVENT message.
+ * The type of the message will be either ATT_WRITE_RSP
+ * or ATT_ERROR_RSP (if an error occurred on the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_WRITE_RSP
+ * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP (with
+ * SUCCESS status) is received by the calling application task.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_WriteCharDesc( uint16 connHandle, attWriteReq_t *pReq, uint8 taskId );
+
+/**
+ * @brief This sub-procedure is used to write a Characteristic Value to
+ * a server when the client knows the Characteristic Value Handle
+ * but the length of the Characteristic Value is longer than can
+ * be sent in a single Write Request Attribute Protocol message.
+ *
+ * The ATT Prepare Write Request and Execute Write Request are
+ * used to perform this sub-procedure.
+ *
+ * If the return status from this function is SUCCESS, the calling
+ * application task will receive multiple OSAL GATT_MSG_EVENT messages.
+ * The type of the messages will be either ATT_PREPARE_WRITE_RSP,
+ * ATT_EXECUTE_WRITE_RSP or ATT_ERROR_RSP (if an error occurred on
+ * the server).
+ *
+ * Note: This sub-procedure is complete when either ATT_PREPARE_WRITE_RSP
+ * (with bleTimeout status), ATT_EXECUTE_WRITE_RSP (with SUCCESS
+ * or bleTimeout status), or ATT_ERROR_RSP (with SUCCESS status)
+ * is received by the calling application task.
+ *
+ * Note: The 'pReq->pValue' pointer will be freed when the sub-procedure
+ * is complete.
+ *
+ * @param connHandle - connection to use
+ * @param pReq - pointer to request to be sent
+ * @param taskId - task to be notified of response
+ *
+ * @return SUCCESS: Request was sent successfully.
+ * INVALIDPARAMETER: Invalid connection handle or request field.v
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A response is pending with this server.
+ * bleMemAllocError: Memory allocation error occurred.
+ * bleTimeout: Previous transaction timed out.
+ */
+extern bStatus_t GATT_WriteLongCharDesc( uint16 connHandle, gattPrepareWriteReq_t *pReq, uint8 taskId );
+
+/**
+ * @}
+ */
+
+/*-------------------------------------------------------------------
+ * Internal API - This function is only called from GATT Qualification modules.
+ */
+
+ /**
+ * @internal
+ *
+ * @brief Set the next available attribute handle.
+ *
+ * @param handle - next attribute handle.
+ *
+ * @return none
+ */
+extern void GATT_SetNextHandle( uint16 handle );
+
+/*-------------------------------------------------------------------
+ * TASK API - These functions must only be called by OSAL.
+ */
+
+/**
+ * @internal
+ *
+ * @brief GATT Task initialization function.
+ *
+ * @param taskId - GATT task ID.
+ *
+ * @return void
+ */
+extern void GATT_Init( uint8 taskId );
+
+/**
+ * @internal
+ *
+ * @brief GATT Task event processing function.
+ *
+ * @param taskId - GATT task ID
+ * @param events - GATT events.
+ *
+ * @return events not processed
+ */
+extern uint16 GATT_ProcessEvent( uint8 taskId, uint16 events );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 38 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\include\\gattservapp.h"
+/**
+ @headerfile: gattservapp.h
+ $Date: 2009-06-29 16:20:52 -0700 (Mon, 29 Jun 2009) $
+ $Revision: 20240 $
+
+ @mainpage BLE GATT Server Application API
+
+ Description: This file contains the GATT Server Application (GATTServApp)
+ definitions and prototypes.
+
+ \image html HighLevelGATTServApp.PNG
+
+
+ Functional Description
+ The GATT Server Application (GATTServApp) provides the following abilities:
+
+ - Service Registration - This API is used to register a service's
+ attribute list and callback functions with the GATT Server Application.
+ - Service Deregistration - This API is used to deregister a service's
+ attribute list and callback functions from the GATT Server Application.
+ - GATT Service Addition - This API is the add function for the GATT
+ Service. It registers the GATT Service's attribute list and callback
+ functions with the GATT Server Application.
+ - GATT Service Deletion - This API is the delete function for the
+ GATT Service. It deregisters the GATT Service's attribute list and
+ callback functions from the GATT Server Application.
+
+
+ Service Attribute List
+ A profile may support one or more services. Each of the services may support
+ characteristics or references to other services. Each characteristic contains
+ a value and may contain optional descriptors. The service, characteristic,
+ characteristic value and descriptors are all stored as attributes on the server.
+ The service attribute list to be registered with the GATT Server must start
+ with a Service attribute followed by all the attributes associated with that
+ Service attribute.
+
+
+ \image html GATTAttributeList.PNG
+
+
+ Service Callback Functions
+ The encoding of each attribute value is defined in the applicable profile.
+ The GATT Server doesn't directly access the attribute value for reading
+ or writing. It uses the Read and Write callback functions provided by the
+ registering profile to execute the incoming Attribute Protocol (ATT) Read
+ and Write request respectively.
+
+
+ Copyright 2009 - 2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/** @defgroup GATT_SERV_MSG_EVENT_DEFINES GATT Server Message IDs
+ * @{
+ */
+
+
+
+/** @} End GATT_SERV_MSG_EVENT_DEFINES */
+
+
+/** @defgroup GATT_PROP_BITMAPS_DEFINES GATT Characteristic Properties Bit Fields
+ * @{
+ */
+
+#line 120 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\include\\gattservapp.h"
+
+/** @} End GATT_PROP_BITMAPS_DEFINES */
+
+/** @defgroup GATT_EXT_PROP_BITMAPS_DEFINES GATT Characteristic Extended Properties Bit Fields
+ * @{
+ */
+
+
+
+
+/** @} End GATT_EXT_PROP_BITMAPS_DEFINES */
+
+/** @defgroup GATT_CLIENT_CFG_BITMAPS_DEFINES GATT Client Characteristic Configuration Bit Fields
+ * @{
+ */
+
+
+
+
+/** @} End GATT_CLIENT_CFG_BITMAPS_DEFINES */
+
+/** @defgroup GATT_SERV_CFG_BITMAPS_DEFINES GATT Server Characteristic Configuration Bit Fields
+ * @{
+ */
+
+
+
+/** @} End GATT_SERV_CFG_BITMAPS_DEFINES */
+
+
+
+/** @defgroup GATT_FORMAT_TYPES_DEFINES GATT Characteristic Format Types
+ * @{
+ */
+
+#line 182 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\include\\gattservapp.h"
+
+/** @} End GATT_FORMAT_TYPES_DEFINES */
+
+/** @defgroup GATT_NS_TYPES_DEFINES GATT Namespace Types
+ * @{
+ */
+
+
+
+
+/** @} End GATT_NS_TYPES_DEFINES */
+
+/** @defgroup GATT_NS_BT_DESC_DEFINES GATT Bluetooth Namespace Descriptions
+ * @{
+ */
+
+
+
+/** @} End GATT_NS_BT_DESC_DEFINES */
+
+// All profile services bit fields
+
+
+// GATT Services bit fields
+
+
+#line 216 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\include\\gattservapp.h"
+
+// GATT Server Parameters
+
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+// The number of attribute records in a given attribute table
+
+
+// The handle of a service is the handle of the first attribute
+
+
+// The handle of the first included service (i = 1) is the value of the second attribute
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/**
+ * @defgroup GATT_SERV_APP_CB_API GATT Server App Callback API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Callback function prototype to read an attribute value.
+ *
+ * @param connHandle - connection request was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be read (to be returned)
+ * @param pLen - length of data (to be returned)
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return SUCCESS: Read was successfully.
+ * Error, otherwise: ref ATT_ERR_CODE_DEFINES.
+ */
+typedef bStatus_t (*pfnGATTReadAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 *pLen, uint16 offset,
+ uint8 maxLen );
+/**
+ * @brief Callback function prototype to write an attribute value.
+ *
+ * @param connHandle - connection request was received on
+ * @param pAttr - pointer to attribute
+ * @param pValue - pointer to data to be written
+ * @param pLen - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return SUCCESS: Write was successfully.
+ * Error, otherwise: ref ATT_ERR_CODE_DEFINES.
+ */
+typedef bStatus_t (*pfnGATTWriteAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset );
+/**
+ * @brief Callback function prototype to authorize a Read or Write operation
+ * on a given attribute.
+ *
+ * @param connHandle - connection request was received on
+ * @param pAttr - pointer to attribute
+ * @param opcode - request opcode (ATT_READ_REQ or ATT_WRITE_REQ)
+ *
+ * @return SUCCESS: Operation authorized.
+ * ATT_ERR_INSUFFICIENT_AUTHOR: Authorization required.
+ */
+typedef bStatus_t (*pfnGATTAuthorizeAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 opcode );
+/**
+ * @}
+ */
+
+/**
+ * GATT Structure for Characteristic Presentation Format Value.
+ */
+typedef struct
+{
+ uint8 format; //!< Format of the value of this characteristic
+ uint8 exponent; //!< A sign integer which represents the exponent of an integer
+ uint16 unit; //!< Unit of this attribute as defined in the data dictionary
+ uint8 nameSpace; //!< Name space of the description
+ uint16 desc; //!< Description of this attribute as defined in a higher layer profile
+} gattCharFormat_t;
+
+/**
+ * GATT Structure for Client Characteristic Configuration.
+ */
+typedef struct
+{
+ uint16 connHandle; //!< Client connection handle
+ uint8 value; //!< Characteristic configuration value for this client
+} gattCharCfg_t;
+
+/**
+ * GATT Structure for service callback functions - must be setup by the application
+ * and used when GATTServApp_RegisterService() is called.
+ */
+typedef struct
+{
+ pfnGATTReadAttrCB_t pfnReadAttrCB; //!< Read callback function pointer
+ pfnGATTWriteAttrCB_t pfnWriteAttrCB; //!< Write callback function pointer
+ pfnGATTAuthorizeAttrCB_t pfnAuthorizeAttrCB; //!< Authorization callback function pointer
+} gattServiceCBs_t;
+
+/**
+ * GATT Server App event header format.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GATT_SERV_MSG_EVENT and status
+ uint16 connHandle; //!< Connection message was received on
+ uint8 method; //!< GATT type of command. Ref: @ref GATT_SERV_MSG_EVENT_DEFINES
+} gattEventHdr_t;
+
+/**
+ * GATT_CLIENT_CHAR_CFG_UPDATED_EVENT message format. This message is sent to
+ * the app when a Client Characteristic Configuration is updated.
+ */
+typedef struct
+{
+ osal_event_hdr_t hdr; //!< GATT_SERV_MSG_EVENT and status
+ uint16 connHandle; //!< Connection message was received on
+ uint8 method; //!< GATT_CLIENT_CHAR_CFG_UPDATED_EVENT
+ uint16 attrHandle; //!< attribute handle
+ uint16 value; //!< attribute new value
+} gattClientCharCfgUpdatedEvent_t;
+
+
+/*********************************************************************
+ * VARIABLES
+ */
+
+/*********************************************************************
+ * API FUNCTIONS
+ */
+
+/**
+ * @defgroup GATT_SERV_APP_API GATT Server App API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Register your task ID to receive event messages
+ * from the GATT Server Application.
+ *
+ * @param taskID - Default task ID to send events.
+ *
+ * @return none
+ */
+extern void GATTServApp_RegisterForMsg( uint8 taskID );
+
+/**
+ * @brief Register a service's attribute list and callback functions with
+ * the GATT Server Application.
+ *
+ * @param pAttrs - Array of attribute records to be registered
+ * @param numAttrs - Number of attributes in array
+ * @param pServiceCBs - Service callback function pointers
+ *
+ * @return SUCCESS: Service registered successfully.
+ * INVALIDPARAMETER: Invalid service field.
+ * FAILURE: Not enough attribute handles available.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t GATTServApp_RegisterService( gattAttribute_t *pAttrs, uint16 numAttrs,
+ const gattServiceCBs_t *pServiceCBs );
+/**
+ * @brief Deregister a service's attribute list and callback functions from
+ * the GATT Server Application.
+ *
+ * NOTE: It's the caller's responsibility to free the service attribute
+ * list returned from this API.
+ *
+ * @param handle - handle of service to be deregistered
+ * @param p2pAttrs - pointer to array of attribute records (to be returned)
+ *
+ * @return SUCCESS: Service deregistered successfully.
+ * FAILURE: Service not found.
+ */
+bStatus_t GATTServApp_DeregisterService( uint16 handle, gattAttribute_t **p2pAttrs );
+
+/**
+ * @brief Find the attribute record within a service attribute
+ * table for a given attribute value pointer.
+ *
+ * @param pAttrTbl - pointer to attribute table
+ * @param numAttrs - number of attributes in attribute table
+ * @param pValue - pointer to attribute value
+ *
+ * @return Pointer to attribute record. NULL, if not found.
+ */
+extern gattAttribute_t *GATTServApp_FindAttr( gattAttribute_t *pAttrTbl,
+ uint16 numAttrs, uint8 *pValue );
+/**
+ * @brief Add function for the GATT Service.
+ *
+ * @param services - services to add. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return SUCCESS: Service added successfully.
+ * INVALIDPARAMETER: Invalid service field.
+ * FAILURE: Not enough attribute handles available.
+ * bleMemAllocError: Memory allocation error occurred.
+ */
+extern bStatus_t GATTServApp_AddService( uint32 services );
+
+/**
+ * @brief Delete function for the GATT Service.
+ *
+ * @param services - services to delete. This is a bit map and can
+ * contain more than one service.
+ *
+ * @return SUCCESS: Service deleted successfully.
+ * FAILURE: Service not found.
+ */
+extern bStatus_t GATTServApp_DelService( uint32 services );
+
+/**
+ * @brief Set a GATT Server parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param len - length of data to right
+ * @param pValue - pointer to data to write. This is dependent on the
+ * parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast
+ * to uint16 pointer).
+ *
+ * @return SUCCESS: Parameter set successful
+ * FAILURE: Parameter in use
+ * INVALIDPARAMETER: Invalid parameter
+ * bleInvalidRange: Invalid value
+ * bleMemAllocError: Memory allocation failed
+ */
+extern bStatus_t GATTServApp_SetParameter( uint8 param, uint8 len, void *pValue );
+
+/**
+ * @brief Get a GATT Server parameter.
+ *
+ * @param param - Profile parameter ID
+ * @param pValue - pointer to data to put. This is dependent on the
+ * parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be
+ * cast to uint16 pointer).
+ *
+ * @return SUCCESS: Parameter get successful
+ * INVALIDPARAMETER: Invalid parameter
+ */
+extern bStatus_t GATTServApp_GetParameter( uint8 param, void *pValue );
+
+/**
+ * @brief Update the Client Characteristic Configuration for a given
+ * Client.
+ *
+ * Note: This API should only be called from the Bond Manager.
+ *
+ * @param connHandle - connection handle.
+ * @param attrHandle - attribute handle.
+ * @param value - characteristic configuration value.
+ *
+ * @return SUCCESS: Parameter get successful
+ * INVALIDPARAMETER: Invalid parameter
+ */
+extern bStatus_t GATTServApp_UpdateCharCfg( uint16 connHandle, uint16 attrHandle, uint16 value );
+
+/**
+ * @brief Initialize the client characteristic configuration table.
+ *
+ * Note: Each client has its own instantiation of the Client
+ * Characteristic Configuration. Reads/Writes of the Client
+ * Characteristic Configuration only only affect the
+ * configuration of that client.
+ *
+ * @param connHandle - connection handle (0xFFFF for all connections).
+ * @param charCfgTbl - client characteristic configuration table.
+ *
+ * @return none
+ */
+extern void GATTServApp_InitCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl );
+
+/**
+ * @brief Read the client characteristic configuration for a given
+ * client.
+ *
+ * Note: Each client has its own instantiation of the Client
+ * Characteristic Configuration. Reads of the Client
+ * Characteristic Configuration only shows the configuration
+ * for that client.
+ *
+ * @param connHandle - connection handle.
+ * @param charCfgTbl - client characteristic configuration table.
+ *
+ * @return attribute value
+ */
+extern uint16 GATTServApp_ReadCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl );
+
+/**
+ * @brief Write the client characteristic configuration for a given
+ * client.
+ *
+ * Note: Each client has its own instantiation of the Client
+ * Characteristic Configuration. Writes of the Client
+ * Characteristic Configuration only only affect the
+ * configuration of that client.
+ *
+ * @param connHandle - connection handle.
+ * @param charCfgTbl - client characteristic configuration table.
+ * @param value - attribute new value.
+ *
+ * @return Success or Failure
+ */
+extern uint8 GATTServApp_WriteCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl, uint16 value );
+
+/**
+ * @brief Process the client characteristic configuration
+ * write request for a given client.
+ *
+ * @param connHandle - connection message was received on.
+ * @param pAttr - pointer to attribute.
+ * @param pValue - pointer to data to be written.
+ * @param len - length of data.
+ * @param offset - offset of the first octet to be written.
+ * @param validCfg - valid configuration.
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t GATTServApp_ProcessCCCWriteReq( uint16 connHandle, gattAttribute_t *pAttr,
+ uint8 *pValue, uint8 len, uint16 offset,
+ uint16 validCfg );
+
+/**
+ * @brief Process Client Charateristic Configuration change.
+ *
+ * @param charCfgTbl - characteristic configuration table.
+ * @param pValue - pointer to attribute value.
+ * @param authenticated - whether an authenticated link is required.
+ * @param attrTbl - attribute table.
+ * @param numAttrs - number of attributes in attribute table.
+ * @param taskId - task to be notified of confirmation.
+ *
+ * @return Success or Failure
+ */
+extern bStatus_t GATTServApp_ProcessCharCfg( gattCharCfg_t *charCfgTbl, uint8 *pValue,
+ uint8 authenticated, gattAttribute_t *attrTbl,
+ uint16 numAttrs, uint8 taskId );
+
+/**
+ * @brief Build and send the GATT_CLIENT_CHAR_CFG_UPDATED_EVENT to
+ * the application.
+ *
+ * @param connHandle - connection handle
+ * @param attrHandle - attribute handle
+ * @param value - attribute new value
+ *
+ * @return none
+ */
+extern void GATTServApp_SendCCCUpdatedEvent( uint16 connHandle, uint16 attrHandle, uint16 value );
+
+/**
+ * @brief Send out a Service Changed Indication.
+ *
+ * @param connHandle - connection to use
+ * @param taskId - task to be notified of confirmation
+ *
+ * @return SUCCESS: Indication was sent successfully.
+ * FAILURE: Service Changed attribute not found.
+ * INVALIDPARAMETER: Invalid connection handle or request field.
+ * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
+ * bleNotConnected: Connection is down.
+ * blePending: A confirmation is pending with this client.
+ */
+extern bStatus_t GATTServApp_SendServiceChangedInd( uint16 connHandle, uint8 taskId );
+
+/**
+ * @brief Read an attribute. If the format of the attribute value
+ * is unknown to GATT Server, use the callback function
+ * provided by the Service.
+ *
+ * @param connHandle - connection message was received on
+ * @param pAttr - pointer to attribute
+ * @param service - handle of owner service
+ * @param pValue - pointer to data to be read
+ * @param pLen - length of data to be read
+ * @param offset - offset of the first octet to be read
+ * @param maxLen - maximum length of data to be read
+ *
+ * @return Success or Failure
+ */
+extern uint8 GATTServApp_ReadAttr( uint16 connHandle, gattAttribute_t *pAttr,
+ uint16 service, uint8 *pValue, uint8 *pLen,
+ uint16 offset, uint8 maxLen );
+
+/**
+ * @brief Write attribute data
+ *
+ * @param connHandle - connection message was received on
+ * @param handle - attribute handle
+ * @param pValue - pointer to data to be written
+ * @param len - length of data
+ * @param offset - offset of the first octet to be written
+ *
+ * @return Success or Failure
+ */
+extern uint8 GATTServApp_WriteAttr( uint16 connHandle, uint16 handle,
+ uint8 *pValue, uint16 len, uint16 offset );
+
+/**
+ * @}
+ */
+
+/**
+ * @brief Set a GATT Server Application Parameter value. Use this
+ * function to change the default GATT parameter values.
+ *
+ * @param value - new param value
+ *
+ * @return void
+ */
+extern void GATTServApp_SetParamValue( uint16 value );
+
+/**
+ * @brief Get a GATT Server Application Parameter value.
+ *
+ * @param none
+ *
+ * @return GATT Parameter value
+ */
+extern uint16 GATTServApp_GetParamValue( void );
+
+/*-------------------------------------------------------------------
+ * TASK API - These functions must only be called by OSAL.
+ */
+
+/**
+ * @internal
+ *
+ * @brief Initialize the GATT Server Test Application.
+ *
+ * @param taskId - Task identifier for the desired task
+ *
+ * @return void
+ *
+ */
+extern void GATTServApp_Init( uint8 taskId );
+
+/**
+ * @internal
+ *
+ * @brief GATT Server 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
+ */
+extern uint16 GATTServApp_ProcessEvent( uint8 taskId, uint16 events );
+
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 40 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+
+/* Profiles */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\Profiles\\Roles\\peripheral.h"
+/**
+ @headerfile: peripheral.h
+ $Date: 2013-05-01 13:58:23 -0700 (Wed, 01 May 2013) $
+ $Revision: 34101 $
+
+ @mainpage TI BLE GAP Peripheral Role
+
+ This GAP profile advertises and allows connections.
+
+ Copyright 2009 - 2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*/
+
+
+
+
+
+
+
+
+
+/*-------------------------------------------------------------------
+ * INCLUDES
+ */
+
+/*-------------------------------------------------------------------
+ * CONSTANTS
+ */
+
+/** @defgroup GAPROLE_PROFILE_PARAMETERS GAP Role Parameters
+ * @{
+ */
+#line 86 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\Profiles\\Roles\\peripheral.h"
+/** @} End GAPROLE_PROFILE_PARAMETERS */
+
+/*-------------------------------------------------------------------
+ * TYPEDEFS
+ */
+
+/**
+ * GAP Peripheral Role States.
+ */
+typedef enum
+{
+ GAPROLE_INIT = 0, //!< Waiting to be started
+ GAPROLE_STARTED, //!< Started but not advertising
+ GAPROLE_ADVERTISING, //!< Currently Advertising
+ GAPROLE_WAITING, //!< Device is started but not advertising, is in waiting period before advertising again
+ GAPROLE_WAITING_AFTER_TIMEOUT, //!< Device just timed out from a connection but is not yet advertising, is in waiting period before advertising again
+ GAPROLE_CONNECTED, //!< In a connection
+ GAPROLE_ERROR //!< Error occurred - invalid state
+} gaprole_States_t;
+
+/**
+ * Possible actions the peripheral device may take if an unsuccessful parameter
+ * update is received.
+ *
+ * Parameters for GAPRole_SendUpdateParam() only
+ */
+
+
+
+
+
+/*-------------------------------------------------------------------
+ * MACROS
+ */
+
+/*-------------------------------------------------------------------
+ * Profile Callbacks
+ */
+
+/**
+ * Callback when the connection parameteres are updated.
+ */
+typedef void (*gapRolesParamUpdateCB_t)( uint16 connInterval,
+ uint16 connSlaveLatency,
+ uint16 connTimeout );
+
+/**
+ * Callback when the device has been started. Callback event to
+ * the Notify of a state change.
+ */
+typedef void (*gapRolesStateNotify_t)( gaprole_States_t newState );
+
+/**
+ * Callback when the device has read an new RSSI value during a connection.
+ */
+typedef void (*gapRolesRssiRead_t)( int8 newRSSI );
+
+/**
+ * Callback structure - must be setup by the application and used when gapRoles_StartDevice() is called.
+ */
+typedef struct
+{
+ gapRolesStateNotify_t pfnStateChange; //!< Whenever the device changes state
+ gapRolesRssiRead_t pfnRssiRead; //!< When a valid RSSI is read from controller
+} gapRolesCBs_t;
+
+/*-------------------------------------------------------------------
+ * API FUNCTIONS
+ */
+
+/**
+ * @defgroup GAPROLES_PERIPHERAL_API GAP Peripheral Role API Functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Set a GAP Role parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will set the
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also,
+ * the "len" field must be set to the size of a "uint16" and the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
+ * @param len - length of data to write
+ * @param pValue - pointer to data to write. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPRole_SetParameter( uint16 param, uint8 len, void *pValue );
+
+/**
+ * @brief Get a GAP Role parameter.
+ *
+ * NOTE: You can call this function with a GAP Parameter ID and it will get a
+ * GAP Parameter. GAP Parameters are defined in (gap.h). Also, the
+ * "pValue" field must point to a "uint16".
+ *
+ * @param param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
+ * @param pValue - pointer to location to get the value. This is dependent on
+ * the parameter ID and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
+ */
+extern bStatus_t GAPRole_GetParameter( uint16 param, void *pValue );
+
+/**
+ * @brief Does the device initialization. Only call this function once.
+ *
+ * @param pAppCallbacks - pointer to application callbacks.
+ *
+ * @return SUCCESS or bleAlreadyInRequestedMode
+ */
+extern bStatus_t GAPRole_StartDevice( gapRolesCBs_t *pAppCallbacks );
+
+/**
+ * @brief Terminates the existing connection.
+ *
+ * @return SUCCESS or bleIncorrectMode
+ */
+extern bStatus_t GAPRole_TerminateConnection( void );
+
+/**
+ * @brief Update the parameters of an existing connection
+ *
+ * @param connInterval - the new connection interval
+ * @param latency - the new slave latency
+ * @param connTimeout - the new timeout value
+ * @param handleFailure - what to do if the update does not occur.
+ * Method may choose to terminate connection, try again, or take no action
+ *
+ * @return SUCCESS, bleNotConnected or bleInvalidRange
+ */
+extern bStatus_t GAPRole_SendUpdateParam( uint16 minConnInterval, uint16 maxConnInterval,
+ uint16 latency, uint16 connTimeout, uint8 handleFailure );
+
+/**
+ * @brief Register application's callbacks.
+ *
+ * @param pParamUpdateCB - pointer to param update callback.
+ *
+ * @return none
+ */
+extern void GAPRole_RegisterAppCBs( gapRolesParamUpdateCB_t *pParamUpdateCB );
+
+/**
+ * @} End GAPROLES_PERIPHERAL_API
+ */
+
+
+/*-------------------------------------------------------------------
+ * TASK FUNCTIONS - Don't call these. These are system functions.
+ */
+
+/**
+ * @internal
+ *
+ * @brief Initialization function for the GAP Role Task.
+ * This is called during initialization and should contain
+ * any application specific initialization (ie. hardware
+ * initialization/setup, table initialization, power up
+ * notificaiton ... ).
+ *
+ * @param the ID assigned by OSAL. This ID should be
+ * used to send messages and set timers.
+ *
+ * @return void
+ */
+extern void GAPRole_Init( uint8 task_id );
+
+/**
+ * @internal
+ *
+ * @brief GAP Role 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 events not processed
+ */
+extern uint16 GAPRole_ProcessEvent( uint8 task_id, uint16 events );
+
+/*-------------------------------------------------------------------
+-------------------------------------------------------------------*/
+
+
+
+
+
+#line 46 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+
+
+/* Application */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\wimu.h"
+/**************************************************************************************************
+ Filename: wimu.h
+
+ Description: This file contains the WIMU application
+ (based on Simple BLE Peripheral sample application)
+ definitions and prototypes.
+
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+/*********************************************************************
+ * DATA TYPES
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Simple BLE Peripheral Task Events
+
+
+
+
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Task Initialization for the BLE Application
+ */
+extern void WIMU_Init( uint8 task_id );
+
+/*
+ * Task Event Processor for the BLE Application
+ */
+extern uint16 WIMU_ProcessEvent( uint8 task_id, uint16 events );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 50 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\Source\\OSAL_WIMU.c"
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+// The order in this table must be identical to the task initialization calls below in osalInitTask.
+const pTaskEventHandlerFn tasksArr[] =
+{
+ LL_ProcessEvent, // task 0
+ Hal_ProcessEvent, // task 1
+ HCI_ProcessEvent, // task 2
+
+//OSAL_CBTIMER_PROCESS_EVENT( osal_CbTimerProcessEvent ), // task 3
+
+ L2CAP_ProcessEvent, // task 4
+ GAP_ProcessEvent, // task 5
+ GATT_ProcessEvent, // task 6
+ SM_ProcessEvent, // task 7
+ GAPRole_ProcessEvent, // task 8
+ GAPBondMgr_ProcessEvent, // task 9
+ GATTServApp_ProcessEvent, // task 10
+ WIMU_ProcessEvent // task 11
+};
+
+const uint8 tasksCnt = sizeof( tasksArr ) / sizeof( tasksArr[0] );
+uint16 *tasksEvents;
+
+/*********************************************************************
+ * FUNCTIONS
+ *********************************************************************/
+
+/*********************************************************************
+ * @fn osalInitTasks
+ *
+ * @brief This function invokes the initialization function for each task.
+ *
+ * @param void
+ *
+ * @return none
+ */
+void osalInitTasks( void )
+{
+ uint8 taskID = 0;
+
+ tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);
+ osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));
+
+ /* LL Task */
+ LL_Init( taskID++ );
+
+ /* Hal Task */
+ Hal_Init( taskID++ );
+
+ /* HCI Task */
+ HCI_Init( taskID++ );
+/*
+#if defined ( OSAL_CBTIMER_NUM_TASKS )
+ // Callback Timer Tasks
+ osal_CbTimerInit( taskID );
+ taskID += OSAL_CBTIMER_NUM_TASKS;
+#endif*/
+
+ /* L2CAP Task */
+ L2CAP_Init( taskID++ );
+
+ /* GAP Task */
+ GAP_Init( taskID++ );
+
+ /* GATT Task */
+ GATT_Init( taskID++ );
+
+ /* SM Task */
+ SM_Init( taskID++ );
+
+ /* Profiles */
+ GAPRole_Init( taskID++ );
+ GAPBondMgr_Init( taskID++ );
+
+ GATTServApp_Init( taskID++ );
+
+ /* Application */
+ WIMU_Init( taskID );
+}
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OnBoard.i b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OnBoard.i
new file mode 100644
index 0000000..b9d4ec6
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/OnBoard.i
@@ -0,0 +1,2979 @@
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\common\\cc2540\\OnBoard.c"
+/**************************************************************************************************
+ Filename: OnBoard.c
+ Revised: $Date: 2008-03-18 15:14:17 -0700 (Tue, 18 Mar 2008) $
+ Revision: $Revision: 16604 $
+
+ Description: This file contains the UI and control for the
+ peripherals on the EVAL development board
+ Notes: This file targets the Chipcon CC2430DB/CC2430EB
+
+
+ Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+/*********************************************************************
+ * INCLUDES
+ */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\bcomdef.h"
+/**
+ @headerfile: bcomdef.h
+
+
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+/**************************************************************************************************
+ Filename: comdef.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: Type definitions and macros.
+
+
+ Copyright 2004-2008 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/* HAL */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+/**
+ @headerfile: hal_types.h
+
+
+**************************************************************************************************/
+
+
+
+
+/* Texas Instruments CC2540 */
+
+/* ------------------------------------------------------------------------------------------------
+ * Types
+ * ------------------------------------------------------------------------------------------------
+ */
+/** @defgroup HAL_TYPES HAL Types
+ * @{
+ */
+typedef signed char int8; //!< Signed 8 bit integer
+typedef unsigned char uint8; //!< Unsigned 8 bit integer
+
+typedef signed short int16; //!< Signed 16 bit integer
+typedef unsigned short uint16; //!< Unsigned 16 bit integer
+
+typedef signed long int32; //!< Signed 32 bit integer
+typedef unsigned long uint32; //!< Unsigned 32 bit integer
+
+typedef unsigned char bool; //!< Boolean data type
+
+typedef uint8 halDataAlign_t; //!< Used for byte alignment
+/** @} End HAL_TYPES */
+
+/* ------------------------------------------------------------------------------------------------
+ * Memory Attributes and Compiler Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ----------- IAR Compiler ----------- */
+#line 82 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+/* ----------- KEIL Compiler ----------- */
+#line 105 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_types.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Standard Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************************************************
+ */
+#line 55 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+/**************************************************************************************************
+ Filename: hal_defs.h
+ Revised: $Date: 2012-08-17 16:28:43 -0700 (Fri, 17 Aug 2012) $
+ Revision: $Revision: 31295 $
+
+ Description: This file contains useful macros and data types
+
+
+ Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* takes a byte out of a uint32 : var - uint32, ByteNum - byte to take out (0 - 3) */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 101 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_defs.h"
+
+/*
+ * This macro is for use by other macros to form a fully valid C statement.
+ * Without this, the if/else conditionals could show unexpected behavior.
+ *
+ * For example, use...
+ * #define SET_REGS() st( ioreg1 = 0; ioreg2 = 0; )
+ * instead of ...
+ * #define SET_REGS() { ioreg1 = 0; ioreg2 = 0; }
+ * or
+ * #define SET_REGS() ioreg1 = 0; ioreg2 = 0;
+ * The last macro would not behave as expected in the if/else construct.
+ * The second to last macro will cause a compiler error in certain uses
+ * of if/else construct
+ *
+ * It is not necessary, or recommended, to use this macro where there is
+ * already a valid C statement. For example, the following is redundant...
+ * #define CALL_FUNC() st( func(); )
+ * This should simply be...
+ * #define CALL_FUNC() func()
+ *
+ * (The while condition below evaluates false without generating a
+ * constant-controlling-loop type of warning on most compilers.)
+ */
+
+
+
+/**************************************************************************************************
+ */
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * Lint Keywords
+ */
+
+
+#line 71 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*** Generic Status Return Values ***/
+#line 107 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\comdef.h"
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+// Generic Status return
+typedef uint8 Status_t;
+
+// Data types
+typedef int32 int24;
+typedef uint32 uint24;
+
+/*********************************************************************
+ * Global System Events
+ */
+
+
+
+/*********************************************************************
+ * Global Generic System Messages
+ */
+
+
+
+// OSAL System Message IDs/Events Reserved for applications (user applications)
+// 0xE0 – 0xFC
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 57 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\bcomdef.h"
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+ // Set the Controller Configuration
+#line 92 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\bcomdef.h"
+
+#line 102 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\bcomdef.h"
+
+/** @defgroup BLE_COMMON_DEFINES BLE Common Defines
+ * @{
+ */
+//! Default Public and Random Address Length
+
+
+//! Default key length
+
+
+//! BLE Channel Map length
+
+
+//! BLE Event mask length
+
+
+//! BLE Local Name length
+
+
+//! BLE Maximum Advertising Packet Length
+
+
+//! BLE Random Number Size
+
+
+//! BLE Feature Supported length
+
+
+/** @defgroup BLE_STATUS_VALUES BLE Default BLE Status Values
+ * returned as bStatus_t
+ * @{
+ */
+#line 146 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\ble\\include\\bcomdef.h"
+
+// GAP Status Return Values - returned as bStatus_t
+
+
+
+
+// ATT Status Return Values - returned as bStatus_t
+
+
+
+
+
+// L2CAP Status Return Values - returned as bStatus_t
+
+
+/** @} End BLE_STATUS_VALUES */
+
+/** @defgroup BLE_NV_IDS BLE Non-volatile IDs
+ * @{
+ */
+// Device NV Items - Range 0 - 0x1F
+
+
+
+
+// Bonding NV Items - Range 0x20 - 0x5F - This allows for 10 bondings
+
+
+
+// GATT Configuration NV Items - Range 0x70 - 0x79 - This must match the number of Bonding entries
+
+
+/** @} End BLE_NV_IDS */
+
+/*********************************************************************
+ * BLE OSAL GAP GLOBAL Events
+ */
+
+
+
+/** @defgroup BLE_MSG_IDS BLE OSAL Message ID Events
+ * Reserved Message ID Event Values:
+ * 0xC0 - Key Presses
+ * 0xE0 to 0xFC - App
+ * @{
+ */
+// GAP - Messages IDs (0xD0 - 0xDF)
+
+
+// SM - Messages IDs (0xC1 - 0xCF)
+
+
+// GATT - Messages IDs (0xB0 - 0xBF)
+
+
+
+// L2CAP - Messages IDs (0xA0 - 0xAF)
+
+
+
+// HCI - Messages IDs (0x90 - 0x9F)
+
+
+
+
+/** @} End BLE_MSG_IDS */
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+ //! BLE Generic Status return: @ref BLE_STATUS_VALUES
+typedef Status_t bStatus_t;
+
+/** @} End GAP_MSG_EVENT_DEFINES */
+
+
+/*********************************************************************
+ * System Events
+ */
+
+/*********************************************************************
+ * Global System Messages
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+// TI Base 128-bit UUID: F000XXXX-0451-4000-B000-000000000000
+
+
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 46 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\common\\cc2540\\OnBoard.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\common\\cc2540\\OnBoard.h"
+/**************************************************************************************************
+ Filename: OnBoard.h
+ Revised: $Date: 2008-07-25 17:36:14 -0700 (Fri, 25 Jul 2008) $
+ Revision: $Revision: 17620 $
+
+ Description: Defines stuff for EVALuation boards
+ This file targets the Chipcon CC2540DB/CC2540EB
+
+
+ Copyright 2008-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+/**************************************************************************************************
+ Filename: hal_mcu.h
+ Revised: $Date: 2012-07-13 06:58:11 -0700 (Fri, 13 Jul 2012) $
+ Revision: $Revision: 30922 $
+
+ Description: Describe the purpose and contents of the file.
+
+
+ Copyright 2006-2010 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+/*
+ * Target : Texas Instruments CC2540 (8051 core)
+ *
+ */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Includes
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Target Defines
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* ---------------------- IAR Compiler ---------------------- */
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/**************************************************************************************************
+ * - ioCC2540.h -
+ *
+ * Header file with definitions for the Texas Instruments CC2540 low-power System-on-Chip:
+ * an 8051-based MCU with 2.4 GHz Bluetooth low energy RF transceiver, and up to 256 kB FLASH.
+ *
+ * This file supports the IAR Embedded Workbench for 8051.
+ *
+ **************************************************************************************************
+ */
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Compiler Abstraction
+ * ------------------------------------------------------------------------------------------------
+ */
+
+#pragma language=extended
+#line 41 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 77 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Vectors
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 101 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * SFR Bit Alias
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* USBIE P2IE , not in a bit addressable register */
+
+/* ------------------------------------------------------------------------------------------------
+ * SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * SFRs with an address ending with 0 or 8 are bit accessible.
+ * They are defined with the SFRBIT() macro that sets the name of each bit.
+ */
+
+/* Port 0 */
+__sfr __no_init volatile union { unsigned char P0; struct { unsigned char P0_0 : 1; unsigned char P0_1 : 1; unsigned char P0_2 : 1; unsigned char P0_3 : 1; unsigned char P0_4 : 1; unsigned char P0_5 : 1; unsigned char P0_6 : 1; unsigned char P0_7 : 1; }; } @ 0x80;
+__sfr __no_init volatile unsigned char SP @ 0x81; /* Stack Pointer */
+__sfr __no_init volatile unsigned char DPL0 @ 0x82; /* Data Pointer 0 Low Byte */
+__sfr __no_init volatile unsigned char DPH0 @ 0x83; /* Data Pointer 0 High Byte */
+__sfr __no_init volatile unsigned char DPL1 @ 0x84; /* Data Pointer 1 Low Byte */
+__sfr __no_init volatile unsigned char DPH1 @ 0x85; /* Data Pointer 1 High Byte */
+__sfr __no_init volatile unsigned char U0CSR @ 0x86; /* USART 0 Control and Status */
+__sfr __no_init volatile unsigned char PCON @ 0x87; /* Power Mode Control */
+
+/* Interrupt Flags */
+__sfr __no_init volatile union { unsigned char TCON; struct { unsigned char IT0 : 1; unsigned char RFERRIF : 1; unsigned char IT1 : 1; unsigned char URX0IF : 1; unsigned char _TCON4 : 1; unsigned char ADCIF : 1; unsigned char _TCON6 : 1; unsigned char URX1IF : 1; }; } @ 0x88;
+__sfr __no_init volatile unsigned char P0IFG @ 0x89; /* Port 0 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P1IFG @ 0x8A; /* Port 1 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char P2IFG @ 0x8B; /* Port 2 Interrupt Status Flag */
+__sfr __no_init volatile unsigned char PICTL @ 0x8C; /* Port Interrupt Control */
+__sfr __no_init volatile unsigned char P1IEN @ 0x8D; /* Port 1 Interrupt Mask */
+__sfr __no_init volatile unsigned char _SFR8E @ 0x8E; /* not used */
+__sfr __no_init volatile unsigned char P0INP @ 0x8F; /* Port 0 Input Mode */
+
+/* Port 1 */
+__sfr __no_init volatile union { unsigned char P1; struct { unsigned char P1_0 : 1; unsigned char P1_1 : 1; unsigned char P1_2 : 1; unsigned char P1_3 : 1; unsigned char P1_4 : 1; unsigned char P1_5 : 1; unsigned char P1_6 : 1; unsigned char P1_7 : 1; }; } @ 0x90;
+__sfr __no_init volatile unsigned char _SFR91 @ 0x91; /* reserved */
+__sfr __no_init volatile unsigned char DPS @ 0x92; /* Data Pointer Select */
+__sfr __no_init volatile unsigned char MPAGE @ 0x93; /* Memory Page Select */
+__sfr __no_init volatile unsigned char T2CTRL @ 0x94; /* Timer2 Control Register */
+__sfr __no_init volatile unsigned char ST0 @ 0x95; /* Sleep Timer 0 */
+__sfr __no_init volatile unsigned char ST1 @ 0x96; /* Sleep Timer 1 */
+__sfr __no_init volatile unsigned char ST2 @ 0x97; /* Sleep Timer 2 */
+
+/* Interrupt Flags 2 */
+__sfr __no_init volatile union { unsigned char S0CON; struct { unsigned char ENCIF_0 : 1; unsigned char ENCIF_1 : 1; unsigned char _S0CON2 : 1; unsigned char _S0CON3 : 1; unsigned char _S0CON4 : 1; unsigned char _S0CON5 : 1; unsigned char _S0CON6 : 1; unsigned char _S0CON7 : 1; }; } @ 0x98;
+__sfr __no_init volatile unsigned char _SFR99 @ 0x99; /* reserved */
+__sfr __no_init volatile unsigned char IEN2 @ 0x9A; /* Interrupt Enable 2 */
+__sfr __no_init volatile unsigned char S1CON @ 0x9B; /* Interrupt Flags 3 */
+__sfr __no_init volatile unsigned char T2CSPCFG @ 0x9C; /* Timer2 CSP Interface Configuration (legacy name) */
+__sfr __no_init volatile unsigned char T2EVTCFG @ 0x9C; /* Timer2 Event Output Configuration */
+__sfr __no_init volatile unsigned char SLEEPSTA @ 0x9D; /* Sleep Status */
+__sfr __no_init volatile unsigned char CLKCONSTA @ 0x9E; /* Clock Control Status */
+__sfr __no_init volatile unsigned char FMAP @ 0x9F; /* Flash Bank Map */
+
+/* Port 2 */
+__sfr __no_init volatile union { unsigned char P2; struct { unsigned char P2_0 : 1; unsigned char P2_1 : 1; unsigned char P2_2 : 1; unsigned char P2_3 : 1; unsigned char P2_4 : 1; unsigned char _P2_5 : 1; unsigned char _P2_6 : 1; unsigned char _P2_7 : 1; }; } @ 0xA0;
+__sfr __no_init volatile unsigned char T2IRQF @ 0xA1; /* Timer2 Interrupt Flags */
+__sfr __no_init volatile unsigned char T2M0 @ 0xA2; /* Timer2 Multiplexed Register 0 */
+__sfr __no_init volatile unsigned char T2M1 @ 0xA3; /* Timer2 Multiplexed Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF0 @ 0xA4; /* Timer2 Multiplexed Overflow Register 0 */
+__sfr __no_init volatile unsigned char T2MOVF1 @ 0xA5; /* Timer2 Multiplexed Overflow Register 1 */
+__sfr __no_init volatile unsigned char T2MOVF2 @ 0xA6; /* Timer2 Multiplexed Overflow Register 2 */
+__sfr __no_init volatile unsigned char T2IRQM @ 0xA7; /* Timer2 Interrupt Mask */
+
+/* Interrupt Enable 0 */
+__sfr __no_init volatile union { unsigned char IEN0; struct { unsigned char RFERRIE : 1; unsigned char ADCIE : 1; unsigned char URX0IE : 1; unsigned char URX1IE : 1; unsigned char ENCIE : 1; unsigned char STIE : 1; unsigned char _IEN06 : 1; unsigned char EA : 1; }; } @ 0xA8;
+__sfr __no_init volatile unsigned char IP0 @ 0xA9; /* Interrupt Priority 0 */
+__sfr __no_init volatile unsigned char _SFRAA @ 0xAA; /* not used */
+__sfr __no_init volatile unsigned char P0IEN @ 0xAB; /* Port 0 Interrupt Mask */
+__sfr __no_init volatile unsigned char P2IEN @ 0xAC; /* Port 2 Interrupt Mask */
+__sfr __no_init volatile unsigned char STLOAD @ 0xAD; /* Sleep Timer Load Status */
+__sfr __no_init volatile unsigned char PMUX @ 0xAE; /* Power Down Signal MUX */
+__sfr __no_init volatile unsigned char T1STAT @ 0xAF; /* Timer 1 Status */
+
+__sfr __no_init volatile unsigned char _SFRB0 @ 0xB0; /* not used */
+__sfr __no_init volatile unsigned char ENCDI @ 0xB1; /* Encryption/Decryption Input Data */
+__sfr __no_init volatile unsigned char ENCDO @ 0xB2; /* Encryption/Decryption Output Data */
+__sfr __no_init volatile unsigned char ENCCS @ 0xB3; /* Encryption/Decryption Control and Status */
+__sfr __no_init volatile unsigned char ADCCON1 @ 0xB4; /* ADC Control 1 */
+__sfr __no_init volatile unsigned char ADCCON2 @ 0xB5; /* ADC Control 2 */
+__sfr __no_init volatile unsigned char ADCCON3 @ 0xB6; /* ADC Control 3 */
+__sfr __no_init volatile unsigned char _SFRB7 @ 0xB7; /* reserved */
+
+/* Interrupt Enable 1 */
+__sfr __no_init volatile union { unsigned char IEN1; struct { unsigned char DMAIE : 1; unsigned char T1IE : 1; unsigned char T2IE : 1; unsigned char T3IE : 1; unsigned char T4IE : 1; unsigned char P0IE : 1; unsigned char _IEN16 : 1; unsigned char _IEN17 : 1; }; } @ 0xB8;
+__sfr __no_init volatile unsigned char IP1 @ 0xB9; /* Interrupt Priority 1 */
+__sfr __no_init volatile unsigned char ADCL @ 0xBA; /* ADC Data Low */
+__sfr __no_init volatile unsigned char ADCH @ 0xBB; /* ADC Data High */
+__sfr __no_init volatile unsigned char RNDL @ 0xBC; /* Random Number Generator Low Byte */
+__sfr __no_init volatile unsigned char RNDH @ 0xBD; /* Random Number Generator High Byte */
+__sfr __no_init volatile unsigned char SLEEPCMD @ 0xBE; /* Sleep Mode Control Command */
+__sfr __no_init volatile unsigned char _SFRBF @ 0xBF; /* reserved */
+
+/* Interrupt Flags 4 */
+__sfr __no_init volatile union { unsigned char IRCON; struct { unsigned char DMAIF : 1; unsigned char T1IF : 1; unsigned char T2IF : 1; unsigned char T3IF : 1; unsigned char T4IF : 1; unsigned char P0IF : 1; unsigned char _IRCON6 : 1; unsigned char STIF : 1; }; } @ 0xC0;
+__sfr __no_init volatile unsigned char U0DBUF @ 0xC1; /* USART 0 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U0BAUD @ 0xC2; /* USART 0 Baud Rate Control */
+__sfr __no_init volatile unsigned char T2MSEL @ 0xC3; /* Timer2 Multiplex Select */
+__sfr __no_init volatile unsigned char U0UCR @ 0xC4; /* USART 0 UART Control */
+__sfr __no_init volatile unsigned char U0GCR @ 0xC5; /* USART 0 Generic Control */
+__sfr __no_init volatile unsigned char CLKCONCMD @ 0xC6; /* Clock Control Command */
+__sfr __no_init volatile unsigned char MEMCTR @ 0xC7; /* Memory System Control */
+
+__sfr __no_init volatile unsigned char _SFRC8 @ 0xC8; /* not used */
+__sfr __no_init volatile unsigned char WDCTL @ 0xC9; /* Watchdog Timer Control */
+__sfr __no_init volatile unsigned char T3CNT @ 0xCA; /* Timer 3 Counter */
+__sfr __no_init volatile unsigned char T3CTL @ 0xCB; /* Timer 3 Control */
+__sfr __no_init volatile unsigned char T3CCTL0 @ 0xCC; /* Timer 3 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC0 @ 0xCD; /* Timer 3 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T3CCTL1 @ 0xCE; /* Timer 3 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T3CC1 @ 0xCF; /* Timer 3 Channel 1 Capture/Compare Value */
+
+ /* Program Status Word */
+__sfr __no_init volatile union { unsigned char PSW; struct { unsigned char P : 1; unsigned char F1 : 1; unsigned char OV : 1; unsigned char RS0 : 1; unsigned char RS1 : 1; unsigned char F0 : 1; unsigned char AC : 1; unsigned char CY : 1; }; } @ 0xD0;
+__sfr __no_init volatile unsigned char DMAIRQ @ 0xD1; /* DMA Interrupt Flag */
+__sfr __no_init volatile unsigned char DMA1CFGL @ 0xD2; /* DMA Channel 1-4 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA1CFGH @ 0xD3; /* DMA Channel 1-4 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMA0CFGL @ 0xD4; /* DMA Channel 0 Configuration Address Low Byte */
+__sfr __no_init volatile unsigned char DMA0CFGH @ 0xD5; /* DMA Channel 0 Configuration Address High Byte */
+__sfr __no_init volatile unsigned char DMAARM @ 0xD6; /* DMA Channel Arm */
+__sfr __no_init volatile unsigned char DMAREQ @ 0xD7; /* DMA Channel Start Request and Status */
+
+/* Timers 1/3/4 Interrupt Mask/Flag */
+__sfr __no_init volatile union { unsigned char TIMIF; struct { unsigned char T3OVFIF : 1; unsigned char T3CH0IF : 1; unsigned char T3CH1IF : 1; unsigned char T4OVFIF : 1; unsigned char T4CH0IF : 1; unsigned char T4CH1IF : 1; unsigned char T1OVFIM : 1; unsigned char _TIMIF7 : 1; }; } @ 0xD8;
+__sfr __no_init volatile unsigned char _SFRD9 @ 0xD9; /* reserved */
+__sfr __no_init volatile unsigned char T1CC0L @ 0xDA; /* Timer 1 Channel 0 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC0H @ 0xDB; /* Timer 1 Channel 0 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC1L @ 0xDC; /* Timer 1 Channel 1 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC1H @ 0xDD; /* Timer 1 Channel 1 Capture/Compare Value High Byte */
+__sfr __no_init volatile unsigned char T1CC2L @ 0xDE; /* Timer 1 Channel 2 Capture/Compare Value Low Byte */
+__sfr __no_init volatile unsigned char T1CC2H @ 0xDF; /* Timer 1 Channel 2 Capture/Compare Value High Byte */
+
+__sfr __no_init volatile unsigned char ACC @ 0xE0; /* Accumulator */
+__sfr __no_init volatile unsigned char _SFRE1 @ 0xE1; /* reserved */
+__sfr __no_init volatile unsigned char T1CNTL @ 0xE2; /* Timer 1 Counter Low */
+__sfr __no_init volatile unsigned char T1CNTH @ 0xE3; /* Timer 1 Counter High */
+__sfr __no_init volatile unsigned char T1CTL @ 0xE4; /* Timer 1 Control And Status */
+__sfr __no_init volatile unsigned char T1CCTL0 @ 0xE5; /* Timer 1 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL1 @ 0xE6; /* Timer 1 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T1CCTL2 @ 0xE7; /* Timer 1 Channel 2 Capture/Compare Control */
+
+/* Interrupt Flags 5 */
+__sfr __no_init volatile union { unsigned char IRCON2; struct { unsigned char P2IF : 1; unsigned char UTX0IF : 1; unsigned char UTX1IF : 1; unsigned char P1IF : 1; unsigned char WDTIF : 1; unsigned char _IRCON25 : 1; unsigned char _IRCON26 : 1; unsigned char _IRCON27 : 1; }; } @ 0xE8;
+__sfr __no_init volatile unsigned char _SFRE9 @ 0xE9; /* reserved */
+__sfr __no_init volatile unsigned char T4CNT @ 0xEA; /* Timer 4 Counter */
+__sfr __no_init volatile unsigned char T4CTL @ 0xEB; /* Timer 4 Control */
+__sfr __no_init volatile unsigned char T4CCTL0 @ 0xEC; /* Timer 4 Channel 0 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC0 @ 0xED; /* Timer 4 Channel 0 Capture/Compare Value */
+__sfr __no_init volatile unsigned char T4CCTL1 @ 0xEE; /* Timer 4 Channel 1 Capture/Compare Control */
+__sfr __no_init volatile unsigned char T4CC1 @ 0xEF; /* Timer 4 Channel 1 Capture/Compare Value */
+
+__sfr __no_init volatile unsigned char B @ 0xF0; /* B Register */
+__sfr __no_init volatile unsigned char PERCFG @ 0xF1; /* Peripheral I/O Control */
+__sfr __no_init volatile unsigned char ADCCFG @ 0xF2; /* ADC Input Configuration (legacy name) */
+__sfr __no_init volatile unsigned char APCFG @ 0xF2; /* Analog Periferal I/O Configuration */
+__sfr __no_init volatile unsigned char P0SEL @ 0xF3; /* Port 0 Function Select */
+__sfr __no_init volatile unsigned char P1SEL @ 0xF4; /* Port 1 Function Select */
+__sfr __no_init volatile unsigned char P2SEL @ 0xF5; /* Port 2 Function Select */
+__sfr __no_init volatile unsigned char P1INP @ 0xF6; /* Port 1 Input Mode */
+__sfr __no_init volatile unsigned char P2INP @ 0xF7; /* Port 2 Input Mode */
+
+/* USART 1 Control and Status */
+__sfr __no_init volatile union { unsigned char U1CSR; struct { unsigned char U1ACTIVE : 1; unsigned char U1TX_BYTE : 1; unsigned char U1RX_BYTE : 1; unsigned char U1ERR : 1; unsigned char U1FE : 1; unsigned char U1SLAVE : 1; unsigned char U1RE : 1; unsigned char U1MODE : 1; }; } @ 0xF8;
+__sfr __no_init volatile unsigned char U1DBUF @ 0xF9; /* USART 1 Receive/Transmit Data Buffer */
+__sfr __no_init volatile unsigned char U1BAUD @ 0xFA; /* USART 1 Baud Rate Control */
+__sfr __no_init volatile unsigned char U1UCR @ 0xFB; /* USART 1 UART Control */
+__sfr __no_init volatile unsigned char U1GCR @ 0xFC; /* USART 1 Generic Control */
+__sfr __no_init volatile unsigned char P0DIR @ 0xFD; /* Port 0 Direction */
+__sfr __no_init volatile unsigned char P1DIR @ 0xFE; /* Port 1 Direction */
+__sfr __no_init volatile unsigned char P2DIR @ 0xFF; /* Port 2 Direction */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Radio Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Radio Control Registers */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata USB Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 329 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Registers
+ * ------------------------------------------------------------------------------------------------
+ */
+/* Observability Control */
+#line 345 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Identification */
+
+
+
+/* Debug Interface DMA Write to Flash */
+
+
+/* Flash Controller */
+#line 360 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* Chip Information */
+
+
+
+/* IR Generation Control */
+
+
+/* Clock Loss Detector */
+
+
+/* Timer 1 Channels (only mapped as XREG) */
+#line 378 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Definition which includes channels represented in SFR (additional XREG mapping of SFR) */
+#line 394 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+/* Pointers for array access */
+
+
+
+/* Sleep Timer Capture Control */
+
+
+
+
+
+
+/* Op.Amp. Control */
+
+
+
+
+/* Analog Comparator Control */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Xdata Mapped SFRs
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/*
+ * Most SFRs are also accessible through XDATA address space. The register definitions for
+ * this type of access are listed below. The register names are identical to the SFR names
+ * but with the prefix X_ to denote an XDATA register.
+ *
+ * Some SFRs are not accessible through XDATA space. For clarity, entries are included for these
+ * registers. They have a prefix of _NA to denote "not available."
+ *
+ * For register descriptions, refer to the actual SFR declartions elsewhere in this file.
+ */
+
+#line 437 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 446 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 455 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 465 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 474 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 483 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 492 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 501 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 510 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 519 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 528 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 537 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 546 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 555 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 565 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+#line 574 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\ioCC2540.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Flash
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ */
+
+
+#pragma language=default
+
+
+/**************************************************************************************************
+ */
+#line 76 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+#line 84 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ---------------------- Keil Compiler ---------------------- */
+#line 104 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+
+/* ------------------------------------------------------------------------------------------------
+ * Interrupt Macros
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+typedef unsigned char halIntState_t;
+
+
+
+
+
+ /* IAR library uses XCH instruction with EA. It may cause the higher priority interrupt to be
+ * locked out, therefore, may increase interrupt latency. It may also create a lockup condition.
+ * This workaround should only be used with 8051 using IAR compiler. When IAR fixes this by
+ * removing XCH usage in its library, compile the following macros to null to disable them.
+ */
+#line 131 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* ------------------------------------------------------------------------------------------------
+ * Reset Macro
+ * ------------------------------------------------------------------------------------------------
+ */
+#line 142 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/* disable interrupts, set watchdog timer, wait for reset */
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 rev numbers
+ * ------------------------------------------------------------------------------------------------
+ */
+
+
+
+
+
+/* ------------------------------------------------------------------------------------------------
+ * CC2540 sleep common code
+ * ------------------------------------------------------------------------------------------------
+ */
+
+/* PCON bit definitions */
+
+
+/* SLEEPCMD bit definitions */
+
+
+
+/* SLEEPSTA bit definitions */
+
+
+
+/* SLEEPCMD and SLEEPSTA bit definitions */
+
+
+
+/* CLKCONCMD bit definitions */
+
+
+
+
+
+
+/* STLOAD */
+
+
+
+
+#line 199 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_mcu.h"
+
+/**************************************************************************************************
+ */
+#line 45 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\common\\cc2540\\OnBoard.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_sleep.h"
+/**************************************************************************************************
+ Filename: hal_sleep.h
+ Revised: $Date: 2013-02-27 11:32:02 -0800 (Wed, 27 Feb 2013) $
+ Revision: $Revision: 33315 $
+
+ Description: This file contains the interface to the power management service.
+
+
+ Copyright 2006-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*
+ * Execute power management procedure
+ */
+extern void halSleep( uint32 osal_timer );
+
+/*
+ * Used in mac_mcu
+ */
+extern void halSleepWait(uint16 duration);
+
+/*
+ * Used in hal_drivers, AN044 - DELAY EXTERNAL INTERRUPTS
+ */
+extern void halRestoreSleepLevel( void );
+
+/*
+ * Used by the interrupt routines to exit from sleep.
+ */
+extern void halSleepExit(void);
+
+/*
+ * Set the max sleep loop time lesser than the T2 rollover period.
+ */
+extern void halSetMaxSleepLoopTime(uint32 rolloverTime);
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 46 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\common\\cc2540\\OnBoard.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+/******************************************************************************
+ Filename: OSAL.h
+ Revised: $Date: 2012-02-17 15:07:16 -0800 (Fri, 17 Feb 2012) $
+ Revision: $Revision: 29376 $
+
+ Description: This API allows the software components in the Z-Stack to be
+ written independently of the specifics of the operating system,
+ kernel, or tasking environment (including control loops or
+ connect-to-interrupt systems).
+
+
+ Copyright 2004-2011 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+/* - LIMITS.H -
+
+ Integral ANSI element sizes.
+
+ $Revision: 38615 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+#line 1 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+/* - SYSMAC.H -
+
+ Defines system macros to maintain source compatibility
+ with different IAR compilers.
+
+ $Revision: 6040 $
+
+ Copyright 1986 - 1999 IAR Systems. All rights reserved.
+*/
+
+
+
+
+
+ #pragma system_include
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 65 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+#line 73 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\sysmac.h"
+
+
+
+
+
+
+
+/* Macro for frmwri and frmrd */
+
+
+/* Typedefs put here to appear only once */
+typedef unsigned int size_t;
+typedef signed int ptrdiff_t;
+
+#line 18 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 80 "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 6.0\\8051\\inc\\clib\\limits.h"
+
+#line 56 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+/**************************************************************************************************
+ Filename: OSAL_Memory.h
+ Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
+ Revision: $Revision: 23160 $
+
+ Description: This module defines the OSAL memory control functions.
+
+
+ Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+
+
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialize memory manager.
+ */
+ void osal_mem_init( void );
+
+ /*
+ * Setup efficient search for the first free block of heap.
+ */
+ void osal_mem_kick( void );
+
+ /*
+ * Allocate a block of memory.
+ */
+
+
+
+
+ void *osal_mem_alloc( uint16 size );
+
+
+ /*
+ * Free a block of memory.
+ */
+
+
+
+
+ void osal_mem_free( void *ptr );
+
+
+#line 130 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+#line 137 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Memory.h"
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 59 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\osal\\include\\OSAL_Timers.h"
+/**************************************************************************************************
+ Filename: OSAL_Timers.h
+ Revised: $Date: 2011-09-16 19:09:24 -0700 (Fri, 16 Sep 2011) $
+ Revision: $Revision: 27618 $
+
+ Description: This file contains the OSAL Timer definition and manipulation functions.
+
+
+ Copyright 2004-2009 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ * the unit is chosen such that the 320us tick equivalent can fit in
+ * 32 bits.
+ */
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+ /*
+ * Initialization for the OSAL Timer System.
+ */
+ extern void osalTimerInit( void );
+
+ /*
+ * Set a Timer
+ */
+ extern uint8 osal_start_timerEx( uint8 task_id, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Set a timer that reloads itself.
+ */
+ extern uint8 osal_start_reload_timer( uint8 taskID, uint16 event_id, uint32 timeout_value );
+
+ /*
+ * Stop a Timer
+ */
+ extern uint8 osal_stop_timerEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Get the tick count of a Timer.
+ */
+ extern uint32 osal_get_timeoutEx( uint8 task_id, uint16 event_id );
+
+ /*
+ * Simulated Timer Interrupt Service Routine
+ */
+
+ extern void osal_timer_ISR( void );
+
+ /*
+ * Adjust timer tables
+ */
+ extern void osal_adjust_timers( void );
+
+ /*
+ * Update timer tables
+ */
+ extern void osalTimerUpdate( uint32 updateTime );
+
+ /*
+ * Count active timers
+ */
+ extern uint8 osal_timer_num_active( void );
+
+ /*
+ * Set the hardware timer interrupts for sleep mode.
+ * These functions should only be called in OSAL_PwrMgr.c
+ */
+ extern void osal_sleep_timers( void );
+ extern void osal_unsleep_timers( void );
+
+ /*
+ * Read the system clock - returns milliseconds
+ */
+ extern uint32 osal_GetSystemClock( void );
+
+ /*
+ * Get the next OSAL timer expiration.
+ * This function should only be called in OSAL_PwrMgr.c
+ */
+ extern uint32 osal_next_timeout( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 60 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\osal\\include\\osal.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/*** Interrupts ***/
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+typedef struct
+{
+ void *next;
+ uint16 len;
+ uint8 dest_id;
+} osal_msg_hdr_t;
+
+typedef struct
+{
+ uint8 event;
+ uint8 status;
+} osal_event_hdr_t;
+
+typedef void * osal_msg_q_t;
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*********************************************************************
+ * FUNCTIONS
+ */
+
+/*** Message Management ***/
+
+ /*
+ * Task Message Allocation
+ */
+ extern uint8 * osal_msg_allocate(uint16 len );
+
+ /*
+ * Task Message Deallocation
+ */
+ extern uint8 osal_msg_deallocate( uint8 *msg_ptr );
+
+ /*
+ * Send a Task Message
+ */
+ extern uint8 osal_msg_send( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern uint8 osal_msg_push_front( uint8 destination_task, uint8 *msg_ptr );
+
+ /*
+ * Receive a Task Message
+ */
+ extern uint8 *osal_msg_receive( uint8 task_id );
+
+ /*
+ * Find in place a matching Task Message / Event.
+ */
+ extern osal_event_hdr_t *osal_msg_find(uint8 task_id, uint8 event);
+
+ /*
+ * Enqueue a Task Message
+ */
+ extern void osal_msg_enqueue( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Enqueue a Task Message Up to Max
+ */
+ extern uint8 osal_msg_enqueue_max( osal_msg_q_t *q_ptr, void *msg_ptr, uint8 max );
+
+ /*
+ * Dequeue a Task Message
+ */
+ extern void *osal_msg_dequeue( osal_msg_q_t *q_ptr );
+
+ /*
+ * Push a Task Message to head of queue
+ */
+ extern void osal_msg_push( osal_msg_q_t *q_ptr, void *msg_ptr );
+
+ /*
+ * Extract and remove a Task Message from queue
+ */
+ extern void osal_msg_extract( osal_msg_q_t *q_ptr, void *msg_ptr, void *prev_ptr );
+
+
+/*** Task Synchronization ***/
+
+ /*
+ * Set a Task Event
+ */
+ extern uint8 osal_set_event( uint8 task_id, uint16 event_flag );
+
+
+ /*
+ * Clear a Task Event
+ */
+ extern uint8 osal_clear_event( uint8 task_id, uint16 event_flag );
+
+
+/*** Interrupt Management ***/
+
+ /*
+ * Register Interrupt Service Routine (ISR)
+ */
+ extern uint8 osal_isr_register( uint8 interrupt_id, void (*isr_ptr)( uint8* ) );
+
+ /*
+ * Enable Interrupt
+ */
+ extern uint8 osal_int_enable( uint8 interrupt_id );
+
+ /*
+ * Disable Interrupt
+ */
+ extern uint8 osal_int_disable( uint8 interrupt_id );
+
+
+/*** Task Management ***/
+
+ /*
+ * Initialize the Task System
+ */
+ extern uint8 osal_init_system( void );
+
+ /*
+ * System Processing Loop
+ */
+
+
+
+ extern void osal_start_system( void );
+
+
+ /*
+ * One Pass Throu the OSAL Processing Loop
+ */
+ extern void osal_run_system( void );
+
+ /*
+ * Get the active task ID
+ */
+ extern uint8 osal_self( void );
+
+
+/*** Helper Functions ***/
+
+ /*
+ * String Length
+ */
+ extern int osal_strlen( char *pString );
+
+ /*
+ * Memory copy
+ */
+ extern void *osal_memcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory Duplicate - allocates and copies
+ */
+ extern void *osal_memdup( const void *src, unsigned int len );
+
+ /*
+ * Reverse Memory copy
+ */
+ extern void *osal_revmemcpy( void*, const void *, unsigned int );
+
+ /*
+ * Memory compare
+ */
+ extern uint8 osal_memcmp( const void *src1, const void *src2, unsigned int len );
+
+ /*
+ * Memory set
+ */
+ extern void *osal_memset( void *dest, uint8 value, int len );
+
+ /*
+ * Build a uint16 out of 2 bytes (0 then 1).
+ */
+ extern uint16 osal_build_uint16( uint8 *swapped );
+
+ /*
+ * Build a uint32 out of sequential bytes.
+ */
+ extern uint32 osal_build_uint32( uint8 *swapped, uint8 len );
+
+ /*
+ * Convert long to ascii string
+ */
+
+ extern uint8 *_ltoa( uint32 l, uint8 * buf, uint8 radix );
+
+
+ /*
+ * Random number generator
+ */
+ extern uint16 osal_rand( void );
+
+ /*
+ * Buffer an uint32 value - LSB first.
+ */
+ extern uint8* osal_buffer_uint32( uint8 *buf, uint32 val );
+
+ /*
+ * Buffer an uint24 value - LSB first
+ */
+ extern uint8* osal_buffer_uint24( uint8 *buf, uint24 val );
+
+ /*
+ * Is all of the array elements set to a value?
+ */
+ extern uint8 osal_isbufset( uint8 *buf, uint8 val, uint8 len );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 47 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\common\\cc2540\\OnBoard.h"
+
+/*********************************************************************
+ */
+// Internal (MCU) RAM addresses
+
+
+
+
+// Internal (MCU) heap size
+
+
+
+
+// Memory Allocation Heap
+
+
+
+
+
+
+// Initialization levels
+
+
+
+
+
+
+typedef struct
+{
+ osal_event_hdr_t hdr;
+ uint8 state; // shift
+ uint8 keys; // keys
+} keyChange_t;
+
+// Timer clock and power-saving definitions
+
+
+
+/* OSAL timer defines */
+
+
+
+
+
+extern void _itoa(uint16 num, uint8 *buf, uint8 radix);
+
+
+
+
+
+
+/* Tx and Rx buffer size defines used by SPIMgr.c */
+
+
+
+
+
+/* system restart and boot loader used from MTEL.c */
+// Restart system from absolute beginning
+// Disables interrupts, forces WatchDog reset
+
+
+
+
+
+
+
+
+/* Reset reason for reset indication */
+
+
+/* port definition stuff used by MT */
+#line 133 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\common\\cc2540\\OnBoard.h"
+
+/* sleep macros required by OSAL_PwrMgr.c */
+
+
+
+
+
+/* used by MTEL.c */
+uint8 OnBoard_SendKeys( uint8 keys, uint8 state );
+
+/*
+ * Board specific random number generator
+ */
+extern uint16 Onboard_rand( void );
+
+/*
+ * Get elapsed timer clock counts
+ * reset: reset count register if TRUE
+ */
+extern uint32 TimerElapsed( void );
+
+/*
+ * Initialize the Peripherals
+ * level: 0=cold, 1=warm, 2=ready
+ */
+extern void InitBoard( uint8 level );
+
+/*
+ * Register for all key events
+ */
+extern uint8 RegisterForKeys( uint8 task_id );
+
+/* Keypad Control Functions */
+
+/*
+ * Send "Key Pressed" message to application
+ */
+extern uint8 OnBoard_SendKeys( uint8 keys, uint8 shift);
+
+/*
+ * Callback routine to handle keys
+ */
+extern void OnBoard_KeyCallback ( uint8 keys, uint8 state );
+
+/*
+ * Perform a soft reset - jump to 0x0
+ */
+extern __near_func void Onboard_soft_reset( void );
+
+
+/*********************************************************************
+ */
+
+#line 47 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\common\\cc2540\\OnBoard.c"
+
+
+
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_led.h"
+/**************************************************************************************************
+ Filename: hal_led.h
+ Revised: $Date: 2007-07-06 10:42:24 -0700 (Fri, 06 Jul 2007) $
+ Revision: $Revision: 13579 $
+
+ Description: This file contains the interface to the LED Service.
+
+
+ Copyright 2005-2007 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/*********************************************************************
+ * INCLUDES
+ */
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\include\\hal_board.h"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+/*******************************************************************************
+ Filename: hal_board_cfg.h
+ Revised: $Date: 2013-02-27 11:32:02 -0800 (Wed, 27 Feb 2013) $
+ Revision: $Revision: 33315 $
+
+ Description:
+
+ Abstract board-specific registers, addresses, & initialization for H/W based on the
+ Texas Instruments CC254x (8051 core).
+
+
+ Copyright 2006-2013 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+*******************************************************************************/
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+ * INCLUDES
+ */
+
+
+
+
+
+/*******************************************************************************
+ * CONSTANTS
+ */
+
+/* Board Identifier */
+
+
+
+
+
+/* Clock Speed */
+
+
+
+/* Sleep Clock */
+
+
+
+
+// For non-USB, assume external, unless an internal crystal is explicitly indicated.
+
+
+
+
+
+
+// Minimum Time for Stable External 32kHz Clock (in ms)
+
+
+/* LCD Max Chars and Buffer */
+
+
+
+/* LED Configuration */
+
+#line 101 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+
+
+/* 1 - Green */
+
+
+
+
+
+
+ /* 2 - Red */
+
+
+
+
+
+ /* 3 - Yellow */
+
+
+
+
+
+
+/* Push Button Configuration */
+
+
+
+
+/* S1 */
+
+
+
+#line 140 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Joystick Center Press */
+
+
+
+
+/* OSAL NV implemented by internal flash pages. */
+
+// Flash is partitioned into 8 banks of 32 KB or 16 pages.
+
+
+// Flash is constructed of 128 pages of 2 KB.
+
+
+// SNV can use a larger logical page size to accomodate more or bigger items or extend lifetime.
+
+
+
+// CODE banks get mapped into the XDATA range 8000-FFFF.
+
+
+// The last 16 bytes of the last available page are reserved for flash lock bits.
+
+
+// NV page definitions must coincide with segment declaration in project *.xcl file.
+#line 172 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+// Re-defining Z_EXTADDR_LEN here so as not to include a Z-Stack .h file.
+
+
+
+
+
+
+
+
+// Used by DMA macros to shift 1 to create a mask for DMA registers.
+
+
+
+
+
+
+
+/* Critical Vdd Monitoring to prevent flash damage or radio lockup. */
+
+// Vdd/3 / Internal Reference X ENOB --> (Vdd / 3) / 1.15 X 127
+
+
+
+
+
+
+
+/*******************************************************************************
+ * MACROS
+ */
+
+/* Cache Prefetch Control */
+
+
+
+
+/* Setting Clocks */
+
+// switch to the 16MHz HSOSC and wait until it is stable
+
+
+
+
+
+
+// switch to the 32MHz XOSC and wait until it is stable
+
+
+
+
+
+
+// set 32kHz OSC and wait until it is stable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* Board Initialization */
+#line 256 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Debounce */
+
+
+/* ----------- Push Buttons ---------- */
+#line 267 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* LED's */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#line 315 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* XNV */
+
+
+
+
+
+
+
+// The TI reference design uses UART1 Alt. 2 in SPI mode.
+#line 356 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Driver Configuration */
+
+/* Set to TRUE enable H/W TIMER usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable ADC usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable DMA usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable Flash access, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable AES usage, FALSE disable it */
+
+
+
+
+
+
+
+
+/* Set to TRUE enable LCD usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable LED usage, FALSE disable it */
+#line 400 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+/* Set to TRUE enable KEY usage, FALSE disable it */
+
+
+
+
+/* Set to TRUE enable UART usage, FALSE disable it */
+#line 414 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+
+ // Always prefer to use DMA over ISR.
+#line 444 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\target\\CC2540EB\\hal_board_cfg.h"
+
+ // Used to set P2 priority - USART0 over USART1 if both are defined.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*******************************************************************************
+*/
+#line 2 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\include\\hal_board.h"
+#line 52 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_led.h"
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+/* LEDS - The LED number is the same as the bit position */
+
+
+
+
+
+
+/* Modes */
+
+
+
+
+
+
+/* Defaults */
+
+
+
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+
+/*
+ * Initialize LED Service.
+ */
+extern void HalLedInit( void );
+
+/*
+ * Set the LED ON/OFF/TOGGLE.
+ */
+extern uint8 HalLedSet( uint8 led, uint8 mode );
+
+/*
+ * Blink the LED.
+ */
+extern void HalLedBlink( uint8 leds, uint8 cnt, uint8 duty, uint16 time );
+
+/*
+ * Put LEDs in sleep state - store current values
+ */
+extern void HalLedEnterSleep( void );
+
+/*
+ * Retore LEDs from sleep state
+ */
+extern void HalLedExitSleep( void );
+
+/*
+ * Return LED state
+ */
+extern uint8 HalLedGetState ( void );
+
+/*********************************************************************
+*********************************************************************/
+
+
+
+
+
+#line 51 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\common\\cc2540\\OnBoard.c"
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_key.h"
+/**************************************************************************************************
+ Filename: hal_key.h
+ Revised: $Date: 2007-07-06 10:42:24 -0700 (Fri, 06 Jul 2007) $
+ Revision: $Revision: 13579 $
+
+ Description: This file contains the interface to the KEY Service.
+
+
+ Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
+
+ IMPORTANT: Your use of this Software is limited to those specific rights
+ granted under the terms of a software license agreement between the user
+ who downloaded the software, his/her employer (which must be your employer)
+ and Texas Instruments Incorporated (the "License"). You may not use this
+ Software unless you agree to abide by the terms of the License. The License
+ limits your use, and you acknowledge, that the Software may not be modified,
+ copied or distributed unless embedded on a Texas Instruments microcontroller
+ or used solely and exclusively in conjunction with a Texas Instruments radio
+ frequency transceiver, which is integrated into your product. Other than for
+ the foregoing purpose, you may not use, reproduce, copy, prepare derivative
+ works of, modify, distribute, perform, display or sell this Software and/or
+ its documentation for any purpose.
+
+ YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
+ PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
+ NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
+ TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
+ NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
+ LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
+ INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
+ OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
+ OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
+ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
+
+ Should you have any questions regarding your right to use this Software,
+ contact Texas Instruments Incorporated at www.TI.com.
+**************************************************************************************************/
+
+
+
+
+
+
+
+
+
+/**************************************************************************************************
+ * INCLUDES
+ **************************************************************************************************/
+#line 1 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Components\\hal\\include\\hal_board.h"
+#line 52 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\WIMU\\CC2540DB\\..\\..\\..\\..\\Components\\hal\\include\\hal_key.h"
+
+/**************************************************************************************************
+ * MACROS
+ **************************************************************************************************/
+
+/**************************************************************************************************
+ * CONSTANTS
+ **************************************************************************************************/
+
+/* Interrupt option - Enable or disable */
+
+
+
+/* Key state - shift or nornal */
+
+
+
+
+
+
+
+
+
+
+
+
+/* Joystick */
+
+
+
+
+
+
+/* Buttons */
+
+
+
+
+
+
+/**************************************************************************************************
+ * TYPEDEFS
+ **************************************************************************************************/
+typedef void (*halKeyCBack_t) (uint8 keys, uint8 state);
+
+/**************************************************************************************************
+ * GLOBAL VARIABLES
+ **************************************************************************************************/
+extern bool Hal_KeyIntEnable;
+
+/**************************************************************************************************
+ * FUNCTIONS - API
+ **************************************************************************************************/
+
+/*
+ * Initialize the Key Service
+ */
+extern void HalKeyInit( void );
+
+/*
+ * Configure the Key Service
+ */
+extern void HalKeyConfig( bool interruptEnable, const halKeyCBack_t cback);
+
+/*
+ * Read the Key status
+ */
+extern uint8 HalKeyRead( void);
+
+/*
+ * Enter sleep mode, store important values
+ */
+extern void HalKeyEnterSleep ( void );
+
+/*
+ * Exit sleep mode, retore values
+ */
+extern uint8 HalKeyExitSleep ( void );
+
+/*
+ * This is for internal used by hal_driver
+ */
+extern void HalKeyPoll ( void );
+
+/*
+ * This is for internal used by hal_sleep
+ */
+extern bool HalKeyPressed( void );
+
+extern uint8 hal_key_keys(void);
+
+extern uint8 hal_key_int_keys(void);
+
+/**************************************************************************************************
+**************************************************************************************************/
+
+
+
+
+
+#line 52 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\common\\cc2540\\OnBoard.c"
+
+
+/*********************************************************************
+ * MACROS
+ */
+
+/*********************************************************************
+ * CONSTANTS
+ */
+
+// Task ID not initialized
+
+
+
+/*********************************************************************
+ * TYPEDEFS
+ */
+
+/*********************************************************************
+ * GLOBAL VARIABLES
+ */
+uint8 OnboardKeyIntEnable;
+
+
+/*********************************************************************
+ * EXTERNAL VARIABLES
+ */
+
+/*********************************************************************
+ * EXTERNAL FUNCTIONS
+ */
+extern uint8 LL_PseudoRand( uint8 *randData, uint8 dataLen );
+
+#line 94 "D:\\Simon_Dev\\WIMuGPS\\Workspace\\openwimu\\Firmware\\Radio\\Projects\\Wimu\\Projects\\ble\\common\\cc2540\\OnBoard.c"
+void appForceBoot(void);
+
+
+/*********************************************************************
+ * LOCAL VARIABLES
+ */
+
+// Registered keys task ID, initialized to NOT USED.
+static uint8 registeredKeysTaskID = 0xFF;
+
+/*********************************************************************
+ * @fn InitBoard()
+ * @brief Initialize the CC2540DB Board Peripherals
+ * @param level: COLD,WARM,READY
+ * @return None
+ */
+void InitBoard( uint8 level )
+{
+ if ( level == 0 )
+ {
+ // Interrupts off
+ osal_int_disable( 0xFF );
+ // Turn all LEDs off
+ HalLedSet( (0x01 | 0x02 | 0x04 | 0x08), 0x00 );
+ // Check for Brown-Out reset
+// ChkReset();
+ }
+ else // !OB_COLD
+ {
+ /* Initialize Key stuff */
+ OnboardKeyIntEnable = 0x01;
+ //OnboardKeyIntEnable = HAL_KEY_INTERRUPT_DISABLE;
+ HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback);
+ }
+}
+
+/*********************************************************************
+ * @fn Onboard_rand
+ *
+ * @brief Random number generator
+ *
+ * @param none
+ *
+ * @return uint16 - new random number
+ *
+ *********************************************************************/
+uint16 Onboard_rand( void )
+{
+ uint16 randNum;
+
+ LL_PseudoRand( (uint8 *)&randNum, 2 );
+
+ return ( randNum );
+}
+
+/*********************************************************************
+ * @fn _itoa
+ *
+ * @brief convert a 16bit number to ASCII
+ *
+ * @param num -
+ * buf -
+ * radix -
+ *
+ * @return void
+ *
+ *********************************************************************/
+void _itoa(uint16 num, uint8 *buf, uint8 radix)
+{
+ char c,i;
+ uint8 *p, rst[5];
+
+ p = rst;
+ for ( i=0; i<5; i++,p++ )
+ {
+ c = num % radix; // Isolate a digit
+ *p = c + (( c < 10 ) ? '0' : '7'); // Convert to Ascii
+ num /= radix;
+ if ( !num )
+ break;
+ }
+
+ for ( c=0 ; c<=i; c++ )
+ *buf++ = *p--; // Reverse character order
+
+ *buf = '\0';
+}
+
+/*********************************************************************
+ * "Keyboard" Support
+ *********************************************************************/
+
+/*********************************************************************
+ * Keyboard Register function
+ *
+ * The keyboard handler is setup to send all keyboard changes to
+ * one task (if a task is registered).
+ *
+ * If a task registers, it will get all the keys. You can change this
+ * to register for individual keys.
+ *********************************************************************/
+uint8 RegisterForKeys( uint8 task_id )
+{
+ // Allow only the first task
+ if ( registeredKeysTaskID == 0xFF )
+ {
+ registeredKeysTaskID = task_id;
+ return ( 1 );
+ }
+ else
+ return ( 0 );
+}
+
+/*********************************************************************
+ * @fn OnBoard_SendKeys
+ *
+ * @brief Send "Key Pressed" message to application.
+ *
+ * @param keys - keys that were pressed
+ * state - shifted
+ *
+ * @return status
+ *********************************************************************/
+uint8 OnBoard_SendKeys( uint8 keys, uint8 state )
+{
+ keyChange_t *msgPtr;
+
+ if ( registeredKeysTaskID != 0xFF )
+ {
+ // Send the address to the task
+ msgPtr = (keyChange_t *)osal_msg_allocate( sizeof(keyChange_t) );
+ if ( msgPtr )
+ {
+ msgPtr->hdr.event = 0xC0;
+ msgPtr->state = state;
+ msgPtr->keys = keys;
+
+ osal_msg_send( registeredKeysTaskID, (uint8 *)msgPtr );
+ }
+ return ( 0x00 );
+ }
+ else
+ return ( 0x01 );
+}
+
+/*********************************************************************
+ * @fn OnBoard_KeyCallback
+ *
+ * @brief Callback service for keys
+ *
+ * @param keys - keys that were pressed
+ * state - shifted
+ *
+ * @return void
+ *********************************************************************/
+void OnBoard_KeyCallback ( uint8 keys, uint8 state )
+{
+ uint8 shift;
+ (void)state;
+
+ // shift key (S1) is used to generate key interrupt
+ // applications should not use S1 when key interrupt is enabled
+ shift = (OnboardKeyIntEnable == 0x01) ? 0 : ((keys & 0x20) ? 1 : 0);
+
+ if ( OnBoard_SendKeys( keys, shift ) != 0x00 )
+ {
+ // Process SW1 here
+ if ( keys & 0x01 ) // Switch 1
+ {
+ }
+ // Process SW2 here
+ if ( keys & 0x02 ) // Switch 2
+ {
+ }
+ // Process SW3 here
+ if ( keys & 0x10 ) // Switch 3
+ {
+ }
+ // Process SW4 here
+ if ( keys & 0x08 ) // Switch 4
+ {
+ }
+ // Process SW5 here
+ if ( keys & 0x04 ) // Switch 5
+ {
+ }
+ // Process SW6 here
+ if ( keys & 0x20 ) // Switch 6
+ {
+ }
+ }
+
+ /* If any key is currently pressed down and interrupt
+ is still enabled, disable interrupt and switch to polling */
+ if( keys != 0 )
+ {
+ if( OnboardKeyIntEnable == 0x01 )
+ {
+ OnboardKeyIntEnable = 0x00;
+ HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback);
+ }
+ }
+ /* If no key is currently pressed down and interrupt
+ is disabled, enable interrupt and turn off polling */
+ else
+ {
+ if( OnboardKeyIntEnable == 0x00 )
+ {
+ OnboardKeyIntEnable = 0x01;
+ HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback);
+ }
+ }
+}
+
+/*********************************************************************
+ * @fn Onboard_soft_reset
+ *
+ * @brief Effect a soft reset.
+ *
+ * @param none
+ *
+ * @return none
+ *
+ *********************************************************************/
+__near_func void Onboard_soft_reset( void )
+{
+ do { EA = 0; } while (320 == -1);
+ asm("LJMP 0x0");
+}
+
+
+
+
+
+
+/*********************************************************************
+ * @fn appForceBoot
+ *
+ * @brief Common force-boot function for the HCI library to invoke.
+ *
+ * @param none
+ *
+ * @return void
+ *********************************************************************/
+void appForceBoot(void)
+{
+ // Dummy function for HCI library that cannot depend on the SBL build defines.
+}
+
+
+/*********************************************************************
+*********************************************************************/
diff --git a/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/WIMU.map b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/WIMU.map
new file mode 100644
index 0000000..a7e9dc8
--- /dev/null
+++ b/Firmware/Radio/Projects/Wimu/Projects/ble/WIMU/CC2540DB/CC2540F128-WIMU/List/WIMU.map
@@ -0,0 +1,30140 @@
+################################################################################
+# #
+# IAR Universal Linker V5.0.2.5/W32 #
+# #
+# Link time = 27/Mar/2017 11:08:50 #
+# Target CPU = x51 #
+# List file = D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\List\WIMU.map #
+# Output file 1 = D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Exe\WIMU.hex #
+# Format: intel-extended #
+# Output file 2 = D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Exe\WIMU.d51 #
+# Format: debug #
+# UBROF version 10.0.3 #
+# Using library modules for C-SPY (-rt) #
+# Command line = "-IC:\Program Files (x86)\IAR Systems\Embedded Wo #
+# rkbench 6.0\8051\CONFIG\" #
+# -D_NR_OF_BANKS=0x07 -D_CODEBANK_END=0xFFFF #
+# -D_CODEBANK_START=0x8000 -D?CBANK_MASK=0xFF #
+# -D?CBANK=0x9F #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\Libraries\CC2540 #
+# DB\bin\CC2540_BLE_peri.lib #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\Libraries\Common #
+# \bin\CC254x_BLE_HCI_TL_None.lib #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\OSAL.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\OSAL_ClockBLE.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\OSAL_Memory.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\OSAL_PwrMgr.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\OSAL_Timers.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\OSAL_WIMU.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\OnBoard.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\WIMU_Main.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\actimetryservice.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\battservice.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\devinfoservice.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\gap.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\gapbondmgr.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\gatt_uuid.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\gpsservice.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\hal_adc.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\hal_aes.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\hal_crc.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\hal_dma.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\hal_drivers.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\hal_flash.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\hal_key.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\hal_led.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\hal_sleep.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\hal_startup.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\hal_timer.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\hal_uart.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\npi.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\osal_bufmgr.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\osal_cbtimer.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\osal_snv.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\peripheral.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\st_util.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\timeservice.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\wimu.r51 #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Obj\wimu_util.r51 #
+# -o #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\Exe\WIMU.d51 #
+# -l #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\CC #
+# 2540F128-WIMU\List\WIMU.map #
+# -xmsn -f #
+# D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\ #
+# Radio\Projects\Wimu\Projects\ble\WIMU\CC2540DB\.. #
+# \..\common\cc2540\ti_51ew_cc2540f128b.xcl #
+# (-D_IDATA0_START=0x00 -D_IDATA0_END=0xFF #
+# -D_PDATA0_START=0x1E00 -D_PDATA0_END=0x1EFF #
+# -D_IXDATA0_START=0x0001 -D_IXDATA0_END=0x1EFF #
+# -D_XDATA0_START=_IXDATA0_START #
+# -D_XDATA0_END=_IXDATA0_END #
+# -D_NEAR_CODE_START=0x0000 #
+# -D_FIRST_BANK_ADDR=0x10000 -D?REGISTER_BANK=0x0 #
+# -D_REGISTER_BANK_START=0x0 -D?PBANK_NUMBER=0x1E #
+# -D_BREG_START=0x00 -D?VB=0x20 -D?ESP=0x9B #
+# -Z(BIT)BREG=_BREG_START -Z(BIT)BIT_N=0-7F #
+# -Z(DATA)REGISTERS+8=_REGISTER_BANK_START #
+# -Z(DATA)BDATA_Z,BDATA_N,BDATA_I=20-2F #
+# -Z(DATA)VREG+_NR_OF_VIRTUAL_REGISTERS=08-7F #
+# -Z(DATA)PSP,XSP=08-7F -Z(DATA)DOVERLAY=08-7F #
+# -Z(DATA)DATA_I,DATA_Z,DATA_N=08-7F #
+# -U(IDATA)0-7F=(DATA)0-7F #
+# -Z(IDATA)IDATA_I,IDATA_Z,IDATA_N=08-_IDATA0_END #
+# -Z(IDATA)ISTACK+_IDATA_STACK_SIZE#08-_IDATA0_END #
+# -Z(IDATA)IOVERLAY=08-FF -Z(CODE)INTVEC=0 #
+# -Z(CODE)CSTART=_NEAR_CODE_START-(_CODEBANK_START- #
+# 1) #
+# -Z(CODE)BIT_ID,BDATA_ID,DATA_ID,IDATA_ID,IXDATA_I #
+# D,PDATA_ID,XDATA_ID=_NEAR_CODE_START-(_CODEBANK_S #
+# TART-1) #
+# -D_SLEEP_CODE_SPACE_START=(_CODEBANK_START-8) #
+# -D_SLEEP_CODE_SPACE_END=(_CODEBANK_START-1) #
+# -Z(CODE)SLEEP_CODE=_SLEEP_CODE_SPACE_START-_SLEEP #
+# _CODE_SPACE_END #
+# -Z(CODE)BANK_RELAYS,RCODE,DIFUNCT,CODE_C,CODE_N,N #
+# EAR_CODE=_NEAR_CODE_START-(_CODEBANK_START-1) #
+# -P(CONST)XDATA_ROM_C=0x8000-0xFFFF #
+# -P(CODE)XDATA_ROM_C_FLASH=0x18000-0x1FFFF #
+# -QXDATA_ROM_C=XDATA_ROM_C_FLASH #
+# -P(CODE)BANKED_CODE=_NEAR_CODE_START-(_CODEBANK_S #
+# TART-1),[(_CODEBANK_START+_FIRST_BANK_ADDR)-(_COD #
+# EBANK_END+_FIRST_BANK_ADDR)]*_NR_OF_BANKS+10000 #
+# -Z(CODE)CHECKSUM#(_CODEBANK_START-1) #
+# -Z(XDATA)EXT_STACK+_EXTENDED_STACK_SIZE=_EXTENDED #
+# _STACK_START #
+# -Z(XDATA)PSTACK+_PDATA_STACK_SIZE=_PDATA0_START-_ #
+# PDATA0_END #
+# -Z(XDATA)XSTACK+_XDATA_STACK_SIZE=_XDATA0_START-_ #
+# XDATA0_END #
+# -Z(XDATA)PDATA_Z,PDATA_I=_PDATA0_START-_PDATA0_EN #
+# D #
+# -P(XDATA)PDATA_N=_PDATA0_START-_PDATA0_END #
+# -Z(XDATA)IXDATA_Z,IXDATA_I=_IXDATA0_START-_IXDATA #
+# 0_END #
+# -P(XDATA)IXDATA_N=_IXDATA0_START-_IXDATA0_END #
+# -Z(XDATA)XDATA_Z,XDATA_I=_XDATA0_START-_XDATA0_EN #
+# D #
+# -P(XDATA)XDATA_N=_XDATA0_START-_XDATA0_END #
+# -Z(XDATA)XDATA_HEAP+_XDATA_HEAP_SIZE=_XDATA0_STAR #
+# T-_XDATA0_END #
+# -cx51 -D_BLENV_ADDRESS_SPACE_START=0x3E800 #
+# -D_BLENV_ADDRESS_SPACE_END=0x3F7FF #
+# -Z(CODE)BLENV_ADDRESS_SPACE=_BLENV_ADDRESS_SPACE_ #
+# START-_BLENV_ADDRESS_SPACE_END #
+# -M(CODE)[(_CODEBANK_START+_FIRST_BANK_ADDR)-(_COD #
+# EBANK_END+_FIRST_BANK_ADDR)]*_NR_OF_BANKS+0x10000 #
+# =0x8000 #
+# -ww69=i -D_BANK0_START=0x00000 #
+# -D_BANK0_END=0x07FFF -D_BANK1_START=0x18000 #
+# -D_BANK1_END=0x1FFFF -D_BANK2_START=0x28000 #
+# -D_BANK2_END=0x2FFFF -D_BANK3_START=0x38000 #
+# -D_BANK3_END=(_BLENV_ADDRESS_SPACE_START-1) #
+# -P(CODE)BANK0=_BANK0_START-_BANK0_END #
+# -P(CODE)BANK1=_BANK1_START-_BANK1_END #
+# -P(CODE)BANK2=_BANK2_START-_BANK2_END #
+# -P(CODE)BANK3=_BANK3_START-_BANK3_END #
+# -D_FLASH_LOCK_BITS_START=0x3FFF0 #
+# -D_FLASH_LOCK_BITS_END=0x3FFFF #
+# -Z(CODE)FLASH_LOCK_BITS=_FLASH_LOCK_BITS_START-_F #
+# LASH_LOCK_BITS_END #
+# -U(CODE)0x0000=(CODE)_FLASH_LOCK_BITS_START-_FLAS #
+# H_LOCK_BITS_END) #
+# -D_NR_OF_VIRTUAL_REGISTERS=10 -D?PBANK=0x93 #
+# -e?BCALL_FF=?BCALL -e?BRET_FF=?BRET #
+# -e?BDISPATCH_FF=?BDISPATCH #
+# -e_medium_write=_formatted_write #
+# -e_medium_read=_formatted_read -rt #
+# -Ointel-extended=D:\Simon_Dev\WIMuGPS\Workspace\o #
+# penwimu\Firmware\Radio\Projects\Wimu\Projects\ble #
+# \WIMU\CC2540DB\CC2540F128-WIMU\Exe\WIMU.hex #
+# -s __program_start #
+# "C:\Program Files (x86)\IAR Systems\Embedded Work #
+# bench 6.0\8051\LIB\CLIB\cl-pli-blxd-1e16x01.r51" #
+# -D_IDATA_STACK_SIZE=0xD5 #
+# -D_EXTENDED_STACK_START=0x00 #
+# -D_EXTENDED_STACK_SIZE=0x00 #
+# -D_PDATA_STACK_SIZE=0x00 #
+# -D_XDATA_STACK_SIZE=0x300 #
+# -D_XDATA_HEAP_SIZE=0xFFF -D_FAR_HEAP_SIZE=0xFFF #
+# -D_HUGE_HEAP_SIZE=0xFFF #
+# -D_FAR22_HEAP_SIZE=0xFFF #
+# #
+# Copyright (C) 1987-2010 IAR Systems AB. #
+################################################################################
+
+
+
+
+
+ ****************************************
+ * *
+ * CROSS REFERENCE *
+ * *
+ ****************************************
+
+ Program entry at : CODE 0000010A Relocatable, from module : CSTARTUP
+
+
+
+
+ ****************************************
+ * *
+ * RUNTIME MODEL *
+ * *
+ ****************************************
+
+ __SystemLibrary = CLib
+ __calling_convention = xdata_reentrant
+ __code_model = banked
+ __core = plain
+ __data_model = large
+ __dptr_size = 16
+ __extended_stack = disabled
+ __location_for_constants = data
+ __number_of_dptrs = 1
+ __rt_version = 1
+
+
+
+ ****************************************
+ * *
+ * MODULE MAP *
+ * *
+ ****************************************
+
+
+ DEFINED ABSOLUTE ENTRIES
+ *************************************************************************
+
+ DEFINED ABSOLUTE ENTRIES
+ PROGRAM MODULE, NAME : ?ABS_ENTRY_MOD
+
+Absolute parts
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ _FAR22_HEAP_SIZE 00000FFF
+ _HUGE_HEAP_SIZE 00000FFF
+ _FAR_HEAP_SIZE 00000FFF
+ _XDATA_HEAP_SIZE 00000FFF
+ _XDATA_STACK_SIZE 00000300
+ _PDATA_STACK_SIZE 00000000
+ _EXTENDED_STACK_SIZE 00000000
+ _EXTENDED_STACK_START 00000000
+ _IDATA_STACK_SIZE 000000D5
+ ?PBANK 00000093
+ _NR_OF_VIRTUAL_REGISTERS
+ 00000010
+ _FLASH_LOCK_BITS_END 0001FFFF
+ _FLASH_LOCK_BITS_START
+ 0001FFF0
+ _BANK3_END 0001E7FF
+ _BANK3_START 00018000
+ _BANK2_END 00017FFF
+ _BANK2_START 00010000
+ _BANK1_END 0000FFFF
+ _BANK1_START 00008000
+ _BANK0_END 00007FFF
+ _BANK0_START 00000000
+ _BLENV_ADDRESS_SPACE_END
+ 0001F7FF
+ _BLENV_ADDRESS_SPACE_START
+ 0001E800
+ _SLEEP_CODE_SPACE_END 00007FFF
+ _SLEEP_CODE_SPACE_START
+ 00007FF8
+ ?ESP 0000009B
+ ?VB 00000020 ?BANKED_ENTER_XDATA (?BANKED_ENTER_XDATA)
+ ?BANKED_LEAVE_XDATA (?BANKED_LEAVE_XDATA)
+ ?FUNC_ENTER_XDATA (?FUNC_ENTER_XDATA)
+ ?FUNC_LEAVE_XDATA (?FUNC_LEAVE_XDATA)
+ ?INTERRUPT_ENTER_XSP (?INTERRUPT_ENTER_XSP)
+ ?INTERRUPT_LEAVE_XSP (?INTERRUPT_LEAVE_XSP)
+ _BREG_START 00000000
+ ?PBANK_NUMBER 0000001E
+ _REGISTER_BANK_START 00000000
+ ?REGISTER_BANK 00000000 Segment part 6 (CSTARTUP)
+ _FIRST_BANK_ADDR 00010000
+ _NEAR_CODE_START 00000000
+ _XDATA0_END 00001EFF
+ _XDATA0_START 00000001
+ _IXDATA0_END 00001EFF
+ _IXDATA0_START 00000001
+ _PDATA0_END 00001EFF
+ _PDATA0_START 00001E00
+ _IDATA0_END 000000FF
+ _IDATA0_START 00000000
+ ?CBANK 0000009F ?RESET_CODE_BANK (CSTARTUP)
+ Segment part 0 (?BANKED_CODE_SUPPORT)
+ ?CBANK_MASK 000000FF
+ _CODEBANK_START 00008000
+ _CODEBANK_END 0000FFFF
+ _NR_OF_BANKS 00000007
+ *************************************************************************
+
+ FILE NAME : D:\Simon_Dev\WIMuGPS\Workspace\openwimu\Firmware\Radio\Projects\Wimu\Projects\ble\Libraries\CC2540DB\bin\CC2540_BLE_peri.lib
+ LIBRARY MODULE, NAME : att_server
+
+ SEGMENTS IN THE MODULE
+ ======================
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A3A4 - 0001A3BA (0x17 bytes), align: 0
+ Segment part 6. Intra module refs: ATT_ErrorRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ErrorRsp 0001A3A4
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A3BB - 0001A3E9 (0x2f bytes), align: 0
+ Segment part 8. Intra module refs: ATT_ExchangeMTURsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ExchangeMTURsp 0001A3BB
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A3EA - 0001A422 (0x39 bytes), align: 0
+ Segment part 10. Intra module refs: ATT_FindInfoRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_FindInfoRsp 0001A3EA
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A423 - 0001A44A (0x28 bytes), align: 0
+ Segment part 12. Intra module refs: ATT_FindByTypeValueRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_FindByTypeValueRsp
+ 0001A423
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A44B - 0001A472 (0x28 bytes), align: 0
+ Segment part 14. Intra module refs: ATT_ReadByTypeRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ReadByTypeRsp 0001A44B
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A473 - 0001A478 (0x6 bytes), align: 0
+ Segment part 16. Intra module refs: ATT_ExchangeMTURsp
+ ATT_FindByTypeValueRsp
+ ATT_FindInfoRsp
+ ATT_ReadByGrpTypeRsp
+ ATT_ReadByTypeRsp
+ Segment part 35
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A479 - 0001A48F (0x17 bytes), align: 0
+ Segment part 17. Intra module refs: ATT_ReadRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ReadRsp 0001A479
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A490 - 0001A4A6 (0x17 bytes), align: 0
+ Segment part 19. Intra module refs: ATT_ReadBlobRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ReadBlobRsp 0001A490
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A4A7 - 0001A4BC (0x16 bytes), align: 0
+ Segment part 21. Intra module refs: ATT_ReadMultiRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ReadMultiRsp 0001A4A7
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A4BD - 0001A4E3 (0x27 bytes), align: 0
+ Segment part 23. Intra module refs: ATT_ReadByGrpTypeRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ReadByGrpTypeRsp 0001A4BD
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A4E4 - 0001A4F6 (0x13 bytes), align: 0
+ Segment part 25. Intra module refs: ATT_WriteRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_WriteRsp 0001A4E4
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A4F7 - 0001A50C (0x16 bytes), align: 0
+ Segment part 27. Intra module refs: ATT_PrepareWriteRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_PrepareWriteRsp 0001A4F7
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A50D - 0001A51F (0x13 bytes), align: 0
+ Segment part 29. Intra module refs: ATT_ExecuteWriteRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ExecuteWriteRsp 0001A50D
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A520 - 0001A52F (0x10 bytes), align: 0
+ Segment part 31. Intra module refs: ATT_HandleValueNoti::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_HandleValueNoti 0001A520
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A530 - 0001A535 (0x6 bytes), align: 0
+ Segment part 33. Intra module refs: ATT_HandleValueInd
+ ATT_HandleValueNoti
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A536 - 0001A539 (0x4 bytes), align: 0
+ Segment part 34. Intra module refs: ATT_ExecuteWriteRsp
+ ATT_WriteRsp
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A53A - 0001A53F (0x6 bytes), align: 0
+ Segment part 35. Intra module refs: ATT_ErrorRsp
+ ATT_PrepareWriteRsp
+ ATT_ReadBlobRsp
+ ATT_ReadMultiRsp
+ ATT_ReadRsp
+ Segment part 33
+ Segment part 34
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A540 - 0001A544 (0x5 bytes), align: 0
+ Segment part 36. Intra module refs: ATT_ExchangeMTURsp
+ ATT_FindByTypeValueRsp
+ ATT_FindInfoRsp
+ ATT_ReadByGrpTypeRsp
+ ATT_ReadByTypeRsp
+ Segment part 35
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001A545 - 0001A556 (0x12 bytes), align: 0
+ Segment part 37. Intra module refs: ATT_HandleValueInd::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_HandleValueInd 0001A545
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000004EF - 000004F4 (0x6 bytes), align: 0
+ Segment part 7.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ErrorRsp::?relay 000004EF gattProcessRxData (gatt_task)
+ gattServApp_ProcessMsg (gattservapp)
+ gattServerProcessMsgCB (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000004F5 - 000004FA (0x6 bytes), align: 0
+ Segment part 9.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ExchangeMTURsp::?relay
+ 000004F5 gattServApp_ProcessMsg (gattservapp)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000004FB - 00000500 (0x6 bytes), align: 0
+ Segment part 11.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_FindInfoRsp::?relay
+ 000004FB gattProcessFindInfoReq (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000501 - 00000506 (0x6 bytes), align: 0
+ Segment part 13.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_FindByTypeValueRsp::?relay
+ 00000501 gattServApp_ProcessFindByTypeValueReq (gattservapp)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000507 - 0000050C (0x6 bytes), align: 0
+ Segment part 15.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ReadByTypeRsp::?relay
+ 00000507 gattServApp_ProcessReadByTypeReq (gattservapp)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000050D - 00000512 (0x6 bytes), align: 0
+ Segment part 18.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ReadRsp::?relay 0000050D gattServApp_ProcessMsg (gattservapp)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000513 - 00000518 (0x6 bytes), align: 0
+ Segment part 20.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ReadBlobRsp::?relay
+ 00000513 gattServApp_ProcessMsg (gattservapp)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000519 - 0000051E (0x6 bytes), align: 0
+ Segment part 22.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ReadMultiRsp::?relay
+ 00000519 gattServApp_ProcessReadMultiReq (gattservapp)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000051F - 00000524 (0x6 bytes), align: 0
+ Segment part 24.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ReadByGrpTypeRsp::?relay
+ 0000051F gattServApp_ProcessReadByGrpTypeReq (gattservapp)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000525 - 0000052A (0x6 bytes), align: 0
+ Segment part 26.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_WriteRsp::?relay 00000525 gattServApp_ProcessWriteReq (gattservapp)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000052B - 00000530 (0x6 bytes), align: 0
+ Segment part 28.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_PrepareWriteRsp::?relay
+ 0000052B gattServApp_ProcessPrepareWriteReq (gattservapp)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000531 - 00000536 (0x6 bytes), align: 0
+ Segment part 30.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ExecuteWriteRsp::?relay
+ 00000531 gattServApp_ProcessExecuteWriteReq (gattservapp)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000537 - 0000053C (0x6 bytes), align: 0
+ Segment part 32.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_HandleValueNoti::?relay
+ 00000537 GATT_Notification (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000053D - 00000542 (0x6 bytes), align: 0
+ Segment part 38.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_HandleValueInd::?relay
+ 0000053D GATT_Indication (gatt_server)
+
+ -------------------------------------------------------------------------
+ LIBRARY MODULE, NAME : att_util
+
+ SEGMENTS IN THE MODULE
+ ======================
+ 1 (was XDATA_ROM_C)
+ Relative segment, address: CONST 00008E7D - 00008E8C (0x10 bytes), align: 0
+ Segment part 6. Intra module refs: ATT_ConvertUUIDto128
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ btBaseUUID 00008E7D
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012306 - 000123FF (0xfa bytes), align: 0
+ Segment part 7. Intra module refs: ATT_ParsePacket::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParsePacket 00012306
+ calls direct
+ XSTACK = 00000000 ( 00000011 )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012400 - 00012404 (0x5 bytes), align: 0
+ Segment part 9. Intra module refs: ATT_ParseFindByTypeValueReq
+ ATT_ParsePacket
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012405 - 0001242E (0x2a bytes), align: 0
+ Segment part 10. Intra module refs: ATT_BuildErrorRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildErrorRsp 00012405
+ XSTACK = 00000000 ( 00000009 )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001242F - 00012439 (0xb bytes), align: 0
+ Segment part 16. Intra module refs: ATT_BuildExchangeMTURsp
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001243A - 0001245A (0x21 bytes), align: 0
+ Segment part 17. Intra module refs: ATT_ParseExchangeMTUReq::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseExchangeMTUReq
+ 0001243A
+ XSTACK = 00000004 ( 00000009 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001245B - 0001245C (0x2 bytes), align: 0
+ Segment part 19. Intra module refs: ATT_BuildExchangeMTURsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildExchangeMTURsp
+ 0001245B
+ ISTACK = 00000000 ( 00000003 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001245D - 0001245E (0x2 bytes), align: 0
+ Segment part 22. Intra module refs: Segment part 16
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001245F - 00012465 (0x7 bytes), align: 0
+ Segment part 23. Intra module refs: ATT_ParseExecuteWriteReq
+ Segment part 22
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012466 - 0001246A (0x5 bytes), align: 0
+ Segment part 26. Intra module refs: ATT_BuildErrorRsp
+ ATT_ParseExchangeMTUReq
+ ATT_ParseFindInfoReq
+ ATT_ParseReadBlobReq
+ ATT_ParseReadReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001246B - 0001248B (0x21 bytes), align: 0
+ Segment part 29. Intra module refs: ATT_ParseFindInfoReq::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseFindInfoReq 0001246B
+ XSTACK = 00000004 ( 00000009 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001248C - 0001253D (0xb2 bytes), align: 0
+ Segment part 31. Intra module refs: ATT_BuildFindInfoRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildFindInfoRsp 0001248C
+ calls direct
+ XSTACK = 00000000 ( 00000014 )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001253E - 0001254B (0xe bytes), align: 0
+ Segment part 33. Intra module refs: ATT_BuildFindInfoRsp
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001254C - 00012567 (0x1c bytes), align: 0
+ Segment part 34. Intra module refs: ATT_BuildFindInfoRsp
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012568 - 00012568 (0x1 bytes), align: 0
+ Segment part 35. Intra module refs: Segment part 34
+ Segment part 89
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012569 - 0001256C (0x4 bytes), align: 0
+ Segment part 36. Intra module refs: Segment part 35
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001256D - 00012574 (0x8 bytes), align: 0
+ Segment part 37. Intra module refs: ATT_BuildFindByTypeValueRsp
+ Segment part 36
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012575 - 00012575 (0x1 bytes), align: 0
+ Segment part 38. Intra module refs: Segment part 34
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012576 - 0001257D (0x8 bytes), align: 0
+ Segment part 39. Intra module refs: Segment part 38
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001257E - 00012584 (0x7 bytes), align: 0
+ Segment part 40. Intra module refs: Segment part 34
+ Segment part 39
+ Segment part 47
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012585 - 0001258E (0xa bytes), align: 0
+ Segment part 43. Intra module refs: ATT_BuildFindInfoRsp
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001258F - 00012597 (0x9 bytes), align: 0
+ Segment part 47. Intra module refs: ATT_BuildFindInfoRsp
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012598 - 0001265C (0xc5 bytes), align: 0
+ Segment part 48. Intra module refs: ATT_ParseFindByTypeValueReq::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseFindByTypeValueReq
+ 00012598
+ calls direct
+ XSTACK = 00000004 ( 00000010 )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001265D - 00012664 (0x8 bytes), align: 0
+ Segment part 50. Intra module refs: ATT_CompareUUID
+ ATT_ParseFindByTypeValueReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012665 - 000126BB (0x57 bytes), align: 0
+ Segment part 51. Intra module refs: ATT_BuildFindByTypeValueRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildFindByTypeValueRsp
+ 00012665
+ XSTACK = 00000000 ( 0000000B )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000126BC - 000126C0 (0x5 bytes), align: 0
+ Segment part 53. Intra module refs: ATT_BuildFindByTypeValueRsp
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000126C1 - 000126C8 (0x8 bytes), align: 0
+ Segment part 54. Intra module refs: ATT_BuildErrorRsp
+ ATT_BuildFindByTypeValueRsp
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000126C9 - 000126CD (0x5 bytes), align: 0
+ Segment part 57. Intra module refs: ATT_ParsePacket
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000126CE - 000126D2 (0x5 bytes), align: 0
+ Segment part 58. Intra module refs: ATT_CompareUUID
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000126D3 - 000126D7 (0x5 bytes), align: 0
+ Segment part 59. Intra module refs: ATT_ConvertUUIDto128
+ ATT_ParseWriteReq
+ Segment part 58
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000126D8 - 00012754 (0x7d bytes), align: 0
+ Segment part 62. Intra module refs: ATT_ParseReadByTypeReq::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseReadByTypeReq
+ 000126D8
+ calls direct
+ XSTACK = 00000004 ( 0000000C )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012755 - 0001275D (0x9 bytes), align: 0
+ Segment part 64. Intra module refs: ATT_ParseReadByTypeReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001275E, align: 0
+ Segment part 65. Intra module refs: ATT_BuildReadByTypeRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildReadByTypeRsp
+ 0001275E
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001275E - 00012796 (0x39 bytes), align: 0
+ Segment part 67. Intra module refs: ATT_BuildReadByGrpTypeRsp
+ ATT_BuildReadByTypeRsp
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012797 - 00012798 (0x2 bytes), align: 0
+ Segment part 68. Intra module refs: Segment part 67
+ Segment part 98
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012799 - 000127A0 (0x8 bytes), align: 0
+ Segment part 69. Intra module refs: Segment part 68
+ Segment part 84
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000127A1 - 000127C2 (0x22 bytes), align: 0
+ Segment part 74. Intra module refs: ATT_ParseReadReq::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseReadReq 000127A1
+ XSTACK = 00000004 ( 00000009 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000127C3 - 000127C9 (0x7 bytes), align: 0
+ Segment part 76. Intra module refs: ATT_ParseExchangeMTUReq
+ ATT_ParseReadReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000127CA - 000127D1 (0x8 bytes), align: 0
+ Segment part 77. Intra module refs: ATT_ParseExchangeMTUReq
+ ATT_ParseFindInfoReq
+ ATT_ParseReadBlobReq
+ ATT_ParseReadReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000127D2 - 000127D7 (0x6 bytes), align: 0
+ Segment part 78. Intra module refs: ATT_ParseExchangeMTUReq
+ ATT_ParseReadReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000127D8, align: 0
+ Segment part 79. Intra module refs: ATT_BuildReadRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildReadRsp 000127D8
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000127D8 - 000127FE (0x27 bytes), align: 0
+ Segment part 81. Intra module refs: ATT_BuildReadBlobRsp
+ ATT_BuildReadMultiRsp
+ ATT_BuildReadRsp
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000127FF - 00012824 (0x26 bytes), align: 0
+ Segment part 84. Intra module refs: ATT_BuildPrepareWriteRsp
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012825 - 00012829 (0x5 bytes), align: 0
+ Segment part 85. Intra module refs: Segment part 67
+ Segment part 84
+ Segment part 98
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001282A - 0001282E (0x5 bytes), align: 0
+ Segment part 86. Intra module refs: ATT_ParsePrepareWriteReq
+ ATT_ParseReadByTypeReq
+ ATT_ParseReadMultiReq
+ Segment part 81
+ Segment part 85
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001282F - 00012832 (0x4 bytes), align: 0
+ Segment part 87. Intra module refs: Segment part 84
+ Segment part 98
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012833 - 00012840 (0xe bytes), align: 0
+ Segment part 88. Intra module refs: Segment part 81
+ Segment part 87
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012841 - 0001284E (0xe bytes), align: 0
+ Segment part 89. Intra module refs: Segment part 84
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001284F - 0001285D (0xf bytes), align: 0
+ Segment part 90. Intra module refs: Segment part 54
+ Segment part 89
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001285E - 000128D8 (0x7b bytes), align: 0
+ Segment part 91. Intra module refs: ATT_ParseWriteReq::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseWriteReq 0001285E
+ calls direct
+ XSTACK = 00000004 ( 0000000E )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000128D9 - 000128DB (0x3 bytes), align: 0
+ Segment part 93. Intra module refs: ATT_ParseReadMultiReq
+ ATT_ParseWriteReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000128DC - 000128E0 (0x5 bytes), align: 0
+ Segment part 94. Intra module refs: ATT_ConvertUUIDto128
+ Segment part 93
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000128E1 - 000128E6 (0x6 bytes), align: 0
+ Segment part 95. Intra module refs: ATT_ParseExecuteWriteReq
+ ATT_ParsePacket
+ ATT_ParseReadByTypeReq
+ ATT_ParseReadMultiReq
+ ATT_ParseWriteReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000128E7 - 0001290F (0x29 bytes), align: 0
+ Segment part 98. Intra module refs: ATT_BuildHandleValueInd
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012910 - 00012913 (0x4 bytes), align: 0
+ Segment part 99. Intra module refs: Segment part 16
+ Segment part 98
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012914 - 00012927 (0x14 bytes), align: 0
+ Segment part 100. Intra module refs: Segment part 89
+ Segment part 99
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012928 - 00012928 (0x1 bytes), align: 0
+ Segment part 101. Intra module refs: Segment part 100
+ Segment part 90
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012929 - 0001292F (0x7 bytes), align: 0
+ Segment part 102. Intra module refs: Segment part 100
+ Segment part 101
+ Segment part 159
+ Segment part 90
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012930 - 00012951 (0x22 bytes), align: 0
+ Segment part 107. Intra module refs: ATT_ParseReadBlobReq::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseReadBlobReq 00012930
+ XSTACK = 00000004 ( 00000009 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012952 - 00012958 (0x7 bytes), align: 0
+ Segment part 109. Intra module refs: ATT_ParseFindInfoReq
+ ATT_ParseReadBlobReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012959 - 0001297A (0x22 bytes), align: 0
+ Segment part 110. Intra module refs: ATT_ParseFindInfoReq
+ ATT_ParseReadBlobReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001297B - 0001298D (0x13 bytes), align: 0
+ Segment part 111. Intra module refs: Segment part 110
+ Segment part 78
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001298E - 00012990 (0x3 bytes), align: 0
+ Segment part 112. Intra module refs: ATT_BuildReadBlobRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildReadBlobRsp 0001298E
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012991 - 000129A5 (0x15 bytes), align: 0
+ Segment part 118. Intra module refs: ATT_BuildFindByTypeValueRsp
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000129A6 - 00012A15 (0x70 bytes), align: 0
+ Segment part 119. Intra module refs: ATT_ParseReadMultiReq::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseReadMultiReq 000129A6
+ XSTACK = 00000004 ( 0000000A )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012A16 - 00012A19 (0x4 bytes), align: 0
+ Segment part 121. Intra module refs: ATT_ParseExecuteWriteReq
+ ATT_ParseReadMultiReq
+ ATT_ParseWriteReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012A1A - 00012A1F (0x6 bytes), align: 0
+ Segment part 122. Intra module refs: Segment part 109
+ Segment part 121
+ Segment part 178
+ Segment part 57
+ Segment part 76
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012A20 - 00012A22 (0x3 bytes), align: 0
+ Segment part 123. Intra module refs: ATT_BuildReadMultiRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildReadMultiRsp 00012A20
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012A23 - 00012A25 (0x3 bytes), align: 0
+ Segment part 128. Intra module refs: ATT_BuildReadByGrpTypeRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildReadByGrpTypeRsp
+ 00012A23
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012A26 - 00012A85 (0x60 bytes), align: 0
+ Segment part 136. Intra module refs: ATT_ParsePrepareWriteReq::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParsePrepareWriteReq
+ 00012A26
+ calls direct
+ XSTACK = 00000004 ( 0000000C )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012A86 - 00012A92 (0xd bytes), align: 0
+ Segment part 138. Intra module refs: ATT_ParsePrepareWriteReq
+ ATT_ParseReadByTypeReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012A93 - 00012A99 (0x7 bytes), align: 0
+ Segment part 139. Intra module refs: ATT_ParseWriteReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012A9A - 00012A9B (0x2 bytes), align: 0
+ Segment part 140. Intra module refs: Segment part 139
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012A9C - 00012A9C (0x1 bytes), align: 0
+ Segment part 141. Intra module refs: ATT_ParsePrepareWriteReq
+ ATT_ParseReadByTypeReq
+ Segment part 140
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012A9D - 00012AA2 (0x6 bytes), align: 0
+ Segment part 142. Intra module refs: ATT_ParseFindByTypeValueReq
+ Segment part 141
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012AA3 - 00012AAC (0xa bytes), align: 0
+ Segment part 143. Intra module refs: ATT_ParseReadMultiReq
+ Segment part 139
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012AAD - 00012AAD (0x1 bytes), align: 0
+ Segment part 144. Intra module refs: Segment part 142
+ Segment part 33
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012AAE - 00012AB3 (0x6 bytes), align: 0
+ Segment part 145. Intra module refs: Segment part 144
+ Segment part 186
+ Segment part 69
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012AB4 - 00012AC4 (0x11 bytes), align: 0
+ Segment part 146. Intra module refs: ATT_ParsePrepareWriteReq
+ ATT_ParseReadByTypeReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012AC5 - 00012ACC (0x8 bytes), align: 0
+ Segment part 147. Intra module refs: ATT_ParsePrepareWriteReq
+ ATT_ParseReadByTypeReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012ACD - 00012ACF (0x3 bytes), align: 0
+ Segment part 148. Intra module refs: ATT_BuildPrepareWriteRsp::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildPrepareWriteRsp
+ 00012ACD
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012AD0 - 00012AD8 (0x9 bytes), align: 0
+ Segment part 152. Intra module refs: ATT_ParsePrepareWriteReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012AD9 - 00012ADC (0x4 bytes), align: 0
+ Segment part 157. Intra module refs: ATT_BuildErrorRsp
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012ADD - 00012AE0 (0x4 bytes), align: 0
+ Segment part 158. Intra module refs: ATT_BuildErrorRsp
+ Segment part 157
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012AE1 - 00012AE4 (0x4 bytes), align: 0
+ Segment part 159. Intra module refs: Segment part 118
+ Segment part 158
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012AE5 - 00012B14 (0x30 bytes), align: 0
+ Segment part 160. Intra module refs: ATT_ParseExecuteWriteReq::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseExecuteWriteReq
+ 00012AE5
+ XSTACK = 00000004 ( 00000000 )
+ ISTACK = 00000000 ( 00000003 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012B15 - 00012B17 (0x3 bytes), align: 0
+ Segment part 164. Intra module refs: ATT_BuildHandleValueInd::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildHandleValueInd
+ 00012B15
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012B18 - 00012B24 (0xd bytes), align: 0
+ Segment part 168. Intra module refs: ATT_ParsePrepareWriteReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012B25 - 00012B29 (0x5 bytes), align: 0
+ Segment part 169. Intra module refs: ATT_ParsePrepareWriteReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012B2A - 00012B34 (0xb bytes), align: 0
+ Segment part 170. Intra module refs: Segment part 169
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012B35 - 00012C1D (0xe9 bytes), align: 0
+ Segment part 173. Intra module refs: attSendMsg::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ attSendMsg 00012B35
+ calls direct
+ XSTACK = 00000002 ( 00000018 )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012C1E - 00012C22 (0x5 bytes), align: 0
+ Segment part 175. Intra module refs: ATT_BuildFindInfoRsp
+ attSendMsg
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012C23 - 00012CD1 (0xaf bytes), align: 0
+ Segment part 176. Intra module refs: ATT_CompareUUID::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_CompareUUID 00012C23
+ calls direct
+ XSTACK = 00000004 ( 0000001E )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012CD2 - 00012CD8 (0x7 bytes), align: 0
+ Segment part 178. Intra module refs: ATT_CompareUUID
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012CD9 - 00012D36 (0x5e bytes), align: 0
+ Segment part 179. Intra module refs: ATT_ConvertUUIDto128::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ConvertUUIDto128 00012CD9
+ calls direct
+ XSTACK = 0000001C ( 0000000E )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012D37 - 00012D3F (0x9 bytes), align: 0
+ Segment part 181. Intra module refs: ATT_ConvertUUIDto128
+ ATT_ParseFindByTypeValueReq
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00012D40 - 00012D43 (0x4 bytes), align: 0
+ Segment part 186. Intra module refs: ATT_ConvertUUIDto128
+ Segment part 81
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000543 - 00000548 (0x6 bytes), align: 0
+ Segment part 8.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParsePacket::?relay
+ 00000543 gattProcessRxData (gatt_task)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000549 - 0000054E (0x6 bytes), align: 0
+ Segment part 11.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildErrorRsp::?relay
+ 00000549 ATT_ErrorRsp (att_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000054F - 00000554 (0x6 bytes), align: 0
+ Segment part 18.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseExchangeMTUReq::?relay
+ 0000054F Segment part 12 (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000555 - 0000055A (0x6 bytes), align: 0
+ Segment part 20.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildExchangeMTURsp::?relay
+ 00000555 ATT_ExchangeMTURsp (att_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000055B - 00000560 (0x6 bytes), align: 0
+ Segment part 30.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseFindInfoReq::?relay
+ 0000055B Segment part 12 (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000561 - 00000566 (0x6 bytes), align: 0
+ Segment part 32.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildFindInfoRsp::?relay
+ 00000561 ATT_FindInfoRsp (att_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000567 - 0000056C (0x6 bytes), align: 0
+ Segment part 49.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseFindByTypeValueReq::?relay
+ 00000567 Segment part 12 (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000056D - 00000572 (0x6 bytes), align: 0
+ Segment part 52.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildFindByTypeValueRsp::?relay
+ 0000056D ATT_FindByTypeValueRsp (att_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000573 - 00000578 (0x6 bytes), align: 0
+ Segment part 63.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseReadByTypeReq::?relay
+ 00000573 Segment part 12 (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000579 - 0000057E (0x6 bytes), align: 0
+ Segment part 66.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildReadByTypeRsp::?relay
+ 00000579 ATT_ReadByTypeRsp (att_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000057F - 00000584 (0x6 bytes), align: 0
+ Segment part 75.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseReadReq::?relay
+ 0000057F Segment part 12 (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000585 - 0000058A (0x6 bytes), align: 0
+ Segment part 80.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildReadRsp::?relay
+ 00000585 ATT_ReadRsp (att_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000058B - 00000590 (0x6 bytes), align: 0
+ Segment part 92.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseWriteReq::?relay
+ 0000058B Segment part 12 (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000591 - 00000596 (0x6 bytes), align: 0
+ Segment part 108.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseReadBlobReq::?relay
+ 00000591 Segment part 12 (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000597 - 0000059C (0x6 bytes), align: 0
+ Segment part 113.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildReadBlobRsp::?relay
+ 00000597 ATT_ReadBlobRsp (att_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000059D - 000005A2 (0x6 bytes), align: 0
+ Segment part 120.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseReadMultiReq::?relay
+ 0000059D Segment part 12 (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005A3 - 000005A8 (0x6 bytes), align: 0
+ Segment part 124.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildReadMultiRsp::?relay
+ 000005A3 ATT_ReadMultiRsp (att_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005A9 - 000005AE (0x6 bytes), align: 0
+ Segment part 129.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildReadByGrpTypeRsp::?relay
+ 000005A9 ATT_ReadByGrpTypeRsp (att_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005AF - 000005B4 (0x6 bytes), align: 0
+ Segment part 137.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParsePrepareWriteReq::?relay
+ 000005AF Segment part 12 (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005B5 - 000005BA (0x6 bytes), align: 0
+ Segment part 149.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildPrepareWriteRsp::?relay
+ 000005B5 ATT_PrepareWriteRsp (att_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005BB - 000005C0 (0x6 bytes), align: 0
+ Segment part 161.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ParseExecuteWriteReq::?relay
+ 000005BB Segment part 12 (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005C1 - 000005C6 (0x6 bytes), align: 0
+ Segment part 165.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_BuildHandleValueInd::?relay
+ 000005C1 Segment part 33 (att_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005C7 - 000005CC (0x6 bytes), align: 0
+ Segment part 174.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ attSendMsg::?relay 000005C7 Segment part 16 (att_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005CD - 000005D2 (0x6 bytes), align: 0
+ Segment part 177.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_CompareUUID::?relay
+ 000005CD GATTServApp_ReadAttr (gattservapp)
+ Segment part 39 (gatt_server)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005D3 - 000005D8 (0x6 bytes), align: 0
+ Segment part 180. Intra module refs: ATT_CompareUUID
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ ATT_ConvertUUIDto128::?relay
+ 000005D3
+ -------------------------------------------------------------------------
+ 1 (was XDATA_ROM_C_FLASH)
+ Relative segment, address: CODE 00008E7D - 00008E8C (0x10 bytes), align: 0
+ Segment part 192. Intra module refs: btBaseUUID
+
+ -------------------------------------------------------------------------
+ LIBRARY MODULE, NAME : gap_configmgr
+
+ SEGMENTS IN THE MODULE
+ ======================
+XDATA_I
+ Relative segment, address: XDATA 00000E2D - 00000E2D (0x1 bytes), align: 0
+ Segment part 6. Intra module refs: GAP_ParamsInit
+ gapIncSignCounter
+ gapProcessRandomAddrComplete
+ gapSendDeviceInitDoneEvent
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapAppTaskID 00000E2D gapProcessConnectionCompleteEvt (gap_linkmgr)
+ gapSendLinkUpdateEvent (gap_linkmgr)
+ -------------------------------------------------------------------------
+XDATA_Z
+ Relative segment, address: XDATA 00000301 - 00000301 (0x1 bytes), align: 0
+ Segment part 8. Intra module refs: GAP_ParamsInit
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapProfileRole 00000301 GAP_Authenticate (gap_linkmgr)
+ GAP_Bond (gap_linkmgr)
+ GAP_MakeDiscoverable (gap_peridevmgr)
+ GAP_PeriDevMgrInit (gap_peridevmgr)
+ GAP_SendSlaveSecurityRequest (gap_perilinkmgr)
+ GAP_Signable (gap_linkmgr)
+ GAP_UpdateAdvertisingData (gap_peridevmgr)
+ SM_ResponderInit (sm_rsppairing)
+ gapProcessAdvertisingEvt (gap_peridevmgr)
+ gapProcessOSALMsg (gap_task)
+ smProcessDataMsg (sm_pairing)
+ smProcessOSALMsg (sm_task)
+ -------------------------------------------------------------------------
+XDATA_Z
+ Relative segment, address: XDATA 00000302 - 00000302 (0x1 bytes), align: 0
+ Segment part 9. Intra module refs: gapGetDevAddress
+ gapGetDevAddressMode
+ gapProcessNewAddr
+ gapProcessRandomAddrComplete
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapDeviceAddrMode 00000302 GAP_MakeDiscoverable (gap_peridevmgr)
+ gapSetAdvParams (gap_peridevmgr)
+ -------------------------------------------------------------------------
+XDATA_Z
+ Relative segment, address: XDATA 00000303 - 00000304 (0x2 bytes), align: 0
+ Segment part 10.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapPrivateAddrChangeTimeout
+ 00000303 GAP_EndDiscoverable (gap_peridevmgr)
+ GAP_MakeDiscoverable (gap_peridevmgr)
+ GAP_ProcessEvent (gap_task)
+ -------------------------------------------------------------------------
+XDATA_Z
+ Relative segment, address: XDATA 00000305 - 00000305 (0x1 bytes), align: 0
+ Segment part 11. Intra module refs: gapProcessRandomAddrComplete
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapAutoAdvPrivateAddrChange
+ 00000305 GAP_ProcessEvent (gap_task)
+ gapProcessAdvertisingEvt (gap_peridevmgr)
+ gapWriteAdvEnableStatus (gap_peridevmgr)
+ -------------------------------------------------------------------------
+XDATA_Z
+ Relative segment, address: XDATA 00000306 - 00000315 (0x10 bytes), align: 0
+ Segment part 12. Intra module refs: GAP_ParamsInit
+ GAP_SecParamsInit
+ Segment part 58
+ gapGetDevAddress
+ gapGetIRK
+ gapGetSRK
+ gapReadBD_ADDRStatus
+ gapReadBufSizeCmdStatus
+ gapSendDeviceInitDoneEvent
+ -------------------------------------------------------------------------
+XDATA_I
+ Relative segment, address: XDATA 00000E2E - 00000E79 (0x4c bytes), align: 0
+ Segment part 13. Intra module refs: Segment part 22
+ -------------------------------------------------------------------------
+XDATA_Z
+ Relative segment, address: XDATA 00000316 - 0000031B (0x6 bytes), align: 0
+ Segment part 15. Intra module refs: gapGetDevAddress
+ gapProcessNewAddr
+ gapProcessRandomAddrComplete
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017394 - 000173BB (0x28 bytes), align: 0
+ Segment part 18. Intra module refs: GAP_SetParamValue::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_SetParamValue 00017394
+ ISTACK = 00000000 ( 00000002 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000173BC - 000173D7 (0x1c bytes), align: 0
+ Segment part 20. Intra module refs: GAP_GetParamValue::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_GetParamValue 000173BC
+ XSTACK = 00000014 ( 00000000 )
+ ISTACK = 00000000 ( 00000002 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000173D8 - 000173E9 (0x12 bytes), align: 0
+ Segment part 22. Intra module refs: GAP_GetParamValue
+ GAP_SetParamValue
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000173EA - 0001741B (0x32 bytes), align: 0
+ Segment part 23. Intra module refs: GAP_ParamsInit::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_ParamsInit 000173EA
+ calls direct
+ XSTACK = 00000000 ( 00000009 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001741C - 00017420 (0x5 bytes), align: 0
+ Segment part 25. Intra module refs: GAP_ParamsInit
+ GAP_SecParamsInit
+ gapReadBufSizeCmdStatus
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017421 - 0001747B (0x5b bytes), align: 0
+ Segment part 26. Intra module refs: GAP_SecParamsInit::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_SecParamsInit 00017421
+ calls direct
+ XSTACK = 00000002 ( 00000009 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001747C - 00017482 (0x7 bytes), align: 0
+ Segment part 28. Intra module refs: GAP_SecParamsInit
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017483 - 00017488 (0x6 bytes), align: 0
+ Segment part 31. Intra module refs: GAP_GetParamValue
+ Segment part 28
+ Segment part 41
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017489 - 000174CC (0x44 bytes), align: 0
+ Segment part 32. Intra module refs: gapReadBD_ADDRStatus::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapReadBD_ADDRStatus 00017489
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000174CD - 000174D1 (0x5 bytes), align: 0
+ Segment part 34. Intra module refs: gapProcessNewAddr
+ gapReadBD_ADDRStatus
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000174D2 - 0001751C (0x4b bytes), align: 0
+ Segment part 35. Intra module refs: gapReadBufSizeCmdStatus::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapReadBufSizeCmdStatus
+ 000174D2
+ calls direct
+ XSTACK = 00000000 ( 00000009 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001751D - 0001755A (0x3e bytes), align: 0
+ Segment part 37. Intra module refs: gapProcessNewAddr::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapProcessNewAddr 0001751D
+ calls direct
+ XSTACK = 00000014 ( 0000000C )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001755B - 0001758D (0x33 bytes), align: 0
+ Segment part 39. Intra module refs: gapAddAddrAdj::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapAddAddrAdj 0001755B
+ XSTACK = 0000000A ( 00000000 )
+ ISTACK = 00000000 ( 00000002 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001758E - 00017590 (0x3 bytes), align: 0
+ Segment part 41. Intra module refs: gapGetIRK
+ gapGetSRK
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017591 - 00017597 (0x7 bytes), align: 0
+ Segment part 42. Intra module refs: GAP_GetParamValue
+ GAP_SetParamValue
+ Segment part 41
+ gapAddAddrAdj
+ gapDetermineAddrType
+ gapGetDevAddress
+ gapGetDevAddressMode
+ gapGetSignCounter
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017598 - 000175C5 (0x2e bytes), align: 0
+ Segment part 43. Intra module refs: gapDetermineAddrType::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapDetermineAddrType 00017598
+ ISTACK = 00000000 ( 00000002 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000175C6 - 0001764E (0x89 bytes), align: 0
+ Segment part 45. Intra module refs: gapProcessRandomAddrComplete::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapProcessRandomAddrComplete
+ 000175C6
+ calls direct
+ XSTACK = 00000000 ( 00000010 )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001764F - 00017653 (0x5 bytes), align: 0
+ Segment part 47. Intra module refs: gapIncSignCounter
+ gapProcessRandomAddrComplete
+ gapSendDeviceInitDoneEvent
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017654 - 00017654 (0x1 bytes), align: 0
+ Segment part 48. Intra module refs: gapProcessRandomAddrComplete
+ gapReadBufSizeCmdStatus
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017655 - 0001765A (0x6 bytes), align: 0
+ Segment part 49. Intra module refs: GAP_SecParamsInit
+ Segment part 48
+ gapProcessRandomAddrComplete
+ gapSendDeviceInitDoneEvent
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001765B - 00017664 (0xa bytes), align: 0
+ Segment part 50. Intra module refs: gapProcessRandomAddrComplete
+ gapSendDeviceInitDoneEvent
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017665 - 0001766C (0x8 bytes), align: 0
+ Segment part 51. Intra module refs: Segment part 50
+ gapUpdateConnSignCounter
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001766D - 00017676 (0xa bytes), align: 0
+ Segment part 52. Intra module refs: gapGetSRK::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapGetSRK 0001766D
+ ISTACK = 00000000 ( 00000002 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017677 - 00017683 (0xd bytes), align: 0
+ Segment part 54. Intra module refs: gapGetSignCounter::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapGetSignCounter 00017677
+ ISTACK = 00000000 ( 00000002 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017684 - 000176AA (0x27 bytes), align: 0
+ Segment part 56. Intra module refs: gapIncSignCounter::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapIncSignCounter 00017684
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000176AB - 000176B6 (0xc bytes), align: 0
+ Segment part 58. Intra module refs: gapGetSignCounter
+ gapIncSignCounter
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000176B7 - 00017778 (0xc2 bytes), align: 0
+ Segment part 59. Intra module refs: gapUpdateConnSignCounter::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapUpdateConnSignCounter
+ 000176B7
+ calls direct
+ XSTACK = 00000004 ( 00000014 )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017779 - 00017784 (0xc bytes), align: 0
+ Segment part 61. Intra module refs: gapGetDevAddressMode::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapGetDevAddressMode 00017779
+ ISTACK = 00000000 ( 00000002 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017785 - 0001779C (0x18 bytes), align: 0
+ Segment part 63. Intra module refs: gapGetDevAddress::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapGetDevAddress 00017785
+ ISTACK = 00000000 ( 00000002 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001779D - 000177A6 (0xa bytes), align: 0
+ Segment part 65. Intra module refs: gapGetIRK::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapGetIRK 0001779D
+ ISTACK = 00000000 ( 00000002 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 000177A7 - 00017814 (0x6e bytes), align: 0
+ Segment part 67. Intra module refs: gapSendDeviceInitDoneEvent::?relay
+ LOCAL ADDRESS
+ ===== =======
+ gapSendDeviceInitDoneEvent
+ 000177A7
+ calls direct
+ XSTACK = 0000000A ( 0000000E )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017815 - 00017824 (0x10 bytes), align: 0
+ Segment part 69. Intra module refs: gapProcessRandomAddrComplete
+ gapSendDeviceInitDoneEvent
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017825 - 00017828 (0x4 bytes), align: 0
+ Segment part 72. Intra module refs: gapProcessRandomAddrComplete
+ gapUpdateConnSignCounter
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017829 - 00017829 (0x1 bytes), align: 0
+ Segment part 73. Intra module refs: Segment part 72
+ gapSendDeviceInitDoneEvent
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001782A - 0001782C (0x3 bytes), align: 0
+ Segment part 74. Intra module refs: Segment part 73
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 0001782D - 00017832 (0x6 bytes), align: 0
+ Segment part 75. Intra module refs: Segment part 74
+ gapProcessNewAddr
+ gapReadBD_ADDRStatus
+ -------------------------------------------------------------------------
+ 2 (was BANKED_CODE)
+ Relative segment, address: CODE 00017833 - 0001783B (0x9 bytes), align: 0
+ Segment part 76. Intra module refs: gapReadBufSizeCmdStatus
+ -------------------------------------------------------------------------
+XDATA_ID
+ Relative segment, address: CODE 0000013A - 0000013A (0x1 bytes), align: 0
+ Segment part 7. Intra module refs: gapAppTaskID
+ -------------------------------------------------------------------------
+XDATA_ID
+ Relative segment, address: CODE 0000013B - 00000186 (0x4c bytes), align: 0
+ Segment part 14. Intra module refs: Segment part 13
+ -------------------------------------------------------------------------
+ 1 (was XDATA_ROM_C)
+ Relative segment, address: CONST 00008F7E - 00008F81 (0x4 bytes), align: 0
+ Segment part 16. Intra module refs: GAP_MakeDiscoverable (gap_peridevmgr)
+ gapProcessRandomAddrComplete
+ gapWriteAdvEnableStatus (gap_peridevmgr)
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ __Constant_ea60 00008F7E
+ -------------------------------------------------------------------------
+ 1 (was XDATA_ROM_C)
+ Relative segment, address: CONST 00008F76 - 00008F79 (0x4 bytes), align: 0
+ Segment part 17. Intra module refs: LL_ENC_Decrypt (ll_enc)
+ LL_ENC_Encrypt (ll_enc)
+ LL_TxData (ll)
+ gapIncSignCounter
+ llFindStartType (ll_scheduler)
+ llSetupNextSlaveEvent (ll_slaveEndCauses)
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ __Constant_1 00008F76
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005D9 - 000005DE (0x6 bytes), align: 0
+ Segment part 19.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_SetParamValue::?relay
+ 000005D9 ?Subroutine4 (wimu)
+ GAPBondMgr_Register (gapbondmgr)
+ GAPRole_SetParameter (peripheral)
+ WIMU_Init (wimu)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005DF - 000005E4 (0x6 bytes), align: 0
+ Segment part 21. Intra module refs: gapUpdateConnSignCounter
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_GetParamValue::?relay
+ 000005DF GAP_MakeDiscoverable (gap_peridevmgr)
+ GAP_ProcessEvent (gap_task)
+ SM_StartPairing (sm_pairing)
+ Segment part 40 (gap_peridevmgr)
+ Segment part 46 (gap_peridevmgr)
+ Segment part 88 (gap_linkmgr)
+ gapPasskeyNeededCB (gap_linkmgr)
+ gapRole_ProcessGAPMsg (peripheral)
+ gapRole_ProcessOSALMsg (peripheral)
+ gapRole_startConnUpdate (peripheral)
+ gapSendBondCompleteEvent (gap_linkmgr)
+ gapSetAdvParams (gap_peridevmgr)
+ smStartRspTimer (sm_mgr)
+ smpParsePairingReq (smp)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005E5 - 000005EA (0x6 bytes), align: 0
+ Segment part 24.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_ParamsInit::?relay
+ 000005E5 GAP_DeviceInit (gap)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005EB - 000005F0 (0x6 bytes), align: 0
+ Segment part 27.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_SecParamsInit::?relay
+ 000005EB GAP_DeviceInit (gap)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005F1 - 000005F6 (0x6 bytes), align: 0
+ Segment part 33.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapReadBD_ADDRStatus::?relay
+ 000005F1 gapProcessHCICmdCompleteEvt (gap_task)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005F7 - 000005FC (0x6 bytes), align: 0
+ Segment part 36.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapReadBufSizeCmdStatus::?relay
+ 000005F7 gapProcessHCICmdCompleteEvt (gap_task)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 000005FD - 00000602 (0x6 bytes), align: 0
+ Segment part 38.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapProcessNewAddr::?relay
+ 000005FD GAP_ProcessEvent (gap_task)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000603 - 00000608 (0x6 bytes), align: 0
+ Segment part 40. Intra module refs: gapProcessNewAddr
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapAddAddrAdj::?relay 00000603 gapSetAdvParams (gap_peridevmgr)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000609 - 0000060E (0x6 bytes), align: 0
+ Segment part 44.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapDetermineAddrType::?relay
+ 00000609 gapProcessConnectionCompleteEvt (gap_linkmgr)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000060F - 00000614 (0x6 bytes), align: 0
+ Segment part 46.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapProcessRandomAddrComplete::?relay
+ 0000060F gapProcessHCICmdCompleteEvt (gap_task)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000615 - 0000061A (0x6 bytes), align: 0
+ Segment part 53.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapGetSRK::?relay 00000615 SM_GenerateAuthenSig (sm_mgr)
+ smResponderSendNextKeyInfo (sm_rsppairing)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000061B - 00000620 (0x6 bytes), align: 0
+ Segment part 55.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapGetSignCounter::?relay
+ 0000061B SM_GenerateAuthenSig (sm_mgr)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000621 - 00000626 (0x6 bytes), align: 0
+ Segment part 57.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapIncSignCounter::?relay
+ 00000621 SM_GenerateAuthenSig (sm_mgr)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000627 - 0000062C (0x6 bytes), align: 0
+ Segment part 60.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapUpdateConnSignCounter::?relay
+ 00000627 SM_VerifyAuthenSig (sm_mgr)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000062D - 00000632 (0x6 bytes), align: 0
+ Segment part 62.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapGetDevAddressMode::?relay
+ 0000062D smResponderSendNextKeyInfo (sm_rsppairing)
+ sm_c1 (sm_pairing)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000633 - 00000638 (0x6 bytes), align: 0
+ Segment part 64.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapGetDevAddress::?relay
+ 00000633 smResponderSendNextKeyInfo (sm_rsppairing)
+ sm_c1 (sm_pairing)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000639 - 0000063E (0x6 bytes), align: 0
+ Segment part 66.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapGetIRK::?relay 00000639 GAP_ProcessEvent (gap_task)
+ smResponderSendNextKeyInfo (sm_rsppairing)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000063F - 00000644 (0x6 bytes), align: 0
+ Segment part 68. Intra module refs: gapReadBD_ADDRStatus
+ gapReadBufSizeCmdStatus
+ LOCAL ADDRESS
+ ===== =======
+ gapSendDeviceInitDoneEvent::?relay
+ 0000063F
+ -------------------------------------------------------------------------
+ 1 (was XDATA_ROM_C_FLASH)
+ Relative segment, address: CODE 00008F7E - 00008F81 (0x4 bytes), align: 0
+ Segment part 77. Intra module refs: __Constant_ea60
+ -------------------------------------------------------------------------
+ 1 (was XDATA_ROM_C_FLASH)
+ Relative segment, address: CODE 00008F76 - 00008F79 (0x4 bytes), align: 0
+ Segment part 78. Intra module refs: __Constant_1
+
+ -------------------------------------------------------------------------
+ LIBRARY MODULE, NAME : gap_devmgr
+
+ SEGMENTS IN THE MODULE
+ ======================
+XDATA_Z
+ Relative segment, address: XDATA 0000031C - 0000031D (0x2 bytes), align: 0
+ Segment part 7. Intra module refs: gapIsAdvertising
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ pGapAdvertState 0000031C GAP_MakeDiscoverable (gap_peridevmgr)
+ Segment part 41 (gap_peridevmgr)
+ Segment part 48 (gap_peridevmgr)
+ Segment part 87 (gap_peridevmgr)
+ Segment part 99 (gap_peridevmgr)
+ gapFreeAdvertState (gap_peridevmgr)
+ gapSetAdvParams (gap_peridevmgr)
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001AD94 - 0001AD9A (0x7 bytes), align: 0
+ Segment part 8. Intra module refs: GAP_ResolvePrivateAddr::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_ResolvePrivateAddr
+ 0001AD94
+ calls direct
+ ISTACK = 00000000 ( 00000002 )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001AD9B - 0001ADA1 (0x7 bytes), align: 0
+ Segment part 10. Intra module refs: GAP_ResolvePrivateAddr
+ gapIsAdvertising
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001ADA2 - 0001ADB9 (0x18 bytes), align: 0
+ Segment part 11. Intra module refs: gapIsAdvertising::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapIsAdvertising 0001ADA2
+ ISTACK = 00000000 ( 00000002 )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001ADBA - 0001ADD1 (0x18 bytes), align: 0
+ Segment part 15. Intra module refs: gapValidADType::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapValidADType 0001ADBA
+ XSTACK = 00000012 ( 00000000 )
+ -------------------------------------------------------------------------
+ 3 (was BANKED_CODE)
+ Relative segment, address: CODE 0001ADD2 - 0001AE6A (0x99 bytes), align: 0
+ Segment part 17. Intra module refs: gapFindADType::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapFindADType 0001ADD2
+ calls direct
+ XSTACK = 00000002 ( 00000012 )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000645 - 0000064A (0x6 bytes), align: 0
+ Segment part 9.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_ResolvePrivateAddr::?relay
+ 00000645 gapBondMgrResolvePrivateAddr (gapbondmgr)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 0000064B - 00000650 (0x6 bytes), align: 0
+ Segment part 12.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapIsAdvertising::?relay
+ 0000064B GAP_ProcessEvent (gap_task)
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000651 - 00000656 (0x6 bytes), align: 0
+ Segment part 16. Intra module refs: gapFindADType
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapValidADType::?relay
+ 00000651
+ -------------------------------------------------------------------------
+BANK_RELAYS
+ Relative segment, address: CODE 00000657 - 0000065C (0x6 bytes), align: 0
+ Segment part 18.
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapFindADType::?relay 00000657 isLimitedDiscoverableMode (gap_peridevmgr)
+
+ -------------------------------------------------------------------------
+ LIBRARY MODULE, NAME : gap_linkmgr
+
+ SEGMENTS IN THE MODULE
+ ======================
+XDATA_Z
+ Relative segment, address: XDATA 0000031E - 0000031F (0x2 bytes), align: 0
+ Segment part 6. Intra module refs: gapFreeEstLink
+ gapProcessConnectionCompleteEvt
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ pEstLink 0000031E
+ -------------------------------------------------------------------------
+XDATA_Z
+ Relative segment, address: XDATA 00000320 - 00000321 (0x2 bytes), align: 0
+ Segment part 7. Intra module refs: GAP_Authenticate
+ Segment part 102
+ Segment part 108
+ Segment part 111
+ Segment part 25
+ Segment part 49
+ gapFreeAuthLink
+ gapPairingCompleteCB
+ sendAuthEvent
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ pAuthLink 00000320 GAP_SendSlaveSecurityRequest (gap_perilinkmgr)
+ -------------------------------------------------------------------------
+XDATA_Z
+ Relative segment, address: XDATA 00000322 - 00000323 (0x2 bytes), align: 0
+ Segment part 8. Intra module refs: GAP_TerminateLinkReq
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ pfnCentralConnCBs 00000322 gapProcessHCICmdCompleteEvt (gap_task)
+ gapProcessOSALMsg (gap_task)
+ -------------------------------------------------------------------------
+XDATA_Z
+ Relative segment, address: XDATA 00000324 - 00000324 (0x1 bytes), align: 0
+ Segment part 9. Intra module refs: GAP_TerminateLinkReq
+ gapProcessConnectionCompleteEvt
+ gapProcessDisconnectCompleteEvt
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000BE96 - 0000BF1B (0x86 bytes), align: 0
+ Segment part 14. Intra module refs: GAP_TerminateLinkReq::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_TerminateLinkReq 0000BE96
+ calls direct
+ XSTACK = 00000000 ( 0000000C )
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000BF1C - 0000BF20 (0x5 bytes), align: 0
+ Segment part 16. Intra module refs: GAP_TerminateAuth
+ GAP_TerminateLinkReq
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000BF21 - 0000BF25 (0x5 bytes), align: 0
+ Segment part 17. Intra module refs: GAP_TerminateLinkReq
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000BF26 - 0000BF33 (0xe bytes), align: 0
+ Segment part 18. Intra module refs: Segment part 17
+ gapProcessConnectionCompleteEvt
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000BF34 - 0000BFA2 (0x6f bytes), align: 0
+ Segment part 19. Intra module refs: GAP_Signable::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_Signable 0000BF34
+ calls direct
+ XSTACK = 00000000 ( 00000010 )
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000BFA3 - 0000BFA5 (0x3 bytes), align: 0
+ Segment part 21. Intra module refs: GAP_Authenticate
+ GAP_Signable
+ gapPairingCompleteCB
+ gapPasskeyNeededCB
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000BFA6 - 0000BFAB (0x6 bytes), align: 0
+ Segment part 22. Intra module refs: Segment part 21
+ gapPairingCompleteCB
+ sendAuthEvent
+ sendEstLinkEvent
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000BFAC - 0000C0A8 (0xfd bytes), align: 0
+ Segment part 23. Intra module refs: GAP_Authenticate::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_Authenticate 0000BFAC
+ calls direct
+ XSTACK = 00000000 ( 00000010 )
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C0A9 - 0000C0AE (0x6 bytes), align: 0
+ Segment part 25. Intra module refs: GAP_Authenticate
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C0AF - 0000C0B4 (0x6 bytes), align: 0
+ Segment part 26. Intra module refs: Segment part 25
+ gapProcessConnectionCompleteEvt
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C0B5 - 0000C0BA (0x6 bytes), align: 0
+ Segment part 27. Intra module refs: GAP_Authenticate
+ GAP_Bond
+ gapProcessDisconnectCompleteEvt
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C0BB - 0000C0C0 (0x6 bytes), align: 0
+ Segment part 28. Intra module refs: Segment part 27
+ gapProcessConnUpdateCompleteEvt
+ gapProcessConnectionCompleteEvt
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C0C1 - 0000C0FA (0x3a bytes), align: 0
+ Segment part 29. Intra module refs: GAP_TerminateAuth::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_TerminateAuth 0000C0C1
+ calls direct
+ XSTACK = 00000000 ( 0000000D )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C0FB - 0000C19E (0xa4 bytes), align: 0
+ Segment part 33. Intra module refs: GAP_PasscodeUpdate::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_PasscodeUpdate 0000C0FB
+ calls direct
+ XSTACK = 00000016 ( 00000020 )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C19F - 0000C1A3 (0x5 bytes), align: 0
+ Segment part 35. Intra module refs: GAP_Bond
+ GAP_PasscodeUpdate
+ gapSendBondCompleteEvent
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C1A4 - 0000C278 (0xd5 bytes), align: 0
+ Segment part 36. Intra module refs: GAP_Bond::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ GAP_Bond 0000C1A4
+ calls direct
+ XSTACK = 00000001 ( 00000014 )
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C279 - 0000C3CD (0x155 bytes), align: 0
+ Segment part 38. Intra module refs: gapProcessConnectionCompleteEvt::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapProcessConnectionCompleteEvt
+ 0000C279
+ calls direct
+ XSTACK = 00000000 ( 00000020 )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C3CE - 0000C3D1 (0x4 bytes), align: 0
+ Segment part 40. Intra module refs: sendAuthEvent
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C3D2 - 0000C3D6 (0x5 bytes), align: 0
+ Segment part 41. Intra module refs: GAP_Bond
+ Segment part 40
+ gapProcessConnectionCompleteEvt
+ sendAuthEvent
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C3D7 - 0000C3DC (0x6 bytes), align: 0
+ Segment part 42. Intra module refs: GAP_Bond
+ gapPairingCompleteCB
+ gapProcessConnectionCompleteEvt
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C3DD - 0000C433 (0x57 bytes), align: 0
+ Segment part 43. Intra module refs: gapProcessConnUpdateCompleteEvt::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapProcessConnUpdateCompleteEvt
+ 0000C3DD
+ calls direct
+ XSTACK = 00000000 ( 0000000D )
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C434 - 0000C4A3 (0x70 bytes), align: 0
+ Segment part 45. Intra module refs: gapProcessDisconnectCompleteEvt::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapProcessDisconnectCompleteEvt
+ 0000C434
+ calls direct
+ XSTACK = 00000000 ( 0000000E )
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C4A4 - 0000C4A8 (0x5 bytes), align: 0
+ Segment part 47. Intra module refs: GAP_Authenticate
+ GAP_Signable
+ gapProcessDisconnectCompleteEvt
+ sendTerminateEvent
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C4A9 - 0000C4AF (0x7 bytes), align: 0
+ Segment part 48. Intra module refs: GAP_Authenticate
+ gapProcessDisconnectCompleteEvt
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C4B0 - 0000C4B2 (0x3 bytes), align: 0
+ Segment part 49. Intra module refs: GAP_Authenticate
+ gapFreeAuthLink
+ gapPairingCompleteCB
+ gapProcessDisconnectCompleteEvt
+ sendAuthEvent
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C4B3 - 0000C4BA (0x8 bytes), align: 0
+ Segment part 50. Intra module refs: GAP_TerminateLinkReq
+ Segment part 49
+ gapFreeEstLink
+ gapProcessConnectionCompleteEvt
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C4BB - 0000C591 (0xd7 bytes), align: 0
+ Segment part 51. Intra module refs: sendEstLinkEvent::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ sendEstLinkEvent 0000C4BB
+ calls direct
+ XSTACK = 00000020 ( 0000001A )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C592 - 0000C596 (0x5 bytes), align: 0
+ Segment part 53. Intra module refs: gapPairingCompleteCB
+ sendEstLinkEvent
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C597 - 0000C5A1 (0xb bytes), align: 0
+ Segment part 54. Intra module refs: GAP_Signable
+ gapPairingCompleteCB
+ sendEstLinkEvent
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C5A2 - 0000C5E5 (0x44 bytes), align: 0
+ Segment part 55. Intra module refs: sendTerminateEvent::?relay
+ LOCAL ADDRESS
+ ===== =======
+ sendTerminateEvent 0000C5A2
+ calls direct
+ XSTACK = 00000016 ( 0000000E )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C5E6 - 0000C5EE (0x9 bytes), align: 0
+ Segment part 57. Intra module refs: sendTerminateEvent
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C5EF - 0000C660 (0x72 bytes), align: 0
+ Segment part 58. Intra module refs: gapSendLinkUpdateEvent::?relay
+ ENTRY ADDRESS REF BY
+ ===== ======= ======
+ gapSendLinkUpdateEvent
+ 0000C5EF
+ calls direct
+ XSTACK = 0000000D ( 00000014 )
+ ISTACK = 00000000 ( 00000001 )
+ -------------------------------------------------------------------------
+ 1 (was BANKED_CODE)
+ Relative segment, address: CODE 0000C661 - 0000C670 (0x10 bytes), align: 0
+ Segment part 60. Intra module refs: gapSendLinkUpdateEvent
+ sendEstLinkEvent
+ -------------------------------------------------------------------------
+