diff --git a/AT32F413_periph_lib_V2.1.5.chm b/AT32F413_periph_lib_V2.1.6.chm similarity index 62% rename from AT32F413_periph_lib_V2.1.5.chm rename to AT32F413_periph_lib_V2.1.6.chm index 9e53319..4ec8ddd 100644 Binary files a/AT32F413_periph_lib_V2.1.5.chm and b/AT32F413_periph_lib_V2.1.6.chm differ diff --git a/document/AT32F413 firmware BSP&Pack_user_guide_EN_2.05.pdf b/document/AT32F413 firmware BSP&Pack_user_guide_EN_2.05.pdf deleted file mode 100644 index 9c91bf7..0000000 Binary files a/document/AT32F413 firmware BSP&Pack_user_guide_EN_2.05.pdf and /dev/null differ diff --git a/document/AT32F413固件库BSP&Pack应用指南.pdf b/document/AT32F413固件库BSP&Pack应用指南.pdf index 820b912..8b885b5 100644 Binary files a/document/AT32F413固件库BSP&Pack应用指南.pdf and b/document/AT32F413固件库BSP&Pack应用指南.pdf differ diff --git a/document/ReleaseNotes_AT32F413_Firmware_Library.pdf b/document/ReleaseNotes_AT32F413_Firmware_Library.pdf new file mode 100644 index 0000000..7b8e601 Binary files /dev/null and b/document/ReleaseNotes_AT32F413_Firmware_Library.pdf differ diff --git a/document/ReleaseNotes_AT32F413_Firmware_Library_Drivers_EN_V2.0.5.pdf b/document/ReleaseNotes_AT32F413_Firmware_Library_Drivers_EN_V2.0.5.pdf deleted file mode 100644 index 43f3fea..0000000 Binary files a/document/ReleaseNotes_AT32F413_Firmware_Library_Drivers_EN_V2.0.5.pdf and /dev/null differ diff --git a/document/ReleaseNotes_AT32F413_Firmware_Library_EN_V2.1.5.pdf b/document/ReleaseNotes_AT32F413_Firmware_Library_EN_V2.1.5.pdf deleted file mode 100644 index 2aaf74a..0000000 Binary files a/document/ReleaseNotes_AT32F413_Firmware_Library_EN_V2.1.5.pdf and /dev/null differ diff --git a/libraries/cmsis/cm4/device_support/at32f413.h b/libraries/cmsis/cm4/device_support/at32f413.h index f2ca109..6c2cfe3 100644 --- a/libraries/cmsis/cm4/device_support/at32f413.h +++ b/libraries/cmsis/cm4/device_support/at32f413.h @@ -124,7 +124,7 @@ extern "C" { */ #define __AT32F413_LIBRARY_VERSION_MAJOR (0x02) /*!< [31:24] major version */ #define __AT32F413_LIBRARY_VERSION_MIDDLE (0x01) /*!< [23:16] middle version */ -#define __AT32F413_LIBRARY_VERSION_MINOR (0x05) /*!< [15:8] minor version */ +#define __AT32F413_LIBRARY_VERSION_MINOR (0x06) /*!< [15:8] minor version */ #define __AT32F413_LIBRARY_VERSION_RC (0x00) /*!< [7:0] release candidate */ #define __AT32F413_LIBRARY_VERSION ((__AT32F413_LIBRARY_VERSION_MAJOR << 24) | \ (__AT32F413_LIBRARY_VERSION_MIDDLE << 16) | \ diff --git a/libraries/drivers/ReleaseNotes_AT32F413_Firmware_Library_Drivers.pdf b/libraries/drivers/ReleaseNotes_AT32F413_Firmware_Library_Drivers.pdf index c73975f..a27bec2 100644 Binary files a/libraries/drivers/ReleaseNotes_AT32F413_Firmware_Library_Drivers.pdf and b/libraries/drivers/ReleaseNotes_AT32F413_Firmware_Library_Drivers.pdf differ diff --git a/libraries/drivers/inc/at32f413_gpio.h b/libraries/drivers/inc/at32f413_gpio.h index dfb2a47..3d6260a 100644 --- a/libraries/drivers/inc/at32f413_gpio.h +++ b/libraries/drivers/inc/at32f413_gpio.h @@ -764,6 +764,7 @@ flag_status gpio_output_data_bit_read(gpio_type *gpio_x, uint16_t pins); uint16_t gpio_output_data_read(gpio_type *gpio_x); void gpio_bits_set(gpio_type *gpio_x, uint16_t pins); void gpio_bits_reset(gpio_type *gpio_x, uint16_t pins); +void gpio_bits_toggle(gpio_type *gpio_x, uint16_t pins); void gpio_bits_write(gpio_type *gpio_x, uint16_t pins, confirm_state bit_state); void gpio_port_write(gpio_type *gpio_x, uint16_t port_value); void gpio_pin_wp_config(gpio_type *gpio_x, uint16_t pins); diff --git a/libraries/drivers/src/at32f413_flash.c b/libraries/drivers/src/at32f413_flash.c index a412fff..809e27d 100644 --- a/libraries/drivers/src/at32f413_flash.c +++ b/libraries/drivers/src/at32f413_flash.c @@ -239,7 +239,7 @@ void flash_spim_unlock(void) { FLASH->unlock3 = FLASH_UNLOCK_KEY1; FLASH->unlock3 = FLASH_UNLOCK_KEY2; - UNUSED(*(__IO uint32_t*)USD_BASE); + UNUSED(*(__IO uint32_t*)USD_BASE); } /** @@ -744,8 +744,8 @@ void flash_interrupt_enable(uint32_t flash_int, confirm_state new_state) */ void flash_spim_model_select(flash_spim_model_type mode) { + UNUSED(*(__IO uint32_t*)USD_BASE); FLASH->select = mode; - /* dummy read */ flash_spim_dummy_read(); } diff --git a/libraries/drivers/src/at32f413_gpio.c b/libraries/drivers/src/at32f413_gpio.c index c35d1be..f5126bb 100644 --- a/libraries/drivers/src/at32f413_gpio.c +++ b/libraries/drivers/src/at32f413_gpio.c @@ -341,6 +341,37 @@ void gpio_bits_reset(gpio_type *gpio_x, uint16_t pins) gpio_x->clr = pins; } +/** + * @brief toggle the selected data port bits. + * @param gpio_x: to select the gpio peripheral. + * this parameter can be one of the following values: + * GPIOA, GPIOB, GPIOC, GPIOD, GPIOF. + * @param pins: gpio pin number + * parameter can be any combination of gpio_pin_x, gpio_pin_x as following values: + * - GPIO_PINS_0 + * - GPIO_PINS_1 + * - GPIO_PINS_2 + * - GPIO_PINS_3 + * - GPIO_PINS_4 + * - GPIO_PINS_5 + * - GPIO_PINS_6 + * - GPIO_PINS_7 + * - GPIO_PINS_8 + * - GPIO_PINS_9 + * - GPIO_PINS_10 + * - GPIO_PINS_11 + * - GPIO_PINS_12 + * - GPIO_PINS_13 + * - GPIO_PINS_14 + * - GPIO_PINS_15 + * - GPIO_PINS_ALL + * @retval none + */ +void gpio_bits_toggle(gpio_type *gpio_x, uint16_t pins) +{ + gpio_x->odt ^= pins; +} + /** * @brief set or clear the selected data port bit. * @param gpio_x: to select the gpio peripheral. diff --git a/libraries/drivers/src/at32f413_rtc.c b/libraries/drivers/src/at32f413_rtc.c index 4a84d51..97ae08c 100644 --- a/libraries/drivers/src/at32f413_rtc.c +++ b/libraries/drivers/src/at32f413_rtc.c @@ -58,11 +58,11 @@ void rtc_counter_set(uint32_t counter_value) } /** - * @brief rtc counter get + * @brief rtc lowlevel counter get * @param none * @retval rtc counter */ -uint32_t rtc_counter_get(void) +uint32_t rtc_lowlevel_counter_get(void) { uint32_t cnt = 0; @@ -72,6 +72,28 @@ uint32_t rtc_counter_get(void) return cnt; } +/** + * @brief rtc counter get + * @param none + * @retval rtc counter + */ +uint32_t rtc_counter_get(void) +{ + uint32_t cnt1 = 0; + uint32_t cnt2 = 0; + + while(1) + { + cnt1 = rtc_lowlevel_counter_get(); + cnt2 = rtc_lowlevel_counter_get(); + + if(cnt1 == cnt2) + { + return cnt1; + } + } +} + /** * @brief rtc divider set * @param div_value (0x0000_0000 ~ 0x000F_FFFF) diff --git a/libraries/drivers/src/at32f413_usart.c b/libraries/drivers/src/at32f413_usart.c index 813bff6..45bba38 100644 --- a/libraries/drivers/src/at32f413_usart.c +++ b/libraries/drivers/src/at32f413_usart.c @@ -90,7 +90,7 @@ void usart_reset(usart_type* usart_x) * this parameter can be one of the following values: * - USART_DATA_8BITS * - USART_DATA_9BITS. - * note: + * note: * - when parity check is disabled, the data bit width is the actual data bit number. * - when parity check is enabled, the data bit width is the actual data bit number minus 1, and the MSB bit is replaced with the parity bit. * @param stop_bit: stop bits transmitted diff --git a/project/at_start_f413/examples/i2s/halfduplex_dma/readme.txt b/project/at_start_f413/examples/i2s/halfduplex_dma/readme.txt index 942341d..64de6be 100644 --- a/project/at_start_f413/examples/i2s/halfduplex_dma/readme.txt +++ b/project/at_start_f413/examples/i2s/halfduplex_dma/readme.txt @@ -8,10 +8,11 @@ this demo is based on the at-start board, in this demo, shows in halfduplex mode how to use dma transfer data. the pins connection as follow: - - pb0 as mck out - - i2s2 slaver i2s1 master - - pb12 <---> pa4(ws) - - pb13 <---> pa5(ck) - - pb15 <---> pa7(sd) + - pb6 as mck out + i2s2 i2s1 + - pb12 <---> pa15 + - pb13 <---> pb3 + - pb15 <---> pb5 + + for more detailed information. please refer to the application note document AN0102. - for more detailed information. please refer to the application note document AN0102. \ No newline at end of file diff --git a/project/at_start_f413/examples/i2s/halfduplex_dma/src/main.c b/project/at_start_f413/examples/i2s/halfduplex_dma/src/main.c index bf7c25b..1a1a5c8 100644 --- a/project/at_start_f413/examples/i2s/halfduplex_dma/src/main.c +++ b/project/at_start_f413/examples/i2s/halfduplex_dma/src/main.c @@ -44,10 +44,6 @@ uint16_t i2s1_buffer_tx[32] = {0x0102, 0x0304, 0x0506, 0x0708, 0x090A, 0x0B0C, uint16_t i2s2_buffer_rx[32]; volatile error_status transfer_status = ERROR; -static void gpio_config(void); -static void i2s_config(void); -error_status buffer_compare(uint16_t* pbuffer1, uint16_t* pbuffer2, uint16_t buffer_length); - /** * @brief buffer_compare function. * @param none @@ -69,17 +65,18 @@ error_status buffer_compare(uint16_t* pbuffer1, uint16_t* pbuffer2, uint16_t buf } /** - * @brief i2s configuration. + * @brief dma configuration. * @param none * @retval none */ -static void i2s_config(void) +static void dma_config(void) { dma_init_type dma_init_struct; - i2s_init_type i2s_init_struct; crm_periph_clock_enable(CRM_DMA1_PERIPH_CLOCK, TRUE); - dma_reset(DMA1_CHANNEL4); + crm_periph_clock_enable(CRM_DMA2_PERIPH_CLOCK, TRUE); + + /* use dma1_channel3 as spi1 transmit channel */ dma_reset(DMA1_CHANNEL3); dma_default_para_init(&dma_init_struct); dma_init_struct.buffer_size = 32; @@ -93,15 +90,36 @@ static void i2s_config(void) dma_init_struct.priority = DMA_PRIORITY_HIGH; dma_init_struct.loop_mode_enable = FALSE; dma_init(DMA1_CHANNEL3, &dma_init_struct); - + + /* use dma1_channel4 as spi2 receive channel */ + dma_reset(DMA1_CHANNEL4); + dma_init_struct.buffer_size = 32; dma_init_struct.direction = DMA_DIR_PERIPHERAL_TO_MEMORY; dma_init_struct.memory_base_addr = (uint32_t)i2s2_buffer_rx; + 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)&(SPI2->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; + dma_init_struct.loop_mode_enable = FALSE; dma_init(DMA1_CHANNEL4, &dma_init_struct); +} +/** + * @brief i2s configuration. + * @param none + * @retval none + */ +static void i2s_config(void) +{ + i2s_init_type i2s_init_struct; + + /* master i2s initialization */ crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); - crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); i2s_default_para_init(&i2s_init_struct); + + /* master transmission mode */ i2s_init_struct.audio_protocol = I2S_AUDIO_PROTOCOL_PHILLIPS; i2s_init_struct.data_channel_format = I2S_DATA_16BIT_CHANNEL_32BIT; i2s_init_struct.mclk_output_enable = TRUE; @@ -109,14 +127,27 @@ static void i2s_config(void) i2s_init_struct.clock_polarity = I2S_CLOCK_POLARITY_LOW; i2s_init_struct.operation_mode = I2S_MODE_MASTER_TX; i2s_init(SPI1, &i2s_init_struct); - - i2s_init_struct.operation_mode =I2S_MODE_SLAVE_RX; + + /* use dma transmit */ + spi_i2s_dma_transmitter_enable(SPI1, TRUE); + + i2s_enable(SPI1, TRUE); + + /* slave i2s initialization */ + crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + + /* slave reception mode */ + i2s_init_struct.audio_protocol = I2S_AUDIO_PROTOCOL_PHILLIPS; + i2s_init_struct.data_channel_format = I2S_DATA_16BIT_CHANNEL_32BIT; + i2s_init_struct.mclk_output_enable = TRUE; + i2s_init_struct.audio_sampling_freq = I2S_AUDIO_FREQUENCY_48K; + i2s_init_struct.clock_polarity = I2S_CLOCK_POLARITY_LOW; + i2s_init_struct.operation_mode = I2S_MODE_SLAVE_RX; i2s_init(SPI2, &i2s_init_struct); - dma_channel_enable(DMA1_CHANNEL3, TRUE); - dma_channel_enable(DMA1_CHANNEL4, TRUE); + /* use dma receive */ spi_i2s_dma_receiver_enable(SPI2, TRUE); - i2s_enable(SPI1, TRUE); + i2s_enable(SPI2, TRUE); } @@ -130,49 +161,54 @@ static void gpio_config(void) gpio_init_type gpio_initstructure; crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); + crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK, TRUE); + gpio_pin_remap_config(SWJTAG_GMUX_010, TRUE); + gpio_pin_remap_config(SPI1_MUX_01, TRUE); - /* master ws pin */ - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; - gpio_initstructure.gpio_pull = GPIO_PULL_UP; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + /* master i2s ws pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pins = GPIO_PINS_4; + gpio_initstructure.gpio_pins = GPIO_PINS_15; gpio_init(GPIOA, &gpio_initstructure); - /* master ck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_5; - gpio_init(GPIOA, &gpio_initstructure); - - /* master sd pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_7; - gpio_init(GPIOA, &gpio_initstructure); - - /* master mck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_0; + /* master i2s ck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_3; gpio_init(GPIOB, &gpio_initstructure); - /* slave ws pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_UP; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_12; + /* master i2s sd pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_5; gpio_init(GPIOB, &gpio_initstructure); - /* slave ck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_13; + /* master i2s mck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_6; gpio_init(GPIOB, &gpio_initstructure); - /* slave sd pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_15; + /* slave i2s ws pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pins = GPIO_PINS_12; + gpio_init(GPIOB, &gpio_initstructure); + + /* slave i2s ck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_13; + gpio_init(GPIOB, &gpio_initstructure); + + /* slave i2s sd pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_15; gpio_init(GPIOB, &gpio_initstructure); } @@ -185,14 +221,25 @@ int main(void) { system_clock_config(); at32_board_init(); - at32_led_off(LED2); - at32_led_off(LED3); - at32_led_off(LED4); + at32_led_on(LED4); gpio_config(); + dma_config(); i2s_config(); - spi_i2s_dma_transmitter_enable(SPI1, TRUE); + + /* enable i2s slave dma to get data */ + dma_channel_enable(DMA1_CHANNEL4, TRUE); + + /* enable i2s master dma to fill data */ + dma_channel_enable(DMA1_CHANNEL3, TRUE); - while(dma_flag_get(DMA1_FDT4_FLAG) == RESET); + /* wait slave i2s data receive end */ + while(dma_flag_get(DMA1_FDT4_FLAG) == RESET) + { + } + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); /* test result:the data check */ transfer_status = buffer_compare(i2s2_buffer_rx, i2s1_buffer_tx, 32); @@ -204,7 +251,7 @@ int main(void) } else { - at32_led_off(LED2); + at32_led_on(LED3); } while(1) { diff --git a/project/at_start_f413/examples/i2s/halfduplex_interrupt/readme.txt b/project/at_start_f413/examples/i2s/halfduplex_interrupt/readme.txt index 8c534b7..b0800aa 100644 --- a/project/at_start_f413/examples/i2s/halfduplex_interrupt/readme.txt +++ b/project/at_start_f413/examples/i2s/halfduplex_interrupt/readme.txt @@ -8,10 +8,11 @@ this demo is based on the at-start board, in this demo, shows in halfduplex mode how to use interrupt transfer data. the pins connection as follow: - - pb0 as mck out + - pb6 as mck out - i2s2 slaver i2s1 master - - pb12 <---> pa4(ws) - - pb13 <---> pa5(ck) - - pb15 <---> pa7(sd) + - pb12 <---> pa15(ws) + - pb13 <---> pb3(ck) + - pb15 <---> pb5(sd) + + for more detailed information. please refer to the application note document AN0102. - for more detailed information. please refer to the application note document AN0102. \ No newline at end of file diff --git a/project/at_start_f413/examples/i2s/halfduplex_interrupt/src/at32f413_int.c b/project/at_start_f413/examples/i2s/halfduplex_interrupt/src/at32f413_int.c index 55b41a5..5a8656b 100644 --- a/project/at_start_f413/examples/i2s/halfduplex_interrupt/src/at32f413_int.c +++ b/project/at_start_f413/examples/i2s/halfduplex_interrupt/src/at32f413_int.c @@ -24,11 +24,6 @@ /* includes ------------------------------------------------------------------*/ #include "at32f413_int.h" -#include "at32f413_board.h" - -extern uint16_t i2s1_buffer_tx[]; -extern uint16_t i2s2_buffer_rx[]; -extern __IO uint32_t tx_index, rx_index; /** @addtogroup AT32F413_periph_examples * @{ @@ -135,37 +130,6 @@ void SysTick_Handler(void) { } - -/** - * @brief This function handles the spi2 interrupt request. - * @param None - * @retval None - */ - void SPI2_IRQHandler(void) -{ - if(spi_i2s_interrupt_flag_get(SPI2, SPI_I2S_RDBF_FLAG) != RESET) - { - i2s2_buffer_rx[rx_index++] = spi_i2s_data_receive(SPI2); - } -} - -/** - * @brief This function handles the spi1 interrupt request. - * @param None - * @retval None - */ -void SPI1_IRQHandler(void) -{ - if(spi_i2s_interrupt_flag_get(SPI1, SPI_I2S_TDBE_FLAG) != RESET) - { - spi_i2s_data_transmit(SPI1, i2s1_buffer_tx[tx_index++]); - if(tx_index == 32) - { - spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, FALSE); - } - } -} - /** * @} */ diff --git a/project/at_start_f413/examples/i2s/halfduplex_interrupt/src/main.c b/project/at_start_f413/examples/i2s/halfduplex_interrupt/src/main.c index 7c287a2..943553c 100644 --- a/project/at_start_f413/examples/i2s/halfduplex_interrupt/src/main.c +++ b/project/at_start_f413/examples/i2s/halfduplex_interrupt/src/main.c @@ -44,11 +44,6 @@ uint16_t i2s2_buffer_rx[32]; __IO uint32_t tx_index = 0, rx_index = 0; volatile error_status transfer_status1 = ERROR, transfer_status2 = ERROR; -static void gpio_config(void); -static void i2s_config(i2s_data_channel_format_type format, i2s_audio_sampling_freq_type freq); -error_status buffer_compare(uint16_t* pbuffer1, uint16_t* pbuffer2, uint16_t buffer_length); -error_status buffer_compare_24bits(uint16_t* pbuffer1, uint16_t* pbuffer2, uint16_t buffer_length); - /** * @brief buffer_compare function. * @param none @@ -100,15 +95,14 @@ error_status buffer_compare_24bits(uint16_t* pbuffer1, uint16_t* pbuffer2, uint1 static void i2s_config(i2s_data_channel_format_type format, i2s_audio_sampling_freq_type freq) { i2s_init_type i2s_init_struct; - + + /* master i2s initialization */ crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); - crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); - nvic_irq_enable(SPI1_IRQn, 0, 0); - nvic_irq_enable(SPI2_IRQn, 0, 0); - spi_i2s_reset(SPI2); spi_i2s_reset(SPI1); i2s_default_para_init(&i2s_init_struct); + + /* master transmission mode */ i2s_init_struct.audio_protocol = I2S_AUDIO_PROTOCOL_PHILLIPS; i2s_init_struct.data_channel_format = format; i2s_init_struct.mclk_output_enable = TRUE; @@ -116,14 +110,26 @@ static void i2s_config(i2s_data_channel_format_type format, i2s_audio_sampling_f i2s_init_struct.clock_polarity = I2S_CLOCK_POLARITY_LOW; i2s_init_struct.operation_mode = I2S_MODE_MASTER_TX; i2s_init(SPI1, &i2s_init_struct); - + + /* enable transmit data buffer empty interrupt */ + spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, TRUE); + + /* slave i2s initialization */ + crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + nvic_irq_enable(SPI2_IRQn, 0, 0); + spi_i2s_reset(SPI2); + + /* slave reception mode */ + i2s_init_struct.audio_protocol = I2S_AUDIO_PROTOCOL_PHILLIPS; + i2s_init_struct.data_channel_format = format; + i2s_init_struct.mclk_output_enable = TRUE; + i2s_init_struct.audio_sampling_freq = freq; + i2s_init_struct.clock_polarity = I2S_CLOCK_POLARITY_LOW; i2s_init_struct.operation_mode =I2S_MODE_SLAVE_RX; i2s_init(SPI2, &i2s_init_struct); - + + /* enable receive data buffer full interrupt */ spi_i2s_interrupt_enable(SPI2, SPI_I2S_RDBF_INT, TRUE); - spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, TRUE); - i2s_enable(SPI2, TRUE); - i2s_enable(SPI1, TRUE); } /** @@ -136,50 +142,85 @@ static void gpio_config(void) gpio_init_type gpio_initstructure; crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); + crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK, TRUE); + gpio_pin_remap_config(SWJTAG_GMUX_010, TRUE); + gpio_pin_remap_config(SPI1_MUX_01, TRUE); - /* master ws pin */ - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; - gpio_initstructure.gpio_pull = GPIO_PULL_UP; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + /* master i2s ws pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pins = GPIO_PINS_4; + gpio_initstructure.gpio_pins = GPIO_PINS_15; gpio_init(GPIOA, &gpio_initstructure); - /* master ck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_5; - gpio_init(GPIOA, &gpio_initstructure); - - /* master sd pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_7; - gpio_init(GPIOA, &gpio_initstructure); - - /* master mck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_0; + /* master i2s ck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_3; gpio_init(GPIOB, &gpio_initstructure); - /* slave ws pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_UP; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_12; + /* master i2s sd pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_5; gpio_init(GPIOB, &gpio_initstructure); - /* slave ck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_13; + /* master i2s mck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_6; gpio_init(GPIOB, &gpio_initstructure); - /* slave sd pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_15; + /* slave i2s ws pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pins = GPIO_PINS_12; gpio_init(GPIOB, &gpio_initstructure); + + /* slave i2s ck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_13; + gpio_init(GPIOB, &gpio_initstructure); + + /* slave i2s sd pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_15; + gpio_init(GPIOB, &gpio_initstructure); +} + +/** + * @brief spi2 interrupt function + * @param none + * @retval none + */ + void SPI2_IRQHandler(void) +{ + if(spi_i2s_interrupt_flag_get(SPI2, SPI_I2S_RDBF_FLAG) != RESET) + { + i2s2_buffer_rx[rx_index++] = spi_i2s_data_receive(SPI2); + } +} + +/** + * @brief spi1 interrupt function + * @param none + * @retval none + */ +void SPI1_IRQHandler(void) +{ + if(spi_i2s_interrupt_flag_get(SPI1, SPI_I2S_TDBE_FLAG) != RESET) + { + spi_i2s_data_transmit(SPI1, i2s1_buffer_tx[tx_index++]); + if(tx_index == 32) + { + spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, FALSE); + } + } } /** @@ -193,22 +234,45 @@ int main(void) nvic_priority_group_config(NVIC_PRIORITY_GROUP_4); system_clock_config(); at32_board_init(); - at32_led_off(LED2); - at32_led_off(LED3); - at32_led_off(LED4); + at32_led_on(LED4); gpio_config(); i2s_config(I2S_DATA_16BIT_CHANNEL_32BIT, I2S_AUDIO_FREQUENCY_48K); + + /* enable slave and master i2s to start communication */ + i2s_enable(SPI2, TRUE); + i2s_enable(SPI1, TRUE); + + /* wait data receive end */ while(rx_index < 32); + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); /* test result:the data check */ transfer_status1 = buffer_compare(i2s2_buffer_rx, i2s1_buffer_tx, 32); - for(index = 0; index < 32; index++) i2s2_buffer_rx[index] = 0; + /* receive buffer clear */ tx_index = 0; rx_index = 0; - + for(index = 0; index < 32; index++) + { + i2s2_buffer_rx[index] = 0; + } + + /* change frame format */ i2s_config(I2S_DATA_24BIT_CHANNEL_32BIT, I2S_AUDIO_FREQUENCY_16K); + + /* enable slave and master i2s to start communication */ + i2s_enable(SPI2, TRUE); + i2s_enable(SPI1, TRUE); + + /* wait data receive end */ while(rx_index < 32); + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); /* test result:the data check */ transfer_status2 = buffer_compare_24bits(i2s2_buffer_rx, i2s1_buffer_tx, 32); @@ -220,7 +284,7 @@ int main(void) } else { - at32_led_off(LED2); + at32_led_on(LED3); } while(1) diff --git a/project/at_start_f413/examples/i2s/spii2s_switch_halfduplex_polling/readme.txt b/project/at_start_f413/examples/i2s/spii2s_switch_halfduplex_polling/readme.txt index 843f6a3..6086288 100644 --- a/project/at_start_f413/examples/i2s/spii2s_switch_halfduplex_polling/readme.txt +++ b/project/at_start_f413/examples/i2s/spii2s_switch_halfduplex_polling/readme.txt @@ -9,10 +9,9 @@ mode how to use polling transfer data. use the mode switch to realize spi and i2s communication. the pins connection as follow: - - pb0 as mck out - i2s2 slaver i2s1 master - - pb12 <---> pa4(ws) - - pb13 <---> pa5(ck) - - pb15 <---> pa7(sd) + - pb12 <---> pa15(ws) + - pb13 <---> pb3(ck) + - pb15 <---> pb5(sd) for more detailed information. please refer to the application note document AN0102. diff --git a/project/at_start_f413/examples/i2s/spii2s_switch_halfduplex_polling/src/main.c b/project/at_start_f413/examples/i2s/spii2s_switch_halfduplex_polling/src/main.c index 2415495..30289fb 100644 --- a/project/at_start_f413/examples/i2s/spii2s_switch_halfduplex_polling/src/main.c +++ b/project/at_start_f413/examples/i2s/spii2s_switch_halfduplex_polling/src/main.c @@ -34,6 +34,9 @@ * @{ */ +#define SPI_MASTER_CS_HIGH gpio_bits_set(GPIOA, GPIO_PINS_15) +#define SPI_MASTER_CS_LOW gpio_bits_reset(GPIOA, GPIO_PINS_15) + uint16_t i2s1_buffer_tx[32] = {0x0102, 0x0304, 0x0506, 0x0708, 0x090A, 0x0B0C, 0x0D0E, 0x0F10, 0x1112, 0x1314, 0x1516, 0x1718, 0x191A, 0x1B1C, 0x1D1E, 0x1F20, 0x2122, 0x2324, @@ -53,11 +56,6 @@ uint16_t spi2_buffer_rx[32]; __IO uint32_t tx_index = 0, rx_index = 0; volatile error_status transfer_status1 = ERROR, transfer_status2 = ERROR, transfer_status3 = ERROR; -static void gpio_config(void); -static void spi_config(void); -static void i2s_config(i2s_operation_mode_type i2s1_mode, i2s_operation_mode_type i2s2_mode); -error_status buffer_compare(uint16_t* pbuffer1, uint16_t* pbuffer2, uint16_t buffer_length); - /** * @brief buffer_compare function. * @param none @@ -86,13 +84,12 @@ error_status buffer_compare(uint16_t* pbuffer1, uint16_t* pbuffer2, uint16_t buf static void i2s_config(i2s_operation_mode_type i2s1_mode, i2s_operation_mode_type i2s2_mode) { i2s_init_type i2s_init_struct; - + + /* i2s1 initialization */ crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); - crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); - - spi_i2s_reset(SPI2); spi_i2s_reset(SPI1); i2s_default_para_init(&i2s_init_struct); + i2s_init_struct.audio_protocol = I2S_AUDIO_PROTOCOL_PHILLIPS; i2s_init_struct.data_channel_format = I2S_DATA_16BIT_CHANNEL_32BIT; i2s_init_struct.mclk_output_enable = FALSE; @@ -100,7 +97,15 @@ static void i2s_config(i2s_operation_mode_type i2s1_mode, i2s_operation_mode_typ i2s_init_struct.clock_polarity = I2S_CLOCK_POLARITY_LOW; i2s_init_struct.operation_mode = i2s1_mode; i2s_init(SPI1, &i2s_init_struct); - + + /* i2s2 initialization */ + crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + spi_i2s_reset(SPI2); + i2s_init_struct.audio_protocol = I2S_AUDIO_PROTOCOL_PHILLIPS; + i2s_init_struct.data_channel_format = I2S_DATA_16BIT_CHANNEL_32BIT; + i2s_init_struct.mclk_output_enable = FALSE; + i2s_init_struct.audio_sampling_freq = I2S_AUDIO_FREQUENCY_48K; + i2s_init_struct.clock_polarity = I2S_CLOCK_POLARITY_LOW; i2s_init_struct.operation_mode =i2s2_mode; i2s_init(SPI2, &i2s_init_struct); } @@ -113,12 +118,13 @@ static void i2s_config(i2s_operation_mode_type i2s1_mode, i2s_operation_mode_typ static void spi_config(void) { spi_init_type spi_init_struct; + + /* master spi initialization */ crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); - crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); - - spi_i2s_reset(SPI2); spi_i2s_reset(SPI1); spi_default_para_init(&spi_init_struct); + + /* single line bidirectional half duplex mode-transmitting */ spi_init_struct.transmission_mode = SPI_TRANSMIT_HALF_DUPLEX_TX; spi_init_struct.master_slave_mode =SPI_MODE_MASTER; spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; @@ -128,68 +134,92 @@ static void spi_config(void) spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; spi_init_struct.cs_mode_selection = SPI_CS_SOFTWARE_MODE; spi_init(SPI1, &spi_init_struct); - + + spi_enable(SPI1, TRUE); + + /* slave spi initialization */ + crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + spi_i2s_reset(SPI2); + + /* dual line unidirectional simplex receive-only mode */ spi_init_struct.transmission_mode = SPI_TRANSMIT_SIMPLEX_RX; spi_init_struct.master_slave_mode =SPI_MODE_SLAVE; + spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; + spi_init_struct.first_bit_transmission = SPI_FIRST_BIT_MSB; + spi_init_struct.frame_bit_num = SPI_FRAME_16BIT; + spi_init_struct.clock_polarity = SPI_CLOCK_POLARITY_LOW; + spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; + spi_init_struct.cs_mode_selection = SPI_CS_HARDWARE_MODE; spi_init(SPI2, &spi_init_struct); spi_enable(SPI2, TRUE); - spi_enable(SPI1, TRUE); } /** * @brief gpio configuration. - * @param none + * @param spi_i2s_mode:select spi or i2s to be use + * - 0 (spi mode) + * - 1 (i2s mode) * @retval none */ -static void gpio_config(void) +static void gpio_config(uint16_t spi_i2s_mode) { gpio_init_type gpio_initstructure; crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); + crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK, TRUE); + gpio_pin_remap_config(SWJTAG_GMUX_010, TRUE); + gpio_pin_remap_config(SPI1_MUX_01, TRUE); - /* master ws pin */ - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; - gpio_initstructure.gpio_pull = GPIO_PULL_UP; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + /* master ws/cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pins = GPIO_PINS_4; + gpio_initstructure.gpio_pins = GPIO_PINS_15; + if(spi_i2s_mode == 0) + { + gpio_initstructure.gpio_mode = GPIO_MODE_OUTPUT; + } + else + { + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + } gpio_init(GPIOA, &gpio_initstructure); + if(spi_i2s_mode == 0) + { + /* non communication time: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; + } /* master ck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_5; - gpio_init(GPIOA, &gpio_initstructure); + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pins = GPIO_PINS_3; + gpio_init(GPIOB, &gpio_initstructure); /* master sd pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_7; - gpio_init(GPIOA, &gpio_initstructure); - - /* master mck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_0; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_pins = GPIO_PINS_5; gpio_init(GPIOB, &gpio_initstructure); /* slave ws pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_UP; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_12; + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pins = GPIO_PINS_12; gpio_init(GPIOB, &gpio_initstructure); /* slave ck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_13; + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_pins = GPIO_PINS_13; gpio_init(GPIOB, &gpio_initstructure); /* slave sd pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_15; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_pins = GPIO_PINS_15; gpio_init(GPIOB, &gpio_initstructure); } @@ -203,53 +233,97 @@ int main(void) __IO uint32_t index = 0; system_clock_config(); at32_board_init(); - at32_led_off(LED2); - at32_led_off(LED3); - at32_led_off(LED4); - gpio_config(); + at32_led_on(LED4); + + /* first: i2s communication */ + gpio_config(1); i2s_config(I2S_MODE_MASTER_TX, I2S_MODE_SLAVE_RX); i2s_enable(SPI2, TRUE); i2s_enable(SPI1, TRUE); while(rx_index < 32) { + /* i2s transmit data fill */ while(spi_i2s_flag_get(SPI1, SPI_I2S_TDBE_FLAG) == RESET); spi_i2s_data_transmit(SPI1, i2s1_buffer_tx[tx_index++]); + + /* i2s receive data get */ while(spi_i2s_flag_get(SPI2, SPI_I2S_RDBF_FLAG) == RESET); i2s2_buffer_rx[rx_index++] = spi_i2s_data_receive(SPI2); } + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); /* test result:the data check */ transfer_status1 = buffer_compare(i2s2_buffer_rx, i2s1_buffer_tx, 32); + /* receive buffer clear */ tx_index = 0; rx_index = 0; + for(index = 0; index < 32; index++) + { + i2s2_buffer_rx[index] = 0; + } + + /* second: spi communication */ + gpio_config(0); spi_config(); + + /* start communication: master pull down CS pin select slave */ + SPI_MASTER_CS_LOW; + while(rx_index < 32) { + /* spi transmit data fill */ while(spi_i2s_flag_get(SPI1, SPI_I2S_TDBE_FLAG) == RESET); spi_i2s_data_transmit(SPI1, spi1_buffer_tx[tx_index++]); + + /* spi receive data get */ while(spi_i2s_flag_get(SPI2, SPI_I2S_RDBF_FLAG) == RESET); spi2_buffer_rx[rx_index++] = spi_i2s_data_receive(SPI2); } + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); + + /* end communication: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; /* test result:the data check */ transfer_status2 = buffer_compare(spi2_buffer_rx, spi1_buffer_tx, 32); - for(index = 0; index < 32; index++) i2s2_buffer_rx[index] = 0; + /* receive buffer clear */ tx_index = 0; rx_index = 0; + for(index = 0; index < 32; index++) + { + i2s2_buffer_rx[index] = 0; + } + + /* third: i2s communication */ + gpio_config(1); i2s_config(I2S_MODE_SLAVE_TX, I2S_MODE_MASTER_RX); + + /* when slave transmission mode,the slave trans data need fill in advance */ while(spi_i2s_flag_get(SPI1, SPI_I2S_TDBE_FLAG) == RESET); spi_i2s_data_transmit(SPI1, i2s1_buffer_tx[tx_index++]); + i2s_enable(SPI1, TRUE); i2s_enable(SPI2, TRUE); while(rx_index < 32) { + /* i2s receive data get */ while(spi_i2s_flag_get(SPI2, SPI_I2S_RDBF_FLAG) == RESET); i2s2_buffer_rx[rx_index++] = spi_i2s_data_receive(SPI2); + + /* i2s transmit data fill */ while(spi_i2s_flag_get(SPI1, SPI_I2S_TDBE_FLAG) == RESET); spi_i2s_data_transmit(SPI1, i2s1_buffer_tx[tx_index++]); } + + /* master half duplex receiving mode,the busy flag isnot usefull */ /* test result:the data check */ transfer_status3 = buffer_compare(i2s2_buffer_rx, i2s1_buffer_tx, 32); @@ -261,7 +335,7 @@ int main(void) } else { - at32_led_off(LED2); + at32_led_on(LED3); } while(1) { diff --git a/project/at_start_f413/examples/pwc/deepsleep_rtc/src/main.c b/project/at_start_f413/examples/pwc/deepsleep_rtc/src/main.c index c03d424..422a483 100644 --- a/project/at_start_f413/examples/pwc/deepsleep_rtc/src/main.c +++ b/project/at_start_f413/examples/pwc/deepsleep_rtc/src/main.c @@ -124,11 +124,14 @@ void system_clock_recover(void) */ int main(void) { - __IO uint32_t index = 0; + crm_clocks_freq_type crm_clocks_freq_struct = {0}; __IO uint32_t systick_index = 0; /* congfig the system clock */ system_clock_config(); + + /* get system clock */ + crm_clocks_freq_get(&crm_clocks_freq_struct); /* init at start board */ at32_board_init(); @@ -179,8 +182,18 @@ int main(void) at32_led_on(LED2); - /* wait 3 LICK cycles to ensureclock stable */ - delay_us(5); + /* wait 3 LICK(maximum 120us) cycles to ensure clock stable */ + /* when wakeup from deepsleep,system clock source changes to HICK */ + if((CRM->misc3_bit.hick_to_sclk == TRUE) && (CRM->misc1_bit.hickdiv == TRUE)) + { + /* HICK is 48MHz */ + delay_us(((120 * 6 * HICK_VALUE) /crm_clocks_freq_struct.sclk_freq) + 1); + } + else + { + /* HICK is 8MHz */ + delay_us(((120 * HICK_VALUE) /crm_clocks_freq_struct.sclk_freq) + 1); + } /* wake up from deep sleep mode, congfig the system clock */ system_clock_recover(); diff --git a/project/at_start_f413/examples/spi/crc_transfer_polling/readme.txt b/project/at_start_f413/examples/spi/crc_transfer_polling/readme.txt index 9c89d4c..ec29e71 100644 --- a/project/at_start_f413/examples/spi/crc_transfer_polling/readme.txt +++ b/project/at_start_f413/examples/spi/crc_transfer_polling/readme.txt @@ -9,8 +9,10 @@ crc value by polling mode. the pins connection as follow: - spi2 slaver spi1 master + pb12(cs) <---> pa4(cs) pb13(sck) <---> pa5(sck) pb14(miso) <---> pa6(miso) pb15(mosi) <---> pa7(mosi) - for more detailed information. please refer to the application note document AN0102. \ No newline at end of file + for more detailed information. please refer to the application note document AN0102. + diff --git a/project/at_start_f413/examples/spi/crc_transfer_polling/src/main.c b/project/at_start_f413/examples/spi/crc_transfer_polling/src/main.c index 097b872..d07d756 100644 --- a/project/at_start_f413/examples/spi/crc_transfer_polling/src/main.c +++ b/project/at_start_f413/examples/spi/crc_transfer_polling/src/main.c @@ -34,7 +34,9 @@ * @{ */ -#define BUFFER_SIZE 32 +#define SPI_MASTER_CS_HIGH gpio_bits_set(GPIOA, GPIO_PINS_4) +#define SPI_MASTER_CS_LOW gpio_bits_reset(GPIOA, GPIO_PINS_4) +#define BUFFER_SIZE 32 uint16_t spi1_tx_buffer[BUFFER_SIZE] = {0x0102, 0x0304, 0x0506, 0x0708, 0x090A, 0x0B0C, 0x0D0E, 0x0F10, 0x1112, 0x1314, 0x1516, 0x1718, 0x191A, 0x1B1C, 0x1D1E, 0x1F20, @@ -49,10 +51,6 @@ uint32_t tx_index = 0, rx_index = 0; __IO uint16_t crc1_value = 0, crc2_value = 0; volatile error_status transfer_status1 = ERROR, transfer_status2 = ERROR; -static void gpio_config(void); -static void spi_config(void); -error_status buffer_compare(uint16_t* pbuffer1, uint16_t* pbuffer2, uint16_t buffer_length); - /** * @brief buffer compare function. * @param pbuffer1, pbuffer2: buffers to be compared. @@ -81,9 +79,12 @@ error_status buffer_compare(uint16_t* pbuffer1, uint16_t* pbuffer2, uint16_t buf static void spi_config(void) { spi_init_type spi_init_struct; + + /* master spi initialization */ crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); - crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); spi_default_para_init(&spi_init_struct); + + /* dual line unidirectional full-duplex mode */ spi_init_struct.transmission_mode = SPI_TRANSMIT_FULL_DUPLEX; spi_init_struct.master_slave_mode = SPI_MODE_MASTER; spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; @@ -93,15 +94,31 @@ static void spi_config(void) spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; spi_init_struct.cs_mode_selection = SPI_CS_SOFTWARE_MODE; spi_init(SPI1, &spi_init_struct); - - spi_init_struct.master_slave_mode = SPI_MODE_SLAVE; - spi_init(SPI2, &spi_init_struct); - + + /* hardware crc calculation config */ spi_crc_polynomial_set(SPI1, 7); - spi_crc_polynomial_set(SPI2, 7); spi_crc_enable(SPI1, TRUE); - spi_crc_enable(SPI2, TRUE); + spi_enable(SPI1, TRUE); + + /* slave spi initialization */ + crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + + /* dual line unidirectional full-duplex mode */ + spi_init_struct.transmission_mode = SPI_TRANSMIT_FULL_DUPLEX; + spi_init_struct.master_slave_mode = SPI_MODE_SLAVE; + spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; + spi_init_struct.first_bit_transmission = SPI_FIRST_BIT_MSB; + spi_init_struct.frame_bit_num = SPI_FRAME_16BIT; + spi_init_struct.clock_polarity = SPI_CLOCK_POLARITY_LOW; + spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; + spi_init_struct.cs_mode_selection = SPI_CS_HARDWARE_MODE; + spi_init(SPI2, &spi_init_struct); + + /* hardware crc calculation config */ + spi_crc_polynomial_set(SPI2, 7); + spi_crc_enable(SPI2, TRUE); + spi_enable(SPI2, TRUE); } @@ -115,47 +132,72 @@ static void gpio_config(void) gpio_init_type gpio_initstructure; crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); - - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + + /* master spi cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_OUTPUT; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pins = GPIO_PINS_5; + gpio_initstructure.gpio_pins = GPIO_PINS_4; gpio_init(GPIOA, &gpio_initstructure); - - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + + /* non communication time: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; + + /* master spi sck pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pins = GPIO_PINS_6; + gpio_initstructure.gpio_pins = GPIO_PINS_5; gpio_init(GPIOA, &gpio_initstructure); - - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + + /* master spi miso pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pins = GPIO_PINS_7; + gpio_initstructure.gpio_pins = GPIO_PINS_6; gpio_init(GPIOA, &gpio_initstructure); - - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + + /* master spi mosi pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pins = GPIO_PINS_13; + gpio_initstructure.gpio_pins = GPIO_PINS_7; + gpio_init(GPIOA, &gpio_initstructure); + + /* slave spi cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pins = GPIO_PINS_12; gpio_init(GPIOB, &gpio_initstructure); - - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + + /* slave spi sck pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pins = GPIO_PINS_14; + gpio_initstructure.gpio_pins = GPIO_PINS_13; gpio_init(GPIOB, &gpio_initstructure); - - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + + /* slave spi miso pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pins = GPIO_PINS_15; + gpio_initstructure.gpio_pins = GPIO_PINS_14; + gpio_init(GPIOB, &gpio_initstructure); + + /* slave spi mosi pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pins = GPIO_PINS_15; gpio_init(GPIOB, &gpio_initstructure); } @@ -168,35 +210,58 @@ int main(void) { system_clock_config(); at32_board_init(); + at32_led_on(LED4); gpio_config(); spi_config(); - + + /* start communication: master pull down CS pin select slave */ + SPI_MASTER_CS_LOW; + /* transfer procedure:the "BUFFER_SIZE-1" data transfer */ while(tx_index < BUFFER_SIZE - 1) { + /* slave and master transmit data fill */ while(spi_i2s_flag_get(SPI2, SPI_I2S_TDBE_FLAG) == RESET); spi_i2s_data_transmit(SPI2, spi2_tx_buffer[tx_index]); while(spi_i2s_flag_get(SPI1, SPI_I2S_TDBE_FLAG) == RESET); spi_i2s_data_transmit(SPI1, spi1_tx_buffer[tx_index++]); + + /* slave and master receive data get */ while(spi_i2s_flag_get(SPI2, SPI_I2S_RDBF_FLAG) == RESET); spi2_rx_buffer[rx_index] = spi_i2s_data_receive(SPI2); while(spi_i2s_flag_get(SPI1, SPI_I2S_RDBF_FLAG) == RESET); spi1_rx_buffer[rx_index++] = spi_i2s_data_receive(SPI1); } + + /* wait master and slave transmit data buffer empty */ while(spi_i2s_flag_get(SPI1, SPI_I2S_TDBE_FLAG) == RESET); while(spi_i2s_flag_get(SPI2, SPI_I2S_TDBE_FLAG) == RESET); /* transfer procedure:the last data and crc transfer */ + /* slave the last transmit data fill and crc transfer setting */ spi_i2s_data_transmit(SPI2, spi2_tx_buffer[tx_index]); spi_crc_next_transmit(SPI2); + + /* master the last transmit data fill and crc transfer setting */ spi_i2s_data_transmit(SPI1, spi1_tx_buffer[tx_index]); spi_crc_next_transmit(SPI1); + + /* wait master and slave the last data transfer end */ while(spi_i2s_flag_get(SPI1, SPI_I2S_RDBF_FLAG) == RESET); spi1_rx_buffer[rx_index] = spi_i2s_data_receive(SPI1); while(spi_i2s_flag_get(SPI2, SPI_I2S_RDBF_FLAG) == RESET); spi2_rx_buffer[rx_index] = spi_i2s_data_receive(SPI2); + + /* wait master and slave the crc transfer end */ while(spi_i2s_flag_get(SPI1, SPI_I2S_RDBF_FLAG) == RESET); while(spi_i2s_flag_get(SPI2, SPI_I2S_RDBF_FLAG) == RESET); + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); + + /* end communication: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; /* test result:the data and crc check */ transfer_status1 = buffer_compare(spi2_rx_buffer, spi1_tx_buffer, BUFFER_SIZE); @@ -214,14 +279,14 @@ int main(void) crc1_value = spi_i2s_data_receive(SPI1); crc2_value = spi_i2s_data_receive(SPI2); - /* test result indicate:if success,led2 lights */ + /* test result indicate:if SUCCESS ,led2 lights */ if((transfer_status1 == SUCCESS) && (transfer_status2 == SUCCESS)) { at32_led_on(LED2); } else { - at32_led_off(LED2); + at32_led_on(LED3); } while(1) { diff --git a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/inc/at32f413_clock.h b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/inc/at32f413_clock.h similarity index 100% rename from project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/inc/at32f413_clock.h rename to project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/inc/at32f413_clock.h diff --git a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/inc/at32f413_conf.h b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/inc/at32f413_conf.h similarity index 100% rename from project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/inc/at32f413_conf.h rename to project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/inc/at32f413_conf.h diff --git a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/inc/at32f413_int.h b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/inc/at32f413_int.h similarity index 100% rename from project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/inc/at32f413_int.h rename to project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/inc/at32f413_int.h diff --git a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/mdk_v5/use_jtagpin_hardwarecs_dma.uvoptx b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/mdk_v5/fullduplex_dma_jtagpin.uvoptx similarity index 99% rename from project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/mdk_v5/use_jtagpin_hardwarecs_dma.uvoptx rename to project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/mdk_v5/fullduplex_dma_jtagpin.uvoptx index 51765ac..2f24c98 100644 --- a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/mdk_v5/use_jtagpin_hardwarecs_dma.uvoptx +++ b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/mdk_v5/fullduplex_dma_jtagpin.uvoptx @@ -22,7 +22,7 @@ - use_jtagpin_hardwarecs_dma + fullduplex_dma_jtagpin 0x4 ARM-ADS diff --git a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/mdk_v5/use_jtagpin_hardwarecs_dma.uvprojx b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/mdk_v5/fullduplex_dma_jtagpin.uvprojx similarity index 99% rename from project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/mdk_v5/use_jtagpin_hardwarecs_dma.uvprojx rename to project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/mdk_v5/fullduplex_dma_jtagpin.uvprojx index 116ee44..0f3c0a0 100644 --- a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/mdk_v5/use_jtagpin_hardwarecs_dma.uvprojx +++ b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/mdk_v5/fullduplex_dma_jtagpin.uvprojx @@ -7,7 +7,7 @@ - use_jtagpin_hardwarecs_dma + fullduplex_dma_jtagpin 0x4 ARM-ADS 5060960::V5.06 update 7 (build 960)::.\ARMCC @@ -48,7 +48,7 @@ 1 .\objects\ - use_jtagpin_hardwarecs_dma + fullduplex_dma_jtagpin 1 0 1 @@ -482,7 +482,7 @@ - <Project Info> + fullduplex_dma_jtagpin 0 1 diff --git a/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/readme.txt b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/readme.txt new file mode 100644 index 0000000..73aba43 --- /dev/null +++ b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/readme.txt @@ -0,0 +1,19 @@ +/** + ************************************************************************** + * @file readme.txt + * @brief readme + ************************************************************************** + */ + + this demo is based on the at-start board, in this demo, shows how to use + dma recieve data. spi1 use jtag pin as spi pin,and config spi in hardware + cs mode. + the pins connection as follow: + - spi2 slave spi1 master + pb12(cs) <---> pa15(cs) + pb13(sck) <---> pb3(sck) + pb14(miso) <---> pb4(miso) + pb15(mosi) <---> pb5(mosi) + + for more detailed information. please refer to the application note document AN0102. + diff --git a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/src/at32f413_clock.c b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/src/at32f413_clock.c similarity index 100% rename from project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/src/at32f413_clock.c rename to project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/src/at32f413_clock.c diff --git a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/src/at32f413_int.c b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/src/at32f413_int.c similarity index 93% rename from project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/src/at32f413_int.c rename to project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/src/at32f413_int.c index ffacaf6..7e47225 100644 --- a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/src/at32f413_int.c +++ b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/src/at32f413_int.c @@ -30,7 +30,7 @@ * @{ */ -/** @addtogroup 413_SPI_use_jtagpin_hardwarecs_dma +/** @addtogroup 413_SPI_fullduplex_dma_jtagpin * @{ */ diff --git a/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/src/main.c b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/src/main.c new file mode 100644 index 0000000..295f43c --- /dev/null +++ b/project/at_start_f413/examples/spi/fullduplex_dma_jtagpin/src/main.c @@ -0,0 +1,331 @@ +/** + ************************************************************************** + * @file main.c + * @brief main program + ************************************************************************** + * Copyright notice & Disclaimer + * + * The software Board Support Package (BSP) that is made available to + * download from Artery official website is the copyrighted work of Artery. + * Artery authorizes customers to use, copy, and distribute the BSP + * software and its related documentation for the purpose of design and + * development in conjunction with Artery microcontrollers. Use of the + * software is governed by this copyright notice and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES, + * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS, + * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR + * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS, + * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. + * + ************************************************************************** + */ + +#include "at32f413_board.h" +#include "at32f413_clock.h" + +/** @addtogroup AT32F413_periph_examples + * @{ + */ + +/** @addtogroup 413_SPI_fullduplex_dma_jtagpin SPI_fullduplex_dma_jtagpin + * @{ + */ + +#define SPI_MASTER_CS_HIGH gpio_bits_set(GPIOA, GPIO_PINS_15) +#define SPI_MASTER_CS_LOW gpio_bits_reset(GPIOA, GPIO_PINS_15) +#define BUFFER_SIZE 32 + +spi_init_type spi_init_struct; +uint8_t spi1_tx_buffer[BUFFER_SIZE] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20}; +uint8_t spi2_tx_buffer[BUFFER_SIZE] = {0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, + 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70}; +uint8_t spi1_rx_buffer[BUFFER_SIZE], spi2_rx_buffer[BUFFER_SIZE]; +volatile error_status transfer_status1 = ERROR, transfer_status2 = ERROR; + +/** + * @brief buffer compare function. + * @param pbuffer1, pbuffer2: buffers to be compared. + * @param buffer_length: buffer's length + * @retval the result of compare + */ +error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t bufferlength) +{ + while(bufferlength--) + { + if(*pbuffer1 != *pbuffer2) + { + return ERROR; + } + + pbuffer1++; + pbuffer2++; + } + return SUCCESS; +} + +/** + * @brief dma configuration. + * @param none + * @retval none + */ +static void dma_config(void) +{ + dma_init_type dma_init_struct; + crm_periph_clock_enable(CRM_DMA1_PERIPH_CLOCK, TRUE); + + /* use dma1_channel3 as spi1 transmit channel */ + dma_reset(DMA1_CHANNEL3); + dma_default_para_init(&dma_init_struct); + dma_init_struct.buffer_size = BUFFER_SIZE; + dma_init_struct.direction = DMA_DIR_MEMORY_TO_PERIPHERAL; + dma_init_struct.memory_base_addr = (uint32_t)spi1_tx_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)&(SPI1->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; + dma_init_struct.loop_mode_enable = FALSE; + dma_init(DMA1_CHANNEL3, &dma_init_struct); + + /* use dma1_channel2 as spi1 receive channel */ + dma_reset(DMA1_CHANNEL2); + dma_init_struct.buffer_size = BUFFER_SIZE; + dma_init_struct.direction = DMA_DIR_PERIPHERAL_TO_MEMORY; + dma_init_struct.memory_base_addr = (uint32_t)spi1_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)&(SPI1->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; + dma_init_struct.loop_mode_enable = FALSE; + dma_init(DMA1_CHANNEL2, &dma_init_struct); + + /* use dma1_channel5 as spi2 transmit channel */ + dma_reset(DMA1_CHANNEL5); + dma_default_para_init(&dma_init_struct); + dma_init_struct.buffer_size = BUFFER_SIZE; + dma_init_struct.direction = DMA_DIR_MEMORY_TO_PERIPHERAL; + dma_init_struct.memory_base_addr = (uint32_t)spi2_tx_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)&(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; + dma_init_struct.loop_mode_enable = FALSE; + dma_init(DMA1_CHANNEL5, &dma_init_struct); + + /* use dma1_channel4 as spi2 receive channel */ + dma_reset(DMA1_CHANNEL4); + dma_init_struct.buffer_size = BUFFER_SIZE; + dma_init_struct.direction = DMA_DIR_PERIPHERAL_TO_MEMORY; + 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)&(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; + dma_init_struct.loop_mode_enable = FALSE; + dma_init(DMA1_CHANNEL4, &dma_init_struct); +} + +/** + * @brief spi configuration. + * @param none + * @retval none + */ +static void spi_config(void) +{ + /* spi master initialization */ + crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); + spi_default_para_init(&spi_init_struct); + + /* dual line unidirectional full-duplex mode */ + spi_init_struct.transmission_mode = SPI_TRANSMIT_FULL_DUPLEX; + spi_init_struct.master_slave_mode = SPI_MODE_MASTER; + spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; + spi_init_struct.first_bit_transmission = SPI_FIRST_BIT_LSB; + spi_init_struct.frame_bit_num = SPI_FRAME_8BIT; + spi_init_struct.clock_polarity = SPI_CLOCK_POLARITY_LOW; + spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; + spi_init_struct.cs_mode_selection = SPI_CS_SOFTWARE_MODE; + spi_init(SPI1, &spi_init_struct); + + /* use dma transmit and receive */ + spi_i2s_dma_transmitter_enable(SPI1, TRUE); + spi_i2s_dma_receiver_enable(SPI1, TRUE); + + spi_enable(SPI1, TRUE); + + /* spi slave initialization */ + crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + + /* dual line unidirectional full-duplex mode */ + spi_init_struct.transmission_mode = SPI_TRANSMIT_FULL_DUPLEX; + spi_init_struct.master_slave_mode = SPI_MODE_SLAVE; + spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; + spi_init_struct.first_bit_transmission = SPI_FIRST_BIT_LSB; + spi_init_struct.frame_bit_num = SPI_FRAME_8BIT; + spi_init_struct.clock_polarity = SPI_CLOCK_POLARITY_LOW; + spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; + spi_init_struct.cs_mode_selection = SPI_CS_HARDWARE_MODE; + spi_init(SPI2, &spi_init_struct); + + /* use dma transmit and receive */ + spi_i2s_dma_transmitter_enable(SPI2, TRUE); + spi_i2s_dma_receiver_enable(SPI2, TRUE); + + spi_enable(SPI2, TRUE); +} + +/** + * @brief gpio configuration. + * @param none + * @retval none + */ +static void gpio_config(void) +{ + gpio_init_type gpio_initstructure; + crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE); + crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); + crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK, TRUE); + gpio_pin_remap_config(SWJTAG_GMUX_010, TRUE); + gpio_pin_remap_config(SPI1_MUX_01, TRUE); + gpio_default_para_init(&gpio_initstructure); + + /* spi master gpio initialization */ + /* spi1 cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_OUTPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_15; + gpio_init(GPIOA, &gpio_initstructure); + + /* non communication time: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; + + /* spi1 sck pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_3; + gpio_init(GPIOB, &gpio_initstructure); + + /* spi1 miso pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_4; + gpio_init(GPIOB, &gpio_initstructure); + + /* spi1 mosi pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_5; + gpio_init(GPIOB, &gpio_initstructure); + + /* spi2 gpio initialization */ + /* spi2 cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_12; + gpio_init(GPIOB, &gpio_initstructure); + + /* spi2 sck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_13; + gpio_init(GPIOB, &gpio_initstructure); + + /* spi2 miso pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_14; + gpio_init(GPIOB, &gpio_initstructure); + + /* spi2 mosi pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_15; + gpio_init(GPIOB, &gpio_initstructure); +} + +/** + * @brief main function. + * @param none + * @retval none + */ +int main(void) +{ + __IO uint32_t index = 0; + system_clock_config(); + at32_board_init(); + at32_led_on(LED4); + dma_config(); + gpio_config(); + spi_config(); + + /* start communication: master pull down CS pin select slave */ + SPI_MASTER_CS_LOW; + + /* enable spi slave dma to fill and get data */ + dma_channel_enable(DMA1_CHANNEL5, TRUE); + dma_channel_enable(DMA1_CHANNEL4, TRUE); + + /* enable spi master dma to fill and get data */ + dma_channel_enable(DMA1_CHANNEL2, TRUE); + dma_channel_enable(DMA1_CHANNEL3, TRUE); + + /* wait master and slave spi data receive end */ + while(dma_flag_get(DMA1_FDT2_FLAG) == RESET) + { + } + while(dma_flag_get(DMA1_FDT4_FLAG) == RESET) + { + } + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); + + /* end communication: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; + + /* test result:the data check */ + transfer_status1 = buffer_compare(spi2_rx_buffer, spi1_tx_buffer, BUFFER_SIZE); + transfer_status2 = buffer_compare(spi1_rx_buffer, spi2_tx_buffer, BUFFER_SIZE); + + /* test result indicate:if SUCCESS ,led2 lights */ + if((transfer_status1 == SUCCESS) && (transfer_status2 == SUCCESS)) + { + at32_led_on(LED2); + } + else + { + at32_led_on(LED3); + } + while(1) + { + } +} + +/** + * @} + */ + +/** + * @} + */ diff --git a/project/at_start_f413/examples/spi/fullduplex_polling/readme.txt b/project/at_start_f413/examples/spi/fullduplex_polling/readme.txt index 780ce5e..f75f4e1 100644 --- a/project/at_start_f413/examples/spi/fullduplex_polling/readme.txt +++ b/project/at_start_f413/examples/spi/fullduplex_polling/readme.txt @@ -8,9 +8,11 @@ this demo is based on the at-start board, in this demo, shows how to use fullduplex mode transfer data by polling mode. the pins connection as follow: - - spi2 slaver spi1 master + - spi2 spi1 + pb12(cs) <---> pa4(cs) pb13(sck) <---> pa5(sck) pb14(miso) <---> pa6(miso) pb15(mosi) <---> pa7(mosi) - for more detailed information. please refer to the application note document AN0102. \ No newline at end of file + for more detailed information. please refer to the application note document AN0102. + diff --git a/project/at_start_f413/examples/spi/fullduplex_polling/src/main.c b/project/at_start_f413/examples/spi/fullduplex_polling/src/main.c index 500c044..a086ab6 100644 --- a/project/at_start_f413/examples/spi/fullduplex_polling/src/main.c +++ b/project/at_start_f413/examples/spi/fullduplex_polling/src/main.c @@ -34,7 +34,12 @@ * @{ */ -#define BUFFER_SIZE 32 +#define SPI1_AS_MASTER_CS_HIGH gpio_bits_set(GPIOA, GPIO_PINS_4) +#define SPI1_AS_MASTER_CS_LOW gpio_bits_reset(GPIOA, GPIO_PINS_4) + +#define SPI2_AS_MASTER_CS_HIGH gpio_bits_set(GPIOB, GPIO_PINS_12) +#define SPI2_AS_MASTER_CS_LOW gpio_bits_reset(GPIOB, GPIO_PINS_12) +#define BUFFER_SIZE 32 spi_init_type spi_init_struct; uint8_t spi1_tx_buffer[BUFFER_SIZE] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, @@ -50,10 +55,6 @@ uint32_t tx_index = 0, rx_index = 0; volatile error_status transfer_status1 = ERROR, transfer_status2 = ERROR; volatile error_status transfer_status3 = ERROR, transfer_status4 = ERROR; -static void gpio_config(uint16_t spi1_mode, uint16_t spi2_mode); -static void spi_config(void); -error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t bufferlength); - /** * @brief buffer compare function. * @param pbuffer1, pbuffer2: buffers to be compared. @@ -82,9 +83,11 @@ error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t buffe */ static void spi_config(void) { + /* master spi initialization */ crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); - crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); spi_default_para_init(&spi_init_struct); + + /* dual line unidirectional full-duplex mode */ spi_init_struct.transmission_mode = SPI_TRANSMIT_FULL_DUPLEX; spi_init_struct.master_slave_mode = SPI_MODE_MASTER; spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; @@ -94,11 +97,23 @@ static void spi_config(void) spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; spi_init_struct.cs_mode_selection = SPI_CS_SOFTWARE_MODE; spi_init(SPI1, &spi_init_struct); - + + spi_enable(SPI1, TRUE); + + /* slave spi initialization */ + crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + + /* dual line unidirectional full-duplex mode */ + spi_init_struct.transmission_mode = SPI_TRANSMIT_FULL_DUPLEX; spi_init_struct.master_slave_mode = SPI_MODE_SLAVE; + spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; + spi_init_struct.first_bit_transmission = SPI_FIRST_BIT_LSB; + spi_init_struct.frame_bit_num = SPI_FRAME_8BIT; + spi_init_struct.clock_polarity = SPI_CLOCK_POLARITY_LOW; + spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; + spi_init_struct.cs_mode_selection = SPI_CS_HARDWARE_MODE; spi_init(SPI2, &spi_init_struct); - spi_enable(SPI1, TRUE); spi_enable(SPI2, TRUE); } @@ -113,85 +128,124 @@ static void gpio_config(uint16_t spi1_mode, uint16_t spi2_mode) crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); gpio_default_para_init(&gpio_initstructure); - /* spi1 sck pin */ - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + + /* spi1 cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; if(spi1_mode == SPI_MODE_MASTER) { - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_mode = GPIO_MODE_OUTPUT; } else { - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; } - gpio_initstructure.gpio_pins = GPIO_PINS_5; + gpio_initstructure.gpio_pins = GPIO_PINS_4; + gpio_init(GPIOA, &gpio_initstructure); + + /* spi1 sck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + if(spi1_mode == SPI_MODE_MASTER) + { + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + } + else + { + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + } + gpio_initstructure.gpio_pins = GPIO_PINS_5; gpio_init(GPIOA, &gpio_initstructure); /* spi1 miso pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; if(spi1_mode == SPI_MODE_MASTER) { - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; } else { - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; } - gpio_initstructure.gpio_pins = GPIO_PINS_6; + gpio_initstructure.gpio_pins = GPIO_PINS_6; gpio_init(GPIOA, &gpio_initstructure); /* spi1 mosi pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; if(spi1_mode == SPI_MODE_MASTER) { - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; } else { - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; } - gpio_initstructure.gpio_pins = GPIO_PINS_7; + gpio_initstructure.gpio_pins = GPIO_PINS_7; gpio_init(GPIOA, &gpio_initstructure); - - /* spi2 sck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + + /* spi2 cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; if(spi2_mode == SPI_MODE_SLAVE) { - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; } else { - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_mode = GPIO_MODE_OUTPUT; } - gpio_initstructure.gpio_pins = GPIO_PINS_13; + gpio_initstructure.gpio_pins = GPIO_PINS_12; + gpio_init(GPIOB, &gpio_initstructure); + + /* spi2 sck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + if(spi2_mode == SPI_MODE_SLAVE) + { + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + } + else + { + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + } + gpio_initstructure.gpio_pins = GPIO_PINS_13; gpio_init(GPIOB, &gpio_initstructure); /* spi2 miso pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; if(spi2_mode == SPI_MODE_SLAVE) { - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; } else { - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; } - gpio_initstructure.gpio_pins = GPIO_PINS_14; + gpio_initstructure.gpio_pins = GPIO_PINS_14; gpio_init(GPIOB, &gpio_initstructure); /* spi2 mosi pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; if(spi2_mode == SPI_MODE_SLAVE) { - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; } else { - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; } - gpio_initstructure.gpio_pins = GPIO_PINS_15; + gpio_initstructure.gpio_pins = GPIO_PINS_15; gpio_init(GPIOB, &gpio_initstructure); + + /* non communication time: master pull up CS pin release slave */ + if(spi1_mode == SPI_MODE_MASTER) + { + SPI1_AS_MASTER_CS_HIGH; + } + if(spi2_mode == SPI_MODE_MASTER) + { + SPI2_AS_MASTER_CS_HIGH; + } } /** @@ -204,64 +258,96 @@ int main(void) __IO uint32_t index = 0; system_clock_config(); at32_board_init(); + at32_led_on(LED4); gpio_config(SPI_MODE_MASTER, SPI_MODE_SLAVE); spi_config(); - + + /* start communication: master pull down CS pin select slave */ + SPI1_AS_MASTER_CS_LOW; + /* transfer procedure:the "BUFFER_SIZE" data transfer */ while(tx_index < BUFFER_SIZE) { + /* slave and master transmit data fill */ while(spi_i2s_flag_get(SPI2, SPI_I2S_TDBE_FLAG) == RESET); spi_i2s_data_transmit(SPI2, spi2_tx_buffer[tx_index]); while(spi_i2s_flag_get(SPI1, SPI_I2S_TDBE_FLAG) == RESET); spi_i2s_data_transmit(SPI1, spi1_tx_buffer[tx_index++]); + + /* slave and master receive data get */ while(spi_i2s_flag_get(SPI2, SPI_I2S_RDBF_FLAG) == RESET); spi2_rx_buffer[rx_index] = spi_i2s_data_receive(SPI2); while(spi_i2s_flag_get(SPI1, SPI_I2S_RDBF_FLAG) == RESET); spi1_rx_buffer[rx_index++] = spi_i2s_data_receive(SPI1); } - + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); + + /* end communication: master pull up CS pin release slave */ + SPI1_AS_MASTER_CS_HIGH; + /* test result:the data check */ transfer_status1 = buffer_compare(spi2_rx_buffer, spi1_tx_buffer, BUFFER_SIZE); transfer_status2 = buffer_compare(spi1_rx_buffer, spi2_tx_buffer, BUFFER_SIZE); - - /* master &slave mode switch */ + spi_enable(SPI1, FALSE); spi_enable(SPI2, FALSE); + + /* master & slave mode switch */ gpio_config(SPI_MODE_SLAVE, SPI_MODE_MASTER); spi_init_struct.master_slave_mode =SPI_MODE_SLAVE; + spi_init_struct.cs_mode_selection = SPI_CS_HARDWARE_MODE; spi_init(SPI1, &spi_init_struct); - + spi_init_struct.master_slave_mode =SPI_MODE_MASTER; + spi_init_struct.cs_mode_selection = SPI_CS_SOFTWARE_MODE; spi_init(SPI2, &spi_init_struct); - + + /* receive buffer clear */ tx_index = 0; rx_index = 0; for(index = 0; index < BUFFER_SIZE; index++) + { spi1_rx_buffer[index] = 0; - for(index = 0; index < BUFFER_SIZE; index++) spi2_rx_buffer[index] = 0; - + } + spi_enable(SPI2, TRUE); spi_enable(SPI1, TRUE); + + /* start communication: master pull down CS pin select slave */ + SPI2_AS_MASTER_CS_LOW; /* transfer procedure:the "BUFFER_SIZE" data transfer */ while(tx_index < BUFFER_SIZE) { + /* slave and master transmit data fill */ while(spi_i2s_flag_get(SPI1, SPI_I2S_TDBE_FLAG) == RESET); spi_i2s_data_transmit(SPI1, spi1_tx_buffer[tx_index]); while(spi_i2s_flag_get(SPI2, SPI_I2S_TDBE_FLAG) == RESET); spi_i2s_data_transmit(SPI2, spi2_tx_buffer[tx_index++]); + + /* slave and master receive data get */ while(spi_i2s_flag_get(SPI1, SPI_I2S_RDBF_FLAG) == RESET); spi1_rx_buffer[rx_index] = spi_i2s_data_receive(SPI1); while(spi_i2s_flag_get(SPI2, SPI_I2S_RDBF_FLAG) == RESET); spi2_rx_buffer[rx_index++] = spi_i2s_data_receive(SPI2); } + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + + /* end communication: master pull up CS pin release slave */ + SPI2_AS_MASTER_CS_HIGH; /* test result:the data check */ transfer_status3 = buffer_compare(spi2_rx_buffer, spi1_tx_buffer, BUFFER_SIZE); transfer_status4 = buffer_compare(spi1_rx_buffer, spi2_tx_buffer, BUFFER_SIZE); - /* test result indicate:if success ,led2 lights */ + /* test result indicate:if SUCCESS ,led2 lights */ if((transfer_status1 == SUCCESS) && (transfer_status2 == SUCCESS) && \ (transfer_status3 == SUCCESS) && (transfer_status4 == SUCCESS)) { @@ -269,7 +355,7 @@ int main(void) } else { - at32_led_off(LED2); + at32_led_on(LED3); } while(1) { diff --git a/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/inc/at32f413_clock.h b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/inc/at32f413_clock.h new file mode 100644 index 0000000..168cd13 --- /dev/null +++ b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/inc/at32f413_clock.h @@ -0,0 +1,44 @@ +/** + ************************************************************************** + * @file at32f413_clock.h + * @brief header file of clock program + ************************************************************************** + * Copyright notice & Disclaimer + * + * The software Board Support Package (BSP) that is made available to + * download from Artery official website is the copyrighted work of Artery. + * Artery authorizes customers to use, copy, and distribute the BSP + * software and its related documentation for the purpose of design and + * development in conjunction with Artery microcontrollers. Use of the + * software is governed by this copyright notice and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES, + * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS, + * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR + * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS, + * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. + * + ************************************************************************** + */ + +/* define to prevent recursive inclusion -------------------------------------*/ +#ifndef __AT32F413_CLOCK_H +#define __AT32F413_CLOCK_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* includes ------------------------------------------------------------------*/ +#include "at32f413.h" + +/* exported functions ------------------------------------------------------- */ +void system_clock_config(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __AT32F413_CLOCK_H */ + diff --git a/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/inc/at32f413_conf.h b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/inc/at32f413_conf.h new file mode 100644 index 0000000..b1997b7 --- /dev/null +++ b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/inc/at32f413_conf.h @@ -0,0 +1,157 @@ +/** + ************************************************************************** + * @file at32f413_conf.h + * @brief at32f413 config header file + ************************************************************************** + * Copyright notice & Disclaimer + * + * The software Board Support Package (BSP) that is made available to + * download from Artery official website is the copyrighted work of Artery. + * Artery authorizes customers to use, copy, and distribute the BSP + * software and its related documentation for the purpose of design and + * development in conjunction with Artery microcontrollers. Use of the + * software is governed by this copyright notice and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES, + * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS, + * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR + * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS, + * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. + * + ************************************************************************** + */ + +/* define to prevent recursive inclusion -------------------------------------*/ +#ifndef __AT32F413_CONF_H +#define __AT32F413_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief in the following line adjust the value of high speed external crystal (hext) + * used in your application + * + * tip: to avoid modifying this file each time you need to use different hext, you + * can define the hext value in your toolchain compiler preprocessor. + * + */ +#if !defined HEXT_VALUE +#define HEXT_VALUE ((uint32_t)8000000) /*!< value of the high speed external crystal in hz */ +#endif + +/** + * @brief in the following line adjust the high speed external crystal (hext) startup + * timeout value + */ +#define HEXT_STARTUP_TIMEOUT ((uint16_t)0x3000) /*!< time out for hext start up */ +#define HICK_VALUE ((uint32_t)8000000) /*!< value of the high speed internal clock in hz */ +#define LEXT_VALUE ((uint32_t)32768) /*!< value of the low speed external clock in hz */ + +/* module define -------------------------------------------------------------*/ +#define CRM_MODULE_ENABLED +#define TMR_MODULE_ENABLED +#define RTC_MODULE_ENABLED +#define BPR_MODULE_ENABLED +#define GPIO_MODULE_ENABLED +#define I2C_MODULE_ENABLED +#define USART_MODULE_ENABLED +#define PWC_MODULE_ENABLED +#define CAN_MODULE_ENABLED +#define ADC_MODULE_ENABLED +#define SPI_MODULE_ENABLED +#define DMA_MODULE_ENABLED +#define DEBUG_MODULE_ENABLED +#define FLASH_MODULE_ENABLED +#define CRC_MODULE_ENABLED +#define WWDT_MODULE_ENABLED +#define WDT_MODULE_ENABLED +#define EXINT_MODULE_ENABLED +#define SDIO_MODULE_ENABLED +#define USB_MODULE_ENABLED +#define ACC_MODULE_ENABLED +#define MISC_MODULE_ENABLED + +/* includes ------------------------------------------------------------------*/ +#ifdef CRM_MODULE_ENABLED +#include "at32f413_crm.h" +#endif +#ifdef TMR_MODULE_ENABLED +#include "at32f413_tmr.h" +#endif +#ifdef RTC_MODULE_ENABLED +#include "at32f413_rtc.h" +#endif +#ifdef BPR_MODULE_ENABLED +#include "at32f413_bpr.h" +#endif +#ifdef GPIO_MODULE_ENABLED +#include "at32f413_gpio.h" +#endif +#ifdef I2C_MODULE_ENABLED +#include "at32f413_i2c.h" +#endif +#ifdef USART_MODULE_ENABLED +#include "at32f413_usart.h" +#endif +#ifdef PWC_MODULE_ENABLED +#include "at32f413_pwc.h" +#endif +#ifdef CAN_MODULE_ENABLED +#include "at32f413_can.h" +#endif +#ifdef ADC_MODULE_ENABLED +#include "at32f413_adc.h" +#endif +#ifdef SPI_MODULE_ENABLED +#include "at32f413_spi.h" +#endif +#ifdef DMA_MODULE_ENABLED +#include "at32f413_dma.h" +#endif +#ifdef DEBUG_MODULE_ENABLED +#include "at32f413_debug.h" +#endif +#ifdef FLASH_MODULE_ENABLED +#include "at32f413_flash.h" +#endif +#ifdef CRC_MODULE_ENABLED +#include "at32f413_crc.h" +#endif +#ifdef WWDT_MODULE_ENABLED +#include "at32f413_wwdt.h" +#endif +#ifdef WDT_MODULE_ENABLED +#include "at32f413_wdt.h" +#endif +#ifdef EXINT_MODULE_ENABLED +#include "at32f413_exint.h" +#endif +#ifdef SDIO_MODULE_ENABLED +#include "at32f413_sdio.h" +#endif +#ifdef ACC_MODULE_ENABLED +#include "at32f413_acc.h" +#endif +#ifdef MISC_MODULE_ENABLED +#include "at32f413_misc.h" +#endif +#ifdef USB_MODULE_ENABLED +#include "at32f413_usb.h" +#endif + +/** + * @} + */ + + /** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/inc/at32f413_int.h b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/inc/at32f413_int.h new file mode 100644 index 0000000..b156dba --- /dev/null +++ b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/inc/at32f413_int.h @@ -0,0 +1,56 @@ +/** + ************************************************************************** + * @file at32f413_int.h + * @brief header file of main interrupt service routines. + ************************************************************************** + * Copyright notice & Disclaimer + * + * The software Board Support Package (BSP) that is made available to + * download from Artery official website is the copyrighted work of Artery. + * Artery authorizes customers to use, copy, and distribute the BSP + * software and its related documentation for the purpose of design and + * development in conjunction with Artery microcontrollers. Use of the + * software is governed by this copyright notice and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES, + * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS, + * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR + * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS, + * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. + * + ************************************************************************** + */ + +/* define to prevent recursive inclusion -------------------------------------*/ +#ifndef __AT32F413_INT_H +#define __AT32F413_INT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* includes ------------------------------------------------------------------*/ +#include "at32f413.h" + +/* exported types ------------------------------------------------------------*/ +/* exported constants --------------------------------------------------------*/ +/* exported macro ------------------------------------------------------------*/ +/* exported functions ------------------------------------------------------- */ + +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void DebugMon_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/mdk_v5/halfduplex_dma_jtagpin.uvoptx b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/mdk_v5/halfduplex_dma_jtagpin.uvoptx new file mode 100644 index 0000000..4ee2af9 --- /dev/null +++ b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/mdk_v5/halfduplex_dma_jtagpin.uvoptx @@ -0,0 +1,368 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp; *.cc; *.cxx + 0 + + + + 0 + 0 + + + + halfduplex_dma_jtagpin + 0x4 + ARM-ADS + + 12000000 + + 0 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 0 + 0 + 1 + + 0 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + + + + + + + + + + + BIN\CMSIS_AGDI.dll + + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0AT32F413_256 -FS08000000 -FL040000 -FP0($$Device:-AT32F413RCT7$Flash\AT32F413_256.FLM)) + + + + + 0 + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + + + + user + 0 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + ..\src\at32f413_clock.c + at32f413_clock.c + 0 + 0 + + + 1 + 2 + 1 + 0 + 0 + 0 + ..\src\at32f413_int.c + at32f413_int.c + 0 + 0 + + + 1 + 3 + 1 + 0 + 0 + 0 + ..\src\main.c + main.c + 0 + 0 + + + + + bsp + 0 + 0 + 0 + 0 + + 2 + 4 + 1 + 0 + 0 + 0 + ..\..\..\..\..\at32f413_board\at32f413_board.c + at32f413_board.c + 0 + 0 + + + + + firmware + 0 + 0 + 0 + 0 + + 3 + 5 + 1 + 0 + 0 + 0 + ..\..\..\..\..\..\libraries\drivers\src\at32f413_gpio.c + at32f413_gpio.c + 0 + 0 + + + 3 + 6 + 1 + 0 + 0 + 0 + ..\..\..\..\..\..\libraries\drivers\src\at32f413_misc.c + at32f413_misc.c + 0 + 0 + + + 3 + 7 + 1 + 0 + 0 + 0 + ..\..\..\..\..\..\libraries\drivers\src\at32f413_crm.c + at32f413_crm.c + 0 + 0 + + + 3 + 8 + 1 + 0 + 0 + 0 + ..\..\..\..\..\..\libraries\drivers\src\at32f413_usart.c + at32f413_usart.c + 0 + 0 + + + 3 + 9 + 1 + 0 + 0 + 0 + ..\..\..\..\..\..\libraries\drivers\src\at32f413_dma.c + at32f413_dma.c + 0 + 0 + + + 3 + 10 + 1 + 0 + 0 + 0 + ..\..\..\..\..\..\libraries\drivers\src\at32f413_spi.c + at32f413_spi.c + 0 + 0 + + + + + cmsis + 0 + 0 + 0 + 0 + + 4 + 11 + 1 + 0 + 0 + 0 + ..\..\..\..\..\..\libraries\cmsis\cm4\device_support\system_at32f413.c + system_at32f413.c + 0 + 0 + + + 4 + 12 + 2 + 0 + 0 + 0 + ..\..\..\..\..\..\libraries\cmsis\cm4\device_support\startup\mdk\startup_at32f413.s + startup_at32f413.s + 0 + 0 + + + + + readme + 0 + 0 + 0 + 0 + + 5 + 13 + 5 + 0 + 0 + 0 + ..\readme.txt + readme.txt + 0 + 0 + + + +
diff --git a/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/mdk_v5/halfduplex_dma_jtagpin.uvprojx b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/mdk_v5/halfduplex_dma_jtagpin.uvprojx new file mode 100644 index 0000000..c2785dd --- /dev/null +++ b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/mdk_v5/halfduplex_dma_jtagpin.uvprojx @@ -0,0 +1,492 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + halfduplex_dma_jtagpin + 0x4 + ARM-ADS + 5060960::V5.06 update 7 (build 960)::.\ARMCC + 0 + + + -AT32F413RCT7 + ArteryTek + ArteryTek.AT32F413_DFP.2.0.0 + IRAM(0x20000000,0x8000) IROM(0x08000000,0x40000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE + + + + 0 + $$Device:-AT32F413RCT7$Device\Include\at32f413.h + + + + + + + + + + $$Device:-AT32F413RCT7$SVD\AT32F413xx_v2.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\objects\ + halfduplex_dma_jtagpin + 1 + 0 + 1 + 1 + 1 + .\listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 0 + + + SARMCM3.DLL + -REMAP + DCM.DLL + -pCM4 + SARMCM3.DLL + + TCM.DLL + -pCM4 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M4" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 8 + 0 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x8000 + + + 1 + 0x8000000 + 0x40000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x8000000 + 0x40000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x8000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + AT32F413RCT7,USE_STDPERIPH_DRIVER,AT_START_F413_V1 + + ..\..\..\..\..\..\libraries\drivers\inc;..\..\..\..\..\..\libraries\cmsis\cm4\core_support;..\..\..\..\..\..\libraries\cmsis\cm4\device_support;..\inc;..\..\..\..\..\at32f413_board + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 4 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x08000000 + 0x20000000 + + + + + + + + + + + + + user + + + at32f413_clock.c + 1 + ..\src\at32f413_clock.c + + + at32f413_int.c + 1 + ..\src\at32f413_int.c + + + main.c + 1 + ..\src\main.c + + + + + bsp + + + at32f413_board.c + 1 + ..\..\..\..\..\at32f413_board\at32f413_board.c + + + + + firmware + + + at32f413_gpio.c + 1 + ..\..\..\..\..\..\libraries\drivers\src\at32f413_gpio.c + + + at32f413_misc.c + 1 + ..\..\..\..\..\..\libraries\drivers\src\at32f413_misc.c + + + at32f413_crm.c + 1 + ..\..\..\..\..\..\libraries\drivers\src\at32f413_crm.c + + + at32f413_usart.c + 1 + ..\..\..\..\..\..\libraries\drivers\src\at32f413_usart.c + + + at32f413_dma.c + 1 + ..\..\..\..\..\..\libraries\drivers\src\at32f413_dma.c + + + at32f413_spi.c + 1 + ..\..\..\..\..\..\libraries\drivers\src\at32f413_spi.c + + + + + cmsis + + + system_at32f413.c + 1 + ..\..\..\..\..\..\libraries\cmsis\cm4\device_support\system_at32f413.c + + + startup_at32f413.s + 2 + ..\..\..\..\..\..\libraries\cmsis\cm4\device_support\startup\mdk\startup_at32f413.s + + + + + readme + + + readme.txt + 5 + ..\readme.txt + + + + + + + + + + + + + + + + + halfduplex_dma_jtagpin + 0 + 1 + + + + +
diff --git a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/readme.txt b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/readme.txt similarity index 72% rename from project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/readme.txt rename to project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/readme.txt index 6a35227..dc45154 100644 --- a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/readme.txt +++ b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/readme.txt @@ -6,12 +6,13 @@ */ this demo is based on the at-start board, in this demo, shows how to use - dma recieve data. spi3 use jtag pin as spi pin,and config spi in hardware + dma recieve data. spi1 use jtag pin as spi pin,and config spi in hardware cs mode. the pins connection as follow: - - spi2 slaver spi1 master - - pb12(cs) <---> pa15(cs) + - spi2 slave spi1 master + pb12(cs) <---> pa15(cs) pb13(sck) <---> pb3(sck) pb14(miso) <---> pb5(mosi) - for more detailed information. please refer to the application note document AN0102. \ No newline at end of file + for more detailed information. please refer to the application note document AN0102. + diff --git a/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/src/at32f413_clock.c b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/src/at32f413_clock.c new file mode 100644 index 0000000..c24f23d --- /dev/null +++ b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/src/at32f413_clock.c @@ -0,0 +1,94 @@ +/** + ************************************************************************** + * @file at32f413_clock.c + * @brief system clock config program + ************************************************************************** + * Copyright notice & Disclaimer + * + * The software Board Support Package (BSP) that is made available to + * download from Artery official website is the copyrighted work of Artery. + * Artery authorizes customers to use, copy, and distribute the BSP + * software and its related documentation for the purpose of design and + * development in conjunction with Artery microcontrollers. Use of the + * software is governed by this copyright notice and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES, + * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS, + * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR + * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS, + * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. + * + ************************************************************************** + */ + +/* includes ------------------------------------------------------------------*/ +#include "at32f413_clock.h" + +/** + * @brief system clock config program + * @note the system clock is configured as follow: + * system clock (sclk) = hext / 2 * pll_mult + * system clock source = pll (hext) + * - hext = HEXT_VALUE + * - sclk = 192000000 + * - ahbdiv = 1 + * - ahbclk = 192000000 + * - apb2div = 2 + * - apb2clk = 96000000 + * - apb1div = 2 + * - apb1clk = 96000000 + * - pll_mult = 48 + * - pll_range = GT72MHZ (greater than 72 mhz) + * @param none + * @retval none + */ +void system_clock_config(void) +{ + /* reset crm */ + crm_reset(); + + crm_clock_source_enable(CRM_CLOCK_SOURCE_HEXT, TRUE); + + /* wait till hext is ready */ + while(crm_hext_stable_wait() == ERROR) + { + } + + /* config pll clock resource */ + crm_pll_config(CRM_PLL_SOURCE_HEXT_DIV, CRM_PLL_MULT_48, CRM_PLL_OUTPUT_RANGE_GT72MHZ); + + /* enable pll */ + crm_clock_source_enable(CRM_CLOCK_SOURCE_PLL, TRUE); + + /* wait till pll is ready */ + while(crm_flag_get(CRM_PLL_STABLE_FLAG) != SET) + { + } + + /* config ahbclk */ + crm_ahb_div_set(CRM_AHB_DIV_1); + + /* config apb2clk, the maximum frequency of APB1/APB2 clock is 100 MHz */ + crm_apb2_div_set(CRM_APB2_DIV_2); + + /* config apb1clk, the maximum frequency of APB1/APB2 clock is 100 MHz */ + crm_apb1_div_set(CRM_APB1_DIV_2); + + /* enable auto step mode */ + crm_auto_step_mode_enable(TRUE); + + /* select pll as system clock source */ + crm_sysclk_switch(CRM_SCLK_PLL); + + /* wait till pll is used as system clock source */ + while(crm_sysclk_switch_status_get() != CRM_SCLK_PLL) + { + } + + /* disable auto step mode */ + crm_auto_step_mode_enable(FALSE); + + /* update system_core_clock global variable */ + system_core_clock_update(); +} diff --git a/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/src/at32f413_int.c b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/src/at32f413_int.c new file mode 100644 index 0000000..4e1d648 --- /dev/null +++ b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/src/at32f413_int.c @@ -0,0 +1,143 @@ +/** + ************************************************************************** + * @file at32f413_int.c + * @brief main interrupt service routines. + ************************************************************************** + * Copyright notice & Disclaimer + * + * The software Board Support Package (BSP) that is made available to + * download from Artery official website is the copyrighted work of Artery. + * Artery authorizes customers to use, copy, and distribute the BSP + * software and its related documentation for the purpose of design and + * development in conjunction with Artery microcontrollers. Use of the + * software is governed by this copyright notice and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES, + * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS, + * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR + * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS, + * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. + * + ************************************************************************** + */ + +/* includes ------------------------------------------------------------------*/ +#include "at32f413_int.h" +#include "at32f413_board.h" + +/** @addtogroup AT32F413_periph_examples + * @{ + */ + +/** @addtogroup 413_SPI_halfduplex_dma_jtagpin + * @{ + */ + +/** + * @brief this function handles nmi exception. + * @param none + * @retval none + */ +void NMI_Handler(void) +{ +} + +/** + * @brief this function handles hard fault exception. + * @param none + * @retval none + */ +void HardFault_Handler(void) +{ + /* go to infinite loop when hard fault exception occurs */ + while(1) + { + } +} + +/** + * @brief this function handles memory manage exception. + * @param none + * @retval none + */ +void MemManage_Handler(void) +{ + /* go to infinite loop when memory manage exception occurs */ + while(1) + { + } +} + +/** + * @brief this function handles bus fault exception. + * @param none + * @retval none + */ +void BusFault_Handler(void) +{ + /* go to infinite loop when bus fault exception occurs */ + while(1) + { + } +} + +/** + * @brief this function handles usage fault exception. + * @param none + * @retval none + */ +void UsageFault_Handler(void) +{ + /* go to infinite loop when usage fault exception occurs */ + while(1) + { + } +} + +/** + * @brief this function handles svcall exception. + * @param none + * @retval none + */ +void SVC_Handler(void) +{ +} + +/** + * @brief this function handles debug monitor exception. + * @param none + * @retval none + */ +void DebugMon_Handler(void) +{ +} + +/** + * @brief this function handles pendsv_handler exception. + * @param none + * @retval none + */ +void PendSV_Handler(void) +{ +} + +/** + * @brief this function handles systick handler. + * @param none + * @retval none + */ +void SysTick_Handler(void) +{ +} + +/** + * @} + */ + +/** + * @} + */ + + + diff --git a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/src/main.c b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/src/main.c similarity index 53% rename from project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/src/main.c rename to project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/src/main.c index 7da9c9f..5e098ff 100644 --- a/project/at_start_f413/examples/spi/use_jtagpin_hardwarecs_dma/src/main.c +++ b/project/at_start_f413/examples/spi/halfduplex_dma_jtagpin/src/main.c @@ -29,33 +29,31 @@ * @{ */ -/** @addtogroup 413_SPI_use_jtagpin_hardwarecs_dma SPI_use_jtagpin_hardwarecs_dma +/** @addtogroup 413_SPI_halfduplex_dma_jtagpin SPI_halfduplex_dma_jtagpin * @{ */ -#define BUFFER_SIZE 32 +#define SPI_MASTER_CS_HIGH gpio_bits_set(GPIOA, GPIO_PINS_15) +#define SPI_MASTER_CS_LOW gpio_bits_reset(GPIOA, GPIO_PINS_15) +#define BUFFER_SIZE 32 +spi_init_type spi_init_struct; uint8_t spi1_tx_buffer[BUFFER_SIZE] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20}; uint8_t spi2_rx_buffer[BUFFER_SIZE]; -__IO uint8_t tx_index = 0; volatile error_status transfer_status = ERROR; -static void gpio_config(void); -static void spi_config(void); -error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t buffer_length); - /** * @brief buffer compare function. * @param pbuffer1, pbuffer2: buffers to be compared. * @param buffer_length: buffer's length * @retval the result of compare */ -error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t buffer_length) +error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t bufferlength) { - while(buffer_length--) + while(bufferlength--) { if(*pbuffer1 != *pbuffer2) { @@ -69,19 +67,33 @@ error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t buffe } /** - * @brief spi configuration. + * @brief dma configuration. * @param none * @retval none */ -static void spi_config(void) +static void dma_config(void) { dma_init_type dma_init_struct; - spi_init_type spi_init_struct; - crm_periph_clock_enable(CRM_DMA1_PERIPH_CLOCK, TRUE); - dma_reset(DMA1_CHANNEL4); + + /* use dma1_channel3 as spi1 transmit channel */ + dma_reset(DMA1_CHANNEL3); dma_default_para_init(&dma_init_struct); dma_init_struct.buffer_size = BUFFER_SIZE; + dma_init_struct.direction = DMA_DIR_MEMORY_TO_PERIPHERAL; + dma_init_struct.memory_base_addr = (uint32_t)spi1_tx_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)&(SPI1->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; + dma_init_struct.loop_mode_enable = FALSE; + dma_init(DMA1_CHANNEL3, &dma_init_struct); + + /* use dma1_channel4 as spi2 receive channel */ + dma_reset(DMA1_CHANNEL4); + dma_init_struct.buffer_size = BUFFER_SIZE; dma_init_struct.direction = DMA_DIR_PERIPHERAL_TO_MEMORY; dma_init_struct.memory_base_addr = (uint32_t)spi2_rx_buffer; dma_init_struct.memory_data_width = DMA_MEMORY_DATA_WIDTH_BYTE; @@ -92,10 +104,22 @@ static void spi_config(void) dma_init_struct.priority = DMA_PRIORITY_MEDIUM; dma_init_struct.loop_mode_enable = FALSE; dma_init(DMA1_CHANNEL4, &dma_init_struct); +} +/** + * @brief spi configuration. + * @param none + * @retval none + */ +static void spi_config(void) +{ + spi_init_type spi_init_struct; + + /* spi master initialization */ crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); - crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); spi_default_para_init(&spi_init_struct); + + /* single line bidirectional half duplex mode-transmitting */ spi_init_struct.transmission_mode = SPI_TRANSMIT_HALF_DUPLEX_TX; spi_init_struct.master_slave_mode = SPI_MODE_MASTER; spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; @@ -103,16 +127,31 @@ static void spi_config(void) spi_init_struct.frame_bit_num = SPI_FRAME_8BIT; spi_init_struct.clock_polarity = SPI_CLOCK_POLARITY_LOW; spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; - spi_init_struct.cs_mode_selection = SPI_CS_HARDWARE_MODE; + spi_init_struct.cs_mode_selection = SPI_CS_SOFTWARE_MODE; spi_init(SPI1, &spi_init_struct); - - spi_init_struct.master_slave_mode = SPI_MODE_SLAVE; - spi_init_struct.transmission_mode = SPI_TRANSMIT_HALF_DUPLEX_RX; - spi_init(SPI2, &spi_init_struct); - - spi_hardware_cs_output_enable(SPI1, TRUE); - spi_i2s_dma_receiver_enable(SPI2, TRUE); + + /* use dma transmit */ + spi_i2s_dma_transmitter_enable(SPI1, TRUE); + spi_enable(SPI1, TRUE); + + /* spi slave initialization */ + crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + + /* single line bidirectional half duplex mode-receiving */ + spi_init_struct.transmission_mode = SPI_TRANSMIT_HALF_DUPLEX_RX; + spi_init_struct.master_slave_mode = SPI_MODE_SLAVE; + spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; + spi_init_struct.first_bit_transmission = SPI_FIRST_BIT_MSB; + spi_init_struct.frame_bit_num = SPI_FRAME_8BIT; + spi_init_struct.clock_polarity = SPI_CLOCK_POLARITY_LOW; + spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; + spi_init_struct.cs_mode_selection = SPI_CS_HARDWARE_MODE; + spi_init(SPI2, &spi_init_struct); + + /* use dma receive */ + spi_i2s_dma_receiver_enable(SPI2, TRUE); + spi_enable(SPI2, TRUE); } @@ -129,43 +168,53 @@ static void gpio_config(void) crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK, TRUE); gpio_pin_remap_config(SWJTAG_GMUX_010, TRUE); gpio_pin_remap_config(SPI1_MUX_01, TRUE); - - /* master sck pin */ - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_default_para_init(&gpio_initstructure); + + /* spi master gpio initialization */ + /* spi1 cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pins = GPIO_PINS_3; - gpio_init(GPIOB, &gpio_initstructure); - - /* master mosi pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_5; - gpio_init(GPIOB, &gpio_initstructure); - - /* master cs pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_UP; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_15; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_OUTPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_15; gpio_init(GPIOA, &gpio_initstructure); - - /* slave sck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; - gpio_initstructure.gpio_pins = GPIO_PINS_13; + + /* non communication time: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; + + /* spi1 sck pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_3; gpio_init(GPIOB, &gpio_initstructure); - /* slave miso pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_14; + /* spi1 mosi pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_5; + gpio_init(GPIOB, &gpio_initstructure); + + /* spi2 gpio initialization */ + /* spi2 cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_12; gpio_init(GPIOB, &gpio_initstructure); - /* slave cs pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_UP; - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; - gpio_initstructure.gpio_pins = GPIO_PINS_12; + /* spi2 sck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_13; + gpio_init(GPIOB, &gpio_initstructure); + + /* spi2 miso pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_14; gpio_init(GPIOB, &gpio_initstructure); } @@ -176,35 +225,51 @@ static void gpio_config(void) */ int main(void) { + __IO uint32_t index = 0; system_clock_config(); at32_board_init(); - - /* button press:ensure code canbe download normally */ - while(at32_button_press() == NO_BUTTON); - + at32_led_on(LED4); + dma_config(); gpio_config(); spi_config(); + + /* start communication: master pull down CS pin select slave */ + SPI_MASTER_CS_LOW; + + /* enable spi slave dma to get data */ dma_channel_enable(DMA1_CHANNEL4, TRUE); - - /* transfer procedure:the "BUFFER_SIZE" data transfer */ - while(tx_index < BUFFER_SIZE) + + /* enable spi master dma to fill data */ + dma_channel_enable(DMA1_CHANNEL3, TRUE); + + /* wait master spi data fill end */ + while(dma_flag_get(DMA1_FDT3_FLAG) == RESET) { - while(spi_i2s_flag_get(SPI1, SPI_I2S_TDBE_FLAG) == RESET); - spi_i2s_data_transmit(SPI1, spi1_tx_buffer[tx_index++]); } - while(!dma_flag_get(DMA1_FDT4_FLAG)); + + /* wait slave spi data get end */ + while(dma_flag_get(DMA1_FDT4_FLAG) == RESET) + { + } + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); + + /* end communication: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; /* test result:the data check */ transfer_status = buffer_compare(spi2_rx_buffer, spi1_tx_buffer, BUFFER_SIZE); - /* test result indicate:if success ,led2 lights */ + /* test result indicate:if SUCCESS ,led2 lights */ if(transfer_status == SUCCESS) { at32_led_on(LED2); } else { - at32_led_off(LED2); + at32_led_on(LED3); } while(1) { diff --git a/project/at_start_f413/examples/spi/halfduplex_interrupt/readme.txt b/project/at_start_f413/examples/spi/halfduplex_interrupt/readme.txt index a09be62..b4c9d76 100644 --- a/project/at_start_f413/examples/spi/halfduplex_interrupt/readme.txt +++ b/project/at_start_f413/examples/spi/halfduplex_interrupt/readme.txt @@ -9,7 +9,9 @@ halfduplex mode transfer data by interrupt mode. the pins connection as follow: - spi2 slaver spi1 master + pb12(cs) <---> pa4(cs) pb13(sck) <---> pa5(sck) pb14(miso) <---> pa7(mosi) - for more detailed information. please refer to the application note document AN0102. \ No newline at end of file + for more detailed information. please refer to the application note document AN0102. + diff --git a/project/at_start_f413/examples/spi/halfduplex_interrupt/src/at32f413_int.c b/project/at_start_f413/examples/spi/halfduplex_interrupt/src/at32f413_int.c index 976a5d4..d81055c 100644 --- a/project/at_start_f413/examples/spi/halfduplex_interrupt/src/at32f413_int.c +++ b/project/at_start_f413/examples/spi/halfduplex_interrupt/src/at32f413_int.c @@ -24,12 +24,6 @@ /* includes ------------------------------------------------------------------*/ #include "at32f413_int.h" -#include "at32f413_board.h" - -extern uint8_t spi1_tx_buffer[]; -extern uint8_t spi2_rx_buffer[]; -extern uint32_t tx_index; -extern uint32_t rx_index; /** @addtogroup AT32F413_periph_examples * @{ @@ -39,8 +33,6 @@ extern uint32_t rx_index; * @{ */ -#define BUFFERSIZE 32 - /** * @brief this function handles nmi exception. * @param none @@ -138,35 +130,6 @@ void SysTick_Handler(void) { } -/** - * @brief This function handles the spi1 interrupt request. - * @param None - * @retval None - */ - void SPI1_IRQHandler(void) -{ - if(spi_i2s_interrupt_flag_get(SPI1, SPI_I2S_TDBE_FLAG) != RESET) - { - spi_i2s_data_transmit(SPI1, spi1_tx_buffer[tx_index++]); - if(tx_index == BUFFERSIZE) - { - spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, FALSE); - } - } -} - -/** - * @brief This function handles the spi2 interrupt request. - * @param None - * @retval None - */ - void SPI2_IRQHandler(void) -{ - if(spi_i2s_interrupt_flag_get(SPI2, SPI_I2S_RDBF_FLAG) != RESET) - { - spi2_rx_buffer[rx_index++] = spi_i2s_data_receive(SPI2); - } -} /** * @} diff --git a/project/at_start_f413/examples/spi/halfduplex_interrupt/src/main.c b/project/at_start_f413/examples/spi/halfduplex_interrupt/src/main.c index 7926029..4fb50ba 100644 --- a/project/at_start_f413/examples/spi/halfduplex_interrupt/src/main.c +++ b/project/at_start_f413/examples/spi/halfduplex_interrupt/src/main.c @@ -33,9 +33,9 @@ * @{ */ -#define BUFFER_SIZE 32 - -spi_init_type spi_init_struct; +#define SPI_MASTER_CS_HIGH gpio_bits_set(GPIOA, GPIO_PINS_4) +#define SPI_MASTER_CS_LOW gpio_bits_reset(GPIOA, GPIO_PINS_4) +#define BUFFER_SIZE 32 uint8_t spi1_tx_buffer[BUFFER_SIZE] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, @@ -45,10 +45,6 @@ uint8_t spi2_rx_buffer[BUFFER_SIZE]; volatile uint32_t tx_index = 0, rx_index = 0; volatile error_status transfer_status = ERROR; -static void gpio_config(void); -static void spi_config(void); -error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t buffer_length); - /** * @brief buffer compare function. * @param pbuffer1, pbuffer2: buffers to be compared. @@ -77,9 +73,14 @@ error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t buffe */ static void spi_config(void) { + spi_init_type spi_init_struct; + + /* master spi initialization */ crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); - crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + nvic_irq_enable(SPI1_IRQn, 0, 0); spi_default_para_init(&spi_init_struct); + + /* single line bidirectional half duplex mode - transmitting */ spi_init_struct.transmission_mode = SPI_TRANSMIT_HALF_DUPLEX_TX; spi_init_struct.master_slave_mode =SPI_MODE_MASTER; spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; @@ -89,18 +90,27 @@ static void spi_config(void) spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; spi_init_struct.cs_mode_selection = SPI_CS_SOFTWARE_MODE; spi_init(SPI1, &spi_init_struct); + + /* enable transmit data buffer empty interrupt */ + spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, TRUE); + + /* slave spi initialization */ + crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + nvic_irq_enable(SPI2_IRQn, 0, 0); + /* single line bidirectional half duplex mode - receiving */ spi_init_struct.transmission_mode = SPI_TRANSMIT_HALF_DUPLEX_RX; spi_init_struct.master_slave_mode =SPI_MODE_SLAVE; + spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; + spi_init_struct.first_bit_transmission = SPI_FIRST_BIT_MSB; + spi_init_struct.frame_bit_num = SPI_FRAME_8BIT; + spi_init_struct.clock_polarity = SPI_CLOCK_POLARITY_LOW; + spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; + spi_init_struct.cs_mode_selection = SPI_CS_HARDWARE_MODE; spi_init(SPI2, &spi_init_struct); - - nvic_irq_enable(SPI1_IRQn, 0, 0); - nvic_irq_enable(SPI2_IRQn, 0, 0); - spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, TRUE); + + /* enable receive data buffer full interrupt */ spi_i2s_interrupt_enable(SPI2, SPI_I2S_RDBF_INT, TRUE); - - spi_enable(SPI2, TRUE); - spi_enable(SPI1, TRUE); } /** @@ -113,35 +123,83 @@ static void gpio_config(void) gpio_init_type gpio_initstructure; crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); + gpio_default_para_init(&gpio_initstructure); - - /* spi1 sck pin */ - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + + /* master spi cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_OUTPUT; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_5; + gpio_initstructure.gpio_pins = GPIO_PINS_4; + gpio_init(GPIOA, &gpio_initstructure); + + /* non communication time: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; + + /* master spi sck pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_5; gpio_init(GPIOA, &gpio_initstructure); - /* spi1 mosi pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_7; + /* master spi mosi pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_7; gpio_init(GPIOA, &gpio_initstructure); - - /* spi2 sck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; - gpio_initstructure.gpio_pins = GPIO_PINS_13; + + /* slave spi cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pins = GPIO_PINS_12; + gpio_init(GPIOB, &gpio_initstructure); + + /* slave spi sck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_13; gpio_init(GPIOB, &gpio_initstructure); - /* spi2 miso pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_14; + /* slave spi miso pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_14; gpio_init(GPIOB, &gpio_initstructure); +} - while(gpio_input_data_bit_read(GPIOB, GPIO_PINS_13)!=RESET); +/** + * @brief spi1 interrupt function + * @param none + * @retval none + */ + void SPI1_IRQHandler(void) +{ + if(spi_i2s_interrupt_flag_get(SPI1, SPI_I2S_TDBE_FLAG) != RESET) + { + spi_i2s_data_transmit(SPI1, spi1_tx_buffer[tx_index++]); + if(tx_index == BUFFER_SIZE) + { + spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, FALSE); + } + } +} + +/** + * @brief spi2 interrupt function + * @param none + * @retval none + */ + void SPI2_IRQHandler(void) +{ + if(spi_i2s_interrupt_flag_get(SPI2, SPI_I2S_RDBF_FLAG) != RESET) + { + spi2_rx_buffer[rx_index++] = spi_i2s_data_receive(SPI2); + } } /** @@ -153,23 +211,39 @@ int main(void) { system_clock_config(); at32_board_init(); + at32_led_on(LED4); nvic_priority_group_config(NVIC_PRIORITY_GROUP_4); gpio_config(); /* config spi1 send spi2 receive */ spi_config(); + + /* start communication: master pull down CS pin select slave */ + SPI_MASTER_CS_LOW; + + spi_enable(SPI2, TRUE); + spi_enable(SPI1, TRUE); + + /* wait slave data receive end */ while(rx_index < BUFFER_SIZE); + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); + + /* end communication: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; /* test result:the data check */ transfer_status = buffer_compare(spi2_rx_buffer, spi1_tx_buffer, BUFFER_SIZE); - /* test result indicate:if success ,led2 lights */ + /* test result indicate:if SUCCESS ,led2 lights */ if(transfer_status==SUCCESS) { at32_led_on(LED2); } else { - at32_led_off(LED2); + at32_led_on(LED3); } while(1) { diff --git a/project/at_start_f413/examples/spi/halfduplex_transceiver_switch/readme.txt b/project/at_start_f413/examples/spi/halfduplex_transceiver_switch/readme.txt index 050f607..1ba8d7c 100644 --- a/project/at_start_f413/examples/spi/halfduplex_transceiver_switch/readme.txt +++ b/project/at_start_f413/examples/spi/halfduplex_transceiver_switch/readme.txt @@ -10,6 +10,7 @@ realize data send and receive. the pins connection as follow: - spi2 slaver spi1 master + pb12(cs) <---> pa4(cs) pb13(sck) <---> pa5(sck) pb14(miso) <---> pa7(mosi) diff --git a/project/at_start_f413/examples/spi/halfduplex_transceiver_switch/src/at32f413_int.c b/project/at_start_f413/examples/spi/halfduplex_transceiver_switch/src/at32f413_int.c index 50de87b..7b490cb 100644 --- a/project/at_start_f413/examples/spi/halfduplex_transceiver_switch/src/at32f413_int.c +++ b/project/at_start_f413/examples/spi/halfduplex_transceiver_switch/src/at32f413_int.c @@ -24,14 +24,6 @@ /* includes ------------------------------------------------------------------*/ #include "at32f413_int.h" -#include "at32f413_board.h" - -extern uint8_t spi1_tx_buffer[]; -extern uint8_t spi2_tx_buffer[]; -extern uint8_t spi1_rx_buffer[]; -extern uint8_t spi2_rx_buffer[]; -extern uint32_t tx_index; -extern uint32_t rx_index; /** @addtogroup AT32F413_periph_examples * @{ @@ -41,8 +33,6 @@ extern uint32_t rx_index; * @{ */ -#define BUFFERSIZE 32 - /** * @brief this function handles nmi exception. * @param none @@ -140,54 +130,6 @@ void SysTick_Handler(void) { } -/** - * @brief This function handles the spi1 interrupt request. - * @param None - * @retval None - */ - void SPI1_IRQHandler(void) -{ - if(spi_i2s_interrupt_flag_get(SPI1, SPI_I2S_TDBE_FLAG) != RESET) - { - spi_i2s_data_transmit(SPI1, spi1_tx_buffer[tx_index++]); - if(tx_index == BUFFERSIZE) - { - spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, FALSE); - } - } - if(spi_i2s_interrupt_flag_get(SPI1, SPI_I2S_RDBF_FLAG) != RESET) - { - spi_enable(SPI1, FALSE); - spi1_rx_buffer[rx_index++] = spi_i2s_data_receive(SPI1); - spi_enable(SPI1, TRUE); - if(rx_index == BUFFERSIZE) - { - spi_i2s_interrupt_enable(SPI1, SPI_I2S_RDBF_INT, FALSE); - } - } -} - -/** - * @brief This function handles the spi2 interrupt request. - * @param None - * @retval None - */ - void SPI2_IRQHandler(void) -{ - if(spi_i2s_interrupt_flag_get(SPI2, SPI_I2S_TDBE_FLAG) != RESET) - { - spi_i2s_data_transmit(SPI2, spi2_tx_buffer[tx_index++]); - if(tx_index == BUFFERSIZE) - { - spi_i2s_interrupt_enable(SPI2, SPI_I2S_TDBE_INT, FALSE); - } - } - if(spi_i2s_interrupt_flag_get(SPI2, SPI_I2S_RDBF_FLAG) != RESET) - { - spi2_rx_buffer[rx_index++] = spi_i2s_data_receive(SPI2); - } -} - /** * @} */ diff --git a/project/at_start_f413/examples/spi/halfduplex_transceiver_switch/src/main.c b/project/at_start_f413/examples/spi/halfduplex_transceiver_switch/src/main.c index 7eb2e00..e6d54b9 100644 --- a/project/at_start_f413/examples/spi/halfduplex_transceiver_switch/src/main.c +++ b/project/at_start_f413/examples/spi/halfduplex_transceiver_switch/src/main.c @@ -33,8 +33,9 @@ * @{ */ -#define BUFFER_SIZE 32 - +#define SPI_MASTER_CS_HIGH gpio_bits_set(GPIOA, GPIO_PINS_4) +#define SPI_MASTER_CS_LOW gpio_bits_reset(GPIOA, GPIO_PINS_4) +#define BUFFER_SIZE 32 spi_init_type spi_init_struct; uint8_t spi1_tx_buffer[BUFFER_SIZE] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, @@ -49,10 +50,6 @@ uint8_t spi1_rx_buffer[BUFFER_SIZE], spi2_rx_buffer[BUFFER_SIZE]; volatile uint32_t tx_index = 0, rx_index = 0; volatile error_status transfer_status1 = ERROR, transfer_status2 = ERROR; -static void gpio_config(void); -static void spi_config(void); -error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t buffer_length); - /** * @brief buffer compare function. * @param pbuffer1, pbuffer2: buffers to be compared. @@ -81,9 +78,12 @@ error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t buffe */ static void spi_config(void) { + /* master spi initialization */ crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); - crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + nvic_irq_enable(SPI1_IRQn, 0, 0); spi_default_para_init(&spi_init_struct); + + /* single line bidirectional half duplex mode - transmitting */ spi_init_struct.transmission_mode = SPI_TRANSMIT_HALF_DUPLEX_TX; spi_init_struct.master_slave_mode = SPI_MODE_MASTER; spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_256; @@ -93,18 +93,27 @@ static void spi_config(void) spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; spi_init_struct.cs_mode_selection = SPI_CS_SOFTWARE_MODE; spi_init(SPI1, &spi_init_struct); - + + /* enable transmit data buffer empty interrupt */ + spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, TRUE); + + /* slave spi initialization */ + crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + nvic_irq_enable(SPI2_IRQn, 0, 0); + + /* single line bidirectional half duplex mode - receiving */ spi_init_struct.transmission_mode = SPI_TRANSMIT_HALF_DUPLEX_RX; spi_init_struct.master_slave_mode = SPI_MODE_SLAVE; + spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_256; + spi_init_struct.first_bit_transmission = SPI_FIRST_BIT_MSB; + spi_init_struct.frame_bit_num = SPI_FRAME_8BIT; + spi_init_struct.clock_polarity = SPI_CLOCK_POLARITY_LOW; + spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; + spi_init_struct.cs_mode_selection = SPI_CS_HARDWARE_MODE; spi_init(SPI2, &spi_init_struct); - nvic_irq_enable(SPI1_IRQn, 0, 0); - nvic_irq_enable(SPI2_IRQn, 0, 0); - spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, TRUE); + /* enable receive data buffer full interrupt */ spi_i2s_interrupt_enable(SPI2, SPI_I2S_RDBF_INT, TRUE); - - spi_enable(SPI1, TRUE); - spi_enable(SPI2, TRUE); } /** @@ -118,36 +127,103 @@ static void gpio_config(void) crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); gpio_default_para_init(&gpio_initstructure); - - /* spi1 sck pin */ - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + + /* master spi cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_OUTPUT; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_5; + gpio_initstructure.gpio_pins = GPIO_PINS_4; + gpio_init(GPIOA, &gpio_initstructure); + + /* non communication time: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; + + /* master spi sck pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_5; gpio_init(GPIOA, &gpio_initstructure); - /* spi1 mosi pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_7; + /* master spi mosi pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_7; gpio_init(GPIOA, &gpio_initstructure); - - /* spi2 sck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; - gpio_initstructure.gpio_pins = GPIO_PINS_13; + + /* slave spi cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pins = GPIO_PINS_12; gpio_init(GPIOB, &gpio_initstructure); - /* spi2 miso pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_14; + /* slave spi sck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_13; gpio_init(GPIOB, &gpio_initstructure); - while(gpio_input_data_bit_read(GPIOB, GPIO_PINS_13)!=RESET); + /* slave spi miso pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_14; + gpio_init(GPIOB, &gpio_initstructure); } +/** + * @brief spi1 interrupt function + * @param none + * @retval none + */ + void SPI1_IRQHandler(void) +{ + if(spi_i2s_interrupt_flag_get(SPI1, SPI_I2S_TDBE_FLAG) != RESET) + { + spi_i2s_data_transmit(SPI1, spi1_tx_buffer[tx_index++]); + if(tx_index == BUFFER_SIZE) + { + spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, FALSE); + } + } + if(spi_i2s_interrupt_flag_get(SPI1, SPI_I2S_RDBF_FLAG) != RESET) + { + spi_enable(SPI1, FALSE); + spi1_rx_buffer[rx_index++] = spi_i2s_data_receive(SPI1); + spi_enable(SPI1, TRUE); + if(rx_index == BUFFER_SIZE) + { + spi_i2s_interrupt_enable(SPI1, SPI_I2S_RDBF_INT, FALSE); + spi_enable(SPI1, FALSE); + } + } +} + +/** + * @brief spi2 interrupt function + * @param none + * @retval none + */ + void SPI2_IRQHandler(void) +{ + if(spi_i2s_interrupt_flag_get(SPI2, SPI_I2S_TDBE_FLAG) != RESET) + { + spi_i2s_data_transmit(SPI2, spi2_tx_buffer[tx_index++]); + if(tx_index == BUFFER_SIZE) + { + spi_i2s_interrupt_enable(SPI2, SPI_I2S_TDBE_INT, FALSE); + } + } + if(spi_i2s_interrupt_flag_get(SPI2, SPI_I2S_RDBF_FLAG) != RESET) + { + spi2_rx_buffer[rx_index++] = spi_i2s_data_receive(SPI2); + } +} + + /** * @brief main function. * @param none @@ -157,37 +233,70 @@ int main(void) { system_clock_config(); at32_board_init(); + at32_led_on(LED4); nvic_priority_group_config(NVIC_PRIORITY_GROUP_4); gpio_config(); + /* config spi1 send spi2 receive */ spi_config(); + + /* start communication: master pull down CS pin select slave */ + SPI_MASTER_CS_LOW; + + spi_enable(SPI2, TRUE); + spi_enable(SPI1, TRUE); + + /* wait data receive end */ while(rx_index < BUFFER_SIZE); - + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); + + /* end communication: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; + /* test result:the data check */ transfer_status1 = buffer_compare(spi2_rx_buffer, spi1_tx_buffer, BUFFER_SIZE); - + /* config spi2 send spi1 receive */ spi_enable(SPI1, FALSE); spi_enable(SPI2, FALSE); + rx_index = 0; tx_index = 0; spi_i2s_interrupt_enable(SPI1, SPI_I2S_TDBE_INT, FALSE); spi_i2s_interrupt_enable(SPI2, SPI_I2S_RDBF_INT, FALSE); - + + /* single line bidirectional half duplex mode - receiving */ spi_init_struct.transmission_mode = SPI_TRANSMIT_HALF_DUPLEX_RX; spi_init_struct.master_slave_mode = SPI_MODE_MASTER; + spi_init_struct.cs_mode_selection = SPI_CS_SOFTWARE_MODE; spi_init(SPI1, &spi_init_struct); - + + /* single line bidirectional half duplex mode - transmitting */ spi_init_struct.transmission_mode = SPI_TRANSMIT_HALF_DUPLEX_TX; spi_init_struct.master_slave_mode = SPI_MODE_SLAVE; + spi_init_struct.cs_mode_selection = SPI_CS_HARDWARE_MODE; spi_init(SPI2, &spi_init_struct); spi_i2s_interrupt_enable(SPI1, SPI_I2S_RDBF_INT, TRUE); spi_i2s_interrupt_enable(SPI2, SPI_I2S_TDBE_INT, TRUE); + + /* start communication: master pull down CS pin select slave */ + SPI_MASTER_CS_LOW; + spi_enable(SPI2, TRUE); spi_enable(SPI1, TRUE); + + /* wait slave data receive end */ while(rx_index < BUFFER_SIZE); - + + /* master half duplex receiving modethe busy flag isnot usefull */ + + /* end communication: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; + /* test result:the data check */ transfer_status2 = buffer_compare(spi1_rx_buffer, spi2_tx_buffer, BUFFER_SIZE); @@ -198,7 +307,7 @@ int main(void) } else { - at32_led_off(LED2); + at32_led_on(LED3); } while(1) { diff --git a/project/at_start_f413/examples/spi/only_receive_mode_polling/readme.txt b/project/at_start_f413/examples/spi/only_receive_mode_polling/readme.txt index 2969812..c3662bd 100644 --- a/project/at_start_f413/examples/spi/only_receive_mode_polling/readme.txt +++ b/project/at_start_f413/examples/spi/only_receive_mode_polling/readme.txt @@ -9,7 +9,9 @@ only receive mode receive data by polling mode. the pins connection as follow: - spi2 slaver spi1 master + pb12(cs) <---> pa4(cs) pb13(sck) <---> pa5(sck) pb15(mosi) <---> pa7(mosi) - for more detailed information. please refer to the application note document AN0102. \ No newline at end of file + for more detailed information. please refer to the application note document AN0102. + diff --git a/project/at_start_f413/examples/spi/only_receive_mode_polling/src/main.c b/project/at_start_f413/examples/spi/only_receive_mode_polling/src/main.c index 7e13a5d..c25fe5a 100644 --- a/project/at_start_f413/examples/spi/only_receive_mode_polling/src/main.c +++ b/project/at_start_f413/examples/spi/only_receive_mode_polling/src/main.c @@ -33,9 +33,10 @@ * @{ */ -#define BUFFER_SIZE 32 +#define SPI_MASTER_CS_HIGH gpio_bits_set(GPIOA, GPIO_PINS_4) +#define SPI_MASTER_CS_LOW gpio_bits_reset(GPIOA, GPIO_PINS_4) +#define BUFFER_SIZE 32 -spi_init_type spi_init_struct; uint8_t spi1_tx_buffer[BUFFER_SIZE] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, @@ -44,10 +45,6 @@ uint8_t spi2_rx_buffer[BUFFER_SIZE]; uint32_t tx_index = 0, rx_index = 0; volatile error_status transfer_status = ERROR; -static void gpio_config(void); -static void spi_config(void); -error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t buffer_length); - /** * @brief buffer compare function. * @param pbuffer1, pbuffer2: buffers to be compared. @@ -76,9 +73,13 @@ error_status buffer_compare(uint8_t* pbuffer1, uint8_t* pbuffer2, uint16_t buffe */ static void spi_config(void) { + spi_init_type spi_init_struct; + + /* master spi initialization */ crm_periph_clock_enable(CRM_SPI1_PERIPH_CLOCK, TRUE); - crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); spi_default_para_init(&spi_init_struct); + + /* dual line unidirectional full-duplex mode */ spi_init_struct.transmission_mode = SPI_TRANSMIT_FULL_DUPLEX; spi_init_struct.master_slave_mode = SPI_MODE_MASTER; spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; @@ -88,12 +89,23 @@ static void spi_config(void) spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; spi_init_struct.cs_mode_selection = SPI_CS_SOFTWARE_MODE; spi_init(SPI1, &spi_init_struct); - + + spi_enable(SPI1, TRUE); + + /* slave spi initialization */ + crm_periph_clock_enable(CRM_SPI2_PERIPH_CLOCK, TRUE); + + /* dual line unidirectional simplex receive-only mode */ spi_init_struct.transmission_mode = SPI_TRANSMIT_SIMPLEX_RX; spi_init_struct.master_slave_mode = SPI_MODE_SLAVE; + spi_init_struct.mclk_freq_division = SPI_MCLK_DIV_8; + spi_init_struct.first_bit_transmission = SPI_FIRST_BIT_LSB; + spi_init_struct.frame_bit_num = SPI_FRAME_8BIT; + spi_init_struct.clock_polarity = SPI_CLOCK_POLARITY_LOW; + spi_init_struct.clock_phase = SPI_CLOCK_PHASE_2EDGE; + spi_init_struct.cs_mode_selection = SPI_CS_HARDWARE_MODE; spi_init(SPI2, &spi_init_struct); - - spi_enable(SPI1, TRUE); + spi_enable(SPI2, TRUE); } @@ -108,34 +120,49 @@ static void gpio_config(void) crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); gpio_default_para_init(&gpio_initstructure); - - /* spi1 sck pin */ - gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + + /* master spi cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_OUTPUT; gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_5; + gpio_initstructure.gpio_pins = GPIO_PINS_4; gpio_init(GPIOA, &gpio_initstructure); - - /* spi1 mosi pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_MUX; - gpio_initstructure.gpio_pins = GPIO_PINS_7; + + /* non communication time: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; + + /* master spi sck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_5; gpio_init(GPIOA, &gpio_initstructure); - - /* spi2 sck pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; - gpio_initstructure.gpio_pins = GPIO_PINS_13; + + /* master spi mosi pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_MUX; + gpio_initstructure.gpio_pins = GPIO_PINS_7; + gpio_init(GPIOA, &gpio_initstructure); + + /* slave spi cs pin */ + gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + gpio_initstructure.gpio_pins = GPIO_PINS_12; + gpio_init(GPIOB, &gpio_initstructure); + + /* slave spi sck pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_13; gpio_init(GPIOB, &gpio_initstructure); - /* spi2 mosi pin */ - gpio_initstructure.gpio_pull = GPIO_PULL_DOWN; - gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; - gpio_initstructure.gpio_pins = GPIO_PINS_15; + /* slave spi mosi pin */ + gpio_initstructure.gpio_pull = GPIO_PULL_UP; + gpio_initstructure.gpio_mode = GPIO_MODE_INPUT; + gpio_initstructure.gpio_pins = GPIO_PINS_15; gpio_init(GPIOB, &gpio_initstructure); - - while(gpio_input_data_bit_read(GPIOB, GPIO_PINS_13) != RESET); } /** @@ -147,17 +174,31 @@ int main(void) { system_clock_config(); at32_board_init(); + at32_led_on(LED4); gpio_config(); spi_config(); - + + /* start communication: master pull down CS pin select slave */ + SPI_MASTER_CS_LOW; + /* transfer procedure:the "BUFFER_SIZE" data transfer */ while(tx_index < BUFFER_SIZE) { + /* master transmit data fill */ while(spi_i2s_flag_get(SPI1, SPI_I2S_TDBE_FLAG) == RESET); spi_i2s_data_transmit(SPI1, spi1_tx_buffer[tx_index++]); + + /* slave receive data get */ while(spi_i2s_flag_get(SPI2, SPI_I2S_RDBF_FLAG) == RESET); spi2_rx_buffer[rx_index++] = spi_i2s_data_receive(SPI2); } + + /* wait master and slave idle when communication end */ + while(spi_i2s_flag_get(SPI1, SPI_I2S_BF_FLAG) != RESET); + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); + + /* end communication: master pull up CS pin release slave */ + SPI_MASTER_CS_HIGH; /* test result:the data check */ transfer_status = buffer_compare(spi2_rx_buffer, spi1_tx_buffer, BUFFER_SIZE); @@ -169,7 +210,7 @@ int main(void) } else { - at32_led_off(LED2); + at32_led_on(LED3); } while(1) { diff --git a/project/at_start_f413/examples/spi/w25q_flash/readme.txt b/project/at_start_f413/examples/spi/w25q_flash/readme.txt index af7438d..cdb0623 100644 --- a/project/at_start_f413/examples/spi/w25q_flash/readme.txt +++ b/project/at_start_f413/examples/spi/w25q_flash/readme.txt @@ -5,8 +5,8 @@ ************************************************************************** */ - this demo is based on the at-start board and AT32-Comm-EV board, in this demo, - shows how to use spi access the w25q flash chip. + this demo is based on the at-start board, in this demo,shows how to use spi access + the w25q flash chip. the pins use as follow: - cs <---> pb12(software cs, pb12 as a general io to control flash cs) - sck <---> pb13 diff --git a/project/at_start_f413/examples/spi/w25q_flash/src/spi_flash.c b/project/at_start_f413/examples/spi/w25q_flash/src/spi_flash.c index 0d8d7ca..ca58c63 100644 --- a/project/at_start_f413/examples/spi/w25q_flash/src/spi_flash.c +++ b/project/at_start_f413/examples/spi/w25q_flash/src/spi_flash.c @@ -339,6 +339,9 @@ void spi_bytes_write(uint8_t *pbuffer, uint32_t length) while(dma_flag_get(DMA1_FDT4_FLAG) == RESET); dma_flag_clear(DMA1_FDT4_FLAG); + + /* wait spi idle when communication end */ + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); dma_channel_enable(DMA1_CHANNEL4, FALSE); dma_channel_enable(DMA1_CHANNEL5, FALSE); @@ -354,6 +357,9 @@ void spi_bytes_write(uint8_t *pbuffer, uint32_t length) dummy_data = spi_i2s_data_receive(SPI2); pbuffer++; } + + /* wait spi idle when communication end */ + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); #endif } @@ -403,6 +409,9 @@ void spi_bytes_read(uint8_t *pbuffer, uint32_t length) while(dma_flag_get(DMA1_FDT4_FLAG) == RESET); dma_flag_clear(DMA1_FDT4_FLAG); + + /* wait spi idle when communication end */ + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); dma_channel_enable(DMA1_CHANNEL4, FALSE); dma_channel_enable(DMA1_CHANNEL5, FALSE); @@ -418,6 +427,9 @@ void spi_bytes_read(uint8_t *pbuffer, uint32_t length) *pbuffer = spi_i2s_data_receive(SPI2); pbuffer++; } + + /* wait spi idle when communication end */ + while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); #endif } @@ -490,7 +502,10 @@ uint8_t spi_byte_write(uint8_t data) spi_i2s_data_transmit(SPI2, data); while(spi_i2s_flag_get(SPI2, SPI_I2S_RDBF_FLAG) == RESET); brxbuff = spi_i2s_data_receive(SPI2); + + /* wait spi idle when communication end */ while(spi_i2s_flag_get(SPI2, SPI_I2S_BF_FLAG) != RESET); + return brxbuff; } diff --git a/project/at_start_f413/templates/iar_v6.10/template.ewd b/project/at_start_f413/templates/iar_v6.10/template.ewd index 1d15828..7a0250c 100644 --- a/project/at_start_f413/templates/iar_v6.10/template.ewd +++ b/project/at_start_f413/templates/iar_v6.10/template.ewd @@ -3,7 +3,7 @@ 2 - Debug + template ARM @@ -828,832 +828,6 @@ - - Release - - ARM - - 0 - - C-SPY - 2 - - 22 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ARMSIM_ID - 2 - - 1 - 1 - 0 - - - - - - - - ANGEL_ID - 2 - - 0 - 1 - 0 - - - - - - - - - - - - GDBSERVER_ID - 2 - - 0 - 1 - 0 - - - - - - - - - - - IARROM_ID - 2 - - 1 - 1 - 0 - - - - - - - - - JLINK_ID - 2 - - 12 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LMIFTDI_ID - 2 - - 2 - 1 - 0 - - - - - - - - - - MACRAIGOR_ID - 2 - - 3 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - PEMICRO_ID - 2 - - 0 - 1 - 0 - - - - - - - - - - - - - - - - - RDI_ID - 2 - - 1 - 1 - 0 - - - - - - - - - - - - - - - - - STLINK_ID - 2 - - 1 - 1 - 0 - - - - - - - THIRDPARTY_ID - 2 - - 0 - 1 - 0 - - - - - - - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\PowerPac\PowerPacRTOS.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB6_Plugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin - 0 - - - $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin - 1 - - - $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin - 0 - - - $EW_DIR$\common\plugins\Stack\Stack.ENU.ewplugin - 1 - - - $EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin - 1 - - - diff --git a/project/at_start_f413/templates/iar_v6.10/template.ewp b/project/at_start_f413/templates/iar_v6.10/template.ewp index d8c5fe4..d8f3d3b 100644 --- a/project/at_start_f413/templates/iar_v6.10/template.ewp +++ b/project/at_start_f413/templates/iar_v6.10/template.ewp @@ -3,7 +3,7 @@ 2 - Debug + template ARM @@ -17,15 +17,15 @@ 1 - - Release - - ARM - - 0 - - General - 3 - - 18 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 26 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 8 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 0 - - - - - - - - - CUSTOM - 3 - - - - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 11 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 0 - - - - - - - BILINK - 0 - - - bsp diff --git a/project/at_start_f413/templates/iar_v7.4/template.ewd b/project/at_start_f413/templates/iar_v7.4/template.ewd index 70b6446..58f19f8 100644 --- a/project/at_start_f413/templates/iar_v7.4/template.ewd +++ b/project/at_start_f413/templates/iar_v7.4/template.ewd @@ -3,7 +3,7 @@ 2 - Debug + template ARM @@ -1487,1491 +1487,6 @@ - - Release - - ARM - - 0 - - C-SPY - 2 - - 26 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ARMSIM_ID - 2 - - 1 - 1 - 0 - - - - - - - - ANGEL_ID - 2 - - 0 - 1 - 0 - - - - - - - - - - - - CMSISDAP_ID - 2 - - 2 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GDBSERVER_ID - 2 - - 0 - 1 - 0 - - - - - - - - - - - IARROM_ID - 2 - - 1 - 1 - 0 - - - - - - - - - IJET_ID - 2 - - 6 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - JLINK_ID - 2 - - 15 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LMIFTDI_ID - 2 - - 2 - 1 - 0 - - - - - - - - - - MACRAIGOR_ID - 2 - - 3 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - PEMICRO_ID - 2 - - 1 - 1 - 0 - - - - - - - - - - - - - - - - - - - RDI_ID - 2 - - 2 - 1 - 0 - - - - - - - - - - - - - - - - STLINK_ID - 2 - - 2 - 1 - 0 - - - - - - - - - - - THIRDPARTY_ID - 2 - - 0 - 1 - 0 - - - - - - - - XDS100_ID - 2 - - 4 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin - 0 - - - $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin - 1 - - - $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin - 0 - - - $EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin - 1 - - - $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin - 0 - - - diff --git a/project/at_start_f413/templates/iar_v7.4/template.ewp b/project/at_start_f413/templates/iar_v7.4/template.ewp index 441fae4..10da9b5 100644 --- a/project/at_start_f413/templates/iar_v7.4/template.ewp +++ b/project/at_start_f413/templates/iar_v7.4/template.ewp @@ -3,7 +3,7 @@ 2 - Debug + template ARM @@ -17,15 +17,15 @@ 1 - - Release - - ARM - - 0 - - General - 3 - - 24 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 31 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 9 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 0 - - - - - - - - - CUSTOM - 3 - - - - 0 - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 16 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 0 - - - - - - - BILINK - 0 - - - bsp diff --git a/project/at_start_f413/templates/iar_v7.4/template.ewt b/project/at_start_f413/templates/iar_v7.4/template.ewt index 4bf1c5b..3ce70fa 100644 --- a/project/at_start_f413/templates/iar_v7.4/template.ewt +++ b/project/at_start_f413/templates/iar_v7.4/template.ewt @@ -3,7 +3,7 @@ 2 - Debug + template ARM @@ -1048,1052 +1048,6 @@ - - Release - - ARM - - 0 - - C-STAT - 1 - - 1 - - 0 - - 600 - 0 - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RuntimeChecking - 0 - - 2 - 1 - 0 - - - - - - - - - - - - - - - - - - - - bsp diff --git a/project/at_start_f413/templates/iar_v8.2/template.ewd b/project/at_start_f413/templates/iar_v8.2/template.ewd index 5835530..c57399a 100644 --- a/project/at_start_f413/templates/iar_v8.2/template.ewd +++ b/project/at_start_f413/templates/iar_v8.2/template.ewd @@ -2,7 +2,7 @@ 3 - Debug + template ARM @@ -1453,1456 +1453,4 @@ - - Release - - ARM - - 0 - - C-SPY - 2 - - 29 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ARMSIM_ID - 2 - - 1 - 1 - 0 - - - - - - - - CADI_ID - 2 - - 0 - 1 - 0 - - - - - - - - - CMSISDAP_ID - 2 - - 4 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GDBSERVER_ID - 2 - - 0 - 1 - 0 - - - - - - - - - - - IJET_ID - 2 - - 8 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - JLINK_ID - 2 - - 16 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LMIFTDI_ID - 2 - - 2 - 1 - 0 - - - - - - - - - - NULINK_ID - 2 - - 0 - 1 - 0 - - - - - - - PEMICRO_ID - 2 - - 3 - 1 - 0 - - - - - - - - STLINK_ID - 2 - - 5 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - THIRDPARTY_ID - 2 - - 0 - 1 - 0 - - - - - - - - TIFET_ID - 2 - - 1 - 1 - 0 - - - - - - - - - - - - - - - - - - - XDS100_ID - 2 - - 6 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\FreeRtos\FreeRtosArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm8.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm8BE.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin - 0 - - - $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin - 1 - - - $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin - 0 - - - $EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin - 0 - - - $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin - 0 - - - diff --git a/project/at_start_f413/templates/iar_v8.2/template.ewp b/project/at_start_f413/templates/iar_v8.2/template.ewp index f2c362c..fedfedb 100644 --- a/project/at_start_f413/templates/iar_v8.2/template.ewp +++ b/project/at_start_f413/templates/iar_v8.2/template.ewp @@ -2,7 +2,7 @@ 3 - Debug + template ARM @@ -16,15 +16,15 @@ 1 - - Release - - ARM - - 0 - - General - 3 - - 30 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 34 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 10 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 0 - - - - - - - - - CUSTOM - 3 - - - - 0 - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 20 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 0 - - - - - - - BILINK - 0 - - - bsp diff --git a/project/at_start_f413/templates/iar_v8.2/template.ewt b/project/at_start_f413/templates/iar_v8.2/template.ewt index b9e8ae4..b272464 100644 --- a/project/at_start_f413/templates/iar_v8.2/template.ewt +++ b/project/at_start_f413/templates/iar_v8.2/template.ewt @@ -2,7 +2,7 @@ 3 - Debug + template ARM @@ -1187,1192 +1187,6 @@ - - Release - - ARM - - 0 - - C-STAT - 261 - - 261 - - 0 - - 1 - 600 - 0 - 2 - 0 - 1 - 100 - - - 1.5.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RuntimeChecking - 0 - - 2 - 1 - 0 - - - - - - - - - - - - - - - - - - - - bsp diff --git a/project/at_start_f413/templates/iar_v9.3/template.ewd b/project/at_start_f413/templates/iar_v9.3/template.ewd index d36d537..68cd29d 100644 --- a/project/at_start_f413/templates/iar_v9.3/template.ewd +++ b/project/at_start_f413/templates/iar_v9.3/template.ewd @@ -2,7 +2,7 @@ 3 - Debug + template ARM @@ -1543,1546 +1543,4 @@ - - Release - - ARM - - 0 - - C-SPY - 2 - - 32 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ARMSIM_ID - 2 - - 1 - 1 - 0 - - - - - - - - CADI_ID - 2 - - 0 - 1 - 0 - - - - - - - - - CMSISDAP_ID - 2 - - 4 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GDBSERVER_ID - 2 - - 0 - 1 - 0 - - - - - - - - - - - IJET_ID - 2 - - 9 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - JLINK_ID - 2 - - 16 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LMIFTDI_ID - 2 - - 3 - 1 - 0 - - - - - - - - - - - - - NULINK_ID - 2 - - 0 - 1 - 0 - - - - - - - PEMICRO_ID - 2 - - 3 - 1 - 0 - - - - - - - - STLINK_ID - 2 - - 7 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - THIRDPARTY_ID - 2 - - 0 - 1 - 0 - - - - - - - - TIFET_ID - 2 - - 1 - 1 - 0 - - - - - - - - - - - - - - - - - - - XDS100_ID - 2 - - 9 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\FreeRtos\FreeRtosArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin2.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9BE.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin - 0 - - - $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin - 0 - - - $EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin - 0 - - - $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin - 0 - - - diff --git a/project/at_start_f413/templates/iar_v9.3/template.ewp b/project/at_start_f413/templates/iar_v9.3/template.ewp index 959f5d5..f481181 100644 --- a/project/at_start_f413/templates/iar_v9.3/template.ewp +++ b/project/at_start_f413/templates/iar_v9.3/template.ewp @@ -2,7 +2,7 @@ 3 - Debug + template ARM @@ -16,19 +16,19 @@ 1 - - Release - - ARM - - 0 - - General - 3 - - 35 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 37 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 11 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 0 - - - - - - - - - CUSTOM - 3 - - - - 0 - inputOutputBased - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 27 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 0 - - - - - - bsp diff --git a/project/at_start_f413/templates/iar_v9.3/template.ewt b/project/at_start_f413/templates/iar_v9.3/template.ewt index e6ec94c..9a0897d 100644 --- a/project/at_start_f413/templates/iar_v9.3/template.ewt +++ b/project/at_start_f413/templates/iar_v9.3/template.ewt @@ -2,7 +2,7 @@ 3 - Debug + template ARM @@ -22,7 +22,7 @@ 0 1 100 - Debug/C-STAT + template/C-STAT 2.4.1 @@ -1423,1428 +1423,6 @@ - - Release - - ARM - - 0 - - C-STAT - 516 - - 516 - - 0 - - 1 - 600 - 1 - 2 - 0 - 1 - 100 - Release/C-STAT - - - 2.4.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RuntimeChecking - 0 - - 2 - 1 - 0 - - - - - - - - - - - - - - - - - - - - bsp diff --git a/utilities/at32f413_usart_iap_demo/tool_release/IAP_Programmer.exe b/utilities/at32f413_usart_iap_demo/tool_release/IAP_Programmer.exe index 78db0fa..6b12b62 100644 Binary files a/utilities/at32f413_usart_iap_demo/tool_release/IAP_Programmer.exe and b/utilities/at32f413_usart_iap_demo/tool_release/IAP_Programmer.exe differ diff --git a/utilities/at32f413_usb_iap_demo/tool_release/IAP_Programmer.exe b/utilities/at32f413_usb_iap_demo/tool_release/IAP_Programmer.exe index 78db0fa..6b12b62 100644 Binary files a/utilities/at32f413_usb_iap_demo/tool_release/IAP_Programmer.exe and b/utilities/at32f413_usb_iap_demo/tool_release/IAP_Programmer.exe differ