ui_task.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /**
  2. ******************************************************************************
  3. * @file ui_task.c
  4. * @author Motor Control SDK Team, ST Microelectronics
  5. * @brief This file implementes user interface tasks definition
  6. *
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under Ultimate Liberty license
  14. * SLA0044, the "License"; You may not use this file except in compliance with
  15. * the License. You may obtain a copy of the License at:
  16. * www.st.com/SLA0044
  17. *
  18. ******************************************************************************
  19. */
  20. /* Includes ------------------------------------------------------------------*/
  21. /* Pre-compiler coherency check */
  22. #include "ui_task.h"
  23. #include "mc_config.h"
  24. #include "parameters_conversion.h"
  25. #define OPT_DACX 0x20 /*!<Bit field indicating that the UI uses SPI AD7303 DAC.*/
  26. MCP_Handle_t * pMCP = MC_NULL;
  27. MCP_Handle_t MCP_UI_Params;
  28. static volatile uint16_t bUITaskCounter;
  29. static volatile uint16_t bCOMTimeoutCounter;
  30. static volatile uint16_t bCOMATRTimeCounter = SERIALCOM_ATR_TIME_TICKS;
  31. void UI_TaskInit( uint32_t* pUICfg, uint8_t bMCNum, MCI_Handle_t* pMCIList[],
  32. MCT_Handle_t* pMCTList[],const char* s_fwVer )
  33. {
  34. pMCP = &MCP_UI_Params;
  35. pMCP->_Super = UI_Params;
  36. UFCP_Init( & pUSART );
  37. MCP_Init(pMCP, (FCP_Handle_t *) & pUSART, & UFCP_Send, & UFCP_Receive, & UFCP_AbortReceive, s_fwVer);
  38. UI_Init( &pMCP->_Super, bMCNum, pMCIList, pMCTList, pUICfg ); /* Initialize UI and link MC components */
  39. }
  40. __weak void UI_Scheduler(void)
  41. {
  42. if(bUITaskCounter > 0u)
  43. {
  44. bUITaskCounter--;
  45. }
  46. if(bCOMTimeoutCounter > 1u)
  47. {
  48. bCOMTimeoutCounter--;
  49. }
  50. if(bCOMATRTimeCounter > 1u)
  51. {
  52. bCOMATRTimeCounter--;
  53. }
  54. }
  55. __weak MCP_Handle_t * GetMCP(void)
  56. {
  57. return pMCP;
  58. }
  59. __weak bool UI_IdleTimeHasElapsed(void)
  60. {
  61. bool retVal = false;
  62. if (bUITaskCounter == 0u)
  63. {
  64. retVal = true;
  65. }
  66. return (retVal);
  67. }
  68. __weak void UI_SetIdleTime(uint16_t SysTickCount)
  69. {
  70. bUITaskCounter = SysTickCount;
  71. }
  72. __weak bool UI_SerialCommunicationTimeOutHasElapsed(void)
  73. {
  74. bool retVal = false;
  75. if (bCOMTimeoutCounter == 1u)
  76. {
  77. bCOMTimeoutCounter = 0u;
  78. retVal = true;
  79. }
  80. return (retVal);
  81. }
  82. __weak bool UI_SerialCommunicationATRTimeHasElapsed(void)
  83. {
  84. bool retVal = false;
  85. if (bCOMATRTimeCounter == 1u)
  86. {
  87. bCOMATRTimeCounter = 0u;
  88. retVal = true;
  89. }
  90. return (retVal);
  91. }
  92. __weak void UI_SerialCommunicationTimeOutStop(void)
  93. {
  94. bCOMTimeoutCounter = 0u;
  95. }
  96. __weak void UI_SerialCommunicationTimeOutStart(void)
  97. {
  98. bCOMTimeoutCounter = SERIALCOM_TIMEOUT_OCCURENCE_TICKS;
  99. }
  100. /******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/