S32 SDK
flexio.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 - 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016 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  */
18 
19 #ifndef FLEXIO_DRIVER_H
20 #define FLEXIO_DRIVER_H
21 
22 #include <stddef.h>
23 #include <stdbool.h>
24 #include "device_registers.h"
25 #include "flexio_hal.h"
26 #include "osif.h"
27 #include "status.h"
28 
34 /*******************************************************************************
35  * Enumerations.
36  ******************************************************************************/
37 
38 
42 typedef enum
43 {
48 
52 typedef enum
53 {
58 
59 
60 /*******************************************************************************
61 * Definitions
62 ******************************************************************************/
63 
64 
74 typedef void (*flexio_callback_t)(void *driverState, flexio_event_t event, void *userData);
75 
76 
79 /*
80  * FlexIO interrupt service routine
81  */
82 typedef void (*flexio_isr_t)(void *isrParam);
83 
84 /*
85  * FlexIO common context structure
86  * This is a common structure used by all FlexIO drivers as a part of their context structure.
87  * It is needed for common operations such as interrupt handling.
88  */
89 typedef struct
90 {
91  flexio_isr_t isr; /* Interrupt handler for this driver instance */
92  uint32_t instance; /* FlexIO device instance number */
93  uint8_t resourceCount; /* Count of internal resources used (shifters and timers) */
94  uint8_t resourceIndex; /* Index of first used internal resource instance (shifter and timer) */
95 } flexio_common_state_t;
96 
97 /*
98  * FlexIO device context structure
99  * This is a structure containing data common to all drivers on one device
100  */
101 typedef struct
102 {
103  uint8_t resourceAllocation; /* Mask to keep track of resources allocated on current device */
104  mutex_t resourceLock; /* Mutex for guarding channel allocation. */
105  /* Array of pointers to runtime state structures. Each FlexIO instance can have at most
106  one driver instance per shifter. */
107  flexio_common_state_t *flexioStatePtr[FEATURE_FLEXIO_MAX_SHIFTER_COUNT];
108 } flexio_device_state_t;
109 
113 /*******************************************************************************
114  * API
115  ******************************************************************************/
121 #if defined(__cplusplus)
122 extern "C" {
123 #endif
124 
138 status_t FLEXIO_DRV_InitDevice(uint32_t instance, flexio_device_state_t *deviceState);
139 
140 
149 status_t FLEXIO_DRV_DeinitDevice(uint32_t instance);
150 
151 
160 status_t FLEXIO_DRV_Reset(uint32_t instance);
161 
162 
163 
165 #if defined(__cplusplus)
166 }
167 #endif
168 
171 #endif /* FLEXIO_DRIVER_H */
172 /*******************************************************************************
173  * EOF
174  ******************************************************************************/
flexio_event_t
flexio events Implements : flexio_event_t_Class
Definition: flexio.h:52
void(* flexio_callback_t)(void *driverState, flexio_event_t event, void *userData)
flexio callback function
Definition: flexio.h:74
status_t FLEXIO_DRV_Reset(uint32_t instance)
Resets the FlexIO device.
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
Definition: status.h:31
flexio_driver_type_t
Driver type: interrupts/polling/DMA Implements : flexio_driver_type_t_Class.
Definition: flexio.h:42
status_t FLEXIO_DRV_DeinitDevice(uint32_t instance)
De-initializes the FlexIO device.
#define FEATURE_FLEXIO_MAX_SHIFTER_COUNT
status_t FLEXIO_DRV_InitDevice(uint32_t instance, flexio_device_state_t *deviceState)
Initializes the FlexIO device.
Definition: flexio_common.c:89