101 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			101 lines
		
	
	
		
			2.5 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 "chip_reg_base.h"
							 | 
						||
| 
								 | 
							
								#include "hw_reg_api.h"
							 | 
						||
| 
								 | 
							
								#include "ahb_rf.h"
							 | 
						||
| 
								 | 
							
								#include "sram.h"
							 | 
						||
| 
								 | 
							
								#include "irq.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#if HW_PLATFORM > HW_PLATFORM_SIMU
							 | 
						||
| 
								 | 
							
								#include "dbg_io.h"
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								#include "iot_io.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "watchdog.h"
							 | 
						||
| 
								 | 
							
								#include "ahb.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define TEST_CPU 0
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#if TEST_CPU == 0
							 | 
						||
| 
								 | 
							
								extern iot_wdg_info g_wdg_info;
							 | 
						||
| 
								 | 
							
								extern iot_wdg_info g_wdg_timeout;
							 | 
						||
| 
								 | 
							
								extern int g_feed_dog;
							 | 
						||
| 
								 | 
							
								#else
							 | 
						||
| 
								 | 
							
								extern iot_wdg_info g_wdg_info_1;
							 | 
						||
| 
								 | 
							
								extern iot_wdg_info g_wdg_timeout_1;
							 | 
						||
| 
								 | 
							
								extern int g_feed_dog_1;
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								int cnt = 0;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void wdg_main() {
							 | 
						||
| 
								 | 
							
								    dbg_uart_init();
							 | 
						||
| 
								 | 
							
								    int i = 0;
							 | 
						||
| 
								 | 
							
								    int j =0;
							 | 
						||
| 
								 | 
							
								    int k = 0;
							 | 
						||
| 
								 | 
							
								    volatile int len = 1000000;
							 | 
						||
| 
								 | 
							
								#if TEST_CPU == 0
							 | 
						||
| 
								 | 
							
								    uint32_t *reg = (uint32_t *) 0x4400e010;
							 | 
						||
| 
								 | 
							
								    //wdg_init(0);
							 | 
						||
| 
								 | 
							
								#else
							 | 
						||
| 
								 | 
							
								    uint32_t *reg = (uint32_t *) 0x62010010;
							 | 
						||
| 
								 | 
							
								    //wdg_init(1);
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								    iot_printf("aaaaaaaaa");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    while(1) {
							 | 
						||
| 
								 | 
							
								        for (i=0; i<len; i++);
							 | 
						||
| 
								 | 
							
								        iot_printf("k = %d, j = %d\n", k, j);
							 | 
						||
| 
								 | 
							
								        iot_printf("intc: %08x, timeout: %08x, cpu: %08x, full: %08x\n",
							 | 
						||
| 
								 | 
							
								            *reg, *(reg+2), *(reg+4), *(reg+6));
							 | 
						||
| 
								 | 
							
								        j++;
							 | 
						||
| 
								 | 
							
								        if (j == 10000) {
							 | 
						||
| 
								 | 
							
								           j = 0;
							 | 
						||
| 
								 | 
							
								           k++;
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        if ( k == 100) {
							 | 
						||
| 
								 | 
							
								            k = 0;
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								#if TEST_CPU == 0
							 | 
						||
| 
								 | 
							
								        if(g_feed_dog == 1 && cnt < 5){
							 | 
						||
| 
								 | 
							
								            iot_printf("cnt %d, feed dog\n", cnt);
							 | 
						||
| 
								 | 
							
								            wdg_feed_dog(0);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								            iot_interrupt_unmask(g_wdg_info.handle);
							 | 
						||
| 
								 | 
							
								            g_feed_dog = 0;
							 | 
						||
| 
								 | 
							
								            cnt++;
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								#else
							 | 
						||
| 
								 | 
							
								         if(g_feed_dog_1 == 1 && cnt < 5){
							 | 
						||
| 
								 | 
							
								            iot_printf("cnt %d, feed dog\n", cnt);
							 | 
						||
| 
								 | 
							
								            wdg_feed_dog(1);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								            iot_interrupt_unmask(g_wdg_info_1.handle);
							 | 
						||
| 
								 | 
							
								            g_feed_dog_1 = 0;
							 | 
						||
| 
								 | 
							
								            cnt++;
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    return;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								int main(void) {
							 | 
						||
| 
								 | 
							
								    wdg_main();
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 |