2016-05-25 20:23:37 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
|
2016-05-25 20:23:37 -07:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2014-05-02 17:54:01 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2016-07-07 21:43:55 -07:00
|
|
|
#include "HAL/AnalogTrigger.h"
|
2016-07-12 10:45:14 -07:00
|
|
|
#include "HAL/Types.h"
|
2016-06-20 23:22:49 -07:00
|
|
|
|
2016-07-12 21:53:06 -07:00
|
|
|
#ifdef __cplusplus
|
2016-05-20 17:30:37 -07:00
|
|
|
extern "C" {
|
2016-07-12 21:53:06 -07:00
|
|
|
#endif
|
2016-09-25 16:50:13 -07:00
|
|
|
|
2016-09-05 07:31:51 -07:00
|
|
|
typedef void (*HAL_InterruptHandlerFunction)(uint32_t interruptAssertedMask,
|
|
|
|
|
void* param);
|
2014-05-02 17:54:01 -04:00
|
|
|
|
2018-07-04 00:18:18 -07:00
|
|
|
/**
|
|
|
|
|
* Initializes an interrupt.
|
|
|
|
|
*
|
|
|
|
|
* @param watcher true for synchronous interrupts, false for asynchronous
|
|
|
|
|
* @return the created interrupt handle
|
|
|
|
|
*/
|
2016-07-12 10:45:14 -07:00
|
|
|
HAL_InterruptHandle HAL_InitializeInterrupts(HAL_Bool watcher, int32_t* status);
|
2018-07-04 00:18:18 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Frees an interrupt.
|
|
|
|
|
*
|
|
|
|
|
* @param interruptHandle the interrupt handle
|
|
|
|
|
* @return the param passed to the interrupt, or nullptr if one
|
|
|
|
|
* wasn't passed.
|
|
|
|
|
*/
|
2018-05-24 17:02:13 -07:00
|
|
|
void* HAL_CleanInterrupts(HAL_InterruptHandle interruptHandle, int32_t* status);
|
2014-05-02 17:54:01 -04:00
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
2018-07-04 00:18:18 -07:00
|
|
|
* In synchronous mode, waits for the defined interrupt to occur.
|
|
|
|
|
*
|
|
|
|
|
* @param interruptHandle the interrupt handle
|
|
|
|
|
* @param timeout timeout in seconds
|
|
|
|
|
* @param ignorePrevious if true, ignore interrupts that happened before
|
|
|
|
|
* waitForInterrupt was called
|
|
|
|
|
* @return the mask of interrupts that fired
|
2018-05-31 20:47:15 -07:00
|
|
|
*/
|
2016-08-12 13:45:28 -07:00
|
|
|
int64_t HAL_WaitForInterrupt(HAL_InterruptHandle interruptHandle,
|
2016-07-12 10:45:14 -07:00
|
|
|
double timeout, HAL_Bool ignorePrevious,
|
|
|
|
|
int32_t* status);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
2018-07-04 00:18:18 -07:00
|
|
|
* Enables interrupts to occur on this input.
|
|
|
|
|
*
|
2018-05-31 20:47:15 -07:00
|
|
|
* Interrupts are disabled when the RequestInterrupt call is made. This gives
|
|
|
|
|
* time to do the setup of the other options before starting to field
|
|
|
|
|
* interrupts.
|
2018-07-04 00:18:18 -07:00
|
|
|
*
|
|
|
|
|
* @param interruptHandle the interrupt handle
|
2018-05-31 20:47:15 -07:00
|
|
|
*/
|
2016-08-12 13:45:28 -07:00
|
|
|
void HAL_EnableInterrupts(HAL_InterruptHandle interruptHandle, int32_t* status);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
2018-07-04 00:18:18 -07:00
|
|
|
* Disables interrupts without without deallocating structures.
|
|
|
|
|
*
|
|
|
|
|
* @param interruptHandle the interrupt handle
|
2018-05-31 20:47:15 -07:00
|
|
|
*/
|
2016-08-12 13:45:28 -07:00
|
|
|
void HAL_DisableInterrupts(HAL_InterruptHandle interruptHandle,
|
2016-07-09 00:24:26 -07:00
|
|
|
int32_t* status);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
2018-07-04 00:18:18 -07:00
|
|
|
* Returns the timestamp for the rising interrupt that occurred most recently.
|
|
|
|
|
*
|
|
|
|
|
* This is in the same time domain as HAL_GetFPGATime().
|
|
|
|
|
*
|
|
|
|
|
* @param interruptHandle the interrupt handle
|
|
|
|
|
* @return timestamp in seconds since FPGA Initialization
|
2018-05-31 20:47:15 -07:00
|
|
|
*/
|
2016-08-12 13:45:28 -07:00
|
|
|
double HAL_ReadInterruptRisingTimestamp(HAL_InterruptHandle interruptHandle,
|
2016-07-09 01:12:37 -07:00
|
|
|
int32_t* status);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
2018-07-04 00:18:18 -07:00
|
|
|
* Returns the timestamp for the falling interrupt that occurred most recently.
|
|
|
|
|
*
|
|
|
|
|
* This is in the same time domain as HAL_GetFPGATime().
|
|
|
|
|
*
|
|
|
|
|
* @param interruptHandle the interrupt handle
|
|
|
|
|
* @return timestamp in seconds since FPGA Initialization
|
2018-05-31 20:47:15 -07:00
|
|
|
*/
|
2016-08-12 13:45:28 -07:00
|
|
|
double HAL_ReadInterruptFallingTimestamp(HAL_InterruptHandle interruptHandle,
|
2016-07-09 01:12:37 -07:00
|
|
|
int32_t* status);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
2018-07-04 00:18:18 -07:00
|
|
|
/**
|
|
|
|
|
* Requests interrupts on a specific digital source.
|
|
|
|
|
*
|
|
|
|
|
* @param interruptHandle the interrupt handle
|
|
|
|
|
* @param digitalSourceHandle the digital source handle (either a
|
|
|
|
|
* HAL_AnalogTriggerHandle of a HAL_DigitalHandle)
|
|
|
|
|
* @param analogTriggerType the trigger type if the source is an AnalogTrigger
|
|
|
|
|
*/
|
2016-08-12 13:45:28 -07:00
|
|
|
void HAL_RequestInterrupts(HAL_InterruptHandle interruptHandle,
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_Handle digitalSourceHandle,
|
|
|
|
|
HAL_AnalogTriggerType analogTriggerType,
|
|
|
|
|
int32_t* status);
|
2018-07-04 00:18:18 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Attaches an asynchronous interrupt handler to the interrupt.
|
|
|
|
|
*
|
|
|
|
|
* This interrupt gets called directly on the FPGA interrupt thread, so will
|
|
|
|
|
* block other interrupts while running.
|
|
|
|
|
*
|
|
|
|
|
* @param interruptHandle the interrupt handle
|
|
|
|
|
* @param handler the handler function for the interrupt to call
|
|
|
|
|
* @param param a parameter to be passed to the handler
|
|
|
|
|
*/
|
2016-08-12 13:45:28 -07:00
|
|
|
void HAL_AttachInterruptHandler(HAL_InterruptHandle interruptHandle,
|
2016-09-05 07:31:51 -07:00
|
|
|
HAL_InterruptHandlerFunction handler,
|
|
|
|
|
void* param, int32_t* status);
|
2018-07-04 00:18:18 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Attaches an asynchronous interrupt handler to the interrupt.
|
|
|
|
|
*
|
|
|
|
|
* This interrupt gets called on a thread specific to the interrupt, so will not
|
|
|
|
|
* block other interrupts.
|
|
|
|
|
*
|
|
|
|
|
* @param interruptHandle the interrupt handle
|
|
|
|
|
* @param handler the handler function for the interrupt to call
|
|
|
|
|
* @param param a parameter to be passed to the handler
|
|
|
|
|
*/
|
2016-10-23 14:34:43 -07:00
|
|
|
void HAL_AttachInterruptHandlerThreaded(HAL_InterruptHandle interruptHandle,
|
|
|
|
|
HAL_InterruptHandlerFunction handler,
|
|
|
|
|
void* param, int32_t* status);
|
2018-07-04 00:18:18 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the edges to trigger the interrupt on.
|
|
|
|
|
*
|
|
|
|
|
* Note that both edges triggered is a valid configuration.
|
|
|
|
|
*
|
|
|
|
|
* @param interruptHandle the interrupt handle
|
|
|
|
|
* @param risingEdge true for triggering on rising edge
|
|
|
|
|
* @param fallingEdge true for triggering on falling edge
|
|
|
|
|
*/
|
2016-08-12 13:45:28 -07:00
|
|
|
void HAL_SetInterruptUpSourceEdge(HAL_InterruptHandle interruptHandle,
|
2016-07-12 10:45:14 -07:00
|
|
|
HAL_Bool risingEdge, HAL_Bool fallingEdge,
|
2016-07-09 00:24:26 -07:00
|
|
|
int32_t* status);
|
2016-07-12 21:53:06 -07:00
|
|
|
#ifdef __cplusplus
|
2017-10-16 19:56:08 -07:00
|
|
|
} // extern "C"
|
2016-07-12 21:53:06 -07:00
|
|
|
#endif
|