main commencé + emetteur_rf changé
This commit is contained in:
parent
e56c871761
commit
89850bfc2f
3 changed files with 49 additions and 23 deletions
|
@ -42,11 +42,14 @@ void emetteur_rf_init(void){
|
||||||
LL_USART_SetBaudRate(uart_port, periph_speed, baudrate);
|
LL_USART_SetBaudRate(uart_port, periph_speed, baudrate);
|
||||||
*/}
|
*/}
|
||||||
|
|
||||||
void emetteur_send_bytes(USART_TypeDef * uart_port,char* buf, int len){
|
|
||||||
|
|
||||||
|
|
||||||
|
void emetteur_send_bytes(char* buf, int len){
|
||||||
for(int i = 0; i < len; i++){
|
for(int i = 0; i < len; i++){
|
||||||
LL_GPIO_SetOutputPin(GPIOA,LL_GPIO_PIN_11);
|
LL_GPIO_SetOutputPin(GPIOA,LL_GPIO_PIN_11);
|
||||||
LL_USART_TransmitData8(uart_port, buf[i]);
|
LL_USART_TransmitData8(USART1, buf[i]);
|
||||||
while(!LL_USART_IsActiveFlag_TXE(uart_port));
|
while(!LL_USART_IsActiveFlag_TXE(USART1));
|
||||||
LL_GPIO_ResetOutputPin(GPIOA,LL_GPIO_PIN_11);
|
LL_GPIO_ResetOutputPin(GPIOA,LL_GPIO_PIN_11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "stm32f1xx_ll_gpio.h"
|
#include "stm32f1xx_ll_gpio.h"
|
||||||
|
|
||||||
void emetteur_rf_init(void);
|
void emetteur_rf_init(void);
|
||||||
void emetteur_send_bytes(USART_TypeDef * uart_port,char* buf, int len);
|
void emetteur_send_bytes(char* buf, int len);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
|
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
|
||||||
#include "stm32f1xx_ll_bus.h"
|
#include "stm32f1xx_ll_bus.h"
|
||||||
|
|
||||||
|
|
||||||
#include "RFInput.h"
|
#include "RFInput.h"
|
||||||
#include "IncrEncoder.h"
|
#include "IncrEncoder.h"
|
||||||
#include "DcMotor.h"
|
#include "DcMotor.h"
|
||||||
|
@ -28,6 +29,9 @@
|
||||||
#include "alimentation.h"
|
#include "alimentation.h"
|
||||||
#include "accelerometer.h"
|
#include "accelerometer.h"
|
||||||
|
|
||||||
|
#define CONTROL_LOOP_PERIOD 250
|
||||||
|
#define MSG_TRANSFER_PERIOD 3000
|
||||||
|
|
||||||
void SystemClock_Config(void);
|
void SystemClock_Config(void);
|
||||||
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
@ -38,18 +42,18 @@ void SystemClock_Config(void);
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int val = 0;
|
|
||||||
int val2 = 0;
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
float level;
|
int battery_level_good = 0;
|
||||||
int level_enough;
|
int angle_roulis_good = 0;
|
||||||
double xx,yy;
|
int angle_sail = 0;
|
||||||
int bon;
|
int RF_Input_Duty = 0;
|
||||||
|
int TX_Flag = 0, CONTROL_LOOP_Flag = 0;
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
/* Configure the system clock to 72 MHz */
|
/* Configure the system clock to 72 MHz */
|
||||||
SystemClock_Config();
|
SystemClock_Config();
|
||||||
|
|
||||||
//alimentation_init();
|
//alimentation_init();
|
||||||
RF_INPUT_Init();
|
RF_INPUT_Init();
|
||||||
DC_MOTOR_Init();
|
DC_MOTOR_Init();
|
||||||
|
@ -59,20 +63,39 @@ int main(void)
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
LL_mDelay(100);
|
if(CONTROL_LOOP_Flag){
|
||||||
//counter = (counter + 1) % 100;
|
battery_level_good = is_level_enough();
|
||||||
//DC_MOTOR_SetSpeed(counter);
|
angle_roulis_good = accelero_angle_bon();
|
||||||
//val = RF_INPUT_GetPeriodUs();
|
|
||||||
//val2 = RF_INPUT_GetDutyTimeUs();
|
if(!angle_roulis_good){
|
||||||
//SAIL_SetAngle(counter);
|
SAIL_SetAngle(90);
|
||||||
//level = get_battery_level();
|
DC_MOTOR_SetSpeed(0);
|
||||||
//level_enough = is_level_enough();
|
}else{
|
||||||
xx = accelero_get_x();
|
angle_sail = INCR_ENCODER_GetAngle();
|
||||||
//yy = accelero_get_y();
|
SAIL_SetAngle(angle_sail/2);
|
||||||
//bon = accelero_angle_bon();
|
RF_Input_Duty = RF_INPUT_GetDutyTimeRelative();
|
||||||
|
DC_MOTOR_SetSpeed(RF_Input_Duty);
|
||||||
|
}
|
||||||
|
|
||||||
|
CONTROL_LOOP_Flag = 0;
|
||||||
|
}
|
||||||
|
if(TX_Flag){
|
||||||
|
|
||||||
|
TX_Flag = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SysTick_Handler(void)
|
||||||
|
{
|
||||||
|
if(counter % CONTROL_LOOP_PERIOD == 0){
|
||||||
|
CONTROL_LOOP_Flag = 1;
|
||||||
|
}
|
||||||
|
if(counter % MSG_TRANSFER_PERIOD == 0){
|
||||||
|
TX_Flag = 1;
|
||||||
|
}
|
||||||
|
counter = (counter+1) % (CONTROL_LOOP_PERIOD*MSG_TRANSFER_PERIOD) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue