Merge remote-tracking branch 'origin/YA'

This commit is contained in:
Arnaud Vergnet 2020-11-10 14:15:24 +01:00
commit 4ca6136473
16 changed files with 348 additions and 39 deletions

View file

@ -345,7 +345,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>DLGDARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=2156,213,2522,450,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=2124,217,2535,660,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=2076,105,2660,897,0)(133=2592,151,3176,943,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@ -382,9 +382,9 @@
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>46</LineNumber>
<LineNumber>65</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134219406</Address>
<Address>134223216</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
@ -393,9 +393,32 @@
<BreakIfRCount>1</BreakIfRCount>
<Filename>../Src/main.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/main.c\46</Expression>
<Expression>\\NUCLEO_F103RB\../Src/main.c\65</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>69</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134223230</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>../Src/main.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/main.c\69</Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
<Ww>
<count>0</count>
<WinNumber>1</WinNumber>
<ItemText>counter,0x10</ItemText>
</Ww>
</WatchWindow1>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
@ -416,7 +439,7 @@
<AscS3>0</AscS3>
<aSer3>0</aSer3>
<eProf>0</eProf>
<aLa>0</aLa>
<aLa>1</aLa>
<aPa1>0</aPa1>
<AscS4>0</AscS4>
<aSer4>0</aSer4>
@ -438,6 +461,13 @@
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<LogicAnalyzers>
<Wi>
<IntNumber>0</IntNumber>
<FirstString>((PORTB &amp; 0x00000100) &gt;&gt; 8 &amp; 0x100) &gt;&gt; 8</FirstString>
<SecondString>FF000000000000000000000000000000E0FFEF400100000000000000000000000000000028504F5254422026203078303030303031303029203E3E2038000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F1400000000000000000000000000000000000000AE110008</SecondString>
</Wi>
</LogicAnalyzers>
<DebugDescription>
<Enable>1</Enable>
<EnableFlashSeq>0</EnableFlashSeq>
@ -618,6 +648,18 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>14</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\Services\Scheduler.c</PathWithFileName>
<FilenameWithoutPath>Scheduler.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@ -628,7 +670,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>14</FileNumber>
<FileNumber>15</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -640,7 +682,7 @@
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>15</FileNumber>
<FileNumber>16</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -652,7 +694,7 @@
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>16</FileNumber>
<FileNumber>17</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -664,7 +706,7 @@
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>17</FileNumber>
<FileNumber>18</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -684,7 +726,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>18</FileNumber>
<FileNumber>19</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -696,7 +738,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>19</FileNumber>
<FileNumber>20</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -708,7 +750,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>20</FileNumber>
<FileNumber>21</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -718,17 +760,29 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>22</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\LLDrivers\src\stm32f1xx_ll_gpio.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_ll_gpio.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>Doc</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>21</FileNumber>
<FileNumber>23</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -742,13 +796,13 @@
<Group>
<GroupName>Drivers/CMSIS</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>22</FileNumber>
<FileNumber>24</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -768,7 +822,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>23</FileNumber>
<FileNumber>25</FileNumber>
<FileType>2</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>

View file

@ -453,6 +453,11 @@
<FileType>1</FileType>
<FilePath>..\Services\Voltage.c</FilePath>
</File>
<File>
<FileName>Scheduler.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\Scheduler.c</FilePath>
</File>
</Files>
</Group>
<Group>
@ -498,6 +503,11 @@
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_tim.c</FilePath>
</File>
<File>
<FileName>stm32f1xx_ll_gpio.c</FileName>
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_gpio.c</FilePath>
</File>
</Files>
</Group>
<Group>
@ -982,6 +992,11 @@
<FileType>1</FileType>
<FilePath>..\Services\Voltage.c</FilePath>
</File>
<File>
<FileName>Scheduler.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\Scheduler.c</FilePath>
</File>
</Files>
</Group>
<Group>
@ -1027,6 +1042,11 @@
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_tim.c</FilePath>
</File>
<File>
<FileName>stm32f1xx_ll_gpio.c</FileName>
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_gpio.c</FilePath>
</File>
</Files>
</Group>
<Group>

View file

@ -1 +1,52 @@
#include "ADC.h"
#include "stm32f1xx_ll_bus.h" // Pour horloge
void ADC_conf(ADC_TypeDef *adc, uint32_t voie)
{
if (adc == ADC1) {
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1);
} else if (adc == ADC2) {
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC2);
}
// Division de la frequence
RCC->CFGR |= RCC_CFGR_ADCPRE_DIV6;
// Fixe le nombre de conversion à 1
adc->SQR1&= ADC_SQR1_L;
// Indique la voie a convertir
adc->SQR3|= voie;
// Calibration
adc->CR2 |= ADC_CR2_CAL_Msk;
while ((adc->CR2 & ADC_CR2_CAL_Msk));
}
void ADC_start(ADC_TypeDef *adc)
{
adc->CR2 |= ADC_CR2_ADON;
}
uint16_t ADC_readRaw(ADC_TypeDef *adc)
{
// Lancement de la conversion
adc->CR2 |= ADC_CR2_ADON;
while(!(ADC1->SR & ADC_SR_EOC)) {}
return ADC1->DR & ADC_DR_DATA_Msk;
}
double ADC_convertToVolt(uint16_t value)
{
return ((double) value) / 4095.0 * 3.3;
}
double ADC_readVolt(ADC_TypeDef *adc)
{
return ADC_convertToVolt(ADC_readRaw(adc));
}

