Statistics
| Branch: | Tag: | Revision:

mongoose / examples / PIC32 / http_server / firmware / src / system_config / pic32mx_eth_sk2_encx24j600 / system_init.c @ eaef5bd1

History | View | Annotate | Download (21.1 KB)

1
/* clang-format off */
2
/*******************************************************************************
3
  System Initialization File
4

5
  File Name:
6
    system_init.c
7

8
  Summary:
9
    This file contains source code necessary to initialize the system.
10

11
  Description:
12
    This file contains source code necessary to initialize the system.  It
13
    implements the "SYS_Initialize" function, defines the configuration bits,
14
    and allocates any necessary global system resources, such as the
15
    sysObj structure that contains the object handles to all the MPLAB Harmony
16
    module objects in the system.
17
 *******************************************************************************/
18

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

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

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

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

    
44
// *****************************************************************************
45
// *****************************************************************************
46
// Section: Included Files
47
// *****************************************************************************
48
// *****************************************************************************
49

    
50
#include "system_config.h"
51
#include "system_definitions.h"
52

    
53

    
54
// ****************************************************************************
55
// ****************************************************************************
56
// Section: Configuration Bits
57
// ****************************************************************************
58
// ****************************************************************************
59
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">
60

    
61
/*** DEVCFG0 ***/
62

    
63
#pragma config DEBUG =      ON
64
#pragma config ICESEL =     ICS_PGx2
65
#pragma config PWP =        OFF
66
#pragma config BWP =        OFF
67
#pragma config CP =         OFF
68

    
69
/*** DEVCFG1 ***/
70

    
71
#pragma config FNOSC =      PRIPLL
72
#pragma config FSOSCEN =    ON
73
#pragma config IESO =       ON
74
#pragma config POSCMOD =    XT
75
#pragma config OSCIOFNC =   OFF
76
#pragma config FPBDIV =     DIV_1
77
#pragma config FCKSM =      CSECME
78
#pragma config WDTPS =      PS1048576
79
#pragma config FWDTEN =     OFF
80
/*** DEVCFG2 ***/
81

    
82
#pragma config FPLLIDIV =   DIV_2
83
#pragma config FPLLMUL =    MUL_20
84
#pragma config FPLLODIV =   DIV_1
85
#pragma config UPLLIDIV =   DIV_2
86
#pragma config UPLLEN =     ON
87
/*** DEVCFG3 ***/
88

    
89
#pragma config USERID =     0xffff
90
#pragma config FSRSSEL =    PRIORITY_7
91
#pragma config FMIIEN =     OFF
92
#pragma config FETHIO =     OFF
93
#pragma config FCANIO =     OFF
94
#pragma config FUSBIDIO =   OFF
95
#pragma config FVBUSONIO =  OFF
96
// </editor-fold>
97

    
98
// *****************************************************************************
99
// *****************************************************************************
100
// Section: Driver Initialization Data
101
// *****************************************************************************
102
// *****************************************************************************
103
// <editor-fold defaultstate="collapsed" desc="ENC 600 Driver Initialization Data">
104
/* ENC 600 Driver Configuration */
105
DRV_ENCX24J600_Configuration drvEncX24j600InitDataIdx0 = {
106
    .txDescriptors =        DRV_ENCX24J600_MAC_TX_DESCRIPTORS_IDX0,
107
    .rxDescriptors =        DRV_ENCX24J600_MAC_RX_DESCRIPTORS_IDX0,
108
    .rxDescBufferSize =     DRV_ENCX24J600_MAX_RX_BUFFER_IDX0,
109
    .spiDrvIndex =          DRV_ENCX24J600_SPI_DRIVER_INDEX_IDX0,
110
    .spiBps =               DRV_ENCX24J600_SPI_BPS_IDX0,
111
    .spiSSPortModule =      DRV_ENCX24J600_SPI_SS_PORT_MODULE_IDX0,
112
    .spiSSPortChannel =     DRV_ENCX24J600_SPI_SS_PORT_CHANNEL_IDX0,
113
    .spiSSPortPin =         DRV_ENCX24J600_SPI_SS_PORT_PIN_IDX0,
114
    .rxBufferSize =                 DRV_ENCX24J600_RX_BUFFER_SIZE_IDX0,
115
    .maxFrameSize =                DRV_ENCX24J600_MAX_FRAME_SIZE_IDX0,
116
};
117
// </editor-fold>
118
// <editor-fold defaultstate="collapsed" desc="DRV_SPI Initialization Data">
119
 /*** SPI Driver Initialization Data ***/
