-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduler.c
81 lines (70 loc) · 2.74 KB
/
scheduler.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* @file scheduler.c
* @date 2/11/20
* @author: connorhumiston
* @brief
* scheduler.h defines functions for scheduling and avoids interrupt incoherencies
*/
//***********************************************************************************
// Include files
//***********************************************************************************
#include "scheduler.h"
#include "em_emu.h"
#include "em_assert.h"
//***********************************************************************************
// Private Variables
//***********************************************************************************
static unsigned int event_scheduled;
//***********************************************************************************
// Functions
//***********************************************************************************
/***************************************************************************//**
* @brief
* Opens the scheduler functionality
* @details
* Resets the private variable event_scheduled to 0
******************************************************************************/
void scheduler_open(void)
{
// __disable_irq();
event_scheduled = 0;
// __enable_irq();
}
/***************************************************************************//**
* @brief
* Adds a new event to the scheduler
* @details
* ORs a new event, the input argument, into the existing state of the private variable event_scheduled.
* @param[in] event
* the event parameter includes the bits of the event being added
******************************************************************************/
void add_scheduled_event(uint32_t event)
{
__disable_irq();
event_scheduled |= event; //adds an event by ORing the event bits to the scheduler
__enable_irq();
}
/***************************************************************************//**
* @brief
* Removes an event from the scheduler
* @details
* Removes the event, the input argument, from the existing state of the private variable
* @param[in] event
* the event parameter includes the bits of the event being removed
******************************************************************************/
void remove_scheduled_event(uint32_t event)
{
__disable_irq();
event_scheduled &= ~event; //negates/removes the event bits using an AND NOT
__enable_irq();
}
/***************************************************************************//**
* @brief
* Returns the currently scheduled events
* @details
* Returns the current state of the private variable event_scheduled.
******************************************************************************/
uint32_t get_scheduled_events(void)
{
return event_scheduled;
}