SHARE
TWEET

Untitled

a guest Jul 9th, 2019 144 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '****************************************************************
  2. '*  Name    : UNTITLED.BAS                                      *
  3. '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
  4. '*  Notice  : Copyright (c) 2019 [select VIEW...EDITOR OPTIONS] *
  5. '*          : All Rights Reserved                               *
  6. '*  Date    : 08/07/2019                                        *
  7. '*  Version : 1.0                                               *
  8. '*  Notes   :                                                   *
  9. '*          :                                                   *
  10. '****************************************************************
  11.  
  12. Device = 16F1826
  13. $define test
  14.  
  15. Config1 FOSC_INTOSC, WDTE_OFF, PWRTE_ON, MCLRE_ON, CP_ON, CPD_ON, BOREN_ON, CLKOUTEN_OFF, IESO_OFF, FCMEN_OFF
  16. Config2 WRT_OFF, PLLEN_ON, STVREN_OFF,LVP_OFF 'BORV_LO
  17.  
  18. Xtal 16
  19. OSCCON = %01111000  
  20. OPTION_REG = %00000111  
  21.  
  22. '---------------------------------------
  23.  
  24. $define CC1101_IOCFG2       $00        ' GDO2 Output pin configuration
  25. $define CC1101_IOCFG1       $01        ' GDO1 Output pin configuration
  26. $define CC1101_IOCFG0       $02        ' GDO0 Output pin configuration
  27. $define CC1101_FIFOTHR      $03        ' RX FIFO And TX FIFO thresholds
  28. $define CC1101_SYNC1        $04        ' 8 bit msb  word  SYNC
  29. $define CC1101_SYNC0        $05        ' 8 bit lsb  word  SYNC
  30. $define CC1101_PKTLEN       $06        '
  31.  
  32. $define CC1101_PKTCTRL1     $07        ' Packet automation control  
  33. $define CC1101_PKTCTRL0     $08        ' Packet automation control
  34. $define CC1101_ADDR         $09        ' Device address
  35. $define CC1101_CHANNR       $0A        ' Channel number  10
  36. $define CC1101_FSCTRL1      $0B        ' Frequency synthesizer control
  37. $define CC1101_FSCTRL0      $0C        ' Frequency synthesizer control
  38. $define CC1101_FREQ2        $0D        ' Frequency control Word, High INT8U
  39. $define CC1101_FREQ1        $0E        ' Frequency control Word, middle INT8U
  40. $define CC1101_FREQ0        $0F        ' Frequency control Word, Low INT8U
  41. $define CC1101_MDMCFG4      $10        ' Modem configuration  
  42. $define CC1101_MDMCFG3      $11        ' Modem configuration
  43. $define CC1101_MDMCFG2      $12        ' Modem configuration
  44. $define CC1101_MDMCFG1      $13        ' Modem configuration  
  45. $define CC1101_MDMCFG0      $14        ' Modem configuration
  46. $define CC1101_DEVIATN      $15        ' Modem deviation setting
  47. $define CC1101_MCSM2        $16        ' Main Radio Control State Machine configuration
  48. $define CC1101_MCSM1        $17        ' Main Radio Control State Machine configuration
  49. $define CC1101_MCSM0        $18        ' Main Radio Control State Machine configuration
  50. $define CC1101_FOCCFG       $19        ' Frequency Offset Compensation configuration
  51. $define CC1101_BSCFG        $1A        ' Bit Synchronization configuration
  52. $define CC1101_AGCCTRL2     $1B        ' AGC control
  53. $define CC1101_AGCCTRL1     $1C        ' AGC control
  54. $define CC1101_AGCCTRL0     $1D        ' AGC control
  55. $define CC1101_WOREVT1      $1E        ' High INT8U Event 0 timeout
  56. $define CC1101_WOREVT0      $1F        ' Low INT8U Event 0 timeout
  57. $define CC1101_WORCTRL      $20        ' Wake On Radio control
  58. $define CC1101_FREND1       $21        ' Front End RX configuration
  59. $define CC1101_FREND0       $22        ' Front End TX configuration
  60. $define CC1101_FSCAL3       $23        ' Frequency synthesizer calibration
  61. $define CC1101_FSCAL2       $24        ' Frequency synthesizer calibration
  62. $define CC1101_FSCAL1       $25        ' Frequency synthesizer calibration
  63. $define CC1101_FSCAL0       $26        ' Frequency synthesizer calibration
  64. $define CC1101_RCCTRL1      $27        ' RC oscillator configuration
  65. $define CC1101_RCCTRL0      $28        ' RC oscillator configuration
  66. $define CC1101_FSTEST       $29        ' Frequency synthesizer calibration control
  67. $define CC1101_PTEST        $2A        ' Production test
  68. $define CC1101_AGCTEST      $2B        ' AGC test
  69. $define CC1101_TEST2        $2C        ' Various test settings
  70. $define CC1101_TEST1        $2D        ' Various test settings
  71. $define CC1101_TEST0        $2E        ' Various test settings
  72.  
  73. 'CC1101 Strobe commands
  74. $define CC1101_SRES         $30        ' Reset chip.
  75. $define CC1101_SFSTXON      $31        ' Enable And calibrate frequency synthesizer (If MCSM0.FS_AUTOCAL=1).
  76.                                        ' If in RX/TX: Go To a Wait state where only the synthesizer is
  77.                                         ' running (For quick RX / TX turnaround).
  78. $define CC1101_SXOFF        $32        ' Turn off crystal oscillator.
  79. $define CC1101_SCAL         $33        ' Calibrate frequency synthesizer And turn it off
  80.                                         ' (enables quick start).
  81. $define CC1101_SRX          $34        ' Enable RX. Perform calibration first If coming from IDLE And
  82.                                         ' MCSM0.FS_AUTOCAL=1.
  83. $define CC1101_STX          $35        ' In IDLE state: Enable TX. Perform calibration first If
  84.                                         ' MCSM0.FS_AUTOCAL=1. If in RX state And CCA is enabled:
  85.                                         ' Only go To TX If channel is Clear.
  86. $define CC1101_SIDLE        $36        ' Exit RX / TX, turn off frequency synthesizer And exit
  87.                                         ' Wake-On-Radio mode If applicable.
  88. $define CC1101_SAFC         $37        ' Perform AFC adjustment of the frequency synthesizer
  89. $define CC1101_SWOR         $38        ' Start automatic RX polling sequence (Wake-on-Radio)
  90. $define CC1101_SPWD         $39        ' Enter power down mode when CSn goes High.
  91. $define CC1101_SFRX         $3A        ' Flush the RX FIFO buffer.
  92. $define CC1101_SFTX         $3B        ' Flush the TX FIFO buffer.
  93. $define CC1101_SWORRST      $3C        ' Reset real time clock.
  94. $define CC1101_SNOP         $3D        ' No operation. May be used To pad strobe commands To two
  95.                                         ' INT8Us For simpler software.
  96. 'CC1101 STATUS REGSITER  
  97. $define CC1101_PARTNUM      $30
  98. $define CC1101_VERSION      $31
  99. $define CC1101_FREQEST      $32
  100. $define CC1101_LQI          $33
  101. $define CC1101_RSSI         $34
  102. $define CC1101_MARCSTATE    $35
  103. $define CC1101_WORTIME1     $36
  104. $define CC1101_WORTIME0     $37
  105. $define CC1101_PKTSTATUS    $38
  106. $define CC1101_VCO_VC_DAC   $39
  107. $define CC1101_TXBYTES      $3A
  108. $define CC1101_RXBYTES      $3B
  109.  
  110. $define WRITE_BURST     $40     '
  111. $define READ_SINGLE     $80     '
  112. $define READ_BURST      $C0     '
  113. $define BYTES_IN_RXFIFO $7F     'Byte number in RXfifo
  114.  
  115.  
  116. 'CC1101 PATABLE,TXFIFO,RXFIFO
  117.  
  118. $define CC1101_PATABLE      $3E
  119. $define CC1101_TXFIFO       $3F
  120. $define CC1101_RXFIFO       $3F
  121.  
  122. '-------Set symbol -------------------------------------------
  123.  
  124. Symbol GIE = INTCON.7  ' Global Interrupt Enable
  125. Symbol PEIE = INTCON.6 ' Peripheral Interrupt Enable
  126. Symbol RCIE = PIE1.5   ' USART Receive Interrupt Enable
  127. Symbol RCIF = PIR1.5   ' USART Receive Interrupt flag
  128. Symbol SCK_PIN = PORTB.4  'SCK1
  129. Symbol MOSI_PIN = PORTA.1 'SDO1
  130. Symbol MISO_PIN = PORTA.0 'SDI1
  131. Symbol SS_PIN = PORTB.5   'SS1
  132. Symbol GDO0 = PORTB.0
  133. Symbol GDO2 = PORTB.3
  134. Symbol Tx_serial = PORTB.7
  135. Symbol Led = PORTA.4      
  136. Symbol pul = PORTB.6      
  137.  
  138. '---Set Port----------------------------------------------------
  139.  
  140. LATA  = %00000000    
  141. LATB  = %00000000
  142. TRISA = %00100001
  143. TRISB = %01001011 'bit0 GDO0 - bit1 miso input - mosi bit2 out - bit3 GDO2 - clk bit4 out - SS bit5 out
  144.  
  145. WPUA = %00100000
  146. WPUB = %01000000
  147. CM1CON0.7 = 0    
  148. CM2CON0.7 = 0    
  149. SRCON0.7 = 0    
  150. Clear ANSELA    
  151. Clear ANSELB
  152. APFCON0 = 0      
  153. APFCON1 = 0
  154.  
  155. INTCON = %00000000
  156.  
  157. '-----------------Set input  output---------------------------------
  158.  
  159. Output MOSI_PIN '
  160. Output SS_PIN   '
  161. Input MISO_PIN  '
  162. Input GDO0      '
  163. Input GDO2
  164.  
  165. '------------------------------------
  166. Dim rxBuffer[64] As Byte
  167. Dim x As Byte
  168. Dim PaTable[8] As Byte '
  169. Dim addr_SWR As Byte
  170. Dim Add_PTR As Word
  171. Dim value_SWR As Byte
  172. Dim txBuffer[64] As Byte Heap
  173. Dim add_BurstReg As Byte
  174. Dim i As Byte
  175. Dim temp As Byte
  176. Dim num As  Byte
  177. Dim strobe As Byte
  178. Dim value_SRR As Byte
  179. Dim size As Byte
  180. Dim Ret_Val As Bit
  181. Dim CC1101_STATUS[2] As Byte
  182.  
  183. Str PaTable = $60,$60,$60,$60,$60,$60,$60,$60
  184. DelayMS 200        
  185.  
  186. main:
  187.  
  188. GoSub CC1101_init        '
  189. GoSub CC1101_SetReceive  '
  190.  
  191.  
  192. main_1:
  193.  
  194. Toggle Led
  195. DelayMS 300
  196.  
  197. If pul = 0 Then
  198.  DelayMS 200
  199.  If pul = 0 Then GoSub tx_routine
  200. End If
  201.  
  202. GoTo main_1
  203.  
  204. '----------------------------------------------------------------------
  205. tx_routine:
  206.  
  207.  
  208. size = 61
  209.  
  210. For i = 0 To size - 1
  211.   txBuffer [i] = i
  212.   Next i
  213.  
  214. GoSub CC1101_SendData
  215.  
  216. DelayMS 1
  217. SerOut Tx_serial,84,["tx ok "]
  218.  
  219. Return
  220.  
  221. '----------------------------------------------------------
  222. CC1101_reset:
  223.   Low SS_PIN   '
  224.   DelayMS 1
  225.   High SS_PIN
  226.   DelayMS 1
  227.   Low SS_PIN
  228.   While MISO_PIN = 1 : Wend    
  229.   SHOut MOSI_PIN,SCK_PIN,MsbFirst_H,[CC1101_SRES]
  230.   While MISO_PIN = 1 : Wend
  231.   High SS_PIN
  232.   $ifdef test
  233.   SerOut Tx_serial,84,["reset ok"]
  234.   DelayMS 50
  235.   SerOut Tx_serial,84,[CC1101_SRES]
  236.   $endif
  237. Return
  238. '--------------------------------------------------------------
  239. CC1101_init:
  240.   High SS_PIN    
  241.   High SCK_PIN
  242.   Low MOSI_PIN
  243.   GoSub CC1101_reset
  244.   GoSub CC1101_RegConfigSettings
  245.   add_BurstReg = CC1101_PATABLE  
  246.   Add_PTR = AddressOf(PaTable)    
  247.   num = 8
  248.   GoSub CC1101_SpiWriteBurstReg  
  249.   $ifdef test
  250.   SerOut Tx_serial,84,["PATABLE OK"]
  251.   $endif
  252. Return
  253. '---------------------------------------------------
  254. CC1101_SpiWriteReg:      
  255.   Low SS_PIN
  256.   While MISO_PIN = 1 : Wend
  257.   SHOut MOSI_PIN,SCK_PIN,MsbFirst_H,[addr_SWR]
  258.   SHOut MOSI_PIN,SCK_PIN,MsbFirst_H,[value_SWR]
  259.   High SS_PIN
  260. Return
  261.  
  262. '---------------------------------------------------------------------
  263. CC1101_SpiWriteBurstReg:  
  264. Low SS_PIN
  265.   While MISO_PIN = 1 : Wend            
  266.   'SHOut MOSI_PIN,SCK_PIN,MsbFirst_H,[add_BurstReg | WRITE_BURST] 'add_BurstReg(3E) | WRITE_BURST($40) = $7E
  267.   SHOut MOSI_PIN,SCK_PIN,MsbFirst_H,[add_BurstReg <PIPE> $40]
  268.   For i = 0 To num - 1
  269.     value_SRR = Ptr8(Add_PTR++)
  270.     SHOut MOSI_PIN,SCK_PIN,MsbFirst_H,[value_SRR]
  271.   Next i
  272.   High SS_PIN
  273. Return
  274. '---------------------------------------------------------
  275. CC1101_SpiStrobe:  
  276.   Low SS_PIN
  277.   While MISO_PIN = 1 : Wend
  278.   SHOut MOSI_PIN,SCK_PIN,MsbFirst_H,[strobe]
  279.   High SS_PIN
  280. Return
  281. '----------------------------------------------------------
  282. CC1101_SpiReadReg:              
  283.   Low SS_PIN
  284.   While MISO_PIN = 1 : Wend
  285.   SHOut MOSI_PIN,SCK_PIN,MsbFirst_H,[addr_SWR<PIPE>$80]
  286.   SHIn MISO_PIN,SCK_PIN,MsbPost_H,[value_SRR]
  287.   High SS_PIN
  288. Return
  289. '---------------------------------------------------------------
  290. CC1101_SpiReadStatus:          
  291.   Low SS_PIN
  292.   While MISO_PIN = 1 : Wend
  293.   SHOut MOSI_PIN,SCK_PIN,MsbFirst_H,[addr_SWR<PIPE>$C0]'READ_BURST $C0
  294.   SHIn MISO_PIN,SCK_PIN,MsbPost_H,[value_SRR]
  295.   High SS_PIN
  296. Return
  297. '----------------------------------------------------------------
  298. CC1101_SpiReadBurstReg:
  299.   Low SS_PIN
  300.   While MISO_PIN = 1 : Wend
  301.   SHOut MOSI_PIN,SCK_PIN,MsbFirst_H,[add_BurstReg <PIPE>$C0 ]
  302.   For i = 0 To num - 1
  303.     SHIn MISO_PIN,SCK_PIN,MsbPost_H,[x]
  304.     Ptr8(Add_PTR++) = x
  305.   Next i
  306.   High SS_PIN
  307. Return
  308. '----------------------------------------------------------------
  309. CC1101_RegConfigSettings:
  310.  
  311.   addr_SWR = CC1101_FSCTRL1  ' SpiWriteReg(CC1101_FSCTRL1 =%0B, 0x08)
  312.   value_SWR = 0x08
  313.   GoSub CC1101_SpiWriteReg
  314.  
  315.   addr_SWR = CC1101_FSCTRL0
  316.   value_SWR = 0x00
  317.   GoSub CC1101_SpiWriteReg   ' SpiWriteReg(CC1101_FSCTRL0 =$0C, 0x00)
  318.  
  319.   addr_SWR = CC1101_FREQ2
  320.   value_SWR = 0x10
  321.   GoSub CC1101_SpiWriteReg   ' SpiWriteReg(CC1101_FREQ2 =$0D ,0x10)
  322.  
  323.   addr_SWR = CC1101_FREQ1
  324.   value_SWR = 0xA7
  325.   GoSub CC1101_SpiWriteReg   ' SpiWriteReg(CC1101_FREQ1 =$0E,0xA7)
  326.  
  327.   addr_SWR = CC1101_FREQ0
  328.   value_SWR = 0x62
  329.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_FREQ0=$0F,0x62)
  330.  
  331.   addr_SWR = CC1101_MDMCFG4
  332.   value_SWR = 0x5B
  333.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_MDMCFG4=$10,0x5B)
  334.  
  335.   addr_SWR = CC1101_MDMCFG3
  336.   value_SWR = 0xF8
  337.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_MDMCFG3=$11,0xF8)
  338.  
  339.   addr_SWR = CC1101_MDMCFG2  
  340.   value_SWR = 0x03            
  341.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_MDMCFG2=$12,0x03)
  342.  
  343.   addr_SWR = CC1101_MDMCFG1
  344.   value_SWR = 0x22
  345.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_MDMCFG1=$13,0x22)
  346.  
  347.   addr_SWR = CC1101_MDMCFG0
  348.   value_SWR = 0xF8
  349.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_MDMCFG0=$14,0xF8)
  350.  
  351.   addr_SWR = CC1101_CHANNR
  352.   value_SWR = 0x00
  353.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_CHANNR=$0A,0x00)
  354.  
  355.   addr_SWR = CC1101_DEVIATN
  356.   value_SWR = 0x47
  357.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_DEVIATN=$15,0x47)
  358.  
  359.   addr_SWR = CC1101_FREND1
  360.   value_SWR = 0xB6
  361.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_FREND1=$21,0xB6)
  362.  
  363.   addr_SWR = CC1101_FREND0
  364.   value_SWR = 0x10
  365.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_FREND0=$22,0x10)
  366.  
  367.   addr_SWR = CC1101_MCSM0
  368.   value_SWR = 0x18
  369.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_MCSM0=$18 ,0x18)
  370.  
  371.   addr_SWR = CC1101_FOCCFG
  372.   value_SWR = 0x1D
  373.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_FOCCFG=$19,0x1D)
  374.  
  375.   addr_SWR = CC1101_BSCFG
  376.   value_SWR = 0x1C
  377.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_BSCFG=$1A,0x1C)
  378.  
  379.   addr_SWR = CC1101_AGCCTRL2
  380.   value_SWR = 0xC7
  381.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_AGCCTRL2=$1B,0xC7)
  382.  
  383.   addr_SWR = CC1101_AGCCTRL1
  384.   value_SWR = 0x00
  385.   GoSub CC1101_SpiWriteReg     ' SpiWriteReg(CC1101_AGCCTRL1=$1C,0x00)
  386.  
  387.   addr_SWR = CC1101_AGCCTRL0
  388.   value_SWR = 0xB2
  389.   GoSub CC1101_SpiWriteReg     ' SpiWriteReg(CC1101_AGCCTRL0=$1D,0xB2)
  390.  
  391.   addr_SWR = CC1101_FSCAL3
  392.   value_SWR = 0xEA
  393.   GoSub CC1101_SpiWriteReg     ' SpiWriteReg(CC1101_FSCAL3=$23,0xEA)
  394.  
  395.   addr_SWR = CC1101_FSCAL2
  396.   value_SWR = 0x2A
  397.   GoSub CC1101_SpiWriteReg     ' SpiWriteReg(CC1101_FSCAL2=$24,0x2A)
  398.  
  399.   addr_SWR = CC1101_FSCAL1
  400.   value_SWR = 0x00
  401.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_FSCAL1=$25,0x00)
  402.  
  403.   addr_SWR = CC1101_FSCAL0
  404.   value_SWR = 0x11
  405.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_FSCAL0=$26,0x11)
  406.  
  407.   addr_SWR = CC1101_FSTEST
  408.   value_SWR = 0x59
  409.   GoSub CC1101_SpiWriteReg   ' SpiWriteReg(CC1101_FSTEST=$29,0x59)
  410.  
  411.   addr_SWR = CC1101_TEST2
  412.   value_SWR = 0x81
  413.   GoSub CC1101_SpiWriteReg   ' SpiWriteReg(CC1101_TEST2=$2C,0x81)
  414.  
  415.   addr_SWR = CC1101_TEST1
  416.   value_SWR = 0x35
  417.   GoSub CC1101_SpiWriteReg   ' SpiWriteReg(CC1101_TEST1=2D,0x35)
  418.  
  419.   addr_SWR = CC1101_TEST0
  420.   value_SWR = 0x09
  421.   GoSub CC1101_SpiWriteReg   ' SpiWriteReg(CC1101_TEST0=2E,0x09)
  422.  
  423.  
  424.   addr_SWR = CC1101_IOCFG2
  425.   value_SWR = 0x0B
  426.   GoSub CC1101_SpiWriteReg  ' SpiWriteReg(CC1101_IOCFG2=$00,0x0B)
  427.  
  428.  
  429.   addr_SWR = CC1101_IOCFG0
  430.   value_SWR = 0x06
  431.   GoSub CC1101_SpiWriteReg   ' SpiWriteReg(CC1101_IOCFG0=$02,0x06)
  432.  
  433. 'two status bytes will be appended to the payload of the packet,
  434. 'including RSSI LQI and CRC OK
  435. 'No address check
  436.  
  437.   addr_SWR = CC1101_PKTCTRL1   '
  438.                                '
  439.   value_SWR = 0x04
  440.   GoSub CC1101_SpiWriteReg     ' SpiWriteReg(CC1101_PKTCTRL1=$07, 0x04)
  441.  
  442. 'whitening offCRC EnableĀ£Ā»variable length packets, packet length configured
  443. 'by the first byte after sync word
  444.  
  445.   addr_SWR = CC1101_PKTCTRL0
  446.   value_SWR = 0x05             '
  447.   GoSub CC1101_SpiWriteReg     ' SpiWriteReg(CC1101_PKTCTRL0=$08,0x05)
  448.  
  449.  
  450.   addr_SWR = CC1101_ADDR      'address used for packet filtration.
  451.   value_SWR = 0x00
  452.   GoSub CC1101_SpiWriteReg    ' SpiWriteReg(CC1101_ADDR=$09,0x00)
  453.  
  454.   addr_SWR = CC1101_PKTLEN
  455.   value_SWR = 0x3D            '
  456.   GoSub CC1101_SpiWriteReg    '
  457.                               '
  458.   SerOut Tx_serial,84,["config ok"] 'For Test
  459.  
  460.  Return
  461. '--------------------------------------------------------------------------------
  462.  CC1101_SendData:
  463.   addr_SWR = CC1101_TXFIFO             '
  464.   value_SWR = size                     '
  465.   GoSub CC1101_SpiWriteReg             '
  466.   add_BurstReg = CC1101_TXFIFO
  467.   Add_PTR = AddressOf(txBuffer)        '
  468.   num = size                           '
  469.   GoSub CC1101_SpiWriteBurstReg;       '
  470.   strobe = CC1101_STX                  '
  471.   GoSub CC1101_SpiStrobe               '
  472.   While GDO0 = 0: Wend          '
  473.   While GDO0 = 1: Wend          '
  474.   strobe = CC1101_SFTX          '
  475.   GoSub CC1101_SpiStrobe        ' flush TXfifo
  476. Return
  477. '----------------------------------------------------------------------------------
  478. CC1101_SetReceive:
  479.   strobe = CC1101_SRX     '
  480.   GoSub CC1101_SpiStrobe
  481. Return
  482. '-------------------------------------------------------------
  483. CC1101_CheckReceiveFlag:   '
  484.   Ret_Val = 0              '
  485.   If GDO0 = 1 Then         '
  486.     While GDO0  = 1 : Wend
  487.     Ret_Val = 1
  488.     Return
  489.   End If
  490. Return
  491. '---------------------------------------------------------
  492. CC1101_ReceiveData:
  493.   Ret_Val = 0
  494.   addr_SWR = CC1101_RXBYTES   '
  495.   GoSub CC1101_SpiReadStatus  '
  496.   value_SRR = value_SRR & $7F
  497.   If value_SRR <> 0 Then
  498.     addr_SWR = CC1101_RXFIFO  
  499.     GoSub CC1101_SpiReadReg   '
  500.     size = value_SRR          '
  501.     add_BurstReg = CC1101_RXFIFO
  502.     num = size
  503.     Add_PTR = AddressOf(rxBuffer)
  504.     GoSub CC1101_SpiReadBurstReg  '
  505.     Add_PTR = AddressOf(CC1101_STATUS)
  506.     num = 2
  507.     GoSub CC1101_SpiReadBurstReg  '
  508.     strobe = CC1101_SFRX          '
  509.     GoSub CC1101_SpiStrobe
  510.     Ret_Val = size                '
  511.   Else
  512.     strobe = CC1101_SFRX
  513.     GoSub CC1101_SpiStrobe
  514.     Ret_Val = 0
  515.   End If
  516. Return
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top