mbed library sources. Supersedes mbed-src.

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Tue Nov 08 17:45:16 2016 +0000
Revision:
150:02e0a0aed4ec
Parent:
149:156823d33999
This updates the lib to the mbed lib v129

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 144:ef7eb2e8f9f7 1 /***************************************************************************//**
<> 144:ef7eb2e8f9f7 2 * @file pinmap.c
<> 144:ef7eb2e8f9f7 3 *******************************************************************************
<> 144:ef7eb2e8f9f7 4 * @section License
<> 144:ef7eb2e8f9f7 5 * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>
<> 144:ef7eb2e8f9f7 6 *******************************************************************************
<> 144:ef7eb2e8f9f7 7 *
<> 144:ef7eb2e8f9f7 8 * SPDX-License-Identifier: Apache-2.0
<> 144:ef7eb2e8f9f7 9 *
<> 144:ef7eb2e8f9f7 10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
<> 144:ef7eb2e8f9f7 11 * not use this file except in compliance with the License.
<> 144:ef7eb2e8f9f7 12 * You may obtain a copy of the License at
<> 144:ef7eb2e8f9f7 13 *
<> 144:ef7eb2e8f9f7 14 * http://www.apache.org/licenses/LICENSE-2.0
<> 144:ef7eb2e8f9f7 15 *
<> 144:ef7eb2e8f9f7 16 * Unless required by applicable law or agreed to in writing, software
<> 144:ef7eb2e8f9f7 17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
<> 144:ef7eb2e8f9f7 18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 144:ef7eb2e8f9f7 19 * See the License for the specific language governing permissions and
<> 144:ef7eb2e8f9f7 20 * limitations under the License.
<> 144:ef7eb2e8f9f7 21 *
<> 144:ef7eb2e8f9f7 22 ******************************************************************************/
<> 144:ef7eb2e8f9f7 23
<> 144:ef7eb2e8f9f7 24 #include "pinmap.h"
<> 144:ef7eb2e8f9f7 25 #include "em_gpio.h"
<> 144:ef7eb2e8f9f7 26 #include "em_cmu.h"
<> 144:ef7eb2e8f9f7 27 #include "mbed_assert.h"
<> 144:ef7eb2e8f9f7 28
<> 144:ef7eb2e8f9f7 29 static int gpio_clock_inited = 0;
<> 144:ef7eb2e8f9f7 30
<> 144:ef7eb2e8f9f7 31 void pin_function(PinName pin, int function)
<> 144:ef7eb2e8f9f7 32 {
<> 144:ef7eb2e8f9f7 33 //Intentionally left empty. We have repurposed the function field.
<> 144:ef7eb2e8f9f7 34 }
<> 144:ef7eb2e8f9f7 35
<> 144:ef7eb2e8f9f7 36 void pin_mode(PinName pin, PinMode mode)
<> 144:ef7eb2e8f9f7 37 {
<> 150:02e0a0aed4ec 38 MBED_ASSERT(pin != NC);
<> 144:ef7eb2e8f9f7 39
<> 144:ef7eb2e8f9f7 40 /* Enable GPIO clock if not already done */
<> 144:ef7eb2e8f9f7 41 if (!gpio_clock_inited) {
<> 144:ef7eb2e8f9f7 42 CMU_ClockEnable(cmuClock_GPIO, true);
<> 144:ef7eb2e8f9f7 43 gpio_clock_inited = 1;
<> 144:ef7eb2e8f9f7 44 }
<> 144:ef7eb2e8f9f7 45
<> 144:ef7eb2e8f9f7 46 /* Pin and port index encoded in one uint32.
<> 144:ef7eb2e8f9f7 47 * First four bits represent the pin number
<> 144:ef7eb2e8f9f7 48 * The remaining bits represent the port number */
<> 144:ef7eb2e8f9f7 49 uint32_t pin_number = (uint32_t) pin;
<> 144:ef7eb2e8f9f7 50 int pin_index = (pin_number & 0xF);
<> 144:ef7eb2e8f9f7 51 int port_index = pin_number >> 4;
<> 144:ef7eb2e8f9f7 52
<> 144:ef7eb2e8f9f7 53 GPIO_PinModeSet(port_index, pin_index, mode & 0xF, GPIO_PinOutGet(port_index, pin_index & 0xF));
<> 144:ef7eb2e8f9f7 54 }
<> 144:ef7eb2e8f9f7 55
<> 144:ef7eb2e8f9f7 56 // TODO_LP get pin_mode to be able to store previous settings