Exemplo n.º 1
0
void app_main(void *data)
{
    EatEvent_st event;
    EatEntryPara_st *para;
    event_handler_func func = NULL;
    APP_InitRegions();//Init app RAM
    APP_init_clib();

    para = (EatEntryPara_st*)data;

    memcpy(&app_para, para, sizeof(EatEntryPara_st));
    eat_trace(" App Main ENTRY  update:%d result:%d", app_para.is_update_app,app_para.update_app_result);
    if(app_para.is_update_app && app_para.update_app_result)
    {
        eat_update_app_ok();
    }

    eat_trace(" app_main ENTRY");
    //event_register_handler(EAT_EVENT_TIMER, timer_proc);
    //event_register_handler(EAT_EVENT_KEY, key_proc);
    event_register_handler(EAT_EVENT_MDM_READY_RD, (event_handler_func)mdm_rx_proc);
    //event_register_handler(EAT_EVENT_MDM_READY_WR, mdm_tx_proc);
    //event_register_handler(EAT_EVENT_INT, int_proc);
    //event_register_handler(EAT_EVENT_UART_READY_RD, uart_rx_proc);
    //event_register_handler(EAT_EVENT_UART_READY_WR, uart_tx_proc);
    //event_register_handler(EAT_EVENT_UART_SEND_COMPLETE, uart_send_complete_proc);
    //event_register_handler(EAT_EVENT_USER_MSG, user_msg_proc);
    event_register_handler(EAT_EVENT_ADC, (event_handler_func)adc_event_proc);
    
    while(EAT_TRUE)
    {
        eat_get_event(&event);
        eat_trace("%s-%d:msg %x", __FILE__, __LINE__,event.event);
        func = EventHandlerTable[event.event];
        if(event.event < EAT_EVENT_NUM && func != NULL)
        {
            (*func)(&event);
        }
    }
}
Exemplo n.º 2
0
static void app_main(void *data)
{
    EatUartConfig_st uart_config;
    EatEvent_st event;
    int event_num = 0;

	APP_InitRegions(); //APP RAM initialize
    APP_init_clib(); //C library initialize

    if(eat_uart_open(eat_uart_app ) == EAT_FALSE)
    {
	    eat_trace("[%s] uart(%d) open fail!", __FUNCTION__, eat_uart_app);
    }
	
    uart_config.baud = EAT_UART_BAUD_115200;
    uart_config.dataBits = EAT_UART_DATA_BITS_8;
    uart_config.parity = EAT_UART_PARITY_NONE;
    uart_config.stopBits = EAT_UART_STOP_BITS_1;
    if(EAT_FALSE == eat_uart_set_config(eat_uart_app, &uart_config))
    {
        eat_trace("[%s] uart(%d) set config fail!", __FUNCTION__, eat_uart_app);
    }
    //eat_uart_set_send_complete_event(eat_uart_app, EAT_TRUE);
    eat_timer_start(EAT_TIMER_1, 10000);
    while(1)
    {
        event_num = eat_get_event_num();
get_event:
        if(event_num>0)
        {
            eat_get_event(&event);
            eat_trace("[%s] event_id=%d", __FUNCTION__, event.event);

            if (event.event == EAT_EVENT_NULL || event.event >= EAT_EVENT_NUM)
            {
                eat_trace("[%s] invalid event type", __FUNCTION__, event.event);
                continue;
            }

            switch (event.event)
            {
                case EAT_EVENT_TIMER :
                    {
                        //Restart timer
                        if(event.data.timer.timer_id == EAT_TIMER_2)
                        {
                            eat_timer_start(EAT_TIMER_2, 50);
                        }else 
                        {
                            if(eat_timer_process())
                                eat_timer_start(event.data.timer.timer_id, 6000);
                            else
                                eat_timer_start(EAT_TIMER_2, 50);
                        }
                        // eat_trace("Timer test 1, timer ID:%d", event.data.timer.timer_id);
                    }
                    break;
                case EAT_EVENT_MDM_READY_RD:
                    mdm_rx_proc(&event);
                    break;
                case EAT_EVENT_MDM_READY_WR:
                    eat_trace("[%s] uart(%d) event :%s", __FUNCTION__, event.data.uart, "EAT_EVENT_MDM_READY_WR");
                    break;
                case EAT_EVENT_UART_READY_RD:
                    uart_rx_proc(&event);
                    break;
                case EAT_EVENT_UART_READY_WR:
                    eat_trace("[%s] uart(%d) event :%s", __FUNCTION__, event.data.uart, "EAT_EVENT_UART_READY_WR");
                    uart_ready_wr_proc();
                    break;
                case EAT_EVENT_UART_SEND_COMPLETE:
                    uart_send_complete_proc(&event);
                    break;

                default:
                    break;
            }
            event_num = eat_get_event_num();
            if(event_num>0)
                goto get_event;
            else
                eat_sleep(50);
        }else
        {
            eat_sleep(50);
        }
    }	
}
Exemplo n.º 3
0
void app_main(void *data)
{
    EatEvent_st event;
    eat_bool rc;
    EatEntryPara_st *para;


    APP_InitRegions();//Init app RAM
    APP_init_clib(); //C library initialize, second step

    para = (EatEntryPara_st*)data;
    if(para->is_update_app && para->update_app_result)
    {
        //APP update succeed
        LOG_DEBUG("app upgrade success");
        eat_update_app_ok(); //clear update APP flag
    }

    LOG_INFO("booting: version:%s, build_time=%s %s. core(version:%s, buildno=%s, buildtime=%s)",
            VERSION_STR, __DATE__, __TIME__, eat_get_version(), eat_get_buildno(), eat_get_buildtime());

    rc = eat_mem_init(s_memPool, EAT_MEM_MAX_SIZE);
    if (!rc)
    {
    	LOG_ERROR("eat memory initial error:%d!", rc);
        return;
    }

    if (lzo_init() != LZO_E_OK)
    {
        return;
    }

    log_initial();

    setting_restore();

    fs_initial();

    seek_initial();

    startWatchdog();


    while(EAT_TRUE)
    {
    	unsigned int event_num = eat_get_event_num();
    	if (event_num != 0)
    	{
    		int i = 0;
    		for (i = 0; i < event_num; i++)
    		{
    			eat_get_event(&event);

    	        event_proc(&event);
    		}
    	}

    	//poll
    }
}
Exemplo n.º 4
0
Arquivo: main.c Projeto: igou/com
void app_main(void *data)
{   
    EatEvent_st event;
    u16 len = 0;
    EatUartConfig_st uart_config;
    eat_bool ret;

    APP_InitRegions();//Init app RAM
    APP_init_clib(); //C library initialize, second step
    #if 0
   if(eat_uart_open(EAT_UART_1 ) == EAT_FALSE)
    {
	    eat_trace("[%s] uart(%d) open fail!", __FUNCTION__, EAT_UART_1);
    }
	
    uart_config.baud = EAT_UART_BAUD_115200;
    uart_config.dataBits = EAT_UART_DATA_BITS_8;
    uart_config.parity = EAT_UART_PARITY_NONE;
    uart_config.stopBits = EAT_UART_STOP_BITS_1;
    if(EAT_FALSE == eat_uart_set_config(EAT_UART_1, &uart_config))
    {
        eat_trace("[%s] uart(%d) set config fail!", __FUNCTION__, EAT_UART_1);
    }
 #endif
    log_0("app_main ENTRY");
    Gpio_init();
    ret = eat_mem_init(s_memPool,EAT_MEM_MAX_SIZE);
    if (!ret)
        log_0("ERROR: eat memory initial error!");
    
    eat_timer_start(TIMER_SOFT_RESET,600000);
    at_cluster();

    while(EAT_TRUE)
    {
        eat_get_event(&event);
        log_2("MSG id%x", event.event);
        switch(event.event)
        {
          case EAT_EVENT_TIMER :
           {
             EatTimer_enum timer_id = event.data.timer.timer_id;
             timer_hdlr(timer_id);
           } 
             break;
          case EAT_EVENT_INT :      
             log_0("INTERRUPT IS COMING");
             if(get_key())/*donw = 1 */
                key_hdlr();               
             break;
             
           case EAT_EVENT_USER_MSG:
            {
             u8 data = event.data.user_msg.data[0];
             set_debounce(data);
            }
              break;
           case EAT_EVENT_KEY:
           {
            eat_bool press = event.data.key.is_pressed;
            log_0("power key");
            pwrkey_hdlr(press);
           }
              break;
              
          case EAT_EVENT_MDM_READY_WR:
              break;
              
          case EAT_EVENT_UART_READY_RD:
            log_2("EAT_EVENT_UART_READY_RD");
              break;
          case EAT_EVENT_MDM_READY_RD:
              {        
                  len = 0;
                           /* boot info(such as:RDY ;+CFUN: 1  ;+CPIN: READY)
                            * will be sent to here(main task);
                            */
                  len = eat_modem_read(buf, 2048); /*necessary:Read it out*/ 
                  buf[len] = 0;
                  log_2("main task buf (%s)",buf);
                  #if 0
                 if(core_is_ready(buf))
                    {
                     eat_trace("core is ready");
                     eat_timer_start(TIMER_SOFT_RESET,600000);
                     at_cluster();
                   }  
                 #endif
               }
              break;    
          case EAT_EVENT_UART_SEND_COMPLETE :
              break;
          default:
              break;
        }

    }

}