fft
Dependencies: BSP_DISCO_F746NG SDFileSystem_Warning_Fixed
mbed_src_STM32F7/common/pinmap_common.c@3:6f7e05dd8d15, 2020-03-06 (annotated)
- Committer:
- aria19970520
- Date:
- Fri Mar 06 06:52:14 2020 +0000
- Revision:
- 3:6f7e05dd8d15
- Parent:
- 0:3e46577dc273
fft
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:3e46577dc273 | 1 | /* mbed Microcontroller Library |
MikamiUitOpen | 0:3e46577dc273 | 2 | * Copyright (c) 2006-2013 ARM Limited |
MikamiUitOpen | 0:3e46577dc273 | 3 | * |
MikamiUitOpen | 0:3e46577dc273 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
MikamiUitOpen | 0:3e46577dc273 | 5 | * you may not use this file except in compliance with the License. |
MikamiUitOpen | 0:3e46577dc273 | 6 | * You may obtain a copy of the License at |
MikamiUitOpen | 0:3e46577dc273 | 7 | * |
MikamiUitOpen | 0:3e46577dc273 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
MikamiUitOpen | 0:3e46577dc273 | 9 | * |
MikamiUitOpen | 0:3e46577dc273 | 10 | * Unless required by applicable law or agreed to in writing, software |
MikamiUitOpen | 0:3e46577dc273 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
MikamiUitOpen | 0:3e46577dc273 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
MikamiUitOpen | 0:3e46577dc273 | 13 | * See the License for the specific language governing permissions and |
MikamiUitOpen | 0:3e46577dc273 | 14 | * limitations under the License. |
MikamiUitOpen | 0:3e46577dc273 | 15 | */ |
MikamiUitOpen | 0:3e46577dc273 | 16 | #include "pinmap.h" |
MikamiUitOpen | 0:3e46577dc273 | 17 | #include "mbed_error.h" |
MikamiUitOpen | 0:3e46577dc273 | 18 | |
MikamiUitOpen | 0:3e46577dc273 | 19 | void pinmap_pinout(PinName pin, const PinMap *map) { |
MikamiUitOpen | 0:3e46577dc273 | 20 | if (pin == NC) |
MikamiUitOpen | 0:3e46577dc273 | 21 | return; |
MikamiUitOpen | 0:3e46577dc273 | 22 | |
MikamiUitOpen | 0:3e46577dc273 | 23 | while (map->pin != NC) { |
MikamiUitOpen | 0:3e46577dc273 | 24 | if (map->pin == pin) { |
MikamiUitOpen | 0:3e46577dc273 | 25 | pin_function(pin, map->function); |
MikamiUitOpen | 0:3e46577dc273 | 26 | |
MikamiUitOpen | 0:3e46577dc273 | 27 | pin_mode(pin, PullNone); |
MikamiUitOpen | 0:3e46577dc273 | 28 | return; |
MikamiUitOpen | 0:3e46577dc273 | 29 | } |
MikamiUitOpen | 0:3e46577dc273 | 30 | map++; |
MikamiUitOpen | 0:3e46577dc273 | 31 | } |
MikamiUitOpen | 0:3e46577dc273 | 32 | error("could not pinout"); |
MikamiUitOpen | 0:3e46577dc273 | 33 | } |
MikamiUitOpen | 0:3e46577dc273 | 34 | |
MikamiUitOpen | 0:3e46577dc273 | 35 | uint32_t pinmap_merge(uint32_t a, uint32_t b) { |
MikamiUitOpen | 0:3e46577dc273 | 36 | // both are the same (inc both NC) |
MikamiUitOpen | 0:3e46577dc273 | 37 | if (a == b) |
MikamiUitOpen | 0:3e46577dc273 | 38 | return a; |
MikamiUitOpen | 0:3e46577dc273 | 39 | |
MikamiUitOpen | 0:3e46577dc273 | 40 | // one (or both) is not connected |
MikamiUitOpen | 0:3e46577dc273 | 41 | if (a == (uint32_t)NC) |
MikamiUitOpen | 0:3e46577dc273 | 42 | return b; |
MikamiUitOpen | 0:3e46577dc273 | 43 | if (b == (uint32_t)NC) |
MikamiUitOpen | 0:3e46577dc273 | 44 | return a; |
MikamiUitOpen | 0:3e46577dc273 | 45 | |
MikamiUitOpen | 0:3e46577dc273 | 46 | // mis-match error case |
MikamiUitOpen | 0:3e46577dc273 | 47 | error("pinmap mis-match"); |
MikamiUitOpen | 0:3e46577dc273 | 48 | return (uint32_t)NC; |
MikamiUitOpen | 0:3e46577dc273 | 49 | } |
MikamiUitOpen | 0:3e46577dc273 | 50 | |
MikamiUitOpen | 0:3e46577dc273 | 51 | uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) { |
MikamiUitOpen | 0:3e46577dc273 | 52 | while (map->pin != NC) { |
MikamiUitOpen | 0:3e46577dc273 | 53 | if (map->pin == pin) |
MikamiUitOpen | 0:3e46577dc273 | 54 | return map->peripheral; |
MikamiUitOpen | 0:3e46577dc273 | 55 | map++; |
MikamiUitOpen | 0:3e46577dc273 | 56 | } |
MikamiUitOpen | 0:3e46577dc273 | 57 | return (uint32_t)NC; |
MikamiUitOpen | 0:3e46577dc273 | 58 | } |
MikamiUitOpen | 0:3e46577dc273 | 59 | |
MikamiUitOpen | 0:3e46577dc273 | 60 | uint32_t pinmap_peripheral(PinName pin, const PinMap* map) { |
MikamiUitOpen | 0:3e46577dc273 | 61 | uint32_t peripheral = (uint32_t)NC; |
MikamiUitOpen | 0:3e46577dc273 | 62 | |
MikamiUitOpen | 0:3e46577dc273 | 63 | if (pin == (PinName)NC) |
MikamiUitOpen | 0:3e46577dc273 | 64 | return (uint32_t)NC; |
MikamiUitOpen | 0:3e46577dc273 | 65 | peripheral = pinmap_find_peripheral(pin, map); |
MikamiUitOpen | 0:3e46577dc273 | 66 | if ((uint32_t)NC == peripheral) // no mapping available |
MikamiUitOpen | 0:3e46577dc273 | 67 | error("pinmap not found for peripheral"); |
MikamiUitOpen | 0:3e46577dc273 | 68 | return peripheral; |
MikamiUitOpen | 0:3e46577dc273 | 69 | } |
MikamiUitOpen | 0:3e46577dc273 | 70 | |
MikamiUitOpen | 0:3e46577dc273 | 71 | uint32_t pinmap_find_function(PinName pin, const PinMap* map) { |
MikamiUitOpen | 0:3e46577dc273 | 72 | while (map->pin != NC) { |
MikamiUitOpen | 0:3e46577dc273 | 73 | if (map->pin == pin) |
MikamiUitOpen | 0:3e46577dc273 | 74 | return map->function; |
MikamiUitOpen | 0:3e46577dc273 | 75 | map++; |
MikamiUitOpen | 0:3e46577dc273 | 76 | } |
MikamiUitOpen | 0:3e46577dc273 | 77 | return (uint32_t)NC; |
MikamiUitOpen | 0:3e46577dc273 | 78 | } |
MikamiUitOpen | 0:3e46577dc273 | 79 | |
MikamiUitOpen | 0:3e46577dc273 | 80 | uint32_t pinmap_function(PinName pin, const PinMap* map) { |
MikamiUitOpen | 0:3e46577dc273 | 81 | uint32_t function = (uint32_t)NC; |
MikamiUitOpen | 0:3e46577dc273 | 82 | |
MikamiUitOpen | 0:3e46577dc273 | 83 | if (pin == (PinName)NC) |
MikamiUitOpen | 0:3e46577dc273 | 84 | return (uint32_t)NC; |
MikamiUitOpen | 0:3e46577dc273 | 85 | function = pinmap_find_function(pin, map); |
MikamiUitOpen | 0:3e46577dc273 | 86 | if ((uint32_t)NC == function) // no mapping available |
MikamiUitOpen | 0:3e46577dc273 | 87 | error("pinmap not found for function"); |
MikamiUitOpen | 0:3e46577dc273 | 88 | return function; |
MikamiUitOpen | 0:3e46577dc273 | 89 | } |