# 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, VIRTUAL_PIN_COUNT = 72, 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).

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