Compare commits

...

15 Commits

Author SHA1 Message Date
Maxim
c863f5bf20 доработка в кабинете 2026-05-06 12:52:14 +03:00
Maxim
655a8dd474 git changes 2026-05-04 09:33:30 +03:00
Maxim
eb364c8831 После отладки 2026-05-04 09:33:00 +03:00
Maxim
e1628a6c0a WIP. Для отладки 2026-04-29 13:57:54 +03:00
sasha80
9d8910af0a Доработка. Функция для чтения параллельного порта. Пример в котором данные с параллельной шины направляются в stdout 2026-04-20 08:20:42 +03:00
sasha80
ade3b26942 Добавлен пример для работы прерывания по gpio 2026-04-15 11:34:49 +03:00
mstroh
99f2780c1f Merge pull request #417 from WiringPi/develop
WiringPi 3.18
2026-02-08 21:32:04 +01:00
Manfred Wallner
c6bdf371d5 Merge pull request #414 from WiringPi/mstroh76-patch-1
Unit test: Adjust for Pi1/Zero test hardware
2026-02-08 21:28:11 +01:00
Manfred Wallner
056d3b5332 Merge pull request #415 from WiringPi/mstroh76-patch-2
Unit test: Supporting 5 SPI CS channels
2026-02-08 21:27:46 +01:00
Manfred Wallner
c88fb22b2d Merge pull request #416 from WiringPi/mstroh76-patch-3
Unit test: Adjust MaxPWMFreq for Raspberry Pi 1 models
2026-02-08 21:27:05 +01:00
mstroh
3025af515e Adjust MaxFreq for Raspberry Pi 1 models
Updated maximum frequency settings for Raspberry Pi models.
2026-01-18 11:10:55 +01:00
mstroh
111f4f36d1 Unit test supporting 5 SPI CS channels 2026-01-17 19:45:30 +01:00
mstroh
ece0ffe62a Change ANOTHER_LISTENER_PIN to BCM 12
old has conflict with SPI CE1
2026-01-17 16:27:49 +01:00
mstroh
960b112000 Adjust for Pi1/Zero test hardware 2026-01-17 15:00:49 +01:00
mstroh
b2af17eea9 Merge pull request #366 from WiringPi/develop
Release 3.16
2025-06-06 20:22:31 +02:00
234 changed files with 318 additions and 20 deletions

0
.github/workflows/build.yml vendored Normal file → Executable file
View File

3
.gitignore vendored Normal file → Executable file
View File

@@ -5,3 +5,6 @@ lib*.so.*
debian-template/wiringPi
debian-template/wiringpi-*.deb
gpio/gpio
/.idea/
/.vscode/
/debian-template/

0
COPYING.LESSER Normal file → Executable file
View File

0
INSTALL Normal file → Executable file
View File

0
People Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
VERSION Normal file → Executable file
View File

0
debian-template/wiringPi/control_template Normal file → Executable file
View File

0
debian/.gitignore vendored Normal file → Executable file
View File

0
debian/changelog vendored Normal file → Executable file
View File

0
debian/compat vendored Normal file → Executable file
View File

0
debian/control vendored Normal file → Executable file
View File

0
debian/copyright vendored Normal file → Executable file
View File

0
debian/libwiringpi-dev.dirs vendored Normal file → Executable file
View File

0
debian/libwiringpi-dev.install vendored Normal file → Executable file
View File

0
debian/libwiringpi2.install vendored Normal file → Executable file
View File

0
debian/libwiringpi2.shlibs vendored Normal file → Executable file
View File

0
debian/rules vendored Normal file → Executable file
View File

0
debian/wiringpi.dirs vendored Normal file → Executable file
View File

0
debian/wiringpi.install vendored Normal file → Executable file
View File

0
devLib/Makefile Normal file → Executable file
View File

0
devLib/ds1302.c Normal file → Executable file
View File

0
devLib/ds1302.h Normal file → Executable file
View File

0
devLib/font.h Normal file → Executable file
View File

0
devLib/gertboard.c Normal file → Executable file
View File

0
devLib/gertboard.h Normal file → Executable file
View File

