浏览代码

ADC 수정중 ...

PYJ 5 年之前
父节点
当前提交
4c65e78d12

文件差异内容过多而无法显示
+ 2 - 2
.mxproject


+ 2 - 0
Bluecell_Inc/uart.h

@@ -26,6 +26,8 @@ typedef struct  {
26
 } uart_hal_tx_type;
26
 } uart_hal_tx_type;
27
 
27
 
28
 extern UART_HandleTypeDef huart1;
28
 extern UART_HandleTypeDef huart1;
29
+extern UART_HandleTypeDef huart2;
30
+
29
 
31
 
30
 extern UARTQUEUE TerminalQueue;
32
 extern UARTQUEUE TerminalQueue;
31
 void PutDataToUartQueue(UART_HandleTypeDef *huart, uint8_t data);
33
 void PutDataToUartQueue(UART_HandleTypeDef *huart, uint8_t data);

+ 1 - 1
Bluecell_Src/Bluecell_operate.c

@@ -1714,7 +1714,7 @@ void ADC_Check(void){
1714
         bluecell_Currdatastatus.DET_UL4_IN_L 
1714
         bluecell_Currdatastatus.DET_UL4_IN_L 
1715
             = ((ADC3Ret[0] & 0x00FF) );
1715
             = ((ADC3Ret[0] & 0x00FF) );
1716
 
1716
 
1717
-#if 0 // PYJ.2020.04.26_BEGIN -- 
1717
+#if 1 // PYJ.2020.04.26_BEGIN -- 
1718
         ret = (ADC3Ret[0]) * Volt_Calc_val;
1718
         ret = (ADC3Ret[0]) * Volt_Calc_val;
1719
         printf("ADC3Ret[0] : %d        UL4 : %f\r\n",ADC3Ret[0],ret);
1719
         printf("ADC3Ret[0] : %d        UL4 : %f\r\n",ADC3Ret[0],ret);
1720
         ret = (ADC3Ret[1]) * Volt_Calc_val;
1720
         ret = (ADC3Ret[1]) * Volt_Calc_val;

+ 5 - 5
Bluecell_Src/uart.c

@@ -72,9 +72,9 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
72
 //       _Error_Handler(__FILE__, __LINE__);
72
 //       _Error_Handler(__FILE__, __LINE__);
73
 //    }
73
 //    }
74
     uart_buf[cnt++] = *(pQueue->Buffer + pQueue->tail); 
74
     uart_buf[cnt++] = *(pQueue->Buffer + pQueue->tail); 
75
-#ifdef DEBUG_PRINT
76
-    printf("%02x ",*(pQueue->Buffer + pQueue->tail)) ;
77
-#endif /* DEBUG_PRINT */
75
+//#ifdef DEBUG_PRINT
76
+//    printf("%02x ",*(pQueue->Buffer + pQueue->tail)) ;
77
+//#endif /* DEBUG_PRINT */
78
 
78
 
79
     pQueue->tail++;
79
     pQueue->tail++;
80
     if (pQueue->tail >= QUEUE_BUFFER_LENGTH) pQueue->tail = 0;
80
     if (pQueue->tail >= QUEUE_BUFFER_LENGTH) pQueue->tail = 0;
@@ -102,7 +102,7 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
102
 //        for(int i  = 0; i < cnt; i++)
102
 //        for(int i  = 0; i < cnt; i++)
103
 //            uart_buf[i] = 0;
103
 //            uart_buf[i] = 0;
104
         cnt = 0;
104
         cnt = 0;
105
-//        HAL_Delay(1);
105
+        HAL_Delay(1);
106
     }
106
     }
107
 
107
 
108
 }
108
 }
@@ -111,6 +111,6 @@ void Uart_Check(void){
111
 }
111
 }
112
 
112
 
113
 void Uart1_Data_Send(uint8_t* data,uint8_t size){
113
 void Uart1_Data_Send(uint8_t* data,uint8_t size){
114
-    HAL_UART_Transmit_DMA(&huart1, data,size); 
114
+    HAL_UART_Transmit_DMA(&hTerminal, data,size); 
115
 }
115
 }
116
 
116
 

+ 0 - 184
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_crc.h

