PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
gpio.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2013 Spansion LLC. All Rights Reserved.
3 *
4 * This software is owned and published by:
5 * Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA 94088-3453 ("Spansion").
6 *
7 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
8 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
9 *
10 * This software contains source code for use with Spansion
11 * components. This software is licensed by Spansion to be adapted only
12 * for use in systems utilizing Spansion components. Spansion shall not be
13 * responsible for misuse or illegal use of this software for devices not
14 * supported herein. Spansion is providing this software "AS IS" and will
15 * not be responsible for issues arising from incorrect user implementation
16 * of the software.
17 *
18 * SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
19 * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
20 * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
21 * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
22 * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
23 * WARRANTY OF NONINFRINGEMENT.
24 * SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
25 * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
26 * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
27 * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
28 * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
30 * SAVINGS OR PROFITS,
31 * EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
33 * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
34 * FROM, THE SOFTWARE.
35 *
36 * This software may be replicated in part or whole for the licensed use,
37 * with the restriction that this Disclaimer and Copyright notice must be
38 * included with each copy of this software, whether used in part or whole,
39 * at all times.
40 */
41 /******************************************************************************/
53 #ifndef __GPIO_H__
54 #define __GPIO_H__
55 
56 /******************************************************************************/
57 /* Include files */
58 /******************************************************************************/
59 #include "pdl.h"
60 
61 /* C binding of definitions if building with C++ compiler */
62 #ifdef __cplusplus
63 extern "C"
64 {
65 #endif
66 
80 
81 /******************************************************************************/
82 /* Defines */
83 /******************************************************************************/
84 
85 #define Gpio1pin_InitIn(p,settings) do{ stc_gpio1pin_init_t __v__;\
86  __v__.bPullup=0u;__v__.bInitVal=0u;\
87  (settings);\
88  p##_INITIN(__v__); }while(0)
89 
90 #define Gpio1pin_InitOut(p,settings) do{ stc_gpio1pin_init_t __v__;\
91  __v__.bPullup=0u;__v__.bInitVal=0u;\
92  (settings);\
93  p##_INITOUT(__v__); }while(0)
94 
95 #define Gpio1pin_Init(p,settings) do{ stc_gpio1pin_init_t __v__;__v__.bOutput=0u;\
96  __v__.bPullup=0u;__v__.bInitVal=0u;\
97  (settings);\
98  p##_INIT( __v__ ); }while(0)
99 
100 #define Gpio1pin_InitDirectionInput (__v__.bOutput=0u)
101 #define Gpio1pin_InitDirectionOutput (__v__.bOutput=1u)
102 #define Gpio1pin_InitPullup(v) (__v__.bPullup=(v))
103 #define Gpio1pin_InitVal(v) (__v__.bInitVal=(v))
104 
105 
106 
107 #define Gpio1pin_Get(p) p##_GET
108 #define Gpio1pin_Put(p,v) p##_PUT(v)
109 
110 #define PINRELOC_SET_EPFR(epfr,pos,width,value) \
111  ((epfr) = ((epfr) & ~(((1u<<(width))-1u)<<(pos)) | \
112  ((value) << (pos))))
113 
114 /******************************************************************************/
115 /* Parameterized Port Concatenators */
116 /******************************************************************************/
117 #define GPIO_PASTER(x, p, y) x##p##y
118 #define GPIO_EVALUATOR(x, p, y) GPIO_PASTER(x, p, y)
119 
120 #define GPIO_PASTER2(x, p1, p2, y) x(##p1##p2##,##y)
121 #define GPIO_EVALUATOR2(x, p1, p2, y) GPIO_PASTER2(x, p1, p2, y)
122 
123 #define GpioGet(port) GPIO_EVALUATOR(GPIO1PIN_, port, _GET)
124 #define GpioPut(port, value) GPIO_EVALUATOR(GPIO1PIN_, port, _PUT( value ))
125 
126 #define GpioInitOut(port, pullup) GPIO_EVALUATOR2(Gpio1pin_InitOut, GPIO1PIN_, port, Gpio1pin_InitVal( pullup ))
127 #define GpioInitIn(port, value) GPIO_EVALUATOR2(Gpio1pin_InitIn, GPIO1PIN_, port, Gpio1pin_InitPullup( value ))
128 
129 /******************************************************************************/
130 /* Inclusion of GPIO defines of user defined device */
131 /******************************************************************************/
132 
133 #if (PDL_DEVICE_MB9BF56X == PDL_ON)
134  #if (PDL_PACKAGE == PDL_DEVICE_PACKAGE_M)
135  #include "gpio_mb9bf56xm.h"
136  #elif (PDL_PACKAGE == PDL_DEVICE_PACKAGE_N)
137  #include "gpio_mb9bf56xn.h"
138  #elif (PDL_PACKAGE == PDL_DEVICE_PACKAGE_R)
139  #include "gpio_mb9bf56xr.h"
140  #else
141  #error Package for MB9BF56X not found!
142  #endif
143 #else
144  #error Device not found!
145 #endif
146 
147 
148 /******************************************************************************/
149 /* Types */
150 /******************************************************************************/
151 
152 typedef struct stc_gpio1pin_init
153 {
158 
159 
161 
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif /* __GPIO_H__ */
167 
168 /******************************************************************************/
169 /* EOF (not truncated) */
170 /******************************************************************************/