mirror of
https://github.com/ArteryTek/AT32F413_Firmware_Library.git
synced 2026-05-21 09:22:02 +00:00
update version to v2.0.4
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_conf.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
@@ -150,7 +150,7 @@ extern "C" {
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_user.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb 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
|
||||
* 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,
|
||||
@@ -23,7 +23,7 @@
|
||||
*
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __HID_IAP_USER_H
|
||||
#define __HID_IAP_USER_H
|
||||
@@ -31,7 +31,7 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "hid_iap_class.h"
|
||||
|
||||
/** @addtogroup UTILITIES_examples
|
||||
@@ -55,7 +55,7 @@ extern "C" {
|
||||
/** @defgroup app_led3_toggle_exported_functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
void iap_init(void);
|
||||
iap_result_type iap_get_upgrade_flag(void);
|
||||
void app_loop(void);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usb_conf.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb 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
|
||||
* 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,
|
||||
@@ -39,7 +39,7 @@ extern "C" {
|
||||
/** @addtogroup AT32F413_periph_examples
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup 413_USB_device_hid_app_led3
|
||||
* @{
|
||||
*/
|
||||
@@ -68,8 +68,8 @@ extern "C" {
|
||||
* @brief user custom endpoint buffer
|
||||
* EPTn_TX_ADDR, EPTn_RX_ADDR must less than usb buffer size
|
||||
*/
|
||||
|
||||
/* ept0 tx start address 0x40, size 0x40,
|
||||
|
||||
/* ept0 tx start address 0x40, size 0x40,
|
||||
so rx start address is 0x40 + 0x40 = 0x80 */
|
||||
#define EPT0_TX_ADDR 0x40 /*!< usb endpoint 0 tx buffer address offset */
|
||||
#define EPT0_RX_ADDR 0x80 /*!< usb endpoint 0 rx buffer address offset */
|
||||
@@ -101,11 +101,11 @@ void usb_delay_us(uint32_t us);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file readme.txt
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief readme
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
/* includes ------------------------------------------------------------------*/
|
||||
#include "at32f413_clock.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief system clock config program
|
||||
* @note the system clock is configured as follow:
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
@@ -134,8 +134,8 @@ void SysTick_Handler(void)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_user.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb hid iap user 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
|
||||
* 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,
|
||||
@@ -50,31 +50,31 @@ void iap_respond(uint8_t *res_buf, uint16_t iap_cmd, uint16_t result);
|
||||
/**
|
||||
* @brief clear iap upgrade flag
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_clear_upgrade_flag(void)
|
||||
{
|
||||
flash_unlock();
|
||||
flash_sector_erase(iap_info.flag_address);
|
||||
flash_lock();
|
||||
flash_lock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set iap upgrade complete flag
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_set_upgrade_flag(void)
|
||||
{
|
||||
flash_unlock();
|
||||
flash_word_program(iap_info.flag_address, IAP_UPGRADE_COMPLETE_FLAG);
|
||||
flash_lock();
|
||||
flash_lock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get iap upgrade complete flag
|
||||
* @param none
|
||||
* @retval the status of the iap flag
|
||||
* @retval the status of the iap flag
|
||||
*/
|
||||
iap_result_type iap_get_upgrade_flag(void)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ iap_result_type iap_get_upgrade_flag(void)
|
||||
/**
|
||||
* @brief iap init
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_init(void)
|
||||
{
|
||||
@@ -105,13 +105,13 @@ void iap_init(void)
|
||||
{
|
||||
iap_info.sector_size = SECTOR_SIZE_2K;
|
||||
}
|
||||
|
||||
|
||||
iap_info.flash_start_address = FLASH_BASE;
|
||||
iap_info.flash_end_address = iap_info.flash_start_address + iap_info.flash_size;
|
||||
|
||||
|
||||
iap_info.app_address = FLASH_APP_ADDRESS;
|
||||
iap_info.flag_address = iap_info.app_address - iap_info.sector_size;
|
||||
|
||||
|
||||
iap_info.fifo_length = 0;
|
||||
iap_info.iap_address = 0;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void iap_init(void)
|
||||
/**
|
||||
* @brief iap idle function
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_idle(void)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ void iap_idle(void)
|
||||
/**
|
||||
* @brief iap start function
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_start(void)
|
||||
{
|
||||
@@ -143,22 +143,22 @@ void iap_start(void)
|
||||
/*
|
||||
* @brief iap jump
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_jump()
|
||||
{
|
||||
iap_info.state = IAP_STS_JMP_WAIT;
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_JMP, IAP_ACK);
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_JMP, IAP_ACK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief iap get
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_get()
|
||||
{
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_GET, IAP_ACK);
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_GET, IAP_ACK);
|
||||
iap_info.iap_tx[4] = (uint8_t)((iap_info.app_address >> 24) & 0xFF);
|
||||
iap_info.iap_tx[5] = (uint8_t)((iap_info.app_address >> 16) & 0xFF);
|
||||
iap_info.iap_tx[6] = (uint8_t)((iap_info.app_address >> 8) & 0xFF);
|
||||
@@ -172,7 +172,7 @@ void iap_get()
|
||||
* @param res_buf: data buffer pointer.
|
||||
* @param iap_cmd: iap command
|
||||
* @param result: iap result
|
||||
* @retval the result of the address parse
|
||||
* @retval the result of the address parse
|
||||
*/
|
||||
void iap_respond(uint8_t *res_buf, uint16_t iap_cmd, uint16_t result)
|
||||
{
|
||||
@@ -180,7 +180,7 @@ void iap_respond(uint8_t *res_buf, uint16_t iap_cmd, uint16_t result)
|
||||
res_buf[1] = (uint8_t)((iap_cmd) & 0xFF);
|
||||
res_buf[2] = (uint8_t)((result >> 8) & 0xFF);
|
||||
res_buf[3] = (uint8_t)((result) & 0xFF);
|
||||
|
||||
|
||||
iap_info.respond_flag = 1;
|
||||
}
|
||||
|
||||
@@ -189,22 +189,22 @@ void iap_respond(uint8_t *res_buf, uint16_t iap_cmd, uint16_t result)
|
||||
* @param udev: to the structure of usbd_core_type
|
||||
* @param pdata: data buffer point
|
||||
* @param len: data length
|
||||
* @retval iap_result_type
|
||||
* @retval iap_result_type
|
||||
*/
|
||||
iap_result_type usbd_hid_iap_process(void *udev, uint8_t *pdata, uint16_t len)
|
||||
{
|
||||
iap_result_type status = IAP_SUCCESS;
|
||||
uint16_t iap_cmd;
|
||||
|
||||
|
||||
if(len < 2)
|
||||
{
|
||||
return IAP_FAILED;
|
||||
}
|
||||
|
||||
|
||||
iap_info.respond_flag = 0;
|
||||
|
||||
|
||||
iap_cmd = (pdata[0] << 8) | pdata[1];
|
||||
|
||||
|
||||
switch(iap_cmd)
|
||||
{
|
||||
case IAP_CMD_IDLE:
|
||||
@@ -221,21 +221,21 @@ iap_result_type usbd_hid_iap_process(void *udev, uint8_t *pdata, uint16_t len)
|
||||
break;
|
||||
default:
|
||||
status = IAP_FAILED;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(iap_info.respond_flag)
|
||||
{
|
||||
usb_iap_class_send_report(udev, iap_info.iap_tx, 64);
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usb device in transfer complete function
|
||||
* @param udev: to the structure of usbd_core_type
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void usbd_hid_iap_in_complete(void *udev)
|
||||
{
|
||||
@@ -248,7 +248,7 @@ void usbd_hid_iap_in_complete(void *udev)
|
||||
/**
|
||||
* @brief iap loop
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void app_loop(void)
|
||||
{
|
||||
@@ -261,8 +261,8 @@ void app_loop(void)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file main.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief main program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -152,7 +152,7 @@ int main(void)
|
||||
{
|
||||
/* config vector table offset */
|
||||
nvic_vector_table_set(NVIC_VECTTAB_FLASH, 0x4000);
|
||||
|
||||
|
||||
system_clock_config();
|
||||
|
||||
/* config nvic priority group */
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_conf.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
@@ -150,7 +150,7 @@ extern "C" {
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_user.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb 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
|
||||
* 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,
|
||||
@@ -23,7 +23,7 @@
|
||||
*
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __HID_IAP_USER_H
|
||||
#define __HID_IAP_USER_H
|
||||
@@ -31,7 +31,7 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "hid_iap_class.h"
|
||||
|
||||
/** @addtogroup UTILITIES_examples
|
||||
@@ -55,7 +55,7 @@ extern "C" {
|
||||
/** @defgroup app_led4_toggle_exported_functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
void iap_init(void);
|
||||
iap_result_type iap_get_upgrade_flag(void);
|
||||
void app_loop(void);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usb_conf.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb 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
|
||||
* 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,
|
||||
@@ -39,7 +39,7 @@ extern "C" {
|
||||
/** @addtogroup AT32F413_periph_examples
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup 413_USB_device_hid_app_led3
|
||||
* @{
|
||||
*/
|
||||
@@ -68,8 +68,8 @@ extern "C" {
|
||||
* @brief user custom endpoint buffer
|
||||
* EPTn_TX_ADDR, EPTn_RX_ADDR must less than usb buffer size
|
||||
*/
|
||||
|
||||
/* ept0 tx start address 0x40, size 0x40,
|
||||
|
||||
/* ept0 tx start address 0x40, size 0x40,
|
||||
so rx start address is 0x40 + 0x40 = 0x80 */
|
||||
#define EPT0_TX_ADDR 0x40 /*!< usb endpoint 0 tx buffer address offset */
|
||||
#define EPT0_RX_ADDR 0x80 /*!< usb endpoint 0 rx buffer address offset */
|
||||
@@ -101,11 +101,11 @@ void usb_delay_us(uint32_t us);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file readme.txt
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief readme
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
/* includes ------------------------------------------------------------------*/
|
||||
#include "at32f413_clock.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief system clock config program
|
||||
* @note the system clock is configured as follow:
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
@@ -134,8 +134,8 @@ void SysTick_Handler(void)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_user.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb hid iap user 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
|
||||
* 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,
|
||||
@@ -50,31 +50,31 @@ void iap_respond(uint8_t *res_buf, uint16_t iap_cmd, uint16_t result);
|
||||
/**
|
||||
* @brief clear iap upgrade flag
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_clear_upgrade_flag(void)
|
||||
{
|
||||
flash_unlock();
|
||||
flash_sector_erase(iap_info.flag_address);
|
||||
flash_lock();
|
||||
flash_lock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set iap upgrade complete flag
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_set_upgrade_flag(void)
|
||||
{
|
||||
flash_unlock();
|
||||
flash_word_program(iap_info.flag_address, IAP_UPGRADE_COMPLETE_FLAG);
|
||||
flash_lock();
|
||||
flash_lock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get iap upgrade complete flag
|
||||
* @param none
|
||||
* @retval the status of the iap flag
|
||||
* @retval the status of the iap flag
|
||||
*/
|
||||
iap_result_type iap_get_upgrade_flag(void)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ iap_result_type iap_get_upgrade_flag(void)
|
||||
/**
|
||||
* @brief iap init
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_init(void)
|
||||
{
|
||||
@@ -105,13 +105,13 @@ void iap_init(void)
|
||||
{
|
||||
iap_info.sector_size = SECTOR_SIZE_2K;
|
||||
}
|
||||
|
||||
|
||||
iap_info.flash_start_address = FLASH_BASE;
|
||||
iap_info.flash_end_address = iap_info.flash_start_address + iap_info.flash_size;
|
||||
|
||||
|
||||
iap_info.app_address = FLASH_APP_ADDRESS;
|
||||
iap_info.flag_address = iap_info.app_address - iap_info.sector_size;
|
||||
|
||||
|
||||
iap_info.fifo_length = 0;
|
||||
iap_info.iap_address = 0;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void iap_init(void)
|
||||
/**
|
||||
* @brief iap idle function
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_idle(void)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ void iap_idle(void)
|
||||
/**
|
||||
* @brief iap start function
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_start(void)
|
||||
{
|
||||
@@ -143,22 +143,22 @@ void iap_start(void)
|
||||
/*
|
||||
* @brief iap jump
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_jump()
|
||||
{
|
||||
iap_info.state = IAP_STS_JMP_WAIT;
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_JMP, IAP_ACK);
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_JMP, IAP_ACK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief iap get
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_get()
|
||||
{
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_GET, IAP_ACK);
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_GET, IAP_ACK);
|
||||
iap_info.iap_tx[4] = (uint8_t)((iap_info.app_address >> 24) & 0xFF);
|
||||
iap_info.iap_tx[5] = (uint8_t)((iap_info.app_address >> 16) & 0xFF);
|
||||
iap_info.iap_tx[6] = (uint8_t)((iap_info.app_address >> 8) & 0xFF);
|
||||
@@ -172,7 +172,7 @@ void iap_get()
|
||||
* @param res_buf: data buffer pointer.
|
||||
* @param iap_cmd: iap command
|
||||
* @param result: iap result
|
||||
* @retval the result of the address parse
|
||||
* @retval the result of the address parse
|
||||
*/
|
||||
void iap_respond(uint8_t *res_buf, uint16_t iap_cmd, uint16_t result)
|
||||
{
|
||||
@@ -180,7 +180,7 @@ void iap_respond(uint8_t *res_buf, uint16_t iap_cmd, uint16_t result)
|
||||
res_buf[1] = (uint8_t)((iap_cmd) & 0xFF);
|
||||
res_buf[2] = (uint8_t)((result >> 8) & 0xFF);
|
||||
res_buf[3] = (uint8_t)((result) & 0xFF);
|
||||
|
||||
|
||||
iap_info.respond_flag = 1;
|
||||
}
|
||||
|
||||
@@ -189,22 +189,22 @@ void iap_respond(uint8_t *res_buf, uint16_t iap_cmd, uint16_t result)
|
||||
* @param udev: to the structure of usbd_core_type
|
||||
* @param pdata: data buffer point
|
||||
* @param len: data length
|
||||
* @retval iap_result_type
|
||||
* @retval iap_result_type
|
||||
*/
|
||||
iap_result_type usbd_hid_iap_process(void *udev, uint8_t *pdata, uint16_t len)
|
||||
{
|
||||
iap_result_type status = IAP_SUCCESS;
|
||||
uint16_t iap_cmd;
|
||||
|
||||
|
||||
if(len < 2)
|
||||
{
|
||||
return IAP_FAILED;
|
||||
}
|
||||
|
||||
|
||||
iap_info.respond_flag = 0;
|
||||
|
||||
|
||||
iap_cmd = (pdata[0] << 8) | pdata[1];
|
||||
|
||||
|
||||
switch(iap_cmd)
|
||||
{
|
||||
case IAP_CMD_IDLE:
|
||||
@@ -221,21 +221,21 @@ iap_result_type usbd_hid_iap_process(void *udev, uint8_t *pdata, uint16_t len)
|
||||
break;
|
||||
default:
|
||||
status = IAP_FAILED;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(iap_info.respond_flag)
|
||||
{
|
||||
usb_iap_class_send_report(udev, iap_info.iap_tx, 64);
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usb device in transfer complete function
|
||||
* @param udev: to the structure of usbd_core_type
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void usbd_hid_iap_in_complete(void *udev)
|
||||
{
|
||||
@@ -248,7 +248,7 @@ void usbd_hid_iap_in_complete(void *udev)
|
||||
/**
|
||||
* @brief iap loop
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void app_loop(void)
|
||||
{
|
||||
@@ -261,8 +261,8 @@ void app_loop(void)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file main.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief main program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -152,7 +152,7 @@ int main(void)
|
||||
{
|
||||
/* config vector table offset */
|
||||
nvic_vector_table_set(NVIC_VECTTAB_FLASH, 0x4000);
|
||||
|
||||
|
||||
system_clock_config();
|
||||
|
||||
/* config nvic priority group */
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_conf.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
@@ -150,7 +150,7 @@ extern "C" {
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_user.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb 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
|
||||
* 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,
|
||||
@@ -23,7 +23,7 @@
|
||||
*
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __HID_IAP_USER_H
|
||||
#define __HID_IAP_USER_H
|
||||
@@ -31,7 +31,7 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "hid_iap_class.h"
|
||||
|
||||
/** @addtogroup UTILITIES_examples
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usb_conf.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb 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
|
||||
* 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,
|
||||
@@ -39,7 +39,7 @@ extern "C" {
|
||||
/** @addtogroup AT32F413_periph_examples
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup 413_USB_device_hid_iap
|
||||
* @{
|
||||
*/
|
||||
@@ -68,8 +68,8 @@ extern "C" {
|
||||
* @brief user custom endpoint buffer
|
||||
* EPTn_TX_ADDR, EPTn_RX_ADDR must less than usb buffer size
|
||||
*/
|
||||
|
||||
/* ept0 tx start address 0x40, size 0x40,
|
||||
|
||||
/* ept0 tx start address 0x40, size 0x40,
|
||||
so rx start address is 0x40 + 0x40 = 0x80 */
|
||||
#define EPT0_TX_ADDR 0x40 /*!< usb endpoint 0 tx buffer address offset */
|
||||
#define EPT0_RX_ADDR 0x80 /*!< usb endpoint 0 rx buffer address offset */
|
||||
@@ -101,11 +101,11 @@ void usb_delay_us(uint32_t us);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file readme.txt
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief readme
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
/* includes ------------------------------------------------------------------*/
|
||||
#include "at32f413_clock.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief system clock config program
|
||||
* @note the system clock is configured as follow:
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @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
|
||||
* 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,
|
||||
@@ -134,8 +134,8 @@ void SysTick_Handler(void)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_user.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb hid iap user 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
|
||||
* 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,
|
||||
@@ -52,14 +52,14 @@ void iap_respond(uint8_t *res_buf, uint16_t iap_cmd, uint16_t result);
|
||||
/**
|
||||
* @brief jump to app
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void jump_to_app(uint32_t address)
|
||||
{
|
||||
uint32_t stkptr, jumpaddr;
|
||||
stkptr = *(uint32_t *)address;
|
||||
jumpaddr = *(uint32_t *)(address + sizeof(uint32_t));
|
||||
|
||||
|
||||
/* disable nvic irq and periph clock, clear pending */
|
||||
nvic_irq_disable(USBFS_L_CAN1_RX0_IRQn);
|
||||
__NVIC_ClearPendingIRQ(USBFS_L_CAN1_RX0_IRQn);
|
||||
@@ -77,31 +77,31 @@ void jump_to_app(uint32_t address)
|
||||
/**
|
||||
* @brief clear iap upgrade flag
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_clear_upgrade_flag(void)
|
||||
{
|
||||
flash_unlock();
|
||||
flash_sector_erase(iap_info.flag_address);
|
||||
flash_lock();
|
||||
flash_lock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set iap upgrade complete flag
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_set_upgrade_flag(void)
|
||||
{
|
||||
flash_unlock();
|
||||
flash_word_program(iap_info.flag_address, IAP_UPGRADE_COMPLETE_FLAG);
|
||||
flash_lock();
|
||||
flash_lock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get iap upgrade complete flag
|
||||
* @param none
|
||||
* @retval the status of the iap flag
|
||||
* @retval the status of the iap flag
|
||||
*/
|
||||
iap_result_type iap_get_upgrade_flag(void)
|
||||
{
|
||||
@@ -119,7 +119,7 @@ iap_result_type iap_get_upgrade_flag(void)
|
||||
/**
|
||||
* @brief set iap upgrade complete flag
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_erase_sector(uint32_t address)
|
||||
{
|
||||
@@ -150,7 +150,7 @@ void iap_erase_sector(uint32_t address)
|
||||
* @brief crc cal
|
||||
* @param addr: start address
|
||||
* @param nk: nk byte
|
||||
* @retval crc value
|
||||
* @retval crc value
|
||||
*/
|
||||
uint32_t crc_cal(uint32_t addr, uint16_t nk)
|
||||
{
|
||||
@@ -159,7 +159,7 @@ uint32_t crc_cal(uint32_t addr, uint16_t nk)
|
||||
uint32_t value, i_index = 0;
|
||||
crm_periph_clock_enable(CRM_CRC_PERIPH_CLOCK, TRUE);
|
||||
crc_data_reset();
|
||||
|
||||
|
||||
for(i_index = 0; i_index < wlen; i_index ++)
|
||||
{
|
||||
value = *paddr;
|
||||
@@ -172,7 +172,7 @@ uint32_t crc_cal(uint32_t addr, uint16_t nk)
|
||||
/**
|
||||
* @brief iap init
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_init(void)
|
||||
{
|
||||
@@ -185,13 +185,13 @@ void iap_init(void)
|
||||
{
|
||||
iap_info.sector_size = SECTOR_SIZE_2K;
|
||||
}
|
||||
|
||||
|
||||
iap_info.flash_start_address = FLASH_BASE;
|
||||
iap_info.flash_end_address = iap_info.flash_start_address + iap_info.flash_size;
|
||||
|
||||
|
||||
iap_info.app_address = FLASH_APP_ADDRESS;
|
||||
iap_info.flag_address = iap_info.app_address - iap_info.sector_size;
|
||||
|
||||
|
||||
iap_info.fifo_length = 0;
|
||||
iap_info.iap_address = 0;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ void iap_init(void)
|
||||
/**
|
||||
* @brief iap idle function
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_idle(void)
|
||||
{
|
||||
@@ -211,7 +211,7 @@ void iap_idle(void)
|
||||
/**
|
||||
* @brief iap start function
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_start(void)
|
||||
{
|
||||
@@ -224,7 +224,7 @@ void iap_start(void)
|
||||
* @brief iap parse address
|
||||
* @param pdata: data buffer pointer.
|
||||
* @param len: data length
|
||||
* @retval the result of the address parse
|
||||
* @retval the result of the address parse
|
||||
*/
|
||||
iap_result_type iap_address(uint8_t *pdata, uint32_t len)
|
||||
{
|
||||
@@ -232,12 +232,12 @@ iap_result_type iap_address(uint8_t *pdata, uint32_t len)
|
||||
uint16_t result = IAP_ACK;
|
||||
uint8_t *paddr = pdata + 2; /* skip iap cmd */
|
||||
uint32_t address;
|
||||
|
||||
address = (paddr[0] << 24) |
|
||||
(paddr[1] << 16) |
|
||||
(paddr[2] << 8) |
|
||||
|
||||
address = (paddr[0] << 24) |
|
||||
(paddr[1] << 16) |
|
||||
(paddr[2] << 8) |
|
||||
paddr[3];
|
||||
|
||||
|
||||
/* check the address is valid */
|
||||
if(address < iap_info.app_address || address > iap_info.flash_end_address)
|
||||
{
|
||||
@@ -247,25 +247,25 @@ iap_result_type iap_address(uint8_t *pdata, uint32_t len)
|
||||
else
|
||||
{
|
||||
iap_info.iap_address = address;
|
||||
|
||||
|
||||
if(iap_info.state == IAP_STS_START)
|
||||
{
|
||||
iap_clear_upgrade_flag();
|
||||
}
|
||||
iap_erase_sector(iap_info.iap_address);
|
||||
}
|
||||
|
||||
|
||||
iap_info.state = IAP_STS_ADDR;
|
||||
|
||||
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_ADDR, result);
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
/*
|
||||
* @brief iap data write
|
||||
* @param pdata: data buffer pointer.
|
||||
* @param len: buffer length
|
||||
* @retval the result of the address parse
|
||||
* @retval the result of the address parse
|
||||
*/
|
||||
iap_result_type iap_data_write(uint8_t *pdata, uint32_t len)
|
||||
{
|
||||
@@ -273,7 +273,7 @@ iap_result_type iap_data_write(uint8_t *pdata, uint32_t len)
|
||||
uint8_t *valid_data = pdata + 4;
|
||||
uint32_t *pbuf;
|
||||
uint32_t i_index = 0;
|
||||
|
||||
|
||||
if(iap_info.state == IAP_STS_ADDR)
|
||||
{
|
||||
if(data_len + iap_info.fifo_length <= HID_IAP_BUFFER_LEN)
|
||||
@@ -294,15 +294,15 @@ iap_result_type iap_data_write(uint8_t *pdata, uint32_t len)
|
||||
iap_info.iap_address += 4;
|
||||
}
|
||||
flash_lock();
|
||||
|
||||
|
||||
iap_info.fifo_length = 0;
|
||||
iap_info.iap_address = 0;
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_DATA, IAP_ACK);
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_DATA, IAP_ACK);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_ADDR, IAP_NACK);
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_ADDR, IAP_NACK);
|
||||
}
|
||||
return IAP_SUCCESS;
|
||||
}
|
||||
@@ -310,63 +310,63 @@ iap_result_type iap_data_write(uint8_t *pdata, uint32_t len)
|
||||
/*
|
||||
* @brief iap finish
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_finish()
|
||||
{
|
||||
iap_info.state = IAP_STS_FINISH;
|
||||
iap_set_upgrade_flag();
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_FINISH, IAP_ACK);
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_FINISH, IAP_ACK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief iap crc
|
||||
* @param pdata: data buffer pointer.
|
||||
* @param len: buffer length
|
||||
* @retval the result of the address parse
|
||||
* @retval the result of the address parse
|
||||
*/
|
||||
void iap_crc(uint8_t *pdata, uint32_t len)
|
||||
{
|
||||
uint8_t *paddr = pdata + 2; /* skip iap cmd */
|
||||
uint16_t crc_nk;
|
||||
uint32_t crc_value;
|
||||
uint32_t address = (paddr[0] << 24) |
|
||||
(paddr[1] << 16) |
|
||||
(paddr[2] << 8) |
|
||||
uint32_t address = (paddr[0] << 24) |
|
||||
(paddr[1] << 16) |
|
||||
(paddr[2] << 8) |
|
||||
paddr[3];
|
||||
paddr = pdata + 6;
|
||||
|
||||
|
||||
crc_nk = (paddr[0] << 16) | paddr[1];
|
||||
|
||||
|
||||
crc_value = crc_cal(address, crc_nk);
|
||||
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_CRC, IAP_ACK);
|
||||
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_CRC, IAP_ACK);
|
||||
iap_info.iap_tx[4] = (uint8_t)((crc_value >> 24) & 0xFF);
|
||||
iap_info.iap_tx[5] = (uint8_t)((crc_value >> 16) & 0xFF);
|
||||
iap_info.iap_tx[6] = (uint8_t)((crc_value >> 8) & 0xFF);
|
||||
iap_info.iap_tx[7] = (uint8_t)((crc_value) & 0xFF);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief iap jump
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_jump()
|
||||
{
|
||||
iap_info.state = IAP_STS_JMP_WAIT;
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_JMP, IAP_ACK);
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_JMP, IAP_ACK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief iap get
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_get()
|
||||
{
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_GET, IAP_ACK);
|
||||
iap_respond(iap_info.iap_tx, IAP_CMD_GET, IAP_ACK);
|
||||
iap_info.iap_tx[4] = (uint8_t)((iap_info.app_address >> 24) & 0xFF);
|
||||
iap_info.iap_tx[5] = (uint8_t)((iap_info.app_address >> 16) & 0xFF);
|
||||
iap_info.iap_tx[6] = (uint8_t)((iap_info.app_address >> 8) & 0xFF);
|
||||
@@ -380,7 +380,7 @@ void iap_get()
|
||||
* @param res_buf: data buffer pointer.
|
||||
* @param iap_cmd: iap command
|
||||
* @param result: iap result
|
||||
* @retval the result of the address parse
|
||||
* @retval the result of the address parse
|
||||
*/
|
||||
void iap_respond(uint8_t *res_buf, uint16_t iap_cmd, uint16_t result)
|
||||
{
|
||||
@@ -388,7 +388,7 @@ void iap_respond(uint8_t *res_buf, uint16_t iap_cmd, uint16_t result)
|
||||
res_buf[1] = (uint8_t)((iap_cmd) & 0xFF);
|
||||
res_buf[2] = (uint8_t)((result >> 8) & 0xFF);
|
||||
res_buf[3] = (uint8_t)((result) & 0xFF);
|
||||
|
||||
|
||||
iap_info.respond_flag = 1;
|
||||
}
|
||||
|
||||
@@ -397,22 +397,22 @@ void iap_respond(uint8_t *res_buf, uint16_t iap_cmd, uint16_t result)
|
||||
* @param udev: to the structure of usbd_core_type
|
||||
* @param pdata: data buffer point
|
||||
* @param len: data length
|
||||
* @retval iap_result_type
|
||||
* @retval iap_result_type
|
||||
*/
|
||||
iap_result_type usbd_hid_iap_process(void *udev, uint8_t *pdata, uint16_t len)
|
||||
{
|
||||
iap_result_type status = IAP_SUCCESS;
|
||||
uint16_t iap_cmd;
|
||||
|
||||
|
||||
if(len < 2)
|
||||
{
|
||||
return IAP_FAILED;
|
||||
}
|
||||
|
||||
|
||||
iap_info.respond_flag = 0;
|
||||
|
||||
|
||||
iap_cmd = (pdata[0] << 8) | pdata[1];
|
||||
|
||||
|
||||
switch(iap_cmd)
|
||||
{
|
||||
case IAP_CMD_IDLE:
|
||||
@@ -441,21 +441,21 @@ iap_result_type usbd_hid_iap_process(void *udev, uint8_t *pdata, uint16_t len)
|
||||
break;
|
||||
default:
|
||||
status = IAP_FAILED;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(iap_info.respond_flag)
|
||||
{
|
||||
usb_iap_class_send_report(udev, iap_info.iap_tx, 64);
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usb device in transfer complete function
|
||||
* @param udev: to the structure of usbd_core_type
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void usbd_hid_iap_in_complete(void *udev)
|
||||
{
|
||||
@@ -468,7 +468,7 @@ void usbd_hid_iap_in_complete(void *udev)
|
||||
/**
|
||||
* @brief iap loop
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
void iap_loop(void)
|
||||
{
|
||||
@@ -480,8 +480,8 @@ void iap_loop(void)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file main.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief main program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
Reference in New Issue
Block a user