update version to v2.1.0

This commit is contained in:
Artery-MCU
2023-08-08 19:30:55 +08:00
parent d7bcb64bf8
commit f49a554036
408 changed files with 224076 additions and 1271 deletions

View File

@@ -12,4 +12,4 @@
2. frequency 16k and 48k
3. bit width 16bit,
4. speaker feedback
for more detailed information, please refer to the application note document AN0097.
for more detailed information, please refer to the application note document AN0097.

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -12,4 +12,4 @@
2. frequency 16k and 48k
3. bit width 16bit,
4. speaker feedback
for more detailed information, please refer to the application note document AN0097.
for more detailed information, please refer to the application note document AN0097.

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -44,7 +44,10 @@ otg_core_type otg_core_struct;
void usb_clock48m_select(usb_clk48_s clk_s);
void usb_gpio_config(void);
void usb_low_power_wakeup_config(void);
uint8_t report_buf[USBD_AUHID_IN_MAXPACKET_SIZE];
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t report_buf[USBD_AUHID_IN_MAXPACKET_SIZE] ALIGNED_TAIL;
/**
* @brief main function.

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -42,7 +42,10 @@
/* usb global struct define */
otg_core_type otg_core_struct;
__IO uint8_t keyboard_send_flag;
uint8_t usb_buffer[256];
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t usb_buffer[256] ALIGNED_TAIL;
void usb_clock48m_select(usb_clk48_s clk_s);
void keyboard_send_string(void *udev, uint8_t *string, uint8_t len);

View File

@@ -51,8 +51,8 @@ extern "C" {
#define SECTOR_SIZE_4K 4096
uint8_t *get_inquiry(uint8_t lun);
usb_sts_type msc_disk_read(uint8_t lun, uint32_t addr, uint8_t *read_buf, uint32_t len);
usb_sts_type msc_disk_write(uint8_t lun, uint32_t addr, uint8_t *buf, uint32_t len);
usb_sts_type msc_disk_read(uint8_t lun, uint64_t addr, uint8_t *read_buf, uint32_t len);
usb_sts_type msc_disk_write(uint8_t lun, uint64_t addr, uint8_t *buf, uint32_t len);
usb_sts_type msc_disk_capacity(uint8_t lun, uint32_t *blk_nbr, uint32_t *blk_size);
/**

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -50,8 +50,8 @@ void NMI_Handler(void)
void HardFault_Handler(void)
{
/* go to infinite loop when hard fault exception occurs */
// __nop();
// __nop();
// __nop();
// __nop();
while(1)
{
}
@@ -67,8 +67,8 @@ void MemManage_Handler(void)
/* go to infinite loop when memory manage exception occurs */
while(1)
{
}
{
}
}

View File

@@ -40,7 +40,10 @@
/* usb global struct define */
otg_core_type otg_core_struct;
uint8_t usb_buffer[256];
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t usb_buffer[256] ALIGNED_TAIL;
void usb_clock48m_select(usb_clk48_s clk_s);
void usb_gpio_config(void);
void usb_low_power_wakeup_config(void);

View File

