| 166 | } |
| 167 | |
| 168 | static rt_err_t _pwm_control(struct rt_device_pwm *device, int cmd, void *arg) |
| 169 | { |
| 170 | struct pico_pwm *_pwm = rt_container_of(device, struct pico_pwm, pwm_device); |
| 171 | struct rt_pwm_configuration *configuration = (struct rt_pwm_configuration *)arg; |
| 172 | |
| 173 | switch (cmd) |
| 174 | { |
| 175 | case PWM_CMD_ENABLE: |
| 176 | pwm_set_enabled (_pwm->slice_num, RT_TRUE); |
| 177 | return RT_EOK; |
| 178 | case PWM_CMD_DISABLE: |
| 179 | pwm_set_enabled (_pwm->slice_num, RT_FALSE); |
| 180 | return RT_EOK; |
| 181 | case PWM_CMD_SET: |
| 182 | return _pwm_set(_pwm->slice_num, configuration); |
| 183 | case PWM_CMD_GET: |
| 184 | return _pwm_get(_pwm->slice_num, configuration); |
| 185 | default: |
| 186 | return -RT_EINVAL; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | static struct rt_pwm_ops _pwm_ops = |
| 191 | { |