S32 SDK
pins_driver.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
7  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
9  * IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
10  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
11  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
12  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
14  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
15  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
16  * THE POSSIBILITY OF SUCH DAMAGE.
17  */
29 #include "device_registers.h"
30 #include "pins_gpio_hw_access.h"
31 #if defined(FEATURE_PINS_DRIVER_USING_SIUL2)
32 #include "pins_siul2_hw_access.h"
33 #elif defined(FEATURE_PINS_DRIVER_USING_PORT)
34 #include "pins_port_hw_access.h"
35 #endif
36 
37 /*******************************************************************************
38  * Definitions
39  ******************************************************************************/
40 
41 /*******************************************************************************
42  * Variables
43  ******************************************************************************/
44 
45 /*FUNCTION**********************************************************************
46  *
47  * Function Name : PINS_DRV_Init
48  * Description : This function configures the pins with the options provided
49  * in the given structure.
50  *
51  * Implements : PINS_DRV_Init_Activity
52  *END**************************************************************************/
53 status_t PINS_DRV_Init(uint32_t pinCount,
54  const pin_settings_config_t config[])
55 {
56  uint32_t i;
57  status_t result = STATUS_SUCCESS;
58  status_t pinInitStatus;
59  for (i = 0U; i < pinCount; i++)
60  {
61  pinInitStatus = PINS_Init(&config[i]);
62  if (STATUS_SUCCESS != pinInitStatus)
63  {
64  result = pinInitStatus;
65  }
66  }
67 
68  return result;
69 }
70 
71 #if defined(FEATURE_PINS_DRIVER_USING_PORT)
72 #if FEATURE_PINS_HAS_PULL_SELECTION
73 /*FUNCTION**********************************************************************
74  *
75  * Function Name : PINS_DRV_SetPullSel
76  * Description : This function configures the internal resistor.
77  *
78  * Implements : PINS_DRV_SetPullSel_Activity
79  *END**************************************************************************/
80 void PINS_DRV_SetPullSel(PORT_Type * const base,
81  uint32_t pin,
82  port_pull_config_t pullConfig)
83 {
84  PINS_SetPullSel(base, pin, pullConfig);
85 }
86 
87 #endif /* FEATURE_PINS_HAS_PULL_SELECTION */
88 
89 /*FUNCTION**********************************************************************
90  *
91  * Function Name : PINS_DRV_SetMuxModeSel
92  * Description : This function configures the pin muxing.
93  *
94  * Implements : PINS_DRV_SetMuxModeSel_Activity
95  *END**************************************************************************/
96 void PINS_DRV_SetMuxModeSel(PORT_Type * const base,
97  uint32_t pin,
98  port_mux_t mux)
99 {
100  PINS_SetMuxModeSel(base, pin, mux);
101 }
102 
103 /*FUNCTION**********************************************************************
104  *
105  * Function Name : PINS_DRV_SetPinIntSel
106  * Description : This function configures the port pin interrupt/DMA request.
107  *
108  * Implements : PINS_DRV_SetPinIntSel_Activity
109  *END**************************************************************************/
110 void PINS_DRV_SetPinIntSel(PORT_Type * const base,
111  uint32_t pin,
112  port_interrupt_config_t intConfig)
113 {
114  PINS_SetPinIntSel(base, pin, intConfig);
115 }
116 
117 /*FUNCTION**********************************************************************
118  *
119  * Function Name : PINS_DRV_GetPinIntSel
120  * Description : This function gets the current port pin interrupt/DMA request configuration.
121  *
122  * Implements : PINS_DRV_GetPinIntSel_Activity
123  *END**************************************************************************/
124 port_interrupt_config_t PINS_DRV_GetPinIntSel(const PORT_Type * const base,
125  uint32_t pin)
126 {
127  return PINS_GetPinIntSel(base, pin);
128 }
129 
130 /*FUNCTION**********************************************************************
131  *
132  * Function Name : PINS_DRV_ClearPinIntFlagCmd
133  * Description : This function clears the individual pin-interrupt status flag.
134  *
135  * Implements : PINS_DRV_ClearPinIntFlagCmd_Activity
136  *END**************************************************************************/
137 void PINS_DRV_ClearPinIntFlagCmd(PORT_Type * const base,
138  uint32_t pin)
139 {
140  PINS_ClearPinIntFlagCmd(base, pin);
141 }
142 
143 /*FUNCTION**********************************************************************
144  *
145  * Function Name : PINS_DRV_GetPortIntFlag
146  * Description : This function reads the entire port interrupt status flag.
147  *
148  * Implements : PINS_DRV_GetPortIntFlag_Activity
149  *END**************************************************************************/
150 uint32_t PINS_DRV_GetPortIntFlag(const PORT_Type * const base)
151 {
152  return PINS_GetPortIntFlag(base);
153 }
154 
155 /*FUNCTION**********************************************************************
156  *
157  * Function Name : PINS_DRV_ClearPortIntFlagCmd
158  * Description : This function clears the entire port interrupt status flag.
159  *
160  * Implements : PINS_DRV_ClearPortIntFlagCmd_Activity
161  *END**************************************************************************/
162 void PINS_DRV_ClearPortIntFlagCmd(PORT_Type * const base)
163 {
164  PINS_ClearPortIntFlagCmd(base);
165 }
166 
167 /*FUNCTION**********************************************************************
168  *
169  * Function Name : PINS_DRV_GetPinsDirection
170  * Description : This function returns the current pins directions for a port. Pins
171  * corresponding to bits with value of '1' are configured as output and
172  * pins corresponding to bits with value of '0' are configured as input.
173  *
174  * Implements : PINS_DRV_GetPinsDirection_Activity
175  *END**************************************************************************/
176 pins_channel_type_t PINS_DRV_GetPinsDirection(const GPIO_Type * const base)
177 {
178  return PINS_GPIO_GetPinsDirection(base);
179 }
180 
181 /*FUNCTION**********************************************************************
182  *
183  * Function Name : PINS_DRV_SetPinDirection
184  * Description : This function configures the direction for the given pin, with the
185  * given value('1' for pin to be configured as output and '0' for pin to
186  * be configured as input).
187  *
188  * Implements : PINS_DRV_SetPinDirection_Activity
189  *END**************************************************************************/
190 void PINS_DRV_SetPinDirection(GPIO_Type * const base,
191  pins_channel_type_t pin,
192  pins_level_type_t direction)
193 {
194  PINS_GPIO_SetPinDirection(base, pin, direction);
195 }
196 
197 /*FUNCTION**********************************************************************
198  *
199  * Function Name : PINS_DRV_SetPinsDirection
200  * Description : This function sets the direction configuration for all pins
201  * in a port. Pins corresponding to bits with value of '1' will be configured as
202  * output and pins corresponding to bits with value of '0' will be configured as
203  * input.
204  *
205  * Implements : PINS_DRV_SetPinsDirection_Activity
206  *END**************************************************************************/
207 void PINS_DRV_SetPinsDirection(GPIO_Type * const base,
208  pins_channel_type_t pins)
209 {
210  PINS_GPIO_SetPinsDirection(base, pins);
211 }
212 
213 /*FUNCTION**********************************************************************
214  *
215  * Function Name : PINS_DRV_SetPortInputDisable
216  * Description : This function sets the pins input state for a port.
217  * Pins corresponding to bits with value of '1' will not be configured
218  * as input and pins corresponding to bits with value of '0' will be configured
219  * as input.
220  *
221  * Implements : PINS_DRV_SetPortInputDisable_Activity
222  *END**************************************************************************/
223 void PINS_DRV_SetPortInputDisable(GPIO_Type * const base,
224  pins_channel_type_t pins)
225 {
226  PINS_GPIO_SetPortInputDisable(base, pins);
227 }
228 
229 /*FUNCTION**********************************************************************
230  *
231  * Function Name : PINS_DRV_GetPortInputDisable
232  * Description : This function returns the current pins input state for a port. Pins
233  * corresponding to bits with value of '1' are not configured as input and
234  * pins corresponding to bits with value of '0' are configured as input.
235  *
236  * Implements : PINS_DRV_GetPortInputDisable_Activity
237  *END**************************************************************************/
238 pins_channel_type_t PINS_DRV_GetPortInputDisable(const GPIO_Type * const base)
239 {
240  return PINS_GPIO_GetPortInputDisable(base);
241 }
242 
243 #elif defined(FEATURE_PINS_DRIVER_USING_SIUL2)
244 #endif /* FEATURE_PINS_DRIVER_USING_PORT */
245 
246 /*FUNCTION**********************************************************************
247  *
248  * Function Name : PINS_DRV_WritePin
249  * Description : This function writes the given pin from a port, with the given value
250  * ('0' represents LOW, '1' represents HIGH).
251  *
252  * Implements : PINS_DRV_WritePin_Activity
253  *END**************************************************************************/
254 void PINS_DRV_WritePin(GPIO_Type * const base,
255  pins_channel_type_t pin,
256  pins_level_type_t value)
257 {
258  PINS_GPIO_WritePin(base, pin, value);
259 }
260 
261 /*FUNCTION**********************************************************************
262  *
263  * Function Name : PINS_DRV_WritePins
264  * Description : This function writes all pins configured as output with the values given in
265  * the parameter pins. '0' represents LOW, '1' represents HIGH.
266  *
267  * Implements : PINS_DRV_WritePins_Activity
268  *END**************************************************************************/
269 void PINS_DRV_WritePins(GPIO_Type * const base,
270  pins_channel_type_t pins)
271 {
272  PINS_GPIO_WritePins(base, pins);
273 }
274 
275 /*FUNCTION**********************************************************************
276  *
277  * Function Name : PINS_DRV_GetPinsOutput
278  * Description : This function returns the current output that is written to a port. Only pins
279  * that are configured as output will have meaningful values.
280  *
281  * Implements : PINS_DRV_GetPinsOutput_Activity
282  *END**************************************************************************/
283 pins_channel_type_t PINS_DRV_GetPinsOutput(const GPIO_Type * const base)
284 {
285  return PINS_GPIO_GetPinsOutput(base);
286 }
287 
288 /*FUNCTION**********************************************************************
289  *
290  * Function Name : PINS_DRV_SetPins
291  * Description : This function configures output pins listed in parameter pins (bits that are
292  * '1') to have a value of 'set' (HIGH). Pins corresponding to '0' will be
293  * unaffected.
294  *
295  * Implements : PINS_DRV_SetPins_Activity
296  *END**************************************************************************/
297 void PINS_DRV_SetPins(GPIO_Type * const base,
298  pins_channel_type_t pins)
299 {
300  PINS_GPIO_SetPins(base, pins);
301 }
302 
303 /*FUNCTION**********************************************************************
304  *
305  * Function Name : PINS_DRV_ClearPins
306  * Description : This function configures output pins listed in parameter pins (bits that are
307  * '1') to have a 'cleared' value (LOW). Pins corresponding to '0' will be
308  * unaffected.
309  *
310  * Implements : PINS_DRV_ClearPins_Activity
311  *END**************************************************************************/
312 void PINS_DRV_ClearPins(GPIO_Type * const base,
313  pins_channel_type_t pins)
314 {
315  PINS_GPIO_ClearPins(base, pins);
316 }
317 
318 /*FUNCTION**********************************************************************
319  *
320  * Function Name : PINS_DRV_TogglePins
321  * Description : This function toggles output pins listed in parameter pins (bits that are
322  * '1'). Pins corresponding to '0' will be unaffected.
323  *
324  * Implements : PINS_DRV_TogglePins_Activity
325  *END**************************************************************************/
326 void PINS_DRV_TogglePins(GPIO_Type * const base,
327  pins_channel_type_t pins)
328 {
329  PINS_GPIO_TogglePins(base, pins);
330 }
331 
332 /*FUNCTION**********************************************************************
333  *
334  * Function Name : PINS_DRV_ReadPins
335  * Description : This function returns the current input values from a port. Only pins
336  * configured as input will have meaningful values.
337  *
338  * Implements : PINS_DRV_ReadPins_Activity
339  *END**************************************************************************/
340 pins_channel_type_t PINS_DRV_ReadPins(const GPIO_Type * const base)
341 {
342  return PINS_GPIO_ReadPins(base);
343 }
344 
345 /******************************************************************************
346  * EOF
347  *****************************************************************************/
rtc_interrupt_config_t * intConfig
Definition: rtc_driver.c:78
status_t PINS_DRV_Init(uint32_t pinCount, const pin_settings_config_t config[])
Initializes the pins with the given configuration structure.
Definition: pins_driver.c:53
pins_channel_type_t PINS_DRV_GetPinsOutput(const GPIO_Type *const base)
Get the current output from a port.
Definition: pins_driver.c:283
void PINS_DRV_WritePin(GPIO_Type *const base, pins_channel_type_t pin, pins_level_type_t value)
Write a pin of a port with a given value.
Definition: pins_driver.c:254
void PINS_DRV_TogglePins(GPIO_Type *const base, pins_channel_type_t pins)
Toggle pins value.
Definition: pins_driver.c:326
void PINS_DRV_WritePins(GPIO_Type *const base, pins_channel_type_t pins)
Write all pins of a port.
Definition: pins_driver.c:269
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
Definition: status.h:44
Defines the converter configuration.
Definition: pins_driver.h:504
void PINS_DRV_SetPins(GPIO_Type *const base, pins_channel_type_t pins)
Write pins with 'Set' value.
Definition: pins_driver.c:297
pins_channel_type_t PINS_DRV_ReadPins(const GPIO_Type *const base)
Read input pins.
Definition: pins_driver.c:340
uint8_t pins_level_type_t
Type of a port levels representation. Implements : pins_level_type_t_Class.
Definition: pins_driver.h:56
void PINS_DRV_ClearPins(GPIO_Type *const base, pins_channel_type_t pins)
Write pins to 'Clear' value.
Definition: pins_driver.c:312