ostask.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* ----> DO NOT REMOVE THE FOLLOWING NOTICE <----
  2. Copyright (c) 2014-2017 Datalight, Inc.
  3. All Rights Reserved Worldwide.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; use version 2 of the License.
  7. This program is distributed in the hope that it will be useful,
  8. but "AS-IS," WITHOUT ANY WARRANTY; without even the implied warranty
  9. of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  14. */
  15. /* Businesses and individuals that for commercial or other reasons cannot
  16. comply with the terms of the GPLv2 license may obtain a commercial license
  17. before incorporating Reliance Edge into proprietary software for
  18. distribution in any form. Visit http://www.datalight.com/reliance-edge for
  19. more information.
  20. */
  21. /** @file
  22. @brief Implements task functions.
  23. */
  24. #include "ch.h"
  25. #include "hal.h"
  26. #if (HAL_USE_SDMMC == TRUE)
  27. #include "sama_sdmmc_lld.h"
  28. #if SDMMC_USE_RELEDGE_LIB == 1
  29. #include <redfs.h>
  30. #if (REDCONF_TASK_COUNT > 1U) && (REDCONF_API_POSIX == 1)
  31. #include <redosdeviations.h>
  32. /** @brief Get the current task ID.
  33. This task ID must be unique for all tasks using the file system.
  34. @return The task ID. Must not be 0.
  35. */
  36. uint32_t RedOsTaskId(void)
  37. {
  38. /* Simply casting the xTaskGetCurrentTaskHandle() return value results in
  39. warnings from some compilers, so use variables.
  40. */
  41. thread_t* t= chThdGetSelfX();
  42. uintptr_t taskptr = CAST_TASK_PTR_TO_UINTPTR(t);
  43. uint32_t ulTaskPtr = (uint32_t)taskptr;
  44. /* Assert no information was lost casting from uintptr_t to uint32_t.
  45. */
  46. REDASSERT(ulTaskPtr == taskptr);
  47. /* NULL is a valid task handle in FreeRTOS, so add one to all task IDs.
  48. */
  49. REDASSERT((ulTaskPtr + 1U) != 0U);
  50. return ulTaskPtr + 1U;
  51. }
  52. #endif
  53. #endif
  54. #endif