This commit is contained in:
sheinz 2016-11-05 21:48:04 +02:00
commit a6ccf90c07
91 changed files with 1494 additions and 242 deletions

View file

@ -84,7 +84,7 @@ static void telnetTask(void *pvParameters)
char buf[80];
snprintf(buf, sizeof(buf), "Uptime %d seconds\r\n",
xTaskGetTickCount()*portTICK_RATE_MS/1000);
xTaskGetTickCount()*portTICK_PERIOD_MS/1000);
netconn_write(client, buf, strlen(buf), NETCONN_COPY);
snprintf(buf, sizeof(buf), "Free heap %d bytes\r\n", (int)xPortGetFreeHeapSize());
netconn_write(client, buf, strlen(buf), NETCONN_COPY);

View file

@ -31,7 +31,7 @@ extern char *ca_cert, *client_endpoint, *client_cert, *client_key;
static int wifi_alive = 0;
static int ssl_reset;
static SSLConnection *ssl_conn;
static xQueueHandle publish_queue;
static QueueHandle_t publish_queue;
static void beat_task(void *pvParameters) {
char msg[16];
@ -39,7 +39,7 @@ static void beat_task(void *pvParameters) {
while (1) {
if (!wifi_alive) {
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
continue;
}
@ -50,7 +50,7 @@ static void beat_task(void *pvParameters) {
printf("Publish queue overflow\r\n");
}
vTaskDelay(10000 / portTICK_RATE_MS);
vTaskDelay(10000 / portTICK_PERIOD_MS);
}
}
@ -142,7 +142,7 @@ static void mqtt_task(void *pvParameters) {
ssl_conn = (SSLConnection *) malloc(sizeof(SSLConnection));
while (1) {
if (!wifi_alive) {
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
continue;
}
@ -191,7 +191,7 @@ static void mqtt_task(void *pvParameters) {
while (wifi_alive && !ssl_reset) {
char msg[64];
while (xQueueReceive(publish_queue, (void *) msg, 0) == pdTRUE) {
portTickType task_tick = xTaskGetTickCount();
TickType_t task_tick = xTaskGetTickCount();
uint32_t free_heap = xPortGetFreeHeapSize();
uint32_t free_stack = uxTaskGetStackHighWaterMark(NULL);
snprintf(msg, sizeof(msg), "%u: free heap %u, free stack %u",
@ -246,7 +246,7 @@ static void wifi_task(void *pvParameters) {
printf("WiFi: connection failed\r\n");
break;
}
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
--retries;
}
@ -256,12 +256,12 @@ static void wifi_task(void *pvParameters) {
printf("WiFi: Connected\n\r");
wifi_alive = 1;
}
vTaskDelay(500 / portTICK_RATE_MS);
vTaskDelay(500 / portTICK_PERIOD_MS);
}
wifi_alive = 0;
printf("WiFi: disconnected\n\r");
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}

View file

@ -133,7 +133,7 @@ int ssl_connect(SSLConnection* conn, const char* host, int port) {
}
handle_error(ret);
vTaskDelay(5000 / portTICK_RATE_MS);
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
mbedtls_ssl_get_record_expansion(&conn->ssl_ctx);

View file

@ -19,9 +19,9 @@ void blinkenTask(void *pvParameters)
gpio_enable(gpio, GPIO_OUTPUT);
while(1) {
gpio_write(gpio, 1);
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
gpio_write(gpio, 0);
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
@ -45,9 +45,9 @@ void blinkenRegisterTask(void *pvParameters)
IOMUX_GPIO2 = IOMUX_GPIO2_FUNC_GPIO | IOMUX_PIN_OUTPUT_ENABLE; /* change this line if you change 'gpio' */
while(1) {
GPIO.OUT_SET = BIT(gpio);
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
GPIO.OUT_CLEAR = BIT(gpio);
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}

View file

@ -26,11 +26,11 @@ typedef struct
} my_event_t;
// Communication Queue
static xQueueHandle mainqueue;
static xTimerHandle timerHandle;
static QueueHandle_t mainqueue;
static TimerHandle_t timerHandle;
// Own BMP180 User Inform Implementation
bool bmp180_i2c_informUser(const xQueueHandle* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure)
bool bmp180_i2c_informUser(const QueueHandle_t* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure)
{
my_event_t ev;
@ -43,7 +43,7 @@ bool bmp180_i2c_informUser(const xQueueHandle* resultQueue, uint8_t cmd, bmp180_
}
// Timer call back
static void bmp180_i2c_timer_cb(xTimerHandle xTimer)
static void bmp180_i2c_timer_cb(TimerHandle_t xTimer)
{
my_event_t ev;
ev.event_type = MY_EVT_TIMER;
@ -55,7 +55,7 @@ static void bmp180_i2c_timer_cb(xTimerHandle xTimer)
void bmp180_task(void *pvParameters)
{
// Received pvParameters is communication queue
xQueueHandle *com_queue = (xQueueHandle *)pvParameters;
QueueHandle_t *com_queue = (QueueHandle_t *)pvParameters;
printf("%s: Started user interface task\n", __FUNCTION__);
@ -116,7 +116,7 @@ void user_init(void)
xTaskCreate(bmp180_task, "bmp180_task", 256, &mainqueue, 2, NULL);
// Create Timer (Trigger a measurement every second)
timerHandle = xTimerCreate("BMP180 Trigger", 1000/portTICK_RATE_MS, pdTRUE, NULL, bmp180_i2c_timer_cb);
timerHandle = xTimerCreate("BMP180 Trigger", 1000/portTICK_PERIOD_MS, pdTRUE, NULL, bmp180_i2c_timer_cb);
if (timerHandle != NULL)
{

View file

@ -31,14 +31,14 @@ static void bmp280_task_forced(void *pvParameters)
while (1) {
while (!bmp280_init(&bmp280_dev, &params)) {
printf("BMP280 initialization failed\n");
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
bool bme280p = bmp280_dev.id == BME280_CHIP_ID;
printf("BMP280: found %s\n", bme280p ? "BME280" : "BMP280");
while(1) {
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
if (!bmp280_force_measurement(&bmp280_dev)) {
printf("Failed initiating measurement\n");
break;
@ -72,14 +72,14 @@ static void bmp280_task_normal(void *pvParameters)
while (1) {
while (!bmp280_init(&bmp280_dev, &params)) {
printf("BMP280 initialization failed\n");
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
bool bme280p = bmp280_dev.id == BME280_CHIP_ID;
printf("BMP280: found %s\n", bme280p ? "BME280" : "BMP280");
while(1) {
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
if (!bmp280_read_float(&bmp280_dev, &temperature, &pressure, &humidity)) {
printf("Temperature/pressure reading failed\n");
break;

View file

@ -34,8 +34,8 @@ void buttonPollTask(void *pvParameters)
{
taskYIELD();
}
printf("Polled for button press at %dms\r\n", xTaskGetTickCount()*portTICK_RATE_MS);
vTaskDelay(200 / portTICK_RATE_MS);
printf("Polled for button press at %dms\r\n", xTaskGetTickCount()*portTICK_PERIOD_MS);
vTaskDelay(200 / portTICK_PERIOD_MS);
}
}
@ -50,14 +50,14 @@ void buttonPollTask(void *pvParameters)
void buttonIntTask(void *pvParameters)
{
printf("Waiting for button press interrupt on gpio %d...\r\n", gpio);
xQueueHandle *tsqueue = (xQueueHandle *)pvParameters;
QueueHandle_t *tsqueue = (QueueHandle_t *)pvParameters;
gpio_set_interrupt(gpio, int_type);
uint32_t last = 0;
while(1) {
uint32_t button_ts;
xQueueReceive(*tsqueue, &button_ts, portMAX_DELAY);
button_ts *= portTICK_RATE_MS;
button_ts *= portTICK_PERIOD_MS;
if(last < button_ts-200) {
printf("Button interrupt fired at %dms\r\n", button_ts);
last = button_ts;
@ -65,7 +65,7 @@ void buttonIntTask(void *pvParameters)
}
}
static xQueueHandle tsqueue;
static QueueHandle_t tsqueue;
void GPIO_HANDLER(void)
{

View file

@ -1,4 +1,4 @@
PROGRAM=dht_sensor
PROGRAM = dht_sensor
EXTRA_COMPONENTS = extras/dht
include ../../common.mk

View file

@ -8,7 +8,7 @@
#include "esp/uart.h"
#include "FreeRTOS.h"
#include "task.h"
#include "dht.h"
#include <dht/dht.h>
#include "esp8266.h"
/* An example using the ubiquitous DHT** humidity sensors
@ -16,6 +16,7 @@
* from a sensor attached to GPIO pin 4.
*/
uint8_t const dht_gpio = 4;
const dht_sensor_type_t sensor_type = DHT_TYPE_DHT22;
void dhtMeasurementTask(void *pvParameters)
{
@ -28,7 +29,7 @@ void dhtMeasurementTask(void *pvParameters)
gpio_set_pullup(dht_gpio, false, false);
while(1) {
if (dht_read_data(dht_gpio, &humidity, &temperature)) {
if (dht_read_data(sensor_type, dht_gpio, &humidity, &temperature)) {
printf("Humidity: %d%% Temp: %dC\n",
humidity / 10,
temperature / 10);
@ -37,7 +38,7 @@ void dhtMeasurementTask(void *pvParameters)
}
// Three second delay...
vTaskDelay(3000 / portTICK_RATE_MS);
vTaskDelay(3000 / portTICK_PERIOD_MS);
}
}

View file

@ -0,0 +1,4 @@
PROGRAM = ds1302_test
EXTRA_COMPONENTS = extras/ds1302
#ESPBAUD = 460800
include ../../common.mk

View file

@ -0,0 +1,48 @@
/*
* Example of using DS1302 RTC driver
*
* Part of esp-open-rtos
* Copyright (C) 2016 Ruslan V. Uss <unclerus@gmail.com>
* Pavel Merzlyakov <merzlyakovpavel@gmail.com>
* BSD Licensed as described in the file LICENSE
*/
#include <esp/uart.h>
#include <espressif/esp_common.h>
#include <ds1302/ds1302.h>
#include <stdio.h>
#define CE_PIN 5
#define IO_PIN 4
#define SCLK_PIN 0
void user_init(void)
{
uart_set_baud(0, 115200);
printf("SDK version:%s\n", sdk_system_get_sdk_version());
struct tm time = {
.tm_year = 2016,
.tm_mon = 9,
.tm_mday = 31,
.tm_hour = 21,
.tm_min = 54,
.tm_sec = 10
};
ds1302_init(CE_PIN, IO_PIN, SCLK_PIN);
ds1302_set_write_protect(false);
ds1302_set_time(&time);
ds1302_start(true);
while (true)
{
ds1302_get_time(&time);
printf("%04d-%02d-%02d %02d:%02d:%02d\n", time.tm_year, time.tm_mon + 1,
time.tm_mday, time.tm_hour, time.tm_min, time.tm_sec);
for (uint32_t i = 0; i < 1000; i++)
sdk_os_delay_us(500);
}
}

View file

@ -14,32 +14,33 @@
#define SCL_PIN 5
#define SDA_PIN 4
void user_init (void)
void user_init(void)
{
uart_set_baud (0, 115200);
printf ("SDK version:%s\n", sdk_system_get_sdk_version ());
uart_set_baud(0, 115200);
printf("SDK version:%s\n", sdk_system_get_sdk_version());
i2c_init (SCL_PIN, SDA_PIN);
ds1307_start (true);
i2c_init(SCL_PIN, SDA_PIN);
ds1307_start(true);
// setup datetime: 2016-10-09 13:50:10
struct tm time = {
.tm_year = 2016,
.tm_mon = 10,
.tm_mon = 9, // 0-based
.tm_mday = 9,
.tm_hour = 13,
.tm_min = 50,
.tm_sec = 10
.tm_min = 50,
.tm_sec = 10
};
ds1307_set_time (&time);
ds1307_set_time(&time);
while (true)
{
ds1307_get_time (&time);
ds1307_get_time(&time);
printf ("%04d-%02d-%02d %02d:%02d:%02d\n", time.tm_year, time.tm_mon, time.tm_mday, time.tm_hour, time.tm_min, time.tm_sec);
printf("%04d-%02d-%02d %02d:%02d:%02d\n", time.tm_year, time.tm_mon + 1,
time.tm_mday, time.tm_hour, time.tm_min, time.tm_sec);
for (uint32_t i = 0; i < 1000; i ++)
sdk_os_delay_us (500);
for (uint32_t i = 0; i < 1000; i++)
sdk_os_delay_us(500);
}
}

View file

@ -88,7 +88,7 @@ void broadcast_temperature(void *pvParameters)
}
netbuf_delete(buf); // De-allocate packet buffer
}
vTaskDelay(1000/portTICK_RATE_MS);
vTaskDelay(1000/portTICK_PERIOD_MS);
}
err = netconn_disconnect(conn);
@ -97,7 +97,7 @@ void broadcast_temperature(void *pvParameters)
err = netconn_delete(conn);
printf("%s : Deleted connection (%s)\n", __FUNCTION__, lwip_strerr(err));
vTaskDelay(1000/portTICK_RATE_MS);
vTaskDelay(1000/portTICK_PERIOD_MS);
}
}

View file

@ -64,7 +64,7 @@ void print_temperature(void *pvParameters) {
// Wait for a little bit between each sample (note that the
// ds18b20_measure_and_read_multi operation already takes at
// least 750ms to run, so this is on top of that delay).
vTaskDelay(LOOP_DELAY_MS / portTICK_RATE_MS);
vTaskDelay(LOOP_DELAY_MS / portTICK_PERIOD_MS);
}
}
}

View file

@ -93,7 +93,7 @@ void timerRegTask(void *pvParameters)
printf("frc2 handler called %d times, last value 0x%08x\r\n", frc2_handler_call_count,
frc2_last_count_val);
vTaskDelay(500 / portTICK_RATE_MS);
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}

View file

@ -229,7 +229,7 @@ void user_init(void)
test_isr();
test_sign_extension();
xTaskHandle taskHandle;
TaskHandle_t taskHandle;
xTaskCreate(test_system_interaction, "interactionTask", 256, &taskHandle, 2, NULL);
}
@ -304,7 +304,7 @@ static void test_system_interaction()
*/
}
uint32_t ticks = xTaskGetTickCount() - start;
printf("Timer interaction test PASSED after %dms.\n", ticks*portTICK_RATE_MS);
printf("Timer interaction test PASSED after %dms.\n", ticks*portTICK_PERIOD_MS);
abort();
}

View file

@ -118,7 +118,7 @@ void rewrite_file_task(void *p)
}
while (false);
vTaskDelay(DELAY_MS / portTICK_RATE_MS);
vTaskDelay(DELAY_MS / portTICK_PERIOD_MS);
}
}

View file

@ -43,7 +43,7 @@ void http_get_task(void *pvParameters)
printf("DNS lookup failed err=%d res=%p\r\n", err, res);
if(res)
freeaddrinfo(res);
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
failures++;
continue;
}
@ -55,7 +55,7 @@ void http_get_task(void *pvParameters)
if(s < 0) {
printf("... Failed to allocate socket.\r\n");
freeaddrinfo(res);
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
failures++;
continue;
}
@ -66,7 +66,7 @@ void http_get_task(void *pvParameters)
close(s);
freeaddrinfo(res);
printf("... socket connect failed.\r\n");
vTaskDelay(4000 / portTICK_RATE_MS);
vTaskDelay(4000 / portTICK_PERIOD_MS);
failures++;
continue;
}
@ -81,7 +81,7 @@ void http_get_task(void *pvParameters)
if (write(s, req, strlen(req)) < 0) {
printf("... socket send failed\r\n");
close(s);
vTaskDelay(4000 / portTICK_RATE_MS);
vTaskDelay(4000 / portTICK_PERIOD_MS);
failures++;
continue;
}
@ -106,7 +106,7 @@ void http_get_task(void *pvParameters)
printf("successes = %d failures = %d\r\n", successes, failures);
for(int countdown = 10; countdown >= 0; countdown--) {
printf("%d... ", countdown);
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
printf("\r\nStarting again!\r\n");
}

View file

@ -181,7 +181,7 @@ void http_get_task(void *pvParameters)
err_t dns_err;
ip_addr_t host_ip;
do {
vTaskDelay(500 / portTICK_RATE_MS);
vTaskDelay(500 / portTICK_PERIOD_MS);
dns_err = netconn_gethostbyname(WEB_SERVER, &host_ip);
} while(dns_err != ERR_OK);
printf("done.\n");
@ -313,7 +313,7 @@ void http_get_task(void *pvParameters)
printf("\n\nsuccesses = %d failures = %d\n", successes, failures);
for(int countdown = successes ? 10 : 5; countdown >= 0; countdown--) {
printf("%d... ", countdown);
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
printf("\nStarting again!\n");
}

View file

@ -57,7 +57,7 @@ static dma_descriptor_t dma_block_list[DMA_QUEUE_SIZE];
static uint8_t dma_buffer[DMA_QUEUE_SIZE][DMA_BUFFER_SIZE];
// Queue of empty DMA blocks
static xQueueHandle dma_queue;
static QueueHandle_t dma_queue;
/**
* Create a circular list of DMA descriptors
@ -183,7 +183,7 @@ void play_task(void *pvParameters)
printf("underrun counter: %d\n", underrun_counter);
vTaskDelay(1000 / portTICK_RATE_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
close(fd);

View file

@ -24,18 +24,18 @@
#define MQTT_USER NULL
#define MQTT_PASS NULL
xSemaphoreHandle wifi_alive;
xQueueHandle publish_queue;
SemaphoreHandle_t wifi_alive;
QueueHandle_t publish_queue;
#define PUB_MSG_LEN 16
static void beat_task(void *pvParameters)
{
portTickType xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = xTaskGetTickCount();
char msg[PUB_MSG_LEN];
int count = 0;
while (1) {
vTaskDelayUntil(&xLastWakeTime, 10000 / portTICK_RATE_MS);
vTaskDelayUntil(&xLastWakeTime, 10000 / portTICK_PERIOD_MS);
printf("beat\r\n");
snprintf(msg, PUB_MSG_LEN, "Beat %d\r\n", count++);
if (xQueueSend(publish_queue, (void *)msg, 0) == pdFALSE) {
@ -190,7 +190,7 @@ static void wifi_task(void *pvParameters)
printf("WiFi: connection failed\r\n");
break;
}
vTaskDelay( 1000 / portTICK_RATE_MS );
vTaskDelay( 1000 / portTICK_PERIOD_MS );
--retries;
}
if (status == STATION_GOT_IP) {
@ -205,7 +205,7 @@ static void wifi_task(void *pvParameters)
}
printf("WiFi: disconnected\n\r");
sdk_wifi_station_disconnect();
vTaskDelay( 1000 / portTICK_RATE_MS );
vTaskDelay( 1000 / portTICK_PERIOD_MS );
}
}

View file

@ -109,10 +109,10 @@ void tftp_client_task(void *pvParameters)
*/
while(1) {
tftpclient_download_and_verify_file1(slot, &conf);
vTaskDelay(5000 / portTICK_RATE_MS);
vTaskDelay(5000 / portTICK_PERIOD_MS);
tftpclient_download_file2(slot);
vTaskDelay(5000 / portTICK_RATE_MS);
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
}

View file

@ -8,7 +8,7 @@
void task1(void *pvParameters)
{
xQueueHandle *queue = (xQueueHandle *)pvParameters;
QueueHandle_t *queue = (QueueHandle_t *)pvParameters;
printf("Hello from task1!\r\n");
uint32_t count = 0;
while(1) {
@ -21,7 +21,7 @@ void task1(void *pvParameters)
void task2(void *pvParameters)
{
printf("Hello from task 2!\r\n");
xQueueHandle *queue = (xQueueHandle *)pvParameters;
QueueHandle_t *queue = (QueueHandle_t *)pvParameters;
while(1) {
uint32_t count;
if(xQueueReceive(*queue, &count, 1000)) {
@ -32,7 +32,7 @@ void task2(void *pvParameters)
}
}
static xQueueHandle mainqueue;
static QueueHandle_t mainqueue;
void user_init(void)
{

View file

@ -27,7 +27,7 @@
#define SNTP_SERVERS "0.pool.ntp.org", "1.pool.ntp.org", \
"2.pool.ntp.org", "3.pool.ntp.org"
#define vTaskDelayMs(ms) vTaskDelay((ms)/portTICK_RATE_MS)
#define vTaskDelayMs(ms) vTaskDelay((ms)/portTICK_PERIOD_MS)
#define UNUSED_ARG(x) (void)x
void sntp_tsk(void *pvParameters)

View file

@ -96,7 +96,7 @@ void test_task(void *pvParameters)
}
while (1) {
vTaskDelay(2000 / portTICK_RATE_MS);
vTaskDelay(2000 / portTICK_PERIOD_MS);
example_write_file();

View file

@ -0,0 +1,3 @@
PROGRAM=SSD1306_Example
EXTRA_COMPONENTS = extras/ssd1306 extras/i2c
include ../../common.mk

View file

@ -0,0 +1,3 @@
# I2C / SSD1306 OLED LCD Example
To run this example connect the SSD1306 OLED LCD and configure SDA/SCL pins in ssd1306_i2c.c file.

View file

@ -0,0 +1,89 @@
#define image_width 128
#define image_height 64
static unsigned char image_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf8, 0xc3, 0xc7, 0x0f, 0x00, 0x1e, 0xfc, 0xf0, 0xe7, 0x30, 0xc0, 0x9f,
0x7f, 0xf0, 0x80, 0x0f, 0x18, 0x30, 0xc4, 0x18, 0x80, 0x61, 0x8c, 0x31,
0xe0, 0x30, 0xc0, 0x38, 0x0c, 0x0c, 0x63, 0x08, 0x18, 0x30, 0xc0, 0x30,
0x80, 0x61, 0x0c, 0x33, 0xe0, 0x31, 0xc0, 0x30, 0x0c, 0x0c, 0x63, 0x00,
0x18, 0xf0, 0xc0, 0x30, 0xc0, 0xc0, 0x0c, 0x33, 0x60, 0x31, 0xc0, 0x30,
0x0c, 0x06, 0xe6, 0x01, 0xf8, 0xe3, 0xc7, 0x30, 0xc0, 0xc0, 0x0c, 0xf3,
0x67, 0x33, 0xc0, 0x38, 0x0c, 0x06, 0xc6, 0x0f, 0x18, 0x80, 0xcf, 0x18,
0xcf, 0xc0, 0x8c, 0x31, 0x60, 0x36, 0xcf, 0x1f, 0x0c, 0x06, 0x06, 0x1f,
0x18, 0x00, 0xce, 0x0f, 0xcf, 0xc0, 0xfc, 0x30, 0x60, 0x36, 0xcf, 0x18,
0x0c, 0x06, 0x06, 0x1c, 0x18, 0x00, 0xcc, 0x00, 0x80, 0x61, 0x0c, 0x30,
0x60, 0x3c, 0xc0, 0x30, 0x0c, 0x0c, 0x03, 0x18, 0x18, 0x10, 0xcc, 0x00,
0x80, 0x61, 0x0c, 0x30, 0x60, 0x38, 0xc0, 0x30, 0x0c, 0x0c, 0x23, 0x18,
0xf8, 0xf3, 0xc3, 0x00, 0x00, 0x1e, 0x0c, 0xf0, 0x67, 0x38, 0xc0, 0x60,
0x0c, 0xf0, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x1f, 0xfc, 0x01, 0x1c, 0xf8, 0x81,
0x0f, 0x78, 0x00, 0x0c, 0x80, 0x1f, 0xfe, 0x00, 0xf0, 0x87, 0x3f, 0xfc,
0x07, 0x1f, 0xfc, 0xc3, 0x1f, 0xfc, 0x00, 0x0c, 0xe0, 0x3f, 0xfe, 0x03,
0x38, 0xc4, 0x21, 0x0c, 0x0e, 0x1b, 0x04, 0xc7, 0x18, 0x8e, 0x00, 0x0c,
0x70, 0x20, 0x06, 0x07, 0x18, 0xc0, 0x00, 0x0c, 0x0c, 0x18, 0x00, 0x66,
0x30, 0x07, 0x00, 0x0c, 0x30, 0x00, 0x06, 0x06, 0x18, 0xc0, 0x00, 0x0c,
0x18, 0x18, 0x00, 0x67, 0x30, 0x03, 0x00, 0x0c, 0x18, 0x00, 0x06, 0x0c,
0xf0, 0x81, 0x0f, 0x0c, 0x18, 0x18, 0xf0, 0x61, 0x30, 0x7b, 0x00, 0x0c,
0x18, 0x00, 0x06, 0x0c, 0xe0, 0x07, 0x3f, 0x0c, 0x18, 0x18, 0xf0, 0x63,
0x30, 0xff, 0x00, 0x0c, 0x18, 0x00, 0x06, 0x0c, 0x00, 0x0e, 0x70, 0x0c,
0x18, 0x18, 0x00, 0x67, 0x30, 0xc7, 0x01, 0x0c, 0x18, 0x00, 0x06, 0x0c,
0x00, 0x0c, 0x60, 0x0c, 0x18, 0x18, 0x00, 0x66, 0x30, 0x83, 0x01, 0x0c,
0x18, 0x00, 0x06, 0x0c, 0x00, 0x0c, 0x60, 0x0c, 0x0c, 0x18, 0x00, 0x66,
0x30, 0x83, 0x01, 0x0c, 0x30, 0x00, 0x06, 0x06, 0x08, 0x4e, 0x70, 0x0c,
0x0e, 0x18, 0x04, 0xc7, 0x18, 0xc6, 0x01, 0x0c, 0x70, 0x20, 0x06, 0x07,
0xf8, 0xc7, 0x3f, 0xfc, 0x07, 0xff, 0xfc, 0xc3, 0x1f, 0xfe, 0x00, 0xfc,
0xe3, 0x3f, 0xfe, 0x03, 0xf0, 0x83, 0x1f, 0xfc, 0x01, 0xff, 0xf8, 0x81,
0x0f, 0x78, 0x00, 0xfc, 0x83, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x18,
0x18, 0x7e, 0xc0, 0xe1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x01, 0x00, 0x00, 0x18, 0x18, 0xfe, 0x80, 0x61, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x18, 0x18, 0xc6, 0x81, 0x33,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3d, 0x06, 0x06, 0x18,
0x18, 0x86, 0x01, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x7f, 0x06, 0x06, 0x18, 0x18, 0x86, 0x01, 0x1e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0xe3, 0x0c, 0x03, 0x18, 0x18, 0xc6, 0x01, 0x0e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc1, 0x0c, 0x03, 0x18,
0x18, 0xfe, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0xc1, 0x98, 0x01, 0x18, 0x18, 0x7e, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0xc1, 0x98, 0x01, 0x18, 0x18, 0xc6, 0x00, 0x1b,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc1, 0xf0, 0x00, 0x18,
0x18, 0x86, 0x81, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0xe3, 0xf0, 0x00, 0x30, 0x0c, 0x86, 0x81, 0x71, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x7f, 0x60, 0x00, 0xf0, 0x0f, 0x06, 0xc3, 0x60,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3d, 0x60, 0x00, 0xc0,
0x03, 0x06, 0xe7, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };

View file

@ -0,0 +1,65 @@
#include "espressif/esp_common.h"
#include "esp/uart.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include <string.h>
#include "i2c/i2c.h"
#include "ssd1306/ssd1306.h"
#include "image.xbm"
/* Change this according to you schematics */
#define SCL_PIN GPIO_ID_PIN((14))
#define SDA_PIN GPIO_ID_PIN((12))
/* Local frame buffer */
static uint8_t buffer[SSD1306_ROWS * SSD1306_COLS / 8];
static void ssd1306_task(void *pvParameters)
{
printf("%s: Started user interface task\n", __FUNCTION__);
vTaskDelay(1000/portTICK_PERIOD_MS);
if (ssd1306_load_xbm(image_bits, buffer))
goto error_loop;
ssd1306_set_whole_display_lighting(false);
while (1) {
vTaskDelay(2000 / portTICK_PERIOD_MS);
printf("%s: steel alive\n", __FUNCTION__);
}
error_loop:
printf("%s: error while loading framebuffer into SSD1306\n", __func__);
for(;;){
vTaskDelay(2000 / portTICK_PERIOD_MS);
printf("%s: error loop\n", __FUNCTION__);
}
}
void user_init(void)
{
// Setup HW
uart_set_baud(0, 115200);
printf("SDK version:%s\n", sdk_system_get_sdk_version());
i2c_init(SCL_PIN, SDA_PIN);
if (ssd1306_init()){
for (;;) {
printf("%s: failed to init SSD1306 lcd\n", __func__);
vTaskDelay(1000/portTICK_PERIOD_MS);
}
}
ssd1306_set_whole_display_lighting(true);
vTaskDelay(1000/portTICK_PERIOD_MS);
// Create user interface task
xTaskCreate(ssd1306_task, "ssd1306_task", 256, NULL, 2, NULL);
}

View file

@ -59,7 +59,7 @@ static void cmd_help(uint32_t argc, char *argv[])
static void cmd_sleep(uint32_t argc, char *argv[])
{
printf("Type away while I take a 2 second nap (ie. let you test the UART HW FIFO\n");
vTaskDelay(2000 / portTICK_RATE_MS);
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
static void handle_command(char *cmd)

View file

@ -56,7 +56,7 @@ void tsl2561MeasurementTask(void *pvParameters)
}
// 0.1 second delay
vTaskDelay(100 / portTICK_RATE_MS);
vTaskDelay(100 / portTICK_PERIOD_MS);
}
}

View file

@ -0,0 +1,4 @@
PROGRAM = wifi_scan
#ESPBAUD = 460800
include ../../common.mk

72
examples/wifi_scan/main.c Normal file
View file

@ -0,0 +1,72 @@
/*
* WiFi scan
*
* Part of esp-open-rtos
* Copyright (C) 2016 Ruslan V. Uss <unclerus@gmail.com>
* BSD Licensed as described in the file LICENSE
*/
#include <esp/uart.h>
#include <stdio.h>
#include <espressif/esp_common.h>
#include <FreeRTOS.h>
#include <task.h>
#include <string.h>
static const char * const auth_modes [] = {
[AUTH_OPEN] = "Open",
[AUTH_WEP] = "WEP",
[AUTH_WPA_PSK] = "WPA/PSK",
[AUTH_WPA2_PSK] = "WPA2/PSK",
[AUTH_WPA_WPA2_PSK] = "WPA/WPA2/PSK"
};
static void scan_done_cb(void *arg, sdk_scan_status_t status)
{
char ssid[33]; // max SSID length + zero byte
if (status != SCAN_OK)
{
printf("Error: WiFi scan failed\n");
return;
}
struct sdk_bss_info *bss = (struct sdk_bss_info *)arg;
// first one is invalid
bss = bss->next.stqe_next;
printf("\n----------------------------------------------------------------------------------\n");
printf(" Wi-Fi networks\n");
printf("----------------------------------------------------------------------------------\n");
while (NULL != bss)
{
size_t len = strlen((const char *)bss->ssid);
memcpy(ssid, bss->ssid, len);
ssid[len] = 0;
printf("%32s (" MACSTR ") RSSI: %02d, security: %s\n", ssid,
MAC2STR(bss->bssid), bss->rssi, auth_modes[bss->authmode]);
bss = bss->next.stqe_next;
}
}
static void scan_task(void *arg)
{
while (true)
{
sdk_wifi_station_scan(NULL, scan_done_cb);
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
}
void user_init()
{
uart_set_baud(0, 115200);
printf("SDK version:%s\n\n", sdk_system_get_sdk_version());
// We can scan only in station mode
sdk_wifi_set_opmode(STATION_MODE);
xTaskCreate(scan_task, "scan", 512, NULL, 2, NULL);
}

View file

@ -70,7 +70,7 @@ static void demo(void *pvParameters)
sizeof(ws2812_pixel_t));
ws2812_i2s_update(pixels);
vTaskDelay(20 / portTICK_RATE_MS);
vTaskDelay(20 / portTICK_PERIOD_MS);
}
}
}

View file

@ -18,7 +18,7 @@
#include "ws2812.h"
#define delay_ms(ms) vTaskDelay((ms) / portTICK_RATE_MS)
#define delay_ms(ms) vTaskDelay((ms) / portTICK_PERIOD_MS)
/** GPIO number used to control the RGBs */