To get the board of the RF1000, RF2000, RF2000V Printers working, we need inverted Signals on the SPI.
The problem is in src/spicmds.c located. On four position the signal must be inverted to get the printer working. With the signals changed, all works like a charm.
one of the position is line 33:
command_config_spi(uint32_t *args)
{
struct spidev_s *spi = oid_alloc(args[0], command_config_spi, sizeof(*spi));
#spi->pin = gpio_out_setup(args[1], 0); original line
spi->pin = gpio_out_setup(args[1], 1);
spi->flags |= SF_HAVE_PIN;
}
the other position is in line 87 and 95 spidev_transfer(struct spidev_s *spi, uint8_t receive_data, uint8_t data_len, uint8_t *data) and line 154 spidev_shutdown(void)
Always the same, the signal must inverted here. It is not possible to simple negate the pin.
How can this solved ? Any hints or idea ?
What type of micro-controller is this on and what is the device that needs the inverted CS pin?
-Kevin
It is a DRV 8711 from TI. An the board is frrom Conrad with a Mega 2560 CPU.
with this patch it works for this printer only
src/spicmds.c | 8 +++±—
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/spicmds.c b/src/spicmds.c
index f9158226..f24bfca3 100644
--- a/src/spicmds.c
+++ b/src/spicmds.c
@@ -30,7 +30,7 @@ void
command_config_spi(uint32_t *args)
{
struct spidev_s *spi = oid_alloc(args[0], command_config_spi, sizeof(*spi));
- spi->pin = gpio_out_setup(args[1], 0);
+ spi->pin = gpio_out_setup(args[1], 1);
spi->flags |= SF_HAVE_PIN;
}
DECL_COMMAND(command_config_spi, "config_spi oid=%c pin=%u");
@@ -84,7 +84,7 @@ spidev_transfer(struct spidev_s *spi, uint8_t receive_data
spi_prepare(spi->spi_config);
if (spi->flags & SF_HAVE_PIN)
- gpio_out_write(spi->pin, 1);
+ gpio_out_write(spi->pin, 0);
if (CONFIG_HAVE_GPIO_BITBANGING && spi->flags & SF_SOFTWARE)
spi_software_transfer(spi->spi_software, receive_data, data_len, data);
@@ -92,7 +92,7 @@ spidev_transfer(struct spidev_s *spi, uint8_t receive_data
spi_transfer(spi->spi_config, receive_data, data_len, data);
if (spi->flags & SF_HAVE_PIN)
- gpio_out_write(spi->pin, 0);
+ gpio_out_write(spi->pin, 1);
}
void
@@ -151,7 +151,7 @@ spidev_shutdown(void)
struct spidev_s *spi;
foreach_oid(oid, spi, command_config_spi) {
if (spi->flags & SF_HAVE_PIN)
- gpio_out_write(spi->pin, 0);
+ gpio_out_write(spi->pin, 1);
}
// Send shutdown messages
Okay. To get that merged into the Klipper master branch it seems like it would require micro-controller changes to configure an “inverted cs” flag for the spi device (similar to how the step pin can be inverted when configuring a stepper motor in src/stepper.c).
Cheers,
-Kevin
Thx for the hint,
something was similar in src/stepper.c. I will try to understand the code.
-Andy