K1Guitar/project/src/main.c

170 lines
4.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* add user code begin Header */
/**
**************************************************************************
* @file main.c
* @brief main program
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
*
**************************************************************************
*/
/* add user code end Header */
/* Includes ------------------------------------------------------------------*/
#include "includes.h"
/* private includes ----------------------------------------------------------*/
/* add user code begin private includes */
/* add user code end private includes */
/* private typedef -----------------------------------------------------------*/
/* add user code begin private typedef */
/* add user code end private typedef */
/* private define ------------------------------------------------------------*/
/* add user code begin private define */
/* add user code end private define */
/* private macro -------------------------------------------------------------*/
/* add user code begin private macro */
/* add user code end private macro */
/* private variables ---------------------------------------------------------*/
/* add user code begin private variables */
/* add user code end private variables */
/* private function prototypes --------------------------------------------*/
/* add user code begin function prototypes */
void bsp_init(void);
/* add user code end function prototypes */
/* private user code ---------------------------------------------------------*/
/* add user code begin 0 */
/* add user code end 0 */
/**
* @brief main function.
* @param none
* @retval none
*/
int main(void)
{
/* add user code begin 1 */
/* add user code end 1 */
/* system clock config. */
wk_system_clock_config();
/* config periph clock. */
wk_periph_clock_config();
/* add user code begin 2 */
bsp_init();
BSP_MainPowerEnable(1);
LCD_Init();
LCD_Dump_Init();
app_log_init();
drv_nvm_init();
TaskInit();
timer_init();
/* 关机键看门狗:TMR7 + HardFault hook,与主循环/伴奏 ISR 解耦 */
Power_Key_WatchdogInit();
InitMenuUI();
/* GPIO 默认会拉高蓝牙和 12V。关机充电前先全部关掉,只留主电给屏幕 */
BSP_DreamCorePowerEnable(0);
BSP_HT7178PowerEnable(0);
BSP_BlueToothPowerEnable(0);
BSP_ChargerEnable(1);
Power_LogRails("boot");
CurrUIProcress = IdleProcess;
LOG_I("BOOT", "main init done ui=Idle");
/* add user code end 2 */
while(1)
{
if(!powon)
{
app_adc_in1_scan_part(4);
app_adc_in1_scan_part(7);
}
/* add user code begin 3 */
Power_Key_Scan();
System_AudioBringUp_Poll();
Power_ChargeIdle_LogPoll();
AutoPowerOff_Scan();
System_PowerOff_Poll();
System_LowBat_Poll();
LCD_Dump_Poll();
#if !DEBUG_LCD_DUMP
app_log_poll();
TP_LivePoll();
#endif
rt_thread_delay(1);
/* add user code end 3 */
}
}
/* add user code begin 4 */
void bsp_init(void)
{
/* init debug function. */
wk_debug_config();
/* nvic config. */
wk_nvic_config();
/* timebase config. */
wk_timebase_init();
/* TMR6 1ms 硬件定时器(独立于 SysTick 的时间基准) */
wk_tmr6_1ms_init();
/* init dma1 channel1 */
/* config dma channel transfer parameter */
/* user need to modify define values DMAx_CHANNELy_XXX_BASE_ADDR and DMAx_CHANNELy_BUFFER_SIZE in at32xxx_wk_config.h */
/* init usart2 function. */
wk_usart2_init();
/* init uart4 function. */
wk_uart4_init();
/* init spi1 function. */
wk_spi1_init();
W25Q128_Init();
/* init adc1 function. */
wk_adc1_init();
/* init acc function. */
wk_acc_init();
/* init usbfs function. */
wk_usbfs_init();
/* init gpio function. */
wk_gpio_config();
}
/* add user code end 4 */