inport from local
Dependents: Hobbyking_Cheetah_0511
targets/TARGET_STM/TARGET_STM32F4/gpio_irq_device.h@0:85b3fd62ea1a, 2020-03-16 (annotated)
- Committer:
- NYX
- Date:
- Mon Mar 16 06:35:48 2020 +0000
- Revision:
- 0:85b3fd62ea1a
reinport to mbed;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
NYX | 0:85b3fd62ea1a | 1 | /* mbed Microcontroller Library |
NYX | 0:85b3fd62ea1a | 2 | ******************************************************************************* |
NYX | 0:85b3fd62ea1a | 3 | * Copyright (c) 2017, STMicroelectronics |
NYX | 0:85b3fd62ea1a | 4 | * All rights reserved. |
NYX | 0:85b3fd62ea1a | 5 | * |
NYX | 0:85b3fd62ea1a | 6 | * Redistribution and use in source and binary forms, with or without |
NYX | 0:85b3fd62ea1a | 7 | * modification, are permitted provided that the following conditions are met: |
NYX | 0:85b3fd62ea1a | 8 | * |
NYX | 0:85b3fd62ea1a | 9 | * 1. Redistributions of source code must retain the above copyright notice, |
NYX | 0:85b3fd62ea1a | 10 | * this list of conditions and the following disclaimer. |
NYX | 0:85b3fd62ea1a | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
NYX | 0:85b3fd62ea1a | 12 | * this list of conditions and the following disclaimer in the documentation |
NYX | 0:85b3fd62ea1a | 13 | * and/or other materials provided with the distribution. |
NYX | 0:85b3fd62ea1a | 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
NYX | 0:85b3fd62ea1a | 15 | * may be used to endorse or promote products derived from this software |
NYX | 0:85b3fd62ea1a | 16 | * without specific prior written permission. |
NYX | 0:85b3fd62ea1a | 17 | * |
NYX | 0:85b3fd62ea1a | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
NYX | 0:85b3fd62ea1a | 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
NYX | 0:85b3fd62ea1a | 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
NYX | 0:85b3fd62ea1a | 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
NYX | 0:85b3fd62ea1a | 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
NYX | 0:85b3fd62ea1a | 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
NYX | 0:85b3fd62ea1a | 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
NYX | 0:85b3fd62ea1a | 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
NYX | 0:85b3fd62ea1a | 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
NYX | 0:85b3fd62ea1a | 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
NYX | 0:85b3fd62ea1a | 28 | ******************************************************************************* |
NYX | 0:85b3fd62ea1a | 29 | */ |
NYX | 0:85b3fd62ea1a | 30 | #ifndef MBED_GPIO_IRQ_DEVICE_H |
NYX | 0:85b3fd62ea1a | 31 | #define MBED_GPIO_IRQ_DEVICE_H |
NYX | 0:85b3fd62ea1a | 32 | |
NYX | 0:85b3fd62ea1a | 33 | #ifdef __cplusplus |
NYX | 0:85b3fd62ea1a | 34 | extern "C" { |
NYX | 0:85b3fd62ea1a | 35 | #endif |
NYX | 0:85b3fd62ea1a | 36 | |
NYX | 0:85b3fd62ea1a | 37 | // when LL is available, below include can be used |
NYX | 0:85b3fd62ea1a | 38 | // #include "stm32f4xx_ll_exti.h" |
NYX | 0:85b3fd62ea1a | 39 | // until then let's define locally the required functions |
NYX | 0:85b3fd62ea1a | 40 | __STATIC_INLINE void LL_EXTI_EnableRisingTrig_0_31(uint32_t ExtiLine) |
NYX | 0:85b3fd62ea1a | 41 | { |
NYX | 0:85b3fd62ea1a | 42 | SET_BIT(EXTI->RTSR, ExtiLine); |
NYX | 0:85b3fd62ea1a | 43 | } |
NYX | 0:85b3fd62ea1a | 44 | __STATIC_INLINE void LL_EXTI_DisableRisingTrig_0_31(uint32_t ExtiLine) |
NYX | 0:85b3fd62ea1a | 45 | { |
NYX | 0:85b3fd62ea1a | 46 | CLEAR_BIT(EXTI->RTSR, ExtiLine); |
NYX | 0:85b3fd62ea1a | 47 | } |
NYX | 0:85b3fd62ea1a | 48 | __STATIC_INLINE void LL_EXTI_EnableFallingTrig_0_31(uint32_t ExtiLine) |
NYX | 0:85b3fd62ea1a | 49 | { |
NYX | 0:85b3fd62ea1a | 50 | SET_BIT(EXTI->FTSR, ExtiLine); |
NYX | 0:85b3fd62ea1a | 51 | } |
NYX | 0:85b3fd62ea1a | 52 | __STATIC_INLINE void LL_EXTI_DisableFallingTrig_0_31(uint32_t ExtiLine) |
NYX | 0:85b3fd62ea1a | 53 | { |
NYX | 0:85b3fd62ea1a | 54 | CLEAR_BIT(EXTI->FTSR, ExtiLine); |
NYX | 0:85b3fd62ea1a | 55 | } |
NYX | 0:85b3fd62ea1a | 56 | __STATIC_INLINE void LL_EXTI_EnableIT_0_31(uint32_t ExtiLine) |
NYX | 0:85b3fd62ea1a | 57 | { |
NYX | 0:85b3fd62ea1a | 58 | SET_BIT(EXTI->IMR, ExtiLine); |
NYX | 0:85b3fd62ea1a | 59 | } |
NYX | 0:85b3fd62ea1a | 60 | __STATIC_INLINE void LL_EXTI_DisableIT_0_31(uint32_t ExtiLine) |
NYX | 0:85b3fd62ea1a | 61 | { |
NYX | 0:85b3fd62ea1a | 62 | CLEAR_BIT(EXTI->IMR, ExtiLine); |
NYX | 0:85b3fd62ea1a | 63 | } |
NYX | 0:85b3fd62ea1a | 64 | // Above lines shall be later defined in LL |
NYX | 0:85b3fd62ea1a | 65 | |
NYX | 0:85b3fd62ea1a | 66 | // Number of EXTI irq vectors (EXTI0, EXTI1, EXTI2, EXTI3, EXTI4, EXTI5_9, EXTI10_15) |
NYX | 0:85b3fd62ea1a | 67 | #define CHANNEL_NUM (7) |
NYX | 0:85b3fd62ea1a | 68 | |
NYX | 0:85b3fd62ea1a | 69 | #define EXTI_IRQ0_NUM_LINES 1 |
NYX | 0:85b3fd62ea1a | 70 | #define EXTI_IRQ1_NUM_LINES 1 |
NYX | 0:85b3fd62ea1a | 71 | #define EXTI_IRQ2_NUM_LINES 1 |
NYX | 0:85b3fd62ea1a | 72 | #define EXTI_IRQ3_NUM_LINES 1 |
NYX | 0:85b3fd62ea1a | 73 | #define EXTI_IRQ4_NUM_LINES 1 |
NYX | 0:85b3fd62ea1a | 74 | #define EXTI_IRQ5_NUM_LINES 5 |
NYX | 0:85b3fd62ea1a | 75 | #define EXTI_IRQ6_NUM_LINES 6 |
NYX | 0:85b3fd62ea1a | 76 | |
NYX | 0:85b3fd62ea1a | 77 | // Max pins for one line (max with EXTI10_15) |
NYX | 0:85b3fd62ea1a | 78 | #define MAX_PIN_LINE (EXTI_IRQ6_NUM_LINES) |
NYX | 0:85b3fd62ea1a | 79 | |
NYX | 0:85b3fd62ea1a | 80 | /* Structure to describe how the HW EXTI lines are defined in this HW */ |
NYX | 0:85b3fd62ea1a | 81 | typedef struct exti_lines { |
NYX | 0:85b3fd62ea1a | 82 | uint32_t gpio_idx; // an index entry for each EXIT line |
NYX | 0:85b3fd62ea1a | 83 | uint32_t irq_index; // the IRQ index |
NYX | 0:85b3fd62ea1a | 84 | IRQn_Type irq_n; // the corresponding EXTI IRQn |
NYX | 0:85b3fd62ea1a | 85 | } exti_lines_t; |
NYX | 0:85b3fd62ea1a | 86 | |
NYX | 0:85b3fd62ea1a | 87 | // Used to return the index for channels array. |
NYX | 0:85b3fd62ea1a | 88 | extern const exti_lines_t pin_lines_desc[]; |
NYX | 0:85b3fd62ea1a | 89 | |
NYX | 0:85b3fd62ea1a | 90 | #ifdef __cplusplus |
NYX | 0:85b3fd62ea1a | 91 | } |
NYX | 0:85b3fd62ea1a | 92 | #endif |
NYX | 0:85b3fd62ea1a | 93 | |
NYX | 0:85b3fd62ea1a | 94 | #endif |