no-OS
Classes | Enumerations | Functions
pwm.h File Reference

Header file of PWM Interface. More...

#include <stdint.h>
#include <stdbool.h>
Include dependency graph for pwm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pwm_init_param
 Structure containing the init parameters needed by the PWM generator. More...
 
struct  pwm_desc
 Structure representing an PWM generator device. More...
 

Enumerations

enum  pwm_polarity {
  PWM_POLARITY_HIGH,
  PWM_POLARITY_LOW
}
 Possible polarities of the PWM signal. More...
 

Functions

int32_t pwm_init (struct pwm_desc **desc, const struct pwm_init_param *param)
 Initialize the pwm axi generator and the handler associated with it. More...
 
int32_t pwm_remove (struct pwm_desc *desc)
 Free the memory allocated by axi_pwmgen_init(). More...
 
int32_t pwm_enable (struct pwm_desc *desc)
 Enable PWM generator device. More...
 
int32_t pwm_disable (struct pwm_desc *desc)
 Disable PWM generator device. More...
 
int32_t pwm_set_period (struct pwm_desc *desc, uint32_t period_ns)
 Set period of PWM generator device. More...
 
int32_t pwm_get_period (struct pwm_desc *desc, uint32_t *period_ns)
 Get period of PWM generator device. More...
 
int32_t pwm_set_duty_cycle (struct pwm_desc *desc, uint32_t duty_cycle_ns)
 Set duty cycle of PWM generator device. More...
 
int32_t pwm_get_duty_cycle (struct pwm_desc *desc, uint32_t *duty_cycle_ns)
 Get duty cycle of PWM generator device. More...
 
int32_t pwm_set_phase (struct pwm_desc *desc, uint32_t phase_ns)
 Set phase of PWM generator device. More...
 
int32_t pwm_get_phase (struct pwm_desc *desc, uint32_t *phase_ns)
 Get phase of PWM generator device. More...
 
int32_t pwm_set_polarity (struct pwm_desc *desc, enum pwm_polarity polarity)
 
int32_t pwm_get_polarity (struct pwm_desc *desc, enum pwm_polarity *polarity)
 

Detailed Description

Header file of PWM Interface.

Author
Cristian Pop (crist.nosp@m.ian..nosp@m.pop@a.nosp@m.nalo.nosp@m.g.com)

Copyright 2020(c) Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Enumeration Type Documentation

◆ pwm_polarity

Possible polarities of the PWM signal.

Enumerator
PWM_POLARITY_HIGH 

PWM duty cycle is high, idle low

PWM_POLARITY_LOW 

PWM duty cycle is low, idle high

Function Documentation

◆ pwm_disable()

int32_t pwm_disable ( struct pwm_desc desc)

Disable PWM generator device.

Parameters
[in]desc- Decriptor containing PWM generator parameters.
Returns
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ pwm_enable()

int32_t pwm_enable ( struct pwm_desc desc)

Enable PWM generator device.

Parameters
[in]desc- Decriptor containing PWM generator parameters.
Returns
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ pwm_get_duty_cycle()

int32_t pwm_get_duty_cycle ( struct pwm_desc desc,
uint32_t *  duty_cycle_ns 
)

Get duty cycle of PWM generator device.

Parameters
[in]desc- Decriptor containing PWM generator parameters.
[out]duty_cycle_ns- PWM duty cycle.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ pwm_get_period()

int32_t pwm_get_period ( struct pwm_desc desc,
uint32_t *  period_ns 
)

Get period of PWM generator device.

Parameters
[in]desc- Decriptor containing PWM generator parameters.
[out]period_ns- PWM period.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ pwm_get_phase()

int32_t pwm_get_phase ( struct pwm_desc desc,
uint32_t *  phase_ns 
)

Get phase of PWM generator device.

Parameters
[in]desc- Decriptor containing PWM generator parameters.
[out]phase_ns- PWM phase.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ pwm_get_polarity()

int32_t pwm_get_polarity ( struct pwm_desc desc,
enum pwm_polarity polarity 
)

◆ pwm_init()

int32_t pwm_init ( struct pwm_desc **  desc,
const struct pwm_init_param param 
)

Initialize the pwm axi generator and the handler associated with it.

Parameters
[out]desc- Decriptor containing PWM generator parameters.
[in]param- Structure containing the PWM generator init parameters.
Returns
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ pwm_remove()

int32_t pwm_remove ( struct pwm_desc desc)

Free the memory allocated by axi_pwmgen_init().

Parameters
[in]desc- Pointer to the device handler.
Returns
SUCCESS in case of success, FAILURE otherwise
Here is the caller graph for this function:

◆ pwm_set_duty_cycle()

int32_t pwm_set_duty_cycle ( struct pwm_desc desc,
uint32_t  duty_cycle_ns 
)

Set duty cycle of PWM generator device.

Parameters
[in]desc- Decriptor containing PWM generator parameters.
[in]duty_cycle_ns- PWM duty cycle.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ pwm_set_period()

int32_t pwm_set_period ( struct pwm_desc desc,
uint32_t  period_ns 
)

Set period of PWM generator device.

Parameters
[in]desc- Decriptor containing PWM generator parameters.
[in]period_ns- PWM period.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ pwm_set_phase()

int32_t pwm_set_phase ( struct pwm_desc desc,
uint32_t  phase_ns 
)

Set phase of PWM generator device.

Parameters
[in]desc- Decriptor containing PWM generator parameters.
[in]phase_ns- PWM phase.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ pwm_set_polarity()

int32_t pwm_set_polarity ( struct pwm_desc desc,
enum pwm_polarity  polarity 
)