@@ -1,184 +0,0 @@
1
-/**
2
-  ******************************************************************************
3
-  * @file    stm32f1xx_hal_crc.h
4
-  * @author  MCD Application Team
5
-  * @brief   Header file of CRC HAL module.
6
-  ******************************************************************************
7
-  * @attention
8
-  *
9
-  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
-  * All rights reserved.</center></h2>
11
-  *
12
-  * This software component is licensed by ST under BSD 3-Clause license,
13
-  * the "License"; You may not use this file except in compliance with the
14
-  * License. You may obtain a copy of the License at:
15
-  *                        opensource.org/licenses/BSD-3-Clause
16
-  *
17
-  ******************************************************************************
18
-  */
19
-
20
-/* Define to prevent recursive inclusion -------------------------------------*/
21
-#ifndef STM32F1xx_HAL_CRC_H
22
-#define STM32F1xx_HAL_CRC_H
23
-
24
-#ifdef __cplusplus
25
-extern "C" {
26
-#endif
27
-
28
-/* Includes ------------------------------------------------------------------*/
29
-#include "stm32f1xx_hal_def.h"
30
-
31
-/** @addtogroup STM32F1xx_HAL_Driver
32
-  * @{
33
-  */
34
-
35
-/** @addtogroup CRC
36
-  * @{
37
-  */
38
-
39
-/* Exported types ------------------------------------------------------------*/
40
-/** @defgroup CRC_Exported_Types CRC Exported Types
41
-  * @{
42
-  */
43
-
44
-/**
45
-  * @brief  CRC HAL State Structure definition
46
-  */
47
-typedef enum
48
-{
49
-  HAL_CRC_STATE_RESET     = 0x00U,  /*!< CRC not yet initialized or disabled */
50
-  HAL_CRC_STATE_READY     = 0x01U,  /*!< CRC initialized and ready for use   */
51
-  HAL_CRC_STATE_BUSY      = 0x02U,  /*!< CRC internal process is ongoing     */
52
-  HAL_CRC_STATE_TIMEOUT   = 0x03U,  /*!< CRC timeout state                   */
53
-  HAL_CRC_STATE_ERROR     = 0x04U   /*!< CRC error state                     */
54
-} HAL_CRC_StateTypeDef;
55
-
56
-
57
-/**
58
-  * @brief  CRC Handle Structure definition
59
-  */
60
-typedef struct
61
-{
62
-  CRC_TypeDef                 *Instance;   /*!< Register base address        */
63
-
64
-  HAL_LockTypeDef             Lock;        /*!< CRC Locking object           */
65
-
66
-  __IO HAL_CRC_StateTypeDef   State;       /*!< CRC communication state      */
67
-
68
-} CRC_HandleTypeDef;
69
-/**
70
-  * @}
71
-  */
72
-
73
-/* Exported constants --------------------------------------------------------*/
74
-/** @defgroup CRC_Exported_Constants CRC Exported Constants
75
-  * @{
76
-  */
77
-
78
-/**
79
-  * @}
80
-  */
81
-
82
-/* Exported macros -----------------------------------------------------------*/
83
-/** @defgroup CRC_Exported_Macros CRC Exported Macros
84
-  * @{
85
-  */
86
-
87
-/** @brief Reset CRC handle state.
88
-  * @param  __HANDLE__ CRC handle.
89
-  * @retval None
90
-  */
91
-#define __HAL_CRC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRC_STATE_RESET)
92
-
93
-/**
94
-  * @brief  Reset CRC Data Register.
95
-  * @param  __HANDLE__ CRC handle
96
-  * @retval None
97
-  */
98
-#define __HAL_CRC_DR_RESET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_RESET)
99
-
100
-/**
101
-  * @brief Store data in the Independent Data (ID) register.
102
-  * @param __HANDLE__ CRC handle
103
-  * @param __VALUE__  Value to be stored in the ID register
104
-  * @note  Refer to the Reference Manual to get the authorized __VALUE__ length in bits
105
-  * @retval None
106
-  */
107
-#define __HAL_CRC_SET_IDR(__HANDLE__, __VALUE__) (WRITE_REG((__HANDLE__)->Instance->IDR, (__VALUE__)))
108
-
109
-/**
110
-  * @brief Return the data stored in the Independent Data (ID) register.
111
-  * @param __HANDLE__ CRC handle
112
-  * @note  Refer to the Reference Manual to get the authorized __VALUE__ length in bits
113
-  * @retval Value of the ID register
114
-  */
115
-#define __HAL_CRC_GET_IDR(__HANDLE__) (((__HANDLE__)->Instance->IDR) & CRC_IDR_IDR)
116
-/**
117
-  * @}
118
-  */
119
-
120
-
121
-/* Private macros --------------------------------------------------------*/
122
-/** @defgroup  CRC_Private_Macros CRC Private Macros
123
-  * @{
124
-  */
125
-
126
-/**
127
-  * @}
128
-  */
129
-
130
-/* Exported functions --------------------------------------------------------*/
131
-/** @defgroup CRC_Exported_Functions CRC Exported Functions
132
-  * @{
133
-  */
134
-
135
-/* Initialization and de-initialization functions  ****************************/
136
-/** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions
137
-  * @{
138
-  */
139
-HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc);
140
-HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc);
141
-void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc);
142
-void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc);
143
-/**
144
-  * @}
145
-  */
146
-
147
-/* Peripheral Control functions ***********************************************/
148
-/** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions
149
-  * @{
150
-  */
151
-uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength);
152
-uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength);
153
-/**
154
-  * @}
155
-  */
156
-
157
-/* Peripheral State and Error functions ***************************************/
158
-/** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions
159
-  * @{
160
-  */
161
-HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc);
162
-/**
163
-  * @}
164
-  */
165
-
166
-/**
167
-  * @}
168
-  */
169
-
170
-/**
171
-  * @}
172
-  */
173
-
174
-/**
175
-  * @}
176
-  */
177
-
178
-#ifdef __cplusplus
179
-}
180
-#endif
181
-
182
-#endif /* STM32F1xx_HAL_CRC_H */
183
-
184
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 0 - 330
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_crc.c

