Adding Doxygen-style docs for IDE autocompletion in LinkGPIO

This commit is contained in:
Rodrigo Alfonso
2024-08-06 01:54:38 -03:00
parent 94b7dce26a
commit 4085482c75
2 changed files with 31 additions and 0 deletions

View File

@@ -50,28 +50,56 @@ class LinkGPIO {
enum Pin { SI, SO, SD, SC };
enum Direction { INPUT, OUTPUT };
/**
* @brief Resets communication mode to General Purpose.
* \warning Required to initialize the library!
*/
void reset() {
Link::_REG_RCNT = RCNT_GENERAL_PURPOSE;
Link::_REG_SIOCNT = SIOCNT_GENERAL_PURPOSE;
}
/**
* @brief Configures a `pin` to use a `direction` (input or output).
* @param pin One of the enum values from `LinkGPIO::Pin`.
* @param direction One of the enum values from `LinkGPIO::Direction`.
*/
void setMode(Pin pin, Direction direction) {
_SET_BIT(Link::_REG_RCNT, DIRECTION_BITS[pin],
direction == Direction::OUTPUT);
}
/**
* @brief Returns the direction set at `pin`.
*/
Direction getMode(Pin pin) {
return Direction(_GET_BIT(Link::_REG_RCNT, DIRECTION_BITS[pin]));
}
/**
* @brief Returns whether a `pin` is *HIGH* or not (when set as an input).
* @param pin One of the enum values from `LinkGPIO::Pin`.
*/
bool readPin(Pin pin) {
return (Link::_REG_RCNT & (1 << DATA_BITS[pin])) != 0;
}
/**
* @brief Sets a `pin` to be high or not (when set as an output).
*
* @param pin One of the enum values from `LinkGPIO::Pin`.
* @param isHigh `true` = HIGH, `false` = LOW.
*/
void writePin(Pin pin, bool isHigh) {
_SET_BIT(Link::_REG_RCNT, DATA_BITS[pin], isHigh);
}
/**
* @brief If it `isEnabled`, an IRQ will be generated when `SI` changes from
* HIGH to LOW.
*
* @param isEnabled Enable SI-falling interrupts.
*/
void setSIInterrupts(bool isEnabled) {
_SET_BIT(Link::_REG_RCNT, BIT_SI_INTERRUPT, isEnabled);
}

View File

@@ -266,6 +266,9 @@ class LinkRawCable {
extern LinkRawCable* linkRawCable;
/**
* @brief SERIAL interrupt handler.
*/
inline void LINK_RAW_CABLE_ISR_SERIAL() {
linkRawCable->_onSerial();
}