My Project - RET HER  versionsnr
krnl.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  k_t
 
struct  k_msg_t
 

Macros

#define KRNL_VRS   20210114
 
#define sbi(r, b)   r |= _BV(b)
 
#define cbi(r, b)   r &= ~_BV(b)
 
#define cbi(r, b)   r &= ~_BV(b)
 
#define K_BUGBLINK   0
 
#define KRNL
 
#define KRNLBUG   1
 
#define DYNMEMORY   1
 
#define WDT_PERIOD   WDTO_1S
 
#define QHD_PRIO   102
 
#define DMY_PRIO   (QHD_PRIO - 2)
 
#define ZOMBI_PRIO   (QHD_PRIO - 1)
 
#define DMY_STK_SZ   90
 
#define MAIN_PRIO   50
 
#define STAK_HASH   0x5c
 
#define MAX_SEM_VAL   50
 
#define MAX_INT   0x7FFF
 
#define SEM_MAX_VALUE   32000
 
#define BACKSTOPPER   1
 
#define CEILINGFAIL   -3
 
#define lo8(X)   ((unsigned char)((unsigned int)(X)))
 
#define hi8(X)   ((unsigned char)((unsigned int)(X) >> 8))
 
#define K_CHG_STAK()
 
#define k_eat_msec_time(x)   _delay_ms(x)
 

Functions

void * k_malloc (int k)
 
void k_free (void *m)
 
void __attribute__ ((weak)) k_enable_wdt(void)
 
unsigned long ki_millis (void)
 
unsigned long k_millis (void)
 
void k_eat_ticks (int ticks)
 
void ki_task_shift (void) __attribute__((naked))
 
int k_sleep (int time)
 
struct k_tk_crt_task (void(*pTask)(void), char prio, int stkSize)
 
int k_set_prio (char prio)
 
struct k_tk_crt_sem (char init_val, int maxvalue)
 
int k_mut_ceil_set (struct k_t *sem, char prio)
 
int k_mut_ceil_enter (struct k_t *sem, int timeout)
 
int k_mut_ceil_leave (struct k_t *sem)
 
int k_set_sem_timer (struct k_t *sem, int val)
 
int ki_signal (struct k_t *sem)
 
int k_signal (struct k_t *sem)
 
int k_wait (struct k_t *sem, int timeout)
 
int k_sem_signals_lost (struct k_t *sem)
 
int ki_wait (struct k_t *sem, int timeout)
 
int ki_semval (struct k_t *sem)
 
int k_semval (struct k_t *sem)
 
int ki_msg_count (struct k_msg_t *m)
 
int k_msg_count (struct k_msg_t *m)
 
struct k_msg_tk_crt_send_Q (int nr_el, int el_size, void *pBuf)
 
char ki_send (struct k_msg_t *pB, void *el)
 
char k_send (struct k_msg_t *pB, void *el)
 
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)
 
int k_tmrInfo (void)
 
int k_init (int nrTask, int nrSem, int nrMsg)
 
int k_start (int tm)
 
int k_stop (unsigned int exitVal)
 
void k_reset ()
 
int k_stk_chk (struct k_t *t)
 
int k_unused_stak (struct k_t *t)
 
void k_round_robbin (void)
 
void k_release (void)
 
int freeRam (void)
 

Variables

int k_config
 
int k_task
 
int k_sem
 
int k_msg
 
volatile char krnl_preempt_flag
 
char dmy_stk [90]
 
struct k_ttask_pool
 
struct k_tsem_pool
 
struct k_t AQ
 
struct k_tpmain_el
 
struct k_tpAQ
 
struct k_tpDmy
 
struct k_tpRun
 
struct k_tpSleepSem
 
struct k_msg_tsend_pool
 
char nr_task
 
char nr_sem
 
char nr_send
 
volatile char k_running
 
volatile char k_err_cnt
 
unsigned long k_millis_counter
 
char k_preempt_flag
 
volatile char k_bug_on
 
void int nrClip
 
void int val
 

Macro Definition Documentation

◆ BACKSTOPPER

#define BACKSTOPPER   1

Definition at line 254 of file krnl.h.

◆ cbi [1/2]

#define cbi (   r,
 
)    r &= ~_BV(b)

Definition at line 209 of file krnl.h.

◆ cbi [2/2]

