WXK
2023-08-30 72d5e74bf1969d0a1429a14a4f409eddf938d66d
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*******************************************************************************
 * File Name         : BSP.c
 * Description       :
 * Created on        : 2018Äê7ÔÂ23ÈÕ
 * Author            : ¶Å¼ü
 *******************************************************************************/
 
/*******************************************************************************
 *                              Include Files                                  *
 *******************************************************************************/
#include "BSP.h"
#include "stm32l0xx_hal.h"
#include "HIDO_Debug.h"
#include "Uart.h"
#include "Shell.h"
//#include "DBG.h"
#include "RTC.h"
#include "SPI.h"
#include "LED.h"
#include "Beep.h"
#include "Key.h"
#include "Led.h"
#include "ADC.h"
#include "Power.h"
#include "GPS.h"
#include "Lora.h"
#include "Battery.h"
 
/*******************************************************************************
 *                                  Macro                                      *
 *******************************************************************************/
 
/*******************************************************************************
 *                             Type Definition                                 *
 *******************************************************************************/
 
/*******************************************************************************
 *                             Global Variable                                 *
 *******************************************************************************/
 
/*******************************************************************************
 *                             Local Variable                                  *
 *******************************************************************************/
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
extern UART_HandleTypeDef hlpuart1;
extern TIM_HandleTypeDef htim21;
//extern RTC_HandleTypeDef hrtc;
 
/*******************************************************************************
 *                        Local Function Declaration                           *
 *******************************************************************************/
 
/*******************************************************************************
 *                             Local Function                                  *
 *******************************************************************************/
/*******************************************************************************
 * Function Name     : BSP_ResourceInit
 * Description       :
 * Input             :
 * Output            :
 * Return            :
 * Author            : ¶Å¼ü
 * Modified Date:    : 2018Äê7ÔÂ23ÈÕ
 *******************************************************************************/
static HIDO_INT32 BSP_ResourceInit(void)
{
    Power_PinRegister(POWER_PIN_GPS_LORA, GPIOA, GPIO_PIN_8);
 
    Uart_Register(UART_ID_DBG, &huart1);
    Uart_Register(UART_ID_GPS, &huart2);
     Uart_Register(UART_ID_LORA, &hlpuart1);
 
//    Key_PinRegister(KEY_ID_RIGHT, GPIOB, GPIO_PIN_0, GPIO_PIN_0);
//    Key_PinRegister(KEY_ID_LEFT, GPIOC, GPIO_PIN_4, 0);
 
//    Led_PinRegister(LED_ID_0, GPIOB, GPIO_PIN_4, LED_ACTIVE_STATE_SET);
//    Led_PinRegister(LED_ID_1, GPIOA, GPIO_PIN_4, LED_ACTIVE_STATE_RESET);
//    Led_PinRegister(LED_ID_2, GPIOA, GPIO_PIN_5, LED_ACTIVE_STATE_RESET);
//    Led_PinRegister(LED_ID_3, GPIOA, GPIO_PIN_11, LED_ACTIVE_STATE_RESET);
//    Led_PinRegister(LED_ID_4, GPIOA, GPIO_PIN_12, LED_ACTIVE_STATE_RESET);
    
    Lora_PinRegister(LORA_PIN_RESET, GPIOB, GPIO_PIN_14);
    Lora_PinRegister(LORA_PIN_SLEEP, GPIOB, GPIO_PIN_2);
    Lora_PinRegister(LORA_PIN_RUN, GPIOB, GPIO_PIN_12);
 
//        GPIO_InitTypeDef GPIO_InitStruct = {0};
//  GPIO_InitStruct.Pin = GPIO_PIN_12;
//  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
//  GPIO_InitStruct.Pull = GPIO_NOPULL;
//  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
//  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
        
//  GPIO_InitStruct.Pin = GPIO_PIN_14;
//  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
//  GPIO_InitStruct.Pull = GPIO_NOPULL;
//  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
//  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
            
    GPS_PinRegister(GPS_PIN_REST, GPIOA, GPIO_PIN_4);
    Beep_TimerRegister(&htim21, TIM_CHANNEL_1);
    Battery_PinRegister(BATTERY_PIN_MEARS_CTRL,  GPIOA, GPIO_PIN_11);
//    RTC_Init(&hrtc);
 
    return HIDO_OK;
}
 
/*******************************************************************************
 *                             Global Function                                 *
 *******************************************************************************/
/*******************************************************************************
 * Function Name     : HAL_UART_ErrorCallback
 * Description       :
 * Input             :
 * Output            :
 * Return            :
 * Author            : ¶Å¼ü
 * Modified Date:    : 2018Äê7ÔÂ23ÈÕ
 *******************************************************************************/
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
{
    Uart_RxErrorFromISR(huart);
}
 
/*******************************************************************************
 * Function Name     : HAL_UART_TxCpltCallback
 * Description       :
 * Input             :
 * Output            :
 * Return            :
 * Author            : ¶Å¼ü
 * Modified Date:    : 2018Äê7ÔÂ23ÈÕ
 *******************************************************************************/
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
    Uart_TxOverFromISR(huart);
}
 
/*******************************************************************************
 * Function Name     : HAL_UART_RxCpltCallback
 * Description       :
 * Input             :
 * Output            :
 * Return            :
 * Author            : ¶Å¼ü
 * Modified Date:    : 2018Äê7ÔÂ23ÈÕ
 *******************************************************************************/
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
    Uart_RxOverFromISR(huart);
}
 
#if 0
/*******************************************************************************
 * Function Name     : HAL_RTC_AlarmAEventCallback
 * Description       :
 * Input             :
 * Output            :
 * Return            :
 * Author            : ¶Å¼ü
 * Modified Date:    : 2018Äê7ÔÂ23ÈÕ
 *******************************************************************************/
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
{
#ifdef __APP_CODE__
    HIDO_Debug("HAL_RTC_AlarmAEventCallback\r\n");
#endif
}
#endif 
 
/*******************************************************************************
 * Function Name     : HAL_TIM_PeriodElapsedCallback
 * Description       :
 * Input             :
 * Output            :
 * Return            :
 * Author            : ¶Å¼ü
 * Modified Date:    : 2018Äê7ÔÂ23ÈÕ
 *******************************************************************************/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
    //if(htim == &htim8)
    {
//        Key_10MsISR();
//        Beep_10MsISR();
//        Led_10MsISR();
//        VibratingMotor_10MsISR();
    }
}
 
/*******************************************************************************
 * Function Name     : BSP_Init
 * Description       :
 * Input             :
 * Output            :
 * Return            :
 * Author            : ¶Å¼ü
 * Modified Date:    : 2018Äê7ÔÂ23ÈÕ
 *******************************************************************************/
HIDO_INT32 BSP_Init(void)
{
    BSP_ResourceInit();
    
    return HIDO_OK;
}