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