IoT_SCV_CH584M/APP/peripheral_main.c

105 lines
2.9 KiB
C
Raw Normal View History

2024-11-14 09:47:21 +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_wf5803.h"
/*********************************************************************
* 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()
{
PRINT("Main_Circulation\n");
2024-11-14 09:47:21 +08:00
while(1)
{
TMOS_SystemProcess();
}
}
/*********************************************************************
* @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);
#if(defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
GPIOA_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU);
GPIOB_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU);
#endif
#ifdef DEBUG
// GPIOA_SetBits(GPIO_Pin_14);
// GPIOPinRemap(ENABLE, RB_PIN_UART0);
// GPIOA_ModeCfg(GPIO_Pin_14, GPIO_ModeOut_PP_5mA);
// UART0_DefInit();
// GPIOA_SetBits(GPIO_Pin_9);
// // GPIOPinRemap(ENABLE, RB_PIN_UART1);
// GPIOA_ModeCfg(GPIO_Pin_9, GPIO_ModeOut_PP_5mA);
// // UART0_DefInit();
// UART1_DefInit();
/* <20><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<49><4F>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD> */
GPIOA_SetBits(GPIO_Pin_9);
GPIOA_ModeCfg(GPIO_Pin_8, GPIO_ModeIN_PU); // RXD-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
GPIOA_ModeCfg(GPIO_Pin_9, GPIO_ModeOut_PP_5mA); // TXD-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<49><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ƽ
UART1_DefInit();
2024-11-14 09:47:21 +08:00
#endif
PRINT("Start @ChipID=%02X\n", R8_CHIP_ID);
2024-11-14 09:47:21 +08:00
PRINT("%s\n", VER_LIB);
CH58x_BLEInit();
PRINT("BLE init ok\n");
2024-11-14 09:47:21 +08:00
HAL_Init();
PRINT("HAL init ok\n");
2024-11-14 09:47:21 +08:00
GAPRole_PeripheralInit();
PRINT("GAP init ok\n");
2024-11-14 09:47:21 +08:00
Peripheral_Init();
PRINT("Peripheral init ok\n");
2024-11-14 09:47:21 +08:00
2024-11-19 19:01:02 +08:00
BSP_PRESS_Init();
PRINT("BSP init ok\n");
2024-11-14 09:47:21 +08:00
Main_Circulation();
PRINT("Main_Circulation\n");
2024-11-14 09:47:21 +08:00
}
/******************************** endfile @ main ******************************/