Raspberry pi 将GPIO引脚拉低,作为关机前的最后一个动作

Raspberry pi 将GPIO引脚拉低,作为关机前的最后一个动作,raspberry-pi,gpio,halt,Raspberry Pi,Gpio,Halt,我想通过将GPIO引脚拉低10秒来发出断电状态的信号。我在/etc/rc.*目录中发现了运行级别。最终,“halt”命令会运行 我想编辑并重新编译halt.c文件,但找不到它。我有两个问题: 这是正确的方法吗 源代码在哪里?(等待Q1的肯定回答) 多谢各位。 Justin我没有使用Raspberry Pi,但是在大多数系统上,停止,关机和重新启动都是指向同一个二进制文件的链接。另一种方法是只编写一个程序来做你想做的事情,并使它成为在/etc/rc.d/rc0.d中调用的最后一件事。是系统关闭时所

我想通过将GPIO引脚拉低10秒来发出断电状态的信号。我在/etc/rc.*目录中发现了运行级别。最终,“halt”命令会运行

我想编辑并重新编译halt.c文件,但找不到它。我有两个问题:

  • 这是正确的方法吗
  • 源代码在哪里?(等待Q1的肯定回答)
  • 多谢各位。
    Justin

    我没有使用Raspberry Pi,但是在大多数系统上,停止关机重新启动都是指向同一个二进制文件的链接。另一种方法是只编写一个程序来做你想做的事情,并使它成为在/etc/rc.d/rc0.d中调用的最后一件事。是系统关闭时所做的。

    以下是我对这个问题的看法“powerctl\u pin”

    */

    /*
    Raspi3B电源控制引脚Raspbian Jessie
    比尔格斯——2017 CC-BY-SA 3.0
    需要WiringPIhttp://wiringpi.com/
    汇编:
    gcc-o powerctl_引脚powerctl_引脚.c-l wiringPi&&chmod+x powerctl_引脚&&
    sudo cp powerctl_引脚/箱/
    安装:
    sudo/bin/powerctl_针脚21安装
    卸载:
    sudo/bin/powerctl_引脚21卸载
    关闭:
    sudo/bin/powerctl_引脚21断电
    /bin/powerctl_pin Broadcom_pin,模式
    有效模式:关机、开机、安装、卸载
    与mosfet锁存开关配合使用
    https://easyeda.com/Bilgus/New_Project-4ce1316bb1f6402985f8d1c4f196448d
    原电路:
    http://www.mosaic-industries.com/embedded-systems/microcontroller-projects
    /树莓pi/开关电源控制器
    */
    #包括
    #包括
    #包括
    #包括//sigterm,sigint()
    #包括“wiringPi.h”
    #定义WIRINGPI_代码999/*在安装时启用错误检查*/
    #定义断电SVC“PwrCtl引脚服务”
    #定义POWEROFF\u SVC\u路径“/lib/systemd/system/”POWEROFF\u SVC
    #定义要求“shutdown.target umount.target final.target poweroff.target”
    #在“shutdown.target umount.target final.target”之后定义
    #在“systemd poweroff.service”之前定义
    #定义WANTEDBY“poweroff.target”
    #定义POWERINT_SVC“PwrCtl_Pin-Interrupt.service”
    #定义POWERINT\u SVC\u路径“/lib/systemd/system/”POWERINT\u SVC
    静态无效断电中断中断初始化(int引脚);
    静态int g_引脚=0;
    /*启用上拉-无需保持闩锁*/
    静态无效通电_引脚(内部引脚)
    {
    上拉控制(销、上拉);
    引脚模式(引脚,输入);
    }
    /*将短回路中的针脚拉低以关闭电源*/
    静态无效断电引脚(内部引脚)
    {
    拉拔控制(插销、PUD_OFF);
    INTC;
    对于(c=0;c
    
    /*
        Raspi3B Power Control Pin Raspbian Jessie
        Bilgus -- 2017 CC-BY-SA 3.0
        Requires WiringPI http://wiringpi.com/
    
        Compiling:
        gcc -o powerctl_pin powerctl_pin.c -l wiringPi && chmod +x powerctl_pin     && 
        sudo cp powerctl_pin /bin/
    
        Install:
        sudo /bin/powerctl_pin 21 install
    
        Uninstall:
        sudo /bin/powerctl_pin 21 uninstall
    
        Shutdown:
        sudo /bin/powerctl_pin 21 poweroff
    
    
        /bin/powerctl_pin Broadcom_pin#, mode
        Valid Modes: poweroff, poweron, install, uninstall
        Works with mosfet latch switch
        https://easyeda.com/Bilgus/New_Project-4ce1316bb1f6402985f8d1c4f196448d
        Original Circuit:
        http://www.mosaic-industries.com/embedded-systems/microcontroller-projects
        /raspberry-pi/on-off-power-controller