Amélioration du build avec cmake

This commit is contained in:
Samuel 2026-07-06 21:32:36 +02:00
parent 156e8258ba
commit 03b6c7c5bd
3 changed files with 20 additions and 8 deletions

12
CMakeLists.txt Normal file
View File

@ -0,0 +1,12 @@
project(RP2040_Servomoteurs C)
include(../pico_sdk_import.cmake)
add_library(RP2040_Servomoteurs
Servomoteur.c
)
target_link_libraries(RP2040_Servomoteurs
pico_stdlib
hardware_pwm
)

View File

@ -21,18 +21,15 @@ Ajouter le fichier nouvellement créé .gitmodules à votre projet.
Configuration de la compilation Configuration de la compilation
------------------------------- -------------------------------
Dans le fichier CMakeLists.txt, ajouter le fichier Servomoteur.c Dans le fichier CMakeLists.txt, ajouter le dossier du sub module:
add_executable(<MonProjet> add_subdirectory(RP2040_Servomoteurs)
...
RP2040_Servomoteurs/Servomoteur.c
)
Dans le fichier CMakeLists.txt, ajouter la bibliothèque PWM : Dans le fichier CMakeLists.txt, ajouter la bibliothèque RP2040_Servomoteur :
target_link_libraries(Modele_RPiPico target_link_libraries(Modele_RPiPico
... ...
hardware_pwm RP2040_Servomoteur
) )
Intégration au code source Intégration au code source

View File

@ -8,9 +8,12 @@
#define SERVO_VALEUR_0_5MS 261 #define SERVO_VALEUR_0_5MS 261
// Servomoteurs // Nom des GPIOs des servomoteurs.
// Ici, SERVO0 utilisera la GPIO 0 du RP2040
#define SERVO0 0 #define SERVO0 0
#define SERVO1 1 #define SERVO1 1
// Position prédéfinies
#define DOIGT_AVANCE 0, SERVO_VALEUR_1_5MS #define DOIGT_AVANCE 0, SERVO_VALEUR_1_5MS
#define DOIGT_RETRAIT 0, SERVO_VALEUR_0_5MS #define DOIGT_RETRAIT 0, SERVO_VALEUR_0_5MS