View file

@ -1,4 +1,15 @@
#ifndef ADC_H
#define ADC_H
#include "stm32f1xx_ll_adc.h"
void ADC_conf(ADC_TypeDef *adc, uint32_t voie);
void ADC_start(ADC_TypeDef *adc);
uint16_t ADC_readRaw(ADC_TypeDef *adc);
double ADC_readVolt(ADC_TypeDef *adc);
double ADC_convertToVolt(uint16_t value);
#endif

View file

@ -173,7 +173,7 @@ void Timer_conf(TIM_TypeDef * timer, int arr, int psc)
int getArrFromFreq(float freq)
{
return (72000000 / freq) - 1;
return (72000 / freq) - 1;
}
void Timer_pwmo_conf(TIM_TypeDef * timer, int channel, float freq, float dutyCycle)

View file

@ -1 +1,58 @@
#include "USART.h"
#include "GPIO.h"
#include "stm32f1xx_ll_bus.h" // Pour horloge
void Usart_conf(USART_TypeDef *USARTx) {
int txPin;
GPIO_TypeDef *usartGpio;
if (USARTx == USART1) {
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
txPin = LL_GPIO_PIN_9;
usartGpio = GPIOA;
} else if (USARTx == USART2) {
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
txPin = LL_GPIO_PIN_2;
usartGpio = GPIOA;
} else if (USARTx == USART3) {
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART3);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
txPin = LL_GPIO_PIN_10;
usartGpio = GPIOB;
}
LL_USART_InitTypeDef usartInit;
LL_USART_StructInit(&usartInit);
usartInit.DataWidth = LL_USART_DATAWIDTH_8B;
usartInit.BaudRate = 9600;
usartInit.TransferDirection = LL_USART_DIRECTION_TX_RX;
LL_USART_Init(USARTx, &usartInit);
GPIO_conf(usartGpio, txPin, LL_GPIO_MODE_ALTERNATE, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_UP);
}
void Usart_enable(USART_TypeDef *USARTx) {
LL_USART_Enable(USARTx);
}
void sendChar(USART_TypeDef *USARTx, char c) {
LL_USART_TransmitData8(USARTx, c);
while (!LL_USART_IsActiveFlag_TXE(USARTx)) {}
}
void Usart_send(USART_TypeDef *USARTx, char *msg, int length) {
for (int i = 0; i < length; i++) {
sendChar(USARTx, msg[i]);
}
}

View file

@ -1,5 +1,10 @@
#ifndef USART_H
#define USART_H
#include "stm32f1xx_ll_usart.h"
void Usart_conf(USART_TypeDef *USARTx);
void Usart_enable(USART_TypeDef *USARTx);
void Usart_send(USART_TypeDef *USARTx, char *msg, int length);
#endif

View file

@ -1,11 +1,12 @@
#include "IncrementalEncoder.h"
#include "Timer.h"
#include "GPIO.h"
void IncrementalEncoder_conf(TIM_TypeDef * timer)
void IncrementalEncoder_conf(TIM_TypeDef * timer, GPIO_TypeDef * gpio, int pin)
{
Timer_encoder_conf(timer);
// TODO GPIO config
GPIO_conf(gpio, pin, LL_GPIO_MODE_INPUT, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_UP);
}
void IncrementalEncoder_start(TIM_TypeDef * timer)

View file

@ -9,7 +9,7 @@
* @param TIM_TypeDef Timer : indique le timer à utiliser : TIM1, TIM2, TIM3 ou TIM4
* @retval None
*/
void IncrementalEncoder_conf(TIM_TypeDef * timer);
void IncrementalEncoder_conf(TIM_TypeDef * timer, GPIO_TypeDef * gpio, int pin);
/**
* @brief Démarre le codeur incrémental associé au timer donné

23
Services/Scheduler.c Normal file
View file

@ -0,0 +1,23 @@
#include "Scheduler.h"
#include "Timer.h"
#include "stm32f1xx_ll_utils.h"
void (*it_callback_SysTick)(void);
void SysTick_Handler(void)
{
(*it_callback_SysTick)();
}
void Scheduler_conf(void (*it_callback) (void))
{
it_callback_SysTick = it_callback;
SysTick->CTRL &= ~(SysTick_CTRL_CLKSOURCE_Msk);
SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
SysTick->LOAD = 9000;
}
void Scheduler_start(void)
{
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}

22
Services/Scheduler.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef SCHEDULER_H
#define SCHEDULER_H
#include "stm32f103xb.h"
/**
* @brief Configure l'horloge interne comme ordonanceur toutes les 1ms
* @note
* @param (void)* it_callback : Tache de fond à executer
* @retval None
*/
void Scheduler_conf(void (*it_callback) (void));
/**
* @brief Démarre ordonanceur
* @note
* @param None
* @retval None
*/
void Scheduler_start(void);
#endif

