Statistics
| Branch: | Tag: | Revision:

mongoose / examples / PIC32 / mqtt_client / firmware / src / system_config / mx795_CC3100_e16 / framework / driver / usart / src / drv_usart_mapping.c @ eaef5bd1

History | View | Annotate | Download (10.8 KB)

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

5
  Company:
6
    Microchip Technology Inc.
7

8
  File Name:
9
    drv_usart_mapping.c
10

11
  Summary:
12
    Source code for the USART 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_USART_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_USART_INDEX_0:
66
        {
67
            returnValue = DRV_USART0_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_USART_Deinitialize( SYS_MODULE_OBJ object)
80
{
81
    switch(object)
82
    {
83
        case DRV_USART_INDEX_0:
84
        {
85
            DRV_USART0_Deinitialize();
86
            break;
87
        }
88
        default:
89
        {
90
            break;
91
        }
92
    }
93
}
94

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

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

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

    
131
void DRV_USART_TasksReceive ( SYS_MODULE_OBJ object )
132
{
133
    switch(object)
134
    {
135
        case DRV_USART_INDEX_0:
136
        {
137
            DRV_USART0_TasksReceive();
138
            break;
139
        }
140
        default:
141
        {
142
            break;
143
        }
144
    }
145
}
146

    
147
void DRV_USART_TasksError ( SYS_MODULE_OBJ object )
148
{
149
    switch(object)
150
    {
151
        case DRV_USART_INDEX_0:
152
        {
153
            DRV_USART0_TasksError();
154
            break;
155
        }
156
        default:
157
        {
158
            break;
159
        }
160
    }
161
}
162

    
163

    
164
//client interface
165
DRV_HANDLE DRV_USART_Open( const SYS_MODULE_INDEX index, const DRV_IO_INTENT ioIntent)
166
{
167
    DRV_HANDLE returnValue;
168

    
169
    switch(index)
170
    {
171
        case DRV_USART_INDEX_0:
172
        {
173
            returnValue = DRV_USART0_Open(index,ioIntent);
174
            break;
175
        }
176
        default:
177
        {
178
            returnValue = DRV_HANDLE_INVALID;
179
            break;
180
        }
181
    }
182
    return returnValue;
183
}
184

    
185
void DRV_USART_Close( const DRV_HANDLE handle)
186
{
187
    uintptr_t instance;
188

    
189
    instance = handle & 0x00FF;
190
    //As we are handling single client, only multiple instance is taken care.
191
    switch(instance)
192
    {
193
        case DRV_USART_INDEX_0:
194
        {
195
            DRV_USART0_Close();
196
            break;
197
        }
198
        default:
199
        {
200
            break;
201
        }
202
    }
203
}
204

    
205
DRV_USART_CLIENT_STATUS DRV_USART_ClientStatus ( DRV_HANDLE handle )
206
{
207
    uintptr_t instance;
208
    DRV_USART_CLIENT_STATUS returnValue;
209

    
210
    instance = handle & 0x00FF;
211
    //As we are handling single client, only multiple instance is taken care.
212
    switch(instance)
213
    {
214
        case DRV_USART_INDEX_0:
215
        {
216
            returnValue = DRV_USART0_ClientStatus();
217
            break;
218
        }
219
        default:
220
        {
221
            returnValue = DRV_CLIENT_STATUS_ERROR;
222
            break;
223
        }
224
    }
225
    return returnValue;
226
}
227

    
228
DRV_USART_TRANSFER_STATUS DRV_USART_TransferStatus( const DRV_HANDLE handle )
229
{
230
    uintptr_t instance;
231
    DRV_USART_TRANSFER_STATUS returnValue;
232

    
233
    instance = handle & 0x00FF;
234
    //As we are handling single client, only multiple instance is taken care.
235
    switch(instance)
236
    {
237
        case DRV_USART_INDEX_0:
238
        {
239
            returnValue = DRV_USART0_TransferStatus();
240
            break;
241
        }
242
        default:
243
        {
244
            returnValue = (DRV_USART_TRANSFER_STATUS)NULL;
245
            break;
246
        }
247
    }
248
    return returnValue;
249
}
250

    
251

    
252

    
253
//Byte Model
254
uint8_t DRV_USART_ReadByte( const DRV_HANDLE handle )
255
{
256
    uintptr_t instance;
257
    uint8_t returnValue;
258

    
259
    instance = handle & 0x00FF;
260
    //As we are handling single client, only multiple instance is taken care.
261
    switch(instance)
262
    {
263
        case DRV_USART_INDEX_0:
264
        {
265
            returnValue = DRV_USART0_ReadByte();
266
            break;
267
        }
268
        default:
269
        {
270
            SYS_ASSERT(false, "Incorrect Driver Handle");
271
            returnValue = 0;
272
            break;
273
        }
274
    }
275
    return returnValue;
276
}
277

    
278
void DRV_USART_WriteByte( const DRV_HANDLE handle, const uint8_t byte)
279
{
280
    uintptr_t instance;
281

    
282
    instance = handle & 0x00FF;
283
    //As we are handling single client, only multiple instance is taken care.
284
    switch(instance)
285
    {
286
        case DRV_USART_INDEX_0:
287
        {
288
            DRV_USART0_WriteByte(byte);
289
            break;
290
        }
291
        default:
292
        {
293
            break;
294
        }
295
    }
296
}
297

    
298
unsigned int DRV_USART_ReceiverBufferSizeGet( const DRV_HANDLE handle )
299
{
300
    uintptr_t instance;
301
    unsigned int returnValue;
302

    
303
    instance = handle & 0x00FF;
304
    //As we are handling single client, only multiple instance is taken care.
305
    switch(instance)
306
    {
307
        case DRV_USART_INDEX_0:
308
        {
309
            returnValue = DRV_USART0_ReceiverBufferSizeGet();
310
            break;
311
        }
312
        default:
313
        {
314
            returnValue = (unsigned int)NULL;
315
            break;
316
        }
317
    }
318
    return returnValue;
319
}
320

    
321
unsigned int DRV_USART_TransmitBufferSizeGet( const DRV_HANDLE handle )
322
{
323
    uintptr_t instance;
324
    unsigned int returnValue;
325

    
326
    instance = handle & 0x00FF;
327
    //As we are handling single client, only multiple instance is taken care.
328
    switch(instance)
329
    {
330
        case DRV_USART_INDEX_0:
331
        {
332
            returnValue = DRV_USART0_TransmitBufferSizeGet();
333
            break;
334
        }
335
        default:
336
        {
337
            returnValue = (unsigned int)NULL;
338
            break;
339
        }
340
    }
341
    return returnValue;
342
}
343

    
344
bool DRV_USART_ReceiverBufferIsEmpty( const DRV_HANDLE handle )
345
{
346
    uintptr_t instance;
347
    bool returnValue;
348

    
349
    instance = handle & 0x00FF;
350
    //As we are handling single client, only multiple instance is taken care.
351
    switch(instance)
352
    {
353
        case DRV_USART_INDEX_0:
354
        {
355
            returnValue = DRV_USART0_ReceiverBufferIsEmpty();
356
            break;
357
        }
358
        default:
359
        {
360
            returnValue = false;
361
            break;
362
        }
363
    }
364
    return returnValue;
365
}
366

    
367
bool DRV_USART_TransmitBufferIsFull( const DRV_HANDLE handle )
368
{
369
    uintptr_t instance;
370
    bool returnValue;
371

    
372
    instance = handle & 0x00FF;
373
    //As we are handling single client, only multiple instance is taken care.
374
    switch(instance)
375
    {
376
        case DRV_USART_INDEX_0:
377
        {
378
            returnValue = DRV_USART0_TransmitBufferIsFull();
379
            break;
380
        }
381
        default:
382
        {
383
            returnValue = false;
384
            break;
385
        }
386
    }
387
    return returnValue;
388
}
389

    
390
DRV_USART_BAUD_SET_RESULT DRV_USART_BaudSet(const DRV_HANDLE handle, uint32_t baud)
391
{
392
    uintptr_t instance;
393
    DRV_USART_BAUD_SET_RESULT returnValue;
394

    
395
    instance = handle & 0x00FF;
396
    //As we are handling single client, only multiple instance is taken care.
397
    switch(instance)
398
    {
399
        case DRV_USART_INDEX_0:
400
        {
401
            returnValue = DRV_USART0_BaudSet(baud);
402
            break;
403
        }
404
        default:
405
        {
406
            returnValue = DRV_USART_BAUD_SET_ERROR;
407
            break;
408
        }
409
    }
410
    return returnValue;
411
}
412

    
413
DRV_USART_LINE_CONTROL_SET_RESULT DRV_USART_LineControlSet(const DRV_HANDLE handle,const DRV_USART_LINE_CONTROL lineControl)
414
{
415
    uintptr_t instance;
416
    DRV_USART_LINE_CONTROL_SET_RESULT returnValue;
417

    
418
    instance = handle & 0x00FF;
419
    //As we are handling single client, only multiple instance is taken care.
420
    switch(instance)
421
    {
422
        case DRV_USART_INDEX_0:
423
        {
424
            returnValue = DRV_USART0_LineControlSet(lineControl);
425
            break;
426
        }
427
        default:
428
        {
429
            returnValue = DRV_USART_LINE_CONTROL_SET_ERROR;
430
            break;
431
        }
432
    }
433
    return returnValue;
434
}
435

    
436

    
437
/*******************************************************************************
438
 End of File
439
*/