fast_io.h File Reference
#include <sming_attr.h>
Include dependency graph for fast_io.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define GP_IF0(flag, value)   ((value) & (((flag)&1) - 1))
 Return value if flag is clear, otherwise 0. More...
 
#define GP_IF1(flag, value)   ((value) & ~(((flag)&1) - 1))
 Return value if flag is set, otherwise 0. More...
 
#define GP_SELECT(flag, value0, value1)   (((value0) & (((flag)&1) - 1)) | ((value1) & ~(((flag)&1) - 1)))
 Choose one of two values depending on whether flag is 0 or 1. More...
 
#define GP_FAST_READ(pin, reg)   ((*(const volatile uint32_t*)(reg) >> ((pin)&31)) & 1)
 Read a GPIO into bit 0. More...
 
#define GP_FAST_WRITE(pin, val, regclr, regset)   (*(volatile uint32_t*)GP_SELECT(val, regclr, regset) = BIT(pin))
 Set or clear a GPIO line. More...
 

Macro Definition Documentation

◆ GP_FAST_READ

#define GP_FAST_READ (   pin,
  reg 
)    ((*(const volatile uint32_t*)(reg) >> ((pin)&31)) & 1)

Read a GPIO into bit 0.

Parameters
pinPin number to read
regGPIO address for INPUT
Return values
uint32_tEither 0 or 1

◆ GP_FAST_WRITE

#define GP_FAST_WRITE (   pin,
  val,
  regclr,
  regset 
)    (*(volatile uint32_t*)GP_SELECT(val, regclr, regset) = BIT(pin))

Set or clear a GPIO line.

Parameters
pinNumber of GPIO pin to write
regclrAbsolute register address used to CLEAR a GPIO to 0
regsetAbsolute register address used to SET a GPIO to 1

◆ GP_IF0

#define GP_IF0 (   flag,
  value 
)    ((value) & (((flag)&1) - 1))

Return value if flag is clear, otherwise 0.

Parameters
flagOnly bit 0 is checked
valueif flag is clear

◆ GP_IF1

#define GP_IF1 (   flag,
  value 
)    ((value) & ~(((flag)&1) - 1))

Return value if flag is set, otherwise 0.

Parameters
flagOnly bit 0 is checked
valueif flag is set

◆ GP_SELECT

#define GP_SELECT (   flag,
  value0,
  value1 
)    (((value0) & (((flag)&1) - 1)) | ((value1) & ~(((flag)&1) - 1)))

Choose one of two values depending on whether flag is 0 or 1.

Parameters
flagOnly bit 0 is checked
value0if flag is clear
value1if flag is set