|
采用Spirit1实现433M的无线发送,通过SPI接口配置了SPirit1,配置寄存器读写正确,写入TXFIFO数据,发送前读取TXFIFO的数据Number为20,然后启动发送,SPIRIT1_GPIO3中断能进入,但是没有发送完成的中断状态,发送后读取TXFIFO的数据Number为0,采用SPIRIT1的配置工具生成的参数配置,测试结果也是一样,SPIRIT1_GPIO3中断能进入,但是没有发送完成的中断状态,数据也没有发送出去,什么原因?- f# @9 [4 q& f1 }- B! l /* Spirit ON */ SpiritEnterShutdown();' v8 p* S, D! E, T. \! H ; _% `$ L8 U0 A/ M3 s SpiritExitShutdown(); SpiritManagementWaExtraCurrent();- l: e' ~1 v- l$ X ) g+ V a" s; [) \! ^ // SpiritManagementIdentificationRFBoard(); SpiritSetXtalFrequency(); ) Y0 [3 W; W) ^/ Z1 A- ]6 }8 M7 j3 a /* if the board has eeprom, we can compensate the offset calling SpiritManagementGetOffset (if eeprom is not present this fcn will return 0) */ xRadioInit.lFrequencyBase = xRadioInit.lFrequencyBase + SpiritManagementGetOffset();7 C. O) [4 O, S, z7 {" k, u , U# g" ~$ l4 J; O ~3 v /* Initialize the signals to drive the range extender application board */ SpiritManagementRangeExtInit(); /* uC IRQ config uC IRQ enable*/# f9 x9 q+ C+ x Sprit1_GPIO3_IRQ_Init();" S. z$ W! t' g/ X" i /* Spirit IRQ config */ SpiritGpioInit(&xGpioIRQ); /* Spirit Radio config */ SpiritRadioInit(&xRadioInit);+ k5 n. }) r. k, Y 3 f$ x# E Z9 j4 `6 _/ \2 q$ E /* Spirit Radio set power */* D0 I: e' V0 P: R SpiritRadioSetPALeveldBm(7,POWER_DBM); SpiritRadioSetPALevelMaxIndex(7);. n, c) B8 s6 Y7 n L% N; R " n c& B% p! U6 K- @" k c) ]' [ /* Spirit Packet config */ SpiritPktBasicInit(&xBasicInit); SpiritPktBasicAddressesInit(&xAddressInit);" Z& H# h5 r, ~2 J. Z0 s /* Spirit IRQs enable */ SpiritIrqDeInit(NULL);. r: E% e. z+ h# H SpiritIrq(TX_DATA_SENT , S_ENABLE); SpiritIrq(TX_FIFO_ERROR , S_ENABLE); % W; p' ?* z/ Y6 T P. } /* payload length config */8 u+ A0 Q7 c1 L3 x0 u, m SpiritPktBasicSetPayloadLength(20);1 ^, i. i5 }! K$ P) }2 {* e+ I. F1 r 9 ]3 ^* K3 [; _' l8 N0 l /* destination address.! @1 J/ `; T" g% K5 U1 N9 ` By default it is not used because address is disabled, see struct xAddressInit*/' q8 A$ A. J9 g SpiritPktBasicSetDestinationAddress(0x35);* |4 T7 T+ l7 u) c0 z3 p /* IRQ registers blanking */% }' F" d; ~. s3 x SpiritIrqClearStatus();/ x r* P) \: {; y; b3 n6 }0 Y /* Infinite loop */# f0 J# U" p" U" l$ h /* USER CODE BEGIN WHILE */ while (1). N# B6 t. [: I { 7 f5 O |- ^& a2 [* ] /* fit the TX FIFO */- P- o4 z6 t; o5 E1 I) X. D SpiritCmdStrobeFlushTxFifo(); SpiritSpiWriteLinearFifo(20, vectcTxBuff);5 c P# P/ F8 D& a" X( f% K* ?. v + `+ T& Y8 Y3 n$ ^1 L ^6 X! V0 K /* send the TX command */ SpiritCmdStrobeTx(); J O6 a2 g- H1 E ! l5 T2 o* G, A/ K" f. I /* wait for TX done */ // while(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11)==GPIO_PIN_RESET);1 K {3 } q/ O0 p ' R: d' E6 q1 g& j( J) n9 p6 i' M // while(!xTxDoneFlag)- S3 Q6 D q4 g( X2 u3 {# r // { // SpiritRefreshStatus(); // // SpiritIrqGetStatus(&xIrqStatus); // - J, D$ }* c& l# v // if(xIrqStatus.IRQ_TX_DATA_SENT) // { // xTxDoneFlag = SET;3 g; K# C ^7 ^1 ~3 Z // } ) l* n4 ]0 L8 c# m r8 A6 u2 k$ D // }; Y) K j! b% h$ K4 ~ // SpiritIrqGetStatus(&xIrqStatus); /* wait for TX done */& w( { t. s1 [( J0 Q5 k( d: c/ @% I. ? while(!xTxDoneFlag);) ^; p- V. V \( {) q, r xTxDoneFlag = RESET;" Q F! \/ q/ l/ r* q g_dwtx_send_ok++;0 a: ?: t) T. e V; T /* pause between two transmissions */0 p% k1 s, I1 T HAL_Delay(500); //delay 500ms6 [ _$ @& P* W4 p7 R /* USER CODE END WHILE */5 O/ e$ z4 x0 @. R" }5 ] /* USER CODE BEGIN 3 */4 q: ~; g2 {3 t `6 R7 v } /* USER CODE END 3 */4 ?3 c) `; v- D' N }, F3 [3 ~9 P$ i //中断处理部分+ E1 F; U& v1 p% M+ D if(GPIO_PIN_11 == GPIO_Pin)//SPIRIT1_GPIO3中断$ H( U$ f2 X) L5 V2 d' _% e { /* Get the IRQ status */ SpiritIrqGetStatus(&xIrqStatus);, C) k2 }6 @! L+ Y4 j 3 j4 O5 e) k2 H5 g1 c /* Check the SPIRIT TX_DATA_SENT IRQ flag */ if(xIrqStatus.IRQ_TX_DATA_SENT)! l8 [' a% W1 p, o8 b/ F; y* w { g_dwTest_Count[0]++; /* set the tx_done_flag to manage the event in the main() */5 F: C. h: h7 n6 O! q xTxDoneFlag = SET; // g_btransmitting = 0;) X" }3 V2 C% T / d7 {* S2 c6 U" e* o2 h7 f. | /* toggle LED1 */: |) m5 s* p3 L3 ` // GPIO_Led_Invert();# m O2 T1 t9 C /* Flush the RX FIFO */ // SpiritCmdStrobeFlushRxFifo(); . @% [7 Y- i" M: x /* RX command - to ensure the device will be ready for the next reception */ // SpiritCmdStrobeRx();2 n/ B8 }* D7 _9 v }$ @. f1 J; ~$ Z1 g& N /* Check the SPIRIT RX_DATA_DISC IRQ flag */ if(xIrqStatus.IRQ_RX_DATA_DISC) {: h# G$ v/ s0 U4 D b/ ]& N: z5 m /* toggle LED1 */ // GPIO_Led_Invert();//SdkEvalLedToggle(LED1); g_dwTest_Count[1]++;2 [" @5 I) Q: G1 @* S3 b /* RX command - to ensure the device will be ready for the next reception */ SpiritCmdStrobeRx(); } % ^* P/ r& f& \$ [( G3 c3 ` /* Check the SPIRIT RX_DATA_READY IRQ flag */! U1 X! |. {$ i0 A5 A/ j if(xIrqStatus.IRQ_RX_DATA_READY)# y) V# Q v$ x. t2 t: T( M { g_bReceive_New_Frame = TRUE; g_dwTest_Count[2]++; } //////////////test///////////////////////////////- E4 b7 I- e) u" j if(xIrqStatus.IRQ_TX_FIFO_ERROR)/ X! b! p: _- _. R4 }* _ {2 j6 J3 q& J }! \0 [4 f' l. ~ g_dwTest_Count[3]++;/ w) e$ N7 ?0 q5 y9 W4 ]) [/ i, ^ }4 L! w) l @( R' x1 N' B/ o //////////////test/////////////////////////////// } 2 I) Y! H' a8 ~5 h- b$ L1 O void SpiritSetXtalFrequency(void) { do{9 \' o8 Q G5 h$ H /* Delay for state transition */$ T2 D% C0 e8 X7 Z HAL_Delay(2); //delay 2ms" |2 `; h4 w2 m$ V7 x /* Reads the MC_STATUS register */! e2 t7 T- f1 D4 ~, x SpiritRefreshStatus(); }while(g_xStatus.MC_STATE!=MC_STATE_READY);, G/ \( x$ G* U SpiritRadioSetXtalFrequency(XTAL_FREQUENCY);//XTAL_FREQUENCY = 26000000; * _) p3 X1 D# i, z. w% v& Y* n SpiritManagementSetRangeExtender(RANGE_EXT_NONE); ' s) H& o% Z% i SpiritManagementSetBand(0);8 y% t( b% w* ] # c# J3 B9 X3 T1 ~ SpiritManagementSetOffset(FREQUENCY_OFFSET); } ; H# \ Y7 x- M2 p* H |
微信公众号
手机版