Subversion Repositories DashDisplay

Rev

Rev 74 | Rev 76 | Go to most recent revision | 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) 2020 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. {
  29. #endif
  30.  
  31. /* Includes ------------------------------------------------------------------*/
  32. #include "stm32l1xx_hal.h"
  33.  
  34. /* Private includes ----------------------------------------------------------*/
  35. /* USER CODE BEGIN Includes */
  36. #include "display.h"
  37. #include "nvram.h"
  38.  
  39. #include "libPLX/plx.h"
  40.  
  41.   /* USER CODE END Includes */
  42.  
  43.   /* Exported types ------------------------------------------------------------*/
  44.   /* USER CODE BEGIN ET */
  45.  
  46. #define TX_USART_BUFF_SIZ 512
  47. #define RX_USART_BUFF_SIZ 512
  48.  
  49. #define MAXRDG 32
  50.  
  51.   extern const int DialTimeout;
  52.  
  53.   /// \brief Sensor information as read in from serial port, and expressed as structures.
  54.   typedef union
  55.   {
  56.     PLX_SensorInfo Sensor[MAXRDG];
  57.     char Bytes[MAXRDG * sizeof(PLX_SensorInfo)];
  58.   } data_t;
  59.  
  60.   typedef struct
  61.   {
  62.     enum PLX_Observations Obs; ///<  Observation type
  63.     int8_t Instance;              ///< Observation instance
  64.   } uniqueObs_t;
  65.  
  66.   typedef struct
  67.   {
  68.     int Max;
  69.     int Min;
  70.     uniqueObs_t observation; //< observation identifier
  71.     uint16_t data;           ///< Data value
  72.     uint32_t sum;            ///< Sum of readings since last logged
  73.     uint32_t lastUpdated;    ///< Time of last update
  74.     uint16_t count;          ///< Count of readings since last logged .
  75.     uint8_t updated;         ///< Set when updated
  76.   } info_t;
  77.  
  78.   typedef struct
  79.   {
  80.     int8_t knobPos;             ///< User interface knob position
  81.     uniqueObs_t OldObservation; ///< Previous item observed
  82.     int16_t dial0;              ///< Display needle position 0
  83.     int16_t dial1;              ///< Display needle position 1
  84.     uint16_t dial_timer;        ///< Time of last NVRAM store
  85.   } context_t;
  86.  
  87.   extern uniqueObs_t const nullObs;
  88.  
  89.   extern context_t const nullContext;  
  90.  
  91.   extern info_t Info[MAXRDG];
  92.  
  93.   extern context_t contexts[MAX_DISPLAYS];
  94.  
  95.   // declarations need to be visible elsewhere
  96.   extern SPI_HandleTypeDef hspi1;
  97.  
  98.   extern UART_HandleTypeDef huart1;
  99.   extern UART_HandleTypeDef huart2;
  100.   extern UART_HandleTypeDef huart3;
  101.  
  102.   extern TIM_HandleTypeDef htim3;
  103.   extern TIM_HandleTypeDef htim9;
  104.  
  105.   /* USER CODE END ET */
  106.  
  107.   /* Exported constants --------------------------------------------------------*/
  108.   /* USER CODE BEGIN EC */
  109.  
  110.   /* USER CODE END EC */
  111.  
  112.   /* Exported macro ------------------------------------------------------------*/
  113.   /* USER CODE BEGIN EM */
  114.  
  115.   /* USER CODE END EM */
  116.  
  117.   /* Exported functions prototypes ---------------------------------------------*/
  118.   void Error_Handler(void);
  119.  
  120.   /* USER CODE BEGIN EFP */
  121.   extern context_t context[MAX_DISPLAYS];
  122.  
  123.   extern uint8_t btConnected();
  124.  
  125.   extern uint8_t isValid(int i);
  126. /* USER CODE END EFP */
  127.  
  128. /* Private defines -----------------------------------------------------------*/
  129. #define SPI_NSS1_Pin GPIO_PIN_4
  130. #define SPI_NSS1_GPIO_Port GPIOA
  131. #define SPI_SCK_Pin GPIO_PIN_5
  132. #define SPI_SCK_GPIO_Port GPIOA
  133. #define SPI_CD_Pin GPIO_PIN_6
  134. #define SPI_CD_GPIO_Port GPIOA
  135. #define SPI_MOSI_Pin GPIO_PIN_7
  136. #define SPI_MOSI_GPIO_Port GPIOA
  137. #define SPI_RESET_Pin GPIO_PIN_4
  138. #define SPI_RESET_GPIO_Port GPIOC
  139. #define SPI_NSS2_Pin GPIO_PIN_5
  140. #define SPI_NSS2_GPIO_Port GPIOC
  141. #define BT_STATE_Pin GPIO_PIN_2
  142. #define BT_STATE_GPIO_Port GPIOB
  143. #define SW1_PUSH_Pin GPIO_PIN_12
  144. #define SW1_PUSH_GPIO_Port GPIOB
  145. #define SW1_I_Pin GPIO_PIN_13
  146. #define SW1_I_GPIO_Port GPIOB
  147. #define SW1_Q_Pin GPIO_PIN_14
  148. #define SW1_Q_GPIO_Port GPIOB
  149. #define SW2_PUSH_Pin GPIO_PIN_15
  150. #define SW2_PUSH_GPIO_Port GPIOB
  151. #define SW2_I_Pin GPIO_PIN_6
  152. #define SW2_I_GPIO_Port GPIOC
  153. #define SW2_Q_Pin GPIO_PIN_7
  154. #define SW2_Q_GPIO_Port GPIOC
  155. #define POWER_LATCH_Pin GPIO_PIN_8
  156. #define POWER_LATCH_GPIO_Port GPIOC
  157. #define IGNITION_Pin GPIO_PIN_9
  158. #define IGNITION_GPIO_Port GPIOC
  159. #define BT_BUTTON_Pin GPIO_PIN_8
  160. #define BT_BUTTON_GPIO_Port GPIOA
  161. #define PLX_TX_Pin GPIO_PIN_9
  162. #define PLX_TX_GPIO_Port GPIOA
  163. #define PLX_RX_Pin GPIO_PIN_10
  164. #define PLX_RX_GPIO_Port GPIOA
  165. #define BT_RESET_Pin GPIO_PIN_11
  166. #define BT_RESET_GPIO_Port GPIOA
  167. #define USB_PWR_Pin GPIO_PIN_12
  168. #define USB_PWR_GPIO_Port GPIOC
  169.   /* USER CODE BEGIN Private defines */
  170.  
  171.   /* USER CODE END Private defines */
  172.  
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176.  
  177. #endif /* __MAIN_H */
  178.