изменила форматирование. Добавила автовыбор ножек в зависимости от выбранной платы
This commit is contained in:
1 parent
78ef98a74d
commit
f3df27f5fc
12 files changed
+261
-268
No files matched your search
@@ -12,6 +12,14 @@
|
||||
// Define a Array
|
||||
int pinReadArray[4]={0,0,0,0};
|
||||
|
||||
#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
|
||||
|
||||
//Function Declaration
|
||||
void TaskBlink(void *pvParameters);
|
||||
void TaskAnalogReadPin0(void *pvParameters);
|
||||
@@ -30,40 +38,39 @@ void setup() {
|
||||
* Create a queue.
|
||||
* https://www.freertos.org/a00116.html
|
||||
*/
|
||||
arrayQueue=xQueueCreate(10, //Queue length
|
||||
sizeof(int)); //Queue item size
|
||||
arrayQueue=xQueueCreate(10, // Queue length
|
||||
sizeof(int)); // Queue item size
|
||||
if(arrayQueue!=NULL){
|
||||
|
||||
// Create task that consumes the queue if it was created.
|
||||
xTaskCreate(TaskSerial,// Task function
|
||||
"PrintSerial",// Task name
|
||||
128,// Stack size
|
||||
xTaskCreate(TaskSerial, // Task function
|
||||
"PrintSerial", // Task name
|
||||
128, // Stack size
|
||||
NULL,
|
||||
2,// Priority
|
||||
2, // Priority
|
||||
NULL);
|
||||
|
||||
// Create task that publish data in the queue if it was created.
|
||||
xTaskCreate(TaskAnalogReadPin0, // Task function
|
||||
"AnalogRead1",// Task name
|
||||
128,// Stack size
|
||||
"AnalogRead1", // Task name
|
||||
128, // Stack size
|
||||
NULL,
|
||||
1,// Priority
|
||||
1, // Priority
|
||||
NULL);
|
||||
|
||||
// Create other task that publish data in the queue if it was created.
|
||||
xTaskCreate(TaskAnalogReadPin1,// Task function
|
||||
"AnalogRead2",// Task name
|
||||
128,// Stack size
|
||||
xTaskCreate(TaskAnalogReadPin1, // Task function
|
||||
"AnalogRead2", // 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);
|
||||
|
||||
}
|
||||
@@ -86,7 +93,7 @@ void TaskAnalogReadPin0(void *pvParameters){
|
||||
* https://www.freertos.org/a00117.html
|
||||
*/
|
||||
xQueueSend(arrayQueue,&pinReadArray,portMAX_DELAY);
|
||||
// One tick delay (15ms) in between reads for stability
|
||||
// One tick delay (10ms) in between reads for stability
|
||||
vTaskDelay(1);
|
||||
}
|
||||
}
|
||||
@@ -106,7 +113,7 @@ void TaskAnalogReadPin1(void *pvParameters){
|
||||
* https://www.freertos.org/a00117.html
|
||||
*/
|
||||
xQueueSend(arrayQueue,&pinReadArray,portMAX_DELAY);
|
||||
// One tick delay (15ms) in between reads for stability
|
||||
// One tick delay (10ms) in between reads for stability
|
||||
vTaskDelay(1);
|
||||
}
|
||||
}
|
||||
@@ -122,11 +129,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);
|
||||
}
|
||||
|
||||
for (;;){
|
||||
if(xQueueReceive(arrayQueue,&pinReadArray,portMAX_DELAY) == pdPASS ){
|
||||
@@ -149,12 +151,12 @@ void TaskSerial(void *pvParameters){
|
||||
*/
|
||||
void TaskBlink(void *pvParameters){
|
||||
(void) pvParameters;
|
||||
pinMode(LED_BUILTIN,OUTPUT);
|
||||
digitalWrite(LED_BUILTIN,LOW);
|
||||
pinMode(blink_pin,OUTPUT);
|
||||
digitalWrite(blink_pin,LOW);
|
||||
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