@@ -71,10 +71,10 @@ uint8_t *get_inquiry(uint8_t lun)
* @param len: read length
* @retval status of usb_sts_type
*/
usb_sts_type msc_disk_read(uint8_t lun, uint32_t addr, uint8_t *read_buf, uint32_t len)
usb_sts_type msc_disk_read(uint8_t lun, uint64_t addr, uint8_t *read_buf, uint32_t len)
{
uint32_t i = 0;
uint32_t flash_addr = addr + USB_FLASH_ADDR_OFFSET;
uint32_t flash_addr = (uint32_t)addr + USB_FLASH_ADDR_OFFSET;
switch(lun)
{
case INTERNAL_FLASH_LUN:
@@ -102,9 +102,9 @@ usb_sts_type msc_disk_read(uint8_t lun, uint32_t addr, uint8_t *read_buf, uint32
* @param len: write length
* @retval status of usb_sts_type
*/
usb_sts_type msc_disk_write(uint8_t lun, uint32_t addr, uint8_t *buf, uint32_t len)
usb_sts_type msc_disk_write(uint8_t lun, uint64_t addr, uint8_t *buf, uint32_t len)
{
uint32_t flash_addr = addr + USB_FLASH_ADDR_OFFSET;
uint32_t flash_addr = (uint32_t)addr + USB_FLASH_ADDR_OFFSET;
uint32_t i = 0, tolen = len;
uint32_t erase_addr = flash_addr;
switch(lun)

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -40,7 +40,10 @@
/* usb global struct define */
otg_core_type otg_core_struct;
uint8_t report_buf[USBD_CUSTOM_IN_MAXPACKET_SIZE];
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t report_buf[USBD_CUSTOM_IN_MAXPACKET_SIZE] ALIGNED_TAIL;
void usb_clock48m_select(usb_clk48_s clk_s);
void usb_gpio_config(void);
void usb_low_power_wakeup_config(void);

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -51,8 +51,8 @@ extern "C" {
#define SECTOR_SIZE_4K 4096
uint8_t *get_inquiry(uint8_t lun);
usb_sts_type msc_disk_read(uint8_t lun, uint32_t addr, uint8_t *read_buf, uint32_t len);
usb_sts_type msc_disk_write(uint8_t lun, uint32_t addr, uint8_t *buf, uint32_t len);
usb_sts_type msc_disk_read(uint8_t lun, uint64_t addr, uint8_t *read_buf, uint32_t len);
usb_sts_type msc_disk_write(uint8_t lun, uint64_t addr, uint8_t *buf, uint32_t len);
usb_sts_type msc_disk_capacity(uint8_t lun, uint32_t *blk_nbr, uint32_t *blk_size);
/**

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -70,10 +70,10 @@ uint8_t *get_inquiry(uint8_t lun)
* @param len: read length
* @retval status of usb_sts_type
*/
usb_sts_type msc_disk_read(uint8_t lun, uint32_t addr, uint8_t *read_buf, uint32_t len)
usb_sts_type msc_disk_read(uint8_t lun, uint64_t addr, uint8_t *read_buf, uint32_t len)
{
uint32_t i = 0;
uint32_t flash_addr = addr + USB_FLASH_ADDR_OFFSET;
uint32_t flash_addr = (uint32_t)addr + USB_FLASH_ADDR_OFFSET;
switch(lun)
{
case INTERNAL_FLASH_LUN:
@@ -101,9 +101,9 @@ usb_sts_type msc_disk_read(uint8_t lun, uint32_t addr, uint8_t *read_buf, uint32
* @param len: write length
* @retval status of usb_sts_type
*/
usb_sts_type msc_disk_write(uint8_t lun, uint32_t addr, uint8_t *buf, uint32_t len)
usb_sts_type msc_disk_write(uint8_t lun, uint64_t addr, uint8_t *buf, uint32_t len)
{
uint32_t flash_addr = addr + USB_FLASH_ADDR_OFFSET;
uint32_t flash_addr = (uint32_t)addr + USB_FLASH_ADDR_OFFSET;
uint32_t i = 0, tolen = len;
uint32_t erase_addr = flash_addr;
switch(lun)

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -41,6 +41,10 @@
/* usb global struct define */
otg_core_type otg_core_struct;
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t usb_buffer[256] ALIGNED_TAIL;
void usb_clock48m_select(usb_clk48_s clk_s);
void usb_gpio_config(void);
void usb_low_power_wakeup_config(void);
@@ -52,6 +56,8 @@ void usb_low_power_wakeup_config(void);
*/
int main(void)
{
uint32_t rx_len = 0;
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
system_clock_config();
@@ -83,8 +89,9 @@ int main(void)
while(1)
{
/* get usb vcp receive data */
/* usb_printer_get_rxdata(&otg_core_struct.dev, usb_buffer); */
/* get usb printer receive data */
rx_len = usb_printer_get_rxdata(&otg_core_struct.dev, usb_buffer);
UNUSED(rx_len);
/* user code ...*/
}

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -40,7 +40,10 @@
/* usb global struct define */
otg_core_type otg_core_struct;
uint8_t usb_buffer[256];
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t usb_buffer[256] ALIGNED_TAIL;
void usb_clock48m_select(usb_clk48_s clk_s);
void usb_gpio_config(void);
void usb_low_power_wakeup_config(void);

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -29,6 +29,7 @@
#include "usbd_int.h"
#include "cdc_class.h"
#include "cdc_desc.h"
#include "string.h"
/** @addtogroup AT32F415_periph_examples
* @{
@@ -40,7 +41,9 @@
/* usb global struct define */
otg_core_type otg_core_struct;
uint8_t usb_buffer[256];
uint32_t usb_buffer[256];
uint8_t usart2_tx_counter = 0;
uint16_t data_len;
void usb_clock48m_select(usb_clk48_s clk_s);
void usb_gpio_config(void);
void usb_low_power_wakeup_config(void);
@@ -51,6 +54,7 @@ void usb_usart_config(linecoding_type linecoding);
void usart_gpio_config(void);
#define usart_buffer_size 2048
uint8_t usart_rx_buffer[usart_buffer_size];
uint32_t usb_tx_buffer[512];
uint16_t hw_usart_rx_index = 0;
uint16_t hw_usart_read_index = 0;
uint16_t usart_rx_data_len = 0;
@@ -65,8 +69,6 @@ uint16_t usart_receive_data(void);
*/
int main(void)
{
uint16_t data_len;
uint32_t timeout;
uint8_t send_zero_packet = 0;
@@ -108,12 +110,12 @@ int main(void)
while(1)
{
/* get usb vcp receive data */
data_len = usb_vcp_get_rxdata(&otg_core_struct.dev, usb_buffer);
data_len = usb_vcp_get_rxdata(&otg_core_struct.dev, (uint8_t *)usb_buffer);
/* send data to hardware usart */
if(data_len > 0)
{
usart_send_data(usb_buffer, data_len);
usart_send_data((uint8_t *)usb_buffer, data_len);
}
/* if hardware usart received data,usb send data to host */
@@ -133,7 +135,8 @@ int main(void)
do
{
/* send data to host */
if(usb_vcp_send_data(&otg_core_struct.dev, &usart_rx_buffer[hw_usart_read_index], usart_rx_data_len) == SUCCESS)
memcpy((uint8_t *)usb_tx_buffer, &usart_rx_buffer[hw_usart_read_index], usart_rx_data_len);
if(usb_vcp_send_data(&otg_core_struct.dev, (uint8_t *)usb_tx_buffer, usart_rx_data_len) == SUCCESS)
{
hw_usart_read_index = hw_usart_read_index + usart_rx_data_len;
@@ -148,7 +151,8 @@ int main(void)
do
{
/* send data to host */
if(usb_vcp_send_data(&otg_core_struct.dev, &usart_rx_buffer[hw_usart_read_index], usart_buffer_size - hw_usart_read_index) == SUCCESS)
memcpy((uint8_t *)usb_tx_buffer, &usart_rx_buffer[hw_usart_read_index], usart_buffer_size - hw_usart_read_index);
if(usb_vcp_send_data(&otg_core_struct.dev, (uint8_t *)usb_tx_buffer, usart_buffer_size - hw_usart_read_index) == SUCCESS)
{
/* get fifo overflow data count */
ov_cnt = usart_rx_data_len - (usart_buffer_size - hw_usart_read_index);
@@ -160,7 +164,8 @@ int main(void)
do
{
/* send data to host */
if(usb_vcp_send_data(&otg_core_struct.dev, &usart_rx_buffer[hw_usart_read_index], ov_cnt) == SUCCESS)
memcpy((uint8_t *)usb_tx_buffer, &usart_rx_buffer[hw_usart_read_index], ov_cnt);
if(usb_vcp_send_data(&otg_core_struct.dev, (uint8_t *)usb_tx_buffer, ov_cnt) == SUCCESS)
{
hw_usart_read_index = ov_cnt;
break;
@@ -201,7 +206,7 @@ uint16_t usart_receive_data(void)
uint16_t usart_data_len;
if(hw_usart_read_index == hw_usart_rx_index)
{
usart_data_len = 0;
usart_data_len = 0;
}
else
{
@@ -253,7 +258,7 @@ void usb_usart_config( linecoding_type linecoding)
case 0x0:
usart_stop_bit = USART_STOP_1_BIT;
break;
/* to be used when transmitting and receiving data in smartcard mode */
/* to be used when transmitting and receiving data in smartcard mode */
case 0x1:
usart_stop_bit = USART_STOP_1_5_BIT;
break;
@@ -263,23 +268,7 @@ void usb_usart_config( linecoding_type linecoding)
default :
break;
}
/* data bits */
switch(linecoding.data)
{
/* hardware usart not support data bits for 5/6 */
case 0x5:
case 0x6:
case 0x7:
break;
case 0x8:
usart_data_bit = USART_DATA_8BITS;
break;
/* hardware usart not support data bits for 16 */
case 0x10:
break;
default :
break;
}
/* parity */
switch(linecoding.parity)
{
@@ -299,6 +288,49 @@ void usb_usart_config( linecoding_type linecoding)
default :
break;
}
if(USART_PARITY_NONE == usart_parity_select)
{
/* data bits */
switch(linecoding.data)
{
/* hardware usart not support data bits for 5/6 */
case 0x5:
case 0x6:
case 0x7:
break;
case 0x8:
usart_data_bit = USART_DATA_8BITS;
break;
/* hardware usart not support data bits for 16 */
case 0x10:
break;
default :
break;
}
}
else
{
/* data bits */
switch(linecoding.data)
{
/* hardware usart not support data bits for 5/6 */
case 0x5:
case 0x6:
break;
case 0x7:
usart_data_bit = USART_DATA_8BITS;
break;
case 0x8:
usart_data_bit = USART_DATA_9BITS;
break;
/* hardware usart not support data bits for 16 */
case 0x10:
break;
default :
break;
}
}
nvic_irq_enable(USART2_IRQn, 0, 0);

View File

@@ -47,8 +47,8 @@ extern "C" {
#define USB_FLASH_ADDR_OFFSET 0x08004000
uint8_t *get_inquiry(uint8_t lun);
usb_sts_type msc_disk_read(uint8_t lun, uint32_t addr, uint8_t *read_buf, uint32_t len);
usb_sts_type msc_disk_write(uint8_t lun, uint32_t addr, uint8_t *buf, uint32_t len);
usb_sts_type msc_disk_read(uint8_t lun, uint64_t addr, uint8_t *read_buf, uint32_t len);
usb_sts_type msc_disk_write(uint8_t lun, uint64_t addr, uint8_t *buf, uint32_t len);
usb_sts_type msc_disk_capacity(uint8_t lun, uint32_t *blk_nbr, uint32_t *blk_size);
/**

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -70,13 +70,13 @@ uint8_t *get_inquiry(uint8_t lun)
* @param len: read length
* @retval status of usb_sts_type
*/
usb_sts_type msc_disk_read(uint8_t lun, uint32_t addr, uint8_t *read_buf, uint32_t len)
usb_sts_type msc_disk_read(uint8_t lun, uint64_t addr, uint8_t *read_buf, uint32_t len)
{
switch(lun)
{
case 0:
flash_fat16_read(addr, read_buf, len);
flash_fat16_read((uint32_t)addr, read_buf, len);
break;
case 1:
break;
@@ -92,12 +92,12 @@ usb_sts_type msc_disk_read(uint8_t lun, uint32_t addr, uint8_t *read_buf, uint32
* @param len: write length
* @retval status of usb_sts_type
*/
usb_sts_type msc_disk_write(uint8_t lun, uint32_t addr, uint8_t *buf, uint32_t len)
usb_sts_type msc_disk_write(uint8_t lun, uint64_t addr, uint8_t *buf, uint32_t len)
{
switch(lun)
{
case 0:
flash_fat16_write(addr, buf, len);
flash_fat16_write((uint32_t)addr, buf, len);
break;
case 1:
break;