no-OS
Macros | Functions
axi_pwm.c File Reference
#include <stdlib.h>
#include "no_os_pwm.h"
#include "axi_pwm_extra.h"
#include "no_os_axi_io.h"
#include "no_os_util.h"
#include "no_os_error.h"
Include dependency graph for axi_pwm.c:

Macros

#define AXI_PWMGEN_REG_CORE_VERSION   0x00
 
#define AXI_PWMGEN_REG_ID   0x04
 
#define AXI_PWMGEN_REG_SCRATCHPAD   0x08
 
#define AXI_PWMGEN_REG_CORE_MAGIC   0x0C
 
#define AXI_PWMGEN_REG_CONFIG   0x10
 
#define AXI_PWMGEN_REG_NPWM   0x14
 
#define AXI_PWMGEN_CH_PERIOD_BASE   0x40
 
#define AXI_PWMGEN_CH_DUTY_BASE   0x44
 
#define AXI_PWMGEN_CH_PHASE_BASE   0x48
 
#define AXI_PWMGEN_CHX_PERIOD(ch)   (AXI_PWMGEN_CH_PERIOD_BASE + (12 * (ch)))
 
#define AXI_PWMGEN_CHX_DUTY(ch)   (AXI_PWMGEN_CH_DUTY_BASE + (12 * (ch)))
 
#define AXI_PWMGEN_CHX_PHASE(ch)   (AXI_PWMGEN_CH_PHASE_BASE + (12 * (ch)))
 
#define AXI_PWMGEN_TEST_DATA   0x5A0F0081
 
#define AXI_PWMGEN_LOAD_CONIG   NO_OS_BIT(1)
 
#define AXI_PWMGEN_RESET   NO_OS_BIT(0)
 
#define AXI_PWMGEN_CHANNEL_DISABLE   0
 
#define AXI_PWMGEN_MAX_CHANNELS   4
 
#define NSEC_PER_USEC   1000L
 
#define USEC_PER_SEC   1000000L
 

Functions

int32_t no_os_pwm_enable (struct no_os_pwm_desc *desc)
 Enable PWM generator device. More...
 
int32_t no_os_pwm_disable (struct no_os_pwm_desc *desc)
 Disable PWM generator device. More...
 
int32_t no_os_pwm_set_period (struct no_os_pwm_desc *desc, uint32_t period_ns)
 Set period of PWM generator device. More...
 
int32_t no_os_pwm_get_period (struct no_os_pwm_desc *desc, uint32_t *period_ns)
 Get period of PWM generator device. More...
 
int32_t no_os_pwm_set_duty_cycle (struct no_os_pwm_desc *desc, uint32_t duty_cycle_ns)
 Set duty cycle of PWM generator device. More...
 
int32_t no_os_pwm_get_duty_cycle (struct no_os_pwm_desc *desc, uint32_t *duty_cycle_ns)
 Get duty cycle of PWM generator device. More...
 
int32_t no_os_pwm_set_phase (struct no_os_pwm_desc *desc, uint32_t phase_ns)
 Set phase of PWM generator device. More...
 
int32_t no_os_pwm_get_phase (struct no_os_pwm_desc *desc, uint32_t *phase_ns)
 Get phase of PWM generator device. More...
 
int32_t no_os_pwm_init (struct no_os_pwm_desc **desc, const struct no_os_pwm_init_param *param)
 Initialize the pwm axi generator and the handler associated with it. More...
 
int32_t no_os_pwm_remove (struct no_os_pwm_desc *desc)
 Free the memory allocated by axi_pwmgen_init(). More...
 

Macro Definition Documentation

◆ AXI_PWMGEN_CH_DUTY_BASE

#define AXI_PWMGEN_CH_DUTY_BASE   0x44

◆ AXI_PWMGEN_CH_PERIOD_BASE

#define AXI_PWMGEN_CH_PERIOD_BASE   0x40

◆ AXI_PWMGEN_CH_PHASE_BASE

#define AXI_PWMGEN_CH_PHASE_BASE   0x48

◆ AXI_PWMGEN_CHANNEL_DISABLE

