Files
BC1C-firmware/project/src/main.c

162 lines
4.0 KiB
C
Raw Normal View History

2024-04-12 00:32:45 +08:00
/* 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 "at32f403a_407_wk_config.h"
2024-04-12 00:32:45 +08:00
/* private includes ----------------------------------------------------------*/
/* add user code begin private includes */
2024-04-13 00:05:19 +08:00
#include "dwt_delay.h"
#include "eeprom.h"
2024-04-13 00:05:19 +08:00
#include "by_debug.h"
#include "by_crc16.h"
#include "by_frame.h"
#include "by_messy.h"
#include "by_motion.h"
2024-04-12 00:32:45 +08:00
/* 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 */
/* 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
*/
2024-04-12 00:32:45 +08:00
int main(void)
{
2024-04-13 22:52:03 +08:00
/* add user code begin 1 */
by_debug_init();
/* add user code end 1 */
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* system clock config. */
wk_system_clock_config();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* config periph clock. */
wk_periph_clock_config();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* init debug function. */
wk_debug_config();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* nvic config. */
wk_nvic_config();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* init usart1 function. */
wk_usart1_init();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* init usart2 function. */
wk_usart2_init();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* init usart3 function. */
wk_usart3_init();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* init i2c1 function. */
wk_i2c1_init();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* init i2c2 function. */
wk_i2c2_init();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* init tmr6 function. */
wk_tmr6_init();
2024-04-13 22:52:03 +08:00
/* init tmr8 function. */
wk_tmr8_init();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* init tmr11 function. */
wk_tmr11_init();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* init tmr12 function. */
wk_tmr12_init();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* init can1 function. */
wk_can1_init();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* init can2 function. */
wk_can2_init();
2024-04-12 00:32:45 +08:00
/* init crc function. */
wk_crc_init();
2024-04-13 22:52:03 +08:00
/* init gpio function. */
wk_gpio_config();
2024-04-12 00:32:45 +08:00
2024-04-13 22:52:03 +08:00
/* add user code begin 2 */
/* dwt delay init */
2024-04-13 22:52:03 +08:00
DWT_Init();
LOGD("dwt init done");
/* simulative eeprom init */
flash_ee_init();
LOGD("eeprom init done");
/* motion init */
by_motion_init();
LOGD("motion init done");
/* messy init */
by_messy_init();
LOGD("frame init done");
LOGI("init done");
2024-04-13 00:05:19 +08:00
2024-04-13 22:52:03 +08:00
/* add user code end 2 */
2024-04-12 00:32:45 +08:00
while (1) {
2024-04-13 22:52:03 +08:00
/* add user code begin 3 */
by_messy_loop();
by_motion_loop();
2024-04-13 22:52:03 +08:00
/* add user code end 3 */
}
2024-04-12 00:32:45 +08:00
}