
A Anhang
49 DELAY_US ( TR X_RE S ET_T I ME_U S );
50 TRX _ RESET _ HIGH ();
51 trx _ reg_wr i te ( RG_TRX_STATE , CMD_TRX _ OFF );
52 DELAY_US ( TR X_INI T _TIM E _US );
53
54 /* setup transmitt e r
55 * - c o n f i gure radio c hannel
56 * - enable trans m itters automatic crc16 generation
57 * - go into TX state ,
58 * - enable " transmi t end " IRQ
59 */
60 trx _ bit_wr i te ( SR_CHANNEL , CHANNEL );
61 trx _ bit_wr i te ( SR_TX_AUTO_CRC_ON ,1);
62 trx _ reg_wr i te ( RG_TRX_STATE , CMD_PLL_ON );
63 trx _ reg_wr i te ( RG_IRQ_MASK , TRX_IRQ _TX_EN D );
64
65 /* enable global interrupts */
66 sei ();
67
68 /* wait 500 ms and indicate ready state */
69 WAIT500MS ();
70 LED _ SET_VA L UE (1);
71
72 /* i nitialize variables */
73 tx_ i n_pro g ress = false ;
74 but t on_pr e ssed = false ;
75
76 while (1)
77 {
78 if ( button_ p resse d == true )
79 {
80 /* indicate busy state */
81 LED _ T OGGLE (1);
82 LED _ T OGGLE (0);
83
84 /* send frame when button is pressed */
85 if ( tx _in_p r ogres s == false )
86 {
87 tx_in _ progre ss = true ;
88 trx_f r ame_w rite ( sizeof ( txfrm ) , txfrm );
89 TRX_S L PTR_HI GH ();
90 TRX_SL P TR_LOW ();
91
92 /* " de b o u n c e " button */
93 _delay_ms (100);
94 butto n _press ed = false ;
95 }
96 }
97 }
43
Comentários a estes Manuais