@@ -1,330 +0,0 @@
1
-/**
2
-  ******************************************************************************
3
-  * @file    stm32f1xx_hal_crc.c
4
-  * @author  MCD Application Team
5
-  * @brief   CRC HAL module driver.
6
-  *          This file provides firmware functions to manage the following
7
-  *          functionalities of the Cyclic Redundancy Check (CRC) peripheral:
8
-  *           + Initialization and de-initialization functions
9
-  *           + Peripheral Control functions
10
-  *           + Peripheral State functions
11
-  *
12
-  @verbatim
13
- ===============================================================================
14
-                     ##### How to use this driver #####
15
- ===============================================================================
16
-    [..]
17
-         (+) Enable CRC AHB clock using __HAL_RCC_CRC_CLK_ENABLE();
18
-         (+) Initialize CRC calculator
19
-             (++) specify generating polynomial (peripheral default or non-default one)
20
-             (++) specify initialization value (peripheral default or non-default one)
21
-             (++) specify input data format
22
-             (++) specify input or output data inversion mode if any
23
-         (+) Use HAL_CRC_Accumulate() function to compute the CRC value of the
24
-             input data buffer starting with the previously computed CRC as
25
-             initialization value
26
-         (+) Use HAL_CRC_Calculate() function to compute the CRC value of the
27
-             input data buffer starting with the defined initialization value
28
-             (default or non-default) to initiate CRC calculation
29
-
30
-  @endverbatim
31
-  ******************************************************************************
32
-  * @attention
33
-  *
34
-  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
35
-  * All rights reserved.</center></h2>
36
-  *
37
-  * This software component is licensed by ST under BSD 3-Clause license,
38
-  * the "License"; You may not use this file except in compliance with the
39
-  * License. You may obtain a copy of the License at:
40
-  *                        opensource.org/licenses/BSD-3-Clause
41
-  *
42
-  ******************************************************************************
43
-  */
44
-
45
-/* Includes ------------------------------------------------------------------*/
46
-#include "stm32f1xx_hal.h"
47
-
48
-/** @addtogroup STM32F1xx_HAL_Driver
49
-  * @{
50
-  */
51
-
52
-/** @defgroup CRC CRC
53
-  * @brief CRC HAL module driver.
54
-  * @{
55
-  */
56
-
57
-#ifdef HAL_CRC_MODULE_ENABLED
58
-
59
-/* Private typedef -----------------------------------------------------------*/
60
-/* Private define ------------------------------------------------------------*/
61
-/* Private macro -------------------------------------------------------------*/
62
-/* Private variables ---------------------------------------------------------*/
63
-/* Private function prototypes -----------------------------------------------*/
64
-
65
-/* Exported functions --------------------------------------------------------*/
66
-
67
-/** @defgroup CRC_Exported_Functions CRC Exported Functions
68
-  * @{
69
-  */
70
-
71
-/** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions
72
- *  @brief    Initialization and Configuration functions.
73
- *
74
-@verbatim
75
- ===============================================================================
76
-            ##### Initialization and de-initialization functions #####
77
- ===============================================================================
78
-    [..]  This section provides functions allowing to:
79
-      (+) Initialize the CRC according to the specified parameters
80
-          in the CRC_InitTypeDef and create the associated handle
81
-      (+) DeInitialize the CRC peripheral
82
-      (+) Initialize the CRC MSP (MCU Specific Package)
83
-      (+) DeInitialize the CRC MSP
84
-
85
-@endverbatim
86
-  * @{
87
-  */
88
-
89
-/**
90
-  * @brief  Initialize the CRC according to the specified
91
-  *         parameters in the CRC_InitTypeDef and create the associated handle.
92
-  * @param  hcrc CRC handle
93
-  * @retval HAL status
94
-  */
95
-HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc)
96
-{
97
-  /* Check the CRC handle allocation */
98
-  if (hcrc == NULL)
99
-  {
100
-    return HAL_ERROR;
101
-  }
102
-
103
-  /* Check the parameters */
104
-  assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
105
-
106
-  if (hcrc->State == HAL_CRC_STATE_RESET)
107
-  {
108
-    /* Allocate lock resource and initialize it */
109
-    hcrc->Lock = HAL_UNLOCKED;
110
-    /* Init the low level hardware */
111
-    HAL_CRC_MspInit(hcrc);
112
-  }
113
-
114
-  /* Change CRC peripheral state */
115
-  hcrc->State = HAL_CRC_STATE_READY;
116
-
117
-  /* Return function status */
118
-  return HAL_OK;
119
-}
120
-
121
-/**
122
-  * @brief  DeInitialize the CRC peripheral.
123
-  * @param  hcrc CRC handle
124
-  * @retval HAL status
125
-  */
126
-HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc)
127
-{
128
-  /* Check the CRC handle allocation */
129
-  if (hcrc == NULL)
130
-  {
131
-    return HAL_ERROR;
132
-  }
133
-
134
-  /* Check the parameters */
135
-  assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
136
-
137
-  /* Check the CRC peripheral state */
138
-  if (hcrc->State == HAL_CRC_STATE_BUSY)
139
-  {
140
-    return HAL_BUSY;
141
-  }
142
-
143
-  /* Change CRC peripheral state */
144
-  hcrc->State = HAL_CRC_STATE_BUSY;
145
-
146
-  /* Reset CRC calculation unit */
147
-  __HAL_CRC_DR_RESET(hcrc);
148
-
149
-  /* Reset IDR register content */
150
-  CLEAR_BIT(hcrc->Instance->IDR, CRC_IDR_IDR);
151
-
152
-  /* DeInit the low level hardware */
153
-  HAL_CRC_MspDeInit(hcrc);
154
-
155
-  /* Change CRC peripheral state */
156
-  hcrc->State = HAL_CRC_STATE_RESET;
157
-
158
-  /* Process unlocked */
159
-  __HAL_UNLOCK(hcrc);
160
-
161
-  /* Return function status */
162
-  return HAL_OK;
163
-}
164
-
165
-/**
166
-  * @brief  Initializes the CRC MSP.
167
-  * @param  hcrc CRC handle
168
-  * @retval None
169
-  */
170
-__weak void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc)
171
-{
172
-  /* Prevent unused argument(s) compilation warning */
173
-  UNUSED(hcrc);
174
-
175
-  /* NOTE : This function should not be modified, when the callback is needed,
176
-            the HAL_CRC_MspInit can be implemented in the user file
177
-   */
178
-}
179
-
180
-/**
181
-  * @brief  DeInitialize the CRC MSP.
182
-  * @param  hcrc CRC handle
183
-  * @retval None
184
-  */
185
-__weak void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc)
186
-{
187
-  /* Prevent unused argument(s) compilation warning */
188
-  UNUSED(hcrc);
189
-
190
-  /* NOTE : This function should not be modified, when the callback is needed,
191
-            the HAL_CRC_MspDeInit can be implemented in the user file
192
-   */
193
-}
194
-
195
-/**
196
-  * @}
197
-  */
198
-
199
-/** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions
200
- *  @brief    management functions.
201
- *
202
-@verbatim
203
- ===============================================================================
204
-                      ##### Peripheral Control functions #####
205
- ===============================================================================
206
-    [..]  This section provides functions allowing to:
207
-      (+) compute the 32-bit CRC value of a 32-bit data buffer
208
-          using combination of the previous CRC value and the new one.
209
-
210
-       [..]  or
211
-
212
-      (+) compute the 32-bit CRC value of a 32-bit data buffer
213
-          independently of the previous CRC value.
214
-
215
-@endverbatim
216
-  * @{
217
-  */
218
-
219
-/**
220
-  * @brief  Compute the 32-bit CRC value of a 32-bit data buffer
221
-  *         starting with the previously computed CRC as initialization value.
222
-  * @param  hcrc CRC handle
223
-  * @param  pBuffer pointer to the input data buffer.
224
-  * @param  BufferLength input data buffer length (number of uint32_t words).
225
-  * @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits)
226
-  */
227
-uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
228
-{
229
-  uint32_t index;      /* CRC input data buffer index */
230
-  uint32_t temp = 0U;  /* CRC output (read from hcrc->Instance->DR register) */
231
-
232
-  /* Change CRC peripheral state */
233
-  hcrc->State = HAL_CRC_STATE_BUSY;
234
-
235
-  /* Enter Data to the CRC calculator */
236
-  for (index = 0U; index < BufferLength; index++)
237
-  {
238
-    hcrc->Instance->DR = pBuffer[index];
239
-  }
240
-  temp = hcrc->Instance->DR;
241
-
242
-  /* Change CRC peripheral state */
243
-  hcrc->State = HAL_CRC_STATE_READY;
244
-
245
-  /* Return the CRC computed value */
246
-  return temp;
247
-}
248
-
249
-/**
250
-  * @brief  Compute the 32-bit CRC value of a 32-bit data buffer
251
-  *         starting with hcrc->Instance->INIT as initialization value.
252
-  * @param  hcrc CRC handle
253
-  * @param  pBuffer pointer to the input data buffer.
254
-  * @param  BufferLength input data buffer length (number of uint32_t words).
255
-  * @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits)
256
-  */
257
-uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
258
-{
259
-  uint32_t index;      /* CRC input data buffer index */
260
-  uint32_t temp = 0U;  /* CRC output (read from hcrc->Instance->DR register) */
261
-
262
-  /* Change CRC peripheral state */
263
-  hcrc->State = HAL_CRC_STATE_BUSY;
264
-
265
-  /* Reset CRC Calculation Unit (hcrc->Instance->INIT is
266
-  *  written in hcrc->Instance->DR) */
267
-  __HAL_CRC_DR_RESET(hcrc);
268
-
269
-  /* Enter 32-bit input data to the CRC calculator */
270
-  for (index = 0U; index < BufferLength; index++)
271
-  {
272
-    hcrc->Instance->DR = pBuffer[index];
273
-  }
274
-  temp = hcrc->Instance->DR;
275
-
276
-  /* Change CRC peripheral state */
277
-  hcrc->State = HAL_CRC_STATE_READY;
278
-
279
-  /* Return the CRC computed value */
280
-  return temp;
281
-}
282
-
283
-/**
284
-  * @}
285
-  */
286
-
287
-/** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions
288
- *  @brief    Peripheral State functions.
289
- *
290
-@verbatim
291
- ===============================================================================
292
-                      ##### Peripheral State functions #####
293
- ===============================================================================
294
-    [..]
295
-    This subsection permits to get in run-time the status of the peripheral.
296
-
297
-@endverbatim
298
-  * @{
299
-  */
300
-
301
-/**
302
-  * @brief  Return the CRC handle state.
303
-  * @param  hcrc CRC handle
304
-  * @retval HAL state
305
-  */
306
-HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc)
307
-{
308
-  /* Return CRC handle state */
309
-  return hcrc->State;
310
-}
311
-
312
-/**
313
-  * @}
314
-  */
315
-
316
-/**
317
-  * @}
318
-  */
319
-
320
-
321
-#endif /* HAL_CRC_MODULE_ENABLED */
322
-/**
323
-  * @}
324
-  */
325
-
326
-/**
327
-  * @}
328
-  */
329
-
330
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 1 - 1
Inc/stm32f1xx_hal_conf.h

