Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Fri Jun 02 19:35:26 2017 +0000
Revision:
45:8b0bee6baf38
Parent:
18:6a4db94011d3
Final CAMM AAMC Working Code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1
sahilmgandhi 18:6a4db94011d3 2 /** \addtogroup hal */
sahilmgandhi 18:6a4db94011d3 3 /** @{*/
sahilmgandhi 18:6a4db94011d3 4 /* mbed Microcontroller Library
sahilmgandhi 18:6a4db94011d3 5 * Copyright (c) 2006-2013 ARM Limited
sahilmgandhi 18:6a4db94011d3 6 *
sahilmgandhi 18:6a4db94011d3 7 * Licensed under the Apache License, Version 2.0 (the "License");
sahilmgandhi 18:6a4db94011d3 8 * you may not use this file except in compliance with the License.
sahilmgandhi 18:6a4db94011d3 9 * You may obtain a copy of the License at
sahilmgandhi 18:6a4db94011d3 10 *
sahilmgandhi 18:6a4db94011d3 11 * http://www.apache.org/licenses/LICENSE-2.0
sahilmgandhi 18:6a4db94011d3 12 *
sahilmgandhi 18:6a4db94011d3 13 * Unless required by applicable law or agreed to in writing, software
sahilmgandhi 18:6a4db94011d3 14 * distributed under the License is distributed on an "AS IS" BASIS,
sahilmgandhi 18:6a4db94011d3 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sahilmgandhi 18:6a4db94011d3 16 * See the License for the specific language governing permissions and
sahilmgandhi 18:6a4db94011d3 17 * limitations under the License.
sahilmgandhi 18:6a4db94011d3 18 */
sahilmgandhi 18:6a4db94011d3 19 #ifndef MBED_GPIO_API_H
sahilmgandhi 18:6a4db94011d3 20 #define MBED_GPIO_API_H
sahilmgandhi 18:6a4db94011d3 21
sahilmgandhi 18:6a4db94011d3 22 #include <stdint.h>
sahilmgandhi 18:6a4db94011d3 23 #include "device.h"
sahilmgandhi 18:6a4db94011d3 24
sahilmgandhi 18:6a4db94011d3 25 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 26 extern "C" {
sahilmgandhi 18:6a4db94011d3 27 #endif
sahilmgandhi 18:6a4db94011d3 28
sahilmgandhi 18:6a4db94011d3 29 /**
sahilmgandhi 18:6a4db94011d3 30 * \defgroup hal_gpio GPIO HAL functions
sahilmgandhi 18:6a4db94011d3 31 * @{
sahilmgandhi 18:6a4db94011d3 32 */
sahilmgandhi 18:6a4db94011d3 33
sahilmgandhi 18:6a4db94011d3 34 /** Set the given pin as GPIO
sahilmgandhi 18:6a4db94011d3 35 *
sahilmgandhi 18:6a4db94011d3 36 * @param pin The pin to be set as GPIO
sahilmgandhi 18:6a4db94011d3 37 * @return The GPIO port mask for this pin
sahilmgandhi 18:6a4db94011d3 38 **/
sahilmgandhi 18:6a4db94011d3 39 uint32_t gpio_set(PinName pin);
sahilmgandhi 18:6a4db94011d3 40 /* Checks if gpio object is connected (pin was not initialized with NC)
sahilmgandhi 18:6a4db94011d3 41 * @param pin The pin to be set as GPIO
sahilmgandhi 18:6a4db94011d3 42 * @return 0 if port is initialized with NC
sahilmgandhi 18:6a4db94011d3 43 **/
sahilmgandhi 18:6a4db94011d3 44 int gpio_is_connected(const gpio_t *obj);
sahilmgandhi 18:6a4db94011d3 45
sahilmgandhi 18:6a4db94011d3 46 /** Initialize the GPIO pin
sahilmgandhi 18:6a4db94011d3 47 *
sahilmgandhi 18:6a4db94011d3 48 * @param obj The GPIO object to initialize
sahilmgandhi 18:6a4db94011d3 49 * @param pin The GPIO pin to initialize
sahilmgandhi 18:6a4db94011d3 50 */
sahilmgandhi 18:6a4db94011d3 51 void gpio_init(gpio_t *obj, PinName pin);
sahilmgandhi 18:6a4db94011d3 52
sahilmgandhi 18:6a4db94011d3 53 /** Set the input pin mode
sahilmgandhi 18:6a4db94011d3 54 *
sahilmgandhi 18:6a4db94011d3 55 * @param obj The GPIO object
sahilmgandhi 18:6a4db94011d3 56 * @param mode The pin mode to be set
sahilmgandhi 18:6a4db94011d3 57 */
sahilmgandhi 18:6a4db94011d3 58 void gpio_mode(gpio_t *obj, PinMode mode);
sahilmgandhi 18:6a4db94011d3 59
sahilmgandhi 18:6a4db94011d3 60 /** Set the pin direction
sahilmgandhi 18:6a4db94011d3 61 *
sahilmgandhi 18:6a4db94011d3 62 * @param obj The GPIO object
sahilmgandhi 18:6a4db94011d3 63 * @param direction The pin direction to be set
sahilmgandhi 18:6a4db94011d3 64 */
sahilmgandhi 18:6a4db94011d3 65 void gpio_dir(gpio_t *obj, PinDirection direction);
sahilmgandhi 18:6a4db94011d3 66
sahilmgandhi 18:6a4db94011d3 67 /** Set the output value
sahilmgandhi 18:6a4db94011d3 68 *
sahilmgandhi 18:6a4db94011d3 69 * @param obj The GPIO object
sahilmgandhi 18:6a4db94011d3 70 * @param value The value to be set
sahilmgandhi 18:6a4db94011d3 71 */
sahilmgandhi 18:6a4db94011d3 72 void gpio_write(gpio_t *obj, int value);
sahilmgandhi 18:6a4db94011d3 73
sahilmgandhi 18:6a4db94011d3 74 /** Read the input value
sahilmgandhi 18:6a4db94011d3 75 *
sahilmgandhi 18:6a4db94011d3 76 * @param obj The GPIO object
sahilmgandhi 18:6a4db94011d3 77 * @return An integer value 1 or 0
sahilmgandhi 18:6a4db94011d3 78 */
sahilmgandhi 18:6a4db94011d3 79 int gpio_read(gpio_t *obj);
sahilmgandhi 18:6a4db94011d3 80
sahilmgandhi 18:6a4db94011d3 81 // the following functions are generic and implemented in the common gpio.c file
sahilmgandhi 18:6a4db94011d3 82 // TODO: fix, will be moved to the common gpio header file
sahilmgandhi 18:6a4db94011d3 83
sahilmgandhi 18:6a4db94011d3 84 /** Init the input pin and set mode to PullDefault
sahilmgandhi 18:6a4db94011d3 85 *
sahilmgandhi 18:6a4db94011d3 86 * @param obj The GPIO object
sahilmgandhi 18:6a4db94011d3 87 * @param pin The pin name
sahilmgandhi 18:6a4db94011d3 88 */
sahilmgandhi 18:6a4db94011d3 89 void gpio_init_in(gpio_t* gpio, PinName pin);
sahilmgandhi 18:6a4db94011d3 90
sahilmgandhi 18:6a4db94011d3 91 /** Init the input pin and set the mode
sahilmgandhi 18:6a4db94011d3 92 *
sahilmgandhi 18:6a4db94011d3 93 * @param obj The GPIO object
sahilmgandhi 18:6a4db94011d3 94 * @param pin The pin name
sahilmgandhi 18:6a4db94011d3 95 * @param mode The pin mode to be set
sahilmgandhi 18:6a4db94011d3 96 */
sahilmgandhi 18:6a4db94011d3 97 void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode);
sahilmgandhi 18:6a4db94011d3 98
sahilmgandhi 18:6a4db94011d3 99 /** Init the output pin as an output, with predefined output value 0
sahilmgandhi 18:6a4db94011d3 100 *
sahilmgandhi 18:6a4db94011d3 101 * @param obj The GPIO object
sahilmgandhi 18:6a4db94011d3 102 * @param pin The pin name
sahilmgandhi 18:6a4db94011d3 103 * @return An integer value 1 or 0
sahilmgandhi 18:6a4db94011d3 104 */
sahilmgandhi 18:6a4db94011d3 105 void gpio_init_out(gpio_t* gpio, PinName pin);
sahilmgandhi 18:6a4db94011d3 106
sahilmgandhi 18:6a4db94011d3 107 /** Init the pin as an output and set the output value
sahilmgandhi 18:6a4db94011d3 108 *
sahilmgandhi 18:6a4db94011d3 109 * @param obj The GPIO object
sahilmgandhi 18:6a4db94011d3 110 * @param pin The pin name
sahilmgandhi 18:6a4db94011d3 111 * @param value The value to be set
sahilmgandhi 18:6a4db94011d3 112 */
sahilmgandhi 18:6a4db94011d3 113 void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value);
sahilmgandhi 18:6a4db94011d3 114
sahilmgandhi 18:6a4db94011d3 115 /** Init the pin to be in/out
sahilmgandhi 18:6a4db94011d3 116 *
sahilmgandhi 18:6a4db94011d3 117 * @param obj The GPIO object
sahilmgandhi 18:6a4db94011d3 118 * @param pin The pin name
sahilmgandhi 18:6a4db94011d3 119 * @param direction The pin direction to be set
sahilmgandhi 18:6a4db94011d3 120 * @param mode The pin mode to be set
sahilmgandhi 18:6a4db94011d3 121 * @param value The value to be set for an output pin
sahilmgandhi 18:6a4db94011d3 122 */
sahilmgandhi 18:6a4db94011d3 123 void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value);
sahilmgandhi 18:6a4db94011d3 124
sahilmgandhi 18:6a4db94011d3 125 /**@}*/
sahilmgandhi 18:6a4db94011d3 126
sahilmgandhi 18:6a4db94011d3 127 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 128 }
sahilmgandhi 18:6a4db94011d3 129 #endif
sahilmgandhi 18:6a4db94011d3 130
sahilmgandhi 18:6a4db94011d3 131 #endif
sahilmgandhi 18:6a4db94011d3 132
sahilmgandhi 18:6a4db94011d3 133 /** @}*/