|
enum | nrf24_msg_id {
SYSTEM_MSG = 0,
CONTROL_MSG,
SENSOR_MSG,
CHAT_MSG,
TEST_MSG,
KILL_MSG,
THIEF_MSG,
LAST_MSG_ID
} |
|
enum | nrf24_system_msg { NULL_MSG = 0,
PING_MSG,
PING_RESPONSE_MSG,
SPAM_MSG
} |
|
enum | nrf24_control_msg { ONBOARD_LED,
LINEAR_ACTUATOR,
LAST_CONTROL_ID
} |
|
enum | nrf24_sensor_msg { TEMPERATURE_SENSOR,
LAST_SENSOR_ID
} |
|
enum | nrf24_thief_msg {
ARM_MSG,
DISARM_MSG,
TRIP_MSG,
ACCESS_MSG,
ERROR_MSG,
DIFFICULTY_MSG,
LAST_THIEF_ID
} |
|
enum | nrf24_address {
MASTER = 0x00,
SCRUM_PUN = 0x08,
BALL_TRAP,
TOMS_PAD,
NOODLE,
MOUSE_TRAP = 0x10,
ULTRASONIC = 0x18,
DAN,
CAM,
JAKE,
SUPREME = 0x20,
BOT,
SNEAK,
LASER,
SIMON,
OGLAZERBOIZ = 0x28,
OGLAZ2,
LOCK_PICK,
PIEZO,
MIKE = 0x30,
SORCE,
MALONEY,
MUHLBAIER,
LAST_ADDRESS,
ALL_ALL = 0x3F
} |
|
enum | nrfstate_e { NRFNET_INITIALIZED = 0x00,
NRFNET_NORMAL_STATE = 0x00,
NRFNET_WAITING_FOR_MIN_WINDOW
} |
|
enum | nrfrole_e { ROLE_MASTER,
ROLE_BRANCH,
ROLE_LEAF
} |
|
enum | pipe_status_e { CHILD_INITIALIZED,
CHILD_ACTIVE,
CHILD_MISSING
} |
|
|
void | nrf24_NetworkInit (void(*ce)(uint8_t), void(*csn)(uint8_t), uint8_t spi_channel) |
| Initialize nRF24 Network Module. More...
|
|
void | nrf24_NetworkInitN (nrfnet_t *net, void(*ce)(uint8_t), void(*csn)(uint8_t), uint8_t spi_channel, uint8_t node) |
|
void | nrf24_RegisterMsgHandler (enum nrf24_msg_id msg_id, nrf24_handler_fn_t fn_ptr) |
|
void | nrf24_RegisterMsgHandlerN (nrfnet_t *net, enum nrf24_msg_id msg_id, nrf24_handler_fn_t fn_ptr) |
|
void | nrf24_SendMsg (uint8_t to, enum nrf24_msg_id msg_id, uint8_t *data, uint8_t len) |
|
void | nrf24_SendMsgN (nrfnet_t *net, uint8_t to, enum nrf24_msg_id msg_id, uint8_t *data, uint8_t len) |
|
void | nrf24_RegisterControlHandler (enum nrf24_control_msg control_id, nrf24_handler_fn_t fn_ptr) |
|
void | nrf24_RegisterControlHandlerN (nrfnet_t *net, enum nrf24_control_msg control_id, nrf24_handler_fn_t fn_ptr) |
|
void | nrf24_RegisterSensorHandler (enum nrf24_sensor_msg sensor_id, nrf24_handler_fn_t fn_ptr) |
|
void | nrf24_RegisterSensorHandlerN (nrfnet_t *net, enum nrf24_sensor_msg sensor_id, nrf24_handler_fn_t fn_ptr) |
|
void | nrf24_NetworkISRHandler (void) |
|
void | nrf24_Ping (uint8_t to) |
|
char * | NameFromAddress (uint8_t address) |
|
uint8_t | AddressFromName (char *name) |
|
- Version
- 0.1
Dependencies: nrf24.h spi.h task.h timing.h subsys.h uart.h
Default Pinouts:
MSP430F5529:
- MISO P3.1
- MOSI P3.0
- SCK P3.2
- CS P2.3
- CE P2.4
- IRQ P2.5
PIC32MX250F128B:
- MISO pin3/A1
- MOSI pin24/B13
- SCK pin25/B14
- CS pin7/B3
- CE pin6/B2
- IRQ pin9/A2
Created on April 7, 2015, 6:24 PM
#define NRF24_ADDRESS_MASK 0x6C6C6C7800 |
#define NRF24_BRANCH_WINDOW_MS 7 |
#define NRF24_CHANNEL_BRANCH_1 30 |
#define NRF24_CHANNEL_BRANCH_2 34 |
#define NRF24_CHANNEL_BRANCH_3 38 |
#define NRF24_CHANNEL_BRANCH_4 42 |
#define NRF24_CHANNEL_BRANCH_5 46 |
#define NRF24_CHANNEL_BRANCH_6 50 |
#define NRF24_MIN_WINDOW_MS 8 |
#define NRF24_MISSING_NODE_TIMEOUT 100 |
#define nrf24_NetworkISRHandlerN |
( |
|
net | ) |
nRF24_ISR(&net.radio) |
#define NRFNET_MSG_BUFFER_LENGTH 16 |
typedef void(* nrf24_handler_fn_t)(uint8_t *data, uint8_t len, uint8_t from) |
function pointer type for consuming certain msg_id's
Enumerator |
---|
MASTER |
Brainframe / Scrumshank Redemption.
|
SCRUM_PUN |
Branch 1 - ScrumPun.
|
BALL_TRAP |
|
TOMS_PAD |
|
NOODLE |
|
MOUSE_TRAP |
Branch 2 - RedBulls.
|
ULTRASONIC |
Branch 3 - SmartHomies.
|
DAN |
|
CAM |
|
JAKE |
|
SUPREME |
Branch 4 - TeamSupreme.
|
BOT |
|
SNEAK |
|
LASER |
|
SIMON |
|
OGLAZERBOIZ |
Branch 5 - Muhlbaier's Fav. Clinic.
|
OGLAZ2 |
|
LOCK_PICK |
|
PIEZO |
|
MIKE |
Branch 6 - Scrumshank Redemption.
|
SORCE |
|
MALONEY |
|
MUHLBAIER |
|
LAST_ADDRESS |
|
ALL_ALL |
|
Enumerator |
---|
ONBOARD_LED |
|
LINEAR_ACTUATOR |
|
LAST_CONTROL_ID |
reserved name to determine number of control msgs supported
|
Enumerator |
---|
SYSTEM_MSG |
built-in / MM
|
CONTROL_MSG |
general control msg / max payload 5+ bytes
|
SENSOR_MSG |
general sensor msg / max payload 4+ bytes
|
CHAT_MSG |
built-in / Jon W.
|
TEST_MSG |
Used for testing the network.
|
KILL_MSG |
Used to remotely kill (reset) a node on the network.
|
THIEF_MSG |
Used to support the Theif class project.
|
LAST_MSG_ID |
reserved name to determine number of message IDs supported
|
Enumerator |
---|
TEMPERATURE_SENSOR |
|
LAST_SENSOR_ID |
reserved name to determine number of sensors supported
|
Enumerator |
---|
NULL_MSG |
|
PING_MSG |
|
PING_RESPONSE_MSG |
|
SPAM_MSG |
|
Enumerator |
---|
ARM_MSG |
Brainframe->Thing, data is difficulty.
|
DISARM_MSG |
Brainframe->Thing, data is difficulty.
|
TRIP_MSG |
Thing->Brainframe, data is score (1 barely tripped)
|
ACCESS_MSG |
Thing->Brainframe, data is score (1 great job)
|
ERROR_MSG |
Thing->Brainframe, data is error code (TBD)
|
DIFFICULTY_MSG |
Brainframe->Thing, data is difficulty.
|
LAST_THIEF_ID |
reserved name to determine number of messages supported
|
Enumerator |
---|
ROLE_MASTER |
|
ROLE_BRANCH |
|
ROLE_LEAF |
|
Enumerator |
---|
NRFNET_INITIALIZED |
|
NRFNET_NORMAL_STATE |
|
NRFNET_WAITING_FOR_MIN_WINDOW |
|
Enumerator |
---|
CHILD_INITIALIZED |
|
CHILD_ACTIVE |
|
CHILD_MISSING |
|
uint8_t AddressFromName |
( |
char * |
name | ) |
|
- Parameters
-
name | pointer to name to lookup |
- Returns
- address network address
char* NameFromAddress |
( |
uint8_t |
address | ) |
|
Convert network address to name
- Parameters
-
address | address to convert to name |
- Returns
- string pointer to name
void nrf24_NetworkInit |
( |
void(*)(uint8_t) |
ce, |
|
|
void(*)(uint8_t) |
csn, |
|
|
uint8_t |
spi_channel |
|
) |
| |
Initialize nRF24 Network Module.
- Parameters
-
ce | Function pointer to Chip Enable signal function. If input to the function is 0 the CE line should output GND. If the input to the function is 1 the CE pin should output 3.3V |
csn | Function pointer to Not Chip Select signal function. If input to the function is 0 the CSN line should output GND. If the input to the function is 1 the CSN pin should output 3.3V |
spi_channel | SPI channel number to be passed to the SPI Module |
void nrf24_NetworkInitN |
( |
nrfnet_t * |
net, |
|
|
void(*)(uint8_t) |
ce, |
|
|
void(*)(uint8_t) |
csn, |
|
|
uint8_t |
spi_channel, |
|
|
uint8_t |
node |
|
) |
| |
void nrf24_NetworkISRHandler |
( |
void |
| ) |
|
void nrf24_Ping |
( |
uint8_t |
to | ) |
|
Register a control message Handler for a specific control ID
Same as nrf24_RegisterMsgHandler() except the Handler will be called when the message ID is CONTROL_MSG and the control_id (byte after msg ID, i.e. byte 4) matches control_id
.
- Parameters
-
control_id | Control ID to register Handler for |
fn_ptr | Pointer to Handler function |
Register a message Handler for a specific message ID
When a message with a message ID that matches msg_id
is received the Handler function will be called with a data pointer to the remaining payload (data), the length of the remaining payload (len), and the from address (from).
Only one handler per message ID may be registered.
Handlers for SYSTEM_MSG, CONTROL_MSG, SENSOR_MSG, and CHAT_MSG are built-in but can be overridden.
Example:
void PongHandler(uint8_t * data, uint8_t len, uint8_t from) {
}
- Parameters
-
msg_id | Message ID to register Handler for |
fn_ptr | Pointer to Handler function |
Register a sensor message Handler for a specific sensor ID
Same as nrf24_RegisterMsgHandler() except the Handler will be called when the message ID is SENSOR_MSG and the sensor_id (byte after msg ID, i.e. byte 4) matches sensor_id
.
- Parameters
-
sensor_id | Sensor ID to register Handler for |
fn_ptr | Pointer to Handler function |
void nrf24_SendMsg |
( |
uint8_t |
to, |
|
|
enum nrf24_msg_id |
msg_id, |
|
|
uint8_t * |
data, |
|
|
uint8_t |
len |
|
) |
| |
Send a message over the nRF24 network
- Parameters
-
to | address to send message to (use enum nrf24_address for now) |
msg_id | Message ID |
data | pointer to data payload (address bytes and message ID will be generated automatically, this pointer should point to the fourth byte of the payload). |
len | length to the data payload (min 0, max 29) |
void nrf24_SendMsgN |
( |
nrfnet_t * |
net, |
|
|
uint8_t |
to, |
|
|
enum nrf24_msg_id |
msg_id, |
|
|
uint8_t * |
data, |
|
|
uint8_t |
len |
|
) |
| |