From f082d912aefd2d394b0c84eb12c2fd98afb30bda Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 3 May 2020 11:17:37 +0200 Subject: [PATCH] Display test: more hacks --- test-display/main.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test-display/main.c b/test-display/main.c index ade3d3b..11b09f3 100644 --- a/test-display/main.c +++ b/test-display/main.c @@ -118,13 +118,15 @@ static void display_init(void) { debug_puts("I2C init\n"); i2c_peripheral_disable(I2C1); - i2c_set_speed(I2C1, i2c_speed_sm_100k, CPU_CLOCK_MHZ); + i2c_set_speed(I2C1, i2c_speed_sm_100k, rcc_apb1_frequency / 1000000); i2c_peripheral_enable(I2C1); debug_puts("I2C transfer\n"); - // byte disp[] = { 0x7f, 0x12, 0xb6, 0xd2 }; - byte disp[] = { 0xff, 0xff, 0xff, 0xff }; + // byte disp[] = { 0xb6, 0xb6, 0xb6, 0xb6 }; + // byte disp[] = { 0x7f, 0x12, 0xbc, 0xb6 }; + // byte disp[] = { 0xff, 0xff, 0xff, 0xff }; + byte disp[] = { 0x80, 0x80, 0x80, 0xff }; byte cmds[] = { 0x00, 0x47, 0, 0, 0, 0 }; cmds[2] = (disp[0] & 0xf0) | (disp[2] >> 4); cmds[3] = (disp[1] & 0xf0) | (disp[3] >> 4); @@ -135,6 +137,16 @@ static void display_init(void) debug_puts("I2C done\n"); } +static void display_test(void) +{ + static byte mode; + + byte cmds[] = { 0x00, mode ? 0x77 : 0x77 }; + i2c_transfer7(I2C1, 0x70/2, (byte *) cmds, sizeof(cmds), NULL, 0); + + mode = !mode; +} + /*** USB ***/ static usbd_device *usbd_dev; @@ -345,6 +357,7 @@ int main(void) if (ms_ticks - last_blink >= 100) { debug_led_toggle(); last_blink = ms_ticks; + display_test(); } if (usb_event_pending) { -- 2.39.5