main.lst 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. C51 COMPILER V9.60.7.0 MAIN 11/21/2025 17:14:05 PAGE 1
  2. C51 COMPILER V9.60.7.0, COMPILATION OF MODULE MAIN
  3. OBJECT MODULE PLACED IN .\Objects\main.obj
  4. COMPILER INVOKED BY: d:\Keil_v5\C51\BIN\C51.EXE ..\source\main.c OBJECTADVANCED OPTIMIZE(9,SPEED) BROWSE ORDER NOAREGS M
  5. -ODC2 INCDIR(..\..\..\..\driver\inc;..\..\..\..\mcu;..\..\..\..\middleware\log;..\..\..\..\middleware\delay;..\..\..\..\m
  6. -iddleware\rf_basis) DEFINE(IS_CLIENT_BOARD=1) DEBUG PRINT(.\Listings\main.lst) TABS(2) OBJECT(.\Objects\main.obj)
  7. line level source
  8. 1 /**
  9. 2 ************************************************************************
  10. 3 * @file main.c
  11. 4 * @brief Example for RF tx function.
  12. 5 * @version V0.6
  13. 6 * @date 2024-11-20
  14. 7 * @author Panchip Team
  15. 8 * Copyright (C) 2024 Panchip Technology Corp. All rights reserved.
  16. 9 ****************************************************************************
  17. 10 */
  18. 11
  19. 12 #include <intrins.h>
  20. 13 #include "stdlib.h"
  21. 14 #include <string.h>
  22. 15 #include <stdio.h>
  23. 16 #include "gpio.h"
  24. 17 #include "rcc.h"
  25. 18 #include "rf.h"
  26. 19 #include "uart.h"
  27. 20 #include "timer.h"
  28. 21 #include "log.h"
  29. 22
  30. 23 #ifndef IS_CLIENT_BOARD
  31. #define IS_CLIENT_BOARD 0
  32. #endif
  33. 26
  34. 27 #if IS_CLIENT_BOARD
  35. 28 #define USER_KEY_PIN GPIO_P32
  36. 29 #define USER_KEY_PIN_BIT P3_2
  37. 30 #define USER_KEY_PIN_MUX GPIO_P32_MUX_IO
  38. 31 #else
  39. #define USER_KEY_PIN GPIO_P33
  40. #define USER_KEY_PIN_BIT P3_3
  41. #define USER_KEY_PIN_MUX GPIO_P33_MUX_IO
  42. #endif
  43. 36
  44. 37 #define RF_ADRESS_SIZE 5
  45. 38 #define RF_TX_BUF_SIZE 64 // The length of PAYLOAD/ACK PAYLOAD to be sent each time
  46. 39 #define RF_RX_BUF_SIZE 64 // Receive payload length is set by RF_SetRxPayloadLen
  47. 40 RF_ITStatus_t rf_status;
  48. 41
  49. 42 typedef struct
  50. 43 {
  51. 44 /* radio param */
  52. 45 u16 channel; // 2400~2480
  53. 46 RF_TxPower_t txPower; // 0dbm~13dbm
  54. 47 RF_DataRate_t rate; // 1Mbps, 2Mbps and 250Kbps
  55. 48
  56. 49 /* radio config */
  57. 50 RF_ChipMode_t ChipMode; // 297L、BLE and 24L01
  58. 51 RF_WorkMode_t WorkMode; // normal mode and enhance mode
  59. 52 bool EnAPL; // ack payload enable or disable only used in enhancde mode
  60. 53 bool EnDPL; // dynamic payload enable or disable only used in enhancde mode
  61. C51 COMPILER V9.60.7.0 MAIN 11/21/2025 17:14:05 PAGE 2
  62. 54 bool EnTxNoAck; // tx noack enable or disable only used in normal mode
  63. 55 bool EnWhite; // whiten enable or disable
  64. 56 RF_Crc_t crc;
  65. 57 u8 AddrWidth;
  66. 58 u8 TRxAddr[RF_ADRESS_SIZE];
  67. 59
  68. 60 u16 RxTimeoutUs; // RF Wait for ack timeout time in enhance mode or receive a packet with timeo
  69. -ut in normal mode
  70. 61 u16 TxSetupTimeUs; // RF tx setup time, the time from the end of the last bit of received packet
  71. -to the start of the first bit of the ack packet
  72. 62
  73. 63 u8 TxBuf[RF_TX_BUF_SIZE];
  74. 64 u8 RxBuf[RF_RX_BUF_SIZE];
  75. 65
  76. 66 u8 TxLen;
  77. 67 u8 RxLen;
  78. 68 } RFConfig_t;
  79. 69
  80. 70 RFConfig_t xdata gRfConfig =
  81. 71 {
  82. 72 /*.Channel = */ 2418,
  83. 73 /*.TxPower = */ 7,
  84. 74 /*.DataRate = */ RF_DR_1Mbps,
  85. 75 /*.ChipMode = */ RF_CHIPMODE_BLE,
  86. 76 /*.WorkMode = */ RF_WORKMODE_NORMAL,
  87. 77 /*.EnAPL = */ ENABLE,
  88. 78 /*.EnDPL = */ ENABLE,
  89. 79 /*.EnTxNoAck = */ DISABLE,
  90. 80 /*.EnWhite = */ ENABLE,
  91. 81 /*.Crc = */ RF_CRC_2BYTE,
  92. 82 /*.AddrWidth = */ RF_ADRESS_SIZE,
  93. 83 /*.TRxAddr = */ {0x10, 0x22, 0x55, 0x0F, 0x71}, // If you want to test multi-pipe0, you can u
  94. -se this address
  95. 84 // /*.TRxAddr = */ {0x11, 0x22, 0x55, 0x0F, 0x71}, // If you want to test multi-pipe1, you can
  96. -use this address
  97. 85 // /*.TRxAddr = */ {0x12, 0x22, 0x55, 0x0F, 0x71}, // If you want to test multi-pipe2, you can
  98. -use this address
  99. 86 // /*.TRxAddr = */ {0x13, 0x22, 0x55, 0x0F, 0x71}, // If you want to test multi-pipe3, you can
  100. -use this address
  101. 87 // /*.TRxAddr = */ {0x14, 0x22, 0x55, 0x0F, 0x71}, // If you want to test multi-pipe4, you can
  102. -use this address
  103. 88 // /*.TRxAddr = */ {0x15, 0x22, 0x55, 0x0F, 0x71}, // If you want to test multi-pipe5, you can
  104. -use this address
  105. 89 /*.RxTimeoutUs = */ 1000,
  106. 90 /*.TxSetupTimeUs = */ 200,
  107. 91 /*.TxBuf = */ {0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
  108. 92 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
  109. 93 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
  110. 94 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
  111. 95 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
  112. 96 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
  113. 97 0x55,0x55,0x55,0x55},
  114. 98 /*.RxBuf = */ {0},
  115. 99 /*.TxLen = */ 0,
  116. 100 /*.RxLen = */ 0,
  117. 101 };
  118. 102
  119. 103 u16 xdata Timer2IntCnt = 0; // The interrupt period of timer2's setting is about 50ms
  120. 104
  121. 105 void APP_UartInit(void)
  122. 106 {
  123. 107 1 RCC_PeriphClockCmd(RCC_PERIPH_UART, ENABLE);
  124. C51 COMPILER V9.60.7.0 MAIN 11/21/2025 17:14:05 PAGE 3
  125. 108 1 RCC_PeriphClockCmd(RCC_PERIPH_PORT, ENABLE);
  126. 109 1 RCC_PeriphClockCmd(RCC_PERIPH_TIMER1, ENABLE);
  127. 110 1
  128. 111 1 /** Initialize uart params(if baudrate is 115200, timer1 will be used by uart) */
  129. 112 1 GPIO_Init(GPIO_P31, GPIO_P31_MUX_TXD0, GPIO_MODE_OUTPUT_PP, GPIO_NOPULL);
  130. 113 1 UART_Init(LENGTH_8, DISABLE_RX, DISABLE_PAR, BAUD_115200);
  131. 114 1 }
  132. 115
  133. 116 void APP_Timer2Init(void)
  134. 117 {
  135. 118 1 RCC_PeriphClockCmd(RCC_PERIPH_TIMER2, ENABLE);
  136. 119 1
  137. 120 1 TIM_TimeBaseInit(TIMER2, TIM2_Mode0_16BitAutoReload, TIM_CLK_DIV_12T, 0xFACB);
  138. 121 1 TIM_EnableIRQ(TIMER2); /**< Enable timer0 interrupt */
  139. 122 1 TIM_Cmd(TIMER2, ENABLE); /**< Start timer0 */
  140. 123 1 }
  141. 124
  142. 125 void APP_RfInit(RFConfig_t *pCfg)
  143. 126 {
  144. 127 1 RCC_PeriphClockCmd(RCC_PERIPH_RF, ENABLE);
  145. 128 1
  146. 129 1 RF_Init();
  147. 130 1
  148. 131 1 RF_CarrierOffset(0x00);
  149. 132 1 RF_SetChipMode(pCfg->ChipMode);
  150. 133 1 RF_SetDataRate(pCfg->rate);
  151. 134 1 RF_SetChannel(pCfg->channel-2400);
  152. 135 1 RF_SetCrc(pCfg->crc);
  153. 136 1 RF_SetTxPower(pCfg->txPower);
  154. 137 1
  155. 138 1 RF_SetFifoLenType(RF_FIFOLEN_TYPE_64);
  156. 139 1
  157. 140 1 RF_SetTxAddr(pCfg->TRxAddr, pCfg->AddrWidth);
  158. 141 1 RF_SetRxAddr(RF_PIPE0, pCfg->TRxAddr, pCfg->AddrWidth);
  159. 142 1 RF_SetRxPayloadLen(RF_PIPE0, sizeof(gRfConfig.RxBuf));
  160. 143 1
  161. 144 1 RF_SetWorkMode(pCfg->WorkMode);
  162. 145 1
  163. 146 1 /* RF tx setup time: 112us is minimum value */
  164. 147 1 RF_SetTxSetupTime(pCfg->TxSetupTimeUs);
  165. 148 1
  166. 149 1 if(pCfg->WorkMode == RF_WORKMODE_ENHANCE)
  167. 150 1 {
  168. 151 2 RF_SetTRxAckTimeout(pCfg->RxTimeoutUs);
  169. 152 2 RF_SetAutoRetrans(250, 3); // 250us delay, 3 times retransmit
  170. 153 2 RF_SetNoAck(pCfg->EnTxNoAck);
  171. 154 2 RF_SetAckPayload(pCfg->EnAPL);
  172. 155 2 RF_EnableDynamicPayload(RF_PIPE0, pCfg->EnDPL);
  173. 156 2 }
  174. 157 1 else
  175. 158 1 {
  176. 159 2 RF_SetAutoRetrans(250, 0); // You must disable the auto retransmit function, when chip is in norma
  177. -l mode
  178. 160 2 RF_SetNoAck(ENABLE); // You must enable the Tx noack bit, when chip is in normal mode
  179. 161 2 RF_SetAckPayload(DISABLE);
  180. 162 2 RF_EnableDynamicPayload(RF_PIPE0, DISABLE);
  181. 163 2 }
  182. 164 1
  183. 165 1 RF_ITConfig(RF_ITCONF_TX|RF_ITCONF_RX|RF_ITCONF_TX_MAX, ENABLE);
  184. 166 1 RF_EnableIRQ();
  185. 167 1 }
  186. 168 void DelayMs(u16 Ms)
  187. C51 COMPILER V9.60.7.0 MAIN 11/21/2025 17:14:05 PAGE 4
  188. 169 {
  189. 170 1 u16 i, j;
  190. 171 1
  191. 172 1 for (i = 0; i < Ms; i++)
  192. 173 1 {
  193. 174 2 for (j = 0; j < 1000; j++)
  194. 175 2 {
  195. 176 3 ;
  196. 177 3 _nop_();
  197. 178 3 }
  198. 179 2 }
  199. 180 1 }
  200. 181 static unsigned char key_flag = 0;
  201. 182 unsigned char key_scan(void)
  202. 183 {
  203. 184 1 uint8_t P10Sta;
  204. 185 1 if (USER_KEY_PIN_BIT)
  205. 186 1 {
  206. 187 2 P10Sta = 1;
  207. 188 2 }
  208. 189 1 else
  209. 190 1 {
  210. 191 2 P10Sta = 0;
  211. 192 2 }
  212. 193 1 // printf("USER_KEY_PIN_BIT=[%bu]\r\n", P10Sta);
  213. 194 1 if(P10Sta==0)
  214. 195 1 {
  215. 196 2 if (key_flag== 0)
  216. 197 2 {
  217. 198 3 DelayMs(300);
  218. 199 3 if(P10Sta==0)
  219. 200 3 {
  220. 201 4 key_flag = 1;
  221. 202 4 }
  222. 203 3 }
  223. 204 2
  224. 205 2 }
  225. 206 1 else
  226. 207 1 {
  227. 208 2 if(P10Sta)
  228. 209 2 {
  229. 210 3 if(key_flag==1)
  230. 211 3 {
  231. 212 4 DelayMs(300);
  232. 213 4 if(P10Sta)
  233. 214 4 {
  234. 215 5 if(key_flag==1)
  235. 216 5 {
  236. 217 6 key_flag=0;
  237. 218 6 return 1;
  238. 219 6 }
  239. 220 5 key_flag=0;
  240. 221 5 }
  241. 222 4 }
  242. 223 3 }
  243. 224 2 }
  244. 225 1
  245. 226 1 return 0;
  246. 227 1 }
  247. 228 int main(void)
  248. 229 {
  249. 230 1 uint8_t txrx_done = 0;
  250. C51 COMPILER V9.60.7.0 MAIN 11/21/2025 17:14:05 PAGE 5
  251. 231 1 uint8_t mode = 250;
  252. 232 1 uint8_t mode_set = 0;
  253. 233 1 uint8_t rf_ch = 2;
  254. 234 1 uint8_t get_rand_num = 0;
  255. 235 1 uint8_t autoMode = 0;
  256. 236 1 int sendPacketCount = 0;
  257. 237 1 /** System clock initialize */
  258. 238 1 RCC_SysClkInit();
  259. 239 1 DelayMs(1000);
  260. 240 1 APP_UartInit();
  261. 241 1 APP_Timer2Init();
  262. 242 1 APP_RfInit(&gRfConfig);
  263. 243 1
  264. 244 1 RF_EnterTxMode();
  265. 245 1 GPIO_Init(USER_KEY_PIN, USER_KEY_PIN_MUX, GPIO_MODE_INPUT, GPIO_PULLUP);
  266. 246 1 EA = 1;
  267. 247 1
  268. 248 1 printf("RF Tx Test.\r\n");
  269. 249 1
  270. 250 1 while (1)
  271. 251 1 {
  272. 252 2 // static u8 Count = 0;
  273. 253 2 if (rf_status)
  274. 254 2 {
  275. 255 3 switch (rf_status)
  276. 256 3 {
  277. 257 4 case RF_IT_TX_RX_DONE:
  278. 258 4 printf("Tx&Rx done.\n");
  279. 259 4 break;
  280. 260 4 case RF_IT_TX_DONE:
  281. 261 4 // printf("Tx done.\n");
  282. 262 4 txrx_done = 1;
  283. 263 4 break;
  284. 264 4 case RF_IT_RX_DONE:
  285. 265 4 // printf("Rx done.\n");
  286. 266 4 break;
  287. 267 4 case RF_IT_TX_MAX_RT:
  288. 268 4 printf("Tx fail.\n");
  289. 269 4 break;
  290. 270 4 default:
  291. 271 4 break;
  292. 272 4 }
  293. 273 3 rf_status = RF_IT_NONE;
  294. 274 3 }
  295. 275 2 if(key_scan())
  296. 276 2 {
  297. 277 3 txrx_done = 1;
  298. 278 3 mode_set = 1;
  299. 279 3 mode++;
  300. 280 3 if(mode>=9)mode = 0;
  301. 281 3 printf("mode=[%bu]\r\n", mode);
  302. 282 3 }
  303. 283 2
  304. 284 2 switch(mode)
  305. 285 2 {
  306. 286 3 case 0:
  307. 287 3 if(mode_set)
  308. 288 3 {
  309. 289 4 mode_set = 0;
  310. 290 4 txrx_done = 1;
  311. 291 4 RF_Deinit();
  312. 292 4 APP_RfInit(&gRfConfig);
  313. C51 COMPILER V9.60.7.0 MAIN 11/21/2025 17:14:05 PAGE 6
  314. 293 4 RF_SetChannel(02);
  315. 294 4 RF_EnterTxMode();
  316. 295 4 }
  317. 296 3 if (txrx_done)
  318. 297 3 {
  319. 298 4 txrx_done = 0;
  320. 299 4 // DelayMs(50);
  321. 300 4 RF_FlushTxFifo();
  322. 301 4 if(gRfConfig.EnTxNoAck)
  323. 302 4 {
  324. 303 5 RF_WriteTxPayloadByXDATA(rf_tx_noack, gRfConfig.TxBuf, sizeof(gRfConfig.TxBuf));
  325. 304 5 }
  326. 305 4 else
  327. 306 4 {
  328. 307 5 RF_WriteTxPayloadByXDATA(rf_tx, gRfConfig.TxBuf, sizeof(gRfConfig.TxBuf));
  329. 308 5 }
  330. 309 4 // printf("TxLen[%bu]:\n", sizeof(gRfConfig.TxBuf));
  331. 310 4 // panlog_hexdump(16, gRfConfig.TxBuf, sizeof(gRfConfig.TxBuf));
  332. 311 4 }
  333. 312 3
  334. 313 3 break;
  335. 314 3 case 1:
  336. 315 3 if(mode_set)
  337. 316 3 {
  338. 317 4 mode_set = 0;
  339. 318 4 txrx_done = 1;
  340. 319 4 RF_SetChannel(40);
  341. 320 4 }
  342. 321 3 if (txrx_done)
  343. 322 3 {
  344. 323 4 txrx_done = 0;
  345. 324 4 // DelayMs(50);
  346. 325 4 RF_FlushTxFifo();
  347. 326 4 RF_WriteTxPayloadByXDATA(rf_tx_noack, gRfConfig.TxBuf, sizeof(gRfConfig.TxBuf));
  348. 327 4 // printf("start to send data\r\n");
  349. 328 4 }
  350. 329 3 break;
  351. 330 3 case 2:
  352. 331 3 if(mode_set)
  353. 332 3 {
  354. 333 4 mode_set = 0;
  355. 334 4 txrx_done = 1;
  356. 335 4 RF_SetChannel(80);
  357. 336 4 }
  358. 337 3 if (txrx_done)
  359. 338 3 {
  360. 339 4 txrx_done = 0;
  361. 340 4 // DelayMs(50);
  362. 341 4 RF_FlushTxFifo();
  363. 342 4 RF_WriteTxPayloadByXDATA(rf_tx_noack, gRfConfig.TxBuf, sizeof(gRfConfig.TxBuf));
  364. 343 4 // printf("start to send data\r\n");
  365. 344 4 }
  366. 345 3 break;
  367. 346 3 case 3:
  368. 347 3 if(mode_set)
  369. 348 3 {
  370. 349 4 mode_set = 0;
  371. 350 4 RF_SetChannel(2);
  372. 351 4 RF_EnterRxMode();
  373. 352 4 printf("RF_EnterRxMode\r\n");
  374. 353 4 }
  375. 354 3 break;
  376. C51 COMPILER V9.60.7.0 MAIN 11/21/2025 17:14:05 PAGE 7
  377. 355 3 case 4:
  378. 356 3 if(mode_set)
  379. 357 3 {
  380. 358 4 mode_set = 0;
  381. 359 4 txrx_done=0;
  382. 360 4 RF_Deinit();
  383. 361 4 APP_RfInit(&gRfConfig);
  384. 362 4 RF_SetChannel(2);
  385. 363 4 RF_EnterTxMode();
  386. 364 4 // DelayMs(50);
  387. 365 4
  388. 366 4 RF_Carrier();
  389. 367 4 }
  390. 368 3 break;
  391. 369 3 case 5:
  392. 370 3 if(mode_set)
  393. 371 3 {
  394. 372 4 mode_set = 0;
  395. 373 4 RF_SetChannel(40);
  396. 374 4 }
  397. 375 3 break;
  398. 376 3 case 6:
  399. 377 3 if(mode_set)
  400. 378 3 {
  401. 379 4
  402. 380 4 mode_set = 0;
  403. 381 4 RF_SetChannel(80);
  404. 382 4 }
  405. 383 3 break;
  406. 384 3 case 7:
  407. 385 3 if(mode_set)
  408. 386 3 {
  409. 387 4 mode_set = 0;
  410. 388 4 RF_Deinit();
  411. 389 4 APP_RfInit(&gRfConfig);
  412. 390 4 RF_EnterTxMode();
  413. 391 4 txrx_done=1;
  414. 392 4 sendPacketCount = 0;
  415. 393 4 }
  416. 394 3 if (sendPacketCount >= 300)
  417. 395 3 {
  418. 396 4 sendPacketCount = 0;
  419. 397 4 // flag_200ms = 0;
  420. 398 4 get_rand_num = rand()%41;
  421. 399 4 rf_ch = get_rand_num*2;
  422. 400 4 if(rf_ch>80)rf_ch=80;
  423. 401 4 RF_SetChannel(rf_ch);
  424. 402 4 printf("rand_num=[%bu]\r\n", rf_ch);
  425. 403 4 }
  426. 404 3 if (txrx_done)
  427. 405 3 {
  428. 406 4 sendPacketCount++;
  429. 407 4 txrx_done=0;
  430. 408 4 RF_FlushTxFifo();
  431. 409 4 RF_WriteTxPayloadByXDATA(rf_tx_noack, gRfConfig.TxBuf, sizeof(gRfConfig.TxBuf));
  432. 410 4 }
  433. 411 3
  434. 412 3 break;
  435. 413 3 case 8:
  436. 414 3 if(mode_set)
  437. 415 3 {
  438. 416 4 mode_set = 0;
  439. C51 COMPILER V9.60.7.0 MAIN 11/21/2025 17:14:05 PAGE 8
  440. 417 4 rf_ch = 0;
  441. 418 4 txrx_done=1;
  442. 419 4 sendPacketCount = 0;
  443. 420 4 }
  444. 421 3
  445. 422 3 if (sendPacketCount >= 300)
  446. 423 3 {
  447. 424 4 sendPacketCount = 0;
  448. 425 4 txrx_done=0;
  449. 426 4 rf_ch+=2;
  450. 427 4 if(rf_ch>80)rf_ch=2;
  451. 428 4 RF_SetChannel(rf_ch);
  452. 429 4 printf("rf_ch=[%bu]\r\n", rf_ch);
  453. 430 4 }
  454. 431 3 if (txrx_done)
  455. 432 3 {
  456. 433 4 txrx_done=0;
  457. 434 4 sendPacketCount++;
  458. 435 4 RF_FlushTxFifo();
  459. 436 4 RF_WriteTxPayloadByXDATA(rf_tx_noack, gRfConfig.TxBuf, sizeof(gRfConfig.TxBuf));
  460. 437 4 }
  461. 438 3 break;
  462. 439 3 }
  463. 440 2 // if(Timer2IntCnt >= 500)
  464. 441 2 // {
  465. 442 2 // Timer2IntCnt = 0;
  466. 443 2 // memset(gRfConfig.TxBuf, Count++, sizeof(gRfConfig.TxBuf));
  467. 444 2 // RF_FlushTxFifo();
  468. 445 2 // if(gRfConfig.EnTxNoAck)
  469. 446 2 // {
  470. 447 2 // RF_WriteTxPayloadByXDATA(rf_tx_noack, gRfConfig.TxBuf, sizeof(gRfConfig.TxBuf));
  471. 448 2 // }
  472. 449 2 // else
  473. 450 2 // {
  474. 451 2 // RF_WriteTxPayloadByXDATA(rf_tx, gRfConfig.TxBuf, sizeof(gRfConfig.TxBuf));
  475. 452 2 // }
  476. 453 2 // printf("TxLen[%bu]:\n", sizeof(gRfConfig.TxBuf));
  477. 454 2 // panlog_hexdump(16, gRfConfig.TxBuf, sizeof(gRfConfig.TxBuf));
  478. 455 2 // }
  479. 456 2
  480. 457 2 // if(gRfConfig.RxLen > 0)
  481. 458 2 // {
  482. 459 2 // printf("RxLen[%bu]:\n", gRfConfig.RxLen);
  483. 460 2 // panlog_hexdump(16, gRfConfig.RxBuf, gRfConfig.RxLen);
  484. 461 2 // gRfConfig.RxLen = 0;
  485. 462 2 // }
  486. 463 2 }
  487. 464 1 }
  488. 465
  489. 466 /**
  490. 467 * @brief
  491. 468 * @param None
  492. 469 * @retval None
  493. 470 */
  494. 471 void RF_InterruptHandler(void) interrupt RF_COM3_VECTOR
  495. 472 {
  496. 473 1
  497. 474 1 rf_status = RF_GetIRQFlags();
  498. 475 1 switch (rf_status)
  499. 476 1 {
  500. 477 2 case RF_IT_TX_RX_DONE:
  501. 478 2 if(gRfConfig.EnAPL != RF_APL_DISABLE)
  502. C51 COMPILER V9.60.7.0 MAIN 11/21/2025 17:14:05 PAGE 9
  503. 479 2 {
  504. 480 3 gRfConfig.RxLen = RF_ReadRxPayloadByXDATA(gRfConfig.RxBuf, sizeof(gRfConfig.RxBuf));
  505. 481 3 }
  506. 482 2 //printf("Tx&Rx done.\n");
  507. 483 2 break;
  508. 484 2 case RF_IT_TX_DONE:
  509. 485 2 //printf("Tx done.\n");
  510. 486 2 break;
  511. 487 2 case RF_IT_RX_DONE:
  512. 488 2 //printf("Rx done.\n");
  513. 489 2 break;
  514. 490 2 case RF_IT_TX_MAX_RT:
  515. 491 2 //printf("Tx fail.\n");
  516. 492 2 break;
  517. 493 2 default:
  518. 494 2 break;
  519. 495 2 }
  520. 496 1 RF_FlushRxFifo();
  521. 497 1 RF_ClearIRQFlags();
  522. 498 1 }
  523. 499
  524. 500 void TIMER2_InterruptHandler(void) interrupt TIMER2_VECTOR
  525. 501 {
  526. 502 1 /* mode1:Tmax = (0x10000)*(1/(16M/div_12)) = 49.152ms */
  527. 503 1 /* Clear timer2 global interrupt falg */
  528. 504 1 TF2 = 0;
  529. 505 1 Timer2IntCnt++;
  530. 506 1 }
  531. MODULE INFORMATION: STATIC OVERLAYABLE
  532. CODE SIZE = 1476 ----
  533. CONSTANT SIZE = 98 ----
  534. XDATA SIZE = 153 ----
  535. PDATA SIZE = ---- ----
  536. DATA SIZE = 2 11
  537. IDATA SIZE = ---- ----
  538. BIT SIZE = ---- ----
  539. EDATA SIZE = ---- ----
  540. HDATA SIZE = ---- ----
  541. XDATA CONST SIZE = ---- ----
  542. FAR CONST SIZE = ---- ----
  543. END OF MODULE INFORMATION.
  544. C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)