mirror of
https://git.etud.insa-toulouse.fr/boujon/voilier-team-1.git
synced 2025-06-08 07:50:49 +02:00
Battery fixed, changing some priorities for interrupts. Modified ADC Interrupt function, getGauge function
This commit is contained in:
parent
8cfcdf0385
commit
30e02a0cbf
7 changed files with 44 additions and 122 deletions
15
driver/adc.c
15
driver/adc.c
|
@ -23,7 +23,7 @@ void MyADC_Init(MyADC_Struct_TypeDef * ADCStructPtr)
|
|||
ADCStructPtr->ADC->SQR3 |= ADCStructPtr->channel; //Sequence Reader, seulement le SQ1 est lu dans notre cas, nous associons un channel <20> ce dernier.
|
||||
ADCStructPtr->ADC->CR2 |= ADC_CR2_EXTTRIG; //Activation du trigger externe
|
||||
ADCStructPtr->ADC->CR2 |= ADC_CR2_EXTSEL; //Event externe choisie : SWSTART
|
||||
MyADC_ActiveIT(ADCStructPtr->ADC,1);
|
||||
MyADC_ActiveIT(ADCStructPtr->ADC,2);
|
||||
ADCStructPtr->ADC->CR2 |= ADC_CR2_ADON; //Init l'ADC
|
||||
MyADC_Base_Start(ADCStructPtr->ADC); //Debut du premier ADC
|
||||
}
|
||||
|
@ -37,8 +37,13 @@ void MyADC_ActiveIT(ADC_TypeDef * ADC, uint8_t Prio)
|
|||
|
||||
void ADC1_2_IRQHandler(void)
|
||||
{
|
||||
if (pFncADC != 0)
|
||||
(*pFncADC) (ADC1->DR); /* appel indirect de la fonction */
|
||||
MyADC_Base_Start(ADC1);
|
||||
ADC1->SR &= ~ADC_SR_EOC; //Prochaine lecture pouvant <20>tre effectu<74>e.
|
||||
if (ADC1->SR & ADC_SR_EOC)
|
||||
{
|
||||
ADC1->SR &= ~ADC_SR_EOC; //Prochaine lecture pouvant <20>tre effectu<74>e.
|
||||
if (pFncADC != 0)
|
||||
{
|
||||
(*pFncADC) (ADC1->DR); /* appel indirect de la fonction */
|
||||
}
|
||||
MyADC_Base_Start(ADC1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ void MyUART_Init(MyUART_Struct_Typedef * UARTStructPtr){
|
|||
}
|
||||
//TxD Enable, RxD Enable, USART Global Enable
|
||||
UARTStructPtr->UART->CR1 |= (USART_CR1_TE | USART_CR1_RE);
|
||||
MyUART_ActiveIT(UARTStructPtr->UART,2);
|
||||
MyUART_ActiveIT(UARTStructPtr->UART,3);
|
||||
}
|
||||
|
||||
void MyUART_InitGPIO(MyUART_Struct_Typedef * UARTStructPtr)
|
||||
|
|
|
@ -13,17 +13,20 @@ void battery(uint32_t data)
|
|||
{
|
||||
return;
|
||||
}
|
||||
float percentBattery = ((float)data)/MAX_BAT;
|
||||
if(percentBattery > 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
oldAdc = data;
|
||||
actualMinutes = rtcBattery.minutes;
|
||||
float percentBattery = ((float)data)/MAX_BAT;
|
||||
char batteryBar[13]="[__________]";
|
||||
char testChar[24];
|
||||
char testChar[25];
|
||||
|
||||
getGauge(batteryBar, percentBattery);
|
||||
sprintf(testChar,"[%.2d:%.2d] %s %.2d%%",rtcBattery.hours,rtcBattery.minutes,batteryBar,(int)(percentBattery*100));
|
||||
MyUART_SendArray(&uartCool, (uint8_t *)testChar, 24);
|
||||
|
||||
sprintf(testChar,"[%.2d:%.2d] %s %.3d%%",rtcBattery.hours,rtcBattery.minutes,batteryBar,(int)(percentBattery*100));
|
||||
MyUART_SendArray(&uartCool, (uint8_t *)testChar, 25);
|
||||
MyUART_Send(&uartCool, '\n');
|
||||
}
|
||||
|
||||
|
@ -31,10 +34,6 @@ void getGauge(char gauge[], float percent)
|
|||
{
|
||||
int i;
|
||||
percent=percent*10;
|
||||
if(percent>10)
|
||||
{
|
||||
percent = 10.0;
|
||||
}
|
||||
for(i=(10-percent)+1; i<11; i++)
|
||||
{
|
||||
gauge[i]='#';
|
||||
|
@ -54,7 +53,7 @@ char isClose(uint32_t data, uint32_t compare, int precision)
|
|||
void initBattery(void)
|
||||
{
|
||||
MyADC_Init_Periph(battery);
|
||||
MyADC_Struct_TypeDef adcBattery = {ADC1,10,cycles41d5};
|
||||
MyADC_Struct_TypeDef adcBattery = {ADC1,10,cycles239d5};
|
||||
MyADC_Init(&adcBattery);
|
||||
MyGPIO_Struct_TypeDef gpioBattery = {GPIOC,0,In_Analog};
|
||||
MyGPIO_Init(&gpioBattery);
|
||||
|
|
|
@ -42,6 +42,7 @@ void MyGirouette_Init_IT_Z(uint8_t GPIO_Pin)
|
|||
EXTI->IMR |= (0x01<<GPIO_Pin); // Autorisation de l'interruption de la ligne
|
||||
EXTI->RTSR|= (0x01<<GPIO_Pin); // Activation du déclenchement de l'interruption sur un front montant
|
||||
AFIO->EXTICR[0] &= ~(0x0000000F);// L'interruption « EXTI0 » doit être provoquée par une modification PA0
|
||||
NVIC->IP[EXTI0_IRQn] |= (1 << 0x4); //Prio de l'interruption (p.197 manuel reference RM0008 pour ADC1_IRQn)
|
||||
NVIC->ISER[0] |= (1 << (6 & 0x1F)); // Autorisation de l'interruption « EXTI0 » NUMERO 6,
|
||||
|
||||
}
|
||||
|
|
|
@ -34,13 +34,12 @@ int main (void)
|
|||
|
||||
void initImplementation(void)
|
||||
{
|
||||
initRemote();
|
||||
MyServo_Init();
|
||||
MyServo_ChangeAngle(179);
|
||||
initRemote();
|
||||
Init_accelerometre();
|
||||
MyGirouette_Init(TIM4);
|
||||
MyGirouette_Init_IT_Z(0);
|
||||
testRemote();
|
||||
MyMotor_Init();
|
||||
MyMotor_ChangeSpeed(0);
|
||||
MyMotor_ChangeDirection(HORAIRE);
|
||||
|
|
|
@ -125,7 +125,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=429,109,850,536,0)(121=247,294,668,721,0)(122=875,109,1296,536,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=123,134,717,885,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=752,272,1128,829,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=429,109,850,536,0)(121=247,294,668,721,0)(122=875,109,1296,536,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=123,134,717,885,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>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
|
@ -312,7 +312,7 @@
|
|||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ST-LINKIII-KEIL_SWO</Key>
|
||||
<Name>-U066FFF504955857567155843 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2</Name>
|
||||
<Name>-U066FFF504955857567155843 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
|
@ -395,6 +395,12 @@
|
|||
<pszMrulep></pszMrulep>
|
||||
<pSingCmdsp></pSingCmdsp>
|
||||
<pMultCmdsp></pMultCmdsp>
|
||||
<SystemViewers>
|
||||
<Entry>
|
||||
<Name>System Viewer\ADC1</Name>
|
||||
<WinId>35905</WinId>
|
||||
</Entry>
|
||||
</SystemViewers>
|
||||
<DebugDescription>
|
||||
<Enable>1</Enable>
|
||||
<EnableFlashSeq>0</EnableFlashSeq>
|
||||
|
@ -498,8 +504,8 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\driver\adc.h</PathWithFileName>
|
||||
<FilenameWithoutPath>adc.h</FilenameWithoutPath>
|
||||
<PathWithFileName>..\driver\MyI2C.h</PathWithFileName>
|
||||
<FilenameWithoutPath>MyI2C.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
|
@ -510,70 +516,22 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\driver\gpio.h</PathWithFileName>
|
||||
<FilenameWithoutPath>gpio.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\driver\MyI2C.h</PathWithFileName>
|
||||
<FilenameWithoutPath>MyI2C.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\driver\MySPI.h</PathWithFileName>
|
||||
<FilenameWithoutPath>MySPI.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\driver\timer.h</PathWithFileName>
|
||||
<FilenameWithoutPath>timer.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\driver\uart.h</PathWithFileName>
|
||||
<FilenameWithoutPath>uart.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>New Group</GroupName>
|
||||
<GroupName>MesImplementations</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -585,7 +543,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -597,7 +555,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -609,7 +567,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -621,7 +579,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -633,7 +591,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -645,9 +603,9 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\implementation\girouette.c</PathWithFileName>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<TargetName>Simulé</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pCCUsed>
|
||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
|
@ -418,16 +418,6 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\driver\uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adc.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\driver\adc.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gpio.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\driver\gpio.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MyI2C.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
|
@ -438,20 +428,10 @@
|
|||
<FileType>5</FileType>
|
||||
<FilePath>..\driver\MySPI.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>timer.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\driver\timer.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>uart.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\driver\uart.h</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>New Group</GroupName>
|
||||
<GroupName>MesImplementations</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>accelerometer.c</FileName>
|
||||
|
@ -910,16 +890,6 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\driver\uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adc.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\driver\adc.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gpio.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\driver\gpio.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MyI2C.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
|
@ -930,20 +900,10 @@
|
|||
<FileType>5</FileType>
|
||||
<FilePath>..\driver\MySPI.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>timer.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\driver\timer.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>uart.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\driver\uart.h</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>New Group</GroupName>
|
||||
<GroupName>MesImplementations</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>accelerometer.c</FileName>
|
||||
|
|
Loading…
Add table
Reference in a new issue