diff options
author | fishsoupisgood <github@madingley.org> | 2020-06-18 13:26:56 +0100 |
---|---|---|
committer | fishsoupisgood <github@madingley.org> | 2020-06-18 13:26:56 +0100 |
commit | e41764fceeabb1cdb6a7a299e00f2166a6f6ac32 (patch) | |
tree | c58c73d742bf990ec692d61ca8d911dd43fab8c6 /app/oled2.c | |
parent | f7b7cf9e80200cade938d47527e39034c75b9b6d (diff) | |
download | robs_speedo-e41764fceeabb1cdb6a7a299e00f2166a6f6ac32.tar.gz robs_speedo-e41764fceeabb1cdb6a7a299e00f2166a6f6ac32.tar.bz2 robs_speedo-e41764fceeabb1cdb6a7a299e00f2166a6f6ac32.zip |
moved stm32 into directory added noddy pcb
Diffstat (limited to 'app/oled2.c')
-rw-r--r-- | app/oled2.c | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/app/oled2.c b/app/oled2.c deleted file mode 100644 index bccb4ba..0000000 --- a/app/oled2.c +++ /dev/null @@ -1,124 +0,0 @@ -#include "project.h" - - -static uint8_t dma_buf[DMA_BUF_SZ]; -uint8_t vram_2[DMA_BUF_SZ]; - -static int dma_in_progress = 0; -static int refresh_enabled = 0; -static uint32_t refresh_wdt = 0; -static int oled_sad = 0; - - -static void -start_dma (void) -{ - uint8_t cmds[] = { - SSD1306_SET_PAGE_ADDR, 0, 0xff, - SSD1306_SET_COLUMN_ADDR, 0, SSD1306_WIDTH - 1 - }; - - if (dma_in_progress) - return; - - - 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; - } - - refresh_wdt = 0; - dma_in_progress = 1; - - i2cp2_start_dma (dma_buf, DMA_BUF_SZ); -} - - - -void -dma1_channel4_isr (void) -{ - if (dma_in_progress) { - i2cp2_stop_dma(); - - i2cp_stop (I2C2); - dma_in_progress = 0; - } - - if (refresh_enabled) - start_dma(); -} - -void -oled2_ticker (void) -{ - if (!refresh_enabled) - return; - - refresh_wdt++; - - if ((refresh_wdt < MS_TO_TICKS (1000)) && (!oled_sad)) - return; - - refresh_wdt = 0; - - /*No refresh for 1s, restart everything */ - - i2cp2_stop_dma(); - i2cp_stop (I2C2); - dma_in_progress = 0; - - if (oled_sad) { - oled_sad = 0; - i2cp2_reset_sm(); - } - - start_dma(); - -} - -void -oled2_enable_refresh (void) -{ - refresh_enabled = 1; - start_dma(); -} - - -void -oled2_disable_refresh (void) -{ - refresh_enabled = 0; - - while (dma_in_progress); -} - - - -void -oled2_init (void) -{ - oled_reset (I2C2); - - delay_us (100); - - oled_generate_stream (vram_2); - - nvic_enable_irq (NVIC_DMA1_CHANNEL4_IRQ); - oled2_enable_refresh(); -} - - -void -oled2_shutdown (void) -{ - oled2_disable_refresh(); - oled_off (I2C2); -} |