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 #ifdef ARDUINO_ARCH_AVR
15 
17 #define UNDEFINED_PIN 255
18 
20 //
21 // DEFINE NUMBER OF MAIN TRACK REGISTER
22 
24 #define MAX_MAIN_REGISTERS 12
25 
26 #define MAX_PROG_REGISTERS 3
27 
29 //
30 // DEFINE PINS ACCORDING TO MOTOR SHIELD MODEL
31 //
32 
33 #ifdef ARDUINO_AVR_MEGA // is using Mega 1280, define as Mega 2560 (pinouts and functionality are identical)
34 #ifndef ARDUINO_AVR_MEGA2560
35 #define ARDUINO_AVR_MEGA2560
36 #endif
37 #endif
38 
39 #if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) // Configuration for UNO or NANO
40 
42 #define DCC_SIGNAL_PIN_MAIN 10 // Arduino Uno - uses OC1B
43 
44 #define DCC_SIGNAL_PIN_PROG 5 // Arduino Uno - uses OC0B
45 
46 #elif defined(ARDUINO_AVR_MEGA2560)
47 
48 #define DCC_SIGNAL_PIN_MAIN 12 // Arduino Mega - uses OC1B
49 #define DCC_SIGNAL_PIN_PROG 2 // Arduino Mega - uses OC3B
50 
51 #endif
52 
54 // SELECT MOTOR SHIELD
56 
58 #define MOTOR_SHIELD_SIGNAL_ENABLE_PIN_MAIN 3
59 #define MOTOR_SHIELD_SIGNAL_ENABLE_PIN_PROG 11
60 
61 #define MOTOR_SHIELD_CURRENT_MONITOR_PIN_MAIN A0
62 #define MOTOR_SHIELD_CURRENT_MONITOR_PIN_PROG A1
63 
64 #define MOTOR_SHIELD_DIRECTION_MOTOR_CHANNEL_PIN_A 12
65 #define MOTOR_SHIELD_DIRECTION_MOTOR_CHANNEL_PIN_B 13
66 
67 #define POLOLU_SIGNAL_ENABLE_PIN_MAIN 9
68 #define POLOLU_SIGNAL_ENABLE_PIN_PROG 11
69 
70 #define POLOLU_CURRENT_MONITOR_PIN_MAIN A0
71 #define POLOLU_CURRENT_MONITOR_PIN_PROG A1
72 
73 #define POLOLU_DIRECTION_MOTOR_CHANNEL_PIN_A 7
74 #define POLOLU_DIRECTION_MOTOR_CHANNEL_PIN_B 8
75 
76 #ifdef USE_ETHERNET
77 enum EthernetProtocol
78 {
79  HTTP,
80  TCP
81 };
82 #endif
83 
84 struct DCCppConfig
85 {
86 #ifdef USE_ETHERNET
87  static uint8_t EthernetIp[4];
88  static uint8_t EthernetMac[6];
89  static int EthernetPort;
90  static EthernetProtocol Protocol;
91 #endif
92 
93  static byte SignalEnablePinMain; // PWM : *_SIGNAL_ENABLE_PIN_MAIN
94  static byte CurrentMonitorMain; // Current sensor : *_CURRENT_MONITOR_PIN_MAIN
95 
96  static byte SignalEnablePinProg; // PWM : *_SIGNAL_ENABLE_PIN_PROG
97  static byte CurrentMonitorProg; // Current sensor : *_CURRENT_MONITOR_PIN_PROG
98 
99  // Only for shields : indirection of the signal from SignalPinMain to DirectionMotor of the shield
100  static byte DirectionMotorA; // *_DIRECTION_MOTOR_CHANNEL_PIN_A
101  static byte DirectionMotorB; // *_DIRECTION_MOTOR_CHANNEL_PIN_B
102 };
103 
105 
106 #endif
107 #endif