41 #if defined(ARDUINO) && ARDUINO >= 100 52 #define NMRADCC_VERSION 200 // Version 2.0.0 54 #define MAX_DCC_MESSAGE_LEN 6 // including XOR-Byte 59 uint8_t PreambleBits ;
60 uint8_t Data[MAX_DCC_MESSAGE_LEN] ;
70 #define MAN_ID_JMRI 0x12 71 #define MAN_ID_DIY 0x0D 72 #define MAN_ID_SILICON_RAILWAY 0x21 88 #define CV_ACCESSORY_DECODER_ADDRESS_LSB 1 89 #define CV_ACCESSORY_DECODER_ADDRESS_MSB 9 91 #define CV_MULTIFUNCTION_PRIMARY_ADDRESS 1 92 #define CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB 17 93 #define CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB 18 95 #define CV_VERSION_ID 7 96 #define CV_MANUFACTURER_ID 8 97 #define CV_29_CONFIG 29 101 #define MAXCV SPI_FLASH_SEC_SIZE 102 #elif defined(ESP8266) 103 #include <spi_flash.h> 104 #define MAXCV SPI_FLASH_SEC_SIZE 105 #elif defined( __STM32F1__) 106 #define MAXCV (EEPROM_PAGE_SIZE/4 - 1) // number of storage places (CV address could be larger 109 #define MAXCV E2END // the upper limit of the CV value currently defined to max memory. 113 CV29_LOCO_DIR = 0b00000001,
114 CV29_F0_LOCATION = 0b00000010,
115 CV29_APS = 0b00000100,
116 CV29_ADV_ACK = 0b00001000,
117 CV29_SPEED_TABLE_ENABLE = 0b00010000,
118 CV29_EXT_ADDRESSING = 0b00100000,
119 CV29_OUTPUT_ADDRESS_MODE = 0b01000000,
120 CV29_ACCESSORY_DECODER = 0b10000000,
124 #ifdef NMRA_DCC_ENABLE_14_SPEED_STEP_MODE 148 #ifdef NMRA_DCC_ENABLE_14_SPEED_STEP_MODE 153 #define FN_BIT_00 0x10 154 #define FN_BIT_01 0x01 155 #define FN_BIT_02 0x02 156 #define FN_BIT_03 0x04 157 #define FN_BIT_04 0x08 159 #define FN_BIT_05 0x01 160 #define FN_BIT_06 0x02 161 #define FN_BIT_07 0x04 162 #define FN_BIT_08 0x08 164 #define FN_BIT_09 0x01 165 #define FN_BIT_10 0x02 166 #define FN_BIT_11 0x04 167 #define FN_BIT_12 0x08 169 #define FN_BIT_13 0x01 170 #define FN_BIT_14 0x02 171 #define FN_BIT_15 0x04 172 #define FN_BIT_16 0x08 173 #define FN_BIT_17 0x10 174 #define FN_BIT_18 0x20 175 #define FN_BIT_19 0x40 176 #define FN_BIT_20 0x80 178 #define FN_BIT_21 0x01 179 #define FN_BIT_22 0x02 180 #define FN_BIT_23 0x04 181 #define FN_BIT_24 0x08 182 #define FN_BIT_25 0x10 183 #define FN_BIT_26 0x20 184 #define FN_BIT_27 0x40 185 #define FN_BIT_28 0x80 189 typedef struct countOf_t {
194 extern struct countOf_t countOf;
206 #define FLAGS_MY_ADDRESS_ONLY 0x01 // Only process DCC Packets with My Address 207 #define FLAGS_AUTO_FACTORY_DEFAULT 0x02 // Call notifyCVResetFactoryDefault() if CV 7 & 8 == 255 208 #define FLAGS_SETCV_CALLED 0x10 // only used internally !! 209 #define FLAGS_OUTPUT_ADDRESS_MODE 0x40 // CV 29/541 bit 6 210 #define FLAGS_DCC_ACCESSORY_DECODER 0x80 // CV 29/541 bit 7 213 #define FLAGS_CV29_BITS (FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER) 227 void pin( uint8_t ExtIntNum, uint8_t ExtIntPinNum, uint8_t EnablePullup);
240 #ifdef digitalPinToInterrupt 241 void pin( uint8_t ExtIntPinNum, uint8_t EnablePullup);
265 void init( uint8_t ManufacturerId, uint8_t VersionId, uint8_t Flags, uint8_t OpsModeAddressBaseCV );
282 void initAccessoryDecoder( uint8_t ManufacturerId, uint8_t VersionId, uint8_t Flags, uint8_t OpsModeAddressBaseCV );
308 uint8_t getCV( uint16_t CV );
323 uint8_t setCV( uint16_t CV, uint8_t Value);
333 void setAccDecDCCAddrNextReceived(uint8_t enable);
348 uint8_t isSetCVReady(
void );
361 uint16_t getAddr(
void);
384 uint8_t getIntCount(
void);
385 uint8_t getTickCount(
void);
386 uint8_t getBitCount(
void);
387 uint8_t getState(
void);
388 uint8_t getNestedIrqCount(
void);
397 #if defined (__cplusplus) 411 extern void notifyDccReset(uint8_t hardReset ) __attribute__ ((weak));
422 extern void notifyDccIdle(
void) __attribute__ ((weak));
443 extern void notifyDccSpeed( uint16_t Addr, DCC_ADDR_TYPE AddrType, uint8_t Speed, DCC_DIRECTION Dir, DCC_SPEED_STEPS SpeedSteps ) __attribute__ ((weak));
457 extern void notifyDccSpeedRaw( uint16_t Addr, DCC_ADDR_TYPE AddrType, uint8_t Raw) __attribute__ ((weak));
479 extern void notifyDccFunc( uint16_t Addr, DCC_ADDR_TYPE AddrType, FN_GROUP FuncGrp, uint8_t FuncState) __attribute__ ((weak));
501 extern void notifyDccAccTurnoutBoard( uint16_t BoardAddr, uint8_t OutputPair, uint8_t Direction, uint8_t OutputPower ) __attribute__ ((weak));
520 extern void notifyDccAccTurnoutOutput( uint16_t Addr, uint8_t Direction, uint8_t OutputPower ) __attribute__ ((weak));
536 extern void notifyDccAccBoardAddrSet( uint16_t BoardAddr) __attribute__ ((weak));
552 extern void notifyDccAccOutputAddrSet( uint16_t Addr) __attribute__ ((weak));
565 extern void notifyDccSigOutputState( uint16_t Addr, uint8_t State) __attribute__ ((weak));
580 extern void notifyDccMsg(
DCC_MSG * Msg ) __attribute__ ((weak));
598 extern uint8_t notifyCVValid( uint16_t CV, uint8_t Writable ) __attribute__ ((weak));
614 extern uint8_t notifyCVRead( uint16_t CV) __attribute__ ((weak));
631 extern uint8_t notifyCVWrite( uint16_t CV, uint8_t Value) __attribute__ ((weak));
651 extern uint8_t notifyIsSetCVReady(
void) __attribute__ ((weak));
669 extern void notifyCVChange( uint16_t CV, uint8_t Value) __attribute__ ((weak));
670 extern void notifyDccCVChange( uint16_t CV, uint8_t Value) __attribute__ ((weak));
687 extern void notifyCVResetFactoryDefault(
void) __attribute__ ((weak));
700 extern void notifyCVAck(
void) __attribute__ ((weak));
710 extern void notifyServiceMode(
bool) __attribute__ ((weak));
714 extern void notifyDccAccState( uint16_t Addr, uint16_t BoardAddr, uint8_t OutputAddr, uint8_t State ) __attribute__ ((weak));
715 extern void notifyDccSigState( uint16_t Addr, uint8_t OutputIndex, uint8_t State) __attribute__ ((weak));
717 #if defined (__cplusplus)