update version to v2.0.6

This commit is contained in:
Artery-MCU
2022-06-30 17:16:46 +08:00
parent f09f510f6d
commit ac9d1046b7
1097 changed files with 33325 additions and 2709 deletions

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_adc.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the adc firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_can.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the can firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_cmp.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the gpio firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -95,7 +95,7 @@ void cmp_init(cmp_sel_type cmp_sel, cmp_init_type* cmp_init_struct)
void cmp_default_para_init(cmp_init_type *cmp_init_struct)
{
/* reset cmp init structure parameters values */
cmp_init_struct->cmp_non_inverting = CMP_NON_INVERTING_PA1;
cmp_init_struct->cmp_non_inverting = CMP_NON_INVERTING_PA1_PA3;
cmp_init_struct->cmp_inverting = CMP_INVERTING_1_4VREFINT;
cmp_init_struct->cmp_speed = CMP_SPEED_FAST;
cmp_init_struct->cmp_output = CMP_OUTPUT_NONE;
@@ -173,6 +173,16 @@ void cmp_write_protect_enable(cmp_sel_type cmp_sel)
}
}
/**
* @brief enable or disable double comparator mode
* @param new_state (TRUE or FALSE)
* @retval none
*/
void cmp_double_mode_enable(confirm_state new_state)
{
CMP->ctrlsts1_bit.dcmpen = new_state;
}
/**
* @}
*/

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_crc.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the crc firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_crm.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the crm firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -927,12 +927,13 @@ void crm_otgfs_ep3_remap_enable(confirm_state new_state)
*
* at32f415xx revision C: (support)
* usb divider(CRM_CFG[usbdiv]) support to be reset.
* @param new_state (TRUE or FALSE)
* @param none
* @retval none
*/
void crm_usbdiv_reset(confirm_state new_state)
void crm_usbdiv_reset(void)
{
CRM->otg_extctrl_bit.usbdivrst = new_state;
CRM->otg_extctrl_bit.usbdivrst = 1;
CRM->otg_extctrl_bit.usbdivrst = 0;
}
/**

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_debug.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the debug firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_dma.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the dma firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_ertc.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the ertc firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -406,7 +406,7 @@ void ertc_calendar_get(ertc_time_type* time)
ertc_reg_time_type reg_tm;
ertc_reg_date_type reg_dt;
(void) (ERTC->sts);
UNUSED(ERTC->sts);
reg_tm.time = ERTC->time;
reg_dt.date = ERTC->date;
@@ -724,8 +724,8 @@ uint32_t ertc_alarm_sub_second_get(ertc_alarm_type alarm_x)
* - ERTC_WAT_CLK_ERTCCLK_DIV8: ERTC_CLK / 8.
* - ERTC_WAT_CLK_ERTCCLK_DIV4: ERTC_CLK / 4.
* - ERTC_WAT_CLK_ERTCCLK_DIV2: ERTC_CLK / 2.
* - ERTC_WAT_CLK_CK_A_16BITS: CK_A, wakeup counter = ERTC_WAT
* - ERTC_WAT_CLK_CK_A_17BITS: CK_A, wakeup counter = ERTC_WAT + 65535.
* - ERTC_WAT_CLK_CK_B_16BITS: CK_B, wakeup counter = ERTC_WAT
* - ERTC_WAT_CLK_CK_B_17BITS: CK_B, wakeup counter = ERTC_WAT + 65535.
* @retval none.
*/
void ertc_wakeup_clock_set(ertc_wakeup_clock_type clock)

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_exint.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the exint firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_flash.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the flash firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -173,22 +173,17 @@ void flash_lock(void)
flash_status_type flash_sector_erase(uint32_t sector_address)
{
flash_status_type status = FLASH_OPERATE_DONE;
/* 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_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;
/* disable the secers bit */
FLASH->ctrl_bit.secers = FALSE;
/* wait for operation to be completed */
status = flash_operation_wait_for(ERASE_TIMEOUT);
/* disable the secers bit */
FLASH->ctrl_bit.secers = FALSE;
}
/* return the erase status */
return status;
}
@@ -202,21 +197,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_operation_wait_for(ERASE_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* if the previous operation is completed, continue to erase */
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_operation_wait_for(ERASE_TIMEOUT);
/* disable the bankers bit */
FLASH->ctrl_bit.bankers = FALSE;
}
/* return the erase status */
return status;
}
@@ -239,41 +229,36 @@ flash_status_type flash_user_system_data_erase(void)
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;
}
@@ -288,19 +273,15 @@ flash_status_type flash_user_system_data_erase(void)
flash_status_type flash_word_program(uint32_t address, uint32_t data)
{
flash_status_type status = FLASH_OPERATE_DONE;
/* 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_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_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the fprgm bit */
FLASH->ctrl_bit.fprgm = FALSE;
/* disable the fprgm bit */
FLASH->ctrl_bit.fprgm = FALSE;
}
/* return the program status */
return status;
}
@@ -315,19 +296,15 @@ flash_status_type flash_word_program(uint32_t address, uint32_t data)
flash_status_type flash_halfword_program(uint32_t address, uint16_t data)
{
flash_status_type status = FLASH_OPERATE_DONE;
/* 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_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_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the fprgm bit */
FLASH->ctrl_bit.fprgm = FALSE;
/* disable the fprgm bit */
FLASH->ctrl_bit.fprgm = FALSE;
}
/* return the program status */
return status;
}
@@ -342,19 +319,15 @@ flash_status_type flash_halfword_program(uint32_t address, uint16_t data)
flash_status_type flash_byte_program(uint32_t address, uint8_t data)
{
flash_status_type status = FLASH_OPERATE_DONE;
/* 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_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_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the fprgm bit */
FLASH->ctrl_bit.fprgm = FALSE;
/* disable the fprgm bit */
FLASH->ctrl_bit.fprgm = FALSE;
}
/* return the program status */
return status;
}
@@ -369,24 +342,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;
}
@@ -409,42 +380,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;
}
@@ -472,38 +439,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;
}
@@ -530,65 +495,63 @@ flag_status flash_fap_status_get(void)
flash_status_type flash_fap_high_level_enable(confirm_state new_state)
{
flash_status_type status = FLASH_OPERATE_DONE;
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);
if(new_state == FALSE)
{
/* 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.fap_hl_dis = TRUE;
/* wait for operation to be completed */
status = flash_operation_wait_for(ERASE_TIMEOUT);
if(new_state == FALSE)
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)
{
FLASH->ctrl_bit.fap_hl_dis = TRUE;
/* 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);
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)
{
/* 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);
/* disable the usdprgm bit */
FLASH->ctrl_bit.usdprgm = FALSE;
}
}
else
{
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)
{
/* enable the user system data programming operation */
FLASH->ctrl_bit.usdprgm = TRUE;
USD->fap = FAP_HIGH_LEVEL_KEY;
/* 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;
}
}
else
{
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)
{
/* enable the user system data programming operation */
FLASH->ctrl_bit.usdprgm = TRUE;
USD->fap = FAP_HIGH_LEVEL_KEY;
/* wait for operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
/* disable the usdprgm bit */
FLASH->ctrl_bit.usdprgm = FALSE;
}
}
/* return the flash access protection operation status */
return status;
}
@@ -625,26 +588,22 @@ flag_status flash_fap_high_level_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;
}
@@ -692,29 +651,28 @@ 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);
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;
}
@@ -824,21 +782,20 @@ void flash_boot_memory_extension_mode_enable(void)
flash_status_type flash_extension_memory_slib_enable(uint32_t pwd, uint16_t data_start_sector)
{
flash_status_type status = FLASH_OPERATE_DONE;
/* wait for last operation to be completed */
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
/* unlock slib cfg register */
FLASH->slib_unlock = SLIB_UNLOCK_KEY;
while(FLASH->slib_misc_sts_bit.slib_ulkf==RESET);
/* configure slib, set pwd and range */
FLASH->slib_set_pwd = pwd;
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
if(status == FLASH_OPERATE_DONE)
{
/* unlock slib cfg register */
FLASH->slib_unlock = SLIB_UNLOCK_KEY;
while(FLASH->slib_misc_sts_bit.slib_ulkf==RESET);
/* configure slib, set pwd and range */
FLASH->slib_set_pwd = pwd;
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
FLASH->em_slib_set = (uint32_t)(data_start_sector << 16) + (uint32_t)0x5AA5;
status = flash_operation_wait_for(PROGRAMMING_TIMEOUT);
}
return status;
}

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_gpio.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the gpio firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -390,7 +390,7 @@ void gpio_bits_write(gpio_type *gpio_x, uint16_t pins, confirm_state bit_state)
* @param port_value: specifies the value to be written to the port output data register.
* @retval none
*/
void gpio_port_wirte(gpio_type *gpio_x, uint16_t port_value)
void gpio_port_write(gpio_type *gpio_x, uint16_t port_value)
{
gpio_x->odt = port_value;
}

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_i2c.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the i2c firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -600,7 +600,7 @@ flag_status i2c_flag_get(i2c_type *i2c_x, uint32_t flag)
* @brief clear flag status
* @param i2c_x: to select the i2c peripheral.
* this parameter can be one of the following values:
* I2C1, I2C2.
* I2C1, I2C2, I2C3.
* @param flag
* this parameter can be any combination of the following values:
* - I2C_BUSERR_FLAG: bus error flag.
@@ -610,11 +610,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 at32f415_misc.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the misc firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_pwc.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the pwc firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_sdio.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @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.
* @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 at32f415_spi.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the spi firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -579,23 +579,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 at32f415_tmr.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the tmr firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -1046,15 +1046,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
* @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;
}
/**

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_usart.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the usart firmware library
**************************************************************************
* Copyright notice & Disclaimer
@@ -579,6 +579,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())
@@ -591,7 +596,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 at32f415_usb.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the usb firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_wdt.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the wdt firmware library
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file at32f415_wwdt.c
* @version v2.0.5
* @date 2022-05-20
* @version v2.0.6
* @date 2022-06-28
* @brief contains all the functions for the wwdt firmware library
**************************************************************************
* Copyright notice & Disclaimer