feat: 开启定时器和串口接收中断
This commit is contained in:
35
BC1C.ATWP
35
BC1C.ATWP
@@ -20,9 +20,9 @@
|
|||||||
</Mode>
|
</Mode>
|
||||||
<Parameters>
|
<Parameters>
|
||||||
<ParametersSub name="BaudRate" value="500"/>
|
<ParametersSub name="BaudRate" value="500"/>
|
||||||
<ParametersSub name="Sample_Point" value="87.5"/>
|
<ParametersSub name="Sample_Point" value="90.0"/>
|
||||||
<ParametersSub name="BaudRate_Division" value="30"/>
|
<ParametersSub name="BaudRate_Division" value="24"/>
|
||||||
<ParametersSub name="BTS1" value="CAN_BTS1_6TQ"/>
|
<ParametersSub name="BTS1" value="CAN_BTS1_8TQ"/>
|
||||||
<ParametersSub name="BTS2" value="CAN_BTS2_1TQ"/>
|
<ParametersSub name="BTS2" value="CAN_BTS2_1TQ"/>
|
||||||
<ParametersSub name="RSAW" value="CAN_RSAW_1TQ"/>
|
<ParametersSub name="RSAW" value="CAN_RSAW_1TQ"/>
|
||||||
</Parameters>
|
</Parameters>
|
||||||
@@ -33,9 +33,9 @@
|
|||||||
</Mode>
|
</Mode>
|
||||||
<Parameters>
|
<Parameters>
|
||||||
<ParametersSub name="BaudRate" value="500"/>
|
<ParametersSub name="BaudRate" value="500"/>
|
||||||
<ParametersSub name="Sample_Point" value="87.5"/>
|
<ParametersSub name="Sample_Point" value="90.0"/>
|
||||||
<ParametersSub name="BaudRate_Division" value="30"/>
|
<ParametersSub name="BaudRate_Division" value="24"/>
|
||||||
<ParametersSub name="BTS1" value="CAN_BTS1_6TQ"/>
|
<ParametersSub name="BTS1" value="CAN_BTS1_8TQ"/>
|
||||||
<ParametersSub name="BTS2" value="CAN_BTS2_1TQ"/>
|
<ParametersSub name="BTS2" value="CAN_BTS2_1TQ"/>
|
||||||
<ParametersSub name="RSAW" value="CAN_RSAW_1TQ"/>
|
<ParametersSub name="RSAW" value="CAN_RSAW_1TQ"/>
|
||||||
</Parameters>
|
</Parameters>
|
||||||
@@ -71,11 +71,15 @@
|
|||||||
<ParametersSub name="GeneralCallMode" value="FALSE"/>
|
<ParametersSub name="GeneralCallMode" value="FALSE"/>
|
||||||
</Parameters>
|
</Parameters>
|
||||||
</I2C2>
|
</I2C2>
|
||||||
<PWC>
|
<TMR6>
|
||||||
<Mode>
|
<Mode>
|
||||||
<ModeSub name="Voltage-Monitoring" value="TRUE"/>
|
<ModeSub name="Activated" value="TRUE"/>
|
||||||
</Mode>
|
</Mode>
|
||||||
</PWC>
|
<Parameters>
|
||||||
|
<ParametersSub name="DividerValue" value="4999"/>
|
||||||
|
<ParametersSub name="Period" value="47999"/>
|
||||||
|
</Parameters>
|
||||||
|
</TMR6>
|
||||||
<TMR8>
|
<TMR8>
|
||||||
<Mode>
|
<Mode>
|
||||||
<ModeSub name="Channel1 mode" value="Output_CH1"/>
|
<ModeSub name="Channel1 mode" value="Output_CH1"/>
|
||||||
@@ -128,13 +132,14 @@
|
|||||||
<I2C1_ERR_IRQHandler>0;0;0</I2C1_ERR_IRQHandler>
|
<I2C1_ERR_IRQHandler>0;0;0</I2C1_ERR_IRQHandler>
|
||||||
<I2C2_EVT_IRQHandler>0;0;0</I2C2_EVT_IRQHandler>
|
<I2C2_EVT_IRQHandler>0;0;0</I2C2_EVT_IRQHandler>
|
||||||
<I2C2_ERR_IRQHandler>0;0;0</I2C2_ERR_IRQHandler>
|
<I2C2_ERR_IRQHandler>0;0;0</I2C2_ERR_IRQHandler>
|
||||||
<USART1_IRQHandler>0;0;0</USART1_IRQHandler>
|
<USART1_IRQHandler>1;1;0</USART1_IRQHandler>
|
||||||
<USART2_IRQHandler>0;0;0</USART2_IRQHandler>
|
<USART2_IRQHandler>1;1;0</USART2_IRQHandler>
|
||||||
<USART3_IRQHandler>0;0;0</USART3_IRQHandler>
|
<USART3_IRQHandler>1;1;0</USART3_IRQHandler>
|
||||||
<TMR8_BRK_TMR12_IRQHandler>0;0;0</TMR8_BRK_TMR12_IRQHandler>
|
<TMR8_BRK_TMR12_IRQHandler>0;0;0</TMR8_BRK_TMR12_IRQHandler>
|
||||||
<TMR8_OVF_TMR13_IRQHandler>0;0;0</TMR8_OVF_TMR13_IRQHandler>
|
<TMR8_OVF_TMR13_IRQHandler>0;0;0</TMR8_OVF_TMR13_IRQHandler>
|
||||||
<TMR8_TRG_HALL_TMR14_IRQHandler>0;0;0</TMR8_TRG_HALL_TMR14_IRQHandler>
|
<TMR8_TRG_HALL_TMR14_IRQHandler>0;0;0</TMR8_TRG_HALL_TMR14_IRQHandler>
|
||||||
<TMR8_CH_IRQHandler>0;0;0</TMR8_CH_IRQHandler>
|
<TMR8_CH_IRQHandler>0;0;0</TMR8_CH_IRQHandler>
|
||||||
|
<TMR6_GLOBAL_IRQHandler>1;0;0</TMR6_GLOBAL_IRQHandler>
|
||||||
<CAN2_TX_IRQHandler>0;0;0</CAN2_TX_IRQHandler>
|
<CAN2_TX_IRQHandler>0;0;0</CAN2_TX_IRQHandler>
|
||||||
<CAN2_RX0_IRQHandler>0;0;0</CAN2_RX0_IRQHandler>
|
<CAN2_RX0_IRQHandler>0;0;0</CAN2_RX0_IRQHandler>
|
||||||
<CAN2_RX1_IRQHandler>0;0;0</CAN2_RX1_IRQHandler>
|
<CAN2_RX1_IRQHandler>0;0;0</CAN2_RX1_IRQHandler>
|
||||||
@@ -205,9 +210,7 @@
|
|||||||
<KeepUserCode>true</KeepUserCode>
|
<KeepUserCode>true</KeepUserCode>
|
||||||
<MinHeapSize>0x200</MinHeapSize>
|
<MinHeapSize>0x200</MinHeapSize>
|
||||||
<MinStackSize>0x400</MinStackSize>
|
<MinStackSize>0x400</MinStackSize>
|
||||||
<UseFirmware>true</UseFirmware>
|
<UseFirmware>false</UseFirmware>
|
||||||
<UseFirmwareZip>true</UseFirmwareZip>
|
<PackageVersion></PackageVersion>
|
||||||
<FirmwarePath>C:/Users/ForgotDoge/Desktop/AT32_Work_Bench_V1.0.03/AT32F403A_407_Firmware_Library_V2.1.8.zip</FirmwarePath>
|
|
||||||
<FirmwareFolderPath></FirmwareFolderPath>
|
|
||||||
</ProjectInfomation>
|
</ProjectInfomation>
|
||||||
</Root>
|
</Root>
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ extern "C" {
|
|||||||
#define DEBUG_MODULE_ENABLED
|
#define DEBUG_MODULE_ENABLED
|
||||||
/*#define DMA_MODULE_ENABLED----------------------*/
|
/*#define DMA_MODULE_ENABLED----------------------*/
|
||||||
/*#define EMAC_MODULE_ENABLED---------------------*/
|
/*#define EMAC_MODULE_ENABLED---------------------*/
|
||||||
#define EXINT_MODULE_ENABLED
|
/*#define EXINT_MODULE_ENABLED--------------------*/
|
||||||
#define FLASH_MODULE_ENABLED
|
#define FLASH_MODULE_ENABLED
|
||||||
#define GPIO_MODULE_ENABLED
|
#define GPIO_MODULE_ENABLED
|
||||||
#define I2C_MODULE_ENABLED
|
#define I2C_MODULE_ENABLED
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ void SVC_Handler(void);
|
|||||||
void DebugMon_Handler(void);
|
void DebugMon_Handler(void);
|
||||||
void PendSV_Handler(void);
|
void PendSV_Handler(void);
|
||||||
|
|
||||||
|
void USART1_IRQHandler(void);
|
||||||
|
void USART2_IRQHandler(void);
|
||||||
|
void USART3_IRQHandler(void);
|
||||||
|
void TMR6_GLOBAL_IRQHandler(void);
|
||||||
/* add user code begin exported functions */
|
/* add user code begin exported functions */
|
||||||
|
|
||||||
/* add user code end exported functions */
|
/* add user code end exported functions */
|
||||||
|
|||||||
@@ -86,9 +86,6 @@ extern "C" {
|
|||||||
/* init can2 function. */
|
/* init can2 function. */
|
||||||
void wk_can2_init(void);
|
void wk_can2_init(void);
|
||||||
|
|
||||||
/* init pwc function. */
|
|
||||||
void wk_pwc_init(void);
|
|
||||||
|
|
||||||
/* init usart1 function. */
|
/* init usart1 function. */
|
||||||
void wk_usart1_init(void);
|
void wk_usart1_init(void);
|
||||||
|
|
||||||
@@ -98,6 +95,9 @@ extern "C" {
|
|||||||
/* init usart3 function. */
|
/* init usart3 function. */
|
||||||
void wk_usart3_init(void);
|
void wk_usart3_init(void);
|
||||||
|
|
||||||
|
/* init tmr6 function. */
|
||||||
|
void wk_tmr6_init(void);
|
||||||
|
|
||||||
/* init tmr8 function. */
|
/* init tmr8 function. */
|
||||||
void wk_tmr8_init(void);
|
void wk_tmr8_init(void);
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
/* private includes ----------------------------------------------------------*/
|
/* private includes ----------------------------------------------------------*/
|
||||||
/* add user code begin private includes */
|
/* add user code begin private includes */
|
||||||
|
#include "by_debug.h"
|
||||||
/* add user code end private includes */
|
/* add user code end private includes */
|
||||||
|
|
||||||
/* private typedef -----------------------------------------------------------*/
|
/* private typedef -----------------------------------------------------------*/
|
||||||
@@ -94,8 +94,7 @@ void HardFault_Handler(void)
|
|||||||
|
|
||||||
/* add user code end HardFault_IRQ 0 */
|
/* add user code end HardFault_IRQ 0 */
|
||||||
/* go to infinite loop when hard fault exception occurs */
|
/* go to infinite loop when hard fault exception occurs */
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
/* add user code begin W1_HardFault_IRQ 0 */
|
/* add user code begin W1_HardFault_IRQ 0 */
|
||||||
|
|
||||||
/* add user code end W1_HardFault_IRQ 0 */
|
/* add user code end W1_HardFault_IRQ 0 */
|
||||||
@@ -113,8 +112,7 @@ void MemManage_Handler(void)
|
|||||||
|
|
||||||
/* add user code end MemoryManagement_IRQ 0 */
|
/* add user code end MemoryManagement_IRQ 0 */
|
||||||
/* go to infinite loop when memory manage exception occurs */
|
/* go to infinite loop when memory manage exception occurs */
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
/* add user code begin W1_MemoryManagement_IRQ 0 */
|
/* add user code begin W1_MemoryManagement_IRQ 0 */
|
||||||
|
|
||||||
/* add user code end W1_MemoryManagement_IRQ 0 */
|
/* add user code end W1_MemoryManagement_IRQ 0 */
|
||||||
@@ -132,8 +130,7 @@ void BusFault_Handler(void)
|
|||||||
|
|
||||||
/* add user code end BusFault_IRQ 0 */
|
/* add user code end BusFault_IRQ 0 */
|
||||||
/* go to infinite loop when bus fault exception occurs */
|
/* go to infinite loop when bus fault exception occurs */
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
/* add user code begin W1_BusFault_IRQ 0 */
|
/* add user code begin W1_BusFault_IRQ 0 */
|
||||||
|
|
||||||
/* add user code end W1_BusFault_IRQ 0 */
|
/* add user code end W1_BusFault_IRQ 0 */
|
||||||
@@ -151,8 +148,7 @@ void UsageFault_Handler(void)
|
|||||||
|
|
||||||
/* add user code end UsageFault_IRQ 0 */
|
/* add user code end UsageFault_IRQ 0 */
|
||||||
/* go to infinite loop when usage fault exception occurs */
|
/* go to infinite loop when usage fault exception occurs */
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
/* add user code begin W1_UsageFault_IRQ 0 */
|
/* add user code begin W1_UsageFault_IRQ 0 */
|
||||||
|
|
||||||
/* add user code end W1_UsageFault_IRQ 0 */
|
/* add user code end W1_UsageFault_IRQ 0 */
|
||||||
@@ -204,6 +200,72 @@ void PendSV_Handler(void)
|
|||||||
/* add user code end PendSV_IRQ 1 */
|
/* add user code end PendSV_IRQ 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles USART1 handler.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void USART1_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* add user code begin USART1_IRQ 0 */
|
||||||
|
|
||||||
|
/* add user code end USART1_IRQ 0 */
|
||||||
|
/* add user code begin USART1_IRQ 1 */
|
||||||
|
|
||||||
|
/* add user code end USART1_IRQ 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles USART2 handler.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void USART2_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* add user code begin USART2_IRQ 0 */
|
||||||
|
if (SET == usart_flag_get(USART2, USART_RDBF_FLAG)) {
|
||||||
|
usart_data_receive(USART2);
|
||||||
|
usart_flag_clear(USART2, USART_RDBF_FLAG);
|
||||||
|
}
|
||||||
|
/* add user code end USART2_IRQ 0 */
|
||||||
|
/* add user code begin USART2_IRQ 1 */
|
||||||
|
|
||||||
|
/* add user code end USART2_IRQ 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles USART3 handler.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void USART3_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* add user code begin USART3_IRQ 0 */
|
||||||
|
|
||||||
|
/* add user code end USART3_IRQ 0 */
|
||||||
|
/* add user code begin USART3_IRQ 1 */
|
||||||
|
|
||||||
|
/* add user code end USART3_IRQ 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this function handles TMR6 handler.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void TMR6_GLOBAL_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* add user code begin TMR6_GLOBAL_IRQ 0 */
|
||||||
|
static uint64_t i = 0;
|
||||||
|
if (SET == tmr_flag_get(TMR6, TMR_OVF_FLAG)) {
|
||||||
|
tmr_flag_clear(TMR6, TMR_OVF_FLAG);
|
||||||
|
}
|
||||||
|
/* add user code end TMR6_GLOBAL_IRQ 0 */
|
||||||
|
/* add user code begin TMR6_GLOBAL_IRQ 1 */
|
||||||
|
|
||||||
|
/* add user code end TMR6_GLOBAL_IRQ 1 */
|
||||||
|
}
|
||||||
|
|
||||||
/* add user code begin 1 */
|
/* add user code begin 1 */
|
||||||
|
|
||||||
/* add user code end 1 */
|
/* add user code end 1 */
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
* @brief system clock config program
|
* @brief system clock config program
|
||||||
* @note the system clock is configured as follow:
|
* @note the system clock is configured as follow:
|
||||||
* system clock (sclk) = hick / 12 * pll_mult
|
* system clock (sclk) = hick / 12 * pll_mult
|
||||||
* system clock source = pll (hick)
|
* system clock source = HICK_VALUE
|
||||||
* - hext = HEXT_VALUE
|
* - hext = HEXT_VALUE
|
||||||
* - sclk = 240000000
|
* - sclk = 240000000
|
||||||
* - ahbdiv = 1
|
* - ahbdiv = 1
|
||||||
@@ -88,24 +88,21 @@ void wk_system_clock_config(void)
|
|||||||
crm_clock_source_enable(CRM_CLOCK_SOURCE_LICK, TRUE);
|
crm_clock_source_enable(CRM_CLOCK_SOURCE_LICK, TRUE);
|
||||||
|
|
||||||
/* wait till lick is ready */
|
/* wait till lick is ready */
|
||||||
while(crm_flag_get(CRM_LICK_STABLE_FLAG) != SET)
|
while (crm_flag_get(CRM_LICK_STABLE_FLAG) != SET) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enable hext */
|
/* enable hext */
|
||||||
crm_clock_source_enable(CRM_CLOCK_SOURCE_HEXT, TRUE);
|
crm_clock_source_enable(CRM_CLOCK_SOURCE_HEXT, TRUE);
|
||||||
|
|
||||||
/* wait till hext is ready */
|
/* wait till hext is ready */
|
||||||
while(crm_hext_stable_wait() == ERROR)
|
while (crm_hext_stable_wait() == ERROR) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enable hick */
|
/* enable hick */
|
||||||
crm_clock_source_enable(CRM_CLOCK_SOURCE_HICK, TRUE);
|
crm_clock_source_enable(CRM_CLOCK_SOURCE_HICK, TRUE);
|
||||||
|
|
||||||
/* wait till hick is ready */
|
/* wait till hick is ready */
|
||||||
while(crm_flag_get(CRM_HICK_STABLE_FLAG) != SET)
|
while (crm_flag_get(CRM_HICK_STABLE_FLAG) != SET) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* config pll clock resource */
|
/* config pll clock resource */
|
||||||
@@ -115,8 +112,7 @@ void wk_system_clock_config(void)
|
|||||||
crm_clock_source_enable(CRM_CLOCK_SOURCE_PLL, TRUE);
|
crm_clock_source_enable(CRM_CLOCK_SOURCE_PLL, TRUE);
|
||||||
|
|
||||||
/* wait till pll is ready */
|
/* wait till pll is ready */
|
||||||
while(crm_flag_get(CRM_PLL_STABLE_FLAG) != SET)
|
while (crm_flag_get(CRM_PLL_STABLE_FLAG) != SET) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* config ahbclk */
|
/* config ahbclk */
|
||||||
@@ -135,8 +131,7 @@ void wk_system_clock_config(void)
|
|||||||
crm_sysclk_switch(CRM_SCLK_PLL);
|
crm_sysclk_switch(CRM_SCLK_PLL);
|
||||||
|
|
||||||
/* wait till pll is used as system clock source */
|
/* wait till pll is used as system clock source */
|
||||||
while(crm_sysclk_switch_status_get() != CRM_SCLK_PLL)
|
while (crm_sysclk_switch_status_get() != CRM_SCLK_PLL) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disable auto step mode */
|
/* disable auto step mode */
|
||||||
@@ -180,6 +175,9 @@ void wk_periph_clock_config(void)
|
|||||||
/* enable tmr11 periph clock */
|
/* enable tmr11 periph clock */
|
||||||
crm_periph_clock_enable(CRM_TMR11_PERIPH_CLOCK, TRUE);
|
crm_periph_clock_enable(CRM_TMR11_PERIPH_CLOCK, TRUE);
|
||||||
|
|
||||||
|
/* enable tmr6 periph clock */
|
||||||
|
crm_periph_clock_enable(CRM_TMR6_PERIPH_CLOCK, TRUE);
|
||||||
|
|
||||||
/* enable tmr12 periph clock */
|
/* enable tmr12 periph clock */
|
||||||
crm_periph_clock_enable(CRM_TMR12_PERIPH_CLOCK, TRUE);
|
crm_periph_clock_enable(CRM_TMR12_PERIPH_CLOCK, TRUE);
|
||||||
|
|
||||||
@@ -200,9 +198,6 @@ void wk_periph_clock_config(void)
|
|||||||
|
|
||||||
/* enable can2 periph clock */
|
/* enable can2 periph clock */
|
||||||
crm_periph_clock_enable(CRM_CAN2_PERIPH_CLOCK, TRUE);
|
crm_periph_clock_enable(CRM_CAN2_PERIPH_CLOCK, TRUE);
|
||||||
|
|
||||||
/* enable pwc periph clock */
|
|
||||||
crm_periph_clock_enable(CRM_PWC_PERIPH_CLOCK, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -224,6 +219,11 @@ void wk_debug_config(void)
|
|||||||
void wk_nvic_config(void)
|
void wk_nvic_config(void)
|
||||||
{
|
{
|
||||||
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
|
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
|
||||||
|
|
||||||
|
nvic_irq_enable(USART1_IRQn, 1, 0);
|
||||||
|
nvic_irq_enable(USART2_IRQn, 1, 0);
|
||||||
|
nvic_irq_enable(USART3_IRQn, 1, 0);
|
||||||
|
nvic_irq_enable(TMR6_GLOBAL_IRQn, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,9 +233,17 @@ void wk_nvic_config(void)
|
|||||||
*/
|
*/
|
||||||
void wk_gpio_config(void)
|
void wk_gpio_config(void)
|
||||||
{
|
{
|
||||||
|
/* add user code begin gpio_config 0 */
|
||||||
|
|
||||||
|
/* add user code end gpio_config 0 */
|
||||||
|
|
||||||
gpio_init_type gpio_init_struct;
|
gpio_init_type gpio_init_struct;
|
||||||
gpio_default_para_init(&gpio_init_struct);
|
gpio_default_para_init(&gpio_init_struct);
|
||||||
|
|
||||||
|
/* add user code begin gpio_config 1 */
|
||||||
|
|
||||||
|
/* add user code end gpio_config 1 */
|
||||||
|
|
||||||
/* gpio input config */
|
/* gpio input config */
|
||||||
gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
|
gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
|
||||||
gpio_init_struct.gpio_pins = GPIO_PINS_4 | GPIO_PINS_5 | GPIO_PINS_6 | GPIO_PINS_7;
|
gpio_init_struct.gpio_pins = GPIO_PINS_4 | GPIO_PINS_5 | GPIO_PINS_6 | GPIO_PINS_7;
|
||||||
@@ -261,6 +269,10 @@ void wk_gpio_config(void)
|
|||||||
gpio_init_struct.gpio_pins = GPIO_PINS_0 | GPIO_PINS_1 | GPIO_PINS_2 | GPIO_PINS_3;
|
gpio_init_struct.gpio_pins = GPIO_PINS_0 | GPIO_PINS_1 | GPIO_PINS_2 | GPIO_PINS_3;
|
||||||
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
||||||
gpio_init(GPIOC, &gpio_init_struct);
|
gpio_init(GPIOC, &gpio_init_struct);
|
||||||
|
|
||||||
|
/* add user code begin gpio_config 2 */
|
||||||
|
|
||||||
|
/* add user code end gpio_config 2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -359,44 +371,6 @@ void wk_i2c2_init(void)
|
|||||||
/* add user code end i2c2_init 2 */
|
/* add user code end i2c2_init 2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief init pwc function.
|
|
||||||
* @param none
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
void wk_pwc_init(void)
|
|
||||||
{
|
|
||||||
/* add user code begin pwc_init 0 */
|
|
||||||
|
|
||||||
/* add user code end pwc_init 0 */
|
|
||||||
|
|
||||||
exint_init_type exint_init_struct;
|
|
||||||
|
|
||||||
/* add user code begin pwc_init 1 */
|
|
||||||
|
|
||||||
/* add user code end pwc_init 1 */
|
|
||||||
|
|
||||||
/* enable power voltage monitor */
|
|
||||||
pwc_power_voltage_monitor_enable(TRUE);
|
|
||||||
|
|
||||||
exint_default_para_init(&exint_init_struct);
|
|
||||||
exint_init_struct.line_enable = TRUE;
|
|
||||||
exint_init_struct.line_mode = EXINT_LINE_INTERRUPUT;
|
|
||||||
exint_init_struct.line_select = EXINT_LINE_16;
|
|
||||||
exint_init_struct.line_polarity = EXINT_TRIGGER_RISING_EDGE;
|
|
||||||
exint_init(&exint_init_struct);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Users need to configure PWC interrupt functions according to the actual application.
|
|
||||||
* 1. Add the user's interrupt handler code into the below function in the at32f403a_407_int.c file.
|
|
||||||
* --void PVM_IRQHandler (void)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* add user code begin pwc_init 2 */
|
|
||||||
|
|
||||||
/* add user code end pwc_init 2 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief init usart1 function
|
* @brief init usart1 function
|
||||||
* @param none
|
* @param none
|
||||||
@@ -439,6 +413,14 @@ void wk_usart1_init(void)
|
|||||||
|
|
||||||
usart_hardware_flow_control_set(USART1, USART_HARDWARE_FLOW_NONE);
|
usart_hardware_flow_control_set(USART1, USART_HARDWARE_FLOW_NONE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Users need to configure USART1 interrupt functions according to the actual application.
|
||||||
|
* 1. Call the below function to enable the corresponding USART1 interrupt.
|
||||||
|
* --usart_interrupt_enable(...)
|
||||||
|
* 2. Add the user's interrupt handler code into the below function in the at32f403a_407_int.c file.
|
||||||
|
* --void USART1_IRQHandler(void)
|
||||||
|
*/
|
||||||
|
|
||||||
usart_enable(USART1, TRUE);
|
usart_enable(USART1, TRUE);
|
||||||
|
|
||||||
/* add user code begin usart1_init 2 */
|
/* add user code begin usart1_init 2 */
|
||||||
@@ -488,10 +470,18 @@ void wk_usart2_init(void)
|
|||||||
|
|
||||||
usart_hardware_flow_control_set(USART2, USART_HARDWARE_FLOW_NONE);
|
usart_hardware_flow_control_set(USART2, USART_HARDWARE_FLOW_NONE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Users need to configure USART2 interrupt functions according to the actual application.
|
||||||
|
* 1. Call the below function to enable the corresponding USART2 interrupt.
|
||||||
|
* --usart_interrupt_enable(...)
|
||||||
|
* 2. Add the user's interrupt handler code into the below function in the at32f403a_407_int.c file.
|
||||||
|
* --void USART2_IRQHandler(void)
|
||||||
|
*/
|
||||||
|
|
||||||
usart_enable(USART2, TRUE);
|
usart_enable(USART2, TRUE);
|
||||||
|
|
||||||
/* add user code begin usart2_init 2 */
|
/* add user code begin usart2_init 2 */
|
||||||
|
usart_interrupt_enable(USART2, USART_RDBF_INT, TRUE);
|
||||||
/* add user code end usart2_init 2 */
|
/* add user code end usart2_init 2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,6 +529,14 @@ void wk_usart3_init(void)
|
|||||||
|
|
||||||
usart_hardware_flow_control_set(USART3, USART_HARDWARE_FLOW_NONE);
|
usart_hardware_flow_control_set(USART3, USART_HARDWARE_FLOW_NONE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Users need to configure USART3 interrupt functions according to the actual application.
|
||||||
|
* 1. Call the below function to enable the corresponding USART3 interrupt.
|
||||||
|
* --usart_interrupt_enable(...)
|
||||||
|
* 2. Add the user's interrupt handler code into the below function in the at32f403a_407_int.c file.
|
||||||
|
* --void USART3_IRQHandler(void)
|
||||||
|
*/
|
||||||
|
|
||||||
usart_enable(USART3, TRUE);
|
usart_enable(USART3, TRUE);
|
||||||
|
|
||||||
/* add user code begin usart3_init 2 */
|
/* add user code begin usart3_init 2 */
|
||||||
@@ -546,6 +544,44 @@ void wk_usart3_init(void)
|
|||||||
/* add user code end usart3_init 2 */
|
/* add user code end usart3_init 2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief init tmr6 function.
|
||||||
|
* @param none
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void wk_tmr6_init(void)
|
||||||
|
{
|
||||||
|
/* add user code begin tmr6_init 0 */
|
||||||
|
|
||||||
|
/* add user code end tmr6_init 0 */
|
||||||
|
|
||||||
|
/* add user code begin tmr6_init 1 */
|
||||||
|
|
||||||
|
/* add user code end tmr6_init 1 */
|
||||||
|
|
||||||
|
/* configure counter settings */
|
||||||
|
tmr_base_init(TMR6, 47999, 4999);
|
||||||
|
tmr_cnt_dir_set(TMR6, TMR_COUNT_UP);
|
||||||
|
tmr_period_buffer_enable(TMR6, FALSE);
|
||||||
|
|
||||||
|
/* configure primary mode settings */
|
||||||
|
tmr_primary_mode_select(TMR6, TMR_PRIMARY_SEL_RESET);
|
||||||
|
|
||||||
|
tmr_counter_enable(TMR6, TRUE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Users need to configure TMR6 interrupt functions according to the actual application.
|
||||||
|
* 1. Call the below function to enable the corresponding TMR6 interrupt.
|
||||||
|
* --tmr_interrupt_enable(...)
|
||||||
|
* 2. Add the user's interrupt handler code into the below function in the at32f403a_407_int.c file.
|
||||||
|
* --void TMR6_GLOBAL_IRQHandler(void)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* add user code begin tmr6_init 2 */
|
||||||
|
tmr_interrupt_enable(TMR6, TMR_OVF_INT, TRUE);
|
||||||
|
/* add user code end tmr6_init 2 */
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief init tmr8 function.
|
* @brief init tmr8 function.
|
||||||
* @param none
|
* @param none
|
||||||
@@ -668,7 +704,6 @@ void wk_tmr8_init(void)
|
|||||||
tmr_brkdt_struct.deadtime = 0;
|
tmr_brkdt_struct.deadtime = 0;
|
||||||
tmr_brkdt_config(TMR8, &tmr_brkdt_struct);
|
tmr_brkdt_config(TMR8, &tmr_brkdt_struct);
|
||||||
|
|
||||||
|
|
||||||
tmr_output_enable(TMR8, TRUE);
|
tmr_output_enable(TMR8, TRUE);
|
||||||
|
|
||||||
tmr_counter_enable(TMR8, TRUE);
|
tmr_counter_enable(TMR8, TRUE);
|
||||||
@@ -855,9 +890,9 @@ void wk_can1_init(void)
|
|||||||
|
|
||||||
/*can_baudrate_setting-------------------------------------------------------------*/
|
/*can_baudrate_setting-------------------------------------------------------------*/
|
||||||
/*set baudrate = pclk/(baudrate_div *(1 + bts1_size + bts2_size))------------------*/
|
/*set baudrate = pclk/(baudrate_div *(1 + bts1_size + bts2_size))------------------*/
|
||||||
can_baudrate_struct.baudrate_div = 30; /*value: 1~0xFFF*/
|
can_baudrate_struct.baudrate_div = 24; /*value: 1~0xFFF*/
|
||||||
can_baudrate_struct.rsaw_size = CAN_RSAW_1TQ; /*value: 1~4*/
|
can_baudrate_struct.rsaw_size = CAN_RSAW_1TQ; /*value: 1~4*/
|
||||||
can_baudrate_struct.bts1_size = CAN_BTS1_6TQ; /*value: 1~16*/
|
can_baudrate_struct.bts1_size = CAN_BTS1_8TQ; /*value: 1~16*/
|
||||||
can_baudrate_struct.bts2_size = CAN_BTS2_1TQ; /*value: 1~8*/
|
can_baudrate_struct.bts2_size = CAN_BTS2_1TQ; /*value: 1~8*/
|
||||||
can_baudrate_set(CAN1, &can_baudrate_struct);
|
can_baudrate_set(CAN1, &can_baudrate_struct);
|
||||||
|
|
||||||
@@ -933,9 +968,9 @@ void wk_can2_init(void)
|
|||||||
|
|
||||||
/*can_baudrate_setting-------------------------------------------------------------*/
|
/*can_baudrate_setting-------------------------------------------------------------*/
|
||||||
/*set baudrate = pclk/(baudrate_div *(1 + bts1_size + bts2_size))------------------*/
|
/*set baudrate = pclk/(baudrate_div *(1 + bts1_size + bts2_size))------------------*/
|
||||||
can_baudrate_struct.baudrate_div = 30; /*value: 1~0xFFF*/
|
can_baudrate_struct.baudrate_div = 24; /*value: 1~0xFFF*/
|
||||||
can_baudrate_struct.rsaw_size = CAN_RSAW_1TQ; /*value: 1~4*/
|
can_baudrate_struct.rsaw_size = CAN_RSAW_1TQ; /*value: 1~4*/
|
||||||
can_baudrate_struct.bts1_size = CAN_BTS1_6TQ; /*value: 1~16*/
|
can_baudrate_struct.bts1_size = CAN_BTS1_8TQ; /*value: 1~16*/
|
||||||
can_baudrate_struct.bts2_size = CAN_BTS2_1TQ; /*value: 1~8*/
|
can_baudrate_struct.bts2_size = CAN_BTS2_1TQ; /*value: 1~8*/
|
||||||
can_baudrate_set(CAN2, &can_baudrate_struct);
|
can_baudrate_set(CAN2, &can_baudrate_struct);
|
||||||
|
|
||||||
@@ -1008,9 +1043,11 @@ void wk_adc1_init(void)
|
|||||||
|
|
||||||
/* adc calibration-------------------------------------------------------- */
|
/* adc calibration-------------------------------------------------------- */
|
||||||
adc_calibration_init(ADC1);
|
adc_calibration_init(ADC1);
|
||||||
while(adc_calibration_init_status_get(ADC1));
|
while (adc_calibration_init_status_get(ADC1))
|
||||||
|
;
|
||||||
adc_calibration_start(ADC1);
|
adc_calibration_start(ADC1);
|
||||||
while(adc_calibration_status_get(ADC1));
|
while (adc_calibration_status_get(ADC1))
|
||||||
|
;
|
||||||
|
|
||||||
/* add user code begin adc1_init 2 */
|
/* add user code begin adc1_init 2 */
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "at32f403a_407_wk_config.h"
|
#include "at32f403a_407_wk_config.h"
|
||||||
|
|
||||||
/* private includes ----------------------------------------------------------*/
|
/* private includes ----------------------------------------------------------*/
|
||||||
/* add user code begin private includes */
|
/* add user code begin private includes */
|
||||||
#include "dwt_delay.h"
|
#include "dwt_delay.h"
|
||||||
@@ -71,7 +72,7 @@
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
/* add user code begin 1 */
|
/* add user code begin 1 */
|
||||||
|
by_debug_init();
|
||||||
/* add user code end 1 */
|
/* add user code end 1 */
|
||||||
|
|
||||||
/* system clock config. */
|
/* system clock config. */
|
||||||
@@ -83,9 +84,6 @@ int main(void)
|
|||||||
/* init debug function. */
|
/* init debug function. */
|
||||||
wk_debug_config();
|
wk_debug_config();
|
||||||
|
|
||||||
/* init pwc function. */
|
|
||||||
wk_pwc_init();
|
|
||||||
|
|
||||||
/* nvic config. */
|
/* nvic config. */
|
||||||
wk_nvic_config();
|
wk_nvic_config();
|
||||||
|
|
||||||
@@ -107,6 +105,9 @@ int main(void)
|
|||||||
/* init adc1 function. */
|
/* init adc1 function. */
|
||||||
wk_adc1_init();
|
wk_adc1_init();
|
||||||
|
|
||||||
|
/* init tmr6 function. */
|
||||||
|
wk_tmr6_init();
|
||||||
|
|
||||||
/* init tmr8 function. */
|
/* init tmr8 function. */
|
||||||
wk_tmr8_init();
|
wk_tmr8_init();
|
||||||
|
|
||||||
@@ -127,9 +128,9 @@ int main(void)
|
|||||||
|
|
||||||
/* add user code begin 2 */
|
/* add user code begin 2 */
|
||||||
DWT_Init();
|
DWT_Init();
|
||||||
by_debug_init();
|
|
||||||
/* add user code end 2 */
|
|
||||||
|
|
||||||
|
lwprintf("init done!\r\n");
|
||||||
|
/* add user code end 2 */
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* add user code begin 3 */
|
/* add user code begin 3 */
|
||||||
|
|||||||
Reference in New Issue
Block a user