My Project - RET HER
versionsnr
|
Go to the documentation of this file.
150 #include <avr/interrupt.h>
151 #include <util/delay.h>
155 #if (F_CPU == 8000000)
156 #pragma message("krnl detected 8 MHz")
159 #if (KRNL_VRS != 20191008)
160 #error "KRNL VERSION NOT UPDATED in krnl.c "
182 #define KRNLTMRVECTOR TIMER0_OVF_vect
198 #define KRNLTMRVECTOR TIMER1_OVF_vect
200 #define TCCRxA TCCR1A
201 #define TCCRxB TCCR1B
204 #define TIMSKx TIMSK1
206 #define PRESCALE 0x03
207 #define COUNTMAX 0xffff
209 #define DIVV8 (DIVV / 2)
215 #define KRNLTMRVECTOR TIMER2_OVF_vect
217 #define TCCRxA TCCR2A
218 #define TCCRxB TCCR2B
221 #define TIMSKx TIMSK2
223 #define PRESCALE 0x05
230 #define KRNLTMRVECTOR TIMER3_OVF_vect
232 #define TCCRxA TCCR3A
233 #define TCCRxB TCCR3B
236 #define TIMSKx TIMSK3
238 #define PRESCALE 0x03
239 #define COUNTMAX 0xffff
241 #define DIVV8 (DIVV / 2)
245 #define KRNLTMRVECTOR TIMER4_OVF_vect
247 #define TCCRxA TCCR4A
248 #define TCCRxB TCCR4B
251 #define TIMSKx TIMSK4
253 #define PRESCALE 0x03
254 #define COUNTMAX 0xffff
256 #define DIVV8 (DIVV / 2)
260 #define KRNLTMRVECTOR TIMER5_OVF_vect
262 #define TCCRxA TCCR5A
263 #define TCCRxB TCCR5B
266 #define TIMSKx TIMSK5
268 #define PRESCALE 0x03
269 #define COUNTMAX 0xffff
271 #define DIVV8 (DIVV / 2)
275 #pragma err "KRNL: no valid tmr selected"
387 #define MICROSECONDS_PER_TIMER0_OVERFLOW (1024) //clockCyclesToMicroseconds(64 * 256))
390 #define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000)
395 #define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3)
396 #define FRACT_MAX (1000 >> 3)
418 static struct k_t *pE;
579 pStak = malloc(stkSize);
591 pT->
cnt1 = (int)(pStk);
594 for (i = 0; i < stkSize; i++)
599 s = pStk + stkSize - 1;
613 #if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
625 #if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega2561__)
630 #if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2561__)
634 for (i = 0; i < 30; i++)
657 extern int __heap_start, *__brkval;
660 x = ((int)&v - (__brkval == 0 ? (
int)&__heap_start : (int)__brkval));
706 pstk = (
char *)(t->
cnt1);
710 pstk = (
char *)(
pRun->cnt1);
799 sem->
cnt1 = init_val;
801 sem->
maxv = maxvalue;
839 k_sem_signal(sem->
nr, sem->
cnt1);
862 k_sem_clip(sem->
nr, sem->
clip);
895 k_sem_wait(sem->
nr, sem->
cnt1);
904 k_sem_wait(sem->
nr, -1111);
909 pRun->cnt2 = timeout;
913 pRun->cnt3 = (int)sem;
919 k_sem_wait(sem->
nr, sem->
cnt1);
928 return ((
char)(
pRun->cnt2));
935 retval =
ki_wait(sem, timeout);
947 retval =
ki_wait(sem, timeout);
962 retval =
ki_wait(sem, timeout);
1069 if (pMsg->
sem == NULL)
1075 pMsg->
r = pMsg->
w = -1;
1121 for (i = 0; i < pB->
el_size; i++)
1124 *(pDst++) = *(pSrc++);
1149 char r, *pSrc, *pDst;
1168 for (i = 0; i < pB->
el_size; i++)
1170 *(pDst++) = *(pSrc++);
1187 char r, *pSrc, *pDst;
1207 for (i = 0; i < pB->
el_size; i++)
1209 *(pDst++) = *(pSrc++);
1270 k_sem = nrSem + nrMsg + 1;
1363 #if defined(__AVR_ATmega32U4__)
1374 if (F_CPU == 16000000L)
1386 TIMSKx |= (1 << TOIEx);
1423 TIMSKx &= ~(1 << TOIEx);
1462 char k_set_preempt(
char on)
1473 char k_get_preempt(
void)
struct k_t * deQ(struct k_t *el)
volatile unsigned long timer0_millis
int k_mut_ceil_set(struct k_t *sem, char prio)
int k_set_prio(char prio)
int k_sem_signals_lost(struct k_t *sem)
int k_unused_stak(struct k_t *t)
char k_send(struct k_msg_t *pB, void *el)
volatile unsigned long timer0_overflow_count
unsigned long ki_millis(void)
struct k_msg_t * send_pool
int ki_semval(struct k_t *sem)
unsigned long k_millis(void)
unsigned char timer0_fract
void k_round_robbin(void)
int k_signal(struct k_t *sem)
unsigned long k_millis_counter
void enQ(struct k_t *Q, struct k_t *el)
int k_mut_ceil_leave(struct k_t *sem)
volatile int fakecnt_preset
int k_init(int nrTask, int nrSem, int nrMsg)
void prio_enQ(struct k_t *Q, struct k_t *el)
int ki_wait(struct k_t *sem, int timeout)
int k_stop(unsigned int exitVal)
int k_mut_ceil_enter(struct k_t *sem, int timeout)
volatile unsigned int tcntValue
static volatile char stopp
int k_set_sem_timer(struct k_t *sem, int val)
int ki_msg_count(struct k_msg_t *m)
void ki_task_shift(void) __attribute__((naked))
int k_wait(struct k_t *sem, int timeout)
char ki_send(struct k_msg_t *pB, void *el)
struct k_t * k_crt_sem(char init_val, int maxvalue)
struct k_t * k_crt_task(void(*pTask)(void), char prio, int stkSize)
ISR(KRNLTMRVECTOR, ISR_NAKED)
void __attribute__((naked, noinline))
void k_eat_ticks(int ticks)
int ki_signal(struct k_t *sem)
int k_semval(struct k_t *sem)
int k_msg_count(struct k_msg_t *m)
char k_receive(struct k_msg_t *pB, void *el, int timeout, int *lost_msg)
char ki_receive(struct k_msg_t *pB, void *el, int *lost_msg)
struct k_msg_t * k_crt_send_Q(int nr_el, int el_size, void *pBuf)