iLLD_TC27xC  1.0
Ifx_CircularBuffer.asm.c
Go to the documentation of this file.
1 /**
2  * \file Ifx_CircularBuffer.asm.c
3  * \brief Circular buffer functions (assembler implementation).
4  *
5  * \version iLLD_0_1_0_10
6  * \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
7  *
8  *
9  * IMPORTANT NOTICE
10  *
11  *
12  * Infineon Technologies AG (Infineon) is supplying this file for use
13  * exclusively with Infineon's microcontroller products. This file can be freely
14  * distributed within development tools that are supporting such microcontroller
15  * products.
16  *
17  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
18  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
20  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
21  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
22  *
23  */
24 
25 #include "Ifx_CircularBuffer.h"
26 
27 #if !(IFX_CFG_CIRCULARBUFFER_C)
28 
30 {
31  uint32 data;
32 
33  __asm(" ld.da\ta14/a15,[%1]\n" /* Get circular buffer state */
34  " ld.w\t%0,[a14/a15+c]\n" /* Get the value from the buffer, and increment the buffer pointer */
35  " st.da\t[%1],a14/a15\n" /* Store the new circular buffer state */
36  : "=d" (data) : "a" (buffer) : "a14", "a15");
37 
38  return data;
39 }
40 
41 
43 {
44  Ifx_SizeT data;
45 
46  __asm(" ld.da\ta14/a15,[%1]\n" /* Get circular buffer state */
47  " ld.h\t%0,[a14/a15+c]\n" /* Get the value from the buffer, and increment the buffer pointer */
48  " st.da\t[%1],a14/a15\n" /* Store the new circular buffer state */
49  : "=d" (data) : "a" (buffer) : "a14", "a15");
50 
51  return data;
52 }
53 
54 
55 /** \brief Add a 32 bit value to the circular buffer, and post-increment the circular buffer pointer
56  *
57  * \param buffer Specifies circular buffer.
58  * \param data Specifies value to be added to the buffer.
59  *
60  * \return None.
61  */
63 {
64  __asm(" ld.da\ta14/a15,[%0]\n" /* Get circular buffer state */
65  " st.w\t[a14/a15+c]0,%1\n" /* Store the value to the buffer, and increment the buffer pointer */
66  " ld.w\t%1,[a14/a15+c]\n" /* Read the value from the buffer, to get the buffer pointer incremented (bug workaround) */
67  " st.da\t[%0],a14/a15\n" /* Store the new circular buffer state */
68  :
69  : "a" (buffer), "d" (data) : "a14", "a15");
70 }
71 
72 
73 void *Ifx_CircularBuffer_read8(Ifx_CircularBuffer *buffer, void *data, Ifx_SizeT count)
74 {
75  count--;
76  __asm(" mov.a\ta13,%3\n" /* Get count value */
77  " ld.da\ta14/a15,[%1]\n" /* Get circular buffer state */
78  "Ifx_CircularBuffer_read1:" " ld.b\td15,[a14/a15+c]\n"/* read the value from the buffer, and increment the buffer pointer */
79  " st.b\t[%2+],d15\n" /* Store value to the data buffer, and increment the pointer */
80  " loop\ta13,Ifx_CircularBuffer_read1\n" /* loop */
81  " mov.d\t%0,a15\n" /* Get the new index value */
82  " extr.u\t%0,%0,#0,#16\n": "=d" (buffer->index) : "a" (buffer), "a" (data), "d" (count) : "a13", "a14", "a15",
83  "d15");
84 
85  return data;
86 }
87 
88 
89 void *Ifx_CircularBuffer_read32(Ifx_CircularBuffer *buffer, void *data, Ifx_SizeT count)
90 {
91  count--;
92  __asm(" mov.a\ta13,%3\n" /* Get count value */
93  " ld.da\ta14/a15,[%1]\n" /* Get circular buffer state */
94  "Ifx_CircularBuffer_read2:" " ld.w\td15,[a14/a15+c]\n"/* read the value from the buffer, and increment the buffer pointer */
95  " st.w\t[%2+],d15\n" /* Store value to the data buffer, and increment the pointer */
96  " loop\ta13,Ifx_CircularBuffer_read2\n" /* loop */
97  " mov.d\t%0,a15\n" /* Get the new index value */
98  " extr.u\t%0,%0,#0,#16\n": "=d" (buffer->index) : "a" (buffer), "a" (data), "d" (count) : "a13", "a14", "a15",
99  "d15");
100 
101  return data;
102 }
103 
104 
105 const void *Ifx_CircularBuffer_write8(Ifx_CircularBuffer *buffer, const void *data, Ifx_SizeT count)
106 {
107  count--;
108  __asm(" mov.a\ta13,%3\n" /* Get count value */
109  " ld.da\ta14/a15,[%1]\n" /* Get circular buffer state */
110  "Ifx_CircularBuffer_write1:" " ld.b\td15,[%2+]\n"/* Get value from the data buffer, and increment the pointer */
111  " st.b\t[a14/a15+c]0,d15\n" /* Store the value to the buffer, and increment the buffer pointer */
112  " ld.b\td15,[a14/a15+c]\n" /* Read the value from the buffer, to get the buffer pointer incremented (bug workaround) */
113  " loop\ta13,Ifx_CircularBuffer_write1\n" /* loop */
114  " mov.d\t%0,a15\n" /* Get the new index value */
115  " extr.u\t%0,%0,#0,#16\n": "=d" (buffer->index) : "a" (buffer), "a" (data), "d" (count) : "a13", "a14", "a15",
116  "d15");
117 
118  return data;
119 }
120 
121 
122 const void *Ifx_CircularBuffer_write32(Ifx_CircularBuffer *buffer, const void *data, Ifx_SizeT count)
123 {
124  count--;
125  __asm(" mov.a\ta13,%3\n" /* Get count value */
126  " ld.da\ta14/a15,[%1]\n" /* Get circular buffer state */
127  "Ifx_CircularBuffer_write2:" " ld.w\td15,[%2+]\n"/* Get value from the data buffer, and increment the pointer */
128  " st.w\t[a14/a15+c]0,d15\n" /* Store the value to the buffer, and increment the buffer pointer */
129  " ld.w\td15,[a14/a15+c]\n" /* Read the value from the buffer, to get the buffer pointer incremented (bug workaround) */
130  " loop\ta13,Ifx_CircularBuffer_write2\n" /* loop */
131  " mov.d\t%0,a15\n" /* Get the new index value */
132  " extr.u\t%0,%0,#0,#16\n": "=d" (buffer->index) : "a" (buffer), "a" (data), "d" (count) : "a13", "a14", "a15",
133  "d15");
134 
135  return data;
136 }
137 
138 
139 #endif