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 
56 
57 /*******************************************************************************
58 * Definitions
59 ******************************************************************************/
60 
63 /*
64  * FlexIO interrupt service routine
65  */
66 typedef void (*flexio_isr_t)(void *isrParam);
67 
68 /*
69  * FlexIO common context structure
70  * This is a common structure used by all FlexIO drivers as a part of their context structure.
71  * It is needed for common operations such as interrupt handling.
72  */
73 typedef struct
74 {
75  flexio_isr_t isr; /* Interrupt handler for this driver instance */
76  uint32_t instance; /* FlexIO device instance number */
77  uint8_t resourceCount; /* Count of internal resources used (shifters and timers) */
78  uint8_t resourceIndex; /* Index of first used internal resource instance (shifter and timer) */
79 } flexio_common_state_t;
80 
81 /*
82  * FlexIO device context structure
83  * This is a structure containing data common to all drivers on one device
84  */
85 typedef struct
86 {
87  uint8_t resourceAllocation; /* Mask to keep track of resources allocated on current device */
88  mutex_t resourceLock; /* Mutex for guarding channel allocation. */
89  /* Array of pointers to runtime state structures. Each FlexIO instance can have at most
90  one driver instance per shifter. */
91  flexio_common_state_t *flexioStatePtr[FEATURE_FLEXIO_MAX_SHIFTER_COUNT];
92 } flexio_device_state_t;
93 
97 /*******************************************************************************
98  * API
99  ******************************************************************************/
105 #if defined(__cplusplus)
106 extern "C" {
107 #endif
108 
122 status_t FLEXIO_DRV_InitDevice(uint32_t instance, flexio_device_state_t *deviceState);
123 
124 
133 status_t FLEXIO_DRV_DeinitDevice(uint32_t instance);
134 
135 
144 status_t FLEXIO_DRV_Reset(uint32_t instance);
145 
146 
147 
149 #if defined(__cplusplus)
150 }
151 #endif
152 
155 #endif /* FLEXIO_DRIVER_H */
156 /*******************************************************************************
157  * EOF
158  ******************************************************************************/
#define FEATURE_FLEXIO_MAX_SHIFTER_COUNT
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.
status_t FLEXIO_DRV_InitDevice(uint32_t instance, flexio_device_state_t *deviceState)
Initializes the FlexIO device.
Definition: flexio_common.c:89