Statistics
| Branch: | Tag: | Revision:

mongoose / examples / PIC32 / mqtt_client / firmware / src / system_config / mx795_CC3100_e16 / system_init.c @ eaef5bd1

History | View | Annotate | Download (8.78 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 =      FRCPLL
72
#pragma config FSOSCEN =    ON
73
#pragma config IESO =       ON
74
#pragma config POSCMOD =    OFF
75
#pragma config OSCIOFNC =   OFF
76
#pragma config FPBDIV =     DIV_1
77
#pragma config FCKSM =      CSECMD
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 =     OFF
87
/*** DEVCFG3 ***/
88

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

    
98
// *****************************************************************************
99
// *****************************************************************************
100
// Section: Driver Initialization Data
101
// *****************************************************************************
102
// *****************************************************************************
103
// <editor-fold defaultstate="collapsed" desc="DRV_SPI Initialization Data"> 
104
 /*** SPI Driver Initialization Data ***/
105
// </editor-fold>
106
// <editor-fold defaultstate="collapsed" desc="DRV_USART Initialization Data">
107
// </editor-fold>
108

    
109
// *****************************************************************************
110
// *****************************************************************************
111
// Section: System Data
112
// *****************************************************************************
113
// *****************************************************************************
114

    
115
/* Structure to hold the object handles for the modules in the system. */
116
SYSTEM_OBJECTS sysObj;
117

    
118
// *****************************************************************************
119
// *****************************************************************************
120
// Section: Module Initialization Data
121
// *****************************************************************************
122
// *****************************************************************************
123
// <editor-fold defaultstate="collapsed" desc="SYS_CONSOLE Initialization Data">
124
// </editor-fold>
125
// <editor-fold defaultstate="collapsed" desc="SYS_DEBUG Initialization Data">
126
/*** System Debug Initialization Data ***/
127

    
128
SYS_DEBUG_INIT debugInit =
129
{
130
    .moduleInit = {0},
131
    .errorLevel = SYS_ERROR_FATAL
132
};
133
// </editor-fold>
134
//<editor-fold defaultstate="collapsed" desc="SYS_DEVCON Initialization Data">
135
/*******************************************************************************
136
  Device Control System Service Initialization Data
137
*/
138

    
139
const SYS_DEVCON_INIT sysDevconInit =
140
{
141
    .moduleInit = {0},
142
};
143

    
144
// </editor-fold>
145

    
146
// *****************************************************************************
147
// *****************************************************************************
148
// Section: Library/Stack Initialization Data
149
// *****************************************************************************
150
// *****************************************************************************
151

    
152
// *****************************************************************************
153
// *****************************************************************************
154
// Section: Static Initialization Functions
155
// *****************************************************************************
156
// *****************************************************************************
157

    
158

    
159
// *****************************************************************************
160
// *****************************************************************************
161
// Section: System Initialization
162
// *****************************************************************************
163
// *****************************************************************************
164

    
165
/*******************************************************************************
166
  Function:
167
    void SYS_Initialize ( void *data )
168

169
  Summary:
170
    Initializes the board, services, drivers, application and other modules.
171

172
  Remarks:
173
    See prototype in system/common/sys_module.h.
174
 */
175

    
176
void SYS_Initialize ( void* data )
177
{
178
    /* Core Processor Initialization */
179
    SYS_CLK_Initialize( NULL );
180
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
181
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
182
    SYS_DEVCON_JTAGDisable();
183
    SYS_PORTS_Initialize();
184

    
185
    /* Initialize Drivers */
186

    
187
    /*** SPI Driver Index 0 initialization***/
188

    
189
    sysObj.spiObjectIdx0 = DRV_SPI_Initialize(DRV_SPI_INDEX_0, (const SYS_MODULE_INIT  * const)NULL);
190
    /* RTCC Initialization Call */
191
    DRV_RTCC_Initialize();
192

    
193
    sysObj.drvUsart0 = DRV_USART_Initialize(DRV_USART_INDEX_0, (SYS_MODULE_INIT *)NULL);
194
    SYS_INT_VectorPrioritySet(INT_VECTOR_UART2, INT_PRIORITY_LEVEL3);
195
    SYS_INT_VectorSubprioritySet(INT_VECTOR_UART2, INT_SUBPRIORITY_LEVEL0);
196

    
197
    /* Initialize System Services */
198
    sysObj.sysConsole0 = SYS_CONSOLE_Initialize(SYS_CONSOLE_INDEX_0, NULL);
199

    
200

    
201
    /*** Debug Service Initialization Code ***/
202
    sysObj.sysDebug = SYS_DEBUG_Initialize(SYS_DEBUG_INDEX_0, (SYS_MODULE_INIT*)&debugInit);
203

    
204
    /*** Interrupt Service Initialization Code ***/
205
    SYS_INT_Initialize();
206
  
207
    /* Initialize Middleware */
208

    
209
    /* Enable Global Interrupts */
210
    SYS_INT_Enable();
211

    
212
    /* Initialize the Application */
213
    APP_Initialize();
214
}
215

    
216

    
217
/*******************************************************************************
218
 End of File
219
*/
220