@@ -39,7 +39,7 @@
39
 /*#define HAL_CAN_LEGACY_MODULE_ENABLED   */
39
 /*#define HAL_CAN_LEGACY_MODULE_ENABLED   */
40
 /*#define HAL_CEC_MODULE_ENABLED   */
40
 /*#define HAL_CEC_MODULE_ENABLED   */
41
 /*#define HAL_CORTEX_MODULE_ENABLED   */
41
 /*#define HAL_CORTEX_MODULE_ENABLED   */
42
-#define HAL_CRC_MODULE_ENABLED
42
+/*#define HAL_CRC_MODULE_ENABLED   */
43
 /*#define HAL_DAC_MODULE_ENABLED   */
43
 /*#define HAL_DAC_MODULE_ENABLED   */
44
 #define HAL_DMA_MODULE_ENABLED
44
 #define HAL_DMA_MODULE_ENABLED
45
 /*#define HAL_ETH_MODULE_ENABLED   */
45
 /*#define HAL_ETH_MODULE_ENABLED   */

+ 2 - 0
Inc/stm32f1xx_it.h

@@ -59,6 +59,8 @@ void SysTick_Handler(void);
59
 void DMA1_Channel1_IRQHandler(void);
59
 void DMA1_Channel1_IRQHandler(void);
60
 void DMA1_Channel4_IRQHandler(void);
60
 void DMA1_Channel4_IRQHandler(void);
61
 void DMA1_Channel5_IRQHandler(void);
61
 void DMA1_Channel5_IRQHandler(void);
62
+void DMA1_Channel6_IRQHandler(void);
63
+void DMA1_Channel7_IRQHandler(void);
62
 void ADC1_2_IRQHandler(void);
64
 void ADC1_2_IRQHandler(void);
63
 void TIM2_IRQHandler(void);
65
 void TIM2_IRQHandler(void);
64
 void USART1_IRQHandler(void);
66
 void USART1_IRQHandler(void);

+ 43 - 24
STM32F103ZET_JDASMBIC.ioc

@@ -58,7 +58,9 @@ Dma.Request0=USART1_RX
58
 Dma.Request1=USART1_TX
58
 Dma.Request1=USART1_TX
59
 Dma.Request2=ADC1
59
 Dma.Request2=ADC1
60
 Dma.Request3=ADC3
60
 Dma.Request3=ADC3
61
-Dma.RequestsNb=4
61
+Dma.Request4=USART2_RX
62
+Dma.Request5=USART2_TX
63
+Dma.RequestsNb=6
62
 Dma.USART1_RX.0.Direction=DMA_PERIPH_TO_MEMORY
64
 Dma.USART1_RX.0.Direction=DMA_PERIPH_TO_MEMORY
63
 Dma.USART1_RX.0.Instance=DMA1_Channel5
65
 Dma.USART1_RX.0.Instance=DMA1_Channel5
64
 Dma.USART1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
66
 Dma.USART1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
@@ -77,6 +79,24 @@ Dma.USART1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
77
 Dma.USART1_TX.1.PeriphInc=DMA_PINC_DISABLE
79
 Dma.USART1_TX.1.PeriphInc=DMA_PINC_DISABLE
78
 Dma.USART1_TX.1.Priority=DMA_PRIORITY_LOW
80
 Dma.USART1_TX.1.Priority=DMA_PRIORITY_LOW
79
 Dma.USART1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
81
 Dma.USART1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
82
+Dma.USART2_RX.4.Direction=DMA_PERIPH_TO_MEMORY
83
+Dma.USART2_RX.4.Instance=DMA1_Channel6
84
+Dma.USART2_RX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE
85
+Dma.USART2_RX.4.MemInc=DMA_MINC_ENABLE
86
+Dma.USART2_RX.4.Mode=DMA_NORMAL
87
+Dma.USART2_RX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
88
+Dma.USART2_RX.4.PeriphInc=DMA_PINC_DISABLE
89
+Dma.USART2_RX.4.Priority=DMA_PRIORITY_LOW
90
+Dma.USART2_RX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
91
+Dma.USART2_TX.5.Direction=DMA_MEMORY_TO_PERIPH
92
+Dma.USART2_TX.5.Instance=DMA1_Channel7
93
+Dma.USART2_TX.5.MemDataAlignment=DMA_MDATAALIGN_BYTE
94
+Dma.USART2_TX.5.MemInc=DMA_MINC_ENABLE
95
+Dma.USART2_TX.5.Mode=DMA_NORMAL
96
+Dma.USART2_TX.5.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
97
+Dma.USART2_TX.5.PeriphInc=DMA_PINC_DISABLE
98
+Dma.USART2_TX.5.Priority=DMA_PRIORITY_LOW
99
+Dma.USART2_TX.5.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
80
 File.Version=6
100
 File.Version=6
81
 GPIO.groupedBy=Group By Peripherals
101
 GPIO.groupedBy=Group By Peripherals
82
 I2C2.I2C_Mode=I2C_Fast
102
 I2C2.I2C_Mode=I2C_Fast
