Mbed OS Reference
Loading...
Searching...
No Matches
port_api.h
1
2/** \addtogroup hal */
3/** @{*/
4/* mbed Microcontroller Library
5 * Copyright (c) 2006-2013 ARM Limited
6 * SPDX-License-Identifier: Apache-2.0
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20#ifndef MBED_PORTMAP_H
21#define MBED_PORTMAP_H
22
23#include "device.h"
24
25#if DEVICE_PORTIN || DEVICE_PORTOUT
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/** Port HAL structure. port_s is declared in the target's HAL
32 */
33typedef struct port_s port_t;
34
35/**
36 * \defgroup hal_port Port HAL functions
37 * @{
38 */
39
40/** Get the pin name from the port's pin number
41 *
42 * @param port The port name
43 * @param pin_n The pin number within the specified port
44 * @return The pin name for the port's pin number
45 */
46PinName port_pin(PortName port, int pin_n);
47
48/** Initilize the port
49 *
50 * @param obj The port object to initialize
51 * @param port The port name
52 * @param mask The bitmask to identify which bits in the port should be included (0 - ignore)
53 * @param dir The port direction
54 */
55void port_init(port_t *obj, PortName port, int mask, PinDirection dir);
56
57/** Set the input port mode
58 *
59 * @param obj The port object
60 * @param mode THe port mode to be set
61 */
62void port_mode(port_t *obj, PinMode mode);
63
64/** Set port direction (in/out)
65 *
66 * @param obj The port object
67 * @param dir The port direction to be set
68 */
69void port_dir(port_t *obj, PinDirection dir);
70
71/** Write value to the port
72 *
73 * @param obj The port object
74 * @param value The value to be set
75 */
76void port_write(port_t *obj, int value);
77
78/** Read the current value on the port
79 *
80 * @param obj The port object
81 * @return An integer with each bit corresponding to an associated port pin setting
82 */
83int port_read(port_t *obj);
84
85/**@}*/
86
87#ifdef __cplusplus
88}
89#endif
90#endif
91
92#endif
93
94/** @}*/
void port_mode(port_t *obj, PinMode mode)
Set the input port mode.
int port_read(port_t *obj)
Read the current value on the port.
PinName port_pin(PortName port, int pin_n)
Get the pin name from the port's pin number.
void port_init(port_t *obj, PortName port, int mask, PinDirection dir)
Initilize the port.
void port_dir(port_t *obj, PinDirection dir)
Set port direction (in/out)
void port_write(port_t *obj, int value)
Write value to the port.
struct port_s port_t
Port HAL structure.
Definition: port_api.h:33