update version to v2.1.4

This commit is contained in:
Artery-MCU
2024-05-13 13:48:59 +08:00
parent 0a93017e07
commit 95481a671d
13 changed files with 21 additions and 126 deletions

View File

@@ -128,7 +128,7 @@ extern "C" {
*/ */
#define __AT32F415_LIBRARY_VERSION_MAJOR (0x02) /*!< [31:24] major version */ #define __AT32F415_LIBRARY_VERSION_MAJOR (0x02) /*!< [31:24] major version */
#define __AT32F415_LIBRARY_VERSION_MIDDLE (0x01) /*!< [23:16] middle 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_RC (0x00) /*!< [7:0] release candidate */
#define __AT32F415_LIBRARY_VERSION ((__AT32F415_LIBRARY_VERSION_MAJOR << 24) | \ #define __AT32F415_LIBRARY_VERSION ((__AT32F415_LIBRARY_VERSION_MAJOR << 24) | \
(__AT32F415_LIBRARY_VERSION_MIDDLE << 16) | \ (__AT32F415_LIBRARY_VERSION_MIDDLE << 16) | \

View File

@@ -78,6 +78,9 @@ typedef enum
CMP_SPEED_SLOW = 0x01, /*!< comparator selected slow speed */ CMP_SPEED_SLOW = 0x01, /*!< comparator selected slow speed */
} cmp_speed_type; } 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 * @brief cmp output type
*/ */

View File

@@ -687,10 +687,10 @@ uint16_t adc_ordinary_conversion_data_get(adc_type *adc_x)
* ADC1. * ADC1.
* @param adc_preempt_channel: select the preempt channel. * @param adc_preempt_channel: select the preempt channel.
* this parameter can be one of the following values: * this parameter can be one of the following values:
* - ADC_PREEMPTED_CHANNEL_1 * - ADC_PREEMPT_CHANNEL_1
* - ADC_PREEMPTED_CHANNEL_2 * - ADC_PREEMPT_CHANNEL_2
* - ADC_PREEMPTED_CHANNEL_3 * - ADC_PREEMPT_CHANNEL_3
* - ADC_PREEMPTED_CHANNEL_4 * - ADC_PREEMPT_CHANNEL_4
* @retval the conversion data for selection preempt channel. * @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) uint16_t adc_preempt_conversion_data_get(adc_type *adc_x, adc_preempt_channel_type adc_preempt_channel)

View File

@@ -136,8 +136,8 @@ typedef struct
uint8_t device_addr; /*!< device address */ uint8_t device_addr; /*!< device address */
uint8_t remote_wakup; /*!< remote wakeup state */ uint8_t remote_wakup; /*!< remote wakeup state */
uint8_t default_config; /*!< usb default config state */ uint32_t default_config; /*!< usb default config state */
uint8_t dev_config; /*!< usb device config state */ uint32_t dev_config; /*!< usb device config state */
uint32_t config_status; /*!< usb configure status */ uint32_t config_status; /*!< usb configure status */
}usbd_core_type; }usbd_core_type;

View File

@@ -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) */ 0x85, HID_REPORT_ID_6, /* REPORT_ID (0xF0) */
0x09, 0x06, /* USAGE */ 0x09, 0x06, /* USAGE */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x26, 0x00,0xff, /* LOGICAL_MAXIMUM (255) */ 0x26, 0xFF,0x00, /* LOGICAL_MAXIMUM (255) */
0x75, 0x08, /* REPORT_SIZE (8) */ 0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (64) */ 0x95, 0x3F, /* REPORT_COUNT (64) */
0x91, 0x02, /* OUTPUT(Data,Var,Abs,Vol) */ 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) */ 0x85, HID_REPORT_ID_6, /* REPORT_ID (0xF0) */
0x09, 0x07, /* USAGE */ 0x09, 0x07, /* USAGE */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x26, 0x00,0xff, /* LOGICAL_MAXIMUM (255) */ 0x26, 0xFF,0x00, /* LOGICAL_MAXIMUM (255) */
0x75, 0x08, /* REPORT_SIZE (8) */ 0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (64) */ 0x95, 0x3F, /* REPORT_COUNT (64) */
0x81, 0x82, /* INPUT(Data,Var,Abs,Vol) */ 0x81, 0x82, /* INPUT(Data,Var,Abs,Vol) */

View File

