NMRA(speed28, Aint(addr,0) Aint(speed,1) Aint(reverse,2), {
/* 0<=speed<=28 or <=126; reverse: 0 forwards, non-0 backwards */
int adj;
+ Byte cmd;
ADDR;
nmra_errchk(cn, speed, speed>=0 && speed<=28);
- *c++= 0x40 | (reverse ? 0 : 0x20);
+ cmd= 0x40 | (reverse ? 0 : 0x20);
if (speed) {
adj= speed + 3;
- *c |= adj & 1 ? 0x10 : 0;
- *c |= adj >> 1;
+ cmd |= adj & 1 ? 0x10 : 0;
+ cmd |= adj >> 1;
}
- c++;
+ *c++= cmd;
})
NMRA(estop1, Aint(addr,0), {
/* Baseline Speed and direction Forwards E-Stop(I) S9.2 B table l.56 */
/* Baseline Broadcast stop Forwards(I) Emergency S9.2 B l.98- */
CONST(0x00, 0x71);
})
+NMRA(bstop, Anone, {
+ /* Baseline Broadcast stop Forwards(I) non-Emergency S9.2 B l.98- */
+ CONST(0x00, 0x70);
+})
NMRA(reset, Anone, {
/* Baseline Decoder Reset S9.2 B l.77- */
CONST(0x00, 0x00);
/* Function Group One RP9.2.1 C l.234- */
FUNCS(0x80 | ((bitmap >> 1) & 0x0f) | ((bitmap << 4 & 0x10)));
})
-NMRA(funcs5to9, Aint(addr,0) Abitmap(bitmap,1), {
+NMRA(funcs5to8, Aint(addr,0) Abitmap(bitmap,1), {
/* Function Group Two RP9.2.1 C l.246- */
- FUNCS(0xa0 | ((bitmap >> 5) & 0x0f));
+ FUNCS(0xb0 | ((bitmap >> 5) & 0x0f));
})
NMRA(funcs9to12, Aint(addr,0) Abitmap(bitmap,1), {
/* Function Group Two RP9.2.1 C l.246- */
- FUNCS(0xb0 | ((bitmap >> 9) & 0x0f));
+ FUNCS(0xa0 | ((bitmap >> 9) & 0x0f));
})
NMRA(cvwrite, Aint(addr,0) Aint(cv,1) Abyte(value,2), {
/* Configuration Variable Access Long Form RP9.2.1 C l.286- */
*c++= value;
})
+/*
+ * Service mode.
+ */
+NMRA(svc_cvwrite, Aint(cv,0) Abyte(value,1), {
+ /* Service Mode Instruction for Direct Mode, Write Byte
+ * RP 9.2.3 E l.107-
+ */
+ int adj;
+ nmra_errchk(cn, cv, cv>=1 && cv<=1024);
+ adj= cv - 1;
+ *c++= 0x7c | (adj >> 8);
+ *c++= adj;
+ *c++= value;
+})
+NMRA(svc_factoryreset, Anone, {
+ /* Service Mode Instruction for Decoder Factory Reset
+ * RP 9.2.3 E l.279-
+ * (See also Packet Sequence for Physical Register Addressing
+ * RP 9.2.3 E l.166-)
+ */
+ CONST(0x7f, 0x08);
+})
+NMRA(svc_pagepreset, Anone, {
+ /* Service Mode Page Preset Instruction
+ * RP 9.2.3 E l.90-91
+ * used in various packet sequences.
+ */
+ CONST(0x7d, 0x01);
+})
+
#undef Aint
#undef Abitmap
#undef Abyte