LibDriver NRF905
Loading...
Searching...
No Matches
driver_nrf905.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_NRF905_H
38#define DRIVER_NRF905_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef enum
63{
67
76
87
96
105
116
128
132typedef enum
133{
137
141typedef enum
142{
146
156
160typedef struct nrf905_handle_s
161{
162 uint8_t (*ce_gpio_init)(void);
163 uint8_t (*ce_gpio_deinit)(void);
164 uint8_t (*ce_gpio_write)(uint8_t value);
165 uint8_t (*tx_en_gpio_init)(void);
166 uint8_t (*tx_en_gpio_deinit)(void);
167 uint8_t (*tx_en_gpio_write)(uint8_t value);
168 uint8_t (*pwr_up_gpio_init)(void);
169 uint8_t (*pwr_up_gpio_deinit)(void);
170 uint8_t (*pwr_up_gpio_write)(uint8_t value);
171 uint8_t (*spi_init)(void);
172 uint8_t (*spi_deinit)(void);
173 uint8_t (*spi_read)(uint8_t reg, uint8_t *buf, uint16_t len);
174 uint8_t (*spi_write)(uint8_t reg, uint8_t *buf, uint16_t len);
175 uint8_t (*spi_transmit)(uint8_t *tx, uint8_t *rx, uint16_t len);
176 void (*delay_ms)(uint32_t ms);
177 void (*debug_print)(const char *const fmt, ...);
178 void (*receive_callback)(uint8_t type, uint8_t *buf, uint8_t len);
179 uint8_t inited;
180 uint8_t conf[10];
181 uint8_t finished;
182 uint8_t mode;
184
200
204
211
218#define DRIVER_NRF905_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
219
226#define DRIVER_NRF905_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
227
234#define DRIVER_NRF905_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
235
242#define DRIVER_NRF905_LINK_SPI_READ(HANDLE, FUC) (HANDLE)->spi_read = FUC
243
250#define DRIVER_NRF905_LINK_SPI_WRITE(HANDLE, FUC) (HANDLE)->spi_write = FUC
251
258#define DRIVER_NRF905_LINK_SPI_TRANSMIT(HANDLE, FUC) (HANDLE)->spi_transmit = FUC
259
266#define DRIVER_NRF905_LINK_CE_GPIO_INIT(HANDLE, FUC) (HANDLE)->ce_gpio_init = FUC
267
274#define DRIVER_NRF905_LINK_CE_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->ce_gpio_deinit = FUC
275
282#define DRIVER_NRF905_LINK_CE_GPIO_WRITE(HANDLE, FUC) (HANDLE)->ce_gpio_write = FUC
283
290#define DRIVER_NRF905_LINK_TX_EN_GPIO_INIT(HANDLE, FUC) (HANDLE)->tx_en_gpio_init = FUC
291
298#define DRIVER_NRF905_LINK_TX_EN_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->tx_en_gpio_deinit = FUC
299
306#define DRIVER_NRF905_LINK_TX_EN_GPIO_WRITE(HANDLE, FUC) (HANDLE)->tx_en_gpio_write = FUC
307
314#define DRIVER_NRF905_LINK_PWR_UP_GPIO_INIT(HANDLE, FUC) (HANDLE)->pwr_up_gpio_init = FUC
315
322#define DRIVER_NRF905_LINK_PWR_UP_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->pwr_up_gpio_deinit = FUC
323
330#define DRIVER_NRF905_LINK_PWR_UP_GPIO_WRITE(HANDLE, FUC) (HANDLE)->pwr_up_gpio_write = FUC
331
338#define DRIVER_NRF905_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
339
346#define DRIVER_NRF905_LINK_DEBUG_PEINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
347
354#define DRIVER_NRF905_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
355
359
366
375uint8_t nrf905_info(nrf905_info_t *info);
376
387uint8_t nrf905_irq_handler(nrf905_handle_t *handle);
388
402uint8_t nrf905_init(nrf905_handle_t *handle);
403
418uint8_t nrf905_deinit(nrf905_handle_t *handle);
419
431uint8_t nrf905_set_power_up(nrf905_handle_t *handle, nrf905_bool_t enable);
432
444uint8_t nrf905_set_enable(nrf905_handle_t *handle, nrf905_bool_t enable);
445
457uint8_t nrf905_set_mode(nrf905_handle_t *handle, nrf905_mode_t mode);
458
473uint8_t nrf905_send(nrf905_handle_t *handle, uint8_t *buf, uint8_t len);
474
485uint8_t nrf905_write_conf(nrf905_handle_t *handle);
486
498uint8_t nrf905_read_conf(nrf905_handle_t *handle, uint8_t conf[10]);
499
511uint8_t nrf905_update_conf(nrf905_handle_t *handle, uint8_t conf[10]);
512
526uint8_t nrf905_set_tx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len);
527
541uint8_t nrf905_get_tx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len);
542
556uint8_t nrf905_get_rx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len);
557
571uint8_t nrf905_set_tx_address(nrf905_handle_t *handle, uint8_t *addr, uint8_t len);
572
586uint8_t nrf905_get_tx_address(nrf905_handle_t *handle, uint8_t *addr, uint8_t len);
587
602uint8_t nrf905_channel_config(nrf905_handle_t *handle, uint16_t freq, nrf905_pll_mode_t mode, nrf905_output_power_t power);
603
615uint8_t nrf905_get_status(nrf905_handle_t *handle, uint8_t *status);
616
629uint8_t nrf905_set_frequency(nrf905_handle_t *handle, uint16_t freq);
630
642uint8_t nrf905_get_frequency(nrf905_handle_t *handle, uint16_t *freq);
643
655uint8_t nrf905_frequency_convert_to_register(nrf905_handle_t *handle, float mhz, uint16_t *reg);
656
668uint8_t nrf905_frequency_convert_to_data(nrf905_handle_t *handle, uint16_t reg, float *mhz);
669
682
695
708
721
734
747
760
773
786
799
812
825
838uint8_t nrf905_set_rx_payload_width(nrf905_handle_t *handle, uint8_t width);
839
851uint8_t nrf905_get_rx_payload_width(nrf905_handle_t *handle, uint8_t *width);
852
865uint8_t nrf905_set_tx_payload_width(nrf905_handle_t *handle, uint8_t width);
866
878uint8_t nrf905_get_tx_payload_width(nrf905_handle_t *handle, uint8_t *width);
879
891uint8_t nrf905_set_rx_address(nrf905_handle_t *handle, uint8_t addr[4]);
892
904uint8_t nrf905_get_rx_address(nrf905_handle_t *handle, uint8_t addr[4]);
905
918
931
944
957
970
983
995uint8_t nrf905_set_crc(nrf905_handle_t *handle, nrf905_bool_t enable);
996
1008uint8_t nrf905_get_crc(nrf905_handle_t *handle, nrf905_bool_t *enable);
1009
1022
1035
1039
1046
1060uint8_t nrf905_set_reg(nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
1061
1075uint8_t nrf905_get_reg(nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
1076
1080
1084
1085#ifdef __cplusplus
1086}
1087#endif
1088
1089#endif
nrf905_address_width_t
nrf905 address width enumeration definition
uint8_t nrf905_set_output_clock(nrf905_handle_t *handle, nrf905_bool_t enable)
enable or disable the output clock
nrf905_output_clock_frequency_t
nrf905 output clock frequency enumeration definition
uint8_t nrf905_get_rx_address_width(nrf905_handle_t *handle, nrf905_address_width_t *width)
get the rx address width
uint8_t nrf905_set_frequency(nrf905_handle_t *handle, uint16_t freq)
set the frequency
uint8_t nrf905_read_conf(nrf905_handle_t *handle, uint8_t conf[10])
read the conf
uint8_t nrf905_set_tx_payload_width(nrf905_handle_t *handle, uint8_t width)
set the tx payload width
uint8_t nrf905_init(nrf905_handle_t *handle)
initialize the chip
uint8_t nrf905_get_crc_mode(nrf905_handle_t *handle, nrf905_crc_mode_t *mode)
get the crc mode
uint8_t nrf905_get_auto_retransmit(nrf905_handle_t *handle, nrf905_bool_t *enable)
get the auto retransmit status
nrf905_crystal_oscillator_frequency_t
nrf905 crystal oscillator frequency enumeration definition
uint8_t nrf905_update_conf(nrf905_handle_t *handle, uint8_t conf[10])
update the conf
uint8_t nrf905_get_rx_address(nrf905_handle_t *handle, uint8_t addr[4])
get the rx address
uint8_t nrf905_frequency_convert_to_register(nrf905_handle_t *handle, float mhz, uint16_t *reg)
convert the frequency to the register raw data
nrf905_crc_mode_t
nrf905 crc mode enumeration definition
uint8_t nrf905_set_crc_mode(nrf905_handle_t *handle, nrf905_crc_mode_t mode)
set the crc mode
uint8_t nrf905_set_pll_mode(nrf905_handle_t *handle, nrf905_pll_mode_t mode)
set the pll mode
nrf905_output_power_t
nrf905 output power enumeration definition
nrf905_mode_t
nrf905 mode enumeration definition
uint8_t nrf905_get_tx_payload_width(nrf905_handle_t *handle, uint8_t *width)
get the tx payload width
uint8_t nrf905_set_output_power(nrf905_handle_t *handle, nrf905_output_power_t output_power)
set the output power
uint8_t nrf905_set_enable(nrf905_handle_t *handle, nrf905_bool_t enable)
enable or disable the chip
nrf905_status_t
nrf905 status enumeration definition
struct nrf905_info_s nrf905_info_t
nrf905 information structure definition
nrf905_pll_mode_t
nrf905 pll mode enumeration definition
uint8_t nrf905_get_tx_address_width(nrf905_handle_t *handle, nrf905_address_width_t *width)
get the tx address width
uint8_t nrf905_get_tx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
get the tx payload
uint8_t nrf905_set_rx_payload_width(nrf905_handle_t *handle, uint8_t width)
set the rx payload width
uint8_t nrf905_set_power_up(nrf905_handle_t *handle, nrf905_bool_t enable)
set the power up
uint8_t nrf905_get_status(nrf905_handle_t *handle, uint8_t *status)
get the status
uint8_t nrf905_get_rx_mode(nrf905_handle_t *handle, nrf905_rx_mode_t *mode)
get the rx mode
uint8_t nrf905_get_output_power(nrf905_handle_t *handle, nrf905_output_power_t *output_power)
get the output power
uint8_t nrf905_set_rx_address_width(nrf905_handle_t *handle, nrf905_address_width_t width)
set the rx address width
uint8_t nrf905_send(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
send data
uint8_t nrf905_set_crystal_oscillator_frequency(nrf905_handle_t *handle, nrf905_crystal_oscillator_frequency_t freq)
set the crystal oscillator frequency
uint8_t nrf905_set_rx_address(nrf905_handle_t *handle, uint8_t addr[4])
set the rx address
uint8_t nrf905_info(nrf905_info_t *info)
get chip's information
uint8_t nrf905_set_tx_address_width(nrf905_handle_t *handle, nrf905_address_width_t width)
set the tx address width
uint8_t nrf905_get_output_clock(nrf905_handle_t *handle, nrf905_bool_t *enable)
get the output clock status
uint8_t nrf905_set_tx_address(nrf905_handle_t *handle, uint8_t *addr, uint8_t len)
set the tx address
uint8_t nrf905_get_pll_mode(nrf905_handle_t *handle, nrf905_pll_mode_t *mode)
get the pll mode
uint8_t nrf905_set_rx_mode(nrf905_handle_t *handle, nrf905_rx_mode_t mode)
set the rx mode
uint8_t nrf905_write_conf(nrf905_handle_t *handle)
write the conf
uint8_t nrf905_frequency_convert_to_data(nrf905_handle_t *handle, uint16_t reg, float *mhz)
convert the register raw data to the frequency
uint8_t nrf905_irq_handler(nrf905_handle_t *handle)
irq handler
uint8_t nrf905_get_tx_address(nrf905_handle_t *handle, uint8_t *addr, uint8_t len)
get the tx address
uint8_t nrf905_get_crystal_oscillator_frequency(nrf905_handle_t *handle, nrf905_crystal_oscillator_frequency_t *freq)
get the crystal oscillator frequency
uint8_t nrf905_set_auto_retransmit(nrf905_handle_t *handle, nrf905_bool_t enable)
enable or disable the auto retransmit
uint8_t nrf905_get_rx_payload_width(nrf905_handle_t *handle, uint8_t *width)
get the rx payload width
uint8_t nrf905_set_output_clock_frequency(nrf905_handle_t *handle, nrf905_output_clock_frequency_t freq)
set the output clock frequency
uint8_t nrf905_set_mode(nrf905_handle_t *handle, nrf905_mode_t mode)
set the mode
uint8_t nrf905_channel_config(nrf905_handle_t *handle, uint16_t freq, nrf905_pll_mode_t mode, nrf905_output_power_t power)
config the channel
nrf905_rx_mode_t
nrf905 rx mode enumeration definition
uint8_t nrf905_get_frequency(nrf905_handle_t *handle, uint16_t *freq)
get the frequency
struct nrf905_handle_s nrf905_handle_t
nrf905 handle structure definition
uint8_t nrf905_get_rx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
get the rx payload
uint8_t nrf905_set_crc(nrf905_handle_t *handle, nrf905_bool_t enable)
enable or disable the crc
uint8_t nrf905_deinit(nrf905_handle_t *handle)
close the chip
uint8_t nrf905_get_output_clock_frequency(nrf905_handle_t *handle, nrf905_output_clock_frequency_t *freq)
get the output clock frequency
uint8_t nrf905_set_tx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
set the tx payload
nrf905_bool_t
nrf905 bool enumeration definition
uint8_t nrf905_get_crc(nrf905_handle_t *handle, nrf905_bool_t *enable)
get the crc status
@ NRF905_ADDRESS_WIDTH_1_BYTE
@ NRF905_ADDRESS_WIDTH_4_BYTE
@ NRF905_OUTPUT_CLOCK_FREQUENCY_1MHZ
@ NRF905_OUTPUT_CLOCK_FREQUENCY_4MHZ
@ NRF905_OUTPUT_CLOCK_FREQUENCY_2MHZ
@ NRF905_OUTPUT_CLOCK_FREQUENCY_500KHZ
@ NRF905_CRYSTAL_OSCILLATOR_FREQUENCY_12MHZ
@ NRF905_CRYSTAL_OSCILLATOR_FREQUENCY_16MHZ
@ NRF905_CRYSTAL_OSCILLATOR_FREQUENCY_8MHZ
@ NRF905_CRYSTAL_OSCILLATOR_FREQUENCY_20MHZ
@ NRF905_CRYSTAL_OSCILLATOR_FREQUENCY_4MHZ
@ NRF905_CRC_MODE_8
@ NRF905_CRC_MODE_16
@ NRF905_OUTPUT_POWER_6_DBM
@ NRF905_OUTPUT_POWER_NEGATIVE_2_DBM
@ NRF905_OUTPUT_POWER_10_DBM
@ NRF905_OUTPUT_POWER_NEGATIVE_10_DBM
@ NRF905_MODE_RX
@ NRF905_MODE_TX
@ NRF905_STATUS_AM
@ NRF905_STATUS_RX_DONE
@ NRF905_STATUS_TX_DONE
@ NRF905_PLL_MODE_433_MHZ
@ NRF905_PLL_MODE_868_915_MHZ
@ NRF905_RX_MODE_REDUCED_POWER
@ NRF905_RX_MODE_NORMAL
@ NRF905_BOOL_FALSE
@ NRF905_BOOL_TRUE
uint8_t nrf905_get_reg(nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t nrf905_set_reg(nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
nrf905 handle structure definition
uint8_t(* ce_gpio_deinit)(void)
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_read)(uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* spi_write)(uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* tx_en_gpio_init)(void)
void(* receive_callback)(uint8_t type, uint8_t *buf, uint8_t len)
uint8_t(* tx_en_gpio_deinit)(void)
uint8_t(* pwr_up_gpio_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint8_t(* spi_transmit)(uint8_t *tx, uint8_t *rx, uint16_t len)
uint8_t(* spi_deinit)(void)
uint8_t(* tx_en_gpio_write)(uint8_t value)
uint8_t conf[10]
uint8_t(* pwr_up_gpio_init)(void)
uint8_t(* pwr_up_gpio_write)(uint8_t value)
uint8_t(* ce_gpio_init)(void)
uint8_t(* ce_gpio_write)(uint8_t value)
nrf905 information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]