IoT_SCV_CH584M/APP/peripheral_main.c

108 lines
2.4 KiB
C
Raw Normal View History

/* 头文件包含 */
2024-12-11 16:21:57 +08:00
#include "CONFIG.h"
#include "HAL.h"
#include "gattprofile.h"
#include "peripheral.h"
#include "bsp_bmp390.h"
2024-12-11 16:21:57 +08:00
#include "bsp_ml307r.h"
#include "bsp_uart.h"
#include "bsp_adc.h"
#include "bsp_motor.h"
#include "bsp_led.h"
#include "bsp_key.h"
2025-04-01 15:09:01 +08:00
#include "bsp_iwdg.h"
2025-05-13 17:29:54 +08:00
#include "bsp_valve.h"
2024-12-11 16:21:57 +08:00
#include "log.h"
#undef LOG_ENABLE
#define LOG_ENABLE 1
#define LOG_LVL LOG_DEBUG
2024-12-11 16:21:57 +08:00
#undef LOG_TAG
#define LOG_TAG "main"
2024-12-11 16:21:57 +08:00
__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();
2024-12-11 16:21:57 +08:00
}
}
2024-12-11 16:21:57 +08:00
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);
2024-12-11 16:21:57 +08:00
#endif
#ifdef DEBUG
BSP_SHELL_Init(4000000);
2024-12-11 16:21:57 +08:00
#endif
DelayMs(1000 * 3);
ShowRestartReason();
// log打印编译时间和编译日期
logDebug("Compile Time: %s %s", __DATE__, __TIME__);
logDebug("GetSysClock = %d Hz", GetSysClock());
2024-12-11 16:21:57 +08:00
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]);
2024-12-11 16:21:57 +08:00
CH58x_BLEInit();
HAL_Init();
GAPRole_PeripheralInit();
Peripheral_Init();
MultiTimerInstall((PlatformTicksFunction_t)BSP_Get_Tick);
BSP_KEY_Init(app_task_handler);
BSP_ADC_Init();
2025-05-13 17:29:54 +08:00
BSP_VAVLE_Init();
BSP_LED_Init();
// BSP_Ml307r_Init();
// logDebug("BSP_M1307r ok\n");
2025-05-23 18:50:49 +08:00
IWDG_Init(IWDG_TIMEOUT_MS, IWDG_FEED_MS);
2025-03-21 11:44:42 +08:00
BSP_PRESS_Init();
Function_Check();
2024-12-11 16:21:57 +08:00
logDebug("BSP_Get_Tick1 %d\n",BSP_Get_Tick());
DelayMs(1000);
logDebug("BSP_Get_Tick2 %d\n",BSP_Get_Tick());
2024-12-11 16:21:57 +08:00
Main_Circulation();
logDebug("Main_Circulation\n");
}
/******************************** endfile @ main ******************************/