]> Zhao Yanbai Git Server - acecode.git/commitdiff
F103HAL gpio output open drain mode
authorAceVest <zhaoyanbai@126.com>
Sat, 1 Jun 2019 07:15:14 +0000 (15:15 +0800)
committerAceVest <zhaoyanbai@126.com>
Sat, 1 Jun 2019 07:15:14 +0000 (15:15 +0800)
learn/stm32/F103HAL/F103HAL.elf.launch
learn/stm32/F103HAL/Src/System.c [new file with mode: 0644]
learn/stm32/F103HAL/Src/main.c

index 925476b664cd7629e1de7c5705c95338f53f8def..27e5676eed5fb11862218d5376ee460c6b6dedfd 100644 (file)
@@ -65,5 +65,6 @@
 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
 <listEntry value="4"/>
 </listAttribute>
+<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;&#10;"/>
 <stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
 </launchConfiguration>
diff --git a/learn/stm32/F103HAL/Src/System.c b/learn/stm32/F103HAL/Src/System.c
new file mode 100644 (file)
index 0000000..3abf807
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * System.c
+ *
+ *  Created on: Jun 1, 2019
+ *      Author: ace
+ */
+
+
+#include "stm32f1xx_hal.h"
+
+void SystemPreInit() {
+       __HAL_RCC_GPIOB_CLK_ENABLE();
+}
+
+
+#define LED_Pin                GPIO_PIN_6
+#define LED_GPIO_Port  GPIOB
+
+void SystemSetup() {
+       GPIO_InitTypeDef GPIO_InitStruct;
+       GPIO_InitStruct.Mode    = GPIO_MODE_OUTPUT_OD;
+       GPIO_InitStruct.Pin             = LED_Pin;
+       GPIO_InitStruct.Pull    = GPIO_NOPULL;
+       GPIO_InitStruct.Speed   = GPIO_SPEED_FREQ_HIGH;
+
+       HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct);
+}
+
+void SystemLoop() {
+       HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
+       HAL_Delay(1000);
+}
index d211515350118d1888ed347265266158b2a23687..e6d0a59833dd49efbaef3b970ee8951953dc3209 100644 (file)
@@ -56,7 +56,9 @@ void SystemClock_Config(void);
 \r
 /* Private user code ---------------------------------------------------------*/\r
 /* USER CODE BEGIN 0 */\r
-\r
+void SystemPreInit();\r
+void SystemSetup();\r
+void SystemLoop();\r
 /* USER CODE END 0 */\r
 \r
 /**\r
@@ -83,19 +85,20 @@ int main(void)
   SystemClock_Config();\r
 \r
   /* USER CODE BEGIN SysInit */\r
-\r
+  SystemPreInit();\r
   /* USER CODE END SysInit */\r
 \r
   /* Initialize all configured peripherals */\r
   MX_GPIO_Init();\r
   /* USER CODE BEGIN 2 */\r
-\r
+  SystemSetup();\r
   /* USER CODE END 2 */\r
 \r
   /* Infinite loop */\r
   /* USER CODE BEGIN WHILE */\r
   while (1)\r
   {\r
+         SystemLoop();\r
     /* USER CODE END WHILE */\r
 \r
     /* USER CODE BEGIN 3 */\r