]> mj.ucw.cz Git - home-hw.git/commitdiff
SSR: Cleanup
authorMartin Mares <mj@ucw.cz>
Tue, 7 Aug 2018 18:51:12 +0000 (20:51 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 7 Aug 2018 18:51:12 +0000 (20:51 +0200)
ssr/Inc/app.h
ssr/Makefile
ssr/Src/bmp085.c [deleted file]
ssr/Src/display.c [deleted file]
ssr/Src/main.c

index 05a96f2c70eb9226f060737fa58f4de4e3f31105..ba8b412069d1e9529fb163d590b37cfe00a04d8b 100644 (file)
@@ -1,11 +1,5 @@
 // main.c
 
-// display.c
-
-void display_init(void);
-void display_counter(uint cnt);
-void display_buffer(byte *buf);
-
 // usbdev.c
 
 extern byte rx_packet[64];
@@ -13,17 +7,3 @@ extern byte tx_packet[64];
 extern volatile byte rx_packet_state, tx_packet_state;
 
 void tx_packet_send(void);
-
-// bmp085.c
-
-extern byte bmp_request;
-extern int adjusted_temp;
-extern int adjusted_press;
-extern u32 bmp_counter;
-
-extern volatile byte *bmp_i2c_ptr;
-extern volatile byte bmp_i2c_len;
-extern volatile byte bmp_i2c_addr;
-
-void bmp_init(void);
-void bmp_step(void);
index e127df34a3b014c4295cf5d810a55e44970d2db1..764e66bdf686df4a66b7ecc7fb8d4302a2d42f20 100644 (file)
@@ -56,8 +56,6 @@ Src/main.c \
 Src/debug.c \
 Src/usb.c \
 Src/usbdev.c \
-Src/display.c \
-Src/bmp085.c \
 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_rcc.c \
 /Src/system_stm32f1xx.c \
 Src/stm32f1xx_it.c \
diff --git a/ssr/Src/bmp085.c b/ssr/Src/bmp085.c
deleted file mode 100644 (file)
index 45039b7..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-#include "stm32f1xx.h"
-#include "stm32f1xx_hal.h"
-
-#include "util.h"
-#include "app.h"
-
-#undef TEST_VECTOR
-
-#if 0
-#define bmp_debug debug_printf
-#else
-static inline void bmp_debug(char *msg, ...)
-{ }
-#endif
-
-static byte bmp_i2c_buf[4];
-volatile byte *bmp_i2c_ptr;
-volatile byte bmp_i2c_len;
-volatile byte bmp_i2c_addr;
-
-static uint bmp_read(uint reg, uint bytes)
-{
-  bmp_i2c_buf[0] = reg;
-  bmp_i2c_ptr = bmp_i2c_buf;
-  bmp_i2c_len = 1;
-  bmp_i2c_addr = 0xee;
-
-  LL_I2C_GenerateStartCondition(I2C1);
-  LL_I2C_EnableIT_TX(I2C1);
-
-  while (bmp_i2c_len)
-    ;
-
-  bmp_i2c_ptr = bmp_i2c_buf;
-  bmp_i2c_len = bytes;
-  bmp_i2c_addr = 0xef;
-
-  LL_I2C_GenerateStartCondition(I2C1);
-  LL_I2C_EnableIT_RX(I2C1);
-
-  while (bmp_i2c_len)
-    ;
-
-  uint d = 0;
-  for (uint i=0; i<bytes; i++)
-    d = (d << 8) | bmp_i2c_buf[i];
-
-  return d;
-}
-
-static void bmp_start_measure(uint type)
-{
-  LL_I2C_GenerateStartCondition(I2C1);
-  while (!LL_I2C_IsActiveFlag_SB(I2C1))
-    ;
-
-  LL_I2C_TransmitData8(I2C1, 0xee);
-  while (!LL_I2C_IsActiveFlag_ADDR(I2C1))
-    ;
-  LL_I2C_ClearFlag_ADDR(I2C1);
-
-  while (!LL_I2C_IsActiveFlag_TXE(I2C1))
-    ;
-  LL_I2C_TransmitData8(I2C1, 0xf4);
-
-  while (!LL_I2C_IsActiveFlag_TXE(I2C1))
-    ;
-  LL_I2C_TransmitData8(I2C1, type);
-
-  while (!LL_I2C_IsActiveFlag_TXE(I2C1))
-    ;
-  LL_I2C_GenerateStopCondition(I2C1);
-}
-
-// Formulae from BMP085 specs
-static void bmp_recalc(uint UT, uint UP, uint oss, u16 cc[11], int *tt, int *pp)
-{
-  s16 AC1 = cc[0];
-  s16 AC2 = cc[1];
-  s16 AC3 = cc[2];
-  u16 AC4 = cc[3];
-  u16 AC5 = cc[4];
-  u16 AC6 = cc[5];
-  s16 B1 = cc[6];
-  s16 B2 = cc[7];
-  // s16 MB = cc[8];
-  s16 MC = cc[9];
-  s16 MD = cc[10];
-  UP >>= (8-oss);
-
-  int X1 = (UT-AC6)*AC5 / (1<<15);
-  int X2 = MC*(1<<11) / (X1+MD);
-  int B5 = X1 + X2;
-  int T = (B5+8) / (1<<4);
-  *tt = T;
-
-  int B6 = B5 - 4000;
-  X1 = (B2*(B6*B6/(1<<12))) / (1<<11);
-  X2 = AC2 * B6 / (1<<11);
-  int X3 = X1 + X2;
-  int B3 = (((AC1*4 + X3) << oss) + 2) / 4;
-  X1 = AC3 * B6 / (1<<13);
-  X2 = (B1*(B6*B6/(1<<12))) / (1<<16);
-  X3 = ((X1+X2) + 2) / (1<<2);
-  uint B4 = (uint)(AC4 * (X3 + 32768)) / (1U<<15);
-  uint B7 = (uint)(UP-B3) * (uint)(50000>>oss);
-  int p;
-  if (B7 < 0x80000000)
-    p = (B7*2) / B4;
-  else
-    p = B7 / B4 * 2;
-  X1 = (p/(1<<8)) * (p/(1<<8));
-  X1 = (X1*3038) / (1<<16);
-  X2 = (-7357*p) / (1<<16);
-  p = p + (X1 + X2 + 3791) / (1<<4);
-  *pp = p;
-}
-
-#ifdef TEST_VECTOR
-
-#define BMP_OSS 0
-static u16 bmp_constants[11] = {
-  408,
-  -72,
-  -14383,
-  32741,
-  32757,
-  23153,
-  6190,
-  4,
-  32768,
-  -8711,
-  2868,
-};
-
-void bmp_init(void)
-{
-  bmp_debug("BMP: Test constants\n");
-}
-
-#else
-
-#define BMP_OSS 3
-static u16 bmp_constants[11];
-
-void bmp_init(void)
-{
-  bmp_debug("BMP: Reading constants\n");
-  for (uint i=0; i<11; i++)
-    {
-      bmp_constants[i] = bmp_read(0xaa + 2*i, 2);
-      bmp_debug("BMP: const[%d] = %04x\n", i, bmp_constants[i]);
-    }
-}
-
-#endif
-
-enum bmp_state {
-  BMP_IDLE,
-  BMP_TEMP,
-  BMP_PRESSURE,
-};
-
-byte bmp_request;
-static byte bmp_state = BMP_IDLE;
-static u16 raw_temp;
-static u32 raw_press;
-int adjusted_temp;
-int adjusted_press;
-u32 bmp_counter;
-
-void bmp_step(void)
-{
-  switch (bmp_state)
-    {
-    case BMP_IDLE:
-      if (!bmp_request)
-       return;
-      bmp_request = 0;
-      bmp_debug("BMP: Start measure\n");
-      bmp_start_measure(0x2e);
-      bmp_state++;
-      break;
-    case BMP_TEMP:
-      if (!LL_GPIO_IsInputPinSet(BMP_DONE_GPIO_Port, BMP_DONE_Pin))
-       return;
-      bmp_debug("BMP: Temperature measured\n");
-#ifdef TEST_VECTOR
-      raw_temp = 27898;
-#else
-      raw_temp = bmp_read(0xf6, 2);
-#endif
-      bmp_debug("BMP: Raw temperature: %04x\n", raw_temp);
-      bmp_start_measure(0xf4 | (BMP_OSS<<6));
-      bmp_state++;
-      break;
-    case BMP_PRESSURE:
-      if (!LL_GPIO_IsInputPinSet(BMP_DONE_GPIO_Port, BMP_DONE_Pin))
-       return;
-      bmp_debug("BMP: Pressure measured\n");
-#ifdef TEST_VECTOR
-      raw_press = 23843 << 8;
-#else
-      raw_press = bmp_read(0xf6, 3);
-#endif
-      bmp_debug("BMP: Raw pressure: %06x\n", raw_press);
-      bmp_recalc(raw_temp, raw_press, BMP_OSS, bmp_constants, &adjusted_temp, &adjusted_press);
-      bmp_debug("BMP: Adjusted temp %d, press %d\n", adjusted_temp, adjusted_press);
-      bmp_counter++;
-      bmp_state = BMP_IDLE;
-      break;
-    }
-}
diff --git a/ssr/Src/display.c b/ssr/Src/display.c
deleted file mode 100644 (file)
index 2af6ad1..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-#include "util.h"
-#include "main.h"
-#include "app.h"
-
-static const byte Gentium23x32[] = {
-        0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x1F, 0x00, 0x80, 0xFF, 0xFF, 0x00, 0xE0, 0xFF, 0xFF, 0x03, 0xF0, 0xFF, 0xFF, 0x0F, 0xF8, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFE, 0x01, 0xE0, 0x3F, 0x3E, 0x00, 0x00, 0x7F, 0x1F, 0x00, 0x00, 0x7C, 0x0F, 0x00, 0x00, 0x78, 0x0F, 0x00, 0x00, 0x78, 0x1F, 0x00, 0x00, 0x78, 0x3F, 0x00, 0x00, 0x78, 0x7F, 0x00, 0x00, 0x3E, 0xFE, 0x07, 0xC0, 0x3F, 0xFE, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x0F, 0xF8, 0xFF, 0xFF, 0x07, 0xE0, 0xFF, 0xFF, 0x03, 0x80, 0xFF, 0xFF, 0x00, 0x00, 0xFC, 0x0F, 0x00,  // Code for char 0
-        0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x70, 0x78, 0x00, 0x00, 0x70, 0x78, 0x00, 0x00, 0x78, 0x78, 0x00, 0x00, 0x78, 0x7C, 0x00, 0x00, 0x78, 0x3C, 0x00, 0x00, 0x78, 0xFE, 0xFF, 0xFF, 0x7F, 0xFE, 0xFF, 0xFF, 0x7F, 0xFE, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFE, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,  // Code for char 1
-        0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x80, 0x01, 0x00, 0x78, 0xE0, 0x03, 0x00, 0x7C, 0xF0, 0x03, 0x00, 0x7E, 0xF8, 0x03, 0x80, 0x7F, 0xFC, 0x01, 0xC0, 0x7F, 0xFE, 0x01, 0xE0, 0x7F, 0x3E, 0x00, 0xF0, 0x7F, 0x1E, 0x00, 0xFC, 0x7F, 0x0F, 0x00, 0xFE, 0x79, 0x0F, 0x00, 0xFF, 0x78, 0x0F, 0xC0, 0x7F, 0x78, 0x1F, 0xE0, 0x3F, 0x78, 0x3F, 0xF8, 0x0F, 0x78, 0xFF, 0xFF, 0x07, 0x78, 0xFE, 0xFF, 0x03, 0x78, 0xFE, 0xFF, 0x00, 0x7C, 0xFC, 0x7F, 0x80, 0x7F, 0xF8, 0x1F, 0x80, 0x7F, 0xE0, 0x07, 0x80, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 2
-        0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xC0, 0x00, 0x00, 0x1F, 0xF0, 0x01, 0x00, 0x1E, 0xF8, 0x01, 0x00, 0x3E, 0xFC, 0x01, 0x00, 0x3C, 0xFE, 0x00, 0x00, 0x7C, 0xFE, 0x00, 0x00, 0x78, 0x1E, 0xE0, 0x00, 0x78, 0x0F, 0xF0, 0x00, 0x78, 0x0F, 0xF0, 0x00, 0x78, 0x0F, 0xF0, 0x00, 0x78, 0x1F, 0xF8, 0x01, 0x7C, 0x3F, 0xFC, 0x01, 0x7C, 0xFF, 0xFF, 0x07, 0x3F, 0xFE, 0xFF, 0xFF, 0x3F, 0xFE, 0xFF, 0xFF, 0x1F, 0xFC, 0xCF, 0xFF, 0x0F, 0xF8, 0xC7, 0xFF, 0x07, 0xE0, 0x83, 0xFF, 0x03, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 3
-        0x17, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0xC0, 0x3F, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0xF8, 0x3F, 0x00, 0x00, 0xFE, 0x3D, 0x00, 0x00, 0xFF, 0x3C, 0x70, 0xC0, 0x3F, 0x3C, 0x70, 0xE0, 0x1F, 0x3C, 0x70, 0xF8, 0x07, 0x3C, 0x78, 0xFC, 0x03, 0x3C, 0x78, 0xFE, 0xFF, 0xFF, 0x7F, 0xFE, 0xFF, 0xFF, 0x7F, 0xFE, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFE, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x3C, 0x78, 0x00, 0x00, 0x3C, 0x70, 0x00, 0x00, 0x1C, 0x70, 0x00, 0x00, 0x08, 0x00,  // Code for char 4
-        0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0xC0, 0x00, 0x1F, 0x00, 0xFE, 0x01, 0x1E, 0xFC, 0xFF, 0x01, 0x3E, 0xFC, 0xFF, 0x00, 0x3C, 0xFC, 0xFF, 0x00, 0x3C, 0xFC, 0x7F, 0x00, 0x78, 0x3C, 0x78, 0x00, 0x78, 0x3C, 0x78, 0x00, 0x78, 0x3C, 0x78, 0x00, 0x78, 0x3C, 0x78, 0x00, 0x78, 0x3C, 0xF8, 0x00, 0x7C, 0x3C, 0xF8, 0x00, 0x7E, 0x3C, 0xF0, 0x03, 0x3F, 0x3C, 0xF0, 0xFF, 0x3F, 0x3C, 0xF0, 0xFF, 0x1F, 0x1E, 0xE0, 0xFF, 0x0F, 0x0F, 0xC0, 0xFF, 0x07, 0x06, 0x80, 0xFF, 0x03, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 5
-        0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x7F, 0x00, 0x00, 0xF8, 0xFF, 0x01, 0x00, 0xFE, 0xFF, 0x07, 0x80, 0xFF, 0xFF, 0x0F, 0xC0, 0xFF, 0xFF, 0x1F, 0xE0, 0xFF, 0xFF, 0x3F, 0xF0, 0xFF, 0xC1, 0x3F, 0xF8, 0xF7, 0x00, 0x7E, 0xF8, 0x71, 0x00, 0x7C, 0xFC, 0x78, 0x00, 0x78, 0x7C, 0x78, 0x00, 0x78, 0x3E, 0x78, 0x00, 0x78, 0x1E, 0xF8, 0x00, 0x7C, 0x1E, 0xF8, 0x03, 0x3E, 0x0F, 0xF0, 0xFF, 0x3F, 0x0F, 0xF0, 0xFF, 0x1F, 0x0F, 0xE0, 0xFF, 0x0F, 0x06, 0xE0, 0xFF, 0x07, 0x00, 0x80, 0xFF, 0x03, 0x00, 0x00, 0x7E, 0x00,  // Code for char 6
-        0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x01, 0x00, 0x00, 0xF8, 0x01, 0x00, 0x00, 0xFC, 0x01, 0x00, 0x00, 0xFC, 0x01, 0x00, 0x20, 0x7C, 0x00, 0x00, 0x78, 0x3C, 0x00, 0x00, 0x7E, 0x3C, 0x00, 0x80, 0x7F, 0x3C, 0x00, 0xE0, 0x3F, 0x3C, 0x00, 0xF8, 0x3F, 0x3C, 0x00, 0xFE, 0x1F, 0x3C, 0x80, 0xFF, 0x0F, 0x3C, 0xE0, 0xFF, 0x01, 0x3C, 0xF8, 0x7F, 0x00, 0x3C, 0xFE, 0x0F, 0x00, 0xFC, 0xFF, 0x03, 0x00, 0xFC, 0xFF, 0x00, 0x00, 0xFC, 0x1F, 0x00, 0x00, 0xFC, 0x07, 0x00, 0x00, 0xFC, 0x01, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,  // Code for char 7
-        0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x03, 0xC0, 0x07, 0xFC, 0x07, 0xF0, 0x1F, 0xFE, 0x1F, 0xF8, 0x3F, 0xFF, 0x1F, 0xFC, 0xBF, 0xFF, 0x3F, 0xFE, 0xFF, 0xFF, 0x3F, 0xFE, 0xFF, 0x0F, 0x7E, 0x1F, 0xFE, 0x03, 0x7C, 0x0F, 0xFC, 0x01, 0x78, 0x0F, 0xF8, 0x01, 0x78, 0x0F, 0xF8, 0x01, 0x78, 0x0F, 0xF8, 0x03, 0x78, 0x1F, 0xFC, 0x07, 0x7C, 0xFF, 0xFF, 0x0F, 0x3E, 0xFE, 0xFF, 0xFF, 0x3F, 0xFE, 0xDF, 0xFF, 0x1F, 0xFC, 0xCF, 0xFF, 0x0F, 0xF8, 0x87, 0xFF, 0x07, 0xF0, 0x01, 0xFF, 0x03, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 8
-        0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0xC0, 0xFF, 0x00, 0x00, 0xF0, 0xFF, 0x01, 0x60, 0xF8, 0xFF, 0x03, 0xE0, 0xFC, 0xFF, 0x07, 0xF0, 0xFC, 0xFF, 0x07, 0xF0, 0x7E, 0xE0, 0x0F, 0xF8, 0x1E, 0x80, 0x0F, 0x78, 0x0F, 0x00, 0x0F, 0x7C, 0x0F, 0x00, 0x0F, 0x7C, 0x0F, 0x00, 0x0F, 0x3E, 0x0F, 0x00, 0x0F, 0x3F, 0x1F, 0x00, 0x87, 0x1F, 0x3F, 0x80, 0xE7, 0x1F, 0xFE, 0xC1, 0xFB, 0x0F, 0xFE, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0x03, 0xF8, 0xFF, 0xFF, 0x01, 0xF0, 0xFF, 0x7F, 0x00, 0xC0, 0xFF, 0x1F, 0x00, 0x00, 0xFF, 0x03, 0x00,  // Code for char 9
-        0x0F, 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, 0xE0, 0x03, 0xC0, 0x07, 0xF0, 0x07, 0xE0, 0x0F, 0xF8, 0x07, 0xF0, 0x0F, 0xF8, 0x07, 0xF0, 0x0F, 0xF8, 0x07, 0xF0, 0x0F, 0xF8, 0x07, 0xF0, 0x0F, 0xF8, 0x03, 0xF0, 0x07, 0xF0, 0x01, 0xE0, 0x03, 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   // Code for char :
-};
-
-// Based on https://github.com/adafruit/Adafruit_SSD1306
-
-#define SSD1306_SETLOWCOLUMN 0x00
-#define SSD1306_SETHIGHCOLUMN 0x10
-#define SSD1306_MEMORYMODE 0x20
-#define SSD1306_SETSTARTLINE 0x40
-#define SSD1306_SETCONTRAST 0x81
-#define SSD1306_CHARGEPUMP 0x8D
-#define SSD1306_SEGREMAP 0xA0
-#define SSD1306_DISPLAYALLON_RESUME 0xA4
-#define SSD1306_DISPLAYALLON 0xA5
-#define SSD1306_NORMALDISPLAY 0xA6
-#define SSD1306_INVERTDISPLAY 0xA7
-#define SSD1306_SETMULTIPLEX 0xA8
-#define SSD1306_DISPLAYOFF 0xAE
-#define SSD1306_DISPLAYON 0xAF
-#define SSD1306_SETSTARTPAGE 0xB0
-#define SSD1306_COMSCANINC 0xC0
-#define SSD1306_COMSCANDEC 0xC8
-#define SSD1306_SETDISPLAYOFFSET 0xD3
-#define SSD1306_SETCOMPINS 0xDA
-#define SSD1306_SETVCOMDETECT 0xDB
-#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
-#define SSD1306_SETPRECHARGE 0xD9
-#define SSD1306_NOP 0xE3
-
-static const byte display_init_cmds[] = {
-  SSD1306_DISPLAYOFF,
-  SSD1306_SETDISPLAYCLOCKDIV, 0x80,  // the suggested ratio 0x80
-  SSD1306_SETMULTIPLEX, 0x1F,        // ratio 32
-  SSD1306_SETDISPLAYOFFSET,0x0,      // no offset
-  SSD1306_SETSTARTLINE | 0x0,        // line #0
-  SSD1306_CHARGEPUMP, 0x14,          // internal vcc
-  SSD1306_MEMORYMODE, 0x02,          // page mode
-  SSD1306_SEGREMAP | 0x0,            // column 0 mapped to SEG0
-  SSD1306_COMSCANINC,                // column scan direction not reversed
-  SSD1306_SETCOMPINS, 0x02,          // sequential COM pins, disable remap
-  SSD1306_SETCONTRAST, 0x7F,         // contrast level 127
-  SSD1306_SETPRECHARGE, 0xF1,        // pre-charge period (1, 15)
-  SSD1306_SETVCOMDETECT, 0x40,       // vcomh regulator level-
-  SSD1306_DISPLAYALLON_RESUME,
-  SSD1306_NORMALDISPLAY,
-  SSD1306_DISPLAYON,
-};
-
-static void display_send_byte(byte d)
-{
-  while (!LL_I2C_IsActiveFlag_TXE(I2C2))
-    ;
-  LL_I2C_TransmitData8(I2C2, d);
-}
-
-static void display_cmd(byte cmd)
-{
-  LL_I2C_GenerateStartCondition(I2C2);
-  while (!LL_I2C_IsActiveFlag_SB(I2C2))
-    ;
-  LL_I2C_TransmitData8(I2C2, 0x78);            // Address
-  while (!LL_I2C_IsActiveFlag_ADDR(I2C2))
-    ;
-  LL_I2C_ClearFlag_ADDR(I2C2);
-  display_send_byte(0x00);                     // Will send a command
-  display_send_byte(cmd);
-  while (!LL_I2C_IsActiveFlag_TXE(I2C2))
-    ;
-  LL_I2C_GenerateStopCondition(I2C2);
-}
-
-static void display_data_start(void)
-{
-  LL_I2C_GenerateStartCondition(I2C2);
-  while (!LL_I2C_IsActiveFlag_SB(I2C2))
-    ;
-  LL_I2C_TransmitData8(I2C2, 0x78);            // Address
-  while (!LL_I2C_IsActiveFlag_ADDR(I2C2))
-    ;
-  LL_I2C_ClearFlag_ADDR(I2C2);
-  display_send_byte(0x40);                     // Will send data
-}
-
-static void display_data(byte d)
-{
-  display_send_byte(d);
-}
-
-static void display_data_end(void)
-{
-  while (!LL_I2C_IsActiveFlag_TXE(I2C2))
-    ;
-  LL_I2C_GenerateStopCondition(I2C2);
-}
-
-void display_init(void)
-{
-  for (uint i=0; i < sizeof(display_init_cmds); i++)
-    display_cmd(display_init_cmds[i]);
-
-  for (uint p=0; p<4; p++)
-    {
-      display_cmd(SSD1306_SETSTARTPAGE + p);
-      display_cmd(SSD1306_SETHIGHCOLUMN);
-      display_cmd(SSD1306_SETLOWCOLUMN);
-      display_data_start();
-      for (uint i=0; i<128; i++)
-       display_data(0);
-      display_data_end();
-    }
-}
-
-void display_counter(uint cnt)
-{
-  byte d[5];
-  for (uint i=0; i<4; i++)
-    {
-      d[3-i] = cnt % 10;
-      cnt /= 10;
-    }
-  d[4] = d[3];
-  d[3] = d[2];
-  d[2] = 10;
-
-  for (uint p=0; p<4; p++)
-    {
-      display_cmd(SSD1306_SETSTARTPAGE + p);
-      display_cmd(SSD1306_SETHIGHCOLUMN);
-      display_cmd(SSD1306_SETLOWCOLUMN);
-      display_data_start();
-      for (uint i=0; i<5; i++)
-       {
-         for (uint j=0; j<23; j++)
-           {
-             byte x = Gentium23x32[(23*4+1)*d[i] + 1 + 4*j + p];
-             display_data(x);
-           }
-         display_data(0);
-         display_data(0);
-         display_data(0);
-       }
-      display_data_end();
-    }
-}
-
-void display_buffer(byte *buf)
-{
-  for (uint p=0; p<4; p++)
-    {
-      display_cmd(SSD1306_SETSTARTPAGE + p);
-      display_cmd(SSD1306_SETHIGHCOLUMN);
-      display_cmd(SSD1306_SETLOWCOLUMN);
-      display_data_start();
-      for (uint i=0; i<5; i++)
-       {
-         uint ch = buf[i];
-         if (ch <= 10)
-           {
-             for (uint j=0; j<23; j++)
-               {
-                 byte x = Gentium23x32[(23*4+1)*ch + 1 + 4*j + p];
-                 display_data(x);
-               }
-           }
-         else
-           {
-             for (uint j=0; j<23; j++)
-               display_data(0);
-           }
-         display_data(0);
-         display_data(0);
-         display_data(0);
-       }
-      display_data_end();
-    }
-}
index 5601e5cc70ee7a51b8be36beacdcc285f83b45ac..dc015c0ad0ab1b5e1694cdefb7be22a87fccfa13 100644 (file)
@@ -121,19 +121,12 @@ int main(void)
   MX_TIM4_Init();
   MX_USART1_UART_Init();
   /* USER CODE BEGIN 2 */
-  display_init();
   usb_start(&usb);
-  bmp_init();
 
   LL_TIM_EnableCounter(TIM4);
   LL_TIM_EnableIT_UPDATE(TIM4);
   LL_TIM_GenerateEvent_UPDATE(TIM4);
 
-  {
-    byte buf[5] = { 0xff, 0xff, 10, 0xff, 0xff };
-    display_buffer(buf);
-  }
-
   /* USER CODE END 2 */
 
   /* Infinite loop */
@@ -149,21 +142,14 @@ int main(void)
          LL_GPIO_ResetOutputPin(LED_GPIO_Port, LED_Pin);
        led_state ^= 1;
 
-       display_buffer(rx_packet);
        tx_packet_state = 1;
-       put_u32_be(tx_packet, adjusted_temp);
-       put_u32_be(tx_packet + 4, adjusted_press);
-       put_u32_be(tx_packet + 8, bmp_counter);
+       put_u32_be(tx_packet, 42);
        usb_ep_send(&usb, 0x82, tx_packet, 12);
        rx_packet_state = 0;
        usb_ep_receive(&usb, 0x01, rx_packet, 64);
-       bmp_request = 1;
       }
 
-    bmp_step();
-
     // debug_printf("Counter = %d\n", cnt);
-    // display_counter(cnt);
 
     __WFI();