My Project - RET HER
versionsnr
|
Go to the documentation of this file.
58 #define KRNL_VRS 20210114
201 #define sbi(r, b) r |= _BV(b)
205 #define cbi(r, b) r &= ~_BV(b)
209 #define cbi(r, b) r &= ~_BV(b)
236 #define WDT_PERIOD WDTO_1S
238 #define QHD_PRIO 102 // Queue head prio - for sentinel use
240 #define DMY_PRIO (QHD_PRIO - 2) // dummy task prio (0 == highest prio)
241 #define ZOMBI_PRIO (QHD_PRIO - 1)
242 #define DMY_STK_SZ 90 // staksize for dummy
243 #define MAIN_PRIO 50 // main task prio
244 #define STAK_HASH 0x5c // just a hashcode
245 #define MAX_SEM_VAL 50 // NB is also max for nr elem in msgQ !
246 #define MAX_INT 0x7FFF
248 #define SEM_MAX_VALUE 32000
254 #define BACKSTOPPER 1
256 #define CEILINGFAIL -3
271 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
274 #elif defined(__AVR_ATmega1284P__)
277 #elif defined(__AVR_ATmega328P__)
280 #elif defined(__AVR_ATmega32U4__)
284 #error "unknown AVR cpu type - bad place to come"
290 #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
292 #if (KRNLTMR != 0) && (KRNLTMR != 1) && (KRNLTMR != 2)
293 #error "bad timer selection for krnl heartbeat(168/328/328p/...)"
298 #if defined(__AVR_ATmega32U4__)
300 #if (KRNLTMR != 0) && (KRNLTMR != 1) && (KRNLTMR != 3)
301 #error "bad timer selection for krnl heartbeat(32u4)...)"
306 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
308 #if (KRNLTMR != 0) && (KRNLTMR != 1) && (KRNLTMR != 2) && (KRNLTMR != 3) && (KRNLTMR != 4) && (KRNLTMR != 5)
309 #error "bad timer for krnl heartbeat(1280/2560/2561) in krnl"
314 #if defined(__AVR_ATmega1284P__)
316 #if (KRNLTMR != 0) && (KRNLTMR != 1) && (KRNLTMR != 2) && (KRNLTMR != 3)
317 #error "bad timer for krnl heartbeat(1284P) in krnl"
469 #define lo8(X) ((unsigned char)((unsigned int)(X)))
470 #define hi8(X) ((unsigned char)((unsigned int)(X) >> 8))
475 #define K_CHG_STAK() \
476 if (pRun != AQ.next) \
487 #define K_CHG_STAK() \
488 if (pRun != AQ.next) \
507 #if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega32U4__)
509 #define DI() __asm__ volatile("cli")
510 #define EI() __asm__ volatile("sei")
511 #define RETI() __asm__ volatile("reti")
517 #if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2561__)
522 #define PUSHREGS() __asm__ volatile( \
525 "in r0, __SREG__ \n\t" \
528 "in r0 , 0x3b \n\t" \
530 "in r0 , 0x3c \n\t" \
564 #define POPREGS() __asm__ volatile( \
596 "out 0x3c , r0 \n\t " \
598 "out 0x3b , r0 \n\t " \
600 "out __SREG__ , r0 \n\t " \
604 #elif defined(__AVR_ATmega1284P__)
609 #define PUSHREGS() __asm__ volatile( \
612 "in r0, __SREG__ \n\t" \
615 "in r0 , 0x3b \n\t" \
649 #define POPREGS() __asm__ volatile( \
681 "out 0x3b , r0 \n\t " \
683 "out __SREG__ , r0 \n\t " \
687 #elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega32U4__)
690 #define PUSHREGS() __asm__ volatile( \
693 "in r0, __SREG__ \n\t" \
728 #define POPREGS() __asm__ volatile( \
760 "out __SREG__ , r0 \n\t " \
765 #error "unknown arch"
813 #define k_eat_msec_time(x) _delay_ms(x)
927 int k_wait(
struct k_t *sem,
int timeout);
1122 int k_init(
int nrTask,
int nrSem,
int nrMsg);
1150 int k_stop(
unsigned int exitVal);
1164 void k_bugblink13(
char on);
1190 char k_set_preempt(
char on);
1196 char k_get_preempt(
void);
1227 #endif // #ifndef KRNL
int ki_signal(struct k_t *sem)
int k_mut_ceil_set(struct k_t *sem, char prio)
struct k_t * k_crt_sem(char init_val, int maxvalue)
struct k_msg_t * k_crt_send_Q(int nr_el, int el_size, void *pBuf)
int ki_wait(struct k_t *sem, int timeout)
int k_msg_count(struct k_msg_t *m)
struct k_t * k_crt_task(void(*pTask)(void), char prio, int stkSize)
int k_semval(struct k_t *sem)
int k_mut_ceil_leave(struct k_t *sem)
int k_init(int nrTask, int nrSem, int nrMsg)
void k_round_robbin(void)
int k_signal(struct k_t *sem)
int k_set_prio(char prio)
int k_sem_signals_lost(struct k_t *sem)
void __attribute__((weak)) k_enable_wdt(void)
char k_receive(struct k_msg_t *pB, void *el, int timeout, int *lost_msg)
unsigned long k_millis_counter
int k_unused_stak(struct k_t *t)
int k_stk_chk(struct k_t *t)
char k_send(struct k_msg_t *pB, void *el)
char ki_receive(struct k_msg_t *pB, void *el, int *lost_msg)
int k_mut_ceil_enter(struct k_t *sem, int timeout)
char ki_send(struct k_msg_t *pB, void *el)
void ki_task_shift(void) __attribute__((naked))
int k_set_sem_timer(struct k_t *sem, int val)
int ki_msg_count(struct k_msg_t *m)
volatile char krnl_preempt_flag
int k_stop(unsigned int exitVal)
int k_wait(struct k_t *sem, int timeout)
int ki_semval(struct k_t *sem)
unsigned long k_millis(void)
void k_eat_ticks(int ticks)
unsigned long ki_millis(void)
struct k_msg_t * send_pool