38 #include "drv_digital_out.h" 39 #include "drv_i2c_master.h" 51 #define PWM_MAP_MIKROBUS( cfg, mikrobus ) \ 52 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \ 53 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \ 54 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); 61 #define PWM_MAX_RESOLUTION 4096 68 #define PWM_RETVAL uint8_t 70 #define PWM_INIT_ERROR 0xFF 85 #define PWM_DISABLE 0x00 86 #define PWM_ENABLE 0x01 93 #define PWM_RESTART 0x80 94 #define PWM_EXTCLK 0x40 96 #define PWM_SLEEP 0x10 97 #define PWM_SUB_1 0x08 98 #define PWM_SUB_2 0x04 99 #define PWM_SUB_3 0x02 100 #define PWM_ALL_CALL 0x01 107 #define PWM_INVRT 0x10 109 #define PWM_OUTDRV 0x04 110 #define PWM_OUTNE1 0x02 111 #define PWM_OUTNE0 0x01 118 #define PWM_I2C_ADDRESS 0x40 125 #define PWM_MODE1_REG 0x00 132 #define PWM_MODE2_REG 0x01 139 #define PWM_PRE_SCALE 0xFE 146 #define PWM_TEST 0xFF 153 #define PWM_CH0_ON_L 0x06 154 #define PWM_CH0_ON_H 0x07 155 #define PWM_CH0_OFF_L 0x08 156 #define PWM_CH0_OFF_H 0x09 163 #define PWM_CH1_ON_L 0x0A 164 #define PWM_CH1_ON_H 0x0B 165 #define PWM_CH1_OFF_L 0x0C 166 #define PWM_CH1_OFF_H 0x0D 173 #define PWM_CH2_ON_L 0x0E 174 #define PWM_CH2_ON_H 0x0F 175 #define PWM_CH2_OFF_L 0x10 176 #define PWM_CH2_OFF_H 0x11 183 #define PWM_CH3_ON_L 0x12 184 #define PWM_CH3_ON_H 0x13 185 #define PWM_CH3_OFF_L 0x14 186 #define PWM_CH3_OFF_H 0x15 193 #define PWM_CH4_ON_L 0x16 194 #define PWM_CH4_ON_H 0x17 195 #define PWM_CH4_OFF_L 0x18 196 #define PWM_CH4_OFF_H 0x19 203 #define PWM_CH5_ON_L 0x1A 204 #define PWM_CH5_ON_H 0x1B 205 #define PWM_CH5_OFF_L 0x1C 206 #define PWM_CH5_OFF_H 0x1D 213 #define PWM_CH6_ON_L 0x1E 214 #define PWM_CH6_ON_H 0x1F 215 #define PWM_CH6_OFF_L 0x20 216 #define PWM_CH6_OFF_H 0x21 223 #define PWM_CH7_ON_L 0x22 224 #define PWM_CH7_ON_H 0x23 225 #define PWM_CH7_OFF_L 0x24 226 #define PWM_CH7_OFF_H 0x25 233 #define PWM_CH8_ON_L 0x26 234 #define PWM_CH8_ON_H 0x27 235 #define PWM_CH8_OFF_L 0x28 236 #define PWM_CH8_OFF_H 0x29 243 #define PWM_CH9_ON_L 0x2A 244 #define PWM_CH9_ON_H 0x2B 245 #define PWM_CH9_OFF_L 0x2C 246 #define PWM_CH9_OFF_H 0x2D 253 #define PWM_CH10_ON_L 0x2E 254 #define PWM_CH10_ON_H 0x2F 255 #define PWM_CH10_OFF_L 0x30 256 #define PWM_CH10_OFF_H 0x31 263 #define PWM_CH11_ON_L 0x32 264 #define PWM_CH11_ON_H 0x33 265 #define PWM_CH11_OFF_L 0x34 266 #define PWM_CH11_OFF_H 0x35 273 #define PWM_CH12_ON_L 0x36 274 #define PWM_CH12_ON_H 0x37 275 #define PWM_CH12_OFF_L 0x38 276 #define PWM_CH12_OFF_H 0x39 283 #define PWM_CH13_ON_L 0x3A 284 #define PWM_CH13_ON_H 0x3B 285 #define PWM_CH13_OFF_L 0x3C 286 #define PWM_CH13_OFF_H 0x3D 293 #define PWM_CH14_ON_L 0x3E 294 #define PWM_CH14_ON_H 0x3F 295 #define PWM_CH14_OFF_L 0x40 296 #define PWM_CH14_OFF_H 0x41 303 #define PWM_CH15_ON_L 0x42 304 #define PWM_CH15_ON_H 0x43 305 #define PWM_CH15_OFF_L 0x44 306 #define PWM_CH15_OFF_H 0x45 313 #define PWM_ALL_CH_ON_L 0xFA 314 #define PWM_ALL_CH_ON_H 0xFB 315 #define PWM_ALL_CH_OFF_L 0xFC 316 #define PWM_ALL_CH_OFF_H 0xFD void pwm_dev_config(pwm_t *ctx, uint8_t *config)
Device configuration function.
#define PWM_RETVAL
Definition: pwm.h:68
Click ctx object definition.
Definition: pwm.h:329
uint8_t slave_address
Definition: pwm.h:341
void pwm_set_all_raw(pwm_t *ctx, uint16_t raw_dc)
Set all channels raw function.
uint8_t i2c_address
Definition: pwm.h:362
void pwm_all_chann_state(pwm_t *ctx, uint8_t state)
All channels state function.
PWM_RETVAL pwm_init(pwm_t *ctx, pwm_cfg_t *cfg)
Initialization function.
uint32_t i2c_speed
Definition: pwm.h:361
void pwm_set_output(pwm_t *ctx, uint8_t en_ou)
Output state set function.
void pwm_channel_state(pwm_t *ctx, uint8_t chann_id, uint8_t state)
Channel state function.
void pwm_set_all(pwm_t *ctx, uint8_t duty_cyc)
Set all channels function.
pin_name_t scl
Definition: pwm.h:352
void pwm_output_config(pwm_t *ctx, uint8_t *config1)
Output configuration function.
pin_name_t sda
Definition: pwm.h:353
pin_name_t rst
Definition: pwm.h:357
void pwm_cfg_setup(pwm_cfg_t *cfg)
Config Object Initialization function.
i2c_master_t i2c
Definition: pwm.h:337
void pwm_set_channel_raw(pwm_t *ctx, uint8_t chann_id, uint16_t raw_off_set, uint16_t raw_dc)
Set channel raw function.
Click configuration structure definition.
Definition: pwm.h:348
digital_out_t rst
Definition: pwm.h:333
void pwm_generic_read(pwm_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void pwm_generic_write(pwm_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void pwm_set_pre_scale(pwm_t *ctx, uint8_t pre_scale)
Set pre scale function.