@@ -85,16 +105,15 @@ KeepUserPlacement=false
85
 Mcu.Family=STM32F1
105
 Mcu.Family=STM32F1
86
 Mcu.IP0=ADC1
106
 Mcu.IP0=ADC1
87
 Mcu.IP1=ADC3
107
 Mcu.IP1=ADC3
88
-Mcu.IP10=USART2
89
-Mcu.IP2=CRC
90
-Mcu.IP3=DMA
91
-Mcu.IP4=I2C2
92
-Mcu.IP5=NVIC
93
-Mcu.IP6=RCC
94
-Mcu.IP7=SYS
95
-Mcu.IP8=TIM6
96
-Mcu.IP9=USART1
97
-Mcu.IPNb=11
108
+Mcu.IP2=DMA
109
+Mcu.IP3=I2C2
110
+Mcu.IP4=NVIC
111
+Mcu.IP5=RCC
112
+Mcu.IP6=SYS
113
+Mcu.IP7=TIM6
114
+Mcu.IP8=USART1
115
+Mcu.IP9=USART2
116
+Mcu.IPNb=10
98
 Mcu.Name=STM32F103Z(C-D-E)Tx
117
 Mcu.Name=STM32F103Z(C-D-E)Tx
99
 Mcu.Package=LQFP144
118
 Mcu.Package=LQFP144
100
 Mcu.Pin0=PE3
119
 Mcu.Pin0=PE3
@@ -147,26 +166,27 @@ Mcu.Pin50=PG15
147
 Mcu.Pin51=PB6
166
 Mcu.Pin51=PB6
148
 Mcu.Pin52=PB7
167
 Mcu.Pin52=PB7
149
 Mcu.Pin53=PB9
168
 Mcu.Pin53=PB9
150
-Mcu.Pin54=VP_CRC_VS_CRC
151
-Mcu.Pin55=VP_SYS_VS_tim2
152
-Mcu.Pin56=VP_TIM6_VS_ClockSourceINT
169
+Mcu.Pin54=VP_SYS_VS_tim2
170
+Mcu.Pin55=VP_TIM6_VS_ClockSourceINT
153
 Mcu.Pin6=PF9
171
 Mcu.Pin6=PF9
154
 Mcu.Pin7=PF10
172
 Mcu.Pin7=PF10
155
 Mcu.Pin8=PC2
173
 Mcu.Pin8=PC2
156
 Mcu.Pin9=PA2
174
 Mcu.Pin9=PA2
157
-Mcu.PinsNb=57
175
+Mcu.PinsNb=56
158
 Mcu.ThirdPartyNb=0
176
 Mcu.ThirdPartyNb=0
159
 Mcu.UserConstants=
177
 Mcu.UserConstants=
160
 Mcu.UserName=STM32F103ZETx
178
 Mcu.UserName=STM32F103ZETx
161
 MxCube.Version=5.6.1
179
 MxCube.Version=5.6.1
162
 MxDb.Version=DB.5.0.60
180
 MxDb.Version=DB.5.0.60
163
 NVIC.ADC1_2_IRQn=true\:0\:0\:false\:false\:true\:true\:true
181
 NVIC.ADC1_2_IRQn=true\:0\:0\:false\:false\:true\:true\:true
164
-NVIC.ADC3_IRQn=true\:0\:0\:false\:true\:true\:10\:true\:true
182
+NVIC.ADC3_IRQn=true\:0\:0\:false\:true\:true\:8\:true\:true
165
 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
183
 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
166
 NVIC.DMA1_Channel1_IRQn=true\:0\:0\:false\:true\:true\:1\:false\:true
184
 NVIC.DMA1_Channel1_IRQn=true\:0\:0\:false\:true\:true\:1\:false\:true
167
 NVIC.DMA1_Channel4_IRQn=true\:0\:0\:false\:true\:true\:2\:false\:true
185
 NVIC.DMA1_Channel4_IRQn=true\:0\:0\:false\:true\:true\:2\:false\:true
168
 NVIC.DMA1_Channel5_IRQn=true\:0\:0\:false\:true\:true\:3\:false\:true
186
 NVIC.DMA1_Channel5_IRQn=true\:0\:0\:false\:true\:true\:3\:false\:true
169
-NVIC.DMA2_Channel4_5_IRQn=true\:0\:0\:false\:true\:true\:8\:false\:true
187
+NVIC.DMA1_Channel6_IRQn=true\:0\:0\:false\:true\:true\:9\:false\:true
188
+NVIC.DMA1_Channel7_IRQn=true\:0\:0\:false\:true\:true\:10\:false\:true
189
+NVIC.DMA2_Channel4_5_IRQn=true\:0\:0\:false\:true\:true\:6\:false\:true
170
 NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
190
 NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
171
 NVIC.ForceEnableDMAVector=true
191
 NVIC.ForceEnableDMAVector=true
172
 NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
192
 NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
@@ -177,11 +197,11 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
177
 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
197
 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
178
 NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
198
 NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
179
 NVIC.TIM2_IRQn=true\:0\:0\:false\:false\:true\:false\:true
199
 NVIC.TIM2_IRQn=true\:0\:0\:false\:false\:true\:false\:true
180
-NVIC.TIM6_IRQn=true\:0\:0\:false\:true\:true\:9\:true\:true
200
+NVIC.TIM6_IRQn=true\:0\:0\:false\:true\:true\:7\:true\:true
181
 NVIC.TimeBase=TIM2_IRQn
201
 NVIC.TimeBase=TIM2_IRQn
182
 NVIC.TimeBaseIP=TIM2
202
 NVIC.TimeBaseIP=TIM2
183
-NVIC.USART1_IRQn=true\:0\:0\:false\:true\:true\:6\:true\:true
184
-NVIC.USART2_IRQn=true\:0\:0\:false\:true\:true\:7\:true\:true
203
+NVIC.USART1_IRQn=true\:0\:0\:false\:true\:true\:4\:true\:true
204
+NVIC.USART2_IRQn=true\:0\:0\:false\:true\:true\:5\:true\:true
185
 NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
205
 NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
186
 PA10.GPIOParameters=GPIO_Label
206
 PA10.GPIOParameters=GPIO_Label
187
 PA10.GPIO_Label=MBIC_DOWN
207
 PA10.GPIO_Label=MBIC_DOWN
@@ -425,7 +445,7 @@ ProjectManager.StackSize=0x400
425
 ProjectManager.TargetToolchain=TrueSTUDIO
445
 ProjectManager.TargetToolchain=TrueSTUDIO
426
 ProjectManager.ToolChainLocation=
446
 ProjectManager.ToolChainLocation=
427
 ProjectManager.UnderRoot=true
