Statistics
| Branch: | Tag: | Revision:

mongoose / examples / PIC32 / mqtt_client / firmware / src / system_config / mx795_CC3100_e16 / framework / driver / spi / static / src / drv_spi_mapping.c @ eaef5bd1

History | View | Annotate | Download (9.93 KB)

1
/* clang-format off */
2
/*******************************************************************************
3
  SPI Driver Dynamic to Static mapping
4

5
  Company:
6
    Microchip Technology Inc.
7

8
  File Name:
9
    drv_spi_mapping.c
10

11
  Summary:
12
    Source code for the SPI driver dynamic APIs to static API mapping.
13

14
  Description:
15
    This file contains code that maps dynamic APIs to static whenever
16
    the static mode of the driver is selected..
17

18
  Remarks:
19
    Static interfaces incorporate the driver instance number within the names
20
    of the routines, eliminating the need for an object ID or object handle.
21

22
    Static single-open interfaces also eliminate the need for the open handle.
23
*******************************************************************************/
24

    
25
//DOM-IGNORE-BEGIN
26
/*******************************************************************************
27
Copyright (c) 2015 released Microchip Technology Inc.  All rights reserved.
28

29
Microchip licenses to you the right to use, modify, copy and distribute
30
Software only when embedded on a Microchip microcontroller or digital signal
31
controller that is integrated into your product or third party product
32
(pursuant to the sublicense terms in the accompanying license agreement).
33

34
You should refer to the license agreement accompanying this Software for
35
additional information regarding your rights and obligations.
36

37
SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
38
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
39
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
40
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
41
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
42
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
43
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
44
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
45
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
46
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
47
*******************************************************************************/
48
//DOM-IGNORE-END
49

    
50
// *****************************************************************************
51
// *****************************************************************************
52
// Section: Included Files
53
// *****************************************************************************
54
// *****************************************************************************
55
#include "system_config.h"
56
#include "system_definitions.h"
57

    
58

    
59
SYS_MODULE_OBJ DRV_SPI_Initialize(const SYS_MODULE_INDEX index,const SYS_MODULE_INIT * const init)
60
{
61
    SYS_MODULE_OBJ returnValue;
62

    
63
    switch(index)
64
    {
65
        case DRV_SPI_INDEX_0:
66
        {
67
            returnValue = DRV_SPI0_Initialize();
68
            break;
69
        }
70
        default:
71
        {
72
            returnValue = SYS_MODULE_OBJ_INVALID;
73
            break;
74
        }
75
    }
76
    return returnValue;
77
}
78

    
79
void DRV_SPI_Deinitialize( SYS_MODULE_OBJ object)
80
{
81
    switch(object)
82
    {
83
        case DRV_SPI_INDEX_0:
84
        {
85
            DRV_SPI0_Deinitialize();
86
            break;
87
        }
88
        default:
89
        {
90
            break;
91
        }
92
    }
93
}
94

    
95
SYS_STATUS DRV_SPI_Status( SYS_MODULE_OBJ object)
96
{
97
    SYS_STATUS returnValue;
98

    
99
    switch(object)
100
    {
101
        case DRV_SPI_INDEX_0:
102
        {
103
            returnValue = DRV_SPI0_Status();
104
            break;
105
        }
106
        default:
107
        {
108
            returnValue = SYS_STATUS_ERROR;
109
            break;
110
        }
111
    }
112
    return returnValue;
113
}
114

    
115
void DRV_SPI_Tasks ( SYS_MODULE_OBJ object )
116
{
117
    switch(object)
118
    {
119
        case DRV_SPI_INDEX_0:
120
        {
121
            DRV_SPI0_Tasks();
122
            break;
123
        }
124
        default:
125
        {
126
            break;
127
        }
128
    }
129
}
130

    
131

    
132
//client interface
133
DRV_HANDLE DRV_SPI_Open( const SYS_MODULE_INDEX index, const DRV_IO_INTENT ioIntent)
134
{
135
    DRV_HANDLE returnValue;
136

    
137
    switch(index)
138
    {
139
        case DRV_SPI_INDEX_0:
140
        {
141
            returnValue = DRV_SPI0_Open(index,ioIntent);
142
            break;
143
        }
144
        default:
145
        {
146
            returnValue = DRV_HANDLE_INVALID;
147
            break;
148
        }
149
    }
150
    return returnValue;
151
}
152

    
153
void DRV_SPI_Close( const DRV_HANDLE handle)
154
{
155
    uintptr_t instance;
156

    
157
    instance = handle & 0x00FF;
158
    //As we are handling single client, only multiple instance is taken care.
159
    switch(instance)
160
    {
161
        case DRV_SPI_INDEX_0:
162
        {
163
            DRV_SPI0_Close( );
164
            break;
165
        }
166
        default:
167
        {
168
            break;
169
        }
170
    }
171
}
172

    
173
int32_t DRV_SPI_ClientConfigure ( DRV_HANDLE handle, const DRV_SPI_CLIENT_DATA * cfgData  )
174
{
175
    uintptr_t instance;
176
    int32_t returnValue;
177

    
178
    instance = handle & 0x00FF;
179
    //As we are handling single client, only multiple instance is taken care.
180
    switch(instance)
181
    {
182
        case DRV_SPI_INDEX_0:
183
        {
184
            returnValue = DRV_SPI0_ClientConfigure( cfgData );
185
            break;
186
        }
187
        default:
188
        {
189
            returnValue = (int32_t)DRV_HANDLE_INVALID;
190
            break;
191
        }
192
    }
193
    return returnValue;
194
}
195

    
196

    
197
//Read & Write Client Interface
198

    
199
DRV_SPI_BUFFER_HANDLE DRV_SPI_BufferAddRead ( DRV_HANDLE handle,void *rxBuffer,size_t size,DRV_SPI_BUFFER_EVENT_HANDLER completeCB,void * context)
200
{
201
    uintptr_t instance;
202
    DRV_SPI_BUFFER_HANDLE returnValue;
203

    
204
    instance = handle & 0x00FF;
205
    //As we are handling single client, only multiple instance is taken care.
206
    switch(instance)
207
    {
208
        case DRV_SPI_INDEX_0:
209
        {
210
            returnValue = DRV_SPI0_BufferAddRead ( rxBuffer, size, completeCB, context);
211
            break;
212
        }
213
        default:
214
        {
215
            returnValue = DRV_SPI_BUFFER_HANDLE_INVALID;
216
            break;
217
        }
218
    }
219
    return returnValue;
220
}
221

    
222
DRV_SPI_BUFFER_HANDLE DRV_SPI_BufferAddWrite ( DRV_HANDLE handle,void *txBuffer,size_t size,DRV_SPI_BUFFER_EVENT_HANDLER completeCB,void * context)
223
{
224
    uintptr_t instance;
225
    DRV_SPI_BUFFER_HANDLE returnValue;
226

    
227
    instance = handle & 0x00FF;
228
    //As we are handling single client, only multiple instance is taken care.
229
    switch(instance)
230
    {
231
        case DRV_SPI_INDEX_0:
232
        {
233
            returnValue = DRV_SPI0_BufferAddWrite ( txBuffer, size, completeCB, context);
234
            break;
235
        }
236
        default:
237
        {
238
            returnValue = DRV_SPI_BUFFER_HANDLE_INVALID;
239
            break;
240
        }
241
    }
242
    return returnValue;
243
}
244

    
245
DRV_SPI_BUFFER_HANDLE DRV_SPI_BufferAddWriteRead ( DRV_HANDLE handle, void *txBuffer, size_t txSize,
246
    void *rxBuffer, size_t rxSize, DRV_SPI_BUFFER_EVENT_HANDLER completeCB, void * context )
