DIGITAL_IO
|
DIGITAL_IO.h
00001 /* 00002 * 00003 * @file digital_io.h 00004 * @date 2015-12-22 00005 * 00006 * NOTE: 00007 * This file is generated by DAVE. Any manual modification done to this file will be lost when the code is regenerated. 00008 * 00009 * @cond 00010 *********************************************************************************************************************** 00011 * DIGITAL_IO v4.0.14 - The DIGITAL_IO APP is used to configure a port pin as digital Input/Output. 00012 * 00013 * Copyright (c) 2015, Infineon Technologies AG 00014 * All rights reserved. 00015 * 00016 * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the 00017 * following conditions are met: 00018 * 00019 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following 00020 * disclaimer. 00021 * 00022 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 00023 * following disclaimer in the documentation and/or other materials provided with the distribution. 00024 * 00025 * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote 00026 * products derived from this software without specific prior written permission. 00027 * 00028 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 00029 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00030 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00031 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00032 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00033 * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00034 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes 00037 * with Infineon Technologies AG ([email protected]). 00038 *********************************************************************************************************************** 00039 * 00040 * Change History 00041 * -------------- 00042 * 00043 * 2015-02-16 00044 * - Initial version 00045 * 00046 * 2015-04-22 00047 * - XMC_ASSERT is added in static inline functions.<br> 00048 * 00049 * 2015-06-20 00050 * - Version check added for XMCLib dependency.<br> 00051 * 00052 * 2015-12-22 00053 * - Added hardware controlled IO feature. 00054 * 00055 * @endcond 00056 * 00057 */ 00058 00059 /*********************************************************************************************************************** 00060 * HEADER FILES 00061 **********************************************************************************************************************/ 00062 00063 #ifndef DIGITAL_IO_H 00064 #define DIGITAL_IO_H 00065 00066 #include <xmc_gpio.h> 00067 #include <DAVE_common.h> 00068 #include "digital_io_conf.h" 00069 00070 /*********************************************************************************************************************** 00071 * MACROS 00072 **********************************************************************************************************************/ 00073 #if (!((XMC_LIB_MAJOR_VERSION == 2U) && \ 00074 (XMC_LIB_MINOR_VERSION >= 0U) && \ 00075 (XMC_LIB_PATCH_VERSION >= 0U))) 00076 #error "DIGITAL_IO requires XMC Peripheral Library v2.0.0 or higher" 00077 #endif 00078 00079 /********************************************************************************************************************** 00080 * ENUMS 00081 **********************************************************************************************************************/ 00082 00091 typedef enum DIGITAL_IO_STATUS 00092 { 00093 DIGITAL_IO_STATUS_OK = 0U, 00094 DIGITAL_IO_STATUS_FAILURE = 1U 00095 } DIGITAL_IO_STATUS_t; 00096 00101 /********************************************************************************************************************** 00102 * DATA STRUCTURES 00103 **********************************************************************************************************************/ 00112 typedef struct DIGITAL_IO 00113 { 00114 XMC_GPIO_PORT_t *const gpio_port; 00115 const XMC_GPIO_CONFIG_t gpio_config; 00116 const uint8_t gpio_pin; 00117 const XMC_GPIO_HWCTRL_t hwctrl; 00118 } DIGITAL_IO_t; 00119 00120 00126 /*********************************************************************************************************************** 00127 * API Prototypes 00128 **********************************************************************************************************************/ 00129 00130 00131 #ifdef __cplusplus 00132 extern "C" { 00133 #endif 00134 00180 DAVE_APP_VERSION_t DIGITAL_IO_GetAppVersion(void); 00181 00222 DIGITAL_IO_STATUS_t DIGITAL_IO_Init(const DIGITAL_IO_t *const handler); 00223 00266 __STATIC_INLINE void DIGITAL_IO_SetOutputHigh(const DIGITAL_IO_t *const handler) 00267 { 00268 XMC_ASSERT("DIGITAL_IO_SetOutputHigh: handler null pointer", handler != NULL); 00269 XMC_GPIO_SetOutputHigh(handler->gpio_port, handler->gpio_pin); 00270 } 00271 00313 __STATIC_INLINE void DIGITAL_IO_SetOutputLow(const DIGITAL_IO_t *const handler) 00314 { 00315 XMC_ASSERT("DIGITAL_IO_SetOutputLow: handler null pointer", handler != NULL); 00316 XMC_GPIO_SetOutputLow(handler->gpio_port,handler->gpio_pin); 00317 } 00318 00365 __STATIC_INLINE void DIGITAL_IO_ToggleOutput(const DIGITAL_IO_t *const handler) 00366 { 00367 XMC_ASSERT("DIGITAL_IO_ToggleOutput: handler null pointer", handler != NULL); 00368 XMC_GPIO_ToggleOutput(handler->gpio_port, handler->gpio_pin); 00369 } 00370 00419 __STATIC_INLINE uint32_t DIGITAL_IO_GetInput(const DIGITAL_IO_t *const handler) 00420 { 00421 XMC_ASSERT("DIGITAL_IO_GetInput: handler null pointer", handler != NULL); 00422 return XMC_GPIO_GetInput(handler->gpio_port, handler->gpio_pin); 00423 } 00424 00429 #ifdef __cplusplus 00430 } 00431 #endif 00432 00433 /* Include APP extern file */ 00434 #include "digital_io_extern.h" 00435 00436 00437 #endif /* DIGITAL_IO_H */