OSAL_SampleLight.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**************************************************************************************************
  2. Filename: OSAL_SampleLight.c
  3. Revised: $Date: 2008-02-07 12:10:00 -0800 (Thu, 07 Feb 2008) $
  4. Revision: $Revision: 16360 $
  5. Description: This file contains all the settings and other functions
  6. that the user should set and change.
  7. Copyright 2006-2007 Texas Instruments Incorporated. All rights reserved.
  8. IMPORTANT: Your use of this Software is limited to those specific rights
  9. granted under the terms of a software license agreement between the user
  10. who downloaded the software, his/her employer (which must be your employer)
  11. and Texas Instruments Incorporated (the "License"). You may not use this
  12. Software unless you agree to abide by the terms of the License. The License
  13. limits your use, and you acknowledge, that the Software may not be modified,
  14. copied or distributed unless embedded on a Texas Instruments microcontroller
  15. or used solely and exclusively in conjunction with a Texas Instruments radio
  16. frequency transceiver, which is integrated into your product. Other than for
  17. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  18. works of, modify, distribute, perform, display or sell this Software and/or
  19. its documentation for any purpose.
  20. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  21. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  22. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  23. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  24. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  25. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  26. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  27. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  28. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  29. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  30. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  31. Should you have any questions regarding your right to use this Software,
  32. contact Texas Instruments Incorporated at www.TI.com.
  33. **************************************************************************************************/
  34. /*********************************************************************
  35. * INCLUDES
  36. */
  37. #include "ZComDef.h"
  38. #include "hal_drivers.h"
  39. #include "OSAL.h"
  40. #include "OSAL_Tasks.h"
  41. #if defined ( MT_TASK )
  42. #include "MT.h"
  43. #include "MT_TASK.h"
  44. #endif
  45. #include "nwk.h"
  46. #include "APS.h"
  47. #include "ZDApp.h"
  48. #if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )
  49. #include "ZDNwkMgr.h"
  50. #endif
  51. #if defined ( ZIGBEE_FRAGMENTATION )
  52. #include "aps_frag.h"
  53. #endif
  54. #include "zcl_samplelight.h"
  55. /*********************************************************************
  56. * GLOBAL VARIABLES
  57. */
  58. // The order in this table must be identical to the task initialization calls below in osalInitTask.
  59. const pTaskEventHandlerFn tasksArr[] = {
  60. macEventLoop,
  61. nwk_event_loop,
  62. Hal_ProcessEvent,
  63. #if defined( MT_TASK )
  64. MT_ProcessEvent,
  65. #endif
  66. APS_event_loop,
  67. #if defined ( ZIGBEE_FRAGMENTATION )
  68. APSF_ProcessEvent,
  69. #endif
  70. ZDApp_event_loop,
  71. #if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )
  72. ZDNwkMgr_event_loop,
  73. #endif
  74. zcl_event_loop,
  75. zclSampleLight_event_loop
  76. };
  77. const uint8 tasksCnt = sizeof( tasksArr ) / sizeof( tasksArr[0] );
  78. uint16 *tasksEvents;
  79. /*********************************************************************
  80. * FUNCTIONS
  81. *********************************************************************/
  82. /*********************************************************************
  83. * @fn osalInitTasks
  84. *
  85. * @brief This function invokes the initialization function for each task.
  86. *
  87. * @param void
  88. *
  89. * @return none
  90. */
  91. void osalInitTasks( void )
  92. {
  93. uint8 taskID = 0;
  94. tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);
  95. osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));
  96. macTaskInit( taskID++ );
  97. nwk_init( taskID++ );
  98. Hal_Init( taskID++ );
  99. #if defined( MT_TASK )
  100. MT_TaskInit( taskID++ );
  101. #endif
  102. APS_Init( taskID++ );
  103. #if defined ( ZIGBEE_FRAGMENTATION )
  104. APSF_Init( taskID++ );
  105. #endif
  106. ZDApp_Init( taskID++ );
  107. #if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )
  108. ZDNwkMgr_Init( taskID++ );
  109. #endif
  110. zcl_Init( taskID++ );
  111. zclSampleLight_Init( taskID );
  112. }
  113. /*********************************************************************
  114. *********************************************************************/