ESP32beta Example Code: Blinky with xTask (FreeRTOS)

User avatar
rudi ;-)
Posts: 1730
Joined: Fri Nov 13, 2015 3:25 pm

ESP32beta Example Code: Blinky with xTask (FreeRTOS)

Postby rudi ;-) » Wed Dec 30, 2015 3:30 pm

Sample code for the ESP31B alias ESP32beta

hi

a simply blinky demo with xTask ( FreeRTOS )
we can mask the gpio too.
but this shows the simple things.
have used simple api:

Code: Select all

GPIO_OUTPUT_SET( gpio_no, bit_value )

for your free using:

Code: Select all


/*
 * user_main.c
 *
 *  Created on: 30.12.2015
 *      Author: rudi ;-)
 *      Free Blinky example by using the xtask in freertos
 *      do not forget to use lib: driver
 *      in makefile for gpio
 *
 */

// change this to your right paths
#include <esp_common.h>
#include <../driver_lib/include/gpio.h>
#include <../freertos/task.h>
#include <../freertos/FreeRTOS.h>

// select your gpio here
// do not use gpio 23 
// there is no gpio 23 :) on esp31b alias esp32beta
const int gpio = 22;

/* task to blink an LED.
 * simple used
 * GPIO_OUTPUT_SET( gpio_no, bit_value )
 * 1s (1000ms) high
 * 3s (3000ms) low
 * if you connect led+ to powersupply+ and led- to the gpiopin 22
 * then led is on if pin is low ( 0 ) and will 3s (3000ms) on, and 1s (1000ms) off
 */
void blinkyTask(void *pvParameters)
{

// ESP32
// GPIO_OUTPUT_SET( gpio_no, bit_value )

	while(1) {
		printf("GPIO:%i goes high\n",gpio);
		GPIO_OUTPUT_SET( gpio, 1 );
		vTaskDelay(1000 / portTICK_RATE_MS);

		printf("GPIO:%i goes low\n", gpio);
		GPIO_OUTPUT_SET( gpio, 0 );
		vTaskDelay(3000 / portTICK_RATE_MS);
    }
}



void user_init(void)
{
	printf("Hi - this is the ESP32beta Blinky Demo using xTask (FreeRTOS)\n");
	xTaskCreate(blinkyTask, (signed char *)"blinkyTask", 256, NULL, 2, NULL);
}


best wishes
rudi ;-)
blinky.png
blinky.png (15.73 KiB) Viewed 13234 times

edit: named topic to "ESP32beta" ( ESP31B ) because we have later ESP32 "release"

edit2: As long as there is no available "Guide" as ESP32 FreeRTOS documentary online and if you're not familiar with FreeRTOS, maybe help in the meantime, the ESP8266. There are good sections enable the easy entry into the ESP32. Then combine it with useful sections of ESP32_RTOS_API_Referenz. Hope this helps for the meantime.

http://bbs.espressif.com/viewtopic.php?f=51&t=822#p1569

@admin
can you create a "code example" extra topic, please?
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

chrisfraser
Posts: 7
Joined: Sun Dec 06, 2015 7:58 pm

Re: ESP32beta Example Code: Blinky with xTask (FreeRTOS)

Postby chrisfraser » Sun Jan 03, 2016 9:50 pm

Nice work Rudi. This helped me get off the ground. Please check the above code as I think you will get errors if gpio is const.

I have packaged a similar thing for Eclipse on Ubuntu. Check out: https://github.com/chrisfraser/esp32_blink

User avatar
rudi ;-)
Posts: 1730
Joined: Fri Nov 13, 2015 3:25 pm

Re: ESP32beta Example Code: Blinky with xTask (FreeRTOS)

Postby rudi ;-) » Wed Jan 06, 2016 10:42 pm

chrisfraser wrote: ..will get errors if gpio is const.
I have packaged a similar thing for Eclipse on Ubuntu. Check out: https://github.com/chrisfraser/esp32_blink
hi chris
you're welcome!
const makes fail ?
have tested just in time with UO ESP32 develop kit eclipse: newbuild, compile and run.
i took const because gpio in this example goes fixed, only value for this then can changed.
normally is ok, but you can comment const and use it without const. perhabs my config is not right.

Code: Select all

..
// select your gpio here
// gpio do not use gpio 23 there is no gpio 23 :) on esp31b alias esp32beta
// const make errors noted online
// by chrisfraser » Sun Jan 03, 2016 10:50 pm 
// rudi to do: check it again whats wrong

// const
int gpio = 22;
..

but will check again
txs!

best wishes
rudi ;-)

btw:
have a try in this Fast TCP Webserver Example (Arduino APK on Flash too ) and let me know, what you think. you can use "AES256" too, example:
sign user / firmware "online" by user code and you can release by user code parts of Webframes ect..( protection )
in combine with Android Devices a nice dream :), will upload next time more.
if you need Webframe src, pm me, because src is trival at time ( without docu in all ), i do not spread everywhere online, and must clean before.
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

Who is online

Users browsing this forum: No registered users and 84 guests