123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937 |
- extern "C" {
- typedef enum
- {
- NRF_GZLL_MODE_DEVICE,
- NRF_GZLL_MODE_HOST,
- NRF_GZLL_MODE_SUSPEND,
- } nrf_gzll_mode_t;
- typedef enum
- {
- NRF_GZLL_DEVICE_CHANNEL_SELECTION_POLICY_USE_SUCCESSFUL,
- NRF_GZLL_DEVICE_CHANNEL_SELECTION_POLICY_USE_CURRENT,
- } nrf_gzll_device_channel_selection_policy_t;
- typedef enum
- {
- NRF_GZLL_TX_POWER_4_DBM,
- NRF_GZLL_TX_POWER_0_DBM,
- NRF_GZLL_TX_POWER_N4_DBM,
- NRF_GZLL_TX_POWER_N8_DBM,
- NRF_GZLL_TX_POWER_N12_DBM,
- NRF_GZLL_TX_POWER_N16_DBM,
- NRF_GZLL_TX_POWER_N20_DBM
- } nrf_gzll_tx_power_t;
- typedef enum
- {
- NRF_GZLL_DATARATE_250KBIT = 0,
- NRF_GZLL_DATARATE_1MBIT = 1,
- NRF_GZLL_DATARATE_2MBIT = 2
- } nrf_gzll_datarate_t;
- typedef enum
- {
- NRF_GZLL_XOSC_CTL_AUTO,
- NRF_GZLL_XOSC_CTL_MANUAL
- } nrf_gzll_xosc_ctl_t;
- typedef enum
- {
- NRF_GZLL_ERROR_CODE_NO_ERROR = 0,
- NRF_GZLL_ERROR_CODE_FAILED_TO_INITIALIZE = 1,
- NRF_GZLL_ERROR_CODE_ATTEMPTED_TO_CONFIGURE_WHEN_ENABLED = 2,
- NRF_GZLL_ERROR_CODE_POINTER_IS_NULL = 3,
- NRF_GZLL_ERROR_CODE_INVALID_PIPE = 4,
- NRF_GZLL_ERROR_CODE_INVALID_MODE = 5,
- NRF_GZLL_ERROR_CODE_INVALID_PAYLOAD_LENGTH = 6,
- NRF_GZLL_ERROR_CODE_INVALID_CHANNEL_TABLE_SIZE = 7,
- NRF_GZLL_ERROR_CODE_INSUFFICIENT_PACKETS_AVAILABLE = 8,
- NRF_GZLL_ERROR_CODE_ATTEMPTED_TO_ADD_TO_FULL_FIFO = 9,
- NRF_GZLL_ERROR_CODE_NO_SPACE_IN_RX_FIFO_FOR_ACK = 10,
- NRF_GZLL_ERROR_CODE_ATTEMPTED_TO_FETCH_FROM_EMPTY_FIFO = 11,
- NRF_GZLL_ERROR_CODE_ATTEMPTED_TO_FLUSH_WHEN_ENABLED = 12,
- NRF_GZLL_ERROR_CODE_INVALID_PARAMETER = 14,
- NRF_GZLL_ERROR_CODE_INTERNAL_ASSERT_OCCURRED = 15,
- NRF_GZLL_ERROR_CODE_CALLBACK_NOT_IMPLEMENTED = 16,
- NRF_GZLL_ERROR_CODE_INVALID_ADDRESS = 17,
- NRF_GZLL_ERROR_CODE_NUMBER_OF_ERROR_CODES = 18,
- } nrf_gzll_error_code_t;
- typedef struct
- {
- bool payload_received_in_ack;
- uint16_t num_tx_attempts;
- uint16_t num_channel_switches;
- int8_t rssi;
- uint8_t rf_channel;
- } nrf_gzll_device_tx_info_t;
- typedef struct
- {
- bool packet_removed_from_tx_fifo;
- int8_t rssi;
- uint8_t rf_channel;
- } nrf_gzll_host_rx_info_t;
- typedef struct
- {
- uint32_t packets_num;
- uint32_t timeouts_num;
- uint32_t channel_timeouts[NRF_GZLL_CONST_MAX_CHANNEL_TABLE_SIZE];
- uint32_t channel_packets[NRF_GZLL_CONST_MAX_CHANNEL_TABLE_SIZE];
- } nrf_gzll_tx_statistics_t;
- typedef void (*nrf_gzll_tx_timeout_callback)(uint32_t pipe, uint8_t rf_channel);
- typedef void (*nrf_gzll_crc_failure_callback)(uint32_t pipe, uint8_t rf_channel);
- typedef struct
- {
- bool pa_enabled;
- bool pa_active_high;
- uint8_t pa_gpio_pin;
- uint8_t pa_gpiote_channel;
- bool lna_enabled;
- bool lna_active_high;
- uint8_t lna_gpio_pin;
- uint8_t lna_gpiote_channel;
- NRF_TIMER_Type * timer;
- uint8_t ppi_channels[NRF_GZLL_PA_LNA_PPI_CHANNELS_NUM];
- uint8_t ramp_up_time;
- } nrf_gzll_pa_lna_cfg_t;
- bool nrf_gzll_init(nrf_gzll_mode_t mode);
- bool nrf_gzll_enable(void);
- void nrf_gzll_disable(void);
- bool nrf_gzll_is_enabled(void);
- void nrf_gzll_device_tx_success(uint32_t pipe, nrf_gzll_device_tx_info_t tx_info);
- void nrf_gzll_device_tx_failed(uint32_t pipe, nrf_gzll_device_tx_info_t tx_info);
- void nrf_gzll_host_rx_data_ready(uint32_t pipe, nrf_gzll_host_rx_info_t rx_info);
- void nrf_gzll_disabled(void);
- void nrf_gzll_mode_changed(void);
- bool nrf_gzll_add_packet_to_tx_fifo(uint32_t pipe, uint8_t * p_payload, uint32_t length);
- bool nrf_gzll_fetch_packet_from_rx_fifo(uint32_t pipe, uint8_t * p_payload, uint32_t * p_length);
- int32_t nrf_gzll_get_tx_fifo_packet_count(uint32_t pipe);
- int32_t nrf_gzll_get_rx_fifo_packet_count(uint32_t pipe);
- uint32_t nrf_gzll_get_total_allocated_packet_count(void);
- bool nrf_gzll_ok_to_add_packet_to_tx_fifo(uint32_t pipe);
- bool nrf_gzll_flush_tx_fifo(uint32_t pipe);
- bool nrf_gzll_flush_rx_fifo(uint32_t pipe);
- bool nrf_gzll_tx_statistics_enable(nrf_gzll_tx_statistics_t * p_statistics);
- void nrf_gzll_tx_statistics_disable(void);
- bool nrf_gzll_get_channel_timeouts(uint8_t channel_index, uint32_t *p_timeouts);
- void nrf_gzll_reset_tx_statistics(void);
- void nrf_gzll_tx_timeout_callback_register(nrf_gzll_tx_timeout_callback callback);
- void nrf_gzll_crc_failure_callback_register(nrf_gzll_crc_failure_callback callback);
- bool nrf_gzll_set_mode(nrf_gzll_mode_t mode);
- nrf_gzll_mode_t nrf_gzll_get_mode(void);
- bool nrf_gzll_set_base_address_0(uint32_t base_address);
- uint32_t nrf_gzll_get_base_address_0(void);
- bool nrf_gzll_set_base_address_1(uint32_t base_address);
- uint32_t nrf_gzll_get_base_address_1(void);
- bool nrf_gzll_set_address_prefix_byte(uint32_t pipe, uint8_t address_prefix_byte);
- bool nrf_gzll_get_address_prefix_byte(uint32_t pipe, uint8_t * p_out_address_prefix_byte);
- bool nrf_gzll_set_rx_pipes_enabled(uint32_t pipes);
- uint32_t nrf_gzll_get_rx_pipes_enabled(void);
- bool nrf_gzll_set_timeslot_period(uint32_t period_us);
- uint32_t nrf_gzll_get_timeslot_period(void);
- bool nrf_gzll_set_device_channel_selection_policy(nrf_gzll_device_channel_selection_policy_t policy);
- nrf_gzll_device_channel_selection_policy_t nrf_gzll_get_device_channel_selection_policy(void);
- bool nrf_gzll_set_timeslots_per_channel(uint32_t timeslots);
- uint32_t nrf_gzll_get_timeslots_per_channel(void);
- bool nrf_gzll_set_timeslots_per_channel_when_device_out_of_sync(uint32_t timeslots);
- uint32_t nrf_gzll_get_timeslots_per_channel_when_device_out_of_sync(void);
- bool nrf_gzll_set_sync_lifetime(uint32_t lifetime);
- uint32_t nrf_gzll_get_sync_lifetime(void);
- void nrf_gzll_set_max_tx_attempts(uint16_t max_tx_attempts);
- uint16_t nrf_gzll_get_max_tx_attempts(void);
- bool nrf_gzll_set_channel_table(uint8_t * p_channel_table, uint32_t size);
- bool nrf_gzll_get_channel_table(uint8_t * p_channel_table, uint32_t * p_size);
- uint32_t nrf_gzll_get_channel_table_size(void);
- bool nrf_gzll_set_tx_power(nrf_gzll_tx_power_t tx_power);
- nrf_gzll_tx_power_t nrf_gzll_get_tx_power(void);
- bool nrf_gzll_set_datarate(nrf_gzll_datarate_t data_rate);
- nrf_gzll_datarate_t nrf_gzll_get_datarate(void);
- bool nrf_gzll_set_xosc_ctl(nrf_gzll_xosc_ctl_t xosc_ctl);
- nrf_gzll_xosc_ctl_t nrf_gzll_get_xosc_ctl(void);
- void nrf_gzll_set_auto_disable(uint32_t num_ticks);
- bool nrf_gzll_set_pa_lna_cfg(nrf_gzll_pa_lna_cfg_t const * p_pa_lna_cfg);
- uint32_t nrf_gzll_get_tick_count(void);
- void nrf_gzll_clear_tick_count(void);
- nrf_gzll_error_code_t nrf_gzll_get_error_code(void);
- void nrf_gzll_reset_error_code(void);
- }
|