#define cbi (   r,
 
)    r &= ~_BV(b)

Definition at line 209 of file krnl.h.

◆ CEILINGFAIL

#define CEILINGFAIL   -3

Definition at line 256 of file krnl.h.

◆ DMY_PRIO

#define DMY_PRIO   (QHD_PRIO - 2)

Definition at line 240 of file krnl.h.

◆ DMY_STK_SZ

#define DMY_STK_SZ   90

Definition at line 242 of file krnl.h.

◆ DYNMEMORY

#define DYNMEMORY   1

Definition at line 230 of file krnl.h.

◆ hi8

#define hi8 (   X)    ((unsigned char)((unsigned int)(X) >> 8))

Definition at line 470 of file krnl.h.

◆ K_BUGBLINK

#define K_BUGBLINK   0

Definition at line 215 of file krnl.h.

◆ K_CHG_STAK

#define K_CHG_STAK ( )
Value:
if (pRun != AQ.next) \
{ \
pRun->sp_lo = SPL; \
pRun->sp_hi = SPH; \
pRun = AQ.next; \
k_breakout(); \
SPL = pRun->sp_lo; \
SPH = pRun->sp_hi; \
}

Definition at line 475 of file krnl.h.

◆ k_eat_msec_time

#define k_eat_msec_time (   x)    _delay_ms(x)

Eats CPU time in k_tick quants

Parameters
[in]eatTimenumber of k:ticks to eat

Definition at line 813 of file krnl.h.

◆ KRNL

#define KRNL

Definition at line 218 of file krnl.h.

◆ KRNL_VRS

#define KRNL_VRS   20210114

Definition at line 58 of file krnl.h.

◆ KRNLBUG

#define KRNLBUG   1

Definition at line 222 of file krnl.h.

◆ lo8

#define lo8 (   X)    ((unsigned char)((unsigned int)(X)))

Definition at line 469 of file krnl.h.

◆ MAIN_PRIO

#define MAIN_PRIO   50

Definition at line 243 of file krnl.h.

◆ MAX_INT

#define MAX_INT   0x7FFF

Definition at line 246 of file krnl.h.

◆ MAX_SEM_VAL

#define MAX_SEM_VAL   50

Definition at line 245 of file krnl.h.

◆ QHD_PRIO

#define QHD_PRIO   102

Definition at line 238 of file krnl.h.

◆ sbi

#define sbi (   r,
 
)    r |= _BV(b)

Definition at line 201 of file krnl.h.

◆ SEM_MAX_VALUE

#define SEM_MAX_VALUE   32000

Definition at line 248 of file krnl.h.

◆ STAK_HASH

#define STAK_HASH   0x5c

Definition at line 244 of file krnl.h.

◆ WDT_PERIOD

#define WDT_PERIOD   WDTO_1S

Definition at line 236 of file krnl.h.

◆ ZOMBI_PRIO

#define ZOMBI_PRIO   (QHD_PRIO - 1)

Definition at line 241 of file krnl.h.

Function Documentation

◆ __attribute__()

void __attribute__ ( (weak)  )

a function for overloading on usersite which is called when a semaphore is overflooding no reset occur - it's only reading out semaphore idendity Signal operations has not taken place ! 1: means first semahore allocated by user, 2 the next etc Interrupt is disabled when called and must not be enabled during.. so no print etc

Parameters
[in]nrid of semaphore 1,2,3,...
[in]nrClipnumber of times clip has occured (may be reset by call k_wait_lost)

called in a signal call val is sem val AFTER signal has taken place

called when wait called. val is sem value after countdown has taken place NB is the wait call willl not wait and there is no token at the semaphore val will be -1111

a function for overloading on usersite which is called when a msgQ is overflooding no reset occur - it's only readind out smsgQ idendity 1: means first msgQ allocated by user etc Interrupt is disabled when called and must not be enabled during.. so no print etc

Parameters
nr: id of send Q 0,1,2,...
nrClipnumber of times clip has occured (may be reset by call k_receive and lost parm not eq NULL)

Breakout function called from scheduler

◆ freeRam()

int freeRam ( void  )

returns amount of free memory in your system

Definition at line 654 of file krnl.c.

◆ k_crt_sem()

struct k_t* k_crt_sem ( char  init_val,
int  maxvalue 
)

