µGFX library fork

gos_rawrtos.c 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * This file is subject to the terms of the GFX License. If a copy of
  3. * the license was not distributed with this file, you can obtain one at:
  4. *
  5. * http://ugfx.org/license.html
  6. */
  7. #include "../../gfx.h"
  8. #if GFX_USE_OS_RAWRTOS
  9. #include <string.h>
  10. #include "raw_api.h"
  11. #include "raw_config.h"
  12. #if CONFIG_RAW_MUTEX != 1
  13. #error "GOS: CONFIG_RAW_MUTEX must be defined in raw_config.h"
  14. #endif
  15. #if CONFIG_RAW_SEMAPHORE != 1
  16. #error "GOS: CONFIG_RAW_SEMAPHORE must be defined in raw_config.h"
  17. #endif
  18. void _gosInit(void)
  19. {
  20. #if !GFX_OS_NO_INIT
  21. #error "GOS: Operating System initialization for RawRTOS is not yet implemented in uGFX. Please set GFX_OS_NO_INIT to TRUE in your gfxconf.h"
  22. #endif
  23. #if !GFX_OS_INIT_NO_WARNING
  24. #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
  25. #warning "GOS: Operating System initialization has been turned off. Make sure you call raw_os_start() before gfxInit() in your application!"
  26. #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
  27. COMPILER_WARNING("GOS: Operating System initialization has been turned off. Make sure you call raw_os_start() before gfxInit() in your application!")
  28. #endif
  29. #endif
  30. }
  31. void _gosPostInit(void)
  32. {
  33. }
  34. void _gosDeinit(void)
  35. {
  36. }
  37. void gfxSleepMilliseconds(delaytime_t ms)
  38. {
  39. systemticks_t ticks = ms*RAW_TICKS_PER_SECOND/1000;
  40. if(!ticks)ticks = 1;
  41. raw_sleep(ticks);
  42. }
  43. void gfxSleepMicroseconds(delaytime_t us)
  44. {
  45. systemticks_t ticks = (us/1000)*RAW_TICKS_PER_SECOND/1000;
  46. if(!ticks)ticks = 1;
  47. raw_sleep(ticks);
  48. }
  49. bool_t gfxSemWait(gfxSem* psem, delaytime_t ms)
  50. {
  51. systemticks_t ticks = ms*RAW_TICKS_PER_SECOND/1000;
  52. if(!ticks)ticks=1;
  53. if(raw_semaphore_get((psem), ticks)==RAW_SUCCESS)
  54. return TRUE;
  55. return FALSE;
  56. }
  57. bool_t gfxSemWaitI(gfxSem* psem)
  58. {
  59. if(raw_semaphore_get((psem), TIME_IMMEDIATE)==RAW_SUCCESS)
  60. return TRUE;
  61. return FALSE;
  62. }
  63. gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
  64. {
  65. RAW_U16 ret;
  66. gfxThreadHandle taskobj;
  67. taskobj = gfxAlloc(sizeof(RAW_TASK_OBJ));
  68. ret = raw_task_create(taskobj, (RAW_U8 *)"uGFX_TASK", param,
  69. prio, 0, stackarea,
  70. stacksz/sizeof(PORT_STACK) , fn, 1);
  71. if (ret != RAW_SUCCESS) {
  72. for (;;);
  73. }
  74. return (taskobj);
  75. }
  76. #endif