[jaluino] r432 committed - working NRF24L01 samples: read registers, send and receive

38 views
Skip to first unread message

jal...@googlecode.com

unread,
Jun 15, 2013, 11:54:08 AM6/15/13
to jal...@googlegroups.com
Revision: 432
Author: sebastienlelong
Date: Sat Jun 15 08:53:51 2013
Log: working NRF24L01 samples: read registers, send and receive
http://code.google.com/p/jaluino/source/detail?r=432

Added:
/trunk/samples/jaluino_bee_nrf24_receive.jal
/trunk/samples/jaluino_bee_nrf24_send.jal
Modified:
/trunk/lib/nrf24l01.jal
/trunk/samples/jaluino_bee_nrf24_readreg.jal

=======================================
--- /dev/null
+++ /trunk/samples/jaluino_bee_nrf24_receive.jal Sat Jun 15 08:53:51 2013
@@ -0,0 +1,104 @@
+-- Title: nRF24L01 wireless network module sample for for Jaluino Bee,
receive data, print to serial, LED flashes
+-- Author: Sébastien Lelong, Copyright (c) 2008..2139, all rights reserved.
+-- Adapted-by:
+-- Compiler: 2.4q
+-- Revision: $Revision: 373 $
+--
+-- This file is part of jaluino (http://jaluino.googlecode.com)
+-- Released under the BSD license
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: test nRF24L01 module and SPI connectivity by displaying
register values
+-- on serial
+--
+-- Notes: connect pins accordingly
+-- - Vcc: 3V3
+-- - GND: GND (yes)
+-- - CE: A2
+-- - CSN: A3
+-- - SCK: A5
+-- - MO: B3 (SDO)
+-- - MI: B2 (SDI)
+-- (carefull, MO/MI aren't crossed-over as usual when using SPI device)
+--
+
+include jaluino_bee
+include delay
+include print
+include format
+
+-- ok, now setup serial
+const serial_hw_baudrate = 9_600
+include serial_hardware
+serial_hw_init()
+
+
+-- Configure Remappable Pins on MSSP2
+-- PPS module writes are protected, we need to first unlock it
+pps_control_lock(false)
+-- RP2 <-> SCK2
+PPS_MAP_RP2 = PPS_SCK2
+PPS_MAP_SCK2IN = RP2
+-- RP5 <-> SDI2
+PPS_MAP_SDI2 = RP5
+-- RP6 <-> SDO2
+PPS_MAP_RP6 = PPS_SDO2
+-- PPS configuration is done, we can lock again
+pps_control_lock(true)
+
+alias pin_sdi2_direction is pin_b2_direction
+alias pin_sdo2_direction is pin_b3_direction
+alias pin_sck2_direction is pin_a5_direction
+
+-- configure SPI to use MSSP2 module
+include spi_master_hw2
+pin_sdi2_direction = input -- spi input
+pin_sdo2_direction = output -- spi output
+pin_sck2_direction = output -- spi clock
+alias spi_master_data is spi_master_hw2
+
+pin_A2_direction = output
+pin_A3_direction = output
+alias nrf24_ce_pin is pin_A2
+alias nrf24_csn_pin is pin_A3
+-- Receving adress, size must be NRF24_ADDR_LEN
+const byte NRF24_RECEIVE_ADDR[] = {0x00,0x01,0x02,0x03,0x04}
+-- will receive one byte at a time
+const byte NRF24_PAYLOAD_SIZE = 1
+include nrf24l01
+
+nrf24_ce_pin = low
+nrf24_csn_pin = high
+spi2_init(SPI_MODE_00,SPI_RATE_FOSC_4) -- init spi, choose mode and speed
+
+nrf24_init()
+
+const byte str[] = "Alive..."
+print_string(serial_hw_data,str)
+print_crlf(serial_hw_data)
+
+nrf24_print_registers()
+
+const byte str2[] = "Received: "
+const byte str3[] = "Sleeping..."
+
+forever loop
+
+ if nrf24_data_ready() == true then
+ nrf24_get_data()
+ var byte i = 0
+ var byte c = 0
+ for NRF24_PAYLOAD_SIZE loop
+ c = nrf24_bufout[i]
+ print_byte_dec(serial_hw_data,c)
+ serial_hw_data = ","
+ i = i + 1
+ end loop
+ print_crlf(serial_hw_data)
+ ;else
+ ; print_string(serial_hw_data,str3)
+ ; delay_1ms(100)
+ ; print_crlf(serial_hw_data)
+ end if
+
+end loop
+
=======================================
--- /dev/null
+++ /trunk/samples/jaluino_bee_nrf24_send.jal Sat Jun 15 08:53:51 2013
@@ -0,0 +1,115 @@
+-- Title: nRF24L01 wireless network module sample for for Jaluino Bee,
send data
+-- Author: Sébastien Lelong, Copyright (c) 2008..2139, all rights reserved.
+-- Adapted-by:
+-- Compiler: 2.4q
+-- Revision: $Revision: 373 $
+--
+-- This file is part of jaluino (http://jaluino.googlecode.com)
+-- Released under the BSD license
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: test nRF24L01 module and SPI connectivity by displaying
register values
+-- on serial
+--
+-- Notes: connect pins accordingly
+-- - Vcc: 3V3
+-- - GND: GND (yes)
+-- - CE: A2
+-- - CSN: A3
+-- - SCK: A5
+-- - MO: B3 (SDO)
+-- - MI: B2 (SDI)
+-- (carefull, MO/MI aren't crossed-over as usual when using SPI device)
+--
+
+include jaluino_bee
+include delay
+include print
+include format
+
+-- Assuming LED is enable on hardware (jumper)
+onboard_led_direction = output
+
+-- ok, now setup serial
+const serial_hw_baudrate = 9_600
+include serial_hardware
+serial_hw_init()
+
+
+-- Configure Remappable Pins on MSSP2
+-- PPS module writes are protected, we need to first unlock it
+pps_control_lock(false)
+-- RP2 <-> SCK2
+PPS_MAP_RP2 = PPS_SCK2
+PPS_MAP_SCK2IN = RP2
+-- RP5 <-> SDI2
+PPS_MAP_SDI2 = RP5
+-- RP6 <-> SDO2
+PPS_MAP_RP6 = PPS_SDO2
+-- PPS configuration is done, we can lock again
+pps_control_lock(true)
+
+alias pin_sdi2_direction is pin_b2_direction
+alias pin_sdo2_direction is pin_b3_direction
+alias pin_sck2_direction is pin_a5_direction
+
+-- configure SPI to use MSSP2 module
+include spi_master_hw2
+pin_sdi2_direction = input -- spi input
+pin_sdo2_direction = output -- spi output
+pin_sck2_direction = output -- spi clock
+alias spi_master_data is spi_master_hw2
+
+pin_A2_direction = output
+pin_A3_direction = output
+alias nrf24_ce_pin is pin_A2
+alias nrf24_csn_pin is pin_A3
+-- Receving adress, size must be NRF24_ADDR_LEN
+const byte NRF24_RECEIVE_ADDR[] = {0x05,0x06,0x07,0x08,0x09}
+-- will send one byte at a time
+const byte NRF24_PAYLOAD_SIZE = 1
+include nrf24l01
+
+nrf24_ce_pin = low
+nrf24_csn_pin = high
+spi2_init(SPI_MODE_00,SPI_RATE_FOSC_16) -- init spi, choose mode and speed
+
+delay_1ms(10)
+nrf24_init()
+
+const byte str[] = "Alive..."
+print_string(serial_hw_data,str)
+print_crlf(serial_hw_data)
+
+nrf24_print_registers()
+
+const byte str2[] = "Sending: "
+
+-- set destination address
+var byte taddr[] = {0x00,0x01,0x02,0x03,0x04} -- see receive sample addr
+nrf24_set_taddr(taddr)
+
+print_byte_dec(serial_hw_data,nrf24_ptx)
+
+
+forever loop
+
+ var byte i = 0
+
+ for 50 loop
+ print_string(serial_hw_data,str2)
+ print_byte_dec(serial_hw_data,i)
+ print_crlf(serial_hw_data)
+ print_byte_dec(serial_hw_data,nrf24_ptx)
+ nrf24_send(i)
+ print_byte_dec(serial_hw_data,nrf24_ptx)
+ i = i + 1
+ onboard_led = high
+ while nrf24_is_sending() == true loop
+ end loop
+ delay_1ms(10)
+ onboard_led = low
+ delay_1ms(10)
+ end loop
+
+end loop
+
=======================================
--- /trunk/lib/nrf24l01.jal Sat Jun 1 10:40:34 2013
+++ /trunk/lib/nrf24l01.jal Sat Jun 15 08:53:51 2013
@@ -157,6 +157,10 @@
procedure nrf24_transmit_sync(byte in len)
procedure nrf24_read_register(byte in reg, byte in len)
procedure nrf24_transfer_sync(byte in len)
+procedure nrf24_send(byte in value)
+function nrf24_get_status() return byte
+procedure nrf24_power_up_tx()
+function nrf24_rx_fifo_empty() return bit

const byte NRF24_BUFFER_LEN = 10
var volatile byte nrf24_bufout[NRF24_BUFFER_LEN]
@@ -173,6 +177,9 @@
end loop
-- Set receiving address
nrf24_set_raddr()
+ -- power
+ var byte rfset = 0b00001000 -- 2Mb but -18Db power
+ nrf24_config_register(NRF24_RF_SETUP, rfset)
-- Set RF channel
nrf24_config_register(NRF24_RF_CH,NRF24_CHANNEL)
-- Set length of incoming payload
@@ -185,16 +192,16 @@

-- Clocks only one byte into the given MiRF register
procedure nrf24_config_register(byte in reg, byte in value) is
- nrf24_csn_pin = low
- spi_master_data = (NRF24_W_REGISTER | (NRF24_REGISTER_MASK & reg))
- spi_master_data = value
- nrf24_csn_pin = high
-end procedure
+ nrf24_csn_pin = low
+spi_master_data = (NRF24_W_REGISTER | (NRF24_REGISTER_MASK & reg))
+ spi_master_data = value
+ nrf24_csn_pin = high
+ end procedure

-procedure nrf24_power_up_rx() is
- nrf24_ptx = 0
- nrf24_ce_pin = low
- nrf24_config_register(NRF24_CONFIG_REG, NRF24_CONFIG | (
(1<<NRF24_PWR_UP) | (1<<NRF24_PRIM_RX) ) )
+ procedure nrf24_power_up_rx() is
+ nrf24_ptx = 0
+ nrf24_ce_pin = low
+nrf24_config_register(NRF24_CONFIG_REG, NRF24_CONFIG | ( (1<<NRF24_PWR_UP)
| (1<<NRF24_PRIM_RX) ) )
nrf24_ce_pin = high
nrf24_config_register(NRF24_STATUS,(1 << NRF24_TX_DS) | (1 <<
NRF24_MAX_RT));
end procedure
@@ -249,46 +256,324 @@

procedure nrf24_transfer_sync(byte in len) is
var byte i = 0
- -- assuming dataout/datein have same size
- ;serial_hw_data = "i"
- ;serial_hw_data = i + "0"
-
nrf24_bufout[0] = 0x00

for len loop
- ;serial_hw_data = i + "0"
- ;serial_hw_data = " "
nrf24_bufout[i] = spi_master_hw2_exchange(nrf24_bufin[i])
- ;const byte str[] = "xfer bufout[i]:"
- ;print_string(serial_hw_data,str)
- ;print_byte_bin(serial_hw_data,nrf24_bufout[i])
+ i = i + 1
+ end loop
+end procedure
+
+-- Sends a data package to the default address. Be sure to send the correct
+-- amount of bytes as configured as payload on the receiver.
+procedure nrf24_send(byte in value) is
+
+ var byte st = nrf24_get_status()
+ while nrf24_ptx == 1 loop
+ st = nrf24_get_status()
+ if (st & ((1 << NRF24_TX_DS) | (1 << NRF24_MAX_RT))) == true then
+ nrf24_ptx = 0
+ exit loop
+ end if
+ end loop
+
+ nrf24_ce_pin = low
+ nrf24_power_up_tx()
+ nrf24_csn_pin = low
+
+ spi_master_data = NRF24_FLUSH_TX
+ nrf24_csn_pin = high
+ delay_1ms(1) ; delete ?
+ nrf24_csn_pin = low
+
+ spi_master_data = NRF24_W_TX_PAYLOAD
+ -- Write payload
+ nrf24_bufin[0] = value
+ -- TODO: I could send multiple byte at a time
+ nrf24_transmit_sync(1)
+
+ -- Pull up chip select
+ nrf24_csn_pin = high
+ -- Start transmission
+ nrf24_ce_pin = high
+
+end procedure
+
+function nrf24_get_status() return byte is
+ var byte rv
+ nrf24_read_register(STATUS,1)
+ rv = nrf24_bufout[0]
+ return rv
+end function
+
+procedure nrf24_power_up_tx() is
+ nrf24_ptx = 1
+ nrf24_config_register(NRF24_CONFIG_REG, NRF24_CONFIG | (
(1<<NRF24_PWR_UP) | (0<<NRF24_PRIM_RX) ) )
+end procedure
+
+procedure nrf24_power_down() is
+ nrf24_ce_pin = low
+ nrf24_config_register(NRF24_CONFIG_REG, NRF24_CONFIG)
+end procedure
+
+-- Test if chip is still sending.
+-- When sending has finished return chip to listening.
+function nrf24_is_sending() return bit is
+ var byte st
+
+ if nrf24_ptx == 1 then
+ st = nrf24_get_status()
+ ;print_byte_bin(serial_hw_data,st)
+ ;serial_hw_data = ","
+ ;print_byte_bin(serial_hw_data,(st & ((1 << NRF24_TX_DS) | (1 <<
NRF24_MAX_RT))))
;print_crlf(serial_hw_data)
+ -- if sending successful (TX_DS) or max retries exceded (MAX_RT).
+ if (st & ((1 << NRF24_TX_DS) | (1 << NRF24_MAX_RT))) != 0 then
+ nrf24_power_up_rx()
+ return false
+ end if
+ return true
+ end if
+
+ return false
+
+end function
+
+-- Checks if data is available for reading
+function nrf24_data_ready() return bit is
+ -- See note in nrf24_get_data() function - just checking RX_DR isn't
good enough
+ var byte st = nrf24_get_status()
+
+ -- We can short circuit on RX_DR, but if it's not set, we still need
+ -- to check the FIFO for any pending packets
+ if (st & (1 << NRF24_RX_DR)) != 0 then
+ return true
+ end if
+ return !nrf24_rx_fifo_empty()
+
+end function
+
+function nrf24_rx_fifo_empty() return bit is
+ var byte fifostatus
+ nrf24_read_register(NRF24_FIFO_STATUS,1)
+ fifostatus = nrf24_bufout[0]
+ return (fifostatus & (1 << NRF24_RX_EMPTY))
+end function
+
+-- Reads payload bytes into data array
+procedure nrf24_get_data() is
+ nrf24_csn_pin = low -- Pull down chip select
+ spi_master_data = NRF24_R_RX_PAYLOAD -- Send cmd to read rx payload
+ nrf24_transfer_sync(NRF24_PAYLOAD_SIZE)
+ nrf24_csn_pin = high -- Pull up chip select
+ -- NVI: per product spec, p 67, note c:
+ -- "The RX_DR IRQ is asserted by a new packet arrival event. The
procedure
+ -- for handling this interrupt should be: 1) read payload through SPI,
+ -- 2) clear RX_DR IRQ, 3) read FIFO_STATUS to check if there are more
+ -- payloads available in RX FIFO, 4) if there are more data in RX FIFO,
+ -- repeat from step 1)."
+ -- So if we're going to clear RX_DR here, we need to check the RX FIFO
+ -- in the dataReady() function
+ nrf24_config_register(NRF24_STATUS,(1<<NRF24_RX_DR)) -- Reset status
register
+end procedure
+
+-- Sets the transmitting address
+procedure nrf24_set_taddr(byte in adr[]) is
+ -- load input buffer (to send to NRF24)
+ -- /!\ assuming adr is adr[NRF24_ADDR_LEN]
+ var byte i = 0
+ for NRF24_ADDR_LEN loop
+ nrf24_bufin[i] = adr[i]
i = i + 1
end loop
- ;const byte str[] = "xfer bufout[0]:"
- ;print_string(serial_hw_data,str)
- ;print_byte_bin(serial_hw_data,nrf24_bufout[0])
- ;print_crlf(serial_hw_data)
+ -- RX_ADDR_P0 must be set to the sending addr for auto ack to work.
+ nrf24_write_register(NRF24_RX_ADDR_P0,NRF24_ADDR_LEN)
+ nrf24_write_register(NRF24_TX_ADDR,NRF24_ADDR_LEN)
end procedure

