mbed library sources. Supersedes mbed-src. Edited target satm32f446 for user USART3 pins
Fork of mbed-dev by
targets/TARGET_NORDIC/TARGET_NRF5x/pinmap.c@186:707f6e361f3e, 2018-06-22 (annotated)
- Committer:
- Anna Bridge
- Date:
- Fri Jun 22 16:45:37 2018 +0100
- Revision:
- 186:707f6e361f3e
mbed-dev library. Release version 162
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anna Bridge |
186:707f6e361f3e | 1 | /* mbed Microcontroller Library |
Anna Bridge |
186:707f6e361f3e | 2 | * Copyright (c) 2006-2013 ARM Limited |
Anna Bridge |
186:707f6e361f3e | 3 | * |
Anna Bridge |
186:707f6e361f3e | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Anna Bridge |
186:707f6e361f3e | 5 | * you may not use this file except in compliance with the License. |
Anna Bridge |
186:707f6e361f3e | 6 | * You may obtain a copy of the License at |
Anna Bridge |
186:707f6e361f3e | 7 | * |
Anna Bridge |
186:707f6e361f3e | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Anna Bridge |
186:707f6e361f3e | 9 | * |
Anna Bridge |
186:707f6e361f3e | 10 | * Unless required by applicable law or agreed to in writing, software |
Anna Bridge |
186:707f6e361f3e | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Anna Bridge |
186:707f6e361f3e | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Anna Bridge |
186:707f6e361f3e | 13 | * See the License for the specific language governing permissions and |
Anna Bridge |
186:707f6e361f3e | 14 | * limitations under the License. |
Anna Bridge |
186:707f6e361f3e | 15 | */ |
Anna Bridge |
186:707f6e361f3e | 16 | #include "mbed_assert.h" |
Anna Bridge |
186:707f6e361f3e | 17 | #include "mbed_error.h" |
Anna Bridge |
186:707f6e361f3e | 18 | #include "pinmap.h" |
Anna Bridge |
186:707f6e361f3e | 19 | #include "nrf_gpio.h" |
Anna Bridge |
186:707f6e361f3e | 20 | |
Anna Bridge |
186:707f6e361f3e | 21 | void pin_function(PinName pin, int function) |
Anna Bridge |
186:707f6e361f3e | 22 | { |
Anna Bridge |
186:707f6e361f3e | 23 | /* Avoid compiler warnings */ |
Anna Bridge |
186:707f6e361f3e | 24 | (void) pin; |
Anna Bridge |
186:707f6e361f3e | 25 | (void) function; |
Anna Bridge |
186:707f6e361f3e | 26 | } |
Anna Bridge |
186:707f6e361f3e | 27 | |
Anna Bridge |
186:707f6e361f3e | 28 | void pin_mode(PinName pin, PinMode mode) |
Anna Bridge |
186:707f6e361f3e | 29 | { |
Anna Bridge |
186:707f6e361f3e | 30 | MBED_ASSERT(pin != (PinName)NC); |
Anna Bridge |
186:707f6e361f3e | 31 | |
Anna Bridge |
186:707f6e361f3e | 32 | uint32_t pin_number = (uint32_t)pin; |
Anna Bridge |
186:707f6e361f3e | 33 | |
Anna Bridge |
186:707f6e361f3e | 34 | #ifdef TARGET_SDK_11 |
Anna Bridge |
186:707f6e361f3e | 35 | NRF_GPIO_Type * reg = NRF_GPIO; |
Anna Bridge |
186:707f6e361f3e | 36 | #else |
Anna Bridge |
186:707f6e361f3e | 37 | NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number); |
Anna Bridge |
186:707f6e361f3e | 38 | #endif |
Anna Bridge |
186:707f6e361f3e | 39 | reg->PIN_CNF[pin_number] &= ~GPIO_PIN_CNF_PULL_Msk; |
Anna Bridge |
186:707f6e361f3e | 40 | reg->PIN_CNF[pin_number] |= (mode << GPIO_PIN_CNF_PULL_Pos); |
Anna Bridge |
186:707f6e361f3e | 41 | } |