Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (7.76 KB)

1
/* clang-format off */
2
/*******************************************************************************
3
  SPI Driver Local Data Structures for static implementation
4

5
  Company:
6
    Microchip Technology Inc.
7

8
  File Name:
9
    drv_spi_static_local.h
10

11
  Summary:
12
    SPI Driver Local Data Structures for static implementation
13

14
  Description:
15
    Driver Local Data Structures for static implementation
16
*******************************************************************************/
17

    
18
//DOM-IGNORE-BEGIN
19
/*******************************************************************************
20
Copyright (c) 2015 released Microchip Technology Inc.  All rights reserved.
21

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

27
You should refer to the license agreement accompanying this Software for
28
additional information regarding your rights and obligations.
29

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

    
43
#ifndef _DRV_SPI_STATIC_LOCAL_H
44
#define _DRV_SPI_STATIC_LOCAL_H
45

    
46

    
47
// *****************************************************************************
48
// *****************************************************************************
49
// Section: Included Files
50
// *****************************************************************************
51
// *****************************************************************************
52
#include "system_config.h"
53
#include "driver/spi/drv_spi.h"
54
#include "system/int/sys_int.h"
55
#include "system/debug/sys_debug.h"
56
#include "driver/spi/static/src/drv_spi_static_sys_queue.h"
57

    
58
// DOM-IGNORE-BEGIN
59
#ifdef __cplusplus  // Provide C++ Compatibility
60

    
61
    extern "C" {
62

    
63
#endif
64
// DOM-IGNORE-END
65

    
66
// *****************************************************************************
67
// *****************************************************************************
68
// Section: Data Type Definitions
69
// *****************************************************************************
70
// *****************************************************************************
71
#define MAX(a,b) ((a<b) ? b : a)
72
#define MIN(a,b) ((b<a) ? b : a)
73

    
74
#define PLIB_SPI_RX_8BIT_FIFO_SIZE(index)    16
75
#define PLIB_SPI_RX_8BIT_HW_MARK(index)      8
76
#define PLIB_SPI_RX_16BIT_FIFO_SIZE(index)   8
77
#define PLIB_SPI_RX_16BIT_HW_MARK(index)     4
78
#define PLIB_SPI_RX_32BIT_FIFO_SIZE(index)   4
79
#define PLIB_SPI_RX_32BIT_HW_MARK(index)     2
80

    
81

    
82
#define PLIB_SPI_TX_8BIT_FIFO_SIZE(index)   16
83
#define PLIB_SPI_TX_8BIT_LW_MARK(index)     8
84
#define PLIB_SPI_TX_16BIT_FIFO_SIZE(index)  8
85
#define PLIB_SPI_TX_16BIT_LW_MARK(index)    4
86
#define PLIB_SPI_TX_32BIT_FIFO_SIZE(index)  4
87
#define PLIB_SPI_TX_32BIT_LW_MARK(index)    2
88

    
89
struct DRV_SPI_OBJ;
90

    
91
/* SPI Job object. */
92
typedef struct _DRV_SPI_JOB_OBJECT
93
{
94
    uint8_t *txBuffer;
95
    uint8_t *rxBuffer;
96
    size_t dataTxed;
97
    size_t dataRxed;
98
    size_t dataLeftToTx;
99
    size_t dummyLeftToTx;
100
    size_t dataLeftToRx;
101
    size_t dummyLeftToRx;
102
    DRV_SPI_BUFFER_EVENT status;
103
    DRV_SPI_BUFFER_EVENT_HANDLER completeCB;
104
    void * context;
105
}DRV_SPI_JOB_OBJECT;
106

    
107
// *****************************************************************************
108
/* SPI Static Driver Instance Object
109

110
  Summary:
111
    Object used to keep any data required for the static SPI driver.
112

113
  Description:
114
    This object is used to keep track of any data that must be maintained to
115
    manage the SPI static driver.
116

117
  Remarks:
118
    None.
119
*/
120

    
121
typedef struct DRV_SPI_OBJ
122
{
123
    uint8_t                                     numTrfsSmPolled;
124
    bool                                        errEnabled;
125
    DRV_SPI_BUFFER_EVENT_HANDLER                operationStarting;
126
    DRV_SPI_BUFFER_EVENT_HANDLER                operationEnded;
127
    DRV_SPI_SYS_QUEUE_HANDLE                    queue;
128
    DRV_SPI_JOB_OBJECT *                        currentJob;
129
    bool                                        txEnabled;
130
    bool                                        rxEnabled;
131
    uint8_t                                     symbolsInProgress;
132
} DRV_SPI_OBJ;
133

    
134
// *****************************************************************************
135
// *****************************************************************************
136
// Section: Queue related Data Type Definitions
137
// *****************************************************************************
138
// *****************************************************************************
139
typedef struct _DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA
140
{
141
    struct _DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA * pNext;
142
}DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA;
143

    
144
typedef struct _DRV_SPI_SYS_QUEUE_QUEUE_DATA
145
{
146
    void * pQueueManager;
147
    DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA * pHead;
148
    DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA * pTail;
149
    DRV_SPI_SYS_QUEUE_INTERUPT_CHANGE fptrIntChange;
150
    size_t numReserved;
151
    size_t maxElements;
152
    size_t numAlloc;
153
    struct _DRV_SPI_SYS_QUEUE_QUEUE_DATA * pNext;
154
    size_t numEnqueued;
155
    size_t numAllocOps;
156
    size_t numFreeOps;
157
    size_t numDequeueOps;
158
    size_t numEnqueueOps;
159
    size_t numReserveLW;
160
    size_t numAllocHW;
161
    size_t numEnqueuedHW;
162
    size_t outOfMemoryErrors;
163
}DRV_SPI_SYS_QUEUE_QUEUE_DATA;
164

    
165
typedef struct _DRV_SPI_SYS_QUEUE_QUEUE_MANAGER_DATA
166
{
167
    DRV_SPI_SYS_QUEUE_QUEUE_DATA * pQueueArea;
168
    DRV_SPI_SYS_QUEUE_QUEUE_DATA * pFreeQueueHead;
169
    DRV_SPI_SYS_QUEUE_QUEUE_DATA * pFreeQueueTail;
170
    DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA * pElementArea;
171
    DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA * pFreeElementHead;
172
    DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA * pFreeElementTail;
173
    size_t numReserveElements;
174
    size_t numFreeElements;
175
    size_t numAllocOps;
176
    size_t numFreeOps;
177
    size_t numQueueCreateOps;
178
    size_t numQueueDestroyOps;
179
    size_t freeElementsLW;
180
    size_t reserveElementsLW;
181
    size_t outOfMemoryErrors;
182
    uint8_t numQueues;
183
    uint8_t numQueuesHW;
184
}DRV_SPI_SYS_QUEUE_QUEUE_MANAGER_DATA;
185

    
186
// *****************************************************************************
187
// *****************************************************************************
188
// Section: Local functions.
189
// *****************************************************************************
190
// *****************************************************************************
191

    
192
int32_t DRV_SPI0_PolledMasterRM8BitTasks ( struct DRV_SPI_OBJ * dObj );
193
int32_t DRV_SPI0_PolledErrorTasks(struct DRV_SPI_OBJ * dObj);
194
int32_t DRV_SPI0_MasterRMSend8BitPolled( struct DRV_SPI_OBJ * dObj );
195
int32_t DRV_SPI0_MasterRMReceive8BitPolled( struct DRV_SPI_OBJ * dObj );
196
// DOM-IGNORE-BEGIN
197
#ifdef __cplusplus
198
}
199
#endif
200
// DOM-IGNORE-END
201

    
202
#endif //#ifndef _DRV_SPI_STATIC_LOCAL_H
203

    
204
/*******************************************************************************
205
 End of File
206
*/
207