-;void send(uint8_t *value);
-;void setRADDR(uint8_t * adr);
-;void setTADDR(uint8_t * adr);
-;bool dataReady();
-;bool isSending();
-;bool rxFifoEmpty();
-;bool txFifoEmpty();
-;void getData(uint8_t * data);
-;uint8_t getStatus();
-;
-;void transmitSync(uint8_t *dataout,uint8_t len);
-;void transferSync(uint8_t *dataout,uint8_t *datain,uint8_t len);
-;void configRegister(uint8_t reg, uint8_t value);
-;void readRegister(uint8_t reg, uint8_t * value, uint8_t len);
-;void writeRegister(uint8_t reg, uint8_t * value, uint8_t len);
-;void powerUpRx();
-;void powerUpTx();
-;void powerDown();
-;
-;void flushRx();
+procedure nrf24_print_registers() is
+ nrf24_read_register(NRF24_CONFIG_REG,1)
+ var byte config = nrf24_bufout[0]
+ const byte str00[] = "CONFIG: "
+ print_string(serial_hw_data,str00)
+ print_byte_bin(serial_hw_data,config)
+ serial_hw_data = ","
+ print_byte_bin(serial_hw_data,nrf24_bufout[0])
+ print_crlf(serial_hw_data)
+ const byte str2[] = " MASK_RX_DR[6] : "
+ print_string(serial_hw_data,str2)
+ print_byte_bin(serial_hw_data,(config >> NRF24_MASK_RX_DR) & 1)
+ print_crlf(serial_hw_data)
+ const byte str3[] = " MASK_TX_DS[5] : "
+ print_string(serial_hw_data,str3)
+ print_byte_bin(serial_hw_data,(config >> NRF24_MASK_TX_DS) & 1)
+ print_crlf(serial_hw_data)
+ const byte str4[] = " MASK_MAX_RT[4]: "
+ print_string(serial_hw_data,str4)
+ print_byte_bin(serial_hw_data,(config >> NRF24_MASK_MAX_RT) & 1)
+ print_crlf(serial_hw_data)
+ const byte str5[] = " EN_CRC[3] : "
+ print_string(serial_hw_data,str5)
+ print_byte_bin(serial_hw_data,(config >> NRF24_EN_CRC) & 1)
+ print_crlf(serial_hw_data)
+ const byte str6[] = " CRCO[2] : "
+ print_string(serial_hw_data,str6)
+ print_byte_bin(serial_hw_data,(config >> NRF24_CRCO) & 1)
+ print_crlf(serial_hw_data)
+ const byte str7[] = " PWR_UP[1] : "
+ print_string(serial_hw_data,str7)
+ print_byte_bin(serial_hw_data,(config >> NRF24_PWR_UP) & 1)
+ print_crlf(serial_hw_data)
+ const byte str8[] = " PRIM_RX[0] : "
+ print_string(serial_hw_data,str8)
+ print_byte_bin(serial_hw_data,(config >> NRF24_PWR_UP) & 1)
+ print_crlf(serial_hw_data)
+ print_crlf(serial_hw_data)

