Add optional use of threading for runtime module (-DRUNTIME_USES_THREADING)
parent
6291c813ec
commit
dc52340562
|
@ -9,8 +9,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define ASSERT_BUFFER_LEN 8
|
#define ASSERT_BUFFER_LEN 8
|
||||||
|
|
||||||
#define RTA_USER0 0x01
|
#define RTA_USER0 0x01
|
||||||
|
@ -102,7 +100,11 @@ struct rt_ram {
|
||||||
unix_time_changing_t
|
unix_time_changing_t
|
||||||
unix_time_changing;
|
unix_time_changing;
|
||||||
|
|
||||||
|
#if !defined(RUNTIME_USES_THREADING)
|
||||||
SYSTIMER *timer;
|
SYSTIMER *timer;
|
||||||
|
#else
|
||||||
|
thread_t *rtThread;
|
||||||
|
#endif
|
||||||
|
|
||||||
systick_t secs_last;
|
systick_t secs_last;
|
||||||
systick_t secs_current,
|
systick_t secs_current,
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
volatile struct rt_ram rt_ram;
|
volatile struct rt_ram rt_ram;
|
||||||
|
|
||||||
/*! \brief Signal Thread.
|
/*! \brief Signal Thread.
|
||||||
|
@ -19,9 +18,16 @@
|
||||||
*/
|
*/
|
||||||
void runtime_signal(void)
|
void runtime_signal(void)
|
||||||
{
|
{
|
||||||
|
#if !defined(RUNTIME_USES_THREADING)
|
||||||
timer_start( rt_ram.timer, 1L );
|
timer_start( rt_ram.timer, 1L );
|
||||||
|
#else
|
||||||
|
thread_wake( rt_ram.rtThread );
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Runtime-Thread.
|
/*! \brief Runtime-Thread.
|
||||||
*
|
*
|
||||||
* Ermittelt Betriebsstunden des Geräts
|
* Ermittelt Betriebsstunden des Geräts
|
||||||
|
@ -44,6 +50,23 @@ void runtime_cycle(void)
|
||||||
rt_ram.secs_last = rt_ram.secs_current;
|
rt_ram.secs_last = rt_ram.secs_current;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(RUNTIME_USES_THREADING)
|
||||||
|
|
||||||
|
void runtime_thread(void* arg){
|
||||||
|
|
||||||
|
while (1){
|
||||||
|
wait_ms( 10000l );
|
||||||
|
runtime_cycle();
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Startet Runtime-Thread.
|
/*! \brief Startet Runtime-Thread.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -62,8 +85,16 @@ void runtime_start(int16_t bank)
|
||||||
rt_ram.secs_last = systick_secs();
|
rt_ram.secs_last = systick_secs();
|
||||||
rt_ram.bank = bank;
|
rt_ram.bank = bank;
|
||||||
|
|
||||||
|
#if !defined(RUNTIME_USES_THREADING)
|
||||||
|
|
||||||
rt_ram.timer = timer_create_ex( TIMERID_SYS_RUNTIME, 10000000L, runtime_cycle, TF_REPEAT);
|
rt_ram.timer = timer_create_ex( TIMERID_SYS_RUNTIME, 10000000L, runtime_cycle, TF_REPEAT);
|
||||||
timer_start( rt_ram.timer, 0 );
|
timer_start( rt_ram.timer, 0 );
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
thread_alloc( runtime_thread, NULL, 256 );
|
||||||
|
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue