Pic Nordic nrf2401a routines. More...
#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 |
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 |
Nordic nrf2401a routines
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 101 of file pic_rf_2401a.h.
#define OP_ENABLE_CH2 7 |
rf_config options - enable channel 2 reception
Definition at line 105 of file pic_rf_2401a.h.
#define OP_ENABLE_CRC 2 |
rf_config options - enable CRC (recommended!)
Definition at line 99 of file pic_rf_2401a.h.
#define OP_ENABLE_RECEIVE 0 |
rf_config options - enable receive
Definition at line 95 of file pic_rf_2401a.h.
#define OP_ENABLE_SHOCKBURST 6 |
rf_config options - enable shockburst transmition
Definition at line 103 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 97 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 183 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 180 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 192 of file pic_rf_2401a.h.
#define pic_rf_receive_mode | ( | ) | pic_rf_set_mode(RECEIVE_MODE) |
Change to receive mode
Definition at line 174 of file pic_rf_2401a.h.
#define pic_rf_transmit_mode | ( | ) | pic_rf_set_mode(TRANSMIT_MODE) |
Change to transmit mode
Definition at line 177 of file pic_rf_2401a.h.
#define RECEIVE_MODE 1 |
Mode selection - receive
Definition at line 109 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 111 of file pic_rf_2401a.h.
Referenced by pic_rf_set_mode(), and pic_rf_transmit().
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 83 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 62 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 130 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 41 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 54 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 273 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 199 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 178 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 221 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 154 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 116 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 114 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().