+
+ nrf24_read_register(NRF24_EN_AA,1)
+ var byte en_aa = nrf24_bufout[0]
+ const byte str9[] = "EN_AA: "
+ print_string(serial_hw_data,str9)
+ print_byte_bin(serial_hw_data,en_aa)
+ print_crlf(serial_hw_data)
+ const byte str10[] = " ENAA_P5[5] : "
+ print_string(serial_hw_data,str10)
+ print_byte_bin(serial_hw_data,(en_aa >> NRF24_ENAA_P5) & 1)
+ print_crlf(serial_hw_data)
+ const byte str11[] = " ENAA_P4[4] : "
+ print_string(serial_hw_data,str11)
+ print_byte_bin(serial_hw_data,(en_aa >> NRF24_ENAA_P4) & 1)
+ print_crlf(serial_hw_data)
+ const byte str12[] = " ENAA_P3[3] : "
+ print_string(serial_hw_data,str12)
+ print_byte_bin(serial_hw_data,(en_aa >> NRF24_ENAA_P3) & 1)
+ print_crlf(serial_hw_data)
+ const byte str13[] = " ENAA_P2[2] : "
+ print_string(serial_hw_data,str13)
+ print_byte_bin(serial_hw_data,(en_aa >> NRF24_ENAA_P2) & 1)
+ print_crlf(serial_hw_data)
+ const byte str14[] = " ENAA_P1[1] : "
+ print_string(serial_hw_data,str14)
+ print_byte_bin(serial_hw_data,(en_aa >> NRF24_ENAA_P1) & 1)
+ print_crlf(serial_hw_data)
+ const byte str15[] = " ENAA_P0[0] : "
+ print_string(serial_hw_data,str15)
+ print_byte_bin(serial_hw_data,(en_aa >> NRF24_ENAA_P0) & 1)
+ print_crlf(serial_hw_data)
+ print_crlf(serial_hw_data)
+
+ nrf24_read_register(NRF24_EN_RXADDR,1)
+ var byte en_rxaddr = nrf24_bufout[0]
+ const byte str16[] = "EN_RXADDR: "
+ print_string(serial_hw_data,str16)
+ print_byte_bin(serial_hw_data,en_rxaddr)
+ print_crlf(serial_hw_data)
+ const byte str17[] = " ERX_P5[5] : "
+ print_string(serial_hw_data,str17)
+ print_byte_bin(serial_hw_data,(en_rxaddr >> NRF24_ERX_P5) & 1)
+ print_crlf(serial_hw_data)
+ const byte str18[] = " ERX_P4[4] : "
+ print_string(serial_hw_data,str18)
+ print_byte_bin(serial_hw_data,(en_rxaddr >> NRF24_ERX_P4) & 1)
+ print_crlf(serial_hw_data)
+ const byte str19[] = " ERX_P3[3] : "
+ print_string(serial_hw_data,str19)
+ print_byte_bin(serial_hw_data,(en_rxaddr >> NRF24_ERX_P3) & 1)
+ print_crlf(serial_hw_data)
+ const byte str20[] = " ERX_P2[2] : "
+ print_string(serial_hw_data,str20)
+ print_byte_bin(serial_hw_data,(en_rxaddr >> NRF24_ERX_P2) & 1)
+ print_crlf(serial_hw_data)
+ const byte str21[] = " ERX_P1[1] : "
+ print_string(serial_hw_data,str21)
+ print_byte_bin(serial_hw_data,(en_rxaddr >> NRF24_ERX_P1) & 1)
+ print_crlf(serial_hw_data)
+ const byte str22[] = " ERX_P0[0] : "
+ print_string(serial_hw_data,str22)
+ print_byte_bin(serial_hw_data,(en_rxaddr >> NRF24_ERX_P0) & 1)
+ print_crlf(serial_hw_data)
+ print_crlf(serial_hw_data)
+
+ nrf24_read_register(NRF24_SETUP_AW,1)
+ var byte setup_aw = nrf24_bufout[0]
+ const byte str23[] = "SETUP_AW: "
+ print_string(serial_hw_data,str23)
+ print_byte_bin(serial_hw_data,setup_aw)
+ print_crlf(serial_hw_data)
+ const byte str24[] = " AW[0-1] : "
+ print_string(serial_hw_data,str24)
+ print_byte_bin(serial_hw_data,(setup_aw >> NRF24_AW) & 1)
+ print_crlf(serial_hw_data)
+ print_crlf(serial_hw_data)
+
+ nrf24_read_register(NRF24_SETUP_RETR,1)
+ var byte setup_retr = nrf24_bufout[0]
+ const byte str25[] = "SETUP_RETR: "
+ print_string(serial_hw_data,str25)
+ print_byte_bin(serial_hw_data,setup_retr)
+ print_crlf(serial_hw_data)
+ const byte str26[] = " ARD[4-7] : "
+ print_string(serial_hw_data,str26)
+ print_byte_bin(serial_hw_data,(setup_retr >> NRF24_ARD) & 1)
+ print_crlf(serial_hw_data)
+ const byte str27[] = " ARC[0-3] : "
+ print_string(serial_hw_data,str27)
+ print_byte_bin(serial_hw_data,(setup_retr >> NRF24_ARC) & 1)
+ print_crlf(serial_hw_data)
+ print_crlf(serial_hw_data)
+
+ nrf24_read_register(NRF24_RF_CH,1)
+ var byte rf_ch = nrf24_bufout[0]
+ const byte str28[] = "RF_CH: "
+ print_string(serial_hw_data,str28)
+ print_byte_bin(serial_hw_data,rf_ch)
+ print_crlf(serial_hw_data)
+ const byte str29[] = " RF_CH[0-6] : "
+ print_string(serial_hw_data,str29)
+ print_byte_bin(serial_hw_data,rf_ch)
+ print_crlf(serial_hw_data)
+ print_crlf(serial_hw_data)
+
+ nrf24_read_register(NRF24_RF_SETUP,1)
+ var byte rf_setup = nrf24_bufout[0]
+ const byte str30[] = "RF_SETUP: "
+ print_string(serial_hw_data,str30)
+ print_byte_bin(serial_hw_data,rf_setup)
+ print_crlf(serial_hw_data)
+ const byte str31[] = " CONT_WAVE[7] : "
+ print_string(serial_hw_data,str31)
+ print_byte_bin(serial_hw_data,(rf_setup >> NRF24_CONT_WAVE) & 1)
+ print_crlf(serial_hw_data)
+ const byte str32[] = " RF_DR_LOW[5] : "
+ print_string(serial_hw_data,str32)
+ print_byte_bin(serial_hw_data,(rf_setup >> NRF24_RF_DR_LOW) & 1)
+ print_crlf(serial_hw_data)
+ const byte str33[] = " PLL_LOCK[4] : "
+ print_string(serial_hw_data,str33)
+ print_byte_bin(serial_hw_data,(rf_setup >> NRF24_PLL_LOCK) & 1)
+ print_crlf(serial_hw_data)
+ const byte str34[] = " RF_DR_HIGH[3] : "
+ print_string(serial_hw_data,str34)
+ print_byte_bin(serial_hw_data,(rf_setup >> NRF24_RF_DR_HIGH) & 1)
+ print_crlf(serial_hw_data)
+ const byte str35[] = " RF_PWR[1-2] : "
+ print_string(serial_hw_data,str35)
+ print_byte_bin(serial_hw_data,(rf_setup >> NRF24_RF_PWR) & 0b11)
+ print_crlf(serial_hw_data)
+ print_crlf(serial_hw_data)
+
+ nrf24_read_register(NRF24_RX_ADDR_P1,count(NRF24_RECEIVE_ADDR))
+ const byte str36[] = "NRF24_RX_ADDR_P1: "
+ print_string(serial_hw_data,str36)
+ var byte i = 0
+ for count(NRF24_RECEIVE_ADDR) loop
+ var byte c = nrf24_bufout[i]
+ print_byte_hex(serial_hw_data,c)
+ serial_hw_data = c + "0"
+ serial_hw_data = ","
+ i = i + 1
+ end loop
+ print_crlf(serial_hw_data)
+
+end procedure
=======================================
--- /trunk/samples/jaluino_bee_nrf24_readreg.jal Sat Jun 1 10:40:34 2013
+++ /trunk/samples/jaluino_bee_nrf24_readreg.jal Sat Jun 15 08:53:51 2013
@@ -79,191 +79,8 @@


