135 lines
4.3 KiB
C
135 lines
4.3 KiB
C
|
/*
|
||
|
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
||
|
* exclusively with CVA's microcontroller products. This file can be freely
|
||
|
* distributed within development tools that are supporting such microcontroller
|
||
|
* products.
|
||
|
*
|
||
|
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||
|
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||
|
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
||
|
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||
|
*/
|
||
|
|
||
|
/*******************************************************************************
|
||
|
* the includes
|
||
|
******************************************************************************/
|
||
|
|
||
|
#include "mcu.h"
|
||
|
#include "drivers/cpu/startup/system_M012x.h"
|
||
|
|
||
|
/*******************************************************************************
|
||
|
* the defines
|
||
|
******************************************************************************/
|
||
|
|
||
|
/*******************************************************************************
|
||
|
* the typedefs
|
||
|
******************************************************************************/
|
||
|
|
||
|
/*******************************************************************************
|
||
|
* the globals
|
||
|
******************************************************************************/
|
||
|
|
||
|
/*******************************************************************************
|
||
|
* the functions
|
||
|
******************************************************************************/
|
||
|
|
||
|
void Mcu_Init(McuType *obj)
|
||
|
{
|
||
|
/* Initialize ADC driver */
|
||
|
AdcDrv_Init(&obj->adcDrv, ADC, SCG0);
|
||
|
|
||
|
/* Initialize clock driver */
|
||
|
ClockDrv_InitParamsType clockInitParams;
|
||
|
clockInitParams.sircFreq = CPU_INT_SLOW_CLK_HZ;
|
||
|
clockInitParams.xtalClkFreq = CPU_XTAL_CLK_HZ;
|
||
|
clockInitParams.rtcClkInFreq = 0;
|
||
|
clockInitParams.tclkFreq[0] = 0;
|
||
|
clockInitParams.tclkFreq[1] = 0;
|
||
|
clockInitParams.tclkFreq[2] = 0;
|
||
|
ClockDrv_Init(&obj->clockDrv, RCM, PCC0, SCG0, SCG1, PCC1, SCG2, &clockInitParams);
|
||
|
|
||
|
/* Initialize CMU PLL driver */
|
||
|
CmuDrv_Init(&obj->cmuPllDrv, CMU_PLL);
|
||
|
|
||
|
/* Initialize CMU SOSC driver */
|
||
|
CmuDrv_Init(&obj->cmuSoscDrv, CMU_SOSC);
|
||
|
|
||
|
/* Initialize crc driver */
|
||
|
CrcDrv_Init(&obj->crcDrv, CRC);
|
||
|
|
||
|
/* Initialize rtc driver */
|
||
|
EDmaDrv_Init(&obj->edmaDrv, DMA, DMAMUX);
|
||
|
|
||
|
/* Initialize eim driver */
|
||
|
EimDrv_Init(&obj->eimDrv, EIM);
|
||
|
|
||
|
/* Initialize erm driver */
|
||
|
ErmDrv_Init(&obj->ermDrv, ERM);
|
||
|
|
||
|
/* Initialize fhu driver */
|
||
|
FhuDrv_Init(&obj->fhuDrv, FHU);
|
||
|
|
||
|
/* Initialize Flash driver */
|
||
|
FlashDrv_Init(&obj->flashDrv, FTFC, SCG0);
|
||
|
|
||
|
/* Initialize flexCAN driver */
|
||
|
FlexCanDrv_InitHwParType initHwPar;
|
||
|
initHwPar.canRamNum = 2;
|
||
|
FlexCanDrv_Init(&obj->flexCanDrv, CAN, PCC1, PCC0, SCG0, SCG2, SIM, &initHwPar);
|
||
|
|
||
|
/* Initialize IIC driver */
|
||
|
I2cDrv_Init(&obj->i2cDrv0, I2C);
|
||
|
|
||
|
/* Initialize LPIT driver */
|
||
|
LpitDrv_Init(&obj->lpitDrv, LPIT);
|
||
|
|
||
|
/* Initialize LPTMR driver */
|
||
|
LptmrDrv_Init(&obj->lptmrDrv, LPTMR);
|
||
|
|
||
|
/* Initialize MFT drivers */
|
||
|
MftDrv_Init(&obj->mftDrv0, MFT0);
|
||
|
MftDrv_Init(&obj->mftDrv1, MFT1);
|
||
|
|
||
|
/* Initialize mpu driver */
|
||
|
MpuDrv_Init(&obj->mpuDrv, MPU);
|
||
|
|
||
|
/* Initialize PDB driver */
|
||
|
PdbDrv_Init(&obj->pdbDrv, PDB);
|
||
|
|
||
|
/* Initialize PINS driver */
|
||
|
PinsDrv_Init(&obj->pta, PORTA, GPIOA);
|
||
|
PinsDrv_Init(&obj->ptb, PORTB, GPIOB);
|
||
|
PinsDrv_Init(&obj->ptc, PORTC, GPIOC);
|
||
|
|
||
|
/* Initialize POWER driver */
|
||
|
PowerDrv_Init(&obj->powerDrv, PMC, SCG2, SCG1, SCG0);
|
||
|
|
||
|
/* Initialize PWMLITE driver */
|
||
|
PwmLiteDrv_Init(&obj->pwmLiteDrv0, PWMLITE0, SIM);
|
||
|
PwmLiteDrv_Init(&obj->pwmLiteDrv1, PWMLITE1, SIM);
|
||
|
|
||
|
/* Initialize reset driver */
|
||
|
ResetDrv_Init(&obj->resetDrv, RCM, PCC1, PCC0);
|
||
|
|
||
|
/* Initialize rtc driver */
|
||
|
RtcDrv_Init(&obj->rtcDrv, RTC);
|
||
|
|
||
|
/* Initialize SPI0&SPI1 driver */
|
||
|
SpiDrv_Init(&obj->spiDrv0, SPI0);
|
||
|
SpiDrv_Init(&obj->spiDrv1, SPI1);
|
||
|
|
||
|
/* Initialize TRGMUX driver */
|
||
|
TrgMuxDrv_Init(&obj->trgMuxDrv, TRGMUX, SIM);
|
||
|
|
||
|
/* Initialize UART0&UART1 driver */
|
||
|
UartDrv_Init(&obj->uartDrv0, UART0);
|
||
|
UartDrv_Init(&obj->uartDrv1, UART1);
|
||
|
|
||
|
/* Initialize watchdog driver */
|
||
|
WdgDrv_Init(&obj->wdgDrv, WDG);
|
||
|
}
|