Merge branch 'master' into experiments/unaligned_load

This commit is contained in:
Angus Gratton 2015-09-10 08:19:42 +10:00
commit a5266adb48
59 changed files with 2478 additions and 858 deletions

View file

@ -1,28 +1,31 @@
EXAMPLES = $(shell find $(dir $(lastword $(MAKEFILE_LIST))) -mindepth 2 -name Makefile | sed s/Makefile//g)
# Generate some dummy .dummybuild/.dummyrebuild target files
EXAMPLES_BUILD = $(patsubst %,%.dummybuild,$(EXAMPLES))
EXAMPLES_REBUILD = $(patsubst %,%.dummyrebuild,$(EXAMPLES))
warning:
@echo "******************************************************"
@echo "You may not want this Makefile, even though it's here!"
@echo "******************************************************"
@echo ""
@echo "SUGGESTIONS:"
@echo "Running 'make' in one of the subdirectories will build a single example."
@echo "Running 'make help' in one of the subdirectories will print some help."
@echo "Running 'make' in one of the subdirectories of examples/ will build a single example."
@echo "Running 'make help' in one of the subdirectories of examples/ will print some help."
@echo ""
@echo "OTHERWISE:"
@echo "This makefile is for building all of the examples at once, as a developer test."
@echo "To use it, run 'make build-examples' or 'make rebuild-examples'"
@echo
build-examples:
set -e
for example in `find . -mindepth 2 -name Makefile | sed s/Makefile//)`; do
$(MAKE) -C $$example
done
build-examples: $(EXAMPLES_BUILD)
rebuild-examples:
set -e
for example in `find . -mindepth 2 -name Makefile | sed s/Makefile//)`; do
$(MAKE) -C $$example rebuild
done
rebuild-examples: $(EXAMPLES_REBUILD)
%.dummybuild:
make -C $(dir $@)
%.dummyrebuild:
make -C $(dir $@) rebuild
.PHONY: warning rebuild-examples build-examples
.NOTPARALLEL:

View file

@ -30,8 +30,8 @@ void blinkenTask(void *pvParameters)
/* This task uses all raw register operations to set the pins.
It's not fully parameterised, as the IOMUX_SET macro requires the pin number
as part of the GPxx value.
It's not fully parameterised, as the IOMUX_GPIO# macros involve a non-linear
mapping from GPIO to IOMUX ports.
There is no significant performance benefit to this way over the
blinkenTask version, so it's probably better to use the blinkenTask
@ -41,12 +41,12 @@ void blinkenTask(void *pvParameters)
*/
void blinkenRegisterTask(void *pvParameters)
{
GPIO_DIR_SET = BIT(gpio);
IOMUX_SET(GP14,GPIO,IOMUX_OE); /* change this line if you change 'gpio' */
GPIO.ENABLE_OUT_SET = BIT(gpio);
IOMUX_GPIO14 = IOMUX_GPIO14_FUNC_GPIO | IOMUX_PIN_OUTPUT_ENABLE; /* change this line if you change 'gpio' */
while(1) {
GPIO_OUT_SET = BIT(gpio);
GPIO.OUT_SET = BIT(gpio);
vTaskDelay(1000 / portTICK_RATE_MS);
GPIO_OUT_CLEAR = BIT(gpio);
GPIO.OUT_CLEAR = BIT(gpio);
vTaskDelay(1000 / portTICK_RATE_MS);
}
}

View file

@ -26,7 +26,7 @@ void frc1_interrupt_handler(void)
void frc2_interrupt_handler(void)
{
/* FRC2 needs the match register updated on each timer interrupt */
timer_set_frequency(TIMER_FRC2, freq_frc2);
timer_set_frequency(FRC2, freq_frc2);
frc2_count++;
gpio_toggle(gpio_frc2);
}
@ -41,24 +41,24 @@ void user_init(void)
gpio_write(gpio_frc1, 1);
/* stop both timers and mask their interrupts as a precaution */
timer_set_interrupts(TIMER_FRC1, false);
timer_set_run(TIMER_FRC1, false);
timer_set_interrupts(TIMER_FRC2, false);
timer_set_run(TIMER_FRC2, false);
timer_set_interrupts(FRC1, false);
timer_set_run(FRC1, false);
timer_set_interrupts(FRC2, false);
timer_set_run(FRC2, false);
/* set up ISRs */
_xt_isr_attach(INUM_TIMER_FRC1, frc1_interrupt_handler);
_xt_isr_attach(INUM_TIMER_FRC2, frc2_interrupt_handler);
/* configure timer frequencies */
timer_set_frequency(TIMER_FRC1, freq_frc1);
timer_set_frequency(TIMER_FRC2, freq_frc2);
timer_set_frequency(FRC1, freq_frc1);
timer_set_frequency(FRC2, freq_frc2);
/* unmask interrupts and start timers */
timer_set_interrupts(TIMER_FRC1, true);
timer_set_run(TIMER_FRC1, true);
timer_set_interrupts(TIMER_FRC2, true);
timer_set_run(TIMER_FRC2, true);
timer_set_interrupts(FRC1, true);
timer_set_run(FRC1, true);
timer_set_interrupts(FRC2, true);
timer_set_run(FRC2, true);
gpio_write(gpio_frc1, 0);
}