forever loop
- nrf24_read_register(NRF24_CONFIG_REG,1)
- var byte config = nrf24_bufout[0]
- const byte str00[] = "CONFIG: "
- print_string(serial_hw_data,str00)
- print_byte_bin(serial_hw_data,config)
- serial_hw_data = ","
- print_byte_bin(serial_hw_data,nrf24_bufout[0])
- print_crlf(serial_hw_data)
- const byte str2[] = " MASK_RX_DR[6] : "
- print_string(serial_hw_data,str2)
- print_byte_bin(serial_hw_data,(config >> NRF24_MASK_RX_DR) & 1)
- print_crlf(serial_hw_data)
- const byte str3[] = " MASK_TX_DS[5] : "
- print_string(serial_hw_data,str3)
- print_byte_bin(serial_hw_data,(config >> NRF24_MASK_TX_DS) & 1)
- print_crlf(serial_hw_data)
- const byte str4[] = " MASK_MAX_RT[4]: "
- print_string(serial_hw_data,str4)
- print_byte_bin(serial_hw_data,(config >> NRF24_MASK_MAX_RT) & 1)
- print_crlf(serial_hw_data)
- const byte str5[] = " EN_CRC[3] : "
- print_string(serial_hw_data,str5)
- print_byte_bin(serial_hw_data,(config >> NRF24_EN_CRC) & 1)
- print_crlf(serial_hw_data)
- const byte str6[] = " CRCO[2] : "
- print_string(serial_hw_data,str6)
- print_byte_bin(serial_hw_data,(config >> NRF24_CRCO) & 1)
- print_crlf(serial_hw_data)
- const byte str7[] = " PWR_UP[1] : "
- print_string(serial_hw_data,str7)
- print_byte_bin(serial_hw_data,(config >> NRF24_PWR_UP) & 1)
- print_crlf(serial_hw_data)
- const byte str8[] = " PRIM_RX[0] : "
- print_string(serial_hw_data,str8)
- print_byte_bin(serial_hw_data,(config >> NRF24_PWR_UP) & 1)
- print_crlf(serial_hw_data)
- print_crlf(serial_hw_data)
+ nrf24_print_registers()