120
  /*** Index 0  ***/
121
 DRV_SPI_INIT drvSpi0InitData =
122
 {
123
    .spiId = DRV_SPI_SPI_ID_IDX0,
124
    .taskMode = DRV_SPI_TASK_MODE_IDX0,
125
    .spiMode = DRV_SPI_SPI_MODE_IDX0,
126
    .allowIdleRun = DRV_SPI_ALLOW_IDLE_RUN_IDX0,
127
    .spiProtocolType = DRV_SPI_SPI_PROTOCOL_TYPE_IDX0,
128
    .commWidth = DRV_SPI_COMM_WIDTH_IDX0,
129
    .spiClk = DRV_SPI_SPI_CLOCK_IDX0,
130
    .baudRate = DRV_SPI_BAUD_RATE_IDX0,
131
    .bufferType = DRV_SPI_BUFFER_TYPE_IDX0,
132
    .clockMode = DRV_SPI_CLOCK_MODE_IDX0,
133
    .inputSamplePhase = DRV_SPI_INPUT_PHASE_IDX0,
134
    .txInterruptSource = DRV_SPI_TX_INT_SOURCE_IDX0,
135
    .rxInterruptSource = DRV_SPI_RX_INT_SOURCE_IDX0,
136
    .errInterruptSource = DRV_SPI_ERROR_INT_SOURCE_IDX0,
137
    .queueSize = DRV_SPI_QUEUE_SIZE_IDX0,
138
    .jobQueueReserveSize = DRV_SPI_RESERVED_JOB_IDX0,
139
 };
