os_sample1.c 994 B

12345678910111213141516171819202122232425262728293031323334
  1. /* ----------------------------------------------------------------------
  2. * Copyright (C) 2011 ARM Limited. All rights reserved.
  3. *
  4. * $Date: 30. November 2011
  5. * $Revision: V0.02
  6. *
  7. * Project: CMSIS-RTOS API
  8. * Title: os_sample1.c
  9. *
  10. * Description: This file shows the usage of the CMSIS-RTOS API.
  11. *
  12. * Version 0.02
  13. * Initial Proposal Phase
  14. * -------------------------------------------------------------------- */
  15. #define osObjectsExternal
  16. #include "my_objects.h" // Reference CMSIS OS Objects
  17. void thread_sample (void const *argument) {
  18. osThreadId my_thread;
  19. osPriority my_priority;
  20. int i = 1000;
  21. my_thread = osThreadGetId();
  22. my_priority = osThreadGetPriority (my_thread); // Get priority of own thread
  23. while (i > 0) {
  24. osThreadSetPriority (my_thread, osPriorityAboveNormal);
  25. i--;
  26. }
  27. osThreadSetPriority (my_thread, my_priority);
  28. osThreadTerminate (my_thread); // terminate own thread
  29. }