Skip to content

Commit

Permalink
updated files to move stuff out of core cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
naichenzhao committed Nov 22, 2023
1 parent 436b36b commit bcbbf43
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 82 deletions.
46 changes: 0 additions & 46 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,49 +123,3 @@ define(SCHEDULER)
define(LF_SOURCE_DIRECTORY)
define(LF_PACKAGE_DIRECTORY)
define(LF_FILE_SEPARATOR)



# ==========================================================
# Stuff I added
# ==========================================================

if(${CMAKE_SYSTEM_NAME} MATCHES "Stm32")
set(CPU_PARAMETERS
-mcpu=cortex-m4
-mthumb
-mfpu=fpv4-sp-d16
-mfloat-abi=softfp )

set(MCU_FAMILY STM32F4xx )
set(MCU_MODEL STM32F446xx )

target_compile_definitions(core PRIVATE
${MCU_MODEL}
USE_HAL_DRIVER )

target_compile_options(core PRIVATE
${CPU_PARAMETERS}
-Wall
-Wextra
-Wpedantic
-Wno-unused-parameter
$<$<COMPILE_LANGUAGE:CXX>:
-Wno-volatile
-Wold-style-cast
-Wuseless-cast
-Wsuggest-override>
$<$<CONFIG:Debug>:-Og -g3 -ggdb>
$<$<CONFIG:Release>:-Og -g0> )

set(CUBEMX_INCLUDE_DIRECTORIES
../STM_sdk/Core/Inc
../STM_sdk/Drivers/${MCU_FAMILY}_HAL_Driver/Inc
../STM_sdk/Drivers/${MCU_FAMILY}_HAL_Driver/Inc/Legacy
../STM_sdk/Drivers/CMSIS/Device/ST/${MCU_FAMILY}/Include
../STM_sdk/Drivers/CMSIS/Include )

target_include_directories(core PUBLIC
${CUBEMX_INCLUDE_DIRECTORIES} )
endif()
# ==========================================================
70 changes: 34 additions & 36 deletions core/platform/lf_STM32f4_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,46 +119,44 @@ static void lf_busy_wait_until(instant_t wakeup_time) {

// I am pretty sure this function doesnt work
// Ill try to fix it once i know what the fuck its supposed to do, LOL
int _lf_interruptable_sleep_until_locked(environment_t *env, instant_t wakeup_time) {
// // Get the current time and sleep time
// instant_t now;
// _lf_clock_now(&now);
// interval_t duration = wakeup_time - now;

// // Edge case handling for super small duration
// if (duration <= 0) {
// return 0;
// } else if (duration < 10) {
// lf_busy_wait_until(wakeup_time);
// return 0;
// }

// // Enable interrupts and prepare to wait
// _lf_async_event = false;
// instant_t curr;
// lf_enable_interrupts_nested();

// do {
// _lf_clock_now(&curr);

// // Exit wither when the timer is up or there is an exception
// } while (!_lf_async_event && (now < wakeup_time));

// // Disable interrupts again on exit
// lf_disable_interrupts_nested();

// if (!_lf_async_event) {
// return 0;
// } else {
// LF_PRINT_DEBUG(" *The STM32 rises from sleep* \n");
// return -1;
// }
/* sleep until wakeup time
But, wake up if there is an async event
*/
int _lf_interruptable_sleep_until_locked(environment_t *env, instant_t wakeup_time) {
// Get the current time and sleep time
instant_t now;
_lf_clock_now(&now);
interval_t duration = wakeup_time - now;

// Edge case handling for super small duration
if (duration <= 0) {
return 0;
} else if (duration < 10) {
lf_busy_wait_until(wakeup_time);
return 0;
}

// Enable interrupts and prepare to wait
_lf_async_event = false;
lf_enable_interrupts_nested();

do {
_lf_clock_now(&now);
} while (now < wakeup_time);
return 0;

// Exit when the timer is up or there is an exception
} while (!_lf_async_event && (now < wakeup_time));

// Disable interrupts again on exit
lf_disable_interrupts_nested();

if (!_lf_async_event) {
return 0;
} else {
LF_PRINT_DEBUG(" *The STM32 rises from sleep* \n");
return -1;
}

}

// + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
Expand Down

0 comments on commit bcbbf43

Please sign in to comment.