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.
Dependents: EEPROMWrite Full-Project
Fork of mbed-src by
targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/pinmap.c@636:c140da0be6c8, 2015-11-02 (annotated)
- Committer:
- ptcrews
- Date:
- Mon Nov 02 19:22:36 2015 +0000
- Revision:
- 636:c140da0be6c8
- Parent:
- 627:4fa1328d9c60
Changed serial_api.c for Nucleo L1 boards. Changed define conditionals from USART4 and USART5 to UART4 and UART5.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 627:4fa1328d9c60 | 1 | /***************************************************************************//** |
mbed_official | 627:4fa1328d9c60 | 2 | * @file pinmap.c |
mbed_official | 627:4fa1328d9c60 | 3 | ******************************************************************************* |
mbed_official | 627:4fa1328d9c60 | 4 | * @section License |
mbed_official | 627:4fa1328d9c60 | 5 | * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b> |
mbed_official | 627:4fa1328d9c60 | 6 | ******************************************************************************* |
mbed_official | 525:c320967f86b9 | 7 | * |
mbed_official | 627:4fa1328d9c60 | 8 | * Permission is granted to anyone to use this software for any purpose, |
mbed_official | 627:4fa1328d9c60 | 9 | * including commercial applications, and to alter it and redistribute it |
mbed_official | 627:4fa1328d9c60 | 10 | * freely, subject to the following restrictions: |
mbed_official | 525:c320967f86b9 | 11 | * |
mbed_official | 627:4fa1328d9c60 | 12 | * 1. The origin of this software must not be misrepresented; you must not |
mbed_official | 627:4fa1328d9c60 | 13 | * claim that you wrote the original software. |
mbed_official | 627:4fa1328d9c60 | 14 | * 2. Altered source versions must be plainly marked as such, and must not be |
mbed_official | 627:4fa1328d9c60 | 15 | * misrepresented as being the original software. |
mbed_official | 627:4fa1328d9c60 | 16 | * 3. This notice may not be removed or altered from any source distribution. |
mbed_official | 525:c320967f86b9 | 17 | * |
mbed_official | 627:4fa1328d9c60 | 18 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no |
mbed_official | 627:4fa1328d9c60 | 19 | * obligation to support this Software. Silicon Labs is providing the |
mbed_official | 627:4fa1328d9c60 | 20 | * Software "AS IS", with no express or implied warranties of any kind, |
mbed_official | 627:4fa1328d9c60 | 21 | * including, but not limited to, any implied warranties of merchantability |
mbed_official | 627:4fa1328d9c60 | 22 | * or fitness for any particular purpose or warranties against infringement |
mbed_official | 627:4fa1328d9c60 | 23 | * of any proprietary rights of a third party. |
mbed_official | 627:4fa1328d9c60 | 24 | * |
mbed_official | 627:4fa1328d9c60 | 25 | * Silicon Labs will not be liable for any consequential, incidental, or |
mbed_official | 627:4fa1328d9c60 | 26 | * special damages, or any other relief, or for any claim by any third party, |
mbed_official | 627:4fa1328d9c60 | 27 | * arising from your use of this Software. |
mbed_official | 627:4fa1328d9c60 | 28 | * |
mbed_official | 627:4fa1328d9c60 | 29 | ******************************************************************************/ |
mbed_official | 627:4fa1328d9c60 | 30 | |
mbed_official | 525:c320967f86b9 | 31 | #include "pinmap.h" |
mbed_official | 525:c320967f86b9 | 32 | #include "em_gpio.h" |
mbed_official | 525:c320967f86b9 | 33 | #include "em_cmu.h" |
mbed_official | 525:c320967f86b9 | 34 | #include "mbed_assert.h" |
mbed_official | 525:c320967f86b9 | 35 | |
mbed_official | 525:c320967f86b9 | 36 | static int gpio_clock_inited = 0; |
mbed_official | 525:c320967f86b9 | 37 | |
mbed_official | 525:c320967f86b9 | 38 | void pin_function(PinName pin, int function) |
mbed_official | 525:c320967f86b9 | 39 | { |
mbed_official | 525:c320967f86b9 | 40 | //Intentionally left empty. We have repurposed the function field. |
mbed_official | 525:c320967f86b9 | 41 | } |
mbed_official | 525:c320967f86b9 | 42 | |
mbed_official | 525:c320967f86b9 | 43 | void pin_mode(PinName pin, PinMode mode) |
mbed_official | 525:c320967f86b9 | 44 | { |
mbed_official | 627:4fa1328d9c60 | 45 | MBED_ASSERT((0xFFFFFF00 |pin) != NC); |
mbed_official | 525:c320967f86b9 | 46 | |
mbed_official | 525:c320967f86b9 | 47 | /* Enable GPIO clock if not already done */ |
mbed_official | 548:1abac31e188e | 48 | if (!gpio_clock_inited) { |
mbed_official | 548:1abac31e188e | 49 | CMU_ClockEnable(cmuClock_GPIO, true); |
mbed_official | 548:1abac31e188e | 50 | gpio_clock_inited = 1; |
mbed_official | 548:1abac31e188e | 51 | } |
mbed_official | 525:c320967f86b9 | 52 | |
mbed_official | 525:c320967f86b9 | 53 | /* Pin and port index encoded in one uint32. |
mbed_official | 525:c320967f86b9 | 54 | * First four bits represent the pin number |
mbed_official | 525:c320967f86b9 | 55 | * The remaining bits represent the port number */ |
mbed_official | 525:c320967f86b9 | 56 | uint32_t pin_number = (uint32_t) pin; |
mbed_official | 525:c320967f86b9 | 57 | int pin_index = (pin_number & 0xF); |
mbed_official | 525:c320967f86b9 | 58 | int port_index = pin_number >> 4; |
mbed_official | 525:c320967f86b9 | 59 | |
mbed_official | 525:c320967f86b9 | 60 | GPIO_PinModeSet(port_index, pin_index, mode & 0xF, GPIO_PinOutGet(port_index, pin_index & 0xF)); |
mbed_official | 525:c320967f86b9 | 61 | } |
mbed_official | 525:c320967f86b9 | 62 | |
mbed_official | 525:c320967f86b9 | 63 | // TODO_LP get pin_mode to be able to store previous settings |