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

Function control

bsp/loongson/ls1cdev/drivers/drv_pwm.c:77–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77static rt_err_t control(struct rt_device_pwm *device, int cmd, void *arg)
78{
79 rt_err_t result = RT_EOK;
80 struct rt_pwm_configuration * configuration = (struct rt_pwm_configuration *)arg;
81
82 rt_kprintf("drv_pwm.c control cmd: %d. \n", cmd);
83
84 if (cmd == PWM_CMD_ENABLE)
85 {
86 rt_kprintf("PWM_CMD_ENABLE\n");
87
88 pwm_info_t pwm_info;
89 switch ( configuration->channel)
90 {
91 case 0:
92 pwm_info.gpio = LS1C_PWM0_GPIO06;
93 //pwm_info.gpio = LS1C_PWM0_GPIO04;
94 break;
95 case 1:
96 pwm_info.gpio = LS1C_PWM1_GPIO92;
97 //pwm_info.gpio = LS1C_PWM1_GPIO05;
98 break;
99 case 2:
100 pwm_info.gpio = LS1C_PWM2_GPIO52;
101 //pwm_info.gpio = LS1C_PWM2_GPIO46;
102 break;
103 case 3:
104 pwm_info.gpio = LS1C_PWM3_GPIO47;
105 //pwm_info.gpio = LS1C_PWM3_GPIO53;
106 break;
107 default:
108 break;
109 }
110 pwm_info.mode = PWM_MODE_NORMAL;
111 pwm_info.duty = ( (float)configuration->pulse ) / ((float)configuration->period );
112 pwm_info.period_ns = configuration->period;
113 pwm_init(&pwm_info);
114 pwm_enable(&pwm_info);
115 }
116 else if (cmd == PWM_CMD_DISABLE)
117 {
118 rt_kprintf("PWM_CMD_DISABLE\n");
119 pwm_info_t pwm_info;
120 switch ( configuration->channel)
121 {
122 case 0:
123 pwm_info.gpio = LS1C_PWM0_GPIO06;
124 //pwm_info.gpio = LS1C_PWM0_GPIO04;
125 break;
126 case 1:
127 pwm_info.gpio = LS1C_PWM1_GPIO92;
128 //pwm_info.gpio = LS1C_PWM1_GPIO05;
129 break;
130 case 2:
131 pwm_info.gpio = LS1C_PWM2_GPIO52;
132 //pwm_info.gpio = LS1C_PWM2_GPIO46;
133 break;
134 case 3:

Callers

nothing calls this directly

Calls 6

rt_kprintfFunction · 0.85
setFunction · 0.70
getFunction · 0.70
pwm_initFunction · 0.50
pwm_enableFunction · 0.50
pwm_disableFunction · 0.50

Tested by

no test coverage detected