gl_flag.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*! \addtogroup GSL
  2. * @{
  3. */
  4. /*!
  5. *
  6. * @file gl_flag.h
  7. *
  8. * @brief This file specifies the Flag APIs
  9. *
  10. * @note Copyright (c) 2009 Sunplus Technology Co., Ltd. \n
  11. * All rights reserved.
  12. *
  13. * @author
  14. *
  15. ******************************************************************************/
  16. #ifndef __GSL_FLAG_H__
  17. #define __GSL_FLAG_H__
  18. /*!
  19. * @defgroup GL_Flag GSL Flag APIs
  20. * @brief GSL Flag APIs
  21. * @{
  22. */
  23. #include "gl_types.h"
  24. /******************************************************************************/
  25. /*!
  26. * @brief Create and initialize a flag object for use.
  27. *
  28. * @param szName string identifier for the interrupt. Up to 16 characters.
  29. * @param pFlagId Flag object identifier returned by the API (on success)
  30. *
  31. * @return @a GL_SUCCESS on success
  32. * @return @a GL_FAILURE on failure
  33. *
  34. * @note None
  35. *******************************************************************************/
  36. GL_Status_t GL_FlagCreate(char *szName, GL_Flag_t * pFlagId);
  37. /******************************************************************************/
  38. /*!
  39. * @brief Used to delete a Flag. Regarding tasks waiting on a deleted Flag, the behavior depends on the underlying OS; the GSL does not guarantee a default behavior (hence, applications should avoid this scenario). Typically, an error is returned to the waiting tasks.
  40. *
  41. * @param pFlagId Flag object identifier
  42. *
  43. * @return @a GL_SUCCESS on success
  44. * @return @a GL_FAILURE on failure
  45. *
  46. * @note None
  47. *******************************************************************************/
  48. GL_Status_t GL_FlagDelete(GL_Flag_t pFlagId);
  49. /******************************************************************************/
  50. /*!
  51. * @brief This sets bits (conditions) to true in a flag. Any bit in "value" that is set to true (1) will set the equivalent bit in the flag. This may wake threads waiting on this flag as a result.
  52. *
  53. * @param pFlagId Flag object identifier
  54. * @param value_i Indefined which bit of flag should be set
  55. *
  56. * @return @a GL_SUCCESS on success
  57. * @return @a GL_FAILURE on failure
  58. *
  59. * @note None
  60. *******************************************************************************/
  61. GL_Status_t GL_FlagSetbits(GL_Flag_t pFlagId,GL_UINT32 value_i);
  62. /******************************************************************************/
  63. /*!
  64. * @brief This causes the calling thread to wait on a set of bits (conditions) to be set in a given flag. The "mode" indicates how the pattern will be interpreted: About the wait mode, there's three selection: \n
  65. * 1) GL_FLAG_WAITMODE_AND :return match if all conditions in the pattern are set in the flag.\n
  66. * 2) GL_FLAG_WAITMODE_OR :return match if any of the conditions in the pattern are set in the flag.\n
  67. * 3) GL_FLAG_WAITMODE_CLR :automatically clear the conditions that caused the calling
  68. * thread to return a match, IF there was a match.\n
  69. * @a GL_FLAG_WAITMODE_CLR can be combined with other two, to clear the bit wait for.\n
  70. *
  71. * @param pFlagId Flag object identifier
  72. * @param value_i Pattern to wait for
  73. * @param mode_i Wait mode
  74. * @param sdTimeout timeout time
  75. *
  76. * @return @a GL_SUCCESS on success
  77. * @return @a GL_FAILURE on failure
  78. *
  79. * @note Do not use it in ISR.
  80. *******************************************************************************/
  81. GL_UINT32 GL_FlagWait(GL_Flag_t pFlagId, GL_UINT32 value_i, GL_UINT8 mode_i,GL_INT32 sdTimeout);
  82. /*!
  83. * @enum GL_FLAG_WAITMODE
  84. */
  85. #define CYG_FLAG_WAITMODE_AND 0 /* all bits must be set */
  86. #define CYG_FLAG_WAITMODE_OR 2 /* any bit must be set */
  87. #define CYG_FLAG_WAITMODE_CLR 1 /* clear when satisfied */
  88. enum GL_FLAG_WAITMODE
  89. {
  90. GL_FLAG_WAITMODE_AND = 0, /**< All events should happen to trigger flag */
  91. GL_FLAG_WAITMODE_CLR = 1, /**< Clear the flag bits when triggering */
  92. GL_FLAG_WAITMODE_OR = 2 /**< One event can trigger the flag */
  93. };
  94. /******************************************************************************/
  95. /*!
  96. * @brief This returns the current bits (conditions) that are set in a given flag.
  97. *
  98. * @param pFlagId Flag object identifier
  99. * @param value_o container of the value peek from GL_Flag_t
  100. *
  101. * @return @a GL_SUCCESS on success
  102. * @return @a GL_FAILURE on failure
  103. *
  104. * @note None
  105. *******************************************************************************/
  106. GL_Status_t GL_FlagPeek(GL_Flag_t pFlagId, GL_UINT32 * value_o);
  107. #ifdef GL_OBJECT_LIST_FLAG
  108. /******************************************************************************/
  109. /*!
  110. * @brief To know if it is a duplicated name in current gsl flag objects
  111. *
  112. * @param name a name
  113. *
  114. * @return @a 0 if not duplicated. @a 1 if duplicated.
  115. *
  116. * @note It blocks scheduler while searching.
  117. *******************************************************************************/
  118. UINT8 GL_FlagIsDupName(const char *name);
  119. /******************************************************************************/
  120. /**
  121. * @brief Used to dump the list of existing flag objects. This helps associate the flag name with the flag object address. Depending on OS support, the list may also display a snapshot of the flag state.The function is used for direct invocation from the IDE shell (if available).The macro is used for invocation from source code. The macro automatically gets compiled out for non-debug builds.
  122. *
  123. * @param wChannel the pre-defined unique ID denoting the output channel to which messages will be printed
  124. *
  125. * @return void
  126. *
  127. * @note Available only in debug builds. Cannot be used from ISR/DSR.
  128. *******************************************************************************/
  129. void GL_FlagDumpList(UINT16 wChannel);
  130. #else
  131. #define GL_FLAG_DUMP_LIST(wChannel) GL_FlagDumpList(wChannel)
  132. #endif
  133. /*! @} end of defgroup GL_Flag */
  134. #endif // __GL_FLAG_H__
  135. /*! @} end of addtogroup GSL */