Exemplo n.º 1
0
/**
 * Main message (infinite) loop.
 */
void loop_loop(int8_t once)
{
    do {
        message_t lmsg;
        if (g_message_buffer.rdpos == g_message_buffer.wrpos) {
            /* no message in the buffer: Run NOP message */
            lmsg.cmd = Cmd_Nop;
            lmsg.arg1i = 0;
        } else {
            /* a message in the buffer: retrieve and process */
            lmsg = g_message_buffer.msg_buf[g_message_buffer.rdpos];
            g_message_buffer.rdpos = iwrap(g_message_buffer.rdpos + 1);

            if (lmsg.cmd != Cmd_ClockTick) {
                usart_sendstr_P(PSTR("[Msg:0x"));
                usart_sendhexb(lmsg.cmd);
                usart_sendstr_P(PSTR("]"));
            }
        }

        int8_t used = 0;
        used |= voice_process(&lmsg);
        used |= vfs_process(&lmsg);
        used |= sound_process(&lmsg);
        used |= ir_process(&lmsg);
        used |= debug_process(&lmsg);
        used |= btn_process(&lmsg);
        used |= clock_process(&lmsg);

        if (!used && (lmsg.cmd != Cmd_Nop)) {
            usart_sendstr_P(PSTR("[Msg not recognized!]\n"));
        }

        /* reset watchdog timer */
        wdt_reset();
    } while (!once);
}
static void usb_process(handle_t handle)
{
  hotplug_msg_t hp_msg = {0};
  os_msg_t msg = {0};
  s32 ret = 0;
  service_t *p_svc = (service_t *)handle;
  
  ret = hotplug_get_msg(&hp_msg); 
  if(ret != SUCCESS)
  {
    return;
  }
  
  msg.para1 = (u32)hp_msg.bus_type << 16;
  msg.para2 = hp_msg.dev_type;
  if(hp_msg.event == HP_BUS_PLUG_IN)
  {
    OS_PRINTF("HP_BUS_PLUG_IN\n");
    msg.content = PNP_SVC_USB_DEV_PLUG_IN;
    msg.para1 |= hp_msg.bus_mode;
  }
  else
  {
    OS_PRINTF("HP_BUS_PLUG_OUT\n");
    msg.content = PNP_SVC_USB_DEV_PLUG_OUT;
  }

  if(hp_msg.dev_type == HP_WIFI)                                                    //deal with wifi
  {
      p_svc->notify(p_svc, &msg);
  }
  else if(!vfs_process(handle, usb_evt_callback))
  {
    p_svc->notify(p_svc, &msg);
  }
}