Subversion Repositories DashDisplay

Rev

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