Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 #include "drv_spi_master.h"
71 #define CLOCKGEN4_REG_DEV_ID 0x01
72 #define CLOCKGEN4_REG_DEV_CTL 0x02
73 #define CLOCKGEN4_REG_DEV_CFG_1 0x03
74 #define CLOCKGEN4_REG_GLOB_CFG 0x05
75 #define CLOCKGEN4_REG_M_MSB 0x06
76 #define CLOCKGEN4_REG_L_MSB 0x07
77 #define CLOCKGEN4_REG_M_LSB 0x08
78 #define CLOCKGEN4_REG_L_LSB 0x09
79 #define CLOCKGEN4_REG_FNC_CFG_1 0x16
80 #define CLOCKGEN4_REG_FNC_CFG_2 0x17
103 #define CLOCKGEN4_INCR_ENABLE 0x80
104 #define CLOCKGEN4_INCR_DISABLE 0x00
110 #define CLOCKGEN4_PLL_UNLOCKED 0x00
111 #define CLOCKGEN4_PLL_LOCKED 0x80
112 #define CLOCKGEN4_AUX_OUT_EN 0x00
113 #define CLOCKGEN4_AUX_OUT_DIS 0x02
114 #define CLOCKGEN4_CLK_OUT_EN 0x00
115 #define CLOCKGEN4_CLK_OUT_DIS 0x01
121 #define CLOCKGEN4_R_MOD_SEL_L_0 0x00
122 #define CLOCKGEN4_R_MOD_SEL_L_1 0x20
123 #define CLOCKGEN4_R_MOD_SEL_L_2 0x40
124 #define CLOCKGEN4_R_MOD_SEL_L_3 0x60
125 #define CLOCKGEN4_R_MOD_SEL_R_1 0x80
126 #define CLOCKGEN4_R_MOD_SEL_R_2 0xA0
127 #define CLOCKGEN4_R_MOD_SEL_R_3 0xC0
128 #define CLOCKGEN4_R_MOD_SEL_R_4 0xE0
129 #define CLOCKGEN4_REG_CLK 0x00
130 #define CLOCKGEN4_CLK_OUT 0x04
131 #define CLOCKGEN4_PLL_STAT_IND 0x06
132 #define CLOCKGEN4_DEV_CFG_1_EN 0x01
133 #define CLOCKGEN4_DEV_CFG_1_DIS 0x00
139 #define CLOCKGEN4_DEV_CFG_FRZ 0x00
140 #define CLOCKGEN4_DEV_CFG_UNFRZ 0x08
141 #define CLOCKGEN4_DEV_CFG_2_EN 0x01
142 #define CLOCKGEN4_DEV_CFG_2_DIS 0x00
148 #define CLOCKGEN4_AUX_OUT_ACT_H 0x00
149 #define CLOCKGEN4_AUX_OUT_ACT_L 0x40
150 #define CLOCKGEN4_REF_CLK_DIV_4 0x00
151 #define CLOCKGEN4_REF_CLK_DIV_2 0x08
152 #define CLOCKGEN4_REF_CLK_DIV_1 0x10
158 #define CLOCKGEN4_CLK_OUT_UNL_L 0x00
159 #define CLOCKGEN4_CLK_OUT_UNL_U 0x10
165 #define CLOCKGEN4_REF_CLK_25_MHZ 25.0
172 #define CLOCKGEN4_I2C_ADR_GND 0x4E
173 #define CLOCKGEN4_I2C_ADR_VCC 0x4F
175 #define CLOCKGEN4_SPI_CHIP_ADR 0x9E
184 #define CLOCKGEN4_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
185 #define CLOCKGEN4_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
202 #define CLOCKGEN4_MAP_MIKROBUS( cfg, mikrobus ) \
203 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
204 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
205 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
206 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
207 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
208 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
462 #endif // CLOCKGEN4_H
uint8_t slave_address
Definition: clockgen4.h:239
void clockgen4_fnc_cfg_1(clockgen4_t *ctx, uint8_t fnc_cfg)
Clock Gen 4 configuration 1 function.
uint32_t clockgen4_set_ratio(clockgen4_t *ctx, float ratio)
Clock Gen 4 set ratio function.
void clockgen4_cfg_setup(clockgen4_cfg_t *cfg)
Clock Gen 4 configuration object setup function.
Clock Gen 4 Click context object.
Definition: clockgen4.h:235
This file contains SPI specific macros, functions, etc.
@ CLOCKGEN4_DRV_SEL_SPI
Definition: clockgen4.h:219
pin_name_t scl
Definition: clockgen4.h:254
void clockgen4_drv_interface_selection(clockgen4_cfg_t *cfg, clockgen4_drv_t drv_sel)
Clock Gen 4 driver interface setup function.
clockgen4_drv_t
Clock Gen 4 Click driver selector.
Definition: clockgen4.h:218
clockgen4_drv_t drv_sel
Definition: clockgen4.h:268
spi_master_t spi
Definition: clockgen4.h:237
pin_name_t mosi
Definition: clockgen4.h:257
void clockgen4_dev_ctl(clockgen4_t *ctx, uint8_t dev_ctl)
Clock Gen 4 device control function.
clockgen4_master_io_t read_f
Definition: clockgen4.h:244
i2c_master_t i2c
Definition: clockgen4.h:236
struct clockgen4_s clockgen4_t
Clock Gen 4 Click context object.
spi_master_mode_t spi_mode
Definition: clockgen4.h:265
spi_master_chip_select_polarity_t cs_polarity
Definition: clockgen4.h:266
uint32_t i2c_speed
Definition: clockgen4.h:261
pin_name_t chip_select
Definition: clockgen4.h:240
pin_name_t cs
Definition: clockgen4.h:259
err_t clockgen4_init(clockgen4_t *ctx, clockgen4_cfg_t *cfg)
Clock Gen 4 initialization function.
uint8_t i2c_address
Definition: clockgen4.h:262
clockgen4_return_value_t
Clock Gen 4 Click return value data.
Definition: clockgen4.h:277
pin_name_t sda
Definition: clockgen4.h:255
@ CLOCKGEN4_OK
Definition: clockgen4.h:278
@ CLOCKGEN4_DRV_SEL_I2C
Definition: clockgen4.h:220
void clockgen4_glob_cfg(clockgen4_t *ctx, uint8_t glob_cfg)
Clock Gen 4 global configuration function.
err_t clockgen4_generic_read(clockgen4_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Clock Gen 4 data reading function.
void clockgen4_dev_cfg(clockgen4_t *ctx, uint8_t dev_cfg)
Clock Gen 4 device configuration function.
pin_name_t sck
Definition: clockgen4.h:258
clockgen4_master_io_t write_f
Definition: clockgen4.h:243
uint32_t spi_speed
Definition: clockgen4.h:264
@ CLOCKGEN4_ERROR
Definition: clockgen4.h:279
pin_name_t miso
Definition: clockgen4.h:256
err_t(* clockgen4_master_io_t)(struct clockgen4_s *, uint8_t, uint8_t *, uint8_t)
Clock Gen 4 Click driver interface.
Definition: clockgen4.h:228
err_t clockgen4_generic_write(clockgen4_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Clock Gen 4 data writing function.
clockgen4_drv_t drv_sel
Definition: clockgen4.h:241
Clock Gen 4 Click configuration object.
Definition: clockgen4.h:253
err_t clockgen4_default_cfg(clockgen4_t *ctx)
Clock Gen 4 default configuration function.
void clockgen4_fnc_cfg_2(clockgen4_t *ctx, uint8_t fnc_cfg)
Clock Gen 4 configuration 2 function.