View file

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

View file

@ -0,0 +1,7 @@
# I2C / BMP180 Example
This example references two addtional drivers [i2c](https://github.com/kanflo/esp-open-rtos-driver-i2c) and [bmp180](https://github.com/Angus71/esp-open-rtos-driver-bmp180), which are provided in the `../../extras` folder.
If you plan to use one or both of this drivers in your own projects, please check the main development pages for updated versions or reported issues.
To run this example connect the BMP085/BMP180 SCL to GPIO0 and SDA to GPIO2.

View file

@ -0,0 +1,132 @@
/* Simple example for I2C / BMP180 / Timer & Event Handling
*
* This sample code is in the public domain.
*/
#include "espressif/esp_common.h"
#include "espressif/sdk_private.h"
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "queue.h"
// BMP180 driver
#include "bmp180/bmp180.h"
#define MY_EVT_TIMER 0x01
#define MY_EVT_BMP180 0x02
#define SCL_PIN GPIO_ID_PIN((0))
#define SDA_PIN GPIO_ID_PIN((2))
typedef struct
{
uint8_t event_type;
bmp180_result_t bmp180_data;
} my_event_t;
// Communication Queue
static xQueueHandle mainqueue;
static xTimerHandle timerHandle;
// Own BMP180 User Inform Implementation
bool bmp180_i2c_informUser(const xQueueHandle* resultQueue, uint8_t cmd, bmp180_temp_t temperatue, bmp180_press_t pressure)
{
my_event_t ev;
ev.event_type = MY_EVT_BMP180;
ev.bmp180_data.cmd = cmd;
ev.bmp180_data.temperatue = temperatue;
ev.bmp180_data.pressure = pressure;
return (xQueueSend(*resultQueue, &ev, 0) == pdTRUE);
}
// Timer call back
static void bmp180_i2c_timer_cb(xTimerHandle xTimer)
{
my_event_t ev;
ev.event_type = MY_EVT_TIMER;
xQueueSend(mainqueue, &ev, 0);
}
// Check for communiction events
void bmp180_task(void *pvParameters)
{
// Received pvParameters is communication queue
xQueueHandle *com_queue = (xQueueHandle *)pvParameters;
printf("%s: Started user interface task\n", __FUNCTION__);
while(1)
{
my_event_t ev;
xQueueReceive(*com_queue, &ev, portMAX_DELAY);
switch(ev.event_type)
{
case MY_EVT_TIMER:
printf("%s: Received Timer Event\n", __FUNCTION__);
bmp180_trigger_measurement(com_queue);
break;
case MY_EVT_BMP180:
printf("%s: Received BMP180 Event temp:=%d.%d°C press=%d.%02dhPa\n", __FUNCTION__, \
(int32_t)ev.bmp180_data.temperatue, abs((int32_t)(ev.bmp180_data.temperatue*10)%10), \
ev.bmp180_data.pressure/100, ev.bmp180_data.pressure%100 );
break;
default:
break;
}
}
}
// Setup HW
void user_setup(void)
{
// Set UART Parameter
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
// Give the UART some time to settle
sdk_os_delay_us(500);
}
void user_init(void)
{
// Setup HW
user_setup();
// Just some infomations
printf("\n");
printf("SDK version : %s\n", sdk_system_get_sdk_version());
printf("GIT version : %s\n", GITSHORTREV);
// Use our user inform implementation
bmp180_informUser = bmp180_i2c_informUser;
// Init BMP180 Interface
bmp180_init(SCL_PIN, SDA_PIN);
// Create Main Communication Queue
mainqueue = xQueueCreate(10, sizeof(my_event_t));
// Create user interface task
xTaskCreate(bmp180_task, (signed char *)"bmp180_task", 256, &mainqueue, 2, NULL);
// Create Timer (Trigger a measurement every second)
timerHandle = xTimerCreate((signed char *)"BMP180 Trigger", 1000/portTICK_RATE_MS, pdTRUE, NULL, bmp180_i2c_timer_cb);
if (timerHandle != NULL)
{
if (xTimerStart(timerHandle, 0) != pdPASS)
{
printf("%s: Unable to start Timer ...\n", __FUNCTION__);
}
}
else
{
printf("%s: Unable to create Timer ...\n", __FUNCTION__);
}
}

View file

@ -15,7 +15,7 @@
/* pin config */
const int gpio = 0; /* gpio 0 usually has "PROGRAM" button attached */
const int active = 0; /* active == 0 for active low */
const gpio_interrupt_t int_type = INT_FALLING;
const gpio_inttype_t int_type = GPIO_INTTYPE_EDGE_NEG;
#define GPIO_HANDLER gpio00_interrupt_handler

View file

@ -11,14 +11,15 @@
#include "FreeRTOS.h"
#include "task.h"
#include "esp8266.h"
#include "common_macros.h"
#define DUMP_SZ 0x10 /* number of regs not size of buffer */
IRAM void dump_frc1_seq(void)
{
uint32_t f1_a = TIMER_FRC1_COUNT_REG;
uint32_t f1_b = TIMER_FRC1_COUNT_REG;
uint32_t f1_c = TIMER_FRC1_COUNT_REG;
uint32_t f1_a = TIMER(0).COUNT;
uint32_t f1_b = TIMER(0).COUNT;
uint32_t f1_c = TIMER(0).COUNT;
printf("FRC1 sequence 0x%08x 0x%08x 0x%08x\r\n", f1_a, f1_b, f1_c);
printf("FRC1 deltas %d %d \r\n", f1_b-f1_a, f1_c-f1_b);
}
@ -33,9 +34,9 @@ IRAM void dump_frc2_seq(void)
* /16 = 0 or 1 (usually 1)
*
*/
uint32_t f2_a = TIMER_FRC2_COUNT_REG;
uint32_t f2_b = TIMER_FRC2_COUNT_REG;
uint32_t f2_c = TIMER_FRC2_COUNT_REG;
uint32_t f2_a = TIMER(1).COUNT;
uint32_t f2_b = TIMER(1).COUNT;
uint32_t f2_c = TIMER(1).COUNT;
printf("FRC2 sequence 0x%08x 0x%08x 0x%08x\r\n", f2_a, f2_b, f2_c);
printf("FRC2 deltas %d %d \r\n", f2_b-f2_a, f2_c-f2_b);
}
@ -99,20 +100,20 @@ void timerRegTask(void *pvParameters)
IRAM void frc1_handler(void)
{
frc1_handler_call_count++;
frc1_last_count_val = TIMER_FRC1_COUNT_REG;
//TIMER_FRC1_LOAD_REG = 0x300000;
//TIMER_FRC1_CLEAR_INT = 0;
frc1_last_count_val = TIMER(0).COUNT;
//TIMER(0).LOAD = 0x300000;
//TIMER(0).STATUS = 0;
//TIMER_FRC1_MATCH_REG = frc1_last_count_val + 0x100000;
}
void frc2_handler(void)
{
frc2_handler_call_count++;
frc2_last_count_val = TIMER_FRC2_COUNT_REG;
TIMER_FRC2_MATCH_REG = frc2_last_count_val + 0x100000;
//TIMER_FRC2_LOAD_REG = 0;
//TIMER_FRC2_LOAD_REG = 0x2000000;
//TIMER_FRC2_CLEAR_INT_REG = 0;
frc2_last_count_val = TIMER(1).COUNT;
TIMER(1).ALARM = frc2_last_count_val + 0x100000;
//TIMER(1).LOAD = 0;
//TIMER(1).LOAD = 0x2000000;
//TIMER(1).STATUS = 0;
}
void user_init(void)
@ -120,19 +121,19 @@ void user_init(void)
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
xTaskCreate(timerRegTask, (signed char *)"timerRegTask", 1024, NULL, 2, NULL);
TIMER_FRC1_CTRL_REG = TIMER_CTRL_DIV_256|TIMER_CTRL_INT_EDGE|TIMER_CTRL_RELOAD;
TIMER_FRC1_LOAD_REG = 0x200000;
TIMER(0).CTRL = VAL2FIELD(TIMER_CTRL_CLKDIV, TIMER_CLKDIV_256) | TIMER_CTRL_RELOAD;
TIMER(0).LOAD = 0x200000;
TIMER_FRC2_CTRL_REG = TIMER_CTRL_DIV_256|TIMER_CTRL_INT_EDGE;
TIMER(1).LOAD = VAL2FIELD(TIMER_CTRL_CLKDIV, TIMER_CLKDIV_256);
DP_INT_ENABLE_REG |= INT_ENABLE_FRC1|INT_ENABLE_FRC2;
DPORT.INT_ENABLE |= DPORT_INT_ENABLE_TIMER0 | DPORT_INT_ENABLE_TIMER1;
_xt_isr_attach(INUM_TIMER_FRC1, frc1_handler);
_xt_isr_unmask(1<<INUM_TIMER_FRC1);
_xt_isr_attach(INUM_TIMER_FRC2, frc2_handler);
_xt_isr_unmask(1<<INUM_TIMER_FRC2);
TIMER_FRC1_CTRL_REG |= TIMER_CTRL_RUN;
TIMER_FRC2_CTRL_REG |= TIMER_CTRL_RUN;
TIMER(0).CTRL |= TIMER_CTRL_RUN;
TIMER(1).CTRL |= TIMER_CTRL_RUN;
dump_timer_regs("timer regs during user_init");
dump_timer_regs("#2 timer regs during user_init");

