]> Zhao Yanbai Git Server - acecode.git/commitdiff
add stm32
authorAceVest <zhaoyanbai@126.com>
Sun, 19 May 2019 16:09:27 +0000 (00:09 +0800)
committerAceVest <zhaoyanbai@126.com>
Sun, 19 May 2019 16:09:27 +0000 (00:09 +0800)
learn/doc/mac_bash_profile
learn/stm32/GPIO.md [new file with mode: 0644]
learn/stm32/env.md [new file with mode: 0644]

index 79bad16a12a29f042344cf24e922062a48fa44da..3bec058385809845331e51661079f5d15fb4affc 100644 (file)
@@ -26,8 +26,8 @@ CLOSECOLOR="\[\033[00m\]"
 
 #PS1='\[\033[02;37m\]\t\[\033[00m\]\[\033[01;37m\]@\[\033[01;33m\]\W\[\033[00m\]\$ '
 #PS1='\[\033[02;37m\]\t\[\033[00m\]\[\033[01;37m\]@\[\033[01;33m\]\W\[\033[00m\]\$ '
-PS1="$GRAY\t$CLOSECOLOR$WHITE@$PURPLE\h $CYAN\W$RED\$ $CLOSECOLOR"
-alias ll='ls -lGh --time-style=long-iso'
+PS1="[$GRAY\t$CLOSECOLOR]\u$WHITE@$PURPLE\h $CYAN\W$RED\$ $CLOSECOLOR"
+alias ll='ls -lGh'
 alias ls='ls -Gh'
 alias rm='rm -rf'
 alias cls='clear'
diff --git a/learn/stm32/GPIO.md b/learn/stm32/GPIO.md
new file mode 100644 (file)
index 0000000..5b0aab2
--- /dev/null
@@ -0,0 +1,52 @@
+# GPIO
+
+
+
+
+GPIO是挂在APB2下的
+
+```
+#define PERIPH_BASE 0x40000000
+#define APB2PERIPH_BASE (PERIPH_BASE+0x10000)
+#define GPIOA_BASE     (APB2PERIPH_BASE+0x0800)
+#define GPIOB_BASE     (APB2PERIPH_BASE+0x0C00)
+#define GPIOC_BASE     (APB2PERIPH_BASE+0x1000)
+#define GPIOD_BASE     (APB2PERIPH_BASE+0x1400)
+#define GPIOE_BASE     (APB2PERIPH_BASE+0x1800)
+```
+
+GPIO的时钟RCC是挂在AHB下的
+
+```
+#define AHBPERIPH_BASE (PERIPH_BASE+0x20000)
+#define RCC_BASE       (AHBPERIPH_BASE+0x1000)
+```
+
+
+假设将PB9设置为推挽输出,并不断写高低电平
+
+```
+#define APB2ENR (*(unsigned int*)(RCC_BASE+0x18))
+#define GPIOB_CRH (*(unsigned int*)(GPIOB_BASE+0x04))
+#define GPIOB_ODR (*(unsigned int*)(GPIOB_BASE+0x0C))
+#define GPIOB_BSRR (*(unsigned int*)(GPIOB_BASE+0x10))
+#define GPIOB_BRR (*(unsigned int*)(GPIOB_BASE+0x14))
+
+unsigned int pin = 9;
+
+// 使能时钟
+APB2ENR |= 1 << 3; // 使能PB的是第3个bit
+
+// 设置为推挽输出
+GPIOB_CRH &= ~(0xF<<((pin-8)*4));      // 清除CNF、MODE的比特位
+GPIOB_CRH |= 0x3<<((pin-8)*4); // 设置为推挽输出的值
+
+// 写高
+GPIOB_BSRR = 1 << pin;
+
+// 写低
+GPIOB_BRR = 1 << pin;
+
+// 取反
+GPIOB_ODR ^= 1 << pin;
+```
\ No newline at end of file
diff --git a/learn/stm32/env.md b/learn/stm32/env.md
new file mode 100644 (file)
index 0000000..6f450ba
--- /dev/null
@@ -0,0 +1,9 @@
+# ENV
+
+```
+st-flash --format ihex write blink.hex
+```
+
+```
+https://github.com/texane/stlink
+```