140
// </editor-fold>
141
// <editor-fold defaultstate="collapsed" desc="DRV_Timer Initialization Data">
142
/*** TMR Driver Initialization Data ***/
143

    
144
const DRV_TMR_INIT drvTmr0InitData =
145
{
146
    .moduleInit.sys.powerState = DRV_TMR_POWER_STATE_IDX0,
147
    .tmrId = DRV_TMR_PERIPHERAL_ID_IDX0,
148
    .clockSource = DRV_TMR_CLOCK_SOURCE_IDX0,
149
    .prescale = DRV_TMR_PRESCALE_IDX0,
150
    .mode = DRV_TMR_OPERATION_MODE_16_BIT,
151
    .interruptSource = DRV_TMR_INTERRUPT_SOURCE_IDX0,
152
    .asyncWriteEnable = false,
153
};
154
// </editor-fold>
155
// <editor-fold defaultstate="collapsed" desc="DRV_USART Initialization Data">
156

    
157
const DRV_USART_INIT drvUsart0InitData =
158
{
159
    .moduleInit.value = DRV_USART_POWER_STATE_IDX0,
160
    .usartID = DRV_USART_PERIPHERAL_ID_IDX0,
161
    .mode = DRV_USART_OPER_MODE_IDX0,
162
    .flags = DRV_USART_INIT_FLAGS_IDX0,
163
    .brgClock = DRV_USART_BRG_CLOCK_IDX0,
164
    .lineControl = DRV_USART_LINE_CNTRL_IDX0,
165
    .baud = DRV_USART_BAUD_RATE_IDX0,
166
    .handshake = DRV_USART_HANDSHAKE_MODE_IDX0,
167
    .interruptTransmit = DRV_USART_XMIT_INT_SRC_IDX0,
168
    .interruptReceive = DRV_USART_RCV_INT_SRC_IDX0,
169
    .interruptError = DRV_USART_ERR_INT_SRC_IDX0,
170
    .queueSizeTransmit = DRV_USART_XMIT_QUEUE_SIZE_IDX0,
171
    .queueSizeReceive = DRV_USART_RCV_QUEUE_SIZE_IDX0,
172
    .dmaChannelTransmit = DMA_CHANNEL_NONE,
173
    .dmaInterruptTransmit = DRV_USART_XMIT_INT_SRC_IDX0,
174
    .dmaChannelReceive = DMA_CHANNEL_NONE,
175
    .dmaInterruptReceive = DRV_USART_RCV_INT_SRC_IDX0,
176
};
177
// </editor-fold>
178

    
179
// *****************************************************************************
180
// *****************************************************************************
181
// Section: System Data
182
// *****************************************************************************
183
// *****************************************************************************
184

    
185
/* Structure to hold the object handles for the modules in the system. */
186
SYSTEM_OBJECTS sysObj;
187

    
188
// *****************************************************************************
189
// *****************************************************************************
190
// Section: Module Initialization Data
191
// *****************************************************************************
192
// *****************************************************************************
193
// <editor-fold defaultstate="collapsed" desc="SYS_COMMAND Initialization Data">
194
/*** System Command Initialization Data ***/
195

    
196
SYS_CMD_INIT sysCmdInit =
197
{
198
    .moduleInit = {0},
199
    .consoleCmdIOParam = SYS_CMD_SINGLE_CHARACTER_READ_CONSOLE_IO_PARAM,
200
};
201
// </editor-fold>
202
// <editor-fold defaultstate="collapsed" desc="SYS_CONSOLE Initialization Data">
203
/*** System Console Initialization Data ***/
204

    
205
SYS_MODULE_OBJ sysConsoleObjects[] = { SYS_MODULE_OBJ_INVALID };
206

    
207
/* Declared in console device implementation (sys_console_uart.c) */
208
extern SYS_CONSOLE_DEV_DESC consUsartDevDesc;
209
SYS_CONSOLE_INIT consUsartInit0 =
210
{
211
    .moduleInit = {0},
212
    .consDevDesc = &consUsartDevDesc,
213
};
214
// </editor-fold>
215
// <editor-fold defaultstate="collapsed" desc="SYS_DEBUG Initialization Data">
216
/*** System Debug Initialization Data ***/
217

    
218
SYS_DEBUG_INIT debugInit =
219
{
220
    .moduleInit = {0},
221
    .errorLevel = SYS_ERROR_FATAL
222
};
223
// </editor-fold>
224
//<editor-fold defaultstate="collapsed" desc="SYS_DEVCON Initialization Data">
225
/*******************************************************************************
226
  Device Control System Service Initialization Data
227
*/
228

    
229
const SYS_DEVCON_INIT sysDevconInit =
230
{
231
    .moduleInit = {0},
232
};
233

    
234
// </editor-fold>
235
// <editor-fold defaultstate="collapsed" desc="SYS_TMR Initialization Data">
236
/*** TMR Service Initialization Data ***/
237
const SYS_TMR_INIT sysTmrInitData =
238
{
239
    .moduleInit = {SYS_MODULE_POWER_RUN_FULL},
240
    .drvIndex = DRV_TMR_INDEX_0,
241
    .tmrFreq = 1000,
242
};
243
// </editor-fold>
244

    
245
// *****************************************************************************
246
// *****************************************************************************
247
// Section: Library/Stack Initialization Data
248
// *****************************************************************************
249
// *****************************************************************************
250
// <editor-fold defaultstate="collapsed" desc="TCPIP Stack Initialization Data">
251
// *****************************************************************************
252
// *****************************************************************************
253
// Section: TCPIP Data
254
// *****************************************************************************
255
// *****************************************************************************
256

    
257
/*** ARP Service Initialization Data ***/
258
const TCPIP_ARP_MODULE_CONFIG tcpipARPInitData =
259
{
260
    .cacheEntries       = TCPIP_ARP_CACHE_ENTRIES,
261
    .deleteOld          = TCPIP_ARP_CACHE_DELETE_OLD,
262
    .entrySolvedTmo     = TCPIP_ARP_CACHE_SOLVED_ENTRY_TMO,
263
    .entryPendingTmo    = TCPIP_ARP_CACHE_PENDING_ENTRY_TMO,
264
    .entryRetryTmo      = TCPIP_ARP_CACHE_PENDING_RETRY_TMO,
265
    .permQuota          = TCPIP_ARP_CACHE_PERMANENT_QUOTA,
266
    .purgeThres         = TCPIP_ARP_CACHE_PURGE_THRESHOLD,
267
    .purgeQuanta        = TCPIP_ARP_CACHE_PURGE_QUANTA,
268
    .retries            = TCPIP_ARP_CACHE_ENTRY_RETRIES,
269
    .gratProbeCount     = TCPIP_ARP_GRATUITOUS_PROBE_COUNT,
270
};
271

    
272

    
273
/*** Announce Discovery Initialization Data ***/
274
const TCPIP_ANNOUNCE_MODULE_CONFIG tcpipAnnounceInitData =
275
{
276
};
277

    
278
/*** UDP Sockets Initialization Data ***/
279
const TCPIP_UDP_MODULE_CONFIG tcpipUDPInitData =
280
{
281
    .nSockets       = TCPIP_UDP_MAX_SOCKETS,
282
    .sktTxBuffSize  = TCPIP_UDP_SOCKET_DEFAULT_TX_SIZE,
283
};
284

    
285
/*** TCP Sockets Initialization Data ***/
286
const TCPIP_TCP_MODULE_CONFIG tcpipTCPInitData =
287
{
288
    .nSockets       = TCPIP_TCP_MAX_SOCKETS,
289
    .sktTxBuffSize  = TCPIP_TCP_SOCKET_DEFAULT_TX_SIZE,
290
    .sktRxBuffSize  = TCPIP_TCP_SOCKET_DEFAULT_RX_SIZE,
291
};
292

    
293

    
294

    
295

    
296

    
297

    
298
/*** DHCP client Initialization Data ***/
299
const TCPIP_DHCP_MODULE_CONFIG tcpipDHCPInitData =
300
{
301
    .dhcpEnable     = TCPIP_DHCP_CLIENT_ENABLED,
302
    .dhcpTmo        = TCPIP_DHCP_TIMEOUT,
303
    .dhcpCliPort    = TCPIP_DHCP_CLIENT_CONNECT_PORT,
304
    .dhcpSrvPort    = TCPIP_DHCP_SERVER_LISTEN_PORT,
305

    
306
};
307

    
308

    
309
/*** ICMP Server Initialization Data ***/
310
const TCPIP_ICMP_MODULE_CONFIG tcpipICMPInitData =
311
{
312
};
313

    
314
/*** NBNS Server Initialization Data ***/
315
const TCPIP_NBNS_MODULE_CONFIG tcpipNBNSInitData =
316
{
317
};
318

    
319
/*** ETH MAC Initialization Data ***/
320
const TCPIP_MODULE_MAC_PIC32INT_CONFIG tcpipMACPIC32INTInitData =
321
{
322
    .nTxDescriptors         = TCPIP_EMAC_TX_DESCRIPTORS,
323
    .rxBuffSize             = TCPIP_EMAC_RX_BUFF_SIZE,
324
    .nRxDescriptors         = TCPIP_EMAC_RX_DESCRIPTORS,
325
    .nRxDedicatedBuffers    = TCPIP_EMAC_RX_DEDICATED_BUFFERS,
326
    .nRxInitBuffers         = TCPIP_EMAC_RX_INIT_BUFFERS,
327
    .rxLowThreshold         = TCPIP_EMAC_RX_LOW_THRESHOLD,
328
    .rxLowFill              = TCPIP_EMAC_RX_LOW_FILL,
329
    .ethFlags               = TCPIP_EMAC_ETH_OPEN_FLAGS,
330
    .phyFlags               = TCPIP_EMAC_PHY_CONFIG_FLAGS,
331
    .linkInitDelay          = TCPIP_EMAC_PHY_LINK_INIT_DELAY,
332
    .phyAddress             = TCPIP_EMAC_PHY_ADDRESS,
333
    .ethModuleId            = TCPIP_EMAC_MODULE_ID,
334
    .pPhyObject             = &DRV_ETHPHY_OBJECT_SMSC_LAN8740,
335
    .pPhyBase               = &DRV_ETHPHY_OBJECT_BASE_Default,
336
};
337

    
338

    
339

    
340
/*** Zeroconfig initialization data ***/
341
const ZCLL_MODULE_CONFIG tcpipZCLLInitData =
342
{
343
};
344

    
345

    
346

    
347

    
348
/*** DNS Client Initialization Data ***/
349
const TCPIP_DNS_CLIENT_MODULE_CONFIG tcpipDNSClientInitData =
350
{
351
    .deleteOldLease         = TCPIP_DNS_CLIENT_DELETE_OLD_ENTRIES,
352
    .cacheEntries           = TCPIP_DNS_CLIENT_CACHE_ENTRIES,
353
    .entrySolvedTmo         = TCPIP_DNS_CLIENT_CACHE_ENTRY_TMO,
354
    .nIPv4Entries  = TCPIP_DNS_CLIENT_CACHE_PER_IPV4_ADDRESS,
355
    .ipAddressType       = TCPIP_DNS_CLIENT_ADDRESS_TYPE,
356
    .nIPv6Entries  = TCPIP_DNS_CLIENT_CACHE_PER_IPV6_ADDRESS,
357
};
358

    
359

    
360

    
361

    
362
TCPIP_STACK_HEAP_INTERNAL_CONFIG tcpipHeapConfig =
363
{
364
    .heapType = TCPIP_STACK_HEAP_TYPE_INTERNAL_HEAP,
365
    .heapFlags = TCPIP_STACK_HEAP_USE_FLAGS,
366
    .heapUsage = TCPIP_STACK_HEAP_USAGE_CONFIG,
367
    .malloc_fnc = TCPIP_STACK_MALLOC_FUNC,
368
    .calloc_fnc = TCPIP_STACK_CALLOC_FUNC,
369
    .free_fnc = TCPIP_STACK_FREE_FUNC,
370
    .heapSize = TCPIP_STACK_DRAM_SIZE,
371
};
372

    
373
const TCPIP_NETWORK_CONFIG __attribute__((unused))  TCPIP_HOSTS_CONFIGURATION[] =
374
{
375
/*** Network Configuration Index 0 ***/
376
    {
377
        TCPIP_NETWORK_DEFAULT_INTERFACE_NAME,       // interface
378
        TCPIP_NETWORK_DEFAULT_HOST_NAME,            // hostName
379
        TCPIP_NETWORK_DEFAULT_MAC_ADDR,             // macAddr
380
        TCPIP_NETWORK_DEFAULT_IP_ADDRESS,           // ipAddr
381
        TCPIP_NETWORK_DEFAULT_IP_MASK,              // ipMask
382
        TCPIP_NETWORK_DEFAULT_GATEWAY,              // gateway
383
        TCPIP_NETWORK_DEFAULT_DNS,                  // priDNS
384
        TCPIP_NETWORK_DEFAULT_SECOND_DNS,           // secondDNS
385
        TCPIP_NETWORK_DEFAULT_POWER_MODE,           // powerMode
386
        TCPIP_NETWORK_DEFAULT_INTERFACE_FLAGS,      // startFlags
387
       &TCPIP_NETWORK_DEFAULT_MAC_DRIVER,           // pMacObject
388
    },
389
};
390

    
391
const TCPIP_STACK_MODULE_CONFIG TCPIP_STACK_MODULE_CONFIG_TBL [] =
392
{
393
    {TCPIP_MODULE_IPV4,          0},
394
    {TCPIP_MODULE_ICMP,          0},                           // TCPIP_MODULE_ICMP
395
    {TCPIP_MODULE_ARP,           &tcpipARPInitData},              // TCPIP_MODULE_ARP
396
    {TCPIP_MODULE_UDP,           &tcpipUDPInitData},              // TCPIP_MODULE_UDP,
397
    {TCPIP_MODULE_TCP,           &tcpipTCPInitData},              // TCPIP_MODULE_TCP,
398
    {TCPIP_MODULE_DHCP_CLIENT,   &tcpipDHCPInitData},             // TCPIP_MODULE_DHCP_CLIENT,
399
    {TCPIP_MODULE_ANNOUNCE,      &tcpipAnnounceInitData},                     // TCPIP_MODULE_ANNOUNCE,
400
    {TCPIP_MODULE_DNS_CLIENT,&tcpipDNSClientInitData}, // TCPIP_MODULE_DNS_CLIENT,
401
    {TCPIP_MODULE_NBNS,          &tcpipNBNSInitData},                           // TCPIP_MODULE_NBNS
402

    
403
    {TCPIP_MODULE_ZCLL, 0},                                    // TCPIP_MODULE_ZCLL,
404
    { TCPIP_MODULE_MANAGER,    & tcpipHeapConfig },          // TCPIP_MODULE_MANAGER
405
    // MAC modules
406
    {TCPIP_MODULE_MAC_ENCJ600, &drvEncX24j600InitDataIdx0},     // TCPIP_MODULE_MAC_ENCJ600
407

    
408
};
409

    
410
/*********************************************************************
411
 * Function:        SYS_MODULE_OBJ TCPIP_STACK_Init()
412
 *
413
 * PreCondition:    None
414
 *
415
 * Input:
416
 *
417
 * Output:          valid system module object if Stack and its componets are initialized
418
 *                  SYS_MODULE_OBJ_INVALID otherwise
419
 *
420
 * Overview:        The function starts the initialization of the stack.
421
 *                  If an error occurs, the SYS_ERROR() is called
422
 *                  and the function de-initialize itself and will return false.
423
 *
424
 * Side Effects:    None
425
 *
426
 * Note:            This function must be called before any of the
427
 *                  stack or its component routines are used.
428
 *
429
 ********************************************************************/
