feat: 增加一些基础功能
This commit is contained in:
@@ -52,11 +52,11 @@ extern "C" {
|
||||
|
||||
/* module define -------------------------------------------------------------*/
|
||||
/*#define ADC_MODULE_ENABLED----------------------*/
|
||||
/*#define CAN_MODULE_ENABLED----------------------*/
|
||||
#define CAN_MODULE_ENABLED
|
||||
/*#define CMP_MODULE_ENABLED----------------------*/
|
||||
/*#define CRC_MODULE_ENABLED----------------------*/
|
||||
#define CRM_MODULE_ENABLED
|
||||
/*#define DEBUG_MODULE_ENABLED--------------------*/
|
||||
#define DEBUG_MODULE_ENABLED
|
||||
/*#define DMA_MODULE_ENABLED----------------------*/
|
||||
/*#define ERTC_MODULE_ENABLED---------------------*/
|
||||
/*#define EXINT_MODULE_ENABLED--------------------*/
|
||||
@@ -68,7 +68,7 @@ extern "C" {
|
||||
/*#define SDIO_MODULE_ENABLED---------------------*/
|
||||
/*#define SPI_MODULE_ENABLED----------------------*/
|
||||
#define TMR_MODULE_ENABLED
|
||||
/*#define USART_MODULE_ENABLED--------------------*/
|
||||
#define USART_MODULE_ENABLED
|
||||
/*#define USB_MODULE_ENABLED----------------------*/
|
||||
/*#define WDT_MODULE_ENABLED----------------------*/
|
||||
/*#define WWDT_MODULE_ENABLED---------------------*/
|
||||
|
||||
@@ -65,6 +65,7 @@ void SVC_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
|
||||
void CAN1_RX0_IRQHandler(void);
|
||||
|
||||
/* add user code begin exported functions */
|
||||
|
||||
|
||||
@@ -55,6 +55,65 @@ extern "C" {
|
||||
|
||||
/* add user code end exported macro */
|
||||
|
||||
/* add user code begin dma define */
|
||||
/* user can only modify the dma define value */
|
||||
//#define DMA1_CHANNEL1_BUFFER_SIZE 0
|
||||
//#define DMA1_CHANNEL1_MEMORY_BASE_ADDR 0
|
||||
//#define DMA1_CHANNEL1_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA1_CHANNEL2_BUFFER_SIZE 0
|
||||
//#define DMA1_CHANNEL2_MEMORY_BASE_ADDR 0
|
||||
//#define DMA1_CHANNEL2_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA1_CHANNEL3_BUFFER_SIZE 0
|
||||
//#define DMA1_CHANNEL3_MEMORY_BASE_ADDR 0
|
||||
//#define DMA1_CHANNEL3_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA1_CHANNEL4_BUFFER_SIZE 0
|
||||
//#define DMA1_CHANNEL4_MEMORY_BASE_ADDR 0
|
||||
//#define DMA1_CHANNEL4_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA1_CHANNEL5_BUFFER_SIZE 0
|
||||
//#define DMA1_CHANNEL5_MEMORY_BASE_ADDR 0
|
||||
//#define DMA1_CHANNEL5_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA1_CHANNEL6_BUFFER_SIZE 0
|
||||
//#define DMA1_CHANNEL6_MEMORY_BASE_ADDR 0
|
||||
//#define DMA1_CHANNEL6_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA1_CHANNEL7_BUFFER_SIZE 0
|
||||
//#define DMA1_CHANNEL7_MEMORY_BASE_ADDR 0
|
||||
//#define DMA1_CHANNEL7_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA2_CHANNEL1_BUFFER_SIZE 0
|
||||
//#define DMA2_CHANNEL1_MEMORY_BASE_ADDR 0
|
||||
//#define DMA2_CHANNEL1_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA2_CHANNEL2_BUFFER_SIZE 0
|
||||
//#define DMA2_CHANNEL2_MEMORY_BASE_ADDR 0
|
||||
//#define DMA2_CHANNEL2_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA2_CHANNEL3_BUFFER_SIZE 0
|
||||
//#define DMA2_CHANNEL3_MEMORY_BASE_ADDR 0
|
||||
//#define DMA2_CHANNEL3_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA2_CHANNEL4_BUFFER_SIZE 0
|
||||
//#define DMA2_CHANNEL4_MEMORY_BASE_ADDR 0
|
||||
//#define DMA2_CHANNEL4_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA2_CHANNEL5_BUFFER_SIZE 0
|
||||
//#define DMA2_CHANNEL5_MEMORY_BASE_ADDR 0
|
||||
//#define DMA2_CHANNEL5_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA2_CHANNEL6_BUFFER_SIZE 0
|
||||
//#define DMA2_CHANNEL6_MEMORY_BASE_ADDR 0
|
||||
//#define DMA2_CHANNEL6_PERIPHERAL_BASE_ADDR 0
|
||||
|
||||
//#define DMA2_CHANNEL7_BUFFER_SIZE 0
|
||||
//#define DMA2_CHANNEL7_MEMORY_BASE_ADDR 0
|
||||
//#define DMA2_CHANNEL7_PERIPHERAL_BASE_ADDR 0
|
||||
/* add user code end dma define */
|
||||
|
||||
/* exported functions ------------------------------------------------------- */
|
||||
/* system clock config. */
|
||||
void wk_system_clock_config(void);
|
||||
@@ -62,9 +121,21 @@ extern "C" {
|
||||
/* config periph clock. */
|
||||
void wk_periph_clock_config(void);
|
||||
|
||||
/* init debug function. */
|
||||
void wk_debug_config(void);
|
||||
|
||||
/* nvic config. */
|
||||
void wk_nvic_config(void);
|
||||
|
||||
/* init gpio function. */
|
||||
void wk_gpio_config(void);
|
||||
|
||||
/* init can1 function. */
|
||||
void wk_can1_init(void);
|
||||
|
||||
/* init usart2 function. */
|
||||
void wk_usart2_init(void);
|
||||
|
||||
/* init tmr1 function. */
|
||||
void wk_tmr1_init(void);
|
||||
|
||||
|
||||
35
project/inc/by_debug.h
Normal file
35
project/inc/by_debug.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef _BY_DEBUG_H__
|
||||
#define _BY_DEBUG_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include "at32f415.h"
|
||||
#include "lwprintf.h"
|
||||
|
||||
#define BY_DEBUG_USART_INDEX (USART2)
|
||||
|
||||
#define BY_DEBUG_LOG_MODE (2) // 0-not log, 1-no debug log, 2-all
|
||||
|
||||
#if (BY_DEBUG_LOG_MODE == 2)
|
||||
#define LOGI(format, ...) lwprintf("[INFO] " format "\r\n", ##__VA_ARGS__)
|
||||
#define LOGW(format, ...) lwprintf("[WARN] " format "\r\n", ##__VA_ARGS__)
|
||||
#define LOGE(format, ...) lwprintf("[ERR] " format "\r\n", ##__VA_ARGS__)
|
||||
#define LOGD(format, ...) lwprintf("[DEBUG] " format "\r\n", ##__VA_ARGS__)
|
||||
#elif (BY_DEBUG_LOG_MODE == 1)
|
||||
#define LOGI(format, ...) lwprintf("[INFO] " format "\r\n", ##__VA_ARGS__)
|
||||
#define LOGW(format, ...) lwprintf("[WARN] " format "\r\n", ##__VA_ARGS__)
|
||||
#define LOGE(format, ...) lwprintf("[ERR] " format "\r\n", ##__VA_ARGS__)
|
||||
#define LOGD(format, ...)
|
||||
#elif (BY_DEBUG_LOG_MODE == 0)
|
||||
#define LOGI(format, ...)
|
||||
#define LOGW(format, ...)
|
||||
#define LOGE(format, ...)
|
||||
#define LOGD(format, ...)
|
||||
#endif
|
||||
|
||||
extern void by_debug_init(void);
|
||||
extern void delay_init(void);
|
||||
extern void delay_us(uint32_t nus);
|
||||
extern void delay_ms(uint16_t nms);
|
||||
extern void delay_sec(uint16_t sec);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user