247
{
248
    uintptr_t instance;
249
    DRV_SPI_BUFFER_HANDLE returnValue;
250

    
251
    instance = handle & 0x00FF;
252
    //As we are handling single client, only multiple instance is taken care.
253
    //Mapping to a new static driver's API name.
254
    switch(instance)
255
    {
256
        case DRV_SPI_INDEX_0:
257
        {
258
            returnValue = DRV_SPI0_BufferAddWriteReadNew ( txBuffer, txSize, rxBuffer, rxSize, completeCB, context );
259
            break;
260
        }
261
        default:
262
        {
263
            returnValue = DRV_SPI_BUFFER_HANDLE_INVALID;
264
            break;
265
        }
266
    }
267
    return returnValue;
268
}
269

    
270
DRV_SPI_BUFFER_HANDLE DRV_SPI_BufferAddRead2 ( DRV_HANDLE handle,void *rxBuffer,size_t size,DRV_SPI_BUFFER_EVENT_HANDLER completeCB,void * context, DRV_SPI_BUFFER_HANDLE * jobHandle)
271
{
272
    uintptr_t instance;
273
    DRV_SPI_BUFFER_HANDLE returnValue;
274

    
275
    instance = handle & 0x00FF;
276
    //As we are handling single client, only multiple instance is taken care.
277
    switch(instance)
278
    {
279
        case DRV_SPI_INDEX_0:
280
        {
281
            returnValue = DRV_SPI0_BufferAddRead2 ( rxBuffer, size, completeCB, context, jobHandle);
282
            break;
283
        }
284
        default:
285
        {
286
            returnValue = DRV_SPI_BUFFER_HANDLE_INVALID;
287
            break;
288
        }
289
    }
290
    return returnValue;
291
}
292

    
293
DRV_SPI_BUFFER_HANDLE DRV_SPI_BufferAddWrite2 ( DRV_HANDLE handle,void *txBuffer,size_t size,DRV_SPI_BUFFER_EVENT_HANDLER completeCB,void * context, DRV_SPI_BUFFER_HANDLE * jobHandle)
294
{
295
    uintptr_t instance;
296
    DRV_SPI_BUFFER_HANDLE returnValue;
297

    
298
    instance = handle & 0x00FF;
299
    //As we are handling single client, only multiple instance is taken care.
300
    switch(instance)
301
    {
302
        case DRV_SPI_INDEX_0:
303
        {
304
            returnValue = DRV_SPI0_BufferAddWrite2 ( txBuffer, size, completeCB, context, jobHandle);
305
            break;
306
        }
307
        default:
308
        {
309
            returnValue = DRV_SPI_BUFFER_HANDLE_INVALID;
310
            break;
311
        }
312
    }
313
    return returnValue;
314
}
315

    
316
DRV_SPI_BUFFER_HANDLE DRV_SPI_BufferAddWriteRead2 ( DRV_HANDLE handle, void *txBuffer, size_t txSize,void *rxBuffer, size_t rxSize,DRV_SPI_BUFFER_EVENT_HANDLER completeCB,void * context, DRV_SPI_BUFFER_HANDLE * jobHandle)
317
{
318
    uintptr_t instance;
319
    DRV_SPI_BUFFER_HANDLE returnValue;
320

    
321
    instance = handle & 0x00FF;
322
    //As we are handling single client, only multiple instance is taken care.
323
    switch(instance)
324
    {
325
        case DRV_SPI_INDEX_0:
326
        {
327
            returnValue = DRV_SPI0_BufferAddWriteRead2 ( txBuffer, txSize, rxBuffer, rxSize, completeCB, context, jobHandle);
328
            break;
329
        }
330
        default:
331
        {
332
            returnValue = DRV_SPI_BUFFER_HANDLE_INVALID;
333
            break;
334
        }
335
    }
336
    return returnValue;
337
}
338

    
339
DRV_SPI_BUFFER_EVENT DRV_SPI_BufferStatus ( DRV_SPI_BUFFER_HANDLE bufferHandle )
340
{
341
    //This function is independent of instance or client.
342
    return DRV_SPI0_BufferStatus ( bufferHandle);
343
}
344

    
345
/*******************************************************************************
346
 End of File
347
*/