summaryrefslogtreecommitdiffstats
path: root/simonnnnn/Core
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--simonnnnn/Core/Inc/button.h (renamed from Core/Inc/button.h)0
-rw-r--r--simonnnnn/Core/Inc/gpio.h (renamed from Core/Inc/gpio.h)0
-rw-r--r--simonnnnn/Core/Inc/lcd_1602.h (renamed from Core/Inc/lcd_1602.h)0
-rw-r--r--simonnnnn/Core/Inc/led.h (renamed from Core/Inc/led.h)0
-rw-r--r--simonnnnn/Core/Inc/main.h (renamed from Core/Inc/main.h)0
-rw-r--r--simonnnnn/Core/Inc/stm32l0xx_hal_conf.h (renamed from Core/Inc/stm32l0xx_hal_conf.h)0
-rw-r--r--simonnnnn/Core/Inc/stm32l0xx_it.h (renamed from Core/Inc/stm32l0xx_it.h)0
-rw-r--r--simonnnnn/Core/Inc/usart.h (renamed from Core/Inc/usart.h)0
-rw-r--r--simonnnnn/Core/Src/button.c (renamed from Core/Src/button.c)0
-rw-r--r--simonnnnn/Core/Src/gpio.c (renamed from Core/Src/gpio.c)25
-rw-r--r--simonnnnn/Core/Src/lcd_1602.c (renamed from Core/Src/lcd_1602.c)0
-rw-r--r--simonnnnn/Core/Src/led.c (renamed from Core/Src/led.c)0
-rw-r--r--simonnnnn/Core/Src/main.c (renamed from Core/Src/main.c)89
-rw-r--r--simonnnnn/Core/Src/stm32l0xx_hal_msp.c (renamed from Core/Src/stm32l0xx_hal_msp.c)0
-rw-r--r--simonnnnn/Core/Src/stm32l0xx_it.c (renamed from Core/Src/stm32l0xx_it.c)0
-rw-r--r--simonnnnn/Core/Src/syscalls.c (renamed from Core/Src/syscalls.c)0
-rw-r--r--simonnnnn/Core/Src/system_stm32l0xx.c (renamed from Core/Src/system_stm32l0xx.c)0
-rw-r--r--simonnnnn/Core/Src/usart.c (renamed from Core/Src/usart.c)0
18 files changed, 84 insertions, 30 deletions
diff --git a/Core/Inc/button.h b/simonnnnn/Core/Inc/button.h
index fff10b7..fff10b7 100644
--- a/Core/Inc/button.h
+++ b/simonnnnn/Core/Inc/button.h
diff --git a/Core/Inc/gpio.h b/simonnnnn/Core/Inc/gpio.h
index 5dd191b..5dd191b 100644
--- a/Core/Inc/gpio.h
+++ b/simonnnnn/Core/Inc/gpio.h
diff --git a/Core/Inc/lcd_1602.h b/simonnnnn/Core/Inc/lcd_1602.h
index 5df49f3..5df49f3 100644
--- a/Core/Inc/lcd_1602.h
+++ b/simonnnnn/Core/Inc/lcd_1602.h
diff --git a/Core/Inc/led.h b/simonnnnn/Core/Inc/led.h
index 50c9084..50c9084 100644
--- a/Core/Inc/led.h
+++ b/simonnnnn/Core/Inc/led.h
diff --git a/Core/Inc/main.h b/simonnnnn/Core/Inc/main.h
index 11c7476..11c7476 100644
--- a/Core/Inc/main.h
+++ b/simonnnnn/Core/Inc/main.h
diff --git a/Core/Inc/stm32l0xx_hal_conf.h b/simonnnnn/Core/Inc/stm32l0xx_hal_conf.h
index 5252f0f..5252f0f 100644
--- a/Core/Inc/stm32l0xx_hal_conf.h
+++ b/simonnnnn/Core/Inc/stm32l0xx_hal_conf.h
diff --git a/Core/Inc/stm32l0xx_it.h b/simonnnnn/Core/Inc/stm32l0xx_it.h
index 77cb7bd..77cb7bd 100644
--- a/Core/Inc/stm32l0xx_it.h
+++ b/simonnnnn/Core/Inc/stm32l0xx_it.h
diff --git a/Core/Inc/usart.h b/simonnnnn/Core/Inc/usart.h
index 953af0e..953af0e 100644
--- a/Core/Inc/usart.h
+++ b/simonnnnn/Core/Inc/usart.h
diff --git a/Core/Src/button.c b/simonnnnn/Core/Src/button.c
index a9333d9..a9333d9 100644
--- a/Core/Src/button.c
+++ b/simonnnnn/Core/Src/button.c
diff --git a/Core/Src/gpio.c b/simonnnnn/Core/Src/gpio.c
index b80c7b9..4cc720b 100644
--- a/Core/Src/gpio.c
+++ b/simonnnnn/Core/Src/gpio.c
@@ -50,7 +50,10 @@ void MX_GPIO_Init(void)
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
+ HAL_GPIO_WritePin(GPIOA, LD2_Pin|GPIO_PIN_6|GPIO_PIN_7, GPIO_PIN_RESET);
+
+ /*Configure GPIO pin Output Level */
+ HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, RS_Pin|RW_Pin|E_Pin|D4_Pin
@@ -62,6 +65,12 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
+ /*Configure GPIO pins : PC0 PC1 PC2 PC3 */
+ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3;
+ GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+
/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = LD2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
@@ -69,6 +78,20 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);
+ /*Configure GPIO pins : PA6 PA7 */
+ GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /*Configure GPIO pin : PC4 */
+ GPIO_InitStruct.Pin = GPIO_PIN_4;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+
/*Configure GPIO pins : PBPin PBPin PBPin PBPin
PBPin PBPin PBPin */
GPIO_InitStruct.Pin = RS_Pin|RW_Pin|E_Pin|D4_Pin
diff --git a/Core/Src/lcd_1602.c b/simonnnnn/Core/Src/lcd_1602.c
index 4dc09b9..4dc09b9 100644
--- a/Core/Src/lcd_1602.c
+++ b/simonnnnn/Core/Src/lcd_1602.c
diff --git a/Core/Src/led.c b/simonnnnn/Core/Src/led.c
index 1a5c58f..1a5c58f 100644
--- a/Core/Src/led.c
+++ b/simonnnnn/Core/Src/led.c
diff --git a/Core/Src/main.c b/simonnnnn/Core/Src/main.c
index 1001ae9..912a153 100644
--- a/Core/Src/main.c
+++ b/simonnnnn/Core/Src/main.c
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <string.h>
/* USER CODE END Includes */
+
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
@@ -60,7 +61,6 @@ void SystemClock_Config(void);
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
-
/* USER CODE BEGIN 0 */
//Declaration des leds et buttons
LED_TypeDef led_rouge; //rouge
@@ -156,13 +156,13 @@ int main(void)
Led_init(&led_system, GPIOA,5); //led_system sur PA5
Led_init(&led_rouge, GPIOA,6); //led_rouge sur PA6
Led_init(&led_verte, GPIOA,7); //led_verte sur PA7
- Led_init(&led_jaune, GPIOB,6); //led_jaune sur PB6
+ Led_init(&led_jaune, GPIOC,4); //led_jaune sur PC4
Button_init(&button_system, GPIOC, 13); //button_system sur PC13
- Button_init(&button_rouge, GPIOC, 14); //button_rouge sur PC13
- Button_init(&button_vert, GPIOC, 15); //button_vert sur PC13
- Button_init(&button_jaune, GPIOH, 0); //button_jaune sur PH0
- Button_init(&button_deux_joueur, GPIOH, 1); //button_deux_joueur sur PH1
+ Button_init(&button_rouge, GPIOC, 0); //button_rouge sur PC0
+ Button_init(&button_vert, GPIOC, 1); //button_vert sur PC1
+ Button_init(&button_jaune, GPIOH, 2); //button_jaune sur PC2
+ Button_init(&button_deux_joueur, GPIOH, 3); //button_deux_joueur sur PH3
//
/* EXEMPLE D'UTILISATION POUR LED ET BUTTON
@@ -199,10 +199,7 @@ int main(void)
/* USER CODE END 2 */
/* Infinite loop */
-
- while (1)
- {
- /* USER CODE BEGIN WHILE */
+ /* USER CODE BEGIN WHILE */
lcd_init();
@@ -215,10 +212,10 @@ int main(void)
current_button_2j_state = Button_State(&button_deux_joueur);
//si front descendant (bouton appuyé)
if (last_button_2j_state == 1 && (current_button_2j_state == 0) && (etat_bouton_deux_joueurs==0)) {
- etat_bouton_deux_joueurs = 1;
+ etat_bouton_deux_joueurs = 1; //si on avait pas activé le mode 2j, on l'active
fonction_led("S",1); //allume la led de la carte
} else if (last_button_2j_state == 1 && (current_button_2j_state == 0) && (etat_bouton_deux_joueurs==1)) {
- etat_bouton_deux_joueurs = 0;
+ etat_bouton_deux_joueurs = 0; //si on avait activé le mode 2j, on le desactive
fonction_led("S",0); //eteind la led de la carte
}
//mise à jour de l’état précédent du bouton
@@ -233,11 +230,9 @@ int main(void)
//lire l’état courant
current_button_system_state = Button_State(&button_system);
//si front descendant (bouton appuyé)
- if (last_button_system_state == 1 && (current_button_system_state == 0) && (etat_bouton_deux_joueurs==0)) {
+ if (last_button_system_state == 1 && (current_button_system_state == 0)) {
etat_bouton_start = 1;
- } else if (last_button_system_state == 1 && (current_button_system_state == 0) && (etat_bouton_deux_joueurs==1)) {
- etat_bouton_start = 0;
- }
+ }
//mise à jour de l’état précédent du bouton
last_button_system_state = current_button_system_state;
@@ -282,11 +277,49 @@ int main(void)
affiche_lcd("A VOUS !",0,1);
int iLed=0;
do { //le joueur appuie sur les boutons
- char bouton[100];
- scanf("%s", bouton); //correspondance
- char* bouton_couleur = bouton; //boutons poussoirs
-
- if (*bouton_couleur!=*suite_de_leds[iLed]){ //le joueur se trompe
+ int bouton_appuye = 0;
+ char* bouton;
+ while (bouton_appuye==0){ //on prend l'entree utilisateur
+ uint8_t last_button_rouge_state = 1; //button non appuyé
+ uint8_t current_button_rouge_state = 1; //button non appuyé
+ uint8_t last_button_vert_state = 1; //button non appuyé
+ uint8_t current_button_vert_state = 1; //button non appuyé
+ uint8_t last_button_jaune_state = 1; //button non appuyé
+ uint8_t current_button_jaune_state = 1; //button non appuyé
+
+ //lire l’état courant
+ current_button_rouge_state = Button_State(&button_rouge);
+ current_button_vert_state = Button_State(&button_vert);
+ current_button_jaune_state = Button_State(&button_jaune);
+ //si front descendant (bouton appuyé)
+ if (last_button_rouge_state == 1 && (current_button_rouge_state == 0)) {
+ bouton_appuye = 1;
+ bouton="R";
+ fonction_led(bouton,1);
+ HAL_Delay(200);
+ fonction_led(bouton,0);
+ } else if (last_button_vert_state == 1 && (current_button_vert_state == 0)) {
+ bouton_appuye = 1;
+ bouton="V";
+ fonction_led(bouton,1);
+ HAL_Delay(200);
+ fonction_led(bouton,0);
+ } else if (last_button_jaune_state == 1 && (current_button_jaune_state == 0)) {
+ bouton_appuye = 1;
+ bouton="J";
+ fonction_led(bouton,1);
+ HAL_Delay(200);
+ fonction_led(bouton,0);
+ }
+
+ //mise à jour de l’état précédent du bouton
+ last_button_rouge_state = current_button_rouge_state;
+ last_button_vert_state = current_button_vert_state;
+ last_button_jaune_state = current_button_jaune_state;
+
+ }
+
+ if (*bouton!=*suite_de_leds[iLed]){ //le joueur se trompe
affiche_lcd("GAME OVER !",0,1);
affiche_lcd("SCORE :",0,1);
@@ -300,9 +333,8 @@ int main(void)
perdu = 0;
}
iLed++;
- } while (iLed<score && perdu!=1);
- //tant qu'on a des leds a faire allume et qu'on a pas perdu
- }
+ } while (iLed<score && perdu!=1); //tant qu'on a des leds a faire allume et qu'on a pas perdu
+ } //fin du while qui test si on a perdu
if (etat_bouton_deux_joueurs && perdu==1 && !deuxieme_joueur_joue){ //si le premier joueur perd en mode 2J
affiche_lcd("J2!",0,1);
@@ -317,16 +349,15 @@ int main(void)
else if (score_un<score_deux){affiche_lcd("JOUEUR 2 GAGNE!",0,1);}
else {affiche_lcd("EGALITE...",0,1);}
}
-
- }
+ } //fin du if button_start
score=0;
/* USER CODE END WHILE */
- }
- /* USER CODE BEGIN 3 */
+
+ /* USER CODE BEGIN 3 */
/* USER CODE END 3 */
-}
+} //fin du main
/**
* @brief System Clock Configuration
diff --git a/Core/Src/stm32l0xx_hal_msp.c b/simonnnnn/Core/Src/stm32l0xx_hal_msp.c
index f614d4a..f614d4a 100644
--- a/Core/Src/stm32l0xx_hal_msp.c
+++ b/simonnnnn/Core/Src/stm32l0xx_hal_msp.c
diff --git a/Core/Src/stm32l0xx_it.c b/simonnnnn/Core/Src/stm32l0xx_it.c
index bf098ed..bf098ed 100644
--- a/Core/Src/stm32l0xx_it.c
+++ b/simonnnnn/Core/Src/stm32l0xx_it.c
diff --git a/Core/Src/syscalls.c b/simonnnnn/Core/Src/syscalls.c
index 914f768..914f768 100644
--- a/Core/Src/syscalls.c
+++ b/simonnnnn/Core/Src/syscalls.c
diff --git a/Core/Src/system_stm32l0xx.c b/simonnnnn/Core/Src/system_stm32l0xx.c
index 9189ed8..9189ed8 100644
--- a/Core/Src/system_stm32l0xx.c
+++ b/simonnnnn/Core/Src/system_stm32l0xx.c
diff --git a/Core/Src/usart.c b/simonnnnn/Core/Src/usart.c
index e6948fb..e6948fb 100644
--- a/Core/Src/usart.c
+++ b/simonnnnn/Core/Src/usart.c