summaryrefslogtreecommitdiffstats
path: root/app/oled2.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/oled2.c')
-rw-r--r--app/oled2.c55
1 files changed, 26 insertions, 29 deletions
diff --git a/app/oled2.c b/app/oled2.c
index 331e5b7..93b9d0d 100644
--- a/app/oled2.c
+++ b/app/oled2.c
@@ -24,17 +24,15 @@ start_dma (void)
memcpy (dma_buf, vram_2, DMA_BUF_SZ);
- if (ssd1306_cmds (I2C2, cmds, sizeof (cmds), 0))
- {
- oled_sad++;
- return;
- }
-
- if (i2cp_start_transaction (I2C2, SSD1306_I2C_ADDRESS, I2C_WRITE))
- {
- oled_sad++;
- return;
- }
+ if (ssd1306_cmds (I2C2, cmds, sizeof (cmds), 0)) {
+ oled_sad++;
+ return;
+ }
+
+ if (i2cp_start_transaction (I2C2, SSD1306_I2C_ADDRESS, I2C_WRITE)) {
+ oled_sad++;
+ return;
+ }
refresh_wdt = 0;
dma_in_progress = 1;
@@ -47,16 +45,15 @@ start_dma (void)
void
dma1_channel4_isr (void)
{
- if (dma_in_progress)
- {
- i2cp2_stop_dma ();
+ if (dma_in_progress) {
+ i2cp2_stop_dma();
- i2cp_stop (I2C2);
- dma_in_progress = 0;
- }
+ i2cp_stop (I2C2);
+ dma_in_progress = 0;
+ }
if (refresh_enabled)
- start_dma ();
+ start_dma();
}
void
@@ -72,19 +69,18 @@ oled2_ticker (void)
refresh_wdt = 0;
-/*No refresh for 1s, restart everything */
+ /*No refresh for 1s, restart everything */
- i2cp2_stop_dma ();
+ i2cp2_stop_dma();
i2cp_stop (I2C2);
dma_in_progress = 0;
- if (oled_sad)
- {
- oled_sad = 0;
- i2cp2_reset_sm ();
- }
+ if (oled_sad) {
+ oled_sad = 0;
+ i2cp2_reset_sm();
+ }
- start_dma ();
+ start_dma();
}
@@ -92,7 +88,7 @@ void
oled2_enable_refresh (void)
{
refresh_enabled = 1;
- start_dma ();
+ start_dma();
}
@@ -100,6 +96,7 @@ void
oled2_disable_refresh (void)
{
refresh_enabled = 0;
+
while (dma_in_progress);
}
@@ -115,13 +112,13 @@ oled2_init (void)
oled_generate_stream (vram_2);
nvic_enable_irq (NVIC_DMA1_CHANNEL4_IRQ);
- oled2_enable_refresh ();
+ oled2_enable_refresh();
}
void
oled2_shutdown (void)
{
- oled2_disable_refresh ();
+ oled2_disable_refresh();
oled_off (I2C2);
}