[11U68]fix P0_11 to use GPIO

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri May 22 10:45:46 2015 +0100
Revision:
548:1abac31e188e
Parent:
525:c320967f86b9
Synchronized with git revision 88d158e43b54f97c5e94da305ea9a096889cc81b

Full URL: https://github.com/mbedmicro/mbed/commit/88d158e43b54f97c5e94da305ea9a096889cc81b/

Silicon Labs - Cosmetic: apply mbed coding style to HAL

Who changed what in which revision?

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