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 #include "no_os_pwm.h"
48 
49 /******************************************************************************/
50 /*************************** Types Declarations *******************************/
51 /******************************************************************************/
58  uint32_t base_addr;
60  uint32_t ref_clock_Hz;
62  uint32_t channel;
63 };
64 
69 struct axi_pwm_desc {
71  uint32_t base_addr;
73  uint32_t ref_clock_Hz;
75  uint32_t channel;
77  uint32_t ch_period;
79  uint32_t hw_major_ver;
80 };
81 
85 extern const struct no_os_pwm_platform_ops axi_pwm_ops;
86 
87 #endif
axi_pwm_desc::hw_major_ver
uint32_t hw_major_ver
Definition: axi_pwm_extra.h:79
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:227
no_os_pwm_desc::duty_cycle_ns
uint32_t duty_cycle_ns
Definition: no_os_pwm.h:107
no_os_pwm_init_param
Structure containing the init parameters needed by the PWM generator.
Definition: no_os_pwm.h:72
AXI_PWMGEN_REG_SCRATCHPAD
#define AXI_PWMGEN_REG_SCRATCHPAD
Definition: axi_pwm.c:56
AXI_PWMGEN_REG_CORE_VERSION
#define AXI_PWMGEN_REG_CORE_VERSION
Definition: axi_pwm.c:54
axi_pwm_init_param::channel
uint32_t channel
Definition: axi_pwm_extra.h:62
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:153
axi_pwm_desc
AXI PWM descriptor.
Definition: axi_pwm_extra.h:69
no_os_pwm_init_param::period_ns
uint32_t period_ns
Definition: no_os_pwm.h:76
AXI_PWMGEN_LOAD_CONIG
#define AXI_PWMGEN_LOAD_CONIG
Definition: axi_pwm.c:67
no_os_pwm_desc::phase_ns
uint32_t phase_ns
Definition: no_os_pwm.h:109
AXI_PWMGEN_CHX_PERIOD
#define AXI_PWMGEN_CHX_PERIOD(p, ch)
Definition: axi_pwm.c:60
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:60
AXI_PWMGEN_RESET
#define AXI_PWMGEN_RESET
Definition: axi_pwm.c:68
no_os_pwm_desc::period_ns
uint32_t period_ns
Definition: no_os_pwm.h:105
axi_pwm_ops
const struct no_os_pwm_platform_ops axi_pwm_ops
AXI platform specific PWM platform ops structure.
Definition: axi_pwm.c:412
axi_pwm_desc::base_addr
uint32_t base_addr
Definition: axi_pwm_extra.h:71
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:82
AXI_PWMGEN_CHANNEL_DISABLE
#define AXI_PWMGEN_CHANNEL_DISABLE
Definition: axi_pwm.c:69
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:133
no_os_pwm_desc::polarity
enum no_os_pwm_polarity polarity
Definition: no_os_pwm.h:111
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:196
NSEC_PER_USEC
#define NSEC_PER_USEC
Definition: axi_pwm.c:71
axi_pwm_enable
int32_t axi_pwm_enable(struct no_os_pwm_desc *desc)
Enable PWM generator device.
Definition: axi_pwm.c:110
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:59
no_os_pwm_desc::enabled
bool enabled
Definition: no_os_pwm.h:113
axi_pwm_disable
int32_t axi_pwm_disable(struct no_os_pwm_desc *desc)
Disable PWM generator device.
Definition: axi_pwm.c:131
no_os_pwm_init_param::extra
void * extra
Definition: no_os_pwm.h:92
AXI_PWMGEN_CHX_PHASE
#define AXI_PWMGEN_CHX_PHASE(p, ch)
Definition: axi_pwm.c:64
no_os_pwm_desc
Structure representing an PWM generator device.
Definition: no_os_pwm.h:99
no_os_pwm_init_param::duty_cycle_ns
uint32_t duty_cycle_ns
Definition: no_os_pwm.h:78
AXI_PWMGEN_REG_CONFIG
#define AXI_PWMGEN_REG_CONFIG
Definition: axi_pwm.c:58
axi_pwm_desc::channel
uint32_t channel
Definition: axi_pwm_extra.h:75
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:269
axi_pwm_init_param
Structure holding the initialization parameters for axi PWM.
Definition: axi_pwm_extra.h:56
no_os_pwm_platform_ops
Structure holding PWM function pointers that point to the platform specific function.
Definition: no_os_pwm.h:131
AXI_PWMGEN_VERSION_MAJOR
#define AXI_PWMGEN_VERSION_MAJOR(x)
Definition: axi_pwm.c:73
no_os_pwm.h
Header file of PWM Interface.
no_os_pwm_desc::extra
void * extra
Definition: no_os_pwm.h:123
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:242
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:75
AXI_PWMGEN_TEST_DATA
#define AXI_PWMGEN_TEST_DATA
Definition: axi_pwm.c:66
AXI_PWMGEN_REG_NPWM
#define AXI_PWMGEN_REG_NPWM
Definition: axi_pwm.c:59
axi_pwm_desc::ref_clock_Hz
uint32_t ref_clock_Hz
Definition: axi_pwm_extra.h:73
axi_pwm_init_param::ref_clock_Hz
uint32_t ref_clock_Hz
Definition: axi_pwm_extra.h:60
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:283
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:73
no_os_pwm_init_param::phase_ns
uint32_t phase_ns
Definition: no_os_pwm.h:80
axi_pwm_init_param::base_addr
uint32_t base_addr
Definition: axi_pwm_extra.h:58
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:181
AXI_PWMGEN_CHX_DUTY
#define AXI_PWMGEN_CHX_DUTY(p, ch)
Definition: axi_pwm.c:62
axi_pwm_desc::ch_period
uint32_t ch_period
Definition: axi_pwm_extra.h:77
axi_pwm_ops
const struct no_os_pwm_platform_ops axi_pwm_ops
AXI specific PWM platform ops structure.
Definition: axi_pwm.c:412
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:389
AXI_PWMGEN_MAX_CHANNELS
#define AXI_PWMGEN_MAX_CHANNELS(p)
Definition: axi_pwm.c:70
axi_pwm_extra.h