File hello_world/main/hello_world_main.c copied from file blink/main/blink.c (similarity 60%) (mode: 100644) (index 2f805b9..61f2c19) |
1 |
|
/* Blink Example |
|
|
1 |
|
/* Hello World Example |
2 |
2 |
|
|
3 |
3 |
This example code is in the Public Domain (or CC0 licensed, at your option.) |
This example code is in the Public Domain (or CC0 licensed, at your option.) |
4 |
4 |
|
|
5 |
5 |
Unless required by applicable law or agreed to in writing, this |
Unless required by applicable law or agreed to in writing, this |
6 |
6 |
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
7 |
7 |
CONDITIONS OF ANY KIND, either express or implied. |
CONDITIONS OF ANY KIND, either express or implied. |
8 |
|
|
|
9 |
|
Three LED GPIOs: 5, 18, 19 |
|
10 |
8 |
*/ |
*/ |
11 |
|
|
|
12 |
9 |
#include <stdio.h> |
#include <stdio.h> |
13 |
10 |
#include "freertos/FreeRTOS.h" |
#include "freertos/FreeRTOS.h" |
14 |
11 |
#include "freertos/task.h" |
#include "freertos/task.h" |
15 |
|
#include "driver/gpio.h" |
|
16 |
|
#include "sdkconfig.h" |
|
17 |
|
|
|
18 |
|
/* Can run 'make menuconfig' to choose the GPIO to blink, |
|
19 |
|
or you can edit the following line and set a number here. |
|
20 |
|
*/ |
|
21 |
|
#define BLINK_GPIO CONFIG_BLINK_GPIO |
|
|
12 |
|
#include "esp_system.h" |
|
13 |
|
#include "esp_spi_flash.h" |
22 |
14 |
|
|
23 |
15 |
const uint8_t LED_B_GPIO = 5; |
const uint8_t LED_B_GPIO = 5; |
24 |
16 |
const uint8_t LED_G_GPIO = 18; |
const uint8_t LED_G_GPIO = 18; |
|
... |
... |
void blink_task(void *pvParameter) |
49 |
41 |
|
|
50 |
42 |
void app_main() |
void app_main() |
51 |
43 |
{ |
{ |
52 |
|
xTaskCreate(&blink_task, "blink_task_blue", |
|
53 |
|
configMINIMAL_STACK_SIZE, (void*)LED_B_GPIO, tskIDLE_PRIORITY+1, NULL); |
|
|
44 |
|
printf("Hello world!\n"); |
|
45 |
|
|
|
46 |
|
/* Print chip information */ |
|
47 |
|
esp_chip_info_t chip_info; |
|
48 |
|
esp_chip_info(&chip_info); |
|
49 |
|
printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ", |
|
50 |
|
chip_info.cores, |
|
51 |
|
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", |
|
52 |
|
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); |
|
53 |
|
|
|
54 |
|
printf("silicon revision %d, ", chip_info.revision); |
|
55 |
|
|
|
56 |
|
printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024), |
|
57 |
|
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); |
|
58 |
|
|
54 |
59 |
xTaskCreate(&blink_task, "blink_task_green", |
xTaskCreate(&blink_task, "blink_task_green", |
55 |
|
configMINIMAL_STACK_SIZE, (void*)LED_G_GPIO, tskIDLE_PRIORITY+1, NULL); |
|
56 |
|
xTaskCreate(&blink_task, "blink_task_red", |
|
57 |
|
configMINIMAL_STACK_SIZE, (void*)LED_R_GPIO, tskIDLE_PRIORITY+1, NULL); |
|
|
60 |
|
configMINIMAL_STACK_SIZE, (void*)LED_G_GPIO, tskIDLE_PRIORITY+1, NULL); |
|
61 |
|
// for (int i = 10; i >= 0; i--) { |
|
62 |
|
// printf("Restarting in %d seconds...\n", i); |
|
63 |
|
// vTaskDelay(1000 / portTICK_PERIOD_MS); |
|
64 |
|
// } |
|
65 |
|
// printf("Restarting now.\n"); |
|
66 |
|
// fflush(stdout); |
|
67 |
|
// esp_restart(); |
58 |
68 |
} |
} |
|
69 |
|
|