Golem  v0.1.1
Generic Operating system Libraries for Embedded Multitasking
 All Data Structures Files Functions Variables Pages
example_glm_conf.c
1 /*
2  * Specify the register size to be used on the platform. Valid values are:
3  * CORE_8BIT
4  * CORE_16BIT
5  * CORE_32BIT
6  * CORE_64BIT
7  *
8  * Golem is configured for a 32-bit system below.
9  */
10 #define CORE_32BIT
11 
12 
13 /*
14  * Specify the maximum frequency (in Hz) with which your platform will run.
15  * For a 80MHz processor this would be as stated below.
16  */
17 #define CORE_FREQ_HZ_MAX 80000000L
18 
19 
20 /*
21  * Specify the frequency (in Hz) with which Golem's tick function is called
22  * by (most probably) some timer interrupt routine. Below it is configured
23  * at 1kHz.
24  *
25  * CORE_TICK_FREQ_HZ defines the resolution of both Golem's scheduler and
26  * alarm functionality. So for this example, the alarm (see glm_alarm.h) is
27  * set to a 1ms resolution. Likewise, the minimum scheduling slot (see
28  * glm_scheduler.h) is set to 1ms.
29  */
30 #define CORE_TICK_FREQ_HZ 1000
31 
32 
33 /*
34  * Specify which function can be called by Golem in order to obtain the
35  * present timer value. With this timer value Golem's multitasking
36  * scheduler can perform with sub-tick precision - in other words; better
37  * than CORE_TICK_FREQ_HZ.
38  *
39  * If this functionality is not needed or not available on your platform,
40  * please comment-out the line.
41  *
42  * Below it is configured for calling a non-Golem function named
43  * core_subtick_read() which should return the timer value as a uint_base_t
44  * (see: glm_intbase.h).
45  *
46  * Note that the CORE_SUBTICK_FUNC must compensate its return value if the
47  * processor speed changes from the specified CORE_FREQ_HZ_MAX at run-time.
48  */
49 #define CORE_SUBTICK_FUNC core_subtick_read
50 
51 
52 /*
53  * The size of each scheduling slot is measured in ticks
54  * and as such it us defined by CORE_TICK_FREQ_HZ. Below
55  * it is configured to a 1/CORE_TICK_FREQ_HZ = 1ms slot.
56  */
57 #define SCHEDULER_SLOT_SIZE_TICKS 1
58 
59 
60 /*
61  * If during a scheduling slot there is time left, the scheduler will enter
62  * an IDLE-state. The scheduler can be configured to run the specified
63  * functions when entering or leaving this IDLE-state respectively. Leave
64  * commented if not used.
65  *
66  * One suggested use is power-saving by throttling down the core frequency
67  * during the IDLE-state. Note that one must obey the core tick configured
68  * by CORE_TICK_FREQ_HZ. Golem also assumes CORE_FREQ_HZ_MAX is true when
69  * it converts the subtick value into a time (if CORE_SUBTICK_FUNC is used)
70  * regardless of any CPU-throttling. Therefore, if using CORE_SUBTICK_FUNC,
71  * compensate for throttled processor speed.
72  *
73  * It is adviced to keep the execution time of these functions short in
74  * order to reduce their impact on the scheduling system. Use wisely in
75  * combination with a good SCHEDULER_IDLE_FUNC_RUNTH_PERC setting.
76  */
77 #define SCHEDULER_IDLE_ENTER_FUNC sleep
78 #define SCHEDULER_IDLE_LEAVE_FUNC wakeup
79 
80 
81 /*
82  * The SCHEDULER_IDLE_ENTER_FUNC and SCHEDULER_IDLE_LEAVE_FUNC execution
83  * time may screw up the scheduling when they cross the slot boundary. Both
84  * functions are only called when there's enough time left in IDLE-state.
85  *
86  * The configuration below states that the IDLE-functions are called only
87  * if the IDLE-time is more than 5% of the slot's time.
88  */
89 #define SCHEDULER_IDLE_FUNC_RUNTH_PERC 5