embeddedlibrary
reusable software modules for embedded systems
|
Go to the source code of this file.
Data Structures | |
union | nrfnet_address_t |
struct | nrfnet_msg_t |
struct | nrfnet_s |
Typedefs | |
typedef void(* | nrf24_handler_fn_t) (uint8_t *data, uint8_t len, uint8_t from) |
typedef struct nrfnet_s | nrfnet_t |
Enumerations | |
enum | nrf24_msg_id { SYSTEM_MSG = 0, CONTROL_MSG, SENSOR_MSG, CHAT_MSG, CHAT_TEA_MSG, CHAT_RSA_MSG, ENIGMA_MSG, BOMBERMAN_MSG, IR_REMOTE_MSG, DRUM_MSG, PONG_MSG, RGB_MATRIX_MSG, WHEEL_LIGHT_MSG, SNAKE_MSG, TEST_MSG, LAST_MSG_ID } |
enum | nrf24_system_msg { NULL_MSG = 0 } |
enum | nrf24_control_msg { ONBOARD_LED, LINEAR_ACTUATOR, COFFEE_POT, TOASTER, LAST_CONTROL_ID } |
enum | nrf24_sensor_msg { TEMPERATURE_SENSOR, SPEED_SENSOR, TORQUE_SENSOR, LAST_SENSOR_ID } |
enum | nrf24_address { MASTER = 0x00, LECAKES = 0x08, ALEYAN, AMRITKAR, CANDELARIA, CARLUCCIO, DONOW, LECAKES_ALL = 0x0F, BLAZEJEWSKI = 0x10, HAAS, HARRIS, HENSHAW, JACOBSEN, KLODNICKI, BLAZEJEWSKI_ALL = 0x17, MORRIS = 0x18, LABARCK, LIU, RITCHIE_III, RUPP, RUSSO, MORRIS_ALL = 0x1F, TRAFFORD = 0x20, WHALEN, WIBLE, MACCARONE, VOTTA, TRAFFORD_ALL = 0x27, MERLINO = 0x28, GOODMAN, 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 } |
Functions | |
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) |
char * | NameFromAddress (uint8_t address) |
uint8_t | AddressFromName (char *name) |
typedef void(* nrf24_handler_fn_t) (uint8_t *data, uint8_t len, uint8_t from) |
function pointer type for consuming certain msg_id's
enum nrf24_control_msg |
enum nrf24_msg_id |
enum nrf24_sensor_msg |
uint8_t AddressFromName | ( | char * | name | ) |
name | pointer to name to lookup |
char* NameFromAddress | ( | uint8_t | address | ) |
Convert network address to name
address | address to convert to name |
void nrf24_NetworkInit | ( | void(*)(uint8_t) | ce, |
void(*)(uint8_t) | csn, | ||
uint8_t | spi_channel | ||
) |
Initialize nRF24 Network Module.
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_RegisterControlHandler | ( | enum nrf24_control_msg | control_id, |
nrf24_handler_fn_t | fn_ptr | ||
) |
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
.
control_id | Control ID to register Handler for |
fn_ptr | Pointer to Handler function |
void nrf24_RegisterMsgHandler | ( | enum nrf24_msg_id | msg_id, |
nrf24_handler_fn_t | fn_ptr | ||
) |
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:
msg_id | Message ID to register Handler for |
fn_ptr | Pointer to Handler function |
void nrf24_RegisterSensorHandler | ( | enum nrf24_sensor_msg | sensor_id, |
nrf24_handler_fn_t | fn_ptr | ||
) |
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
.
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
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) |