# SFBPins.h File Reference

Definitions of the programmer visible 'pins' in SFB. More...

`#include "SFBTypes.h"`
`#include "SFBConstants.h"`
`#include "SFBHWPins.h"`

Include dependency graph for SFBPins.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
struct | PinInfo_s
| A description of a single SFB-programmer-visible hardware pin. More...
## Defines
#define | NOT_A_PIN 99
#define | NOT_A_PORT 99
#define | SFB_GET_PIN_PORT_AND_MASK(sfbPin, infoVar, portVar, maskVar)
| Given a virtual pin 'sfbPin' (which may be an 'Arduino alias'), set portVar to the port number and maskVar (u32) to the bit mask for that virtual pin.
#define | GET_SKETCH_FLAG(sfbPin) ((pinSketchMap[(sfbPin)>>5]>>((sfbPin)&31))&1)
#define | SET_SKETCH_FLAG(sfbPin) (pinSketchMap[(sfbPin)>>5] |= 1<<((sfbPin)&31))
#define | CLR_SKETCH_FLAG(sfbPin) (pinSketchMap[(sfbPin)>>5] &= ~(1<<((sfbPin)&31)))
#define | PULLUP_ONLY 0
| Manipulate pull-up and pull-down resistors on GPIO input pins.
#define | NEITHER_PULLUP_NOR_PULLDOWN 2
#define | PULLDOWN_ONLY 3
## Typedefs
typedef struct PinInfo_s | PinInfo_t
## Enumerations
enum | { FACE_D0_PIN = 0, FACE_D1_PIN = 1, FACE_D2_PIN = 2, FACE_D3_PIN = 3, FACE_RX_PIN = 4, FACE_TX_PIN = 5, FACE_VIN_ENABLE_PIN = 6, FACE_VOUT_ENABLE_PIN = 7, FACE_ISENSE_PIN = 8, FACE_LED_PIN = 9, FACE_SIDE_LED_PIN = 10, FACE_PIN_COUNT = 11 }
enum | { ARDUINO_RX = 0, ARDUINO_TX = 1, ARDUINO_DIGITAL_PIN2 = 2, ARDUINO_DIGITAL_PIN3 = 3, ARDUINO_DIGITAL_PIN4 = 4, ARDUINO_DIGITAL_PIN5 = 5, ARDUINO_DIGITAL_PIN6 = 6, ARDUINO_DIGITAL_PIN7 = 7, ARDUINO_DIGITAL_PIN8 = 8, ARDUINO_DIGITAL_PIN9 = 9, ARDUINO_DIGITAL_PIN10 = 10, ARDUINO_DIGITAL_PIN11 = 11, ARDUINO_DIGITAL_PIN12 = 12, ARDUINO_DIGITAL_PIN13 = 13, ARDUINO_ANALOG_PIN1 = 14, ARDUINO_ANALOG_PIN2 = 15, ARDUINO_ANALOG_PIN3 = 16, ARDUINO_ANALOG_PIN4 = 17, ARDUINO_ANALOG_PIN5 = 18, ARDUINO_ANALOG_PIN6 = 19, NORTH_BASE_PIN = 20, NORTH_D0_PIN = NORTH_BASE_PIN+FACE_D0_PIN, NORTH_D1_PIN = NORTH_BASE_PIN+FACE_D1_PIN, NORTH_D2_PIN = NORTH_BASE_PIN+FACE_D2_PIN, NORTH_D3_PIN = NORTH_BASE_PIN+FACE_D3_PIN, NORTH_RX_PIN = NORTH_BASE_PIN+FACE_RX_PIN, NORTH_TX_PIN = NORTH_BASE_PIN+FACE_TX_PIN, NORTH_VIN_ENABLE_PIN = NORTH_BASE_PIN+FACE_VIN_ENABLE_PIN, NORTH_VOUT_ENABLE_PIN = NORTH_BASE_PIN+FACE_VOUT_ENABLE_PIN, NORTH_ISENSE_PIN = NORTH_BASE_PIN+FACE_ISENSE_PIN, NORTH_LED_PIN = NORTH_BASE_PIN+FACE_LED_PIN, NORTH_SIDE_LED_PIN = NORTH_BASE_PIN+FACE_SIDE_LED_PIN, SOUTH_BASE_PIN = 31, SOUTH_D0_PIN = SOUTH_BASE_PIN+FACE_D0_PIN, SOUTH_D1_PIN = SOUTH_BASE_PIN+FACE_D1_PIN, SOUTH_D2_PIN = SOUTH_BASE_PIN+FACE_D2_PIN, SOUTH_D3_PIN = SOUTH_BASE_PIN+FACE_D3_PIN, SOUTH_RX_PIN = SOUTH_BASE_PIN+FACE_RX_PIN, SOUTH_TX_PIN = SOUTH_BASE_PIN+FACE_TX_PIN, SOUTH_VIN_ENABLE_PIN = SOUTH_BASE_PIN+FACE_VIN_ENABLE_PIN, SOUTH_VOUT_ENABLE_PIN = SOUTH_BASE_PIN+FACE_VOUT_ENABLE_PIN, SOUTH_ISENSE_PIN = SOUTH_BASE_PIN+FACE_ISENSE_PIN, SOUTH_LED_PIN = SOUTH_BASE_PIN+FACE_LED_PIN, SOUTH_SIDE_LED_PIN = SOUTH_BASE_PIN+FACE_SIDE_LED_PIN, EAST_BASE_PIN = 42, EAST_D0_PIN = EAST_BASE_PIN+FACE_D0_PIN, EAST_D1_PIN = EAST_BASE_PIN+FACE_D1_PIN, EAST_D2_PIN = EAST_BASE_PIN+FACE_D2_PIN, EAST_D3_PIN = EAST_BASE_PIN+FACE_D3_PIN, EAST_RX_PIN = EAST_BASE_PIN+FACE_RX_PIN, EAST_TX_PIN = EAST_BASE_PIN+FACE_TX_PIN, EAST_VIN_ENABLE_PIN = EAST_BASE_PIN+FACE_VIN_ENABLE_PIN, EAST_VOUT_ENABLE_PIN = EAST_BASE_PIN+FACE_VOUT_ENABLE_PIN, EAST_ISENSE_PIN = EAST_BASE_PIN+FACE_ISENSE_PIN, EAST_LED_PIN = EAST_BASE_PIN+FACE_LED_PIN, EAST_SIDE_LED_PIN = EAST_BASE_PIN+FACE_SIDE_LED_PIN, WEST_BASE_PIN = 53, WEST_D0_PIN = WEST_BASE_PIN+FACE_D0_PIN, WEST_D1_PIN = WEST_BASE_PIN+FACE_D1_PIN, WEST_D2_PIN = WEST_BASE_PIN+FACE_D2_PIN, WEST_D3_PIN = WEST_BASE_PIN+FACE_D3_PIN, WEST_RX_PIN = WEST_BASE_PIN+FACE_RX_PIN, WEST_TX_PIN = WEST_BASE_PIN+FACE_TX_PIN, WEST_VIN_ENABLE_PIN = WEST_BASE_PIN+FACE_VIN_ENABLE_PIN, WEST_VOUT_ENABLE_PIN = WEST_BASE_PIN+FACE_VOUT_ENABLE_PIN, WEST_ISENSE_PIN = WEST_BASE_PIN+FACE_ISENSE_PIN, WEST_LED_PIN = WEST_BASE_PIN+FACE_LED_PIN, WEST_SIDE_LED_PIN = WEST_BASE_PIN+FACE_SIDE_LED_PIN, BODY_SWITCH0_PIN = 64, BODY_RGB_RED_PIN = 65, BODY_RGB_GREEN_PIN = 66, BODY_RGB_BLUE_PIN = 67, BODY_EEPROM_SSEL1_PIN = 68, BODY_EEPROM_SCK1_PIN = 69, BODY_EEPROM_MISO1_PIN = 70, BODY_EEPROM_MOSI1_PIN = 71, BODY_AMUX_READ_PIN = 72, BODY_AMUX_SELA_PIN = 73, BODY_AMUX_SELB_PIN = 74, BODY_AMUX_SELC_PIN = 75, VIRTUAL_PIN_COUNT = 76, ALIAS_COUNT = 20, FIRST_SFB_PIN = 20 }
enum | { PIN_SKETCH_MAP_WORDS = (VIRTUAL_PIN_COUNT+31)/32 }
## Functions
int | pinInFace (int facePin, int face)
| The painfully named.
void | reflexDigitalWrite (int sfbPin, int value)
void | implDigitalWrite (int sfbPin, int value)
int | reflexDigitalRead (int sfbPin)
int | implDigitalRead (int sfbPin)
void | reflexPinMode (int sfbPin, int mode)
void | implPinMode (int sfbPin, int mode)
void | pins_startup_initialization ()
void | reflexSetPinResistor (int sfbPin, int pullupDownCode)
void | implSetPinResistor (int sfbPin, int pullupDownCode)
## Variables
struct PinInfo_s | aligned
| A description of a single SFB-programmer-visible hardware pin.
PinInfo_t | pinInfoMap [VIRTUAL_PIN_COUNT]
u32 | pinSketchMap [PIN_SKETCH_MAP_WORDS]

