fix for mbed lib issue 3 (i2c problem) see also https://mbed.org/users/mbed_official/code/mbed/issues/3 affected implementations: LPC812, LPC11U24, LPC1768, LPC2368, LPC4088

Fork of mbed-src by mbed official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pinmap.c Source File

pinmap.c

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #include "pinmap.h"
00017 #include "error.h"
00018 
00019 __IO uint32_t* IOCON_REGISTERS[18] = {
00020         &LPC_IOCON->PIO0_0 , &LPC_IOCON->PIO0_1 , &LPC_IOCON->PIO0_2 ,
00021         &LPC_IOCON->PIO0_3 , &LPC_IOCON->PIO0_4 , &LPC_IOCON->PIO0_5 ,
00022         &LPC_IOCON->PIO0_6 , &LPC_IOCON->PIO0_7 , &LPC_IOCON->PIO0_8 ,
00023         &LPC_IOCON->PIO0_9 , &LPC_IOCON->PIO0_10, &LPC_IOCON->PIO0_11,
00024         &LPC_IOCON->PIO0_12, &LPC_IOCON->PIO0_13, &LPC_IOCON->PIO0_14,
00025         &LPC_IOCON->PIO0_15, &LPC_IOCON->PIO0_16, &LPC_IOCON->PIO0_17,
00026 };
00027 
00028 void pin_function(PinName pin, int function) {
00029     
00030 }
00031 
00032 void pin_mode(PinName pin, PinMode mode) {
00033     if (pin == (uint32_t)NC) { return; }
00034     
00035     if ((pin == 10) || (pin == 11)) {
00036         // True open-drain pins can be configured for different I2C-bus speeds
00037         return;
00038     }
00039     
00040     __IO uint32_t *reg = IOCON_REGISTERS[pin];
00041     
00042     if (mode == OpenDrain) {
00043         *reg |= (1 << 10);
00044     } else {
00045         uint32_t tmp = *reg;
00046         tmp &= ~(0x3 << 3);
00047         tmp |= (mode & 0x3) << 3;
00048         *reg = tmp;
00049     }
00050 }