multi_led.lst 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. C51 COMPILER V9.53.0.0 MULTI_LED 08/23/2018 15:10:01 PAGE 1
  2. C51 COMPILER V9.53.0.0, COMPILATION OF MODULE MULTI_LED
  3. OBJECT MODULE PLACED IN .\Output\multi_led.obj
  4. COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE Code\User\Driver\multi_led.c LARGE OPTIMIZE(2,SPEED) BROWSE INCDIR(Code/
  5. -Include;Code/User;Code/User/Common;Code/User/Driver) DEFINE(FOSC_160000) DEBUG OBJECTEXTEND PRINT(.\Output\LST\multi_led
  6. -.lst) TABS(2) OBJECT(.\Output\multi_led.obj)
  7. line level source
  8. 1 /******************************************************************************/
  9. 2 /* -- 居加居-- */
  10. 3 /*
  11. 4 // 文件名:
  12. 5 // 说明:
  13. 6 // 编写人员:kinve
  14. 7 // 编写日期:2018-8-21
  15. 8 // 程序维护:
  16. 9 // 维护记录:
  17. 10 //
  18. 11 //
  19. 12 */
  20. 13 // 免责声明:
  21. 14 // (c) Anxinke Corporation. All rights reserved.
  22. 15 /******************************************************************************/
  23. 16 #include "multi_led.h"
  24. 17
  25. 18 #define EVENT_CB(state) if(handle->led_set_gpio) handle->led_set_gpio((bool)state)
  26. 19
  27. 20 //button handle list head.
  28. 21 static struct Led* head_handle = NULL;
  29. 22
  30. 23 /**
  31. 24 * @brief Initializes the button struct handle.
  32. 25 * @param handle: the button handle strcut.
  33. 26 * @param pin_level: read the HAL GPIO of the connet button level.
  34. 27 * @param active_level: pressed GPIO level.
  35. 28 * @retval None
  36. 29 */
  37. 30 void led_init_Head(void)
  38. 31 {
  39. 32 1 head_handle = NULL;
  40. 33 1 }
  41. 34 void led_init(struct Led* handle, LedCallback led_set_gpio)
  42. 35 {
  43. 36 1 memset(handle, 0, sizeof(struct Led));
  44. 37 1 handle->led_set_gpio = led_set_gpio;
  45. 38 1 }
  46. 39
  47. 40 void led_set_state(struct Led* handle, u8 ID, u8 OnOff, u8 Type, u16 FlashTime, u16 CloseTime, bool Res )
  48. 41 {
  49. 42 1 if ( Type < LED_STATE_MAX )
  50. 43 1 {
  51. 44 2 handle->Play.ID = ID;
  52. 45 2 handle->Play.Type = Type;
  53. 46 2
  54. 47 2 if ( Type != LED_STATE4_NOT )
  55. 48 2 {
  56. 49 3 handle->Play.OnOff = OnOff;
  57. 50 3 }
  58. 51 2
  59. 52 2 handle->Play.FlashTime = FlashTime;
  60. 53 2 handle->Play.CloseTime = CloseTime;
  61. C51 COMPILER V9.53.0.0 MULTI_LED 08/23/2018 15:10:01 PAGE 2
  62. 54 2 handle->Play.Count = 0;
  63. 55 2 handle->Play.Res = Res;
  64. 56 2 }
  65. 57 1 }
  66. 58
  67. 59
  68. 60 /**
  69. 61 * @brief Button driver core function, driver state machine.
  70. 62 * @param handle: the button handle strcut.
  71. 63 * @retval None
  72. 64 */
  73. 65 void led_handler(struct Led* handle)
  74. 66 {
  75. 67 1 switch ( handle->Play.Type )
  76. 68 1 {
  77. 69 2 case LED_STATE0_OFF: //关
  78. 70 2 EVENT_CB(false);
  79. 71 2 handle->Play.Type = LED_STATE_MAX;
  80. 72 2 break;
  81. 73 2
  82. 74 2 case LED_STATE1_ON: //开
  83. 75 2 EVENT_CB(true);
  84. 76 2 handle->Play.Type = LED_STATE_MAX;
  85. 77 2 break;
  86. 78 2
  87. 79 2 case LED_STATE2_FLASH: //闪烁
  88. 80 2 handle->Play.Count += LED_SCAN;
  89. 81 2
  90. 82 2 if ( handle->Play.Count >= handle->Play.FlashTime )
  91. 83 2 {
  92. 84 3 handle->Play.Count = 0;
  93. 85 3 EVENT_CB(handle->Play.OnOff);
  94. 86 3 handle->Play.OnOff = !handle->Play.OnOff;
  95. 87 3 }
  96. 88 2
  97. 89 2 break;
  98. 90 2
  99. 91 2 case LED_STATE3_CONUT: //定时开关
  100. 92 2 if ( handle->Play.CloseTime > 0 )
  101. 93 2 {
  102. 94 3 handle->Play.CloseTime -= LED_SCAN;
  103. 95 3 EVENT_CB(handle->Play.Res); //开始
  104. 96 3 }
  105. 97 2 else
  106. 98 2 {
  107. 99 3 handle->Play.CloseTime = 0;
  108. 100 3 EVENT_CB(!handle->Play.Res); //结束,与结果相反
  109. 101 3 handle->Play.Type = LED_STATE_MAX;
  110. 102 3 }
  111. 103 2
  112. 104 2 break;
  113. 105 2
  114. 106 2 case LED_STATE4_NOT: //取反
  115. 107 2 EVENT_CB(!handle->Play.OnOff);
  116. 108 2 handle->Play.Type = LED_STATE_MAX;
  117. 109 2 break;
  118. 110 2
  119. 111 2 case LED_STATE5_FLASH_DELAY: //闪烁,延时关闭
  120. 112 2 if ( handle->Play.CloseTime > 0 )
  121. 113 2 {
  122. 114 3 handle->Play.CloseTime -= LED_SCAN;
  123. 115 3 //闪烁
  124. C51 COMPILER V9.53.0.0 MULTI_LED 08/23/2018 15:10:01 PAGE 3
  125. 116 3 handle->Play.Count += LED_SCAN; //开始
  126. 117 3
  127. 118 3 if ( handle->Play.Count >= handle->Play.FlashTime )
  128. 119 3 {
  129. 120 4 handle->Play.Count = 0;
  130. 121 4 EVENT_CB(handle->Play.OnOff);
  131. 122 4 handle->Play.OnOff = !handle->Play.OnOff;
  132. 123 4 }
  133. 124 3 }
  134. 125 2 else
  135. 126 2 {
  136. 127 3 handle->Play.CloseTime = 0;
  137. 128 3 EVENT_CB(handle->Play.Res); //结束,与结果
  138. 129 3 handle->Play.Type = LED_STATE_MAX;
  139. 130 3 }
  140. 131 2
  141. 132 2 break;
  142. 133 2 }
  143. 134 1 }
  144. 135
  145. 136 /**
  146. 137 * @brief Start the button work, add the handle into work list.
  147. 138 * @param handle: target handle strcut.
  148. 139 * @retval 0: succeed. -1: already exist.
  149. 140 */
  150. 141 int led_start(struct Led* handle)
  151. 142 {
  152. 143 1 struct Led* target = head_handle;
  153. 144 1 while(target) {
  154. 145 2 if(target == handle) return -1; //already exist.
  155. 146 2 target = target->next;
  156. 147 2 }
  157. 148 1 handle->next = head_handle;
  158. 149 1 head_handle = handle;
  159. 150 1 return 0;
  160. 151 1 }
  161. 152
  162. 153 /**
  163. 154 * @brief Stop the button work, remove the handle off work list.
  164. 155 * @param handle: target handle strcut.
  165. 156 * @retval None
  166. 157 */
  167. 158 void led_stop(struct Led* handle)
  168. 159 {
  169. 160 1 struct Led** curr;
  170. 161 1 for(curr = &head_handle; *curr; ) {
  171. 162 2 struct Led* entry = *curr;
  172. 163 2 if (entry == handle) {
  173. 164 3 *curr = entry->next;
  174. 165 3 // free(entry);
  175. 166 3 } else {
  176. 167 3 curr = &entry->next;
  177. 168 3 }
  178. 169 2 }
  179. 170 1 }
  180. 171
  181. 172 /**
  182. 173 * @brief background ticks, timer repeat invoking interval 5ms.
  183. 174 * @param None.
  184. 175 * @retval None
  185. 176 */
  186. 177 void led_ticks()
  187. C51 COMPILER V9.53.0.0 MULTI_LED 08/23/2018 15:10:01 PAGE 4
  188. 178 {
  189. 179 1 struct Led* target;
  190. 180 1 for(target=head_handle; target; target=target->next) {
  191. 181 2 led_handler(target);
  192. 182 2 }
  193. 183 1 }
  194. 184
  195. MODULE INFORMATION: STATIC OVERLAYABLE
  196. CODE SIZE = 2014 ----
  197. CONSTANT SIZE = ---- ----
  198. XDATA SIZE = 3 38
  199. PDATA SIZE = ---- ----
  200. DATA SIZE = ---- ----
  201. IDATA SIZE = ---- ----
  202. BIT SIZE = ---- ----
  203. END OF MODULE INFORMATION.
  204. C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)