# Additional SFB

Face-related macros and functions:

- CLOCKWISE_FACE(dir)
- COUNTERCLOCKWISE_FACE(dir) a.k.a ANTICLOCKWISE_FACE(dir)
- OPPOSITE_FACE(dir)
- FACE_NAME(face)
- FACE_CODE(face)
- FACE_NUMBER_FROM_CODE(code)
- IS_FACE_CODE(code)

Bit and number macros:

- SET_BIT(value,bitnum)
- CLEAR_BIT(value,bitnum)
- GET_BIT(value,bitnum)
- TEST_BIT(value,bitnum)

Time comparisons handling wraparound (these are actually usable for any u32 counter values, not just millis() or micros()):

- IS_EARLIER(u32a,u32b)
- IS_EARLIER_OR_EQUAL(u32a,u32b)
- IS_LATER(u32a,u32b)
- IS_LATER_OR_EQUAL(u32a,u32b)

u16 comparisons handling wraparound:

- IS_EARLIER16(u16a,u16b)
- IS_EARLIER_OR_EQUAL16(u16a,u16b)
- IS_LATER16(u16a,u16b)
- IS_LATER_OR_EQUAL16(u16a,u16b)

Read and write the onboard EEPROM:

- eepromRead(u32 addr, u8 * dest, u32 length) ;
- eepromWrite(u32 addr, const u8 * source, u32 length) ;
- eepromWait(bool busyWait = false)

Access and update data from the SFB bootblock:

- getBootBlockBoardId()
- getBootBlockBootCount()
- getBootBlockBootLoaderBurnCount()
- getBootBlockBootLoaderChecksum(SFBChecksum cs)
- getBootBlockBootLoaderLength()
- getBootBlockBootMode()
- getBootBlockBurnCount()
- getBootBlockFlags()
- getBootBlockMergedChecksum()
- getBootBlockOwnerId()
- getBootBlockPowerIn(u8 face)
- getBootBlockPowerOnHours()
- getBootBlockPowerOut(u8 face)
- getBootBlockVersion()
- getBootBlockVoltageCalibrationData()
- getBootBlockWatchdogResets
- incrementBootBlockBootCount()
- incrementBootBlockBurnCount()
- incrementBootBlockPowerOnHours()
- setBootBlockBoardId(u32 newBoardId)
- setBootBlockBootMode(u32 newBootMode)
- setBootBlockFlags(u32 newFlags)
- setBootBlockOwnerId(u32 newOwnerId)
- setBootBlockPowerIn(u8 face, bool accept)
- setBootBlockPowerOut(u8 face, bool provide)
- setBootBlockVoltageCalibrationData()
- setBootBlockWatchdogResetFlag(bool bootedClean)

Miscellaneous low-level and hardware-related:

- facePrintTimestamp(u8 face)
- disableInterrupts()
- enableInterrupts()
- suspendInterrupts(u32var)
- restoreInterrupts(u32var)
- reenterBootloader() Drop back to the secondary bootloader if possible
- reenterBrainstem() Drop back to the tertiary bootloader if possible
- attachInterrupt(u32 sfbPin, IRQHandler *handlerFunction, u32 mode)
- detachInterrupt(u32 sfbPin)
- canAttachInterrupt(u32 sfbPin)
- hasAttachedInterrupt(u32 sfbPin)

Interfacing with the watchdog timer:

- watchdogActive()
- watchdogSetInterval(u32 feedIntervalMs)
- watchdogGetInterval()
- watchdogStart(u32 feedIntervalMs)
- watchdogFeed()
- watchdogGetTimeoutFlag()
- watchdogClearTimeoutFlag()
- watchdogSuicide()
- watchdogItWasSuicide()

Power measurement and control (all boards):

- powerOut()
- faceVoltage()
- railVoltage()

Power measurement and control ('weapons grade' boards only):

- powerIn()
- powerDraw()