main.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2013-2017 ARM Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * ----------------------------------------------------------------------
  19. *
  20. * $Date: 1. December 2017
  21. * $Revision: V2.0.0
  22. *
  23. * Project: CMSIS-DAP Examples LPC-Link-II
  24. * Title: main.c CMSIS-DAP Main module for LPC-Link-II
  25. *
  26. *---------------------------------------------------------------------------*/
  27. #include "cmsis_os2.h"
  28. #include "osObjects.h"
  29. #include "rl_usb.h"
  30. #include "DAP_config.h"
  31. #include "DAP.h"
  32. // Application Main program
  33. __NO_RETURN void app_main (void *argument) {
  34. (void)argument;
  35. DAP_Setup(); // DAP Setup
  36. USBD_Initialize(0U); // USB Device Initialization
  37. USBD_Connect(0U); // USB Device Connect
  38. while (!USBD_Configured(0U)); // Wait for USB Device to configure
  39. LED_CONNECTED_OUT(1U); // Turn on Debugger Connected LED
  40. LED_RUNNING_OUT(1U); // Turn on Target Running LED
  41. Delayms(500U); // Wait for 500ms
  42. LED_RUNNING_OUT(0U); // Turn off Target Running LED
  43. LED_CONNECTED_OUT(0U); // Turn off Debugger Connected LED
  44. // Create DAP Thread
  45. DAP_ThreadId = osThreadNew(DAP_Thread, NULL, &DAP_ThreadAttr);
  46. // Create SWO Thread
  47. SWO_ThreadId = osThreadNew(SWO_Thread, NULL, &SWO_ThreadAttr);
  48. osDelay(osWaitForever);
  49. for (;;) {};
  50. }
  51. int main (void) {
  52. SystemCoreClockUpdate();
  53. osKernelInitialize(); // Initialize CMSIS-RTOS
  54. osThreadNew(app_main, NULL, NULL); // Create application main thread
  55. if (osKernelGetState() == osKernelReady) {
  56. osKernelStart(); // Start thread execution
  57. }
  58. for (;;) {};
  59. }