430

    
431

    
432
SYS_MODULE_OBJ TCPIP_STACK_Init()
433
{
434
    TCPIP_STACK_INIT    tcpipInit;
435

    
436
    tcpipInit.moduleInit.sys.powerState = SYS_MODULE_POWER_RUN_FULL;
437
    tcpipInit.pNetConf = TCPIP_HOSTS_CONFIGURATION;
438
    tcpipInit.nNets = sizeof (TCPIP_HOSTS_CONFIGURATION) / sizeof (*TCPIP_HOSTS_CONFIGURATION);
439
    tcpipInit.pModConfig = TCPIP_STACK_MODULE_CONFIG_TBL;
440
    tcpipInit.nModules = sizeof (TCPIP_STACK_MODULE_CONFIG_TBL) / sizeof (*TCPIP_STACK_MODULE_CONFIG_TBL);
441

    
442
    return TCPIP_STACK_Initialize(0, &tcpipInit.moduleInit);
443
}
444
// </editor-fold>
445

    
446
// *****************************************************************************
447
// *****************************************************************************
448
// Section: Static Initialization Functions
449
// *****************************************************************************
450
// *****************************************************************************
451

    
452

    
453
// *****************************************************************************
454
// *****************************************************************************
455
// Section: System Initialization
456
// *****************************************************************************
457
// *****************************************************************************
458

    
459
/*******************************************************************************
460
  Function:
461
    void SYS_Initialize ( void *data )
462

463
  Summary:
464
    Initializes the board, services, drivers, application and other modules.
465

466
  Remarks:
467
    See prototype in system/common/sys_module.h.
468
 */
