6
6
7
7
static TaskHandle_t _tone_task = NULL ;
8
8
static QueueHandle_t _tone_queue = NULL ;
9
- static QueueHandle_t _tone_mutex = NULL ;
10
9
static uint8_t _channel = 0 ;
11
10
12
11
typedef enum {
@@ -30,30 +29,29 @@ static void tone_task(void*){
30
29
switch (tone_msg.tone_cmd ){
31
30
case TONE_START:
32
31
log_d (" Task received from queue TONE_START: _pin=%d, frequency=%u Hz, duration=%u ms" , tone_msg.pin , tone_msg.frequency , tone_msg.duration );
33
- if (xSemaphoreTake (_tone_mutex, portMAX_DELAY) != pdTRUE ){
34
- log_e (" Tone mutex take returned with error" );
35
- break ;
36
- }
32
+
37
33
log_d (" Setup LED controll on channel %d" , _channel);
38
- ledcSetup (_channel, tone_msg.frequency , 11 );
34
+ // ledcSetup(_channel, tone_msg.frequency, 11);
35
+ // ledcAttachPin(tone_msg.pin, _channel);
36
+ // ledcWrite(_channel, 1024);
37
+ ledcWriteTone (_channel, tone_msg.frequency );
39
38
ledcAttachPin (tone_msg.pin , _channel);
40
- ledcWrite (_channel, 1024 );
41
- if (xSemaphoreGive (_tone_mutex) != pdTRUE){
42
- log_e (" Tone mutex give returned with error" );
43
- }
44
39
45
40
if (tone_msg.duration ){
46
- vTaskDelay ( pdMS_TO_TICKS ( tone_msg.duration ) );
41
+ delay ( tone_msg.duration );
47
42
ledcDetachPin (tone_msg.pin );
43
+ ledcWriteTone (_channel, 0 );
48
44
}
49
45
break ;
50
46
51
47
case TONE_END:
52
48
log_d (" Task received from queue TONE_END: pin=%d" , tone_msg.pin );
53
49
ledcDetachPin (tone_msg.pin );
50
+ ledcWriteTone (_channel, 0 );
54
51
break ;
55
52
56
53
case TONE_SET_CHANNEL:
54
+ log_d (" Task received from queue TONE_SET_CHANNEL: channel=%d" , tone_msg.channel );
57
55
_channel = tone_msg.channel ;
58
56
break ;
59
57
@@ -63,17 +61,6 @@ static void tone_task(void*){
63
61
}
64
62
65
63
static int tone_init (){
66
- if (_tone_mutex == NULL ){
67
- log_v (" Creating tone mutex" );
68
- _tone_mutex = xSemaphoreCreateMutex ();
69
- if (_tone_mutex == NULL ){
70
- log_e (" Could not create tone mutex" );
71
- return 0 ; // ERR
72
- }
73
- log_v (" Tone mutex created" );
74
- }
75
-
76
-
77
64
if (_tone_queue == NULL ){
78
65
log_v (" Creating tone queue" );
79
66
_tone_queue = xQueueCreate (128 , sizeof (tone_msg_t ));
0 commit comments