IoT_SCV_CH584M/APP/peripheral_main.c

128 lines
3.1 KiB
C
Raw Normal View History

2024-12-11 16:21:57 +08:00
/********************************** (C) COPYRIGHT *******************************
* File Name : main.c
* Author : WCH
* Version : V1.1
* Date : 2020/08/06
* Description : <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
/******************************************************************************/
/* ͷ<>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> */
#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"
2024-12-11 16:21:57 +08:00
#include "log.h"
#undef LOG_ENABLE
#define LOG_ENABLE 1
#define SYSTICK_INTERVAL (1)
#define PB3_PIN GPIO_Pin_3
2024-12-11 16:21:57 +08:00
uint8_t TxBuff[] = "This is a uart3 tx example\r\n";
/*********************************************************************
* GLOBAL TYPEDEFS
*/
__attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
const uint8_t MacAddr[6] = {0x84, 0xC2, 0xE4, 0x03, 0x02, 0x02};
#endif
/*********************************************************************
* @fn Main_Circulation
*
* @brief <EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD>
*
* @return none
*/
__HIGH_CODE
__attribute__((noinline))
void Main_Circulation()
{
logDebug("Main_Circulation\n");
while(1)
{
TMOS_SystemProcess();
KEY_ProcessLoop();
2024-12-11 16:21:57 +08:00
}
}
/*********************************************************************
* @fn main
*
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @return none
*/
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); //<2F><EFBFBD><E8B6A8><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>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_UART3_Init();
2024-12-11 16:21:57 +08:00
logDebug("%s", TxBuff);
2024-12-11 16:21:57 +08:00
#endif
logDebug("Start @ChipID=%02X\n", R8_CHIP_ID);
logDebug("%s\n", VER_LIB);
CH58x_BLEInit();
logDebug("BLE init ok\n");
HAL_Init();
logDebug("HAL init ok\n");
GAPRole_PeripheralInit();
logDebug("GAP init ok\n");
Peripheral_Init();
logDebug("Peripheral init ok\n");
BSP_KEY_Init(app_task_handler);
BSP_MOTOR_Init();
VALVE_OPEN();
BSP_LED_Init();
2025-03-21 11:44:42 +08:00
BSP_VBAT_Init();
logDebug("VBAT init ok\n");
BSP_Ml307r_Init();
logDebug("BSP_M1307r ok\n");
2025-04-01 15:09:01 +08:00
ShowRestartReason();
IWDG_Init(5000);
logDebug("IWDG init ok\n");
2025-03-21 11:44:42 +08:00
BSP_PRESS_Init();
logDebug("BSP init ok\n");
Function_Check();
2024-12-11 16:21:57 +08:00
Main_Circulation();
logDebug("Main_Circulation\n");
}
/******************************** endfile @ main ******************************/