]> mj.ucw.cz Git - home-hw.git/commitdiff
Display test: more hacks
authorMartin Mares <mj@ucw.cz>
Sun, 3 May 2020 09:17:37 +0000 (11:17 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 3 May 2020 09:17:37 +0000 (11:17 +0200)
test-display/main.c

index ade3d3b8bda50f68434a80d0ce652877e856d8f5..11b09f3f9538fce0c07c532e91324c8b08abc45e 100644 (file)
@@ -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) {