Skip to content

Commit

Permalink
Merge pull request #6981 from RT-Thread/master
Browse files Browse the repository at this point in the history
sync from master
  • Loading branch information
mysterywolf committed Feb 25, 2023
2 parents 759192f + e63e33a commit 1acef42
Show file tree
Hide file tree
Showing 130 changed files with 12,582 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extern "C" {
#endif

#if defined(CY_IP_MXSCB_INSTANCES)
#if defined(CY_DEVICE_PSOC6A256K)
#if defined(CY_DEVICE_PSOC6A256K) || defined(CY8C624ALQI_S2D42)
//Special case for 256k device which has 6 SCBs numbered 0, 1, 2, 4, 5, 6
#define _SCB_ARRAY_SIZE (CY_IP_MXSCB_INSTANCES + 1)
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CySCB_Type *const _CYHAL_SCB_BASE_ADDRESSES[_SCB_ARRAY_SIZE] =
#endif
#ifdef SCB3
SCB3,
#elif defined(CY_DEVICE_PSOC6A256K)
#elif defined(CY_DEVICE_PSOC6A256K) || defined(CY8C624ALQI_S2D42)
NULL, // Placeholder
#endif
#ifdef SCB4
Expand Down
3 changes: 3 additions & 0 deletions bsp/at32/at32f403a-start/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ AT32F403A-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| WDT | 支持 | |
| RTC | 支持 | |
| FLASH | 支持 | |
| USB | 支持 | |

### IO在板级支持包中的映射情况

Expand Down Expand Up @@ -94,6 +95,8 @@ AT32F403A-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| PB9 | CAN1_TX |
| PB5 | CAN2_RX |
| PB6 | CAN2_TX |
| PA11 | USB_DM |
| PA12 | USB_DP |

## 使用说明

Expand Down
3 changes: 3 additions & 0 deletions bsp/at32/at32f403a-start/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ rtconfig.BSP_LIBRARY_TYPE = at32_library
# include libraries
objs.extend(SConscript(os.path.join(libraries_path_prefix, at32_library, 'SConscript')))

# include usb libraries
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'usbd_library', 'SConscript')))

# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'rt_drivers', 'SConscript')))

Expand Down
5 changes: 5 additions & 0 deletions bsp/at32/at32f403a-start/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ menu "On-chip Peripheral Drivers"

config BSP_USING_ON_CHIP_FLASH
bool "Enable on-chip FLASH"
default n

config BSP_USING_USBD
bool "Enable USB BUS"
select RT_USING_USB_DEVICE
default n

menuconfig BSP_USING_RTC
Expand Down
1 change: 1 addition & 0 deletions bsp/at32/at32f403a-start/board/inc/at32_msp.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ void at32_msp_sdio_init(void *instance);
void at32_msp_adc_init(void *instance);
void at32_msp_hwtmr_init(void *instance);
void at32_msp_can_init(void *instance);
void at32_msp_usb_init(void *instance);

#endif /* __AT32_MSP_H__ */
66 changes: 66 additions & 0 deletions bsp/at32/at32f403a-start/board/src/at32_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,69 @@ void at32_msp_can_init(void *instance)
#endif
}
#endif /* BSP_USING_CAN */

#ifdef BSP_USING_USBD
void at32_msp_usb_init(void *instance)
{
usb_clk48_s clk_s;

/* default usb clock source from hick */
clk_s = USB_CLK_HICK;

/* enable usb clock */
crm_periph_clock_enable(CRM_USB_PERIPH_CLOCK, TRUE);

if(clk_s == USB_CLK_HICK)
{
crm_usb_clock_source_select(CRM_USB_CLOCK_SOURCE_HICK);

/* enable the acc calibration ready interrupt */
crm_periph_clock_enable(CRM_ACC_PERIPH_CLOCK, TRUE);

/* update the c1\c2\c3 value */
acc_write_c1(7980);
acc_write_c2(8000);
acc_write_c3(8020);

/* open acc calibration */
acc_calibration_mode_enable(ACC_CAL_HICKTRIM, TRUE);
}
else
{
switch(system_core_clock)
{
/* 48MHz */
case 48000000:
crm_usb_clock_div_set(CRM_USB_DIV_1);
break;
/* 72MHz */
case 72000000:
crm_usb_clock_div_set(CRM_USB_DIV_1_5);
break;
/* 96MHz */
case 96000000:
crm_usb_clock_div_set(CRM_USB_DIV_2);
break;
/* 120MHz */
case 120000000:
crm_usb_clock_div_set(CRM_USB_DIV_2_5);
break;
/* 144MHz */
case 144000000:
crm_usb_clock_div_set(CRM_USB_DIV_3);
break;
/* 168MHz */
case 168000000:
crm_usb_clock_div_set(CRM_USB_DIV_3_5);
break;
/* 192MHz */
case 192000000:
crm_usb_clock_div_set(CRM_USB_DIV_4);
break;
default:
break;
}
}
}

