Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for STM32 #302

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
6de22f6
initial test for support for STM32
naichenzhao Nov 7, 2023
256abcc
Point to lingua-franca stm32 branch
lhstrh Nov 7, 2023
92fcfbe
fixed typo
naichenzhao Nov 11, 2023
dca5be8
please merge
naichenzhao Nov 11, 2023
89986a9
hard coded STM32 support
naichenzhao Nov 11, 2023
436b36b
we dont need STM_main anymore
naichenzhao Nov 19, 2023
bcbbf43
updated files to move stuff out of core cmake
naichenzhao Nov 22, 2023
48be057
fixed printing
naichenzhao Dec 7, 2023
31d62b2
changed naming
naichenzhao Dec 18, 2023
73aea2e
updated sleep functions
naichenzhao Jul 15, 2024
7899e6b
updated delay functions
naichenzhao Jul 15, 2024
d11f3ff
rebased in main
naichenzhao Aug 5, 2024
58d2323
change
naichenzhao Aug 5, 2024
5ae3be6
fixed typo
naichenzhao Nov 11, 2023
4bb9231
bruh
naichenzhao Aug 5, 2024
9527537
we dont need STM_main anymore
naichenzhao Nov 19, 2023
8a97bcd
changes
naichenzhao Aug 5, 2024
c46fbcc
fixed printing
naichenzhao Dec 7, 2023
b3097a8
changed naming
naichenzhao Dec 18, 2023
f92307f
updated sleep functions
naichenzhao Jul 15, 2024
f2554dd
updated delay functions
naichenzhao Jul 15, 2024
03124a5
merge
naichenzhao Aug 5, 2024
6d2964c
Merge branch 'stm32' of github.com:lf-lang/reactor-c into stm32
naichenzhao Aug 5, 2024
13ca0d8
Merge branch 'main' of github.com:lf-lang/reactor-c into stm32
naichenzhao Aug 31, 2024
cd0c9c1
quick commit
naichenzhao Aug 31, 2024
6d8d4db
Suppress unused parameter error
edwardalee Aug 9, 2024
bb75db6
Suppress unused parameter error
edwardalee Aug 9, 2024
6a66f47
deleted artifact from rebase
naichenzhao Aug 31, 2024
a285e52
works with newest version
naichenzhao Aug 31, 2024
6ba0f42
did formatting
naichenzhao Sep 7, 2024
a22a4fd
Update low_level_platform/api/platform/lf_STM32f4_support.h
naichenzhao Sep 16, 2024
42fc271
Update low_level_platform/api/platform/lf_STM32f4_support.h
naichenzhao Sep 16, 2024
895a8fb
Update low_level_platform/impl/src/lf_STM32f4_support.c
naichenzhao Sep 16, 2024
0d3af6d
Update low_level_platform/api/platform/lf_STM32f4_support.h
naichenzhao Sep 16, 2024
50603d7
Update low_level_platform/impl/src/lf_STM32f4_support.c
naichenzhao Sep 16, 2024
cba9193
resolved some more comments
naichenzhao Sep 17, 2024
cf36f59
changed macro
naichenzhao Sep 24, 2024
6e9e3c7
Merge branch 'main' into stm32
naichenzhao Oct 4, 2024
6974d8e
Merge branch 'main' into stm32
naichenzhao Oct 5, 2024
a2e1e4b
Merge branch 'stm32' of https://github.com/lf-lang/reactor-c into stm32
naichenzhao Oct 5, 2024
68ec2d7
Run clang-format
erlingrj Oct 5, 2024
2d23659
Update lf-ref to the new lf branch
erlingrj Oct 5, 2024
128e9a4
Merge branch 'main' into stm32
erlingrj Oct 29, 2024
22b871d
Refactor comments
erlingrj Oct 29, 2024
68bd26a
Dont rely on hardcoded relative path to the "STM_SDK"
erlingrj Oct 29, 2024
335d52b
Remove all the STM32 cmake setup from reactor-c. This happens outside
erlingrj Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated sleep functions
  • Loading branch information
naichenzhao committed Aug 5, 2024
commit f92307f044e9fd48ff90b313a8872b2325360b41
33 changes: 18 additions & 15 deletions low_level_platform/impl/src/lf_STM32f4_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,38 +92,42 @@ int _lf_clock_now(instant_t *t)
}

/**
* Make the STM32 go honk shoo mimimi for set nanoseconds
* I essentially stole this from the lf_nrf52 support
* Make the STM32 sleep for set nanoseconds
* Based on the lf_nrf52 support implementation
*/
int lf_sleep(interval_t sleep_duration) {
instant_t target_time;
instant_t current_time;

_lf_clock_now(&current_time);
target_time = current_time + sleep_duration;

// HAL_Delay only supports miliseconds. We try to use that for as long as possible
// before switching to another meothd for finer tuned delay times
long delaytime_ms = sleep_duration / 1000000;
HAL_Delay(delaytime_ms);

while (current_time <= target_time)
_lf_clock_now(&current_time);

return 0;
}

/**
* Make the STM32 go honk shoo honk shoo for set nanoseconds
* This one uses a do-while loop. :)
* I essentially stole this from the lf_nrf52 support
* Make the STM32 sleep for set nanoseconds
* Based on the lf_nrf52 support implementation
*/
static void lf_busy_wait_until(instant_t wakeup_time) {
naichenzhao marked this conversation as resolved.
Show resolved Hide resolved
instant_t now;
do {
_lf_clock_now(&now);
} while (now < wakeup_time);
instant_t current_time;
_lf_clock_now(&current_time);

// We repurpose the lf_sleep function here, just to better streamline the code
interval_t sleep_duration = wakeup_time - current_time;
lf_sleep(sleep_duration);
}

// I am pretty sure this function doesnt work
naichenzhao marked this conversation as resolved.
Show resolved Hide resolved
// Ill try to fix it once i know what the fuck its supposed to do, LOL
/* sleep until wakeup time
But, wake up if there is an async event

/* 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
Expand All @@ -134,7 +138,7 @@ int _lf_interruptable_sleep_until_locked(environment_t *env, instant_t wakeup_ti
// Edge case handling for super small duration
if (duration <= 0) {
return 0;
} else if (duration < 10) {
} else if (duration < LF_MIN_SLEEP_NS) {
lf_busy_wait_until(wakeup_time);
return 0;
}
Expand All @@ -145,7 +149,6 @@ int _lf_interruptable_sleep_until_locked(environment_t *env, instant_t wakeup_ti

do {
_lf_clock_now(&now);

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

Expand Down