diff --git a/Core/Inc/main.h b/Core/Inc/main.h index 645b59b..ef5c040 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -85,7 +85,13 @@ void Error_Handler(void); #define USARTx_TX_GPIO_Port GPIOA /* USER CODE BEGIN Private defines */ +#ifdef STS_WS +#define HX711_SCK_PIN GPIO_PIN_5 +#define HX711_DOUT_PIN GPIO_PIN_6 +#define HX711_SCK_PORT GPIOA +#define HX711_DOUT_PORT GPIOA +#endif /* USER CODE END Private defines */ #ifdef __cplusplus diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h index 1f15237..de8c96a 100644 --- a/Core/Inc/sys_conf.h +++ b/Core/Inc/sys_conf.h @@ -75,7 +75,7 @@ extern "C" { * @brief Enable/Disable MCU Debugger pins (dbg serial wires) * @note by HW serial wires are ON by default, need to put them OFF to save power */ -#define DEBUGGER_ENABLED 0 +#define DEBUGGER_ENABLED 1 /** * @brief Disable Low Power mode diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c index 7cda6a6..9275388 100644 --- a/Core/Src/gpio.c +++ b/Core/Src/gpio.c @@ -79,6 +79,26 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(BUT3_GPIO_Port, &GPIO_InitStruct); +#ifdef STS_WS + //STS_Weight_Scale + + //HX711_SCK + GPIO_InitStruct.Pin = HX711_SCK_PIN; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + HAL_GPIO_Init(HX711_SCK_PORT, &GPIO_InitStruct); + + //HX711_DOUT + GPIO_InitStruct.Pin = HX711_DOUT_PIN; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + HAL_GPIO_Init(HX711_DOUT_PORT, &GPIO_InitStruct); + + HAL_GPIO_WritePin(HX711_SCK_PORT, HX711_SCK_PIN, GPIO_PIN_RESET); + +#endif /* EXTI interrupt init*/ HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0); HAL_NVIC_EnableIRQ(EXTI0_IRQn); diff --git a/Core/Src/main.c b/Core/Src/main.c index 54e48cd..a56a001 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -23,7 +23,7 @@ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ - +#include "sts_weight_scale.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -85,9 +85,14 @@ int main(void) /* Initialize all configured peripherals */ MX_GPIO_Init(); + MX_LoRaWAN_Init(); /* USER CODE BEGIN 2 */ + APP_LOG(TS_OFF, VLEVEL_M, "\r\n ----- Start ----- \r\n"); + + sts_weight_scale(); + /* USER CODE END 2 */ /* Infinite loop */ @@ -95,6 +100,8 @@ int main(void) while (1) { /* USER CODE END WHILE */ + + MX_LoRaWAN_Process(); /* USER CODE BEGIN 3 */ diff --git a/STM32CubeIDE/.cproject b/STM32CubeIDE/.cproject index 7e926ca..276e35e 100644 --- a/STM32CubeIDE/.cproject +++ b/STM32CubeIDE/.cproject @@ -124,6 +124,7 @@