salof_defconfig.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * @Author: jiejie
  3. * @Github: https://github.com/jiejieTop
  4. * @Date: 2019-12-25 23:56:34
  5. * @LastEditTime: 2020-06-17 18:50:26
  6. * @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
  7. */
  8. #ifndef _SALOF_DEFCONFIG_H_
  9. #define _SALOF_DEFCONFIG_H_
  10. #include "salof_config.h"
  11. #ifdef SALOF_USING_LOG
  12. #define SALOF_USING_RTT 1
  13. #define SALOF_USING_FREERTOS 2
  14. #define SALOF_USING_TENCENTOS 3
  15. #define SALOF_USING_LINUX 4
  16. #define SALOF_BASE_LEVEL (0)
  17. #define SALOF_ERR_LEVEL (SALOF_BASE_LEVEL + 1)
  18. #define SALOF_WARN_LEVEL (SALOF_ERR_LEVEL + 1)
  19. #define SALOF_INFO_LEVEL (SALOF_WARN_LEVEL + 1)
  20. #define SALOF_DEBUG_LEVEL (SALOF_INFO_LEVEL + 1)
  21. #ifndef SALOF_USING_SALOF
  22. #define SALOF_USING_SALOF (1U)
  23. #endif
  24. #ifndef SALOF_USING_IDLE_HOOK
  25. #define SALOF_USING_IDLE_HOOK (0U)
  26. #endif
  27. #ifndef SALOF_LOG_COLOR
  28. #define SALOF_LOG_COLOR (1U)
  29. #endif
  30. #ifndef SALOF_LOG_TS
  31. #define SALOF_LOG_TS (1U)
  32. #endif
  33. #ifndef SALOF_LOG_TAR
  34. #define SALOF_LOG_TAR (0U)
  35. #endif
  36. #ifndef SALOF_LOG_LEVEL
  37. #define SALOF_LOG_LEVEL SALOF_DEBUG_LEVEL //SALOF_WARN_LEVEL SALOF_DEBUG_LEVEL
  38. #endif
  39. #if SALOF_USING_SALOF
  40. #ifndef SALOF_BUFF_SIZE
  41. #define SALOF_BUFF_SIZE (512U)
  42. #endif
  43. #ifndef SALOF_FIFO_SIZE
  44. #define SALOF_FIFO_SIZE (1024*4U)
  45. #endif
  46. #ifndef SALOF_TASK_STACK_SIZE
  47. #define SALOF_TASK_STACK_SIZE (2048U)
  48. #endif
  49. #ifndef SALOF_TASK_TICK
  50. #define SALOF_TASK_TICK (20U)
  51. #endif
  52. #endif
  53. #if !defined(SALOF_OS)
  54. #error "SALOF_OS isn't defined in 'salof_config.h'"
  55. #endif
  56. #if (SALOF_OS == SALOF_USING_FREERTOS)
  57. #include "FreeRTOS.h"
  58. #include "task.h"
  59. #include "semphr.h"
  60. #define salof_mutex SemaphoreHandle_t
  61. #define salof_tcb TaskHandle_t
  62. #define salof_sem salof_mutex
  63. #if SALOF_USING_IDLE_HOOK
  64. #define salof_handler vApplicationIdleHook
  65. #endif
  66. #define SALOF_TASK_PRIO (0U)
  67. #elif (SALOF_OS == SALOF_USING_TENCENTOS)
  68. #include "tos_k.h"
  69. #define salof_mutex k_mutex_t*
  70. #define salof_sem k_sem_t*
  71. #define salof_tcb k_task_t*
  72. #define SALOF_TASK_PRIO (TOS_CFG_TASK_PRIO_MAX - 2u)
  73. #undef SALOF_USING_IDLE_HOOK
  74. #elif (SALOF_OS == SALOF_USING_RTT)
  75. #include <rtconfig.h>
  76. #include <rtthread.h>
  77. #include <rthw.h>
  78. #include <stdio.h>
  79. #define salof_mutex rt_mutex_t
  80. #define salof_sem rt_sem_t
  81. #define salof_tcb rt_thread_t
  82. #define SALOF_TASK_PRIO (RT_THREAD_PRIORITY_MAX - 1)
  83. #elif (SALOF_OS == SALOF_USING_LINUX)
  84. #include "pthread.h"
  85. #include "memory.h"
  86. #include <semaphore.h>
  87. #include <stdlib.h>
  88. #include <stdio.h>
  89. #define salof_mutex pthread_mutex_t*
  90. #define salof_sem sem_t*
  91. #define salof_tcb pthread_t*
  92. #define SALOF_TASK_PRIO (0U)
  93. #undef SALOF_USING_IDLE_HOOK
  94. #else
  95. #error "not supported OS type"
  96. #endif
  97. void *salof_alloc(unsigned int size);
  98. void salof_free(void *mem);
  99. salof_tcb salof_task_create(const char *name,
  100. void (*task_entry)(void *param),
  101. void * const param,
  102. unsigned int stack_size,
  103. unsigned int priority,
  104. unsigned int tick);
  105. salof_mutex salof_mutex_create(void);
  106. void salof_mutex_delete(salof_mutex mutex);
  107. int salof_mutex_pend(salof_mutex mutex, unsigned int timeout);
  108. int salof_mutex_post(salof_mutex mutex);
  109. salof_sem salof_sem_create(void);
  110. void salof_sem_delete(salof_sem sem);
  111. int salof_sem_pend(salof_sem sem, unsigned int timeout);
  112. int salof_sem_post(salof_sem sem);
  113. unsigned int salof_get_tick(void);
  114. char *salof_get_task_name(void);
  115. extern int send_buff(char *buf, int len);
  116. #endif
  117. #endif // !_SALOF_DEFCONFIG_H_