105 lines
2.9 KiB
C
105 lines
2.9 KiB
C
/********************************** (C) COPYRIGHT *******************************
|
||
* File Name : main.c
|
||
* Author : WCH
|
||
* Version : V1.1
|
||
* Date : 2020/08/06
|
||
* Description : 外设从机应用主函数及任务系统初始化
|
||
*********************************************************************************
|
||
* 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.
|
||
*******************************************************************************/
|
||
|
||
/******************************************************************************/
|
||
/* 头文件包含 */
|
||
#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 主循环
|
||
*
|
||
* @return none
|
||
*/
|
||
__HIGH_CODE
|
||
__attribute__((noinline))
|
||
void Main_Circulation()
|
||
{
|
||
PRINT("Main_Circulation\n");
|
||
while(1)
|
||
{
|
||
TMOS_SystemProcess();
|
||
}
|
||
}
|
||
|
||
/*********************************************************************
|
||
* @fn main
|
||
*
|
||
* @brief 主函数
|
||
*
|
||
* @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();
|
||
|
||
/* 配置串口1:先配置IO口模式,再配置串口 */
|
||
GPIOA_SetBits(GPIO_Pin_9);
|
||
GPIOA_ModeCfg(GPIO_Pin_8, GPIO_ModeIN_PU); // RXD-配置上拉输入
|
||
GPIOA_ModeCfg(GPIO_Pin_9, GPIO_ModeOut_PP_5mA); // TXD-配置推挽输出,注意先让IO口输出高电平
|
||
UART1_DefInit();
|
||
|
||
#endif
|
||
PRINT("Start @ChipID=%02X\n", R8_CHIP_ID);
|
||
PRINT("%s\n", VER_LIB);
|
||
|
||
CH58x_BLEInit();
|
||
PRINT("BLE init ok\n");
|
||
HAL_Init();
|
||
PRINT("HAL init ok\n");
|
||
GAPRole_PeripheralInit();
|
||
PRINT("GAP init ok\n");
|
||
Peripheral_Init();
|
||
PRINT("Peripheral init ok\n");
|
||
|
||
BSP_PRESS_Init();
|
||
PRINT("BSP init ok\n");
|
||
|
||
Main_Circulation();
|
||
PRINT("Main_Circulation\n");
|
||
}
|
||
|
||
/******************************** endfile @ main ******************************/
|