summaryrefslogtreecommitdiff
path: root/bsp/CME_M7/StdPeriph_Driver/inc/cmem7_gpio.h
blob: 269bef9ba21af3a723be7214fb1a738746993194 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/**
    *****************************************************************************
    * @file     cmem7_gpio.h
    *
    * @brief    CMEM7 GPIO header file
    *
    *
    * @version  V1.0
    * @date     3. September 2013
    *
    * @note
    *
    *****************************************************************************
    * @attention
    *
    * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
    * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
    * TIME. AS A RESULT, CAPITAL-MICRO SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
    * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
    * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
    * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
    *
    * <h2><center>&copy; COPYRIGHT 2013 Capital-micro </center></h2>
    *****************************************************************************
    */

#ifndef __CMEM7_GPIO_H
#define __CMEM7_GPIO_H

#ifdef __cplusplus
 extern "C" {
#endif

#include "cmem7.h"
#include "cmem7_conf.h"

/** @defgroup GPIO_GROUP
  * @{
  */
typedef enum {
    GPIO_GROUP_GPIO,
} GPIO_GROUP;

#define IS_GPIO_GROUP(GROUP)  (((GROUP) == GPIO_GROUP_GPIO))
/**
  * @}
  */

/** @defgroup GPIO_PWM_CHANNEL
  * @{
  */
typedef enum {
    GPIO_PWM_CHANNEL_GPIO_31,
} GPIO_PWM_CHANNEL;

#define IS_GPIO_PWM_CHANNEL(CHANNEL)  (((CHANNEL) == GPIO_PWM_CHANNEL_GPIO_31))
/**
  * @}
  */

/**
  * @brief  GPIO initialization
  * @note   This function should be called at first before any other interfaces.
    * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
    * @param[in] PositiveTrigger Positive edge interrupt trigger if true, or negative edge
  * @retval None
    */
void GPIO_Init(uint8_t Group, uint32_t PositiveTrigger);

/**
  * @brief  Enable or disable GPIO output in the specific group.
    * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
    * @param[in] Enable each bit indicates if the corresponding GPIO pin
    *                       in the specific GPIO group is enable or not
  * @retval None
    */
void GPIO_EnableOutput(uint8_t Group, uint32_t Enable);

/**
  * @brief  Enable or disable GPIO interrupt in the specific group.
    * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
    * @param[in] Enable each bit indicates if the corresponding GPIO pin interrupt
    *                       in the specific GPIO group is enable or not
  * @retval None
    */
void GPIO_EnableInt(uint8_t Group, uint32_t Enable);

/**
  * @brief  Check specific interrupts are set or not
    * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
    * @retval uint32_t each bit indicates if the corresponding GPIO pin interrupt
    *                   in the specific GPIO group is set or not
    */
uint32_t GPIO_GetIntStatus(uint8_t Group);

/**
  * @brief  Clear GPIO interrupt in the specific group.
    * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
    * @param[in] Clear each bit indicates if the corresponding GPIO pin interrupt
    *                       in the specific GPIO group is clear or not
  * @retval None
    */
void GPIO_ClearInt(uint8_t Group, uint32_t Clear);

/**
  * @brief  Get value of each GPIO pin in the specific group
    * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
    * @retval uint32_t each bit indicates value of the corresponding GPIO pin
    *                   in the specific GPIO group
    */
uint32_t GPIO_Read(uint8_t Group);

/**
  * @brief  Set value of each GPIO pin in the specific group
    * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
    * @param[in] Unmask each bit indicates value of the corresponding GPIO pin
    *                        in the specific GPIO group is set or not
    * @param[in] data each bit indicates value of the corresponding GPIO pin
    *                        in the specific GPIO group to be set
  * @retval None
    */
void GPIO_Write(uint8_t Group, uint32_t Unmask, uint32_t data);

/**
  * @brief  Initialize PWM for the specific GPIO pin
    * @note     It can work before call GPIO_EnableOutput for the specific GPIO pin
    * @param[in] Channel PWM channel, which is a value of @ref GPIO_PWM_CHANNEL
    * @param[in] HighLevelNanoSecond Nanosecond which high level lasts
    * @param[in] LowLevelNanoSecond Nanosecond which low level lasts
  * @retval None
    * @see      GPIO_EnableOutput
    */
void GPIO_InitPwm(uint8_t Channel, uint32_t HighLevelNanoSecond, uint32_t LowLevelNanoSecond);

/**
  * @brief  Enable or disable GPIO PWM in the specific channel.
    *   @param[in] Channel PWM channel, which is a value of @ref GPIO_PWM_CHANNEL
    * @param[in] Enable The bit indicates if the specific channel is enable or not
  * @retval None
    */
void GPIO_EnablePwm(uint8_t Channel, BOOL Enable);



/**
  xjf 20150324

**/
void GPIO_SetBits(uint32_t mask);
void GPIO_clrBits(uint32_t mask);
uint32_t GPIO_getBits(uint32_t mask);


#ifdef __cplusplus
}
#endif

#endif /* __CMEM7_GPIO_H */