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  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  * - Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * - Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in
16  * the documentation and/or other materials provided with the
17  * distribution.
18  * - Neither the name of Analog Devices, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  * - The use of this software may or may not infringe the patent rights
22  * of one or more patent holders. This license does not release you
23  * from the requirement that you obtain separate licenses from these
24  * patent holders to use this software.
25  * - Use of the software either in source or binary form, must be run
26  * on or directly connected to an Analog Devices Inc. component.
27  *
28  * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
29  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
30  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
31  * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
32  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33  * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
34  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *******************************************************************************/
39 
40 #ifndef AXI_PWM_EXTRA_H_
41 #define AXI_PWM_EXTRA_H_
42 
43 /******************************************************************************/
44 /***************************** Include Files **********************************/
45 /******************************************************************************/
46 #include <stdint.h>
47 
48 /******************************************************************************/
49 /*************************** Types Declarations *******************************/
50 /******************************************************************************/
57  uint32_t base_addr;
59  uint32_t ref_clock_Hz;
61  uint32_t channel;
62 };
63 
68 struct axi_pwm_desc {
70  uint32_t base_addr;
72  uint32_t ref_clock_Hz;
74  uint32_t channel;
76  uint32_t ch_period;
77 };
78 
79 #endif
AXI_PWMGEN_CHX_DUTY
#define AXI_PWMGEN_CHX_DUTY(ch)
Definition: axi_pwm.c:64
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.
Definition: axi_pwm.c:280
no_os_pwm_desc::duty_cycle_ns
uint32_t duty_cycle_ns
Definition: no_os_pwm.h:91
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:55
axi_pwm_init_param::channel
uint32_t channel
Definition: axi_pwm_extra.h:61
axi_pwm_desc
AXI PWM descriptor.
Definition: axi_pwm_extra.h:68
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:67
no_os_pwm_remove
int32_t no_os_pwm_remove(struct no_os_pwm_desc *desc)
Free the memory allocated by axi_pwmgen_init().
Definition: axi_pwm.c:372
no_os_pwm_desc::phase_ns
uint32_t phase_ns
Definition: no_os_pwm.h:93
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.
Definition: axi_pwm.c:178
no_os_axi_io.h
Header file of AXI IO.
AXI_PWMGEN_RESET
#define AXI_PWMGEN_RESET
Definition: axi_pwm.c:68
AXI_PWMGEN_CHX_PERIOD
#define AXI_PWMGEN_CHX_PERIOD(ch)
Definition: axi_pwm.c:63
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.
Definition: axi_pwm.c:239
no_os_pwm_desc::period_ns
uint32_t period_ns
Definition: no_os_pwm.h:89
axi_pwm_desc::base_addr
uint32_t base_addr
Definition: axi_pwm_extra.h:70
no_os_pwm_disable
int32_t no_os_pwm_disable(struct no_os_pwm_desc *desc)
Disable PWM generator device.
Definition: axi_pwm.c:128
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.
Definition: axi_pwm.c:224
USEC_PER_SEC
#define USEC_PER_SEC
Definition: axi_pwm.c:72
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:56
no_os_pwm_init_param::polarity
enum no_os_pwm_polarity polarity
Definition: no_os_pwm.h:76
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.
Definition: axi_pwm.c:266
AXI_PWMGEN_CHANNEL_DISABLE
#define AXI_PWMGEN_CHANNEL_DISABLE
Definition: axi_pwm.c:69
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.
Definition: axi_pwm.c:150
no_os_pwm_desc::polarity
enum no_os_pwm_polarity polarity
Definition: no_os_pwm.h:95
NSEC_PER_USEC
#define NSEC_PER_USEC
Definition: axi_pwm.c:71
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: axi_io.c:59
no_os_pwm_desc::enabled
bool enabled
Definition: no_os_pwm.h:97
no_os_pwm_init_param::extra
void * extra
Definition: no_os_pwm.h:78
no_os_pwm_desc
Structure representing an PWM generator device.
Definition: no_os_pwm.h:85
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:57
axi_pwm_desc::channel
uint32_t channel
Definition: axi_pwm_extra.h:74
axi_pwm_init_param
Structure holding the initialization parameters for axi PWM.
Definition: axi_pwm_extra.h:55
no_os_pwm.h
Header file of PWM Interface.
no_os_pwm_desc::extra
void * extra
Definition: no_os_pwm.h:99
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.
Definition: axi_pwm.c:193
AXI_PWMGEN_TEST_DATA
#define AXI_PWMGEN_TEST_DATA
Definition: axi_pwm.c:66
no_os_pwm_enable
int32_t no_os_pwm_enable(struct no_os_pwm_desc *desc)
Enable PWM generator device.
Definition: axi_pwm.c:107
AXI_PWMGEN_REG_NPWM
#define AXI_PWMGEN_REG_NPWM
Definition: axi_pwm.c:58
axi_pwm_desc::ref_clock_Hz
uint32_t ref_clock_Hz
Definition: axi_pwm_extra.h:72
axi_pwm_init_param::ref_clock_Hz
uint32_t ref_clock_Hz
Definition: axi_pwm_extra.h:59
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: axi_io.c:73
axi_pwm_init_param::base_addr
uint32_t base_addr
Definition: axi_pwm_extra.h:57
AXI_PWMGEN_CHX_PHASE
#define AXI_PWMGEN_CHX_PHASE(ch)
Definition: axi_pwm.c:65
no_os_util.h
Implementation of utility functions.
axi_pwm_desc::ch_period
uint32_t ch_period
Definition: axi_pwm_extra.h:76
axi_pwm_extra.h