|
发现初始化时在图形界面设置输出为置位(就是高电平),不能成功,必须在后面重新置位才行,使用时需要当心。9 W0 S# j' `$ y' l) w! d' S" i* F 详细看下文- X9 A( C% R8 O* F/ q% ^9 A static void MX_GPIO_Init(void) { LL_GPIO_InitTypeDef GPIO_InitStruct = {0};) a7 T# Z6 K- L4 t. Q / [3 Z+ R! t- n1 q /* GPIO Ports Clock Enable */5 Z- r6 e G* c3 e LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOD); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);/ p e8 B5 |" X* y6 E* o4 n LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);, D2 ^, D( \6 U5 Q' g* L 0 I& K% M" Z' x2 s a /**/ LL_GPIO_SetOutputPin(Pow_Con_GPIO_Port, Pow_Con_Pin);6 O+ F9 N& r& @8 ~' E: m; |! Q /**/7 u) l$ i, N4 X& n& z/ y LL_GPIO_SetOutputPin(SPI2_NSS_GPIO_Port, SPI2_NSS_Pin); " x: X5 ~( _" P7 v& g. T /**/ LL_GPIO_ResetOutputPin(GPIOB, Dis_Led0_Pin|Dis_Led1_Pin|Dis_Led2_Pin|Dis_Led3_Pin); " Z1 K$ H% \5 A" m, y /**/9 k9 u# Z5 H: \( O! W* e/ S LL_GPIO_ResetOutputPin(GPIOA, Dis_Led5_Pin|Dis_Led6_Pin|Dis_Led7_Pin); ; A! v- _% ?! i) {; a /**/ GPIO_InitStruct.Pin = Pow_Con_Pin;! J9 Y+ b6 e" I, Z7 k GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;1 T- ^0 r1 f _, m GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;+ [" V$ T2 Z( ]6 H" Z. k; y" `# l LL_GPIO_Init(Pow_Con_GPIO_Port, &GPIO_InitStruct);# \; C0 A% L) a( z /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_14|LL_GPIO_PIN_15; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; LL_GPIO_Init(GPIOC, &GPIO_InitStruct);- A/ N/ h6 n! M- q 7 P* r2 U9 R3 T9 c# x /**/ GPIO_InitStruct.Pin = Dis_Led0_Pin|Dis_Led1_Pin|Dis_Led2_Pin|Dis_Led3_Pin; GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_MEDIUM; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; LL_GPIO_Init(GPIOB, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = SPI2_NSS_Pin;; [! T; a7 S7 s$ d/ O GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;9 A" m5 |, L: Z/ l2 \* x1 O3 n( I4 e! @ GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;4 x, W) p3 j/ r u LL_GPIO_Init(SPI2_NSS_GPIO_Port, &GPIO_InitStruct); 9 O) u' x( z" e /**/ GPIO_InitStruct.Pin = Dis_Led5_Pin|Dis_Led6_Pin|Dis_Led7_Pin;# H# c4 P* m/ }" i9 a8 M( { GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;: M, M0 i! S: ^) r# [8 C GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_MEDIUM;) N6 B9 i6 P: q8 [' ~5 Y GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;4 I, G, J8 n. F+ S LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_15;6 ]. L& X j7 u; D: u! P2 v! f( F GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; LL_GPIO_Init(GPIOA, &GPIO_InitStruct);2 W' Z$ h2 z; \! O) i# e ) @9 M' |+ Q. r, w) x7 ^ /**/) N" W7 I+ x, @( O GPIO_InitStruct.Pin = LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_6 ; ^7 @/ a% D% N( ] |LL_GPIO_PIN_7|LL_GPIO_PIN_8;5 v# f1 A. a, U* f GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;" _2 n: y) W5 d0 b LL_GPIO_Init(GPIOB, &GPIO_InitStruct); / N+ S6 q7 H. h- A, r* W /**/6 d( s0 f; n6 r" ]2 D6 {7 \ GPIO_InitStruct.Pin = Pow_Key_Pin;, m/ m& L. a g/ m GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; LL_GPIO_Init(Pow_Key_GPIO_Port, &GPIO_InitStruct);( y5 f4 r" ^/ v* \ //必须添加下列代码,否则口初始化默认置位不成功7 P( a" u, Z( {0 } /**/ LL_GPIO_SetOutputPin(Pow_Con_GPIO_Port, Pow_Con_Pin); 4 x$ k/ n6 }' Y, K8 _* t /**/9 \% Z8 N3 q" @* D% o% ]0 ` LL_GPIO_SetOutputPin(SPI2_NSS_GPIO_Port, SPI2_NSS_Pin);9 r' J" Y; r6 |" m- N% I4 ] 1 K1 O/ g$ E8 ?6 H4 V& c: f } 0 w# u# T7 S: m; G- E* b |
![]() ![]() ![]() ![]() |
| 不知道HAL库有没有这个问题。 |
【STM32H5 评测】ADC 电压表
【STM32H5 评测】基础硬件加密与随机数性能 - STM32H5E5实测硬件AES加解密、HASH运算、TRNG真随机数输出速率与稳定性
【STM32H5 评测】NUCLEO-H5E5ZJ 使用 TrustZone 安全分区系统实践测试
【STM32H5 评测】CPU核心性能 - STM32H5E5跑 RTOS,观察任务切换速度、中断响应快慢
【STM32H5 评测】介绍、环境搭建、工程测试
#双节活动 1.在CubeMX中引用touchGFX出现的问题与解决
如何将STM32CubeMX生成的CMake工程导入STM32CubeIDE
【 逢7发帖赢大礼】1、利用CubeMX生成正点原子H7R7开发板的STM32CubeIDE工程
STM32CubeCLT 1.22.0新版本发布
【下载问题解决】关于ST官网下载软件问题解决
微信公众号
手机版