93 lines
2.6 KiB
C
93 lines
2.6 KiB
C
/**
|
|
* @copyright 2015 Indie Semiconductor.
|
|
*
|
|
* This file is proprietary to Indie Semiconductor.
|
|
* All rights reserved. Reproduction or distribution, in whole
|
|
* or in part, is forbidden except by express written permission
|
|
* of Indie Semiconductor.
|
|
*
|
|
* @file systemInit.c
|
|
* @Author: Jack.Pan
|
|
* @E-mail:jack.pan@indiemicro.com
|
|
* @Date: 2020/09/10
|
|
*/
|
|
|
|
#include <systemInit.h>
|
|
#include <meta.h>
|
|
#include <linSlaveTask.h>
|
|
#include <linStackTask.h>
|
|
#include <wdt_device.h>
|
|
#include <gpio_device.h>
|
|
#include <pwm_aux_device.h>
|
|
#include <gtimer_device.h>
|
|
#include <motorControlTask.h>
|
|
#include <adc_device.h>
|
|
#include "PINdef.h"
|
|
|
|
void gpios_init(void);
|
|
void pmu_init(void);
|
|
|
|
|
|
|
|
void gpios_init(void)
|
|
{
|
|
GPIO_Init(IO_KEY3,GPIO_DIR_INPUT,GPIO_PULL_UP);
|
|
GPIO_Init(IO_KEY4,GPIO_DIR_INPUT,GPIO_PULL_UP);
|
|
GPIO_Init(IO_KEY5,GPIO_DIR_INPUT,GPIO_PULL_UP);
|
|
GPIO_Init(IO_KEY6,GPIO_DIR_INPUT,GPIO_PULL_UP);
|
|
GPIO_Init(IO_KEY7,GPIO_DIR_INPUT,GPIO_PULL_UP);
|
|
GPIO_Init(IO_KEY8,GPIO_DIR_INPUT,GPIO_PULL_UP);
|
|
|
|
GPIO_Init(IO_LED1,GPIO_DIR_OUTPUT,GPIO_PULL_NONE);
|
|
GPIO_Init(IO_LED2,GPIO_DIR_OUTPUT,GPIO_PULL_NONE);
|
|
GPIO_Init(IO_LED3,GPIO_DIR_OUTPUT,GPIO_PULL_NONE);
|
|
GPIO_Init(IO_LED4,GPIO_DIR_OUTPUT,GPIO_PULL_NONE);
|
|
GPIO_Init(IO_LED5,GPIO_DIR_OUTPUT,GPIO_PULL_NONE);
|
|
GPIO_Init(IO_LED6,GPIO_DIR_OUTPUT,GPIO_PULL_NONE);
|
|
}
|
|
|
|
void pmu_init(void)
|
|
{
|
|
// /* Init set BOR voltage level for cpu low voltage safety*/
|
|
// PMU_BORInit(S_BOR_1P5V, BOR_3V3_THRS_2998mV);
|
|
// /* Disable wake up timer */
|
|
// PMU_WakeTimerInit(WAKEUP_TIMEER_DISABLE, WAKEUP_TIMEER_INTERVAL_32768ms);
|
|
}
|
|
|
|
|
|
void SYS_Init(void)
|
|
{
|
|
/* Enable trim revise access enable*/
|
|
HWCFG_TrimAccessUnlock();
|
|
|
|
TRIMHV_SFRS->PMUTRIM.VDD1V5_LDO_TRIM = 3U;
|
|
|
|
CRGA_SFRS->MODULERSTREQ = 0xFFU;
|
|
/* Init system clock */
|
|
Clock_SystemMainClockInit(SYS_MAIN_CLOCK_DIV);
|
|
pmu_init();
|
|
/* Init global timer engine for driving soft timer */
|
|
SysTick_Init(SOFT_TIMER_INTERVAL *1000U * MAIN_CPU_CLOCK, SoftTimer_ExpireCallback);
|
|
#if WATCH_DOG_EN == 1U
|
|
WDTA_Enable(WDTA_INTERVAL_18432MS); /* 8s */
|
|
#endif
|
|
/* Init gpios settings */
|
|
gpios_init();
|
|
/*HWCFG_TrimAccessLockUntilReset();*/
|
|
|
|
ADC_GeneralInit();
|
|
|
|
TIMER_Init(TIMER1, HW_TIMER_PERIODIC_MODE, GTIMER_CLK_DIV_1,1000*16, Timer1_INTTest);//Time1_timing
|
|
|
|
/* tasks init must be called before use. */
|
|
TM_PostTask(TASK_ID_SOFT_TIMER);
|
|
TM_PostTask(TASK_ID_SAFETY_MONITOR);
|
|
TM_PostTask(TASK_ID_LINS);
|
|
//TM_PostTask(TASK_ID_PDS);
|
|
TM_PostTask(TASK_ID_ADC_MEASURE);
|
|
TM_PostTask(TASK_ID_APPL);
|
|
}
|
|
|
|
|
|
|