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
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 void pin_function(PinName pin, int function) { 00020 if (pin == (uint32_t)NC) return; 00021 00022 uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0; 00023 int index = pin_number >> 4; 00024 int offset = (pin_number & 0xF) << 1; 00025 00026 PINCONARRAY->PINSEL[index] &= ~(0x3 << offset); 00027 PINCONARRAY->PINSEL[index] |= function << offset; 00028 } 00029 00030 void pin_mode(PinName pin, PinMode mode) { 00031 if (pin == (uint32_t)NC) { return; } 00032 00033 uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0; 00034 int index = pin_number >> 5; 00035 int offset = pin_number & 0x1F; 00036 uint32_t drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2; 00037 00038 PINCONARRAY->PINMODE_OD[index] &= ~(drain << offset); 00039 PINCONARRAY->PINMODE_OD[index] |= drain << offset; 00040 00041 if (!drain) { 00042 index = pin_number >> 4; 00043 offset = (pin_number & 0xF) << 1; 00044 00045 PINCONARRAY->PINMODE[index] &= ~(0x3 << offset); 00046 PINCONARRAY->PINMODE[index] |= (uint32_t)mode << offset; 00047 } 00048 }
Generated on Tue Jul 12 2022 13:47:01 by 1.7.2