mbed os with nrf51 internal bandgap enabled to read battery level

Dependents:   BLE_file_test BLE_Blink ExternalEncoder

Committer:
elessair
Date:
Sun Oct 23 15:10:02 2016 +0000
Revision:
0:f269e3021894
Initial commit

Who changed what in which revision?

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