BA / SerialCom

Fork of OmniWheels by Gustav Atmel

Committer:
gustavatmel
Date:
Tue May 01 15:55:34 2018 +0000
Revision:
2:798925c9e4a8
Parent:
1:9c5af431a1f1
bluetooth

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gustavatmel 1:9c5af431a1f1 1 /* mbed Microcontroller Library
gustavatmel 1:9c5af431a1f1 2 * Copyright (c) 2006-2013 ARM Limited
gustavatmel 1:9c5af431a1f1 3 *
gustavatmel 1:9c5af431a1f1 4 * Licensed under the Apache License, Version 2.0 (the "License");
gustavatmel 1:9c5af431a1f1 5 * you may not use this file except in compliance with the License.
gustavatmel 1:9c5af431a1f1 6 * You may obtain a copy of the License at
gustavatmel 1:9c5af431a1f1 7 *
gustavatmel 1:9c5af431a1f1 8 * http://www.apache.org/licenses/LICENSE-2.0
gustavatmel 1:9c5af431a1f1 9 *
gustavatmel 1:9c5af431a1f1 10 * Unless required by applicable law or agreed to in writing, software
gustavatmel 1:9c5af431a1f1 11 * distributed under the License is distributed on an "AS IS" BASIS,
gustavatmel 1:9c5af431a1f1 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
gustavatmel 1:9c5af431a1f1 13 * See the License for the specific language governing permissions and
gustavatmel 1:9c5af431a1f1 14 * limitations under the License.
gustavatmel 1:9c5af431a1f1 15 */
gustavatmel 1:9c5af431a1f1 16 #include "mbed_assert.h"
gustavatmel 1:9c5af431a1f1 17 #include "pinmap.h"
gustavatmel 1:9c5af431a1f1 18 #include "mbed_error.h"
gustavatmel 1:9c5af431a1f1 19
gustavatmel 1:9c5af431a1f1 20 void pin_function(PinName pin, int function) {
gustavatmel 1:9c5af431a1f1 21 }
gustavatmel 1:9c5af431a1f1 22
gustavatmel 1:9c5af431a1f1 23 void pin_mode(PinName pin, PinMode mode) {
gustavatmel 1:9c5af431a1f1 24 MBED_ASSERT(pin != (PinName)NC);
gustavatmel 1:9c5af431a1f1 25
gustavatmel 1:9c5af431a1f1 26 if ((pin == P0_22) || (pin == P0_23)) {
gustavatmel 1:9c5af431a1f1 27 // The true open-drain pins PIO0_22 and PIO0_23 can be configured for different I2C-bus speeds.
gustavatmel 1:9c5af431a1f1 28 return;
gustavatmel 1:9c5af431a1f1 29 }
gustavatmel 1:9c5af431a1f1 30
gustavatmel 1:9c5af431a1f1 31 __IO uint32_t *reg = (__IO uint32_t*)(LPC_IOCON_BASE + (pin * 4));
gustavatmel 1:9c5af431a1f1 32
gustavatmel 1:9c5af431a1f1 33 if (mode == OpenDrain) {
gustavatmel 1:9c5af431a1f1 34 *reg |= (1 << 10);
gustavatmel 1:9c5af431a1f1 35 } else {
gustavatmel 1:9c5af431a1f1 36 uint32_t tmp = *reg;
gustavatmel 1:9c5af431a1f1 37 tmp &= ~(0x3 << 3);
gustavatmel 1:9c5af431a1f1 38 tmp |= (mode & 0x3) << 3;
gustavatmel 1:9c5af431a1f1 39 *reg = tmp;
gustavatmel 1:9c5af431a1f1 40 }
gustavatmel 1:9c5af431a1f1 41 }