Subversion Repositories EngineBay2

Rev

Rev 53 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /* USER CODE BEGIN Header */
  2. /**
  3.  ******************************************************************************
  4.  * @file           : main.h
  5.  * @brief          : Header for main.c file.
  6.  *                   This file contains the common defines of the application.
  7.  ******************************************************************************
  8.  * @attention
  9.  *
  10.  * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  11.  * All rights reserved.</center></h2>
  12.  *
  13.  * This software component is licensed by ST under BSD 3-Clause license,
  14.  * the "License"; You may not use this file except in compliance with the
  15.  * License. You may obtain a copy of the License at:
  16.  *                        opensource.org/licenses/BSD-3-Clause
  17.  *
  18.  ******************************************************************************
  19.  */
  20. /* USER CODE END Header */
  21.  
  22. /* Define to prevent recursive inclusion -------------------------------------*/
  23. #ifndef __MAIN_H
  24. #define __MAIN_H
  25.  
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29.  
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "stm32f1xx_hal.h"
  32.  
  33. /* Private includes ----------------------------------------------------------*/
  34. /* USER CODE BEGIN Includes */
  35. #include "main_export.h"
  36. /* USER CODE END Includes */
  37.  
  38. /* Exported types ------------------------------------------------------------*/
  39. /* USER CODE BEGIN ET */
  40.  
  41. /* USER CODE END ET */
  42.  
  43. /* Exported constants --------------------------------------------------------*/
  44. /* USER CODE BEGIN EC */
  45.  
  46. // scale for filtered samples
  47. #define Scale 1024.0
  48. // USART buffer sizes
  49. #define TX_USART_BUFF_SIZ 512
  50.  
  51. #define RX_USART_BUFF_SIZ 512
  52.  
  53. // Number of SPI temperature sensors
  54. #define NUM_SPI_TEMP_SENS 4
  55. #define TEMP_CORR 3 // number of temperature readings that must match before being believed
  56. /* USER CODE END EC */
  57.  
  58. /* Exported macro ------------------------------------------------------------*/
  59. /* USER CODE BEGIN EM */
  60. #if defined __cplusplus
  61.   extern "C"
  62.   {
  63. #endif
  64.  
  65.     // code required to use libIgnTiming/rpm.h
  66.     extern unsigned char volatile periodPulse;
  67.  
  68.     extern unsigned char volatile tim3triggered;
  69.     extern void triggerTim3(void);
  70.  
  71.     // code required to use libPlx/commsLib.h
  72.  
  73.     extern void libPLXcallbackResetSerialTimeout();
  74.  
  75.     extern void libPLXcallbackSendUserData();
  76.  
  77. // we are using timer 2 for the RPM counter
  78. #define RPMTIMER 2
  79.  
  80. // code to trigger timer 3 on rising edge of contact breaker pulse
  81. #define AUXILIARY_HIGH    \
  82.   if (tim3triggered == 0) \
  83.   {                       \
  84.     tim3triggered = 1;    \
  85.     triggerTim3();        \
  86.   }
  87.  
  88. // e.g indicate that there are contact breaker closures
  89. // code to trigger indicating falling edge of contact breaker pulse
  90. #define AUXILIARY_LOW periodPulse = 0;
  91.  
  92. #if defined __cplusplus
  93.   }
  94. #endif
  95.  
  96. /* USER CODE END EM */
  97.  
  98. /* Exported functions prototypes ---------------------------------------------*/
  99. void Error_Handler(void);
  100.  
  101. /* USER CODE BEGIN EFP */
  102.   // reset temperature SPI system
  103.   extern void resetTempCS(void);
  104.   // step onto next temperature SPI value
  105.   extern void nextTempCS(void);
  106.  
  107.   extern void AddTempReading(uint16_t reading, int channel);
  108.  
  109. /* USER CODE END EFP */
  110.  
  111. /* Private defines -----------------------------------------------------------*/
  112. #define LED_Blink_Pin GPIO_PIN_13
  113. #define LED_Blink_GPIO_Port GPIOC
  114. #define V_Batt1_Pin GPIO_PIN_0
  115. #define V_Batt1_GPIO_Port GPIOA
  116. #define V_Batt2_Pin GPIO_PIN_1
  117. #define V_Batt2_GPIO_Port GPIOA
  118. #define V_Map_Pin GPIO_PIN_2
  119. #define V_Map_GPIO_Port GPIOA
  120. #define V_Oil_Pin GPIO_PIN_3
  121. #define V_Oil_GPIO_Port GPIOA
  122. #define V_Oil_Temp_Pin GPIO_PIN_4
  123. #define V_Oil_Temp_GPIO_Port GPIOA
  124. #define SPI1_SCK_Pin GPIO_PIN_5
  125. #define SPI1_SCK_GPIO_Port GPIOA
  126. #define SPI1_MISO_Pin GPIO_PIN_6
  127. #define SPI1_MISO_GPIO_Port GPIOA
  128. #define SPI1_MOSI_Pin GPIO_PIN_7
  129. #define SPI1_MOSI_GPIO_Port GPIOA
  130. #define SPI_CS_Clk_Pin GPIO_PIN_0
  131. #define SPI_CS_Clk_GPIO_Port GPIOB
  132. #define SPI_CS_D_Pin GPIO_PIN_1
  133. #define SPI_CS_D_GPIO_Port GPIOB
  134. #define Uart1_TX_Pin GPIO_PIN_9
  135. #define Uart1_TX_GPIO_Port GPIOA
  136. #define Uart1_RX_Pin GPIO_PIN_10
  137. #define Uart1_RX_GPIO_Port GPIOA
  138. #define CB_Pulse_Pin GPIO_PIN_15
  139. #define CB_Pulse_GPIO_Port GPIOA
  140. #define STARTER_ON_Pin GPIO_PIN_3
  141. #define STARTER_ON_GPIO_Port GPIOB
  142. #define ENA_AUX_5V_Pin GPIO_PIN_7
  143. #define ENA_AUX_5V_GPIO_Port GPIOB
  144.  
  145. /* USER CODE BEGIN Private defines */
  146.  
  147. /* USER CODE END Private defines */
  148.  
  149. #ifdef __cplusplus
  150. }
  151. #endif
  152.  
  153. #endif /* __MAIN_H */
  154.