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