#endif /* BSP_USING_USBD */
3 changes: 3 additions & 0 deletions bsp/at32/at32f407-start/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ AT32F407-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| RTC | 支持 | |
| FLASH | 支持 | |
| EMAC | 支持 | |
| USB | 支持 | |

### IO在板级支持包中的映射情况

Expand Down Expand Up @@ -102,6 +103,8 @@ AT32F407-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| PD9 | EMAC_RMII_RXD0 |
| PD10 | EMAC_RMII_RXD1 |
| PA1 | EMAC_RMII_REF_CLK |
| PA11 | USB_DM |
| PA12 | USB_DP |

## 使用说明

Expand Down
3 changes: 3 additions & 0 deletions bsp/at32/at32f407-start/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ rtconfig.BSP_LIBRARY_TYPE = at32_library
# include libraries
objs.extend(SConscript(os.path.join(libraries_path_prefix, at32_library, 'SConscript')))

# include usb libraries
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'usbd_library', 'SConscript')))

# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'rt_drivers', 'SConscript')))

Expand Down
5 changes: 5 additions & 0 deletions bsp/at32/at32f407-start/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ menu "On-chip Peripheral Drivers"
endchoice
endif

config BSP_USING_USBD
bool "Enable USB BUS"
select RT_USING_USB_DEVICE
default n

menuconfig BSP_USING_RTC
bool "Enable RTC"
select RT_USING_RTC
Expand Down
1 change: 1 addition & 0 deletions bsp/at32/at32f407-start/board/inc/at32_msp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ void at32_msp_adc_init(void *instance);
void at32_msp_hwtmr_init(void *instance);
void at32_msp_can_init(void *instance);
void at32_msp_emac_init(void *instance);
void at32_msp_usb_init(void *instance);

#endif /* __AT32_MSP_H__ */
67 changes: 67 additions & 0 deletions bsp/at32/at32f407-start/board/src/at32_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,70 @@ void at32_msp_emac_init(void *instance)
gpio_init(GPIOD, &gpio_init_struct);
}
#endif /* BSP_USING_EMAC */

#ifdef BSP_USING_USBD
void at32_msp_usb_init(void *instance)
{
usb_clk48_s clk_s;

/* default usb clock source from hick */
clk_s = USB_CLK_HICK;

/* enable usb clock */
crm_periph_clock_enable(CRM_USB_PERIPH_CLOCK, TRUE);

if(clk_s == USB_CLK_HICK)
{
crm_usb_clock_source_select(CRM_USB_CLOCK_SOURCE_HICK);

/* enable the acc calibration ready interrupt */
crm_periph_clock_enable(CRM_ACC_PERIPH_CLOCK, TRUE);

/* update the c1\c2\c3 value */
acc_write_c1(7980);
acc_write_c2(8000);
acc_write_c3(8020);

/* open acc calibration */
acc_calibration_mode_enable(ACC_CAL_HICKTRIM, TRUE);
}
else
{
switch(system_core_clock)
{
/* 48MHz */
case 48000000:
crm_usb_clock_div_set(CRM_USB_DIV_1);
break;
/* 72MHz */
case 72000000:
crm_usb_clock_div_set(CRM_USB_DIV_1_5);
break;
/* 96MHz */
case 96000000:
crm_usb_clock_div_set(CRM_USB_DIV_2);
break;
/* 120MHz */
case 120000000:
crm_usb_clock_div_set(CRM_USB_DIV_2_5);
break;
/* 144MHz */
case 144000000:
crm_usb_clock_div_set(CRM_USB_DIV_3);
break;
/* 168MHz */
case 168000000:
crm_usb_clock_div_set(CRM_USB_DIV_3_5);
break;
/* 192MHz */
case 192000000:
crm_usb_clock_div_set(CRM_USB_DIV_4);
break;
default:
break;
}
}
}

#endif /* BSP_USING_USBD */

3 changes: 3 additions & 0 deletions bsp/at32/at32f413-start/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ AT32F413-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| WDT | 支持 | |
| RTC | 支持 | |
| FLASH | 支持 | |
| USB | 支持 | |

