iLLD_TC27xC  1.0
IfxStdIf_DPipe.h
Go to the documentation of this file.
1 /**
2  * \file IfxStdIf_DPipe.h
3  * \brief Standard interface: Data Pipe
4  * \ingroup IfxStdIf
5  *
6  * \version iLLD_0_1_0_10
7  * \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
8  *
9  *
10  * IMPORTANT NOTICE
11  *
12  *
13  * Infineon Technologies AG (Infineon) is supplying this file for use
14  * exclusively with Infineon's microcontroller products. This file can be freely
15  * distributed within development tools that are supporting such microcontroller
16  * products.
17  *
18  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
22  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
23  *
24  *
25  * \defgroup library_srvsw_stdif_dpipe Standard interface: Data Pipe
26  * \ingroup library_srvsw_stdif
27  *
28  * The standard interafce data pipe (DPipe) abstract the hardware used for data transfer. It provide, after proper initialization an hardware independant way to write
29  * and read data to/from as communciation channel.
30  *
31  * \par Porting StandardIo to DPipe
32  * replace all
33  * - StandardIo type with IfxStdIf_DPipe
34  * - StandardIo_print with IfxStdIf_DPipe_print
35  * delete StandardIo.c and StandardIo.h
36  * Include "StdIf/IfxStdIf_DPipe.h" instead of "SysSe/Bsp/StandardIo.h"
37  *
38  * The following files are already ported: Ifx_Console, Ifx_Shell
39  *
40  */
41 #ifndef STDIF_DPIPE_H_
42 #define STDIF_DPIPE_H_ 1
43 
44 #include "IfxStdIf.h"
45 //----------------------------------------------------------------------------------------
46 #ifndef ENDL
47 # define ENDL "\r\n"
48 #endif
49 
50 /** \brief Forward declaration */
52 
53 typedef volatile boolean *IfxStdIf_DPipe_WriteEvent;
54 typedef volatile boolean *IfxStdIf_DPipe_ReadEvent;
55 
56 /** \brief Size of the buffer allocated on the stack for the print function */
57 #define STDIF_DPIPE_MAX_PRINT_SIZE (255)
58 
59 /** \brief Write binary data into the \ref IfxStdIf_DPipe.
60  *
61  * Initially the parameter 'count' specifies count of data to write.
62  * After execution the data pointed by 'count' specifies the data actually written
63  *
64  * \param driver Pointer to the interface driver object
65  * \param data Pointer to the start of data
66  * \param count Pointer to the count of data (in bytes).
67  * \param timeout in system timer ticks
68  *
69  * \retval TRUE Returns TRUE if all items could be written
70  * \retval FALSE Returns FALSE if not all the items could be written
71  */
73 
74 /** \brief Read data from the \ref IfxStdIf_DPipe object
75  *
76  * Initially the parameter 'count' specifies count of data to read.
77  * After execution the data pointed by 'count' specifies the data actually read.
78  *
79  * \param driver Pointer to the interface driver object
80  * \param data Pointer to the start of data
81  * \param count Pointer to the count of data (in bytes).
82  * \param timeout in system timer ticks
83  *
84  * \retval TRUE Returns TRUE if all items could be read
85  * \retval FALSE Returns FALSE if not all the items could be read
86  */
88 
89 /** \brief Returns the number of bytes in the rx buffer
90  *
91  * \param driver Pointer to the interface driver object
92  *
93  * \return Returns the number of bytes in the rx buffer
94  */
96 
97 /** \brief Returns read event object
98  *
99  * \param driver Pointer to the interface driver object
100  *
101  * \return Returns read event object
102  */
104 
105 /** \brief Returns number of bytes send
106  *
107  * \param driver Pointer to the interface driver object
108  *
109  * \return Returns number of bytes send
110  */
112 
113 /** \brief Returns the time stamp of the last transmit data
114  *
115  * \param driver Pointer to the interface driver object
116  *
117  * \return Returns the time stamp of the last transmit data
118  */
120 
121 /** \brief Returns the number of free bytes (free space) in the tx buffer
122  *
123  * \param driver Pointer to the interface driver object
124  *
125  * \return Returns the number of free bytes in the tx buffer
126  */
128 
129 /** \brief Returns write event object
130  *
131  * \param driver Pointer to the interface driver object
132  *
133  * \return Returns write event object
134  */
136 
137 /** \brief Indicates if the required number of bytes are available for read in the buffer
138  *
139  * \param driver Pointer to the interface driver object
140  * \param count Pointer to the count of data (in bytes).
141  * \param timeout in system timer ticks
142  *
143  * \return Returns TRUE if at least count bytes are available for read in the rx buffer,
144  * if not the Event is armed to be set when the buffer count is bigger or equal to the requested count
145  */
147 
148 /** \brief Indicates if there is enough free space to write the data in the buffer
149  *
150  * \param driver Pointer to the interface driver object
151  * \param count Pointer to the count of data (in bytes).
152  * \param timeout in system timer ticks
153  *
154  * \return Returns TRUE if at least count bytes can be written to the tx buffer,
155  * if not the Event is armed to be set when the buffer free count is bigger or equal to the requested count
156  */
158 
159 /** \brief Flush the transmit buffer by transmitting all data
160  *
161  * \param driver Pointer to the interface driver object
162  * \param timeout timeout for the flush operation
163  *
164  * \return Returns TRUE if the FIFO is empty
165  */
167 
168 /** \brief Clears the RX buffer by removing all data
169  *
170  * \param driver Pointer to the interface driver object
171  * \return void
172  */
174 
175 /** \brief Clears the TX buffer by removing all data
176  *
177  * \param driver Pointer to the interface driver object
178  * \return void
179  */
181 
182 /** \brief handler called on reveive event
183  *
184  * \param driver Pointer to the interface driver object
185  *
186  * \return none
187  */
189 /** \brief handler called on transmit event
190  *
191  * \param driver Pointer to the interface driver object
192  *
193  * \return none
194  */
196 /** \brief handler called on error event
197  *
198  * \param driver Pointer to the interface driver object
199  *
200  * \return none
201  */
203 /** \brief Reset the sendCount counter
204  *
205  * \param driver Pointer to the interface driver object
206  *
207  * \return none
208  */
210 
211 /** \brief Standard interface object
212  */
214 {
215  IfxStdIf_InterfaceDriver driver; /**< \brief Pointer to the specific driver object */
216  boolean txDisabled; /**< \brief If disabled is set to TRUE, the output is disabled, else enabled */
217 
218  /* Standard interface APIs */
219  IfxStdIf_DPipe_Write write; /**< \brief \see IfxStdIf_DPipe_Write */
220  IfxStdIf_DPipe_Read read; /**< \brief \see IfxStdIf_DPipe_Read */
221  IfxStdIf_DPipe_GetReadCount getReadCount; /**< \brief \see IfxStdIf_DPipe_GetReadCount */
222  IfxStdIf_DPipe_GetReadEvent getReadEvent; /**< \brief \see IfxStdIf_DPipe_GetReadEvent */
223  IfxStdIf_DPipe_GetWriteCount getWriteCount; /**< \brief \see IfxStdIf_DPipe_GetWriteCount */
224  IfxStdIf_DPipe_GetWriteEvent getWriteEvent; /**< \brief \see IfxStdIf_DPipe_GetWriteEvent */
225  IfxStdIf_DPipe_CanReadCount canReadCount; /**< \brief \see IfxStdIf_DPipe_CanReadCount */
226  IfxStdIf_DPipe_CanWriteCount canWriteCount; /**< \brief \see IfxStdIf_DPipe_CanWriteCount */
227  IfxStdIf_DPipe_FlushTx flushTx; /**< \brief \see IfxStdIf_DPipe_FlushTx */
228  IfxStdIf_DPipe_ClearTx clearTx; /**< \brief \see IfxStdIf_DPipe_ClearTx */
229  IfxStdIf_DPipe_ClearRx clearRx; /**< \brief \see IfxStdIf_DPipe_ClearRx */
230  IfxStdIf_DPipe_OnReceive onReceive; /**< \brief \see IfxStdIf_DPipe_OnReceive */
231  IfxStdIf_DPipe_OnTransmit onTransmit; /**< \brief \see IfxStdIf_DPipe_OnTransmit */
232  IfxStdIf_DPipe_OnError onError; /**< \brief \see IfxStdIf_DPipe_OnError */
233 
234  IfxStdIf_DPipe_GetSendCount getSendCount; /**< \brief \see IfxStdIf_DPipe_GetSendCount */
235  IfxStdIf_DPipe_GetTxTimeStamp getTxTimeStamp; /**< \brief \see IfxStdIf_DPipe_GetTxTimeStamp */
236  IfxStdIf_DPipe_ResetSendCount resetSendCount; /**< \brief \see IfxStdIf_DPipe_ResetSendCount */
237 };
238 /** \addtogroup library_srvsw_stdif_dpipe
239  * \{ */
240 /** \copydoc IfxStdIf_DPipe_Write
241  */
242 IFX_INLINE boolean IfxStdIf_DPipe_write(IfxStdIf_DPipe *stdif, void *data, Ifx_SizeT *count, Ifx_TickTime timeout)
243 {
244  return stdif->write(stdif->driver, data, count, timeout);
245 }
246 
247 
248 /** \copydoc IfxStdIf_DPipe_Read
249  */
250 IFX_INLINE boolean IfxStdIf_DPipe_read(IfxStdIf_DPipe *stdif, void *data, Ifx_SizeT *count, Ifx_TickTime timeout)
251 {
252  return stdif->read(stdif->driver, data, count, timeout);
253 }
254 
255 
256 /** \copydoc IfxStdIf_DPipe_GetReadCount
257  */
259 {
260  return stdif->getReadCount(stdif->driver);
261 }
262 
263 
264 /** \copydoc IfxStdIf_DPipe_GetWriteCount
265  */
267 {
268  return stdif->getWriteCount(stdif->driver);
269 }
270 
271 
272 /** \copydoc IfxStdIf_DPipe_CanReadCount
273  */
275 {
276  return stdif->canReadCount(stdif->driver, count, timeout);
277 }
278 
279 
280 /** \copydoc IfxStdIf_DPipe_CanWriteCount
281  */
283 {
284  return stdif->canWriteCount(stdif->driver, count, timeout);
285 }
286 
287 
288 /** \copydoc StdIf_DPipe_GetReadEvent
289  */
291 {
292  return stdif->getReadEvent(stdif->driver);
293 }
294 
295 
296 /** \copydoc StdIf_DPipe_GetWriteEvent
297  */
299 {
300  return stdif->getWriteEvent(stdif->driver);
301 }
302 
303 
304 /** \copydoc IfxStdIf_DPipe_FlushTx
305  */
307 {
308  return stdif->flushTx(stdif->driver, timeout);
309 }
310 
311 
312 /** \copydoc IfxStdIf_DPipe_ClearTx
313  */
315 {
316  stdif->clearTx(stdif->driver);
317 }
318 
319 
320 /** \copydoc IfxStdIf_DPipe_ClearRx
321  */
323 {
324  stdif->clearRx(stdif->driver);
325 }
326 
327 
328 /** \copydoc IfxStdIf_DPipe_OnReceive
329  */
331 {
332  stdif->onReceive(stdif->driver);
333 }
334 
335 
336 /** \copydoc IfxStdIf_DPipe_OnTransmit
337  */
339 {
340  stdif->onTransmit(stdif->driver);
341 }
342 
343 
344 /** \copydoc IfxStdIf_DPipe_OnError
345  */
347 {
348  stdif->onError(stdif->driver);
349 }
350 
351 
352 /** \copydoc IfxStdIf_DPipe_GetSendCount
353  */
355 {
356  return stdif->getSendCount(stdif->driver);
357 }
358 
359 
360 /** \copydoc IfxStdIf_DPipe_GetTxTimeStamp
361  */
363 {
364  return stdif->getTxTimeStamp(stdif->driver);
365 }
366 
367 
368 /** \copydoc IfxStdIf_DPipe_ResetSendCount
369  */
371 {
372  stdif->resetSendCount(stdif->driver);
373 }
374 
375 
376 IFX_EXTERN void IfxStdIf_DPipe_print(IfxStdIf_DPipe *stdif, pchar format, ...);
377 
378 /** \} */
379 //----------------------------------------------------------------------------------------
380 
381 #endif /* STDIF_DPIPE_H_ */