469

    
470
void SYS_Initialize ( void* data )
471
{
472
    /* Core Processor Initialization */
473
    SYS_CLK_Initialize( NULL );
474
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
475
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
476
    SYS_DEVCON_JTAGDisable();
477
    SYS_PORTS_Initialize();
478
    /* Board Support Package Initialization */
479
    BSP_Initialize();
480

    
481
    /* Initialize Drivers */
482

    
483
    /*** SPI Driver Index 0 initialization***/
484

    
485
    SYS_INT_VectorPrioritySet(DRV_SPI_INT_VECTOR_IDX0, DRV_SPI_INT_PRIORITY_IDX0);
486
    SYS_INT_VectorSubprioritySet(DRV_SPI_INT_VECTOR_IDX0, DRV_SPI_INT_SUB_PRIORITY_IDX0);
487
    sysObj.spiObjectIdx0 = DRV_SPI_Initialize(DRV_SPI_INDEX_0, (const SYS_MODULE_INIT  * const)&drvSpi0InitData);
488

    
489
    sysObj.drvTmr0 = DRV_TMR_Initialize(DRV_TMR_INDEX_0, (SYS_MODULE_INIT *)&drvTmr0InitData);
490

    
491
    SYS_INT_VectorPrioritySet(INT_VECTOR_T1, INT_PRIORITY_LEVEL1);
492
    SYS_INT_VectorSubprioritySet(INT_VECTOR_T1, INT_SUBPRIORITY_LEVEL0);
493

    
494

    
495
     sysObj.drvUsart0 = DRV_USART_Initialize(DRV_USART_INDEX_0, (SYS_MODULE_INIT *)&drvUsart0InitData);
496

    
497
    /* Initialize System Services */
498

    
499
    /*** Command Service Initialization Code ***/
500
    SYS_CMD_Initialize((SYS_MODULE_INIT*)&sysCmdInit);
501
    sysObj.sysConsole0 = SYS_CONSOLE_Initialize(SYS_CONSOLE_INDEX_0, (SYS_MODULE_INIT *)&consUsartInit0);
502

    
503

    
504
    /*** Debug Service Initialization Code ***/
505
    sysObj.sysDebug = SYS_DEBUG_Initialize(SYS_DEBUG_INDEX_0, (SYS_MODULE_INIT*)&debugInit);
506

    
507
    /*** Interrupt Service Initialization Code ***/
508
    SYS_INT_Initialize();
509

    
510
    /*** Random Service Initialization Code ***/
511
    SYS_RANDOM_Initialize(0, 0);
512

    
513
    /*** TMR Service Initialization Code ***/
514
    sysObj.sysTmr  = SYS_TMR_Initialize(SYS_TMR_INDEX_0, (const SYS_MODULE_INIT  * const)&sysTmrInitData);
515

    
516
    /* Initialize Middleware */
517

    
518
    /* set priority for ETHERNET interrupt source */
519
    SYS_INT_VectorPrioritySet(INT_VECTOR_ETH, INT_PRIORITY_LEVEL5);
520

    
521
    /* set sub-priority for ETHERNET interrupt source */
522
    SYS_INT_VectorSubprioritySet(INT_VECTOR_ETH, INT_SUBPRIORITY_LEVEL3);
523

    
524
    /* TCPIP Stack Initialization */
525
    sysObj.tcpip = TCPIP_STACK_Init();
526
    SYS_ASSERT(sysObj.tcpip != SYS_MODULE_OBJ_INVALID, "TCPIP_STACK_Init Failed" );
527

    
528

    
529
    /* Enable Global Interrupts */
530
    SYS_INT_Enable();
531

    
532
    /* Initialize the Application */
533
    APP_Initialize();
534
}
535

    
536

    
537
/*******************************************************************************
538
 End of File
539
*/
540