Topic: tech dcc pc src prev next

tech dcc pc src > pins.h

#ifndef HERMES_PINS_H
#define HERMES_PINS_H

//#define HERMES_RE_REVERSE

#include <avr/io.h>

#include "constants.h"

// Value by which to multiply a 1024-point ADC reading to acheive a current in
// mA.  This won't be a perfect calculation, but will be close enough for the
// purposes of the controller.
#define HERMES_CURRENT_MULTIPLIER 10

// The maximum current in mA that may be observed before stopping the
// controller.
#define HERMES_CURRENT_LIMIT 500

// Delay between complete screen refreshes.
#define HERMES_SCREEN_REFRESH_MS 1000

// Time that an accessory or function activation should be displayed for.
#define HERMES_ACTIVATION_DISPLAY_MS 1000

// The number of repeat transmissions of accessory packets.  Should be
// sufficiently high that the packet is almost certain to be interpreted by the
// decoder.
#define HERMES_ACCESSORY_TRANSMISSION_COUNT 20

// The number of times a momentary function activation should be transmitted.
#define HERMES_MOMENTARY_FUNCTION_ACTIVATION_COUNT 15

// The number of times a momentary function deactivation should be transmitted
// (this need not be as great as the activation count because the function will
// be deactivated in normal operations).
#define HERMES_MOMENTARY_FUNCTION_DEACTIVATION_COUNT 6

// Common and block rails share a port.
// All the LCD pins share a port.
// All the switch pins share a port.

#define HERMES_PORT_SIGNAL PORTD
#define HERMES_BIT_BLOCK PD4
#define HERMES_BIT_COMMON PD7

#define HERMES_DDR_SIGNAL DDRD
#define HERMES_DD_BLOCK DDD4
#define HERMES_DD_COMMON DDD7

#define HERMES_PORT_LCD PORTD
#define HERMES_BIT_LCD_D4 PD0
#define HERMES_BIT_LCD_D5 PD1
#define HERMES_BIT_LCD_D6 PD2
#define HERMES_BIT_LCD_D7 PD3
#define HERMES_BIT_LCD_RS PD5
#define HERMES_BIT_LCD_E PD6

#define HERMES_MUX_CURRENT 0

#define HERMES_DDR_LCD DDRD

// Rotary encoder A and B.
#define HERMES_PCMSK1 ((1 << PCINT12) | (1 << PCINT13))

// Keypad scanner pins.
#define HERMES_SW_PIN PIND
#define HERMES_SW_PORT PORTD
#define HERMES_SW_DDR DDRD

#define HERMES_SW1_PIN PD0
#define HERMES_SW2_PIN PD1
#define HERMES_SW3_PIN PD2
#define HERMES_SW4_PIN PD3

#define HERMES_SWSEL_PORT PORTB
#define HERMES_SWSEL_DDR DDRB

#define HERMES_SWSEL1_PIN PB0
#define HERMES_SWSEL2_PIN PB1
#define HERMES_SWSEL3_PIN PB2

// Rotary encoder pins.
#define HERMES_RE_PIN PINC
#define HERMES_RE_PORT PORTC
#define HERMES_RE_DDR DDRC

#ifdef HERMES_RE_REVERSE
#define HERMES_RE_A_PIN PC5
#define HERMES_RE_B_PIN PC4
#else
#define HERMES_RE_A_PIN PC4
#define HERMES_RE_B_PIN PC5
#endif

#define HERMES_RE_C_PIN PC3

// LEDs
#define HERMES_LED_DDR DDRC
#define HERMES_LED_PORT PORTC
#define HERMES_LED1_PORT PC1
#define HERMES_LED2_PORT PC2

#endif