no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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_alloc.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_CHX_PERIOD(p, ch)
 
#define AXI_PWMGEN_CHX_DUTY(p, ch)
 
#define AXI_PWMGEN_CHX_PHASE(p, 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(p)
 
#define NSEC_PER_USEC   1000L
 
#define USEC_PER_SEC   1000000L
 
#define AXI_PWMGEN_VERSION_MAJOR(x)
 
#define AXI_PWMGEN_VERSION_MINOR(x)
 
#define AXI_PWMGEN_VERSION_PATCH(x)
 

Functions

int32_t axi_pwm_enable (struct no_os_pwm_desc *desc)
 Enable PWM generator device.
 
int32_t axi_pwm_disable (struct no_os_pwm_desc *desc)
 Disable PWM generator device.
 
int32_t axi_pwm_set_period (struct no_os_pwm_desc *desc, uint32_t period_ns)
 Set period of PWM generator device.
 
int32_t axi_pwm_get_period (struct no_os_pwm_desc *desc, uint32_t *period_ns)
 Get period of PWM generator device.
 
int32_t axi_pwm_set_duty_cycle (struct no_os_pwm_desc *desc, uint32_t duty_cycle_ns)
 Set duty cycle of PWM generator device.
 
int32_t axi_pwm_get_duty_cycle (struct no_os_pwm_desc *desc, uint32_t *duty_cycle_ns)
 Get duty cycle of PWM generator device.
 
int32_t axi_pwm_set_phase (struct no_os_pwm_desc *desc, uint32_t phase_ns)
 Set phase of PWM generator device.
 
int32_t axi_pwm_get_phase (struct no_os_pwm_desc *desc, uint32_t *phase_ns)
 Get phase of PWM generator device.
 
int32_t axi_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.
 
int32_t axi_pwm_remove (struct no_os_pwm_desc *desc)
 Free the memory allocated by axi_pwmgen_init().
 

Variables

const struct no_os_pwm_platform_ops axi_pwm_ops
 AXI platform specific PWM platform ops structure.
 

Macro Definition Documentation

◆ AXI_PWMGEN_CHANNEL_DISABLE

#define AXI_PWMGEN_CHANNEL_DISABLE   0

◆ AXI_PWMGEN_CHX_DUTY

#define AXI_PWMGEN_CHX_DUTY ( p,
ch )
Value:
(((p)->hw_major_ver == 1) ? (0x44 + 12 * (ch)) : (0x80 + 4 * (ch)))

◆ AXI_PWMGEN_CHX_PERIOD

#define AXI_PWMGEN_CHX_PERIOD ( p,
ch )
Value:
(((p)->hw_major_ver == 1) ? (0x40 + 12 * (ch)) : (0x40 + 4 * (ch)))

◆ AXI_PWMGEN_CHX_PHASE

#define AXI_PWMGEN_CHX_PHASE ( p,
ch )
Value:
(((p)->hw_major_ver == 1) ? (0x48 + 12 * (ch)) : (0xC0 + 4 * (ch)))

◆ AXI_PWMGEN_LOAD_CONIG

#define AXI_PWMGEN_LOAD_CONIG   NO_OS_BIT(1)

◆ AXI_PWMGEN_MAX_CHANNELS

#define AXI_PWMGEN_MAX_CHANNELS ( p)
Value:
(((p)->hw_major_ver == 1) ? 4 : 16)

◆ 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

◆ AXI_PWMGEN_VERSION_MAJOR

#define AXI_PWMGEN_VERSION_MAJOR ( x)
Value:
(((x) >> 16) & 0xff)

◆ AXI_PWMGEN_VERSION_MINOR

#define AXI_PWMGEN_VERSION_MINOR ( x)
Value:
(((x) >> 8) & 0xff)

◆ AXI_PWMGEN_VERSION_PATCH

#define AXI_PWMGEN_VERSION_PATCH ( x)
Value:
((x) & 0xff)

◆ NSEC_PER_USEC

#define NSEC_PER_USEC   1000L

◆ USEC_PER_SEC

#define USEC_PER_SEC   1000000L

Function Documentation

◆ axi_pwm_disable()

int32_t axi_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.

◆ axi_pwm_enable()

int32_t axi_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.
Here is the caller graph for this function:

◆ axi_pwm_get_duty_cycle()

int32_t axi_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.

◆ axi_pwm_get_period()

int32_t axi_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.

◆ axi_pwm_get_phase()

int32_t axi_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.

◆ axi_pwm_init()

int32_t axi_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.

Check if channel is out of hw available range

Here is the caller graph for this function:

◆ axi_pwm_remove()

int32_t axi_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

◆ axi_pwm_set_duty_cycle()

int32_t axi_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.
Here is the caller graph for this function:

◆ axi_pwm_set_period()

int32_t axi_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.
Here is the caller graph for this function:

◆ axi_pwm_set_phase()

int32_t axi_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.
Here is the caller graph for this function:

Variable Documentation

◆ axi_pwm_ops

const struct no_os_pwm_platform_ops axi_pwm_ops
Initial value:
= {
.pwm_ops_init = &axi_pwm_init,
.pwm_ops_enable = &axi_pwm_enable,
.pwm_ops_disable = &axi_pwm_disable,
.pwm_ops_set_period = &axi_pwm_set_period,
.pwm_ops_get_period = &axi_pwm_get_period,
.pwm_ops_set_duty_cycle = &axi_pwm_set_duty_cycle,
.pwm_ops_get_duty_cycle = &axi_pwm_get_duty_cycle,
.pwm_ops_set_phase = &axi_pwm_set_phase,
.pwm_ops_get_phase = &axi_pwm_get_phase,
.pwm_ops_remove = &axi_pwm_remove
}
int32_t axi_pwm_set_period(struct no_os_pwm_desc *desc, uint32_t period_ns)
Set period of PWM generator device.
Definition axi_pwm.c:137
int32_t axi_pwm_enable(struct no_os_pwm_desc *desc)
Enable PWM generator device.
Definition axi_pwm.c:94
int32_t axi_pwm_get_phase(struct no_os_pwm_desc *desc, uint32_t *phase_ns)
Get phase of PWM generator device.
Definition axi_pwm.c:253
int32_t axi_pwm_set_phase(struct no_os_pwm_desc *desc, uint32_t phase_ns)
Set phase of PWM generator device.
Definition axi_pwm.c:226
int32_t axi_pwm_remove(struct no_os_pwm_desc *desc)
Free the memory allocated by axi_pwmgen_init().
Definition axi_pwm.c:373
int32_t axi_pwm_disable(struct no_os_pwm_desc *desc)
Disable PWM generator device.
Definition axi_pwm.c:115
int32_t axi_pwm_set_duty_cycle(struct no_os_pwm_desc *desc, uint32_t duty_cycle_ns)
Set duty cycle of PWM generator device.
Definition axi_pwm.c:180
int32_t axi_pwm_get_period(struct no_os_pwm_desc *desc, uint32_t *period_ns)
Get period of PWM generator device.
Definition axi_pwm.c:165
int32_t axi_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.
Definition axi_pwm.c:267
int32_t axi_pwm_get_duty_cycle(struct no_os_pwm_desc *desc, uint32_t *duty_cycle_ns)
Get duty cycle of PWM generator device.
Definition axi_pwm.c:211

AXI platform specific PWM platform ops structure.

AXI specific PWM platform ops structure.