M155=>M260, M156=>M261

master
Scott Lahteine 8 years ago
parent e765eebfb0
commit 75bfde9945

@ -808,22 +808,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -214,6 +214,8 @@
* M226 - Wait until a pin is in a given state: "M226 P<pin> S<state>"
* M240 - Trigger a camera to take a photograph. (Requires CHDK or PHOTOGRAPH_PIN)
* M250 - Set LCD contrast: "M250 C<contrast>" (0-63). (Requires LCD support)
* M260 - i2c Send Data (Requires EXPERIMENTAL_I2CBUS)
* M261 - i2c Request Data (Requires EXPERIMENTAL_I2CBUS)
* M280 - Set servo position absolute: "M280 P<index> S<angle|µs>". (Requires servos)
* M300 - Play beep sound S<frequency Hz> P<duration ms>
* M301 - Set PID parameters P I and D. (Requires PIDTEMP)
@ -5783,59 +5785,6 @@ inline void gcode_M121() { endstops.enable_globally(false); }
#endif // BLINKM
#if ENABLED(EXPERIMENTAL_I2CBUS)
/**
* M155: Send data to a I2C slave device
*
* This is a PoC, the formating and arguments for the GCODE will
* change to be more compatible, the current proposal is:
*
* M155 A<slave device address base 10> ; Sets the I2C slave address the data will be sent to
*
* M155 B<byte-1 value in base 10>
* M155 B<byte-2 value in base 10>
* M155 B<byte-3 value in base 10>
*
* M155 S1 ; Send the buffered data and reset the buffer
* M155 R1 ; Reset the buffer without sending data
*
*/
inline void gcode_M155() {
// Set the target address
if (code_seen('A')) i2c.address(code_value_byte());
// Add a new byte to the buffer
if (code_seen('B')) i2c.addbyte(code_value_byte());
// Flush the buffer to the bus
if (code_seen('S')) i2c.send();
// Reset and rewind the buffer
else if (code_seen('R')) i2c.reset();
}
/**
* M156: Request X bytes from I2C slave device
*
* Usage: M156 A<slave device address base 10> B<number of bytes>
*/
inline void gcode_M156() {
if (code_seen('A')) i2c.address(code_value_byte());
uint8_t bytes = code_seen('B') ? code_value_byte() : 1;
if (i2c.addr && bytes && bytes <= TWIBUS_BUFFER_SIZE) {
i2c.relay(bytes);
}
else {
SERIAL_ERROR_START;
SERIAL_ERRORLN("Bad i2c request");
}
}
#endif // EXPERIMENTAL_I2CBUS
/**
* M200: Set filament diameter and set E axis units to cubic units
*
@ -6182,6 +6131,59 @@ inline void gcode_M226() {
} // code_seen('P')
}
#if ENABLED(EXPERIMENTAL_I2CBUS)
/**
* M260: Send data to a I2C slave device
*
* This is a PoC, the formating and arguments for the GCODE will
* change to be more compatible, the current proposal is:
*
* M260 A<slave device address base 10> ; Sets the I2C slave address the data will be sent to
*
* M260 B<byte-1 value in base 10>
* M260 B<byte-2 value in base 10>
* M260 B<byte-3 value in base 10>
*
* M260 S1 ; Send the buffered data and reset the buffer
* M260 R1 ; Reset the buffer without sending data
*
*/
inline void gcode_M260() {
// Set the target address
if (code_seen('A')) i2c.address(code_value_byte());
// Add a new byte to the buffer
if (code_seen('B')) i2c.addbyte(code_value_byte());
// Flush the buffer to the bus
if (code_seen('S')) i2c.send();
// Reset and rewind the buffer
else if (code_seen('R')) i2c.reset();
}
/**
* M261: Request X bytes from I2C slave device
*
* Usage: M261 A<slave device address base 10> B<number of bytes>
*/
inline void gcode_M261() {
if (code_seen('A')) i2c.address(code_value_byte());
uint8_t bytes = code_seen('B') ? code_value_byte() : 1;
if (i2c.addr && bytes && bytes <= TWIBUS_BUFFER_SIZE) {
i2c.relay(bytes);
}
else {
SERIAL_ERROR_START;
SERIAL_ERRORLN("Bad i2c request");
}
}
#endif // EXPERIMENTAL_I2CBUS
#if HAS_SERVOS
/**
@ -7948,18 +7950,6 @@ void process_next_command() {
#endif // BLINKM
#if ENABLED(EXPERIMENTAL_I2CBUS)
case 155: // M155: Send data to an i2c slave
gcode_M155();
break;
case 156: // M156: Request data from an i2c slave
gcode_M156();
break;
#endif //EXPERIMENTAL_I2CBUS
#if ENABLED(MIXING_EXTRUDER)
case 163: // M163: Set a component weight for mixing extruder
gcode_M163();
@ -8082,6 +8072,18 @@ void process_next_command() {
break;
#endif // HAS_LCD_CONTRAST
#if ENABLED(EXPERIMENTAL_I2CBUS)
case 260: // M260: Send data to an i2c slave
gcode_M260();
break;
case 261: // M261: Request data from an i2c slave
gcode_M261();
break;
#endif // EXPERIMENTAL_I2CBUS
#if ENABLED(PREVENT_COLD_EXTRUSION)
case 302: // M302: Allow cold extrudes (set the minimum extrude temperature)
gcode_M302();

@ -808,22 +808,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -808,22 +808,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -808,22 +808,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -808,22 +808,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -814,22 +814,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -808,22 +808,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -808,22 +808,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -808,22 +808,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -816,22 +816,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -808,22 +808,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -810,22 +810,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -810,22 +810,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -810,22 +810,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -815,22 +815,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -810,22 +810,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -808,22 +808,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -808,22 +808,22 @@
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M155 commands with one B<base 10> arg
* M155 A99 ; Target slave address
* M155 B77 ; M
* M155 B97 ; a
* M155 B114 ; r
* M155 B108 ; l
* M155 B105 ; i
* M155 B110 ; n
* M155 S1 ; Send the current buffer
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M156 A99 B5
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M156 request
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/

@ -43,11 +43,11 @@ typedef void (*twiRequestFunc_t)();
* an experimental feature and it's inner workings as well as public facing
* interface are prune to change in the future.
*
* The two main consumers of this class are M155 and M156, where M155 allows
* The two main consumers of this class are M260 and M261, where M260 allows
* Marlin to send a I2C packet to a device (please be aware that no repeated
* starts are possible), this can be done in caching method by calling multiple
* times M155 B<byte-1 value in base 10> or a one liner M155, have a look at
* the gcode_M155() function for more information. M156 allows Marlin to
* times M260 B<byte-1 value in base 10> or a one liner M260, have a look at
* the gcode_M260() function for more information. M261 allows Marlin to
* request data from a device, the received data is then relayed into the serial
* line for host interpretation.
*

Loading…
Cancel
Save