Buildscript and kernel improvements (#280)
- Implemented `constexpr long int getMicros()` in `Kernel.h` - Changed `secondsToTicks()`, `minutesToTicks()` and `bool isIsr()` to `constexpr` - Added more relevant build info
This commit is contained in:
parent
870924229a
commit
74eb830870
@ -1,3 +1,12 @@
|
||||
if (NOT WIN32)
|
||||
string(ASCII 27 Esc)
|
||||
set(ColorReset "${Esc}[m")
|
||||
set(Cyan "${Esc}[36m")
|
||||
else ()
|
||||
set(ColorReset "")
|
||||
set(Cyan "")
|
||||
endif ()
|
||||
|
||||
function(INIT_TACTILITY_GLOBALS SDKCONFIG_FILE)
|
||||
get_filename_component(SDKCONFIG_FILE_ABS ${SDKCONFIG_FILE} ABSOLUTE)
|
||||
# Find the board identifier in the sdkconfig file
|
||||
@ -10,7 +19,7 @@ function(INIT_TACTILITY_GLOBALS SDKCONFIG_FILE)
|
||||
set(id_length 0)
|
||||
math(EXPR id_length "${sdkconfig_board_id_length} - 21")
|
||||
string(SUBSTRING ${sdkconfig_board_id} 20 ${id_length} board_id)
|
||||
message("Building board ${board_id}")
|
||||
message("Building board: ${Cyan}${board_id}${ColorReset}")
|
||||
|
||||
if (board_id STREQUAL "cyd-2432s024c")
|
||||
set(TACTILITY_BOARD_PROJECT CYD-2432S024C)
|
||||
@ -53,7 +62,7 @@ function(INIT_TACTILITY_GLOBALS SDKCONFIG_FILE)
|
||||
if (TACTILITY_BOARD_PROJECT STREQUAL "")
|
||||
message(FATAL_ERROR "No subproject mapped to \"${TACTILITY_BOARD_ID}\" in root Buildscripts/board.cmake")
|
||||
else ()
|
||||
message("Board project: Boards/${TACTILITY_BOARD_PROJECT}")
|
||||
message("Board project: ${Cyan}Boards/${TACTILITY_BOARD_PROJECT}${ColorReset}\n")
|
||||
set_property(GLOBAL PROPERTY TACTILITY_BOARD_PROJECT ${TACTILITY_BOARD_PROJECT})
|
||||
set_property(GLOBAL PROPERTY TACTILITY_BOARD_ID ${board_id})
|
||||
endif ()
|
||||
|
||||
14
Buildscripts/colors.cmake
Normal file
14
Buildscripts/colors.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
if (NOT WIN32)
|
||||
string(ASCII 27 Esc)
|
||||
set(ColorReset "${Esc}[m")
|
||||
set(Cyan "${Esc}[36m")
|
||||
set(Grey "${Esc}[37m")
|
||||
set(LightPurple "${Esc}[1;35m")
|
||||
set(White "${Esc}[1;37m")
|
||||
else ()
|
||||
set(ColorReset "")
|
||||
set(Cyan "")
|
||||
set(Grey "")
|
||||
set(LightPurple "")
|
||||
set(White "")
|
||||
endif ()
|
||||
@ -10,13 +10,13 @@ endif()
|
||||
|
||||
if (NOT WIN32)
|
||||
string(ASCII 27 Esc)
|
||||
set(ColourReset "${Esc}[m")
|
||||
set(ColorReset "${Esc}[m")
|
||||
set(Cyan "${Esc}[36m")
|
||||
set(Grey "${Esc}[37m")
|
||||
set(LightPurple "${Esc}[1;35m")
|
||||
set(White "${Esc}[1;37m")
|
||||
else ()
|
||||
set(ColourReset "")
|
||||
set(ColorReset "")
|
||||
set(Cyan "")
|
||||
set(Grey "")
|
||||
set(LightPurple "")
|
||||
@ -41,4 +41,4 @@ message("\n\n\
|
||||
${Cyan}@@@\n\
|
||||
${Cyan}@@@\n\
|
||||
${Cyan}@@@\n\
|
||||
${Cyan}@@\n\n${ColourReset}")
|
||||
${Cyan}@@\n\n${ColorReset}")
|
||||
|
||||
@ -8,14 +8,24 @@ set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_CXX_COMPILER_TARGET}")
|
||||
|
||||
include("Buildscripts/logo.cmake")
|
||||
|
||||
if (NOT WIN32)
|
||||
string(ASCII 27 Esc)
|
||||
set(ColorReset "${Esc}[m")
|
||||
set(Cyan "${Esc}[36m")
|
||||
else ()
|
||||
set(ColorReset "")
|
||||
set(Cyan "")
|
||||
endif ()
|
||||
|
||||
file(READ version.txt TACTILITY_VERSION)
|
||||
add_compile_definitions(TT_VERSION="${TACTILITY_VERSION}")
|
||||
|
||||
if (DEFINED ENV{ESP_IDF_VERSION})
|
||||
message("Building with ESP-IDF v$ENV{ESP_IDF_VERSION}")
|
||||
message("Building with ESP-IDF ${Cyan}v$ENV{ESP_IDF_VERSION}${ColorReset}")
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
include("Buildscripts/board.cmake")
|
||||
|
||||
init_tactility_globals("sdkconfig")
|
||||
get_property(TACTILITY_BOARD_PROJECT GLOBAL PROPERTY TACTILITY_BOARD_PROJECT)
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ if (DEFINED ENV{ESP_IDF_VERSION})
|
||||
idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
INCLUDE_DIRS "Include/"
|
||||
REQUIRES mbedtls nvs_flash esp_rom
|
||||
REQUIRES mbedtls nvs_flash esp_rom esp_timer
|
||||
)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
|
||||
@ -2,8 +2,10 @@
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include <esp_timer.h>
|
||||
#else
|
||||
#include "FreeRTOS.h"
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
namespace tt::kernel {
|
||||
@ -16,9 +18,9 @@ typedef enum {
|
||||
|
||||
/** Return true when called from an Interrupt Service Routine (~IRQ mode) */
|
||||
#ifdef ESP_PLATFORM
|
||||
inline constexpr bool isIsr() { return (xPortInIsrContext() == pdTRUE); }
|
||||
constexpr bool isIsr() { return (xPortInIsrContext() == pdTRUE); }
|
||||
#else
|
||||
inline constexpr bool isIsr() { return false; }
|
||||
constexpr bool isIsr() { return false; }
|
||||
#endif
|
||||
|
||||
/** Check if kernel is running
|
||||
@ -52,7 +54,17 @@ uint32_t getTickFrequency();
|
||||
|
||||
TickType_t getTicks();
|
||||
|
||||
inline size_t getMillis() { return getTicks() / portTICK_PERIOD_MS; }
|
||||
constexpr size_t getMillis() { return getTicks() / portTICK_PERIOD_MS; }
|
||||
|
||||
constexpr long int getMicros() {
|
||||
#ifdef ESP_PLATFORM
|
||||
return static_cast<unsigned long>(esp_timer_get_time());
|
||||
#else
|
||||
timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
return 1000000 * tv.tv_sec + tv.tv_usec;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Delay execution
|
||||
* @warning don't call from ISR context
|
||||
@ -68,11 +80,11 @@ void delayTicks(TickType_t ticks);
|
||||
*/
|
||||
bool delayUntilTick(TickType_t tick);
|
||||
|
||||
constexpr inline TickType_t secondsToTicks(uint32_t seconds) {
|
||||
return (TickType_t)seconds * 1000U / portTICK_PERIOD_MS;
|
||||
constexpr TickType_t secondsToTicks(uint32_t seconds) {
|
||||
return static_cast<TickType_t>(seconds) * 1000U / portTICK_PERIOD_MS;
|
||||
}
|
||||
|
||||
constexpr inline TickType_t minutesToTicks(uint32_t minutes) {
|
||||
constexpr TickType_t minutesToTicks(uint32_t minutes) {
|
||||
return secondsToTicks(minutes * 60U);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user