@@ -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) */ 0x85, HID_REPORT_ID_6, /* REPORT_ID (0xF0) */
0x09, 0x06, /* USAGE */ 0x09, 0x06, /* USAGE */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x26, 0x00,0xff, /* LOGICAL_MAXIMUM (255) */ 0x26, 0xFF,0x00, /* LOGICAL_MAXIMUM (255) */
0x75, 0x08, /* REPORT_SIZE (8) */ 0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (64) */ 0x95, 0x3F, /* REPORT_COUNT (64) */
0x91, 0x02, /* OUTPUT(Data,Var,Abs,Vol) */ 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) */ 0x85, HID_REPORT_ID_6, /* REPORT_ID (0xF0) */
0x09, 0x07, /* USAGE */ 0x09, 0x07, /* USAGE */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x26, 0x00,0xff, /* LOGICAL_MAXIMUM (255) */ 0x26, 0xFF,0x00, /* LOGICAL_MAXIMUM (255) */
0x75, 0x08, /* REPORT_SIZE (8) */ 0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (64) */ 0x95, 0x3F, /* REPORT_COUNT (64) */
0x81, 0x82, /* INPUT(Data,Var,Abs,Vol) */ 0x81, 0x82, /* INPUT(Data,Var,Abs,Vol) */

View File

@@ -87,7 +87,7 @@ static void i2s_config(void)
dma_init_struct.memory_base_addr = (uint32_t)i2s1_buffer_tx; 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_data_width = DMA_MEMORY_DATA_WIDTH_HALFWORD;
dma_init_struct.memory_inc_enable = TRUE; 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_data_width = DMA_PERIPHERAL_DATA_WIDTH_HALFWORD;
dma_init_struct.peripheral_inc_enable = FALSE; dma_init_struct.peripheral_inc_enable = FALSE;
dma_init_struct.priority = DMA_PRIORITY_HIGH; 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.direction = DMA_DIR_PERIPHERAL_TO_MEMORY;
dma_init_struct.memory_base_addr = (uint32_t)i2s2_buffer_rx; 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); dma_init(DMA1_CHANNEL4, &dma_init_struct);
crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE);

View File

@@ -86,7 +86,7 @@ static void spi_config(void)
dma_init_struct.memory_base_addr = (uint32_t)spi2_rx_buffer; 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_data_width = DMA_MEMORY_DATA_WIDTH_BYTE;
dma_init_struct.memory_inc_enable = TRUE; 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_data_width = DMA_PERIPHERAL_DATA_WIDTH_BYTE;
dma_init_struct.peripheral_inc_enable = FALSE; dma_init_struct.peripheral_inc_enable = FALSE;
dma_init_struct.priority = DMA_PRIORITY_MEDIUM; dma_init_struct.priority = DMA_PRIORITY_MEDIUM;

View File

@@ -9,8 +9,7 @@
the slib example) describes how to generate an execute-only ip-code (using 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 compiler options), place and protect it (protection using slib) in some preferred
sectors in internal flash memory. the fir filter algorithm from cmsis library 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 is chosen as an example of ip-code to be protected.
by software in slib_enable() function.
the ip-code function fir_lowpass_filter() is called in main.c file. note that 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 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 @note the ip-code and ip-data are placed in sector 2 to sector 5 which will
be protected. 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 @note the application needs to ensure that the systick time base is always
set to 1 millisecond to have correct operation. 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 (a) power on the board then load the code, led3 should toggle fast if not
press reset button. press reset button.
(b) press the user button key to execute the ip-code called in main.c file. (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). (c) if the ip-code is successfully executed, the green led4 should toggle
(d) if the ip-code is successfully executed, the green led4 should toggle continuously. else the red led2 toggles continuously.
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).
for details, please refer to the application note document AN0065. for details, please refer to the application note document AN0065.

View File

@@ -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 SNR_THRESHOLD_F32 140.0f
#define TEST_LENGTH_SAMPLES 320 #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]; 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. * @brief main function.
* @param none * @param none
@@ -136,9 +61,6 @@ int main(void)
inputf32 = &testInput_f32_1kHz_15kHz[0]; inputf32 = &testInput_f32_1kHz_15kHz[0];
outputf32 = &testOutput[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 */ /* wait for key button to be pushed, then turn off led3 */
while(at32_button_press() == NO_BUTTON) while(at32_button_press() == NO_BUTTON)
{ {
@@ -159,28 +81,6 @@ int main(void)
else else
{ {
status = ARM_MATH_SUCCESS; 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 */ /* infinite loop */