#include "rit.h"
#include "power.h"
#include "types.h"
#include <LPC17xx.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()
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.
◆ RIT_Deinit()
De-initializes the RIT, by removing every job and disconnecting power.
Definition at line 43 of file rit.c.
44{
46 NVIC_DisableIRQ(RIT_IRQn);
48}
void POWER_TurnOffPeripheral(u8 bit)
Turns off a peripheral.
_DECL_EXTERNALLY void free_jobs_list(void)
◆ RIT_Disable()
void RIT_Disable |
( |
void |
| ) |
|
Disables the RIT entirely (stops counting).
Definition at line 55 of file rit.c.
56{
58}
#define CLR_BIT(reg, bit)
◆ RIT_Enable()
Enables the RIT counting.
Definition at line 50 of file rit.c.
51{
53}
#define SET_BIT(reg, bit)
◆ RIT_GetIntervalMs()
u32 RIT_GetIntervalMs |
( |
void |
| ) |
|
Returns the interval in millis that RIT uses for its interrupts.
Definition at line 65 of file rit.c.
66{
68}
_USED_EXTERNALLY u32 base_ival
◆ RIT_Init()
Initialize the RIT.
- Parameters
-
alloc | The memory allocator to use for the RIT job list. |
ival_ms | Interval in millis between each RIT interrupt. |
int_priority | Debouncer interrupt priority (0 (highest), 15 (lowest)). If set to INT_PRIO_DEF, the default priority will be used. |
- Note
- The RIT has a fixed number of jobs that can be added to the job queue, defined by RIT_JOBS_COUNT (20 by default) in the peripherals.h file.
- Returns
- RIT_Error The error.
Definition at line 15 of file rit.c.
16{
17
19
23
24 LPC_RIT->RICOMPVAL = (
rit_clk_mhz * ival_ms * 1000);
25 LPC_RIT->RICTRL = 6;
26 LPC_RIT->RICOUNTER = 0;
27
30
32
33
34 NVIC_EnableIRQ(RIT_IRQn);
35
38
39 NVIC_SetPriority(RIT_IRQn, int_priority);
41}
void POWER_TurnOnPeripheral(u8 bit)
Turns on a peripheral.
_DECL_EXTERNALLY u32 counter_reset_value
_PRIVATE const u32 rit_clk_mhz
RIT_CLK frequency in MHz. Can be checked in the RIT GUI in Keil.
_DECL_EXTERNALLY void allocate_jobs_list(MEM_Allocator *const)
@ RIT_ERR_INT_PRIO_INVALID
An invalid priority was specified (must be 0 <= prio <= 15). This is not necessarily an error,...
#define CLR_BITS(reg, value, bit)
#define IS_DEF_PRIORITY(prio)
#define IS_BETWEEN_EQ(value, low, hi)
◆ RIT_IsEnabled()
bool RIT_IsEnabled |
( |
void |
| ) |
|
Returns whether the RIT is counting or not.
Definition at line 60 of file rit.c.
61{
62 return LPC_RIT->RICTRL & (1 << 3);
63}
◆ base_ival
Definition at line 12 of file rit.c.
◆ counter_reset_value
Definition at line 13 of file rit.c.
◆ rit_clk_mhz
RIT_CLK frequency in MHz. Can be checked in the RIT GUI in Keil.
Definition at line 7 of file rit.c.