磁铁、舵机、网页控制、通信协议
This commit is contained in:
1 parent
230ad1254a
commit
40ee976236
17 files changed
+1879
-32
No files matched your search
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @file magnet.c
|
||||
* @brief 单 GPIO 电磁铁控制实现
|
||||
*/
|
||||
|
||||
#include "magnet.h"
|
||||
|
||||
static int s_gpio = -1; /* 未初始化 */
|
||||
|
||||
void magnet_init(int gpio)
|
||||
{
|
||||
s_gpio = gpio;
|
||||
|
||||
gpio_reset_pin(s_gpio);
|
||||
gpio_set_direction(s_gpio, GPIO_MODE_OUTPUT);
|
||||
gpio_set_level(s_gpio, 0); /* 默认关闭 */
|
||||
}
|
||||
|
||||
void magnet_set(bool on)
|
||||
{
|
||||
if (s_gpio >= 0) {
|
||||
gpio_set_level(s_gpio, on ? 1 : 0);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user