Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
过眠
arduino-esp32
提交
77810471
A
arduino-esp32
项目概览
过眠
/
arduino-esp32
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
arduino-esp32
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
77810471
编写于
12月 16, 2018
作者:
M
me-no-dev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move Example to proper folder
上级
be081ac0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
97 addition
and
97 deletion
+97
-97
libraries/ESP32/examples/FreeRTOS/FreeRTOS.ino
libraries/ESP32/examples/FreeRTOS/FreeRTOS.ino
+97
-97
未找到文件。
libraries/FreeRTOS/FreeRTOS.ino
→
libraries/
ESP32/examples/
FreeRTOS/FreeRTOS.ino
浏览文件 @
77810471
#if CONFIG_FREERTOS_UNICORE
#define ARDUINO_RUNNING_CORE 0
#else
#define ARDUINO_RUNNING_CORE 1
#endif
#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif
// define two tasks for Blink & AnalogRead
void
TaskBlink
(
void
*
pvParameters
);
void
TaskAnalogReadA3
(
void
*
pvParameters
);
// the setup function runs once when you press reset or power the board
void
setup
()
{
// initialize serial communication at 115200 bits per second:
Serial
.
begin
(
115200
);
// Now set up two tasks to run independently.
xTaskCreatePinnedToCore
(
TaskBlink
,
"TaskBlink"
// A name just for humans
,
1024
// 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.
,
NULL
,
ARDUINO_RUNNING_CORE
);
xTaskCreatePinnedToCore
(
TaskAnalogReadA3
,
"AnalogReadA3"
,
1024
// Stack size
,
NULL
,
1
// Priority
,
NULL
,
ARDUINO_RUNNING_CORE
);
// Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started.
}
void
loop
()
{
// Empty. Things are done in Tasks.
}
/*--------------------------------------------------*/
/*---------------------- Tasks ---------------------*/
/*--------------------------------------------------*/
void
TaskBlink
(
void
*
pvParameters
)
// This is a task.
{
(
void
)
pvParameters
;
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
If you want to know what pin the on-board LED is connected to on your ESP32 model, check
the Technical Specs of your board.
*/
// initialize digital LED_BUILTIN on pin 13 as an output.
pinMode
(
LED_BUILTIN
,
OUTPUT
);
for
(;;)
// A Task shall never return or exit.
{
digitalWrite
(
LED_BUILTIN
,
HIGH
);
// turn the LED on (HIGH is the voltage level)
vTaskDelay
(
100
);
// one tick delay (15ms) in between reads for stability
digitalWrite
(
LED_BUILTIN
,
LOW
);
// turn the LED off by making the voltage LOW
vTaskDelay
(
100
);
// one tick delay (15ms) in between reads for stability
}
}
void
TaskAnalogReadA3
(
void
*
pvParameters
)
// This is a task.
{
(
void
)
pvParameters
;
/*
AnalogReadSerial
Reads an analog input on pin A3, prints the result to the serial monitor.
Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
Attach the center pin of a potentiometer to pin A3, and the outside pins to +5V and ground.
This example code is in the public domain.
*/
for
(;;)
{
// read the input on analog pin A3:
int
sensorValueA3
=
analogRead
(
A3
);
// print out the value you read:
Serial
.
println
(
sensorValueA3
);
vTaskDelay
(
10
);
// one tick delay (15ms) in between reads for stability
}
}
#if CONFIG_FREERTOS_UNICORE
#define ARDUINO_RUNNING_CORE 0
#else
#define ARDUINO_RUNNING_CORE 1
#endif
#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif
// define two tasks for Blink & AnalogRead
void
TaskBlink
(
void
*
pvParameters
);
void
TaskAnalogReadA3
(
void
*
pvParameters
);
// the setup function runs once when you press reset or power the board
void
setup
()
{
// initialize serial communication at 115200 bits per second:
Serial
.
begin
(
115200
);
// Now set up two tasks to run independently.
xTaskCreatePinnedToCore
(
TaskBlink
,
"TaskBlink"
// A name just for humans
,
1024
// 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.
,
NULL
,
ARDUINO_RUNNING_CORE
);
xTaskCreatePinnedToCore
(
TaskAnalogReadA3
,
"AnalogReadA3"
,
1024
// Stack size
,
NULL
,
1
// Priority
,
NULL
,
ARDUINO_RUNNING_CORE
);
// Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started.
}
void
loop
()
{
// Empty. Things are done in Tasks.
}
/*--------------------------------------------------*/
/*---------------------- Tasks ---------------------*/
/*--------------------------------------------------*/
void
TaskBlink
(
void
*
pvParameters
)
// This is a task.
{
(
void
)
pvParameters
;
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
If you want to know what pin the on-board LED is connected to on your ESP32 model, check
the Technical Specs of your board.
*/
// initialize digital LED_BUILTIN on pin 13 as an output.
pinMode
(
LED_BUILTIN
,
OUTPUT
);
for
(;;)
// A Task shall never return or exit.
{
digitalWrite
(
LED_BUILTIN
,
HIGH
);
// turn the LED on (HIGH is the voltage level)
vTaskDelay
(
100
);
// one tick delay (15ms) in between reads for stability
digitalWrite
(
LED_BUILTIN
,
LOW
);
// turn the LED off by making the voltage LOW
vTaskDelay
(
100
);
// one tick delay (15ms) in between reads for stability
}
}
void
TaskAnalogReadA3
(
void
*
pvParameters
)
// This is a task.
{
(
void
)
pvParameters
;
/*
AnalogReadSerial
Reads an analog input on pin A3, prints the result to the serial monitor.
Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
Attach the center pin of a potentiometer to pin A3, and the outside pins to +5V and ground.
This example code is in the public domain.
*/
for
(;;)
{
// read the input on analog pin A3:
int
sensorValueA3
=
analogRead
(
A3
);
// print out the value you read:
Serial
.
println
(
sensorValueA3
);
vTaskDelay
(
10
);
// one tick delay (15ms) in between reads for stability
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录