diff --git a/simulation/qtcreator-files/paprikaSimulateur/paprikaSimulateur.pro b/simulation/qtcreator-files/paprikaSimulateur/paprikaSimulateur.pro index a8569a6e17f52df4436be3c28935dbde1222aba9..2c4e01e9aa375f6ed36eb696586e921d08856462 100644 --- a/simulation/qtcreator-files/paprikaSimulateur/paprikaSimulateur.pro +++ b/simulation/qtcreator-files/paprikaSimulateur/paprikaSimulateur.pro @@ -35,10 +35,10 @@ HEADERS += \ ../../include/actionneurs/ascenseur.h \ ../../include/asservissement/pidFilterDistance.h \ ../../include/asservissement/pidFilterAngle.h \ - ../../include/asservissement/odometrie.h \ - ../../include/asservissement/commandAllerA.h \ + ../../include/asservissement/odometrie.h \ + ../../include/asservissement/commandAllerA.h \ ../../include/asservissement/command.h \ - ../../include/asservissement/asservissement.h \ + ../../include/asservissement/asservissement.h \ ../../include/simul/XMLReader.h \ ../../include/simul/TableGraphics.h \ ../../include/simul/table.h \ @@ -108,22 +108,23 @@ HEADERS += \ ../../include/strategie/benne.h \ ../../include/actionneurs/fishingNet.h \ ../../include/actionneurs/parasol.h \ - ../../include/strategie/benne.h + ../../include/strategie/benne.h \ + ../../include/clock.h SOURCES += \ ../../src/asservissement/pidFilterDistance.cpp \ - ../../src/asservissement/pidFilterAngle.cpp \ - ../../src/asservissement/commandAllerA.cpp \ + ../../src/asservissement/pidFilterAngle.cpp \ + ../../src/asservissement/commandAllerA.cpp \ ../../src/asservissement/command.cpp \ - ../../src/asservissement/asservissement.cpp \ + ../../src/asservissement/asservissement.cpp \ ../../src/actionneurs/servo.cpp \ ../../src/actionneurs/sensors.cpp \ ../../src/actionneurs/sensor.cpp \ ../../src/position.cpp \ ../../src/distance.cpp \ ../../src/angle.cpp \ - ../../src/positionPlusAngle.cpp \ + ../../src/positionPlusAngle.cpp \ ../../src/simul/XMLReader.cpp \ ../../src/simul/TableGraphics.cpp \ ../../src/simul/table.cpp \ @@ -140,12 +141,12 @@ SOURCES += \ ../../src/hardware/limitSwitchSensor.cpp \ ../../src/hardware/ligthBarrierSensor.cpp \ ../../src/hardware/ax12api.cpp \ - ../../src/hardware/leds.cpp \ + ../../src/hardware/leds.cpp \ ../../src/hardware/analogSensor.cpp \ ../../src/strategie/strategieV2.cpp \ ../../src/strategie/recalibrerOdometrie.cpp \ ../../src/strategie/mediumLevelAction.cpp \ - ../../src/strategie/actionGoTo.cpp \ + ../../src/strategie/actionGoTo.cpp \ ../../src/simul/userdata.cpp \ ../../src/simul/contactlistener.cpp \ ../../src/strategie/strategiev3.cpp \ @@ -180,7 +181,6 @@ SOURCES += \ ../../src/strategie/manipulationCoinGaucheHautPiedSolitaire.cpp \ ../../src/vec3d.cpp \ ../../src/vec2d.cpp \ - ../../src/loop.cpp \ ../../src/InitKrabiJunior.cpp \ ../../src/initkrabi.cpp \ ../../src/initialisation.cpp \ @@ -190,7 +190,8 @@ SOURCES += \ ../../src/strategie/benne.cpp \ ../../src/strategie/zoneConstruction.cpp \ ../../src/actionneurs/fishingNet.cpp \ - ../../src/actionneurs/parasol.cpp + ../../src/actionneurs/parasol.cpp \ + ../../src/clock.cpp FORMS += \ ../../include/simul/remotedebug.ui \ diff --git a/stm32/include/asservissement/asservissement.h b/stm32/include/asservissement/asservissement.h index bac57b2b3bd971fcfab2eb618d3135c4ba894f84..8b5e503400a88a8a6ea1b0a1c6955730c2ad8033 100755 --- a/stm32/include/asservissement/asservissement.h +++ b/stm32/include/asservissement/asservissement.h @@ -18,8 +18,7 @@ #include "roues.h" //#include "capteurs.h" #endif - -#include "loop.h" + #include "sensors.h" #include "constantes.h" #include "odometrie.h" diff --git a/stm32/include/clock.h b/stm32/include/clock.h new file mode 100644 index 0000000000000000000000000000000000000000..1e0c8d32931aad67e4e9bc5e721dc9402e04a44d --- /dev/null +++ b/stm32/include/clock.h @@ -0,0 +1,47 @@ +#ifndef CLOCK_H +#define CLOCK_H + +/**@brief Interuption appelée régulièrement par le microcontroleur + * @see Clock::MS_PER_TICK + */ +extern "C" void SysTick_Handler(); + +class Clock +{ + protected: + virtual void everyTick(); + virtual void every5ms(); + virtual void everySecond(); + + public: + static const unsigned long MS_PER_TICK = 5; + static const unsigned long MATCH_DURATION_MS = 90*1000; + + static Clock* getInstance(); + + unsigned long elapsedSinceStartup() const; + + void matchStart(); + unsigned long elapsedSinceMatchStart() const; + + bool isMatchStarted() const; + bool hasMatchEnded() const; + + + protected: + Clock(); + + private: + void tick(); + + friend void ::SysTick_Handler(); + + unsigned long m_tickCount; + unsigned long m_last5msTick; + unsigned long m_last1sTick; + + unsigned long m_matchStartTime; + bool m_matchStarted; +}; + +#endif // CLOCK_H diff --git a/stm32/include/initialisation.h b/stm32/include/initialisation.h index 2c06038fe716b20e4e01c3704c9d4275fcf34e52..7269ccccd3783bb5763dff55914d2c5083dc0371 100644 --- a/stm32/include/initialisation.h +++ b/stm32/include/initialisation.h @@ -8,7 +8,7 @@ #include "quadratureCoderHandler.h" #include "odometrie.h" #include "strategieV2.h" -#include "loop.h" + #include "asservissement.h" #include "interfaceServosNumeriques.h" diff --git a/stm32/include/loop.h b/stm32/include/loop.h deleted file mode 100644 index 5cde29404929210334fa7fd8be05c3e3c094e809..0000000000000000000000000000000000000000 --- a/stm32/include/loop.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef LOOP_H -#define LOOP_H - -static long systick_count = 0; - -/**@brief fonction externe appellé directement par le microcontroleur à chaque mise à jour. C'est grace à cette fonction que des actions sont exécutés à intervalle régulier */ -extern "C" void SysTick_Handler(); - - -#endif // LOOP_H diff --git a/stm32/paprika_krabi_h107.cbp b/stm32/paprika_krabi_h107.cbp index 2ef58317feccf69ac72f4dc18cccca57ab288117..7c074f7ef00c72b2fc67bd1436d15b5be474fb93 100644 --- a/stm32/paprika_krabi_h107.cbp +++ b/stm32/paprika_krabi_h107.cbp @@ -90,6 +90,7 @@ + @@ -119,6 +120,7 @@ + @@ -164,6 +166,7 @@ + @@ -195,6 +198,7 @@ + diff --git a/stm32/paprika_krabi_jr_h405.cbp b/stm32/paprika_krabi_jr_h405.cbp index 1ff6a4e5e10b3636f21c7026ac36ab10994db93a..d6daf37c005c09d4d3ff66ef8b656f809a59a41b 100644 --- a/stm32/paprika_krabi_jr_h405.cbp +++ b/stm32/paprika_krabi_jr_h405.cbp @@ -108,6 +108,7 @@ + @@ -130,7 +131,6 @@ - @@ -153,6 +153,7 @@ + diff --git a/stm32/src/asservissement/asservissement.cpp b/stm32/src/asservissement/asservissement.cpp index ef80da45eb0d5fb1a2998ea6763f07edb1e7a724..c512fda2eca5808a6564d282e0f9ea8f0b434c71 100644 --- a/stm32/src/asservissement/asservissement.cpp +++ b/stm32/src/asservissement/asservissement.cpp @@ -1,6 +1,8 @@ #include "asservissement.h" #include "strategieV2.h" -#include "ascenseur.h" +#include "ascenseur.h" + +#include "clock.h" #include "misc.h" #include "capteurCouleur.h" @@ -47,7 +49,7 @@ Asservissement * Asservissement::asservissement = NULL; //Pour que nos variables bool Asservissement::matchFini = false; const uint16_t Asservissement::nb_ms_between_updates = MS_BETWEEN_UPDATE; -Asservissement::Asservissement(Odometrie* _odometrie) : testMod(false), testRunning(false), stopped(false), engineLimit(0.5f), testDataSent(0), testDataToSend(0) +Asservissement::Asservissement(Odometrie* _odometrie) : testMod(false), testRunning(false), stopped(false), testDataSent(0), testDataToSend(0), engineLimit(0.5f) /*: seuil_collision(SEUIL_COLISION), @@ -371,7 +373,7 @@ void Asservissement::update(void) } } - if (testMod && !testRunning && testDataSent < testDataToSend && (systick_count % 10 == 0)) + if (testMod && !testRunning && testDataSent < testDataToSend && (Clock::getInstance()->elapsedSinceStartup() % (10*Clock::MS_PER_TICK) == 0)) { // send data #ifndef NO_REMOTE diff --git a/stm32/src/clock.cpp b/stm32/src/clock.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d4d5bd200edf92ab159544e2c6aab6dfb1383f69 --- /dev/null +++ b/stm32/src/clock.cpp @@ -0,0 +1,97 @@ +#include "clock.h" + +#include "asservissement/odometrie.h" +#include "asservissement/asservissement.h" +#include "hardware/tourelle.h" +#include "hardware/leds.h" + +void Clock::everyTick() +{ +} + +void Clock::every5ms() +{ + #ifndef STM32F40_41xxx + Odometrie::odometrie->update(); + Asservissement::asservissement->update(); + + Tourelle::getSingleton()->update(); + //StrategieV2::update(); + #endif +} + +void Clock::everySecond() +{ + Led::toggle(0); +} + +Clock* Clock::getInstance() +{ + static Clock* instance = 0; + if(instance == 0) + instance = new Clock(); + return instance; +} + +Clock::Clock() +{ + m_tickCount = 0; + m_last5msTick = 0; + m_matchStartTime = 0; + m_matchStarted = false; +} + +void Clock::tick() +{ + ++m_tickCount; + + everyTick(); + + if((m_tickCount - m_last5msTick) * Clock::MS_PER_TICK > 5) + { + every5ms(); + m_last5msTick = m_tickCount; + } + + if((m_tickCount - m_last5msTick) * Clock::MS_PER_TICK > 1000) + { + everySecond(); + m_last1sTick = m_tickCount; + } +} + +unsigned long Clock::elapsedSinceStartup() const +{ + return m_tickCount * Clock::MS_PER_TICK; +} + +void Clock::matchStart() +{ + if(isMatchStarted()) + return; + + m_matchStarted = true; + m_matchStartTime = m_tickCount; +} + +unsigned long Clock::elapsedSinceMatchStart() const +{ + if(isMatchStarted()) + return (m_tickCount - m_matchStartTime) * Clock::MS_PER_TICK; + return 0; +} + +bool Clock::isMatchStarted() const +{ + return m_matchStarted; +} + +bool Clock::hasMatchEnded() const +{ + return isMatchStarted() && (elapsedSinceMatchStart() >= Clock::MATCH_DURATION_MS); +} + +extern "C" void SysTick_Handler() +{ + Clock::getInstance()->tick(); +} diff --git a/stm32/src/initKrabiJunior.cpp b/stm32/src/initKrabiJunior.cpp index e5472fd50ccd08ab9c29bc6a8ef1d06367ec9df8..cb73e50d9d9bf2f23dc133ef4e103255da0cdf95 100644 --- a/stm32/src/initKrabiJunior.cpp +++ b/stm32/src/initKrabiJunior.cpp @@ -49,7 +49,7 @@ void InitKrabiJunior::initActionneurs() ServosNumeriques::initUART(1000000); ServosNumeriques::sendMode(); - Sensors* sensors = Sensors::getSingleton(); + /*Sensors* sensors = */Sensors::getSingleton(); ServosNumeriques::setLedState(1, 12); #endif } diff --git a/stm32/src/initialisation.cpp b/stm32/src/initialisation.cpp index 3d781ac43d9c9092480b3b6417dc132268edbc8a..f62f20d6c6810fc60c4c0c9104d6041865cc5f9f 100644 --- a/stm32/src/initialisation.cpp +++ b/stm32/src/initialisation.cpp @@ -7,36 +7,11 @@ #include "stm32f10x_gpio.h" #include "stm32f10x_tim.h" #endif -//#include "stm32f10x_remap.h" -#include "initialisation.h" - -#include "hardware/tourelle.h" - -//pour lancer l'update à chaque tic d'horloge -extern "C" void SysTick_Handler() -{ - // Count the number of SysTick_Handler call - systick_count++; - -#if DEBUG_BLINK_EACH_SECOND - if (systick_count%200 == 0){ - Led::toggle(0); - } -#endif - -#ifndef STM32F40_41xxx - Odometrie::odometrie->update(); +#include "initialisation.h" - //StrategieV2::update(); - - - Tourelle::getSingleton()->update(); - - Asservissement::asservissement->update(); -#endif -} +#include "clock.h" #ifdef ROBOTHW Initialisation::Initialisation(PositionPlusAngle position) : start(position), tirette(0) @@ -70,6 +45,7 @@ void Initialisation::init() #ifdef ROBOTHW tirette->attendreRemise(); tirette->attendreEnlevee(); + Clock::getInstance()->matchStart(); #endif */ asservissement = new Asservissement(odometrie); @@ -112,239 +88,5 @@ void Initialisation::setYellow(bool val) yellow = val; } -#ifdef PONEY -// Initialise le système d'horloge -void Clk_Init() -{ - //Rien pour le STM32F4, tout est déjà fait dans SystemInit(), appelée implicitement - #if defined(STM32F10X_MD) || defined(STM32F10X_CL) - // Démarre l'horloge interne (8 MHz) - RCC_HSICmd(ENABLE); - // On attend qu'elle soit allumée - while(RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET); - // Une fois demarée, on utilise celle ci - RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI); - - // Démarre l'horloge externe à 25MHz - RCC_HSEConfig(RCC_HSE_ON); - // On attend qu'elle soit allumée - while(RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET); - - - // PLL2 à (8/5) * 25Mhz = 40 Mhz - RCC_PREDIV2Config(RCC_PREDIV2_Div5); - RCC_PLL2Config(RCC_PLL2Mul_8); - // On démarre le PLL2 une fois la config entrée - RCC_PLL2Cmd(ENABLE); - // On attend qu'il soit vraiment allumé - while(RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET); - - // Initialisation du PL à (9/5) * 40MHz = 72MHz - RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div5); - RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_9); - // On démarre le PLL une fois la config entrée - RCC_PLLCmd(ENABLE); - // On attend qu'il soit vraiment allumé - while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET); - - // On démarre les composants internes au microcontroleur - RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3); // USB OTG FS clock (OTGFSCLK) - RCC_ADCCLKConfig(RCC_PCLK2_Div6); // ADC clock (ADCCLK) : 72MHz / 6 = 12MHz - RCC_PCLK2Config(RCC_HCLK_Div1); // High Speed APB clock (PCLK2) : 72Mhz - RCC_PCLK1Config(RCC_HCLK_Div2); // Low Speed APB clock (PCLK1) : 72Mhz / 2 = 36MHz - RCC_HCLKConfig(RCC_SYSCLK_Div1); // AHB clock (HCLK) : 72Mhz - // Flash 1 wait state - *(vu32 *)0x40022000 = 0x12; - // On utilise le PLL comme horloge de référence - RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); // system clock (SYSCLK) : 72MHz - #endif -} - -// Définit quelques horloges supplémentaires -void initAutresHorloges() -{ - #ifdef STM32F40_41xxx - RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA, ENABLE); - RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOB, ENABLE); - RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOC, ENABLE); - RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOD, ENABLE); - RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOE, ENABLE); - /*RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_DMA1, ENABLE); - RCC_APB2PeriphClockCmd( RCC_APB2Periph_ADC1, ENABLE); - //RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); no equivalent in F4, seems to be unecessary - - // Sharps - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); - RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC3, ENABLE); - - #elif defined(STM32F10X_MD) || defined(STM32F10X_CL) - RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); - RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); - RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); - #ifdef STM32F10X_CL // stm h107 - RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE, ENABLE); - #endif - #endif -} - - -// Mettez toutes vos initialisations de PIN dans la fonction "initialisation" -// On l'appellera ensuite dans le main au tout début pour tout initialiser d'un coup -void initialisationDesPIN() -{ - - -#ifdef STM32F10X_CL // Pour le stm32 h107 - - // Pompe à vide - - -#endif //STM32F10X_CL - -#ifdef STM32F10X_MD // pour la STM32 H103 2014 v1 : - - // Patte coté de la partie bleu ou jaune - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOB, &GPIO_InitStructure); - - // Tirette - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOE, &GPIO_InitStructure); - - // Pattes des servos - GPIO_PinRemapConfig(GPIO_FullRemap_TIM3, ENABLE); - - // servo 1 - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOC, &GPIO_InitStructure); - - // servo 2 - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOC, &GPIO_InitStructure); - - // servo 3 - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOC, &GPIO_InitStructure); - - // servo 4 - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOC, &GPIO_InitStructure); - - // LED Verte - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; // La vitesse de rafraichissement du port - GPIO_Init(GPIOC, &GPIO_InitStructure); - GPIO_WriteBit(GPIOC, GPIO_Pin_12, Bit_RESET); - -#endif //STM32F10X_MD - -#ifdef STM32F40_41xxx // pour la STM32 H405 2014 v1 : - - // Roues codeuses - GPIO_PinAFConfig (GPIOB, GPIO_PinSource6, GPIO_AF_TIM4); - GPIO_PinAFConfig (GPIOB, GPIO_PinSource7, GPIO_AF_TIM4); - GPIO_PinAFConfig (GPIOA, GPIO_PinSource8, GPIO_AF_TIM1); - GPIO_PinAFConfig (GPIOA, GPIO_PinSource9, GPIO_AF_TIM1); - - // Moteurs - GPIO_InitTypeDef GPIO_InitStructure; - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; // La vitesse de rafraichissement du port - GPIO_Init(GPIOA, &GPIO_InitStructure); - GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_SET);*/ - GPIO_PinAFConfig(GPIOA, GPIO_PinSource0, GPIO_AF_TIM2); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_TIM2); - - // Sharps - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_5; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; - GPIO_Init(GPIOC, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; - GPIO_Init(GPIOB, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 |GPIO_Pin_7; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; - GPIO_Init(GPIOA, &GPIO_InitStructure); - - // Patte coté de la partie bleu ou jaune - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOB, &GPIO_InitStructure); - - // Tirette - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOA, &GPIO_InitStructure); - - // Pattes des servos - GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_TIM3); - GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_TIM3); - GPIO_PinAFConfig(GPIOC, GPIO_PinSource8, GPIO_AF_TIM3); - GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_TIM3); - - // servo 1 - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOC, &GPIO_InitStructure); - - // servo 2 - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOC, &GPIO_InitStructure); - - // servo 3 - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOC, &GPIO_InitStructure); - - // servo 4 - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOC, &GPIO_InitStructure); - - // LED Verte - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; // La vitesse de rafraichissement du port - GPIO_Init(GPIOC, &GPIO_InitStructure); - GPIO_WriteBit(GPIOC, GPIO_Pin_12, Bit_SET); - -#endif //STM32F40_41xxx - -} -#endif //PONEY diff --git a/stm32/src/loop.cpp b/stm32/src/loop.cpp deleted file mode 100644 index a53bc15396d97a9c9c13a5dba38fc4e30b499d63..0000000000000000000000000000000000000000 --- a/stm32/src/loop.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "loop.h"