t
Fork of mbed-dev by
targets/hal/TARGET_RENESAS/TARGET_VK_RZ_A1H/gpio_api.c@119:3921aeca8633, 2016-04-29 (annotated)
- Committer:
- mbed_official
- Date:
- Fri Apr 29 01:15:11 2016 +0100
- Revision:
- 119:3921aeca8633
Synchronized with git revision fe9720f24b1adc71ab6962506ec51290f6afd270
Full URL: https://github.com/mbedmicro/mbed/commit/fe9720f24b1adc71ab6962506ec51290f6afd270/
[Renesas RZ/A1H] Enable asynchronous communications
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 119:3921aeca8633 | 1 | /* mbed Microcontroller Library |
mbed_official | 119:3921aeca8633 | 2 | * Copyright (c) 2006-2013 ARM Limited |
mbed_official | 119:3921aeca8633 | 3 | * |
mbed_official | 119:3921aeca8633 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 119:3921aeca8633 | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 119:3921aeca8633 | 6 | * You may obtain a copy of the License at |
mbed_official | 119:3921aeca8633 | 7 | * |
mbed_official | 119:3921aeca8633 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 119:3921aeca8633 | 9 | * |
mbed_official | 119:3921aeca8633 | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 119:3921aeca8633 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 119:3921aeca8633 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 119:3921aeca8633 | 13 | * See the License for the specific language governing permissions and |
mbed_official | 119:3921aeca8633 | 14 | * limitations under the License. |
mbed_official | 119:3921aeca8633 | 15 | */ |
mbed_official | 119:3921aeca8633 | 16 | #include "gpio_api.h" |
mbed_official | 119:3921aeca8633 | 17 | #include "pinmap.h" |
mbed_official | 119:3921aeca8633 | 18 | #include "gpio_addrdefine.h" |
mbed_official | 119:3921aeca8633 | 19 | |
mbed_official | 119:3921aeca8633 | 20 | |
mbed_official | 119:3921aeca8633 | 21 | uint32_t gpio_set(PinName pin) { |
mbed_official | 119:3921aeca8633 | 22 | pin_function(pin, 0); |
mbed_official | 119:3921aeca8633 | 23 | return (1 << PINNO(pin)); |
mbed_official | 119:3921aeca8633 | 24 | } |
mbed_official | 119:3921aeca8633 | 25 | |
mbed_official | 119:3921aeca8633 | 26 | void gpio_init(gpio_t *obj, PinName pin) { |
mbed_official | 119:3921aeca8633 | 27 | int group ; |
mbed_official | 119:3921aeca8633 | 28 | obj->pin = pin; |
mbed_official | 119:3921aeca8633 | 29 | if(pin == NC) return; |
mbed_official | 119:3921aeca8633 | 30 | |
mbed_official | 119:3921aeca8633 | 31 | obj->mask = gpio_set(pin); |
mbed_official | 119:3921aeca8633 | 32 | |
mbed_official | 119:3921aeca8633 | 33 | group = PINGROUP(pin); |
mbed_official | 119:3921aeca8633 | 34 | if (group > 9) return; |
mbed_official | 119:3921aeca8633 | 35 | |
mbed_official | 119:3921aeca8633 | 36 | obj->reg_set = (volatile uint32_t *) PSR(group); |
mbed_official | 119:3921aeca8633 | 37 | obj->reg_in = (volatile uint32_t *) PPR(group); |
mbed_official | 119:3921aeca8633 | 38 | obj->reg_dir = (volatile uint32_t *)PMSR(group); |
mbed_official | 119:3921aeca8633 | 39 | obj->reg_buf = (volatile uint32_t *)PIBC(group); |
mbed_official | 119:3921aeca8633 | 40 | } |
mbed_official | 119:3921aeca8633 | 41 | |
mbed_official | 119:3921aeca8633 | 42 | void gpio_mode(gpio_t *obj, PinMode mode) { |
mbed_official | 119:3921aeca8633 | 43 | /* Pull up and Pull down settings aren't supported because RZ/A1H doesn't have pull up/down for pins(signals). */ |
mbed_official | 119:3921aeca8633 | 44 | } |
mbed_official | 119:3921aeca8633 | 45 | |
mbed_official | 119:3921aeca8633 | 46 | void gpio_dir(gpio_t *obj, PinDirection direction) { |
mbed_official | 119:3921aeca8633 | 47 | switch (direction) { |
mbed_official | 119:3921aeca8633 | 48 | case PIN_INPUT : |
mbed_official | 119:3921aeca8633 | 49 | *obj->reg_dir = (obj->mask << 16) | obj->mask; |
mbed_official | 119:3921aeca8633 | 50 | *obj->reg_buf |= obj->mask; |
mbed_official | 119:3921aeca8633 | 51 | break; |
mbed_official | 119:3921aeca8633 | 52 | case PIN_OUTPUT: |
mbed_official | 119:3921aeca8633 | 53 | *obj->reg_dir = (obj->mask << 16) | 0; |
mbed_official | 119:3921aeca8633 | 54 | *obj->reg_buf &= ~obj->mask; |
mbed_official | 119:3921aeca8633 | 55 | break; |
mbed_official | 119:3921aeca8633 | 56 | } |
mbed_official | 119:3921aeca8633 | 57 | } |