Harmonsation cosmetique
This commit is contained in:
parent
b2d06d9efc
commit
d5ce192720
5 changed files with 157 additions and 3837 deletions
|
|
@ -2,25 +2,22 @@
|
|||
#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
|
||||
MyGPIO_Init(GPIOA, 9 , AltOut_Ppull);
|
||||
// Configuration PA10 (Rx) en Input Floating
|
||||
MyGPIO_Init(GPIOA, 10 , In_Floating);
|
||||
MyGPIO_Init(GPIOA, 10 , In_Floating);
|
||||
NVIC_EnableIRQ(USART1_IRQn);
|
||||
NVIC_SetPriority(USART1_IRQn, 3<<4);
|
||||
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
|
||||
USARTx->CR1 |= USART_CR1_UE;
|
||||
USARTx->BRR = baudrate;
|
||||
USARTx->CR1 |= USART_CR1_TE;
|
||||
USARTx->CR1 |= USART_CR1_TE;
|
||||
USARTx->CR1 |= USART_CR1_RE;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void USART_Send_Char(USART_TypeDef* USARTx, char car) {
|
||||
while ((USARTx->SR & USART_SR_TXE)==0){}
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
void USART1_IRQHandler(void){
|
||||
void USART1_IRQHandler(void) {
|
||||
signed char commande = USART1->DR;
|
||||
if (pFnc_Receive != 0) {
|
||||
pFnc_Receive(commande);
|
||||
pFnc_Receive(commande);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,39 +3,33 @@
|
|||
#include "DriverGPIO.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
|
||||
if (Timer == TIM3) {
|
||||
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
|
||||
MyTimer_PWM(TIM3, 3); //TIM3 CH3
|
||||
}
|
||||
else{
|
||||
else {
|
||||
//printf("Ce pilote n'existe pas");
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
//printf("Ce pilote n'existe pas");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Update_Motor_PWM(int Consigne, TIM_TypeDef * Timer, int Channel) {
|
||||
|
||||
int duty_cycle;
|
||||
|
||||
if (Consigne>=0){
|
||||
MYGPIO_PinOn(GPIOB, 5);
|
||||
duty_cycle = Consigne;
|
||||
};
|
||||
|
||||
|
||||
void Update_Motor_PWM(int Consigne, TIM_TypeDef * Timer, int Channel) {
|
||||
int duty_cycle;
|
||||
if (Consigne>=0) {
|
||||
MYGPIO_PinOn(GPIOB, 5);
|
||||
duty_cycle = Consigne;
|
||||
}
|
||||
if (Consigne<0){
|
||||
MYGPIO_PinOff(GPIOB,5);
|
||||
duty_cycle = -Consigne;
|
||||
};
|
||||
|
||||
}
|
||||
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
|
|
@ -1,12 +1,13 @@
|
|||
#include "RTC.h"
|
||||
|
||||
initRTC(){
|
||||
|
||||
initRTC() {
|
||||
RTC -> PRLL = 0x7FFF; // Obtenir un période de 1 seconde
|
||||
RTC -> PRLH = 0xFFFF; // Le plus grand possible
|
||||
|
||||
}
|
||||
|
||||
int getTime(){
|
||||
|
||||
int getTime() {
|
||||
return(RTC -> PRLH);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue