mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
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)
|
function(INIT_TACTILITY_GLOBALS SDKCONFIG_FILE)
|
||||||
get_filename_component(SDKCONFIG_FILE_ABS ${SDKCONFIG_FILE} ABSOLUTE)
|
get_filename_component(SDKCONFIG_FILE_ABS ${SDKCONFIG_FILE} ABSOLUTE)
|
||||||
# Find the board identifier in the sdkconfig file
|
# Find the board identifier in the sdkconfig file
|
||||||
@ -10,7 +19,7 @@ function(INIT_TACTILITY_GLOBALS SDKCONFIG_FILE)
|
|||||||
set(id_length 0)
|
set(id_length 0)
|
||||||
math(EXPR id_length "${sdkconfig_board_id_length} - 21")
|
math(EXPR id_length "${sdkconfig_board_id_length} - 21")
|
||||||
string(SUBSTRING ${sdkconfig_board_id} 20 ${id_length} board_id)
|
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")
|
if (board_id STREQUAL "cyd-2432s024c")
|
||||||
set(TACTILITY_BOARD_PROJECT CYD-2432S024C)
|
set(TACTILITY_BOARD_PROJECT CYD-2432S024C)
|
||||||
@ -53,7 +62,7 @@ function(INIT_TACTILITY_GLOBALS SDKCONFIG_FILE)
|
|||||||
if (TACTILITY_BOARD_PROJECT STREQUAL "")
|
if (TACTILITY_BOARD_PROJECT STREQUAL "")
|
||||||
message(FATAL_ERROR "No subproject mapped to \"${TACTILITY_BOARD_ID}\" in root Buildscripts/board.cmake")
|
message(FATAL_ERROR "No subproject mapped to \"${TACTILITY_BOARD_ID}\" in root Buildscripts/board.cmake")
|
||||||
else ()
|
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_PROJECT ${TACTILITY_BOARD_PROJECT})
|
||||||
set_property(GLOBAL PROPERTY TACTILITY_BOARD_ID ${board_id})
|
set_property(GLOBAL PROPERTY TACTILITY_BOARD_ID ${board_id})
|
||||||
endif ()
|
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)
|
if (NOT WIN32)
|
||||||
string(ASCII 27 Esc)
|
string(ASCII 27 Esc)
|
||||||
set(ColourReset "${Esc}[m")
|
set(ColorReset "${Esc}[m")
|
||||||
set(Cyan "${Esc}[36m")
|
set(Cyan "${Esc}[36m")
|
||||||
set(Grey "${Esc}[37m")
|
set(Grey "${Esc}[37m")
|
||||||
set(LightPurple "${Esc}[1;35m")
|
set(LightPurple "${Esc}[1;35m")
|
||||||
set(White "${Esc}[1;37m")
|
set(White "${Esc}[1;37m")
|
||||||
else ()
|
else ()
|
||||||
set(ColourReset "")
|
set(ColorReset "")
|
||||||
set(Cyan "")
|
set(Cyan "")
|
||||||
set(Grey "")
|
set(Grey "")
|
||||||
set(LightPurple "")
|
set(LightPurple "")
|
||||||
@ -41,4 +41,4 @@ message("\n\n\
|
|||||||
${Cyan}@@@\n\
|
${Cyan}@@@\n\
|
||||||
${Cyan}@@@\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")
|
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)
|
file(READ version.txt TACTILITY_VERSION)
|
||||||
add_compile_definitions(TT_VERSION="${TACTILITY_VERSION}")
|
add_compile_definitions(TT_VERSION="${TACTILITY_VERSION}")
|
||||||
|
|
||||||
if (DEFINED ENV{ESP_IDF_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($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
|
||||||
include("Buildscripts/board.cmake")
|
include("Buildscripts/board.cmake")
|
||||||
|
|
||||||
init_tactility_globals("sdkconfig")
|
init_tactility_globals("sdkconfig")
|
||||||
get_property(TACTILITY_BOARD_PROJECT GLOBAL PROPERTY TACTILITY_BOARD_PROJECT)
|
get_property(TACTILITY_BOARD_PROJECT GLOBAL PROPERTY TACTILITY_BOARD_PROJECT)
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ if (DEFINED ENV{ESP_IDF_VERSION})
|
|||||||
idf_component_register(
|
idf_component_register(
|
||||||
SRCS ${SOURCE_FILES}
|
SRCS ${SOURCE_FILES}
|
||||||
INCLUDE_DIRS "Include/"
|
INCLUDE_DIRS "Include/"
|
||||||
REQUIRES mbedtls nvs_flash esp_rom
|
REQUIRES mbedtls nvs_flash esp_rom esp_timer
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
|||||||
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include <esp_timer.h>
|
||||||
#else
|
#else
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace tt::kernel {
|
namespace tt::kernel {
|
||||||
@ -16,9 +18,9 @@ typedef enum {
|
|||||||
|
|
||||||
/** Return true when called from an Interrupt Service Routine (~IRQ mode) */
|
/** Return true when called from an Interrupt Service Routine (~IRQ mode) */
|
||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
inline constexpr bool isIsr() { return (xPortInIsrContext() == pdTRUE); }
|
constexpr bool isIsr() { return (xPortInIsrContext() == pdTRUE); }
|
||||||
#else
|
#else
|
||||||
inline constexpr bool isIsr() { return false; }
|
constexpr bool isIsr() { return false; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Check if kernel is running
|
/** Check if kernel is running
|
||||||
@ -52,7 +54,17 @@ uint32_t getTickFrequency();
|
|||||||
|
|
||||||
TickType_t getTicks();
|
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
|
/** Delay execution
|
||||||
* @warning don't call from ISR context
|
* @warning don't call from ISR context
|
||||||
@ -68,11 +80,11 @@ void delayTicks(TickType_t ticks);
|
|||||||
*/
|
*/
|
||||||
bool delayUntilTick(TickType_t tick);
|
bool delayUntilTick(TickType_t tick);
|
||||||
|
|
||||||
constexpr inline TickType_t secondsToTicks(uint32_t seconds) {
|
constexpr TickType_t secondsToTicks(uint32_t seconds) {
|
||||||
return (TickType_t)seconds * 1000U / portTICK_PERIOD_MS;
|
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);
|
return secondsToTicks(minutes * 60U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user