42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_spi_master.h"
67#define CCRF_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.gd0 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
73 cfg.gd2 = MIKROBUS( mikrobus, MIKROBUS_PWM )
85#define CCRF_IOCFG2 0x00
86#define CCRF_IOCFG1 0x01
87#define CCRF_IOCFG0 0x02
88#define CCRF_FIFOTHR 0x03
89#define CCRF_SYNC1 0x04
90#define CCRF_SYNC0 0x05
91#define CCRF_PKTLEN 0x06
92#define CCRF_PKTCTRL1 0x07
93#define CCRF_PKTCTRL0 0x08
95#define CCRF_CHANNR 0x0A
96#define CCRF_FSCTRL1 0x0B
97#define CCRF_FSCTRL0 0x0C
98#define CCRF_FREQ2 0x0D
99#define CCRF_FREQ1 0x0E
100#define CCRF_FREQ0 0x0F
101#define CCRF_MDMCFG4 0x10
102#define CCRF_MDMCFG3 0x11
103#define CCRF_MDMCFG2 0x12
104#define CCRF_MDMCFG1 0x13
105#define CCRF_MDMCFG0 0x14
106#define CCRF_DEVIATN 0x15
107#define CCRF_MCSM2 0x16
108#define CCRF_MCSM1 0x17
109#define CCRF_MCSM0 0x18
110#define CCRF_FOCCFG 0x19
111#define CCRF_BSCFG 0x1A
112#define CCRF_AGCCTRL2 0x1B
113#define CCRF_AGCCTRL1 0x1C
114#define CCRF_AGCCTRL0 0x1D
115#define CCRF_WOREVT1 0x1E
116#define CCRF_WOREVT0 0x1F
117#define CCRF_WORCTRL 0x20
118#define CCRF_FREND1 0x21
119#define CCRF_FREND0 0x22
120#define CCRF_FSCAL3 0x23
121#define CCRF_FSCAL2 0x24
122#define CCRF_FSCAL1 0x25
123#define CCRF_FSCAL0 0x26
124#define CCRF_RCCTRL1 0x27
125#define CCRF_RCCTRL0 0x28
126#define CCRF_FSTEST 0x29
127#define CCRF_PTEST 0x2A
128#define CCRF_AGCTEST 0x2B
129#define CCRF_TEST2 0x2C
130#define CCRF_TEST1 0x2D
131#define CCRF_TEST0 0x2E
134#define CCRF_SRES 0x30
135#define CCRF_SFSTXON 0x31
136#define CCRF_SXOFF 0x32
137#define CCRF_SCAL 0x33
140#define CCRF_SIDLE 0x36
141#define CCRF_SAFC 0x37
142#define CCRF_SWOR 0x38
143#define CCRF_SPWD 0x39
144#define CCRF_SFRX 0x3A
145#define CCRF_SFTX 0x3B
146#define CCRF_SWORRST 0x3C
147#define CCRF_SNOP 0x3D
150#define CCRF_PARTNUM 0x30
151#define CCRF_VERSION 0x31
152#define CCRF_FREQEST 0x32
154#define CCRF_RSSI 0x34
155#define CCRF_MARCSTATE 0x35
156#define CCRF_WORTIME1 0x36
157#define CCRF_WORTIME0 0x37
158#define CCRF_PKTSTATUS 0x38
159#define CCRF_VCO_VC_DAC 0x39
160#define CCRF_TXBYTES 0x3A
161#define CCRF_RXBYTES 0x3B
162#define CCRF_RCCTRL1_STATUS 0x3C
163#define CCRF_RCCTRL0_STATUS 0x3D
164#define CCRF_NUM_RXBYTES 0x7F
167#define CCRF_PATABLE 0x3E
168#define CCRF_TXFIFO 0x3F
169#define CCRF_RXFIFO 0x3F
172#define CCRF_LQI_RX 0x01
173#define CCRF_CRC_OK 0x80
176#define CCRF_WRITE_BURST 0x40
177#define CCRF_READ_SINGLE 0x80
178#define CCRF_READ_BURST 0xC0
180#define CCRF_RECEIVE_CRC_ERROR 0x00
181#define CCRF_RECEIVE_CRC_OK 0x80
182#define CCRF_BURST_IN_RXFIFO 0x7F
184#define CCRF_SINGLE_TXFIFO 0x3F
185#define CCRF_BURST_TXFIFO 0x7F
186#define CCRF_SINGLE_RXFIFO 0xBF
187#define CCRF_BURST_RXFIFO 0xFF
189#define CCRF_TX_MODE 0
190#define CCRF_RX_MODE 1
191#define CCRF_IDLE_MODE 2
uint8_t ccrf_get_mrc_state(ccrf_t *ctx)
Get main radio control state machine state function.
void ccrf_set_frequency_offset(ccrf_t *ctx, uint8_t freq_offset)
Set frequency offset function.
void ccrf_disable_fec(ccrf_t *ctx)
Disable forward error correction function.
void ccrf_cfg_setup(ccrf_cfg_t *cfg)
Config Object Initialization function.
void ccrf_set_bit_sync_config(ccrf_t *ctx, uint8_t bs_config)
Set bit synchronization configuration function.
void ccrf_enable_manchester_encoding(ccrf_t *ctx)
Enable Manchester encoding function.
void ccrf_read_bytes(ccrf_t *ctx, uint8_t reg_address, uint8_t *read_data, uint8_t n_bytes)
Sequential read function.
void ccrf_set_gd2_active_low(ccrf_t *ctx)
GD2 select active low function.
void ccrf_set_lna_gain(ccrf_t *ctx, uint8_t lna_gain)
Set the maximum allowable LNA gain function.
uint8_t ccrf_receive_packet(ccrf_t *ctx, uint8_t *rx_buffer, uint8_t *length_buff)
Receive packet data function.
uint8_t ccrf_get_rc_osc_cal_result(ccrf_t *ctx)
Get RC oscillator calibration result function.
uint8_t ccrf_get_gd0_and_packet_state(ccrf_t *ctx)
Get current GDO status and packet status function.
uint8_t ccrf_get_chip_version_number(ccrf_t *ctx)
Get chip version number function.
void ccrf_enable_osc_rc(ccrf_t *ctx)
Enable the RC oscillator calibration function.
void ccrf_disable_osc_rc(ccrf_t *ctx)
Disables the RC oscillator calibration function.
void ccrf_set_auto_initial_calibration(ccrf_t *ctx)
Set automatic initial calibration function.
void ccrf_enable_fec(ccrf_t *ctx)
Enable forward error correction function.
void ccrf_enable_temperature_sensor(ccrf_t *ctx)
Enable analog temperature sensor function.
void ccrf_set_num_ch_filter(ccrf_t *ctx, uint8_t num_ch_filter)
Set the number of channel filter samples function.
void ccrf_set_max_length_packets(ccrf_t *ctx, uint8_t max_length)
Set maximum length packets allowed function.
void ccrf_format_rx_tx_data(ccrf_t *ctx, uint8_t rx_tx_data_format)
Set format of RX and TX data function.
void ccrf_default_cfg(ccrf_t *ctx)
Click Default Configuration function.
void ccrf_set_channel_number(ccrf_t *ctx, uint8_t ch_num)
Set channel number function.
void ccrf_set_gd0_active_high(ccrf_t *ctx)
GD0 select active high function.
void ccrf_disable_manchester_encoding(ccrf_t *ctx)
Disable Manchester encoding function.
void ccrf_set_state_packet_sent(ccrf_t *ctx, uint8_t ps_state)
Set state when a packet has been sent function.
void ccrf_set_dvga_gain(ccrf_t *ctx, uint8_t dvga_gain)
Set the maximum allowable DVGA gain function.
void ccrf_set_gd0_active_low(ccrf_t *ctx)
GD0 select active low function.
void ccrf_transmit_packet(ccrf_t *ctx, uint8_t *tx_buffer, uint8_t n_bytes)
Transmit packet data function.
void ccrf_write_strobe(ccrf_t *ctx, uint8_t strobe)
Write a strobe command function.
void ccrf_set_amplitude_ch_filter(ccrf_t *ctx, uint8_t ach_filter)
Set the target amplitude from channel filter function.
uint8_t ccrf_get_start(ccrf_t *ctx)
Get state of GD0 pin function.
void ccrf_set_state_packet_recived(ccrf_t *ctx, uint8_t pr_state)
Set state after finishing packet reception function.
void ccrf_set_cca_mode(ccrf_t *ctx, uint8_t cca_mode)
Set CCA mode function.
void ccrf_turn_data_whitening_off(ccrf_t *ctx)
Turn data whitening off function.
void ccrf_set_timeout_reg_block(ccrf_t *ctx, uint8_t timeout)
Set the averaging length for the amplitude from the channel filter function.
void ccrf_set_absolute_rssi_threshold(ccrf_t *ctx, uint8_t rssi_threshold)
Set the rabsolute RSSI threshold for asserting carrier sense function.
void ccrf_set_freq_loop_gain_as(ccrf_t *ctx, uint8_t fcl_gain)
Set frequency compensation loop gain after a sync function.
err_t ccrf_init(ccrf_t *ctx, ccrf_cfg_t *cfg)
Initialization function.
void ccrf_write_byte(ccrf_t *ctx, uint8_t reg_address, uint8_t write_data)
Write the byte of data to the 8-bit register address function.
void ccrf_set_agc_gain(ccrf_t *ctx, uint8_t agc_gain)
Set the AGC gain function.
void ccrf_set_if_frequency(ccrf_t *ctx, uint8_t if_freq)
Set desired IF frequency function.
void ccrf_sw_reset(ccrf_t *ctx)
Softwere reset function.
void ccrf_enable_dc_blocking_filter(ccrf_t *ctx)
Enable digital DC blocking filter function.
void ccrf_set_lna_strategies(ccrf_t *ctx, uint8_t lna_strat)
Set the LNA strategies function.
uint8_t ccrf_get_rssi(ccrf_t *ctx)
Get received signal strength indication function.
void ccrf_disable_dc_blocking_filter(ccrf_t *ctx)
Disable digital DC blocking filter function.
uint8_t ccrf_get_chip_part_number(ccrf_t *ctx)
Get chip part number function.
void ccrf_set_hysteresis_lvl(ccrf_t *ctx, uint8_t hyst_lvl)
Set the level of hysteresis on the magnitude deviation function.
uint8_t ccrf_transmit_packet_with_address(ccrf_t *ctx, uint8_t *tx_buffer, uint8_t n_bytes, uint8_t *attempts)
Transmit packet data with address function.
void ccrf_set_gd2_active_high(ccrf_t *ctx)
GD2 select active high function.
uint8_t ccrf_get_rx_fifo_num_bytes(ccrf_t *ctx)
Get number of bytes in RX FIFO function.
void ccrf_disable_temperature_sensor(ccrf_t *ctx)
Disable analog temperature sensor function.
void ccrf_set_min_num_preamble(ccrf_t *ctx, uint8_t p_num)
Set the minimum number of preamble bytes to be transmitted function.
void ccrf_set_modulation(ccrf_t *ctx, uint8_t rf_modulation)
Set the modulation format of the radio signal function.
void ccrf_set_avr_len_ampitude(ccrf_t *ctx, uint8_t al_amp)
Set the averaging length for the amplitude from the channel filter function.
void ccrf_set_sync_word_qualifier_mode(ccrf_t *ctx, uint8_t q_mode)
Set sync-word qualifier mode function.
uint8_t ccrf_read_byte_status(ccrf_t *ctx, uint8_t reg_address)
Read the byte of data from the 8-bit status register address function.
void ccrf_set_timeout_wor(ccrf_t *ctx, uint8_t timeout)
Set the maximum timeout of the WOR module function.
void ccrf_set_fifo_threshold(ccrf_t *ctx, uint8_t threshold_rx_tx)
Set the threshold for the TX FIFO and RX FIFO function.
void ccrf_hw_reset(ccrf_t *ctx)
Hardware reset function.
uint8_t ccrf_get_underflow_rx_fifo(ccrf_t *ctx)
Get underflow RX FIFO status function.
void ccrf_write_bytes(ccrf_t *ctx, uint8_t reg_address, uint8_t *write_data, uint8_t n_bytes)
Sequential write function.
void ccrf_turn_data_whitening_on(ccrf_t *ctx)
Turn data whitening on function.
void ccrf_set_auto_calibrate_mode(ccrf_t *ctx, uint8_t ac_mode)
Set automatically calibrate function.
void ccrf_set_device_address(ccrf_t *ctx, uint8_t dev_addr)
Set device address function.
void ccrf_set_relative_rssi_threshold(ccrf_t *ctx, uint8_t rssi_threshold)
Set the relative change threshold for asserting carrier sense function.
void ccrf_set_freq_loop_gain_bs(ccrf_t *ctx, uint8_t fcl_gain)
Set frequency compensation loop gain before a sync function.
uint8_t ccrf_read_byte(ccrf_t *ctx, uint8_t reg_address)
Read the byte of data from the 8-bit register address function.
Click configuration structure definition.
Definition ccrf.h:221
spi_master_chip_select_polarity_t cs_polarity
Definition ccrf.h:235
pin_name_t sck
Definition ccrf.h:225
pin_name_t gd2
Definition ccrf.h:230
spi_master_mode_t spi_mode
Definition ccrf.h:234
pin_name_t mosi
Definition ccrf.h:224
uint32_t spi_speed
Definition ccrf.h:233
pin_name_t miso
Definition ccrf.h:223
pin_name_t gd0
Definition ccrf.h:229
pin_name_t cs
Definition ccrf.h:226
Click ctx object definition.
Definition ccrf.h:204
spi_master_t spi
Definition ccrf.h:212
digital_in_t gd0
Definition ccrf.h:209
digital_out_t gd2
Definition ccrf.h:206
pin_name_t chip_select
Definition ccrf.h:213