Файл CC2500 TXSEND.bas

Материал из roboforum.ru Wiki
Версия от 07:20, 29 июня 2008; EdGull (обсуждение | вклад) (Новая: <source lang="vb"> $prog &HFF , &HAE , &HD7 , &H00 $regfile = "m8def.dat" $crystal = 8000000 $baud = 19200 $hwstack = 64 $swstack = 32 Config Pinc.0 = Output : Led Alias Portc.0 : Led ...)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

<source lang="vb">

$prog &HFF , &HAE , &HD7 , &H00 $regfile = "m8def.dat" $crystal = 8000000 $baud = 19200 $hwstack = 64 $swstack = 32

Config Pinc.0 = Output : Led Alias Portc.0 : Led = 1 Config Pinb.1 = Output : Zb_cs Alias Portb.1 : Zb_cs = 1 Config Pind.2 = Input : Gdo2 Alias Pind.2 Config Pind.3 = Input : Gdo0 Alias Pind.3 Config Pinb.5 = Output : Zb_sck Alias Portb.5 : Zb_sck = 0 Config Pinb.4 = Input : Zb_miso Alias Pinb.4 Config Pinb.3 = Output : Zb_mosi Alias Portb.3 : Zb_mosi = 0

Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Clockrate = 128 , Polarity = Low , Phase = 0 Spiinit

$include "settings\MSK500TX.bas" $include "include\cc2500.bas"

Dim Count As Byte , Frend0 As Byte , Comchar As Byte

Print Chr(10) ; Chr(13) ; "THIS IS USED FOR FREQUENCY HOPING. ONLY TX MODE!" Call Cc_spi_read_register_burst(ccxxx0_patable , 8) Print "PATable : "; For Count = 1 To 8

  Print Hex(cc_recv_buffer(count)) ; " ";

Next Count Print

Cc_send_buffer(1) = 3 Cc_send_buffer(2) = Asc( "O") Cc_send_buffer(3) = Asc( "K") Cc_send_buffer(4) = Asc( "!") Call Cc_spi_send_strobe(ccxxx0_sidle) Call Cc_spi_send_strobe(ccxxx0_sftx) Call Cc_spi_write_register_burst(ccxxx0_fifo , 4) Call Cc_spi_send_strobe(ccxxx0_scal) Call Cc_spi_send_strobe(ccxxx0_stx)

Do

  Call Cc_spi_send_strobe(ccxxx0_sidle)
  Led = 0
  If Ischarwaiting() = 1 Then
     Comchar = Inkey()
     Frend0 = Cc_spi_read_register(ccxxx0_frend0)
     Count = Frend0 And &H07
     If Chr(comchar) = "+" Then
        Incr Count
     End If
     If Chr(comchar) = "-" Then
        Decr Count
     End If
     If Count > 200 Then Count = 7
     If Count > 7 Then Count = 0
     Frend0 = Frend0 And &HF8
     Frend0 = Frend0 Or Count
     Call Cc_spi_write_register(ccxxx0_frend0 , Frend0)
     Call Cc_spi_send_strobe(ccxxx0_scal)
     If Chr(comchar) = "*" Then
        Print "PATable : ";
        For Count = 1 To 8
           Print Hex(cc_recv_buffer(count)) ; " ";
        Next Count
        Print
        Print "Frend0 = " ; Hex(frend0)
     End If
  End If
  Call Cc_spi_send_strobe(ccxxx0_sftx)
  Call Cc_spi_write_register_burst(ccxxx0_fifo , 4)
  Call Cc_spi_send_strobe(ccxxx0_stx)
  While Gdo0 = 0
  Wend
  While Gdo0 = 1
  Wend
  Led = 1
  Waitms 1000

Loop

</source>