0
devLib/lcd.c Normal file → Executable file
View File

0
devLib/lcd.h Normal file → Executable file
View File

0
devLib/lcd128x64.c Normal file → Executable file
View File

0
devLib/lcd128x64.h Normal file → Executable file
View File

0
devLib/maxdetect.c Normal file → Executable file
View File

0
devLib/maxdetect.h Normal file → Executable file
View File

0
devLib/piFace.c Normal file → Executable file
View File

0
devLib/piFace.h Normal file → Executable file
View File

0
devLib/piFaceOld.c Normal file → Executable file
View File

0
devLib/piGlow.c Normal file → Executable file
View File

0
devLib/piGlow.h Normal file → Executable file
View File

0
devLib/piNes.c Normal file → Executable file
View File

0
devLib/piNes.h Normal file → Executable file
View File

0
devLib/scrollPhat.c Normal file → Executable file
View File

0
devLib/scrollPhat.h Normal file → Executable file
View File

0
devLib/scrollPhatFont.h Normal file → Executable file
View File

0
documentation/deutsch/functions.md Normal file → Executable file
View File

0
documentation/english/functions.md Normal file → Executable file
View File

0
examples/COPYING.LESSER Normal file → Executable file
View File

0
examples/Gertboard/7segments.c Normal file → Executable file
View File

0
examples/Gertboard/Makefile Normal file → Executable file
View File

0
examples/Gertboard/buttons.c Normal file → Executable file
View File

0
examples/Gertboard/gertboard.c Normal file → Executable file
View File

0
examples/Gertboard/record.c Normal file → Executable file
View File

0
examples/Gertboard/temperature.c Normal file → Executable file
View File

0
examples/Gertboard/voltmeter.c Normal file → Executable file
View File

0
examples/Gertboard/vumeter.c Normal file → Executable file
View File

5
examples/Makefile Normal file → Executable file
View File

@@ -27,7 +27,7 @@ Q ?= @
endif
#DEBUG = -g -O0
DEBUG = -O3
DEBUG = -O0 -g
CC ?= gcc
INCLUDE = -I/usr/local/include
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS)
@@ -48,7 +48,8 @@ SRC = blink.c blink8.c blink12.c \
delayTest.c serialRead.c serialTest.c okLed.c ds1302.c \
lowPower.c \
max31855.c \
rht03.c
rht03.c \
gpio-interrupt.c
OBJ = $(SRC:.c=.o)

0
examples/PiFace/Makefile Normal file → Executable file
View File

0
examples/PiFace/blink.c Normal file → Executable file
View File

0
examples/PiFace/buttons.c Normal file → Executable file
View File

0
examples/PiFace/ladder.c Normal file → Executable file
View File

0
examples/PiFace/metro.c Normal file → Executable file
View File

0
examples/PiFace/motor.c Normal file → Executable file
View File

0
examples/PiFace/reaction.c Normal file → Executable file
View File

0
examples/PiGlow/Makefile Normal file → Executable file
View File

0
examples/PiGlow/piGlow0.c Normal file → Executable file
View File

0
examples/PiGlow/piGlow1.c Normal file → Executable file
View File

0
examples/PiGlow/piglow.c Normal file → Executable file
View File

0
examples/README.TXT Normal file → Executable file
View File

0
examples/blink-thread.c Normal file → Executable file
View File

0
examples/blink.c Normal file → Executable file
View File

0
examples/blink.rtb Normal file → Executable file
View File

0
examples/blink.sh Normal file → Executable file
View File

0
examples/blink12.c Normal file → Executable file
View File

0
examples/blink12drcs.c Normal file → Executable file
View File

0
examples/blink6drcs.c Normal file → Executable file
View File

0
examples/blink8-drcn.c Normal file → Executable file
View File

0
examples/blink8.c Normal file → Executable file
View File

0
examples/clock.c Normal file → Executable file
View File

0
examples/delayTest.c Normal file → Executable file
View File

0
examples/ds1302.c Normal file → Executable file
View File

252
examples/gpio-interrupt.c Normal file
View File

