RTEMS  5.0.0
bbb-pwm.h
Go to the documentation of this file.
1 
21 #ifndef LIBBSP_ARM_BEAGLE_BBB_PWM_H
22 #define LIBBSP_ARM_BEAGLE_BBB_PWM_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
27 
31 #define BBB_CONTROL_CONF_GPMC_AD(n) (0x800 + (n * 4))
32 #define BBB_CONTROL_CONF_LCD_DATA(n) (0x8a0 + (n * 4))
33 
39 typedef enum{
40  BBB_PWMSS0 = 0,
41  BBB_PWMSS1,
42  BBB_PWMSS2,
43  BBB_PWMSS_COUNT
44 }BBB_PWMSS;
45 
46 typedef enum{
47  BBB_P8_13_2B = 3,
48  BBB_P8_19_2A,
49  BBB_P8_45_2A,
50  BBB_P8_46_2B,
51  BBB_P8_34_1B,
52  BBB_P8_36_1A,
53  BBB_P9_14_1A,
54  BBB_P9_16_1B,
55  BBB_P9_21_0B,
56  BBB_P9_22_0A,
57  BBB_P9_29_0B,
58  BBB_P9_31_0A
59 }bbb_pwm_pin_t;
60 
61 #define BBB_P8_13_MUX_PWM 4
62 #define BBB_P8_19_MUX_PWM 4
63 #define BBB_P8_45_MUX_PWM 3
64 #define BBB_P8_46_MUX_PWM 3
65 #define BBB_P8_34_MUX_PWM 2
66 #define BBB_P8_36_MUX_PWM 2
67 #define BBB_P9_14_MUX_PWM 6
68 #define BBB_P9_16_MUX_PWM 6
69 #define BBB_P9_21_MUX_PWM 3
70 #define BBB_P9_22_MUX_PWM 3
71 #define BBB_P9_29_MUX_PWM 1
72 #define BBB_P9_31_MUX_PWM 1
73 #define BBB_PWM_FREQ_THRESHOLD 0.5f
74 
88 bool beagle_pwm_init(BBB_PWMSS pwmss_id);
89 
90 /* PWMSS setting
91  * set pulse argument of epwm module
92  *
93  * @param pwm_id : EPWMSS number , 0~2
94  * @param pwm_freq : frequency to be generated
95  * @param dutyA : Duty Cycle(in percentage) in PWM channel A
96  * @param dutyB : Duty Cycle(in percentage) in PWM channel B
97  *
98  * @return : 1 for success
99  * @return : 0 for failed
100  *
101  * @example : beagle_pwm_configure(0 , 50.0f , 50.0f , 25.0f); // Generate 50HZ pwm in PWM0 ,
102  * // duty cycle is 50% for ePWM0A , 25% for ePWM0B
103  *
104  * @Note :
105  * find an number nearst 65535 for TBPRD , to improve duty precision,
106  *
107  * Using big TBPRD can increase the range of CMPA and CMPB ,
108  * and it means we can get better precision on duty cycle.
109  *
110  * EX : 20.25% duty cycle
111  * on TBPRD = 62500 , CMPA = 12656.25 ( .25 rejection) , real duty : 20.2496% (12656 /62500)
112  * on TBPRD = 6250 , CMPA = 1265.625 ( .625 rejection), real duty : 20.24% (1265 6250)
113  * on TBPRD = 500 , CMPA = 101.25 ( .25 rejection) , real duty : 20.2% (101/500)
114  *
115  * Divisor = CLKDIV * HSPCLKDIV
116  * 1 TBPRD : 10 ns (default)
117  * 65535 TBPRD : 655350 ns
118  * 65535 TBPRD : 655350 * Divisor ns = X TBPRD : Cycle
119  *
120  * accrooding to that , we must find a Divisor value , let X nearest 65535 .
121  * so , Divisor must Nearest Cycle/655350
122  */
123 int beagle_pwm_configure(BBB_PWMSS pwm_id, float pwm_freq, float duty_a, float duty_b);
124 
134 bool beagle_pwm_enable(BBB_PWMSS pwmid);
135 
145 bool beagle_pwm_disable(BBB_PWMSS pwmid);
146 
159 bool beagle_pwm_pinmux_setup(bbb_pwm_pin_t pin_no, BBB_PWMSS pwm_id);
160 
171 bool beagle_pwmss_is_running(unsigned int pwmss_id);
172 
173 
174 #ifdef __cplusplus
175 }
176 #endif /* __cplusplus */
177 
178 #endif /* LIBBSP_ARM_BEAGLE_BBB_PWM_H */
BBB_PWMSS
The set of possible PWM subsystem module.
Definition: bbb-pwm.h:39
bool beagle_pwm_pinmux_setup(bbb_pwm_pin_t pin_no, BBB_PWMSS pwm_id)
This function enables pinmuxing for PWM module.
bool beagle_pwm_disable(BBB_PWMSS pwmid)
This API disables the particular PWM module.
bool beagle_pwmss_is_running(unsigned int pwmss_id)
This function determines whether PWMSS-wide clocks enabled or not.
bool beagle_pwm_enable(BBB_PWMSS pwmid)
This API enables the particular PWM module.
bool beagle_pwm_init(BBB_PWMSS pwmss_id)
BeagleBone Black PWM API.