42#define CHIP_NAME "Nordic nRF905"
43#define MANUFACTURER_NAME "Nordic"
44#define SUPPLY_VOLTAGE_MIN 1.9f
45#define SUPPLY_VOLTAGE_MAX 3.6f
46#define MAX_CURRENT 30.0f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 85.0f
49#define DRIVER_VERSION 1000
54#define NRF905_COMMAND_W_CONFIG 0x00
55#define NRF905_COMMAND_R_CONFIG 0x10
56#define NRF905_COMMAND_W_TX_PAYLOAD 0x20
57#define NRF905_COMMAND_R_TX_PAYLOAD 0x21
58#define NRF905_COMMAND_W_TX_ADDRESS 0x22
59#define NRF905_COMMAND_R_TX_ADDRESS 0x23
60#define NRF905_COMMAND_R_RX_PAYLOAD 0x24
61#define NRF905_COMMAND_CHANNEL_CONFIG 0x80
66#define NRF905_REG_CH_NO 0x00
67#define NRF905_REG_CONF1 0x01
68#define NRF905_REG_CONF2 0x02
69#define NRF905_REG_RX_PW 0x03
70#define NRF905_REG_TX_PW 0x04
71#define NRF905_REG_RX_ADDRESS_0 0x05
72#define NRF905_REG_RX_ADDRESS_1 0x06
73#define NRF905_REG_RX_ADDRESS_2 0x07
74#define NRF905_REG_RX_ADDRESS_3 0x08
75#define NRF905_REG_CONF3 0x09
88static uint8_t a_nrf905_spi_transmit(
nrf905_handle_t *handle, uint8_t *tx, uint8_t *rx, uint16_t len)
111static uint8_t a_nrf905_spi_read(
nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
113 if (handle->
spi_read(reg, buf, len) != 0)
134static uint8_t a_nrf905_spi_write(
nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
136 if (handle->
spi_write(reg, buf, len) != 0)
171 handle->
debug_print(
"nrf905: spi_init is null.\n");
177 handle->
debug_print(
"nrf905: spi_deinit is null.\n");
183 handle->
debug_print(
"nrf905: spi_read is null.\n");
189 handle->
debug_print(
"nrf905: spi_write is null.\n");
195 handle->
debug_print(
"nrf905: spi_transmit is null.\n");
201 handle->
debug_print(
"nrf905: ce_gpio_init is null.\n");
207 handle->
debug_print(
"nrf905: ce_gpio_deinit is null.\n");
213 handle->
debug_print(
"nrf905: ce_gpio_write is null.\n");
219 handle->
debug_print(
"nrf905: tx_en_gpio_init is null.\n");
225 handle->
debug_print(
"nrf905: tx_en_gpio_deinit is null.\n");
231 handle->
debug_print(
"nrf905: tx_en_gpio_write is null.\n");
237 handle->
debug_print(
"nrf905: pwr_up_gpio_init is null.\n");
243 handle->
debug_print(
"nrf905: pwr_up_gpio_deinit is null.\n");
249 handle->
debug_print(
"nrf905: pwr_up_gpio_write is null.\n");
255 handle->
debug_print(
"nrf905: delay_ms is null.\n");
261 handle->
debug_print(
"nrf905: receive_callback is null.\n");
274 handle->
debug_print(
"nrf905: pwr up gpio init failed.\n");
281 handle->
debug_print(
"nrf905: ce gpio init failed.\n");
289 handle->
debug_print(
"nrf905: tx en gpio init failed.\n");
296 handle->
conf[0] = 0x6C;
297 handle->
conf[1] = 0x00;
298 handle->
conf[2] = 0x44;
299 handle->
conf[3] = 0x20;
300 handle->
conf[4] = 0x20;
301 handle->
conf[5] = 0xE7;
302 handle->
conf[6] = 0xE7;
303 handle->
conf[7] = 0xE7;
304 handle->
conf[8] = 0xE7;
305 handle->
conf[9] = 0xE7;
339 handle->
debug_print(
"nrf905: power down failed.\n");
345 handle->
debug_print(
"nrf905: spi deinit failed.\n");
351 handle->
debug_print(
"nrf905: pwr up gpio deinit failed.\n");
357 handle->
debug_print(
"nrf905: ce gpio deinit failed.\n");
363 handle->
debug_print(
"nrf905: tx en gpio deinit failed.\n");
400 handle->
debug_print(
"nrf905: ce gpio write failed.\n");
406 res = a_nrf905_spi_transmit(handle, ®, (uint8_t *)&status, 1);
409 handle->
debug_print(
"nrf905: get status failed.\n");
414 if ((status & (1 << 5)) != 0)
416 if (handle->
mode == 1)
433 handle->
debug_print(
"nrf905: get rx payload failed.\n");
444 if ((status & (1 << 7)) != 0)
453 handle->
debug_print(
"nrf905: ce gpio write failed.\n");
485 handle->
debug_print(
"nrf905: set power up failed.\n");
519 handle->
debug_print(
"nrf905: set enable failed.\n");
559 handle->
mode = (uint8_t)mode;
601 handle->
debug_print(
"nrf905: ce gpio write failed.\n");
607 handle->
debug_print(
"nrf905: tx en gpio write failed.\n");
615 handle->
debug_print(
"nrf905: set tx payload failed.\n");
623 handle->
debug_print(
"nrf905: ce gpio write failed.\n");
628 while ((timeout != 0) && (handle->
finished == 0))
635 handle->
debug_print(
"nrf905: ce gpio write failed.\n");
683 handle->
debug_print(
"nrf905: write conf failed.\n");
718 handle->
debug_print(
"nrf905: read conf failed.\n");
748 memcpy(handle->
conf, conf, 10);
788 handle->
debug_print(
"nrf905: set tx payload failed.\n");
831 handle->
debug_print(
"nrf905: get tx payload failed.\n");
874 handle->
debug_print(
"nrf905: get rx payload failed.\n");
917 handle->
debug_print(
"nrf905: set tx address failed.\n");
960 handle->
debug_print(
"nrf905: get tx address failed.\n");
997 handle->
debug_print(
"nrf905: freq is over 0x1FF.\n");
1003 power << 2 | mode << 1 | ((freq >> 8) & 0x1));
1004 buf[1] = (uint8_t)(freq & 0xFF);
1005 res = a_nrf905_spi_write(handle, buf[0], &buf[1], 1);
1008 handle->
debug_print(
"nrf905: channel config failed.\n");
1042 res = a_nrf905_spi_transmit(handle, ®, (uint8_t *)status, 1);
1045 handle->
debug_print(
"nrf905: get status failed.\n");
1079 handle->
debug_print(
"nrf905: freq is over 0x1FF.\n");
1087 prev |= (freq >> 8) & 0x01;
1121 *freq |= ((uint16_t)prev & 0x01) << 8;
1151 *reg = (uint16_t)(((mhz / (1 + bw)) - 422.4f) * 10.0f);
1181 *mhz = (float)(422.4f + (
float)reg / 10.0f) * (1 + bw);
1274 prev |= output_power << 2;
1398 prev |= enable << 5;
1582 handle->
debug_print(
"nrf905: width is over 0x20.\n");
1643 handle->
debug_print(
"nrf905: width is over 0x20.\n");
1822 prev |= enable << 2;
1946 prev |= enable << 6;
2068 return a_nrf905_spi_write(handle, reg, buf, len);
2095 return a_nrf905_spi_read(handle, reg, buf, len);
#define NRF905_COMMAND_R_TX_ADDRESS
#define NRF905_COMMAND_W_TX_ADDRESS
#define SUPPLY_VOLTAGE_MAX
#define NRF905_COMMAND_R_RX_PAYLOAD
#define NRF905_REG_RX_ADDRESS_0
#define NRF905_COMMAND_W_CONFIG
chip command definition
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define NRF905_COMMAND_W_TX_PAYLOAD
#define NRF905_REG_CH_NO
chip byte definition
#define NRF905_COMMAND_R_TX_PAYLOAD
#define CHIP_NAME
chip information definition
#define NRF905_COMMAND_CHANNEL_CONFIG
#define NRF905_COMMAND_R_CONFIG
driver nrf905 header file
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
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
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
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(* 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)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v