#include "config.h"
#include "pic_utils.h"
Go to the source code of this file.
Data Structures | |
struct | _rf_config |
Defines | |
#define | OP_ENABLE_1_MBPS 5 |
#define | OP_ENABLE_CH2 7 |
#define | OP_ENABLE_CRC 2 |
#define | OP_ENABLE_RECEIVE 0 |
#define | OP_ENABLE_SHOCKBURST 6 |
#define | OP_LONG_CRC 1 |
#define | pic_rf_chip_enable(value) change_pin(rf_ce_port, rf_ce_pin, value); |
#define | pic_rf_chip_select(value) change_pin(rf_cs_port, rf_cs_pin, value); |
#define | pic_rf_init_inline(my_config) |
Inline version of the pic_rf_init routine. | |
#define | pic_rf_receive_mode() pic_rf_set_mode(RECEIVE_MODE) |
#define | pic_rf_transmit_mode() pic_rf_set_mode(TRANSMIT_MODE) |
#define | RECEIVE_MODE 1 |
#define | TRANSMIT_MODE 0 |
Typedefs | |
typedef struct _rf_config | rf_config |
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. | |
void | pic_rf_receive (uns8 *data, uns8 bytes_to_receive) |
Receive data from nrf2401a. | |
void | pic_rf_send_byte (uns8 b) |
Internal routine to send a byte to nrf2401a. | |
void | pic_rf_send_bytes (char *bytes, uns8 num_bytes) |
Internal routine to send bytes to nrf2401a. | |
void | pic_rf_send_bytes_inline (char *bytes, uns8 num_bytes) |
Inline version of send_bytes. | |
void | pic_rf_set_channel (uns8 channel) |
Change channel on the nrf2401a. | |
void | pic_rf_set_mode (uns8 mode) |
Set rf mode to transmit or receive. | |
void | pic_rf_setup () |
Setup ports and pins for communication with nrf2401a. | |
void | pic_rf_transmit (char *data, uns8 bytes_to_transmit) |
Transmit data from nrf2401a. | |
Variables | |
static uns8 | rf_current_channel = 2 |
static bit | rf_current_mode_receive = 0 |
Ian Harris 2008 imharris [at] gmail.com
Released under the "do whatever you like with this but if it breaks, you get to keep both pieces" license
Definition in file pic_rf_2401a.h.
#define OP_ENABLE_1_MBPS 5 |
rf_config options - enable 1 MPS transmition (otherwise 250Kbps)
Definition at line 70 of file pic_rf_2401a.h.
#define OP_ENABLE_CH2 7 |
rf_config options - enable channel 2 reception
Definition at line 74 of file pic_rf_2401a.h.
#define OP_ENABLE_CRC 2 |
rf_config options - enable CRC (recommended!)
Definition at line 68 of file pic_rf_2401a.h.
#define OP_ENABLE_RECEIVE 0 |
rf_config options - enable receive
Definition at line 64 of file pic_rf_2401a.h.
#define OP_ENABLE_SHOCKBURST 6 |
rf_config options - enable shockburst transmition
Definition at line 72 of file pic_rf_2401a.h.
#define OP_LONG_CRC 1 |
rf_config options - enable 16 bit CRC (otherwise 8 bit CRC if 0)
Definition at line 66 of file pic_rf_2401a.h.
#define pic_rf_chip_enable | ( | value | ) | change_pin(rf_ce_port, rf_ce_pin, value); |
Set chip enable line (CE) to the given value
Definition at line 152 of file pic_rf_2401a.h.
Referenced by pic_rf_init(), pic_rf_quick_init(), pic_rf_set_channel(), pic_rf_set_mode(), and pic_rf_transmit().
#define pic_rf_chip_select | ( | value | ) | change_pin(rf_cs_port, rf_cs_pin, value); |
Set chip select line (CS) to the given value
Definition at line 149 of file pic_rf_2401a.h.
Referenced by pic_rf_init(), pic_rf_quick_init(), pic_rf_set_channel(), and pic_rf_set_mode().
#define pic_rf_init_inline | ( | my_config | ) |
Depending upon your chip, if you're using the programmatic method of configuring the nrf2401a you may find that this routine helps you use less flash and/or stack space
Definition at line 161 of file pic_rf_2401a.h.
#define pic_rf_receive_mode | ( | ) | pic_rf_set_mode(RECEIVE_MODE) |
Change to receive mode
Definition at line 143 of file pic_rf_2401a.h.
#define pic_rf_transmit_mode | ( | ) | pic_rf_set_mode(TRANSMIT_MODE) |
Change to transmit mode
Definition at line 146 of file pic_rf_2401a.h.
#define RECEIVE_MODE 1 |
Mode selection - receive
Definition at line 78 of file pic_rf_2401a.h.
Referenced by pic_rf_set_mode(), and pic_rf_transmit().
#define TRANSMIT_MODE 0 |
Mode selection - transmit
Definition at line 80 of file pic_rf_2401a.h.
Referenced by pic_rf_set_mode(), and pic_rf_transmit().
typedef struct _rf_config rf_config |
void pic_rf_init | ( | rf_config * | my_config | ) |
Sends the configuration to the Nordic nrf2401a chip ready to begin communication. This routine assumes you have already set my_config to the correct values.
Definition at line 62 of file pic_rf_2401a.c.
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 41 of file pic_rf_2401a.c.
void pic_rf_receive | ( | uns8 * | data, | |
uns8 | bytes_to_receive | |||
) |
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 109 of file pic_rf_2401a.c.
void pic_rf_send_byte | ( | uns8 | b | ) |
Internal routine to send a byte to the nrf2401a. Generally you shouldn't need to use this, see pic_rf_transmit instead
Definition at line 20 of file pic_rf_2401a.c.
void pic_rf_send_bytes | ( | char * | bytes, | |
uns8 | num_bytes | |||
) |
Internal routine to send bytes to the nrf2401a. Generally you shouldn't need to use this, see pic_rf_transmit instead
Definition at line 33 of file pic_rf_2401a.c.
References pic_rf_send_byte(), and uns8.
Referenced by pic_rf_init().
void pic_rf_send_bytes_inline | ( | char * | bytes, | |
uns8 | num_bytes | |||
) | [inline] |
Inline version of pc_rf_send_bytes. This is an internal routine, and generally you shouldn't need to call it. Use pic_rf_transmit instead.
Definition at line 242 of file pic_rf_2401a.h.
References pic_rf_send_byte(), and uns8.
Referenced by pic_rf_transmit().
void pic_rf_set_channel | ( | uns8 | channel | ) |
Reclocks the essential config to change the current channel used by the nrf2401a.
Definition at line 178 of file pic_rf_2401a.c.
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 157 of file pic_rf_2401a.c.
void pic_rf_setup | ( | ) |
Set up ports and pins to correct input/output for communication with Nordif nrf2401a
Definition at line 200 of file pic_rf_2401a.c.
void pic_rf_transmit | ( | char * | data, | |
uns8 | bytes_to_transmit | |||
) |
Changes to transmit mode, clocks data into the nRF2401A and hits the shockburst button. Returns to receive mode when finished.
Definition at line 133 of file pic_rf_2401a.c.
References kill_interrupts, make_output, pic_rf_chip_enable, pic_rf_send_bytes_inline(), pic_rf_set_mode(), RECEIVE_MODE, rf_current_mode_receive, TRANSMIT_MODE, and uns8.
Referenced by pkt_send_packet().
uns8 rf_current_channel = 2 [static] |
Maintain state of current channel
Definition at line 85 of file pic_rf_2401a.h.
Referenced by pic_rf_init(), pic_rf_quick_init(), and pic_rf_set_channel().
bit rf_current_mode_receive = 0 [static] |
Maintain state of current mode (1 = receive mode)
Definition at line 83 of file pic_rf_2401a.h.
Referenced by pic_rf_init(), pic_rf_quick_init(), pic_rf_set_channel(), pic_rf_set_mode(), and pic_rf_transmit().