mbed library sources(for async_print)
Fork of mbed-src by
targets/hal/TARGET_NXP/TARGET_LPC2460/pinmap.c@554:edd95c0879f8, 2015-06-01 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Jun 01 11:00:11 2015 +0100
- Revision:
- 554:edd95c0879f8
Synchronized with git revision 7a1d25e3dfbe5bc1457774d4af3c73383a0ff81d
Full URL: https://github.com/mbedmicro/mbed/commit/7a1d25e3dfbe5bc1457774d4af3c73383a0ff81d/
Silicon Labs - Initial test framework pin definitions for EFM32 platforms
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 554:edd95c0879f8 | 1 | /* mbed Microcontroller Library |
mbed_official | 554:edd95c0879f8 | 2 | * Copyright (c) 2006-2015 ARM Limited |
mbed_official | 554:edd95c0879f8 | 3 | * |
mbed_official | 554:edd95c0879f8 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 554:edd95c0879f8 | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 554:edd95c0879f8 | 6 | * You may obtain a copy of the License at |
mbed_official | 554:edd95c0879f8 | 7 | * |
mbed_official | 554:edd95c0879f8 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 554:edd95c0879f8 | 9 | * |
mbed_official | 554:edd95c0879f8 | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 554:edd95c0879f8 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 554:edd95c0879f8 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 554:edd95c0879f8 | 13 | * See the License for the specific language governing permissions and |
mbed_official | 554:edd95c0879f8 | 14 | * limitations under the License. |
mbed_official | 554:edd95c0879f8 | 15 | */ |
mbed_official | 554:edd95c0879f8 | 16 | #include "mbed_assert.h" |
mbed_official | 554:edd95c0879f8 | 17 | #include "pinmap.h" |
mbed_official | 554:edd95c0879f8 | 18 | #include "mbed_error.h" |
mbed_official | 554:edd95c0879f8 | 19 | |
mbed_official | 554:edd95c0879f8 | 20 | void pin_function(PinName pin, int function) { |
mbed_official | 554:edd95c0879f8 | 21 | MBED_ASSERT(pin != (PinName)NC); |
mbed_official | 554:edd95c0879f8 | 22 | |
mbed_official | 554:edd95c0879f8 | 23 | uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0; |
mbed_official | 554:edd95c0879f8 | 24 | int index = pin_number >> 4; |
mbed_official | 554:edd95c0879f8 | 25 | int offset = (pin_number & 0xF) << 1; |
mbed_official | 554:edd95c0879f8 | 26 | |
mbed_official | 554:edd95c0879f8 | 27 | PINCONARRAY->PINSEL[index] &= ~(0x3 << offset); |
mbed_official | 554:edd95c0879f8 | 28 | PINCONARRAY->PINSEL[index] |= function << offset; |
mbed_official | 554:edd95c0879f8 | 29 | } |
mbed_official | 554:edd95c0879f8 | 30 | |
mbed_official | 554:edd95c0879f8 | 31 | void pin_mode(PinName pin, PinMode mode) { |
mbed_official | 554:edd95c0879f8 | 32 | MBED_ASSERT((pin != (PinName)NC) && (mode != OpenDrain)); |
mbed_official | 554:edd95c0879f8 | 33 | |
mbed_official | 554:edd95c0879f8 | 34 | uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0; |
mbed_official | 554:edd95c0879f8 | 35 | int index = pin_number >> 5; |
mbed_official | 554:edd95c0879f8 | 36 | int offset = pin_number & 0x1F; |
mbed_official | 554:edd95c0879f8 | 37 | uint32_t drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2; |
mbed_official | 554:edd95c0879f8 | 38 | |
mbed_official | 554:edd95c0879f8 | 39 | if (!drain) { |
mbed_official | 554:edd95c0879f8 | 40 | index = pin_number >> 4; |
mbed_official | 554:edd95c0879f8 | 41 | offset = (pin_number & 0xF) << 1; |
mbed_official | 554:edd95c0879f8 | 42 | |
mbed_official | 554:edd95c0879f8 | 43 | PINCONARRAY->PINMODE[index] &= ~(0x3 << offset); |
mbed_official | 554:edd95c0879f8 | 44 | PINCONARRAY->PINMODE[index] |= (uint32_t)mode << offset; |
mbed_official | 554:edd95c0879f8 | 45 | } |
mbed_official | 554:edd95c0879f8 | 46 | } |