diff --git a/README.md b/README.md index 79d38f4c..4c1efcd0 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Features -------- - kernel works in preemptive or cooperative mode +- kernel can operate with 16, 32 or 64-bit timer counter - kernel can operate in tick-less mode - signals (clear, protect) - events diff --git a/StateOS/README b/StateOS/README index ab98a9fa..ce318c04 100644 --- a/StateOS/README +++ b/StateOS/README @@ -9,6 +9,7 @@ There's a dedicated function for immediate change the task state. --------- Features: - kernel works in preemptive or cooperative mode +- kernel can operate with 16, 32 or 64-bit timer counter - kernel can operate in tick-less mode - signals (clear, protect) - events @@ -45,6 +46,7 @@ Features: - updated tick-less mode - updated waitUntil functions - removed OS_TICKLESS definition, tick-less mode depends on OS_FREQUENCY value +- os can work with 16, 32 or 64-bit timer counter --------- 5.4 - added startup files for cosmic compiler diff --git a/StateOS/kernel/inc/os_bar.h b/StateOS/kernel/inc/os_bar.h index c0759b54..ab263924 100644 --- a/StateOS/kernel/inc/os_bar.h +++ b/StateOS/kernel/inc/os_bar.h @@ -2,7 +2,7 @@ @file StateOS: os_bar.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -237,7 +237,7 @@ void bar_delete( bar_t *bar ); * ******************************************************************************/ -unsigned bar_waitUntil( bar_t *bar, uint32_t time ); +unsigned bar_waitUntil( bar_t *bar, cnt_t time ); /****************************************************************************** * @@ -260,7 +260,7 @@ unsigned bar_waitUntil( bar_t *bar, uint32_t time ); * ******************************************************************************/ -unsigned bar_waitFor( bar_t *bar, uint32_t delay ); +unsigned bar_waitFor( bar_t *bar, cnt_t delay ); /****************************************************************************** * @@ -307,10 +307,10 @@ struct Barrier : public __bar Barrier( const unsigned _limit ): __bar _BAR_INIT(_limit) {} ~Barrier( void ) { assert(queue == nullptr); } - void kill ( void ) { bar_kill (this); } - unsigned waitUntil( uint32_t _time ) { return bar_waitUntil(this, _time); } - unsigned waitFor ( uint32_t _delay ) { return bar_waitFor (this, _delay); } - unsigned wait ( void ) { return bar_wait (this); } + void kill ( void ) { bar_kill (this); } + unsigned waitUntil( cnt_t _time ) { return bar_waitUntil(this, _time); } + unsigned waitFor ( cnt_t _delay ) { return bar_waitFor (this, _delay); } + unsigned wait ( void ) { return bar_wait (this); } }; #endif diff --git a/StateOS/kernel/inc/os_box.h b/StateOS/kernel/inc/os_box.h index 95d2eea6..8d675754 100644 --- a/StateOS/kernel/inc/os_box.h +++ b/StateOS/kernel/inc/os_box.h @@ -2,7 +2,7 @@ @file StateOS: os_box.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -274,7 +274,7 @@ void box_delete( box_t *box ); * ******************************************************************************/ -unsigned box_waitUntil( box_t *box, void *data, uint32_t time ); +unsigned box_waitUntil( box_t *box, void *data, cnt_t time ); /****************************************************************************** * @@ -299,7 +299,7 @@ unsigned box_waitUntil( box_t *box, void *data, uint32_t time ); * ******************************************************************************/ -unsigned box_waitFor( box_t *box, void *data, uint32_t delay ); +unsigned box_waitFor( box_t *box, void *data, cnt_t delay ); /****************************************************************************** * @@ -370,7 +370,7 @@ unsigned box_takeISR( box_t *box, void *data ) { return box_waitFor(box, data, I * ******************************************************************************/ -unsigned box_sendUntil( box_t *box, const void *data, uint32_t time ); +unsigned box_sendUntil( box_t *box, const void *data, cnt_t time ); /****************************************************************************** * @@ -395,7 +395,7 @@ unsigned box_sendUntil( box_t *box, const void *data, uint32_t time ); * ******************************************************************************/ -unsigned box_sendFor( box_t *box, const void *data, uint32_t delay ); +unsigned box_sendFor( box_t *box, const void *data, cnt_t delay ); /****************************************************************************** * @@ -474,17 +474,17 @@ struct baseMailBoxQueue : public __box baseMailBoxQueue( const unsigned _limit, const unsigned _size, char * const _data ): __box _BOX_INIT(_limit, _size, _data) {} ~baseMailBoxQueue( void ) { assert(queue == nullptr); } - void kill ( void ) { box_kill (this); } - unsigned waitUntil( void *_data, uint32_t _time ) { return box_waitUntil(this, _data, _time); } - unsigned waitFor ( void *_data, uint32_t _delay ) { return box_waitFor (this, _data, _delay); } - unsigned wait ( void *_data ) { return box_wait (this, _data); } - unsigned take ( void *_data ) { return box_take (this, _data); } - unsigned takeISR ( void *_data ) { return box_takeISR (this, _data); } - unsigned sendUntil( const void *_data, uint32_t _time ) { return box_sendUntil(this, _data, _time); } - unsigned sendFor ( const void *_data, uint32_t _delay ) { return box_sendFor (this, _data, _delay); } - unsigned send ( const void *_data ) { return box_send (this, _data); } - unsigned give ( const void *_data ) { return box_give (this, _data); } - unsigned giveISR ( const void *_data ) { return box_giveISR (this, _data); } + void kill ( void ) { box_kill (this); } + unsigned waitUntil( void *_data, cnt_t _time ) { return box_waitUntil(this, _data, _time); } + unsigned waitFor ( void *_data, cnt_t _delay ) { return box_waitFor (this, _data, _delay); } + unsigned wait ( void *_data ) { return box_wait (this, _data); } + unsigned take ( void *_data ) { return box_take (this, _data); } + unsigned takeISR ( void *_data ) { return box_takeISR (this, _data); } + unsigned sendUntil( const void *_data, cnt_t _time ) { return box_sendUntil(this, _data, _time); } + unsigned sendFor ( const void *_data, cnt_t _delay ) { return box_sendFor (this, _data, _delay); } + unsigned send ( const void *_data ) { return box_send (this, _data); } + unsigned give ( const void *_data ) { return box_give (this, _data); } + unsigned giveISR ( const void *_data ) { return box_giveISR (this, _data); } }; /****************************************************************************** diff --git a/StateOS/kernel/inc/os_cnd.h b/StateOS/kernel/inc/os_cnd.h index 1199bc9b..4ef6bf88 100644 --- a/StateOS/kernel/inc/os_cnd.h +++ b/StateOS/kernel/inc/os_cnd.h @@ -2,7 +2,7 @@ @file StateOS: os_cnd.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -236,7 +236,7 @@ void cnd_delete( cnd_t *cnd ); * ******************************************************************************/ -unsigned cnd_waitUntil( cnd_t *cnd, mtx_t *mtx, uint32_t time ); +unsigned cnd_waitUntil( cnd_t *cnd, mtx_t *mtx, cnt_t time ); /****************************************************************************** * @@ -261,7 +261,7 @@ unsigned cnd_waitUntil( cnd_t *cnd, mtx_t *mtx, uint32_t time ); * ******************************************************************************/ -unsigned cnd_waitFor( cnd_t *cnd, mtx_t *mtx, uint32_t delay ); +unsigned cnd_waitFor( cnd_t *cnd, mtx_t *mtx, cnt_t delay ); /****************************************************************************** * @@ -334,12 +334,12 @@ struct ConditionVariable : public __cnd ConditionVariable( void ): __cnd _CND_INIT() {} ~ConditionVariable( void ) { assert(queue == nullptr); } - void kill ( void ) { cnd_kill (this); } - unsigned waitUntil( mtx_t *_mtx, uint32_t _time ) { return cnd_waitUntil(this, _mtx, _time); } - unsigned waitFor ( mtx_t *_mtx, uint32_t _delay ) { return cnd_waitFor (this, _mtx, _delay); } - unsigned wait ( mtx_t *_mtx ) { return cnd_wait (this, _mtx); } - void give ( bool _all = cndAll ) { cnd_give (this, _all); } - void giveISR ( bool _all = cndAll ) { cnd_giveISR (this, _all); } + void kill ( void ) { cnd_kill (this); } + unsigned waitUntil( mtx_t *_mtx, cnt_t _time ) { return cnd_waitUntil(this, _mtx, _time); } + unsigned waitFor ( mtx_t *_mtx, cnt_t _delay ) { return cnd_waitFor (this, _mtx, _delay); } + unsigned wait ( mtx_t *_mtx ) { return cnd_wait (this, _mtx); } + void give ( bool _all = cndAll ) { cnd_give (this, _all); } + void giveISR ( bool _all = cndAll ) { cnd_giveISR (this, _all); } }; #endif diff --git a/StateOS/kernel/inc/os_evt.h b/StateOS/kernel/inc/os_evt.h index d3363834..7b8b4c0b 100644 --- a/StateOS/kernel/inc/os_evt.h +++ b/StateOS/kernel/inc/os_evt.h @@ -2,7 +2,7 @@ @file StateOS: os_evt.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -227,7 +227,7 @@ void evt_delete( evt_t *evt ); * ******************************************************************************/ -unsigned evt_waitUntil( evt_t *evt, uint32_t time ); +unsigned evt_waitUntil( evt_t *evt, cnt_t time ); /****************************************************************************** * @@ -250,7 +250,7 @@ unsigned evt_waitUntil( evt_t *evt, uint32_t time ); * ******************************************************************************/ -unsigned evt_waitFor( evt_t *evt, uint32_t delay ); +unsigned evt_waitFor( evt_t *evt, cnt_t delay ); /****************************************************************************** * @@ -320,8 +320,8 @@ struct Event : public __evt ~Event( void ) { assert(queue == nullptr); } void kill ( void ) { evt_kill (this); } - unsigned waitUntil( uint32_t _time ) { return evt_waitUntil(this, _time); } - unsigned waitFor ( uint32_t _delay ) { return evt_waitFor (this, _delay); } + unsigned waitUntil( cnt_t _time ) { return evt_waitUntil(this, _time); } + unsigned waitFor ( cnt_t _delay ) { return evt_waitFor (this, _delay); } unsigned wait ( void ) { return evt_wait (this); } void give ( unsigned _event ) { evt_give (this, _event); } void giveISR ( unsigned _event ) { evt_giveISR (this, _event); } diff --git a/StateOS/kernel/inc/os_flg.h b/StateOS/kernel/inc/os_flg.h index ffb47df4..3e6512f8 100644 --- a/StateOS/kernel/inc/os_flg.h +++ b/StateOS/kernel/inc/os_flg.h @@ -2,7 +2,7 @@ @file StateOS: os_flg.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -248,7 +248,7 @@ void flg_delete( flg_t *flg ); * ******************************************************************************/ -unsigned flg_waitUntil( flg_t *flg, unsigned flags, unsigned mode, uint32_t time ); +unsigned flg_waitUntil( flg_t *flg, unsigned flags, unsigned mode, cnt_t time ); /****************************************************************************** * @@ -278,7 +278,7 @@ unsigned flg_waitUntil( flg_t *flg, unsigned flags, unsigned mode, uint32_t time * ******************************************************************************/ -unsigned flg_waitFor( flg_t *flg, unsigned flags, unsigned mode, uint32_t delay ); +unsigned flg_waitFor( flg_t *flg, unsigned flags, unsigned mode, cnt_t delay ); /****************************************************************************** * @@ -407,16 +407,16 @@ struct Flag : public __flg Flag( void ): __flg _FLG_INIT() {} ~Flag( void ) { assert(queue == nullptr); } - void kill ( void ) { flg_kill (this); } - unsigned waitUntil( unsigned _flags, unsigned _mode, uint32_t _time ) { return flg_waitUntil(this, _flags, _mode, _time); } - unsigned waitFor ( unsigned _flags, unsigned _mode, uint32_t _delay ) { return flg_waitFor (this, _flags, _mode, _delay); } - unsigned wait ( unsigned _flags, unsigned _mode = flgAll ) { return flg_wait (this, _flags, _mode); } - unsigned take ( unsigned _flags, unsigned _mode = flgAll ) { return flg_take (this, _flags, _mode); } - unsigned takeISR ( unsigned _flags, unsigned _mode = flgAll ) { return flg_takeISR (this, _flags, _mode); } - unsigned give ( unsigned _flags ) { return flg_give (this, _flags); } - unsigned giveISR ( unsigned _flags ) { return flg_giveISR (this, _flags); } - unsigned clear ( unsigned _flags ) { return flg_clear (this, _flags); } - unsigned clearISR ( unsigned _flags ) { return flg_clearISR (this, _flags); } + void kill ( void ) { flg_kill (this); } + unsigned waitUntil( unsigned _flags, unsigned _mode, cnt_t _time ) { return flg_waitUntil(this, _flags, _mode, _time); } + unsigned waitFor ( unsigned _flags, unsigned _mode, cnt_t _delay ) { return flg_waitFor (this, _flags, _mode, _delay); } + unsigned wait ( unsigned _flags, unsigned _mode = flgAll ) { return flg_wait (this, _flags, _mode); } + unsigned take ( unsigned _flags, unsigned _mode = flgAll ) { return flg_take (this, _flags, _mode); } + unsigned takeISR ( unsigned _flags, unsigned _mode = flgAll ) { return flg_takeISR (this, _flags, _mode); } + unsigned give ( unsigned _flags ) { return flg_give (this, _flags); } + unsigned giveISR ( unsigned _flags ) { return flg_giveISR (this, _flags); } + unsigned clear ( unsigned _flags ) { return flg_clear (this, _flags); } + unsigned clearISR ( unsigned _flags ) { return flg_clearISR (this, _flags); } }; #endif diff --git a/StateOS/kernel/inc/os_job.h b/StateOS/kernel/inc/os_job.h index 866f23e8..41fb7135 100644 --- a/StateOS/kernel/inc/os_job.h +++ b/StateOS/kernel/inc/os_job.h @@ -2,7 +2,7 @@ @file StateOS: os_job.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -265,7 +265,7 @@ void job_delete( job_t *job ); * ******************************************************************************/ -unsigned job_waitUntil( job_t *job, uint32_t time ); +unsigned job_waitUntil( job_t *job, cnt_t time ); /****************************************************************************** * @@ -289,7 +289,7 @@ unsigned job_waitUntil( job_t *job, uint32_t time ); * ******************************************************************************/ -unsigned job_waitFor( job_t *job, uint32_t delay ); +unsigned job_waitFor( job_t *job, cnt_t delay ); /****************************************************************************** * @@ -354,7 +354,7 @@ unsigned job_take( job_t *job ) { return job_waitFor(job, IMMEDIATE); } * ******************************************************************************/ -unsigned job_sendUntil( job_t *job, fun_t *fun, uint32_t time ); +unsigned job_sendUntil( job_t *job, fun_t *fun, cnt_t time ); /****************************************************************************** * @@ -379,7 +379,7 @@ unsigned job_sendUntil( job_t *job, fun_t *fun, uint32_t time ); * ******************************************************************************/ -unsigned job_sendFor( job_t *job, fun_t *fun, uint32_t delay ); +unsigned job_sendFor( job_t *job, fun_t *fun, cnt_t delay ); /****************************************************************************** * @@ -459,16 +459,16 @@ struct baseJobQueue : public __box baseJobQueue( const unsigned _limit, FUN_t * const _data ): __box _BOX_INIT( _limit, sizeof(FUN_t), reinterpret_cast(_data) ) {} ~baseJobQueue( void ) { assert(queue == nullptr); } - void kill ( void ) { box_kill (this); } - unsigned waitUntil( uint32_t _time ) { FUN_t _fun; unsigned event = box_waitUntil(this, &_fun, _time); if (event == E_SUCCESS) _fun(); return event; } - unsigned waitFor ( uint32_t _delay ) { FUN_t _fun; unsigned event = box_waitFor (this, &_fun, _delay); if (event == E_SUCCESS) _fun(); return event; } - unsigned wait ( void ) { FUN_t _fun; unsigned event = box_wait (this, &_fun); if (event == E_SUCCESS) _fun(); return event; } - unsigned take ( void ) { FUN_t _fun; unsigned event = box_take (this, &_fun); if (event == E_SUCCESS) _fun(); return event; } - unsigned sendUntil( FUN_t _fun, uint32_t _time ) { unsigned event = box_sendUntil(this, &_fun, _time); return event; } - unsigned sendFor ( FUN_t _fun, uint32_t _delay ) { unsigned event = box_sendFor (this, &_fun, _delay); return event; } - unsigned send ( FUN_t _fun ) { unsigned event = box_send (this, &_fun); return event; } - unsigned give ( FUN_t _fun ) { unsigned event = box_give (this, &_fun); return event; } - unsigned giveISR ( FUN_t _fun ) { unsigned event = box_giveISR (this, &_fun); return event; } + void kill ( void ) { box_kill (this); } + unsigned waitUntil( cnt_t _time ) { FUN_t _fun; unsigned event = box_waitUntil(this, &_fun, _time); if (event == E_SUCCESS) _fun(); return event; } + unsigned waitFor ( cnt_t _delay ) { FUN_t _fun; unsigned event = box_waitFor (this, &_fun, _delay); if (event == E_SUCCESS) _fun(); return event; } + unsigned wait ( void ) { FUN_t _fun; unsigned event = box_wait (this, &_fun); if (event == E_SUCCESS) _fun(); return event; } + unsigned take ( void ) { FUN_t _fun; unsigned event = box_take (this, &_fun); if (event == E_SUCCESS) _fun(); return event; } + unsigned sendUntil( FUN_t _fun, cnt_t _time ) { unsigned event = box_sendUntil(this, &_fun, _time); return event; } + unsigned sendFor ( FUN_t _fun, cnt_t _delay ) { unsigned event = box_sendFor (this, &_fun, _delay); return event; } + unsigned send ( FUN_t _fun ) { unsigned event = box_send (this, &_fun); return event; } + unsigned give ( FUN_t _fun ) { unsigned event = box_give (this, &_fun); return event; } + unsigned giveISR ( FUN_t _fun ) { unsigned event = box_giveISR (this, &_fun); return event; } }; #else @@ -479,16 +479,16 @@ struct baseJobQueue : public __job baseJobQueue( const unsigned _limit, FUN_t * const _data ): __job _JOB_INIT( _limit, _data ) {} ~baseJobQueue( void ) { assert(queue == nullptr); } - void kill ( void ) { job_kill (this); } - unsigned waitUntil( uint32_t _time ) { return job_waitUntil(this, _time); } - unsigned waitFor ( uint32_t _delay ) { return job_waitFor (this, _delay); } - unsigned wait ( void ) { return job_wait (this); } - unsigned take ( void ) { return job_take (this); } - unsigned sendUntil( FUN_t _fun, uint32_t _time ) { return job_sendUntil(this, _fun, _time); } - unsigned sendFor ( FUN_t _fun, uint32_t _delay ) { return job_sendFor (this, _fun, _delay); } - unsigned send ( FUN_t _fun ) { return job_send (this, _fun); } - unsigned give ( FUN_t _fun ) { return job_give (this, _fun); } - unsigned giveISR ( FUN_t _fun ) { return job_giveISR (this, _fun); } + void kill ( void ) { job_kill (this); } + unsigned waitUntil( cnt_t _time ) { return job_waitUntil(this, _time); } + unsigned waitFor ( cnt_t _delay ) { return job_waitFor (this, _delay); } + unsigned wait ( void ) { return job_wait (this); } + unsigned take ( void ) { return job_take (this); } + unsigned sendUntil( FUN_t _fun, cnt_t _time ) { return job_sendUntil(this, _fun, _time); } + unsigned sendFor ( FUN_t _fun, cnt_t _delay ) { return job_sendFor (this, _fun, _delay); } + unsigned send ( FUN_t _fun ) { return job_send (this, _fun); } + unsigned give ( FUN_t _fun ) { return job_give (this, _fun); } + unsigned giveISR ( FUN_t _fun ) { return job_giveISR (this, _fun); } }; #endif diff --git a/StateOS/kernel/inc/os_lst.h b/StateOS/kernel/inc/os_lst.h index 4565f709..22da187c 100644 --- a/StateOS/kernel/inc/os_lst.h +++ b/StateOS/kernel/inc/os_lst.h @@ -2,7 +2,7 @@ @file StateOS: os_lst.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -230,7 +230,7 @@ void lst_delete( lst_t *lst ); * ******************************************************************************/ -unsigned lst_waitUntil( lst_t *lst, void **data, uint32_t time ); +unsigned lst_waitUntil( lst_t *lst, void **data, cnt_t time ); /****************************************************************************** * @@ -255,7 +255,7 @@ unsigned lst_waitUntil( lst_t *lst, void **data, uint32_t time ); * ******************************************************************************/ -unsigned lst_waitFor( lst_t *lst, void **data, uint32_t delay ); +unsigned lst_waitFor( lst_t *lst, void **data, cnt_t delay ); /****************************************************************************** * @@ -352,14 +352,14 @@ struct List : public __lst List( void ): __lst _LST_INIT() {} ~List( void ) { assert(queue == nullptr); } - void kill ( void ) { lst_kill (this); } - unsigned waitUntil( void **_data, uint32_t _time ) { return lst_waitUntil(this, _data, _time); } - unsigned waitFor ( void **_data, uint32_t _delay ) { return lst_waitFor (this, _data, _delay); } - unsigned wait ( void **_data ) { return lst_wait (this, _data); } - unsigned take ( void **_data ) { return lst_take (this, _data); } - unsigned takeISR ( void **_data ) { return lst_takeISR (this, _data); } - void give ( void *_data ) { lst_give (this, _data); } - void giveISR ( void *_data ) { lst_giveISR (this, _data); } + void kill ( void ) { lst_kill (this); } + unsigned waitUntil( void **_data, cnt_t _time ) { return lst_waitUntil(this, _data, _time); } + unsigned waitFor ( void **_data, cnt_t _delay ) { return lst_waitFor (this, _data, _delay); } + unsigned wait ( void **_data ) { return lst_wait (this, _data); } + unsigned take ( void **_data ) { return lst_take (this, _data); } + unsigned takeISR ( void **_data ) { return lst_takeISR (this, _data); } + void give ( void *_data ) { lst_give (this, _data); } + void giveISR ( void *_data ) { lst_giveISR (this, _data); } }; #endif diff --git a/StateOS/kernel/inc/os_mem.h b/StateOS/kernel/inc/os_mem.h index a7b3d610..7c3fba70 100644 --- a/StateOS/kernel/inc/os_mem.h +++ b/StateOS/kernel/inc/os_mem.h @@ -2,7 +2,7 @@ @file StateOS: os_mem.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -293,7 +293,7 @@ void mem_delete( mem_t *mem ); * ******************************************************************************/ -unsigned mem_waitUntil( mem_t *mem, void **data, uint32_t time ); +unsigned mem_waitUntil( mem_t *mem, void **data, cnt_t time ); /****************************************************************************** * @@ -318,7 +318,7 @@ unsigned mem_waitUntil( mem_t *mem, void **data, uint32_t time ); * ******************************************************************************/ -unsigned mem_waitFor( mem_t *mem, void **data, uint32_t delay ); +unsigned mem_waitFor( mem_t *mem, void **data, cnt_t delay ); /****************************************************************************** * @@ -419,14 +419,14 @@ struct baseMemoryPool : public __mem baseMemoryPool( const unsigned _limit, const unsigned _size, void * const _data ): __mem _MEM_INIT(_limit, _size, _data) { mem_bind(this); } ~baseMemoryPool( void ) { assert(queue == nullptr); } - void kill ( void ) { mem_kill (this); } - unsigned waitUntil( void **_data, uint32_t _time ) { return mem_waitUntil(this, _data, _time); } - unsigned waitFor ( void **_data, uint32_t _delay ) { return mem_waitFor (this, _data, _delay); } - unsigned wait ( void **_data ) { return mem_wait (this, _data); } - unsigned take ( void **_data ) { return mem_take (this, _data); } - unsigned takeISR ( void **_data ) { return mem_takeISR (this, _data); } - void give ( void *_data ) { mem_give (this, _data); } - void giveISR ( void *_data ) { mem_giveISR (this, _data); } + void kill ( void ) { mem_kill (this); } + unsigned waitUntil( void **_data, cnt_t _time ) { return mem_waitUntil(this, _data, _time); } + unsigned waitFor ( void **_data, cnt_t _delay ) { return mem_waitFor (this, _data, _delay); } + unsigned wait ( void **_data ) { return mem_wait (this, _data); } + unsigned take ( void **_data ) { return mem_take (this, _data); } + unsigned takeISR ( void **_data ) { return mem_takeISR (this, _data); } + void give ( void *_data ) { mem_give (this, _data); } + void giveISR ( void *_data ) { mem_giveISR (this, _data); } }; /****************************************************************************** @@ -469,11 +469,11 @@ struct MemoryPoolTT : public MemoryPoolT<_limit, sizeof(T)> explicit MemoryPoolTT( void ): MemoryPoolT<_limit, sizeof(T)>() {} - unsigned waitUntil( T **_data, uint32_t _time ) { return mem_waitUntil(this, reinterpret_cast(_data), _time); } - unsigned waitFor ( T **_data, uint32_t _delay ) { return mem_waitFor (this, reinterpret_cast(_data), _delay); } - unsigned wait ( T **_data ) { return mem_wait (this, reinterpret_cast(_data)); } - unsigned take ( T **_data ) { return mem_take (this, reinterpret_cast(_data)); } - unsigned takeISR ( T **_data ) { return mem_takeISR (this, reinterpret_cast(_data)); } + unsigned waitUntil( T **_data, cnt_t _time ) { return mem_waitUntil(this, reinterpret_cast(_data), _time); } + unsigned waitFor ( T **_data, cnt_t _delay ) { return mem_waitFor (this, reinterpret_cast(_data), _delay); } + unsigned wait ( T **_data ) { return mem_wait (this, reinterpret_cast(_data)); } + unsigned take ( T **_data ) { return mem_take (this, reinterpret_cast(_data)); } + unsigned takeISR ( T **_data ) { return mem_takeISR (this, reinterpret_cast(_data)); } }; #endif diff --git a/StateOS/kernel/inc/os_msg.h b/StateOS/kernel/inc/os_msg.h index 29a7ccd2..480958c6 100644 --- a/StateOS/kernel/inc/os_msg.h +++ b/StateOS/kernel/inc/os_msg.h @@ -2,7 +2,7 @@ @file StateOS: os_msg.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -266,7 +266,7 @@ void msg_delete( msg_t *msg ); * ******************************************************************************/ -unsigned msg_waitUntil( msg_t *msg, unsigned *data, uint32_t time ); +unsigned msg_waitUntil( msg_t *msg, unsigned *data, cnt_t time ); /****************************************************************************** * @@ -291,7 +291,7 @@ unsigned msg_waitUntil( msg_t *msg, unsigned *data, uint32_t time ); * ******************************************************************************/ -unsigned msg_waitFor( msg_t *msg, unsigned *data, uint32_t delay ); +unsigned msg_waitFor( msg_t *msg, unsigned *data, cnt_t delay ); /****************************************************************************** * @@ -362,7 +362,7 @@ unsigned msg_takeISR( msg_t *msg, unsigned *data ) { return msg_waitFor(msg, dat * ******************************************************************************/ -unsigned msg_sendUntil( msg_t *msg, unsigned data, uint32_t time ); +unsigned msg_sendUntil( msg_t *msg, unsigned data, cnt_t time ); /****************************************************************************** * @@ -387,7 +387,7 @@ unsigned msg_sendUntil( msg_t *msg, unsigned data, uint32_t time ); * ******************************************************************************/ -unsigned msg_sendFor( msg_t *msg, unsigned data, uint32_t delay ); +unsigned msg_sendFor( msg_t *msg, unsigned data, cnt_t delay ); /****************************************************************************** * @@ -465,17 +465,17 @@ struct baseMessageQueue : public __msg baseMessageQueue( const unsigned _limit, unsigned * const _data ): __msg _MSG_INIT(_limit, _data) {} ~baseMessageQueue( void ) { assert(queue == nullptr); } - void kill ( void ) { msg_kill (this); } - unsigned waitUntil( unsigned*_data, uint32_t _time ) { return msg_waitUntil(this, _data, _time); } - unsigned waitFor ( unsigned*_data, uint32_t _delay ) { return msg_waitFor (this, _data, _delay); } - unsigned wait ( unsigned*_data ) { return msg_wait (this, _data); } - unsigned take ( unsigned*_data ) { return msg_take (this, _data); } - unsigned takeISR ( unsigned*_data ) { return msg_takeISR (this, _data); } - unsigned sendUntil( unsigned _data, uint32_t _time ) { return msg_sendUntil(this, _data, _time); } - unsigned sendFor ( unsigned _data, uint32_t _delay ) { return msg_sendFor (this, _data, _delay); } - unsigned send ( unsigned _data ) { return msg_send (this, _data); } - unsigned give ( unsigned _data ) { return msg_give (this, _data); } - unsigned giveISR ( unsigned _data ) { return msg_giveISR (this, _data); } + void kill ( void ) { msg_kill (this); } + unsigned waitUntil( unsigned*_data, cnt_t _time ) { return msg_waitUntil(this, _data, _time); } + unsigned waitFor ( unsigned*_data, cnt_t _delay ) { return msg_waitFor (this, _data, _delay); } + unsigned wait ( unsigned*_data ) { return msg_wait (this, _data); } + unsigned take ( unsigned*_data ) { return msg_take (this, _data); } + unsigned takeISR ( unsigned*_data ) { return msg_takeISR (this, _data); } + unsigned sendUntil( unsigned _data, cnt_t _time ) { return msg_sendUntil(this, _data, _time); } + unsigned sendFor ( unsigned _data, cnt_t _delay ) { return msg_sendFor (this, _data, _delay); } + unsigned send ( unsigned _data ) { return msg_send (this, _data); } + unsigned give ( unsigned _data ) { return msg_give (this, _data); } + unsigned giveISR ( unsigned _data ) { return msg_giveISR (this, _data); } }; /****************************************************************************** diff --git a/StateOS/kernel/inc/os_mtx.h b/StateOS/kernel/inc/os_mtx.h index c16b8bac..caa878f3 100644 --- a/StateOS/kernel/inc/os_mtx.h +++ b/StateOS/kernel/inc/os_mtx.h @@ -2,7 +2,7 @@ @file StateOS: os_mtx.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -232,7 +232,7 @@ void mtx_delete( mtx_t *mtx ); * ******************************************************************************/ -unsigned mtx_waitUntil( mtx_t *mtx, uint32_t time ); +unsigned mtx_waitUntil( mtx_t *mtx, cnt_t time ); /****************************************************************************** * @@ -256,7 +256,7 @@ unsigned mtx_waitUntil( mtx_t *mtx, uint32_t time ); * ******************************************************************************/ -unsigned mtx_waitFor( mtx_t *mtx, uint32_t delay ); +unsigned mtx_waitFor( mtx_t *mtx, cnt_t delay ); /****************************************************************************** * @@ -345,12 +345,12 @@ struct Mutex : public __mtx Mutex( void ): __mtx _MTX_INIT() {} ~Mutex( void ) { assert(owner == nullptr); } - void kill ( void ) { mtx_kill (this); } - unsigned waitUntil( uint32_t _time ) { return mtx_waitUntil(this, _time); } - unsigned waitFor ( uint32_t _delay ) { return mtx_waitFor (this, _delay); } - unsigned wait ( void ) { return mtx_wait (this); } - unsigned take ( void ) { return mtx_take (this); } - unsigned give ( void ) { return mtx_give (this); } + void kill ( void ) { mtx_kill (this); } + unsigned waitUntil( cnt_t _time ) { return mtx_waitUntil(this, _time); } + unsigned waitFor ( cnt_t _delay ) { return mtx_waitFor (this, _delay); } + unsigned wait ( void ) { return mtx_wait (this); } + unsigned take ( void ) { return mtx_take (this); } + unsigned give ( void ) { return mtx_give (this); } }; #endif diff --git a/StateOS/kernel/inc/os_mut.h b/StateOS/kernel/inc/os_mut.h index 24406efd..5842878c 100644 --- a/StateOS/kernel/inc/os_mut.h +++ b/StateOS/kernel/inc/os_mut.h @@ -2,7 +2,7 @@ @file StateOS: os_mut.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -231,7 +231,7 @@ void mut_delete( mut_t *mut ); * ******************************************************************************/ -unsigned mut_waitUntil( mut_t *mut, uint32_t time ); +unsigned mut_waitUntil( mut_t *mut, cnt_t time ); /****************************************************************************** * @@ -255,7 +255,7 @@ unsigned mut_waitUntil( mut_t *mut, uint32_t time ); * ******************************************************************************/ -unsigned mut_waitFor( mut_t *mut, uint32_t delay ); +unsigned mut_waitFor( mut_t *mut, cnt_t delay ); /****************************************************************************** * @@ -344,12 +344,12 @@ struct FastMutex : public __mut FastMutex( void ): __mut _MUT_INIT() {} ~FastMutex( void ) { assert(owner == nullptr); } - void kill ( void ) { mut_kill (this); } - unsigned waitUntil( uint32_t _time ) { return mut_waitUntil(this, _time); } - unsigned waitFor ( uint32_t _delay ) { return mut_waitFor (this, _delay); } - unsigned wait ( void ) { return mut_wait (this); } - unsigned take ( void ) { return mut_take (this); } - unsigned give ( void ) { return mut_give (this); } + void kill ( void ) { mut_kill (this); } + unsigned waitUntil( cnt_t _time ) { return mut_waitUntil(this, _time); } + unsigned waitFor ( cnt_t _delay ) { return mut_waitFor (this, _delay); } + unsigned wait ( void ) { return mut_wait (this); } + unsigned take ( void ) { return mut_take (this); } + unsigned give ( void ) { return mut_give (this); } }; #endif diff --git a/StateOS/kernel/inc/os_sem.h b/StateOS/kernel/inc/os_sem.h index 1de8679e..e5e07828 100644 --- a/StateOS/kernel/inc/os_sem.h +++ b/StateOS/kernel/inc/os_sem.h @@ -2,7 +2,7 @@ @file StateOS: os_sem.h @author Rajmund Szymanski - @date 13.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -274,7 +274,7 @@ void sem_delete( sem_t *sem ); * ******************************************************************************/ -unsigned sem_waitUntil( sem_t *sem, uint32_t time ); +unsigned sem_waitUntil( sem_t *sem, cnt_t time ); /****************************************************************************** * @@ -298,7 +298,7 @@ unsigned sem_waitUntil( sem_t *sem, uint32_t time ); * ******************************************************************************/ -unsigned sem_waitFor( sem_t *sem, uint32_t delay ); +unsigned sem_waitFor( sem_t *sem, cnt_t delay ); /****************************************************************************** * @@ -366,7 +366,7 @@ unsigned sem_takeISR( sem_t *sem ) { return sem_waitFor(sem, IMMEDIATE); } * ******************************************************************************/ -unsigned sem_sendUntil( sem_t *sem, uint32_t time ); +unsigned sem_sendUntil( sem_t *sem, cnt_t time ); /****************************************************************************** * @@ -390,7 +390,7 @@ unsigned sem_sendUntil( sem_t *sem, uint32_t time ); * ******************************************************************************/ -unsigned sem_sendFor( sem_t *sem, uint32_t delay ); +unsigned sem_sendFor( sem_t *sem, cnt_t delay ); /****************************************************************************** * @@ -467,17 +467,17 @@ struct Semaphore : public __sem Semaphore( const unsigned _init, const unsigned _limit = semCounting ): __sem _SEM_INIT(_init, _limit) {} ~Semaphore( void ) { assert(queue == nullptr); } - void kill ( void ) { sem_kill (this); } - unsigned waitUntil( uint32_t _time ) { return sem_waitUntil(this, _time); } - unsigned waitFor ( uint32_t _delay ) { return sem_waitFor (this, _delay); } - unsigned wait ( void ) { return sem_wait (this); } - unsigned take ( void ) { return sem_take (this); } - unsigned takeISR ( void ) { return sem_takeISR (this); } - unsigned sendUntil( uint32_t _time ) { return sem_sendUntil(this, _time); } - unsigned sendFor ( uint32_t _delay ) { return sem_sendFor (this, _delay); } - unsigned send ( void ) { return sem_send (this); } - unsigned give ( void ) { return sem_give (this); } - unsigned giveISR ( void ) { return sem_giveISR (this); } + void kill ( void ) { sem_kill (this); } + unsigned waitUntil( cnt_t _time ) { return sem_waitUntil(this, _time); } + unsigned waitFor ( cnt_t _delay ) { return sem_waitFor (this, _delay); } + unsigned wait ( void ) { return sem_wait (this); } + unsigned take ( void ) { return sem_take (this); } + unsigned takeISR ( void ) { return sem_takeISR (this); } + unsigned sendUntil( cnt_t _time ) { return sem_sendUntil(this, _time); } + unsigned sendFor ( cnt_t _delay ) { return sem_sendFor (this, _delay); } + unsigned send ( void ) { return sem_send (this); } + unsigned give ( void ) { return sem_give (this); } + unsigned giveISR ( void ) { return sem_giveISR (this); } }; /****************************************************************************** diff --git a/StateOS/kernel/inc/os_sig.h b/StateOS/kernel/inc/os_sig.h index 70e2b377..d06cfdd1 100644 --- a/StateOS/kernel/inc/os_sig.h +++ b/StateOS/kernel/inc/os_sig.h @@ -2,7 +2,7 @@ @file StateOS: os_sig.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -256,7 +256,7 @@ void sig_delete( sig_t *sig ); * ******************************************************************************/ -unsigned sig_waitUntil( sig_t *sig, uint32_t time ); +unsigned sig_waitUntil( sig_t *sig, cnt_t time ); /****************************************************************************** * @@ -279,7 +279,7 @@ unsigned sig_waitUntil( sig_t *sig, uint32_t time ); * ******************************************************************************/ -unsigned sig_waitFor( sig_t *sig, uint32_t delay ); +unsigned sig_waitFor( sig_t *sig, cnt_t delay ); /****************************************************************************** * @@ -394,16 +394,16 @@ struct Signal : public __sig Signal( const unsigned _type = sigClear ): __sig _SIG_INIT(_type) {} ~Signal( void ) { assert(queue == nullptr); } - void kill ( void ) { sig_kill (this); } - unsigned waitUntil( uint32_t _time ) { return sig_waitUntil(this, _time); } - unsigned waitFor ( uint32_t _delay ) { return sig_waitFor (this, _delay); } - unsigned wait ( void ) { return sig_wait (this); } - unsigned take ( void ) { return sig_take (this); } - unsigned takeISR ( void ) { return sig_takeISR (this); } - void give ( void ) { sig_give (this); } - void giveISR ( void ) { sig_giveISR (this); } - void clear ( void ) { sig_clear (this); } - void clearISR ( void ) { sig_clearISR (this); } + void kill ( void ) { sig_kill (this); } + unsigned waitUntil( cnt_t _time ) { return sig_waitUntil(this, _time); } + unsigned waitFor ( cnt_t _delay ) { return sig_waitFor (this, _delay); } + unsigned wait ( void ) { return sig_wait (this); } + unsigned take ( void ) { return sig_take (this); } + unsigned takeISR ( void ) { return sig_takeISR (this); } + void give ( void ) { sig_give (this); } + void giveISR ( void ) { sig_giveISR (this); } + void clear ( void ) { sig_clear (this); } + void clearISR ( void ) { sig_clearISR (this); } }; #endif diff --git a/StateOS/kernel/inc/os_tmr.h b/StateOS/kernel/inc/os_tmr.h index cd693d3c..42f26d07 100644 --- a/StateOS/kernel/inc/os_tmr.h +++ b/StateOS/kernel/inc/os_tmr.h @@ -2,7 +2,7 @@ @file StateOS: os_tmr.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -46,9 +46,9 @@ struct __tmr obj_t obj; // object header fun_t * state; // callback procedure - uint32_t start; - uint32_t delay; - uint32_t period; + cnt_t start; + cnt_t delay; + cnt_t period; }; /****************************************************************************** @@ -392,7 +392,7 @@ void tmr_delete( tmr_t *tmr ); * ******************************************************************************/ -void tmr_startUntil( tmr_t *tmr, uint32_t time ); +void tmr_startUntil( tmr_t *tmr, cnt_t time ); /****************************************************************************** * @@ -416,7 +416,7 @@ void tmr_startUntil( tmr_t *tmr, uint32_t time ); * ******************************************************************************/ -void tmr_start( tmr_t *tmr, uint32_t delay, uint32_t period ); +void tmr_start( tmr_t *tmr, cnt_t delay, cnt_t period ); /****************************************************************************** * @@ -437,7 +437,7 @@ void tmr_start( tmr_t *tmr, uint32_t delay, uint32_t period ); ******************************************************************************/ __STATIC_INLINE -void tmr_startFor( tmr_t *tmr, uint32_t delay ) { tmr_start(tmr, delay, 0); } +void tmr_startFor( tmr_t *tmr, cnt_t delay ) { tmr_start(tmr, delay, 0); } /****************************************************************************** * @@ -459,7 +459,7 @@ void tmr_startFor( tmr_t *tmr, uint32_t delay ) { tmr_start(tmr, delay, 0); } ******************************************************************************/ __STATIC_INLINE -void tmr_startPeriodic( tmr_t *tmr, uint32_t period ) { tmr_start(tmr, period, period); } +void tmr_startPeriodic( tmr_t *tmr, cnt_t period ) { tmr_start(tmr, period, period); } /****************************************************************************** * @@ -485,7 +485,7 @@ void tmr_startPeriodic( tmr_t *tmr, uint32_t period ) { tmr_start(tmr, period, p * ******************************************************************************/ -void tmr_startFrom( tmr_t *tmr, uint32_t delay, uint32_t period, fun_t *proc ); +void tmr_startFrom( tmr_t *tmr, cnt_t delay, cnt_t period, fun_t *proc ); /****************************************************************************** * @@ -524,7 +524,7 @@ void tmr_stop( tmr_t *tmr ) { tmr_start(tmr, 0, 0); } * ******************************************************************************/ -unsigned tmr_waitUntil( tmr_t *tmr, uint32_t time ); +unsigned tmr_waitUntil( tmr_t *tmr, cnt_t time ); /****************************************************************************** * @@ -547,7 +547,7 @@ unsigned tmr_waitUntil( tmr_t *tmr, uint32_t time ); * ******************************************************************************/ -unsigned tmr_waitFor( tmr_t *tmr, uint32_t delay ); +unsigned tmr_waitFor( tmr_t *tmr, cnt_t delay ); /****************************************************************************** * @@ -630,7 +630,7 @@ void tmr_flipISR( fun_t *proc ) { tmr_thisISR()->state = proc; } ******************************************************************************/ __STATIC_INLINE -void tmr_delayISR( uint32_t delay ) { tmr_thisISR()->delay = delay; } +void tmr_delayISR( cnt_t delay ) { tmr_thisISR()->delay = delay; } #ifdef __cplusplus } @@ -665,26 +665,26 @@ struct Timer : public __tmr ~Timer( void ) { assert(__tmr::obj.id == ID_STOPPED); } #endif - void kill ( void ) { tmr_kill (this); } - void startUntil ( uint32_t _time ) { tmr_startUntil (this, _time); } - void start ( uint32_t _delay, uint32_t _period ) { tmr_start (this, _delay, _period); } - void startFor ( uint32_t _delay ) { tmr_startFor (this, _delay); } - void startPeriodic( uint32_t _period ) { tmr_startPeriodic(this, _period); } + void kill ( void ) { tmr_kill (this); } + void startUntil ( cnt_t _time ) { tmr_startUntil (this, _time); } + void start ( cnt_t _delay, cnt_t _period ) { tmr_start (this, _delay, _period); } + void startFor ( cnt_t _delay ) { tmr_startFor (this, _delay); } + void startPeriodic( cnt_t _period ) { tmr_startPeriodic(this, _period); } #if OS_FUNCTIONAL - void startFrom ( uint32_t _delay, uint32_t _period, FUN_t _state ) { fun_ = _state; - tmr_startFrom (this, _delay, _period, run_); } + void startFrom ( cnt_t _delay, cnt_t _period, FUN_t _state ) { fun_ = _state; + tmr_startFrom (this, _delay, _period, run_); } #else - void startFrom ( uint32_t _delay, uint32_t _period, FUN_t _state ) { tmr_startFrom (this, _delay, _period, _state); } + void startFrom ( cnt_t _delay, cnt_t _period, FUN_t _state ) { tmr_startFrom (this, _delay, _period, _state); } #endif - void stop ( void ) { tmr_stop (this); } + void stop ( void ) { tmr_stop (this); } - unsigned waitUntil( uint32_t _time ) { return tmr_waitUntil (this, _time); } - unsigned waitFor ( uint32_t _delay ) { return tmr_waitFor (this, _delay); } - unsigned wait ( void ) { return tmr_wait (this); } - unsigned take ( void ) { return tmr_take (this); } - unsigned takeISR ( void ) { return tmr_takeISR (this); } + unsigned waitUntil( cnt_t _time ) { return tmr_waitUntil (this, _time); } + unsigned waitFor ( cnt_t _delay ) { return tmr_waitFor (this, _delay); } + unsigned wait ( void ) { return tmr_wait (this); } + unsigned take ( void ) { return tmr_take (this); } + unsigned takeISR ( void ) { return tmr_takeISR (this); } - bool operator!( void ) { return __tmr::obj.id == ID_STOPPED; } + bool operator!( void ) { return __tmr::obj.id == ID_STOPPED; } #if OS_FUNCTIONAL static void run_( void ) { ((Timer *) WAIT.obj.next)->fun_(); } @@ -708,9 +708,9 @@ struct Timer : public __tmr struct startTimerUntil : public Timer { explicit - startTimerUntil( const uint32_t _time ): Timer() { port_sys_init(); tmr_startUntil(this, _time); } + startTimerUntil( const cnt_t _time ): Timer() { port_sys_init(); tmr_startUntil(this, _time); } explicit - startTimerUntil( const uint32_t _time, FUN_t _state ): Timer(_state) { port_sys_init(); tmr_startUntil(this, _time); } + startTimerUntil( const cnt_t _time, FUN_t _state ): Timer(_state) { port_sys_init(); tmr_startUntil(this, _time); } }; /****************************************************************************** @@ -735,9 +735,9 @@ struct startTimerUntil : public Timer struct startTimer : public Timer { explicit - startTimer( const uint32_t _delay, const uint32_t _period ): Timer() { port_sys_init(); tmr_start(this, _delay, _period); } + startTimer( const cnt_t _delay, const cnt_t _period ): Timer() { port_sys_init(); tmr_start(this, _delay, _period); } explicit - startTimer( const uint32_t _delay, const uint32_t _period, FUN_t _state ): Timer(_state) { port_sys_init(); tmr_start(this, _delay, _period); } + startTimer( const cnt_t _delay, const cnt_t _period, FUN_t _state ): Timer(_state) { port_sys_init(); tmr_start(this, _delay, _period); } }; /****************************************************************************** @@ -758,9 +758,9 @@ struct startTimer : public Timer struct startTimerFor : public startTimer { explicit - startTimerFor( const uint32_t _delay ): startTimer(_delay, 0) {} + startTimerFor( const cnt_t _delay ): startTimer(_delay, 0) {} explicit - startTimerFor( const uint32_t _delay, FUN_t _state ): startTimer(_delay, 0, _state) {} + startTimerFor( const cnt_t _delay, FUN_t _state ): startTimer(_delay, 0, _state) {} }; /****************************************************************************** @@ -782,9 +782,9 @@ struct startTimerFor : public startTimer struct startTimerPeriodic : public startTimer { explicit - startTimerPeriodic( const uint32_t _period ): startTimer(_period, _period) {} + startTimerPeriodic( const cnt_t _period ): startTimer(_period, _period) {} explicit - startTimerPeriodic( const uint32_t _period, FUN_t _state ): startTimer(_period, _period, _state) {} + startTimerPeriodic( const cnt_t _period, FUN_t _state ): startTimer(_period, _period, _state) {} }; /****************************************************************************** @@ -798,12 +798,12 @@ struct startTimerPeriodic : public startTimer namespace ThisTimer { #if OS_FUNCTIONAL - static inline void flipISR ( FUN_t _state ) { ((Timer *) WAIT.obj.next)->fun_ = _state; - tmr_flipISR (Timer::run_); } + static inline void flipISR ( FUN_t _state ) { ((Timer *) WAIT.obj.next)->fun_ = _state; + tmr_flipISR (Timer::run_); } #else - static inline void flipISR ( FUN_t _state ) { tmr_flipISR (_state); } + static inline void flipISR ( FUN_t _state ) { tmr_flipISR (_state); } #endif - static inline void delayISR( uint32_t _delay ) { tmr_delayISR(_delay); } + static inline void delayISR( cnt_t _delay ) { tmr_delayISR(_delay); } } #endif//__cplusplus diff --git a/StateOS/kernel/inc/os_tsk.h b/StateOS/kernel/inc/os_tsk.h index acb97099..ef33bba4 100644 --- a/StateOS/kernel/inc/os_tsk.h +++ b/StateOS/kernel/inc/os_tsk.h @@ -2,7 +2,7 @@ @file StateOS: os_tsk.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -48,9 +48,9 @@ struct __tsk obj_t obj; // inherited from timer fun_t * state; // inherited from timer - uint32_t start; // inherited from timer - uint32_t delay; // inherited from timer - uint32_t period;// inherited from timer + cnt_t start; // inherited from timer + cnt_t delay; // inherited from timer + cnt_t period;// inherited from timer tsk_t * back; // previous process in the DELAYED queue void * sp; // current stack pointer @@ -65,7 +65,7 @@ struct __tsk tsk_t * mtree; // tree of tasks waiting for mutexes mtx_t * mlist; // list of mutexes held - uint32_t slice; // time slice + cnt_t slice; // time slice union { unsigned mode; // used by flag object void * data; // used by queue objects @@ -781,7 +781,7 @@ unsigned tsk_getPrio( void ) { return System.cur->basic; } * ******************************************************************************/ -unsigned tsk_waitUntil( unsigned flags, uint32_t time ); +unsigned tsk_waitUntil( unsigned flags, cnt_t time ); /****************************************************************************** * @@ -804,7 +804,7 @@ unsigned tsk_waitUntil( unsigned flags, uint32_t time ); * ******************************************************************************/ -unsigned tsk_waitFor( unsigned flags, uint32_t delay ); +unsigned tsk_waitFor( unsigned flags, cnt_t delay ); /****************************************************************************** * @@ -866,7 +866,7 @@ void tsk_giveISR( tsk_t *tsk, unsigned flags ) { tsk_give(tsk, flags); } ******************************************************************************/ __STATIC_INLINE -unsigned tsk_sleepUntil( uint32_t time ) { return tmr_waitUntil(&WAIT, time); } +unsigned tsk_sleepUntil( cnt_t time ) { return tmr_waitUntil(&WAIT, time); } /****************************************************************************** * @@ -888,7 +888,7 @@ unsigned tsk_sleepUntil( uint32_t time ) { return tmr_waitUntil(&WAIT, time); } ******************************************************************************/ __STATIC_INLINE -unsigned tsk_sleepFor( uint32_t delay ) { return tmr_waitFor(&WAIT, delay); } +unsigned tsk_sleepFor( cnt_t delay ) { return tmr_waitFor(&WAIT, delay); } /****************************************************************************** * @@ -928,7 +928,7 @@ unsigned tsk_sleep( void ) { return tmr_wait(&WAIT); } ******************************************************************************/ __STATIC_INLINE -unsigned tsk_delay( uint32_t delay ) { return tsk_sleepFor(delay); } +unsigned tsk_delay( cnt_t delay ) { return tsk_sleepFor(delay); } /****************************************************************************** * @@ -1130,31 +1130,31 @@ struct startTask : public startTaskT namespace ThisTask { - static inline void pass ( void ) { tsk_pass (); } - static inline void yield ( void ) { tsk_yield (); } + static inline void pass ( void ) { tsk_pass (); } + static inline void yield ( void ) { tsk_yield (); } #if OS_FUNCTIONAL - static inline void flip ( FUN_t _state ) { ((baseTask *) System.cur)->fun_ = _state; - tsk_flip (baseTask::run_); } + static inline void flip ( FUN_t _state ) { ((baseTask *) System.cur)->fun_ = _state; + tsk_flip (baseTask::run_); } #else - static inline void flip ( FUN_t _state ) { tsk_flip (_state); } + static inline void flip ( FUN_t _state ) { tsk_flip (_state); } #endif - static inline void stop ( void ) { tsk_stop (); } - static inline void prio ( unsigned _prio ) { tsk_prio (_prio); } - static inline void setPrio ( unsigned _prio ) { tsk_setPrio (_prio); } - static inline unsigned getPrio ( void ) { return tsk_getPrio (); } - static inline unsigned prio ( void ) { return tsk_getPrio (); } - - static inline void kill ( void ) { tsk_kill (System.cur); } - static inline unsigned detach ( void ) { return tsk_detach (System.cur); } - static inline void suspend ( void ) { tsk_suspend (System.cur); } - - static inline unsigned waitUntil ( unsigned _flags, uint32_t _time ) { return tsk_waitUntil (_flags, _time); } - static inline unsigned waitFor ( unsigned _flags, uint32_t _delay ) { return tsk_waitFor (_flags, _delay); } - static inline unsigned wait ( unsigned _flags ) { return tsk_wait (_flags); } - static inline unsigned sleepUntil( uint32_t _time ) { return tsk_sleepUntil(_time); } - static inline unsigned sleepFor ( uint32_t _delay ) { return tsk_sleepFor (_delay); } - static inline unsigned sleep ( void ) { return tsk_sleep (); } - static inline unsigned delay ( uint32_t _delay ) { return tsk_delay (_delay); } + static inline void stop ( void ) { tsk_stop (); } + static inline void prio ( unsigned _prio ) { tsk_prio (_prio); } + static inline void setPrio ( unsigned _prio ) { tsk_setPrio (_prio); } + static inline unsigned getPrio ( void ) { return tsk_getPrio (); } + static inline unsigned prio ( void ) { return tsk_getPrio (); } + + static inline void kill ( void ) { tsk_kill (System.cur); } + static inline unsigned detach ( void ) { return tsk_detach (System.cur); } + static inline void suspend ( void ) { tsk_suspend (System.cur); } + + static inline unsigned waitUntil ( unsigned _flags, cnt_t _time ) { return tsk_waitUntil (_flags, _time); } + static inline unsigned waitFor ( unsigned _flags, cnt_t _delay ) { return tsk_waitFor (_flags, _delay); } + static inline unsigned wait ( unsigned _flags ) { return tsk_wait (_flags); } + static inline unsigned sleepUntil( cnt_t _time ) { return tsk_sleepUntil(_time); } + static inline unsigned sleepFor ( cnt_t _delay ) { return tsk_sleepFor (_delay); } + static inline unsigned sleep ( void ) { return tsk_sleep (); } + static inline unsigned delay ( cnt_t _delay ) { return tsk_delay (_delay); } } #endif//__cplusplus diff --git a/StateOS/kernel/os.c b/StateOS/kernel/os.c index 67726dbe..0d36e254 100644 --- a/StateOS/kernel/os.c +++ b/StateOS/kernel/os.c @@ -2,7 +2,7 @@ @file StateOS: os.c @author Rajmund Szymanski - @date 08.12.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -29,10 +29,10 @@ #include "oskernel.h" /* -------------------------------------------------------------------------- */ -uint32_t sys_time( void ) +cnt_t sys_time( void ) /* -------------------------------------------------------------------------- */ { - uint32_t cnt; + cnt_t cnt; port_sys_lock(); diff --git a/StateOS/kernel/os.h b/StateOS/kernel/os.h index 3fe76f80..c322d4b2 100644 --- a/StateOS/kernel/os.h +++ b/StateOS/kernel/os.h @@ -2,7 +2,7 @@ @file StateOS: os.h @author Rajmund Szymanski - @date 10.12.2017 + @date 01.01.2018 @brief This file contains definitions for StateOS. ****************************************************************************** @@ -162,10 +162,10 @@ void sys_free( void *ptr ) { core_sys_free(ptr); } * ******************************************************************************/ -uint32_t sys_time( void ); +cnt_t sys_time( void ); __STATIC_INLINE -uint32_t sys_timeISR( void ) { return sys_time(); } +cnt_t sys_timeISR( void ) { return sys_time(); } /****************************************************************************** * diff --git a/StateOS/kernel/osbase.h b/StateOS/kernel/osbase.h index f7b284d5..faf79a93 100644 --- a/StateOS/kernel/osbase.h +++ b/StateOS/kernel/osbase.h @@ -38,6 +38,27 @@ extern "C" { /* -------------------------------------------------------------------------- */ +#ifndef OS_TIMER_SIZE +#define OS_TIMER_SIZE 32 +#endif + +/* -------------------------------------------------------------------------- */ + +#if OS_TIMER_SIZE == 16 +typedef uint16_t cnt_t; +#define CNT_MAX UINT16_MAX +#elif OS_TIMER_SIZE == 32 +typedef uint32_t cnt_t; +#define CNT_MAX UINT32_MAX +#elif OS_TIMER_SIZE == 64 +typedef uint64_t cnt_t; +#define CNT_MAX UINT64_MAX +#else +#error Invalid OS_TIMER_SIZE value! +#endif + +/* -------------------------------------------------------------------------- */ + typedef struct __tmr tmr_t, * const tmr_id; // timer typedef struct __tsk tsk_t, * const tsk_id; // task typedef void fun_t(); // timer/task procedure @@ -79,29 +100,31 @@ typedef struct __sys sys_t; struct __sys { tsk_t * cur; // pointer to the current task control block +#if HW_TIMER_SIZE < OS_TIMER_SIZE volatile - uint32_t cnt; // system timer counter + cnt_t cnt; // system timer counter +#endif }; /* -------------------------------------------------------------------------- */ -#if (OS_FREQUENCY)/1000000 > 0 && (OS_FREQUENCY)/1000000 < (UINT32_MAX) -#define USEC (uint32_t)((OS_FREQUENCY)/1000000) +#if (OS_FREQUENCY)/1000000 > 0 && (OS_FREQUENCY)/1000000 < (CNT_MAX) +#define USEC (cnt_t)((OS_FREQUENCY)/1000000) #endif -#if (OS_FREQUENCY)/1000 > 0 && (OS_FREQUENCY)/1000 < (UINT32_MAX) -#define MSEC (uint32_t)((OS_FREQUENCY)/1000) +#if (OS_FREQUENCY)/1000 > 0 && (OS_FREQUENCY)/1000 < (CNT_MAX) +#define MSEC (cnt_t)((OS_FREQUENCY)/1000) #endif -#if (OS_FREQUENCY) < (UINT32_MAX) -#define SEC ((uint32_t)(OS_FREQUENCY)) +#if (OS_FREQUENCY) < (CNT_MAX) +#define SEC ((cnt_t)(OS_FREQUENCY)) #endif -#if (OS_FREQUENCY) < (UINT32_MAX)/60 -#define MIN ((uint32_t)(OS_FREQUENCY)*60) +#if (OS_FREQUENCY) < (CNT_MAX)/60 +#define MIN ((cnt_t)(OS_FREQUENCY)*60) #endif -#if (OS_FREQUENCY) < (UINT32_MAX)/3600 -#define HOUR ((uint32_t)(OS_FREQUENCY)*3600) +#if (OS_FREQUENCY) < (CNT_MAX)/3600 +#define HOUR ((cnt_t)(OS_FREQUENCY)*3600) #endif -#if (OS_FREQUENCY) < (UINT32_MAX)/86400 -#define DAY ((uint32_t)(OS_FREQUENCY)*86400) +#if (OS_FREQUENCY) < (CNT_MAX)/86400 +#define DAY ((cnt_t)(OS_FREQUENCY)*86400) #endif /* -------------------------------------------------------------------------- */ @@ -121,10 +144,10 @@ struct __sys /* -------------------------------------------------------------------------- */ #ifndef IMMEDIATE -#define IMMEDIATE 0UL // no waiting +#define IMMEDIATE 0 // no waiting #endif #ifndef INFINITE -#define INFINITE UINT32_MAX // infinite waiting +#define INFINITE CNT_MAX // infinite waiting #endif /* -------------------------------------------------------------------------- */ diff --git a/StateOS/kernel/oskernel.c b/StateOS/kernel/oskernel.c index b264dd86..4fb7f545 100644 --- a/StateOS/kernel/oskernel.c +++ b/StateOS/kernel/oskernel.c @@ -2,7 +2,7 @@ @file StateOS: oskernel.c @author Rajmund Szymanski - @date 28.12.2017 + @date 02.01.2018 @brief This file provides set of variables and functions for StateOS. ****************************************************************************** @@ -81,7 +81,7 @@ void priv_tmr_insert( tmr_t *tmr, unsigned id ) if (tmr->delay != INFINITE) do nxt = nxt->obj.next; - while (nxt->delay < tmr->start + tmr->delay - nxt->start); + while (nxt->delay < (cnt_t)(tmr->start + tmr->delay - nxt->start)); priv_rdy_insert(&tmr->obj, &nxt->obj); } @@ -122,12 +122,12 @@ bool priv_tmr_expired( tmr_t *tmr ) if (tmr->delay == INFINITE) return false; // return if timer counting indefinitely - if (tmr->delay <= core_sys_time() - tmr->start) + if (tmr->delay <= (cnt_t)(core_sys_time() - tmr->start)) return true; // return if timer finished counting - port_tmr_start(tmr->start + tmr->delay); + port_tmr_start((cnt_t)(tmr->start + tmr->delay)); - if (tmr->delay > core_sys_time() - tmr->start) + if (tmr->delay > (cnt_t)(core_sys_time() - tmr->start)) return false; // return if timer still counts port_tmr_stop(); @@ -142,7 +142,7 @@ bool priv_tmr_expired( tmr_t *tmr ) static bool priv_tmr_expired( tmr_t *tmr ) { - if (tmr->delay >= core_sys_time() - tmr->start + 1) + if (tmr->delay >= (cnt_t)(core_sys_time() - tmr->start + 1)) return false; // return if timer still counts or counting indefinitely return true; // timer finished counting @@ -162,7 +162,7 @@ void priv_tmr_wakeup( tmr_t *tmr, unsigned event ) tmr->state(); core_tmr_remove(tmr); - if (tmr->delay >= core_sys_time() - tmr->start + 1) + if (tmr->delay >= (cnt_t)(core_sys_time() - tmr->start + 1)) priv_tmr_insert(tmr, ID_TIMER); core_all_wakeup(tmr, event); @@ -333,14 +333,14 @@ void priv_tsk_wait( tsk_t *tsk, void *obj ) /* -------------------------------------------------------------------------- */ -unsigned core_tsk_waitUntil( void *obj, uint32_t time ) +unsigned core_tsk_waitUntil( void *obj, cnt_t time ) { tsk_t *cur = System.cur; cur->start = core_sys_time(); cur->delay = time - cur->start; - if ((int32_t)cur->delay <= 0) + if (cur->delay > ((CNT_MAX)>>1)) return E_TIMEOUT; priv_tsk_wait(cur, obj); @@ -351,7 +351,7 @@ unsigned core_tsk_waitUntil( void *obj, uint32_t time ) /* -------------------------------------------------------------------------- */ -unsigned core_tsk_waitFor( void *obj, uint32_t delay ) +unsigned core_tsk_waitFor( void *obj, cnt_t delay ) { tsk_t *cur = System.cur; diff --git a/StateOS/kernel/oskernel.h b/StateOS/kernel/oskernel.h index d21ed22d..e104efd5 100644 --- a/StateOS/kernel/oskernel.h +++ b/StateOS/kernel/oskernel.h @@ -2,7 +2,7 @@ @file StateOS: oskernel.h @author Rajmund Szymanski - @date 28.12.2017 + @date 02.01.2018 @brief This file defines set of kernel functions for StateOS. ****************************************************************************** @@ -101,11 +101,6 @@ extern sys_t System; // system data __CONSTRUCTOR void port_sys_init( void ); -// return current system time in tick-less mode -#if HW_TIMER_SIZE < 32 // because of CSMCC -uint32_t port_sys_time( void ); -#endif - /* -------------------------------------------------------------------------- */ // initiate task 'tsk' for context switch @@ -169,7 +164,7 @@ void core_tsk_unlink( tsk_t *tsk, unsigned event ); // insert the current task into timers READY queue // force context switch // return event value -unsigned core_tsk_waitUntil( void *obj, uint32_t time ); +unsigned core_tsk_waitUntil( void *obj, cnt_t time ); // delay execution of current task for given duration of time 'delay' // append the current task to the delayed queue of object 'obj' @@ -177,7 +172,7 @@ unsigned core_tsk_waitUntil( void *obj, uint32_t time ); // insert the current task into timers READY queue // force context switch // return event value -unsigned core_tsk_waitFor( void *obj, uint32_t delay ); +unsigned core_tsk_waitFor( void *obj, cnt_t delay ); // delay indefinitely execution of given task // append given task to WAIT timer delayed queue @@ -225,9 +220,14 @@ void *core_tsk_handler( void *sp ); /* -------------------------------------------------------------------------- */ +// return current system time in tick-less mode +#if HW_TIMER_SIZE < OS_TIMER_SIZE // because of CSMCC +cnt_t port_sys_time( void ); +#endif + // return current system time __STATIC_INLINE -uint32_t core_sys_time( void ) +cnt_t core_sys_time( void ) { #if HW_TIMER_SIZE == 0 return System.cnt; @@ -243,8 +243,8 @@ void core_sys_tick( void ); __STATIC_INLINE void core_sys_tick( void ) { -#if HW_TIMER_SIZE < 32 - System.cnt += 1UL << (HW_TIMER_SIZE); +#if HW_TIMER_SIZE < OS_TIMER_SIZE + System.cnt += (cnt_t)(1) << (HW_TIMER_SIZE); #endif } #endif diff --git a/StateOS/kernel/src/os_bar.c b/StateOS/kernel/src/os_bar.c index 7e60249d..88c24381 100644 --- a/StateOS/kernel/src/os_bar.c +++ b/StateOS/kernel/src/os_bar.c @@ -2,7 +2,7 @@ @file StateOS: os_bar.c @author Rajmund Szymanski - @date 22.10.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -96,7 +96,7 @@ void bar_delete( bar_t *bar ) /* -------------------------------------------------------------------------- */ static -unsigned priv_bar_wait( bar_t *bar, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_bar_wait( bar_t *bar, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { unsigned event = E_SUCCESS; @@ -123,7 +123,7 @@ unsigned priv_bar_wait( bar_t *bar, uint32_t time, unsigned(*wait)(void*,uint32_ } /* -------------------------------------------------------------------------- */ -unsigned bar_waitUntil( bar_t *bar, uint32_t time ) +unsigned bar_waitUntil( bar_t *bar, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -132,7 +132,7 @@ unsigned bar_waitUntil( bar_t *bar, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned bar_waitFor( bar_t *bar, uint32_t delay ) +unsigned bar_waitFor( bar_t *bar, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); diff --git a/StateOS/kernel/src/os_box.c b/StateOS/kernel/src/os_box.c index 602865b7..1fa0c6b3 100644 --- a/StateOS/kernel/src/os_box.c +++ b/StateOS/kernel/src/os_box.c @@ -2,7 +2,7 @@ @file StateOS: os_box.c @author Rajmund Szymanski - @date 08.12.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -131,7 +131,7 @@ void priv_box_put( box_t *box, void *data ) /* -------------------------------------------------------------------------- */ static -unsigned priv_box_wait( box_t *box, void *data, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_box_wait( box_t *box, void *data, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { tsk_t * tsk; @@ -163,7 +163,7 @@ unsigned priv_box_wait( box_t *box, void *data, uint32_t time, unsigned(*wait)(v } /* -------------------------------------------------------------------------- */ -unsigned box_waitUntil( box_t *box, void *data, uint32_t time ) +unsigned box_waitUntil( box_t *box, void *data, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -172,7 +172,7 @@ unsigned box_waitUntil( box_t *box, void *data, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned box_waitFor( box_t *box, void *data, uint32_t delay ) +unsigned box_waitFor( box_t *box, void *data, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); @@ -182,7 +182,7 @@ unsigned box_waitFor( box_t *box, void *data, uint32_t delay ) /* -------------------------------------------------------------------------- */ static -unsigned priv_box_send( box_t *box, void *data, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_box_send( box_t *box, void *data, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { tsk_t * tsk; @@ -214,7 +214,7 @@ unsigned priv_box_send( box_t *box, void *data, uint32_t time, unsigned(*wait)(v } /* -------------------------------------------------------------------------- */ -unsigned box_sendUntil( box_t *box, const void *data, uint32_t time ) +unsigned box_sendUntil( box_t *box, const void *data, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -223,7 +223,7 @@ unsigned box_sendUntil( box_t *box, const void *data, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned box_sendFor( box_t *box, const void *data, uint32_t delay ) +unsigned box_sendFor( box_t *box, const void *data, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); diff --git a/StateOS/kernel/src/os_cnd.c b/StateOS/kernel/src/os_cnd.c index 75ee5ba4..a81d535d 100644 --- a/StateOS/kernel/src/os_cnd.c +++ b/StateOS/kernel/src/os_cnd.c @@ -2,7 +2,7 @@ @file StateOS: os_cnd.c @author Rajmund Szymanski - @date 22.10.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -89,7 +89,7 @@ void cnd_delete( cnd_t *cnd ) /* -------------------------------------------------------------------------- */ static -unsigned priv_cnd_wait( cnd_t *cnd, mtx_t *mtx, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_cnd_wait( cnd_t *cnd, mtx_t *mtx, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { unsigned event; @@ -109,7 +109,7 @@ unsigned priv_cnd_wait( cnd_t *cnd, mtx_t *mtx, uint32_t time, unsigned(*wait)(v } /* -------------------------------------------------------------------------- */ -unsigned cnd_waitUntil( cnd_t *cnd, mtx_t *mtx, uint32_t time ) +unsigned cnd_waitUntil( cnd_t *cnd, mtx_t *mtx, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -118,7 +118,7 @@ unsigned cnd_waitUntil( cnd_t *cnd, mtx_t *mtx, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned cnd_waitFor( cnd_t *cnd, mtx_t *mtx, uint32_t delay ) +unsigned cnd_waitFor( cnd_t *cnd, mtx_t *mtx, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); diff --git a/StateOS/kernel/src/os_evt.c b/StateOS/kernel/src/os_evt.c index ea147d5b..c01c9034 100644 --- a/StateOS/kernel/src/os_evt.c +++ b/StateOS/kernel/src/os_evt.c @@ -2,7 +2,7 @@ @file StateOS: os_evt.c @author Rajmund Szymanski - @date 22.10.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -89,7 +89,7 @@ void evt_delete( evt_t *evt ) /* -------------------------------------------------------------------------- */ static -unsigned priv_evt_wait( evt_t *evt, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_evt_wait( evt_t *evt, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { unsigned event; @@ -106,7 +106,7 @@ unsigned priv_evt_wait( evt_t *evt, uint32_t time, unsigned(*wait)(void*,uint32_ } /* -------------------------------------------------------------------------- */ -unsigned evt_waitUntil( evt_t *evt, uint32_t time ) +unsigned evt_waitUntil( evt_t *evt, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -115,7 +115,7 @@ unsigned evt_waitUntil( evt_t *evt, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned evt_waitFor( evt_t *evt, uint32_t delay ) +unsigned evt_waitFor( evt_t *evt, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); diff --git a/StateOS/kernel/src/os_flg.c b/StateOS/kernel/src/os_flg.c index 13c9bbc0..568a2942 100644 --- a/StateOS/kernel/src/os_flg.c +++ b/StateOS/kernel/src/os_flg.c @@ -2,7 +2,7 @@ @file StateOS: os_flg.c @author Rajmund Szymanski - @date 08.12.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -90,7 +90,7 @@ void flg_delete( flg_t *flg ) /* -------------------------------------------------------------------------- */ static -unsigned priv_flg_wait( flg_t *flg, unsigned flags, unsigned mode, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_flg_wait( flg_t *flg, unsigned flags, unsigned mode, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { tsk_t *cur = System.cur; @@ -115,7 +115,7 @@ unsigned priv_flg_wait( flg_t *flg, unsigned flags, unsigned mode, uint32_t time } /* -------------------------------------------------------------------------- */ -unsigned flg_waitUntil( flg_t *flg, unsigned flags, unsigned mode, uint32_t time ) +unsigned flg_waitUntil( flg_t *flg, unsigned flags, unsigned mode, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -124,7 +124,7 @@ unsigned flg_waitUntil( flg_t *flg, unsigned flags, unsigned mode, uint32_t time } /* -------------------------------------------------------------------------- */ -unsigned flg_waitFor( flg_t *flg, unsigned flags, unsigned mode, uint32_t delay ) +unsigned flg_waitFor( flg_t *flg, unsigned flags, unsigned mode, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); diff --git a/StateOS/kernel/src/os_job.c b/StateOS/kernel/src/os_job.c index efc9240b..d236e3cf 100644 --- a/StateOS/kernel/src/os_job.c +++ b/StateOS/kernel/src/os_job.c @@ -2,7 +2,7 @@ @file StateOS: os_job.c @author Rajmund Szymanski - @date 08.12.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -121,7 +121,7 @@ void priv_job_put( job_t *job, fun_t *fun ) /* -------------------------------------------------------------------------- */ static -unsigned priv_job_wait( job_t *job, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_job_wait( job_t *job, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { tsk_t * tsk; @@ -155,7 +155,7 @@ unsigned priv_job_wait( job_t *job, uint32_t time, unsigned(*wait)(void*,uint32_ } /* -------------------------------------------------------------------------- */ -unsigned job_waitUntil( job_t *job, uint32_t time ) +unsigned job_waitUntil( job_t *job, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -164,7 +164,7 @@ unsigned job_waitUntil( job_t *job, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned job_waitFor( job_t *job, uint32_t delay ) +unsigned job_waitFor( job_t *job, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); @@ -174,7 +174,7 @@ unsigned job_waitFor( job_t *job, uint32_t delay ) /* -------------------------------------------------------------------------- */ static -unsigned priv_job_send( job_t *job, fun_t *fun, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_job_send( job_t *job, fun_t *fun, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { tsk_t * tsk; @@ -206,7 +206,7 @@ unsigned priv_job_send( job_t *job, fun_t *fun, uint32_t time, unsigned(*wait)(v } /* -------------------------------------------------------------------------- */ -unsigned job_sendUntil( job_t *job, fun_t *fun, uint32_t time ) +unsigned job_sendUntil( job_t *job, fun_t *fun, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -215,7 +215,7 @@ unsigned job_sendUntil( job_t *job, fun_t *fun, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned job_sendFor( job_t *job, fun_t *fun, uint32_t delay ) +unsigned job_sendFor( job_t *job, fun_t *fun, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); diff --git a/StateOS/kernel/src/os_lst.c b/StateOS/kernel/src/os_lst.c index 38ff40fc..4c15872b 100644 --- a/StateOS/kernel/src/os_lst.c +++ b/StateOS/kernel/src/os_lst.c @@ -2,7 +2,7 @@ @file StateOS: os_lst.c @author Rajmund Szymanski - @date 08.12.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -90,7 +90,7 @@ void lst_delete( lst_t *lst ) /* -------------------------------------------------------------------------- */ static -unsigned priv_lst_wait( lst_t *lst, void **data, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_lst_wait( lst_t *lst, void **data, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { unsigned event = E_SUCCESS; @@ -117,7 +117,7 @@ unsigned priv_lst_wait( lst_t *lst, void **data, uint32_t time, unsigned(*wait)( } /* -------------------------------------------------------------------------- */ -unsigned lst_waitUntil( lst_t *lst, void **data, uint32_t time ) +unsigned lst_waitUntil( lst_t *lst, void **data, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -126,7 +126,7 @@ unsigned lst_waitUntil( lst_t *lst, void **data, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned lst_waitFor( lst_t *lst, void **data, uint32_t delay ) +unsigned lst_waitFor( lst_t *lst, void **data, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); diff --git a/StateOS/kernel/src/os_mem.c b/StateOS/kernel/src/os_mem.c index 8bc819b2..534731b6 100644 --- a/StateOS/kernel/src/os_mem.c +++ b/StateOS/kernel/src/os_mem.c @@ -2,7 +2,7 @@ @file StateOS: os_mem.c @author Rajmund Szymanski - @date 12.12.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -127,7 +127,7 @@ void mem_delete( mem_t *mem ) /* -------------------------------------------------------------------------- */ static -unsigned priv_mem_wait( mem_t *mem, void **data, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_mem_wait( mem_t *mem, void **data, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { unsigned event = E_SUCCESS; @@ -158,7 +158,7 @@ unsigned priv_mem_wait( mem_t *mem, void **data, uint32_t time, unsigned(*wait)( } /* -------------------------------------------------------------------------- */ -unsigned mem_waitUntil( mem_t *mem, void **data, uint32_t time ) +unsigned mem_waitUntil( mem_t *mem, void **data, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -167,7 +167,7 @@ unsigned mem_waitUntil( mem_t *mem, void **data, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned mem_waitFor( mem_t *mem, void **data, uint32_t delay ) +unsigned mem_waitFor( mem_t *mem, void **data, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); diff --git a/StateOS/kernel/src/os_msg.c b/StateOS/kernel/src/os_msg.c index ee4b28a3..614ddf9e 100644 --- a/StateOS/kernel/src/os_msg.c +++ b/StateOS/kernel/src/os_msg.c @@ -2,7 +2,7 @@ @file StateOS: os_msg.c @author Rajmund Szymanski - @date 08.12.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -122,7 +122,7 @@ void priv_msg_put( msg_t *msg, unsigned data ) /* -------------------------------------------------------------------------- */ static -unsigned priv_msg_wait( msg_t *msg, unsigned *data, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_msg_wait( msg_t *msg, unsigned *data, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { tsk_t * tsk; @@ -154,7 +154,7 @@ unsigned priv_msg_wait( msg_t *msg, unsigned *data, uint32_t time, unsigned(*wai } /* -------------------------------------------------------------------------- */ -unsigned msg_waitUntil( msg_t *msg, unsigned *data, uint32_t time ) +unsigned msg_waitUntil( msg_t *msg, unsigned *data, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -163,7 +163,7 @@ unsigned msg_waitUntil( msg_t *msg, unsigned *data, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned msg_waitFor( msg_t *msg, unsigned *data, uint32_t delay ) +unsigned msg_waitFor( msg_t *msg, unsigned *data, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); @@ -173,7 +173,7 @@ unsigned msg_waitFor( msg_t *msg, unsigned *data, uint32_t delay ) /* -------------------------------------------------------------------------- */ static -unsigned priv_msg_send( msg_t *msg, unsigned data, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_msg_send( msg_t *msg, unsigned data, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { tsk_t * tsk; @@ -204,7 +204,7 @@ unsigned priv_msg_send( msg_t *msg, unsigned data, uint32_t time, unsigned(*wait } /* -------------------------------------------------------------------------- */ -unsigned msg_sendUntil( msg_t *msg, unsigned data, uint32_t time ) +unsigned msg_sendUntil( msg_t *msg, unsigned data, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -213,7 +213,7 @@ unsigned msg_sendUntil( msg_t *msg, unsigned data, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned msg_sendFor( msg_t *msg, unsigned data, uint32_t delay ) +unsigned msg_sendFor( msg_t *msg, unsigned data, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); diff --git a/StateOS/kernel/src/os_mtx.c b/StateOS/kernel/src/os_mtx.c index 6ddbec0f..1e5b5b4a 100644 --- a/StateOS/kernel/src/os_mtx.c +++ b/StateOS/kernel/src/os_mtx.c @@ -2,7 +2,7 @@ @file StateOS: os_mtx.c @author Rajmund Szymanski - @date 08.12.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -138,7 +138,7 @@ void mtx_delete( mtx_t *mtx ) /* -------------------------------------------------------------------------- */ static -unsigned priv_mtx_wait( mtx_t *mtx, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_mtx_wait( mtx_t *mtx, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { unsigned event = E_TIMEOUT; @@ -178,7 +178,7 @@ unsigned priv_mtx_wait( mtx_t *mtx, uint32_t time, unsigned(*wait)(void*,uint32_ } /* -------------------------------------------------------------------------- */ -unsigned mtx_waitUntil( mtx_t *mtx, uint32_t time ) +unsigned mtx_waitUntil( mtx_t *mtx, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -187,7 +187,7 @@ unsigned mtx_waitUntil( mtx_t *mtx, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned mtx_waitFor( mtx_t *mtx, uint32_t delay ) +unsigned mtx_waitFor( mtx_t *mtx, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); diff --git a/StateOS/kernel/src/os_mut.c b/StateOS/kernel/src/os_mut.c index 42031673..1660ca29 100644 --- a/StateOS/kernel/src/os_mut.c +++ b/StateOS/kernel/src/os_mut.c @@ -2,7 +2,7 @@ @file StateOS: os_mut.c @author Rajmund Szymanski - @date 08.12.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -89,7 +89,7 @@ void mut_delete( mut_t *mut ) /* -------------------------------------------------------------------------- */ static -unsigned priv_mut_wait( mut_t *mut, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_mut_wait( mut_t *mut, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { unsigned event = E_TIMEOUT; @@ -115,7 +115,7 @@ unsigned priv_mut_wait( mut_t *mut, uint32_t time, unsigned(*wait)(void*,uint32_ } /* -------------------------------------------------------------------------- */ -unsigned mut_waitUntil( mut_t *mut, uint32_t time ) +unsigned mut_waitUntil( mut_t *mut, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -124,7 +124,7 @@ unsigned mut_waitUntil( mut_t *mut, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned mut_waitFor( mut_t *mut, uint32_t delay ) +unsigned mut_waitFor( mut_t *mut, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); diff --git a/StateOS/kernel/src/os_sem.c b/StateOS/kernel/src/os_sem.c index 881306ac..7616d545 100644 --- a/StateOS/kernel/src/os_sem.c +++ b/StateOS/kernel/src/os_sem.c @@ -2,7 +2,7 @@ @file StateOS: os_sem.c @author Rajmund Szymanski - @date 13.12.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -95,7 +95,7 @@ void sem_delete( sem_t *sem ) /* -------------------------------------------------------------------------- */ static -unsigned priv_sem_wait( sem_t *sem, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_sem_wait( sem_t *sem, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { unsigned event = E_SUCCESS; @@ -116,7 +116,7 @@ unsigned priv_sem_wait( sem_t *sem, uint32_t time, unsigned(*wait)(void*,uint32_ } /* -------------------------------------------------------------------------- */ -unsigned sem_waitUntil( sem_t *sem, uint32_t time ) +unsigned sem_waitUntil( sem_t *sem, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -125,7 +125,7 @@ unsigned sem_waitUntil( sem_t *sem, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned sem_waitFor( sem_t *sem, uint32_t delay ) +unsigned sem_waitFor( sem_t *sem, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); @@ -135,7 +135,7 @@ unsigned sem_waitFor( sem_t *sem, uint32_t delay ) /* -------------------------------------------------------------------------- */ static -unsigned priv_sem_send( sem_t *sem, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_sem_send( sem_t *sem, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { unsigned event = E_SUCCESS; @@ -159,7 +159,7 @@ unsigned priv_sem_send( sem_t *sem, uint32_t time, unsigned(*wait)(void*,uint32_ } /* -------------------------------------------------------------------------- */ -unsigned sem_sendUntil( sem_t *sem, uint32_t time ) +unsigned sem_sendUntil( sem_t *sem, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -168,7 +168,7 @@ unsigned sem_sendUntil( sem_t *sem, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned sem_sendFor( sem_t *sem, uint32_t delay ) +unsigned sem_sendFor( sem_t *sem, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); diff --git a/StateOS/kernel/src/os_sig.c b/StateOS/kernel/src/os_sig.c index df23afa1..f257a913 100644 --- a/StateOS/kernel/src/os_sig.c +++ b/StateOS/kernel/src/os_sig.c @@ -2,7 +2,7 @@ @file StateOS: os_sig.c @author Rajmund Szymanski - @date 22.10.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -93,7 +93,7 @@ void sig_delete( sig_t *sig ) /* -------------------------------------------------------------------------- */ static -unsigned priv_sig_wait( sig_t *sig, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_sig_wait( sig_t *sig, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { unsigned event = E_SUCCESS; @@ -117,7 +117,7 @@ unsigned priv_sig_wait( sig_t *sig, uint32_t time, unsigned(*wait)(void*,uint32_ } /* -------------------------------------------------------------------------- */ -unsigned sig_waitUntil( sig_t *sig, uint32_t time ) +unsigned sig_waitUntil( sig_t *sig, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -126,7 +126,7 @@ unsigned sig_waitUntil( sig_t *sig, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned sig_waitFor( sig_t *sig, uint32_t delay ) +unsigned sig_waitFor( sig_t *sig, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); diff --git a/StateOS/kernel/src/os_tmr.c b/StateOS/kernel/src/os_tmr.c index d1631d70..af7bafcf 100644 --- a/StateOS/kernel/src/os_tmr.c +++ b/StateOS/kernel/src/os_tmr.c @@ -2,7 +2,7 @@ @file StateOS: os_tmr.c @author Rajmund Szymanski - @date 19.12.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -106,7 +106,7 @@ void priv_tmr_start( tmr_t *tmr ) } /* -------------------------------------------------------------------------- */ -void tmr_startUntil( tmr_t *tmr, uint32_t time ) +void tmr_startUntil( tmr_t *tmr, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(tmr); @@ -115,7 +115,7 @@ void tmr_startUntil( tmr_t *tmr, uint32_t time ) tmr->start = core_sys_time(); tmr->delay = time - tmr->start; - if ((int32_t)tmr->delay < 0) + if (tmr->delay > ((CNT_MAX)>>1)) tmr->delay = 0; tmr->period = 0; @@ -125,7 +125,7 @@ void tmr_startUntil( tmr_t *tmr, uint32_t time ) } /* -------------------------------------------------------------------------- */ -void tmr_start( tmr_t *tmr, uint32_t delay, uint32_t period ) +void tmr_start( tmr_t *tmr, cnt_t delay, cnt_t period ) /* -------------------------------------------------------------------------- */ { assert(tmr); @@ -142,7 +142,7 @@ void tmr_start( tmr_t *tmr, uint32_t delay, uint32_t period ) } /* -------------------------------------------------------------------------- */ -void tmr_startFrom( tmr_t *tmr, uint32_t delay, uint32_t period, fun_t *proc ) +void tmr_startFrom( tmr_t *tmr, cnt_t delay, cnt_t period, fun_t *proc ) /* -------------------------------------------------------------------------- */ { assert(tmr); @@ -161,7 +161,7 @@ void tmr_startFrom( tmr_t *tmr, uint32_t delay, uint32_t period, fun_t *proc ) /* -------------------------------------------------------------------------- */ static -unsigned priv_tmr_wait( tmr_t *tmr, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_tmr_wait( tmr_t *tmr, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { unsigned event = E_SUCCESS; @@ -181,7 +181,7 @@ unsigned priv_tmr_wait( tmr_t *tmr, uint32_t time, unsigned(*wait)(void*,uint32_ } /* -------------------------------------------------------------------------- */ -unsigned tmr_waitUntil( tmr_t *tmr, uint32_t time ) +unsigned tmr_waitUntil( tmr_t *tmr, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -190,7 +190,7 @@ unsigned tmr_waitUntil( tmr_t *tmr, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned tmr_waitFor( tmr_t *tmr, uint32_t delay ) +unsigned tmr_waitFor( tmr_t *tmr, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside() || !delay); diff --git a/StateOS/kernel/src/os_tsk.c b/StateOS/kernel/src/os_tsk.c index d96d62d1..83185096 100644 --- a/StateOS/kernel/src/os_tsk.c +++ b/StateOS/kernel/src/os_tsk.c @@ -2,7 +2,7 @@ @file StateOS: os_tsk.c @author Rajmund Szymanski - @date 14.12.2017 + @date 01.01.2018 @brief This file provides set of functions for StateOS. ****************************************************************************** @@ -277,7 +277,7 @@ void tsk_prio( unsigned prio ) /* -------------------------------------------------------------------------- */ static -unsigned priv_tsk_wait( unsigned flags, uint32_t time, unsigned(*wait)(void*,uint32_t) ) +unsigned priv_tsk_wait( unsigned flags, cnt_t time, unsigned(*wait)(void*,cnt_t) ) /* -------------------------------------------------------------------------- */ { unsigned event; @@ -293,7 +293,7 @@ unsigned priv_tsk_wait( unsigned flags, uint32_t time, unsigned(*wait)(void*,uin } /* -------------------------------------------------------------------------- */ -unsigned tsk_waitUntil( unsigned flags, uint32_t time ) +unsigned tsk_waitUntil( unsigned flags, cnt_t time ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); @@ -302,7 +302,7 @@ unsigned tsk_waitUntil( unsigned flags, uint32_t time ) } /* -------------------------------------------------------------------------- */ -unsigned tsk_waitFor( unsigned flags, uint32_t delay ) +unsigned tsk_waitFor( unsigned flags, cnt_t delay ) /* -------------------------------------------------------------------------- */ { assert(!port_isr_inside()); diff --git a/StateOS/port/STM32F4/osport.c b/StateOS/port/STM32F4/osport.c index b134ed38..38ced5a8 100644 --- a/StateOS/port/STM32F4/osport.c +++ b/StateOS/port/STM32F4/osport.c @@ -2,7 +2,7 @@ @file StateOS: osport.c @author Rajmund Szymanski - @date 28.12.2017 + @date 05.01.2018 @brief StateOS port file for STM32F4 uC. ****************************************************************************** @@ -86,9 +86,15 @@ void port_sys_init( void ) NVIC_SetPriority(TIM2_IRQn, 0xFF); NVIC_EnableIRQ(TIM2_IRQn); + #if HW_TIMER_SIZE > OS_TIMER_SIZE + TIM2->ARR = CNT_MAX; + #endif TIM2->PSC = (CPU_FREQUENCY)/(OS_FREQUENCY)/2-1; TIM2->EGR = TIM_EGR_UG; TIM2->CR1 = TIM_CR1_CEN; + #if HW_TIMER_SIZE < OS_TIMER_SIZE + TIM2->DIER = TIM_DIER_UIE; + #endif /****************************************************************************** End of configuration @@ -163,7 +169,14 @@ void SysTick_Handler( void ) void TIM2_IRQHandler( void ) { -// if (TIM2->SR & TIM_SR_CC1IF) + #if HW_TIMER_SIZE < OS_TIMER_SIZE + if (TIM2->SR & TIM_SR_UIF) + { + TIM2->SR = ~TIM_SR_UIF; + core_sys_tick(); + } + if (TIM2->SR & TIM_SR_CC1IF) + #endif { TIM2->SR = ~TIM_SR_CC1IF; core_tmr_handler(); @@ -174,6 +187,35 @@ void TIM2_IRQHandler( void ) End of the handler *******************************************************************************/ +/****************************************************************************** + Tick-less mode: return current system time +*******************************************************************************/ + +#if HW_TIMER_SIZE < OS_TIMER_SIZE + +cnt_t port_sys_time( void ) +{ + cnt_t cnt; + uint32_t tck; + + cnt = System.cnt; + tck = TIM2->CNT; + + if (TIM2->SR & TIM_SR_UIF) + { + tck = TIM2->CNT; + cnt += (cnt_t)(1) << (HW_TIMER_SIZE); + } + + return cnt + tck; +} + +#endif + +/****************************************************************************** + End of the function +*******************************************************************************/ + #if OS_ROBIN /****************************************************************************** diff --git a/StateOS/port/STM32F4/osport.h b/StateOS/port/STM32F4/osport.h index 24203663..41fc7378 100644 --- a/StateOS/port/STM32F4/osport.h +++ b/StateOS/port/STM32F4/osport.h @@ -2,7 +2,7 @@ @file StateOS: osport.h @author Rajmund Szymanski - @date 28.12.2017 + @date 05.01.2018 @brief StateOS port definitions for STM32F4 uC. ****************************************************************************** @@ -52,20 +52,28 @@ extern "C" { #endif /* -------------------------------------------------------------------------- */ +// !! WARNING! OS_TIMER_SIZE < HW_TIMER_SIZE may cause unexpected problems !! + +#ifndef OS_TIMER_SIZE +#define OS_TIMER_SIZE 32 /* bit size of system timer counter */ +#endif + +/* -------------------------------------------------------------------------- */ +// !! WARNING! OS_TIMER_SIZE < HW_TIMER_SIZE may cause unexpected problems !! #ifdef HW_TIMER_SIZE -#error HW_TIMER_SIZE is an internal definition! +#error HW_TIMER_SIZE is an internal os definition! #elif OS_FREQUENCY > 1000 -#define HW_TIMER_SIZE 32 +#define HW_TIMER_SIZE 32 /* bit size of hardware timer */ #else -#define HW_TIMER_SIZE 0 +#define HW_TIMER_SIZE 0 /* os does not work in tick-less mode */ #endif /* -------------------------------------------------------------------------- */ // alternate clock source for SysTick #ifdef ST_FREQUENCY -#error ST_FREQUENCY is an internal definition! +#error ST_FREQUENCY is an internal port definition! #else #define ST_FREQUENCY ((CPU_FREQUENCY)/8) #endif @@ -83,7 +91,7 @@ extern "C" { /* -------------------------------------------------------------------------- */ // return current system time -#if HW_TIMER_SIZE >= 32 +#if HW_TIMER_SIZE >= OS_TIMER_SIZE __STATIC_INLINE uint32_t port_sys_time( void ) @@ -122,7 +130,11 @@ __STATIC_INLINE void port_tmr_stop( void ) { #if HW_TIMER_SIZE + #if HW_TIMER_SIZE < OS_TIMER_SIZE + TIM2->DIER = TIM_DIER_UIE; + #else TIM2->DIER = 0; + #endif #endif } @@ -134,7 +146,11 @@ void port_tmr_start( uint32_t timeout ) { #if HW_TIMER_SIZE TIM2->CCR1 = timeout; + #if HW_TIMER_SIZE < OS_TIMER_SIZE + TIM2->DIER = TIM_DIER_CC1IE | TIM_DIER_UIE; + #else TIM2->DIER = TIM_DIER_CC1IE; + #endif #else (void) timeout; #endif @@ -147,7 +163,12 @@ __STATIC_INLINE void port_tmr_force( void ) { #if HW_TIMER_SIZE + #if HW_TIMER_SIZE < OS_TIMER_SIZE + TIM2->DIER = TIM_DIER_CC1IE | TIM_DIER_UIE; + TIM2->EGR = TIM_EGR_CC1G; + #else NVIC_SetPendingIRQ(TIM2_IRQn); + #endif #endif } diff --git a/src/osconfig.h b/src/osconfig.h index f47cf884..2d045091 100644 --- a/src/osconfig.h +++ b/src/osconfig.h @@ -2,7 +2,7 @@ @file StateOS: osconfig.h @author Rajmund Szymanski - @date 28.12.2017 + @date 03.01.2018 @brief StateOS config file for STM32F4 uC. ****************************************************************************** @@ -73,3 +73,9 @@ // idle task stack size in bytes // default value: 128 #define OS_IDLE_STACK 128 + +// ---------------------------- +// bit size of system timer counter +// available values: 16, 32, 64 +// default value: 32 +#define OS_TIMER_SIZE 32