mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
Reverting back to static .a files for C++ and fixing lots of other assorted items
This commit is contained in:
@@ -1,38 +1,39 @@
|
||||
|
||||
#include "HAL/Interrupts.h"
|
||||
|
||||
#include "HAL/Interrupts.hpp"
|
||||
#include "ChipObject.h"
|
||||
|
||||
struct interrupt_t {
|
||||
tInterrupt *anInterrupt;
|
||||
tInterruptManager *manager;
|
||||
struct Interrupt // FIXME: why is this internal?
|
||||
{
|
||||
tInterrupt *anInterrupt;
|
||||
tInterruptManager *manager;
|
||||
};
|
||||
typedef struct interrupt_t Interrupt;
|
||||
|
||||
void* initializeInterrupts(uint32_t interruptIndex, bool watcher, int32_t *status) {
|
||||
Interrupt* anInterrupt = new Interrupt();
|
||||
// Expects the calling leaf class to allocate an interrupt index.
|
||||
anInterrupt->anInterrupt = tInterrupt::create(interruptIndex, status);
|
||||
anInterrupt->anInterrupt->writeConfig_WaitForAck(false, status);
|
||||
anInterrupt->manager = new tInterruptManager(1 << interruptIndex, watcher, status);
|
||||
return anInterrupt;
|
||||
void* initializeInterrupts(uint32_t interruptIndex, bool watcher, int32_t *status)
|
||||
{
|
||||
Interrupt* anInterrupt = new Interrupt();
|
||||
// Expects the calling leaf class to allocate an interrupt index.
|
||||
anInterrupt->anInterrupt = tInterrupt::create(interruptIndex, status);
|
||||
anInterrupt->anInterrupt->writeConfig_WaitForAck(false, status);
|
||||
anInterrupt->manager = new tInterruptManager(1 << interruptIndex, watcher, status);
|
||||
return anInterrupt;
|
||||
}
|
||||
|
||||
void cleanInterrupts(void* interrupt_pointer, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
delete anInterrupt->anInterrupt;
|
||||
delete anInterrupt->manager;
|
||||
anInterrupt->anInterrupt = NULL;
|
||||
anInterrupt->manager = NULL;
|
||||
void cleanInterrupts(void* interrupt_pointer, int32_t *status)
|
||||
{
|
||||
Interrupt* anInterrupt = (Interrupt*)interrupt_pointer;
|
||||
delete anInterrupt->anInterrupt;
|
||||
delete anInterrupt->manager;
|
||||
anInterrupt->anInterrupt = NULL;
|
||||
anInterrupt->manager = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* In synchronous mode, wait for the defined interrupt to occur.
|
||||
* @param timeout Timeout in seconds
|
||||
*/
|
||||
void waitForInterrupt(void* interrupt_pointer, double timeout, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
anInterrupt->manager->watch((int32_t)(timeout * 1e3), status);
|
||||
void waitForInterrupt(void* interrupt_pointer, double timeout, int32_t *status)
|
||||
{
|
||||
Interrupt* anInterrupt = (Interrupt*)interrupt_pointer;
|
||||
anInterrupt->manager->watch((int32_t)(timeout * 1e3), status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,17 +41,19 @@ void waitForInterrupt(void* interrupt_pointer, double timeout, int32_t *status)
|
||||
* oInterrupts are disabled when the RequestInterrupt call is made. This gives time to do the
|
||||
* setup of the other options before starting to field interrupts.
|
||||
*/
|
||||
void enableInterrupts(void* interrupt_pointer, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
anInterrupt->manager->enable(status);
|
||||
void enableInterrupts(void* interrupt_pointer, int32_t *status)
|
||||
{
|
||||
Interrupt* anInterrupt = (Interrupt*)interrupt_pointer;
|
||||
anInterrupt->manager->enable(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable Interrupts without without deallocating structures.
|
||||
*/
|
||||
void disableInterrupts(void* interrupt_pointer, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
anInterrupt->manager->disable(status);
|
||||
void disableInterrupts(void* interrupt_pointer, int32_t *status)
|
||||
{
|
||||
Interrupt* anInterrupt = (Interrupt*)interrupt_pointer;
|
||||
anInterrupt->manager->disable(status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,29 +61,34 @@ void disableInterrupts(void* interrupt_pointer, int32_t *status) {
|
||||
* This is in the same time domain as GetClock().
|
||||
* @return Timestamp in seconds since boot.
|
||||
*/
|
||||
double readInterruptTimestamp(void* interrupt_pointer, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
uint32_t timestamp = anInterrupt->anInterrupt->readTimeStamp(status);
|
||||
return timestamp * 1e-6;
|
||||
double readInterruptTimestamp(void* interrupt_pointer, int32_t *status)
|
||||
{
|
||||
Interrupt* anInterrupt = (Interrupt*)interrupt_pointer;
|
||||
uint32_t timestamp = anInterrupt->anInterrupt->readTimeStamp(status);
|
||||
return timestamp * 1e-6;
|
||||
}
|
||||
|
||||
void requestInterrupts(void* interrupt_pointer, uint8_t routing_module, uint32_t routing_pin,
|
||||
bool routing_analog_trigger, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
bool routing_analog_trigger, int32_t *status)
|
||||
{
|
||||
Interrupt* anInterrupt = (Interrupt*)interrupt_pointer;
|
||||
anInterrupt->anInterrupt->writeConfig_WaitForAck(false, status);
|
||||
anInterrupt->anInterrupt->writeConfig_Source_AnalogTrigger(routing_analog_trigger, status);
|
||||
anInterrupt->anInterrupt->writeConfig_Source_Channel(routing_pin, status);
|
||||
anInterrupt->anInterrupt->writeConfig_Source_Module(routing_module, status);
|
||||
}
|
||||
|
||||
void attachInterruptHandler(void* interrupt_pointer, InterruptHandlerFunction handler,
|
||||
void* param, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
anInterrupt->manager->registerHandler(handler, param, status);
|
||||
void attachInterruptHandler(void* interrupt_pointer, InterruptHandlerFunction handler, void* param,
|
||||
int32_t *status)
|
||||
{
|
||||
Interrupt* anInterrupt = (Interrupt*)interrupt_pointer;
|
||||
anInterrupt->manager->registerHandler(handler, param, status);
|
||||
}
|
||||
|
||||
void setInterruptUpSourceEdge(void* interrupt_pointer, bool risingEdge, bool fallingEdge, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
anInterrupt->anInterrupt->writeConfig_RisingEdge(risingEdge, status);
|
||||
anInterrupt->anInterrupt->writeConfig_FallingEdge(fallingEdge, status);
|
||||
|
||||
void setInterruptUpSourceEdge(void* interrupt_pointer, bool risingEdge, bool fallingEdge,
|
||||
int32_t *status)
|
||||
{
|
||||
Interrupt* anInterrupt = (Interrupt*)interrupt_pointer;
|
||||
anInterrupt->anInterrupt->writeConfig_RisingEdge(risingEdge, status);
|
||||
anInterrupt->anInterrupt->writeConfig_FallingEdge(fallingEdge, status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user