447
 ProjectManager.UnderRoot=true
428
-ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_ADC1_Init-ADC1-false-HAL-true,6-MX_ADC3_Init-ADC3-false-HAL-true,7-MX_USART2_UART_Init-USART2-false-HAL-true,8-MX_TIM6_Init-TIM6-false-HAL-true,9-MX_CRC_Init-CRC-false-HAL-true,10-MX_I2C2_Init-I2C2-false-HAL-true
448
+ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_ADC1_Init-ADC1-false-HAL-true,6-MX_ADC3_Init-ADC3-false-HAL-true,7-MX_USART2_UART_Init-USART2-false-HAL-true,8-MX_TIM6_Init-TIM6-false-HAL-true,9-MX_I2C2_Init-I2C2-false-HAL-true
429
 RCC.ADCFreqValue=14000000
449
 RCC.ADCFreqValue=14000000
430
 RCC.ADCPresc=RCC_ADCPCLK2_DIV4
450
 RCC.ADCPresc=RCC_ADCPCLK2_DIV4
431
 RCC.AHBFreq_Value=56000000
451
 RCC.AHBFreq_Value=56000000
@@ -465,10 +485,9 @@ TIM6.Prescaler=5600 - 1
465
 USART1.BaudRate=921600
485
 USART1.BaudRate=921600
466
 USART1.IPParameters=VirtualMode,BaudRate
486
 USART1.IPParameters=VirtualMode,BaudRate
467
 USART1.VirtualMode=VM_ASYNC
487
 USART1.VirtualMode=VM_ASYNC
468
-USART2.IPParameters=VirtualMode
488
+USART2.BaudRate=921600
489
+USART2.IPParameters=VirtualMode,BaudRate
469
 USART2.VirtualMode=VM_ASYNC
490
 USART2.VirtualMode=VM_ASYNC
470
-VP_CRC_VS_CRC.Mode=CRC_Activate
471
-VP_CRC_VS_CRC.Signal=CRC_VS_CRC
472
 VP_SYS_VS_tim2.Mode=TIM2
491
 VP_SYS_VS_tim2.Mode=TIM2
473
 VP_SYS_VS_tim2.Signal=SYS_VS_tim2
492
 VP_SYS_VS_tim2.Signal=SYS_VS_tim2
474
 VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer
493
 VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer

+ 13 - 34
Src/main.c

@@ -50,8 +50,6 @@ ADC_HandleTypeDef hadc3;
50
 DMA_HandleTypeDef hdma_adc1;
50
 DMA_HandleTypeDef hdma_adc1;
51
 DMA_HandleTypeDef hdma_adc3;
51
 DMA_HandleTypeDef hdma_adc3;
52
 
52
 
53
-CRC_HandleTypeDef hcrc;
54
-
55
 I2C_HandleTypeDef hi2c2;
53
 I2C_HandleTypeDef hi2c2;
56
 
54
 
57
 TIM_HandleTypeDef htim6;
55
 TIM_HandleTypeDef htim6;
@@ -60,6 +58,8 @@ UART_HandleTypeDef huart1;
60
 UART_HandleTypeDef huart2;
58
 UART_HandleTypeDef huart2;
61
 DMA_HandleTypeDef hdma_usart1_rx;
59
 DMA_HandleTypeDef hdma_usart1_rx;
62
 DMA_HandleTypeDef hdma_usart1_tx;
60
 DMA_HandleTypeDef hdma_usart1_tx;
61
+DMA_HandleTypeDef hdma_usart2_rx;
62
+DMA_HandleTypeDef hdma_usart2_tx;
63
 
63
 
64
 /* USER CODE BEGIN PV */
64
 /* USER CODE BEGIN PV */
65
 volatile uint16_t ADC1value[ADC1_CNT];
65
 volatile uint16_t ADC1value[ADC1_CNT];
@@ -88,7 +88,6 @@ static void MX_ADC1_Init(void);
88
 static void MX_ADC3_Init(void);
88
 static void MX_ADC3_Init(void);
89
 static void MX_USART2_UART_Init(void);
89
 static void MX_USART2_UART_Init(void);
90
 static void MX_TIM6_Init(void);
90
 static void MX_TIM6_Init(void);
91
-static void MX_CRC_Init(void);
92
 static void MX_I2C2_Init(void);
91
 static void MX_I2C2_Init(void);
93
 static void MX_NVIC_Init(void);
92
 static void MX_NVIC_Init(void);
94
 /* USER CODE BEGIN PFP */
93
 /* USER CODE BEGIN PFP */
@@ -109,7 +108,7 @@ void Pol_Delay_us(volatile uint32_t microseconds)
109
 
108
 
110
 int _write (int file, uint8_t *ptr, uint16_t len)
109
 int _write (int file, uint8_t *ptr, uint16_t len)
111
 {
110
 {
112
-    HAL_UART_Transmit(&huart1, ptr, len,10);
111
+    HAL_UART_Transmit(&hTerminal, ptr, len,10);
113
     return len;
112
     return len;
114
 }
113
 }
115
 uint16_t adc1cnt = 0 ;
114
 uint16_t adc1cnt = 0 ;
@@ -119,7 +118,7 @@ uint16_t adc3cnt = 0 ;
119
 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
118
 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
