Tentative d'interruption via bouton v2
fonction qui tourne bcp et qui teste les boutons -> message. Cela ne fonctionne pas : -> tempo trop courte pour la fonction qui regarde le port numérique ? -> conversion (ou jsp quoi) pour recup la valeur trop longue ? Et en plus on voit avec des points d'arrets que la queue est remplie mais la tache de gestion des missiles ne la reconnait pas.
This commit is contained in:
parent
0ca03acfc4
commit
5837e17507
8 changed files with 51182 additions and 51261 deletions
|
@ -76,7 +76,6 @@ osThreadId Joueur_1Handle;
|
||||||
osThreadId Block_EnemieHandle;
|
osThreadId Block_EnemieHandle;
|
||||||
osThreadId ProjectileHandle;
|
osThreadId ProjectileHandle;
|
||||||
osThreadId IRQ_BPHandle;
|
osThreadId IRQ_BPHandle;
|
||||||
osThreadId tir_joueurHandle;
|
|
||||||
osMessageQId Queue_JHandle;
|
osMessageQId Queue_JHandle;
|
||||||
osMessageQId Queue_NHandle;
|
osMessageQId Queue_NHandle;
|
||||||
osMessageQId Queue_FHandle;
|
osMessageQId Queue_FHandle;
|
||||||
|
@ -107,7 +106,6 @@ void f_Joueur_1(void const * argument);
|
||||||
void f_block_enemie(void const * argument);
|
void f_block_enemie(void const * argument);
|
||||||
void f_projectile(void const * argument);
|
void f_projectile(void const * argument);
|
||||||
void f_IRQ_BP(void const * argument);
|
void f_IRQ_BP(void const * argument);
|
||||||
void f_tir_joueur(void const * argument);
|
|
||||||
|
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
|
@ -117,11 +115,6 @@ void f_tir_joueur(void const * argument);
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
|
||||||
/* The semaphore used to synchronise the button push task with the interrupt. */
|
|
||||||
static xSemaphoreHandle xButtonSemaphore;
|
|
||||||
|
|
||||||
#define butDEBOUNCE_DELAY 2000
|
|
||||||
|
|
||||||
|
|
||||||
struct Missile
|
struct Missile
|
||||||
{
|
{
|
||||||
|
@ -292,13 +285,9 @@ int main(void)
|
||||||
ProjectileHandle = osThreadCreate(osThread(Projectile), NULL);
|
ProjectileHandle = osThreadCreate(osThread(Projectile), NULL);
|
||||||
|
|
||||||
/* definition and creation of IRQ_BP */
|
/* definition and creation of IRQ_BP */
|
||||||
osThreadDef(IRQ_BP, f_IRQ_BP, osPriorityHigh, 0, 128);
|
osThreadDef(IRQ_BP, f_IRQ_BP, osPriorityAboveNormal, 0, 128);
|
||||||
IRQ_BPHandle = osThreadCreate(osThread(IRQ_BP), NULL);
|
IRQ_BPHandle = osThreadCreate(osThread(IRQ_BP), NULL);
|
||||||
|
|
||||||
/* definition and creation of tir_joueur */
|
|
||||||
osThreadDef(tir_joueur, f_tir_joueur, osPriorityNormal, 0, 128);
|
|
||||||
tir_joueurHandle = osThreadCreate(osThread(tir_joueur), NULL);
|
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_THREADS */
|
/* USER CODE BEGIN RTOS_THREADS */
|
||||||
/* add threads, ... */
|
/* add threads, ... */
|
||||||
/* USER CODE END RTOS_THREADS */
|
/* USER CODE END RTOS_THREADS */
|
||||||
|
@ -1456,7 +1445,7 @@ void f_block_enemie(void const * argument)
|
||||||
struct Monster list_monsters[30];
|
struct Monster list_monsters[30];
|
||||||
uint8_t end = 0;
|
uint8_t end = 0;
|
||||||
uint8_t deplacement = 1;
|
uint8_t deplacement = 1;
|
||||||
struct Missile missile;
|
struct Missile missile = {0,0,0,0,0,0,0,0};
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -1507,9 +1496,8 @@ void f_projectile(void const * argument)
|
||||||
const TickType_t xPeriodeTache = 5000;
|
const TickType_t xPeriodeTache = 5000;
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
struct Missile liste_missile[20];
|
struct Missile liste_missile[20];
|
||||||
struct Missile missile = {70, 70, 1, 0, 0, LCD_COLOR_WHITE, 1,1};
|
struct Missile missile;
|
||||||
uint8_t indice = 1;
|
uint8_t indice = 0;
|
||||||
liste_missile[0] = missile;
|
|
||||||
|
|
||||||
// Paramètre de l'écran pour la reprouductibilité
|
// Paramètre de l'écran pour la reprouductibilité
|
||||||
|
|
||||||
|
@ -1518,8 +1506,11 @@ void f_projectile(void const * argument)
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
//xQueueReceive(Queue_NHandle, &missile, 0);
|
|
||||||
//liste_missile[indice++] = missile;
|
xQueueReceive(Queue_NHandle, &missile, 0);
|
||||||
|
if (missile.valide == 1){
|
||||||
|
liste_missile[indice++] = missile;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0;i< indice;i++)
|
for (int i=0;i< indice;i++)
|
||||||
{
|
{
|
||||||
|
@ -1575,6 +1566,7 @@ void f_projectile(void const * argument)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelayUntil(&xLastWakeTime, xPeriodeTache);
|
vTaskDelayUntil(&xLastWakeTime, xPeriodeTache);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1591,62 +1583,26 @@ void f_projectile(void const * argument)
|
||||||
void f_IRQ_BP(void const * argument)
|
void f_IRQ_BP(void const * argument)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN f_IRQ_BP */
|
/* USER CODE BEGIN f_IRQ_BP */
|
||||||
// Jsp pk long mais ca ne renvoie pas d'erreur. C'était initialement short sur google
|
TickType_t xLastWakeTime;
|
||||||
long sHigherPriorityTaskWoken = pdFALSE;
|
// Faudrait convertir en ms mais jsp comment
|
||||||
|
const TickType_t xPeriodeTache = 10;
|
||||||
|
|
||||||
/* 'Give' the semaphore to unblock the button task. */
|
|
||||||
|
|
||||||
xSemaphoreGiveFromISR( xButtonSemaphore, &sHigherPriorityTaskWoken );
|
|
||||||
|
|
||||||
/* If giving the semaphore unblocked a task, and the unblocked task has a
|
|
||||||
priority that is higher than the currently running task, then
|
|
||||||
sHigherPriorityTaskWoken will have been set to pdTRUE. Passing a pdTRUE
|
|
||||||
value to portYIELD_FROM_ISR() will cause this interrupt to return directly
|
|
||||||
to the higher priority unblocked task. */
|
|
||||||
portYIELD_FROM_ISR( sHigherPriorityTaskWoken );
|
|
||||||
|
|
||||||
|
|
||||||
/* USER CODE END f_IRQ_BP */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE BEGIN Header_f_tir_joueur */
|
|
||||||
/**
|
|
||||||
* @brief Function implementing the tir_joueur thread.
|
|
||||||
* @param argument: Not used
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
/* USER CODE END Header_f_tir_joueur */
|
|
||||||
void f_tir_joueur(void const * argument)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN f_tir_joueur */
|
|
||||||
/* Ensure the semaphore is created before it gets used. */
|
|
||||||
vSemaphoreCreateBinary( xButtonSemaphore );
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
if (HAL_GPIO_ReadPin(BP1_GPIO_Port, BP1_Pin)==0){
|
||||||
/* Block on the semaphore to wait for an interrupt event. The semaphore
|
struct Missile missile = {joueur.x, joueur.y, 1, 0, 1, LCD_COLOR_LIGHTBLUE, 2, 1};
|
||||||
is 'given' from f_IRQ_BP() below. Using portMAX_DELAY as the
|
HAL_GPIO_WritePin(LED13_GPIO_Port, LED13_Pin,1);
|
||||||
block time will cause the task to block indefinitely provided
|
xQueueSend(Queue_NHandle, &missile,0);
|
||||||
INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h. */
|
|
||||||
xSemaphoreTake( xButtonSemaphore, portMAX_DELAY );
|
|
||||||
|
|
||||||
/* The button must have been pushed for this line to be executed.
|
|
||||||
Simply toggle the LED. */
|
|
||||||
HAL_GPIO_WritePin(LED14_GPIO_Port, LED14_Pin,!LED);
|
|
||||||
|
|
||||||
/* Wait a short time then clear any pending button pushes as a crude
|
|
||||||
method of debouncing the switch. xSemaphoreTake() uses a block time of
|
|
||||||
zero this time so it returns immediately rather than waiting for the
|
|
||||||
interrupt to occur. */
|
|
||||||
|
|
||||||
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
|
|
||||||
BSP_LCD_FillRect(50, 50, 40, 40);
|
|
||||||
|
|
||||||
vTaskDelay( butDEBOUNCE_DELAY );
|
|
||||||
xSemaphoreTake( xButtonSemaphore, 0 );
|
|
||||||
}
|
}
|
||||||
/* USER CODE END f_tir_joueur */
|
if(HAL_GPIO_ReadPin(BP2_GPIO_Port, BP2_Pin) ==0){
|
||||||
|
struct Missile missile = {joueur.x, joueur.y, 0, 1, 1, LCD_COLOR_YELLOW , 2, 1};
|
||||||
|
HAL_GPIO_WritePin(LED14_GPIO_Port, LED14_Pin,1);
|
||||||
|
xQueueSend(Queue_NHandle, &missile,0);
|
||||||
|
}
|
||||||
|
vTaskDelayUntil(&xLastWakeTime, xPeriodeTache);
|
||||||
|
}
|
||||||
|
/* USER CODE END f_IRQ_BP */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Binary file not shown.
|
@ -1,25 +1,24 @@
|
||||||
main.c:183:5:main 320 static
|
main.c:176:5:main 288 static
|
||||||
main.c:356:6:SystemClock_Config 216 static
|
main.c:345:6:SystemClock_Config 216 static
|
||||||
main.c:422:13:MX_ADC1_Init 24 static
|
main.c:411:13:MX_ADC1_Init 24 static
|
||||||
main.c:472:13:MX_ADC3_Init 24 static
|
main.c:461:13:MX_ADC3_Init 24 static
|
||||||
main.c:522:13:MX_CRC_Init 8 static
|
main.c:511:13:MX_CRC_Init 8 static
|
||||||
main.c:553:13:MX_DAC_Init 16 static
|
main.c:542:13:MX_DAC_Init 16 static
|
||||||
main.c:591:13:MX_DMA2D_Init 8 static
|
main.c:580:13:MX_DMA2D_Init 8 static
|
||||||
main.c:628:13:MX_LTDC_Init 64 static
|
main.c:617:13:MX_LTDC_Init 64 static
|
||||||
main.c:690:13:MX_RNG_Init 8 static
|
main.c:679:13:MX_RNG_Init 8 static
|
||||||
main.c:716:13:MX_SPI2_Init 8 static
|
main.c:705:13:MX_SPI2_Init 8 static
|
||||||
main.c:756:13:MX_TIM1_Init 40 static
|
main.c:745:13:MX_TIM1_Init 40 static
|
||||||
main.c:803:13:MX_TIM2_Init 40 static
|
main.c:792:13:MX_TIM2_Init 40 static
|
||||||
main.c:848:13:MX_TIM3_Init 88 static
|
main.c:837:13:MX_TIM3_Init 88 static
|
||||||
main.c:914:13:MX_TIM5_Init 40 static
|
main.c:903:13:MX_TIM5_Init 40 static
|
||||||
main.c:959:13:MX_TIM8_Init 112 static
|
main.c:948:13:MX_TIM8_Init 112 static
|
||||||
main.c:1034:13:MX_FMC_Init 40 static
|
main.c:1023:13:MX_FMC_Init 40 static
|
||||||
main.c:1085:13:MX_GPIO_Init 72 static
|
main.c:1074:13:MX_GPIO_Init 72 static
|
||||||
main.c:1321:6:f_GameMaster 32 static
|
main.c:1310:6:f_GameMaster 32 static
|
||||||
main.c:1368:6:f_Joueur_1 96 static
|
main.c:1357:6:f_Joueur_1 96 static
|
||||||
main.c:1450:6:f_block_enemie 1016 static
|
main.c:1439:6:f_block_enemie 1016 static
|
||||||
main.c:1503:6:f_projectile 384 static
|
main.c:1492:6:f_projectile 384 static
|
||||||
main.c:1591:6:f_IRQ_BP 24 static,ignoring_inline_asm
|
main.c:1583:6:f_IRQ_BP 56 static
|
||||||
main.c:1619:6:f_tir_joueur 16 static
|
main.c:1616:6:HAL_TIM_PeriodElapsedCallback 16 static
|
||||||
main.c:1660:6:HAL_TIM_PeriodElapsedCallback 16 static
|
main.c:1633:6:Error_Handler 4 static,ignoring_inline_asm
|
||||||
main.c:1677:6:Error_Handler 4 static,ignoring_inline_asm
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -13,7 +13,7 @@ FREERTOS.FootprintOK=true
|
||||||
FREERTOS.INCLUDE_vTaskDelayUntil=1
|
FREERTOS.INCLUDE_vTaskDelayUntil=1
|
||||||
FREERTOS.IPParameters=Tasks01,configUSE_APPLICATION_TASK_TAG,configUSE_RECURSIVE_MUTEXES,configUSE_COUNTING_SEMAPHORES,configUSE_IDLE_HOOK,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,configTOTAL_HEAP_SIZE,FootprintOK,Queues01,INCLUDE_vTaskDelayUntil
|
FREERTOS.IPParameters=Tasks01,configUSE_APPLICATION_TASK_TAG,configUSE_RECURSIVE_MUTEXES,configUSE_COUNTING_SEMAPHORES,configUSE_IDLE_HOOK,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,configTOTAL_HEAP_SIZE,FootprintOK,Queues01,INCLUDE_vTaskDelayUntil
|
||||||
FREERTOS.Queues01=Queue_J,16,uint16_t,0,Dynamic,NULL,NULL;Queue_N,16,uint16_t,0,Dynamic,NULL,NULL;Queue_F,16,uint16_t,0,Dynamic,NULL,NULL;Queue_E,16,uint16_t,0,Dynamic,NULL,NULL
|
FREERTOS.Queues01=Queue_J,16,uint16_t,0,Dynamic,NULL,NULL;Queue_N,16,uint16_t,0,Dynamic,NULL,NULL;Queue_F,16,uint16_t,0,Dynamic,NULL,NULL;Queue_E,16,uint16_t,0,Dynamic,NULL,NULL
|
||||||
FREERTOS.Tasks01=GameMaster,0,128,f_GameMaster,Default,NULL,Dynamic,NULL,NULL;Joueur_1,0,128,f_Joueur_1,Default,NULL,Dynamic,NULL,NULL;Block_Enemie,-3,128,f_block_enemie,Default,NULL,Dynamic,NULL,NULL;Projectile,0,128,f_projectile,Default,NULL,Dynamic,Dynamic,NULL;IRQ_BP,2,128,f_IRQ_BP,Default,NULL,Dynamic,NULL,NULL;tir_joueur,0,128,f_tir_joueur,Default,NULL,Dynamic,NULL,NULL
|
FREERTOS.Tasks01=GameMaster,0,128,f_GameMaster,Default,NULL,Dynamic,NULL,NULL;Joueur_1,0,128,f_Joueur_1,Default,NULL,Dynamic,NULL,NULL;Block_Enemie,-3,128,f_block_enemie,Default,NULL,Dynamic,NULL,NULL;Projectile,0,128,f_projectile,Default,NULL,Dynamic,Dynamic,NULL;IRQ_BP,1,128,f_IRQ_BP,Default,NULL,Dynamic,NULL,NULL
|
||||||
FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2
|
FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2
|
||||||
FREERTOS.configTOTAL_HEAP_SIZE=32768
|
FREERTOS.configTOTAL_HEAP_SIZE=32768
|
||||||
FREERTOS.configUSE_APPLICATION_TASK_TAG=1
|
FREERTOS.configUSE_APPLICATION_TASK_TAG=1
|
||||||
|
|
Loading…
Reference in a new issue