WXK
2023-09-15 671f59b69396b30ee80c3ddb57e4cd11b979d642
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */
/* USER CODE END Header */
 
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H
 
#ifdef __cplusplus
extern "C" {
#endif
 
/* Includes ------------------------------------------------------------------*/
#include "stm32l0xx_hal.h"
 
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "Usart.h"
#include "serial_at_cmd_app.h"
#include "led.h"    
#include "dw_app.h"
#include "global_param.h"
/* USER CODE END Includes */
 
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
extern SPI_HandleTypeDef hspi1;
extern UART_HandleTypeDef huart1;
extern uint8_t g_start_send_flag,bat_percent,group_id;
extern ADC_HandleTypeDef hadc;
extern LPTIM_HandleTypeDef hlptim1;
extern uint16_t lastpoll_count,interval_count,slot_startcount,tag_frequency,tyncpoll_time,waitusart_timer;
typedef uint32_t  u32;
typedef uint16_t u16;
typedef uint8_t  u8;
extern uint16_t slottime,max_slotpos,current_slotnum;
void SetNextPollTime(u16 time);
void MX_ADC_Init(void);
void MX_ADC_DeInit(void);
/* USER CODE END ET */
 
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
#define LPTIMER_LSB 30.518 //1 puls=30.518us
#define LPTIMER_1S_COUNT 32767
#define USART_KEEPWAKE_TIME 2
#define KEY_KEEPRESET_TIME 5
/* USER CODE END EC */
 
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
 
/* USER CODE END EM */
 
/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);
 
/* USER CODE BEGIN EFP */
 
/* USER CODE END EFP */
 
/* Private defines -----------------------------------------------------------*/
#define BAT_MEAS_Pin GPIO_PIN_1
#define BAT_MEAS_GPIO_Port GPIOA
#define SCL_Pin GPIO_PIN_2
#define SCL_GPIO_Port GPIOA
#define SDA_Pin GPIO_PIN_3
#define SDA_GPIO_Port GPIOA
#define SPI_CS_Pin GPIO_PIN_4
#define SPI_CS_GPIO_Port GPIOA
#define BAT_MEAS_GND_Pin GPIO_PIN_0
#define BAT_MEAS_GND_GPIO_Port GPIOB
#define USER_KEY_Pin GPIO_PIN_1
#define USER_KEY_GPIO_Port GPIOB
#define USER_KEY_EXTI_IRQn EXTI0_1_IRQn
#define INPUT_5V_Pin GPIO_PIN_11
#define INPUT_5V_GPIO_Port GPIOB
#define LED1_G_Pin GPIO_PIN_12
#define LED1_G_GPIO_Port GPIOB
#define LED1_R_Pin GPIO_PIN_13
#define LED1_R_GPIO_Port GPIOB
#define DW_WKUP_Pin GPIO_PIN_8
#define DW_WKUP_GPIO_Port GPIOA
#define RADIO_DIO1_Pin GPIO_PIN_11
#define RADIO_DIO1_GPIO_Port GPIOA
#define RADIO_DIO1_EXTI_IRQn EXTI4_15_IRQn
#define DW_CTRL_Pin GPIO_PIN_12
#define DW_CTRL_GPIO_Port GPIOA
#define LED2_G_Pin GPIO_PIN_15
#define LED2_G_GPIO_Port GPIOA
#define LED2_R_Pin GPIO_PIN_3
#define LED2_R_GPIO_Port GPIOB
#define RADIO_BUSY_Pin GPIO_PIN_4
#define RADIO_BUSY_GPIO_Port GPIOB
#define RADIO_nRESET_Pin GPIO_PIN_5
#define RADIO_nRESET_GPIO_Port GPIOB
#define RADIO_NSS_Pin GPIO_PIN_6
#define RADIO_NSS_GPIO_Port GPIOB
#define PWR_ON_Pin GPIO_PIN_7
#define PWR_ON_GPIO_Port GPIOB
#define PWR_CTL_Pin GPIO_PIN_9
#define PWR_CTL_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
#define GET_IMUINT         HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0)
#define GET_USERKEY     HAL_GPIO_ReadPin(USER_KEY_GPIO_Port,USER_KEY_Pin)
#define STATIONARY_TIME 3
 
 
#define RADIO_SCK_Pin GPIO_PIN_5
#define RADIO_SCK_GPIO_Port GPIOA
#define RADIO_MISO_Pin GPIO_PIN_6
#define RADIO_MISO_GPIO_Port GPIOA
#define RADIO_MOSI_Pin GPIO_PIN_7
#define RADIO_MOSI_GPIO_Port GPIOA
#define OUT1_Pin GPIO_PIN_12
#define OUT1_GPIO_Port GPIOB
#define LED1_Pin GPIO_PIN_13
#define LED1_GPIO_Port GPIOB
 
/* USER CODE END Private defines */
 
#ifdef __cplusplus
}
#endif
 
#endif /* __MAIN_H */
 
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/