/******************************************************************************* System Initialization File File Name: system_init.c Summary: This file contains source code necessary to initialize the system. Description: This file contains source code necessary to initialize the system. It implements the "SYS_Initialize" function, defines the configuration bits, and allocates any necessary global system resources, such as the sysObj structure that contains the object handles to all the MPLAB Harmony module objects in the system. *******************************************************************************/ // DOM-IGNORE-BEGIN /******************************************************************************* Copyright 2017 Microchip Technology Incorporated and its subsidiaries. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE *******************************************************************************/ // DOM-IGNORE-END // ***************************************************************************** // ***************************************************************************** // Section: Included Files // ***************************************************************************** // ***************************************************************************** #include "system_config.h" #include "system_definitions.h" // **************************************************************************** // **************************************************************************** // Section: Configuration Bits // **************************************************************************** // **************************************************************************** // /*** DEVCFG0 ***/ #pragma config DEBUG = OFF #pragma config JTAGEN = OFF #pragma config ICESEL = ICS_PGx2 #pragma config TRCEN = OFF #pragma config BOOTISA = MIPS32 #pragma config FECCCON = OFF_UNLOCKED #pragma config FSLEEP = OFF #pragma config DBGPER = PG_ALL #pragma config SMCLR = MCLR_NORM #pragma config SOSCGAIN = GAIN_LEVEL_3 #pragma config SOSCBOOST = ON #pragma config POSCGAIN = GAIN_LEVEL_3 #pragma config POSCBOOST = ON #pragma config EJTAGBEN = NORMAL #pragma config CP = OFF /*** DEVCFG1 ***/ #pragma config FNOSC = SPLL #pragma config DMTINTV = WIN_127_128 #pragma config FSOSCEN = OFF #pragma config IESO = OFF #pragma config POSCMOD = EC #pragma config OSCIOFNC = OFF #pragma config FCKSM = CSECME #pragma config WDTPS = PS65536 #pragma config WDTSPGM = STOP #pragma config FWDTEN = OFF #pragma config WINDIS = NORMAL #pragma config FWDTWINSZ = WINSZ_25 #pragma config DMTCNT = DMT31 #pragma config FDMTEN = OFF /*** DEVCFG2 ***/ #pragma config FPLLIDIV = DIV_3 #pragma config FPLLRNG = RANGE_5_10_MHZ #pragma config FPLLICLK = PLL_POSC #pragma config FPLLMULT = MUL_50 #pragma config FPLLODIV = DIV_2 #pragma config UPLLFSEL = FREQ_24MHZ /*** DEVCFG3 ***/ #pragma config USERID = 0xffff #pragma config FMIIEN = OFF #pragma config FETHIO = ON #pragma config PGL1WAY = ON #pragma config PMDL1WAY = ON #pragma config IOL1WAY = ON #pragma config FUSBIDIO = ON /*** BF1SEQ0 ***/ #if 0 // @@@@ ??? #pragma config_bf1 TSEQ = 0x0001 #pragma config_bf1 CSEQ = 0xfffe #pragma config_bf2 TSEQ = 0x0000 #pragma config_bf2 CSEQ = 0xffff #endif #pragma config TSEQ = 0x0000 #pragma config CSEQ = 0xffff // // ***************************************************************************** // ***************************************************************************** // Section: Driver Initialization Data // ***************************************************************************** // ***************************************************************************** // /*** TMR Driver Initialization Data ***/ const DRV_TMR_INIT drvTmr0InitData = { .moduleInit.sys.powerState = DRV_TMR_POWER_STATE_IDX0, .tmrId = DRV_TMR_PERIPHERAL_ID_IDX0, .clockSource = DRV_TMR_CLOCK_SOURCE_IDX0, .prescale = DRV_TMR_PRESCALE_IDX0, .mode = DRV_TMR_OPERATION_MODE_16_BIT, .interruptSource = DRV_TMR_INTERRUPT_SOURCE_IDX0, .asyncWriteEnable = false, }; // // const DRV_USART_INIT drvUsart0InitData = { .moduleInit.value = DRV_USART_POWER_STATE_IDX0, .usartID = DRV_USART_PERIPHERAL_ID_IDX0, .mode = DRV_USART_OPER_MODE_IDX0, .flags = DRV_USART_INIT_FLAGS_IDX0, .brgClock = DRV_USART_BRG_CLOCK_IDX0, .lineControl = DRV_USART_LINE_CNTRL_IDX0, .baud = DRV_USART_BAUD_RATE_IDX0, .handshake = DRV_USART_HANDSHAKE_MODE_IDX0, .interruptTransmit = DRV_USART_XMIT_INT_SRC_IDX0, .interruptReceive = DRV_USART_RCV_INT_SRC_IDX0, .interruptError = DRV_USART_ERR_INT_SRC_IDX0, .queueSizeTransmit = DRV_USART_XMIT_QUEUE_SIZE_IDX0, .queueSizeReceive = DRV_USART_RCV_QUEUE_SIZE_IDX0, .dmaChannelTransmit = DMA_CHANNEL_NONE, .dmaInterruptTransmit = DRV_USART_XMIT_INT_SRC_IDX0, .dmaChannelReceive = DMA_CHANNEL_NONE, .dmaInterruptReceive = DRV_USART_RCV_INT_SRC_IDX0, }; // // ***************************************************************************** // ***************************************************************************** // Section: System Data // ***************************************************************************** // ***************************************************************************** /* Structure to hold the object handles for the modules in the system. */ SYSTEM_OBJECTS sysObj; // ***************************************************************************** // ***************************************************************************** // Section: Module Initialization Data // ***************************************************************************** // ***************************************************************************** // /*** TMR Service Initialization Data ***/ const SYS_TMR_INIT sysTmrInitData = { .moduleInit = {SYS_MODULE_POWER_RUN_FULL}, .drvIndex = DRV_TMR_INDEX_0, .tmrFreq = 1000, }; // // ***************************************************************************** // ***************************************************************************** // Section: Library/Stack Initialization Data // ***************************************************************************** // ***************************************************************************** // ***************************************************************************** // ***************************************************************************** // Section: System Initialization // ***************************************************************************** // ***************************************************************************** /******************************************************************************* Function: void SYS_Initialize ( void *data ) Summary: Initializes the board, services, drivers, application and other modules. Remarks: See prototype in system/common/sys_module.h. */ void SYS_Initialize ( void* data ) { /* Core Processor Initialization */ SYS_CLK_Initialize( NULL ); SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)NULL); SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet()); SYS_PORTS_Initialize(); /* Board Support Package Initialization */ BSP_Initialize(); /* Initialize Drivers */ sysObj.drvUsart0 = DRV_USART_Initialize(DRV_USART_INDEX_0, (SYS_MODULE_INIT *)&drvUsart0InitData); /*** Interrupt Service Initialization Code ***/ SYS_INT_Initialize(); /* Enable Global Interrupts */ SYS_INT_Enable(); /* Initialize the Application */ APP_Initialize(); } /******************************************************************************* End of File */