Forráskód Böngészése

添加lora电源的的gpio控制

xuxinyi 2 hónapja
szülő
commit
61b4363bc7
3 módosított fájl, 25 hozzáadás és 6 törlés
  1. 2 0
      Core/Inc/main.h
  2. 12 1
      Core/Src/main.c
  3. 11 5
      lora_bl.ioc

+ 2 - 0
Core/Inc/main.h

@@ -61,6 +61,8 @@ void Error_Handler(void);
 #define JUGE_PIN_GPIO_Port GPIOB
 #define POWER_ON_Pin GPIO_PIN_8
 #define POWER_ON_GPIO_Port GPIOA
+#define CTL_LORA_POWER_Pin GPIO_PIN_15
+#define CTL_LORA_POWER_GPIO_Port GPIOA
 
 /* USER CODE BEGIN Private defines */
 extern uint8_t rx_buf[100];

+ 12 - 1
Core/Src/main.c

@@ -202,7 +202,7 @@ int main(void)
 
   // 将GPIO引脚拉高
   HAL_GPIO_WritePin(POWER_ON_GPIO_Port, POWER_ON_Pin, GPIO_PIN_SET);
-
+  HAL_GPIO_WritePin(POWER_ON_GPIO_Port, CTL_LORA_POWER_Pin, GPIO_PIN_RESET);
   MX_DMA_Init();
   MX_USART1_UART_Init();
   MX_USART2_UART_Init();
@@ -257,6 +257,7 @@ int main(void)
   /* Infinite loop */
   /* USER CODE BEGIN WHILE */
   printf("Device is ready\r\n");
+  printf("设备地址:0x%02X%02X\n", deviceInfo.loraDeviceAddress_H, deviceInfo.loraDeviceAddress_L);
   uint8_t i = 0;
   while (1)
   {
@@ -673,6 +674,9 @@ static void MX_GPIO_Init(void)
   /*Configure GPIO pin Output Level */
   HAL_GPIO_WritePin(POWER_ON_GPIO_Port, POWER_ON_Pin, GPIO_PIN_SET);
 
+  /*Configure GPIO pin Output Level */
+  HAL_GPIO_WritePin(CTL_LORA_POWER_GPIO_Port, CTL_LORA_POWER_Pin, GPIO_PIN_RESET);
+
   /*Configure GPIO pin : JUGE_PIN_Pin */
   GPIO_InitStruct.Pin = JUGE_PIN_Pin;
   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
@@ -686,6 +690,13 @@ static void MX_GPIO_Init(void)
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
   HAL_GPIO_Init(POWER_ON_GPIO_Port, &GPIO_InitStruct);
 
+  /*Configure GPIO pin : CTL_LORA_POWER_Pin */
+  GPIO_InitStruct.Pin = CTL_LORA_POWER_Pin;
+  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
+  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+  HAL_GPIO_Init(CTL_LORA_POWER_GPIO_Port, &GPIO_InitStruct);
+
   /* USER CODE BEGIN MX_GPIO_Init_2 */
 
   /* USER CODE END MX_GPIO_Init_2 */

+ 11 - 5
lora_bl.ioc

@@ -46,10 +46,11 @@ Mcu.Pin10=PA9
 Mcu.Pin11=PA10
 Mcu.Pin12=PA13
 Mcu.Pin13=PA14
-Mcu.Pin14=VP_RTC_VS_RTC_Activate
-Mcu.Pin15=VP_RTC_VS_RTC_Calendar
-Mcu.Pin16=VP_SYS_VS_tim3
-Mcu.Pin17=VP_TIM4_VS_ClockSourceINT
+Mcu.Pin14=PA15
+Mcu.Pin15=VP_RTC_VS_RTC_Activate
+Mcu.Pin16=VP_RTC_VS_RTC_Calendar
+Mcu.Pin17=VP_SYS_VS_tim3
+Mcu.Pin18=VP_TIM4_VS_ClockSourceINT
 Mcu.Pin2=PD0-OSC_IN
 Mcu.Pin3=PD1-OSC_OUT
 Mcu.Pin4=PA2
@@ -58,7 +59,7 @@ Mcu.Pin6=PB10
 Mcu.Pin7=PB11
 Mcu.Pin8=PB15
 Mcu.Pin9=PA8
-Mcu.PinsNb=18
+Mcu.PinsNb=19
 Mcu.ThirdPartyNb=0
 Mcu.UserConstants=
 Mcu.UserName=STM32F103C8Tx
@@ -90,6 +91,11 @@ PA13.Mode=Serial_Wire
 PA13.Signal=SYS_JTMS-SWDIO
 PA14.Mode=Serial_Wire
 PA14.Signal=SYS_JTCK-SWCLK
+PA15.GPIOParameters=GPIO_PuPd,GPIO_Label
+PA15.GPIO_Label=CTL_LORA_POWER
+PA15.GPIO_PuPd=GPIO_PULLDOWN
+PA15.Locked=true
+PA15.Signal=GPIO_Output
 PA2.Mode=Asynchronous
 PA2.Signal=USART2_TX
 PA3.Mode=Asynchronous