90 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			90 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| 
								 | 
							
								/****************************************************************************
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
							 | 
						||
| 
								 | 
							
								be copied by any method or incorporated into another program without
							 | 
						||
| 
								 | 
							
								the express written consent of Aerospace C.Power. This Information or any portion
							 | 
						||
| 
								 | 
							
								thereof remains the property of Aerospace C.Power. The Information contained herein
							 | 
						||
| 
								 | 
							
								is believed to be accurate and Aerospace C.Power assumes no responsibility or
							 | 
						||
| 
								 | 
							
								liability for its use in any way and conveys no license or title under
							 | 
						||
| 
								 | 
							
								any patent or copyright and makes no representation or warranty that this
							 | 
						||
| 
								 | 
							
								Information is free from patent or copyright infringement.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								****************************************************************************/
							 | 
						||
| 
								 | 
							
								#include "ahb.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "iot_io.h"
							 | 
						||
| 
								 | 
							
								#include "dbg_io.h"
							 | 
						||
| 
								 | 
							
								#include "flash.h"
							 | 
						||
| 
								 | 
							
								#include "sfc.h"
							 | 
						||
| 
								 | 
							
								#include "smc.h"
							 | 
						||
| 
								 | 
							
								#include "sram.h"
							 | 
						||
| 
								 | 
							
								#include "gpio_mtx.h"
							 | 
						||
| 
								 | 
							
								#include "sec_glb.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define PSRAM_PRIME_ADDR 0x04000000
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef void (*pJump)(void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void gpio_sel()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    gpio_mtx_enable();
							 | 
						||
| 
								 | 
							
								    gpio_sig_info_t sfc = {
							 | 
						||
| 
								 | 
							
								        6,
							 | 
						||
| 
								 | 
							
								        {
							 | 
						||
| 
								 | 
							
								            {IO_TYPE_OUT, 0, 23, 0xff, 6},
							 | 
						||
| 
								 | 
							
								            {IO_TYPE_OUT, 0, 24, 0xff, 7},
							 | 
						||
| 
								 | 
							
								            {IO_TYPE_IO, 0, 25, 4, 8},
							 | 
						||
| 
								 | 
							
								            {IO_TYPE_IO, 0, 26, 5, 9},
							 | 
						||
| 
								 | 
							
								            {IO_TYPE_IO, 0, 27, 6, 10},
							 | 
						||
| 
								 | 
							
								            {IO_TYPE_IO, 0, 28, 7, 11}
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    };
							 | 
						||
| 
								 | 
							
								    gpio_module_pin_select(&sfc);
							 | 
						||
| 
								 | 
							
								    gpio_module_sig_select(&sfc, GPIO_MTX_MODE_MATRIX);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    gpio_sig_info_t smc = {
							 | 
						||
| 
								 | 
							
								        6,
							 | 
						||
| 
								 | 
							
								        {
							 | 
						||
| 
								 | 
							
								            {IO_TYPE_OUT, 0, 37, 0xff, 0},
							 | 
						||
| 
								 | 
							
								            {IO_TYPE_OUT, 0, 38, 0xff, 1},
							 | 
						||
| 
								 | 
							
								            {IO_TYPE_IO, 0, 39, 0, 2},
							 | 
						||
| 
								 | 
							
								            {IO_TYPE_IO, 0, 40, 1, 3},
							 | 
						||
| 
								 | 
							
								            {IO_TYPE_IO, 0, 41, 2, 4},
							 | 
						||
| 
								 | 
							
								            {IO_TYPE_IO, 0, 42, 3, 5}
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    };
							 | 
						||
| 
								 | 
							
								    gpio_module_pin_select(&smc);
							 | 
						||
| 
								 | 
							
								    gpio_module_sig_select(&smc, GPIO_MTX_MODE_CORE);
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void emc_rst() {
							 | 
						||
| 
								 | 
							
								    ahb_cache_enable();
							 | 
						||
| 
								 | 
							
								    sec_glb_enable(SEC_GLB_EMC);
							 | 
						||
| 
								 | 
							
								    flash_init(1);
							 | 
						||
| 
								 | 
							
								    sram_qspi_init();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    sram_qspi_enter();
							 | 
						||
| 
								 | 
							
								    hal_smc_qspi_quad_cfg(0);
							 | 
						||
| 
								 | 
							
								    ahb_cache_enable();
							 | 
						||
| 
								 | 
							
								    ahb_cache_reset();
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __GNUC__
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								int main(void) {
							 | 
						||
| 
								 | 
							
								    volatile int i = 0;
							 | 
						||
| 
								 | 
							
								    gpio_sel();
							 | 
						||
| 
								 | 
							
								    dbg_uart_init();
							 | 
						||
| 
								 | 
							
								    iot_printf("start to run jump test\r\n");
							 | 
						||
| 
								 | 
							
								    uint32_t addr = PSRAM_PRIME_ADDR;
							 | 
						||
| 
								 | 
							
								    emc_rst();
							 | 
						||
| 
								 | 
							
								    for(i = 0; i< 1000; i++);
							 | 
						||
| 
								 | 
							
								    pJump pjump = (pJump) addr;
							 | 
						||
| 
								 | 
							
								    pjump();
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif // __GCC__
							 | 
						||
| 
								 | 
							
								
							 |