## Detailed Description

Definitions of the programmer visible 'pins' in SFB.

Author:
  David H. Ackley.

Date:
  (C) 2008 All rights reserved.

Code License:
  The GNU Lesser General Public License

License Note:
  All code samples shown in documentation are placed into the public domain.

## Define Documentation

#define PULLUP_ONLY 0

Manipulate pull-up and pull-down resistors on GPIO input pins.

Parameters:

  | sfbPin,: | The pin to configure
  | pullupDownCode,: | One of: 0 - enable pullup 2 - enable neither pullup nor pulldown 3 - enable pulldown

#define SFB_GET_PIN_PORT_AND_MASK | ( | sfbPin,
|  | infoVar,
|  | portVar,
|  | maskVar |  | ) |

Value:

    do {                                                           \
       (infoVar) = pinInfoMap[sfbPin];                              \
       if ((infoVar).aliasMode >= ALIAS_COUNT) {                    \
         (sfbPin) = (infoVar).aliasMode;                            \
         (infoVar) = pinInfoMap[sfbPin];                            \
       }                                                            \
       (portVar) = (infoVar).portNumber;                            \
       (maskVar) = 1UL<<(infoVar).bitNumber;                        \
     } while (0)

Given a virtual pin 'sfbPin' (which may be an 'Arduino alias'), set portVar to the port number and maskVar (u32) to the bit mask for that virtual pin.