### IO在板级支持包中的映射情况

Expand Down Expand Up @@ -94,6 +95,8 @@ AT32F413-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| PB9 | CAN1_TX |
| PB5 | CAN2_RX |
| PB6 | CAN2_TX |
| PA11 | USB_DM |
| PA12 | USB_DP |

## 使用说明

Expand Down
6 changes: 3 additions & 3 deletions bsp/at32/at32f413-start/SConscript
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# for module compiling
from building import *
import os
Import('RTT_ROOT')

cwd = str(Dir('#'))
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)

list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
Expand Down
3 changes: 3 additions & 0 deletions bsp/at32/at32f413-start/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ rtconfig.BSP_LIBRARY_TYPE = at32_library
# include libraries
objs.extend(SConscript(os.path.join(libraries_path_prefix, at32_library, 'SConscript')))

# include usb libraries
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'usbd_library', 'SConscript')))

# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'rt_drivers', 'SConscript')))

Expand Down
5 changes: 5 additions & 0 deletions bsp/at32/at32f413-start/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ menu "On-chip Peripheral Drivers"

config BSP_USING_ON_CHIP_FLASH
bool "Enable on-chip FLASH"
default n

config BSP_USING_USBD
bool "Enable USB BUS"
select RT_USING_USB_DEVICE
default n

menuconfig BSP_USING_RTC
Expand Down
1 change: 1 addition & 0 deletions bsp/at32/at32f413-start/board/inc/at32_msp.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ void at32_msp_sdio_init(void *instance);
void at32_msp_adc_init(void *instance);
void at32_msp_hwtmr_init(void *instance);
void at32_msp_can_init(void *instance);
void at32_msp_usb_init(void *instance);

#endif /* __AT32_MSP_H__ */
66 changes: 66 additions & 0 deletions bsp/at32/at32f413-start/board/src/at32_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,69 @@ void at32_msp_can_init(void *instance)
#endif
}
#endif /* BSP_USING_CAN */

#ifdef BSP_USING_USBD
void at32_msp_usb_init(void *instance)
{
usb_clk48_s clk_s;

/* default usb clock source from hick */
clk_s = USB_CLK_HICK;

/* enable usb clock */
crm_periph_clock_enable(CRM_USB_PERIPH_CLOCK, TRUE);

if(clk_s == USB_CLK_HICK)
{
crm_usb_clock_source_select(CRM_USB_CLOCK_SOURCE_HICK);

/* enable the acc calibration ready interrupt */
crm_periph_clock_enable(CRM_ACC_PERIPH_CLOCK, TRUE);

/* update the c1\c2\c3 value */
acc_write_c1(7980);
acc_write_c2(8000);
acc_write_c3(8020);

/* open acc calibration */
acc_calibration_mode_enable(ACC_CAL_HICKTRIM, TRUE);
}
else
{
switch(system_core_clock)
{
/* 48MHz */
case 48000000:
crm_usb_clock_div_set(CRM_USB_DIV_1);
break;
/* 72MHz */
case 72000000:
crm_usb_clock_div_set(CRM_USB_DIV_1_5);
break;
/* 96MHz */
case 96000000:
crm_usb_clock_div_set(CRM_USB_DIV_2);
break;
/* 120MHz */
case 120000000:
crm_usb_clock_div_set(CRM_USB_DIV_2_5);
break;
/* 144MHz */
case 144000000:
crm_usb_clock_div_set(CRM_USB_DIV_3);
break;
/* 168MHz */
case 168000000:
crm_usb_clock_div_set(CRM_USB_DIV_3_5);
break;
/* 192MHz */
case 192000000:
crm_usb_clock_div_set(CRM_USB_DIV_4);
break;
default:
break;
}
}
}

#endif /* BSP_USING_USBD */
3 changes: 3 additions & 0 deletions bsp/at32/at32f415-start/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ AT32F415-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| WDT | 支持 | |
| RTC | 支持 | |
| FLASH | 支持 | |
| USB | 支持 | |

### IO在板级支持包中的映射情况

Expand Down Expand Up @@ -92,6 +93,8 @@ AT32F415-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| PC5 | ADC1_IN15 |
| PB8 | CAN1_RX |
| PB9 | CAN1_TX |
| PA11 | USB_DM |
| PA12 | USB_DP |

## 使用说明

Expand Down
Loading

0 comments on commit 1acef42

Please sign in to comment.