main/task_dcf.c

changeset 1
86b275481021
child 2
053649608c09
equal deleted inserted replaced
0:913eb9ca40b1 1:86b275481021
1 /**
2 * @file task_dcf.c
3 * @brief DCF77 task.
4 */
5
6
7 #include "dcf77tx.h"
8
9
10 static const char *TAG = "task_dcf";
11
12
13 SemaphoreHandle_t xSemaphoreDCF = NULL; ///< Semaphore DCF task.
14 EventGroupHandle_t xEventGroupDCF; ///< Events DCF task.
15 DCF_State *dcf_state = NULL; ///< Public state for other tasks.
16
17 #define LED1 CONFIG_LED1_PIN
18 #define LED2 CONFIG_LED2_PIN
19
20
21 const int TASK_DCF_REQUEST_START = BIT0;
22 const int TASK_DCF_REQUEST_STOP = BIT1;
23
24 const int TASK_DCF_RUN = BIT2;
25
26
27 bool ready_DCF(void)
28 {
29 return dcf_state->DCF_running;
30 }
31
32
33
34 void request_DCF(bool run)
35 {
36 }
37
38
39
40 void task_DCF(void *pvParameters)
41 {
42 ESP_LOGI(TAG, "Starting DCF77");
43
44 xEventGroupDCF = xEventGroupCreate();
45 xSemaphoreDCF = xSemaphoreCreateMutex();
46 dcf_state = malloc(sizeof(DCF_State));
47 memset(dcf_state, 0x00, sizeof(DCF_State));
48
49 gpio_reset_pin(LED1);
50 gpio_reset_pin(LED2);
51 gpio_set_direction(LED1, GPIO_MODE_OUTPUT);
52 gpio_set_direction(LED2, GPIO_MODE_OUTPUT);
53
54 xEventGroupClearBits(xEventGroupDCF, TASK_DCF_RUN);
55 EventBits_t uxBits;
56
57 for (;;) {
58 uxBits = xEventGroupWaitBits(xEventGroupDCF, TASK_DCF_REQUEST_START | TASK_DCF_REQUEST_STOP, pdFALSE, pdFALSE, portMAX_DELAY );
59
60 if (uxBits & TASK_DCF_REQUEST_START) {
61 if (dcf_state->DCF_running) {
62 /* Already running */
63 xEventGroupClearBits(xEventGroupDCF, TASK_DCF_REQUEST_START);
64 }
65
66 } else if (uxBits & TASK_DCF_REQUEST_STOP) {
67
68 }
69 } /* for(;;) */
70 }
71
72

mercurial