2 * strange macros - do not use directly, usually
5 NMRA(speed28, Aint(addr) Aint(speed) Aint(reverse), {
6 /* 0<=speed<=28 or <=126; reverse: 0 forwards, non-0 backwards */
9 nmra_errchk(cn, speed, speed>=0 && speed<=28);
10 *c++= 0x40 | (reverse ? 0 : 0x20);
13 *c |= adj & 1 ? 0x10 : 0;
18 NMRA(estop1, Aint(addr), {
19 /* Baseline Speed and direction Forwards E-Stop(I) S9.2 B table l.56 */
23 NMRA(speed126, Aint(addr) Aint(speed) Aint(reverse), {
24 /* Advanced Operations 128 Speed Step Control
25 * (actually speeds 0..126) RP9.2.1 C l.200- */
27 nmra_errchk(cn, speed, speed>=0 && speed<=126);
29 *c++= (speed ? speed + 1 : 0) | (reverse ? 0 : 0x80);
33 /* Baseline Broadcast stop Forwards(I) Emergency S9.2 B l.98- */
37 /* Baseline Decoder Reset S9.2 B l.77- */
41 /* Baseline Idle S9.2 B l.87- */
46 * bit 0 is FL aka F0; bits 1-12 are F1-F12; do not call with bits
47 * outside 0-12 set; bits in 0-12 but not relevant for the relevant
48 * command are ignored. */
49 NMRA(funcs0to4, Aint(addr) Abitmap(bitmap), {
50 /* Function Group One RP9.2.1 C l.234- */
51 FUNCS(0x80 | ((bitmap >> 1) & 0x0f) | ((bitmap << 4 & 0x10)));
53 NMRA(funcs5to9, Aint(addr) Abitmap(bitmap), {
54 /* Function Group Two RP9.2.1 C l.246- */
55 FUNCS(0xa0 | ((bitmap >> 5) & 0x0f));
57 NMRA(funcs9to12, Aint(addr) Abitmap(bitmap), {
58 /* Function Group Two RP9.2.1 C l.246- */
59 FUNCS(0xb0 | ((bitmap >> 9) & 0x0f));
61 NMRA(cvwrite, Aint(addr) Aint(cv) Abyte(value), {
62 /* Configuration Variable Access Long Form RP9.2.1 C l.286- */
65 nmra_errchk(cn, cv, cv>=1 && cv<=1024);
67 *c++= 0xec | (adj >> 8);