75 lines
1.7 KiB
C
75 lines
1.7 KiB
C
#pragma once
|
|
|
|
#include <sys/cpu.h>
|
|
|
|
#include <stdint.h>
|
|
#include <avr/interrupt.h>
|
|
|
|
typedef uint64_t systick_t;
|
|
|
|
struct _systick_wait
|
|
{
|
|
systick_t target;
|
|
};
|
|
typedef struct _systick_wait ST_WAIT;
|
|
|
|
typedef void (*systick_handler)(systick_t ticks);
|
|
|
|
extern volatile uint32_t _systick_secs; // system uptime in [s]
|
|
extern volatile uint32_t _systick_sec_frac;
|
|
|
|
extern volatile systick_t _systick_ticks; // system uptime in [us]
|
|
|
|
extern systick_t _systick_us; // Systick Interval in [us]
|
|
|
|
extern uint32_t _st_cycles_per_intervall __attribute__((weak));
|
|
|
|
|
|
void systick_init(systick_t systick_us);
|
|
void systick(void);
|
|
void systick_set_us(systick_t tickus);
|
|
|
|
int systick_correct(int32_t correct);
|
|
|
|
systick_t systick_ticks(void);
|
|
uint32_t systick_secs(void);
|
|
|
|
void systick_set_handler(systick_handler handler);
|
|
void systick_set_handler_sec(systick_handler handler);
|
|
|
|
void wait_ms(uint32_t ms);
|
|
|
|
void wait_async_set(ST_WAIT* wait,systick_t us);
|
|
uint8_t wait_async_test(ST_WAIT* wait);
|
|
|
|
/* call_sys_ctx(...) Rufe Funktion nach Ändern von SP auf CTX ST */
|
|
void call_sys_ctx(void (*proc)(void));
|
|
|
|
#if defined(__DEBUG_PLATFORM__)
|
|
|
|
#define VECT(__vect) \
|
|
void _vect_##__vect(void); \
|
|
ISR(__vect){ \
|
|
rt_dbg->last_vect[3] = rt_dbg->last_vect[2]; \
|
|
rt_dbg->last_vect[2] = rt_dbg->last_vect[1]; \
|
|
rt_dbg->last_vect[1] = rt_dbg->last_vect[0]; \
|
|
rt_dbg->last_vect[0] = (int)__vect; \
|
|
call_sys_ctx( _vect_##__vect ); \
|
|
}; \
|
|
void _vect_##__vect(void)
|
|
|
|
#else
|
|
|
|
#define VECT(__vect) \
|
|
void _vect_##__vect(void); \
|
|
ISR(__vect){ \
|
|
call_sys_ctx( _vect_##__vect ); \
|
|
}; \
|
|
void _vect_##__vect(void)
|
|
|
|
|
|
#endif
|
|
|
|
#include <sys/arch/systick.h>
|
|
|