42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
55#include "drv_spi_master.h"
67#define PWM2_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.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM )
79#define PWM2_RETVAL uint8_t
82#define PWM2_INIT_ERROR 0xFF
89#define PWM2_DEF_FREQ 20000
96#define PWM2_CLOCK_25_MHZ 25000000
97#define PWM2_CLOCK_15_MHZ 15000000
98#define PWM2_CLOCK_5_MHZ 5000000
105#define PWM2_100_PERCENT_DUTY 4095
106#define PWM2_75_PERCENT_DUTY 3072
107#define PWM2_50_PERCENT_DUTY 2048
108#define PWM2_25_PERCENT_DUTY 1024
115#define PWM2_NO_CORRECTION 0
259 static void send_reset_pulse (
pwm2_t *ctx );
268static void send_pulse (
pwm2_t *ctx );
277static void send_frame_buffer (
pwm2_t *ctx );
286static void send_async_update_frame (
pwm2_t *ctx );
295static void send_correction_frame (
pwm2_t *ctx );
304static void send_output_enable_frame (
pwm2_t *ctx );
313static void send_correction_toggle_frame (
pwm2_t *ctx );
322static void set_parameters (
pwm2_t *ctx );
#define PWM2_RETVAL
Definition pwm2.h:79
void pwm2_set_duty_cycle(pwm2_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
void pwm2_toggle_phase_shift(pwm2_t *ctx)
Toggle phase shift.
uint8_t pwm2_set_channel(pwm2_t *ctx, uint8_t n_channel, uint16_t width, uint8_t correction)
Set channel function.
void pwm2_cfg_setup(pwm2_cfg_t *cfg)
Config Object Initialization function.
PWM2_RETVAL pwm2_init(pwm2_t *ctx, pwm2_cfg_t *cfg)
Initialization function.
void pwm2_default_cfg(pwm2_t *ctx)
Click Default Configuration function.
void pwm2_pwm_start(pwm2_t *ctx)
Start PWM module.
void pwm2_pwm_stop(pwm2_t *ctx)
Stop PWM module.
void pwm2_generic_transfer(pwm2_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
Click configuration structure definition.
Definition pwm2.h:160
spi_master_chip_select_polarity_t cs_polarity
Definition pwm2.h:174
pin_name_t sck
Definition pwm2.h:164
spi_master_mode_t spi_mode
Definition pwm2.h:173
pin_name_t mosi
Definition pwm2.h:163
uint32_t spi_speed
Definition pwm2.h:172
uint32_t dev_pwm_freq
Definition pwm2.h:175
pin_name_t pwm
Definition pwm2.h:166
pin_name_t miso
Definition pwm2.h:162
pin_name_t cs
Definition pwm2.h:165
Click ctx object definition.
Definition pwm2.h:129
digital_out_t cs
Definition pwm2.h:133
spi_master_t spi
Definition pwm2.h:139
uint32_t pwm_freq
Definition pwm2.h:145
pin_name_t chip_select
Definition pwm2.h:140
pwm_t pwm
Definition pwm2.h:141
uint8_t correction
Definition pwm2.h:152
uint16_t width
Definition pwm2.h:151