изменила форматирование. Добавила автовыбор ножек в зависимости от выбранной платы
This commit is contained in:
1 parent
78ef98a74d
commit
f3df27f5fc
12 files changed
+261
-268
No files matched your search
@@ -16,14 +16,31 @@
|
||||
*/
|
||||
SemaphoreHandle_t interruptSemaphore;
|
||||
|
||||
void setup() {
|
||||
// set interrupt pin
|
||||
#ifdef BTN_BUILTIN
|
||||
uint8_t int_pin = BTN_BUILTIN;
|
||||
#elif defined(ARDUINO_ELSOMIK)
|
||||
uint8_t int_pin = P0_8;
|
||||
#else
|
||||
uint8_t int_pin = 2;
|
||||
#endif
|
||||
|
||||
// set led pin
|
||||
#ifdef LED_BUILTIN
|
||||
uint8_t blink_pin = LED_BUILTIN;
|
||||
#elif defined(ARDUINO_ELSOMIK)
|
||||
uint8_t blink_pin = P0_0;
|
||||
#else
|
||||
uint8_t blink_pin = 3;
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
// Create task for Arduino led
|
||||
xTaskCreate(TaskLed, // Task function
|
||||
"Led", // Task name
|
||||
128, // Stack size
|
||||
xTaskCreate(TaskLed, // Task function
|
||||
"Led", // Task name
|
||||
128, // Stack size
|
||||
NULL,
|
||||
0, // Priority
|
||||
0, // Priority
|
||||
NULL );
|
||||
|
||||
/**
|
||||
@@ -33,10 +50,8 @@ void setup() {
|
||||
interruptSemaphore = xSemaphoreCreateBinary();
|
||||
if (interruptSemaphore != NULL) {
|
||||
// Attach interrupt for Arduino digital pin
|
||||
attachInterrupt(digitalPinToInterrupt(BTN_BUILTIN), interruptHandler, RISING);
|
||||
}
|
||||
|
||||
|
||||
attachInterrupt(digitalPinToInterrupt(int_pin), interruptHandler, RISING);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {}
|
||||
@@ -59,7 +74,7 @@ void TaskLed(void *pvParameters)
|
||||
{
|
||||
(void) pvParameters;
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
pinMode(blink_pin, OUTPUT);
|
||||
|
||||
for (;;) {
|
||||
|
||||
@@ -68,7 +83,7 @@ void TaskLed(void *pvParameters)
|
||||
* https://www.freertos.org/a00122.html
|
||||
*/
|
||||
if (xSemaphoreTake(interruptSemaphore, portMAX_DELAY) == pdPASS) {
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
digitalWrite(blink_pin, !digitalRead(blink_pin));
|
||||
}
|
||||
vTaskDelay(10);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user