1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2025-09-04 01:05:56 +02:00

Commit initial

This commit is contained in:
Geoffrey Frogeye 2018-02-07 17:57:01 +01:00
commit e0cb79d1cc
57 changed files with 2128 additions and 0 deletions

58
chef/Makefile Normal file
View file

@ -0,0 +1,58 @@
# VARIABLES
## Compilateur
CC=gcc
# Bibliothèques
LIBS=
## Drapeaux pour le linker
LDFLAGS=
## Drapeaux pour le compilateur
CFLAGS=
## Générateurs de drapeaux pour les bibliothèques
PKG_CONFIG=pkg-config
# VARIABLES AUTOMATIQUES
ifdef LIBS
LDFLAGS += $(shell $(PKG_CONFIG) --libs $(LIBS))
CFLAGS += $(shell $(PKG_CONFIG) --cflags $(LIBS))
endif
# Par défaut on affiche les warnings et on ajoute les symboles de debug pour utiliser GDB
CFLAGS += -Wall -Wextra -pedantic -g -DDEBUG
# buildroot se charge de remplacer ces flags avec des optimisations
# RÈGLES AUTOMATIQUES DE COMPILATION
# Génération des fichiers éxecutables
bin/%: obj/%.o
$(CC) $(LDFLAGS) $^ -o $@
# On enlève les symboles inutiles pour gagner en temps de chargement de l'éxecutable
ifeq ($(DEBUG),no)
strip $@
endif
# RÈGLES DE COMPILATION
# Règle éxecutée par défaut (quand on fait juste `make`)
default: bin/testpin bin/premier
# Binaires (dont il faut spécifier les objets explicitement)
bin/premier: obj/common.o
bin/testPin: obj/testPin.o
$(CC) $(LDFLAGS) $^ -lwiringPi -o $@
# Génération des fichiers objets
obj/%.o: src/%.c src/%.h
$(CC) $(CFLAGS) -c $< -o $@
obj/%.o: src/%.c
$(CC) $(CFLAGS) -c $< -o $@
# OUTILS DE DÉVELOPPEMENT
# Supprime les fichiers automatiquement générés
clean:
rm -f obj/*
rm -f bin/*
# Au cas où des fichiers avec certains noms existent, les règles suivantes seront executées quand même
.PHONY: default clean

2
chef/bin/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

2
chef/com/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

2
chef/obj/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

9
chef/run.sh Normal file
View file

@ -0,0 +1,9 @@
#!/bin/sh
EXEC=bin/premier
LOGFILE="${2:=run.log}"
# Logging
"$EXEC" 2>&1 | while read line; do
echo "$(cat /proc/uptime | cut -d ' ' -f 1) $line" >> "$LOGFILE"
done

1
chef/src/common.c Normal file
View file

@ -0,0 +1 @@
#include "common.h"

10
chef/src/common.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef __COMMON_H_
#define __COMMON_H_
#include <stdlib.h>
#include <stdio.h>
#define SIGNAL_AVANCER 42
#endif

7
chef/src/premier.c Normal file
View file

@ -0,0 +1,7 @@
#include "premier.h"
int main() {
printf("Hello world!\n");
// avancer(10);
return 0;
}

5
chef/src/premier.h Normal file
View file

@ -0,0 +1,5 @@
#ifndef __PREMIER_H_
#include "common.h"
#endif

32
chef/src/testpin.c Normal file
View file

@ -0,0 +1,32 @@
/* Teste si une broche est connecté à une autre */
#include <stdlib.h>
#include <stdio.h>
#include <wiringPi.h>
char testPin(char input, char output) {
pinMode(output, OUTPUT);
pinMode(input, INPUT);
digitalWrite(output, 1);
delay(0);
return digitalRead(input);
}
int main(int argc, char *argv[]) {
if (argc != 3) {
printf("Usage: %s INPUT_PIN OUTPUT_PIN\n", argv[0]);
return 2;
}
if (wiringPiSetup() == -1) {
return 3;
}
char input = atoi(argv[1]);
char output = atoi(argv[2]);
char rep = testPin(input, output);
return rep;
}

0
chef/src/testpin.h Normal file
View file