View file

@ -18,14 +18,12 @@
#include "lwip/netdb.h"
#include "lwip/dns.h"
#include "ssid_config.h"
#define WEB_SERVER "chainxor.org"
#define WEB_PORT 80
#define WEB_URL "http://chainxor.org/"
#if !defined(WIFI_SSID) || !defined(WIFI_PASS)
#error "Please define macros WIFI_SSID & WIFI_PASS (here, or better in a local.h file at root level or in program dir."
#endif
void http_get_task(void *pvParameters)
{
int successes = 0, failures = 0;

View file

@ -22,14 +22,12 @@
#include "ssl.h"
#include "ssid_config.h"
#define WEB_SERVER "192.168.0.18"
#define WEB_PORT "8000"
#define WEB_URL "/test"
#if !defined(WIFI_SSID) || !defined(WIFI_PASS)
#error "Please define macros WIFI_SSID & WIFI_PASS (here, or better in a local.h file at root level or in program dir."
#endif
static void display_cipher(SSL *ssl);
static void display_session_id(SSL *ssl);

View file

@ -11,14 +11,11 @@
#include "FreeRTOS.h"
#include "task.h"
#include "esp8266.h"
#include "ssid_config.h"
#include "ota-tftp.h"
#include "rboot-ota.h"
#if !defined(WIFI_SSID) || !defined(WIFI_PASS)
#error "Please define macros WIFI_SSID & WIFI_PASS (here, or better in a local.h file at root level or in program dir."
#endif
void user_init(void)
{
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
@ -29,7 +26,7 @@ void user_init(void)
printf("Image addresses in flash:\r\n");
for(int i = 0; i <conf.count; i++) {
printf("%c%d: offset 0x%08lx\r\n", i == conf.current_rom ? '*':' ', i, conf.roms[i]);
printf("%c%d: offset 0x%08x\r\n", i == conf.current_rom ? '*':' ', i, conf.roms[i]);
}
struct sdk_station_config config = {

View file

@ -25,7 +25,7 @@ void task2(void *pvParameters)
while(1) {
uint32_t count;
if(xQueueReceive(*queue, &count, 1000)) {
printf("Got %lu\n", count);
printf("Got %u\n", count);
} else {
printf("No msg :(\n");
}