]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/T-HEAD_CB2201_CDK/csi/csi_driver/include/drv_pwm.h
Introduce a port for T-HEAD CK802. A simple demo for T-HEAD CB2201 is also included.
[freertos] / FreeRTOS / Demo / T-HEAD_CB2201_CDK / csi / csi_driver / include / drv_pwm.h
1 /*
2  * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 /******************************************************************************
17  * @file     drv_pwm.h
18  * @brief    header file for pwm driver
19  * @version  V1.0
20  * @date     02. June 2017
21  ******************************************************************************/
22 #ifndef _CSI_PWM_H_
23 #define _CSI_PWM_H_
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <stdint.h>
30 #include <drv_common.h>
31
32
33 /// definition for pwm handle.
34 typedef void *pwm_handle_t;
35
36 /****** PWM specific error codes *****/
37 typedef enum {
38     EDRV_PWM_MODE  = (EDRV_SPECIFIC + 1),     ///< Specified Mode not supported
39 } drv_pwm_error_e;
40
41
42 /**
43   \brief       Initialize PWM Interface. 1. Initializes the resources needed for the PWM interface 2.registers event callback function
44   \param[in]   pwm_pin pin name of pwm
45   \return      handle pwm handle to operate.
46 */
47 pwm_handle_t drv_pwm_initialize(pin_t pwm_pin);
48
49 /**
50   \brief       De-initialize PWM Interface. stops operation and releases the software resources used by the interface
51   \param[in]   handle pwm handle to operate.
52   \return      error code
53 */
54 int32_t drv_pwm_uninitialize(pwm_handle_t handle);
55
56 /**
57   \brief       config pwm mode.
58   \param[in]   handle pwm handle to operate.
59   \param[in]   sysclk  configured system clock.
60   \param[in]   period_us  the PWM period in us
61   \param[in]   duty      the PMW duty.  ( 0 - 10000 represents 0% - 100% ,other values are invalid)
62   \return      error code
63 */
64 int32_t drv_pwm_config(pwm_handle_t handle,
65                        uint32_t sysclk,
66                        uint32_t period_us,
67                        uint32_t duty);
68
69 /**
70   \brief       start generate pwm signal.
71   \param[in]   handle pwm handle to operate.
72   \return      error code
73 */
74 int32_t drv_pwm_start(pwm_handle_t handle);
75
76 /**
77   \brief       Stop generate pwm signal.
78   \param[in]   handle pwm handle to operate.
79   \return      error code
80 */
81 int32_t drv_pwm_stop(pwm_handle_t handle);
82
83 /**
84   \brief       Get PWM status.
85   \param[in]   handle pwm handle to operate.
86   \return      PWM status \ref pwm_status_t
87 pwm_status_t drv_pwm_get_status(pwm_handle_t handle);
88 */
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif /* _CSI_PWM_H_ */