изменила форматирование. Добавила автовыбор ножек в зависимости от выбранной платы
This commit is contained in:
1 parent
78ef98a74d
commit
f3df27f5fc
12 files changed
+261
-268
No files matched your search
@@ -15,45 +15,51 @@
|
||||
*/
|
||||
QueueHandle_t integerQueue;
|
||||
|
||||
void setup() {
|
||||
#ifdef LED_BUILTIN
|
||||
uint8_t blink_pin = LED_BUILTIN;
|
||||
#elif defined(ARDUINO_ELSOMIK)
|
||||
uint8_t blink_pin = P0_0;
|
||||
#else
|
||||
uint8_t blink_pin = 2;
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
/**
|
||||
* Create a queue.
|
||||
* https://www.freertos.org/a00116.html
|
||||
*/
|
||||
integerQueue = xQueueCreate(10, // Queue length
|
||||
integerQueue = xQueueCreate(10, // Queue length
|
||||
sizeof(int) // Queue item size
|
||||
);
|
||||
|
||||
if (integerQueue != NULL) {
|
||||
|
||||
// Create task that consumes the queue if it was created.
|
||||
xTaskCreate(TaskSerial, // Task function
|
||||
"Serial", // A name just for humans
|
||||
128, // This stack size can be checked & adjusted by reading the Stack Highwater
|
||||
xTaskCreate(TaskSerial, // Task function
|
||||
"Serial", // A name just for humans
|
||||
128, // This stack size can be checked & adjusted by reading the Stack Highwater
|
||||
NULL,
|
||||
2, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
|
||||
2, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
|
||||
NULL);
|
||||
|
||||
|
||||
// Create task that publish data in the queue if it was created.
|
||||
xTaskCreate(TaskAnalogRead, // Task function
|
||||
"AnalogRead", // Task name
|
||||
128, // Stack size
|
||||
"AnalogRead", // Task name
|
||||
128, // Stack size
|
||||
NULL,
|
||||
1, // Priority
|
||||
1, // Priority
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
xTaskCreate(TaskBlink, // Task function
|
||||
"Blink", // Task name
|
||||
128, // Stack size
|
||||
xTaskCreate(TaskBlink, // Task function
|
||||
"Blink", // Task name
|
||||
128, // Stack size
|
||||
NULL,
|
||||
0, // Priority
|
||||
0, // Priority
|
||||
NULL );
|
||||
|
||||
}
|
||||
|
||||
void loop() {}
|
||||
@@ -79,7 +85,7 @@ void TaskAnalogRead(void *pvParameters)
|
||||
*/
|
||||
xQueueSend(integerQueue, &sensorValue, portMAX_DELAY);
|
||||
|
||||
// One tick delay (15ms) in between reads for stability
|
||||
// One tick delay (10ms) in between reads for stability
|
||||
vTaskDelay(1);
|
||||
}
|
||||
}
|
||||
@@ -94,11 +100,6 @@ void TaskSerial(void * pvParameters) {
|
||||
// Init Arduino serial
|
||||
Serial.begin(9600);
|
||||
|
||||
// Wait for serial port to connect. Needed for native USB, on LEONARDO, MICRO, YUN, and other 32u4 based boards.
|
||||
while (!Serial) {
|
||||
vTaskDelay(1);
|
||||
}
|
||||
|
||||
int valueFromQueue = 0;
|
||||
|
||||
for (;;)
|
||||
@@ -122,13 +123,13 @@ void TaskBlink(void *pvParameters)
|
||||
{
|
||||
(void) pvParameters;
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
pinMode(blink_pin, OUTPUT);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
digitalWrite(blink_pin, HIGH);
|
||||
vTaskDelay( 250 / portTICK_PERIOD_MS );
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
digitalWrite(blink_pin, LOW);
|
||||
vTaskDelay( 250 / portTICK_PERIOD_MS );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user