#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"
◆ AXI_PWMGEN_CHANNEL_DISABLE
#define AXI_PWMGEN_CHANNEL_DISABLE 0 |
◆ AXI_PWMGEN_CHX_DUTY
#define AXI_PWMGEN_CHX_DUTY |
( |
|
p, |
|
|
|
ch |
|
) |
| (((p)->hw_major_ver == 1) ? (0x44 + 12 * (ch)) : (0x80 + 4 * (ch))) |
◆ AXI_PWMGEN_CHX_PERIOD
#define AXI_PWMGEN_CHX_PERIOD |
( |
|
p, |
|
|
|
ch |
|
) |
| (((p)->hw_major_ver == 1) ? (0x40 + 12 * (ch)) : (0x40 + 4 * (ch))) |
◆ AXI_PWMGEN_CHX_PHASE
#define AXI_PWMGEN_CHX_PHASE |
( |
|
p, |
|
|
|
ch |
|
) |
| (((p)->hw_major_ver == 1) ? (0x48 + 12 * (ch)) : (0xC0 + 4 * (ch))) |
◆ AXI_PWMGEN_LOAD_CONIG
◆ AXI_PWMGEN_MAX_CHANNELS
#define AXI_PWMGEN_MAX_CHANNELS |
( |
|
p | ) |
(((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
◆ AXI_PWMGEN_TEST_DATA
#define AXI_PWMGEN_TEST_DATA 0x5A0F0081 |
◆ AXI_PWMGEN_VERSION_MAJOR
#define AXI_PWMGEN_VERSION_MAJOR |
( |
|
x | ) |
(((x) >> 16) & 0xff) |
◆ AXI_PWMGEN_VERSION_MINOR
#define AXI_PWMGEN_VERSION_MINOR |
( |
|
x | ) |
(((x) >> 8) & 0xff) |
◆ AXI_PWMGEN_VERSION_PATCH
#define AXI_PWMGEN_VERSION_PATCH |
( |
|
x | ) |
((x) & 0xff) |
◆ NSEC_PER_USEC
#define NSEC_PER_USEC 1000L |
◆ USEC_PER_SEC
#define USEC_PER_SEC 1000000L |
◆ axi_pwm_disable()
Disable PWM generator device.
- Parameters
-
[in] | desc | - Decriptor containing PWM generator parameters. |
- Returns
- 0 in case of success, -1 otherwise.
◆ axi_pwm_enable()
Enable PWM generator device.
- Parameters
-
[in] | desc | - Decriptor containing PWM generator parameters. |
- Returns
- 0 in case of success, -1 otherwise.
◆ 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()
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
◆ axi_pwm_remove()
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.
◆ 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.
◆ 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.
◆ axi_pwm_ops
Initial value:
AXI platform specific PWM platform ops structure.
AXI specific PWM platform ops structure.
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:221
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:147
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:190
int32_t axi_pwm_enable(struct no_os_pwm_desc *desc)
Enable PWM generator device.
Definition: axi_pwm.c:104
int32_t axi_pwm_disable(struct no_os_pwm_desc *desc)
Disable PWM generator device.
Definition: axi_pwm.c:125
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:263
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:236
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:277
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:175
int32_t axi_pwm_remove(struct no_os_pwm_desc *desc)
Free the memory allocated by axi_pwmgen_init().
Definition: axi_pwm.c:383