creates a standard Dijkstra semaphore. It can be initialized to values in range [0..maxvalue]

Parameters
[in]init_valstartvalue of semaphore 0,1,2,... maxvalue
[in]maxvaluewhich is maxvalue semaphore can reach
Returns
handle to semaphore or NULL pointer
Remarks
only to be called before start of KRNL

Definition at line 772 of file krnl.c.

References k_t::ceiling_prio, k_t::clip, k_t::cnt1, k_t::cnt2, k_err_cnt, k_running, k_sem, k_t::maxv, k_t::next, k_t::nr, nr_sem, k_t::pred, k_t::prio, QHD_PRIO, k_t::saved_prio, SEM_MAX_VALUE, and sem_pool.

Referenced by k_crt_send_Q(), and k_init().

Here is the caller graph for this function:

◆ k_crt_send_Q()

struct k_msg_t* k_crt_send_Q ( int  nr_el,
int  el_size,
void *  pBuf 
)

◆ k_crt_task()

struct k_t* k_crt_task ( void(*)(void)  pTask,
char  prio,
int  stkSize 
)

creates a task and put it in the active Q

Parameters
[in]pTaskpointer to function for code ( void task(void) ...)
[in]prioPriority 1: highest (QHEAD_PRIO-1): lowest
[in]stkSizesize of data area(in bytes) to be used for stak
Returns
: pointer to task handle or NULL if no success
Remarks
only to be called before start of KRNL but after k_init

Definition at line 565 of file krnl.c.

References k_t::cnt1, k_t::cnt2, k_t::cnt3, DMY_PRIO, hi8, jumper(), k_err_cnt, k_running, k_task, lo8, k_t::maxv, k_t::nr, nr_task, pAQ, k_t::prio, prio_enQ(), k_t::pt, k_t::sp_hi, k_t::sp_lo, STAK_HASH, and task_pool.

Referenced by setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ k_eat_ticks()

void k_eat_ticks ( int  ticks)

eat time in quant og krnl ticks starting from now but not from next tick

Definition at line 687 of file krnl.c.

References k_tick_size.

◆ k_free()

void k_free ( void *  m)

call free empty - no function if dft as weak so you can supply with your own

Remarks
do no free mem bq we do not want fragmented memory

◆ k_init()

int k_init ( int  nrTask,
int  nrSem,
int  nrMsg 
)

Initialise KRNL. First function to be called. You have to give max number of tasks, semaphores and message queues you will use

Parameters
[in]nrTask...
[in]nrSem...
[in]nrMsg...

void setup() { allocate resources for creation of 3 tasks 2 semaphores 1 mailboxes k_init(3,2,1); ...
}

Definition at line 1261 of file krnl.c.

References AQ, DMY_PRIO, k_crt_sem(), k_err_cnt, k_msg, k_running, k_sem, k_task, nr_send, nr_task, pAQ, pmain_el, prio_enQ(), pSleepSem, QHD_PRIO, sem_pool, send_pool, and task_pool.

Referenced by setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ k_malloc()

void* k_malloc ( int  k)

call malloc protected by DI and EI if dft as weak so you can supply with your own

◆ k_millis()

unsigned long k_millis ( void  )

Returns nr of milliseconds since krnl was started by k_start

Returns
: unsigned long is returned
Remarks
only to be called after start of KRNL
Interrupt is disabled when reading krnl time and is enabled afterwards

Definition at line 1443 of file krnl.c.

References k_millis_counter.

◆ k_msg_count()

int k_msg_count ( struct k_msg_t m)

returns nr of pending messages

Parameters
[in]msgbufferhandle
Returns
1: ok not suspended, 0: ok you have been suspended
-1 no wait maybe bq no timeout was allowed
Remarks
only to be called after start of KRNL

Definition at line 1033 of file krnl.c.

References ki_msg_count().

Here is the call graph for this function:

◆ k_mut_ceil_enter()

int k_mut_ceil_enter ( struct k_t sem,
int  timeout 
)

Enter mutex (eq to k_wait...) use k_mut_enter / k_mut_leave instead of wait and signal

Parameters
[in]semaka mutex
[in]timeouttimeout value
Returns
0: if you have been waiting, 1 if you just went through, -1 for timeout, -3 if your priority was higher than ceiling priority

Definition at line 939 of file krnl.c.

