main.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) 2013-2021 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: 21. May 2021
  21. * $Revision: V2.0.0
  22. *
  23. * Project: CMSIS-DAP Examples LPC-Link2
  24. * Title: main.c CMSIS-DAP Main module for LPC-Link2
  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. #ifdef LPC_LINK2_ONBOARD
  38. char *ser_num;
  39. ser_num = GetSerialNum();
  40. if (ser_num != NULL) {
  41. USBD_SetSerialNumber(0U, ser_num); // Update Serial Number
  42. }
  43. #endif
  44. USBD_Connect(0U); // USB Device Connect
  45. while (!USBD_Configured(0U)); // Wait for USB Device to configure
  46. LED_CONNECTED_OUT(1U); // Turn on Debugger Connected LED
  47. LED_RUNNING_OUT(1U); // Turn on Target Running LED
  48. Delayms(500U); // Wait for 500ms
  49. LED_RUNNING_OUT(0U); // Turn off Target Running LED
  50. LED_CONNECTED_OUT(0U); // Turn off Debugger Connected LED
  51. // Create DAP Thread
  52. DAP_ThreadId = osThreadNew(DAP_Thread, NULL, &DAP_ThreadAttr);
  53. // Create SWO Thread
  54. SWO_ThreadId = osThreadNew(SWO_Thread, NULL, &SWO_ThreadAttr);
  55. osDelay(osWaitForever);
  56. for (;;) {}
  57. }
  58. int main (void) {
  59. SystemCoreClockUpdate();
  60. osKernelInitialize(); // Initialize CMSIS-RTOS
  61. osThreadNew(app_main, NULL, NULL); // Create application main thread
  62. if (osKernelGetState() == osKernelReady) {
  63. osKernelStart(); // Start thread execution
  64. }
  65. for (;;) {}
  66. }