传感器简介
RCWL0516传感器是一款采用多普勒雷达技术、专门检测物体移动的微波感应模块。该模块具有灵敏度高、感应距离远、可靠性强、感应角度大、供电范围广等特点。广泛应用于各种人体感应照明和防盗报警等场合。
RCWL_0516.c
1 /**
2 * @file RCWL_0516.c
3 * @brief
4 * @version 0.1
5 * @date 2019-06-28
6 *
7 * @copyright Copyright (c) 2019 Chipintelli Technology Co., Ltd.
8 *
9 */
10 /*-----------------------------------------------------------------------------
11 include
12 -----------------------------------------------------------------------------*/
13 #include "ci110x_gpio.h"
14 #include "ci110x_scu.h"
15 #include "ci110x_uart.h"
16 #include "ci_misc.h"
17 #include "ci_sensor.h"
18
19 /*-----------------------------------------------------------------------------
20 define
21 -----------------------------------------------------------------------------*/
22 #define RCWL_GPIO_GROUP (GPIO0)/*!< GPIO组 */
23 #define RCWL_GPIO_PIN (gpio_pin_2)/*!< GPIO pin脚 */
24 #define RCWL_GPIO_PAD (UART1_RX_PAD)/*!< GPIO对应PAD */
25 #define RCWL_GPIO_IRQ (GPIO0_IRQn)/*!< GPIO中断 */
26
27 /*-----------------------------------------------------------------------------
28 extern
29 -----------------------------------------------------------------------------*/
30
31 /*-----------------------------------------------------------------------------
32 struct / enum / union
33 -----------------------------------------------------------------------------*/
34
35 /*-----------------------------------------------------------------------------
36 global
37 -----------------------------------------------------------------------------*/
38
39 /*-----------------------------------------------------------------------------
40 declare
41 -----------------------------------------------------------------------------*/
42
43 /*-----------------------------------------------------------------------------
44 function
45 -----------------------------------------------------------------------------*/
46 /**
47 * @brief 初始化 rcwl-0516
48 *
49 * @param irq_callback 中断回调
50 * @retval RETURN_OK
51 * @retval RETURN_ERR
52 */
53 int32_t rcwl0516_open(void)
54 {
55 NVIC_EnableIRQ(RCWL_GPIO_IRQ);
56 Scu_SetIOReuse(RCWL_GPIO_PAD,FIRST_FUNCTION);
57 Scu_SetDeviceGate((unsigned int)RCWL_GPIO_GROUP,ENABLE);
58 Scu_Setdevice_Reset((unsigned int)RCWL_GPIO_GROUP);
59 Scu_Setdevice_ResetRelease((unsigned int)RCWL_GPIO_GROUP);
60 gpio_irq_trigger_config(RCWL_GPIO_GROUP,RCWL_GPIO_PIN,up_edges_trigger);
61 return RETURN_OK;
62 }
63
64 /**
65 * @brief 中断回调函数
66 *
67 */
68 void rcwl0516_callback(void)
69 {
70 sensor_irq_inform(SENSOR_TYPE_MICROWAVE);
71 }
72
73 /**
74 * @brief rcwl-0516 ops
75 *
76 */
77 sensor_ops_t rcwl0516_ops =
78 {
79 rcwl0516_open,
80 };
81
82 /*-----------------------------------------------------------------------------
83 end of the file
84 -----------------------------------------------------------------------------*/
RCWL_0516.h
1 /**
2 * @file RCWL0516.h
3 * @brief RCWL0516传感器的头文件
4 * @version 0.1
5 * @date 2019-07-02
6 *
7 * @copyright Copyright (c) 2019 Chipintelli Technology Co., Ltd.
8 *
9 */
10
11 #ifndef __RCWL0516_H__
12 #define __RCWL0516_H__
13
14 /**
15 * @ingroup third_device_driver
16 * @defgroup RCWL0516
17 * @brief RCWL0516传感器驱动
18 * @{
19 */
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 /*-----------------------------------------------------------------------------
26 include
27 -----------------------------------------------------------------------------*/
28
29 /*-----------------------------------------------------------------------------
30 define
31 -----------------------------------------------------------------------------*/
32
33 /*-----------------------------------------------------------------------------
34 extern
35 -----------------------------------------------------------------------------*/
36 extern sensor_ops_t rcwl0516_ops;
37
38 /*-----------------------------------------------------------------------------
39 struct / enum / union
40 -----------------------------------------------------------------------------*/
41
42 /*-----------------------------------------------------------------------------
43 global
44 -----------------------------------------------------------------------------*/
45
46 /*-----------------------------------------------------------------------------
47 function declare
48 -----------------------------------------------------------------------------*/
49
50 #ifdef __cplusplus
51 }
52 #endif
53
54 /**
55 * @}
56 */
57
58 #endif
59
60 /*-----------------------------------------------------------------------------
61 end of the file
62 -----------------------------------------------------------------------------*/