pic_rf_24l01.c File Reference

#include "pic_rf_24l01.h"
#include "pic_serial.h"
#include <stdlib.h>
Include dependency graph for pic_rf_24l01.c:

Go to the source code of this file.

Functions

void pic_rf_init (rf_config *my_config)
 Initialise nrf2401a chip with config.
void pic_rf_quick_init (char *my_config, uns8 my_channel, bit my_receive_on)
 Initialise nrf2401a chip with quick config.
uns8 pic_rf_read_register (uns8 cmd, uns8 *data, uns8 data_len)
 Read nRF24L01 register.
uns8 pic_rf_read_register_int (uns8 cmd, uns8 *data, uns8 data_len)
uns8 pic_rf_receive (uns8 *data, uns8 bytes_to_receive)
 Receive data from nrf2401a.
void pic_rf_receive2 (uns8 *data, uns8 bytes_to_receive)
void pic_rf_receive_inline (uns8 *data, uns8 bytes_to_receive)
 Receive data from nRF24L01.
uns8 pic_rf_send_byte (uns8 b)
 Internal routine to send a byte to nrf2401a.
uns8 pic_rf_send_byte_int (uns8 b)
 Clock a byte into the nRF24L01.
uns8 pic_rf_send_command (uns8 cmd, uns8 *data, uns8 data_len)
 Send command to the nrf24l01.
uns8 pic_rf_send_command_single (uns8 cmd, uns8 data)
 Send a single data byte command to the nrf24l01.
void pic_rf_set_channel (uns8 channel)
 Change channel on the nrf2401a.
void pic_rf_set_mode (uns8 requested_mode)
 Set rf mode to transmit or receive.
void pic_rf_setup ()
 Setup ports and pins for communication with nrf2401a.
void pic_rf_transmit (uns8 *data, uns8 bytes_to_transmit)
 Transmit data from nRF24L01.

Function Documentation

void pic_rf_init ( rf_config my_config  ) 
void pic_rf_quick_init ( char *  my_config,
uns8  my_channel,
bit  my_receive_on 
)

While the usual pic_rf_init() routine is excellent when you want to programatically change the 2401a config, if you're only doing this once (at the start) then it's likely you're burning a lot of instructions (154 words on a PIC16 device) just to send some bytes of config out to the 2401a. If you know your config in advance, then you can just send the byte-stream config using this routine. Use the nrf2401a_config.pl script in the tools directory to generate this string.

Definition at line 157 of file pic_rf_24l01.c.

References clear_pin, make_output, pic_rf_chip_enable, pic_rf_chip_select, pic_rf_send_byte(), rf_current_channel, rf_current_mode_receive, and uns8.

Here is the call graph for this function:

uns8 pic_rf_read_register ( uns8  cmd,
uns8 *  data,
uns8  data_len 
)

Internal routine to read a particular nRF24L01 register. Clocks out data_len bytes from the chip. Internal routine.

Parameters:
cmd Read register command, eg RF_RD_REG_STATUS
data Pointer to array of bytes where data will be put
data_len Number of bytes to clock out

Definition at line 92 of file pic_rf_24l01.c.

References clear_pin, pic_rf_send_byte(), set_pin, and uns8.

Referenced by pic_rf_set_mode().

Here is the call graph for this function:

Here is the caller graph for this function:

uns8 pic_rf_read_register_int ( uns8  cmd,
uns8 *  data,
uns8  data_len 
)

Definition at line 106 of file pic_rf_24l01.c.

References clear_pin, pic_rf_send_byte_int(), set_pin, and uns8.

Here is the call graph for this function:

uns8 pic_rf_receive ( uns8 *  data,
uns8  bytes_to_receive 
)

Receive data from nRF24L01.

Having been notified that there is data available, call this routine to clock the data in from the nrf2401a.

!pic_rf_chip_enable(0); // save power

pic_rf_chip_enable(1); // turn chip back on

Definition at line 41 of file pic_rf_24l01.c.

References clear_pin, kill_interrupts, make_input, pic_rf_read_register_inline(), pic_rf_send_command_inline(), RF_R_RX_PAYLOAD, RF_RD_REG_FIFO_STATUS, RF_WR_REG_STATUS, set_pin, test_pin, and uns8.

Here is the call graph for this function:

void pic_rf_receive2 ( uns8 *  data,
uns8  bytes_to_receive 
)

Definition at line 352 of file pic_rf_24l01.c.

References pic_rf_receive_inline().

Here is the call graph for this function:

void pic_rf_receive_inline ( uns8 *  data,
uns8  bytes_to_receive 
) [inline]

Having been notified that there is data available, call this routine to clock the data in from the nRF24L01.