120
 {
119
 {
121
 //?��?��?�� 코드 ?��?��
120
 //?��?��?�� 코드 ?��?��
122
-//諤嵸烄 ?嚙踝蕭?嚙踝蕭 adc?嚙踝蕭嚙???? 嚙?????嚙踝蕭?嚙踝蕭 ?嚙踝蕭 ?嚙踝蕭?嚙踝蕭嚙???? ?嚙踝蕭?嚙踝蕭嚙???? ?嚙踝蕭?嚙踝蕭?? 穈軤𦚯 魽國探嚙???? ?嚙踝蕭?嚙踝蕭
121
+//諤嵸烄 ?嚙踝蕭?嚙踝蕭 adc?嚙踝蕭嚙???????????????嚙踝蕭?嚙踝蕭 ?嚙踝蕭 ?嚙踝蕭?嚙踝蕭嚙??????? ?嚙踝蕭?嚙踝蕭嚙??????? ?嚙踝蕭?嚙踝蕭?? 穈軤𦚯 魽國探嚙??????? ?嚙踝蕭?嚙踝蕭
123
 
122
 
124
     if(hadc->Instance == hadc1.Instance)
123
     if(hadc->Instance == hadc1.Instance)
125
     {
124
     {
@@ -312,7 +311,6 @@ int main(void)
312
   MX_ADC3_Init();
311
   MX_ADC3_Init();
313
   MX_USART2_UART_Init();
312
   MX_USART2_UART_Init();
314
   MX_TIM6_Init();
313
   MX_TIM6_Init();
315
-  MX_CRC_Init();
316
   MX_I2C2_Init();
314
   MX_I2C2_Init();
317
 
315
 
318
   /* Initialize interrupts */
316
   /* Initialize interrupts */
@@ -327,6 +325,7 @@ int main(void)
327
   PE43711_PinInit();
325
   PE43711_PinInit();
328
   EEPROM_M24C08_Init();
326
   EEPROM_M24C08_Init();
329
   Bluecell_DataInit();
327
   Bluecell_DataInit();
328
+
330
 #if 0 // PYJ.2020.04.22_BEGIN -- 
329
 #if 0 // PYJ.2020.04.22_BEGIN -- 
331
   EEPROM_M24C08_write(0xA0,0,i2cTestData,1);
330
   EEPROM_M24C08_write(0xA0,0,i2cTestData,1);
332
   printf("i2c Test Data1 %d\r\n",i2ctest[0]);
331
   printf("i2c Test Data1 %d\r\n",i2ctest[0]);
@@ -343,7 +342,7 @@ int main(void)
343
 //    EEPROMTEST_J();
342
 //    EEPROMTEST_J();
344
 //    eepromtest_j1();
343
 //    eepromtest_j1();
345
 //        eepromtest_j1();
344
 //        eepromtest_j1();
346
-#if 0 // PYJ.2020.05.06_BEGIN -- 
345
+#if 1 // PYJ.2020.05.06_BEGIN -- 
347
     printf("****************************************\r\n");
346
     printf("****************************************\r\n");
348
     printf("MBIC Project\r\n");
347
     printf("MBIC Project\r\n");
349
     printf("Build at %s %s\r\n", __DATE__, __TIME__);
348
     printf("Build at %s %s\r\n", __DATE__, __TIME__);
@@ -439,6 +438,12 @@ static void MX_NVIC_Init(void)
439
   /* ADC3_IRQn interrupt configuration */
438
   /* ADC3_IRQn interrupt configuration */
440
   HAL_NVIC_SetPriority(ADC3_IRQn, 0, 0);
439
   HAL_NVIC_SetPriority(ADC3_IRQn, 0, 0);
441
   HAL_NVIC_EnableIRQ(ADC3_IRQn);
440
   HAL_NVIC_EnableIRQ(ADC3_IRQn);
441
+  /* DMA1_Channel6_IRQn interrupt configuration */
442
+  HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 0, 0);
443
+  HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn);
444
+  /* DMA1_Channel7_IRQn interrupt configuration */
445
+  HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 0, 0);
446
+  HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn);
442
 }
447
 }
443
 
448
 
444
 /**
449
 /**
@@ -587,32 +592,6 @@ static void MX_ADC3_Init(void)
587
 
592
 
588
 }
593
 }
589
 
594
 
590
-/**
591
-  * @brief CRC Initialization Function
592
-  * @param None
593
-  * @retval None
594
-  */
595
-static void MX_CRC_Init(void)
596
-{
597
-
598
-  /* USER CODE BEGIN CRC_Init 0 */
599
-
600
-  /* USER CODE END CRC_Init 0 */
601
-
602
-  /* USER CODE BEGIN CRC_Init 1 */
603
-
604
-  /* USER CODE END CRC_Init 1 */
605
-  hcrc.Instance = CRC;
606
-  if (HAL_CRC_Init(&hcrc) != HAL_OK)
607
-  {
608
-    Error_Handler();
609
-  }
610
-  /* USER CODE BEGIN CRC_Init 2 */
611
-
612
-  /* USER CODE END CRC_Init 2 */
613
-
614
-}
615
-
616
 /**
595
 /**
617
   * @brief I2C2 Initialization Function
596
   * @brief I2C2 Initialization Function
618
   * @param None
597
   * @param None
@@ -701,7 +680,7 @@ static void MX_USART1_UART_Init(void)
701
 
680
 
702
   /* USER CODE END USART1_Init 1 */
681
   /* USER CODE END USART1_Init 1 */
703
   huart1.Instance = USART1;
682
   huart1.Instance = USART1;
704
-  huart1.Init.BaudRate = 921600;
683
+  huart1.Init.BaudRate = 115200;
705
   huart1.Init.WordLength = UART_WORDLENGTH_8B;
684
   huart1.Init.WordLength = UART_WORDLENGTH_8B;
706
   huart1.Init.StopBits = UART_STOPBITS_1;
685
   huart1.Init.StopBits = UART_STOPBITS_1;
707
   huart1.Init.Parity = UART_PARITY_NONE;
686
   huart1.Init.Parity = UART_PARITY_NONE;

+ 41 - 44
Src/stm32f1xx_hal_msp.c

@@ -32,6 +32,10 @@ extern DMA_HandleTypeDef hdma_usart1_rx;
32
 
32
 
33
 extern DMA_HandleTypeDef hdma_usart1_tx;
33
 extern DMA_HandleTypeDef hdma_usart1_tx;
34
 
34
 
35
+extern DMA_HandleTypeDef hdma_usart2_rx;
36
+
37
+extern DMA_HandleTypeDef hdma_usart2_tx;
38
+
35
 /* Private typedef -----------------------------------------------------------*/
39
 /* Private typedef -----------------------------------------------------------*/
36
 /* USER CODE BEGIN TD */
40
 /* USER CODE BEGIN TD */
37
 
41
 
@@ -255,50 +259,6 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
255
 
259
 
256
 }
260
 }
257
 
261
 
