OSAL_SerialApp.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /**************************************************************************************************
  2. Filename: OSAL_SerialApp.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 2004-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 "SerialApp.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. SerialApp_ProcessEvent
  75. };
  76. const uint8 tasksCnt = sizeof( tasksArr ) / sizeof( tasksArr[0] );
  77. uint16 *tasksEvents;
  78. /*********************************************************************
  79. * FUNCTIONS
  80. *********************************************************************/
  81. /*********************************************************************
  82. * @fn osalInitTasks
  83. *
  84. * @brief This function invokes the initialization function for each task.
  85. *
  86. * @param void
  87. *
  88. * @return none
  89. */
  90. void osalInitTasks( void )
  91. {
  92. uint8 taskID = 0;
  93. tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);
  94. osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));
  95. macTaskInit( taskID++ );
  96. nwk_init( taskID++ );
  97. Hal_Init( taskID++ );
  98. #if defined( MT_TASK )
  99. MT_TaskInit( taskID++ );
  100. #endif
  101. APS_Init( taskID++ );
  102. #if defined ( ZIGBEE_FRAGMENTATION )
  103. APSF_Init( taskID++ );
  104. #endif
  105. ZDApp_Init( taskID++ );
  106. #if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )
  107. ZDNwkMgr_Init( taskID++ );
  108. #endif
  109. SerialApp_Init( taskID );
  110. }
  111. /*********************************************************************
  112. *********************************************************************/