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