218 lines
7.0 KiB
C
218 lines
7.0 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file : main.h
|
|
* @brief : Header for main.c file.
|
|
* This file contains the common defines of the application.
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* Copyright (c) 2021 STMicroelectronics.
|
|
* All rights reserved.
|
|
*
|
|
* This software is licensed under terms that can be found in the LICENSE file
|
|
* in the root directory of this software component.
|
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
|
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
#ifndef __MAIN_H
|
|
#define __MAIN_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "stm32wlxx_hal.h"
|
|
|
|
/* Private includes ----------------------------------------------------------*/
|
|
/* USER CODE BEGIN Includes */
|
|
#include "platform.h"
|
|
/* USER CODE END Includes */
|
|
|
|
/* Exported types ------------------------------------------------------------*/
|
|
/* USER CODE BEGIN ET */
|
|
|
|
/* USER CODE END ET */
|
|
|
|
/* Exported constants --------------------------------------------------------*/
|
|
/* USER CODE BEGIN EC */
|
|
|
|
/* USER CODE END EC */
|
|
|
|
/* Exported macro ------------------------------------------------------------*/
|
|
/* USER CODE BEGIN EM */
|
|
|
|
/* USER CODE END EM */
|
|
|
|
/* Exported functions prototypes ---------------------------------------------*/
|
|
void Error_Handler(void);
|
|
|
|
/* USER CODE BEGIN EFP */
|
|
|
|
/* USER CODE END EFP */
|
|
|
|
/* Private defines -----------------------------------------------------------*/
|
|
#define RTC_N_PREDIV_S 10
|
|
#define RTC_PREDIV_S ((1<<RTC_N_PREDIV_S)-1)
|
|
#define RTC_PREDIV_A ((1<<(15-RTC_N_PREDIV_S))-1)
|
|
#if defined(STM32WL55xx)
|
|
#define LED1_Pin GPIO_PIN_15
|
|
#define LED1_GPIO_Port GPIOB
|
|
#define LED2_Pin GPIO_PIN_9
|
|
#define LED2_GPIO_Port GPIOB
|
|
#define LED3_Pin GPIO_PIN_11
|
|
#define LED3_GPIO_Port GPIOB
|
|
#define PROB2_Pin GPIO_PIN_13
|
|
#define PROB2_GPIO_Port GPIOB
|
|
#define PROB1_Pin GPIO_PIN_12
|
|
#define PROB1_GPIO_Port GPIOB
|
|
#endif
|
|
|
|
#define LED1_Pin GPIO_PIN_2
|
|
#define LED1_GPIO_Port GPIOB
|
|
|
|
#define LED1_ON HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET )
|
|
#define LED1_OFF HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET)
|
|
|
|
#define MEMS_POWER_Pin GPIO_PIN_4 // PMU_ENABLE
|
|
#define MEMS_POWER_GPIO_Port GPIOB // PMU_ENABLE
|
|
|
|
#define MEMS_RESET_Pin GPIO_PIN_4
|
|
#define MEMS_RESET_GPIO_Port GPIOB
|
|
|
|
#define PME_ON HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin, GPIO_PIN_SET )
|
|
#define PME_OFF HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin, GPIO_PIN_RESET )
|
|
|
|
#ifdef STS_O7
|
|
|
|
#define HALL1_Pin GPIO_PIN_0 // DOOR CONTACT
|
|
#define HALL1_GPIO_Port GPIOA
|
|
#define HALL1_EXTI_IRQn EXTI0_IRQn
|
|
|
|
#define HALL2_Pin GPIO_PIN_1 // EMERGENCY BUTTON OR SOS BUTTON
|
|
#define HALL2_GPIO_Port GPIOA
|
|
#define HALL2_EXTI_IRQn EXTI1_IRQn
|
|
|
|
#define HALL1_STATE HAL_GPIO_ReadPin(HALL1_GPIO_Port, HALL1_Pin)
|
|
#define HALL2_STATE HAL_GPIO_ReadPin(HALL2_GPIO_Port, HALL2_Pin)
|
|
|
|
|
|
#else
|
|
#define BUT1_Pin GPIO_PIN_0
|
|
#define BUT1_GPIO_Port GPIOA
|
|
#define BUT1_EXTI_IRQn EXTI0_IRQn
|
|
|
|
#define BUT2_Pin GPIO_PIN_1
|
|
#define BUT2_GPIO_Port GPIOA
|
|
#define BUT2_EXTI_IRQn EXTI1_IRQn
|
|
#endif
|
|
|
|
//#if defined(STM32WL55xx)
|
|
#define BUT3_Pin GPIO_PIN_6
|
|
#define BUT3_GPIO_Port GPIOC
|
|
#define BUT3_EXTI_IRQn EXTI9_5_IRQn
|
|
//#endif
|
|
|
|
#define USARTx_RX_Pin GPIO_PIN_3
|
|
#define USARTx_RX_GPIO_Port GPIOA
|
|
#define USARTx_TX_Pin GPIO_PIN_2
|
|
#define USARTx_TX_GPIO_Port GPIOA
|
|
|
|
/* USER CODE BEGIN Private defines */
|
|
/*
|
|
* STM32WL55, STM32WLE5 Clock=48Mhz 48,000,000/800khz = 60
|
|
*/
|
|
#define STS_LAMP_BAR_PWM_TIM_PERIOD (60 - 1)
|
|
#define STS_LAMP_BAR_HTIM htim1
|
|
#define STS_LAMP_BAR_LED_NUM (50)
|
|
|
|
#define WSDATA_PORT_PIN_PA8
|
|
//#define WSDATA_PORT_PIN_PA9
|
|
|
|
#ifdef WSDATA_PORT_PIN_PA8
|
|
#define STS_LAMP_BAR_TIM_CHANNEL TIM_CHANNEL_1
|
|
#define STS_LAMP_BAR_WSDATA_PIN GPIO_PIN_8
|
|
#define STS_LAMP_BAR_WSDATA_PORT GPIOA
|
|
#elif defined(WSDATA_PORT_PIN_PA9)
|
|
#define STS_LAMP_BAR_TIM_CHANNEL TIM_CHANNEL_2
|
|
#define STS_LAMP_BAR_WSDATA_PIN GPIO_PIN_9
|
|
#define STS_LAMP_BAR_WSDATA_PORT GPIOA
|
|
#endif
|
|
|
|
|
|
#define STS_SERVICE_MASK_L0 (0) // Service normal , no mask off
|
|
#define STS_SERVICE_MASK_L1 (1) // service mask level 1, sensing data upload in silence mode, node appearance silence (no LED, No display, no sound, no vibration)
|
|
#define STS_SERVICE_MASK_L2 (2) // service mask level 2, NO sensing data upload (event or periodicity)
|
|
#define STS_SERVICE_MASK_L3 (3) // service mask level 3, NO responsing to cloud control command, or config change/responding, EXCEPT STS_SERVICE_MASK_ON_OFF cmd
|
|
//#define STS_SERVICE_MASK_L4 (1<<4) // service mask level 4, level 3 + node states heart-beat(predefined long periodicity off), EXCEPT STS_SERVICE_MASK_ON_OFF cmd
|
|
|
|
|
|
/*
|
|
#define A111_SPI_MOSI_Pin GPIO_PIN_12
|
|
#define A111_SPI_MOSI_GPIO_Port GPIOA
|
|
#define A111_CS_N_Pin GPIO_PIN_15
|
|
#define A111_CS_N_GPIO_Port GPIOA
|
|
#define A111_SPI_MISO_Pin GPIO_PIN_11
|
|
#define A111_SPI_MISO_GPIO_Port GPIOA
|
|
#define A111_SPI_SCK_Pin GPIO_PIN_3
|
|
#define A111_SPI_SCK_GPIO_Port GPIOB
|
|
#define A111_ENABLE_Pin GPIO_PIN_5
|
|
#define A111_ENABLE_GPIO_Port GPIOB
|
|
#define A111_SENSOR_INTERRUPT_Pin GPIO_PIN_8
|
|
#define A111_SENSOR_INTERRUPT_GPIO_Port GPIOA
|
|
#define A111_SENSOR_INTERRUPT_EXTI_IRQn EXTI9_5_IRQn
|
|
*/
|
|
|
|
#define A111_SPI_SCK_Pin GPIO_PIN_5 //GPIO_PIN_3
|
|
#define A111_SPI_SCK_GPIO_Port GPIOA //GPIOB
|
|
#define A111_SPI_MISO_Pin GPIO_PIN_6 //GPIO_PIN_11
|
|
#define A111_SPI_MISO_GPIO_Port GPIOA //GPIOA
|
|
#define A111_SPI_MOSI_Pin GPIO_PIN_7 //GPIO_PIN_12
|
|
#define A111_SPI_MOSI_GPIO_Port GPIOA //GPIOA
|
|
#define A111_CS_N_Pin GPIO_PIN_4 //GPIO_PIN_15
|
|
#define A111_CS_N_GPIO_Port GPIOA //GPIOA
|
|
#ifdef STM32WL55
|
|
#define A111_SENSOR_INTERRUPT_Pin GPIO_PIN_8
|
|
#define A111_SENSOR_INTERRUPT_GPIO_Port GPIOA
|
|
#define A111_SENSOR_INTERRUPT_EXTI_IRQn EXTI9_5_IRQn
|
|
#define A111_ENABLE_Pin GPIO_PIN_5
|
|
#define A111_ENABLE_GPIO_Port GPIOB
|
|
#endif
|
|
|
|
#if defined(YUNHORN_STS_WLE5CCxx) && defined(RM2)
|
|
#define A111_SENSOR_INTERRUPT_Pin GPIO_PIN_5
|
|
#define A111_SENSOR_INTERRUPT_GPIO_Port GPIOB
|
|
#define A111_SENSOR_INTERRUPT_EXTI_IRQn EXTI9_5_IRQn
|
|
#define A111_ENABLE_Pin GPIO_PIN_3
|
|
#define A111_ENABLE_GPIO_Port GPIOB
|
|
#endif
|
|
|
|
#if defined(YUNHORN_STS_WLE5CCxx) && defined(RM2_1)
|
|
#define A111_SENSOR_INTERRUPT_Pin GPIO_PIN_3 // SWITCH TO PB-3, 2024-05-06
|
|
#define A111_SENSOR_INTERRUPT_GPIO_Port GPIOB
|
|
#define A111_SENSOR_INTERRUPT_EXTI_IRQn EXTI3_IRQn // SWITCH TO PB-3, 2024-05-06
|
|
#define A111_ENABLE_Pin GPIO_PIN_5 // SWITCH TO PB-5, 2024-05-06
|
|
#define A111_ENABLE_GPIO_Port GPIOB
|
|
#endif
|
|
|
|
|
|
#define A111_SPI_HANDLE hspi1
|
|
#ifndef A111_USE_SPI_DMA
|
|
#define A111_USE_SPI_DMA
|
|
#endif
|
|
|
|
|
|
|
|
/* USER CODE END Private defines */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __MAIN_H */
|