DCCpp
This is the library version of a program for Arduino to control railroading DCC devices.
Config.h
1 /**********************************************************************
2 
3 Config.h
4 COPYRIGHT (c) 2013-2016 Gregg E. Berman
5 Adapted for DcDcc by Thierry PARIS
6 
7 Part of DCC++ BASE STATION for the Arduino
8 
9 **********************************************************************/
10 #ifndef __config_h
11 #define __config_h
12 
13 #include "arduino.h"
14 
15 #define UNDEFINED_PIN 255
16 
18 //
19 // DEFINE NUMBER OF MAIN TRACK REGISTER
20 
21 #define MAX_MAIN_REGISTERS 12
22 
24 //
25 // DEFINE PINS ACCORDING TO MOTOR SHIELD MODEL
26 //
27 
28 #ifdef ARDUINO_AVR_MEGA // is using Mega 1280, define as Mega 2560 (pinouts and functionality are identical)
29 #define ARDUINO_AVR_MEGA2560
30 #endif
31 
32 #if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) // Configuration for UNO or NANO
33 
34 #define DCC_SIGNAL_PIN_MAIN 10 // Arduino Uno - uses OC1B
35 #define DCC_SIGNAL_PIN_PROG 5 // Arduino Uno - uses OC0B
36 
37 #elif defined(ARDUINO_AVR_MEGA2560)
38 
39 #define DCC_SIGNAL_PIN_MAIN 12 // Arduino Mega - uses OC1B
40 #define DCC_SIGNAL_PIN_PROG 2 // Arduino Mega - uses OC3B
41 
42 #endif
43 
45 // SELECT MOTOR SHIELD
47 
48 #define MOTOR_SHIELD_SIGNAL_ENABLE_PIN_MAIN 3
49 #define MOTOR_SHIELD_SIGNAL_ENABLE_PIN_PROG 11
50 
51 #define MOTOR_SHIELD_CURRENT_MONITOR_PIN_MAIN A0
52 #define MOTOR_SHIELD_CURRENT_MONITOR_PIN_PROG A1
53 
54 #define MOTOR_SHIELD_DIRECTION_MOTOR_CHANNEL_PIN_A 12
55 #define MOTOR_SHIELD_DIRECTION_MOTOR_CHANNEL_PIN_B 13
56 
57 #define POLOLU_SIGNAL_ENABLE_PIN_MAIN 9
58 #define POLOLU_SIGNAL_ENABLE_PIN_PROG 11
59 
60 #define POLOLU_CURRENT_MONITOR_PIN_MAIN A0
61 #define POLOLU_CURRENT_MONITOR_PIN_PROG A1
62 
63 #define POLOLU_DIRECTION_MOTOR_CHANNEL_PIN_A 7
64 #define POLOLU_DIRECTION_MOTOR_CHANNEL_PIN_B 8
65 
66 #ifdef USE_ETHERNET
67 enum EthernetProtocol
68 {
69  HTTP,
70  TCP
71 };
72 #endif
73 
75 {
76 #ifdef USE_ETHERNET
77  static uint8_t EthernetIp[4];
78  static uint8_t EthernetMac[6];
79  static int EthernetPort;
80  static EthernetProtocol Protocol;
81 #endif
82 
83  static byte SignalEnablePinMain; // PWM : *_SIGNAL_ENABLE_PIN_MAIN
84  static byte CurrentMonitorMain; // Current sensor : *_CURRENT_MONITOR_PIN_MAIN
85 
86  static byte SignalEnablePinProg; // PWM : *_SIGNAL_ENABLE_PIN_PROG
87  static byte CurrentMonitorProg; // Current sensor : *_CURRENT_MONITOR_PIN_PROG
88 
89  // Only for shields : indirection of the signal from SignalPinMain to DirectionMotor of the shield
90  static byte DirectionMotorA; // *_DIRECTION_MOTOR_CHANNEL_PIN_A
91  static byte DirectionMotorB; // *_DIRECTION_MOTOR_CHANNEL_PIN_B
92 };
93 
95 
96 #endif