/* 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) 2020 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 "stm32l1xx_hal.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "display.h"
#include "nvram.h"
#include "libPLX/plx.h"
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
#define TX_USART_BUFF_SIZ 512
#define RX_USART_BUFF_SIZ 512
#define MAXRDG 32
extern const int DialTimeout;
/// \brief Sensor information as read in from serial port, and expressed as structures.
typedef union
{
PLX_SensorInfo Sensor[MAXRDG];
char Bytes[MAXRDG * sizeof(PLX_SensorInfo)];
} data_t;
typedef struct
{
int Max;
int Min;
enum PLX_Observations observation;
uint8_t instance;
uint16_t data;
uint32_t sum; //< Sum of readings since last logged
uint32_t lastUpdated; ///< Time of last update
uint16_t count; //< Count of readings since last logged .
uint8_t updated; ///< Set when updated
} info_t;
typedef struct
{
int8_t knobPos; ///< User interface knob position
int16_t OldObservation;
int16_t OldObservationIndex;
int16_t dial0; ///< Display needle position 0
int16_t dial1; ///< Display needle position 1
uint16_t dial_timer;
// nvram_info_t * info; ///< currently selected item
} context_t;
extern info_t Info[MAXRDG];
extern context_t contexts[MAX_DISPLAYS];
extern int PLXItems;
// declarations need to be visible elsewhere
extern SPI_HandleTypeDef hspi1;
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
extern UART_HandleTypeDef huart3;
extern TIM_HandleTypeDef htim3;
extern TIM_HandleTypeDef htim9;
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
/* USER CODE END EM */
/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);
/* USER CODE BEGIN EFP */
extern context_t context[MAX_DISPLAYS];
extern uint8_t btConnected();
/* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/
#define SPI_NSS1_Pin GPIO_PIN_4
#define SPI_NSS1_GPIO_Port GPIOA
#define SPI_SCK_Pin GPIO_PIN_5
#define SPI_SCK_GPIO_Port GPIOA
#define SPI_CD_Pin GPIO_PIN_6
#define SPI_CD_GPIO_Port GPIOA
#define SPI_MOSI_Pin GPIO_PIN_7
#define SPI_MOSI_GPIO_Port GPIOA
#define SPI_RESET_Pin GPIO_PIN_4
#define SPI_RESET_GPIO_Port GPIOC
#define SPI_NSS2_Pin GPIO_PIN_5
#define SPI_NSS2_GPIO_Port GPIOC
#define BT_STATE_Pin GPIO_PIN_2
#define BT_STATE_GPIO_Port GPIOB
#define SW1_PUSH_Pin GPIO_PIN_12
#define SW1_PUSH_GPIO_Port GPIOB
#define SW1_I_Pin GPIO_PIN_13
#define SW1_I_GPIO_Port GPIOB
#define SW1_Q_Pin GPIO_PIN_14
#define SW1_Q_GPIO_Port GPIOB
#define SW2_PUSH_Pin GPIO_PIN_15
#define SW2_PUSH_GPIO_Port GPIOB
#define SW2_I_Pin GPIO_PIN_6
#define SW2_I_GPIO_Port GPIOC
#define SW2_Q_Pin GPIO_PIN_7
#define SW2_Q_GPIO_Port GPIOC
#define POWER_LATCH_Pin GPIO_PIN_8
#define POWER_LATCH_GPIO_Port GPIOC
#define IGNITION_Pin GPIO_PIN_9
#define IGNITION_GPIO_Port GPIOC
#define BT_BUTTON_Pin GPIO_PIN_8
#define BT_BUTTON_GPIO_Port GPIOA
#define PLX_TX_Pin GPIO_PIN_9
#define PLX_TX_GPIO_Port GPIOA
#define PLX_RX_Pin GPIO_PIN_10
#define PLX_RX_GPIO_Port GPIOA
#define USB_PWR_Pin GPIO_PIN_12
#define USB_PWR_GPIO_Port GPIOC
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H */