mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Initial checkin of unified hierarchy of WPILib 2015
This commit is contained in:
40
hal/Azalea/src/main/native/Notifier.cpp
Normal file
40
hal/Azalea/src/main/native/Notifier.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
#include "HAL/Notifier.h"
|
||||
|
||||
#include "ChipObject.h"
|
||||
|
||||
static const uint32_t kTimerInterruptNumber = 28;
|
||||
|
||||
struct notifier_t {
|
||||
tAlarm *alarm;
|
||||
tInterruptManager *manager;
|
||||
};
|
||||
typedef struct notifier_t Notifier;
|
||||
|
||||
void* initializeNotifier(void (*ProcessQueue)(uint32_t, void*), int32_t *status) {
|
||||
Notifier* notifier = new Notifier();
|
||||
notifier->manager = new tInterruptManager(1 << kTimerInterruptNumber, false, status);
|
||||
notifier->manager->registerHandler(ProcessQueue, NULL, status);
|
||||
notifier->manager->enable(status);
|
||||
notifier->alarm = tAlarm::create(status);
|
||||
return notifier;
|
||||
}
|
||||
|
||||
void cleanNotifier(void* notifier_pointer, int32_t *status) {
|
||||
Notifier* notifier = (Notifier*) notifier_pointer;
|
||||
notifier->alarm->writeEnable(false, status);
|
||||
delete notifier->alarm;
|
||||
notifier->alarm = NULL;
|
||||
notifier->manager->disable(status);
|
||||
delete notifier->manager;
|
||||
notifier->manager = NULL;
|
||||
}
|
||||
|
||||
|
||||
void updateNotifierAlarm(void* notifier_pointer, uint32_t triggerTime, int32_t *status) {
|
||||
Notifier* notifier = (Notifier*) notifier_pointer;
|
||||
// write the first item in the queue into the trigger time
|
||||
notifier->alarm->writeTriggerTime(triggerTime, status);
|
||||
// Enable the alarm. The hardware disables itself after each alarm.
|
||||
notifier->alarm->writeEnable(true, status);
|
||||
}
|
||||
Reference in New Issue
Block a user