1 /** mbed Microcontroller Library
2   ******************************************************************************
3   * @file    gpio_api.h
4   * @author
5   * @version V1.0.0
6   * @brief   This file provides following mbed GPIO API
7   ******************************************************************************
8   * @attention
9   *
10   * Copyright (c) 2006-2013 ARM Limited
11   *
12   * Licensed under the Apache License, Version 2.0 (the "License");
13   * you may not use this file except in compliance with the License.
14   * You may obtain a copy of the License at
15   *
16   *     http://www.apache.org/licenses/LICENSE-2.0
17   *
18   * Unless required by applicable law or agreed to in writing, software
19   * distributed under the License is distributed on an "AS IS" BASIS,
20   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21   * See the License for the specific language governing permissions and
22   * limitations under the License.
23   ******************************************************************************
24   */
25 #ifndef MBED_GPIO_API_H
26 #define MBED_GPIO_API_H
27 
28 #include "device.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /** @addtogroup gpio GPIO
35  *  @ingroup    hal
36  *  @brief      gpio functions
37  *  @{
38  */
39 
40 
41 ///@name Ameba Common
42 ///@{
43 
44 /**
45   * @brief  Initializes the GPIO device, include mode/direction/pull control registers.
46   * @param  obj: gpio object define in application software.
47   * @param  pin: PinName according to pinmux spec.
48   * @retval none
49   */
50 void gpio_init(gpio_t *obj, PinName pin);
51 
52 /**
53   * @brief  Deinitializes the GPIO device, include mode/direction/pull control registers.
54   * @param  obj: gpio object define in application software.
55   * @retval none
56   */
57 void gpio_deinit(gpio_t *obj);
58 
59 /**
60   * @brief  Set the given pin as GPIO.
61   * @param  pin: PinName according to pinmux spec.
62   * @retval : The given pin with GPIO function
63   */
64 uint32_t gpio_set(PinName pin);
65 
66 /**
67   * @brief  Set GPIO mode.
68   * @param  obj: gpio object define in application software.
69   * @param  mode: this parameter can be one of the following values:
70   *		@arg PullNone: HighZ, user can input high or low use this pin
71   *		@arg OpenDrain(is OpenDrain output): no pull + OUT + GPIO[gpio_bit] = 0
72   *		@arg PullDown: pull down
73   *		@arg PullUp: pull up
74   * @retval none
75   */
76 void gpio_mode(gpio_t *obj, PinMode mode);
77 
78 /**
79   * @brief  Set GPIO direction.
80   * @param  obj: gpio object define in application software.
81   * @param  direction: this parameter can be one of the following values:
82   *		@arg PIN_INPUT: this pin is input
83   *		@arg PIN_OUTPUT: this pin is output
84   * @retval none
85   */
86 void gpio_dir(gpio_t *obj, PinDirection direction);
87 
88 /**
89   * @brief  Sets value to the selected output port pin.
90   * @param  obj: gpio object define in application software.
91   * @param  value: specifies the value to be written to the selected pin
92   * 	This parameter can be one of the following values:
93   *		@arg 0: Pin state set to low
94   *		@arg 1: Pin state set to high
95   * @retval none
96   */
97 void gpio_write(gpio_t *obj, int value);
98 
99 /**
100   * @brief  Reads the specified gpio port pin.
101   * @param  obj: gpio object define in application software.
102   * @retval 1: pin state is high
103   * @retval 0: pin state is low
104   */
105 int  gpio_read(gpio_t *obj);
106 
107 ///@}
108 
109 /*\@}*/
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif//MBED_GPIO_API_H
116