View file

@ -1,11 +1,11 @@
#include "ServoMotor.h"
#include "Timer.h"
#define SERVO_MOTO_FREQ 50
void ServoMotor_conf(TIM_TypeDef * timer, int channel)
void ServoMotor_conf(TIM_TypeDef * timer, int channel, GPIO_TypeDef * gpio, int pin)
{
Timer_pwmo_conf(timer, channel, SERVO_MOTO_FREQ, 0);
Timer_pwmo_conf(timer, channel, SERVO_MOTO_FREQ, 0.5);
GPIO_conf(gpio, pin, LL_GPIO_MODE_ALTERNATE, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_UP);
}
void ServoMotor_start(TIM_TypeDef * timer)

View file

@ -2,15 +2,19 @@
#define SERVO_MOTOR_H
#include "stm32f103xb.h"
#include "Timer.h"
#include "GPIO.h"
/**
* @brief Configure le servo moteur associé au timer donné
* @note
* @param TIM_TypeDef Timer : indique le timer à utiliser : TIM1, TIM2, TIM3 ou TIM4
* int channel : Le channel utilisé par le servo moteur
* GPIO_TypeDef gpio : Le GPIO à utiliser pour la sortie de la PWM
* int pin : Le PIN associé au GPIO
* @retval None
*/
void ServoMotor_conf(TIM_TypeDef * timer, int channel);
void ServoMotor_conf(TIM_TypeDef * timer, int channel, GPIO_TypeDef * gpio, int pin);
/**
* @brief Démarre les servo moteurs associés au timer donné

View file

@ -1 +1,35 @@
#include "Sail.h"
#include "ServoMotor.h"
#include "IncrementalEncoder.h"
TIM_TypeDef * MOTOR_TIMER = TIM4;
const int MOTOR_CHANNEL = LL_TIM_CHANNEL_CH3;
GPIO_TypeDef * MOTOR_GPIO = GPIOB;
const int MOTOR_PIN = LL_GPIO_PIN_8;
TIM_TypeDef * ENCODER_TIMER = TIM3;
GPIO_TypeDef * ENCODER_GPIO = GPIOA;
const int ENCODER_PIN = LL_GPIO_PIN_5;
void Sail_conf()
{
ServoMotor_conf(MOTOR_TIMER, MOTOR_CHANNEL, MOTOR_GPIO, MOTOR_PIN);
IncrementalEncoder_conf(ENCODER_TIMER, ENCODER_GPIO, ENCODER_PIN);
}
void Sail_background()
{
}
void Sail_reset()
{
}
void Sail_start()
{
Timer_start(MOTOR_TIMER);
Timer_start(ENCODER_TIMER);
}

View file

@ -7,7 +7,7 @@
* @param None
* @retval None
*/
void Sail_conf();
void Sail_conf(void);
/**
* @brief Execute la tache de fond des voiles en fonction des valeurs récupérées par les drivers
@ -15,7 +15,7 @@ void Sail_conf();
* @param None
* @retval None
*/
void Sail_background();
void Sail_background(void);
/**
* @brief Mets la voile à 90 degres
@ -23,7 +23,7 @@ void Sail_background();
* @param None
* @retval None
*/
void Sail_reset();
void Sail_reset(void);
/**
* @brief Réinitialise la voile à sa position initiale
@ -31,6 +31,6 @@ void Sail_reset();
* @param None
* @retval None
*/
void Sail_start();
void Sail_start(void);
#endif

View file

@ -20,20 +20,45 @@
#include "stm32f1xx_ll_utils.h" // utile dans la fonction SystemClock_Config
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
#include "Chrono.h"
#include "Sail.h"
#include "Scheduler.h"
#include "ADC.h"
#include "GPIO.h"
void SystemClock_Config(void);
/* Private functions ---------------------------------------------------------*/
int counter = 1;
int adcRaw = 0;
double adcVolt = 0.0;
void backgroundTask()
{
counter++;
Sail_background();
adcRaw = ADC_readRaw(ADC1);
adcVolt = ADC_convertToVolt(adcRaw);
}
void configurePeripherals()
{
Sail_conf();
ADC_conf(ADC1, 12);
}
void startPeripherals()
{
Sail_start();
ADC_start(ADC1);
}
/**
* @brief Main program
* @param None
* @retval None
*/
Time * time;
int main(void)
{
/* Configure the system clock to 72 MHz */
@ -41,14 +66,16 @@ int main(void)
/* Add your application code here */
// Configuration chronomètre
Chrono_Conf(TIM3);
// Chrono_Conf(TIM3);
// Lancement chronomètre
Chrono_Start();
// Chrono_Start();
// time = Chrono_Read();
configurePeripherals();
startPeripherals();
time = Chrono_Read();
/* Infinite loop */
Scheduler_conf(backgroundTask);
Scheduler_start();
while (1)
{
}