References k_t::ceiling_prio, CEILINGFAIL, deQ(), ki_task_shift(), ki_wait(), pAQ, prio_enQ(), pRun, and k_t::saved_prio.

Here is the call graph for this function:

◆ k_mut_ceil_leave()

int k_mut_ceil_leave ( struct k_t sem)

Leave mutex (eq to k_signal...) use k_mut_enter/ k_mut_leave instead of wait and signal

Parameters
[in]semused as mutex
Returns
0: ok otherwise bad bad

Definition at line 975 of file krnl.c.

References k_t::ceiling_prio, deQ(), k_signal(), ki_signal(), ki_task_shift(), pAQ, prio_enQ(), pRun, and k_t::saved_prio.

Here is the call graph for this function:

◆ k_mut_ceil_set()

int k_mut_ceil_set ( struct k_t sem,
char  prio 
)

adds ceiling priority to semaphore use k_mut_ceil_enter k_mut_ceil_leave instead of wait and signal Can only be called before k_start

Parameters
[in]semreference to sem used for mutex - no check
[in]prioCeiling pirority
Returns
0: ok , otherwise bad bad
Remarks
only to be called before start of KRNL

Definition at line 753 of file krnl.c.

References k_t::ceiling_prio, DMY_PRIO, k_running, and k_t::prio.

◆ k_receive()

char k_receive ( struct k_msg_t pB,
void *  el,
int  timeout,
int *  lost_msg 
)

Receive data (one element of el_size)in the ringbuffer if there are data DONE BY COPY !

Parameters
[in]pBRef to message buffer
[out]elReference to where data shall be copied to at your site
[in]timeoutMax time you want to wait on data, -1: never, 0: forever, positive: nr of KRNL timer quants
[out]lost_msgnr of lost messages since last receive. will clip at 10000. If lost_msg ptr is NULL then overrun counter is not reset to 0.
Returns
1: ok no suspension, 0: operation did succed, -1: no data in ringbuffer
Remarks
only to be called after start of KRNL

Definition at line 1182 of file krnl.c.

References k_msg_t::cnt, k_msg_t::el_size, ki_wait(), k_msg_t::lost_msg, k_msg_t::nr_el, k_msg_t::pBuf, k_msg_t::r, and k_msg_t::sem.

Here is the call graph for this function:

◆ k_release()

void k_release ( void  )

release switch running to task in front of Active Q

Definition at line 1237 of file krnl.c.

References ki_task_shift().

Here is the call graph for this function:

◆ k_reset()

void k_reset ( )

Reset by disable interrupt plus activate watchdog (15 millisseconds) and just wait...

◆ k_round_robbin()

void k_round_robbin ( void  )

round robbin

Returns
: current state: 1 preempt sch. 0 non preempt

Definition at line 1225 of file krnl.c.

References deQ(), ki_task_shift(), pAQ, prio_enQ(), and pRun.

Here is the call graph for this function:

◆ k_sem_signals_lost()

int k_sem_signals_lost ( struct k_t sem)

Returns how many signals has been lost on semaphore due to saturation

Parameters
[in]semsemaphore handle
Returns
nr of signals lost
Remarks
only to be called after start of KRNL

Definition at line 999 of file krnl.c.

References k_t::clip.

◆ k_semval()

int k_semval ( struct k_t sem)

returns value of semaphore

Parameters
[in]semsemaphore handle
Returns
1: ok not suspended, 0: ok you have been suspended
-1 no wait maybe bq no timeout was allowed
Remarks
only to be called after start of KRNL

Definition at line 1019 of file krnl.c.

References ki_semval().

Here is the call graph for this function:

◆ k_send()

char k_send ( struct k_msg_t pB,
void *  el 
)

Put data (one element of el_size)in the ringbuffer if there are room for it. DONE BY COPY !

Parameters
[in]pBRef to message buffer
[in]elReference to data to be put in buffer. Size if already given in k_crt_send
Returns
0: operation did succed, -1: no room in ringbuffer
Remarks
only to be called after start of KRNL
k_send does not block if no space in buffer. Instead -1 is returned

Definition at line 1129 of file krnl.c.

References ki_send(), and ki_task_shift().

Here is the call graph for this function:

◆ k_set_prio()

int k_set_prio ( char  prio)

change priority of calling task)

