BRTOS  1.90
Brazilian Real-Time Operating System
 All Data Structures Files Functions Variables Macros
stimer.h
Go to the documentation of this file.
1 
9 /*********************************************************************************************************
10 * BRTOS
11 * Brazilian Real-Time Operating System
12 * Acronymous of Basic Real-Time Operating System
13 *
14 *
15 * Open Source RTOS under MIT License
16 *
17 *
18 *
19 * OS Soft Timers functions
20 *
21 *
22 * Authors: Carlos Henrique Barriquelo
23 * Revision: 1.0
24 * Date: 12/01/2013
25 *********************************************************************************************************/
26 
27 
28 /*****************************************************************/
29 /* OS SOFT TIMER */
30 /*****************************************************************/
31 #ifndef TIMERS_H
32 #define TIMERS_H
33 
34 #include "OS_types.h"
35 #include "BRTOSConfig.h"
36 #include "BRTOS.h"
37 
38 #ifdef BRTOS_TMR_EN
39 #if (BRTOS_TMR_EN == 1)
40 
43 #define BRTOS_MAX_TIMER_DEFAULT 8
44 #ifndef BRTOS_MAX_TIMER
45  #define BRTOS_MAX_TIMER BRTOS_MAX_TIMER_DEFAULT
46 #endif
47 
48 /* config defines */
49 // do not change, unless we know what are you doing
50 #define TIMER_CNT ostick_t
51 #define TIMER_MAX_COUNTER (TIMER_CNT)(TICK_COUNT_OVERFLOW-1)
52 
53 /* typedefs for callback struct */
54 typedef TIMER_CNT (*FCN_CALLBACK) (void);
55 
56 /* soft timer possible states:
57 */
58 typedef enum
59 {
60  TIMER_NOT_ALLOCATED = 0,
61  TIMER_NOT_USED = 1,
62  TIMER_STOPPED = 2,
63  TIMER_RUNNING = 3,
64  TIMER_SEARCH = 4,
65 } TIMER_STATE;
66 
67 /* soft timer data struct
68 */
69 typedef struct BRTOS_TIMER_S
70 {
71  FCN_CALLBACK func_cb;
72  TIMER_CNT timeout;
73  TIMER_STATE state;
74 } BRTOS_TIMER_T;
75 
76 /* soft timer typedef
77 */
78 typedef BRTOS_TIMER_T* BRTOS_TIMER;
79 
80 /* soft timers list data struct
81 */
82 
83 typedef struct
84 {
85  BRTOS_TIMER timers [BRTOS_MAX_TIMER];
86  int8_t count;
87 }BRTOS_TMR_T;
88 
89 
90 /* TIMER TASK prototype */
91 #if (TASK_WITH_PARAMETERS == 1)
92 void BRTOSTimerTask(void *param);
93 #else
94 void BRTOSTimerTask(void);
95 #endif
96 
97 /************* public API *********************/
98 void OSTimerInit(uint16_t timertask_stacksize, uint8_t prio);
99 uint8_t OSTimerSet (BRTOS_TIMER *cbp, FCN_CALLBACK cb, TIMER_CNT timeout);
100 TIMER_CNT OSTimerGet (BRTOS_TIMER p);
101 uint8_t OSTimerStart (BRTOS_TIMER p, TIMER_CNT timeout);
102 uint8_t OSTimerStop (BRTOS_TIMER p, uint8_t del);
103 
104 /***************************************/
105 
106 
107 #endif
108 #endif
109 /*****************************************************************/
110 /* OS SOFT TIMER EOF */
111 /*****************************************************************/
112 
113 #endif
BRTOS kernel main defines, functions prototypes and structs declaration.
BRTOS types declaration.