Zephyr API Documentation 4.4.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Files

file  max2221x.h
 Public API for MAX2221X PWM driver.

Enumerations

enum  max2221x_master_chop_freq {
  MAX2221X_FREQ_100KHZ = 0 , MAX2221X_FREQ_80KHZ , MAX2221X_FREQ_60KHZ , MAX2221X_FREQ_50KHZ ,
  MAX2221X_FREQ_40KHZ , MAX2221X_FREQ_30KHZ , MAX2221X_FREQ_25KHZ , MAX2221X_FREQ_20KHZ ,
  MAX2221X_FREQ_15KHZ , MAX2221X_FREQ_10KHZ , MAX2221X_FREQ_7500HZ , MAX2221X_FREQ_5000HZ ,
  MAX2221X_FREQ_2500HZ , MAX2221X_FREQ_INVALID
}
 Master chopping frequency options. More...
enum  max2221x_individual_chop_freq {
  MAX2221X_FREQ_M = 0 , MAX2221X_FREQ_M_2 , MAX2221X_FREQ_M_4 , MAX2221X_FREQ_M_8 ,
  MAX2221X_FREQ_M_INVALID
}
 Individual channel chopping frequency divisor options. More...

Functions

int max2221x_get_master_chop_freq (const struct device *dev)
 Get the master chop frequency of the MAX2221X device.
int max2221x_get_channel_freq (const struct device *dev, uint32_t channel, uint32_t *channel_freq)
 Get the individual channel frequency of the MAX2221X device.
int max2221x_calculate_duty_cycle (uint32_t pulse, uint32_t period, uint16_t *duty_cycle)
 Calculate the duty cycle.
int max2221x_calculate_master_freq_divisor (uint32_t master_freq, uint32_t period, int *freq_divisor)
 Calculate the master frequency divisor used for calculating individual frequency.
int max2221x_get_cycles_per_sec (const struct device *dev, uint32_t channel, uint64_t *cycles)
 Get the cycles per second for the pwm channel.
int max2221x_set_cycles (const struct device *dev, uint32_t channel, uint32_t period, uint32_t pulse, pwm_flags_t flags)
 Set the duty cycle for the pwm channel.

Detailed Description

Enumeration Type Documentation

◆ max2221x_individual_chop_freq

#include <zephyr/drivers/pwm/max2221x.h>

Individual channel chopping frequency divisor options.

Enumerator
MAX2221X_FREQ_M 

Master frequency (no division).

MAX2221X_FREQ_M_2 

Master frequency divided by 2.

MAX2221X_FREQ_M_4 

Master frequency divided by 4.

MAX2221X_FREQ_M_8 

Master frequency divided by 8.

MAX2221X_FREQ_M_INVALID 

Invalid frequency divisor sentinel.

◆ max2221x_master_chop_freq

#include <zephyr/drivers/pwm/max2221x.h>

Master chopping frequency options.

Enumerator
MAX2221X_FREQ_100KHZ 

100 kHz

MAX2221X_FREQ_80KHZ 

80 kHz

MAX2221X_FREQ_60KHZ 

60 kHz

MAX2221X_FREQ_50KHZ 

50 kHz

MAX2221X_FREQ_40KHZ 

40 kHz

MAX2221X_FREQ_30KHZ 

30 kHz

MAX2221X_FREQ_25KHZ 

25 kHz

MAX2221X_FREQ_20KHZ 

20 kHz

MAX2221X_FREQ_15KHZ 

15 kHz

MAX2221X_FREQ_10KHZ 

10 kHz

MAX2221X_FREQ_7500HZ 

7.5 kHz

MAX2221X_FREQ_5000HZ 

5 kHz

MAX2221X_FREQ_2500HZ 

2.5 kHz

MAX2221X_FREQ_INVALID 

Invalid frequency sentinel.

Function Documentation

◆ max2221x_calculate_duty_cycle()

int max2221x_calculate_duty_cycle ( uint32_t pulse,
uint32_t period,
uint16_t * duty_cycle )

#include <zephyr/drivers/pwm/max2221x.h>

Calculate the duty cycle.

Parameters
pulsePulse width (in microseconds) set to the PWM. HW specific.
periodPeriod (in microseconds) set to the PWM. HW specific.
duty_cyclePointer to the variable to store the duty cycle.
Returns
0 on success, or a negative error code on failure.

◆ max2221x_calculate_master_freq_divisor()

int max2221x_calculate_master_freq_divisor ( uint32_t master_freq,
uint32_t period,
int * freq_divisor )

#include <zephyr/drivers/pwm/max2221x.h>

Calculate the master frequency divisor used for calculating individual frequency.

Parameters
master_freqMaster frequency (in Hz) set to the PWM. HW specific.
periodPeriod (in microseconds) set to the PWM. HW specific.
freq_divisorMaster frequency divisor set per channel.
Returns
0 on success, or a negative error code on failure.

◆ max2221x_get_channel_freq()

int max2221x_get_channel_freq ( const struct device * dev,
uint32_t channel,
uint32_t * channel_freq )

#include <zephyr/drivers/pwm/max2221x.h>

Get the individual channel frequency of the MAX2221X device.

Parameters
devPointer to the device structure for the driver instance.
channelThe channel to read.
channel_freqPointer to the variable to store the individual channel frequency.
Returns
The individual channel frequency in Hz on success, or a negative error code on failure.

◆ max2221x_get_cycles_per_sec()

int max2221x_get_cycles_per_sec ( const struct device * dev,
uint32_t channel,
uint64_t * cycles )

#include <zephyr/drivers/pwm/max2221x.h>

Get the cycles per second for the pwm channel.

Parameters
devPointer to the device structure for the driver instance.
channelThe channel to get the cycles.
cyclesPointer to the variable to store the cycles.
Returns
0 on success, or a negative error code on failure.

◆ max2221x_get_master_chop_freq()

int max2221x_get_master_chop_freq ( const struct device * dev)

#include <zephyr/drivers/pwm/max2221x.h>

Get the master chop frequency of the MAX2221X device.

Parameters
devPointer to the device structure for the driver instance.
Returns
The master chop frequency in Hz on success, or a negative error code on failure.

◆ max2221x_set_cycles()

int max2221x_set_cycles ( const struct device * dev,
uint32_t channel,
uint32_t period,
uint32_t pulse,
pwm_flags_t flags )

#include <zephyr/drivers/pwm/max2221x.h>

Set the duty cycle for the pwm channel.

Parameters
devPointer to the device structure for the driver instance.
channelThe channel to set the cycles.
periodPeriod (in microseconds) set to the PWM. HW specific.
pulsePulse width (in microseconds) set to the PWM. HW specific.
flagsFlags for pin configuration.
Returns
0 on success, or a negative error code on failure.