Will also UPDATE sfbPin if necessary, for it to have a non-alias value! infoVar (u32) is scratch storage.

## Enumeration Type Documentation

anonymous enum

Enumerator:

  FACE_D0_PIN | GPIO pin 0 in face.
  FACE_D1_PIN | GPIO pin 1 in face.
  FACE_D2_PIN | GPIO pin 2 in face.
  FACE_D3_PIN | GPIO pin 3 in face.
  FACE_RX_PIN | Serial input or GPIO.
  FACE_TX_PIN | Serial output or GPIO.
  FACE_VIN_ENABLE_PIN | Power input enable.
  FACE_VOUT_ENABLE_PIN | Power output enable.
  FACE_ISENSE_PIN | Face voltage(?) sense.
  FACE_LED_PIN | Face LED.
  FACE_SIDE_LED_PIN | Face side 'headlight' LEDs (if mounted).

anonymous enum

Enumerator:

  ARDUINO_RX | Aliased to NORTH_RX_PIN.
  ARDUINO_TX | Aliased to NORTH_TX_PIN.
  ARDUINO_DIGITAL_PIN2 | Aliased to NORTH_D0_PIN.
  ARDUINO_DIGITAL_PIN3 | Aliased to NORTH_D1_PIN.
  ARDUINO_DIGITAL_PIN4 | Aliased to NORTH_D2_PIN.
  ARDUINO_DIGITAL_PIN5 | Aliased to NORTH_D3_PIN.
  ARDUINO_DIGITAL_PIN6 | Aliased to SOUTH_D0_PIN.
  ARDUINO_DIGITAL_PIN7 | Aliased to SOUTH_D1_PIN.
  ARDUINO_DIGITAL_PIN8 | Aliased to SOUTH_D2_PIN.
  ARDUINO_DIGITAL_PIN9 | Aliased to SOUTH_D3_PIN.
  ARDUINO_DIGITAL_PIN10 | Aliased to EAST_D0_PIN.
  ARDUINO_DIGITAL_PIN11 | Aliased to EAST_D1_PIN.
  ARDUINO_DIGITAL_PIN12 | Aliased to EAST_D2_PIN.
  ARDUINO_DIGITAL_PIN13 | Aliased to BODY_RGB_RED_PIN.
  ARDUINO_ANALOG_PIN1 | Aliased to NORTH_ISENSE_PIN.
  ARDUINO_ANALOG_PIN2 | Aliased to SOUTH_ISENSE_PIN.
  ARDUINO_ANALOG_PIN3 | Aliased to EAST_ISENSE_PIN.
  ARDUINO_ANALOG_PIN4 | Aliased to WEST_ISENSE_PIN.
  NORTH_D0_PIN | Pin 20: D0 on the North face.
  NORTH_D1_PIN | Pin 21: D1 on the North face.
  NORTH_D2_PIN | Pin 22: D2 on the North face.
  NORTH_D3_PIN | Pin 23: D3 on the North face.
  NORTH_RX_PIN | Pin 24: Serial Rx on the North face.
  NORTH_TX_PIN | Pin 25: Serial Tx on the North face.
  NORTH_VIN_ENABLE_PIN | Pin 26: Power input enable on the North face.
  NORTH_VOUT_ENABLE_PIN | Pin 27: Power output enable on the North face.
  NORTH_ISENSE_PIN | Pin 28: ADC current sense on the North face.
  NORTH_LED_PIN | Pin 29: Active-low LED on the North face.
  NORTH_SIDE_LED_PIN | Pin 30: Active-low side LED on the North face.
  SOUTH_D0_PIN | Pin 31: D0 on the South face.
  SOUTH_D1_PIN | Pin 32: D1 on the South face.
  SOUTH_D2_PIN | Pin 33: D2 on the South face.
  SOUTH_D3_PIN | Pin 34: D3 on the South face.
  SOUTH_RX_PIN | Pin 35: Serial Rx on the South face.
  SOUTH_TX_PIN | Pin 36: Serial Tx on the South face.
  SOUTH_VIN_ENABLE_PIN | Pin 37: Power input enable on the South face.
  SOUTH_VOUT_ENABLE_PIN | Pin 38: Power output enable on the South face.
  SOUTH_ISENSE_PIN | Pin 39: ADC current sense on the South face.
  SOUTH_LED_PIN | Pin 40: Active-low LED on the South face.
  SOUTH_SIDE_LED_PIN | Pin 41: Active-low side LED on the South face.
  EAST_D0_PIN | Pin 42: D0 on the East face.
  EAST_D1_PIN | Pin 43: D1 on the East face.
  EAST_D2_PIN | Pin 44: D2 on the East face.
  EAST_D3_PIN | Pin 45: D3 on the East face.
  EAST_RX_PIN | Pin 46: Serial Rx on the East face.
  EAST_TX_PIN | Pin 47: Serial Tx on the East face.
  EAST_VIN_ENABLE_PIN | Pin 48: Power input enable on the East face.
  EAST_VOUT_ENABLE_PIN | Pin 49: Power output enable on the East face.
  EAST_ISENSE_PIN | Pin 50: ADC current sense on the East face.
  EAST_LED_PIN | Pin 51: Active-low LED on the East face.
  EAST_SIDE_LED_PIN | Pin 52: Active-low side LED on the East face.
  WEST_D0_PIN | Pin 53: D0 on the West face.
  WEST_D1_PIN | Pin 54: D1 on the West face.
  WEST_D2_PIN | Pin 55: D2 on the West face.
  WEST_D3_PIN | Pin 56: D3 on the West face.
  WEST_RX_PIN | Pin 57: Serial Rx on the West face.
  WEST_TX_PIN | Pin 58: Serial Tx on the West face.
  WEST_VIN_ENABLE_PIN | Pin 59: Power input enable on the West face.
  WEST_VOUT_ENABLE_PIN | Pin 60: Power output enable on the West face.
  WEST_ISENSE_PIN | Pin 61: ADC current sense on the West face.
  WEST_LED_PIN | Pin 62: Active-low LED on the West face.
  WEST_SIDE_LED_PIN | Pin 63: Active-low side LED on the West face.
  BODY_SWITCH0_PIN | Pin 64: Active low button pressed.
  BODY_RGB_RED_PIN | Pin 65: Active low center RGB red LED.
  BODY_RGB_GREEN_PIN | Pin 66: Active low center RGB green LED.
  BODY_RGB_BLUE_PIN | Pin 67: Active low center RGB blue LED.
  BODY_EEPROM_SSEL1_PIN | Pin 68: EEPROM SSEL.
  BODY_EEPROM_SCK1_PIN | Pin 69: EEPROM SCK.
  BODY_EEPROM_MISO1_PIN | Pin 70: EEPROM MISO.
  BODY_EEPROM_MOSI1_PIN | Pin 71: EEPROM MOSI.
  BODY_AMUX_READ_PIN | Pin 72: Analog MUX Common read.
  BODY_AMUX_SELA_PIN | Pin 73: Analog MUX Select A.
  BODY_AMUX_SELB_PIN | Pin 74: Analog MUX Select B.
  BODY_AMUX_SELC_PIN | Pin 75: Analog MUX Select C.

## Function Documentation

int pinInFace | ( | int | facePin,
|  | int | face |
| ) |  |  |

The painfully named.

## Variable Documentation

struct PinInfo_s aligned

A description of a single SFB-programmer-visible hardware pin.

The attribute is added to force word alignment without union shenanigans...