| ISF 2.1 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
isf_fifo.h
Go to the documentation of this file.
1 /*
2 * isf_fifo.h
3 *
4 * Created on: Oct 1, 2014
5 * Author: B37804
6 */
7
8 #ifndef ISF_FIFO_H_
9 #define ISF_FIFO_H_
10
11 #include <mqxlite.h>
12 #include "isf_types.h"
13 #include "lwevent.h"
14
15 typedef uint32 isf_fifo_status_t;
16
17
18 typedef struct {
19 uint8 *pDataBuffer; /*!< Pointer to the data buffer for the new sensor data samples */
20 uint8 *pInsertPtr; /*!< Pointer to where the next sample goes when buffering multiple samples */
21 uint8 *pLastEntry; /*!< Pointer to the last entry in the fifo. When the pInsertPtr equals lastEntry the fifo is full */
22 uint16 sampleSize; /*!< The size of a single sample in bytes */
23 LWSEM_STRUCT bufferLock; /*!< Lock for the shared data buffer */
24 uint8 fifoState; /*!< Contains fifo state info including initialization state and buffer allocation type */
25 } isf_fifo_t;
26
27 #define ISF_FIFO_ERR_NO_MEM (1)
28 #define ISF_FIFO_ERR_USER_BUF (2)
29 #define ISF_FIFO_ERR_BUSY (3)
30 #define ISF_FIFO_ERR_INVALID_PTR (4)
31 #define ISF_FIFO_ERR_NO_INIT (5)
32 #define ISF_FIFO_FULL (6)
33 #define ISF_FIFO_NO_MORE_ENTRIES (7)
34 /*!
35 * @brief Initializes a fifo structure and allocates a new fifo buffer.
36 */
37 isf_fifo_status_t isf_fifo_alloc ( isf_fifo_t *pFifo, uint16 sampleSize, uint16 bufferCapacity );
38
39 /*!
40 * @brief Initializes a new fifo structure with a provided buffer.
41 */
42 isf_fifo_status_t isf_fifo_init ( isf_fifo_t *pFifo, void *pData, uint16 sampleSize, uint16 bufferCapacity );
43
44 /*!
45 * @brief free a fifo's sample buffer.
46 */
47 isf_fifo_status_t isf_fifo_free ( isf_fifo_t *pFifo );
48
49 /*!
50 * @brief Routine to copy the whole sample buffer
51 */
52 isf_fifo_status_t isf_fifo_resize ( isf_fifo_t *pFifo, uint16 newCapacity );
53
54 /*!
55 * @brief Routine to query the current fifo size (bytes)
56 */
57 uint16 isf_fifo_get_buffer_size ( isf_fifo_t *pFifo );
58
59 /*!
60 * @brief Routine to copy the whole sample buffer
61 */
62 isf_fifo_status_t isf_fifo_data_copy ( isf_fifo_t *pFifo, void *samplePtr );
63
64 /*!
65 * @brief Lock a sample buffer for exclusive access.
66 */
67 isf_fifo_status_t isf_fifo_lock ( isf_fifo_t *pFifo );
68
69 /*!
70 * @brief Attempt to lock a sample buffer for exclusive access.
71 */
72 isf_fifo_status_t isf_fifo_try_lock ( isf_fifo_t *pFifo );
73
74 /*!
75 * @brief Release the exclusive access lock on a sample buffer.
76 */
77 isf_fifo_status_t isf_fifo_unlock ( isf_fifo_t *pFifo );
78
79 /*!
80 * @brief Routine returns the insert pointer for direct access
81 */
82 void *isf_fifo_el_get_insert_pointer ( isf_fifo_t *pFifo );
83
84 /*!
85 * @brief Routine increments the insert pointer after direct access
86 */
87 isf_fifo_status_t isf_fifo_el_increment ( isf_fifo_t *pFifo );
88
89 /*!
90 * @brief Routine to traverse a fifo
91 * To initiate the traversal set pSamplePtr to NULL.
92 * The function will set the pointer to the first available sample and returns ISF_SUCCESS.
93 * Subsequent calls will increment the pointer to each available sample and return ISF_SUCCESS.
94 * When ISF_SUCCESS is returned, pSamplePtr may be dereferenced to obtain a fifo entry.
95 * When no more samples are available, the function returns ISF_FIFO_NO_MORE_ENTRIES.
96 */
97 isf_fifo_status_t isf_fifo_el_traverse ( isf_fifo_t *pFifo, void **pSamplePtr );
98
99 /*!
100 * @brief Routine to clear the fifo
101 */
102 isf_fifo_status_t isf_fifo_el_clear ( isf_fifo_t *pFifo );
103
104 #endif /* ISF_FIFO_H_ */
105
106 /*
107 * isf_fifo.h
108 *
109 * Created on: Oct 1, 2014
110 * Author: B37804
111 */
112
113 #ifndef ISF_FIFO_H_
114 #define ISF_FIFO_H_
115
116 #include <mqxlite.h>
117 #include "isf_types.h"
118 #include "lwevent.h"
119
120 typedef uint32 isf_fifo_status_t;
121
122
123 typedef struct {
124 uint8 *pDataBuffer; /*!< Pointer to the data buffer for the new sensor data samples */
125 uint8 *pInsertPtr; /*!< Pointer to where the next sample goes when buffering multiple samples */
126 uint8 *pLastEntry; /*!< Pointer to the last entry in the fifo. When the pInsertPtr equals lastEntry the fifo is full */
127 uint16 sampleSize; /*!< The size of a single sample in bytes */
128 LWSEM_STRUCT bufferLock; /*!< Lock for the shared data buffer */
129 uint8 fifoState; /*!< Contains fifo state info including initialization state and buffer allocation type */
130 } isf_fifo_t;
131
132 #define ISF_FIFO_ERR_NO_MEM (1)
133 #define ISF_FIFO_ERR_USER_BUF (2)
134 #define ISF_FIFO_ERR_BUSY (3)
135 #define ISF_FIFO_ERR_INVALID_PTR (4)
136 #define ISF_FIFO_ERR_NO_INIT (5)
137 #define ISF_FIFO_FULL (6)
138 #define ISF_FIFO_NO_MORE_ENTRIES (7)
139 /*!
140 * @brief Initializes a fifo structure and allocates a new fifo buffer.
141 */
142 isf_fifo_status_t isf_fifo_alloc ( isf_fifo_t *pFifo, uint16 sampleSize, uint16 bufferCapacity );
143
144 /*!
145 * @brief Initializes a new fifo structure with a provided buffer.
146 */
147 isf_fifo_status_t isf_fifo_init ( isf_fifo_t *pFifo, void *pData, uint16 sampleSize, uint16 bufferCapacity );
148
149 /*!
150 * @brief free a fifo's sample buffer.
151 */
152 isf_fifo_status_t isf_fifo_free ( isf_fifo_t *pFifo );
153
154 /*!
155 * @brief Routine to copy the whole sample buffer
156 */
157 isf_fifo_status_t isf_fifo_resize ( isf_fifo_t *pFifo, uint16 newCapacity );
158
159 /*!
160 * @brief Routine to query the current fifo size (bytes)
161 */
162 uint16 isf_fifo_get_buffer_size ( isf_fifo_t *pFifo );
163
164 /*!
165 * @brief Routine to copy the whole sample buffer
166 */
167 isf_fifo_status_t isf_fifo_data_copy ( isf_fifo_t *pFifo, void *samplePtr );
168
169 /*!
170 * @brief Lock a sample buffer for exclusive access.
171 */
172 isf_fifo_status_t isf_fifo_lock ( isf_fifo_t *pFifo );
173
174 /*!
175 * @brief Attempt to lock a sample buffer for exclusive access.
176 */
177 isf_fifo_status_t isf_fifo_try_lock ( isf_fifo_t *pFifo );
178
179 /*!
180 * @brief Release the exclusive access lock on a sample buffer.
181 */
182 isf_fifo_status_t isf_fifo_unlock ( isf_fifo_t *pFifo );
183
184 /*!
185 * @brief Routine returns the insert pointer for direct access
186 */
187 void *isf_fifo_el_get_insert_pointer ( isf_fifo_t *pFifo );
188
189 /*!
190 * @brief Routine increments the insert pointer after direct access
191 */
192 isf_fifo_status_t isf_fifo_el_increment ( isf_fifo_t *pFifo );
193
194 /*!
195 * @brief Routine to traverse a fifo
196 * To initiate the traversal set pSamplePtr to NULL.
197 * The function will set the pointer to the first available sample and returns ISF_SUCCESS.
198 * Subsequent calls will increment the pointer to each available sample and return ISF_SUCCESS.
199 * When ISF_SUCCESS is returned, pSamplePtr may be dereferenced to obtain a fifo entry.
200 * When no more samples are available, the function returns ISF_FIFO_NO_MORE_ENTRIES.
201 */
202 isf_fifo_status_t isf_fifo_el_traverse ( isf_fifo_t *pFifo, void **pSamplePtr );
203
204 /*!
205 * @brief Routine to clear the fifo
206 */
207 isf_fifo_status_t isf_fifo_el_clear ( isf_fifo_t *pFifo );
208
209 #endif /* ISF_FIFO_H_ */
isf_fifo_try_lock
isf_fifo_status_t isf_fifo_try_lock(isf_fifo_t *pFifo)
Attempt to lock a sample buffer for exclusive access.
Definition: isf_fifo.c:184
uint8
unsigned char uint8
This defines uint8 as unsigned char.
Definition: isf_types.h:18
isf_fifo_lock
isf_fifo_status_t isf_fifo_lock(isf_fifo_t *pFifo)
Lock a sample buffer for exclusive access.
Definition: isf_fifo.c:171
isf_fifo_unlock
isf_fifo_status_t isf_fifo_unlock(isf_fifo_t *pFifo)
Release the exclusive access lock on a sample buffer.
Definition: isf_fifo.c:202
isf_fifo_el_increment
isf_fifo_status_t isf_fifo_el_increment(isf_fifo_t *pFifo)
Routine increments the insert pointer after direct access.
Definition: isf_fifo.c:240
isf_fifo_el_clear
isf_fifo_status_t isf_fifo_el_clear(isf_fifo_t *pFifo)
Routine to clear the fifo.
Definition: isf_fifo.c:220
uint32
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
isf_fifo_t::bufferLock
LWSEM_STRUCT bufferLock
Definition: isf_fifo.h:23
isf_fifo_resize
isf_fifo_status_t isf_fifo_resize(isf_fifo_t *pFifo, uint16 newCapacity)
Routine to copy the whole sample buffer.
Definition: isf_fifo.c:101
isf_types.h
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
isf_fifo_status_t
uint32 isf_fifo_status_t
Definition: isf_fifo.h:15
isf_fifo_t::pDataBuffer
uint8 * pDataBuffer
Definition: isf_fifo.h:19
isf_fifo_init
isf_fifo_status_t isf_fifo_init(isf_fifo_t *pFifo, void *pData, uint16 sampleSize, uint16 bufferCapacity)
Initializes a new fifo structure with a provided buffer.
Definition: isf_fifo.c:19
isf_fifo_alloc
isf_fifo_status_t isf_fifo_alloc(isf_fifo_t *pFifo, uint16 sampleSize, uint16 bufferCapacity)
Initializes a fifo structure and allocates a new fifo buffer.
Definition: isf_fifo.c:69
isf_fifo_free
isf_fifo_status_t isf_fifo_free(isf_fifo_t *pFifo)
free a fifo's sample buffer.
Definition: isf_fifo.c:77
isf_fifo_t::sampleSize
uint16 sampleSize
Definition: isf_fifo.h:22
isf_fifo_t
Definition: isf_fifo.h:18
isf_fifo_get_buffer_size
uint16 isf_fifo_get_buffer_size(isf_fifo_t *pFifo)
Routine to query the current fifo size (bytes)
Definition: isf_fifo.c:134
uint16
unsigned short uint16
This defines uint16 as unsigned short.
Definition: isf_types.h:27
isf_fifo_t::pLastEntry
uint8 * pLastEntry
Definition: isf_fifo.h:21
isf_fifo_el_get_insert_pointer
void * isf_fifo_el_get_insert_pointer(isf_fifo_t *pFifo)
Routine returns the insert pointer for direct access.
Definition: isf_fifo.c:232
isf_fifo_data_copy
isf_fifo_status_t isf_fifo_data_copy(isf_fifo_t *pFifo, void *samplePtr)
Routine to copy the whole sample buffer.
Definition: isf_fifo.c:155
isf_fifo_t::fifoState
uint8 fifoState
Definition: isf_fifo.h:24
isf_fifo_t::pInsertPtr
uint8 * pInsertPtr
Definition: isf_fifo.h:20
isf_fifo_el_traverse
isf_fifo_status_t isf_fifo_el_traverse(isf_fifo_t *pFifo, void **pSamplePtr)
Routine to traverse a fifo To initiate the traversal set pSamplePtr to NULL. The function will set th...
Definition: isf_fifo.c:262
- © Freescale Semiconductor, Inc. 2015. All Rights Reserved.