ADC +UART
This commit is contained in:
parent
30ceea84e7
commit
7f879cf7af
4 changed files with 90 additions and 15 deletions
21
Drivers/Include/Driver_ADC.h
Normal file
21
Drivers/Include/Driver_ADC.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef MYADC_H
|
||||
#define MYADC_H
|
||||
|
||||
#include "stm32f10x.h"
|
||||
#include "Driver_GPIO.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ADC_TypeDef * ADC;
|
||||
char Channel;
|
||||
} MyADC_Struct_TypeDef;
|
||||
|
||||
|
||||
void MyADC_Base_Init(MyADC_Struct_TypeDef * ADC);
|
||||
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));
|
||||
|
||||
#endif
|
|
@ -125,7 +125,7 @@
|
|||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGDARM</Key>
|
||||
<Name>(1010=75,104,451,661,1)(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=1357,482,1778,909,1)(121=-1,-1,-1,-1,0)(122=546,289,967,716,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=911,135,1505,886,0)(131=997,343,1591,1094,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=798,177,1246,591,1)(161=1383,268,1831,682,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=937,133,1313,690,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=1357,482,1778,909,0)(121=-1,-1,-1,-1,0)(122=546,289,967,716,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=911,135,1505,886,0)(131=997,343,1591,1094,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=1375,56,1823,470,0)(161=1383,268,1831,682,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=240,283,843,1034,0)(151=-1,-1,-1,-1,0)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
|
@ -143,7 +143,24 @@
|
|||
<Name>-U -O206 -S8 -C0 -P00 -N00("") -D00(00000000) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>69</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134219582</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>U:\INSA\Microcontrôleur\Projet_Voilier_grp\Voilier\GPIO_Test\Sources\Main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\GPIO_Test\Sources/Main.c\69</Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<Tracepoint>
|
||||
<THDelay>0</THDelay>
|
||||
</Tracepoint>
|
||||
|
@ -417,7 +434,7 @@
|
|||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>3</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Drivers\Sources\Driver_UART.c</PathWithFileName>
|
||||
|
@ -425,6 +442,18 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>4</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>C:\Users\chanfreau\Downloads\voilier\Drivers\Sources\Driver_ADC.c</PathWithFileName>
|
||||
<FilenameWithoutPath>Driver_ADC.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
|
@ -435,7 +464,7 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>4</FileNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
|
|
@ -398,6 +398,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\Drivers\Sources\Driver_UART.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>Driver_ADC.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>C:\Users\chanfreau\Downloads\voilier\Drivers\Sources\Driver_ADC.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -810,6 +815,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\Drivers\Sources\Driver_UART.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>Driver_ADC.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>C:\Users\chanfreau\Downloads\voilier\Drivers\Sources\Driver_ADC.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#include "Driver_GPIO.h"
|
||||
#include "Driver_Timer.h"
|
||||
#include "Driver_UART.h"
|
||||
#include "Driver_ADC.h"
|
||||
|
||||
|
||||
char data[] = "Hello World";
|
||||
int i = 0;
|
||||
int len = sizeof(data) - 1; // -1 pour ne pas envoyer le caractère nul
|
||||
void ADC_interrup(void);
|
||||
|
||||
int main (void){
|
||||
//Déclaration d'une LED et d'un BP par structure GPIO
|
||||
|
@ -14,7 +17,8 @@ int main (void){
|
|||
//Déclaration d'un Timer 500 ms
|
||||
MyTimer_Struct_TypeDef TIM500ms;
|
||||
|
||||
|
||||
//Déclaration ADC de Test
|
||||
MyADC_Struct_TypeDef ADCTEST;
|
||||
//Config LED PA5
|
||||
LED.GPIO_Conf = Out_Ppull;
|
||||
LED.GPIO_Pin = 5;
|
||||
|
@ -49,7 +53,7 @@ int main (void){
|
|||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
//NVIC_EnableIRQ(USART1_IRQn);// Activer les interruptions
|
||||
UART_InitGPIO(&UART);
|
||||
// Envoyer les données
|
||||
|
@ -57,18 +61,19 @@ int main (void){
|
|||
UART_send(data[i]);
|
||||
}
|
||||
|
||||
UART_read(data[i], &UART);
|
||||
|
||||
//UART_read(data[i], &UART);
|
||||
*/
|
||||
|
||||
|
||||
//ADC
|
||||
//TEST ADC//
|
||||
ADCTEST.ADC = ADC1;
|
||||
ADCTEST.Channel = 0;
|
||||
MyADC_Base_Init(&ADCTEST);
|
||||
MyADC_Base_Interuption(ADCTEST.ADC);
|
||||
MyADC_Init_Periph(ADC_interrup);
|
||||
|
||||
while(1){
|
||||
// if (MyGPIO_Read(BP.GPIO,BP.GPIO_Pin)==0){
|
||||
// MyGPIO_Set(LED.GPIO,LED.GPIO_Pin);
|
||||
// }else{
|
||||
// MyGPIO_Reset(LED.GPIO,LED.GPIO_Pin);
|
||||
// }
|
||||
|
||||
MyADC_Base_Start(ADCTEST.ADC);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,3 +84,13 @@ void TIM2_IRQHandler (void)
|
|||
TIM2->SR &= ~(1<<0);
|
||||
}
|
||||
*/
|
||||
void Timer_interup(void)
|
||||
{
|
||||
MyGPIO_Toggle(GPIOA,5);
|
||||
}
|
||||
|
||||
//Interruption du programme par trigger de l'ADC
|
||||
void ADC_interrup()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue