Skip to content

Commit

Permalink
style(framework): optimise the framework
Browse files Browse the repository at this point in the history
1. move deepsleep test to unit-test
2. add i2c_devices / sensor / others folders
3. modify makefile and readme
  • Loading branch information
costaud committed Sep 12, 2017
1 parent 90e4a94 commit 6807464
Show file tree
Hide file tree
Showing 46 changed files with 30 additions and 20 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#Overwrite the IDF_PATH to the esp-idf path in submodule.
IDF_PATH := $(IOT_SOLUTION_PATH)/submodule/esp-idf/
EXTRA_COMPONENT_DIRS += $(IOT_SOLUTION_PATH)/components $(IOT_SOLUTION_PATH)/products $(IOT_SOLUTION_PATH)/platforms

EXTRA_COMPONENT_DIRS += $(IOT_SOLUTION_PATH)/components/i2c_devices
EXTRA_COMPONENT_DIRS += $(IOT_SOLUTION_PATH)/components/i2c_devices/sensor
EXTRA_COMPONENT_DIRS += $(IOT_SOLUTION_PATH)/components/i2c_devices/others
include $(IDF_PATH)/make/project.mk

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
│   ├── hts221
│   ├── http_request
│   ├── i2c_bus
│   ├── i2c_debug
│   ├── is31fl3xxx
│   ├── lcd
│   ├── led
Expand Down Expand Up @@ -89,7 +88,6 @@
│   ├── sensor
│   ├── socket
│   └── switch
├── readme.txt
├── sdkconfig
├── submodule
│   └── esp-idf
Expand Down
4 changes: 2 additions & 2 deletions components/debugs/debugs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "esp_system.h"
#include "esp_log.h"
#include "esp_wifi.h"
#include "esp_deep_sleep.h"
#include "esp_sleep.h"
#include "debugs.h"

#define IOT_CHECK(tag, a, ret) if(!(a)) { \
Expand Down Expand Up @@ -96,7 +96,7 @@ static const char* wakeup_info[] = {

static void wakeup_info_log(void *arg)
{
esp_deep_sleep_wakeup_cause_t wakeup_cause = esp_deep_sleep_get_wakeup_cause();
esp_sleep_wakeup_cause_t wakeup_cause = esp_sleep_get_wakeup_cause();
ESP_LOGI(TAG, "wakeup reason: %s", wakeup_info[wakeup_cause]);
}

Expand Down
4 changes: 2 additions & 2 deletions components/debugs/test/debugs_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

#include "esp_system.h"
#include "esp_deep_sleep.h"
#include "esp_sleep.h"
#include "esp_log.h"
#include "debugs.h"
#include "unity.h"
Expand All @@ -38,7 +38,7 @@ static void debug_123(void* arg)
static void debug_deepsleep(void *arg)
{
ESP_LOGI(TAG, "sleep for 10 seconds");
esp_deep_sleep_enable_timer_wakeup(10 * 1000 * 1000);
esp_sleep_enable_timer_wakeup(10 * 1000 * 1000);
esp_deep_sleep_start();
}

Expand Down
4 changes: 4 additions & 0 deletions components/i2c_devices/component.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#
# "main" pseudo-component makefile.
#
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions components/i2c_devices/others/component.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#
# "main" pseudo-component makefile.
#
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions components/i2c_devices/sensor/component.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#
# "main" pseudo-component makefile.
#
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions components/ulp_monitor/ulp_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <string.h>
#include "esp_log.h"
#include "esp32/ulp.h"
#include "esp_deep_sleep.h"
#include "esp_sleep.h"
#include "driver/adc.h"
#include "driver/rtc_io.h"
#include "soc/rtc_cntl_reg.h"
Expand Down Expand Up @@ -181,7 +181,7 @@ esp_err_t ulp_monitor_start(uint32_t meas_per_hour)
};
ERR_ASSERT(TAG, ulp_add_subprogram(sub_program, sizeof(sub_program)));
size_t size = g_program_len;
esp_deep_sleep_enable_ulp_wakeup();
esp_sleep_enable_ulp_wakeup();
ERR_ASSERT(TAG, ulp_process_macros_and_load(g_program_addr, g_program, &size));
const uint32_t sleep_cycles = rtc_clk_slow_freq_get_hz() * 3600 / meas_per_hour;
REG_WRITE(SENS_ULP_CP_SLEEP_CYC0_REG, sleep_cycles);
Expand All @@ -207,4 +207,4 @@ void ulp_data_write(size_t addr, uint16_t value)
RTC_SLOW_MEM[addr] = value;
return;
}
#endif
#endif
10 changes: 4 additions & 6 deletions tools/unit-test-app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ PROJECT_NAME := unit-test-app
#If IOT_SOLUTION_PATH is not defined, use relative path as default value
IOT_SOLUTION_PATH ?= $(shell pwd)/../../



