168 lines
3.9 KiB
C
168 lines
3.9 KiB
C
#include "stm32f1xx_ll_gpio.h"
|
|
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
|
|
#include "GPIO.h"
|
|
|
|
|
|
void conf_GPIO_girouette(void){
|
|
|
|
//PA5,6,7
|
|
|
|
//Définition
|
|
|
|
LL_GPIO_InitTypeDef My_LL_GPIO_Init_Struct;
|
|
|
|
//Initialisation
|
|
|
|
LL_GPIO_StructInit(&My_LL_GPIO_Init_Struct);
|
|
|
|
//GPIOA - PIN 5 (INDEX)
|
|
|
|
My_LL_GPIO_Init_Struct.Mode=LL_GPIO_MODE_INPUT;
|
|
My_LL_GPIO_Init_Struct.Pin=LL_GPIO_PIN_5;
|
|
My_LL_GPIO_Init_Struct.Pull=LL_GPIO_PULL_DOWN;
|
|
|
|
LL_GPIO_Init(GPIOA,&My_LL_GPIO_Init_Struct);
|
|
|
|
//Initialisation
|
|
|
|
LL_GPIO_StructInit(&My_LL_GPIO_Init_Struct);
|
|
|
|
//GIOA - PIN 6 (CHA)
|
|
|
|
My_LL_GPIO_Init_Struct.Mode=LL_GPIO_MODE_INPUT;
|
|
My_LL_GPIO_Init_Struct.Pin=LL_GPIO_PIN_6;
|
|
My_LL_GPIO_Init_Struct.Pull=LL_GPIO_PULL_DOWN;
|
|
|
|
LL_GPIO_Init(GPIOA,&My_LL_GPIO_Init_Struct);
|
|
|
|
//Initialisation
|
|
|
|
LL_GPIO_StructInit(&My_LL_GPIO_Init_Struct);
|
|
|
|
//GPIOA - PIN 7 (CHB)
|
|
|
|
My_LL_GPIO_Init_Struct.Mode=LL_GPIO_MODE_INPUT;
|
|
My_LL_GPIO_Init_Struct.Pin=LL_GPIO_PIN_7;
|
|
My_LL_GPIO_Init_Struct.Pull=LL_GPIO_PULL_DOWN;
|
|
|
|
LL_GPIO_Init(GPIOA,&My_LL_GPIO_Init_Struct);
|
|
|
|
//Initialisation
|
|
|
|
LL_GPIO_StructInit(&My_LL_GPIO_Init_Struct);
|
|
|
|
|
|
//GPIOA - PIN 8 (PWM)
|
|
|
|
My_LL_GPIO_Init_Struct.Mode=LL_GPIO_MODE_ALTERNATE;
|
|
My_LL_GPIO_Init_Struct.Pin=LL_GPIO_PIN_8;
|
|
My_LL_GPIO_Init_Struct.OutputType=LL_GPIO_OUTPUT_PUSHPULL;
|
|
|
|
LL_GPIO_Init(GPIOA,&My_LL_GPIO_Init_Struct);
|
|
|
|
}
|
|
|
|
void conf_GPIO_roulis(void){
|
|
|
|
//PC 0,1
|
|
|
|
//Définition
|
|
|
|
LL_GPIO_InitTypeDef My_LL_GPIO_Init_Struct;
|
|
|
|
//Initialisation
|
|
|
|
LL_GPIO_StructInit(&My_LL_GPIO_Init_Struct);
|
|
|
|
//GPIOC - PIN 0
|
|
|
|
My_LL_GPIO_Init_Struct.Mode=LL_GPIO_MODE_ANALOG;
|
|
My_LL_GPIO_Init_Struct.Pin=LL_GPIO_PIN_0;
|
|
My_LL_GPIO_Init_Struct.Pull=LL_GPIO_PULL_DOWN;
|
|
|
|
LL_GPIO_Init(GPIOC,&My_LL_GPIO_Init_Struct);
|
|
|
|
//Initialisation
|
|
|
|
LL_GPIO_StructInit(&My_LL_GPIO_Init_Struct);
|
|
|
|
//GPIOC - PIN 1
|
|
|
|
My_LL_GPIO_Init_Struct.Mode=LL_GPIO_MODE_ANALOG;
|
|
My_LL_GPIO_Init_Struct.Pin=LL_GPIO_PIN_1;
|
|
My_LL_GPIO_Init_Struct.Pull=LL_GPIO_PULL_DOWN;
|
|
|
|
LL_GPIO_Init(GPIOC,&My_LL_GPIO_Init_Struct);
|
|
|
|
};
|
|
|
|
void conf_GPIO_RF (void) {
|
|
|
|
LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
|
|
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
|
|
|
|
//RX : TIM4_CH1/2 (PWM In)
|
|
//PB.6 en floating input
|
|
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_6;
|
|
LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
|
|
|
|
//PB.7 en floating input
|
|
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_7;
|
|
LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
|
|
|
|
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
|
|
|
|
//TX : USART1 & Pin EN
|
|
//PA.9 en alternate output pp
|
|
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_9;
|
|
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
|
|
|
|
//PA.11 en output pp
|
|
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_11;
|
|
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
|
|
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
|
|
|
|
}
|
|
|
|
|
|
void conf_GPIO_Moteur (void) {
|
|
|
|
LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
|
|
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
|
|
|
|
//Pin Sens
|
|
//PA.2 en output pp
|
|
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_2;
|
|
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
|
|
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
|
|
|
|
|
|
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
|
|
|
|
//Vitesse : TIM2_CH2 (PWM)
|
|
//PA.1 en alternate pp
|
|
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_1;
|
|
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
|
|
}
|
|
|
|
|
|
|
|
void conf_GPIO(void){
|
|
|
|
//Activation des horloges des GPIOS
|
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
|
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
|
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);
|
|
|
|
conf_GPIO_girouette();
|
|
conf_GPIO_roulis();
|
|
conf_GPIO_Moteur();
|
|
conf_GPIO_RF();
|
|
|
|
}
|