From 774e619ba8f01e4b8744c15ed56e75c56000c918 Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 10 Sep 2015 12:49:14 -0700 Subject: Initial Commit --- RTOS Task Wiki_1.0_manifest.html | 357 +++++++++++++++++++++++++++++++++++++++ notificationTask.c | 257 ++++++++++++++++++++++++++++ notificationTask.h | 79 +++++++++ 3 files changed, 693 insertions(+) create mode 100644 RTOS Task Wiki_1.0_manifest.html create mode 100644 notificationTask.c create mode 100644 notificationTask.h diff --git a/RTOS Task Wiki_1.0_manifest.html b/RTOS Task Wiki_1.0_manifest.html new file mode 100644 index 0000000..9a7d4c3 --- /dev/null +++ b/RTOS Task Wiki_1.0_manifest.html @@ -0,0 +1,357 @@ + + + + + + + + + + + + + +Texas Instruments Manifest + + + +
+ + + + + + + +
+ + + + + + + +
+
+

+ +RTOS Task Wiki Manifest + +

+ +

+ +09-09-2015 + +

+ + +

+ +Manifest ID - SRAS00002103 + +

+
+

Legend

+

(explanation of the fields in the Manifest Table below)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Software Name + +The name of the application or file +
+Version + +Version of the application or file +
+License Type + +Type of license(s) under which TI will be providing +software to the licensee (e.g. BSD-3-Clause, GPL-2.0, TI TSPA License, TI +Commercial License). The license could be under Commercial terms or Open Source. See Open Source Reference License Disclaimer in +the Disclaimers Section. Whenever possible, TI will use an SPDX Short Identifier for an Open Source +License. TI Commercial license terms are not usually included in the manifest and are conveyed through a variety +of means such as a clickwrap license upon install, +a signed license agreement and so forth. +
+Location + +The directory name and path on the media or a specific file where the Software is located. Typically fully qualified path names +are not used and instead the relevant top level directory of the application is given. +A notation often used in the manifests is [as installed]/directory/*. Note that the asterisk implies that all +files under that directory are licensed as the License Type field denotes. Any exceptions to this will +generally be denoted as [as installed]/directory/* except as noted below which means as shown in subsequent rows of +the manifest. +
+Delivered As + +This field will either be “Source”, “Binary” or “Source +and Binary” and is the primary form the content of the Software is delivered +in. If the Software is delivered in an archive format, this field +applies to the contents of the archive. If the word Limited is used +with Source, as in “Limited Source” or “Limited Source and Binary” then +only portions of the Source for the application are provided. +
+Modified by TI + +This field will either be “Yes” or “No”. A “Yes” means +TI has made changes to the Software. A “No” means TI has not made any +changes. Note: This field is not applicable for Software “Obtained +from” TI. +
+Obtained from + +This field specifies from where or from whom TI obtained +the Software. It may be a URL to an Open Source site, a 3rd +party licensor, or TI. See Links Disclaimer in the Disclaimers +Section. +
+
+

Disclaimers

+

Export Control Classification Number (ECCN)

+

Any use of ECCNs listed in the Manifest is at the user’s risk +and without recourse to TI. Your +company, as the exporter of record, is responsible for determining the +correct classification of any item at +the time of export. Any export classification by TI of Software is for +TI’s internal use only and shall not be construed as a representation +or warranty +regarding the proper export classification for such Software or whether +an export +license or other documentation is required for exporting such Software

+

Links in the Manifest

+

Any +links appearing on this Manifest +(for example in the “Obtained from” field) were verified at the time +the Manifest was created. TI makes no guarantee that any listed links +will +remain active in the future.

+

Open Source License References

+

Your company is responsible for confirming the +applicable license terms for any open source Software +listed in this Manifest that was not “Obtained from” TI. Any open +source license +specified in this Manifest for Software that was +not “Obtained from” TI is for TI’s internal use only and shall not be +construed as a representation or warranty regarding the proper open +source license terms +for such Software.

+
+

Export Information

+

ECCN for Software included in this release:

+Publicly Available - Open Source or TI TSPA License +
+ + + + + +

+ RTOS Task Wiki Manifest Table +

+ + +

+ + See the Legend above for a description of these columns. + +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Software NameVersionLicense TypeDelivered AsModified by TI
+ notificationTask.c + + 1.0 + + BSD-3-Clause + + Source + + N/A + Location + [Install Directory]\ +
Obtained from + TI +
+ notificationTask.h + + 1.0 + + BSD-3-Clause + + Source + + N/A + Location + [Install Directory]\ +
Obtained from + TI +
+ +

+

+

+ +

+

Credits

+




+
+

Licenses

+

RTOS Task Wiki Licenses




/*
* Filename: notificationTask.c
*
* Description: Additional Task that sends a notification when the select
* button is pressed on the SmartRF06 board. This is a dummy
* task to be used as a framework for making a more complex
* task.
*
* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/



+
+ + \ No newline at end of file diff --git a/notificationTask.c b/notificationTask.c new file mode 100644 index 0000000..d1b6b0c --- /dev/null +++ b/notificationTask.c @@ -0,0 +1,257 @@ +/* + * Filename: notificationTask.c + * + * Description: Additional Task that sends a notification the the select + * button is pressed on the SmartRF06 board. This is a dummy + * task to be used as a framework for making a more comlex + * task. + * + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +*/ +/********************************************************************* + * INCLUDES + */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "gatt.h" + + +#include "inc/hw_memmap.h" +#include "inc/hw_ints.h" + +#include "board_key.h" +#include "Board.h" +#include "notificationTask.h" + + +#include +/********************************************************************* + * CONSTANTS + */ +#define NOTIFY_TASK_PRIORITY 1 + +#ifndef NOTIFY_TASK_STACK_SIZE +#define NOTIFY_TASK_STACK_SIZE 644 +#endif +#define TASK_NUM_ATTR_SUPPORTED 1 + +#define NOTIFY_TASK_SELECT_EVT 0x0001 + + +/********************************************************************* + * LOCAL VARIABLES + */ +static PIN_Config notifySelectPinCfg[] = +{ + Board_KEY_SELECT | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP, + PIN_TERMINATE +}; +//! \brief PIN State for select pin on SmartRF06 board +static PIN_State notifySelectPinState; + +//! \brief PIN Handles for select pin on SmartRF06 board +static PIN_Handle hNotifySelectPin; +// Entity ID globally used to check for source and/or destination of messages +static ICall_EntityID selfEntity; + +// Semaphore globally used to post events to the application thread +static ICall_Semaphore sem; + +// Clock instances for internal periodic events. +static Clock_Struct periodicClock; + +// Task configuration +Task_Struct notifyTask; +Char notifyTaskStack[NOTIFY_TASK_STACK_SIZE]; +// events flag for internal application events. +static uint16_t events; +//Dummy Data to send in notificaiton +const UInt32 dataToNotify = 0xAAAA5555; + +/********************************************************************* + * LOCAL FUNCTIONS + */ + +static void NotificationTask_init( void ); +static void NotificationTask_taskFxn(UArg a0, UArg a1); +static void NotificationTask_selectPINHwiFxn(PIN_Handle hPin, PIN_Id pinId); + +/********************************************************************* + * PROFILE CALLBACKS + */ + + + +/********************************************************************* + * PUBLIC FUNCTIONS + */ + +/********************************************************************* + * @fn NotificationTask_createTask + * + * @brief Task creation function for the Notification Task + * + * @param None. + * + * @return None. + */ +void NotificationTask_createTask(void) +{ + Task_Params taskParams; + + // Configure task + Task_Params_init(&taskParams); + taskParams.stack = notifyTaskStack; + taskParams.stackSize = NOTIFY_TASK_STACK_SIZE; + taskParams.priority = NOTIFY_TASK_PRIORITY; + + Task_construct(¬ifyTask, NotificationTask_taskFxn, &taskParams, NULL); +} + +/********************************************************************* + * @fn NotificationTask_init + * + * @brief Called during initialization and contains application + * specific initialization (ie. hardware initialization/setup, + * table initialization, power up notification, etc), and + * profile initialization/setup. + * + * @param None. + * + * @return None. + */ +static void NotificationTask_init(void) +{ + // ****************************************************************** + // N0 STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp + // ****************************************************************** + // Register the current thread as an ICall dispatcher application + // so that the application can send and receive messages. + ICall_registerApp(&selfEntity, &sem); + + //Open the select pin on the board, and register it for interrupts + hNotifySelectPin = PIN_open(¬ifySelectPinState, notifySelectPinCfg); + PIN_registerIntCb(hNotifySelectPin, NotificationTask_selectPINHwiFxn); + PIN_setConfig(hNotifySelectPin, + PIN_BM_IRQ, + Board_KEY_SELECT | PIN_IRQ_BOTHEDGES); + + // Enable wakeup + PIN_setConfig(hNotifySelectPin, + PINCC26XX_BM_WAKEUP, + Board_KEY_SELECT | PINCC26XX_WAKEUP_NEGEDGE); + + +} +/********************************************************************* + * @fn NotificationTask_taskFxn + * + * @brief Application task entry point for the Notification Task. + * + * @param a0, a1 - not used. + * + * @return None. + */ +static void NotificationTask_taskFxn(UArg a0, UArg a1) +{ + // Initialize application + NotificationTask_init(); + + // Application main loop + for (;;) + { + // Waits for a signal to the semaphore associated with the calling thread. + // Note that the semaphore associated with a thread is signaled when a + // message is queued to the message receive queue of the thread or when + // ICall_signal() function is called onto the semaphore. + ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER); + + + if (events & NOTIFY_TASK_SELECT_EVT) + { + //Set up notificaiton data + uint16 len = sizeof(UInt32); + attHandleValueNoti_t noti; + bStatus_t status; + noti.handle = 0x1E; + noti.len = len; + + + //attempt to allocate payload + noti.pValue = (uint8 *)GATT_bm_alloc( 0, ATT_HANDLE_VALUE_NOTI, GATT_MAX_MTU, &len ); + + if ( noti.pValue != NULL ) //if allocated + { + //place index + noti.pValue[0] = (dataToNotify >> 24) & 0xFF; + noti.pValue[1] = (dataToNotify >> 16) & 0xFF; + noti.pValue[2] = (dataToNotify >> 8) & 0xFF; + noti.pValue[3] = dataToNotify & 0xFF; + status = GATT_Notification( 0, ¬i, 0 ); //attempt to send + if ( status != SUCCESS ) //if noti not sent + { + GATT_bm_free( (gattMsg_t *)¬i, ATT_HANDLE_VALUE_NOTI ); + } + } + else + { + //bleNoResources + asm(" NOP"); + } + //Clear the event + events &= ~NOTIFY_TASK_SELECT_EVT; + } + + } +} + +static void NotificationTask_selectPINHwiFxn(PIN_Handle hPin, PIN_Id pinId) +{ + if (sem != NULL) + { + //Set the event and wake up the task + events |= NOTIFY_TASK_SELECT_EVT; + Semaphore_post(sem); + } +} diff --git a/notificationTask.h b/notificationTask.h new file mode 100644 index 0000000..c3d348c --- /dev/null +++ b/notificationTask.h @@ -0,0 +1,79 @@ +/* + * Filename: notificationTask.h + * + * Description: Additional Task that sends a notification the the select + * button is pressed on the SmartRF06 board. This is a dummy + * task to be used as a framework for making a more comlex + * task. + * + * + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +*/ +#ifndef NOTIFICATIONTASK_H +#define NOTIFICATIONTASK_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +/********************************************************************* + * INCLUDES + */ + +/********************************************************************* +* EXTERNAL VARIABLES +*/ + +/********************************************************************* + * CONSTANTS + */ + +/********************************************************************* + * FUNCTIONS + */ + +/* + * Task creation function for the Simple BLE Peripheral. + */ +extern void NotificationTask_createTask(void); + + +/********************************************************************* +*********************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif /* NOTIFICATIONTASK_H */ -- cgit v1.2.3-54-g00ecf