From 2458478835911303d641c85683f7d079c003de09 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Mon, 16 Jan 2023 18:55:59 +0100 Subject: [PATCH] Some fixes. Added void csleep(void); --- microfx_src/include/microfx/microfx.h | 13 +++++++++++-- microfx_src/src/microfx.c | 9 +++++++-- template/lib/include/microfx/microfx.h | 13 +++++++++++-- template/lib/libMicrofx.a | Bin 5188 -> 5232 bytes 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/microfx_src/include/microfx/microfx.h b/microfx_src/include/microfx/microfx.h index ccb4ffb..7dbb9bf 100644 --- a/microfx_src/include/microfx/microfx.h +++ b/microfx_src/include/microfx/microfx.h @@ -108,7 +108,7 @@ void tsleep_ms(int ms); Get 1/128 seconds ticks since midnight. */ -void tgetticks(void); +int tgetticks(void); /* int tiselapsed(int start, int ms); @@ -119,5 +119,14 @@ Returns 1 if ms is elapsed and 0 if it is not. int tiselapsed(int start, int ms); -#endif +/******* CPU *******/ +/* void csleep(void); + +Uses asm sleep instruction. +Can be used to reduce battery usage of some loops. +*/ + +void csleep(void); + +#endif diff --git a/microfx_src/src/microfx.c b/microfx_src/src/microfx.c index 4c3bb6e..ab21aa4 100644 --- a/microfx_src/src/microfx.c +++ b/microfx_src/src/microfx.c @@ -104,11 +104,16 @@ void tsleep_ms(int ms) { _Sleep(ms); } -void tgetticks(void) { - _RTC_GetTicks(); +int tgetticks(void) { + return _RTC_GetTicks(); } int tiselapsed(int start, int ms) { return _RTC_Elapsed_ms(start, ms); } +/******* CPU *******/ + +void csleep(void) { + __asm__("sleep"); +} diff --git a/template/lib/include/microfx/microfx.h b/template/lib/include/microfx/microfx.h index ccb4ffb..7dbb9bf 100644 --- a/template/lib/include/microfx/microfx.h +++ b/template/lib/include/microfx/microfx.h @@ -108,7 +108,7 @@ void tsleep_ms(int ms); Get 1/128 seconds ticks since midnight. */ -void tgetticks(void); +int tgetticks(void); /* int tiselapsed(int start, int ms); @@ -119,5 +119,14 @@ Returns 1 if ms is elapsed and 0 if it is not. int tiselapsed(int start, int ms); -#endif +/******* CPU *******/ +/* void csleep(void); + +Uses asm sleep instruction. +Can be used to reduce battery usage of some loops. +*/ + +void csleep(void); + +#endif diff --git a/template/lib/libMicrofx.a b/template/lib/libMicrofx.a index 48126ab4704f646e628baaa9913afbe2f38d129e..0bea3d70d1e5a023d9a52ade767e1a37c436d350 100644 GIT binary patch delta 395 zcmX@2@j+vPY`vv{rG=4#f`I}EAd?CTW`;lsFi7BHU|>*UU|?Foz`*v0dYI>d2?GPq z15)wEGZz?@;**PWQd0{Uic1oUO7xQT^7SEZH8e9fwgCHT@;e^!&1ab`SXdEUMfMY{ zaIOTCx!L3kOj=B=Z#J9onliFWGjKC-GH_0AU=H5Ao9_}MKLcYX0|TQ9(D!UYK*r`C zflNkrsLh+d2&ywO>P(gqR$^l1nCu{|&X_P+fk%9Dy|4g~H37`uA*{|@0t`3>pb_jK ZVnpHTNM?{%%!(;;y5daV0T_OMg delta 379 zcmeyMaYSQ+Y`vk8fvKs2f`I}EAd?CTW(E+xf1_rhd)WbYi3>X-A zu8@K^Ubw(0Ra}x-RHB!xm#+_Ywt}IVxv>S%Cng4)4>9?(utJz(?Dtvaq5d;80C@&Z znwgmZc@`!nlMUFlm{`wjcHlK-++542!nAp#KnCMxMIkjtMwQ7P!b(gmFDB;*t20JS zzQ8Izd9|