summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/T-HEAD_CB2201_CDK/csi/csi_driver/include/drv_pwm.h
blob: 9d585429aac5901a42a7308d8ee70595b865ee29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/******************************************************************************
 * @file     drv_pwm.h
 * @brief    header file for pwm driver
 * @version  V1.0
 * @date     02. June 2017
 ******************************************************************************/
#ifndef _CSI_PWM_H_
#define _CSI_PWM_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <drv_common.h>


/// definition for pwm handle.
typedef void *pwm_handle_t;

/****** PWM specific error codes *****/
typedef enum {
    EDRV_PWM_MODE  = (EDRV_SPECIFIC + 1),     ///< Specified Mode not supported
} drv_pwm_error_e;


/**
  \brief       Initialize PWM Interface. 1. Initializes the resources needed for the PWM interface 2.registers event callback function
  \param[in]   pwm_pin pin name of pwm
  \return      handle pwm handle to operate.
*/
pwm_handle_t drv_pwm_initialize(pin_t pwm_pin);

/**
  \brief       De-initialize PWM Interface. stops operation and releases the software resources used by the interface
  \param[in]   handle pwm handle to operate.
  \return      error code
*/
int32_t drv_pwm_uninitialize(pwm_handle_t handle);

/**
  \brief       config pwm mode.
  \param[in]   handle pwm handle to operate.
  \param[in]   sysclk  configured system clock.
  \param[in]   period_us  the PWM period in us
  \param[in]   duty      the PMW duty.  ( 0 - 10000 represents 0% - 100% ,other values are invalid)
  \return      error code
*/
int32_t drv_pwm_config(pwm_handle_t handle,
                       uint32_t sysclk,
                       uint32_t period_us,
                       uint32_t duty);

/**
  \brief       start generate pwm signal.
  \param[in]   handle pwm handle to operate.
  \return      error code
*/
int32_t drv_pwm_start(pwm_handle_t handle);

/**
  \brief       Stop generate pwm signal.
  \param[in]   handle pwm handle to operate.
  \return      error code
*/
int32_t drv_pwm_stop(pwm_handle_t handle);

/**
  \brief       Get PWM status.
  \param[in]   handle pwm handle to operate.
  \return      PWM status \ref pwm_status_t
pwm_status_t drv_pwm_get_status(pwm_handle_t handle);
*/

#ifdef __cplusplus
}
#endif

#endif /* _CSI_PWM_H_ */