Beispiel #1
0
//------------- main task -------------//
void msc_host_app_task(void* param)
{
  (void) param;;

  OSAL_TASK_BEGIN

  bool is_any_disk_mounted; 
  
  osal_task_delay(10);

  is_any_disk_mounted = false;
  
  for(uint8_t phy_disk=0; phy_disk < CFG_TUSB_HOST_DEVICE_MAX; phy_disk++)
  {
    if ( disk_is_ready(phy_disk) )
    {
      is_any_disk_mounted = true;
      break;
    }
  }

  if ( is_any_disk_mounted )
  {
    int ch = getchar();
    if ( ch > 0 )
    {
      cli_poll( (char) ch);
    }
  }

  OSAL_TASK_END
}
Beispiel #2
0
//--------------------------------------------------------------------+
// IMPLEMENTATION
//--------------------------------------------------------------------+
static DRESULT wait_for_io_complete(uint8_t usb_addr)
{
  // TODO with RTOS, this should use semaphore instead of blocking
  while ( tuh_msc_is_busy(usb_addr) )
  {
    // TODO should have timeout here
    #if CFG_TUSB_OS != OPT_OS_NONE
    osal_task_delay(10);
    #endif
  }

  return RES_OK;
}
Beispiel #3
0
//--------------------------------------------------------------------+
// BLINKING TASK
//--------------------------------------------------------------------+
OSAL_TASK_FUNCTION( led_blinking_task ) (void* p_task_para)
{
  {// task init, only executed exactly one time, real RTOS does not need this but none OS does
    static bool is_init = false;
    if (!is_init)
    {
      is_init = true;
      print_greeting();
    }
  }

  static uint32_t led_on_mask = 0;

  OSAL_TASK_LOOP_BEGIN

  osal_task_delay(1000);

  board_leds(led_on_mask, 1 - led_on_mask);
  led_on_mask = 1 - led_on_mask; // toggle

  OSAL_TASK_LOOP_END
}