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