Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:5c4d7b2438d3 1 /* mbed Microcontroller Library
switches 0:5c4d7b2438d3 2 * Copyright (c) 2006-2013 ARM Limited
switches 0:5c4d7b2438d3 3 *
switches 0:5c4d7b2438d3 4 * Licensed under the Apache License, Version 2.0 (the "License");
switches 0:5c4d7b2438d3 5 * you may not use this file except in compliance with the License.
switches 0:5c4d7b2438d3 6 * You may obtain a copy of the License at
switches 0:5c4d7b2438d3 7 *
switches 0:5c4d7b2438d3 8 * http://www.apache.org/licenses/LICENSE-2.0
switches 0:5c4d7b2438d3 9 *
switches 0:5c4d7b2438d3 10 * Unless required by applicable law or agreed to in writing, software
switches 0:5c4d7b2438d3 11 * distributed under the License is distributed on an "AS IS" BASIS,
switches 0:5c4d7b2438d3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
switches 0:5c4d7b2438d3 13 * See the License for the specific language governing permissions and
switches 0:5c4d7b2438d3 14 * limitations under the License.
switches 0:5c4d7b2438d3 15 */
switches 0:5c4d7b2438d3 16 #ifndef MBED_INTERRUPTIN_H
switches 0:5c4d7b2438d3 17 #define MBED_INTERRUPTIN_H
switches 0:5c4d7b2438d3 18
switches 0:5c4d7b2438d3 19 #include "platform/platform.h"
switches 0:5c4d7b2438d3 20
switches 0:5c4d7b2438d3 21 #if DEVICE_INTERRUPTIN
switches 0:5c4d7b2438d3 22
switches 0:5c4d7b2438d3 23 #include "hal/gpio_api.h"
switches 0:5c4d7b2438d3 24 #include "hal/gpio_irq_api.h"
switches 0:5c4d7b2438d3 25 #include "platform/Callback.h"
switches 0:5c4d7b2438d3 26 #include "platform/critical.h"
switches 0:5c4d7b2438d3 27 #include "platform/toolchain.h"
switches 0:5c4d7b2438d3 28
switches 0:5c4d7b2438d3 29 namespace mbed {
switches 0:5c4d7b2438d3 30 /** \addtogroup drivers */
switches 0:5c4d7b2438d3 31 /** @{*/
switches 0:5c4d7b2438d3 32
switches 0:5c4d7b2438d3 33 /** A digital interrupt input, used to call a function on a rising or falling edge
switches 0:5c4d7b2438d3 34 *
switches 0:5c4d7b2438d3 35 * @Note Synchronization level: Interrupt safe
switches 0:5c4d7b2438d3 36 *
switches 0:5c4d7b2438d3 37 * Example:
switches 0:5c4d7b2438d3 38 * @code
switches 0:5c4d7b2438d3 39 * // Flash an LED while waiting for events
switches 0:5c4d7b2438d3 40 *
switches 0:5c4d7b2438d3 41 * #include "mbed.h"
switches 0:5c4d7b2438d3 42 *
switches 0:5c4d7b2438d3 43 * InterruptIn event(p16);
switches 0:5c4d7b2438d3 44 * DigitalOut led(LED1);
switches 0:5c4d7b2438d3 45 *
switches 0:5c4d7b2438d3 46 * void trigger() {
switches 0:5c4d7b2438d3 47 * printf("triggered!\n");
switches 0:5c4d7b2438d3 48 * }
switches 0:5c4d7b2438d3 49 *
switches 0:5c4d7b2438d3 50 * int main() {
switches 0:5c4d7b2438d3 51 * event.rise(&trigger);
switches 0:5c4d7b2438d3 52 * while(1) {
switches 0:5c4d7b2438d3 53 * led = !led;
switches 0:5c4d7b2438d3 54 * wait(0.25);
switches 0:5c4d7b2438d3 55 * }
switches 0:5c4d7b2438d3 56 * }
switches 0:5c4d7b2438d3 57 * @endcode
switches 0:5c4d7b2438d3 58 */
switches 0:5c4d7b2438d3 59 class InterruptIn {
switches 0:5c4d7b2438d3 60
switches 0:5c4d7b2438d3 61 public:
switches 0:5c4d7b2438d3 62
switches 0:5c4d7b2438d3 63 /** Create an InterruptIn connected to the specified pin
switches 0:5c4d7b2438d3 64 *
switches 0:5c4d7b2438d3 65 * @param pin InterruptIn pin to connect to
switches 0:5c4d7b2438d3 66 * @param name (optional) A string to identify the object
switches 0:5c4d7b2438d3 67 */
switches 0:5c4d7b2438d3 68 InterruptIn(PinName pin);
switches 0:5c4d7b2438d3 69 virtual ~InterruptIn();
switches 0:5c4d7b2438d3 70
switches 0:5c4d7b2438d3 71 /** Read the input, represented as 0 or 1 (int)
switches 0:5c4d7b2438d3 72 *
switches 0:5c4d7b2438d3 73 * @returns
switches 0:5c4d7b2438d3 74 * An integer representing the state of the input pin,
switches 0:5c4d7b2438d3 75 * 0 for logical 0, 1 for logical 1
switches 0:5c4d7b2438d3 76 */
switches 0:5c4d7b2438d3 77 int read();
switches 0:5c4d7b2438d3 78
switches 0:5c4d7b2438d3 79 /** An operator shorthand for read()
switches 0:5c4d7b2438d3 80 */
switches 0:5c4d7b2438d3 81 operator int();
switches 0:5c4d7b2438d3 82
switches 0:5c4d7b2438d3 83
switches 0:5c4d7b2438d3 84 /** Attach a function to call when a rising edge occurs on the input
switches 0:5c4d7b2438d3 85 *
switches 0:5c4d7b2438d3 86 * @param func A pointer to a void function, or 0 to set as none
switches 0:5c4d7b2438d3 87 */
switches 0:5c4d7b2438d3 88 void rise(Callback<void()> func);
switches 0:5c4d7b2438d3 89
switches 0:5c4d7b2438d3 90 /** Attach a member function to call when a rising edge occurs on the input
switches 0:5c4d7b2438d3 91 *
switches 0:5c4d7b2438d3 92 * @param obj pointer to the object to call the member function on
switches 0:5c4d7b2438d3 93 * @param method pointer to the member function to be called
switches 0:5c4d7b2438d3 94 * @deprecated
switches 0:5c4d7b2438d3 95 * The rise function does not support cv-qualifiers. Replaced by
switches 0:5c4d7b2438d3 96 * rise(callback(obj, method)).
switches 0:5c4d7b2438d3 97 */
switches 0:5c4d7b2438d3 98 template<typename T, typename M>
switches 0:5c4d7b2438d3 99 MBED_DEPRECATED_SINCE("mbed-os-5.1",
switches 0:5c4d7b2438d3 100 "The rise function does not support cv-qualifiers. Replaced by "
switches 0:5c4d7b2438d3 101 "rise(callback(obj, method)).")
switches 0:5c4d7b2438d3 102 void rise(T *obj, M method) {
switches 0:5c4d7b2438d3 103 core_util_critical_section_enter();
switches 0:5c4d7b2438d3 104 rise(callback(obj, method));
switches 0:5c4d7b2438d3 105 core_util_critical_section_exit();
switches 0:5c4d7b2438d3 106 }
switches 0:5c4d7b2438d3 107
switches 0:5c4d7b2438d3 108 /** Attach a function to call when a falling edge occurs on the input
switches 0:5c4d7b2438d3 109 *
switches 0:5c4d7b2438d3 110 * @param func A pointer to a void function, or 0 to set as none
switches 0:5c4d7b2438d3 111 */
switches 0:5c4d7b2438d3 112 void fall(Callback<void()> func);
switches 0:5c4d7b2438d3 113
switches 0:5c4d7b2438d3 114 /** Attach a member function to call when a falling edge occurs on the input
switches 0:5c4d7b2438d3 115 *
switches 0:5c4d7b2438d3 116 * @param obj pointer to the object to call the member function on
switches 0:5c4d7b2438d3 117 * @param method pointer to the member function to be called
switches 0:5c4d7b2438d3 118 * @deprecated
switches 0:5c4d7b2438d3 119 * The rise function does not support cv-qualifiers. Replaced by
switches 0:5c4d7b2438d3 120 * rise(callback(obj, method)).
switches 0:5c4d7b2438d3 121 */
switches 0:5c4d7b2438d3 122 template<typename T, typename M>
switches 0:5c4d7b2438d3 123 MBED_DEPRECATED_SINCE("mbed-os-5.1",
switches 0:5c4d7b2438d3 124 "The fall function does not support cv-qualifiers. Replaced by "
switches 0:5c4d7b2438d3 125 "fall(callback(obj, method)).")
switches 0:5c4d7b2438d3 126 void fall(T *obj, M method) {
switches 0:5c4d7b2438d3 127 core_util_critical_section_enter();
switches 0:5c4d7b2438d3 128 fall(callback(obj, method));
switches 0:5c4d7b2438d3 129 core_util_critical_section_exit();
switches 0:5c4d7b2438d3 130 }
switches 0:5c4d7b2438d3 131
switches 0:5c4d7b2438d3 132 /** Set the input pin mode
switches 0:5c4d7b2438d3 133 *
switches 0:5c4d7b2438d3 134 * @param mode PullUp, PullDown, PullNone
switches 0:5c4d7b2438d3 135 */
switches 0:5c4d7b2438d3 136 void mode(PinMode pull);
switches 0:5c4d7b2438d3 137
switches 0:5c4d7b2438d3 138 /** Enable IRQ. This method depends on hw implementation, might enable one
switches 0:5c4d7b2438d3 139 * port interrupts. For further information, check gpio_irq_enable().
switches 0:5c4d7b2438d3 140 */
switches 0:5c4d7b2438d3 141 void enable_irq();
switches 0:5c4d7b2438d3 142
switches 0:5c4d7b2438d3 143 /** Disable IRQ. This method depends on hw implementation, might disable one
switches 0:5c4d7b2438d3 144 * port interrupts. For further information, check gpio_irq_disable().
switches 0:5c4d7b2438d3 145 */
switches 0:5c4d7b2438d3 146 void disable_irq();
switches 0:5c4d7b2438d3 147
switches 0:5c4d7b2438d3 148 static void _irq_handler(uint32_t id, gpio_irq_event event);
switches 0:5c4d7b2438d3 149
switches 0:5c4d7b2438d3 150 protected:
switches 0:5c4d7b2438d3 151 gpio_t gpio;
switches 0:5c4d7b2438d3 152 gpio_irq_t gpio_irq;
switches 0:5c4d7b2438d3 153
switches 0:5c4d7b2438d3 154 Callback<void()> _rise;
switches 0:5c4d7b2438d3 155 Callback<void()> _fall;
switches 0:5c4d7b2438d3 156 };
switches 0:5c4d7b2438d3 157
switches 0:5c4d7b2438d3 158 } // namespace mbed
switches 0:5c4d7b2438d3 159
switches 0:5c4d7b2438d3 160 #endif
switches 0:5c4d7b2438d3 161
switches 0:5c4d7b2438d3 162 #endif
switches 0:5c4d7b2438d3 163
switches 0:5c4d7b2438d3 164 /** @}*/