Subversion Repositories DashDisplay

Rev

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