mbed library sources. Supersedes mbed-src.

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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers port_api.h Source File

port_api.h

00001 
00002 /** \addtogroup hal */
00003 /** @{*/
00004 /* mbed Microcontroller Library
00005  * Copyright (c) 2006-2013 ARM Limited
00006  * SPDX-License-Identifier: Apache-2.0
00007  *
00008  * Licensed under the Apache License, Version 2.0 (the "License");
00009  * you may not use this file except in compliance with the License.
00010  * You may obtain a copy of the License at
00011  *
00012  *     http://www.apache.org/licenses/LICENSE-2.0
00013  *
00014  * Unless required by applicable law or agreed to in writing, software
00015  * distributed under the License is distributed on an "AS IS" BASIS,
00016  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017  * See the License for the specific language governing permissions and
00018  * limitations under the License.
00019  */
00020 #ifndef MBED_PORTMAP_H
00021 #define MBED_PORTMAP_H
00022 
00023 #include "device.h"
00024 
00025 #if DEVICE_PORTIN || DEVICE_PORTOUT
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00031 /** Port HAL structure. port_s is declared in the target's HAL
00032  */
00033 typedef struct port_s port_t;
00034 
00035 /**
00036  * \defgroup hal_port Port HAL functions
00037  * @{
00038  */
00039 
00040 /** Get the pin name from the port's pin number
00041  *
00042  * @param port  The port name
00043  * @param pin_n The pin number within the specified port
00044  * @return The pin name for the port's pin number
00045  */
00046 PinName port_pin(PortName port, int pin_n);
00047 
00048 /** Initilize the port
00049  *
00050  * @param obj  The port object to initialize
00051  * @param port The port name
00052  * @param mask The bitmask to identify which bits in the port should be included (0 - ignore)
00053  * @param dir  The port direction
00054  */
00055 void port_init(port_t *obj, PortName port, int mask, PinDirection dir);
00056 
00057 /** Set the input port mode
00058  *
00059  * @param obj  The port object
00060  * @param mode THe port mode to be set
00061  */
00062 void port_mode(port_t *obj, PinMode mode);
00063 
00064 /** Set port direction (in/out)
00065  *
00066  * @param obj The port object
00067  * @param dir The port direction to be set
00068  */
00069 void port_dir(port_t *obj, PinDirection dir);
00070 
00071 /** Write value to the port
00072  *
00073  * @param obj   The port object
00074  * @param value The value to be set
00075  */
00076 void port_write(port_t *obj, int value);
00077 
00078 /** Read the current value on the port
00079  *
00080  * @param obj The port object
00081  * @return An integer with each bit corresponding to an associated port pin setting
00082  */
00083 int port_read(port_t *obj);
00084 
00085 /**@}*/
00086 
00087 #ifdef __cplusplus
00088 }
00089 #endif
00090 #endif
00091 
00092 #endif
00093 
00094 /** @}*/