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 "osif.h"
26 #include "status.h"
27 
41 /*******************************************************************************
42  * Enumerations.
43  ******************************************************************************/
44 
45 
49 typedef enum
50 {
55 
59 typedef enum
60 {
65 
66 
67 /*******************************************************************************
68 * Definitions
69 ******************************************************************************/
70 
71 
81 typedef void (*flexio_callback_t)(void *driverState, flexio_event_t event, void *userData);
82 
83 
86 /*
87  * FlexIO interrupt service routine
88  */
89 typedef void (*flexio_isr_t)(void *isrParam);
90 
91 /*
92  * FlexIO common context structure
93  * This is a common structure used by all FlexIO drivers as a part of their context structure.
94  * It is needed for common operations such as interrupt handling.
95  */
96 typedef struct
97 {
98  flexio_isr_t isr; /* Interrupt handler for this driver instance */
99  uint32_t instance; /* FlexIO device instance number */
100  uint8_t resourceCount; /* Count of internal resources used (shifters and timers) */
101  uint8_t resourceIndex; /* Index of first used internal resource instance (shifter and timer) */
102 } flexio_common_state_t;
103 
104 /*
105  * FlexIO device context structure
106  * This is a structure containing data common to all drivers on one device
107  */
108 typedef struct
109 {
110  uint8_t resourceAllocation; /* Mask to keep track of resources allocated on current device */
111  mutex_t resourceLock; /* Mutex for guarding channel allocation. */
112  /* Array of pointers to runtime state structures. Each FlexIO instance can have at most
113  one driver instance per shifter. */
114  flexio_common_state_t *flexioStatePtr[FEATURE_FLEXIO_MAX_SHIFTER_COUNT];
115 } flexio_device_state_t;
116 
120 /*******************************************************************************
121  * API
122  ******************************************************************************/
128 #if defined(__cplusplus)
129 extern "C" {
130 #endif
131 
145 status_t FLEXIO_DRV_InitDevice(uint32_t instance, flexio_device_state_t *deviceState);
146 
147 
156 status_t FLEXIO_DRV_DeinitDevice(uint32_t instance);
157 
158 
167 status_t FLEXIO_DRV_Reset(uint32_t instance);
168 
169 
170 
172 #if defined(__cplusplus)
173 }
174 #endif
175 
178 #endif /* FLEXIO_DRIVER_H */
179 /*******************************************************************************
180  * EOF
181  ******************************************************************************/
flexio_event_t
flexio events Implements : flexio_event_t_Class
Definition: flexio.h:59
void(* flexio_callback_t)(void *driverState, flexio_event_t event, void *userData)
flexio callback function
Definition: flexio.h:81
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:44
flexio_driver_type_t
Driver type: interrupts/polling/DMA Implements : flexio_driver_type_t_Class.
Definition: flexio.h:49
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