mbed-src updated for BMD-200 evaluation board. Just pin numbers are updated.
Dependents: mbed_blinky-bmd-200 bmd-200_accel_demo firstRig
Fork of mbed-src by
Replacement for the "mbed" or "mbed-src" library when using the BMD-200 Evaluation kit. This library only remaps the pin names (i.e. LED1 points to p0.01 instead of p0.18, etc) as used by the BMD-200 Evaluation board (select the nRF51822_mkit platform). All other code is untouched.
common/gpio.c@592:5e2eb8beba71, 2015-07-10 (annotated)
- Committer:
- dcnichols
- Date:
- Fri Jul 10 17:36:27 2015 +0000
- Revision:
- 592:5e2eb8beba71
- Parent:
- 221:8276e3a4886f
updating to latest mbed-src
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 113:65a335a675de | 1 | /* mbed Microcontroller Library |
mbed_official | 113:65a335a675de | 2 | * Copyright (c) 2006-2013 ARM Limited |
mbed_official | 113:65a335a675de | 3 | * |
mbed_official | 113:65a335a675de | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 113:65a335a675de | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 113:65a335a675de | 6 | * You may obtain a copy of the License at |
mbed_official | 113:65a335a675de | 7 | * |
mbed_official | 113:65a335a675de | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 113:65a335a675de | 9 | * |
mbed_official | 113:65a335a675de | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 113:65a335a675de | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 113:65a335a675de | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 113:65a335a675de | 13 | * See the License for the specific language governing permissions and |
mbed_official | 113:65a335a675de | 14 | * limitations under the License. |
mbed_official | 113:65a335a675de | 15 | */ |
mbed_official | 113:65a335a675de | 16 | #include "gpio_api.h" |
mbed_official | 113:65a335a675de | 17 | |
mbed_official | 113:65a335a675de | 18 | static inline void _gpio_init_in(gpio_t* gpio, PinName pin, PinMode mode) |
mbed_official | 113:65a335a675de | 19 | { |
mbed_official | 221:8276e3a4886f | 20 | gpio_init(gpio, pin); |
mbed_official | 221:8276e3a4886f | 21 | if (pin != NC) { |
mbed_official | 160:6870f452afa4 | 22 | gpio_dir(gpio, PIN_INPUT); |
mbed_official | 160:6870f452afa4 | 23 | gpio_mode(gpio, mode); |
mbed_official | 160:6870f452afa4 | 24 | } |
mbed_official | 113:65a335a675de | 25 | } |
mbed_official | 221:8276e3a4886f | 26 | |
mbed_official | 113:65a335a675de | 27 | static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int value) |
mbed_official | 113:65a335a675de | 28 | { |
mbed_official | 113:65a335a675de | 29 | gpio_init(gpio, pin); |
mbed_official | 160:6870f452afa4 | 30 | if (pin != NC) { |
mbed_official | 160:6870f452afa4 | 31 | gpio_write(gpio, value); |
mbed_official | 160:6870f452afa4 | 32 | gpio_dir(gpio, PIN_OUTPUT); |
mbed_official | 160:6870f452afa4 | 33 | gpio_mode(gpio, mode); |
mbed_official | 160:6870f452afa4 | 34 | } |
mbed_official | 113:65a335a675de | 35 | } |
mbed_official | 113:65a335a675de | 36 | |
mbed_official | 113:65a335a675de | 37 | void gpio_init_in(gpio_t* gpio, PinName pin) { |
mbed_official | 113:65a335a675de | 38 | gpio_init_in_ex(gpio, pin, PullDefault); |
mbed_official | 113:65a335a675de | 39 | } |
mbed_official | 113:65a335a675de | 40 | |
mbed_official | 113:65a335a675de | 41 | void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode) { |
mbed_official | 113:65a335a675de | 42 | _gpio_init_in(gpio, pin, mode); |
mbed_official | 113:65a335a675de | 43 | } |
mbed_official | 113:65a335a675de | 44 | |
mbed_official | 113:65a335a675de | 45 | void gpio_init_out(gpio_t* gpio, PinName pin) { |
mbed_official | 113:65a335a675de | 46 | gpio_init_out_ex(gpio, pin, 0); |
mbed_official | 113:65a335a675de | 47 | } |
mbed_official | 113:65a335a675de | 48 | |
mbed_official | 113:65a335a675de | 49 | void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value) { |
mbed_official | 113:65a335a675de | 50 | _gpio_init_out(gpio, pin, PullNone, value); |
mbed_official | 113:65a335a675de | 51 | } |
mbed_official | 113:65a335a675de | 52 | |
mbed_official | 113:65a335a675de | 53 | void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value) { |
mbed_official | 113:65a335a675de | 54 | if (direction == PIN_INPUT) { |
mbed_official | 113:65a335a675de | 55 | _gpio_init_in(gpio, pin, mode); |
mbed_official | 160:6870f452afa4 | 56 | if (pin != NC) |
mbed_official | 160:6870f452afa4 | 57 | gpio_write(gpio, value); // we prepare the value in case it is switched later |
mbed_official | 113:65a335a675de | 58 | } else { |
mbed_official | 113:65a335a675de | 59 | _gpio_init_out(gpio, pin, mode, value); |
mbed_official | 113:65a335a675de | 60 | } |
mbed_official | 113:65a335a675de | 61 | } |