Compare commits
No commits in common. "6fb6599efeafeba87608ee956beb6b5e437515c8" and "ed00a94bee8a59ee82e22af4f94ebcb6057da161" have entirely different histories.
6fb6599efe
...
ed00a94bee
6 changed files with 24 additions and 62 deletions
|
|
@ -1,60 +1,21 @@
|
||||||
#include "Driver_ADC.h"
|
#ifndef MYADC_H
|
||||||
|
#define MYADC_H
|
||||||
|
|
||||||
|
#include "stm32f10x.h"
|
||||||
#include "Driver_GPIO.h"
|
#include "Driver_GPIO.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
void (*PtrfctADC)(void); //Déclaration du pointeur de fonction ADC
|
{
|
||||||
|
ADC_TypeDef * ADC;
|
||||||
//---------------------INIT-------------------//
|
char Channel;
|
||||||
void MyADC_Base_Init(MyADC_Struct_TypeDef * ADC){
|
} MyADC_Struct_TypeDef;
|
||||||
|
|
||||||
MyGPIO_Struct_TypeDef * GPIO_ADC; //Déclaration du GPIO de l'ADC
|
|
||||||
|
|
||||||
|
|
||||||
RCC->CFGR |= RCC_CFGR_ADCPRE_DIV6; //Division par 6 de la clock (72MHz) pour l'ADC (12MHz)
|
void MyADC_Base_Init(MyADC_Struct_TypeDef * ADC);
|
||||||
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN; //Start clock ADC1
|
void MyADC_Base_Start(ADC_TypeDef * ADC);
|
||||||
|
void MyADC_Base_Stop(ADC_TypeDef * ADC);
|
||||||
|
void MyADC_Base_Interuption(ADC_TypeDef * ADC);
|
||||||
|
int MyADC_Base_Result (MyADC_Struct_TypeDef * ADC);
|
||||||
|
void MyADC_Init_Periph (void (*fct)(void));
|
||||||
|
|
||||||
GPIO_ADC->GPIO = GPIOC; //Initialisation du GPIO de l'ADC
|
#endif
|
||||||
GPIO_ADC->GPIO_Conf = In_Analog;
|
|
||||||
GPIO_ADC->GPIO_Pin = 0;
|
|
||||||
MyGPIO_Init(GPIO_ADC);
|
|
||||||
|
|
||||||
|
|
||||||
ADC1->SQR1 &= ADC_SQR1_L; //fixe le nombre de conversion à 1
|
|
||||||
ADC1->SQR3|= ADC->Channel; //indique la voie à convertir
|
|
||||||
ADC1->CR2 |= ADC_CR2_EXTTRIG; //activation du trigger externe
|
|
||||||
ADC1->CR2 |= ADC_CR2_EXTSEL; //event externe choisis : SWSTART
|
|
||||||
|
|
||||||
MyADC_Base_Start(ADC->ADC); //Sart ADC1 et Horloge ADC1
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------START-------------------//
|
|
||||||
void MyADC_Base_Start(ADC_TypeDef * ADC){
|
|
||||||
ADC1->CR2 |= ADC_CR2_ADON;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------INTERRUPTION--------------//
|
|
||||||
void MyADC_Base_Interuption(ADC_TypeDef * ADC){
|
|
||||||
//Activation du trigger externe
|
|
||||||
ADC->CR1 |= ADC_CR1_EOCIE; //Interruption de l'ADC autorisée
|
|
||||||
NVIC->ISER[0] |= (0x1<<ADC1_2_IRQn); //Interruption active au niveau NVIC
|
|
||||||
NVIC->IP[ADC1_2_IRQn] |= 1<<4; //Affectation du niveau de priorité
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------HANDLER-----------------//
|
|
||||||
void ADC1_2_IRQHandler (void) {
|
|
||||||
(*PtrfctADC)(); //Appel de la fonction pointée par le pointeur fonction ADC
|
|
||||||
MyADC_Base_Start(ADC1);
|
|
||||||
ADC1->SR &= ~ADC_SR_EOC; //RAZ du flag end of conversion
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------DATA--------------------//
|
|
||||||
int MyADC_Base_Result (MyADC_Struct_TypeDef * ADC){
|
|
||||||
return ADC1->DR & ~((0x0F)<<12); //Retour de la conversion de l'ADC
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------POINTEUR-----------------//
|
|
||||||
void MyADC_Init_Periph (void (*fct)(void)){
|
|
||||||
PtrfctADC=fct; //Affectation du pointeur de fonction ADC
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "Driver_Timer.h"
|
#include "Driver_Timer.h"
|
||||||
|
#include "Driver_Timer.c"
|
||||||
#include "Driver_UART.h"
|
#include "Driver_UART.h"
|
||||||
#include "Plateau.h"
|
#include "Plateau.h"
|
||||||
#include "Driver_GPIO.h"
|
#include "Driver_GPIO.h"
|
||||||
|
|
@ -21,9 +22,9 @@ void Plateau_init(void)
|
||||||
MyTimer_Base_Init(&Timer);
|
MyTimer_Base_Init(&Timer);
|
||||||
MyGPIO_Init(&Pin_Sens);
|
MyGPIO_Init(&Pin_Sens);
|
||||||
|
|
||||||
//MyTimer_PWM(TIM3, 50);
|
MyTimer_PWM(TIM3, 50);
|
||||||
|
|
||||||
//MyTimer_Base_Start(Timer);
|
MyTimer_Base_Start(Timer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -426,7 +426,7 @@
|
||||||
<GroupNumber>1</GroupNumber>
|
<GroupNumber>1</GroupNumber>
|
||||||
<FileNumber>1</FileNumber>
|
<FileNumber>1</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\Drivers\Sources\Driver_GPIO.c</PathWithFileName>
|
<PathWithFileName>..\Drivers\Sources\Driver_GPIO.c</PathWithFileName>
|
||||||
|
|
@ -462,10 +462,10 @@
|
||||||
<GroupNumber>1</GroupNumber>
|
<GroupNumber>1</GroupNumber>
|
||||||
<FileNumber>4</FileNumber>
|
<FileNumber>4</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\Drivers\Sources\Driver_ADC.c</PathWithFileName>
|
<PathWithFileName>C:\Users\chanfreau\Downloads\voilier\Drivers\Sources\Driver_ADC.c</PathWithFileName>
|
||||||
<FilenameWithoutPath>Driver_ADC.c</FilenameWithoutPath>
|
<FilenameWithoutPath>Driver_ADC.c</FilenameWithoutPath>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<bShared>0</bShared>
|
<bShared>0</bShared>
|
||||||
|
|
|
||||||
|
|
@ -401,7 +401,7 @@
|
||||||
<File>
|
<File>
|
||||||
<FileName>Driver_ADC.c</FileName>
|
<FileName>Driver_ADC.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\Drivers\Sources\Driver_ADC.c</FilePath>
|
<FilePath>C:\Users\chanfreau\Downloads\voilier\Drivers\Sources\Driver_ADC.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
@ -838,7 +838,7 @@
|
||||||
<File>
|
<File>
|
||||||
<FileName>Driver_ADC.c</FileName>
|
<FileName>Driver_ADC.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\Drivers\Sources\Driver_ADC.c</FilePath>
|
<FilePath>C:\Users\chanfreau\Downloads\voilier\Drivers\Sources\Driver_ADC.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB |
Binary file not shown.
Loading…
Reference in a new issue