Statistics
| Branch: | Tag: | Revision:

mongoose / examples / PIC32 / mqtt_client / firmware / src / system_config / mx795_CC3100_e16 / framework / system / console / src / sys_console_static.c @ eaef5bd1

History | View | Annotate | Download (12.3 KB)

1
/* clang-format off */
2
/*******************************************************************************
3
  SYS CONSOLE Static Functions for Console System Service
4

5
  Company:
6
    Microchip Technology Inc.
7

8
  File Name:
9
    sys_console_static.c
10

11
  Summary:
12
    SYS CONSOLE static function implementations for the Console System Service.
13

14
  Description:
15
    The Console System Service provides a simple interface to manage the oscillators
16
    on Microchip microcontrollers. This file defines the static implementation for the 
17
    Console System Service.
18
    
19
  Remarks:
20
    Static functions incorporate all system clock configuration settings as
21
    determined by the user via the Microchip Harmony Configurator GUI.  It provides 
22
    static version of the routines, eliminating the need for an object ID or 
23
    object handle.
24
    
25
    Static single-open interfaces also eliminate the need for the open handle.
26
*******************************************************************************/
27

    
28
//DOM-IGNORE-BEGIN
29
/*******************************************************************************
30
Copyright (c) 2014 released Microchip Technology Inc.  All rights reserved.
31

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

37
You should refer to the license agreement accompanying this Software for
38
additional information regarding your rights and obligations.
39

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

    
53
// *****************************************************************************
54
// *****************************************************************************
55
// Section: Include Files
56
// *****************************************************************************
57
// *****************************************************************************
58

    
59
#include "system_config.h"
60
#include "system_definitions.h"
61
#include "system/console/sys_console.h"
62

    
63

    
64
// *****************************************************************************
65
// *****************************************************************************
66
// Section: Global Variable Definitions
67
// *****************************************************************************
68
// *****************************************************************************
69

    
70

    
71
// *****************************************************************************
72
/* Function:
73
    SYS_MODULE_OBJ SYS_CONSOLE_Initialize( const SYS_MODULE_INDEX index,
74
                                       const SYS_MODULE_INIT * const init )
75

76
  Summary:
77
    Initializes data for the instance of the Console module and opens the 
78
    specific module instance.
79

80
  Description:
81
    This function initializes the Console module, and selects the I/O device to
82
    be used. It also initializes any internal data structures.
83

84
  Precondition:
85
    None.
86

87
  Parameters:
88
    index           - Index for the instance to be initialized
89

90
    init            - Pointer to a data structure containing any data necessary
91
                      to initialize the sys console. This pointer may be null if no
92
                      data is required because static overrides have been
93
                      provided.
94

95
 Returns:
96
    If successful, returns a valid handle to an object.  Otherwise, it
97
    returns SYS_MODULE_OBJ_INVALID. The returned object must be passed as
98
    argument to SYS_CONSOLE_Reinitialize, SYS_CONSOLE_Deinitialize, 
99
    SYS_CONSOLE_Tasks and SYS_CONSOLE_Status routines.
100

101
  Remarks:
102
    This routine should only be called once during system initialization
103
    unless SYS_Console_Deinitialize is first called to deinitialize the device
104
    instance before reinitializing it. If the system was already initialized
105
    it safely returns without causing any disturbance.
106
*/
107

    
108
SYS_MODULE_OBJ SYS_CONSOLE_Initialize( const SYS_MODULE_INDEX index, const SYS_MODULE_INIT * const init )
109
{
110
    return 1;
111
}
112

    
113

    
114
// *****************************************************************************
115
/* Function:
116
     void SYS_CONSOLE_Reinitialize ( SYS_MODULE_OBJ object,
117
                                 const SYS_MODULE_INIT * const init )
118

119
   Summary:
120
     Reinitializes and refreshes the data structure for the instance of the
121
     Console module.
122

123
   Description:
124
     This function reinitializes and refreshes the data structure for the
125
     instance of the Console module.
126

127
  PreCondition:
128
     The SYS_CONSOLE_Initialize function should have been called before calling
129
     this function.
130

131
  Parameters:
132
    object          - Identifies the SYS CONSOLE Object returned by the Initialize
133
                      interface
134
    init            - Pointer to the data structure containing any data
135
                      necessary to initialize the hardware
136

137
   Returns:
138
    - true        - if successful
139
    - false        - if unsuccessful
140
*/
141

    
142
bool SYS_CONSOLE_Reinitialize( SYS_MODULE_OBJ object, const SYS_MODULE_INIT * const init )
143
{
144
    return true;
145
}
146

    
147

    
148
// *****************************************************************************
149
/* Function:
150
    void SYS_CONSOLE_Deinitialize ( SYS_MODULE_OBJ object )
151

152
  Summary:
153
    Deinitializes the specific module instance of the Console module.
154

155
  Description:
156
    Deinitializes the specific module instance disabling its operation (and
157
    any hardware for driver modules). Resets all the internal data
158
    structures and fields for the specified instance to the default
159
    settings.
160

161
  PreCondition:
162
    The SYS_CONSOLE_Initialize function should have been called before calling
163
    this function.
164

165
  Parameters:
166
    object    - SYS CONSOLE object handle, returned from SYS_CONSOLE_Initialize
167

168
   Returns:
169
    - true        - if successful
170
    - false        - if unsuccessful
171
*/
172

    
173
bool SYS_CONSOLE_Deinitialize ( SYS_MODULE_OBJ object )
174
{
175
    return true;
176
}
177

    
178

    
179
// *****************************************************************************
180
/* Function:
181
    SYS_STATUS SYS_CONSOLE_Status ( SYS_MODULE_OBJ object )
182

183
  Summary:
184
    Returns status of the specific module instance of the Console module.
185

186
  Description:
187
    This function returns the status of the specific module instance disabling its
188
    operation (and any hardware for driver modules).
189

190
  PreCondition:
191
    The SYS_CONSOLE_Initialize function should have been called before calling
192
    this function.
193

194
  Parameters:
195
    object   - SYS CONSOLE object handle, returned from SYS_CONSOLE_Initialize
196

197
  Returns:
198
    SYS_STATUS_READY    Indicates that any previous module operation for the
199
                        specified module has completed
200

201
    SYS_STATUS_BUSY     Indicates that a previous module operation for the
202
                        specified module has not yet completed
203

204
    SYS_STATUS_ERROR    Indicates that the specified module is in an error state
205
*/
206

    
207
SYS_STATUS SYS_CONSOLE_Status ( SYS_MODULE_OBJ object )
208
{
209
    return SYS_STATUS_READY;
210
}
211

    
212

    
213
// *****************************************************************************
214
/* Function:
215
    void SYS_CONSOLE_Tasks ( SYS_MODULE_OBJ object )
216

217
  Summary:
218
    Maintains the system console's state machine and implements its ISR.
219

220
  Description:
221
    This routine is used to maintain the system console's internal state machine 
222
    and implement its ISR for interrupt-driven implementations.
223

224
  Precondition:
225
    The SYS_CONSOLE_Initialize function must have been called for the specified 
226
    console instance.
227

228
  Parameters:
229
    object   - SYS CONSOLE object handle, returned from SYS_CONSOLE_Initialize
230

231
  Returns:
232
    None.
233
*/
234

    
235
void SYS_CONSOLE_Tasks ( SYS_MODULE_OBJ object )
236
{
237
}
238

    
239
// *****************************************************************************
240
/* Function:
241
    ssize_t SYS_CONSOLE_Read( const SYS_MODULE_INDEX index, int fd, void *buf, size_t count )
242

243
  Summary:
244
    Reads data from the console device.
245

246
  Description:
247
    This function reads the data from the console device.
248

249
  Preconditions:
250
    None.
251

252
  Parameters:
253
    index           - Console instance index
254
    fd              - This field is not used
255
                      Maintained for backward compatibility
256
                      NULL value can be passed as a parameter
257
    buf             - Buffer to hold the read data.
258
    count           - Number of bytes to read.
259

260
  Returns:
261
    Number of bytes actually read.
262

263
  Remarks:
264
    None.
265
*/
266

    
267
ssize_t SYS_CONSOLE_Read(const SYS_MODULE_INDEX index, int fd, void *buf, size_t count )
268
{
269
    size_t  numBytes = 0;
270
    char* pReadByte = (char*)buf;
271
        if( !DRV_USART0_ReceiverBufferIsEmpty() )
272
        {
273
                *pReadByte = DRV_USART0_ReadByte();
274

    
275
                numBytes++;
276
                pReadByte++;
277
    }
278

    
279
    return numBytes;
280
}
281

    
282

    
283
// *****************************************************************************
284
/* Function:
285
    ssize_t SYS_CONSOLE_Write( const SYS_MODULE_INDEX index, int fd, const void *buffer, size_t count )
286

287
  Summary:
288
    Writes data to the console device.
289

290
  Description:
291
    This function writes data to the console device.
292

293
  Preconditions:
294
    None.
295

296
  Parameters:
297
    index           - Console instance index
298
    fd              - This field is not used
299
                      Maintained for backward compatibility
300
                      NULL value can be passed as a parameter
301
    buf             - Buffer holding the data to be written.
302
    count           - Number of bytes to write.
303

304
  Returns:
305
    Number of bytes written or -1 if error.
306

307
  Remarks:
308
    None.
309
*/
310

    
311
ssize_t SYS_CONSOLE_Write(const SYS_MODULE_INDEX index, int fd, const char *buf, size_t count )
312
{
313
    size_t numBytes = 0;
314
    while( numBytes < count )
315
    {
316
        DRV_USART0_WriteByte(buf[numBytes++]);
317
    }
318
    return count;
319
}
320

    
321

    
322
// *****************************************************************************
323
/* Function:
324
    void SYS_CONSOLE_RegisterCallback(const SYS_MODULE_INDEX index, consoleCallbackFunction cbFunc, SYS_CONSOLE_EVENT event)
325

326
  Summary:
327
    Registers a callback function with the console service that will be
328
    executed when the read or write queue is emptied.
329

330
  Description:
331
    This function is used by an application to register a callback function
332
    with the console service. The callback function is called in response to
333
    an event. Separate callback functions are required for each event.
334

335
  Preconditions:
336
    None.
337

338
  Parameters:
339
    index               - Console instance index
340
    consCallbackFunc    - The name of the callback function
341
    event               - Enumerated list of events that can trigger a callback
342

343
  Returns:
344
    None.
345

346
  Remarks:
347
    None.
348
*/
349

    
350
void SYS_CONSOLE_RegisterCallback(const SYS_MODULE_INDEX index, consoleCallbackFunction cbFunc, SYS_CONSOLE_EVENT event)
351
{
352
}
353

    
354

    
355
// *****************************************************************************
356
/* Function:
357
    void SYS_CONSOLE_Flush(const SYS_MODULE_INDEX index)
358

359
  Summary:
360
    Flushes the read and write queues and resets an overflow error for the
361
    console.
362

363
  Description:
364
    This function flushes the read and write queues and resets an overflow
365
    error for the console.
366

367
  Preconditions:
368
    None.
369

370
  Parameters:
371
    index               - Console instance index
372

373
  Returns:
374
    None.
375

376
  Remarks:
377
    None.
378
*/
379

    
380
void SYS_CONSOLE_Flush(const SYS_MODULE_INDEX index)
381
{
382
}
383

    
384
                      
385
/*******************************************************************************
386
 End of File
387
*/