Subversion Repositories DashDisplay

Rev

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