#define AXI_PWMGEN_CHANNEL_DISABLE   0

◆ AXI_PWMGEN_CHX_DUTY

#define AXI_PWMGEN_CHX_DUTY (   ch)    (AXI_PWMGEN_CH_DUTY_BASE + (12 * (ch)))

◆ AXI_PWMGEN_CHX_PERIOD

#define AXI_PWMGEN_CHX_PERIOD (   ch)    (AXI_PWMGEN_CH_PERIOD_BASE + (12 * (ch)))

◆ AXI_PWMGEN_CHX_PHASE

#define AXI_PWMGEN_CHX_PHASE (   ch)    (AXI_PWMGEN_CH_PHASE_BASE + (12 * (ch)))

◆ AXI_PWMGEN_LOAD_CONIG

#define AXI_PWMGEN_LOAD_CONIG   NO_OS_BIT(1)

◆ AXI_PWMGEN_MAX_CHANNELS

#define AXI_PWMGEN_MAX_CHANNELS   4

◆ AXI_PWMGEN_REG_CONFIG

#define AXI_PWMGEN_REG_CONFIG   0x10

◆ AXI_PWMGEN_REG_CORE_MAGIC

#define AXI_PWMGEN_REG_CORE_MAGIC   0x0C

◆ AXI_PWMGEN_REG_CORE_VERSION

#define AXI_PWMGEN_REG_CORE_VERSION   0x00

◆ AXI_PWMGEN_REG_ID

#define AXI_PWMGEN_REG_ID   0x04

◆ AXI_PWMGEN_REG_NPWM

#define AXI_PWMGEN_REG_NPWM   0x14

◆ AXI_PWMGEN_REG_SCRATCHPAD

#define AXI_PWMGEN_REG_SCRATCHPAD   0x08

◆ AXI_PWMGEN_RESET

#define AXI_PWMGEN_RESET   NO_OS_BIT(0)

◆ AXI_PWMGEN_TEST_DATA

#define AXI_PWMGEN_TEST_DATA   0x5A0F0081

◆ NSEC_PER_USEC

#define NSEC_PER_USEC   1000L

◆ USEC_PER_SEC

#define USEC_PER_SEC   1000000L

Function Documentation

◆ no_os_pwm_disable()

int32_t no_os_pwm_disable ( struct no_os_pwm_desc desc)

Disable PWM generator device.

Parameters
[in]desc- Decriptor containing PWM generator parameters.
Returns
0 in case of success, -1 otherwise.

◆ no_os_pwm_enable()

int32_t no_os_pwm_enable ( struct no_os_pwm_desc desc)

Enable PWM generator device.

Parameters
[in]desc- Decriptor containing PWM generator parameters.
Returns
0 in case of success, -1 otherwise.

◆ no_os_pwm_get_duty_cycle()

int32_t no_os_pwm_get_duty_cycle ( struct no_os_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
0 in case of success, -1 otherwise.

◆ no_os_pwm_get_period()

int32_t no_os_pwm_get_period ( struct no_os_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
0 in case of success, -1 otherwise.

◆ no_os_pwm_get_phase()

int32_t no_os_pwm_get_phase ( struct no_os_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
0 in case of success, -1 otherwise.

◆ no_os_pwm_init()

int32_t no_os_pwm_init ( struct no_os_pwm_desc **  desc,
const struct no_os_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
0 in case of success, -1 otherwise.

◆ no_os_pwm_remove()

int32_t no_os_pwm_remove ( struct no_os_pwm_desc desc)

Free the memory allocated by axi_pwmgen_init().

Parameters
[in]desc- Pointer to the device handler.
Returns
0 in case of success, -1 otherwise

◆ no_os_pwm_set_duty_cycle()

int32_t no_os_pwm_set_duty_cycle ( struct no_os_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
0 in case of success, -1 otherwise.

◆ no_os_pwm_set_period()

int32_t no_os_pwm_set_period ( struct no_os_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
0 in case of success, -1 otherwise.

◆ no_os_pwm_set_phase()

int32_t no_os_pwm_set_phase ( struct no_os_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
0 in case of success, -1 otherwise.