Пример #1
0
void MainTask(void) {

    USBH_Init();
    OS_SetPriority(OS_GetTaskID(), TASK_PRIO_APP);                                       // This task has highest prio for real-time application
    OS_CREATETASK(&_TCBMain, "USBH_Task", USBH_Task, TASK_PRIO_USBH_MAIN, _StackMain);   // Start USBH main task
    OS_CREATETASK(&_TCBIsr, "USBH_isr", USBH_ISRTask, TASK_PRIO_USBH_ISR, _StackIsr);    // Start USBH main task
    USBH_HID_Init();
    while (1) {
        BSP_ToggleLED(1);
        if (USBH_HID_GetNumDevices(NULL, 0)) {
            USBH_HID_HANDLE hDevice;
            USBH_HID_DEVICE_INFO aDevInfo[20];
            unsigned NumItems = COUNTOF(_aReportInfo);

            USBH_HID_GetNumDevices(aDevInfo, COUNTOF(aDevInfo));
            hDevice = USBH_HID_Open("hid000");
            if (hDevice) {
                USBH_HID_GetReportDescriptorParsed(hDevice, &_aReportInfo[0], &NumItems);
                USBH_HID_GetReport(hDevice, _aReport, sizeof(_aReport), NULL, NULL);
                USBH_HID_Close(hDevice);
            }
        }
        OS_Delay(100);
    }
}
Пример #2
0
void MainTask(void) {
  USB_Init();
  _AddBULK();
  USB_Start();
  OS_CREATETASK(&_StatusTCB0, "Status Task", _StatusTask, 50, _aStatusStack);
  OS_CREATETASK(&_USBTCB0,    "USB Task",    _USBTask,   150, _aUSBStack);
  OS_Terminate(OS_pCurrentTask);
}
Пример #3
0
int main(void) 
{
  WDTCTL   = WDTPW + WDTHOLD                         ;
  Init_CLK()                                         ;
  Init_J60SPI()                                      ;
  MAIN_POWER_ON                                      ;
  __delay_cycles(5000000)                            ;
  P9DIR   |= IrDA_OUT                                ;
  P9OUT   &=~IrDA_OUT                                ;
  Init_EtherNet()                                    ;
  ENC_SLEEP()                                        ; // 省电  
    
  OS_IncDI()                                         ; // 屏蔽中断
  OS_InitKern()                                      ; // 初始化系统内核
  OS_InitHW()                                        ; // 初始化硬件
  Init_Func()                                        ;
  Init_UART()                                        ;  
  Init_RSUART()                                      ;
  Ini_LED(8)                                         ;
  Init_ADC()                                         ;
  Init_RTC()                                         ;
  LCD_Init()                                         ;

  LED_POWER_ON                                       ;
  BackLight()                                        ;
  OS_CREATERSEMA(&SemaLCD)                           ;
  OS_CREATERSEMA(&SemaSPI)                           ;
  LED_Disp_Float(3.1415925,7,FIT_ZERO)               ;
  LED_Flicker_Digit(8,1)                             ;  
  Color     = Black                                  ;
  Color_BK  = 0xEF9F                                 ;
  
  OS_CREATETASK(&Seg7LED_TASK_TCB, 
                "Seg7LedTask", 
                Seg7LedRefresh, 100, 
                Seg7LED_TASK_STACK  )                ;
  
  OS_CREATETASK(&LCD_TASK_TCB, 
                "LCD_Task", 
                LCD_Task, 100, 
                LCD_TASK_STACK  )                    ;
  
  OS_CREATETASK(&MENU_OP_TASK_TCB, 
                "MENU_OP_Task", 
                MENU_OP_Task, 100, 
                MENU_OP_TASK_STACK)                  ;

  OS_CREATETASK(&KEY_TP_TASK_TCB, 
                "KEY_TP_Task", 
                Key_TP_Task, 100, 
                KEY_TP_TASK_STACK  )                 ;
  
  
  OS_Start()                                         ; 
  return 0                                           ;
}
Пример #4
0
/*********************************************************************
*
*       main
*/
int main(void) {
  OS_IncDI();                      // Initially disable interrupts
  OS_InitKern();                   // Initialize OS
  OS_InitHW();                     // Initialize Hardware for OS
  BSP_Init();                      // Initialize LED ports
  OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP);
  OS_CREATETASK(&TCBLP, "LP Task", LPTask,  99, StackLP);
  OS_Start();                      // Start multitasking
  return 0;
}
Пример #5
0
/*********************************************************************
*
*       main
*/
int main(void) {
  OS_IncDI();                      /* Initially disable interrupts  */
  OS_InitKern();                   /* Initialize OS                 */
  OS_InitHW();                     /* Initialize Hardware for OS    */
  /* You need to create at least one task here !                    */
  OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP);
  OS_CREATETASK(&TCBLP, "LP Task", LPTask,  50, StackLP);
  OS_Start();                      /* Start multitasking            */
  return 0;
}
Пример #6
0
void MainTask(void) {
  IP_Init();
  OS_SetPriority(OS_GetTaskID(), 255);                                 // This task has highest prio for real-time application
  OS_CREATETASK(&_TCB,       "IP_Task", IP_Task, 150, _Stack);         // Start the IP task
  OS_CREATETASK(&_TCBMailer, "Mailer",  _Mailer, 100, _StackMailer);   // Start the mailer
  while (1) {
    BSP_ToggleLED(1);
    if (IP_GetCurrentLinkSpeed() == 0) {
      OS_Delay(50);
    } else {
      OS_Delay (200);
    }
  }
}
Пример #7
0
int main(void) {
  OS_IncDI();                   /* Initially disable interrupts     */
  OS_InitKern();                /* Initialize OS                    */
  OS_InitHW();                  /* Initialize Hardware for OS       */
  OS_Q_Create(&_MyQ, &_MyQBuffer, sizeof(_MyQBuffer));
  /* You need to create at least one task before calling OS_Start() */
  OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP);
  OS_CREATETASK(&TCBLP, "LP Task", LPTask,  50, StackLP);
  OS_DecRI();                   /* Enable interrupts before sending */
  OS_SendString("embOS OS_Q example");
  OS_SendString("\n\nDemonstrating message passing\n");
  OS_Start();                   /* Start multitasking               */
  return 0;
}
Пример #8
0
void MainTask(void) {
  OS_CREATETASK(&_TCB, "HPTask", HPTask, 150, _Stack);
  while (1) {
    BSP_ToggleLED(1);
    OS_Delay (200);
  }
}
Пример #9
0
/****************************************************************************
*    Name        : InitUSBDriver                                            *
*                                                                           *
*    Inputs      : Channel Parameters                                       *
*    Outputs     : None                                                     *
*    Returns     : None                                                     *
*                                                                           *
*    Description : This routine initialises USB driver.It performs following* 
*                 actions.                                                  * 
*                 1. Initialses the USB Transmit and Receive Tasks          *
*                 2. Initialises teh Idle timer                             *
*                 3. Inidicates the Channel idle condition.                 *
*                                                                           *
*****************************************************************************
*/
void InitUSBDriver(GF_UINT8 p_setup_param)
{
  /* Create and Start USB Transmit Task */
  OS_CREATETASK(&USBTxTaskHandle, "USB TX Task", USBInterfaceTransmitTask,  USBTX_TASK_PRIORITY, USBTxStack);

  /* Create and Start USB Recive Task */
  OS_CREATETASK(&USBRxTaskHandle, "USB RX Task", USBInterfaceReceiveTask,  USBRX_TASK_PRIORITY, USBRxStack);

  /* Signal that the channel is NOT busy */
  UsbChannelBusy(FALSE);

  /* Initialise port and timer for timer idle */
#if(USB_IDLE_TYPE == TIMER_IDLE)
  InitIdleTimer();                                          
#endif
}
Пример #10
0
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  #ifdef WIN32
    WSADATA WSAData;
  #endif
  double lon  =  6.9158935; // Longitude
  double lat  = 51.1793436; // Latitude
  int x, y, Zoom;

  GUI_Init();
  #ifdef WIN32
    WSACleanup();
    if (WSAStartup(MAKEWORD(2,0), &WSAData) != 0) {
      return;
    }
  #else
    IP_Init();
    IP_AddLogFilter(IP_MTYPE_APPLICATION);
    _IFaceId = IP_INFO_GetNumInterfaces() - 1;                               // Get the last registered interface ID as this is most likely the interface we want to use in this sample.
    OS_SetPriority(OS_GetTaskID(), TASK_PRIO_IP_TASK);                       // For now, this task has highest prio except IP management tasks.
    OS_CREATETASK(&_IPTCB, "IP_Task", IP_Task, TASK_PRIO_IP_TASK, _IPStack); // Start the IP_Task.
    IP_Connect(_IFaceId);                                                    // Connect the interface if necessary.
    OS_SetPriority(OS_GetTaskID(), TASK_PRIO_IP_CLIENT);                     // Important: Client task priority must be less than priority of IP task!!!
    while (IP_IFaceIsReadyEx(_IFaceId) == 0) {
      OS_Delay(50);
    }
  #endif
  Zoom = 16;
  x = _Long2TileX(lon, Zoom);
  y = _Lat2TileY(lat, Zoom);
  _TileScreen(x, y, Zoom);
  while(1) {
    GUI_Delay(20);
  }
}
Пример #11
0
void MainTask(void) {
  BSP_ClrLED(0);
  BSP_ClrLED(1);
  BSP_ClrLED(2);
  IP_Init();
  OS_SetPriority(OS_GetTaskID(), 255);
  OS_CREATETASK(&_TCBIP       , "IP_Task"  , IP_Task  , 150, _StackIP);
#if USE_RX_TASK
  OS_CREATETASK(&_TCBIPRx     , "IP_RxTask", IP_RxTask, 250, _StackIPRx);
#endif
  OS_CREATETASK_EX(&_TCBClient, "Client"   ,  _Client , 100, _StackClient, NULL);
  while (1) {
    BSP_ToggleLED(2);
    OS_Delay (200);
  }
}
Пример #12
0
void MainTask(void) {

  USB_Init();
  USB_EnableIAD();
  _AddCDC();
  _AddHID();
  USB_Start();
  BSP_SetLED(0);
  OS_CREATETASK(&_HIDTCB,  "HIDTask",  _HIDTask, 200, _aHIDStack);

  while (1) {
    char ac[64];
    int  NumBytesReceived;

    //
    // Wait for configuration
    //
    while ((USB_GetState() & (USB_STAT_CONFIGURED | USB_STAT_SUSPENDED)) != USB_STAT_CONFIGURED) {
      BSP_ToggleLED(0);
      USB_OS_Delay(50);
    }
    BSP_SetLED(0);
    NumBytesReceived = USB_CDC_Receive(&ac[0], sizeof(ac));
    if (NumBytesReceived > 0) {
      USB_CDC_Write(&ac[0], NumBytesReceived);
    }
  }
}
Пример #13
0
/*********************************************************************
*
*             GUI_VNC_X_StartServer
*
* Function description
*   To start the server, the following steps are executed
*   - Make sure the TCP-IP stack is up and running
*   - Init the server context and attach it to the layer
*   - Start the thread (task) which runs the VNC server
* Notes:
*   (1) The first part of the code initializes the TCP/IP stack. In a typical
*       application, this is not required, since the stack should have already been
*       initialized some other place.
*       This could be done in a different module. (TCPIP_AssertInit() ?)
*/
int GUI_VNC_X_StartServer(int LayerIndex, int ServerIndex) {
  /* Make sure the TCP/IP stack is initialized.  (1) */
  if (xn_rtip_init() != 0) {
    OS_SendString("GUI_VNC_X_StartServer: Init failed\n");
    return 1;                    /* Error */
  }
  {
    int interface;
    xn_bind_cs(0);                                        /* append interface to device table */
    interface = xn_interface_open_config(CS89X0_DEVICE, 0, (IOADDRESS)0x20000300,5,0);   /* open interface */
    if (interface < 0) {
      OS_SendString("GUI_VNC_X_StartServer: Can not open interface\n");
      return 1;                                           /* Error */
    }
    xn_set_ip(interface, (PFBYTE)&_IPLocal[0], (PFBYTE)&_IPMask[0]);      /* set IP address of interface */
    HW_EnableEthernetIRQ();                               /* Enable ethernet IRQ. Make sure it is done after xn_interface_open_config() */  
  }

  /* Init VNC context and attach to layer (so context is updated if the display-layer-contents change */
  GUI_VNC_AttachToLayer(&_Context, LayerIndex);
  _Context.ServerIndex = ServerIndex;

  /* Create task for VNC Server */
  OS_CREATETASK(&_VNCServer_TCB, "VNC Server", _ServerTask, 50, _StackVNCServer);
  return 0;                                               /* O.k., server has been started */
}
Пример #14
0
void MainTask(void) {
  IP_Init();
  OS_SetPriority(OS_GetTaskID(), 255);                                      // This task has highest prio for real-time application
  OS_CREATETASK(&_TCB     , "IP_Task"  , IP_Task       , 150, _Stack);      // Start the IP task
#if USE_RX_TASK
  OS_CREATETASK(&_IPRxTCB , "IP_RxTask", IP_RxTask     , 140, _IPRxStack);  // Start the IP_RxTask, optional.
#endif
  OS_CREATETASK(&_TCBShell, "Shell"    , IP_ShellServer, 100, _StackShell); // Start the shell server

  while (IP_IFaceIsReady() == 0) {
    OS_Delay(50);
  }
  while (1) {
    BSP_ToggleLED(1);
    OS_Delay (200);
  }
}
Пример #15
0
int main(void) {
  OS_IncDI();                      /* Initially disable interrupts  */
  OS_InitKern();                   /* Initialize OS                 */
  OS_InitHW();                     /* Initialize Hardware for OS    */
  OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP);
  OS_Start();                      /* Start multitasking            */
  return 0;
}
Пример #16
0
int main(void) {
    OS_IncDI();                      /* Disable interrupts */
    OS_InitKern();                   /* Initialize OS */
    OS_InitHW();                     /* Initialize Hardware */
    BSP_Init();                      /* Initialize LED ports */
    /* You need to create at least one task before calling OS_Start() */
    OS_CREATETASK(&WLFTASK, "Tests task", wolfTask, 100, WLFSTACK);
    OS_Start();                      /* Start the OS */
    return 0;
}
Пример #17
0
extern "C" void DisplayInit(void)
{
  DisplaySetup();
  StartDisplay();
#ifndef __PC__
  DisplayHwSetup();
#endif

  OS_CREATETASK(&TCBDisplayMainTask, "Display Main Task", DisplayMainTask, DISPLAY_MAIN_TASK_PRIO, DisplayTaskStack);
#ifndef __PC__
  InitKeyboard();
#endif
}
/*********************************************************************
*
*       GUI_VNC_X_StartServer
*
* Function description
*   To start the server, the following steps are executed
*   - Make sure the TCP-IP stack is up and running
*   - Init the server context and attach it to the layer
*   - Start the thread (task) which runs the VNC server
* Notes:
*   (1) The first part of the code initializes the TCP/IP stack. In a typical
*       application, this is not required, since the stack should have already been
*       initialized some other place.
*       This could be done in a different module. (TCPIP_AssertInit() ?)
*/
int GUI_VNC_X_StartServer(int LayerIndex, int ServerIndex) {
  //
  // Init VNC context and attach to layer (so context is updated if the display-layer-contents change
  //
  GUI_VNC_AttachToLayer(&_Context, LayerIndex);
  _Context.ServerIndex = ServerIndex;
  //
  // Create task for VNC Server
  //
  OS_CREATETASK(&_VNCServer_TCB, "VNC Server", _ServerTask, 230, _StackVNCServer);
  //
  // O.k., server has been started
  //
  return 0;
}
Пример #19
0
void MainTask(void) {
  OS_CREATETASK(&TCBHP, "HP Task", HPTask, 150, StackHP);
  OS_Delay(1);
  while (1) {
    OS_Delay(100);     // Syncronize to tick to avoid jitter
    //
    // Display measurement overhead
    //
    BSP_SetLED(0);
    BSP_ClrLED(0);
    //
    // Perform measurement
    //
    BSP_SetLED(0);     // Start measurement
    OS_Resume(&TCBHP); // Resume high priority task to force task switch
  }
}
void MainTask(void) {
  OS_U32 MeasureOverhead;               // Time for Measure Overhead
  OS_U32 v;                             // Real context switch time
  
  OS_CREATETASK(&TCBHP, "HP Task", HPTask, 150, StackHP);
  OS_Delay(1);
  //
  // Measure Overhead for time measurement so we can take this into account by subtracting it
  //
  OS_Timing_Start(&MeasureOverhead);
  OS_Timing_End(&MeasureOverhead);
  //
  // Perform measurements in endless loop
  //
  while (1) {
    OS_Delay(100);                    // Syncronize to tick to avoid jitter
    OS_Timing_Start(&_Time);          // Start measurement
    OS_Resume(&TCBHP);                // Resume high priority task to force task switch
    v = OS_Timing_GetCycles(&_Time) - OS_Timing_GetCycles(&MeasureOverhead); // Calculate real context switch time (w/o measurement overhead)
    v = OS_ConvertCycles2us(1000 * v);                                       // Convert cycles to nano-seconds, increase time resolution
    printf("Context switch time: %u.%.3u usec\r\n", v / 1000, v % 1000);     // Print out result
  }
}
Пример #21
0
void InitKeyboard(void)
{
  contrast_key_down = false;
  OS_CREATETASK(&KeyboardTCB,"keyboard Driver",RunKeyboardTask,KEYBORAD_PRIORITY,KeyboardStack);
}
Пример #22
0
void MainTask(void) {
    USB_Init();
    FS_Init();
    OS_CREATETASK(&_USBTCB0, "USB Task", _USBTask, 150, _aUSBStack);
    _FSTask();
}