2025-03-20 11:26:08 +08:00
|
|
|
|
#ifndef __BSP_BMP390_H
|
|
|
|
|
#define __BSP_BMP390_H
|
2024-12-11 16:21:57 +08:00
|
|
|
|
|
|
|
|
|
#include "CH58x_common.h"
|
|
|
|
|
|
2025-03-20 11:26:08 +08:00
|
|
|
|
#define BMP390_IN_START (0x0001 << 0)
|
|
|
|
|
#define BMP390_OUT_START (0x0001 << 1)
|
|
|
|
|
#define BMP390_ATOM_START (0x0001 << 2)
|
|
|
|
|
#define BMP390_EVT_READ (0x0001 << 3)
|
|
|
|
|
#define BMP390_IN_READ (0x0001 << 4)
|
|
|
|
|
#define BMP390_OUT_READ (0x0001 << 5)
|
|
|
|
|
#define BMP390_ATOM_READ (0x0001 << 6)
|
2024-12-11 16:21:57 +08:00
|
|
|
|
|
2025-03-20 11:26:08 +08:00
|
|
|
|
#define CHECK_EVT_START (0x0001 << 0)
|
|
|
|
|
#define MOTOR_STOP_EVT (0x0001 << 1)
|
2025-05-24 13:53:07 +08:00
|
|
|
|
#define AUTO_CLOSE_CHECK_EVT (0x0001 << 2)
|
|
|
|
|
#define AUTO_CLOSE_TIMEOUT_EVT (0x0001 << 3)
|
2025-05-26 15:09:12 +08:00
|
|
|
|
#define MICRO_LEAK_CHECK_EVT (0x0001 << 4) // й©<D0B9><C2A9><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
2025-05-24 13:53:07 +08:00
|
|
|
|
|
|
|
|
|
#define AUTO_CLOSE_NO_FLOW_THRESHOLD 30
|
|
|
|
|
#define AUTO_CLOSE_CHECK_INTERVAL_MS (5 * 60 * 1000)
|
|
|
|
|
#define AUTO_CLOSE_CHECK_COUNT 6
|
|
|
|
|
#define AUTO_CLOSE_TOTAL_TIME_MS (30 * 60 * 1000)
|
2024-12-11 16:21:57 +08:00
|
|
|
|
|
2025-05-26 15:09:12 +08:00
|
|
|
|
#define MICRO_LEAK_CHECK_INTERVAL_MS (10000) // й©<D0B9><C2A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>10<31>룩
|
|
|
|
|
#define MICRO_LEAK_CHECK_COUNT 6 // й©<D0B9><C2A9><EFBFBD><EFBFBD>ȷ<EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD>6<EFBFBD>Σ<EFBFBD>Լ1<D4BC><31><EFBFBD>ӣ<EFBFBD>
|
|
|
|
|
|
2024-12-11 16:21:57 +08:00
|
|
|
|
void PRESS_LowPower(void);
|
|
|
|
|
|
|
|
|
|
void BSP_PRESS_Init(void);
|
2025-03-20 11:26:08 +08:00
|
|
|
|
void Function_Check(void);
|
2025-04-18 10:31:57 +08:00
|
|
|
|
extern uint8_t volatile fault_state;
|
2025-05-21 14:56:56 +08:00
|
|
|
|
extern uint8_t keydown_flag;
|
2024-12-11 16:21:57 +08:00
|
|
|
|
|
2025-05-26 15:09:12 +08:00
|
|
|
|
// й©<D0B9><C2A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>
|
|
|
|
|
void startMicroLeakDetection(void);
|
|
|
|
|
|
2024-12-11 16:21:57 +08:00
|
|
|
|
#include "bmp3.h"
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Function to select the interface between SPI and I2C.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] bmp3 : Structure instance of bmp3_dev
|
|
|
|
|
* @param[in] intf : Interface selection parameter
|
|
|
|
|
*
|
|
|
|
|
* @return Status of execution
|
|
|
|
|
* @retval 0 -> Success
|
|
|
|
|
* @retval < 0 -> Failure Info
|
|
|
|
|
*/
|
|
|
|
|
BMP3_INTF_RET_TYPE BMP390_OUT_InterfaceInit(struct bmp3_dev *bmp3, uint8_t intf);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Function for reading the sensor's registers through I2C bus.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] reg_addr : Register address.
|
|
|
|
|
* @param[out] reg_data : Pointer to the data buffer to store the read data.
|
|
|
|
|
* @param[in] len : No of bytes to read.
|
|
|
|
|
* @param[in] intf_ptr : Interface pointer
|
|
|
|
|
*
|
|
|
|
|
* @return Status of execution
|
|
|
|
|
* @retval = BMP3_INTF_RET_SUCCESS -> Success
|
|
|
|
|
* @retval != BMP3_INTF_RET_SUCCESS -> Failure Info
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
BMP3_INTF_RET_TYPE bmp3_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Function for writing the sensor's registers through I2C bus.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] reg_addr : Register address.
|
|
|
|
|
* @param[in] reg_data : Pointer to the data buffer whose value is to be written.
|
|
|
|
|
* @param[in] len : No of bytes to write.
|
|
|
|
|
* @param[in] intf_ptr : Interface pointer
|
|
|
|
|
*
|
|
|
|
|
* @return Status of execution
|
|
|
|
|
* @retval = BMP3_INTF_RET_SUCCESS -> Success
|
|
|
|
|
* @retval != BMP3_INTF_RET_SUCCESS -> Failure Info
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
BMP3_INTF_RET_TYPE bmp3_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *intf_ptr);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Function for reading the sensor's registers through SPI bus.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] reg_addr : Register address.
|
|
|
|
|
* @param[out] reg_data : Pointer to the data buffer to store the read data.
|
|
|
|
|
* @param[in] len : No of bytes to read.
|
|
|
|
|
* @param[in] intf_ptr : Interface pointer
|
|
|
|
|
*
|
|
|
|
|
* @return Status of execution
|
|
|
|
|
* @retval = BMP3_INTF_RET_SUCCESS -> Success
|
|
|
|
|
* @retval != BMP3_INTF_RET_SUCCESS -> Failure Info
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
BMP3_INTF_RET_TYPE BMP390_OUT_SPI_Read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Function for writing the sensor's registers through SPI bus.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] reg_addr : Register address.
|
|
|
|
|
* @param[in] reg_data : Pointer to the data buffer whose data has to be written.
|
|
|
|
|
* @param[in] len : No of bytes to write.
|
|
|
|
|
* @param[in] intf_ptr : Interface pointer
|
|
|
|
|
*
|
|
|
|
|
* @return Status of execution
|
|
|
|
|
* @retval = BMP3_INTF_RET_SUCCESS -> Success
|
|
|
|
|
* @retval != BMP3_INTF_RET_SUCCESS -> Failure Info
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
BMP3_INTF_RET_TYPE BMP390_OUT_SPI_Write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *intf_ptr);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief This function provides the delay for required time (Microsecond) as per the input provided in some of the
|
|
|
|
|
* APIs.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] period : The required wait time in microsecond.
|
|
|
|
|
* @param[in] intf_ptr : Interface pointer
|
|
|
|
|
*
|
|
|
|
|
* @return void.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void bmp3_delay_us(uint32_t period, void *intf_ptr);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Prints the execution status of the APIs.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] api_name : Name of the API whose execution status has to be printed.
|
|
|
|
|
* @param[in] rslt : Error code returned by the API whose execution status has to be printed.
|
|
|
|
|
*
|
|
|
|
|
* @return void.
|
|
|
|
|
*/
|
|
|
|
|
void bmp3_check_rslt(const char api_name[], int8_t rslt);
|
|
|
|
|
|
2025-05-24 13:53:07 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><D8BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
uint8_t isNoFlowDetected(void);
|
|
|
|
|
void startAutoCloseTimer(void);
|
|
|
|
|
void stopAutoCloseTimer(void);
|
2024-12-11 16:21:57 +08:00
|
|
|
|
|
|
|
|
|
#endif
|