no-OS
Macros | Functions
pwm.c File Reference

Implementation of pwm.c. More...

#include "pwm.h"
#include "stdlib.h"
#include "error.h"
#include <drivers/tmr/adi_tmr.h>
#include <drivers/pwr/adi_pwr.h>
Include dependency graph for pwm.c:

Macros

#define NS_PER_SEC   1000000000
 

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_polarity (struct pwm_desc *desc, enum pwm_polarity polarity)
 
int32_t pwm_get_polarity (struct pwm_desc *desc, enum pwm_polarity *polarity)
 

Detailed Description

Implementation of pwm.c.

Author
Mihail Chindris (mihai.nosp@m.l.ch.nosp@m.indri.nosp@m.s@an.nosp@m.alog..nosp@m.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.

Macro Definition Documentation

◆ NS_PER_SEC

#define NS_PER_SEC   1000000000

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_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_polarity()

int32_t pwm_set_polarity ( struct pwm_desc desc,
enum pwm_polarity  polarity 
)