Parameters
[in]prionew prio, Priority 1: highest (QHEAD_PRIO-1): lowest
Returns
: 0: ok, -1: KRNL not running, -2: illegal value
Remarks
only to be called after start of KRNL

Definition at line 725 of file krnl.c.

References deQ(), DMY_PRIO, k_running, ki_task_shift(), pAQ, k_t::prio, prio_enQ(), and pRun.

Referenced by jumper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ k_set_sem_timer()

int k_set_sem_timer ( struct k_t sem,
int  val 
)

attach a timer to the semaphore so KRNL will signal the semaphore with regular intervals. Can be used for cyclic real time run of a task.

Parameters
[in]semsemaphore handle
[in]valinterval in quant of KRNL ticks (0: disable cyclic timer, 1,2,3... cyclic quant)
Returns
-1: negative val, 0. ok
Remarks
only to be called after start of KRNL

Definition at line 814 of file krnl.c.

References k_t::cnt2, k_t::cnt3, and val.

◆ k_signal()

int k_signal ( struct k_t sem)

Signal a semaphore. Task shift will task place if a task is started by the signal and has higher priority than you.

Parameters
[in]semsemaphore handle
Returns
0: ok , -1: max value of semaphore reached
Remarks
The ki_ indicates that interrups is NOT enabled when leaving ki_signal
only to be called after start of KRNL

Definition at line 867 of file krnl.c.

References ki_signal(), and ki_task_shift().

Referenced by k_mut_ceil_leave().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ k_sleep()

int k_sleep ( int  time)

Set task asleep for a number of ticks.

Parameters
[in]timenr of ticks to sleep < 0
Returns
: 0 is ok(has been suspended), 1(is not suspended), -1 is wait time is less than 0
Remarks
only to be called after start of KRNL

Definition at line 677 of file krnl.c.

References k_wait(), and pSleepSem.

Referenced by t1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ k_start()

int k_start ( int  tm)

start KRNL with tm tick speed (1= 1 msec, 5 = 5 msec)

