39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52#include "drv_spi_master.h"
75#define CLOCKGEN4_REG_DEV_ID 0x01
76#define CLOCKGEN4_REG_DEV_CTL 0x02
77#define CLOCKGEN4_REG_DEV_CFG_1 0x03
78#define CLOCKGEN4_REG_GLOB_CFG 0x05
79#define CLOCKGEN4_REG_M_MSB 0x06
80#define CLOCKGEN4_REG_L_MSB 0x07
81#define CLOCKGEN4_REG_M_LSB 0x08
82#define CLOCKGEN4_REG_L_LSB 0x09
83#define CLOCKGEN4_REG_FNC_CFG_1 0x16
84#define CLOCKGEN4_REG_FNC_CFG_2 0x17
107#define CLOCKGEN4_INCR_ENABLE 0x80
108#define CLOCKGEN4_INCR_DISABLE 0x00
114#define CLOCKGEN4_PLL_UNLOCKED 0x00
115#define CLOCKGEN4_PLL_LOCKED 0x80
116#define CLOCKGEN4_AUX_OUT_EN 0x00
117#define CLOCKGEN4_AUX_OUT_DIS 0x02
118#define CLOCKGEN4_CLK_OUT_EN 0x00
119#define CLOCKGEN4_CLK_OUT_DIS 0x01
125#define CLOCKGEN4_R_MOD_SEL_L_0 0x00
126#define CLOCKGEN4_R_MOD_SEL_L_1 0x20
127#define CLOCKGEN4_R_MOD_SEL_L_2 0x40
128#define CLOCKGEN4_R_MOD_SEL_L_3 0x60
129#define CLOCKGEN4_R_MOD_SEL_R_1 0x80
130#define CLOCKGEN4_R_MOD_SEL_R_2 0xA0
131#define CLOCKGEN4_R_MOD_SEL_R_3 0xC0
132#define CLOCKGEN4_R_MOD_SEL_R_4 0xE0
133#define CLOCKGEN4_REG_CLK 0x00
134#define CLOCKGEN4_CLK_OUT 0x04
135#define CLOCKGEN4_PLL_STAT_IND 0x06
136#define CLOCKGEN4_DEV_CFG_1_EN 0x01
137#define CLOCKGEN4_DEV_CFG_1_DIS 0x00
143#define CLOCKGEN4_DEV_CFG_FRZ 0x00
144#define CLOCKGEN4_DEV_CFG_UNFRZ 0x08
145#define CLOCKGEN4_DEV_CFG_2_EN 0x01
146#define CLOCKGEN4_DEV_CFG_2_DIS 0x00
152#define CLOCKGEN4_AUX_OUT_ACT_H 0x00
153#define CLOCKGEN4_AUX_OUT_ACT_L 0x40
154#define CLOCKGEN4_REF_CLK_DIV_4 0x00
155#define CLOCKGEN4_REF_CLK_DIV_2 0x08
156#define CLOCKGEN4_REF_CLK_DIV_1 0x10
162#define CLOCKGEN4_CLK_OUT_UNL_L 0x00
163#define CLOCKGEN4_CLK_OUT_UNL_U 0x10
169#define CLOCKGEN4_REF_CLK_25_MHZ 25.0
176#define CLOCKGEN4_I2C_ADR_GND 0x4E
177#define CLOCKGEN4_I2C_ADR_VCC 0x4F
179#define CLOCKGEN4_SPI_CHIP_ADR 0x9E
188#define CLOCKGEN4_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
189#define CLOCKGEN4_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
206#define CLOCKGEN4_MAP_MIKROBUS( cfg, mikrobus ) \
207 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
208 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
209 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
210 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
211 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
212 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
clockgen4_return_value_t
Clock Gen 4 Click return value data.
Definition clockgen4.h:281
@ CLOCKGEN4_ERROR
Definition clockgen4.h:283
@ CLOCKGEN4_OK
Definition clockgen4.h:282
clockgen4_drv_t
Clock Gen 4 Click driver selector.
Definition clockgen4.h:222
@ CLOCKGEN4_DRV_SEL_SPI
Definition clockgen4.h:223
@ CLOCKGEN4_DRV_SEL_I2C
Definition clockgen4.h:224
struct clockgen4_s clockgen4_t
Clock Gen 4 Click context object.
err_t(* clockgen4_master_io_t)(struct clockgen4_s *, uint8_t, uint8_t *, uint8_t)
Clock Gen 4 Click driver interface.
Definition clockgen4.h:232
uint32_t clockgen4_set_ratio(clockgen4_t *ctx, float ratio)
Clock Gen 4 set ratio function.
void clockgen4_dev_ctl(clockgen4_t *ctx, uint8_t dev_ctl)
Clock Gen 4 device control function.
void clockgen4_glob_cfg(clockgen4_t *ctx, uint8_t glob_cfg)
Clock Gen 4 global configuration function.
err_t clockgen4_default_cfg(clockgen4_t *ctx)
Clock Gen 4 default configuration function.
void clockgen4_cfg_setup(clockgen4_cfg_t *cfg)
Clock Gen 4 configuration object setup function.
void clockgen4_fnc_cfg_1(clockgen4_t *ctx, uint8_t fnc_cfg)
Clock Gen 4 configuration 1 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.
err_t clockgen4_init(clockgen4_t *ctx, clockgen4_cfg_t *cfg)
Clock Gen 4 initialization function.
void clockgen4_drv_interface_selection(clockgen4_cfg_t *cfg, clockgen4_drv_t drv_sel)
Clock Gen 4 driver interface setup function.
err_t clockgen4_generic_write(clockgen4_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Clock Gen 4 data writing function.
void clockgen4_fnc_cfg_2(clockgen4_t *ctx, uint8_t fnc_cfg)
Clock Gen 4 configuration 2 function.
This file contains SPI specific macros, functions, etc.
Clock Gen 4 Click configuration object.
Definition clockgen4.h:257
uint32_t i2c_speed
Definition clockgen4.h:265
spi_master_chip_select_polarity_t cs_polarity
Definition clockgen4.h:270
pin_name_t sck
Definition clockgen4.h:262
spi_master_mode_t spi_mode
Definition clockgen4.h:269
pin_name_t mosi
Definition clockgen4.h:261
uint32_t spi_speed
Definition clockgen4.h:268
clockgen4_drv_t drv_sel
Definition clockgen4.h:272
pin_name_t scl
Definition clockgen4.h:258
pin_name_t miso
Definition clockgen4.h:260
pin_name_t sda
Definition clockgen4.h:259
pin_name_t cs
Definition clockgen4.h:263
uint8_t i2c_address
Definition clockgen4.h:266
Clock Gen 4 Click context object.
Definition clockgen4.h:239
spi_master_t spi
Definition clockgen4.h:241
clockgen4_master_io_t write_f
Definition clockgen4.h:247
clockgen4_master_io_t read_f
Definition clockgen4.h:248
i2c_master_t i2c
Definition clockgen4.h:240
clockgen4_drv_t drv_sel
Definition clockgen4.h:245
uint8_t slave_address
Definition clockgen4.h:243
pin_name_t chip_select
Definition clockgen4.h:244