arch.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * @Author: jiejie
  3. * @Github: https://github.com/jiejieTop
  4. * @Date: 2019-12-26 19:11:40
  5. * @LastEditTime : 2019-12-28 01:15:29
  6. * @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
  7. */
  8. #include "salof_defconfig.h"
  9. #ifdef SALOF_USING_LOG
  10. void *salof_alloc(unsigned int size)
  11. {
  12. return pvPortMalloc(size);
  13. }
  14. void salof_free(void *mem)
  15. {
  16. vPortFree(mem);
  17. }
  18. salof_tcb salof_task_create(const char *name,
  19. void (*task_entry)(void *param),
  20. void * const param,
  21. unsigned int stack_size,
  22. unsigned int priority,
  23. unsigned int tick)
  24. {
  25. salof_tcb task;
  26. (void)tick;
  27. xTaskCreate(task_entry, name, stack_size, param, priority, &task);
  28. return task;
  29. }
  30. salof_mutex salof_mutex_create(void)
  31. {
  32. return xSemaphoreCreateMutex();
  33. }
  34. void salof_mutex_delete(salof_mutex mutex)
  35. {
  36. vSemaphoreDelete(mutex);
  37. }
  38. int salof_mutex_pend(salof_mutex mutex, unsigned int timeout)
  39. {
  40. if(xSemaphoreTake(mutex, timeout) != pdPASS)
  41. return -1;
  42. return 0;
  43. }
  44. int salof_mutex_post(salof_mutex mutex)
  45. {
  46. if(xSemaphoreGive(mutex) != pdPASS)
  47. return -1;
  48. return 0;
  49. }
  50. salof_sem salof_sem_create(void)
  51. {
  52. return xSemaphoreCreateBinary();
  53. }
  54. void salof_sem_delete(salof_sem sem)
  55. {
  56. vSemaphoreDelete(sem);
  57. }
  58. int salof_sem_pend(salof_sem sem, unsigned int timeout)
  59. {
  60. if(xSemaphoreTake(sem, timeout) != pdPASS)
  61. return -1;
  62. return 0;
  63. }
  64. int salof_sem_post(salof_sem sem)
  65. {
  66. if(xSemaphoreGive(sem) != pdPASS)
  67. return -1;
  68. return 0;
  69. }
  70. unsigned int salof_get_tick(void)
  71. {
  72. return xTaskGetTickCount();
  73. }
  74. char *salof_get_task_name(void)
  75. {
  76. return pcTaskGetTaskName(xTaskGetCurrentTaskHandle());
  77. }
  78. #endif