108 lines
2.4 KiB
C
108 lines
2.4 KiB
C
|
|
/* 头文件包含 */
|
|
#include "CONFIG.h"
|
|
#include "HAL.h"
|
|
#include "gattprofile.h"
|
|
#include "peripheral.h"
|
|
#include "bsp_bmp390.h"
|
|
#include "bsp_ml307r.h"
|
|
#include "bsp_uart.h"
|
|
#include "bsp_adc.h"
|
|
#include "bsp_motor.h"
|
|
#include "bsp_led.h"
|
|
#include "bsp_key.h"
|
|
#include "bsp_iwdg.h"
|
|
#include "bsp_valve.h"
|
|
#include "log.h"
|
|
|
|
#undef LOG_ENABLE
|
|
#define LOG_ENABLE 1
|
|
|
|
#define LOG_LVL LOG_DEBUG
|
|
|
|
#undef LOG_TAG
|
|
#define LOG_TAG "main"
|
|
|
|
__attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
|
|
|
|
|
|
__HIGH_CODE
|
|
__attribute__((noinline))
|
|
void Main_Circulation()
|
|
{
|
|
while(1)
|
|
{
|
|
TMOS_SystemProcess();
|
|
KEY_ProcessLoop();
|
|
MultiTimerYield();
|
|
BSP_UART3_TxLoop();
|
|
}
|
|
}
|
|
|
|
|
|
int main(void)
|
|
{
|
|
#if(defined(DCDC_ENABLE)) && (DCDC_ENABLE == TRUE)
|
|
PWR_DCDCCfg(ENABLE);
|
|
#endif
|
|
HSECFG_Capacitance(HSECap_18p);
|
|
SetSysClock(CLK_SOURCE_HSE_PLL_62_4MHz);
|
|
// SysTick_Config( GetSysClock() / 1000 * SYSTICK_INTERVAL); //设定嘀嗒时间1ms
|
|
#if(defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
|
|
GPIOA_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PD);
|
|
GPIOB_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PD);
|
|
#endif
|
|
|
|
#ifdef DEBUG
|
|
BSP_SHELL_Init(4000000);
|
|
#endif
|
|
DelayMs(1000 * 3);
|
|
|
|
ShowRestartReason();
|
|
|
|
// log打印编译时间和编译日期
|
|
logDebug("Compile Time: %s %s", __DATE__, __TIME__);
|
|
logDebug("GetSysClock = %d Hz", GetSysClock());
|
|
logDebug("Start @ChipID=%02X\n", R8_CHIP_ID);
|
|
logError("中文测试 %2.2f", 123.456);
|
|
logDebug("VER_LIB: %s", VER_LIB);
|
|
|
|
uint8_t MacAddr[6];
|
|
GetMACAddress(MacAddr);
|
|
// 手机APP显示是倒序的[5-0],不是[0-5]
|
|
logDebug("MacAddr: %02X:%02X:%02X:%02X:%02X:%02X", MacAddr[0], MacAddr[1], MacAddr[2], MacAddr[3], MacAddr[4], MacAddr[5]);
|
|
|
|
CH58x_BLEInit();
|
|
HAL_Init();
|
|
GAPRole_PeripheralInit();
|
|
Peripheral_Init();
|
|
MultiTimerInstall((PlatformTicksFunction_t)BSP_Get_Tick);
|
|
BSP_KEY_Init(app_task_handler);
|
|
|
|
|
|
BSP_ADC_Init();
|
|
|
|
BSP_VAVLE_Init();
|
|
|
|
BSP_LED_Init();
|
|
|
|
|
|
// BSP_Ml307r_Init();
|
|
// logDebug("BSP_M1307r ok\n");
|
|
|
|
IWDG_Init(IWDG_TIMEOUT_MS, IWDG_FEED_MS);
|
|
|
|
BSP_PRESS_Init();
|
|
|
|
Function_Check();
|
|
|
|
logDebug("BSP_Get_Tick1 %d\n",BSP_Get_Tick());
|
|
DelayMs(1000);
|
|
logDebug("BSP_Get_Tick2 %d\n",BSP_Get_Tick());
|
|
|
|
Main_Circulation();
|
|
logDebug("Main_Circulation\n");
|
|
}
|
|
|
|
/******************************** endfile @ main ******************************/
|