sci_api.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /******************************************************************************
  2. ** File Name: sci_api.h *
  3. ** Author: Richard Yang *
  4. ** DATE: 11/10/2001 *
  5. ** Copyright: 2001 Spreatrum, Incoporated. All Rights Reserved. *
  6. ** Description: *
  7. ******************************************************************************
  8. ******************************************************************************
  9. ** Edit History *
  10. ** ------------------------------------------------------------------------- *
  11. ** DATE NAME DESCRIPTION *
  12. ** 11/10/2001 Richard.Yang Create. *
  13. ** 08/01/2002 Xueliang.Wang Add some macros. *
  14. ** 11/15/2002 Xueliang.Wang Move some function prototype to os_api.h *
  15. ******************************************************************************/
  16. #ifndef _SCI_API_H
  17. #define _SCI_API_H
  18. /**---------------------------------------------------------------------------*
  19. ** Dependencies *
  20. **---------------------------------------------------------------------------*/
  21. #include "os_api.h"
  22. #include "osi_api.h"
  23. /**---------------------------------------------------------------------------*
  24. ** Compiler Flag *
  25. **---------------------------------------------------------------------------*/
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. /**---------------------------------------------------------------------------*
  30. ** Constant Variables *
  31. **---------------------------------------------------------------------------*/
  32. /**---------------------------------------------------------------------------*
  33. ** Data Structures *
  34. **---------------------------------------------------------------------------*/
  35. /**---------------------------------------------------------------------------*
  36. ** Function Prototypes *
  37. **---------------------------------------------------------------------------*/
  38. /**---------------------------------------------------------------------------*
  39. ** LIST
  40. **---------------------------------------------------------------------------*/
  41. /**---------------------------------------------------------------------------*
  42. ** TIMER
  43. **---------------------------------------------------------------------------*/
  44. /**---------------------------------------------------------------------------*
  45. ** OS API MACROS *
  46. **---------------------------------------------------------------------------*/
  47. /**---------------------------------------------------------------------------*
  48. ** THREAD MACRO:
  49. ** SCI_CREATE_THREAD
  50. ** SCI_CREATE_STATIC_THREAD
  51. ** SCI_STOP_THREAD
  52. ** SCI_IDENTIFY_THREAD
  53. **---------------------------------------------------------------------------*/
  54. /*****************************************************************************/
  55. // Description: Get ID of the thread which call this function.
  56. // Global resource dependence:
  57. // Author:
  58. // Parameter:
  59. // Return: ID of thread
  60. // Note:
  61. /*****************************************************************************/
  62. /******************************************************************************
  63. BLOCK_ID SCI_IDENTIFY_THREAD(void);
  64. ******************************************************************************/
  65. #define SCI_IDENTIFY_THREAD() osiThreadCurrent()
  66. /*****************************************************************************/
  67. // Description: Create a signal.
  68. // Global resource dependence:
  69. // Author: Xueliang.Wang
  70. // Parameter: sig_ptr Pointer to the signal which will be created
  71. // sig_code Signal code.
  72. // sig_size Number of bytes will be alloc for the signal
  73. // sender Sender of this signal.
  74. // Return: None.
  75. // Note:
  76. /*****************************************************************************/
  77. /******************************************************************************
  78. void SCI_CreateSignal(
  79. xSignalHeader sig_ptr,
  80. uint16 sig_code,
  81. uint16 sig_size,
  82. BLOCK_ID sender
  83. )
  84. ******************************************************************************/
  85. /*#ifdef LOW_MEMORY_SUPPORT
  86. #define SCI_CREATE_SIGNAL(sig_ptr, sig_code, sig_size, sender) \
  87. (sig_ptr) = (void*)SCI_ALLOC(sig_size);\
  88. SCI_CreateSignal((xSignalHeader)(sig_ptr), sig_code, sig_size, sender);
  89. #else
  90. */
  91. #define SCI_CREATE_SIGNAL(sig_ptr, sig_code, sig_size, sender) \
  92. sig_ptr = (void *)SCI_ALLOC(sig_size); \
  93. SCI_ASSERT(sig_ptr != SCI_NULL, "SCI_CREATE_SIGNAL FAIL"); \
  94. memset((void *)(sig_ptr), 0, sig_size); \
  95. ((xSignalHeader)(sig_ptr))->SignalSize = sig_size; \
  96. ((xSignalHeader)(sig_ptr))->SignalCode = sig_code; \
  97. ((xSignalHeader)(sig_ptr))->Sender = sender;
  98. //#endif
  99. /*****************************************************************************/
  100. // Description: Send a signal.
  101. // Global resource dependence:
  102. // Author: Xueliang.Wang
  103. // Parameter: sig_ptr Pointer to the signal which will be sent
  104. // revicer ID of thread whihc receives this signal.
  105. // Return: None.
  106. // Note:
  107. /*****************************************************************************/
  108. /******************************************************************************
  109. void SCI_SEND_SIGNAL(
  110. xSignalHeader sig_ptr, // Signal pointer to be sent
  111. BLOCK_ID revicer // Dest thread ID
  112. )
  113. ******************************************************************************/
  114. #define SCI_SEND_SIGNAL(sig_ptr, revicer) \
  115. SCI_SendSignal(sig_ptr, revicer);
  116. /**---------------------------------------------------------------------------*
  117. ** TIME MACRO:
  118. ** SCI_GET_CURRENT_TIME
  119. ** SCI_GET_CURRENT_TICKCOUNT
  120. **---------------------------------------------------------------------------*/
  121. /**---------------------------------------------------------------------------*
  122. ** Compiler Flag *
  123. **---------------------------------------------------------------------------*/
  124. #ifdef __cplusplus
  125. }
  126. #endif
  127. #endif // End _SCI_API_H