diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/Makefile | 3 | ||||
| -rw-r--r-- | app/font21x32.c | 114 | ||||
| -rw-r--r-- | app/font8x16.c | 15 | ||||
| -rw-r--r-- | app/font8x8.c | 10 | ||||
| -rw-r--r-- | app/i2c.c | 2 | ||||
| -rw-r--r-- | app/i2c_hw.c | 273 | ||||
| -rw-r--r-- | app/main.c | 12 | ||||
| -rw-r--r-- | app/oled.c | 187 | ||||
| -rw-r--r-- | app/oled.h | 2 | ||||
| -rw-r--r-- | app/oled1.c | 127 | ||||
| -rw-r--r-- | app/oled2.c | 127 | ||||
| -rw-r--r-- | app/prototypes.h | 82 | ||||
| -rw-r--r-- | app/tacho.h | 1 | ||||
| -rw-r--r-- | app/ticker.c | 3 | 
14 files changed, 648 insertions, 310 deletions
| diff --git a/app/Makefile b/app/Makefile index 1a6088a..7fa09f4 100644 --- a/app/Makefile +++ b/app/Makefile @@ -23,7 +23,8 @@ PROG=speedo  V=1  default: ${PROG}.elf -CSRCS=main.c  led.c i2c.c usart.c ring.c ticker.c oled.c  i2c_hw.c  font8x8.c font8x16.c tacho.c +CSRCS=main.c  led.c i2c.c usart.c ring.c ticker.c oled.c  i2c_hw.c  font8x8.c font8x16.c tacho.c oled1.c oled2.c font21x32.c +  HSRCS=i2c.h oled.h project.h ring.h  BINARY = ${PROG} diff --git a/app/font21x32.c b/app/font21x32.c new file mode 100644 index 0000000..67d1018 --- /dev/null +++ b/app/font21x32.c @@ -0,0 +1,114 @@ +#include "project.h" + +static uint8_t font21x32[][84] = { +  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}, +  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, +   0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, +   0xfc, 0xfe, 0xff, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x0f, +   0xff, 0xfe, 0xfc, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x3f, 0x7f, 0xff, +   0xe0, 0xc0, 0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xf8, 0xff, 0x7f, 0x3f, +   0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, +   0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}, +  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x06, 0x06, 0x06, 0x06, 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xc0, +   0xc0, 0xc0, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}, +  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, +   0x1e, 0x1f, 0x1f, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x83, 0xc7, 0xff, +   0xff, 0xfe, 0x7c, 0x38, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xe0, 0xf0, +   0xf0, 0xf8, 0xfc, 0xf4, 0xf6, 0xf3, 0xf3, 0xf1, 0xf1, 0xf1, 0xf0, 0xfc, +   0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}, +  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x3c, 0x7e, 0x7f, 0x7b, 0x11, 0x01, 0x01, 0x01, 0x01, 0x83, 0xff, 0xff, +   0xfe, 0xfe, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, +   0x00, 0x04, 0x04, 0x04, 0x04, 0x0e, 0x0f, 0x3b, 0xfb, 0xf9, 0xf0, 0xe0, +   0xc0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x3f, 0x3f, 0x6f, 0x6e, 0x40, 0xc0, +   0xc0, 0xc0, 0xc0, 0x60, 0x78, 0x7f, 0x3f, 0x3f, 0x1f, 0x07, 0x00, 0x00,}, +  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x60, 0x38, 0x0c, 0xfe, 0xff, 0xff, +   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xf0, 0xdc, 0xc6, +   0xc3, 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xc0, +   0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, +   0x60, 0x60, 0x60, 0x7f, 0x7f, 0x7f, 0x7f, 0x60, 0x60, 0x60, 0x40, 0x00,}, +  {0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0xff, 0xff, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0f, 0x0f, 0x0f, 0x07, +   0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8f, 0x8f, +   0x06, 0x02, 0x03, 0x03, 0x01, 0x03, 0x03, 0x1e, 0xfe, 0xfc, 0xfc, 0xf0, +   0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x1f, 0x37, 0x67, 0x63, 0x40, 0xc0, +   0xc0, 0xc0, 0x40, 0x60, 0x78, 0x7f, 0x3f, 0x1f, 0x0f, 0x01, 0x00, 0x00,}, +  {0x00, 0x00, 0x80, 0xe0, 0xf0, 0xf8, 0xfc, 0x1e, 0x06, 0x02, 0x03, 0x03, +   0x03, 0x03, 0x3b, 0x7e, 0x7e, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, +   0xff, 0xff, 0xff, 0xff, 0x0c, 0x06, 0x02, 0x02, 0x02, 0x02, 0x06, 0xfe, +   0xfc, 0xf8, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x1f, 0x3f, 0x7f, +   0xff, 0xc0, 0xc0, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xff, 0x7f, 0x7f, 0x1f, +   0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}, +  {0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, +   0x1f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xcf, 0xef, 0x7f, +   0x3f, 0x0f, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0xc0, 0xf0, 0xfc, 0xfe, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xff, 0xff, +   0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}, +  {0x00, 0x00, 0x00, 0xf0, 0xfc, 0xfe, 0xc2, 0x82, 0x03, 0x03, 0x03, 0x03, +   0x03, 0x03, 0x06, 0xfe, 0xfc, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, +   0xc1, 0xe7, 0xef, 0x3f, 0x1f, 0x1f, 0x3f, 0x3e, 0x7e, 0xfc, 0xfe, 0xfb, +   0xfb, 0xf1, 0xe0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x7f, 0x7f, 0xe0, +   0xc0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xc1, 0x63, 0x7f, 0x3f, +   0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, +   0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}, +  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, +   0xfc, 0xfe, 0xfe, 0xff, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0xff, +   0xfe, 0xfc, 0xf8, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0f, 0x1f, 0x3f, +   0x7f, 0x60, 0x40, 0x40, 0x40, 0x40, 0x20, 0x18, 0xff, 0xff, 0xff, 0xff, +   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7e, 0x7e, 0x5c, 0xc0, 0xc0, +   0xc0, 0x40, 0x60, 0x70, 0x38, 0x3f, 0x1f, 0x0f, 0x03, 0x00, 0x00, 0x00,}, +}; + + + +/* this can be budget, since it can only fit one way vertically*/ + +void +font21x32_put_ch (uint8_t * vram, unsigned ch, unsigned x) +{ +  if ((ch >= '0') && (ch <= '9')) +    ch -= '0' - 1; +  else +    ch = 0; + + +  oled_blit_strip (vram, x, x + 21, 0xff, 0, font21x32[ch]); +  x += SSD1306_WIDTH; +  oled_blit_strip (vram, x, x + 21, 0xff, 0, &font21x32[ch][21]); +  x += SSD1306_WIDTH; +  oled_blit_strip (vram, x, x + 21, 0xff, 0, &font21x32[ch][42]); +  x += SSD1306_WIDTH; +  oled_blit_strip (vram, x, x + 21, 0xff, 0, &font21x32[ch][63]); +} + + +void +font21x32_put_str (uint8_t * vram, char *str, unsigned x) +{ +  while (*str) +    { +      font21x32_put_ch (vram, *(str++), x); +      x += 21; +    } +} diff --git a/app/font8x16.c b/app/font8x16.c index 48358f8..3591129 100644 --- a/app/font8x16.c +++ b/app/font8x16.c @@ -516,7 +516,7 @@ static uint8_t font8x16[][16] = {  };  void -font8x16_put_ch (unsigned ch, unsigned x, unsigned y) +font8x16_put_ch (uint8_t * vram, unsigned ch, unsigned x, unsigned y)  {    unsigned shift = y & 7;    unsigned page = y >> 3; @@ -524,7 +524,7 @@ font8x16_put_ch (unsigned ch, unsigned x, unsigned y)    x += page * SSD1306_WIDTH; -  oled_blit_strip (x, x + 8, 0xff << shift, shift, font8x16[ch]); +  oled_blit_strip (vram, x, x + 8, 0xff << shift, shift, font8x16[ch]);    x += SSD1306_WIDTH; @@ -533,18 +533,19 @@ font8x16_put_ch (unsigned ch, unsigned x, unsigned y)    if (shift)      { -      oled_blit_strip (x, x + 8, mask, -shift, font8x16[ch]); +      oled_blit_strip (vram, x, x + 8, mask, -shift, font8x16[ch]);      }    shift = y & 7; -  oled_blit_strip (x, x + 8, ~mask & (0xff << shift), shift, +  oled_blit_strip (vram, x, x + 8, ~mask & (0xff << shift), shift,                     &font8x16[ch][8]);    if (shift)      {        x += SSD1306_WIDTH;        shift = 8 - shift; -      oled_blit_strip (x, x + 8, 0xff >> shift, -shift, &font8x16[ch][8]); +      oled_blit_strip (vram, x, x + 8, 0xff >> shift, -shift, +                       &font8x16[ch][8]);      } @@ -552,11 +553,11 @@ font8x16_put_ch (unsigned ch, unsigned x, unsigned y)  void -font8x16_put_str (char *str, unsigned x, unsigned y) +font8x16_put_str (uint8_t * vram, char *str, unsigned x, unsigned y)  {    while (*str)      { -      font8x16_put_ch (*(str++), x, y); +      font8x16_put_ch (vram, *(str++), x, y);        x += 8;      }  } diff --git a/app/font8x8.c b/app/font8x8.c index 6d0eee1..4d49aa7 100644 --- a/app/font8x8.c +++ b/app/font8x8.c @@ -260,31 +260,31 @@ static uint8_t font8x8[][8] = {  };  void -font8x8_put_ch (unsigned ch, unsigned x, unsigned y) +font8x8_put_ch (uint8_t * vram, unsigned ch, unsigned x, unsigned y)  {    unsigned shift = y & 7;    unsigned page = y >> 3;    x += page * SSD1306_WIDTH; -  oled_blit_strip (x, x + 8, 0xff << shift, shift, font8x8[ch]); +  oled_blit_strip (vram, x, x + 8, 0xff << shift, shift, font8x8[ch]);    if (shift)      {        x += SSD1306_WIDTH;        shift = 8 - shift; -      oled_blit_strip (x, x + 8, 0xff >> shift, -shift, font8x8[ch]); +      oled_blit_strip (vram, x, x + 8, 0xff >> shift, -shift, font8x8[ch]);      }  }  void -font8x8_put_str (char *str, unsigned x, unsigned y) +font8x8_put_str (uint8_t * vram, char *str, unsigned x, unsigned y)  {    while (*str)      { -      font8x8_put_ch (*(str++), x, y); +      font8x8_put_ch (vram, *(str++), x, y);        x += 8;      }  } @@ -1,3 +1,5 @@ +#include "project.h" +  static int mutex = 0;  int diff --git a/app/i2c_hw.c b/app/i2c_hw.c index 1dd352c..35bde08 100644 --- a/app/i2c_hw.c +++ b/app/i2c_hw.c @@ -1,12 +1,15 @@  #include "project.h" -#define I2C I2C1 +#define SCL1 	GPIO6 +#define SDA1	GPIO7 +#define SCL1_PORT	GPIOB +#define SDA1_PORT	GPIOB -#define SCL 	GPIO6 -#define SDA	GPIO7 -#define SCL_PORT	GPIOB -#define SDA_PORT	GPIOB +#define SCL2 	GPIO10 +#define SDA2	GPIO11 +#define SCL2_PORT	GPIOB +#define SDA2_PORT	GPIOB  void  i2c_clear_start (uint32_t i2c) @@ -14,66 +17,53 @@ i2c_clear_start (uint32_t i2c)    I2C_CR1 (i2c) &= ~(uint32_t) I2C_CR1_START;  } -#if 0 -static void -i2cp_ds (void) -{ -  uint32_t i2c = I2C; -  printf ("CR1=%08x CR2=%08x\n", (unsigned) I2C_CR1 (i2c), -          (unsigned) I2C_CR2 (i2c)); -  printf ("SR1=%08x SR2=%08x\n", (unsigned) I2C_SR1 (i2c), -          (unsigned) I2C_SR2 (i2c)); - - -  usart1_drain (); -} -#endif - - -void -i2cp_start (void) +int +i2cp_start (uint32_t i2c)  { -  i2c_send_start (I2C); -  while (!((I2C_SR1 (I2C) & I2C_SR1_SB) -           & (I2C_SR2 (I2C) & (I2C_SR2_MSL | I2C_SR2_BUSY)))); +  uint32_t timeout = 1000; +  i2c_send_start (i2c); +  while (!((I2C_SR1 (i2c) & I2C_SR1_SB) +           & (I2C_SR2 (i2c) & (I2C_SR2_MSL | I2C_SR2_BUSY))) && (timeout--)); + +  return timeout ? 0 : -1;  }  void -i2cp_abort_start (void) +i2cp_abort_start (uint32_t i2c)  { -  i2c_clear_start (I2C); +  i2c_clear_start (i2c);    delay_us (10);  }  void -i2cp_stop (void) +i2cp_stop (uint32_t i2c)  { -  i2c_send_stop (I2C); +  i2c_send_stop (i2c);  }  void -i2cp_abort_stop (void) +i2cp_abort_stop (uint32_t i2c)  { -  i2c_clear_stop (I2C); +  i2c_clear_stop (i2c);    delay_us (10);  }  int -i2cp_send (uint8_t v) +i2cp_send (uint32_t i2c, uint8_t v)  {    uint32_t reg;    uint32_t timeout = 1000; -  i2c_send_data (I2C, v); +  i2c_send_data (i2c, v);    while (!           ((reg = -           I2C_SR1 (I2C)) & (I2C_SR1_BTF | I2C_SR1_BERR | I2C_SR1_ARLO | +           I2C_SR1 (i2c)) & (I2C_SR1_BTF | I2C_SR1_BERR | I2C_SR1_ARLO |                               I2C_SR1_AF | I2C_SR1_PECERR | I2C_SR1_TIMEOUT |                               I2C_SR1_SMBALERT)) && (timeout--)); -  I2C_SR1 (I2C) = +  I2C_SR1 (i2c) =      reg & ~(I2C_SR1_BERR | I2C_SR1_ARLO | I2C_SR1_AF | I2C_SR1_PECERR |              I2C_SR1_TIMEOUT | I2C_SR1_SMBALERT); @@ -86,32 +76,32 @@ i2cp_send (uint8_t v)  /*0 on success 1 on failure*/  int -i2cp_start_transaction (uint8_t a, int wnr) +i2cp_start_transaction (uint32_t i2c, uint8_t a, int wnr)  {    uint32_t reg;    uint32_t __attribute__((unused)) dummy;    uint32_t timeout = 1000; -  i2c_send_start (I2C); -  while (!((I2C_SR1 (I2C) & I2C_SR1_SB) -           & (I2C_SR2 (I2C) & (I2C_SR2_MSL | I2C_SR2_BUSY))) && (timeout--)); +  i2c_send_start (i2c); +  while (!((I2C_SR1 (i2c) & I2C_SR1_SB) +           & (I2C_SR2 (i2c) & (I2C_SR2_MSL | I2C_SR2_BUSY))) && (timeout--));    if (!timeout)      return -1; -  i2c_send_7bit_address (I2C, a, wnr); +  i2c_send_7bit_address (i2c, a, wnr);    while (!           ((reg = -           I2C_SR1 (I2C)) & (I2C_SR1_ADDR | I2C_SR1_BERR | I2C_SR1_ARLO | +           I2C_SR1 (i2c)) & (I2C_SR1_ADDR | I2C_SR1_BERR | I2C_SR1_ARLO |                               I2C_SR1_AF | I2C_SR1_PECERR | I2C_SR1_TIMEOUT |                               I2C_SR1_SMBALERT)) && (timeout--));    if (!timeout)      return -1; -  dummy = I2C_SR2 (I2C); +  dummy = I2C_SR2 (i2c); -  I2C_SR1 (I2C) = +  I2C_SR1 (i2c) =      reg & ~(I2C_SR1_BERR | I2C_SR1_ARLO | I2C_SR1_AF | I2C_SR1_PECERR |              I2C_SR1_TIMEOUT | I2C_SR1_SMBALERT); @@ -122,40 +112,75 @@ i2cp_start_transaction (uint8_t a, int wnr)   /*This is stupid, it bit bangs a dummy transaction to get the host i2c controller back in the game */  void -i2cp_reset_sm (void) +i2cp1_reset_sm (void)  {    int i; -  MAP_OUTPUT_PP (SCL); -  MAP_OUTPUT_PP (SDA); +  MAP_OUTPUT_PP (SCL1); +  MAP_OUTPUT_PP (SDA1); -  SET (SDA); -  SET (SCL); +  SET (SDA1); +  SET (SCL1);    delay_us (10); -  CLEAR (SDA); +  CLEAR (SDA1);    delay_us (10); -  CLEAR (SCL); +  CLEAR (SCL1);    for (i = 0; i < 9; ++i)      {        delay_us (10); -      SET (SCL); +      SET (SCL1);        delay_us (10); -      CLEAR (SCL); +      CLEAR (SCL1);        delay_us (10);      } -  SET (SCL); +  SET (SCL1);    delay_us (10); -  SET (SDA); +  SET (SDA1);    delay_us (10); -  MAP_AF_OD (SCL); -  MAP_AF_OD (SDA); +  MAP_AF_OD (SCL1); +  MAP_AF_OD (SDA1);  }  void -i2cp_start_dma (uint8_t * buf, int len) +i2cp2_reset_sm (void) +{ +  int i; + +  MAP_OUTPUT_PP (SCL2); +  MAP_OUTPUT_PP (SDA2); + +  SET (SDA2); +  SET (SCL2); +  delay_us (10); +  CLEAR (SDA2); +  delay_us (10); +  CLEAR (SCL2); + +  for (i = 0; i < 9; ++i) +    { +      delay_us (10); +      SET (SCL2); +      delay_us (10); +      CLEAR (SCL2); +      delay_us (10); +    } +  SET (SCL2); +  delay_us (10); +  SET (SDA2); +  delay_us (10); + +  MAP_AF_OD (SCL2); +  MAP_AF_OD (SDA2); + +} + + + +void +i2cp1_start_dma (uint8_t * buf, int len)  {    dma_channel_reset (DMA1, DMA_CHANNEL6);    dma_set_peripheral_address (DMA1, DMA_CHANNEL6, (uint32_t) & I2C1_DR); @@ -171,103 +196,149 @@ i2cp_start_dma (uint8_t * buf, int len)    dma_enable_channel (DMA1, DMA_CHANNEL6);    i2c_enable_dma (I2C1); +} + +void +i2cp2_start_dma (uint8_t * buf, int len) +{ +  dma_channel_reset (DMA1, DMA_CHANNEL4); +  dma_set_peripheral_address (DMA1, DMA_CHANNEL4, (uint32_t) & I2C2_DR); +  dma_set_memory_address (DMA1, DMA_CHANNEL4, (uint32_t) buf); +  dma_set_number_of_data (DMA1, DMA_CHANNEL4, len); +  dma_set_read_from_memory (DMA1, DMA_CHANNEL4); +  dma_enable_memory_increment_mode (DMA1, DMA_CHANNEL4); +  dma_set_peripheral_size (DMA1, DMA_CHANNEL4, DMA_CCR_PSIZE_8BIT); +  dma_set_memory_size (DMA1, DMA_CHANNEL4, DMA_CCR_MSIZE_8BIT); +  dma_set_priority (DMA1, DMA_CHANNEL4, DMA_CCR_PL_MEDIUM); +  dma_enable_transfer_complete_interrupt (DMA1, DMA_CHANNEL4); +  dma_enable_transfer_error_interrupt (DMA1, DMA_CHANNEL4); +  dma_enable_channel (DMA1, DMA_CHANNEL4); + +  i2c_enable_dma (I2C2);  } +  int -i2cp_dma_in_progress (void) +i2cp1_dma_in_progress (void)  {    return !(DMA1_ISR & (DMA_ISR_TCIF6 | DMA_ISR_TEIF6));  }  void -i2cp_stop_dma (void) +i2cp1_stop_dma (void)  { -  DMA1_IFCR |= DMA_IFCR_CTCIF7 | DMA_IFCR_CTEIF6 | DMA_IFCR_CGIF6; +  DMA1_IFCR |= DMA_IFCR_CTCIF6 | DMA_IFCR_CTEIF6 | DMA_IFCR_CGIF6;    dma_disable_transfer_complete_interrupt (DMA1, DMA_CHANNEL6);    dma_disable_transfer_error_interrupt (DMA1, DMA_CHANNEL6);    i2c_disable_dma (I2C1); -  dma_disable_channel (DMA1, DMA_CHANNEL7); +  dma_disable_channel (DMA1, DMA_CHANNEL6); +} + +void +i2cp2_stop_dma (void) +{ +  DMA1_IFCR |= DMA_IFCR_CTCIF4 | DMA_IFCR_CTEIF4 | DMA_IFCR_CGIF4; + +  dma_disable_transfer_complete_interrupt (DMA1, DMA_CHANNEL4); +  dma_disable_transfer_error_interrupt (DMA1, DMA_CHANNEL4); + +  i2c_disable_dma (I2C2); +  dma_disable_channel (DMA1, DMA_CHANNEL4);  } +  void -i2cp_reset (void) +i2cp_reset (uint32_t i2c)  {    while (i2c_lock ()); -  i2cp_start (); -  i2cp_abort_start (); -  i2cp_stop (); -  i2cp_abort_stop (); - -  i2cp_start (); -  i2cp_abort_start (); -  i2cp_stop (); -  i2cp_abort_stop (); +  i2cp_start (i2c); +  i2cp_abort_start (i2c); +  i2cp_stop (i2c); +  i2cp_abort_stop (i2c); + +  i2cp_start (i2c); +  i2cp_abort_start (i2c); +  i2cp_stop (i2c); +  i2cp_abort_stop (i2c);    i2c_unlock ();  }  void -i2cp_scan (void) +i2cp_scan (uint32_t i2c)  {    int i, r; -  i2cp_reset (); +  i2cp_reset (i2c);    printf ("Probing bus\n");    for (i = 0; i < 128; ++i)      {        printf ("%d\n", i);        while (i2c_lock ()); -      i2cp_start (); -      i2cp_abort_start (); -      i2cp_stop (); -      i2cp_abort_stop (); +      i2cp_start (i2c); +      i2cp_abort_start (i2c); +      i2cp_stop (i2c); +      i2cp_abort_stop (i2c);        delay_ms (10); -      r = i2cp_start_transaction (i, I2C_WRITE); -      i2cp_stop (); +      r = i2cp_start_transaction (i2c, i, I2C_WRITE); +      i2cp_stop (i2c);        i2c_unlock ();        if (!r)          printf ("Found device at address 0x%x\n", i);        usart1_drain ();      }    printf ("Done\n"); -  i2cp_reset (); +  i2cp_reset (i2c);  } -void -i2cp_init (void) +static void +i2cp_bringup (uint32_t i2c)  { -  rcc_periph_clock_enable (RCC_I2C1); -  rcc_periph_clock_enable (RCC_DMA1); +  i2c_peripheral_enable (i2c); +  i2c_clear_start (i2c); +  i2c_clear_stop (i2c); +  i2c_reset (i2c); +  i2c_peripheral_enable (i2c); -  while (i2c_lock ()); +  I2C_CR1 (i2c) |= I2C_CR1_SWRST; +  delay_us (1000); +  I2C_CR1 (i2c) &= ~I2C_CR1_SWRST; -  i2c_peripheral_enable (I2C); -  i2c_clear_start (I2C); -  i2c_clear_stop (I2C); -  i2c_reset (I2C); -  i2c_peripheral_enable (I2C); +  if (i2c == I2C1) +    i2cp1_reset_sm (); +  else +    i2cp2_reset_sm (); -  I2C_CR1 (I2C) |= I2C_CR1_SWRST; -  delay_us (1000); -  I2C_CR1 (I2C) &= ~I2C_CR1_SWRST; +  i2c_set_clock_frequency (i2c, I2C_CR2_FREQ_36MHZ); +  i2c_set_standard_mode (i2c); +  i2c_set_ccr (i2c, 0x80);      /* t_high=t_high=CCR * Tpclk1 */ +  i2c_set_trise (i2c, 0x0b); + +  i2c_set_own_7bit_slave_address (i2c, 0x00); + +  i2c_peripheral_enable (i2c); +} -  i2cp_reset_sm (); -  i2c_set_clock_frequency (I2C, I2C_CR2_FREQ_36MHZ); -  i2c_set_standard_mode (I2C); -  i2c_set_ccr (I2C, 0x80);      /* t_high=t_high=CCR * Tpclk1 */ -  i2c_set_trise (I2C, 0x0b); +void +i2cp_init (void) +{ +  rcc_periph_clock_enable (RCC_I2C1); +  rcc_periph_clock_enable (RCC_I2C2); +  rcc_periph_clock_enable (RCC_DMA1); + +  while (i2c_lock ()); -  i2c_set_own_7bit_slave_address (I2C, 0x00); +  i2cp_bringup (I2C1); +  i2cp_bringup (I2C2); -  i2c_peripheral_enable (I2C);    i2c_unlock ();  } @@ -42,11 +42,12 @@ main (void)    led_set (); -  oled_init (); +  oled1_init (); +  oled2_init ();    tacho_init (); -  font8x8_put_str ("ABC fish soup!", 0, 0); +  font8x8_put_str (vram_1, "ABC fish soup!", 0, 0);    MAP_OUTPUT_PP (WIGGLE); @@ -56,10 +57,13 @@ main (void)        char buf[20];        sprintf (buf, "%6u rpm", (unsigned) raw_tacho); -      font8x16_put_str (buf, 30, 8); +      font8x16_put_str (vram_1, buf, 30, 8);        sprintf (buf, "%8d", cnt++); -      font8x8_put_str (buf, 0, 24); +      font8x8_put_str (vram_1, buf, 0, 24); + +      sprintf (buf, "%6d", cnt >> 4); +      font21x32_put_str (vram_2, buf, 0);        if (cnt & 1) @@ -1,18 +1,8 @@  #include "project.h" -#define DMA_BUF_SZ (2 + (SSD1306_VRAM_SIZE)) - -uint8_t dma_buf[DMA_BUF_SZ]; -uint8_t update_buf[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; - -  int -ssd1306_cmds (uint8_t * buf, size_t len, int delay) +ssd1306_cmds (uint32_t i2c, uint8_t * buf, size_t len, int delay)  {    int ret = -1; @@ -22,17 +12,17 @@ ssd1306_cmds (uint8_t * buf, size_t len, int delay)    do      { -      if (i2cp_start_transaction (SSD1306_I2C_ADDRESS, I2C_WRITE)) +      if (i2cp_start_transaction (i2c, SSD1306_I2C_ADDRESS, I2C_WRITE))          break; -      if (i2cp_send (SSD1306_COMMAND)) +      if (i2cp_send (i2c, SSD1306_COMMAND))          break;        while (len--) -        if (i2cp_send (*(buf++))) +        if (i2cp_send (i2c, *(buf++)))            break; -      i2cp_stop (); +      i2cp_stop (i2c);        if (delay)          delay_us (delay); @@ -48,141 +38,47 @@ ssd1306_cmds (uint8_t * buf, size_t len, int delay)  }  int -ssd1306_cmd (uint8_t cmd, int delay) +ssd1306_cmd (uint32_t i2c, uint8_t cmd, int delay)  { -  return ssd1306_cmds (&cmd, 1, delay); -} - - - -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, update_buf, DMA_BUF_SZ); - -  if (ssd1306_cmds (cmds, sizeof (cmds), 0)) -    { -      oled_sad++; -      return; -    } - -  if (i2cp_start_transaction (SSD1306_I2C_ADDRESS, I2C_WRITE)) -    { -      oled_sad++; -      return; -    } - -  refresh_wdt = 0; -  dma_in_progress = 1; - -  i2cp_start_dma (dma_buf, DMA_BUF_SZ); +  return ssd1306_cmds (i2c, &cmd, 1, delay);  }  void -dma1_channel6_isr (void) -{ -  if (dma_in_progress) -    { -      i2cp_stop_dma (); - -      i2cp_stop (); -      dma_in_progress = 0; -    } - -  if (refresh_enabled) -    start_dma (); -} - -void -oled_refresh_wdt (void) -{ -  if (!refresh_enabled) -    return; - - - -  refresh_wdt++; - - -  if ((refresh_wdt < 1000) && (!oled_sad)) -    return; - -  refresh_wdt = 0; - -/*No refresh for 1s, restart everything */ - -  i2cp_stop_dma (); -  i2cp_stop (); -  dma_in_progress = 0; - -  if (oled_sad) -    { -      oled_sad = 0; -      i2cp_reset_sm (); -    } - -  start_dma (); - -} - -static void -dma_generate_stream (void) +oled_generate_stream (uint8_t * vram)  { -  memset (update_buf, 0, DMA_BUF_SZ); -  update_buf[0] = SSD1306_DATA_CONTINUE; +  memset (vram, 0, DMA_BUF_SZ); +  vram[0] = SSD1306_DATA_CONTINUE;  } -void -oled_enable_refresh (void) -{ -  refresh_enabled = 1; -  start_dma (); -} -  void -oled_disable_refresh (void) +oled_cls (uint8_t * vram)  { -  refresh_enabled = 0; -  while (dma_in_progress); -} - -void -oled_cls (void) -{ -  memset (update_buf + 1, 0, SSD1306_VRAM_SIZE); +  memset (vram + 1, 0, SSD1306_VRAM_SIZE);  }  void -oled_on (void) +oled_on (uint32_t i2c)  { -  ssd1306_cmd (SSD1306_DISPLAY_ON, 0); +  ssd1306_cmd (i2c, SSD1306_DISPLAY_ON, 0);  }  void -oled_off (void) +oled_off (uint32_t i2c)  { -  ssd1306_cmd (SSD1306_DISPLAY_OFF, 0); +  ssd1306_cmd (i2c, SSD1306_DISPLAY_OFF, 0);  } +#if 0  void  oled_squirt (void)  { @@ -206,9 +102,10 @@ oled_squirt (void)    i2c_unlock ();  } +#endif  void -oled_reset (void) +oled_reset (uint32_t i2c)  {    uint8_t init[] = {      SSD1306_DISPLAY_OFF, @@ -231,25 +128,26 @@ oled_reset (void)      SSD1306_DISPLAY_ON,    }; -  ssd1306_cmds (init, sizeof (init), 0); +  ssd1306_cmds (i2c, init, sizeof (init), 0);  }  void -oled_const_strip (int x, int xe, uint8_t and, uint8_t or) +oled_const_strip (uint8_t * vram, int x, int xe, uint8_t and, uint8_t or)  {    uint8_t r;    for (x++; x <= xe; ++x)      { -      r = update_buf[x] & and; -      update_buf[x] = r | or; +      r = vram[x] & and; +      vram[x] = r | or;      }  }  void -oled_blit_strip (int x, int xe, uint8_t mask, int shift, uint8_t * src) +oled_blit_strip (uint8_t * vram, int x, int xe, uint8_t mask, int shift, +                 uint8_t * src)  {    uint8_t r, s; @@ -261,8 +159,8 @@ oled_blit_strip (int x, int xe, uint8_t mask, int shift, uint8_t * src)            s = *(src++);            s <<= shift;            s &= mask; -          r = update_buf[x] & ~mask; -          update_buf[x] = r | s; +          r = vram[x] & ~mask; +          vram[x] = r | s;          }      } @@ -274,8 +172,8 @@ oled_blit_strip (int x, int xe, uint8_t mask, int shift, uint8_t * src)            s = *(src++);            s >>= shift;            s &= mask; -          r = update_buf[x] & ~mask; -          update_buf[x] = r | s; +          r = vram[x] & ~mask; +          vram[x] = r | s;          }      }    else @@ -284,31 +182,8 @@ oled_blit_strip (int x, int xe, uint8_t mask, int shift, uint8_t * src)          {            s = *(src++);            s &= mask; -          r = update_buf[x] & ~mask; -          update_buf[x] = r | s; +          r = vram[x] & ~mask; +          vram[x] = r | s;          }      }  } - - - -void -oled_init () -{ -  oled_reset (); - -  delay_us (100); - -  dma_generate_stream (); - -  nvic_enable_irq (NVIC_DMA1_CHANNEL6_IRQ); -  oled_enable_refresh (); -} - - -void -oled_shutdown (void) -{ -  oled_disable_refresh (); -  oled_off (); -} @@ -45,3 +45,5 @@  #define SSD1306_HEIGHT 32  #define SSD1306_VRAM_SIZE (SSD1306_WIDTH * ((SSD1306_HEIGHT + 7) >> 3)) + +#define DMA_BUF_SZ (2 + (SSD1306_VRAM_SIZE)) diff --git a/app/oled1.c b/app/oled1.c new file mode 100644 index 0000000..48c6167 --- /dev/null +++ b/app/oled1.c @@ -0,0 +1,127 @@ +#include "project.h" + + +static uint8_t dma_buf[DMA_BUF_SZ]; +uint8_t vram_1[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_1, DMA_BUF_SZ); + +  if (ssd1306_cmds (I2C1, cmds, sizeof (cmds), 0)) +    { +      oled_sad++; +      return; +    } + +  if (i2cp_start_transaction (I2C1, SSD1306_I2C_ADDRESS, I2C_WRITE)) +    { +      oled_sad++; +      return; +    } + +  refresh_wdt = 0; +  dma_in_progress = 1; + +  i2cp1_start_dma (dma_buf, DMA_BUF_SZ); +} + + + +void +dma1_channel6_isr (void) +{ +  if (dma_in_progress) +    { +      i2cp1_stop_dma (); + +      i2cp_stop (I2C1); +      dma_in_progress = 0; +    } + +  if (refresh_enabled) +    start_dma (); +} + +void +oled1_ticker (void) +{ +  if (!refresh_enabled) +    return; + +  refresh_wdt++; + +  if ((refresh_wdt < 1000) && (!oled_sad)) +    return; + +  refresh_wdt = 0; + +/*No refresh for 1s, restart everything */ + +  i2cp1_stop_dma (); +  i2cp_stop (I2C1); +  dma_in_progress = 0; + +  if (oled_sad) +    { +      oled_sad = 0; +      i2cp1_reset_sm (); +    } + +  start_dma (); + +} + +void +oled1_enable_refresh (void) +{ +  refresh_enabled = 1; +  start_dma (); +} + + +void +oled1_disable_refresh (void) +{ +  refresh_enabled = 0; +  while (dma_in_progress); +} + + + +void +oled1_init (void) +{ +  oled_reset (I2C1); + +  delay_us (100); + +  oled_generate_stream (vram_1); + +  nvic_enable_irq (NVIC_DMA1_CHANNEL6_IRQ); +  oled1_enable_refresh (); +} + + +void +oled1_shutdown (void) +{ +  oled1_disable_refresh (); +  oled_off (I2C1); +} diff --git a/app/oled2.c b/app/oled2.c new file mode 100644 index 0000000..331e5b7 --- /dev/null +++ b/app/oled2.c @@ -0,0 +1,127 @@ +#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 < 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); +} diff --git a/app/prototypes.h b/app/prototypes.h index 19b92f0..60ba26c 100644 --- a/app/prototypes.h +++ b/app/prototypes.h @@ -28,45 +28,59 @@ extern void sys_tick_handler(void);  extern void delay_ms(uint32_t d);  extern void ticker_init(void);  /* oled.c */ -extern uint8_t dma_buf[(2 + ((128 * ((32 + 7) >> 3))))]; -extern uint8_t update_buf[(2 + ((128 * ((32 + 7) >> 3))))]; -extern int ssd1306_cmds(uint8_t *buf, size_t len, int delay); -extern int ssd1306_cmd(uint8_t cmd, int delay); -extern void dma1_channel6_isr(void); -extern void oled_refresh_wdt(void); -extern void oled_enable_refresh(void); -extern void oled_disable_refresh(void); -extern void oled_cls(void); -extern void oled_on(void); -extern void oled_off(void); -extern void oled_squirt(void); -extern void oled_reset(void); -extern void oled_const_strip(int x, int xe, uint8_t and, uint8_t or); -extern void oled_blit_strip(int x, int xe, uint8_t mask, int shift, uint8_t *src); -extern void oled_init(void); -extern void oled_shutdown(void); +extern int ssd1306_cmds(uint32_t i2c, uint8_t *buf, size_t len, int delay); +extern int ssd1306_cmd(uint32_t i2c, uint8_t cmd, int delay); +extern void oled_generate_stream(uint8_t *vram); +extern void oled_cls(uint8_t *vram); +extern void oled_on(uint32_t i2c); +extern void oled_off(uint32_t i2c); +extern void oled_reset(uint32_t i2c); +extern void oled_const_strip(uint8_t *vram, int x, int xe, uint8_t and, uint8_t or); +extern void oled_blit_strip(uint8_t *vram, int x, int xe, uint8_t mask, int shift, uint8_t *src);  /* i2c_hw.c */  extern void i2c_clear_start(uint32_t i2c); -extern void i2cp_start(void); -extern void i2cp_abort_start(void); -extern void i2cp_stop(void); -extern void i2cp_abort_stop(void); -extern int i2cp_send(uint8_t v); -extern int i2cp_start_transaction(uint8_t a, int wnr); -extern void i2cp_reset_sm(void); -extern void i2cp_start_dma(uint8_t *buf, int len); -extern int i2cp_dma_in_progress(void); -extern void i2cp_stop_dma(void); -extern void i2cp_reset(void); -extern void i2cp_scan(void); +extern int i2cp_start(uint32_t i2c); +extern void i2cp_abort_start(uint32_t i2c); +extern void i2cp_stop(uint32_t i2c); +extern void i2cp_abort_stop(uint32_t i2c); +extern int i2cp_send(uint32_t i2c, uint8_t v); +extern int i2cp_start_transaction(uint32_t i2c, uint8_t a, int wnr); +extern void i2cp1_reset_sm(void); +extern void i2cp2_reset_sm(void); +extern void i2cp1_start_dma(uint8_t *buf, int len); +extern void i2cp2_start_dma(uint8_t *buf, int len); +extern int i2cp1_dma_in_progress(void); +extern void i2cp1_stop_dma(void); +extern void i2cp2_stop_dma(void); +extern void i2cp_reset(uint32_t i2c); +extern void i2cp_scan(uint32_t i2c);  extern void i2cp_init(void);  /* font8x8.c */ -extern void font8x8_put_ch(unsigned ch, unsigned x, unsigned y); -extern void font8x8_put_str(char *str, unsigned x, unsigned y); +extern void font8x8_put_ch(uint8_t *vram, unsigned ch, unsigned x, unsigned y); +extern void font8x8_put_str(uint8_t *vram, char *str, unsigned x, unsigned y);  /* font8x16.c */ -extern void font8x16_put_ch(unsigned ch, unsigned x, unsigned y); -extern void font8x16_put_str(char *str, unsigned x, unsigned y); +extern void font8x16_put_ch(uint8_t *vram, unsigned ch, unsigned x, unsigned y); +extern void font8x16_put_str(uint8_t *vram, char *str, unsigned x, unsigned y);  /* tacho.c */  extern uint32_t raw_tacho; -extern void exit3_isr(void); +extern void exti3_isr(void);  extern void tacho_init(void); +/* oled1.c */ +extern uint8_t vram_1[(2 + ((128 * ((32 + 7) >> 3))))]; +extern void dma1_channel6_isr(void); +extern void oled1_ticker(void); +extern void oled1_enable_refresh(void); +extern void oled1_disable_refresh(void); +extern void oled1_init(void); +extern void oled1_shutdown(void); +/* oled2.c */ +extern uint8_t vram_2[(2 + ((128 * ((32 + 7) >> 3))))]; +extern void dma1_channel4_isr(void); +extern void oled2_ticker(void); +extern void oled2_enable_refresh(void); +extern void oled2_disable_refresh(void); +extern void oled2_init(void); +extern void oled2_shutdown(void); +/* font21x32.c */ +extern void font21x32_put_ch(uint8_t *vram, unsigned ch, unsigned x); +extern void font21x32_put_str(uint8_t *vram, char *str, unsigned x); diff --git a/app/tacho.h b/app/tacho.h index d756e9b..a044ae7 100644 --- a/app/tacho.h +++ b/app/tacho.h @@ -3,4 +3,3 @@  #define TACHO		GPIO3  #define TACHO_PORT	GPIOB  #define TACHO_ISR	exti3_isr - diff --git a/app/ticker.c b/app/ticker.c index c0008fe..15d5e3f 100644 --- a/app/ticker.c +++ b/app/ticker.c @@ -23,7 +23,8 @@ sys_tick_handler (void)    led_tick (); -  oled_refresh_wdt (); +  oled1_ticker (); +  oled2_ticker ();    ticks++;  } | 
