Skip to content

Commit

Permalink
Update drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
RexhuangTW committed May 30, 2023
1 parent 2f6b16d commit cb3aa3c
Show file tree
Hide file tree
Showing 14 changed files with 1,802 additions and 1,444 deletions.
1 change: 1 addition & 0 deletions examples/lighting-app/rt582/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ int main(void)
info( "==================================================\r\n");
info( "chip-rt582-lighting-example starting Version %d\r\n", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);
info( "==================================================\r\n");

err = PlatformMgr().InitChipStack();
if (err != CHIP_NO_ERROR)
{
Expand Down
36 changes: 30 additions & 6 deletions examples/platform/rt582/init_rt582Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ extern "C" {
#include "crypto_util.h"
#include "EnhancedFlashDataset.h"


static void init_default_pin_mux(void)
{
int i, j;
Expand All @@ -75,21 +74,46 @@ static void init_default_pin_mux(void)
return;
}

static void wdt_isr(void)
{
Wdt_Kick();
}

static void init_wdt_init(void)
{
wdt_config_mode_t wdt_mode;
wdt_config_tick_t wdt_cfg_ticks;

wdt_mode.int_enable = 1;
wdt_mode.reset_enable = 1;
wdt_mode.lock_enable = 0;
wdt_mode.prescale = WDT_PRESCALE_32;

wdt_cfg_ticks.wdt_ticks = 1200 * 1000;
wdt_cfg_ticks.int_ticks = 200 * 1000;
wdt_cfg_ticks.wdt_min_ticks = 0;

Wdt_Start(wdt_mode, wdt_cfg_ticks, wdt_isr);
}

void init_rt582Platform(void)
{
NVIC_SetPriority(CommSubsystem_IRQn, 0x04);

#if LPWR_FLASH_PROTECT_ENABLE==1
flash_cmp_protect_init();
flash_vbat_protect_init();
#endif

init_default_pin_mux();
#if(CHIP_DEVICE_CONFIG_ENABLE_SED != 1)
init_wdt_init();
#endif
Delay_Init();
dma_init();
uartConsoleInit();
crypto_lib_init();

#if LPWR_FLASH_PROTECT_ENABLE==1
flash_vbat_protect_init();
flash_cmp_protect_init();
#endif

enhanced_flash_dataset_init();

#if(CHIP_DEVICE_CONFIG_ENABLE_SED == 1)
Expand Down
54 changes: 27 additions & 27 deletions third_party/rafael/project_config.h
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
#include "chip_define.h"
#include "cm3_mcu.h"


#define MODULE_ENABLE(module) (module > 0)

/*System use UART0 */
#define SUPPORT_UART0 1
#define SUPPORT_UART0 1

/*System use UART1 */
#define SUPPORT_UART1 1
#define SUPPORT_UART1_TX_DMA 1
#define SUPPORT_UART1_RX_DMA 1
#define SUPPORT_UART1 1
#define SUPPORT_UART1_TX_DMA 1
#define SUPPORT_UART1_RX_DMA 1

#define SUPPORT_QSPI_DMA 1
#define SUPPORT_QSPI_DMA 1

#define USE_BSP_UART_DRV 1
#define DEBUG_CONSOLE_UART_ID 0
#define USE_BSP_UART_DRV 1
#define DEBUG_CONSOLE_UART_ID 0

#define SET_SYS_CLK SYS_CLK_64MHZ
#define SET_SYS_CLK SYS_CLK_64MHZ

#define SUPPORT_MULTITASKING 1
#define FLASH_CHECK_ADDRESS_DISABLE 1
#define SUPPORT_MULTITASKING 1
#define FLASH_CHECK_ADDRESS_DISABLE 1

#define SUPPORT_MATTER_CONCURRENT 1
#define SUPPORT_MATTER_CONCURRENT 1
#if (MODULE_ENABLE(SUPPORT_MATTER_CONCURRENT))
#define SUPPORT_BLE 1
#define SUPPORT_THREAD 1
#define RF_FW_INCLUDE_PCI (FALSE)
#define RF_FW_INCLUDE_BLE (FALSE)
#define RF_FW_INCLUDE_MULTI_2P4G (TRUE)
#define RFB_ZIGBEE_ENABLED (TRUE)
#define RFB_MULTI_ENABLED (TRUE)
#define SUPPORT_BLE 1
#define SUPPORT_THREAD 1
#define RF_FW_INCLUDE_PCI (FALSE)
#define RF_FW_INCLUDE_BLE (FALSE)
#define RF_FW_INCLUDE_MULTI_2P4G (TRUE)
#define RFB_ZIGBEE_ENABLED (TRUE)
#define RFB_MULTI_ENABLED (TRUE)
#else
#define SUPPORT_BLE 1
#define SUPPORT_THREAD 0
#define RF_FW_INCLUDE_PCI (TRUE)
#define RF_FW_INCLUDE_BLE (TRUE)
#define RF_FW_INCLUDE_MULTI_2P4G (FALSE)
#define RFB_ZIGBEE_ENABLED (TRUE)
#define RFB_MULTI_ENABLED (FALSE)
#define SUPPORT_BLE 1
#define SUPPORT_THREAD 0
#define RF_FW_INCLUDE_PCI (TRUE)
#define RF_FW_INCLUDE_BLE (TRUE)
#define RF_FW_INCLUDE_MULTI_2P4G (FALSE)
#define RFB_ZIGBEE_ENABLED (TRUE)
#define RFB_MULTI_ENABLED (FALSE)
#endif

#define BLE_SUPPORT_NUM_CONN_MAX 1

/* definition for crypto hw engine */
#define CRYPTO_SECP256R1_ENABLE 1
#define CRYPTO_SECP256R1_ENABLE 1
#define LPWR_FLASH_PROTECT_ENABLE 1
2 changes: 2 additions & 0 deletions third_party/rafael/rt582_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ template("rt582_sdk") {
"${rt582_sdk_root}/Driver/Device/GCC/gcc_startup_cm3_mcu.S",
"${rt582_sdk_root}/Driver/Device/system_cm3_mcu.c",
"${rt582_sdk_root}/Driver/Peripheral/Include/flashctl.h",
"${rt582_sdk_root}/Driver/Peripheral/comparator.c",
"${rt582_sdk_root}/Driver/Peripheral/dma.c",
"${rt582_sdk_root}/Driver/Peripheral/flashctl.c",
"${rt582_sdk_root}/Driver/Peripheral/flashds.c",
"${rt582_sdk_root}/Driver/Peripheral/gpio.c",
"${rt582_sdk_root}/Driver/Peripheral/lpm.c",
"${rt582_sdk_root}/Driver/Peripheral/mp_sector.c",
"${rt582_sdk_root}/Driver/Peripheral/pwm.c",
"${rt582_sdk_root}/Driver/Peripheral/sadc.c",
"${rt582_sdk_root}/Driver/Peripheral/sysctrl.c",
"${rt582_sdk_root}/Driver/Peripheral/sysfun.c",
"${rt582_sdk_root}/Driver/Peripheral/timer.c",
Expand Down
23 changes: 6 additions & 17 deletions third_party/rafael/sdk/Driver/Device/system_cm3_mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ typedef struct
uint32_t reg_value; /**< The value of register to be written*/
} reg_bit_write_t;

/*----------------------------------------------------------------------------
Define PMU Mode
*----------------------------------------------------------------------------*/
/*Define PMU mode type*/
#define PMU_LDO_MODE 0
#define PMU_DCDC_MODE 1

#ifndef SET_PMU_MODE
#define SET_PMU_MODE PMU_DCDC_MODE
#endif

/*----------------------------------------------------------------------------
Define clocks
*----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -133,6 +122,7 @@ void Reg_Bit_Write(reg_bit_write_t reg_write_item)
*((uint32_t *) (reg_write_item.reg_addr)) = reg_value_buf;
}

#if 0
void SystemPmuUpdateDig(void) /* Update PMU settings for digital configuration */
{
PMU->PMU_XTAL.bit.CFG_XTAL_SETTLE_TIME = 0x3F;
Expand All @@ -141,8 +131,10 @@ void SystemPmuUpdateDig(void) /* Update PMU settings for digital configuration *
PMU->PMU_XTAL.bit.CFG_BYPASS_XTAL_SETTLE = 1;
PMU->PMU_CLK_CTRL.bit.CFG_CHIP_EN_AUTO = 1;
PMU->PMU_PWR_CTRL.bit.CFG_BYP_XBUF_LDO = 1;
}

SYSCTRL->GPIO_AIO_CTRL = ((SYSCTRL->GPIO_AIO_CTRL & ~FLASH_DRV_SEL_MASK) | FLASH_DRV_SEL_SET);
}
#endif
void SystemPmuSetMode(pmu_mode_cfg_t pmu_mode)
{
if (pmu_mode == PMU_MODE_DCDC)
Expand Down Expand Up @@ -354,6 +346,7 @@ void SystemPmuUpdateDcdc(void) /* Update PMU settings in DCDC mode */
for (i = 0; i < reg_num; i++)
{
reg_write_item = pmu_mp_init_table_dcdc[i];

Reg_Bit_Write(reg_write_item);
}
}
Expand Down Expand Up @@ -423,8 +416,6 @@ void SystemInit(void)
* So you can not use any global variable.
* Also, NO race condition issue here...
*/
critical_section_init();

/*set PMU XTAL. 2020/10/26 add --- set cfg_xtal_settle_time*/
PMU->PMU_XTAL.reg = (PMU->PMU_XTAL.reg & ~0xFF) | 0x3F;

Expand All @@ -437,7 +428,7 @@ void SystemInit(void)
flash_enable_qe();

#if ((CHIP_VERSION == RT58X_MPA) || (CHIP_VERSION == RT58X_MPB))
SystemPmuUpdateDig();
// SystemPmuUpdateDig();

#if (SET_PMU_MODE == PMU_LDO_MODE)
SystemPmuUpdateLdo();
Expand Down Expand Up @@ -485,7 +476,5 @@ void SystemInit(void)
set_slow_clock_source(EXT32K_GPIO_ENABLE); /* set slow clock(32.768khz) source form gpio */
#endif

flash_suspend_check();

return;
}
Loading

0 comments on commit cb3aa3c

Please sign in to comment.