258
-/**
259
-* @brief CRC MSP Initialization
260
-* This function configures the hardware resources used in this example
261
-* @param hcrc: CRC handle pointer
262
-* @retval None
263
-*/
264
-void HAL_CRC_MspInit(CRC_HandleTypeDef* hcrc)
265
-{
266
-  if(hcrc->Instance==CRC)
267
-  {
268
-  /* USER CODE BEGIN CRC_MspInit 0 */
269
-
270
-  /* USER CODE END CRC_MspInit 0 */
271
-    /* Peripheral clock enable */
272
-    __HAL_RCC_CRC_CLK_ENABLE();
273
-  /* USER CODE BEGIN CRC_MspInit 1 */
274
-
275
-  /* USER CODE END CRC_MspInit 1 */
276
-  }
277
-
278
-}
279
-
280
-/**
281
-* @brief CRC MSP De-Initialization
282
-* This function freeze the hardware resources used in this example
283
-* @param hcrc: CRC handle pointer
284
-* @retval None
285
-*/
286
-void HAL_CRC_MspDeInit(CRC_HandleTypeDef* hcrc)
287
-{
288
-  if(hcrc->Instance==CRC)
289
-  {
290
-  /* USER CODE BEGIN CRC_MspDeInit 0 */
291
-
292
-  /* USER CODE END CRC_MspDeInit 0 */
293
-    /* Peripheral clock disable */
294
-    __HAL_RCC_CRC_CLK_DISABLE();
295
-  /* USER CODE BEGIN CRC_MspDeInit 1 */
296
-
297
-  /* USER CODE END CRC_MspDeInit 1 */
298
-  }
299
-
300
-}
301
-
302
 /**
262
 /**
303
 * @brief I2C MSP Initialization
263
 * @brief I2C MSP Initialization
304
 * This function configures the hardware resources used in this example
264
 * This function configures the hardware resources used in this example
@@ -501,6 +461,39 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
501
     GPIO_InitStruct.Pull = GPIO_NOPULL;
461
     GPIO_InitStruct.Pull = GPIO_NOPULL;
502
     HAL_GPIO_Init(RFU_RX_GPIO_Port, &GPIO_InitStruct);
462
     HAL_GPIO_Init(RFU_RX_GPIO_Port, &GPIO_InitStruct);
503
 
463
 
464
+    /* USART2 DMA Init */
465
+    /* USART2_RX Init */
466
+    hdma_usart2_rx.Instance = DMA1_Channel6;
467
+    hdma_usart2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
468
+    hdma_usart2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
469
+    hdma_usart2_rx.Init.MemInc = DMA_MINC_ENABLE;
470
+    hdma_usart2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
471
+    hdma_usart2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
472
+    hdma_usart2_rx.Init.Mode = DMA_NORMAL;
473
+    hdma_usart2_rx.Init.Priority = DMA_PRIORITY_LOW;
474
+    if (HAL_DMA_Init(&hdma_usart2_rx) != HAL_OK)
475
+    {
476
+      Error_Handler();
477
+    }
478
+
479
+    __HAL_LINKDMA(huart,hdmarx,hdma_usart2_rx);
480
+
481
+    /* USART2_TX Init */
482
+    hdma_usart2_tx.Instance = DMA1_Channel7;
483
+    hdma_usart2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
484
+    hdma_usart2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
485
+    hdma_usart2_tx.Init.MemInc = DMA_MINC_ENABLE;
486
+    hdma_usart2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
487
+    hdma_usart2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
488
+    hdma_usart2_tx.Init.Mode = DMA_NORMAL;
489
+    hdma_usart2_tx.Init.Priority = DMA_PRIORITY_LOW;
490
+    if (HAL_DMA_Init(&hdma_usart2_tx) != HAL_OK)
491
+    {
492
+      Error_Handler();
493
+    }
494
+
495
+    __HAL_LINKDMA(huart,hdmatx,hdma_usart2_tx);
496
+
504
   /* USER CODE BEGIN USART2_MspInit 1 */
497
   /* USER CODE BEGIN USART2_MspInit 1 */
505
 
498
 
506
   /* USER CODE END USART2_MspInit 1 */
499
   /* USER CODE END USART2_MspInit 1 */
@@ -554,6 +547,10 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
554
     */
547
     */
555
     HAL_GPIO_DeInit(GPIOA, RFU_TX_Pin|RFU_RX_Pin);
548
     HAL_GPIO_DeInit(GPIOA, RFU_TX_Pin|RFU_RX_Pin);
556
 
549
 
550
+    /* USART2 DMA DeInit */
551
+    HAL_DMA_DeInit(huart->hdmarx);
552
+    HAL_DMA_DeInit(huart->hdmatx);
553
+
557
     /* USART2 interrupt DeInit */
554
     /* USART2 interrupt DeInit */
558
     HAL_NVIC_DisableIRQ(USART2_IRQn);
555
     HAL_NVIC_DisableIRQ(USART2_IRQn);
559
   /* USER CODE BEGIN USART2_MspDeInit 1 */
556
   /* USER CODE BEGIN USART2_MspDeInit 1 */

+ 30 - 0
Src/stm32f1xx_it.c

@@ -63,6 +63,8 @@ extern ADC_HandleTypeDef hadc3;
63
 extern TIM_HandleTypeDef htim6;
63
 extern TIM_HandleTypeDef htim6;
64
 extern DMA_HandleTypeDef hdma_usart1_rx;
64
 extern DMA_HandleTypeDef hdma_usart1_rx;
65
 extern DMA_HandleTypeDef hdma_usart1_tx;
65
 extern DMA_HandleTypeDef hdma_usart1_tx;
66
+extern DMA_HandleTypeDef hdma_usart2_rx;
67
+extern DMA_HandleTypeDef hdma_usart2_tx;
66
 extern UART_HandleTypeDef huart1;
68
 extern UART_HandleTypeDef huart1;
67
 extern UART_HandleTypeDef huart2;
69
 extern UART_HandleTypeDef huart2;
68
 extern TIM_HandleTypeDef htim2;
70
 extern TIM_HandleTypeDef htim2;
@@ -249,6 +251,34 @@ void DMA1_Channel5_IRQHandler(void)
249
   /* USER CODE END DMA1_Channel5_IRQn 1 */
251
   /* USER CODE END DMA1_Channel5_IRQn 1 */
250
 }
252
 }
251
 
253
 
254
+/**
255
+  * @brief This function handles DMA1 channel6 global interrupt.
256
+  */
257
+void DMA1_Channel6_IRQHandler(void)
258
+{
259
+  /* USER CODE BEGIN DMA1_Channel6_IRQn 0 */
260
+
261
+  /* USER CODE END DMA1_Channel6_IRQn 0 */
262
+  HAL_DMA_IRQHandler(&hdma_usart2_rx);
263
+  /* USER CODE BEGIN DMA1_Channel6_IRQn 1 */
264
+
265
+  /* USER CODE END DMA1_Channel6_IRQn 1 */
266
+}
267
+
268
+/**
269
+  * @brief This function handles DMA1 channel7 global interrupt.
270
+  */
271
+void DMA1_Channel7_IRQHandler(void)
272
+{
273
+  /* USER CODE BEGIN DMA1_Channel7_IRQn 0 */
274
+
275
+  /* USER CODE END DMA1_Channel7_IRQn 0 */
276
+  HAL_DMA_IRQHandler(&hdma_usart2_tx);
277
+  /* USER CODE BEGIN DMA1_Channel7_IRQn 1 */
278
+
279
+  /* USER CODE END DMA1_Channel7_IRQn 1 */
280
+}
281
+
252
 /**
282
 /**
253
   * @brief This function handles ADC1 and ADC2 global interrupts.
283
   * @brief This function handles ADC1 and ADC2 global interrupts.
254
   */
284
   */