* (01)
*/
+static byte disp[4];
+static byte ctrl = 0x77;
+
+static void display_update(void)
+{
+ byte cmds[6];
+ cmds[0] = 0;
+ cmds[1] = ctrl;
+ cmds[2] = (disp[0] & 0xf0) | (disp[2] >> 4);
+ cmds[3] = (disp[1] & 0xf0) | (disp[3] >> 4);
+ cmds[4] = (disp[2] & 0x0f) | (disp[0] << 4);
+ cmds[5] = (disp[3] & 0x0f) | (disp[1] << 4);
+
+ debug_puts("I2C transfer\n");
+ i2c_transfer7(I2C1, 0x70/2, (byte *) cmds, sizeof(cmds), NULL, 0);
+ debug_puts("I2C done\n");
+}
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");
+ disp[0] = 0x7f;
+ disp[1] = 0x12;
+ disp[2] = 0xbc;
+ disp[3] = 0xb6;
+ display_update();
+}
+
+static void display_test(void)
+{
+ static byte mode;
+
+ disp[0] ^= 0x01;
+ display_update();
- // byte disp[] = { 0x7f, 0x12, 0xb6, 0xd2 };
- byte disp[] = { 0xff, 0xff, 0xff, 0xff };
- byte cmds[] = { 0x00, 0x47, 0, 0, 0, 0 };
+#if 0
+ byte cmds[] = { 0x00, mode ? 0x77 : 0x77 };
+ i2c_transfer7(I2C1, 0x70/2, (byte *) cmds, sizeof(cmds), NULL, 0);
+#endif
+
+#if 0
+ byte disp[] = { 0xff, 0xff, mode ? 0xff : 0x00, mode ? 0xff : 0xff };
+ byte cmds[] = { 0x00, 0x77, 0, 0, 0, 0 };
cmds[2] = (disp[0] & 0xf0) | (disp[2] >> 4);
cmds[3] = (disp[1] & 0xf0) | (disp[3] >> 4);
cmds[4] = (disp[2] & 0x0f) | (disp[0] << 4);
cmds[5] = (disp[3] & 0x0f) | (disp[1] << 4);
i2c_transfer7(I2C1, 0x70/2, (byte *) cmds, sizeof(cmds), NULL, 0);
+#endif
- debug_puts("I2C done\n");
+ mode = !mode;
}
/*** USB ***/
u32 last_blink = 0;
for (;;) {
- if (ms_ticks - last_blink >= 100) {
+ if (ms_ticks - last_blink >= 500) {
debug_led_toggle();
last_blink = ms_ticks;
+ display_test();
}
if (usb_event_pending) {