Advertisement
ottojo

Untitled

Jun 23rd, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.02 KB | None | 0 0
  1. //
  2. // Created by simon on 19.06.2019.
  3. //
  4.  
  5.  
  6. #include "main.h"
  7. #include "cmsis_os.h"
  8. #include "rtc.h"
  9.  
  10. #include "ui.h"
  11. #include "IOprocessing.h"
  12.  
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <spi.h>
  16. #include <dac.h>
  17.  
  18.  
  19. #pragma clang diagnostic push
  20. #pragma clang diagnostic ignored "-Wmissing-noreturn"
  21.  
  22. extern osTimerId RotEncPushTimerHandle;
  23. extern osTimerId RotEncRotTimerHandle;
  24.  
  25. /**
  26. * @brief Function implementing the IOTask thread.
  27. * @param argument: Not used
  28. * @retval None
  29. */
  30. void IOTaskFxn(void const *argument) {
  31.  
  32.     int msToWait = 50;
  33.     xTimerChangePeriod(RotEncPushTimerHandle, pdMS_TO_TICKS(msToWait), portMAX_DELAY);
  34.     xTimerChangePeriod(RotEncRotTimerHandle, pdMS_TO_TICKS(msToWait), portMAX_DELAY);
  35.  
  36.     uint16_t buffer;
  37.     uint16_t action;
  38.     for (;;) {
  39.         if (xQueueReceive(IOQueueHandle, &buffer, portMAX_DELAY)) {
  40.  
  41.             switch (buffer) {
  42.                 case ROT_ENC_ENTER:
  43.                     if (!xTimerIsTimerActive(RotEncPushTimerHandle)) {
  44.                         action = ROT_ENC_ENTER;
  45.                         xQueueSend(UITaskQueueHandle, &action, portMAX_DELAY);
  46.                         xTimerReset(RotEncPushTimerHandle, portMAX_DELAY);
  47.                     }
  48.                     break;
  49.  
  50.                 case ROT_ENC_RIGHT:
  51.                     if (!xTimerIsTimerActive(RotEncRotTimerHandle)) {
  52.                         action = ROT_ENC_RIGHT;
  53.                         xQueueSend(UITaskQueueHandle, &action, portMAX_DELAY);
  54.                         xTimerReset(RotEncRotTimerHandle, portMAX_DELAY);
  55.                     }
  56.                     break;
  57.  
  58.                 case ROT_ENC_LEFT:
  59.                     if (!xTimerIsTimerActive(RotEncRotTimerHandle)) {
  60.                         action = ROT_ENC_LEFT;
  61.                         xQueueSend(UITaskQueueHandle, &action, portMAX_DELAY);
  62.                         xTimerReset(RotEncRotTimerHandle, portMAX_DELAY);
  63.                     }
  64.                     break;
  65.             }
  66.         }
  67.         osDelay(5);
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement