1 /**
2     *****************************************************************************
3     * @file     cmem7_gpio.h
4     *
5     * @brief    CMEM7 GPIO header file
6     *
7     *
8     * @version  V1.0
9     * @date     3. September 2013
10     *
11     * @note
12     *
13     *****************************************************************************
14     * @attention
15     *
16     * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
17     * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
18     * TIME. AS A RESULT, CAPITAL-MICRO SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
19     * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
20     * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
21     * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
22     *
23     * <h2><center>&copy; COPYRIGHT 2013 Capital-micro </center></h2>
24     *****************************************************************************
25     */
26 
27 #ifndef __CMEM7_GPIO_H
28 #define __CMEM7_GPIO_H
29 
30 #ifdef __cplusplus
31  extern "C" {
32 #endif
33 
34 #include "cmem7.h"
35 #include "cmem7_conf.h"
36 
37 /** @defgroup GPIO_GROUP
38   * @{
39   */
40 typedef enum {
41     GPIO_GROUP_GPIO,
42 } GPIO_GROUP;
43 
44 #define IS_GPIO_GROUP(GROUP)  (((GROUP) == GPIO_GROUP_GPIO))
45 /**
46   * @}
47   */
48 
49 /** @defgroup GPIO_PWM_CHANNEL
50   * @{
51   */
52 typedef enum {
53     GPIO_PWM_CHANNEL_GPIO_31,
54 } GPIO_PWM_CHANNEL;
55 
56 #define IS_GPIO_PWM_CHANNEL(CHANNEL)  (((CHANNEL) == GPIO_PWM_CHANNEL_GPIO_31))
57 /**
58   * @}
59   */
60 
61 /**
62   * @brief  GPIO initialization
63   * @note   This function should be called at first before any other interfaces.
64     * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
65     * @param[in] PositiveTrigger Positive edge interrupt trigger if true, or negative edge
66   * @retval None
67     */
68 void GPIO_Init(uint8_t Group, uint32_t PositiveTrigger);
69 
70 /**
71   * @brief  Enable or disable GPIO output in the specific group.
72     * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
73     * @param[in] Enable each bit indicates if the corresponding GPIO pin
74     *                       in the specific GPIO group is enable or not
75   * @retval None
76     */
77 void GPIO_EnableOutput(uint8_t Group, uint32_t Enable);
78 
79 /**
80   * @brief  Enable or disable GPIO interrupt in the specific group.
81     * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
82     * @param[in] Enable each bit indicates if the corresponding GPIO pin interrupt
83     *                       in the specific GPIO group is enable or not
84   * @retval None
85     */
86 void GPIO_EnableInt(uint8_t Group, uint32_t Enable);
87 
88 /**
89   * @brief  Check specific interrupts are set or not
90     * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
91     * @retval uint32_t each bit indicates if the corresponding GPIO pin interrupt
92     *                   in the specific GPIO group is set or not
93     */
94 uint32_t GPIO_GetIntStatus(uint8_t Group);
95 
96 /**
97   * @brief  Clear GPIO interrupt in the specific group.
98     * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
99     * @param[in] Clear each bit indicates if the corresponding GPIO pin interrupt
100     *                       in the specific GPIO group is clear or not
101   * @retval None
102     */
103 void GPIO_ClearInt(uint8_t Group, uint32_t Clear);
104 
105 /**
106   * @brief  Get value of each GPIO pin in the specific group
107     * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
108     * @retval uint32_t each bit indicates value of the corresponding GPIO pin
109     *                   in the specific GPIO group
110     */
111 uint32_t GPIO_Read(uint8_t Group);
112 
113 /**
114   * @brief  Set value of each GPIO pin in the specific group
115     * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
116     * @param[in] Unmask each bit indicates value of the corresponding GPIO pin
117     *                        in the specific GPIO group is set or not
118     * @param[in] data each bit indicates value of the corresponding GPIO pin
119     *                        in the specific GPIO group to be set
120   * @retval None
121     */
122 void GPIO_Write(uint8_t Group, uint32_t Unmask, uint32_t data);
123 
124 /**
125   * @brief  Initialize PWM for the specific GPIO pin
126     * @note     It can work before call GPIO_EnableOutput for the specific GPIO pin
127     * @param[in] Channel PWM channel, which is a value of @ref GPIO_PWM_CHANNEL
128     * @param[in] HighLevelNanoSecond Nanosecond which high level lasts
129     * @param[in] LowLevelNanoSecond Nanosecond which low level lasts
130   * @retval None
131     * @see      GPIO_EnableOutput
132     */
133 void GPIO_InitPwm(uint8_t Channel, uint32_t HighLevelNanoSecond, uint32_t LowLevelNanoSecond);
134 
135 /**
136   * @brief  Enable or disable GPIO PWM in the specific channel.
137     *   @param[in] Channel PWM channel, which is a value of @ref GPIO_PWM_CHANNEL
138     * @param[in] Enable The bit indicates if the specific channel is enable or not
139   * @retval None
140     */
141 void GPIO_EnablePwm(uint8_t Channel, BOOL Enable);
142 
143 
144 
145 /**
146   xjf 20150324
147 
148 **/
149 void GPIO_SetBits(uint32_t mask);
150 void GPIO_clrBits(uint32_t mask);
151 uint32_t GPIO_getBits(uint32_t mask);
152 
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 #endif /* __CMEM7_GPIO_H */
159 
160