no-OS
axi_pwm_extra.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * @file axi_pwm_extra.h
3  * @brief Header containing types used in the axi_pwm driver.
4  * @author Cristian Pop (cristian.pop@analog.com)
5 ********************************************************************************
6  * Copyright 2020(c) Analog Devices, Inc.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of Analog Devices, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
25  * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *******************************************************************************/
33 
34 #ifndef AXI_PWM_EXTRA_H_
35 #define AXI_PWM_EXTRA_H_
36 
37 /******************************************************************************/
38 /***************************** Include Files **********************************/
39 /******************************************************************************/
40 #include <stdint.h>
41 #include "no_os_pwm.h"
42 
43 /******************************************************************************/
44 /*************************** Types Declarations *******************************/
45 /******************************************************************************/
52  uint32_t base_addr;
54  uint32_t ref_clock_Hz;
56  uint32_t channel;
57 };
58 
63 struct axi_pwm_desc {
65  uint32_t base_addr;
67  uint32_t ref_clock_Hz;
69  uint32_t channel;
71  uint32_t ch_period;
73  uint32_t hw_major_ver;
74 };
75 
79 extern const struct no_os_pwm_platform_ops axi_pwm_ops;
80 
81 #endif
axi_pwm_desc::hw_major_ver
uint32_t hw_major_ver
Definition: axi_pwm_extra.h:73
no_os_alloc.h
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.
Definition: axi_pwm.c:221
no_os_pwm_desc::duty_cycle_ns
uint32_t duty_cycle_ns
Definition: no_os_pwm.h:101
no_os_pwm_init_param
Structure containing the init parameters needed by the PWM generator.
Definition: no_os_pwm.h:66
AXI_PWMGEN_REG_SCRATCHPAD
#define AXI_PWMGEN_REG_SCRATCHPAD
Definition: axi_pwm.c:50
AXI_PWMGEN_REG_CORE_VERSION
#define AXI_PWMGEN_REG_CORE_VERSION
Definition: axi_pwm.c:48
axi_pwm_init_param::channel
uint32_t channel
Definition: axi_pwm_extra.h:56
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.
Definition: axi_pwm.c:147
axi_pwm_desc
AXI PWM descriptor.
Definition: axi_pwm_extra.h:63
no_os_pwm_init_param::period_ns
uint32_t period_ns
Definition: no_os_pwm.h:70
AXI_PWMGEN_LOAD_CONIG
#define AXI_PWMGEN_LOAD_CONIG
Definition: axi_pwm.c:61
no_os_pwm_desc::phase_ns
uint32_t phase_ns
Definition: no_os_pwm.h:103
AXI_PWMGEN_CHX_PERIOD
#define AXI_PWMGEN_CHX_PERIOD(p, ch)
Definition: axi_pwm.c:54
no_os_axi_io.h
Header file of AXI IO.
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
AXI_PWMGEN_RESET
#define AXI_PWMGEN_RESET
Definition: axi_pwm.c:62
no_os_pwm_desc::period_ns
uint32_t period_ns
Definition: no_os_pwm.h:99
axi_pwm_ops
const struct no_os_pwm_platform_ops axi_pwm_ops
AXI platform specific PWM platform ops structure.
Definition: axi_pwm.c:406
axi_pwm_desc::base_addr
uint32_t base_addr
Definition: axi_pwm_extra.h:65
USEC_PER_SEC
#define USEC_PER_SEC
Definition: axi_pwm.c:66
no_os_error.h
Error codes definition.
NO_OS_DIV_ROUND_UP
#define NO_OS_DIV_ROUND_UP(x, y)
Definition: no_os_util.h:52
no_os_pwm_init_param::polarity
enum no_os_pwm_polarity polarity
Definition: no_os_pwm.h:76
AXI_PWMGEN_CHANNEL_DISABLE
#define AXI_PWMGEN_CHANNEL_DISABLE
Definition: axi_pwm.c:63
no_os_pwm_platform_ops::pwm_ops_init
int32_t(* pwm_ops_init)(struct no_os_pwm_desc **, const struct no_os_pwm_init_param *)
Definition: no_os_pwm.h:127
no_os_pwm_desc::polarity
enum no_os_pwm_polarity polarity
Definition: no_os_pwm.h:105
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.
Definition: axi_pwm.c:190
NSEC_PER_USEC
#define NSEC_PER_USEC
Definition: axi_pwm.c:65
axi_pwm_enable
int32_t axi_pwm_enable(struct no_os_pwm_desc *desc)
Enable PWM generator device.
Definition: axi_pwm.c:104
no_os_axi_io_read
int32_t no_os_axi_io_read(uint32_t base, uint32_t offset, uint32_t *data)
AXI IO Altera specific read function.
Definition: altera_axi_io.c:53
no_os_pwm_desc::enabled
bool enabled
Definition: no_os_pwm.h:107
axi_pwm_disable
int32_t axi_pwm_disable(struct no_os_pwm_desc *desc)
Disable PWM generator device.
Definition: axi_pwm.c:125
no_os_pwm_init_param::extra
void * extra
Definition: no_os_pwm.h:86
AXI_PWMGEN_CHX_PHASE
#define AXI_PWMGEN_CHX_PHASE(p, ch)
Definition: axi_pwm.c:58
no_os_pwm_desc
Structure representing an PWM generator device.
Definition: no_os_pwm.h:93
no_os_pwm_init_param::duty_cycle_ns
uint32_t duty_cycle_ns
Definition: no_os_pwm.h:72
AXI_PWMGEN_REG_CONFIG
#define AXI_PWMGEN_REG_CONFIG
Definition: axi_pwm.c:52
axi_pwm_desc::channel
uint32_t channel
Definition: axi_pwm_extra.h:69
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.
Definition: axi_pwm.c:263
axi_pwm_init_param
Structure holding the initialization parameters for axi PWM.
Definition: axi_pwm_extra.h:50
no_os_pwm_platform_ops
Structure holding PWM function pointers that point to the platform specific function.
Definition: no_os_pwm.h:125
AXI_PWMGEN_VERSION_MAJOR
#define AXI_PWMGEN_VERSION_MAJOR(x)
Definition: axi_pwm.c:67
no_os_pwm.h
Header file of PWM Interface.
no_os_pwm_desc::extra
void * extra
Definition: no_os_pwm.h:117
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.
Definition: axi_pwm.c:236
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
AXI_PWMGEN_TEST_DATA
#define AXI_PWMGEN_TEST_DATA
Definition: axi_pwm.c:60
AXI_PWMGEN_REG_NPWM
#define AXI_PWMGEN_REG_NPWM
Definition: axi_pwm.c:53
axi_pwm_desc::ref_clock_Hz
uint32_t ref_clock_Hz
Definition: axi_pwm_extra.h:67
axi_pwm_init_param::ref_clock_Hz
uint32_t ref_clock_Hz
Definition: axi_pwm_extra.h:54
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.
Definition: axi_pwm.c:277
no_os_axi_io_write
int32_t no_os_axi_io_write(uint32_t base, uint32_t offset, uint32_t data)
AXI IO Altera specific write function.
Definition: altera_axi_io.c:67
no_os_pwm_init_param::phase_ns
uint32_t phase_ns
Definition: no_os_pwm.h:74
axi_pwm_init_param::base_addr
uint32_t base_addr
Definition: axi_pwm_extra.h:52
no_os_util.h
Header file of utility functions.
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.
Definition: axi_pwm.c:175
AXI_PWMGEN_CHX_DUTY
#define AXI_PWMGEN_CHX_DUTY(p, ch)
Definition: axi_pwm.c:56
axi_pwm_desc::ch_period
uint32_t ch_period
Definition: axi_pwm_extra.h:71
axi_pwm_ops
const struct no_os_pwm_platform_ops axi_pwm_ops
AXI specific PWM platform ops structure.
Definition: axi_pwm.c:406
axi_pwm_remove
int32_t axi_pwm_remove(struct no_os_pwm_desc *desc)
Free the memory allocated by axi_pwmgen_init().
Definition: axi_pwm.c:383
AXI_PWMGEN_MAX_CHANNELS
#define AXI_PWMGEN_MAX_CHANNELS(p)
Definition: axi_pwm.c:64
axi_pwm_extra.h