![]() |
#include "rfhelp.h"
#include "rf.h"
#include "ch.h"
#include "hal.h"
#include "crc.h"
#include <string.h>
#include <stdbool.h>
Functions | |
void | rfhelp_init (void) |
void | rfhelp_restart (void) |
int | rfhelp_send_data (char *data, int len) |
int | rfhelp_send_data_crc (char *data, int len) |
int | rfhelp_read_rx_data (char *data, int *len, int *pipe) |
int | rfhelp_read_rx_data_crc (char *data, int *len, int *pipe) |
int | rfhelp_rf_status (void) |
void | rfhelp_set_tx_addr (const char *addr, int addr_len) |
void | rfhelp_set_rx_addr (int pipe, const char *addr, int addr_len) |
void | rfhelp_power_down (void) |
void | rfhelp_power_up (void) |
void rfhelp_init | ( | void | ) |
void rfhelp_power_down | ( | void | ) |
void rfhelp_power_up | ( | void | ) |
int rfhelp_read_rx_data | ( | char * | data, |
int * | len, | ||
int * | pipe | ||
) |
Read data from the RX fifo
data | Pointer to the array in which to store the data. |
len | Pointer to variable storing the data length. |
pipe | Pointer to the pipe on which the data was received. Can be 0. |
int rfhelp_read_rx_data_crc | ( | char * | data, |
int * | len, | ||
int * | pipe | ||
) |
Same as rfhelp_read_rx_data, but will check if there is a valid CRC in the end of the payload.
data | Pointer to the array in which to store the data. |
len | Pointer to variable storing the data length. |
pipe | Pointer to the pipe on which the data was received. Can be 0. |
void rfhelp_restart | ( | void | ) |
Re-init the rf chip
int rfhelp_rf_status | ( | void | ) |
int rfhelp_send_data | ( | char * | data, |
int | len | ||
) |
Set TX mode, send data, wait for result, set RX mode.
data | The data to be sent. |
len | Length of the data. |
int rfhelp_send_data_crc | ( | char * | data, |
int | len | ||
) |
Same as rfhelp_send_data, but will add a crc checksum to the end. This is useful for protecting against corruption between the NRF and the MCU in case there are errors on the SPI bus.
data | The data to be sent. |
len | Length of the data. Should be no more than 30 bytes. |
void rfhelp_set_rx_addr | ( | int | pipe, |
const char * | addr, | ||
int | addr_len | ||
) |
void rfhelp_set_tx_addr | ( | const char * | addr, |
int | addr_len | ||
) |