Go to the documentation of this file.
38 #include "mikrosdk_version.h"
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
62 #define RNG_MAP_MIKROBUS( cfg, mikrobus ) \
63 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
64 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
65 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
72 #define RNG_RETVAL uint8_t
75 #define RNG_INIT_ERROR 0xFF
82 #define RNG_DEVICE_SLAVE_ADDRESS_GND 0x48
83 #define RNG_DEVICE_SLAVE_ADDRESS_VDD 0x49
84 #define RNG_DEVICE_SLAVE_ADDRESS_SDA 0x4A
85 #define RNG_DEVICE_SLAVE_ADDRESS_SCL 0x4B
92 #define RNG_RESET_DEVICE 0x06
99 #define RNG_CONVERSION_REG 0x00
100 #define RNG_CONFIG_REG 0x01
101 #define RNG_LO_THRESH_REG 0x02
102 #define RNG_HI_THRESH_REG 0x03
109 #define RNG_CONFIG_REG_COMP_QUEUE_DISABLE 0x0003
110 #define RNG_CONFIG_REG_COMP_QUEUE_4_CONV 0x0002
111 #define RNG_CONFIG_REG_COMP_QUEUE_2_CONV 0x0001
112 #define RNG_CONFIG_REG_COMP_QUEUE_1_CONV 0x0000
113 #define RNG_CONFIG_REG_COMP_LAT_NON 0x0000
114 #define RNG_CONFIG_REG_COMP_LAT 0x0004
115 #define RNG_CONFIG_REG_COMP_POL_LOW 0x0000
116 #define RNG_CONFIG_REG_COMP_POL_HIGH 0x0008
117 #define RNG_CONFIG_REG_COMP_MODE_TRAD 0x0000
118 #define RNG_CONFIG_REG_COMP_MODE_WINDOW 0x0010
119 #define RNG_CONFIG_REG_DATA_RATE_8_SPS 0x0000
120 #define RNG_CONFIG_REG_DATA_RATE_16_SPS 0x0020
121 #define RNG_CONFIG_REG_DATA_RATE_32_SPS 0x0040
122 #define RNG_CONFIG_REG_DATA_RATE_64_SPS 0x0060
123 #define RNG_CONFIG_REG_DATA_RATE_128_SPS 0x0080
124 #define RNG_CONFIG_REG_DATA_RATE_250_SPS 0x00A0
125 #define RNG_CONFIG_REG_DATA_RATE_475_SPS 0x00C0
126 #define RNG_CONFIG_REG_DATA_RATE_860_SPS 0x00E0
127 #define RNG_CONFIG_REG_DEV_MODE_SINGLE 0x0100
128 #define RNG_CONFIG_REG_DEV_MODE_CONTIN 0x0000
129 #define RNG_CONFIG_REG_PGA_6144 0x0000
130 #define RNG_CONFIG_REG_PGA_4096 0x0200
131 #define RNG_CONFIG_REG_PGA_2048 0x0400
132 #define RNG_CONFIG_REG_PGA_1024 0x0600
133 #define RNG_CONFIG_REG_PGA_512 0x0800
134 #define RNG_CONFIG_REG_PGA_256_1 0x0A00
135 #define RNG_CONFIG_REG_PGA_256_2 0x0C00
136 #define RNG_CONFIG_REG_PGA_256_3 0x0E00
137 #define RNG_CONFIG_REG_MUX_AINP_AINN_0_1 0x0000
138 #define RNG_CONFIG_REG_MUX_AINP_AINN_0_3 0x1000
139 #define RNG_CONFIG_REG_MUX_AINP_AINN_1_3 0x2000
140 #define RNG_CONFIG_REG_MUX_AINP_AINN_2_3 0x3000
141 #define RNG_CONFIG_REG_MUX_AINP_AINN_0_GND 0x4000
142 #define RNG_CONFIG_REG_MUX_AINP_AINN_1_GND 0x5000
143 #define RNG_CONFIG_REG_MUX_AINP_AINN_2_GND 0x6000
144 #define RNG_CONFIG_REG_MUX_AINP_AINN_3_GND 0x7000
145 #define RNG_CONFIG_REG_OS_SINGLE_CONV 0x8000
146 #define RNG_CONFIG_REG_OS_NO_EFFECT 0x0000
153 #define RNG_REG_LOWTHRES_HOLD 0x8000
154 #define RNG_REG_HIGH_THRESH_HOLD 0x7FFF
pin_name_t int_pin
Definition: rng.h:199
void rng_set_threshold(rng_t *ctx, uint8_t thresh_reg, uint16_t thresh_data)
Function used for set threshold values.
uint16_t dev_vref_cfg
Definition: rng.h:206
void rng_reset_device(rng_t *ctx)
Function used for reset device.
pin_name_t sda
Definition: rng.h:195
void rng_set_config(rng_t *ctx, uint16_t conf_data)
Function used for set configuration.
float rng_get_voltage(rng_t *ctx)
Function used for get voltage.
void rng_default_cfg(rng_t *ctx)
Click Default Configuration function.
pin_name_t scl
Definition: rng.h:194
uint16_t dev_vref
Definition: rng.h:183
uint8_t slave_address
Definition: rng.h:179
uint16_t rng_read_function(rng_t *ctx, uint8_t reg)
Read function.
RNG_RETVAL rng_init(rng_t *ctx, rng_cfg_t *cfg)
Initialization function.
i2c_master_t i2c
Definition: rng.h:175
Click configuration structure definition.
Definition: rng.h:191
uint8_t i2c_address
Definition: rng.h:204
Click ctx object definition.
Definition: rng.h:168
void rng_set_vref(rng_t *ctx, uint16_t vref_mv)
Function used for set vref in millivolts.
digital_in_t int_pin
Definition: rng.h:171
uint32_t i2c_speed
Definition: rng.h:203
void rng_write_function(rng_t *ctx, uint8_t reg, uint16_t reg_data)
Write function.
void rng_cfg_setup(rng_cfg_t *cfg)
Config Object Initialization function.
#define RNG_RETVAL
Definition: rng.h:72