Subversion Repositories EDIS_Ignition

Rev

Rev 10 | Rev 12 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10 Rev 11
Line 17... Line 17...
17
 */
17
 */
18
/* USER CODE END Header */
18
/* USER CODE END Header */
19
/* Includes ------------------------------------------------------------------*/
19
/* Includes ------------------------------------------------------------------*/
20
#include "main.h"
20
#include "main.h"
21
 
21
 
22
 
-
 
23
 
-
 
24
/* Private includes ----------------------------------------------------------*/
22
/* Private includes ----------------------------------------------------------*/
25
/* USER CODE BEGIN Includes */
23
/* USER CODE BEGIN Includes */
26
#include "display.h"
24
#include "display.h"
27
#include "bmp280driver.h"
25
#include "bmp280driver.h"
28
#include "libMisc/fixI2C.h"
26
#include "libMisc/fixI2C.h"
Line 42... Line 40...
42
/* USER CODE BEGIN PD */
40
/* USER CODE BEGIN PD */
43
/* USER CODE END PD */
41
/* USER CODE END PD */
44
 
42
 
45
/* Private macro -------------------------------------------------------------*/
43
/* Private macro -------------------------------------------------------------*/
46
/* USER CODE BEGIN PM */
44
/* USER CODE BEGIN PM */
47
 
-
 
-
 
45
#undef TEST_CODE
48
/* USER CODE END PM */
46
/* USER CODE END PM */
49
 
47
 
50
/* Private variables ---------------------------------------------------------*/
48
/* Private variables ---------------------------------------------------------*/
51
CAN_HandleTypeDef hcan;
49
CAN_HandleTypeDef hcan;
52
 
50
 
Line 105... Line 103...
105
  sendInfo(&uc2, &info);
103
  sendInfo(&uc2, &info);
106
 
104
 
107
  ConvToPLXInstance(0, &info);
105
  ConvToPLXInstance(0, &info);
108
  ConvToPLXAddr(PLX_Timing, &info);
106
  ConvToPLXAddr(PLX_Timing, &info);
109
  ConvToPLXReading(ConveriMFDData2Raw(PLX_Timing, 0, timing / TIMING_SCALE), &info);
107
  ConvToPLXReading(ConveriMFDData2Raw(PLX_Timing, 0, timing / TIMING_SCALE), &info);
110
  sendInfo(&uc2, &info );
108
  sendInfo(&uc2, &info);
111
}
109
}
112
 
110
 
113
void triggerSAW()
111
void triggerSAW()
114
{
112
{
115
  // trigger SAW timer, timer 1##pragma endregion
113
  // trigger SAW timer, timer 1##pragma endregion
Line 119... Line 117...
119
 
117
 
120
/* USER CODE END PFP */
118
/* USER CODE END PFP */
121
 
119
 
122
/* Private user code ---------------------------------------------------------*/
120
/* Private user code ---------------------------------------------------------*/
123
/* USER CODE BEGIN 0 */
121
/* USER CODE BEGIN 0 */
-
 
122
void watchdogWrite()
-
 
123
{
-
 
124
  HAL_IWDG_Refresh(&hiwdg);
-
 
125
}
124
 
126
 
125
/* USER CODE END 0 */
127
/* USER CODE END 0 */
126
 
128
 
127
/**
129
/**
128
 * @brief  The application entry point.
130
 * @brief  The application entry point.
Line 195... Line 197...
195
 
197
 
196
  // used to store data
198
  // used to store data
197
  PLX_SensorInfo info;
199
  PLX_SensorInfo info;
198
  int infoCount = -1;
200
  int infoCount = -1;
199
 
201
 
200
  loadTimingInfoFromNvram();
202
  loadTimingInfoFromNvram();
201
 
203
 
202
  // HAL_IWDG_Init(&hiwdg);
204
  // HAL_IWDG_Init(&hiwdg);
203
  /* USER CODE END 2 */
205
  /* USER CODE END 2 */
204
 
206
 
205
  /* Infinite loop */
207
  /* Infinite loop */
Line 244... Line 246...
244
      if (rslt == 0)
246
      if (rslt == 0)
245
      {
247
      {
246
        uint8_t rslt2 = bmp280_get_comp_pres_32bit(&comp_pres, ucomp_data.uncomp_press, &bmp);
248
        uint8_t rslt2 = bmp280_get_comp_pres_32bit(&comp_pres, ucomp_data.uncomp_press, &bmp);
247
 
249
 
248
        uint8_t rslt3 = bmp280_get_comp_temp_32bit(&comp_temp, ucomp_data.uncomp_temp, &bmp);
250
        uint8_t rslt3 = bmp280_get_comp_temp_32bit(&comp_temp, ucomp_data.uncomp_temp, &bmp);
-
 
251
 
-
 
252
#if defined TEST_CODE
-
 
253
        comp_pres = 30000;
-
 
254
        comp_temp = 4000;
-
 
255
#endif
249
        if (rslt2 == 0 && rslt3 == 0)
256
        if (rslt2 == 0 && rslt3 == 0)
250
          cc_feed_env(comp_pres, comp_temp);
257
          cc_feed_env(comp_pres, comp_temp);
251
      }
258
      }
252
 
259
 
253
      // compute RPM value, feed to display
260
      // compute RPM value, feed to display
-
 
261
#if defined TEST_CODE
-
 
262
      int rpm = 2000;
254
 
263
#else
255
      int rpm = CalculateRPM();
264
      int rpm = CalculateRPM();
-
 
265
#endif 
256
      if (rpm > 0)
266
      if (rpm > 0)
257
      {
267
      {
258
        cc_feed_rpm(rpm);
268
        cc_feed_rpm(rpm);
259
        // compute timing value, feed to display
269
        // compute timing value, feed to display
260
        timing = mapTiming(rpm, 1000 - comp_pres / 100);
270
        timing = mapTiming(rpm, 1000 - comp_pres / 100);
Line 321... Line 331...
321
    }
331
    }
322
 
332
 
323
    /* USER CODE END WHILE */
333
    /* USER CODE END WHILE */
324
 
334
 
325
    /* USER CODE BEGIN 3 */
335
    /* USER CODE BEGIN 3 */
326
    HAL_IWDG_Refresh(&hiwdg);
336
    watchdogWrite();
327
 
-
 
328
 
-
 
329
 
-
 
330
// todo occasionally     saveTimingInfoToNvram(); 
-
 
331
   
-
 
332
 
-
 
333
 
337
 
-
 
338
    // todo occasionally     saveTimingInfoToNvram();
334
  }
339
  }
335
  /* USER CODE END 3 */
340
  /* USER CODE END 3 */
336
}
341
}
337
 
342
 
338
/**
343
/**