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.
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 if (mode == OpenDrain) error("OpenDrain not supported on LPC2368"); 00039 00040 if (!drain) { 00041 index = pin_number >> 4; 00042 offset = (pin_number & 0xF) << 1; 00043 00044 PINCONARRAY->PINMODE[index] &= ~(0x3 << offset); 00045 PINCONARRAY->PINMODE[index] |= (uint32_t)mode << offset; 00046 } 00047 }
Generated on Tue Jul 12 2022 13:47:01 by
1.7.2
