Harmonsation cosmetique

This commit is contained in:
Aleksander Taban 2025-12-16 20:33:39 +01:00
parent b2d06d9efc
commit d5ce192720
No known key found for this signature in database
5 changed files with 157 additions and 3837 deletions

View file

@ -2,8 +2,7 @@
#include "DriverGPIO.h" #include "DriverGPIO.h"
void My_USART_Config(USART_TypeDef* USARTx, uint32_t baudrate) { //QUE POUR USART1 void My_USART_Config(USART_TypeDef* USARTx, uint32_t baudrate) { //QUE POUR USART_CR1_RE
// Configuration PA9 (Tx) en Alternate Function Push-Pull // Configuration PA9 (Tx) en Alternate Function Push-Pull
MyGPIO_Init(GPIOA, 9 , AltOut_Ppull); MyGPIO_Init(GPIOA, 9 , AltOut_Ppull);
// Configuration PA10 (Rx) en Input Floating // Configuration PA10 (Rx) en Input Floating
@ -11,7 +10,6 @@ void My_USART_Config(USART_TypeDef* USARTx, uint32_t baudrate) { //QUE POUR USAR
NVIC_EnableIRQ(USART1_IRQn); NVIC_EnableIRQ(USART1_IRQn);
NVIC_SetPriority(USART1_IRQn, 3<<4); NVIC_SetPriority(USART1_IRQn, 3<<4);
RCC->APB2ENR |= RCC_APB2ENR_USART1EN; RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
USARTx->CR1 |= USART_CR1_UE; USARTx->CR1 |= USART_CR1_UE;
USARTx->BRR = baudrate; USARTx->BRR = baudrate;
@ -20,7 +18,6 @@ void My_USART_Config(USART_TypeDef* USARTx, uint32_t baudrate) { //QUE POUR USAR
}; };
void USART_Send_Char(USART_TypeDef* USARTx, char car) { void USART_Send_Char(USART_TypeDef* USARTx, char car) {
while ((USARTx->SR & USART_SR_TXE)==0){} while ((USARTx->SR & USART_SR_TXE)==0){}
USARTx->DR = car; USARTx->DR = car;
@ -43,14 +40,15 @@ void USART_IT_Receive_Enable(USART_TypeDef* USARTx) {
}; };
void Init_IT_Receive(void (*Receive_IT_function) (char)){ void Init_IT_Receive(void (*Receive_IT_function) (char)) {
pFnc_Receive = Receive_IT_function; pFnc_Receive = Receive_IT_function;
}; };
void USART1_IRQHandler(void){ void USART1_IRQHandler(void) {
signed char commande = USART1->DR; signed char commande = USART1->DR;
if (pFnc_Receive != 0) { if (pFnc_Receive != 0) {
pFnc_Receive(commande); pFnc_Receive(commande);
} }
}; };

View file

@ -3,39 +3,33 @@
#include "DriverGPIO.h" #include "DriverGPIO.h"
#include "Horloge.h" #include "Horloge.h"
void initPlato(TIM_TypeDef * Timer, int Channel){ // Config du moteur servo void initPlato(TIM_TypeDef * Timer, int Channel) { // Config du moteur servo
MyGPIO_Init(GPIOB, 5, AltOut_Ppull); //config pin de direction 0 ou 1 MyGPIO_Init(GPIOB, 5, AltOut_Ppull); //config pin de direction 0 ou 1
if (Timer == TIM3) { if (Timer == TIM3) {
Timer_Init(TIM3, 159, 17); // Pour obtenir fréq de 20kHZ Timer_Init(TIM3, 159, 17); // Pour obtenir fréq de 20kHZ
if (Channel == 3){ if (Channel == 3) {
MyGPIO_Init(GPIOB, 0, AltOut_Ppull); // Outut push pull alternate, config pin de consigne entre -100 et 100 MyGPIO_Init(GPIOB, 0, AltOut_Ppull); // Outut push pull alternate, config pin de consigne entre -100 et 100
MyTimer_PWM(TIM3, 3); //TIM3 CH3 MyTimer_PWM(TIM3, 3); //TIM3 CH3
} }
else{ else {
//printf("Ce pilote n'existe pas"); //printf("Ce pilote n'existe pas");
} }
} }
else{ else {
//printf("Ce pilote n'existe pas"); //printf("Ce pilote n'existe pas");
} }
} }
void Update_Motor_PWM(int Consigne, TIM_TypeDef * Timer, int Channel) { void Update_Motor_PWM(int Consigne, TIM_TypeDef * Timer, int Channel) {
int duty_cycle;
int duty_cycle; if (Consigne>=0) {
MYGPIO_PinOn(GPIOB, 5);
if (Consigne>=0){ duty_cycle = Consigne;
MYGPIO_PinOn(GPIOB, 5); }
duty_cycle = Consigne;
};
if (Consigne<0){ if (Consigne<0){
MYGPIO_PinOff(GPIOB,5); MYGPIO_PinOff(GPIOB,5);
duty_cycle = -Consigne; duty_cycle = -Consigne;
}; }
Set_DutyCycle_PWM(Timer, Channel, duty_cycle); Set_DutyCycle_PWM(Timer, Channel, duty_cycle);
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,12 +1,13 @@
#include "RTC.h" #include "RTC.h"
initRTC(){
initRTC() {
RTC -> PRLL = 0x7FFF; // Obtenir un période de 1 seconde RTC -> PRLL = 0x7FFF; // Obtenir un période de 1 seconde
RTC -> PRLH = 0xFFFF; // Le plus grand possible RTC -> PRLH = 0xFFFF; // Le plus grand possible
} }
int getTime(){
int getTime() {
return(RTC -> PRLH); return(RTC -> PRLH);
} }