update version to v2.1.0

This commit is contained in:
Artery-MCU
2022-06-30 17:10:00 +08:00
parent c0f81f4b0d
commit 25f12a4ab3
2232 changed files with 79546 additions and 5346 deletions

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 header file
**************************************************************************
* Copyright notice & Disclaimer
@@ -96,8 +96,8 @@ extern "C" {
* @brief at32f403a_407 standard peripheral library version number
*/
#define __AT32F403A_407_LIBRARY_VERSION_MAJOR (0x02) /*!< [31:24] major version */
#define __AT32F403A_407_LIBRARY_VERSION_MIDDLE (0x00) /*!< [23:16] middle version */
#define __AT32F403A_407_LIBRARY_VERSION_MINOR (0x09) /*!< [15:8] minor version */
#define __AT32F403A_407_LIBRARY_VERSION_MIDDLE (0x01) /*!< [23:16] middle version */
#define __AT32F403A_407_LIBRARY_VERSION_MINOR (0x00) /*!< [15:8] minor version */
#define __AT32F403A_407_LIBRARY_VERSION_RC (0x00) /*!< [7:0] release candidate */
#define __AT32F403A_407_LIBRARY_VERSION ((__AT32F403A_407_LIBRARY_VERSION_MAJOR << 24) | \
(__AT32F403A_407_LIBRARY_VERSION_MIDDLE << 16) | \

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_conf.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 config header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
******************************************************************************
* @file startup_at32f403a_407.s
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407xx devices vector table for gcc toolchain.
* this module performs:
* - set the initial sp

View File

@@ -1,7 +1,7 @@
;**************************************************************************
;* @file startup_at32f403a_407.s
;* @version v2.0.9
;* @date 2022-04-25
;* @version v2.1.0
;* @date 2022-06-09
;* @brief at32f403a_407 startup file for IAR Systems
;**************************************************************************
;

View File

@@ -1,7 +1,7 @@
;**************************************************************************
;* @file startup_at32f403a_407.s
;* @version v2.0.9
;* @date 2022-04-25
;* @version v2.1.0
;* @date 2022-06-09
;* @brief at32f403a_407 startup file for keil
;**************************************************************************
;

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file system_at32f403a_407.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for cmsis cortex-m4 system source file
**************************************************************************
* Copyright notice & Disclaimer
@@ -81,13 +81,13 @@ void SystemInit (void)
/* wait sclk switch status */
while(CRM->cfg_bit.sclksts != CRM_SCLK_HICK);
/* reset hexten, hextbyps, cfden and pllen bits */
CRM->ctrl &= ~(0x010D0000U);
/* reset cfg register, include sclk switch, ahbdiv, apb1div, apb2div, adcdiv,
clkout pllrcs, pllhextdiv, pllmult, usbdiv and pllrange bits */
CRM->cfg = 0;
/* reset hexten, hextbyps, cfden and pllen bits */
CRM->ctrl &= ~(0x010D0000U);
/* reset clkout[3], usbbufs, hickdiv, clkoutdiv */
CRM->misc1 = 0;

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file system_at32f403a_407.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief cmsis cortex-m4 system header file.
**************************************************************************
* Copyright notice & Disclaimer
@@ -45,6 +45,7 @@ extern "C" {
#define HEXT_STABLE_DELAY (5000u)
#define PLL_STABLE_DELAY (500u)
#define SystemCoreClock system_core_clock
/**
* @}

View File

@@ -1,7 +1,7 @@
/******************************************************************************
* @file arm_sorting.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief Private header file for CMSIS DSP Library
******************************************************************************/
/*

View File

@@ -1,7 +1,7 @@
/******************************************************************************
* @file arm_vec_fft.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief Private header file for CMSIS DSP Library
******************************************************************************/
/*

View File

@@ -1,7 +1,7 @@
/******************************************************************************
* @file arm_vec_filtering.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief Private header file for CMSIS DSP Library
******************************************************************************/
/*

View File

@@ -1,7 +1,7 @@
/******************************************************************************
* @file arm_math.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief Public header file for CMSIS DSP Library
******************************************************************************/
/*

View File

@@ -1,7 +1,7 @@
/******************************************************************************
* @file arm_vec_math.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief Public header file for CMSIS DSP Library
******************************************************************************/
/*

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_acc.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 acc header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_adc.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 adc header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_bpr.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 bpr header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_can.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 can header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_crc.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 crc header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_crm.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 crm header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_dac.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 dac header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_debug.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 debug header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_def.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 macros header file
**************************************************************************
* Copyright notice & Disclaimer
@@ -62,6 +62,8 @@ extern "C" {
#endif
#endif
#define UNUSED(x) (void)x /* to avoid gcc/g++ warnings */
#ifdef __cplusplus
}
#endif

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_dma.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 dma header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_emac.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 emac header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_exint.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 exint header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_flash.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 flash header file
**************************************************************************
* Copyright notice & Disclaimer
@@ -705,7 +705,7 @@ error_status flash_slib_disable(uint32_t pwd);
uint32_t flash_slib_remaining_count_get(void);
flag_status flash_slib_state_get(void);
uint16_t flash_slib_start_sector_get(void);
uint16_t flash_slib_datstart_sector_get(void);
uint16_t flash_slib_datastart_sector_get(void);
uint16_t flash_slib_end_sector_get(void);
uint32_t flash_crc_calibrate(uint32_t start_sector, uint32_t sector_cnt);

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_gpio.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 gpio header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_i2c.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 i2c header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_misc.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 misc header file
**************************************************************************
* Copyright notice & Disclaimer
@@ -76,9 +76,9 @@ typedef enum
*/
typedef enum
{
NVIC_LP_SLEEPONEXIT = 0x02, /*!< send event on pending */
NVIC_LP_SLEEPONEXIT = 0x02, /*!< enable sleep-on-exit feature */
NVIC_LP_SLEEPDEEP = 0x04, /*!< enable sleep-deep output signal when entering sleep mode */
NVIC_LP_SEVONPEND = 0x10 /*!< enable sleep-on-exit feature */
NVIC_LP_SEVONPEND = 0x10 /*!< send event on pending */
} nvic_lowpower_mode_type;
/**

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_pwc.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 pwc header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_rtc.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 rtc header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_sdio.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 sdio header file
**************************************************************************
* Copyright notice & Disclaimer
@@ -578,7 +578,7 @@ typedef struct
void sdio_reset(sdio_type *sdio_x);
void sdio_power_set(sdio_type *sdio_x, sdio_power_state_type power_state);
flag_status sdio_power_status_get(sdio_type *sdio_x);
sdio_power_state_type sdio_power_status_get(sdio_type *sdio_x);
void sdio_clock_config(sdio_type *sdio_x, uint16_t clk_div, sdio_edge_phase_type clk_edg);
void sdio_bus_width_config(sdio_type *sdio_x, sdio_bus_width_type width);
void sdio_clock_bypass(sdio_type *sdio_x, confirm_state new_state);

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_spi.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 spi header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_tmr.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 tmr header file
**************************************************************************
* Copyright notice & Disclaimer
@@ -888,7 +888,7 @@ void tmr_input_channel_filter_set(tmr_type *tmr_x, tmr_channel_select_type tmr_c
uint16_t filter_value);
void tmr_pwm_input_config(tmr_type *tmr_x, tmr_input_config_type *input_struct, \
tmr_channel_input_divider_type divider_factor);
void tmr_channel1_input_select(tmr_type *tmr_x, tmr_channel1_input_connected_type ti1_connect);
void tmr_channel1_input_select(tmr_type *tmr_x, tmr_channel1_input_connected_type ch1_connect);
void tmr_input_channel_divider_set(tmr_type *tmr_x, tmr_channel_select_type tmr_channel, \
tmr_channel_input_divider_type divider_factor);
void tmr_primary_mode_select(tmr_type *tmr_x, tmr_primary_select_type primary_mode);

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_usart.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 usart header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_usb.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 usb header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_wdt.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 wdt header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_wwdt.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 wwdt header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_xmc.h
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief at32f403a_407 xmc header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_acc.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the acc firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_adc.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the adc firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_bpr.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the bpr firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_can.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the can firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_crc.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the crc firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_crm.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the crm firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -61,13 +61,13 @@ void crm_reset(void)
/* wait sclk switch status */
while(CRM->cfg_bit.sclksts != CRM_SCLK_HICK);
/* reset hexten, hextbyps, cfden and pllen bits */
CRM->ctrl &= ~(0x010D0000U);
/* reset cfg register, include sclk switch, ahbdiv, apb1div, apb2div, adcdiv,
clkout pllrcs, pllhextdiv, pllmult, usbdiv and pllrange bits */
CRM->cfg = 0;
/* reset hexten, hextbyps, cfden and pllen bits */
CRM->ctrl &= ~(0x010D0000U);
/* reset clkout[3], usbbufs, hickdiv, clkoutdiv */
CRM->misc1 = 0;
@@ -348,6 +348,7 @@ void crm_flag_clear(uint32_t flag)
case CRM_LOWPOWER_RESET_FLAG:
case CRM_ALL_RESET_FLAG:
CRM->ctrlsts_bit.rstfc = TRUE;
while(CRM->ctrlsts_bit.rstfc == TRUE);
break;
case CRM_LICK_READY_INT_FLAG:
CRM->clkint_bit.lickstblfc = TRUE;

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_dac.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the dac firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_debug.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the debug firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_dma.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the dma firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_emac.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the emac firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_exint.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the exint firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_flash.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the flash firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -448,64 +448,42 @@ flash_status_type flash_sector_erase(uint32_t sector_address)
flash_status_type status = FLASH_OPERATE_DONE;
if((sector_address >= FLASH_BANK1_START_ADDR) && (sector_address <= FLASH_BANK1_END_ADDR))
{
/* wait for last operation to be completed */
FLASH->ctrl_bit.secers = TRUE;
FLASH->addr = sector_address;
FLASH->ctrl_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_bank1_operation_wait_for(ERASE_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* if the previous operation is completed, continue to erase the sector */
FLASH->ctrl_bit.secers = TRUE;
FLASH->addr = sector_address;
FLASH->ctrl_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_bank1_operation_wait_for(ERASE_TIMEOUT);
/* disable the secers bit */
FLASH->ctrl_bit.secers = FALSE;
}
/* disable the secers bit */
FLASH->ctrl_bit.secers = FALSE;
}
else if((sector_address >= FLASH_BANK2_START_ADDR) && (sector_address <= FLASH_BANK2_END_ADDR))
{
/* wait for last operation to be completed */
FLASH->ctrl2_bit.secers = TRUE;
FLASH->addr2 = sector_address;
FLASH->ctrl2_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_bank2_operation_wait_for(ERASE_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* if the previous operation is completed, continue to erase the sector */
FLASH->ctrl2_bit.secers = TRUE;
FLASH->addr2 = sector_address;
FLASH->ctrl2_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_bank2_operation_wait_for(ERASE_TIMEOUT);
/* disable the secers bit */
FLASH->ctrl2_bit.secers = FALSE;
}
/* disable the secers bit */
FLASH->ctrl2_bit.secers = FALSE;
}
/* spim : external flash */
else if(sector_address >= FLASH_SPIM_START_ADDR)
{
/* wait for last operation to be completed */
FLASH->ctrl3_bit.secers = TRUE;
FLASH->addr3 = sector_address;
FLASH->ctrl3_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_spim_operation_wait_for(SPIM_ERASE_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* if the previous operation is completed, continue to erase the sector */
FLASH->ctrl3_bit.secers = TRUE;
FLASH->addr3 = sector_address;
FLASH->ctrl3_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_spim_operation_wait_for(SPIM_ERASE_TIMEOUT);
/* disable the secers bit */
FLASH->ctrl3_bit.secers = FALSE;
}
return status;
/* disable the secers bit */
FLASH->ctrl3_bit.secers = FALSE;
}
/* return the erase status */
return status;
}
@@ -519,21 +497,16 @@ flash_status_type flash_sector_erase(uint32_t sector_address)
flash_status_type flash_internal_all_erase(void)
{
flash_status_type status = FLASH_OPERATE_DONE;
/* wait for last operation to be completed */
FLASH->ctrl_bit.bankers = TRUE;
FLASH->ctrl_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_bank1_operation_wait_for(ERASE_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* if the previous operation is completed, continue to erase bank1 */
FLASH->ctrl_bit.bankers = TRUE;
FLASH->ctrl_bit.erstr = TRUE;
/* disable the bankers bit */
FLASH->ctrl_bit.bankers = FALSE;
/* wait for operation to be completed */
status = flash_bank1_operation_wait_for(ERASE_TIMEOUT);
/* disable the bankers bit */
FLASH->ctrl_bit.bankers = FALSE;
}
if(status == FLASH_OPERATE_DONE)
{
/* if the previous operation is completed, continue to erase bank2 */
@@ -559,21 +532,16 @@ flash_status_type flash_internal_all_erase(void)
flash_status_type flash_bank1_erase(void)
{
flash_status_type status = FLASH_OPERATE_DONE;
/* wait for last operation to be completed */
FLASH->ctrl_bit.bankers = TRUE;
FLASH->ctrl_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_bank1_operation_wait_for(ERASE_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* if the previous operation is completed, continue to erase bank1 */
FLASH->ctrl_bit.bankers = TRUE;
FLASH->ctrl_bit.erstr = TRUE;
/* disable the bankers bit */
FLASH->ctrl_bit.bankers = FALSE;
/* wait for operation to be completed */
status = flash_bank1_operation_wait_for(ERASE_TIMEOUT);
/* disable the bankers bit */
FLASH->ctrl_bit.bankers = FALSE;
}
/* return the erase status */
return status;
}
@@ -587,21 +555,16 @@ flash_status_type flash_bank1_erase(void)
flash_status_type flash_bank2_erase(void)
{
flash_status_type status = FLASH_OPERATE_DONE;
/* wait for last operation to be completed */
FLASH->ctrl2_bit.bankers = TRUE;
FLASH->ctrl2_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_bank2_operation_wait_for(ERASE_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* if the previous operation is completed, continue to erase bank2 */
FLASH->ctrl2_bit.bankers = TRUE;
FLASH->ctrl2_bit.erstr = TRUE;
/* disable the bankers bit */
FLASH->ctrl2_bit.bankers = FALSE;
/* wait for operation to be completed */
status = flash_bank2_operation_wait_for(ERASE_TIMEOUT);
/* disable the bankers bit */
FLASH->ctrl2_bit.bankers = FALSE;
}
/* return the erase status */
return status;
}
@@ -615,21 +578,16 @@ flash_status_type flash_bank2_erase(void)
flash_status_type flash_spim_all_erase(void)
{
flash_status_type status = FLASH_OPERATE_DONE;
/* wait for last operation to be completed */
FLASH->ctrl3_bit.chpers = TRUE;
FLASH->ctrl3_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_spim_operation_wait_for(SPIM_ERASE_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* if the previous operation is completed, continue to erase spim */
FLASH->ctrl3_bit.chpers = TRUE;
FLASH->ctrl3_bit.erstr = TRUE;
/* disable the chpers bit */
FLASH->ctrl3_bit.chpers = FALSE;
/* wait for operation to be completed */
status = flash_spim_operation_wait_for(SPIM_ERASE_TIMEOUT);
/* disable the chpers bit */
FLASH->ctrl3_bit.chpers = FALSE;
}
/* return the erase status */
return status;
}
@@ -645,47 +603,43 @@ flash_status_type flash_user_system_data_erase(void)
{
flash_status_type status = FLASH_OPERATE_DONE;
uint16_t fap_val = FAP_RELIEVE_KEY;
/* get the flash access protection status */
if(flash_fap_status_get() != RESET)
{
fap_val = 0x0000;
}
/* wait for last operation to be completed */
/* unlock the user system data */
FLASH->usd_unlock = FLASH_UNLOCK_KEY1;
FLASH->usd_unlock = FLASH_UNLOCK_KEY2;
while(FLASH->ctrl_bit.usdulks==RESET);
/* erase the user system data */
FLASH->ctrl_bit.usders = TRUE;
FLASH->ctrl_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_operation_wait_for(ERASE_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* unlock the user system data */
FLASH->usd_unlock = FLASH_UNLOCK_KEY1;
FLASH->usd_unlock = FLASH_UNLOCK_KEY2;
while(FLASH->ctrl_bit.usdulks==RESET);
/* disable the usders bit */
FLASH->ctrl_bit.usders = FALSE;
/* erase the user system data */
FLASH->ctrl_bit.usders = TRUE;
FLASH->ctrl_bit.erstr = TRUE;
if((status == FLASH_OPERATE_DONE) && (fap_val == FAP_RELIEVE_KEY))
{
/* enable the user system data programming operation */
FLASH->ctrl_bit.usdprgm = TRUE;
/* restore the last flash access protection value */
USD->fap = (uint16_t)fap_val;
/* wait for operation to be completed */
status = flash_operation_wait_for(ERASE_TIMEOUT);
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the usders bit */
FLASH->ctrl_bit.usders = FALSE;
if((status == FLASH_OPERATE_DONE) && (fap_val == FAP_RELIEVE_KEY))
{
/* enable the user system data programming operation */
FLASH->ctrl_bit.usdprgm = TRUE;
/* restore the last flash access protection value */
USD->fap = (uint16_t)fap_val;
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
/*disable the usdprgm bit */
FLASH->ctrl_bit.usdprgm = FALSE;
}
/*disable the usdprgm bit */
FLASH->ctrl_bit.usdprgm = FALSE;
}
/* return the erase status */
return status;
}
@@ -702,52 +656,34 @@ flash_status_type flash_word_program(uint32_t address, uint32_t data)
flash_status_type status = FLASH_OPERATE_DONE;
if((address >= FLASH_BANK1_START_ADDR) && (address <= FLASH_BANK1_END_ADDR))
{
/* wait for last operation to be completed */
FLASH->ctrl_bit.fprgm = TRUE;
*(__IO uint32_t*)address = data;
/* wait for operation to be completed */
status = flash_bank1_operation_wait_for(PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
FLASH->ctrl_bit.fprgm = TRUE;
*(__IO uint32_t*)address = data;
/* wait for operation to be completed */
status = flash_bank1_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the fprgm bit */
FLASH->ctrl_bit.fprgm = FALSE;
}
/* disable the fprgm bit */
FLASH->ctrl_bit.fprgm = FALSE;
}
else if((address >= FLASH_BANK2_START_ADDR) && (address <= FLASH_BANK2_END_ADDR))
{
/* wait for last operation to be completed */
FLASH->ctrl2_bit.fprgm = TRUE;
*(__IO uint32_t*)address = data;
/* wait for operation to be completed */
status = flash_bank2_operation_wait_for(PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
FLASH->ctrl2_bit.fprgm = TRUE;
*(__IO uint32_t*)address = data;
/* wait for operation to be completed */
status = flash_bank2_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the fprgm bit */
FLASH->ctrl2_bit.fprgm = FALSE;
}
/* disable the fprgm bit */
FLASH->ctrl2_bit.fprgm = FALSE;
}
/* spim : external flash */
else if(address >= FLASH_SPIM_START_ADDR)
{
/* wait for last operation to be completed */
FLASH->ctrl3_bit.fprgm = TRUE;
*(__IO uint32_t*)address = data;
/* wait for operation to be completed */
status = flash_spim_operation_wait_for(SPIM_PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
FLASH->ctrl3_bit.fprgm = TRUE;
*(__IO uint32_t*)address = data;
/* wait for operation to be completed */
status = flash_spim_operation_wait_for(SPIM_PROGRAMMING_TIMEOUT);
/* disable the fprgm bit */
FLASH->ctrl3_bit.fprgm = FALSE;
}
/* disable the fprgm bit */
FLASH->ctrl3_bit.fprgm = FALSE;
}
/* return the program status */
@@ -766,52 +702,34 @@ flash_status_type flash_halfword_program(uint32_t address, uint16_t data)
flash_status_type status = FLASH_OPERATE_DONE;
if((address >= FLASH_BANK1_START_ADDR) && (address <= FLASH_BANK1_END_ADDR))
{
/* wait for last operation to be completed */
FLASH->ctrl_bit.fprgm = TRUE;
*(__IO uint16_t*)address = data;
/* wait for operation to be completed */
status = flash_bank1_operation_wait_for(PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
FLASH->ctrl_bit.fprgm = TRUE;
*(__IO uint16_t*)address = data;
/* wait for operation to be completed */
status = flash_bank1_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the fprgm bit */
FLASH->ctrl_bit.fprgm = FALSE;
}
/* disable the fprgm bit */
FLASH->ctrl_bit.fprgm = FALSE;
}
else if((address >= FLASH_BANK2_START_ADDR) && (address <= FLASH_BANK2_END_ADDR))
{
/* wait for last operation to be completed */
FLASH->ctrl2_bit.fprgm = TRUE;
*(__IO uint16_t*)address = data;
/* wait for operation to be completed */
status = flash_bank2_operation_wait_for(PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
FLASH->ctrl2_bit.fprgm = TRUE;
*(__IO uint16_t*)address = data;
/* wait for operation to be completed */
status = flash_bank2_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the fprgm bit */
FLASH->ctrl2_bit.fprgm = FALSE;
}
/* disable the fprgm bit */
FLASH->ctrl2_bit.fprgm = FALSE;
}
/* spim : external flash */
else if(address >= FLASH_SPIM_START_ADDR)
{
/* wait for last operation to be completed */
FLASH->ctrl3_bit.fprgm = TRUE;
*(__IO uint16_t*)address = data;
/* wait for operation to be completed */
status = flash_spim_operation_wait_for(SPIM_PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
FLASH->ctrl3_bit.fprgm = TRUE;
*(__IO uint16_t*)address = data;
/* wait for operation to be completed */
status = flash_spim_operation_wait_for(SPIM_PROGRAMMING_TIMEOUT);
/* disable the fprgm bit */
FLASH->ctrl3_bit.fprgm = FALSE;
}
/* disable the fprgm bit */
FLASH->ctrl3_bit.fprgm = FALSE;
}
/* return the program status */
@@ -831,35 +749,23 @@ flash_status_type flash_byte_program(uint32_t address, uint8_t data)
flash_status_type status = FLASH_OPERATE_DONE;
if((address >= FLASH_BANK1_START_ADDR) && (address <= FLASH_BANK1_END_ADDR))
{
/* wait for last operation to be completed */
FLASH->ctrl_bit.fprgm = TRUE;
*(__IO uint8_t*)address = data;
/* wait for operation to be completed */
status = flash_bank1_operation_wait_for(PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
FLASH->ctrl_bit.fprgm = TRUE;
*(__IO uint8_t*)address = data;
/* wait for operation to be completed */
status = flash_bank1_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the fprgm bit */
FLASH->ctrl_bit.fprgm = FALSE;
}
/* disable the fprgm bit */
FLASH->ctrl_bit.fprgm = FALSE;
}
else if((address >= FLASH_BANK2_START_ADDR) && (address <= FLASH_BANK2_END_ADDR))
{
/* wait for last operation to be completed */
FLASH->ctrl2_bit.fprgm = TRUE;
*(__IO uint8_t*)address = data;
/* wait for operation to be completed */
status = flash_bank2_operation_wait_for(PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
FLASH->ctrl2_bit.fprgm = TRUE;
*(__IO uint8_t*)address = data;
/* wait for operation to be completed */
status = flash_bank2_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the fprgm bit */
FLASH->ctrl2_bit.fprgm = FALSE;
}
/* disable the fprgm bit */
FLASH->ctrl2_bit.fprgm = FALSE;
}
/* return the program status */
return status;
@@ -875,24 +781,22 @@ flash_status_type flash_byte_program(uint32_t address, uint8_t data)
flash_status_type flash_user_system_data_program(uint32_t address, uint8_t data)
{
flash_status_type status = FLASH_OPERATE_DONE;
/* unlock the user system data */
FLASH->usd_unlock = FLASH_UNLOCK_KEY1;
FLASH->usd_unlock = FLASH_UNLOCK_KEY2;
while(FLASH->ctrl_bit.usdulks==RESET);
/* enable the user system data programming operation */
FLASH->ctrl_bit.usdprgm = TRUE;
*(__IO uint16_t*)address = data;
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* unlock the user system data */
FLASH->usd_unlock = FLASH_UNLOCK_KEY1;
FLASH->usd_unlock = FLASH_UNLOCK_KEY2;
while(FLASH->ctrl_bit.usdulks==RESET);
/* enable the user system data programming operation */
FLASH->ctrl_bit.usdprgm = TRUE;
*(__IO uint16_t*)address = data;
/* disable the usdprgm bit */
FLASH->ctrl_bit.usdprgm = FALSE;
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the usdprgm bit */
FLASH->ctrl_bit.usdprgm = FALSE;
}
/* return the user system data program status */
return status;
}
@@ -915,42 +819,38 @@ flash_status_type flash_epp_set(uint32_t *sector_bits)
epp_data[1] = (uint16_t)((sector_bits[0] >> 8) & 0xFF);
epp_data[2] = (uint16_t)((sector_bits[0] >> 16) & 0xFF);
epp_data[3] = (uint16_t)((sector_bits[0] >> 24) & 0xFF);
/* wait for last operation to be completed */
/* unlock the user system data */
FLASH->usd_unlock = FLASH_UNLOCK_KEY1;
FLASH->usd_unlock = FLASH_UNLOCK_KEY2;
while(FLASH->ctrl_bit.usdulks==RESET);
FLASH->ctrl_bit.usdprgm = TRUE;
USD->epp0 = epp_data[0];
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* unlock the user system data */
FLASH->usd_unlock = FLASH_UNLOCK_KEY1;
FLASH->usd_unlock = FLASH_UNLOCK_KEY2;
while(FLASH->ctrl_bit.usdulks==RESET);
FLASH->ctrl_bit.usdprgm = TRUE;
USD->epp0 = epp_data[0];
USD->epp1 = epp_data[1];
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
USD->epp1 = epp_data[1];
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
}
if(status == FLASH_OPERATE_DONE)
{
USD->epp2 = epp_data[2];
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
}
if(status == FLASH_OPERATE_DONE)
{
USD->epp3 = epp_data[3];
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
}
/* disable the usdprgm bit */
FLASH->ctrl_bit.usdprgm = FALSE;
}
if(status == FLASH_OPERATE_DONE)
{
USD->epp2 = epp_data[2];
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
}
if(status == FLASH_OPERATE_DONE)
{
USD->epp3 = epp_data[3];
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
}
/* disable the usdprgm bit */
FLASH->ctrl_bit.usdprgm = FALSE;
/* return the erase/program protection operation status */
return status;
}
@@ -978,38 +878,36 @@ void flash_epp_status_get(uint32_t *sector_bits)
flash_status_type flash_fap_enable(confirm_state new_state)
{
flash_status_type status = FLASH_OPERATE_DONE;
/* unlock the user system data */
FLASH->usd_unlock = FLASH_UNLOCK_KEY1;
FLASH->usd_unlock = FLASH_UNLOCK_KEY2;
while(FLASH->ctrl_bit.usdulks==RESET);
FLASH->ctrl_bit.usders = TRUE;
FLASH->ctrl_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_operation_wait_for(ERASE_TIMEOUT);
/* disable the usders bit */
FLASH->ctrl_bit.usders = FALSE;
if(status == FLASH_OPERATE_DONE)
{
/* unlock the user system data */
FLASH->usd_unlock = FLASH_UNLOCK_KEY1;
FLASH->usd_unlock = FLASH_UNLOCK_KEY2;
while(FLASH->ctrl_bit.usdulks==RESET);
FLASH->ctrl_bit.usders = TRUE;
FLASH->ctrl_bit.erstr = TRUE;
/* wait for operation to be completed */
status = flash_operation_wait_for(ERASE_TIMEOUT);
/* disable the usders bit */
FLASH->ctrl_bit.usders = FALSE;
if(status == FLASH_OPERATE_DONE)
if(new_state == FALSE)
{
if(new_state == FALSE)
{
/* enable the user system data programming operation */
FLASH->ctrl_bit.usdprgm = TRUE;
USD->fap = FAP_RELIEVE_KEY;
/* enable the user system data programming operation */
FLASH->ctrl_bit.usdprgm = TRUE;
USD->fap = FAP_RELIEVE_KEY;
/* Wait for operation to be completed */
status = flash_operation_wait_for(ERASE_TIMEOUT);
/* wait for operation to be completed */
status = flash_operation_wait_for(ERASE_TIMEOUT);
/* disable the usdprgm bit */
FLASH->ctrl_bit.usdprgm = FALSE;
}
/* disable the usdprgm bit */
FLASH->ctrl_bit.usdprgm = FALSE;
}
}
/* return the flash access protection operation status */
return status;
}
@@ -1050,26 +948,22 @@ flag_status flash_fap_status_get(void)
flash_status_type flash_ssb_set(uint8_t usd_ssb)
{
flash_status_type status = FLASH_OPERATE_DONE;
/* wait for last operation to be completed */
/* unlock the user system data */
FLASH->usd_unlock = FLASH_UNLOCK_KEY1;
FLASH->usd_unlock = FLASH_UNLOCK_KEY2;
while(FLASH->ctrl_bit.usdulks==RESET);
/* enable the user system data programming operation */
FLASH->ctrl_bit.usdprgm = TRUE;
USD->ssb = usd_ssb;
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* unlock the user system data */
FLASH->usd_unlock = FLASH_UNLOCK_KEY1;
FLASH->usd_unlock = FLASH_UNLOCK_KEY2;
while(FLASH->ctrl_bit.usdulks==RESET);
/* disable the usdprgm bit */
FLASH->ctrl_bit.usdprgm = FALSE;
/* enable the user system data programming operation */
FLASH->ctrl_bit.usdprgm = TRUE;
USD->ssb = usd_ssb;
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the usdprgm bit */
FLASH->ctrl_bit.usdprgm = FALSE;
}
/* return the user system data program status */
return status;
}
@@ -1153,27 +1047,25 @@ flash_status_type flash_slib_enable(uint32_t pwd, uint16_t start_sector, uint16_
{
uint32_t slib_range;
flash_status_type status = FLASH_OPERATE_DONE;
/* wait for last operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
/*check range param limits*/
if((start_sector>=data_start_sector) || ((data_start_sector > end_sector) && \
(data_start_sector != 0x7FF)) || (start_sector > end_sector))
return FLASH_PROGRAM_ERROR;
/* unlock slib cfg register */
FLASH->slib_unlock = SLIB_UNLOCK_KEY;
while(FLASH->slib_misc_sts_bit.slib_ulkf==RESET);
slib_range = ((uint32_t)(data_start_sector << 11) & FLASH_SLIB_DATA_START_SECTOR) | \
((uint32_t)(end_sector << 22) & FLASH_SLIB_END_SECTOR) | \
(start_sector & FLASH_SLIB_START_SECTOR);
/* configure slib, set pwd and range */
FLASH->slib_set_pwd = pwd;
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
FLASH->slib_set_range = slib_range;
if(status == FLASH_OPERATE_DONE)
{
/* unlock slib cfg register */
FLASH->slib_unlock = SLIB_UNLOCK_KEY;
while(FLASH->slib_misc_sts_bit.slib_ulkf==RESET);
slib_range = ((uint32_t)(data_start_sector << 11) & FLASH_SLIB_DATA_START_SECTOR) | \
((uint32_t)(end_sector << 22) & FLASH_SLIB_END_SECTOR) | \
(start_sector & FLASH_SLIB_START_SECTOR);
/* configure slib, set pwd and range */
FLASH->slib_set_pwd = pwd;
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
FLASH->slib_set_range = slib_range;
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
}
return status;
@@ -1239,7 +1131,7 @@ uint16_t flash_slib_start_sector_get(void)
* @param none
* @retval uint16_t
*/
uint16_t flash_slib_datstart_sector_get(void)
uint16_t flash_slib_datastart_sector_get(void)
{
return (uint16_t)FLASH->slib_sts1_bit.slib_dat_ss;
}

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_gpio.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the gpio firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_i2c.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the i2c firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -619,11 +619,23 @@ flag_status i2c_flag_get(i2c_type *i2c_x, uint32_t flag)
* - I2C_PECERR_FLAG: pec receive error flag.
* - I2C_TMOUT_FLAG: smbus timeout flag.
* - I2C_ALERTF_FLAG: smbus alert flag.
* - I2C_STOPF_FLAG: stop condition generation complete flag.
* - I2C_ADDR7F_FLAG: i2c 0~7 bit address match flag.
* @retval none
*/
void i2c_flag_clear(i2c_type *i2c_x, uint32_t flag)
{
i2c_x->sts1 = (uint16_t)~(flag & (uint32_t)0x00FFFFFF);
{
i2c_x->sts1 = (uint16_t)~(flag & (uint32_t)0x0000DF00);
if(i2c_x->sts1 & I2C_ADDR7F_FLAG)
{
UNUSED(i2c_x->sts2);
}
if(i2c_x->sts1 & I2C_STOPF_FLAG)
{
i2c_x->ctrl1_bit.i2cen = TRUE;
}
}
/**

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_misc.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the misc firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_pwc.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the pwc firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_rtc.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the rtc firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -76,7 +76,7 @@ uint32_t rtc_counter_get(void)
/**
* @brief rtc divider set
* @param div_value (0x0000_0000 ~ 0xFFFF_FFFF)
* @param div_value (0x0000_0000 ~ 0x000F_FFFF)
* @retval none
*/
void rtc_divider_set(uint32_t div_value)
@@ -181,7 +181,7 @@ flag_status rtc_flag_get(uint16_t flag)
* - RTC_TS_FLAG: time second flag.
* - RTC_TA_FLAG: time alarm flag.
* - RTC_OVF_FLAG: overflow flag.
* - RTC_CFGF_FLAG: rtc configuration finish flag.
* - RTC_UPDF_FLAG: rtc update finish flag.
* @retval none
*/
void rtc_flag_clear(uint16_t flag)

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_sdio.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the sdio firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -82,22 +82,11 @@ void sdio_power_set(sdio_type *sdio_x, sdio_power_state_type power_state)
* @param sdio_x: to select the sdio peripheral.
* this parameter can be one of the following values:
* SDIO1, SDIO2.
* @retval flag_status (SET or RESET)
* @retval sdio_power_state_type (SDIO_POWER_ON or SDIO_POWER_OFF)
*/
flag_status sdio_power_status_get(sdio_type *sdio_x)
sdio_power_state_type sdio_power_status_get(sdio_type *sdio_x)
{
flag_status flag = RESET;
if(sdio_x->pwrctrl_bit.ps == SDIO_POWER_ON)
{
flag = SET;
}
else if(sdio_x->pwrctrl_bit.ps == SDIO_POWER_OFF)
{
flag = RESET;
}
return flag;
return (sdio_power_state_type)(sdio_x->pwrctrl_bit.ps);
}
/**

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_spi.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the spi firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -441,7 +441,7 @@ void i2s_init(spi_type* spi_x, i2s_init_type* i2s_init_struct)
* @brief enable or disable i2s.
* @param spi_x: select the i2s peripheral.
* this parameter can be one of the following values:
* SPI1, SPI2, SPI3 ,SPI4
* SPI1, SPI2, SPI3 ,SPI4, I2S2EXT, I2S3EXT
* @param new_state: new state of i2s.
* this parameter can be: TRUE or FALSE.
* @retval none
@@ -455,7 +455,7 @@ void i2s_enable(spi_type* spi_x, confirm_state new_state)
* @brief enable or disable the specified spi/i2s interrupts.
* @param spi_x: select the spi/i2s peripheral.
* this parameter can be one of the following values:
* SPI1, SPI2, SPI3 ,SPI4
* SPI1, SPI2, SPI3 ,SPI4, I2S2EXT, I2S3EXT
* @param spi_i2s_int: specifies the spi/i2s interrupt sources to be enabled or disabled.
* this parameter can be one of the following values:
* - SPI_I2S_ERROR_INT
@@ -481,7 +481,7 @@ void spi_i2s_interrupt_enable(spi_type* spi_x, uint32_t spi_i2s_int, confirm_sta
* @brief enable or disable the spi/i2s dma transmitter mode.
* @param spi_x: select the spi/i2s peripheral.
* this parameter can be one of the following values:
* SPI1, SPI2, SPI3 ,SPI4
* SPI1, SPI2, SPI3 ,SPI4, I2S2EXT, I2S3EXT
* @param new_state: new state of the dma request.
* this parameter can be: TRUE or FALSE.
* @retval none
@@ -495,7 +495,7 @@ void spi_i2s_dma_transmitter_enable(spi_type* spi_x, confirm_state new_state)
* @brief enable or disable the spi/i2s dma receiver mode.
* @param spi_x: select the spi/i2s peripheral.
* this parameter can be one of the following values:
* SPI1, SPI2, SPI3 ,SPI4
* SPI1, SPI2, SPI3 ,SPI4, I2S2EXT, I2S3EXT
* @param new_state: new state of the dma request.
* this parameter can be: TRUE or FALSE.
* @retval none
@@ -509,7 +509,7 @@ void spi_i2s_dma_receiver_enable(spi_type* spi_x, confirm_state new_state)
* @brief spi/i2s data transmit
* @param spi_x: select the spi/i2s peripheral.
* this parameter can be one of the following values:
* SPI1, SPI2, SPI3 ,SPI4
* SPI1, SPI2, SPI3 ,SPI4, I2S2EXT, I2S3EXT
* @param tx_data: the data to be transmit.
* this parameter can be:
* - (0x0000~0xFFFF)
@@ -524,7 +524,7 @@ void spi_i2s_data_transmit(spi_type* spi_x, uint16_t tx_data)
* @brief spi/i2s data receive
* @param spi_x: select the spi/i2s peripheral.
* this parameter can be one of the following values:
* SPI1, SPI2, SPI3 ,SPI4
* SPI1, SPI2, SPI3 ,SPI4, I2S2EXT, I2S3EXT
* @retval the received data value
*/
uint16_t spi_i2s_data_receive(spi_type* spi_x)
@@ -536,7 +536,7 @@ uint16_t spi_i2s_data_receive(spi_type* spi_x)
* @brief get flag of the specified spi/i2s peripheral.
* @param spi_x: select the spi/i2s peripheral.
* this parameter can be one of the following values:
* SPI1, SPI2, SPI3 ,SPI4
* SPI1, SPI2, SPI3 ,SPI4, I2S2EXT, I2S3EXT
* @param spi_i2s_flag: select the spi/i2s flag
* this parameter can be one of the following values:
* - SPI_I2S_RDBF_FLAG
@@ -567,7 +567,7 @@ flag_status spi_i2s_flag_get(spi_type* spi_x, uint32_t spi_i2s_flag)
* @brief clear flag of the specified spi/i2s peripheral.
* @param spi_x: select the spi/i2s peripheral.
* this parameter can be one of the following values:
* SPI1, SPI2, SPI3 ,SPI4
* SPI1, SPI2, SPI3 ,SPI4, I2S2EXT, I2S3EXT
* @param spi_i2s_flag: select the spi/i2s flag
* this parameter can be one of the following values:
* - SPI_CCERR_FLAG
@@ -583,23 +583,21 @@ flag_status spi_i2s_flag_get(spi_type* spi_x, uint32_t spi_i2s_flag)
*/
void spi_i2s_flag_clear(spi_type* spi_x, uint32_t spi_i2s_flag)
{
volatile uint32_t temp = 0;
temp = temp;
if(spi_i2s_flag == SPI_CCERR_FLAG)
spi_x->sts = ~SPI_CCERR_FLAG;
else if(spi_i2s_flag == SPI_I2S_RDBF_FLAG)
temp = REG32(&spi_x->dt);
UNUSED(spi_x->dt);
else if(spi_i2s_flag == I2S_TUERR_FLAG)
temp = REG32(&spi_x->sts);
UNUSED(spi_x->sts);
else if(spi_i2s_flag == SPI_MMERR_FLAG)
{
temp = REG32(&spi_x->sts);
UNUSED(spi_x->sts);
spi_x->ctrl1 = spi_x->ctrl1;
}
else if(spi_i2s_flag == SPI_I2S_ROERR_FLAG)
{
temp = REG32(&spi_x->dt);
temp = REG32(&spi_x->sts);
UNUSED(spi_x->dt);
UNUSED(spi_x->sts);
}
}

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_tmr.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the tmr firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -758,7 +758,8 @@ void tmr_output_channel_switch_set(tmr_type *tmr_x, tmr_channel_select_type tmr_
* @brief enable or disable tmr one cycle mode
* @param tmr_x: select the tmr peripheral.
* this parameter can be one of the following values:
* TMR1, TMR2, TMR3, TMR4, TMR5, TMR6, TMR7, TMR8, TMR9, TMR12
* TMR1, TMR2, TMR3, TMR4, TMR5, TMR6, TMR7, TMR8,
* TMR9, TMR10, TMR11, TMR12, TMR13, TMR14
* @param new_state (TRUE or FALSE)
* @retval none
*/
@@ -1101,15 +1102,15 @@ void tmr_pwm_input_config(tmr_type *tmr_x, tmr_input_config_type *input_struct,
* @param tmr_x: select the tmr peripheral.
* this parameter can be one of the following values:
* TMR1, TMR2, TMR3, TMR4, TMR5, TMR8
* @param ti1_connect
* @param ch1_connect
* this parameter can be one of the following values:
* - TMR_CHANEL1_CONNECTED_C1IRAW
* - TMR_CHANEL1_2_3_CONNECTED_C1IRAW_XOR
* @retval none
*/
void tmr_channel1_input_select(tmr_type *tmr_x, tmr_channel1_input_connected_type ti1_connect)
void tmr_channel1_input_select(tmr_type *tmr_x, tmr_channel1_input_connected_type ch1_connect)
{
tmr_x->ctrl2_bit.c1insel = ti1_connect;
tmr_x->ctrl2_bit.c1insel = ch1_connect;
}
/**
@@ -1207,7 +1208,7 @@ void tmr_sub_mode_select(tmr_type *tmr_x, tmr_sub_mode_select_type sub_mode)
}
/**
* @brief select tmr channel dma
* @brief select tmr channel dma request source
* @param tmr_x: select the tmr peripheral.
* this parameter can be one of the following values:
* TMR1, TMR2, TMR3, TMR4, TMR5, TMR8, TMR9, TMR12

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_usart.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the usart firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -594,6 +594,11 @@ flag_status usart_flag_get(usart_type* usart_x, uint32_t flag)
* - USART_BFF_FLAG:
* - USART_TDC_FLAG:
* - USART_RDBF_FLAG:
* - USART_PERR_FLAG:
* - USART_FERR_FLAG:
* - USART_NERR_FLAG:
* - USART_ROERR_FLAG:
* - USART_IDLEF_FLAG:
* @note
* - USART_PERR_FLAG, USART_FERR_FLAG, USART_NERR_FLAG, USART_ROERR_FLAG and USART_IDLEF_FLAG are cleared by software
* sequence: a read operation to usart sts register (usart_flag_get())
@@ -606,7 +611,15 @@ flag_status usart_flag_get(usart_type* usart_x, uint32_t flag)
*/
void usart_flag_clear(usart_type* usart_x, uint32_t flag)
{
usart_x->sts = ~flag;
if(flag & (USART_PERR_FLAG | USART_FERR_FLAG | USART_NERR_FLAG | USART_ROERR_FLAG | USART_IDLEF_FLAG))
{
UNUSED(usart_x->sts);
UNUSED(usart_x->dt);
}
else
{
usart_x->sts = ~flag;
}
}
/**

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_usb.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains the functions for the usb firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_wdt.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the wdt firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_wwdt.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the wwdt firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f403a_407_xmc.c
* @version v2.0.9
* @date 2022-04-25
* @version v2.1.0
* @date 2022-06-09
* @brief contains all the functions for the xmc firmware library
**************************************************************************
* Copyright notice & Disclaimer