IoT_SCV_CH584M/APP/peripheral_main.c

115 lines
3.0 KiB
C
Raw Blame History

/********************************** (C) COPYRIGHT *******************************
* File Name : main.c
* Author : WCH
* Version : V1.1
* Date : 2020/08/06
* Description : 锟斤拷锟斤拷踊锟接︼拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟较低筹拷锟绞硷拷锟<E68BB7>
*********************************************************************************
* 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"
#include "bsp_ml307r.h"
#include "bsp_uart.h"
#include "log.h"
#undef LOG_ENABLE
#define LOG_ENABLE 0
#define SYSTICK_INTERVAL (1)
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 锟斤拷循锟斤拷
*
* @return none
*/
__HIGH_CODE
__attribute__((noinline))
void Main_Circulation()
{
logDebug("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);
// SysTick_Config( GetSysClock() / 1000 * SYSTICK_INTERVAL); //锟借定锟斤拷锟绞憋拷锟<E68BB7>1ms
// 3V8_EN
GPIOB_ResetBits(GPIO_Pin_3);
// 由外部上拉电阻了
GPIOB_ModeCfg(GPIO_Pin_3, GPIO_ModeOut_PP_5mA);
#if(defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
GPIOA_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU);
GPIOB_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PD);
#endif
#ifdef DEBUG
// DEBUG鐢ㄧ殑uart1
BSP_UART3_Init();
logDebug("%s", TxBuff);
#endif
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_PRESS_Init();
logDebug("BSP init ok\n");
//
// BSP_Ml307r_Init();
// logDebug("Start @ChipID=%02X\n", R8_CHIP_ID);
// logDebug("%s\n", VER_LIB);
Main_Circulation();
logDebug("Main_Circulation\n");
}
/******************************** endfile @ main ******************************/