Commit 1f78d342 authored by Arnaud Cadot's avatar Arnaud Cadot

Moved interruption code to class Clock

parent b8fc410f
......@@ -91,24 +91,25 @@ Asservissement::Asservissement(Odometrie* _odometrie) : testMod(false), testRunn
#ifdef CAPTEURS
sensors = Sensors::getSensors();
#endif
#if 0
#ifdef ROBOTHW //on définie les interruptions possibles dues à certains ports
*((uint32_t *)(STK_CTRL_ADDR)) = 0x03; // CLKSOURCE:0 ; TICKINT: 1 ; ENABLE:1
#ifdef STM32F40_41xxx
*((uint32_t *)(STK_LOAD_ADDR)) = 21000*nb_ms_between_updates; // valeur en ms*9000 (doit etre inférieur à 0x00FFFFFF=16 777 215)
#else
*((uint32_t *)(STK_LOAD_ADDR)) = 9000*nb_ms_between_updates; // valeur en ms*9000 (doit etre inférieur à 0x00FFFFFF=16 777 215)
#endif
// le micro controlleur tourne à une frequence f (72Mhz ici), la valeur à mettre est (0.001*(f/8))*(temps en ms entre chaque update)
// voir p190 de la doc
#ifdef ROBOTHW //on définie les interruptions possibles dues à certains ports
*((uint32_t *)(STK_CTRL_ADDR)) = 0x03; // CLKSOURCE:0 ; TICKINT: 1 ; ENABLE:1
#ifdef STM32F40_41xxx
*((uint32_t *)(STK_LOAD_ADDR)) = 21000*nb_ms_between_updates; // valeur en ms*9000 (doit etre inférieur à 0x00FFFFFF=16 777 215)
#else
*((uint32_t *)(STK_LOAD_ADDR)) = 9000*nb_ms_between_updates; // valeur en ms*9000 (doit etre inférieur à 0x00FFFFFF=16 777 215)
#endif
// le micro controlleur tourne à une frequence f (72Mhz ici), la valeur à mettre est (0.001*(f/8))*(temps en ms entre chaque update)
// voir p190 de la doc
NVIC_InitTypeDef SysTick_IRQ;
NVIC_InitTypeDef SysTick_IRQ;
SysTick_IRQ.NVIC_IRQChannel = SysTick_IRQn;
SysTick_IRQ.NVIC_IRQChannelCmd = ENABLE;
SysTick_IRQ.NVIC_IRQChannelPreemptionPriority = 0;
SysTick_IRQ.NVIC_IRQChannelSubPriority = 1;
NVIC_Init(&SysTick_IRQ);
SysTick_IRQ.NVIC_IRQChannel = SysTick_IRQn;
SysTick_IRQ.NVIC_IRQChannelCmd = ENABLE;
SysTick_IRQ.NVIC_IRQChannelPreemptionPriority = 0;
SysTick_IRQ.NVIC_IRQChannelSubPriority = 1;
NVIC_Init(&SysTick_IRQ);
#endif
#endif
}
......
......@@ -5,6 +5,16 @@
#include "hardware/tourelle.h"
#include "hardware/leds.h"
#ifndef ROBOTHW
#include <QTimer>
#endif
#ifdef STM32F40_41xxx
#define HW_CLOCK_SPEED 72000000 // 72Mhz
#else
#define HW_CLOCK_SPEED 168000000 // 168Mhz
#endif
void Clock::everyTick()
{
}
......@@ -39,6 +49,23 @@ Clock::Clock()
m_last5msTick = 0;
m_matchStartTime = 0;
m_matchStarted = false;
#ifdef ROBOTHW
*((uint32_t *)(STK_CTRL_ADDR)) = 0x03; // CLKSOURCE:0 ; TICKINT: 1 ; ENABLE:1
*((uint32_t *)(STK_LOAD_ADDR)) = (0.001*HW_CLOCK_SPEED*Clock::MS_PER_TICK)/8; // (doit etre inférieur à 0x00FFFFFF=16 777 215)
/* (voir p190 de la doc) */
NVIC_InitTypeDef SysTick_IRQ;
SysTick_IRQ.NVIC_IRQChannel = SysTick_IRQn;
SysTick_IRQ.NVIC_IRQChannelCmd = ENABLE;
SysTick_IRQ.NVIC_IRQChannelPreemptionPriority = 0;
SysTick_IRQ.NVIC_IRQChannelSubPriority = 1;
NVIC_Init(&SysTick_IRQ);
#else
/* Some trick with QTimer here */
#endif
}
void Clock::tick()
......
......@@ -45,9 +45,10 @@ void Initialisation::init()
#ifdef ROBOTHW
tirette->attendreRemise();
tirette->attendreEnlevee();
Clock::getInstance()->matchStart();
#endif
*/
Clock::getInstance()->matchStart(); // Will also start the callbacks
asservissement = new Asservissement(odometrie);
#ifdef ROBOTHW
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment