MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / pwm_enable

Function pwm_enable

bsp/loongson/ls1cdev/libraries/ls1c_pwm.c:84–120  ·  view source on GitHub ↗

* ʹ��PWM * @pwm_info PWMn����ϸ��Ϣ */

Source from the content-addressed store, hash-verified

82 * @pwm_info PWMn����ϸ��Ϣ
83 */
84void pwm_enable(pwm_info_t *pwm_info)
85{
86 unsigned int pwm_reg_base = 0;
87 unsigned int ctrl = 0;
88
89 // ������
90 if (NULL == pwm_info)
91 {
92 return ;
93 }
94
95 // ��ȡ����ַ
96 pwm_reg_base = pwm_get_reg_base(pwm_info->gpio);
97
98 // ���������
99 reg_write_32(0, (volatile unsigned int *)(pwm_reg_base + LS1C_PWM_CNTR));
100
101 // ���ÿ��ƼĴ���
102 ctrl = (0 << LS1C_PWM_INT_LRC_EN)
103 | (0 << LS1C_PWM_INT_HRC_EN)
104 | (0 << LS1C_PWM_CNTR_RST)
105 | (0 << LS1C_PWM_INT_SR)
106 | (0 << LS1C_PWM_INTEN)
107 | (0 << LS1C_PWM_OE)
108 | (1 << LS1C_PWM_CNT_EN);
109 if (PWM_MODE_PULSE == pwm_info->mode) // ������
110 {
111 ctrl |= (1 << LS1C_PWM_SINGLE);
112 }
113 else // ��������
114 {
115 ctrl &= ~(1 << LS1C_PWM_SINGLE);
116 }
117 reg_write_32(ctrl, (volatile unsigned int *)(pwm_reg_base + LS1C_PWM_CTRL));
118
119 return ;
120}
121
122
123

Callers 3

pwm_initFunction · 0.70
controlFunction · 0.50
pwminitFunction · 0.50

Calls 2

pwm_get_reg_baseFunction · 0.85
reg_write_32Function · 0.70

Tested by

no test coverage detected