# 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:

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

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()
- 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)
- 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()