OSAL_ESP.c 4.8 KB

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