Parameters
[in]tmTick length in milli seconds(1..10,20,30..10000
Returns
-1-333 nr of k_Crt calls that went wrong. krnl did not start -111 tick must be 1 bq we are using timer0 and shall maintain millis (std setup) -555 negative tick parm value -666 bad tick quant (legal is 1-10,20,30-10000
Remarks
only to be called after init of KRNL
KRNL WILL NOT START IF YOU HAVE TRIED TO CREATE MORE TASKS/SEMS/MSG QS THAN YOU HAVE ALLOCATED SPACE FOR IN k_init !!!
int errcode = k_start(1);
// if we are coming here its bq 1) KRNL is stopped you errcode will by parameter from k_stop call. Dont use a neg value !
// ir errcode is negatvie KRNL has not being due to errors during init calls like k_crt_sem
// chek if you have allocated enough buffers for tasks, semaphore and mailboxes in k_init call

Definition at line 1303 of file krnl.c.

References fakecnt, fakecnt_preset, k_err_cnt, k_running, k_tick_size, ki_task_shift(), pmain_el, pRun, stopp, and tcntValue.

Referenced by setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ k_stk_chk()

int k_stk_chk ( struct k_t t)

Initialise blink on pin 13 ON when dummy is running Nov 2014 - fake do not use it bq it will not work for emergency use :-) returns nr of unbytes bytes on stak. For chekking if stak is too big or to small...

Parameters
[in]tReference to task (by task handle) If null then yourself
Returns
: nr of unused bytes on stak (int)
Remarks
only to be called after start of KRNL
no chk of if it is a valid task

◆ k_stop()

int k_stop ( unsigned int  exitVal)

stop KRNL

Parameters
[in]exitValWill be returned in k_start to creator (old main)
Remarks
only to be called after k_start
you will only return from k_stop if krnl is not running
ONLY use positive numbers for exitVal because errors during initialization (code between k_init and k_start) then k_start returns negative numbers

Definition at line 1407 of file krnl.c.

References AQ, k_running, ki_task_shift(), pmain_el, and stopp.

Here is the call graph for this function:

◆ k_tmrInfo()

int k_tmrInfo ( void  )

returns which timer is used

Returns
0,1,2,3,4,5 ...

Definition at line 1453 of file krnl.c.

◆ k_unused_stak()

int k_unused_stak ( struct k_t t)

Returns amount of unused stak

Parameters
[in]tPtr to taskdescriptor. If NULL it is yourself
Returns
: amount of unused stak(in bytes)
Remarks
: a watermark philosophy is used

Definition at line 698 of file krnl.c.

References k_t::cnt1, pRun, and STAK_HASH.

◆ k_wait()

int k_wait ( struct k_t sem,
int  timeout 
)

Wait on a semaphore. Task shift will task place if you are blocked.

Parameters
[in]semsemaphore handle
[in]timeout"<0" you will be started after timeout ticks, "=0" wait forever "-1" you will not wait
Returns
1: ok there was a signal hanging - so no suspension
0: ok- you have been suspended
-1: timeout has occured, -2 no wait bq timeout was -1 and semaphore was negative
Remarks
only to be called after start of KRNL

Definition at line 930 of file krnl.c.

References ki_wait().

Referenced by k_sleep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ki_millis()

unsigned long ki_millis ( void  )

Returns nr of milliseconds since krnl was started by k_start

Returns
: unsigned long is returned
Remarks
only to be called after start of KRNL and only when interrupt is disabled
To be called within an ISR so interrupts is no disabled

Definition at line 1434 of file krnl.c.

References k_millis_counter.

◆ ki_msg_count()

int ki_msg_count ( struct k_msg_t m)

returns nr of pending messages

Parameters
[in]msgbufferhandle
Returns
1: ok not suspended, 0: ok you have been suspended
-1 no wait maybe bq no timeout was allowed
Remarks
only to be called after start of KRNL

Definition at line 1027 of file krnl.c.

References k_msg_t::cnt.

Referenced by k_msg_count().

Here is the caller graph for this function:

◆ ki_receive()

char ki_receive ( struct k_msg_t pB,
void *  el,
int *  lost_msg 
)

Receive data (one element of el_size)in the ringbuffer if there are data DONE BY COPY ! No blocking if no data Interrupt will not be enabled after ki_receive

Parameters
[in]pBRef to message buffer
[out]elReference to where data shall be copied to at your site
[out]lost_msgnr of lost messages since last receive. will clip at 10000. If lost_msg ptr is NULL then overrun counter is not reset to 0
Returns
1: data was rdy no suspension, 0: ok you have been suspended , -1: no data in ringbuffer
Remarks
can be used from ISR
only to be called after start of KRNL

Definition at line 1145 of file krnl.c.

References k_msg_t::cnt, k_msg_t::el_size, ki_wait(), k_msg_t::lost_msg, k_msg_t::nr_el, k_msg_t::pBuf, k_msg_t::r, and k_msg_t::sem.

Here is the call graph for this function:

◆ ki_semval()

int ki_semval ( struct k_t sem)

returns value of semaphore

Parameters
[in]semsemaphore handle
Returns
1: ok not suspended, 0: ok you have been suspended
-1 no wait maybe bq no timeout was allowed
Remarks
only to be called after start of KRNL
do not enable interrupt upon leaving

Definition at line 1012 of file krnl.c.

References k_t::cnt1.

Referenced by k_semval().

Here is the caller graph for this function:

◆ ki_send()

char ki_send ( struct k_msg_t pB,
void *  el 
)

Put data (one element of el_size)in the ringbuffer if there are room for it. Intended for ISR use DONE BY COPY !

Parameters
[in]pBRef to message buffer
[in]elReference to data to be put in buffer. Size if already given in k_crt_send
Returns
0: operation did succed, -1: no room in ringbuffer
Remarks
Interrupt will not enabled upon leaving, so ki_send is intended to be used from an ISR
only to be called before start of KRNL

Definition at line 1087 of file krnl.c.

References k_msg_t::cnt, k_msg_t::el_size, ki_signal(), k_msg_t::lost_msg, k_msg_t::nr, k_msg_t::nr_el, k_msg_t::pBuf, k_msg_t::sem, SEM_MAX_VALUE, and k_msg_t::w.

Referenced by k_send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ki_signal()

int ki_signal ( struct k_t sem)

Signal a semaphore. Can be called from an ISR when interrupt is disabled. No task shift will occur - only queue manipulation.

Parameters
[in]semsemaphore handle
Returns
0: ok , -1: max value of semaphore reached
Remarks
only to be called after start of KRNL

Definition at line 830 of file krnl.c.

References k_t::clip, k_t::cnt1, k_t::cnt2, deQ(), k_t::maxv, k_t::next, k_t::nr, pAQ, prio_enQ(), and SEM_MAX_VALUE.

Referenced by ISR(), k_mut_ceil_leave(), k_signal(), and ki_send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ki_task_shift()

void ki_task_shift ( void  )

issues a task shift - handle with care Not to be used by normal user

Referenced by k_mut_ceil_enter(), k_mut_ceil_leave(), k_release(), k_round_robbin(), k_send(), k_set_prio(), k_signal(), k_start(), k_stop(), and ki_wait().

Here is the caller graph for this function:

◆ ki_wait()

int ki_wait ( struct k_t sem,
int  timeout 
)

Like k_wait with the exception interrupt is NOT enabled when leaving

Parameters
[in]semsemaphore handle
[in]timeout"<0" you will be started after timeout ticks, "=0" wait forever "-1" you will not wait
Returns
0: ok , -1: could do wait bw blocking would have taken place
Remarks
The ki_ indicates that interrups is NOT enabled when leaving ki_wait
only to be called after start of KRNL
normally not to be used by users !!! BEWARE

Definition at line 886 of file krnl.c.

References k_t::cnt1, deQ(), enQ(), ki_task_shift(), k_t::nr, and pRun.

Referenced by k_mut_ceil_enter(), k_receive(), k_wait(), and ki_receive().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ AQ

struct k_t AQ

Definition at line 367 of file krnl.h.

◆ dmy_stk

char dmy_stk[90]

◆ k_bug_on

volatile char k_bug_on

◆ k_config

int k_config

Definition at line 279 of file krnl.c.

◆ k_err_cnt

volatile char k_err_cnt

Definition at line 298 of file krnl.c.

Referenced by k_crt_sem(), k_crt_send_Q(), k_crt_task(), k_init(), and k_start().

◆ k_millis_counter

unsigned long k_millis_counter

Definition at line 306 of file krnl.c.

Referenced by ISR(), k_millis(), and ki_millis().

◆ k_msg

int k_msg

Definition at line 330 of file krnl.h.

◆ k_preempt_flag

char k_preempt_flag

◆ k_running

volatile char k_running

◆ k_sem

int k_sem

Definition at line 330 of file krnl.h.

◆ k_task

int k_task

Definition at line 295 of file krnl.c.

Referenced by k_crt_task(), and k_init().

◆ krnl_preempt_flag

volatile char krnl_preempt_flag

◆ nr_sem

char nr_sem

Definition at line 374 of file krnl.h.

◆ nr_send

char nr_send

Definition at line 374 of file krnl.h.

◆ nr_task

char nr_task

Definition at line 296 of file krnl.c.

Referenced by ISR(), k_crt_task(), and k_init().

◆ nrClip

void int nrClip

Definition at line 1012 of file krnl.h.

◆ pAQ

struct k_t * pAQ

Definition at line 368 of file krnl.h.

◆ pDmy

struct k_t * pDmy

Definition at line 368 of file krnl.h.

◆ pmain_el

struct k_t * pmain_el

Definition at line 368 of file krnl.h.

◆ pRun

struct k_t * pRun

Definition at line 369 of file krnl.h.

◆ pSleepSem

struct k_t * pSleepSem

Definition at line 370 of file krnl.h.

◆ sem_pool

struct k_t * sem_pool

Definition at line 367 of file krnl.h.

◆ send_pool

struct k_msg_t* send_pool

Definition at line 293 of file krnl.c.

Referenced by k_crt_send_Q(), and k_init().

◆ task_pool

struct k_t* task_pool

Referenced by ISR(), k_crt_task(), and k_init().

◆ val

void int val

Definition at line 1019 of file krnl.h.

Referenced by k_set_sem_timer().

k_t::sp_hi
volatile char sp_hi
Definition: krnl.h:344
k_t::sp_lo
volatile char sp_lo
Definition: krnl.h:343
pRun
struct k_t * pRun
Definition: krnl.h:369
AQ
struct k_t AQ
Definition: krnl.h:367
k_t::next
struct k_t * next
Definition: krnl.h:341
k_start
int k_start(int tick)
Definition: krnl.c:1303