Subversion Repositories DashDisplay

Rev

Rev 70 | Rev 75 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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