
/* 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>&copy; 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 "libPLX/plx.h"

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
#define MAXRDG 32

extern  const int DialTimeout;


  typedef struct
  {
  	int OldObservation;
  	int OldObservationIndex;
  	int16_t dial0;
  	int16_t dial1;
  	int16_t dial_timer;
  } context_t;

  typedef union
  {
  	PLX_SensorInfo Sensor[MAXRDG];
  	char Bytes[MAXRDG * sizeof(PLX_SensorInfo)];
  } data_t;

extern context_t contexts[MAX_DISPLAYS];

extern data_t Data;

extern uint16_t dial_nvram[MAX_DISPLAYS];

extern int Max[MAXRDG];
extern int Min[MAXRDG];
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];

/* 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 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 */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
