#include "cl_list.h"
#include "rit.h"
#include <LPC17xx.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
◆ allocate_jobs_list()
Definition at line 37 of file rit_job.c.
38{
41 return;
42}
CL_List * CL_ListAlloc(MEM_Allocator *const alloc, u32 elem_sz)
Initializes a new doubly-linked list with tail, with the allocated memory provided by the user.
_PRIVATE CL_List * jobs
Array of jobs to execute in the RIT interrupt handler.
◆ free_jobs_list()
void free_jobs_list |
( |
void |
| ) |
|
Definition at line 45 of file rit_job.c.
46{
49}
void CL_ListFree(CL_List *const list)
Frees the memory previously assigned to the list.
◆ recalculate_reset_value()
_PRIVATE void recalculate_reset_value |
( |
void |
| ) |
|
Definition at line 51 of file rit_job.c.
52{
55 if (!job->enabled || !job->job)
56 continue;
57
60 });
61}
#define CL_LIST_FOREACH_PTR(__type, __name, __list,...)
Macro to iterate over the elements of the list with a pointer to the current element.
_DECL_EXTERNALLY u32 base_ival
External variable that stores the base interval between each RIT interrupt.
_USED_EXTERNALLY u32 counter_reset_value
◆ RIT_AddJob()
Definition at line 104 of file rit_job.c.
105{
109
110
113
115}
CL_Error CL_ListPushBack(CL_List *const list, const void *const elem)
Adds an element at the end of the list.
@ RIT_ERR_DURING_PUSHBACK
An error occurred during the push back of the job in the list.
◆ RIT_ClearJobs()
void RIT_ClearJobs |
( |
void |
| ) |
|
Clears the job queue.
Definition at line 175 of file rit_job.c.
176{
179}
void CL_ListClear(CL_List *const list)
Removes all elements from the list.
◆ RIT_DisableJob()
Exclude this job from the RIT handler queue.
Definition at line 85 of file rit_job.c.
86{
88 if (list_job->job == job)
89 {
90 list_job->enabled = false;
91
92
93
94 if (list_job->interval == counter_reset_value)
95 recalculate_reset_value();
96
97 return RIT_ERR_OK;
98 }
99 });
100
102}
@ RIT_ERR_JOB_NOT_FOUND
The job specified was not found in the handler queue.
◆ RIT_EnableJob()
Include this job in the RIT handler queue.
Definition at line 65 of file rit_job.c.
66{
68 if (list_job->job == job)
69 {
70 list_job->enabled = true;
71
72
73
74 if (list_job->interval > counter_reset_value)
75 counter_reset_value = list_job->interval;
76
77 return RIT_ERR_OK;
78 }
79 });
80
81
83}
◆ RIT_GetJobMultiplierFactor()
Returns the multiplier factor for the given job.
- Parameters
-
job | The job to get the multiplier factor from |
- Returns
- u8 The multiplier factor
Definition at line 143 of file rit_job.c.
144{
146 if (list_job->job == job)
148 })
149
150 return 0;
151}
◆ RIT_GetJobsCount()
u32 RIT_GetJobsCount |
( |
void |
| ) |
|
Returns the number of jobs in the job queue.
Definition at line 138 of file rit_job.c.
139{
141}
u32 CL_ListSize(const CL_List *const list)
Gets the number of elements in the list.
◆ RIT_IRQHandler()
void RIT_IRQHandler |
( |
void |
| ) |
|
|
extern |
Definition at line 183 of file rit_job.c.
184{
185#ifdef SIMULATOR
187#endif
188
189 LPC_RIT->RICOUNTER = 0;
191
193 return;
194
197 if (!job->enabled)
198 continue;
199
200 if (
counter % job->interval == 0 && job->job)
201 job->job();
202 });
203
204
207
208#ifdef SIMULATOR
210#endif
211}
void RIT_Disable(void)
Disables the RIT entirely (stops counting).
void RIT_Enable(void)
Enables the RIT counting.
_PRIVATE u32 counter
Stores the current RIT counter value, and it's incremented by each RIT interrupt. It's used with the ...
#define SET_BIT(reg, bit)
◆ RIT_RemoveJob()
Removes a job from the RIT interrupt handler job queue.
- Parameters
-
Definition at line 117 of file rit_job.c.
118{
120 {
123 {
124 if (list_job->
job == job)
125 {
128
130 break;
131 }
132 }
133 }
134
136}
CL_Error CL_ListRemoveAt(CL_List *const list, u32 index, void *out_elem)
Removes an element at the specified index.
CL_Error CL_ListGetPtr(const CL_List *const list, u32 index, void **out_elem)
Gets an element at the specified index as a pointer, so the user can modify it.
_PRIVATE void recalculate_reset_value(void)
@ RIT_ERR_DURING_REMOVEAT
An error occurred during the removal of the job from the list.
◆ RIT_SetJobMultiplierFactor()
Sets the multiplier factor for the given job.
- Parameters
-
job | The job to set the multiplier factor for |
multiplier_factor | The new multiplier factor |
- Returns
- RIT_Error The error.
Definition at line 153 of file rit_job.c.
154{
155 if (multiplier_factor == 0)
157
159 if (list_job->job == job)
160 {
161 list_job->interval = base_ival * multiplier_factor;
162
163
164
165 if (list_job->interval == counter_reset_value)
166 recalculate_reset_value();
167
168 return RIT_ERR_OK;
169 }
170 });
171
173}
@ RIT_ERR_INVALID_MULTIPLIER
An invalid multiplier factor was specified (must be > 0).
◆ base_ival
External variable that stores the base interval between each RIT interrupt.
- Note
- This variable is used to calculate the RIT counter value for each job.
Definition at line 23 of file rit_job.c.
◆ counter
Stores the current RIT counter value, and it's incremented by each RIT interrupt. It's used with the counter_reset_value, that's the maximum value the counter can reach before being reset, which corresponds to the interval of the less frequent job.
Definition at line 31 of file rit_job.c.
◆ counter_reset_value
◆ jobs
Array of jobs to execute in the RIT interrupt handler.
Definition at line 26 of file rit_job.c.