@@ -0,0 +1,252 @@
/*
Чтение данных с параллельной 8-битной шины Raspberry Pi 4
и вывод в stdout (для передачи, например, в Go-сервер).
Сборка (внутри WiringPi/examples):
make really-all
Использование:
./gpio-interrupt # только stdout
./gpio-interrupt /tmp/log # stdout + лог в файл
./gpio-interrupt - # лог в stderr
Требования:
- Используется модифицированный WiringPi с функцией digitalReadPins()
*/
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
#include <time.h>
#include <sys/time.h>
#include <wiringPi.h>
/*
Подключение физические контакты на Raspberry pi4:
29 - D0
7 - D1
22 - D2
18 - D3
37 - D4
35 - D5
33 - D6
31 - D7
36 - такт
14 - GND
*/
unsigned int wr_pin = 27; // Пин сигнала записи (WR)
unsigned int pins[] = { 21, 7, 6, 5, 25, 24, 23, 22 }; // 8-битная шина данных (wPi)
const size_t out_buffer_len = 32U; // Размер логируемого пакета
const size_t fifo_buffer_len = 4096U; // Размер FIFO буфера
// ================= FIFO =================
struct fifo {
char *buffer;
size_t len;
size_t wri;
size_t rdi;
};
void fifo_reset(struct fifo* ff) {
ff->wri = 0;
ff->rdi = 0;
}
bool fifo_init(struct fifo* ff, size_t len) {
ff->buffer = malloc(len);
ff->len = len;
fifo_reset(ff);
return ff->buffer != NULL;
}
void fifo_uninit(struct fifo* ff) {
free(ff->buffer);
ff->buffer = NULL;
fifo_reset(ff);
}
size_t fifo_available(struct fifo *ff) {
if (ff->wri >= ff->rdi)
return ff->wri - ff->rdi;
else
return ff->wri + ff->len - ff->rdi;
}
bool fifo_can_write(struct fifo *ff, size_t len) {
return (ff->len - fifo_available(ff)) > len;
}
bool fifo_can_read(struct fifo *ff, size_t len) {
return fifo_available(ff) >= len;
}
bool fifo_try_read(struct fifo *ff, char* buffer, size_t len) {
if (!fifo_can_read(ff, len))
return false;
memcpy(buffer, &ff->buffer[ff->rdi], len);
ff->rdi = (ff->rdi + len) % ff->len;
return true;
}
bool fifo_try_write(struct fifo *ff, char* buffer, size_t len) {
if (!fifo_can_write(ff, len))
return false;
memcpy(&ff->buffer[ff->wri], buffer, len);
ff->wri = (ff->wri + len) % ff->len;
return true;
}
// =======================================
static struct fifo isr_ff;
// Защита от дребезга (debounce)
static volatile struct timeval last_isr_time = {0, 0};
static const long debounce_us = 5000; // 5 мс
// Обработчик прерывания
void isr_handle(void) {
struct timeval now;
gettimeofday(&now, NULL);
long diff = (now.tv_sec - last_isr_time.tv_sec) * 1000000L +
(now.tv_usec - last_isr_time.tv_usec);
if (diff < debounce_us) {
return; // игнорируем дребезг
}
last_isr_time = now;
// Читать 8 бит
char byte_read = 0xff & digitalReadPins(pins, sizeof pins / sizeof pins[0]);
fifo_try_write(&isr_ff, &byte_read, 1);
}
// ================= MAIN =================
int main(int argc, char *argv[]) {
FILE *log_file = NULL;
const char *log_path = NULL;
// Обработка аргументов
if (argc > 1) {
log_path = argv[1];
if (strcmp(log_path, "-") == 0) {
log_file = stderr;
fprintf(stderr, "=== Запуск GPIO-монитора (лог в stderr) ===\n");
} else {
log_file = fopen(log_path, "a");
if (!log_file) {
perror("Ошибка открытия лог-файла");
exit(EXIT_FAILURE);
}
fprintf(stderr, "=== Запуск GPIO-монитора (лог в %s) ===\n", log_path);
fprintf(log_file, "\n=== Новая сессия: %ld ===\n", (long)time(NULL));
fflush(log_file);
}
} else {
fprintf(stderr, "=== Запуск GPIO-монитора (только stdout) ===\n");
}
// FIFO
if (!fifo_init(&isr_ff, fifo_buffer_len)) {
perror("Ошибка инициализации FIFO");
exit(EXIT_FAILURE);
}
// WiringPi
if (wiringPiSetup() == -1) {
perror("Ошибка wiringPiSetup()");
exit(EXIT_FAILURE);
}
// Настройка WR
pinMode(wr_pin, INPUT);
pullUpDnControl(wr_pin, PUD_UP);
// Настройка шины данных
for (unsigned int i = 0; i < (sizeof pins / sizeof pins[0]); i++) {
unsigned int pin = pins[i];
// Используем подтяжку вниз (важно для стабильности)
pullUpDnControl(pin, PUD_DOWN);
pinMode(pin, INPUT);
}
// Прерывание по фронту
if (wiringPiISR(wr_pin, INT_EDGE_RISING, &isr_handle) != 0) {
perror("Ошибка wiringPiISR()");
exit(EXIT_FAILURE);
}
fprintf(stderr, "GPIO инициализированы, ожидание данных...\n");
fprintf(stderr, "Антидребезг: %ld мкс\n", debounce_us);
// Диагностика
fprintf(stderr, "Начальные состояния пинов:\n");
for (unsigned int i = 0; i < (sizeof pins / sizeof pins[0]); i++) {
fprintf(stderr, " пин %d = %d\n", pins[i], digitalRead(pins[i]));
}
char byte;
char log_buffer[out_buffer_len];
int log_index = 0;
unsigned long total_bytes = 0;
while (true) {
if (fifo_try_read(&isr_ff, &byte, 1)) {
log_buffer[log_index++] = byte;
total_bytes++;
// Вывод в stdout (побайтно)
fwrite(&byte, 1, 1, stdout);
fflush(stdout);
// Логирование блоками
if (log_index >= (int)out_buffer_len && log_file) {
fprintf(log_file, "--- Пакет #%lu (%zu байт) ---\n",
total_bytes / out_buffer_len, out_buffer_len);
for (int i = 0; i < (int)out_buffer_len; i++) {
fprintf(log_file, " [%02d] = 0x%02x (%3d)\n",
i,
(unsigned char)log_buffer[i],
(unsigned char)log_buffer[i]);
}
fflush(log_file);
// Индикатор прогресса
fprintf(stderr, ".");
if (total_bytes % (32 * 10) == 0) {
fprintf(stderr, " [%lu байт]\n", total_bytes);
}
fflush(stderr);
log_index = 0;
}
} else {
usleep(10000);
}
}
// Очистка (теоретически недостижимо, но для порядка)
if (log_file && log_file != stderr) {
fclose(log_file);
}
fifo_uninit(&isr_ff);
return EXIT_SUCCESS;
}

0
examples/header.h Normal file → Executable file
View File

0
examples/isr-osc.c Normal file → Executable file
View File

0
examples/isr.c Normal file → Executable file
View File

0
examples/isr3.c Normal file → Executable file
View File

0
examples/isr_debounce.c Normal file → Executable file
View File

0
examples/lcd-adafruit.c Normal file → Executable file
View File

0
examples/lcd.c Normal file → Executable file
View File

0
examples/lowPower.c Normal file → Executable file
View File

0
examples/max31855.c Normal file → Executable file
View File

0
examples/nes.c Normal file → Executable file
View File

0
examples/okLed.c Normal file → Executable file
View File

0
examples/pwm.c Normal file → Executable file
View File

0
examples/q2w/Makefile Normal file → Executable file
View File

0
examples/q2w/binary.c Normal file → Executable file
View File

0
examples/q2w/blink-io.c Normal file → Executable file
View File

0
examples/q2w/blink.c Normal file → Executable file
View File

0
examples/q2w/blink.sh Normal file → Executable file
View File

0
examples/q2w/bright.c Normal file → Executable file
View File

0
examples/q2w/button.c Normal file → Executable file
View File

0
examples/q2w/volts.c Normal file → Executable file
View File

0
examples/rht03.c Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More