Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more
targets/TARGET_NXP/TARGET_LPC43XX/pinmap.c@0:b74591d5ab33, 2017-12-11 (annotated)
- Committer:
- be_bryan
- Date:
- Mon Dec 11 17:54:04 2017 +0000
- Revision:
- 0:b74591d5ab33
motor ++
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
be_bryan | 0:b74591d5ab33 | 1 | /* mbed Microcontroller Library |
be_bryan | 0:b74591d5ab33 | 2 | * Copyright (c) 2006-2013 ARM Limited |
be_bryan | 0:b74591d5ab33 | 3 | * |
be_bryan | 0:b74591d5ab33 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
be_bryan | 0:b74591d5ab33 | 5 | * you may not use this file except in compliance with the License. |
be_bryan | 0:b74591d5ab33 | 6 | * You may obtain a copy of the License at |
be_bryan | 0:b74591d5ab33 | 7 | * |
be_bryan | 0:b74591d5ab33 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
be_bryan | 0:b74591d5ab33 | 9 | * |
be_bryan | 0:b74591d5ab33 | 10 | * Unless required by applicable law or agreed to in writing, software |
be_bryan | 0:b74591d5ab33 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
be_bryan | 0:b74591d5ab33 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
be_bryan | 0:b74591d5ab33 | 13 | * See the License for the specific language governing permissions and |
be_bryan | 0:b74591d5ab33 | 14 | * limitations under the License. |
be_bryan | 0:b74591d5ab33 | 15 | * |
be_bryan | 0:b74591d5ab33 | 16 | * Ported to NXP LPC43XX by Micromint USA <support@micromint.com> |
be_bryan | 0:b74591d5ab33 | 17 | */ |
be_bryan | 0:b74591d5ab33 | 18 | #include "mbed_assert.h" |
be_bryan | 0:b74591d5ab33 | 19 | #include "pinmap.h" |
be_bryan | 0:b74591d5ab33 | 20 | #include "mbed_error.h" |
be_bryan | 0:b74591d5ab33 | 21 | |
be_bryan | 0:b74591d5ab33 | 22 | void pin_function(PinName pin, int function) { |
be_bryan | 0:b74591d5ab33 | 23 | MBED_ASSERT(pin != (PinName)NC); |
be_bryan | 0:b74591d5ab33 | 24 | |
be_bryan | 0:b74591d5ab33 | 25 | __IO uint32_t *reg = (__IO uint32_t*) MBED_SCU_REG(pin); |
be_bryan | 0:b74591d5ab33 | 26 | |
be_bryan | 0:b74591d5ab33 | 27 | // Set pin function |
be_bryan | 0:b74591d5ab33 | 28 | *reg = function; |
be_bryan | 0:b74591d5ab33 | 29 | } |
be_bryan | 0:b74591d5ab33 | 30 | |
be_bryan | 0:b74591d5ab33 | 31 | void pin_mode(PinName pin, PinMode mode) { |
be_bryan | 0:b74591d5ab33 | 32 | MBED_ASSERT(pin != (PinName)NC); // && (mode != OpenDrain)); |
be_bryan | 0:b74591d5ab33 | 33 | |
be_bryan | 0:b74591d5ab33 | 34 | __IO uint32_t *reg = (__IO uint32_t*) MBED_SCU_REG(pin); |
be_bryan | 0:b74591d5ab33 | 35 | uint32_t tmp = *reg; |
be_bryan | 0:b74591d5ab33 | 36 | |
be_bryan | 0:b74591d5ab33 | 37 | // pin mode bits: [4:3] -> 11000 = (0x3 << 3) |
be_bryan | 0:b74591d5ab33 | 38 | tmp &= ~(0x3 << 3); |
be_bryan | 0:b74591d5ab33 | 39 | tmp |= (mode & 0x3) << 3; |
be_bryan | 0:b74591d5ab33 | 40 | |
be_bryan | 0:b74591d5ab33 | 41 | *reg = tmp; |
be_bryan | 0:b74591d5ab33 | 42 | } |