Transmission : conf et foncts
This commit is contained in:
parent
b8e0d2bcd8
commit
27c8c1a005
5 changed files with 147 additions and 20 deletions
|
@ -460,7 +460,7 @@
|
|||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>2</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Services\MyRF.c</PathWithFileName>
|
||||
|
@ -480,7 +480,7 @@
|
|||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>3</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\MyDrivers\MyTimer.c</PathWithFileName>
|
||||
|
@ -492,7 +492,7 @@
|
|||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>4</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\MyDrivers\MyPWM.c</PathWithFileName>
|
||||
|
@ -500,6 +500,18 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\MyDrivers\MyUSART.c</PathWithFileName>
|
||||
<FilenameWithoutPath>MyUSART.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
|
@ -510,7 +522,7 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileNumber>6</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -522,7 +534,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>6</FileNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -534,7 +546,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -546,7 +558,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -558,7 +570,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -578,7 +590,7 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -598,7 +610,7 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -618,7 +630,7 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>2</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
|
|
@ -412,6 +412,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\MyDrivers\MyPWM.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MyUSART.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\MyDrivers\MyUSART.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -885,6 +890,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\MyDrivers\MyPWM.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MyUSART.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\MyDrivers\MyUSART.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef PWM_H
|
||||
#define PWM_H
|
||||
#ifndef MYPWM_H
|
||||
#define MYPWM_H
|
||||
|
||||
#include "stm32f103xb.h"
|
||||
|
||||
|
|
105
Services/MyRF.c
105
Services/MyRF.c
|
@ -1,34 +1,58 @@
|
|||
#include "MyRF.h"
|
||||
#include "MyTimer.h"
|
||||
#include "MyPWM.h"
|
||||
#include "MyUSART.h"
|
||||
|
||||
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
|
||||
#include "stm32f1xx_ll_tim.h"
|
||||
#include "stm32f1xx_ll_gpio.h"
|
||||
#include "stm32f1xx_ll_usart.h"
|
||||
|
||||
|
||||
void MyRF_Conf(void) {
|
||||
|
||||
//Initialisation du GPIO
|
||||
//RX
|
||||
//Activation horloge du GPIO
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
|
||||
|
||||
LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
|
||||
|
||||
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
|
||||
|
||||
//PB.6 en floating input
|
||||
My_GPIO_Init_Struct.Pin = PinCH1;
|
||||
LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
|
||||
LL_GPIO_Init(GPIOIn, &My_GPIO_Init_Struct);
|
||||
|
||||
//PB.7 en floating input
|
||||
My_GPIO_Init_Struct.Pin = PinCH2;
|
||||
LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
|
||||
LL_GPIO_Init(GPIOIn, &My_GPIO_Init_Struct);
|
||||
|
||||
|
||||
//Configuration et lancment du Timer PWM Input
|
||||
MyTimer_Conf(TimerCC,0xFFAD,0x15);
|
||||
|
||||
MyPWM_Conf_Input(TimerCC, channelCC1, channelCC2);
|
||||
|
||||
MyTimer_Start(TimerCC);
|
||||
|
||||
//TX
|
||||
//Activation horloge du GPIO
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
|
||||
|
||||
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
|
||||
|
||||
//PA.9 en alternate output pp
|
||||
My_GPIO_Init_Struct.Pin = PinOut;
|
||||
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
LL_GPIO_Init(GPIOOut, &My_GPIO_Init_Struct);
|
||||
|
||||
//Configuration de l'USART
|
||||
MyUSART_Conf(USARTOut, TransferDirTX);
|
||||
|
||||
//Configuration Timer (interruption à 3s, callback MyRF_Transmit_3s) et lancement
|
||||
MyTimer_Conf(TimerRF,65633,3290);
|
||||
MyTimer_IT_Conf(TimerRF,MyRF_Transmit_3s,3);
|
||||
MyTimer_IT_Enable(TimerRF);
|
||||
MyTimer_Start(TimerRF);
|
||||
|
||||
}
|
||||
|
||||
int MyRF_Input_Duty_Cycle(void) {
|
||||
|
@ -36,3 +60,72 @@ int MyRF_Input_Duty_Cycle(void) {
|
|||
return (MyPWM_Duty_Cycle_Permilles(TimerCC, channelCC1, channelCC2) - 75) * 4;
|
||||
|
||||
}
|
||||
|
||||
void MyRF_Transmit_3s(void) {
|
||||
|
||||
//Récupérer :
|
||||
char bordage[3];
|
||||
char heure[2];
|
||||
char min[2];
|
||||
char sec[2];
|
||||
int allure_ref = 0;
|
||||
|
||||
char allure[7][30] = {"pas (ou vent debout).",
|
||||
"au plus près.",
|
||||
"au près.",
|
||||
"au bon plein.",
|
||||
"au travers.",
|
||||
"au grand largue.",
|
||||
"au vent arrière."
|
||||
};
|
||||
char data1[23] = "\" : le voilier navigue ";
|
||||
char data2[15] = " === Bordage : ";
|
||||
|
||||
int i;
|
||||
|
||||
//Heure
|
||||
MyUSART_Transmit_Data_8b(USARTOut, heure[0]);
|
||||
MyUSART_Transmit_Data_8b(USARTOut, heure[1]);
|
||||
MyUSART_Transmit_Data_8b(USARTOut, 'h');
|
||||
//Minutes
|
||||
MyUSART_Transmit_Data_8b(USARTOut, min[0]);
|
||||
MyUSART_Transmit_Data_8b(USARTOut, min[1]);
|
||||
MyUSART_Transmit_Data_8b(USARTOut, '\'');
|
||||
//Secondes
|
||||
MyUSART_Transmit_Data_8b(USARTOut, sec[0]);
|
||||
MyUSART_Transmit_Data_8b(USARTOut, sec[1]);
|
||||
//Texte 1 (allures)
|
||||
for(i=0; i<23; i++) {
|
||||
MyUSART_Transmit_Data_8b(USARTOut, data1[i]);
|
||||
}
|
||||
//Allure
|
||||
for(i=0; i<30; i++) {
|
||||
MyUSART_Transmit_Data_8b(USARTOut, allure[allure_ref][i]);
|
||||
}
|
||||
//Texte 2 (bordage)
|
||||
for(i=0; i<15; i++) {
|
||||
MyUSART_Transmit_Data_8b(USARTOut, data2[i]);
|
||||
}
|
||||
//Bordage
|
||||
for(i=0; i<3; i++) {
|
||||
MyUSART_Transmit_Data_8b(USARTOut, bordage[i]);
|
||||
}
|
||||
MyUSART_Transmit_Data_8b(USARTOut, '%');
|
||||
//Newline (fin)
|
||||
MyUSART_Transmit_Data_8b(USARTOut, '\n');
|
||||
|
||||
}
|
||||
|
||||
void MyRF_Transmit_Batterie_Faible(void) {
|
||||
char data[24] = "/!\\ BATTERIE FAIBLE /!\\\n";
|
||||
for(int i = 0; i<24; i++) {
|
||||
MyUSART_Transmit_Data_8b(USARTOut, data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void MyRF_Transmit_Limite_Roulis(void) {
|
||||
char data[30] = "/!\\ RISQUE DE CHAVIREMENT /!\\\n";
|
||||
for(int i = 0; i<30; i++) {
|
||||
MyUSART_Transmit_Data_8b(USARTOut, data[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,26 @@
|
|||
|
||||
#define PinCH1 LL_GPIO_PIN_6
|
||||
#define PinCH2 LL_GPIO_PIN_7
|
||||
#define GPIOPins GPIOB
|
||||
#define PinOut LL_GPIO_PIN_9
|
||||
#define PinTXEn LL_GPIO_PIN_11
|
||||
#define GPIOIn GPIOB
|
||||
#define GPIOOut GPIOA
|
||||
#define TimerCC TIM4
|
||||
#define channelCC1 LL_TIM_CHANNEL_CH1
|
||||
#define channelCC2 LL_TIM_CHANNEL_CH2
|
||||
#define USARTOut USART1
|
||||
#define TransferDirTX LL_USART_DIRECTION_TX
|
||||
#define TimerRF TIM1
|
||||
|
||||
|
||||
void MyRF_Conf(void);
|
||||
|
||||
int MyRF_Duty_Cycle_Moteur(void);
|
||||
|
||||
void MyRF_Transmit_3s(void);
|
||||
|
||||
void MyRF_Transmit_Batterie_Faible(void);
|
||||
|
||||
void MyRF_Transmit_Limite_Roulis(void);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue