1
0
mirror of https://github.com/preble/libpinproc synced 2026-02-22 18:15:25 +01:00

Added include guards

This commit is contained in:
Gerry Stellenberg
2011-01-16 09:39:36 -06:00
parent aa1d3649ba
commit f198a341f8
7 changed files with 96 additions and 70 deletions

View File

@@ -27,9 +27,11 @@
* @brief libpinproc, P-ROC Layer 1 API (Preliminary)
*
*/
#ifndef _PINPROC_H_
#define _PINPROC_H_
#ifndef PINPROC_PINPROC_H
#define PINPROC_PINPROC_H
#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
/*
* 3rd party "stdint.h" replacement available for Visual C++ before version 2010.
@@ -93,7 +95,7 @@ PR_EXPORT void PRLogSetLevel(PRLogLevel level);
PR_EXPORT const char *PRGetLastErrorText();
/**
/**
* @defgroup device Device Creation & Deletion
* @{
*/
@@ -118,7 +120,7 @@ PR_EXPORT void PRDelete(PRHandle handle); /**< Destroys an existin
/**
* @brief Resets internally maintained driver and switch rule structures.
* @param resetFlags Specify #kPRResetFlagDefault to only reset the configuration in host memory. #kPRResetFlagUpdateDevice will write the default configuration to the device, effectively disabling all drivers and switch rules.
* @param resetFlags Specify #kPRResetFlagDefault to only reset the configuration in host memory. #kPRResetFlagUpdateDevice will write the default configuration to the device, effectively disabling all drivers and switch rules.
*/
PR_EXPORT PRResult PRReset(PRHandle handle, uint32_t resetFlags);
@@ -156,9 +158,9 @@ PR_EXPORT PRResult PRManagerUpdateConfig(PRHandle handle, PRManagerConfig *manag
#define kPRDriverGroupsMax (26) /**< Number of available driver groups. */
#define kPRDriverCount (256) /**< Total number of drivers */
#define kPRDriverAuxCmdOutput (2)
#define kPRDriverAuxCmdDelay (1)
#define kPRDriverAuxCmdJump (0)
#define kPRDriverAuxCmdOutput (2)
#define kPRDriverAuxCmdDelay (1)
#define kPRDriverAuxCmdJump (0)
typedef struct PRDriverGlobalConfig {
bool_t enableOutputs; // Formerly enable_direct_outputs
@@ -225,7 +227,7 @@ PR_EXPORT PRResult PRDriverGetState(PRHandle handle, uint8_t driverNum, PRDriver
PR_EXPORT PRResult PRDriverUpdateState(PRHandle handle, PRDriverState *driverState);
/**
* @brief Loads the driver defaults for the given machine type.
*
*
* PRReset() calls this function internally; this function is useful for basing custom driver settings off of the defaults for a particular machine.
* @note This function does not update the P-ROC hardware, only the internal data structures. Use PRDriverGetGlobalConfig() and PRDriverGetGroupConfig() to retrieve the settings.
*/
@@ -233,106 +235,106 @@ PR_EXPORT PRResult PRDriverLoadMachineTypeDefaults(PRHandle handle, PRMachineTyp
// Driver Group Helper functions:
/**
* Disables (turns off) the given driver group.
/**
* Disables (turns off) the given driver group.
* This function is provided for convenience. See PRDriverGroupDisable() for a full description.
*/
PR_EXPORT PRResult PRDriverGroupDisable(PRHandle handle, uint8_t groupNum);
// Driver Helper functions:
/**
* Disables (turns off) the given driver.
/**
* Disables (turns off) the given driver.
* This function is provided for convenience. See PRDriverStateDisable() for a full description.
*/
PR_EXPORT PRResult PRDriverDisable(PRHandle handle, uint8_t driverNum);
/**
* Pulses the given driver for a number of milliseconds.
/**
* Pulses the given driver for a number of milliseconds.
* This function is provided for convenience. See PRDriverStatePulse() for a full description.
*/
PR_EXPORT PRResult PRDriverPulse(PRHandle handle, uint8_t driverNum, uint8_t milliseconds);
/**
* Assigns a repeating schedule to the given driver.
/**
* Assigns a repeating schedule to the given driver.
* This function is provided for convenience. See PRDriverStateSchedule() for a full description.
*/
PR_EXPORT PRResult PRDriverSchedule(PRHandle handle, uint8_t driverNum, uint32_t schedule, uint8_t cycleSeconds, bool_t now);
/**
* Assigns a pitter-patter schedule (repeating on/off) to the given driver.
/**
* Assigns a pitter-patter schedule (repeating on/off) to the given driver.
* This function is provided for convenience. See PRDriverStatePatter() for a full description.
*/
PR_EXPORT PRResult PRDriverPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime);
/**
* Assigns a pitter-patter schedule (repeating on/off) to the given driver on for the given duration.
/**
* Assigns a pitter-patter schedule (repeating on/off) to the given driver on for the given duration.
* This function is provided for convenience. See PRDriverStatePulsedPatter() for a full description.
*/
PR_EXPORT PRResult PRDriverPulsedPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime);
/**
* Assigns a pitter-patter schedule (repeating on/off) to the given driver for the given duration.
/**
* Assigns a pitter-patter schedule (repeating on/off) to the given driver for the given duration.
* This function is provided for convenience. See PRDriverStatePatter() for a full description.
*/
PR_EXPORT PRResult PRDriverPulsedPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime);
/**
/**
* Prepares an Aux Command to drive the Aux bus.
* This function is provided for convenience.
* This function is provided for convenience.
*/
PR_EXPORT void PRDriverAuxPrepareOutput(PRDriverAuxCommand *auxCommand, uint8_t data, uint8_t extraData, uint8_t enables, bool_t muxEnables, uint16_t delayTime);
/**
/**
* Prepares an Aux Command to delay the Aux logic.
* This function is provided for convenience.
* This function is provided for convenience.
*/
PR_EXPORT void PRDriverAuxPrepareDelay(PRDriverAuxCommand *auxCommand, uint16_t delayTime);
/**
/**
* Prepares an Aux Command to have the Aux memory pointer jump to a new address.
* This function is provided for convenience.
* This function is provided for convenience.
*/
PR_EXPORT void PRDriverAuxPrepareJump(PRDriverAuxCommand *auxCommand, uint8_t jumpAddr);
/**
/**
* Prepares a disabled Aux Command.
* This function is provided for convenience.
* This function is provided for convenience.
*/
PR_EXPORT void PRDriverAuxPrepareDisable(PRDriverAuxCommand *auxCommand);
/** Tickle the watchdog timer. */
PR_EXPORT PRResult PRDriverWatchdogTickle(PRHandle handle);
/**
/**
* Changes the given #PRDriverGroupConfig to reflect a disabled group.
* @note The driver group config structure must be applied using PRDriverUpdateGroupConfig() to have any effect.
*/
PR_EXPORT void PRDriverGroupStateDisable(PRDriverGroupConfig *driverGroup);
/**
/**
* Changes the given #PRDriverState to reflect a disabled state.
* @note The driver state structure must be applied using PRDriverUpdateState() or linked to a switch rule using PRSwitchUpdateRule() to have any effect.
*/
PR_EXPORT void PRDriverStateDisable(PRDriverState *driverState);
/**
/**
* Changes the given #PRDriverState to reflect a pulse state.
* @param milliseconds Number of milliseconds to pulse the driver for.
* @note The driver state structure must be applied using PRDriverUpdateState() or linked to a switch rule using PRSwitchUpdateRule() to have any effect.
*/
PR_EXPORT void PRDriverStatePulse(PRDriverState *driverState, uint8_t milliseconds);
/**
/**
* Changes the given #PRDriverState to reflect a scheduled state.
* Assigns a repeating schedule to the given driver.
* Assigns a repeating schedule to the given driver.
* @note The driver state structure must be applied using PRDriverUpdateState() or linked to a switch rule using PRSwitchUpdateRule() to have any effect.
*/
PR_EXPORT void PRDriverStateSchedule(PRDriverState *driverState, uint32_t schedule, uint8_t cycleSeconds, bool_t now);
/**
/**
* @brief Changes the given #PRDriverState to reflect a pitter-patter schedule state.
* Assigns a pitter-patter schedule (repeating on/off) to the given driver.
* @note The driver state structure must be applied using PRDriverUpdateState() or linked to a switch rule using PRSwitchUpdateRule() to have any effect.
*
*
* Use originalOnTime to pulse the driver for a number of milliseconds before the pitter-patter schedule begins.
*/
PR_EXPORT void PRDriverStatePatter(PRDriverState *driverState, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime);
/**
/**
* @brief Changes the given #PRDriverState to reflect a pitter-patter schedule state.
* Just like the regular Patter above, but PulsePatter only drives the patter
* scheduled for the given number of milliseconds before disabling the driver.
*/
PR_EXPORT void PRDriverStatePulsedPatter(PRDriverState *driverState, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t patterTime);
/**
/**
* Write Aux Port commands into the Aux Port command memory.
*/
@@ -371,7 +373,7 @@ typedef struct PREvent {
uint32_t time; /**< Time (in milliseconds) that this event occurred. */
} PREvent;
/** Get all of the available events that have been received.
/** Get all of the available events that have been received.
* \return Number of events returned; -1 if an error occurred.
*/
PR_EXPORT int PRGetEvents(PRHandle handle, PREvent *eventsOut, int maxEvents);
@@ -406,31 +408,31 @@ PR_EXPORT PRResult PRSwitchUpdateConfig(PRHandle handle, PRSwitchConfig *switchC
/**
* @brief Configures the handling of switch rules within P-ROC.
*
*
* P-ROC's switch rule system allows the user to decide which switch events are returned to software,
* as well as optionally linking one or more driver state changes to rules to create immediate feedback (such as in pop bumpers).
*
* For instance, P-ROC can provide debounced switch events for a flipper button so software can apply lange change behavior.
*
* For instance, P-ROC can provide debounced switch events for a flipper button so software can apply lange change behavior.
* This is accomplished by configuring the P-ROC with a switch rule for the flipper button and then receiving the events via the PRGetEvents() call.
* The same switch can also be configured with a non-debounced rule to fire a flipper coil.
* Multiple driver changes can be tied to a single switch state transition to create more complicated effects: a slingshot
* switch that fires the slingshot coil, a flash lamp, and a score event.
*
*
* P-ROC holds four different switch rules for each switch: closed to open and open to closed, each with a debounced and non-debounced versions:
* - #kPREventTypeSwitchOpenDebounced
* - #kPREventTypeSwitchClosedDebounced
* - #kPREventTypeSwitchClosedDebounced
* - #kPREventTypeSwitchOpenNondebounced
* - #kPREventTypeSwitchClosedNondebounced
*
*
* @section Examples
*
*
* Configuring a basic switch rule to simply notify software via PRGetEvents() without affecting any coil/lamp drivers:
* @code
* PRSwitchRule rule;
* rule.notifyHost = true;
* PRSwitchUpdateRule(handle, switchNum, kPREventTypeSwitchOpenDebounced, &rule, NULL, 0);
* @endcode
*
*
* Configuring a pop bumper switch to pulse the coil and a flash lamp for 50ms each:
* @code
* // Configure a switch rule to fire the coil and flash lamp:
@@ -441,14 +443,14 @@ PR_EXPORT PRResult PRSwitchUpdateConfig(PRHandle handle, PRSwitchConfig *switchC
* PRDriverGetState(handle, drvFlashLamp1, &drivers[1]);
* PRDriverStatePulse(&drivers[0], 50);
* PRDriverStatePulse(&drivers[1], 50);
* PRSwitchUpdateRule(handle, swPopBumper1, kPREventTypeSwitchClosedNondebounced,
* PRSwitchUpdateRule(handle, swPopBumper1, kPREventTypeSwitchClosedNondebounced,
* &rule, drivers, 2);
* // Now configure a switch rule to process scoring in software:
* rule.notifyHost = true;
* PRSwitchUpdateRule(handle, swPopBumper1, kPREventTypeSwitchClosedDebounced,
* PRSwitchUpdateRule(handle, swPopBumper1, kPREventTypeSwitchClosedDebounced,
* &rule, NULL, 0);
* @endcode
*
*
* @param handle The P-ROC device handle.
* @param switchNum The index of the switch this configuration affects.
* @param eventType The switch rule for the specified switchNum to be configured.
@@ -531,8 +533,8 @@ PR_EXTERN_C_END
/**
* @mainpage libpinproc API Documentation
*
*
* This is the documentation for libpinproc, the P-ROC Layer 1 API.
*/
#endif // _PINPROC_H_
#endif /* PINPROC_PINPROC_H */