/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "main_export.h"
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
// scale for filtered samples
#define Scale 1024.0
// USART buffer sizes
#define TX_USART_BUFF_SIZ 512
#define RX_USART_BUFF_SIZ 512
// Number of SPI temperature sensors
#define NUM_SPI_TEMP_SENS 4
#define TEMP_CORR 3 // number of temperature readings that must match before being believed
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
#if defined __cplusplus
extern "C"
{
#endif
// code required to use libIgnTiming/rpm.h
extern unsigned char volatile periodPulse;
extern unsigned char volatile tim3triggered;
extern void triggerTim3(void);
// code required to use libPlx/commsLib.h
extern void libPLXcallbackResetSerialTimeout();
extern void libPLXcallbackSendUserData();
// we are using timer 2 for the RPM counter
#define RPMTIMER 2
// code to trigger timer 3 on rising edge of contact breaker pulse
#define AUXILIARY_HIGH \
if (tim3triggered == 0) \
{ \
tim3triggered = 1; \
triggerTim3(); \
}
// e.g indicate that there are contact breaker closures
// code to trigger indicating falling edge of contact breaker pulse
#define AUXILIARY_LOW periodPulse = 0;
#if defined __cplusplus
}
#endif
/* USER CODE END EM */
/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);
/* USER CODE BEGIN EFP */
// reset temperature SPI system
extern void resetTempCS(void);
// step onto next temperature SPI value
extern void nextTempCS(void);
extern void AddTempReading(uint16_t reading, int channel);
/* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/
#define LED_Blink_Pin GPIO_PIN_13
#define LED_Blink_GPIO_Port GPIOC
#define V_Batt1_Pin GPIO_PIN_0
#define V_Batt1_GPIO_Port GPIOA
#define V_Batt2_Pin GPIO_PIN_1
#define V_Batt2_GPIO_Port GPIOA
#define V_Map_Pin GPIO_PIN_2
#define V_Map_GPIO_Port GPIOA
#define V_Oil_Pin GPIO_PIN_3
#define V_Oil_GPIO_Port GPIOA
#define V_Oil_Temp_Pin GPIO_PIN_4
#define V_Oil_Temp_GPIO_Port GPIOA
#define SPI1_SCK_Pin GPIO_PIN_5
#define SPI1_SCK_GPIO_Port GPIOA
#define SPI1_MISO_Pin GPIO_PIN_6
#define SPI1_MISO_GPIO_Port GPIOA
#define SPI1_MOSI_Pin GPIO_PIN_7
#define SPI1_MOSI_GPIO_Port GPIOA
#define SPI_CS_Clk_Pin GPIO_PIN_0
#define SPI_CS_Clk_GPIO_Port GPIOB
#define SPI_CS_D_Pin GPIO_PIN_1
#define SPI_CS_D_GPIO_Port GPIOB
#define Uart1_TX_Pin GPIO_PIN_9
#define Uart1_TX_GPIO_Port GPIOA
#define Uart1_RX_Pin GPIO_PIN_10
#define Uart1_RX_GPIO_Port GPIOA
#define CB_Pulse_Pin GPIO_PIN_15
#define CB_Pulse_GPIO_Port GPIOA
#define STARTER_ON_Pin GPIO_PIN_3
#define STARTER_ON_GPIO_Port GPIOB
#define ENA_AUX_5V_Pin GPIO_PIN_7
#define ENA_AUX_5V_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H */