#Do not touch the code below
#EXTRA_COMPONENT_DIRS := $(shell pwd)/../../components $(shell pwd)/../../abstract $(shell pwd)/../../platforms $(shell pwd)/../../products
IOT_COMPONENTT_DIR := $(IOT_SOLUTION_PATH)/../../components
IOT_COMPONENTT_DIR := $(IOT_SOLUTION_PATH)/components components
IOT_COMPONENTT_DIR += $(IOT_SOLUTION_PATH)/components/i2c_devices
IOT_COMPONENTT_DIR += $(IOT_SOLUTION_PATH)/components/i2c_devices/sensor
IOT_COMPONENTT_DIR += $(IOT_SOLUTION_PATH)/components/i2c_devices/others

# Find all component names. The component names are the same as the
# directories they're in, so /bla/components/mycomponent/component.mk -> mycomponent.
Expand All @@ -20,7 +20,6 @@ IOT_COMPONENTS := $(dir $(foreach cd,$(IOT_COMPONENTT_DIR),
))
IOT_COMPONENTS := $(sort $(foreach comp,$(IOT_COMPONENTS),$(lastword $(subst /, ,$(comp)))))


# If IOT_ALL set to 1, set TEST_COMPONENTS to all IoT components
ifeq ($(IOT_TEST_ALL),1)
TEST_COMPONENTS := $(IOT_COMPONENTS)
Expand All @@ -30,6 +29,5 @@ else
endif

include $(IOT_SOLUTION_PATH)/Makefile

print_flash_cmd:
echo $(ESPTOOL_WRITE_FLASH_OPTIONS) $(ESPTOOL_ALL_FLASH_ARGS) | sed -e 's:'$(PWD)/build/'::g'
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "freertos/queue.h"
#include "esp_log.h"
#include "unity.h"
#include "esp_deep_sleep.h"
#include "esp_sleep.h"
#include "touchpad.h"

#define TAG "deep_sleep_test"
Expand All @@ -39,7 +39,7 @@ void deep_sleep_gpio_test()
ESP_LOGI(TAG, "start deep sleep, press key 34 and 35 at the same time to wakeup\n");
uint64_t wakeup_pin_mask = 1ULL << 35;
wakeup_pin_mask |= 1ULL << 34;
esp_deep_sleep_enable_ext1_wakeup(wakeup_pin_mask, ESP_EXT1_WAKEUP_ALL_LOW);
esp_sleep_enable_ext1_wakeup(wakeup_pin_mask, ESP_EXT1_WAKEUP_ALL_LOW);
esp_deep_sleep_start();
}

Expand All @@ -53,7 +53,7 @@ void deep_sleep_touch_test()
ESP_LOGI(TAG, "waiting for 5 seconds...\n");
vTaskDelay(5000 / portTICK_PERIOD_MS);
ESP_LOGI(TAG, "start deep sleep, press TP1, TP2, TP3 or TP4 to wakeup\n");
esp_deep_sleep_enable_touchpad_wakeup();
esp_sleep_enable_touchpad_wakeup();
esp_deep_sleep_start();
}

Expand All @@ -65,4 +65,4 @@ TEST_CASE("Deep sleep gpio test", "[deep_sleep][rtc_gpio][current][iot]")
TEST_CASE("Deep sleep touch test", "[deep_sleep][touch][current][iot]")
{
deep_sleep_touch_test();
}
}

0 comments on commit 6807464

Please sign in to comment.