我正在尝试开发一个驱动程序来与设备进行通信。我的驱动程序使用 sysfs 与用户空间通信,并使用 rs232 从外部设备发送/接收信息。我的 Boad 和其他设备通过 rs232 进行通信,但我不知道如何在驱动程序中使用我的 rx、tx、cts/rts 初始化此通信。我看到很多关于 tty 的信息。但没有直接使用 GPIO 进行 rs232 通信。
结构
用户 -> 板
|-----rx------|
|-----tx------|
|-----cts-----|
设备
如果有人有想法:)
谢谢
我想使用 GPIO 引脚执行 SPI 协议操作,想配置为单从操作,我必须以这种方式进行配置,我使用 STM32F100RB 微控制器和 Coocox IDE 在 windowsxp 中执行此操作。
如果任何机构有关于使用 GPIO 引脚的 SPI 协议操作配置的示例源代码,请发送给我。它对我的项目非常有帮助,提前致谢。
问候,帕万尼奥。
当我用sudo python3 program.py执行并按下de switch 1时抛出下一个异常:
Taking picture...
Picture takeng...
Traceback (most recent call last):
File "main.py", line 21, in <module>
if GPIO.input(switch1):
RuntimeError: You must setup() the GPIO channel first
Run Code Online (Sandbox Code Playgroud)
我为这个项目使用了覆盆子凸轮库和rpi.gpio库.任何人都知道我的代码中发生了什么?
import RPi.GPIO as GPIO
import time
import picamera
# initial config for gpio ports
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
# input switches
switch1 = 22
switch2 = 23
switch3 = 24
# setup
GPIO.setup(switch1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(switch2, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(switch3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# main loop
while True:
if GPIO.input(switch1):
print ("Taking picture...") …Run Code Online (Sandbox Code Playgroud) 在c++中,有没有最快的方法将“1”或“0”设置为GPIO?
现在,我们正在使用这个函数:
void gpioSet(int gpio, int value)
{
sprintf(buf, "/sys/class/gpio/gpio%d/value", gpio);
fd = open(buf, O_WRONLY);
sprintf(buf, "%d", value);
write(fd, buf, 1);
close(fd);
}
Run Code Online (Sandbox Code Playgroud)
使用这个函数,CPU在C++下需要“时间”来设置它。
这个问题的原因是我们使用的嵌入式 Linux 板在 SPI 中存在错误。我需要“手动”处理 CS(片选),并且此功能需要时间来设置或重置 CS 的 GPIO。
谢谢。
不确定我是否应该将其发布在这里,但我必须问一下。
语境 :
软件必须处理 GPIO,有些是输出(需要时写入),有些是输入(某些需要时读取,其他最好是类似中断)。
该软件是一个多线程应用程序,在 SCHED_FIFO 调度策略中具有约 10-15 个线程。
假设我有一个名为 WGPIO 的模块,它是处理 GPIO 的包装器。(顺便说一句,这是由 Linux 团队开发的。WGPIO 仍然位于用户空间,但如果需要,他们可以开发驱动程序)
这是我们所说的设计的一些伪代码。
gpio_state state = ON;
// IO_O is output. Set to ON, don't care if it's active_high or active_low btw
WGPIO_WriteOutput(IO_O,state);
// IO_I is input, read when needed
WGPIO_ReadInput(IO_I,&state);
// register callback when rising edge occurs on IO named IO_IT
WGPIO_SetCallback(IO_IT,EDGE_RISING,my_callback);
// Unmask to enable further IT-like processing
WGPIO_UnmaskIRQ(IO_IT);
Run Code Online (Sandbox Code Playgroud)
我必须能够在 …
我正在尝试在Linux中编译C代码,以便在我的Raspberry Pi上制作软盘音乐.我正在使用Scott Vincent的代码来控制GPIO引脚,但我无法编译它.我在终端中使用此命令:
gcc -o floppy_music floppy_music.c
Run Code Online (Sandbox Code Playgroud)
这是代码:
# --------------------------------------
# Written by Scott Vincent
# 16 Feb 2014
# --------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wiringPi.h>
// pin 11 = wiringPi Pin 0. Use this for motor direction.
const int dirPin = 0;
// pin 12 supports pwm mode but it turns out I didn't need pwm mode in the end!
// pin 12 = wiringPi Pin 1. Use this for stepper motor.
const int stepPin = …Run Code Online (Sandbox Code Playgroud)