Преглед на файлове

Onewire fixed, but not work.

Vladimir N. Shilov преди 1 година
родител
ревизия
f9753fc84a
променени са 2 файла, в които са добавени 14 реда и са изтрити 16 реда
  1. 4 4
      lib/main.h
  2. 10 12
      main.c

+ 4 - 4
lib/main.h

@@ -28,14 +28,14 @@
 #define ONEWIRE1_PORT           GPIOB
 #define ONEWIRE1_PIN            9
 #define ONEWIRE1_PWM_DRIVER     PWMD4
-#define ONEWIRE1_MASTER_CHANNEL 4
-#define ONEWIRE1_SAMPLE_CHANNEL 3
+#define ONEWIRE1_MASTER_CHANNEL 3
+#define ONEWIRE1_SAMPLE_CHANNEL 4
 
 #define ONEWIRE2_PORT           GPIOB
 #define ONEWIRE2_PIN            8
 #define ONEWIRE2_PWM_DRIVER     PWMD4
-#define ONEWIRE2_MASTER_CHANNEL 3
-#define ONEWIRE2_SAMPLE_CHANNEL 4
+#define ONEWIRE2_MASTER_CHANNEL 4
+#define ONEWIRE2_SAMPLE_CHANNEL 3
 
 #define ONWIRE_CHANNELS_NUM     2
 #define ONEWIRE_PAD_MODE_IDLE   PAL_MODE_INPUT

+ 10 - 12
main.c

@@ -30,8 +30,8 @@
  * Provate variables.
  */
 onewired_t owdc[ONWIRE_CHANNELS_NUM] = {
-  {0, 0, onewire_OK, &ow_cfg1},
-  {0, 0, onewire_OK, &ow_cfg2}
+  {0, 0, onewire_No_Dev, &ow_cfg1},
+  {0, 0, onewire_No_Dev, &ow_cfg2}
 };
 
 /*
@@ -99,32 +99,30 @@ int main(void) {
    */
   ST7735_Init();
   lcd_MainScreen();
-  chThdSleepMilliseconds(2000);
+  chThdSleepMilliseconds(1000);
   lcd_ClearMain();
 
   /*
    * Normal main() thread activity.
    */
   int32_t t;
-  int a, b, n;
+  int a, b;
 
   ST7735_WriteString(0, LCD_LINE_1, "OneWire1 search...", LiberM_7x10, Blue, Black);
   onewireMeasure(&owdc[ow1]);
-  n = onewireGetDevicesNum(&owdc[ow1]);
-  chsnprintf(buf, 22, "Found %d device[s]", n);
+  chsnprintf(buf, 22, "Found1 %d device[s]", owdc[ow1].dev_on_bus);
   ST7735_WriteString(0, LCD_LINE_1, buf, LiberM_7x10, Cyan, Black);
 
   ST7735_WriteString(0, LCD_LINE_2, "OneWire2 search...", LiberM_7x10, Blue, Black);
   onewireMeasure(&owdc[ow2]);
-  n = onewireGetDevicesNum(&owdc[ow2]);
-  chsnprintf(buf, 22, "Found %d device[s]", n);
-  ST7735_WriteString(0, LCD_LINE_1, buf, LiberM_7x10, Cyan, Black);
+  chsnprintf(buf, 22, "Found2 %d device[s]", owdc[ow2].dev_on_bus);
+  ST7735_WriteString(0, LCD_LINE_2, buf, LiberM_7x10, Cyan, Black);
 
   chThdSleepMilliseconds(1000);
   while (true) {
     onewireMeasure(&owdc[ow1]);
     if (owdc[ow1].err_code == onewire_OK) {
-      t = onewireGetTemperature(&owdc[ow1]);
+      t = owdc[ow1].temperature;
       t += 50;
       t /= 100;
       a = t / 10; b = t % 10;
@@ -135,9 +133,9 @@ int main(void) {
       ST7735_WriteString(0, LCD_LINE_1, buf, LiberM_7x10, Red, Black);
     }
 
-    onewireMeasure(&owdc[ow1]);
+    onewireMeasure(&owdc[ow2]);
     if (owdc[ow2].err_code == onewire_OK) {
-      t = onewireGetTemperature(&owdc[ow2]);
+      t = owdc[ow2].temperature;
       t += 50;
       t /= 100;
       a = t / 10; b = t % 10;