133 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			133 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "os_types.h"
							 | 
						||
| 
								 | 
							
								#include "os_task.h"
							 | 
						||
| 
								 | 
							
								#include "os_mem.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "dbg_io.h"
							 | 
						||
| 
								 | 
							
								#include "iot_diag.h"
							 | 
						||
| 
								 | 
							
								#include "iot_io.h"
							 | 
						||
| 
								 | 
							
								#include "cpu.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								//#include <stdlib.h>
							 | 
						||
| 
								 | 
							
								#include "iot_system_api.h"
							 | 
						||
| 
								 | 
							
								#include "iot_config.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								//#include "iot_gptmr.h"
							 | 
						||
| 
								 | 
							
								#include "iot_system.h"
							 | 
						||
| 
								 | 
							
								//#include "os_mem.h"
							 | 
						||
| 
								 | 
							
								//#include "cpu.h"
							 | 
						||
| 
								 | 
							
								//#include "os_task.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "platform.h"
							 | 
						||
| 
								 | 
							
								#include "encoding.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								//#include "sec_glb.h"
							 | 
						||
| 
								 | 
							
								//#include "ahb.h"
							 | 
						||
| 
								 | 
							
								//#include "intc.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "bits.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "os_utils.h"
							 | 
						||
| 
								 | 
							
								#include "usb_dev.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								static int32_t iot__platform_init()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /*platform intialization*/
							 | 
						||
| 
								 | 
							
								    platform_init();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    //resource initializations;
							 | 
						||
| 
								 | 
							
								//    system_clock_init();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								//    system_uart_init();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    dbg_uart_init();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								   // dbg_uart_stage1_init();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  //  iot_led_init();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void user_task_1(){
							 | 
						||
| 
								 | 
							
								    
							 | 
						||
| 
								 | 
							
								    UsbDevOpen(1);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    while(1)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        iot_printf("user_task_1..CPU:%d..\n",cpu_get_mhartid());
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        os_delay(10000);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    UsbDevStop();
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								int32_t iot__task_init()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    os_task_h handle;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    handle = os_create_task(user_task_1, NULL, 9);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    //create the tasks;
							 | 
						||
| 
								 | 
							
								    if(handle != NULL) {
							 | 
						||
| 
								 | 
							
								        iot_printf("task 1 init successfully...\n");
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								int32_t iot__module_init(void)
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    //platform intialization;
							 | 
						||
| 
								 | 
							
								    iot__platform_init();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    //create all the tasks;
							 | 
						||
| 
								 | 
							
								    iot__task_init();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    iot_printf("starting...\n");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								int32_t iot__task_start()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    //start the tasks;
							 | 
						||
| 
								 | 
							
								    os_start_kernel();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								int32_t iot__module_start(void)
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    int32_t res = 0;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    res = iot__task_start();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    return res;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								int main(void)
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    //module init;
							 | 
						||
| 
								 | 
							
								    iot__module_init();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    //module start;
							 | 
						||
| 
								 | 
							
								    iot__module_start();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 |