Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
M
Minibot
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Diego de Bernard de Fauconval
Minibot
Validations
8cb00734
Valider
8cb00734
rédigé
2 years ago
par
Diego de Bernard de Fauconval
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
bon avancement
parent
01d2e8eb
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
I2C.cpp
+80
-2
80 ajouts, 2 suppressions
I2C.cpp
Makefile
+4
-4
4 ajouts, 4 suppressions
Makefile
encoder.c
+4
-3
4 ajouts, 3 suppressions
encoder.c
avec
88 ajouts
et
9 suppressions
I2C.cpp
+
80
−
2
Voir le fichier @
8cb00734
...
@@ -8,11 +8,21 @@
...
@@ -8,11 +8,21 @@
using
namespace
std
;
using
namespace
std
;
void
takeARide
(
int
speed
);
void
StopTheRide
();
const
int
LED
=
0x08
;
const
int
LED
=
0x08
;
const
int
ON
=
0x01
;
const
int
ON
=
0x01
;
const
int
OFF
=
0x00
;
const
int
OFF
=
0x00
;
int
main
(
int
argc
,
char
const
*
argv
[])
{
const
int
ADC
=
0x48
;
const
int
PWM_PIN_RIGHT
=
23
;
const
int
M1DIR_RIGHT
=
21
;
const
int
PWM_PIN_LEFT
=
26
;
const
int
M2DIR_LEFT
=
22
;
void
useTheLED
()
{
int
fd
=
wiringPiI2CSetup
(
LED
);
int
fd
=
wiringPiI2CSetup
(
LED
);
...
@@ -22,13 +32,81 @@ int main(int argc, char const *argv[]) {
...
@@ -22,13 +32,81 @@ int main(int argc, char const *argv[]) {
printf
(
"LIGHT ON!
\n
"
);
printf
(
"LIGHT ON!
\n
"
);
}
}
delay
(
5000
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
wiringPiI2CWrite
(
fd
,
ON
);
delay
(
770
);
wiringPiI2CWrite
(
fd
,
OFF
);
delay
(
770
);
}
wiringPiI2CWrite
(
fd
,
OFF
);
wiringPiI2CWrite
(
fd
,
OFF
);
if
(
wiringPiI2CRead
(
fd
)
==
OFF
)
{
if
(
wiringPiI2CRead
(
fd
)
==
OFF
)
{
printf
(
"LIGHT OFF!
\n
"
);
printf
(
"LIGHT OFF!
\n
"
);
}
}
}
void
useADC
()
{
int
fd
=
wiringPiI2CSetup
(
ADC
);
cout
<<
wiringPiI2CRead
(
fd
)
<<
endl
;
takeARide
(
600
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
cout
<<
wiringPiI2CRead
(
fd
)
<<
endl
;
delay
(
500
);
}
StopTheRide
();
cout
<<
wiringPiI2CRead
(
fd
)
<<
endl
;
}
void
takeARide
(
int
speed
)
{
int
wheelSpeed
=
speed
;
if
(
wiringPiSetup
()
==
-
1
)
{
printf
(
"WiringPiSetup failed
\n
"
);
exit
(
EXIT_FAILURE
);
}
pinMode
(
PWM_PIN_RIGHT
,
PWM_OUTPUT
);
pinMode
(
PWM_PIN_LEFT
,
PWM_OUTPUT
);
pinMode
(
M1DIR_RIGHT
,
OUTPUT
);
pinMode
(
M2DIR_LEFT
,
OUTPUT
);
printf
(
"pin ready !
\n
"
);
digitalWrite
(
M1DIR_RIGHT
,
1
);
digitalWrite
(
M2DIR_LEFT
,
0
);
pwmWrite
(
PWM_PIN_RIGHT
,
wheelSpeed
);
pwmWrite
(
PWM_PIN_LEFT
,
wheelSpeed
);
printf
(
"There we go !
\n
"
);
}
void
StopTheRide
()
{
printf
(
"And we stop
\n
"
);
pwmWrite
(
PWM_PIN_RIGHT
,
0
);
pwmWrite
(
PWM_PIN_LEFT
,
0
);
}
int
main
(
int
argc
,
char
const
*
argv
[])
{
string
answer
;
cout
<<
"led or adc ?"
<<
endl
;
cin
>>
answer
;
if
(
answer
==
"led"
)
useTheLED
();
else
if
(
answer
==
"adc"
)
{
useADC
();
}
return
0
;
return
0
;
}
}
Ce diff est replié.
Cliquez pour l'agrandir.
Makefile
+
4
−
4
Voir le fichier @
8cb00734
...
@@ -6,8 +6,8 @@ switch : compile_switch
...
@@ -6,8 +6,8 @@ switch : compile_switch
motor
:
compile_motor
motor
:
compile_motor
sudo
./motor
sudo
./motor
led
:
compile_LED
i2c
:
compile_LED
sudo
./
led
sudo
./
i2c
# compilations
# compilations
...
@@ -18,8 +18,8 @@ compile_motor :
...
@@ -18,8 +18,8 @@ compile_motor :
gcc
-o
motor motor.c
-lwiringPi
gcc
-o
motor motor.c
-lwiringPi
compile_LED
:
compile_LED
:
g++
-o
led
I2C.cpp
-lwiringPi
g++
-o
i2c
I2C.cpp
-lwiringPi
.PHONY
:
clean
.PHONY
:
clean
clean
:
clean
:
rm
-rf
switch motor led
rm
-rf
switch motor led
i2c
Ce diff est replié.
Cliquez pour l'agrandir.
encoder.c
+
4
−
3
Voir le fichier @
8cb00734
...
@@ -14,9 +14,10 @@ const int ENC_PIN_2A = 35; //from FPGA to ENCODER -> ouput data from encod
...
@@ -14,9 +14,10 @@ const int ENC_PIN_2A = 35; //from FPGA to ENCODER -> ouput data from encod
const
int
ENC_PIN_2B
=
34
;
//from FPGA to ENCODER -> ouput data from encoder
const
int
ENC_PIN_2B
=
34
;
//from FPGA to ENCODER -> ouput data from encoder
const
int
SCK_PIN
=
14
;
//from RASPI to FPGA -> clock signal
const
int
SCK_PIN
=
14
;
//from RASPI to FPGA -> clock signal
const
int
SCK_PIN_FPGA
=
13
;
//from FPGA to ENCODER -> clock signal
const
int
SCK_PIN_FPGA
=
13
;
//from FPGA to ENCODER -> clock signal
const
int
SS_BAR_1
=
10
;
//CE0 from RASPI to FPGA -> enable encoder
const
int
SS_PIN_1
=
10
;
//CE0 from RASPI to FPGA -> enable encoder
const
int
SS_BAR_2
=
11
;
//CE1 from RASPI to FPGA -> enable encoder
const
int
SS_PIN_2
=
11
;
//CE1 from RASPI to FPGA -> enable encoder
const
int
CE0_PIN_FPGA
=
11
;
const
int
CE1_PIN_FPGA
=
11
;
int
main
(
int
argc
,
char
const
*
argv
[])
int
main
(
int
argc
,
char
const
*
argv
[])
{
{
if
(
wiringPiSetup
()
==
-
1
)
{
if
(
wiringPiSetup
()
==
-
1
)
{
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter