diff --git a/AT32F415_periph_lib_V2.1.2.chm b/AT32F415_periph_lib_V2.1.4.chm similarity index 63% rename from AT32F415_periph_lib_V2.1.2.chm rename to AT32F415_periph_lib_V2.1.4.chm index 916993d..90ecd28 100644 Binary files a/AT32F415_periph_lib_V2.1.2.chm and b/AT32F415_periph_lib_V2.1.4.chm differ diff --git a/document/AT32F415固件库BSP&Pack应用指南.pdf b/document/AT32F415固件库BSP&Pack应用指南.pdf index f434639..2f3cb54 100644 Binary files a/document/AT32F415固件库BSP&Pack应用指南.pdf and b/document/AT32F415固件库BSP&Pack应用指南.pdf differ diff --git a/document/ReleaseNotes_AT32F415_Firmware_Library.pdf b/document/ReleaseNotes_AT32F415_Firmware_Library.pdf index 2cd21c3..dfdeb84 100644 Binary files a/document/ReleaseNotes_AT32F415_Firmware_Library.pdf and b/document/ReleaseNotes_AT32F415_Firmware_Library.pdf differ diff --git a/libraries/cmsis/cm4/device_support/at32f415.h b/libraries/cmsis/cm4/device_support/at32f415.h index 3bda16d..b4fc323 100644 --- a/libraries/cmsis/cm4/device_support/at32f415.h +++ b/libraries/cmsis/cm4/device_support/at32f415.h @@ -128,7 +128,7 @@ extern "C" { */ #define __AT32F415_LIBRARY_VERSION_MAJOR (0x02) /*!< [31:24] major version */ #define __AT32F415_LIBRARY_VERSION_MIDDLE (0x01) /*!< [23:16] middle version */ -#define __AT32F415_LIBRARY_VERSION_MINOR (0x02) /*!< [15:8] minor version */ +#define __AT32F415_LIBRARY_VERSION_MINOR (0x04) /*!< [15:8] minor version */ #define __AT32F415_LIBRARY_VERSION_RC (0x00) /*!< [7:0] release candidate */ #define __AT32F415_LIBRARY_VERSION ((__AT32F415_LIBRARY_VERSION_MAJOR << 24) | \ (__AT32F415_LIBRARY_VERSION_MIDDLE << 16) | \ diff --git a/libraries/drivers/inc/at32f415_cmp.h b/libraries/drivers/inc/at32f415_cmp.h index c57eaf1..802081d 100644 --- a/libraries/drivers/inc/at32f415_cmp.h +++ b/libraries/drivers/inc/at32f415_cmp.h @@ -78,6 +78,9 @@ typedef enum CMP_SPEED_SLOW = 0x01, /*!< comparator selected slow speed */ } cmp_speed_type; +#define CMP_OUTPUT_TMR1CXORAW_OFF CMP_OUTPUT_TMR1CHCLR +#define CMP_OUTPUT_TMR2CXORAW_OFF CMP_OUTPUT_TMR2CHCLR +#define CMP_OUTPUT_TMR3CXORAW_OFF CMP_OUTPUT_TMR3CHCLR /** * @brief cmp output type */ diff --git a/libraries/drivers/src/at32f415_adc.c b/libraries/drivers/src/at32f415_adc.c index 7a703e5..1f398dd 100644 --- a/libraries/drivers/src/at32f415_adc.c +++ b/libraries/drivers/src/at32f415_adc.c @@ -687,10 +687,10 @@ uint16_t adc_ordinary_conversion_data_get(adc_type *adc_x) * ADC1. * @param adc_preempt_channel: select the preempt channel. * this parameter can be one of the following values: - * - ADC_PREEMPTED_CHANNEL_1 - * - ADC_PREEMPTED_CHANNEL_2 - * - ADC_PREEMPTED_CHANNEL_3 - * - ADC_PREEMPTED_CHANNEL_4 + * - ADC_PREEMPT_CHANNEL_1 + * - ADC_PREEMPT_CHANNEL_2 + * - ADC_PREEMPT_CHANNEL_3 + * - ADC_PREEMPT_CHANNEL_4 * @retval the conversion data for selection preempt channel. */ uint16_t adc_preempt_conversion_data_get(adc_type *adc_x, adc_preempt_channel_type adc_preempt_channel) diff --git a/middlewares/usb_drivers/inc/usbd_core.h b/middlewares/usb_drivers/inc/usbd_core.h index f5253b7..e465588 100644 --- a/middlewares/usb_drivers/inc/usbd_core.h +++ b/middlewares/usb_drivers/inc/usbd_core.h @@ -136,8 +136,8 @@ typedef struct uint8_t device_addr; /*!< device address */ uint8_t remote_wakup; /*!< remote wakeup state */ - uint8_t default_config; /*!< usb default config state */ - uint8_t dev_config; /*!< usb device config state */ + uint32_t default_config; /*!< usb default config state */ + uint32_t dev_config; /*!< usb device config state */ uint32_t config_status; /*!< usb configure status */ }usbd_core_type; diff --git a/middlewares/usbd_class/audio_hid/audio_hid_desc.c b/middlewares/usbd_class/audio_hid/audio_hid_desc.c index 27da693..d850205 100644 --- a/middlewares/usbd_class/audio_hid/audio_hid_desc.c +++ b/middlewares/usbd_class/audio_hid/audio_hid_desc.c @@ -506,7 +506,7 @@ ALIGNED_HEAD uint8_t g_usbd_audio_hid_report[USBD_AUHID_HID_SIZ_REPORT_DESC] ALI 0x85, HID_REPORT_ID_6, /* REPORT_ID (0xF0) */ 0x09, 0x06, /* USAGE */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ - 0x26, 0x00,0xff, /* LOGICAL_MAXIMUM (255) */ + 0x26, 0xFF,0x00, /* LOGICAL_MAXIMUM (255) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, 0x3F, /* REPORT_COUNT (64) */ 0x91, 0x02, /* OUTPUT(Data,Var,Abs,Vol) */ @@ -516,7 +516,7 @@ ALIGNED_HEAD uint8_t g_usbd_audio_hid_report[USBD_AUHID_HID_SIZ_REPORT_DESC] ALI 0x85, HID_REPORT_ID_6, /* REPORT_ID (0xF0) */ 0x09, 0x07, /* USAGE */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ - 0x26, 0x00,0xff, /* LOGICAL_MAXIMUM (255) */ + 0x26, 0xFF,0x00, /* LOGICAL_MAXIMUM (255) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, 0x3F, /* REPORT_COUNT (64) */ 0x81, 0x82, /* INPUT(Data,Var,Abs,Vol) */ diff --git a/middlewares/usbd_class/custom_hid/custom_hid_desc.c b/middlewares/usbd_class/custom_hid/custom_hid_desc.c index 0e70ecb..031cdb7 100644 --- a/middlewares/usbd_class/custom_hid/custom_hid_desc.c +++ b/middlewares/usbd_class/custom_hid/custom_hid_desc.c @@ -237,7 +237,7 @@ ALIGNED_HEAD uint8_t g_usbd_custom_hid_report[USBD_CUSHID_SIZ_REPORT_DESC] ALIGN 0x85, HID_REPORT_ID_6, /* REPORT_ID (0xF0) */ 0x09, 0x06, /* USAGE */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ - 0x26, 0x00,0xff, /* LOGICAL_MAXIMUM (255) */ + 0x26, 0xFF,0x00, /* LOGICAL_MAXIMUM (255) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, 0x3F, /* REPORT_COUNT (64) */ 0x91, 0x02, /* OUTPUT(Data,Var,Abs,Vol) */ @@ -247,7 +247,7 @@ ALIGNED_HEAD uint8_t g_usbd_custom_hid_report[USBD_CUSHID_SIZ_REPORT_DESC] ALIGN 0x85, HID_REPORT_ID_6, /* REPORT_ID (0xF0) */ 0x09, 0x07, /* USAGE */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ - 0x26, 0x00,0xff, /* LOGICAL_MAXIMUM (255) */ + 0x26, 0xFF,0x00, /* LOGICAL_MAXIMUM (255) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, 0x3F, /* REPORT_COUNT (64) */ 0x81, 0x82, /* INPUT(Data,Var,Abs,Vol) */ diff --git a/project/at_start_f415/examples/i2s/halfduplex_dma/src/main.c b/project/at_start_f415/examples/i2s/halfduplex_dma/src/main.c index cb06800..ccf220b 100644 --- a/project/at_start_f415/examples/i2s/halfduplex_dma/src/main.c +++ b/project/at_start_f415/examples/i2s/halfduplex_dma/src/main.c @@ -87,7 +87,7 @@ static void i2s_config(void) dma_init_struct.memory_base_addr = (uint32_t)i2s1_buffer_tx; dma_init_struct.memory_data_width = DMA_MEMORY_DATA_WIDTH_HALFWORD; dma_init_struct.memory_inc_enable = TRUE; - dma_init_struct.peripheral_base_addr = (uint32_t)0x4001300C; + dma_init_struct.peripheral_base_addr = (uint32_t)&(SPI1->dt); dma_init_struct.peripheral_data_width = DMA_PERIPHERAL_DATA_WIDTH_HALFWORD; dma_init_struct.peripheral_inc_enable = FALSE; dma_init_struct.priority = DMA_PRIORITY_HIGH; @@ -96,7 +96,7 @@ static void i2s_config(void) dma_init_struct.direction = DMA_DIR_PERIPHERAL_TO_MEMORY; dma_init_struct.memory_base_addr = (uint32_t)i2s2_buffer_rx; - dma_init_struct.peripheral_base_addr = (uint32_t)0x4000380C; + dma_init_struct.peripheral_base_addr = (uint32_t)&(SPI2->dt); dma_init(DMA1_CHANNEL4, &dma_init_struct); crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); diff --git a/project/at_start_f415/examples/spi/use_jtagpin_hardwarecs_dma/src/main.c b/project/at_start_f415/examples/spi/use_jtagpin_hardwarecs_dma/src/main.c index 29e9044..9510a76 100644 --- a/project/at_start_f415/examples/spi/use_jtagpin_hardwarecs_dma/src/main.c +++ b/project/at_start_f415/examples/spi/use_jtagpin_hardwarecs_dma/src/main.c @@ -86,7 +86,7 @@ static void spi_config(void) dma_init_struct.memory_base_addr = (uint32_t)spi2_rx_buffer; dma_init_struct.memory_data_width = DMA_MEMORY_DATA_WIDTH_BYTE; dma_init_struct.memory_inc_enable = TRUE; - dma_init_struct.peripheral_base_addr = (uint32_t)0x4000380C; + dma_init_struct.peripheral_base_addr = (uint32_t)&(SPI2->dt); dma_init_struct.peripheral_data_width = DMA_PERIPHERAL_DATA_WIDTH_BYTE; dma_init_struct.peripheral_inc_enable = FALSE; dma_init_struct.priority = DMA_PRIORITY_MEDIUM; diff --git a/utilities/at32f415_slib_demo/project_l0/readme.txt b/utilities/at32f415_slib_demo/project_l0/readme.txt index be14107..eb57b80 100644 --- a/utilities/at32f415_slib_demo/project_l0/readme.txt +++ b/utilities/at32f415_slib_demo/project_l0/readme.txt @@ -9,8 +9,7 @@ the slib example) describes how to generate an execute-only ip-code (using compiler options), place and protect it (protection using slib) in some preferred sectors in internal flash memory. the fir filter algorithm from cmsis library - is chosen as an example of ip-code to be protected. enabling slib is managed - by software in slib_enable() function. + is chosen as an example of ip-code to be protected. the ip-code function fir_lowpass_filter() is called in main.c file. note that symbol definition file have to be generated in project configuration described @@ -22,9 +21,6 @@ @note the ip-code and ip-data are placed in sector 2 to sector 5 which will be protected. - - activating the slib on these sectors is completed by slib_enable() function - descripes in main file. @note the application needs to ensure that the systick time base is always set to 1 millisecond to have correct operation. @@ -76,12 +72,8 @@ (a) power on the board then load the code, led3 should toggle fast if not press reset button. (b) press the user button key to execute the ip-code called in main.c file. - (c) if macro "use_slib_function" is defined and slib is never enabled, go - to step(e). - (d) if the ip-code is successfully executed, the green led4 should toggle - continuously. else the red led2 toggles continuously. - (e) the slib_enable() function will set slib configuration once the ip-code - is correctly executed. the green led4 will turn on some time and then - a system rest is executed to activate slib. the code will run to step(b). + + (c) if the ip-code is successfully executed, the green led4 should toggle + continuously. else the red led2 toggles continuously. for details, please refer to the application note document AN0065. diff --git a/utilities/at32f415_slib_demo/project_l0/src/main.c b/utilities/at32f415_slib_demo/project_l0/src/main.c index 5ac9c26..b58445a 100644 --- a/utilities/at32f415_slib_demo/project_l0/src/main.c +++ b/utilities/at32f415_slib_demo/project_l0/src/main.c @@ -39,86 +39,11 @@ extern float32_t refOutput[]; * @{ */ -#define USE_SLIB_FUNCTION /* define it when user want to activate slib in this project */ - -#if defined (USE_SLIB_FUNCTION) -#define FLASH_START_ADDR 0x08000000 -#define TEST_SLIB_PSW 0x55665566 -#define SLIB_START_ADDR 0x08001000 -#define SLIB_DATA_ADDR 0x08002000 -#define SLIB_END_ADDR 0x08002800 -#define FLASH_SECTOR_SIZE 0x800 -#define SECTOR_NUM(dwAddr) ((dwAddr & (FLASH_START_ADDR - 1)) / FLASH_SECTOR_SIZE) -#define SECTOR_WORD_CNT (FLASH_SECTOR_SIZE >> 2) /* words per sector */ -#endif #define SNR_THRESHOLD_F32 140.0f #define TEST_LENGTH_SAMPLES 320 -#if defined (USE_SLIB_FUNCTION) -uint32_t dw_start_sector, dw_data_start_sector, dw_end_sector; -uint32_t temp_buf[512]; /* 2kb buffer */ -#endif - static float32_t testOutput[TEST_LENGTH_SAMPLES]; -#if defined (USE_SLIB_FUNCTION) -flash_status_type slib_enable(void); -#endif -void config_flash_interrupt(void); - -/** - * @brief config flash error interrupt. - * @param none - * @retval flash status - */ -void config_flash_interrupt(void) -{ - flash_unlock(); - flash_interrupt_enable(FLASH_ERR_INT, TRUE); - flash_lock(); - /* config nvic priority group */ - nvic_priority_group_config(NVIC_PRIORITY_GROUP_4); - - nvic_irq_enable(FLASH_IRQn, 0, 0); -} - -#if defined (USE_SLIB_FUNCTION) -/** - * @brief config slib enable and program slib area. - * @param none - * @retval flash status - */ -flash_status_type slib_enable(void) -{ - uint32_t *ptr; - uint32_t i, j; - flash_status_type status = FLASH_OPERATE_DONE; - ptr = (uint32_t *)SLIB_START_ADDR; - dw_start_sector = SECTOR_NUM(SLIB_START_ADDR); /* slib start sector */ - dw_data_start_sector = SECTOR_NUM(SLIB_DATA_ADDR); /* slib data sector */ - dw_end_sector = SECTOR_NUM(SLIB_END_ADDR); /* slib end sector */ - flash_unlock(); - status = flash_slib_enable(TEST_SLIB_PSW, dw_start_sector, dw_data_start_sector, dw_end_sector); - if(status != FLASH_OPERATE_DONE) - return status; - for(i = 0; i <= (dw_end_sector - dw_start_sector); i++) - { - memcpy(temp_buf, ptr, FLASH_SECTOR_SIZE); - status = flash_sector_erase(SLIB_START_ADDR + i * FLASH_SECTOR_SIZE); - if(status != FLASH_OPERATE_DONE) - return status; - for(j = 0; j < (FLASH_SECTOR_SIZE >> 2); j++) - { - status = flash_word_program(SLIB_START_ADDR + i * FLASH_SECTOR_SIZE + (j << 2), temp_buf[j]); - if(status != FLASH_OPERATE_DONE) - return status; - } - ptr += SECTOR_WORD_CNT; - } - return status; -} -#endif - /** * @brief main function. * @param none @@ -136,9 +61,6 @@ int main(void) inputf32 = &testInput_f32_1kHz_15kHz[0]; outputf32 = &testOutput[0]; - /* configure flash to generate an interrupt when a write protect error occur */ - config_flash_interrupt(); - /* wait for key button to be pushed, then turn off led3 */ while(at32_button_press() == NO_BUTTON) { @@ -159,28 +81,6 @@ int main(void) else { status = ARM_MATH_SUCCESS; -#if defined (USE_SLIB_FUNCTION) - /* enable slib protection from sector 2 to sector 5 when fir filter ip-code is tested ok */ - if(flash_slib_state_get() == RESET) - { - /* if slib has not been enabled, set slib configuration */ - if(slib_enable() == FLASH_OPERATE_DONE) - { - /* if slib configuration is correctly set, tuen on green led4 */ - at32_led_on(LED4); - delay_sec(3); - - /* execute system reset to activate slib protection */ - nvic_system_reset(); - } - else - { - /* turn on red led2 if slib activation failed */ - at32_led_on(LED2); - while(1); - } - } -#endif } /* infinite loop */