mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
188:bcfe06ba3d64
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 187:0387e8f68319 1 /* mbed Microcontroller Library
AnnaBridge 187:0387e8f68319 2 * Copyright (c) 2017-2018 Nuvoton
AnnaBridge 187:0387e8f68319 3 *
AnnaBridge 187:0387e8f68319 4 * Licensed under the Apache License, Version 2.0 (the "License");
AnnaBridge 187:0387e8f68319 5 * you may not use this file except in compliance with the License.
AnnaBridge 187:0387e8f68319 6 * You may obtain a copy of the License at
AnnaBridge 187:0387e8f68319 7 *
AnnaBridge 187:0387e8f68319 8 * http://www.apache.org/licenses/LICENSE-2.0
AnnaBridge 187:0387e8f68319 9 *
AnnaBridge 187:0387e8f68319 10 * Unless required by applicable law or agreed to in writing, software
AnnaBridge 187:0387e8f68319 11 * distributed under the License is distributed on an "AS IS" BASIS,
AnnaBridge 187:0387e8f68319 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AnnaBridge 187:0387e8f68319 13 * See the License for the specific language governing permissions and
AnnaBridge 187:0387e8f68319 14 * limitations under the License.
AnnaBridge 187:0387e8f68319 15 */
AnnaBridge 187:0387e8f68319 16
AnnaBridge 187:0387e8f68319 17 #ifndef MBED_GPIO_OBJECT_H
AnnaBridge 187:0387e8f68319 18 #define MBED_GPIO_OBJECT_H
AnnaBridge 187:0387e8f68319 19
AnnaBridge 187:0387e8f68319 20 #include "mbed_assert.h"
AnnaBridge 187:0387e8f68319 21 #include "cmsis.h"
AnnaBridge 187:0387e8f68319 22 #include "PortNames.h"
AnnaBridge 187:0387e8f68319 23 #include "PeripheralNames.h"
AnnaBridge 187:0387e8f68319 24 #include "PinNames.h"
AnnaBridge 187:0387e8f68319 25 #include "partition_M2351.h"
AnnaBridge 187:0387e8f68319 26
AnnaBridge 187:0387e8f68319 27 #ifdef __cplusplus
AnnaBridge 187:0387e8f68319 28 extern "C" {
AnnaBridge 187:0387e8f68319 29 #endif
AnnaBridge 187:0387e8f68319 30
AnnaBridge 187:0387e8f68319 31 typedef struct {
AnnaBridge 188:bcfe06ba3d64 32 PinName pin;
AnnaBridge 188:bcfe06ba3d64 33 uint32_t mask;
AnnaBridge 188:bcfe06ba3d64 34 PinDirection direction;
AnnaBridge 188:bcfe06ba3d64 35 PinMode mode;
AnnaBridge 187:0387e8f68319 36 } gpio_t;
AnnaBridge 187:0387e8f68319 37
AnnaBridge 187:0387e8f68319 38 static inline void gpio_write(gpio_t *obj, int value)
AnnaBridge 187:0387e8f68319 39 {
AnnaBridge 187:0387e8f68319 40 MBED_ASSERT(obj->pin != (PinName)NC);
AnnaBridge 187:0387e8f68319 41 uint32_t pin_index = NU_PINNAME_TO_PIN(obj->pin);
AnnaBridge 187:0387e8f68319 42 uint32_t port_index = NU_PINNAME_TO_PORT(obj->pin);
AnnaBridge 187:0387e8f68319 43
AnnaBridge 187:0387e8f68319 44 NU_SET_GPIO_PIN_DATA(port_index, pin_index, value ? 1 : 0);
AnnaBridge 187:0387e8f68319 45 }
AnnaBridge 187:0387e8f68319 46
AnnaBridge 187:0387e8f68319 47 static inline int gpio_read(gpio_t *obj)
AnnaBridge 187:0387e8f68319 48 {
AnnaBridge 187:0387e8f68319 49 MBED_ASSERT(obj->pin != (PinName)NC);
AnnaBridge 187:0387e8f68319 50 uint32_t pin_index = NU_PINNAME_TO_PIN(obj->pin);
AnnaBridge 187:0387e8f68319 51 uint32_t port_index = NU_PINNAME_TO_PORT(obj->pin);
AnnaBridge 187:0387e8f68319 52
AnnaBridge 187:0387e8f68319 53 return (NU_GET_GPIO_PIN_DATA(port_index, pin_index) ? 1 : 0);
AnnaBridge 187:0387e8f68319 54 }
AnnaBridge 187:0387e8f68319 55
AnnaBridge 187:0387e8f68319 56 #ifdef __cplusplus
AnnaBridge 187:0387e8f68319 57 }
AnnaBridge 187:0387e8f68319 58 #endif
AnnaBridge 187:0387e8f68319 59
AnnaBridge 187:0387e8f68319 60 #endif