Definition at line 348 of file pic_rf_24l01.c.

References pic_rf_read_register_inline(), and RF_R_RX_PAYLOAD.

Referenced by pic_rf_receive2().

Here is the call graph for this function:

Here is the caller graph for this function:

uns8 pic_rf_send_byte ( uns8  b  ) 

Clock a byte into the nRF24L01.

Internal routine to send a byte to the nrf2401a. Generally you shouldn't need to use this, see pic_rf_transmit instead

See also:
pic_rf_transmit

Definition at line 123 of file pic_rf_24l01.c.

References change_pin, clear_pin, set_pin, test_pin, and uns8.

uns8 pic_rf_send_byte_int ( uns8  b  ) 

Clock one byte into the nRF24L01. Internal routine.

Parameters:
b The byte to send
Returns:
nRF24L01 status

Definition at line 140 of file pic_rf_24l01.c.

References change_pin, clear_pin, set_pin, test_pin, and uns8.

Referenced by pic_rf_read_register_inline(), pic_rf_read_register_int(), and pic_rf_send_command_inline().

Here is the caller graph for this function:

uns8 pic_rf_send_command ( uns8  cmd,
uns8 *  data,
uns8  data_len 
)

Send a command and associated data to the nRF24L01

Parameters:
cmd Command to send, eg, RF_WR_REG_SETUP_RETR
data Pointer to an array of bytes to send as data for the command
data_len Number of bytes in the array
Returns:
nRF24L01 status

Definition at line 66 of file pic_rf_24l01.c.

References clear_pin, pic_rf_send_byte(), set_pin, and uns8.

Referenced by pic_rf_init(), pic_rf_set_channel(), pic_rf_set_mode(), and pic_rf_transmit().

Here is the call graph for this function:

Here is the caller graph for this function:

uns8 pic_rf_send_command_single ( uns8  cmd,
uns8  data 
)

Send a command and 1 byte of data to the nRF24L01

Parameters:
cmd Command to send, eg, RF_WR_REG_SETUP_RETR
data One byte of data for the command
Returns:
nRF24L01 status

Definition at line 80 of file pic_rf_24l01.c.

References clear_pin, pic_rf_send_byte(), set_pin, and uns8.

Here is the call graph for this function:

void pic_rf_set_channel ( uns8  channel  ) 

Receive data from nRF24L01 (inline).

Reclocks the essential config to change the current channel used by the nrf2401a.

Definition at line 385 of file pic_rf_24l01.c.

References clear_pin, end_crit_sec, kill_interrupts, pic_rf_chip_enable, pic_rf_chip_select, pic_rf_send_byte(), pic_rf_send_command(), rf_current_channel, rf_current_mode_receive, RF_WR_REG_RF_CH, set_pin, and start_crit_sec.

Here is the call graph for this function:

void pic_rf_set_mode ( uns8  mode  ) 

Pass RECEIVE_MODE or TRANSMIT_MODE to change current mode. Generally, you shouldn't need to call this routine. The library assumes you want to receive until you transmit, in which case it switches automatically to transmit mode and back to receive afterwards.

Definition at line 358 of file pic_rf_24l01.c.

References change_pin, clear_pin, CONFIG_PRIM_RX, end_crit_sec, kill_interrupts, make_output, pic_rf_chip_enable, pic_rf_chip_select, pic_rf_read_register(), pic_rf_send_command(), RECEIVE_MODE, rf_current_mode_receive, RF_RD_REG_CONFIG_REG, RF_WR_REG_CONFIG_REG, set_pin, start_crit_sec, TRANSMIT_MODE, and uns8.

Here is the call graph for this function:

void pic_rf_setup (  ) 

Setup ports and pins for communication with nRF24L01.

Set up ports and pins to correct input/output for communication with Nordif nrf2401a

Definition at line 400 of file pic_rf_24l01.c.

References clear_pin, make_input, make_output, and set_pin.

void pic_rf_transmit ( uns8 *  data,
uns8  bytes_to_transmit 
)

Changes to transmit mode, clocks data into the nrf24L01 and hits the shockburst button. Returns to receive mode when finished.

Definition at line 326 of file pic_rf_24l01.c.

References clear_pin, end_crit_sec, pic_rf_read_register_inline(), pic_rf_send_command(), pic_rf_set_mode(), RECEIVE_MODE, RF_RD_REG_CD, RF_W_TX_PAYLOAD, serial_print_int(), serial_print_nl(), serial_print_str(), set_pin, start_crit_sec, TRANSMIT_MODE, and uns8.

Here is the call graph for this function:


Generated on Wed Dec 8 13:47:36 2010 for Pic Pack by  doxygen 1.6.1