RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
bsps
arm
beagle
include
bsp
bbb-pwm.h
Go to the documentation of this file.
1
8
9
/*
10
* SPDX-License-Identifier: BSD-2-Clause
11
*
12
* Copyright (c) 2016 Punit Vara <punitvara@gmail.com>
13
*
14
* Redistribution and use in source and binary forms, with or without
15
* modification, are permitted provided that the following conditions
16
* are met:
17
* 1. Redistributions of source code must retain the above copyright
18
* notice, this list of conditions and the following disclaimer.
19
* 2. Redistributions in binary form must reproduce the above copyright
20
* notice, this list of conditions and the following disclaimer in the
21
* documentation and/or other materials provided with the distribution.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
* POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
40
41
#ifndef LIBBSP_ARM_BEAGLE_BBB_PWM_H
42
#define LIBBSP_ARM_BEAGLE_BBB_PWM_H
43
44
#ifdef __cplusplus
45
extern
"C"
{
46
#endif
/* __cplusplus */
47
51
#define BBB_CONTROL_CONF_GPMC_AD(n) (0x800 + (n * 4))
52
#define BBB_CONTROL_CONF_LCD_DATA(n) (0x8a0 + (n * 4))
53
54
55
typedef
enum
{
56
BBB_P8_13_2B = 3,
57
BBB_P8_19_2A,
58
BBB_P8_45_2A,
59
BBB_P8_46_2B,
60
BBB_P8_34_1B,
61
BBB_P8_36_1A,
62
BBB_P9_14_1A,
63
BBB_P9_16_1B,
64
BBB_P9_21_0B,
65
BBB_P9_22_0A,
66
BBB_P9_29_0B,
67
BBB_P9_31_0A
68
}bbb_pwm_pin_t;
69
70
#define BBB_P8_13_MUX_PWM 4
71
#define BBB_P8_19_MUX_PWM 4
72
#define BBB_P8_45_MUX_PWM 3
73
#define BBB_P8_46_MUX_PWM 3
74
#define BBB_P8_34_MUX_PWM 2
75
#define BBB_P8_36_MUX_PWM 2
76
#define BBB_P9_14_MUX_PWM 6
77
#define BBB_P9_16_MUX_PWM 6
78
#define BBB_P9_21_MUX_PWM 3
79
#define BBB_P9_22_MUX_PWM 3
80
#define BBB_P9_29_MUX_PWM 1
81
#define BBB_P9_31_MUX_PWM 1
82
#define BBB_PWM_FREQ_THRESHOLD 0.5f
83
87
97
bool
beagle_pwm_init
(
BBB_PWMSS
pwmss_id);
98
99
/* PWMSS setting
100
* set pulse argument of epwm module
101
*
102
* @param pwm_id : EPWMSS number , 0~2
103
* @param pwm_freq : frequency to be generated
104
* @param dutyA : Duty Cycle(in percentage) in PWM channel A
105
* @param dutyB : Duty Cycle(in percentage) in PWM channel B
106
*
107
* @return : 1 for success
108
* @return : 0 for failed
109
*
110
* @example : beagle_pwm_configure(0 , 50.0f , 50.0f , 25.0f); // Generate 50HZ pwm in PWM0 ,
111
* // duty cycle is 50% for ePWM0A , 25% for ePWM0B
112
*
113
* @Note :
114
* find an number nearst 65535 for TBPRD , to improve duty precision,
115
*
116
* Using big TBPRD can increase the range of CMPA and CMPB ,
117
* and it means we can get better precision on duty cycle.
118
*
119
* EX : 20.25% duty cycle
120
* on TBPRD = 62500 , CMPA = 12656.25 ( .25 rejection) , real duty : 20.2496% (12656 /62500)
121
* on TBPRD = 6250 , CMPA = 1265.625 ( .625 rejection), real duty : 20.24% (1265 6250)
122
* on TBPRD = 500 , CMPA = 101.25 ( .25 rejection) , real duty : 20.2% (101/500)
123
*
124
* Divisor = CLKDIV * HSPCLKDIV
125
* 1 TBPRD : 10 ns (default)
126
* 65535 TBPRD : 655350 ns
127
* 65535 TBPRD : 655350 * Divisor ns = X TBPRD : Cycle
128
*
129
* accrooding to that , we must find a Divisor value , let X nearest 65535 .
130
* so , Divisor must Nearest Cycle/655350
131
*/
132
int
beagle_pwm_configure(
BBB_PWMSS
pwm_id,
float
pwm_freq,
float
duty_a,
float
duty_b);
133
143
bool
beagle_pwm_enable
(
BBB_PWMSS
pwmid);
144
154
bool
beagle_pwm_disable
(
BBB_PWMSS
pwmid);
155
168
bool
beagle_pwm_pinmux_setup
(bbb_pwm_pin_t pin_no,
BBB_PWMSS
pwm_id);
169
180
bool
beagle_pwmss_is_running
(
unsigned
int
pwmss_id);
181
182
183
#ifdef __cplusplus
184
}
185
#endif
/* __cplusplus */
186
187
#endif
/* LIBBSP_ARM_BEAGLE_BBB_PWM_H */
beagle_pwm_disable
bool beagle_pwm_disable(BBB_PWMSS pwmid)
This API disables the particular PWM module.
beagle_pwm_enable
bool beagle_pwm_enable(BBB_PWMSS pwmid)
This API enables the particular PWM module.
beagle_pwmss_is_running
bool beagle_pwmss_is_running(unsigned int pwmss_id)
This function determines whether PWMSS-wide clocks enabled or not.
beagle_pwm_init
bool beagle_pwm_init(BBB_PWMSS pwmss_id)
BeagleBone Black PWM API.
beagle_pwm_pinmux_setup
bool beagle_pwm_pinmux_setup(bbb_pwm_pin_t pin_no, BBB_PWMSS pwm_id)
This function enables pinmuxing for PWM module.
BBB_PWMSS
BBB_PWMSS
The set of possible PWM subsystem module.
Definition
pwmss.h:58
Generated by
1.18.0