www.pudn.com > M8_cc1100_receive.rar > cc1100.s
.module cc1100.c .area lit(rom, con, rel) _rfSettings:: .byte 0 .byte 11 .byte 0 .byte 16 .byte 167 .byte 98 .byte 45 .byte 59 .byte 115 .byte 162 .byte 248 .byte 0 .byte 0 .byte 182 .byte 16 .byte 24 .byte 29 .byte 28 .byte 199 .byte 0 .byte 178 .byte 234 .byte 10 .byte 0 .byte 17 .byte 89 .byte 136 .byte 49 .byte 11 .byte 6 .byte 6 .byte 5 .byte 69 .byte 240 .byte 240 .dbfile E:\学习基地\IMPORT~1\CC1100-RF-Design\cc1100-design\Firmware\M8_cc1100_receive\cc1100.c .dbsym e rfSettings _rfSettings kX .area text(rom, con, rel) .dbfile E:\学习基地\IMPORT~1\CC1100-RF-Design\cc1100-design\Firmware\M8_cc1100_receive\cc1100.c .dbfunc e delay _delay fV ; i -> R20,R21 ; s -> R16,R17 .even _delay:: rcall push_gset1 .dbline -1 .dbline 105 ; /*C************************************************************************** ; * NAME: cc1100.c ; *---------------------------------------------------------------------------- ; * Copyright (c) 2007 endylu ; *---------------------------------------------------------------------------- ; * RELEASE: M8-cc1100 ; * REVISION: 1.0 ; *---------------------------------------------------------------------------- ; * PURPOSE: ; * This file include cc1100 receive and send function ; *****************************************************************************/ ; ; /*_____ I N C L U D E S ____________________________________________________*/ ; ; #include; #include ; #include "main.h" ; /*_____ M A C R O S ________________________________________________________*/ ; ; ; /*_____ D E F I N I T I O N ________________________________________________*/ ; ; ; //------------------------------------------------------------------------------------------------------ ; // Chipcon ; // Product = CC1100 ; // Chip version = E ; // Crystal accuracy = 40 ppm ; // X-tal frequency = 26 MHz ; // RF output power = 0 dBm ; // RX filterbandwidth = 540.000000 kHz ; // Deviation = 0.000000 ; // Datarate = 250.000000 kbps ; // Modulation = (7) MSK ; // Manchester enable = (0) Manchester disabled ; // RF Frequency = 433.000000 MHz ; // Channel spacing = 199.951172 kHz ; // Channel number = 0 ; // Optimization = Sensitivity ; // Sync mode = (3) 30/32 sync word bits detected ; // Format of RX/TX data = (0) Normal mode, use FIFOs for RX and TX ; // CRC operation = (1) CRC calculation in TX and CRC check in RX enabled ; // Forward Error Correction = (0) FEC disabled ; // Length configuration = (1) Variable length packets, packet length configured by the first received byte after sync word. ; // Packetlength = 255 ; // Preamble count = (2) 4 bytes ; // Append status = 1 ; // Address check = (0) No address check ; // FIFO autoflush = 0 ; // Device address = 0 ; // GDO0 signal selection = ( 6) Asserts when sync word has been sent / received, and de-asserts at the end of the packet ; // GDO2 signal selection = (11) Serial Clock ; const RF_SETTINGS rfSettings = { ; 0x00, ; 0x0B, // FSCTRL1 Frequency synthesizer control. ; 0x00, // FSCTRL0 Frequency synthesizer control. ; 0x10, // FREQ2 Frequency control word, high byte. ; 0xA7, // FREQ1 Frequency control word, middle byte. ; 0x62, // FREQ0 Frequency control word, low byte. ; 0x2D, // MDMCFG4 Modem configuration. ; 0x3B, // MDMCFG3 Modem configuration. ; 0x73, // MDMCFG2 Modem configuration. ; 0xa2, // MDMCFG1 Modem configuration. ; 0xF8, // MDMCFG0 Modem configuration. ; ; 0x00, // CHANNR Channel number. ; 0x00, // DEVIATN Modem deviation setting (when FSK modulation is enabled). ; 0xB6, // FREND1 Front end RX configuration. ; 0x10, // FREND0 Front end RX configuration. ; 0x18, // MCSM0 Main Radio Control State Machine configuration. ; 0x1D, // FOCCFG Frequency Offset Compensation Configuration. ; 0x1C, // BSCFG Bit synchronization Configuration. ; 0xC7, // AGCCTRL2 AGC control. ; 0x00, // AGCCTRL1 AGC control. ; 0xB2, // AGCCTRL0 AGC control. ; ; 0xEA, // FSCAL3 Frequency synthesizer calibration. ; 0x0A, // FSCAL2 Frequency synthesizer calibration. ; 0x00, // FSCAL1 Frequency synthesizer calibration. ; 0x11, // FSCAL0 Frequency synthesizer calibration. ; 0x59, // FSTEST Frequency synthesizer calibration. ; 0x88, // TEST2 Various test settings. ; 0x31, // TEST1 Various test settings. ; 0x0B, // TEST0 Various test settings. ; 0x06, //IOCFG2 GDO2 output pin configuration. ; 0x06, // IOCFG0 GDO0 output pin configuration. Refer to SmartRF?Studio User Manual for detailed pseudo register explanation. ; ; 0x05, // PKTCTRL1 Packet automation control. ; 0x45, // PKTCTRL0 Packet automation control. ; ID_Oneself, // ADDR Device address. ; 0xf0, // PKTLEN Packet length. ; }; ; ; /*_____ D E C L A R A T I O N ______________________________________________*/ ; ; ; ; //***************************************************************************************** ; //函数名:delay(unsigned int s) ; //输入:时间 ; //输出:无 ; //功能描述:普通廷时 ; //***************************************************************************************** ; void delay(unsigned int s) ; { .dbline 107 clr R20 clr R21 rjmp L5 L2: .dbline 107 L3: .dbline 107 subi R20,255 ; offset = 1 sbci R21,255 L5: .dbline 107 ; unsigned int i; ; for(i=0; i R16,R17 .even _halWait:: .dbline -1 .dbline 112 ; } ; ; ; void halWait(INT16U timeout) { L11: .dbline 113 ; do { .dbline 114 ; _nop_(); nop .dbline 115 ; _nop_(); nop .dbline 116 ; _nop_(); nop .dbline 117 ; _nop_(); nop .dbline 118 ; _nop_(); nop .dbline 119 ; _nop_(); nop .dbline 120 ; _nop_(); nop .dbline 121 ; _nop_(); nop .dbline 122 ; _nop_(); nop .dbline 123 ; _nop_(); nop .dbline 124 ; _nop_(); nop .dbline 125 ; _nop_(); nop .dbline 126 ; _nop_(); nop .dbline 127 ; _nop_(); nop .dbline 128 ; _nop_(); nop .dbline 129 L12: .dbline 129 ; } while (--timeout); movw R24,R16 sbiw R24,1 movw R16,R24 cpi R16,0 cpc R16,R17 brne L11 X0: .dbline -2 L10: .dbline 0 ; func end ret .dbsym r timeout 16 i .dbend .dbfunc e UartInit _UartInit fV .even _UartInit:: .dbline -1 .dbline 139 ; } ; ; /***************************************************************************************** ; //函数名:UartInit() ; //输入:无 ; //输出:无 ; //功能描述:串口初始化程序 ; /*****************************************************************************************/ ; void UartInit(void) //用232串口发数据到PC,收集数据 ; { .dbline 140 ; UCSRB=(1<R20 ; i -> R22 ; dat -> R16 .even _SpiTxRxByte:: rcall push_gset2 .dbline -1 .dbline 182 ; } ; ; //***************************************************************************************** ; //函数名:SpisendByte(INT8U dat) ; //输入:发送的数据 ; //输出:无 ; //功能描述:SPI发送一个字节 ; //***************************************************************************************** ; INT8U SpiTxRxByte(INT8U dat) ; { .dbline 184 ; INT8U i,temp; ; temp = 0; clr R20 .dbline 186 ; ; SCK_0; cbi 0x18,5 .dbline 186 .dbline 187 ; for(i=0; i<8; i++) clr R22 rjmp L21 L18: .dbline 188 ; { .dbline 189 ; if(dat & 0x80) sbrs R16,7 rjmp L22 .dbline 190 ; { .dbline 191 ; MOSI_1; sbi 0x18,3 .dbline 191 .dbline 192 ; } rjmp L23 L22: .dbline 193 cbi 0x18,3 L23: .dbline 193 ; else MOSI_0; .dbline 194 ; dat <<= 1; lsl R16 .dbline 196 ; ; SCK_1; sbi 0x18,5 .dbline 196 .dbline 197 ; _nop_(); nop .dbline 198 ; _nop_(); nop .dbline 200 ; ; temp <<= 1; lsl R20 .dbline 201 ; if(MISO)temp++; sbis 0x16,4 rjmp L24 .dbline 201 inc R20 L24: .dbline 202 cbi 0x18,5 .dbline 202 .dbline 203 nop .dbline 204 nop .dbline 205 L19: .dbline 187 inc R22 L21: .dbline 187 cpi R22,8 brlo L18 .dbline 206 ; SCK_0; ; _nop_(); ; _nop_(); ; } ; return temp; mov R16,R20 .dbline -2 L17: rcall pop_gset2 .dbline 0 ; func end ret .dbsym r temp 20 c .dbsym r i 22 c .dbsym r dat 16 c .dbend .dbfunc e RESET_CC1100 _RESET_CC1100 fV .even _RESET_CC1100:: .dbline -1 .dbline 216 ; } ; ; //***************************************************************************************** ; //函数名:void RESET_CC1100(void) ; //输入:无 ; //输出:无 ; //功能描述:复位CC1100 ; //***************************************************************************************** ; void RESET_CC1100(void) ; { .dbline 217 ; CSN_0; cbi 0x18,2 .dbline 217 L27: .dbline 218 L28: .dbline 218 ; while (GDO0); sbic 0x10,2 rjmp L27 .dbline 219 ; SpiTxRxByte(CCxxx0_SRES); //写入复位命令 ldi R16,48 rcall _SpiTxRxByte L30: .dbline 220 L31: .dbline 220 ; while (GDO0); sbic 0x10,2 rjmp L30 .dbline 221 ; CSN_1; sbi 0x18,2 .dbline 221 .dbline -2 L26: .dbline 0 ; func end ret .dbend .dbfunc e POWER_UP_RESET_CC1100 _POWER_UP_RESET_CC1100 fV .even _POWER_UP_RESET_CC1100:: .dbline -1 .dbline 231 ; } ; ; //***************************************************************************************** ; //函数名:void POWER_UP_RESET_CC1100(void) ; //输入:无 ; //输出:无 ; //功能描述:上电复位CC1100 ; //***************************************************************************************** ; void POWER_UP_RESET_CC1100(void) ; { .dbline 232 ; CSN_1; sbi 0x18,2 .dbline 232 .dbline 233 ; halWait(1); ldi R16,1 ldi R17,0 rcall _halWait .dbline 234 ; CSN_0; cbi 0x18,2 .dbline 234 .dbline 235 ; halWait(1); ldi R16,1 ldi R17,0 rcall _halWait .dbline 236 ; CSN_1; sbi 0x18,2 .dbline 236 .dbline 237 ; halWait(41); ldi R16,41 ldi R17,0 rcall _halWait .dbline 238 ; RESET_CC1100(); //复位CC1100 rcall _RESET_CC1100 .dbline -2 L33: .dbline 0 ; func end ret .dbend .dbfunc e halSpiWriteReg _halSpiWriteReg fV ; value -> R20 ; addr -> R22 .even _halSpiWriteReg:: rcall push_gset2 mov R20,R18 mov R22,R16 .dbline -1 .dbline 248 ; } ; ; //***************************************************************************************** ; //函数名:void halSpiWriteReg(INT8U addr, INT8U value) ; //输入:地址和配置字 ; //输出:无 ; //功能描述:SPI写寄存器 ; //***************************************************************************************** ; void halSpiWriteReg(INT8U addr, INT8U value) ; { .dbline 249 ; CSN_0; cbi 0x18,2 .dbline 249 L35: .dbline 250 L36: .dbline 250 ; while (GDO0); sbic 0x10,2 rjmp L35 .dbline 251 ; SpiTxRxByte(addr); //写地址 mov R16,R22 rcall _SpiTxRxByte .dbline 252 ; SpiTxRxByte(value); //写入配置 mov R16,R20 rcall _SpiTxRxByte .dbline 253 ; CSN_1; sbi 0x18,2 .dbline 253 .dbline -2 L34: rcall pop_gset2 .dbline 0 ; func end ret .dbsym r value 20 c .dbsym r addr 22 c .dbend .dbfunc e halSpiWriteBurstReg _halSpiWriteBurstReg fV ; temp -> R20 ; i -> R22 ; count -> R10 ; buffer -> R12,R13 ; addr -> R20 .even _halSpiWriteBurstReg:: rcall push_gset4 movw R12,R18 mov R20,R16 ldd R10,y+8 .dbline -1 .dbline 263 ; } ; ; //***************************************************************************************** ; //函数名:void halSpiWriteBurstReg(INT8U addr, INT8U *buffer, INT8U count) ; //输入:地址,写入缓冲区,写入个数 ; //输出:无 ; //功能描述:SPI连续写配置寄存器 ; //***************************************************************************************** ; void halSpiWriteBurstReg(INT8U addr, INT8U *buffer, INT8U count) ; { .dbline 265 ; INT8U i, temp; ; temp = addr | WRITE_BURST; ori R20,64 .dbline 266 ; CSN_0; cbi 0x18,2 .dbline 266 L39: .dbline 267 L40: .dbline 267 ; while (GDO0); sbic 0x10,2 rjmp L39 .dbline 268 ; SpiTxRxByte(temp); mov R16,R20 rcall _SpiTxRxByte .dbline 269 ; for (i = 0; i < count; i++) clr R22 rjmp L45 L42: .dbline 270 .dbline 271 mov R30,R22 clr R31 add R30,R12 adc R31,R13 ldd R16,z+0 rcall _SpiTxRxByte .dbline 272 L43: .dbline 269 inc R22 L45: .dbline 269 cp R22,R10 brlo L42 .dbline 273 ; { ; SpiTxRxByte(buffer[i]); ; } ; CSN_1; sbi 0x18,2 .dbline 273 .dbline -2 L38: rcall pop_gset4 .dbline 0 ; func end ret .dbsym r temp 20 c .dbsym r i 22 c .dbsym r count 10 c .dbsym r buffer 12 pc .dbsym r addr 20 c .dbend .dbfunc e halSpiStrobe _halSpiStrobe fV ; strobe -> R20 .even _halSpiStrobe:: rcall push_gset1 mov R20,R16 .dbline -1 .dbline 283 ; } ; ; //***************************************************************************************** ; //函数名:void halSpiStrobe(INT8U strobe) ; //输入:命令 ; //输出:无 ; //功能描述:SPI写命令 ; //***************************************************************************************** ; void halSpiStrobe(INT8U strobe) ; { .dbline 284 ; CSN_0; cbi 0x18,2 .dbline 284 L47: .dbline 285 L48: .dbline 285 ; while (GDO0); sbic 0x10,2 rjmp L47 .dbline 286 ; SpiTxRxByte(strobe); //写入命令 mov R16,R20 rcall _SpiTxRxByte .dbline 287 ; CSN_1; sbi 0x18,2 .dbline 287 .dbline -2 L46: rcall pop_gset1 .dbline 0 ; func end ret .dbsym r strobe 20 c .dbend .dbfunc e halSpiReadReg _halSpiReadReg fc ; value -> R20 ; temp -> R22 ; addr -> R20 .even _halSpiReadReg:: rcall push_gset2 mov R20,R16 .dbline -1 .dbline 301 ; } ; ; ; ; ; ; //***************************************************************************************** ; //函数名:INT8U halSpiReadReg(INT8U addr) ; //输入:地址 ; //输出:该寄存器的配置字 ; //功能描述:SPI读寄存器 ; //***************************************************************************************** ; INT8U halSpiReadReg(INT8U addr) ; { .dbline 303 ; INT8U temp, value; ; temp = addr|READ_SINGLE;//读寄存器命令 mov R22,R20 ori R22,128 .dbline 304 ; CSN_0; cbi 0x18,2 .dbline 304 L51: .dbline 305 L52: .dbline 305 ; while (GDO0); sbic 0x10,2 rjmp L51 .dbline 306 ; SpiTxRxByte(temp); mov R16,R22 rcall _SpiTxRxByte .dbline 307 ; value = SpiTxRxByte(0); clr R16 rcall _SpiTxRxByte mov R20,R16 .dbline 308 ; CSN_1; sbi 0x18,2 .dbline 308 .dbline 309 ; return value; .dbline -2 L50: rcall pop_gset2 .dbline 0 ; func end ret .dbsym r value 20 c .dbsym r temp 22 c .dbsym r addr 20 c .dbend .dbfunc e halSpiReadBurstReg _halSpiReadBurstReg fV ; temp -> R20 ; i -> R22 ; count -> R10 ; buffer -> R12,R13 ; addr -> R20 .even _halSpiReadBurstReg:: rcall push_gset4 movw R12,R18 mov R20,R16 ldd R10,y+8 .dbline -1 .dbline 320 ; } ; ; ; //***************************************************************************************** ; //函数名:void halSpiReadBurstReg(INT8U addr, INT8U *buffer, INT8U count) ; //输入:地址,读出数据后暂存的缓冲区,读出配置个数 ; //输出:无 ; //功能描述:SPI连续写配置寄存器 ; //***************************************************************************************** ; void halSpiReadBurstReg(INT8U addr, INT8U *buffer, INT8U count) ; { .dbline 322 ; INT8U i,temp; ; temp = addr | READ_BURST; //写入要读的配置寄存器地址和读命令 ori R20,192 .dbline 323 ; CSN_0; cbi 0x18,2 .dbline 323 L55: .dbline 324 L56: .dbline 324 ; while (GDO0); sbic 0x10,2 rjmp L55 .dbline 325 ; SpiTxRxByte(temp); mov R16,R20 rcall _SpiTxRxByte .dbline 326 ; for (i = 0; i < count; i++) clr R22 rjmp L61 L58: .dbline 327 .dbline 328 clr R16 rcall _SpiTxRxByte mov R30,R22 clr R31 add R30,R12 adc R31,R13 std z+0,R16 .dbline 329 L59: .dbline 326 inc R22 L61: .dbline 326 cp R22,R10 brlo L58 .dbline 330 ; { ; buffer[i] = SpiTxRxByte(0); ; } ; CSN_1; sbi 0x18,2 .dbline 330 .dbline -2 L54: rcall pop_gset4 .dbline 0 ; func end ret .dbsym r temp 20 c .dbsym r i 22 c .dbsym r count 10 c .dbsym r buffer 12 pc .dbsym r addr 20 c .dbend .dbfunc e halSpiReadStatus _halSpiReadStatus fc ; temp -> R20 ; value -> R22 ; addr -> R20 .even _halSpiReadStatus:: rcall push_gset2 mov R20,R16 .dbline -1 .dbline 341 ; } ; ; ; //***************************************************************************************** ; //函数名:INT8U halSpiReadReg(INT8U addr) ; //输入:地址 ; //输出:该状态寄存器当前值 ; //功能描述:SPI读状态寄存器 ; //***************************************************************************************** ; INT8U halSpiReadStatus(INT8U addr) ; { .dbline 343 ; INT8U value,temp; ; temp = addr | READ_BURST; //写入要读的状态寄存器的地址同时写入读命令 ori R20,192 .dbline 344 ; CSN_0; cbi 0x18,2 .dbline 344 L63: .dbline 345 L64: .dbline 345 ; while (GDO0); sbic 0x10,2 rjmp L63 .dbline 346 ; SpiTxRxByte(temp); mov R16,R20 rcall _SpiTxRxByte .dbline 347 ; value = SpiTxRxByte(0); clr R16 rcall _SpiTxRxByte mov R22,R16 .dbline 348 ; CSN_1; sbi 0x18,2 .dbline 348 .dbline 349 ; return value; .dbline -2 L62: rcall pop_gset2 .dbline 0 ; func end ret .dbsym r temp 20 c .dbsym r value 22 c .dbsym r addr 20 c .dbend .dbfunc e halRfWriteRfSettings _halRfWriteRfSettings fV .even _halRfWriteRfSettings:: .dbline -1 .dbline 360 ; } ; ; ; //***************************************************************************************** ; //函数名:void halRfWriteRfSettings(RF_SETTINGS *pRfSettings) ; //输入:无 ; //输出:无 ; //功能描述:配置CC1100的寄存器 ; //***************************************************************************************** ; void halRfWriteRfSettings(void) ; { .dbline 363 ; //halSpiWriteReg(CCxxx0_FIFOTHR,0x09); ; //halSpiWriteReg(CCxxx0_MCSM1,0x00); //CCA,没有作通 ; halSpiWriteReg(CCxxx0_FSCTRL0, rfSettings.FSCTRL2);//自已加的 ldi R30,<_rfSettings ldi R31,>_rfSettings lpm R18,Z ldi R16,12 rcall _halSpiWriteReg .dbline 365 ; // Write register settings ; halSpiWriteReg(CCxxx0_FSCTRL1, rfSettings.FSCTRL1); ldi R30,<_rfSettings+1 ldi R31,>_rfSettings+1 lpm R18,Z ldi R16,11 rcall _halSpiWriteReg .dbline 366 ; halSpiWriteReg(CCxxx0_FSCTRL0, rfSettings.FSCTRL0); ldi R30,<_rfSettings+2 ldi R31,>_rfSettings+2 lpm R18,Z ldi R16,12 rcall _halSpiWriteReg .dbline 367 ; halSpiWriteReg(CCxxx0_FREQ2, rfSettings.FREQ2); ldi R30,<_rfSettings+3 ldi R31,>_rfSettings+3 lpm R18,Z ldi R16,13 rcall _halSpiWriteReg .dbline 368 ; halSpiWriteReg(CCxxx0_FREQ1, rfSettings.FREQ1); ldi R30,<_rfSettings+4 ldi R31,>_rfSettings+4 lpm R18,Z ldi R16,14 rcall _halSpiWriteReg .dbline 369 ; halSpiWriteReg(CCxxx0_FREQ0, rfSettings.FREQ0); ldi R30,<_rfSettings+5 ldi R31,>_rfSettings+5 lpm R18,Z ldi R16,15 rcall _halSpiWriteReg .dbline 370 ; halSpiWriteReg(CCxxx0_MDMCFG4, rfSettings.MDMCFG4); ldi R30,<_rfSettings+6 ldi R31,>_rfSettings+6 lpm R18,Z ldi R16,16 rcall _halSpiWriteReg .dbline 371 ; halSpiWriteReg(CCxxx0_MDMCFG3, rfSettings.MDMCFG3); ldi R30,<_rfSettings+7 ldi R31,>_rfSettings+7 lpm R18,Z ldi R16,17 rcall _halSpiWriteReg .dbline 372 ; halSpiWriteReg(CCxxx0_MDMCFG2, rfSettings.MDMCFG2); ldi R30,<_rfSettings+8 ldi R31,>_rfSettings+8 lpm R18,Z ldi R16,18 rcall _halSpiWriteReg .dbline 373 ; halSpiWriteReg(CCxxx0_MDMCFG1, rfSettings.MDMCFG1); ldi R30,<_rfSettings+9 ldi R31,>_rfSettings+9 lpm R18,Z ldi R16,19 rcall _halSpiWriteReg .dbline 374 ; halSpiWriteReg(CCxxx0_MDMCFG0, rfSettings.MDMCFG0); ldi R30,<_rfSettings+10 ldi R31,>_rfSettings+10 lpm R18,Z ldi R16,20 rcall _halSpiWriteReg .dbline 375 ; halSpiWriteReg(CCxxx0_CHANNR, rfSettings.CHANNR); ldi R30,<_rfSettings+11 ldi R31,>_rfSettings+11 lpm R18,Z ldi R16,10 rcall _halSpiWriteReg .dbline 376 ; halSpiWriteReg(CCxxx0_DEVIATN, rfSettings.DEVIATN); ldi R30,<_rfSettings+12 ldi R31,>_rfSettings+12 lpm R18,Z ldi R16,21 rcall _halSpiWriteReg .dbline 377 ; halSpiWriteReg(CCxxx0_FREND1, rfSettings.FREND1); ldi R30,<_rfSettings+13 ldi R31,>_rfSettings+13 lpm R18,Z ldi R16,33 rcall _halSpiWriteReg .dbline 378 ; halSpiWriteReg(CCxxx0_FREND0, rfSettings.FREND0); ldi R30,<_rfSettings+14 ldi R31,>_rfSettings+14 lpm R18,Z ldi R16,34 rcall _halSpiWriteReg .dbline 379 ; halSpiWriteReg(CCxxx0_MCSM0 , rfSettings.MCSM0 ); ldi R30,<_rfSettings+15 ldi R31,>_rfSettings+15 lpm R18,Z ldi R16,24 rcall _halSpiWriteReg .dbline 380 ; halSpiWriteReg(CCxxx0_FOCCFG, rfSettings.FOCCFG); ldi R30,<_rfSettings+16 ldi R31,>_rfSettings+16 lpm R18,Z ldi R16,25 rcall _halSpiWriteReg .dbline 381 ; halSpiWriteReg(CCxxx0_BSCFG, rfSettings.BSCFG); ldi R30,<_rfSettings+17 ldi R31,>_rfSettings+17 lpm R18,Z ldi R16,26 rcall _halSpiWriteReg .dbline 382 ; halSpiWriteReg(CCxxx0_AGCCTRL2, rfSettings.AGCCTRL2); ldi R30,<_rfSettings+18 ldi R31,>_rfSettings+18 lpm R18,Z ldi R16,27 rcall _halSpiWriteReg .dbline 383 ; halSpiWriteReg(CCxxx0_AGCCTRL1, rfSettings.AGCCTRL1); ldi R30,<_rfSettings+19 ldi R31,>_rfSettings+19 lpm R18,Z ldi R16,28 rcall _halSpiWriteReg .dbline 384 ; halSpiWriteReg(CCxxx0_AGCCTRL0, rfSettings.AGCCTRL0); ldi R30,<_rfSettings+20 ldi R31,>_rfSettings+20 lpm R18,Z ldi R16,29 rcall _halSpiWriteReg .dbline 385 ; halSpiWriteReg(CCxxx0_FSCAL3, rfSettings.FSCAL3); ldi R30,<_rfSettings+21 ldi R31,>_rfSettings+21 lpm R18,Z ldi R16,35 rcall _halSpiWriteReg .dbline 386 ; halSpiWriteReg(CCxxx0_FSCAL2, rfSettings.FSCAL2); ldi R30,<_rfSettings+22 ldi R31,>_rfSettings+22 lpm R18,Z ldi R16,36 rcall _halSpiWriteReg .dbline 387 ; halSpiWriteReg(CCxxx0_FSCAL1, rfSettings.FSCAL1); ldi R30,<_rfSettings+23 ldi R31,>_rfSettings+23 lpm R18,Z ldi R16,37 rcall _halSpiWriteReg .dbline 388 ; halSpiWriteReg(CCxxx0_FSCAL0, rfSettings.FSCAL0); ldi R30,<_rfSettings+24 ldi R31,>_rfSettings+24 lpm R18,Z ldi R16,38 rcall _halSpiWriteReg .dbline 389 ; halSpiWriteReg(CCxxx0_FSTEST, rfSettings.FSTEST); ldi R30,<_rfSettings+25 ldi R31,>_rfSettings+25 lpm R18,Z ldi R16,41 rcall _halSpiWriteReg .dbline 390 ; halSpiWriteReg(CCxxx0_TEST2, rfSettings.TEST2); ldi R30,<_rfSettings+26 ldi R31,>_rfSettings+26 lpm R18,Z ldi R16,44 rcall _halSpiWriteReg .dbline 391 ; halSpiWriteReg(CCxxx0_TEST1, rfSettings.TEST1); ldi R30,<_rfSettings+27 ldi R31,>_rfSettings+27 lpm R18,Z ldi R16,45 rcall _halSpiWriteReg .dbline 392 ; halSpiWriteReg(CCxxx0_TEST0, rfSettings.TEST0); ldi R30,<_rfSettings+28 ldi R31,>_rfSettings+28 lpm R18,Z ldi R16,46 rcall _halSpiWriteReg .dbline 393 ; halSpiWriteReg(CCxxx0_IOCFG2, rfSettings.IOCFG2); ldi R30,<_rfSettings+29 ldi R31,>_rfSettings+29 lpm R18,Z clr R16 rcall _halSpiWriteReg .dbline 394 ; halSpiWriteReg(CCxxx0_IOCFG0, rfSettings.IOCFG0); ldi R30,<_rfSettings+30 ldi R31,>_rfSettings+30 lpm R18,Z ldi R16,2 rcall _halSpiWriteReg .dbline 395 ; halSpiWriteReg(CCxxx0_PKTCTRL1, rfSettings.PKTCTRL1); ldi R30,<_rfSettings+31 ldi R31,>_rfSettings+31 lpm R18,Z ldi R16,7 rcall _halSpiWriteReg .dbline 396 ; halSpiWriteReg(CCxxx0_PKTCTRL0, rfSettings.PKTCTRL0); ldi R30,<_rfSettings+32 ldi R31,>_rfSettings+32 lpm R18,Z ldi R16,8 rcall _halSpiWriteReg .dbline 397 ; halSpiWriteReg(CCxxx0_ADDR, rfSettings.ADDR); ldi R30,<_rfSettings+33 ldi R31,>_rfSettings+33 lpm R18,Z ldi R16,9 rcall _halSpiWriteReg .dbline 398 ; halSpiWriteReg(CCxxx0_PKTLEN, rfSettings.PKTLEN); ldi R30,<_rfSettings+34 ldi R31,>_rfSettings+34 lpm R18,Z ldi R16,6 rcall _halSpiWriteReg .dbline -2 L66: .dbline 0 ; func end ret .dbend .dbfunc e halRfSendPacket _halRfSendPacket fV ; size -> R22 ; txBuffer -> R20,R21 .even _halRfSendPacket:: rcall push_gset2 mov R22,R18 movw R20,R16 sbiw R28,1 .dbline -1 .dbline 413 ; } ; ; ; ; ; ; ; //***************************************************************************************** ; //函数名: ; //输入: ; //输出: ; //功能描述:CC1100发送主叫数据 ; //***************************************************************************************** ; void halRfSendPacket(INT8U *txBuffer, INT8U size) ; { .dbline 415 ; ; halSpiWriteReg(CCxxx0_TXFIFO, size+2); mov R18,R22 subi R18,254 ; addi 2 ldi R16,63 rcall _halSpiWriteReg .dbline 416 ; halSpiWriteReg(CCxxx0_TXFIFO, ID_Opponent); ldi R18,240 ldi R16,63 rcall _halSpiWriteReg .dbline 417 ; halSpiWriteReg(CCxxx0_TXFIFO, ID_Oneself); ldi R18,240 ldi R16,63 rcall _halSpiWriteReg .dbline 419 ; ; halSpiWriteBurstReg(CCxxx0_TXFIFO, txBuffer, size); //写入要发送的数据 std y+0,R22 movw R18,R20 ldi R16,63 rcall _halSpiWriteBurstReg .dbline 422 ; ; ; halSpiStrobe(CCxxx0_STX); //进入发送模式发送数据 ldi R16,53 rcall _halSpiStrobe L102: .dbline 425 L103: .dbline 425 ; ; // Wait for GDO0 to be set - > sync transmitted ; while (!GDO0); in R2,0x10 tst R2 brne L105 ldi R20,1 ldi R21,0 rjmp L106 L105: clr R20 clr R21 L106: sbrc R20,2 rjmp L102 L107: .dbline 428 L108: .dbline 428 ; ; // Wait for GDO0 to be set - > sync transmitted ; while (GDO0); sbic 0x10,2 rjmp L107 .dbline 430 ; ; halSpiStrobe(CCxxx0_SFTX); //清洗发送缓冲区 ldi R16,59 rcall _halSpiStrobe .dbline -2 L101: adiw R28,1 rcall pop_gset2 .dbline 0 ; func end ret .dbsym r size 22 c .dbsym r txBuffer 20 pc .dbend