-
- nrf24_read_register(NRF24_EN_AA,1)
- var byte en_aa = nrf24_bufout[0]
- const byte str9[] = "EN_AA: "
- print_string(serial_hw_data,str9)
- print_byte_bin(serial_hw_data,en_aa)
- print_crlf(serial_hw_data)
- const byte str10[] = " ENAA_P5[5] : "
- print_string(serial_hw_data,str10)
- print_byte_bin(serial_hw_data,(en_aa >> NRF24_ENAA_P5) & 1)
- print_crlf(serial_hw_data)
- const byte str11[] = " ENAA_P4[4] : "
- print_string(serial_hw_data,str11)
- print_byte_bin(serial_hw_data,(en_aa >> NRF24_ENAA_P4) & 1)
- print_crlf(serial_hw_data)
- const byte str12[] = " ENAA_P3[3] : "
- print_string(serial_hw_data,str12)
- print_byte_bin(serial_hw_data,(en_aa >> NRF24_ENAA_P3) & 1)
- print_crlf(serial_hw_data)
- const byte str13[] = " ENAA_P2[2] : "
- print_string(serial_hw_data,str13)
- print_byte_bin(serial_hw_data,(en_aa >> NRF24_ENAA_P2) & 1)
- print_crlf(serial_hw_data)
- const byte str14[] = " ENAA_P1[1] : "
- print_string(serial_hw_data,str14)
- print_byte_bin(serial_hw_data,(en_aa >> NRF24_ENAA_P1) & 1)
- print_crlf(serial_hw_data)
- const byte str15[] = " ENAA_P0[0] : "
- print_string(serial_hw_data,str15)
- print_byte_bin(serial_hw_data,(en_aa >> NRF24_ENAA_P0) & 1)
- print_crlf(serial_hw_data)
- print_crlf(serial_hw_data)
-
- nrf24_read_register(NRF24_EN_RXADDR,1)
- var byte en_rxaddr = nrf24_bufout[0]
- const byte str16[] = "EN_RXADDR: "
- print_string(serial_hw_data,str16)
- print_byte_bin(serial_hw_data,en_rxaddr)
- print_crlf(serial_hw_data)
- const byte str17[] = " ERX_P5[5] : "
- print_string(serial_hw_data,str17)
- print_byte_bin(serial_hw_data,(en_rxaddr >> NRF24_ERX_P5) & 1)
- print_crlf(serial_hw_data)
- const byte str18[] = " ERX_P4[4] : "
- print_string(serial_hw_data,str18)
- print_byte_bin(serial_hw_data,(en_rxaddr >> NRF24_ERX_P4) & 1)
- print_crlf(serial_hw_data)
- const byte str19[] = " ERX_P3[3] : "
- print_string(serial_hw_data,str19)
- print_byte_bin(serial_hw_data,(en_rxaddr >> NRF24_ERX_P3) & 1)
- print_crlf(serial_hw_data)
- const byte str20[] = " ERX_P2[2] : "
- print_string(serial_hw_data,str20)
- print_byte_bin(serial_hw_data,(en_rxaddr >> NRF24_ERX_P2) & 1)
- print_crlf(serial_hw_data)
- const byte str21[] = " ERX_P1[1] : "
- print_string(serial_hw_data,str21)
- print_byte_bin(serial_hw_data,(en_rxaddr >> NRF24_ERX_P1) & 1)
- print_crlf(serial_hw_data)
- const byte str22[] = " ERX_P0[0] : "
- print_string(serial_hw_data,str22)
- print_byte_bin(serial_hw_data,(en_rxaddr >> NRF24_ERX_P0) & 1)
- print_crlf(serial_hw_data)
- print_crlf(serial_hw_data)
-
- nrf24_read_register(NRF24_SETUP_AW,1)
- var byte setup_aw = nrf24_bufout[0]
- const byte str23[] = "SETUP_AW: "
- print_string(serial_hw_data,str23)
- print_byte_bin(serial_hw_data,setup_aw)
- print_crlf(serial_hw_data)
- const byte str24[] = " AW[0-1] : "
- print_string(serial_hw_data,str24)
- print_byte_bin(serial_hw_data,(setup_aw >> NRF24_AW) & 1)
- print_crlf(serial_hw_data)
- print_crlf(serial_hw_data)
-
- nrf24_read_register(NRF24_SETUP_RETR,1)
- var byte setup_retr = nrf24_bufout[0]
- const byte str25[] = "SETUP_RETR: "
- print_string(serial_hw_data,str25)
- print_byte_bin(serial_hw_data,setup_retr)
- print_crlf(serial_hw_data)
- const byte str26[] = " ARD[4-7] : "
- print_string(serial_hw_data,str26)
- print_byte_bin(serial_hw_data,(setup_retr >> NRF24_ARD) & 1)
- print_crlf(serial_hw_data)
- const byte str27[] = " ARC[0-3] : "
- print_string(serial_hw_data,str27)
- print_byte_bin(serial_hw_data,(setup_retr >> NRF24_ARC) & 1)
- print_crlf(serial_hw_data)
- print_crlf(serial_hw_data)
-
- nrf24_read_register(NRF24_RF_CH,1)
- var byte rf_ch = nrf24_bufout[0]
- const byte str28[] = "RF_CH: "
- print_string(serial_hw_data,str28)
- print_byte_bin(serial_hw_data,rf_ch)
- print_crlf(serial_hw_data)
- const byte str29[] = " RF_CH[0-6] : "
- print_string(serial_hw_data,str29)
- print_byte_bin(serial_hw_data,rf_ch)
- print_crlf(serial_hw_data)
- print_crlf(serial_hw_data)
-
- nrf24_read_register(NRF24_RF_SETUP,1)
- var byte rf_setup = nrf24_bufout[0]
- const byte str30[] = "RF_SETUP: "
- print_string(serial_hw_data,str30)
- print_byte_bin(serial_hw_data,rf_setup)
- print_crlf(serial_hw_data)
- const byte str31[] = " CONT_WAVE[7] : "
- print_string(serial_hw_data,str31)
- print_byte_bin(serial_hw_data,(rf_setup >> NRF24_CONT_WAVE) & 1)
- print_crlf(serial_hw_data)
- const byte str32[] = " RF_DR_LOW[5] : "
- print_string(serial_hw_data,str32)
- print_byte_bin(serial_hw_data,(rf_setup >> NRF24_RF_DR_LOW) & 1)
- print_crlf(serial_hw_data)
- const byte str33[] = " PLL_LOCK[4] : "
- print_string(serial_hw_data,str33)
- print_byte_bin(serial_hw_data,(rf_setup >> NRF24_PLL_LOCK) & 1)
- print_crlf(serial_hw_data)
- const byte str34[] = " RF_DR_HIGH[3] : "
- print_string(serial_hw_data,str34)
- print_byte_bin(serial_hw_data,(rf_setup >> NRF24_RF_DR_HIGH) & 1)
- print_crlf(serial_hw_data)
- const byte str35[] = " RF_PWR[1-2] : "
- print_string(serial_hw_data,str35)
- print_byte_bin(serial_hw_data,(rf_setup >> NRF24_RF_PWR) & 0b11)
- print_crlf(serial_hw_data)
- print_crlf(serial_hw_data)
-
- nrf24_read_register(NRF24_RX_ADDR_P1,count(NRF24_RECEIVE_ADDR))
- const byte str36[] = "NRF24_RX_ADDR_P1: "
- print_string(serial_hw_data,str36)
- var byte i = 0
- for count(NRF24_RECEIVE_ADDR) loop
- var byte c = nrf24_bufout[i]
- ;print_byte_hex(serial_hw_data,c)
- serial_hw_data = c + "0"
- serial_hw_data = ","
- i = i + 1
- end loop
- print_crlf(serial_hw_data)
-
-
print_crlf(serial_hw_data)
const byte str37[] = "..."
print_string(serial_hw_data,str37)
@@ -271,7 +88,5 @@
print_crlf(serial_hw_data)
delay_1s(10)

-
end loop
-;
-;
+
Reply all
Reply to author
Forward
0 new messages