I’m trying to add an i2c display to a Malyan M200 board.
The board has a STM32F070CBT6, LQFP-48 package
https://www.digikey.com/en/htmldatasheets/production/1727271/0/0/1/stm32f070rbt6tr.html
There are 2 communication headers available. One connector has pins for USART2 PA2/PA3. This connector is normally unpopulated and not used by the stock firmware. These pins PA2/PA3 are not usable for anything other than USART2 or as generic gpio. I am successfully using this port for rs232 communication with a pi zero 2 w on it’s UART0 gpio pins.
The other header is normally the LCD connection in the stock config. It has pins for PA9 & PA10.
These pins “alt function 1” is USART1, and “alt function 4” is I2C1
I’m trying to connect a ssd1306 to these pins but I can’t get klipper to do do i2c on these pins.
I’ve tried adding the bus pins to klipper/stm32f0_i2c.c at master · Klipper3d/klipper · GitHub as “i2c1b”
DECL_ENUMERATION("i2c_bus", "i2c1", 0);
DECL_CONSTANT_STR("BUS_PINS_i2c1", "PB6,PB7");
DECL_ENUMERATION("i2c_bus", "i2c1a", 1);
DECL_CONSTANT_STR("BUS_PINS_i2c1a", "PF1,PF0");
DECL_ENUMERATION("i2c_bus", "i2c1b", 2);
DECL_CONSTANT_STR("BUS_PINS_i2c1b", "PA9,PA10");
static const struct i2c_info i2c_bus[] = {
{ I2C1, GPIO('B', 6), GPIO('B', 7), GPIO_FUNCTION(1) },
{ I2C1, GPIO('F', 1), GPIO('F', 0), GPIO_FUNCTION(1) },
{ I2C1, GPIO('A', 9), GPIO('A', 10), GPIO_FUNCTION(4) },
};
And then tried to use “i2c1b” in printer.cfg
[display]
lcd_type: ssd1306
i2c_address: 120
i2c_bus: i2c1b
The display board is a Velleman VMA438, and has an address select resistor on the back that says address 0x78.
The firmware builds and runs, but the new bus pins still don’t work.
Loaded MCU 'mcu' 91 commands (v0.10.0-291-g4ce2d379-dirty-20220312_002343-mpsm2 / gcc: (15:7-2018-q2-6) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907] binutils: (2.31.1-11+rpi1+11) 2.31.1)
MCU 'mcu' config: BUS_PINS_i2c1=PB6,PB7 BUS_PINS_spi2a=PC2,PC3,PB10 BUS_PINS_i2c1a=PF1,PF0 BUS_PINS_i2c1b=PA9,PA10 RESERVE_PINS_serial=PA3,PA2 BUS_PINS_spi1a=PB4,PB5,PB3 STATS_SUMSQ_BASE=256 RECEIVE_WINDOW=192 STEPPER_BOTH_EDGE=1 SERIAL_BAUD=250000 ADC_MAX=4095 RESERVE_PINS_crystal=PF0,PF1 BUS_PINS_spi2=PB14,PB15,PB13 BUS_PINS_spi1=PA6,PA7,PA5 MCU=stm32f070xb CLOCK_FREQ=48000000
Sending MCU 'mcu' printer configuration...
Configured MCU 'mcu' (875 moves)
Starting heater checks for heater_bed
Starting heater checks for extruder
MCU 'mcu' shutdown: i2c timeout