Ajout tache de base

This commit is contained in:
leo 2021-03-30 16:15:20 +02:00
parent 28e812de22
commit fa2a323ede
3 changed files with 1115 additions and 979 deletions

View file

@ -71,7 +71,10 @@ UART_HandleTypeDef huart6;
SDRAM_HandleTypeDef hsdram1;
osThreadId defaultTaskHandle;
osThreadId GameMasterHandle;
osThreadId Joueur_1Handle;
osThreadId Block_EnemieHandle;
osThreadId ProjectileHandle;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
@ -97,7 +100,10 @@ static void MX_DAC_Init(void);
static void MX_UART7_Init(void);
static void MX_FMC_Init(void);
static void MX_DMA2D_Init(void);
void StartDefaultTask(void const *argument);
void f_GameMaster(void const * argument);
void f_Joueur_1(void const * argument);
void f_block_enemie(void const * argument);
void f_projectile(void const * argument);
/* USER CODE BEGIN PFP */
@ -112,7 +118,8 @@ void StartDefaultTask(void const *argument);
* @brief The application entry point.
* @retval int
*/
int main(void) {
int main(void)
{
/* USER CODE BEGIN 1 */
char text[50] = { };
static TS_StateTypeDef TS_State;
@ -191,16 +198,29 @@ int main(void) {
/* USER CODE END RTOS_QUEUES */
/* Create the thread(s) */
/* definition and creation of defaultTask */
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 4096);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
/* definition and creation of GameMaster */
osThreadDef(GameMaster, f_GameMaster, osPriorityNormal, 0, 128);
GameMasterHandle = osThreadCreate(osThread(GameMaster), NULL);
/* definition and creation of Joueur_1 */
osThreadDef(Joueur_1, f_Joueur_1, osPriorityNormal, 0, 128);
Joueur_1Handle = osThreadCreate(osThread(Joueur_1), NULL);
/* definition and creation of Block_Enemie */
osThreadDef(Block_Enemie, f_block_enemie, osPriorityIdle, 0, 128);
Block_EnemieHandle = osThreadCreate(osThread(Block_Enemie), NULL);
/* definition and creation of Projectile */
osThreadStaticDef(Projectile, f_projectile, osPriorityNormal, 0, 128, Dynamic, &NULL);
ProjectileHandle = osThreadCreate(osThread(Projectile), (void*) sens);
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */
/* Start scheduler */
//osKernelStart();
osKernelStart();
/* We should never get here as control is now taken by the scheduler */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
@ -261,7 +281,8 @@ int main(void) {
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void) {
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
@ -276,8 +297,7 @@ void SystemClock_Config(void) {
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI
| RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
@ -286,12 +306,14 @@ void SystemClock_Config(void) {
RCC_OscInitStruct.PLL.PLLN = 400;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Activate the Over-Drive mode
*/
if (HAL_PWREx_EnableOverDrive() != HAL_OK) {
if (HAL_PWREx_EnableOverDrive() != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
@ -303,12 +325,14 @@ void SystemClock_Config(void) {
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6) != HAL_OK) {
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC
| RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART6
| RCC_PERIPHCLK_UART7 | RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C3;
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC|RCC_PERIPHCLK_RTC
|RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_USART6
|RCC_PERIPHCLK_UART7|RCC_PERIPHCLK_I2C1
|RCC_PERIPHCLK_I2C3;
PeriphClkInitStruct.PLLSAI.PLLSAIN = 384;
PeriphClkInitStruct.PLLSAI.PLLSAIR = 5;
PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2;
@ -321,7 +345,8 @@ void SystemClock_Config(void) {
PeriphClkInitStruct.Uart7ClockSelection = RCC_UART7CLKSOURCE_PCLK1;
PeriphClkInitStruct.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
PeriphClkInitStruct.I2c3ClockSelection = RCC_I2C3CLKSOURCE_PCLK1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
}
@ -331,7 +356,8 @@ void SystemClock_Config(void) {
* @param None
* @retval None
*/
static void MX_ADC1_Init(void) {
static void MX_ADC1_Init(void)
{
/* USER CODE BEGIN ADC1_Init 0 */
@ -356,7 +382,8 @@ static void MX_ADC1_Init(void) {
hadc1.Init.NbrOfConversion = 1;
hadc1.Init.DMAContinuousRequests = DISABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
if (HAL_ADC_Init(&hadc1) != HAL_OK) {
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
@ -364,7 +391,8 @@ static void MX_ADC1_Init(void) {
sConfig.Channel = ADC_CHANNEL_0;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) {
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN ADC1_Init 2 */
@ -378,7 +406,8 @@ static void MX_ADC1_Init(void) {
* @param None
* @retval None
*/
static void MX_ADC3_Init(void) {
static void MX_ADC3_Init(void)
{
/* USER CODE BEGIN ADC3_Init 0 */
@ -403,7 +432,8 @@ static void MX_ADC3_Init(void) {
hadc3.Init.NbrOfConversion = 1;
hadc3.Init.DMAContinuousRequests = DISABLE;
hadc3.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
if (HAL_ADC_Init(&hadc3) != HAL_OK) {
if (HAL_ADC_Init(&hadc3) != HAL_OK)
{
Error_Handler();
}
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
@ -411,7 +441,8 @@ static void MX_ADC3_Init(void) {
sConfig.Channel = ADC_CHANNEL_6;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) {
if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN ADC3_Init 2 */
@ -425,7 +456,8 @@ static void MX_ADC3_Init(void) {
* @param None
* @retval None
*/
static void MX_DAC_Init(void) {
static void MX_DAC_Init(void)
{
/* USER CODE BEGIN DAC_Init 0 */
@ -439,14 +471,16 @@ static void MX_DAC_Init(void) {
/** DAC Initialization
*/
hdac.Instance = DAC;
if (HAL_DAC_Init(&hdac) != HAL_OK) {
if (HAL_DAC_Init(&hdac) != HAL_OK)
{
Error_Handler();
}
/** DAC channel OUT1 config
*/
sConfig.DAC_Trigger = DAC_TRIGGER_NONE;
sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
if (HAL_DAC_ConfigChannel(&hdac, &sConfig, DAC_CHANNEL_1) != HAL_OK) {
if (HAL_DAC_ConfigChannel(&hdac, &sConfig, DAC_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN DAC_Init 2 */
@ -460,7 +494,8 @@ static void MX_DAC_Init(void) {
* @param None
* @retval None
*/
static void MX_DMA2D_Init(void) {
static void MX_DMA2D_Init(void)
{
/* USER CODE BEGIN DMA2D_Init 0 */
@ -477,10 +512,12 @@ static void MX_DMA2D_Init(void) {
hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_ARGB8888;
hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
hdma2d.LayerCfg[1].InputAlpha = 0;
if (HAL_DMA2D_Init(&hdma2d) != HAL_OK) {
if (HAL_DMA2D_Init(&hdma2d) != HAL_OK)
{
Error_Handler();
}
if (HAL_DMA2D_ConfigLayer(&hdma2d, 1) != HAL_OK) {
if (HAL_DMA2D_ConfigLayer(&hdma2d, 1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN DMA2D_Init 2 */
@ -494,7 +531,8 @@ static void MX_DMA2D_Init(void) {
* @param None
* @retval None
*/
static void MX_I2C1_Init(void) {
static void MX_I2C1_Init(void)
{
/* USER CODE BEGIN I2C1_Init 0 */
@ -512,18 +550,20 @@ static void MX_I2C1_Init(void) {
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK) {
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
{
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE)
!= HAL_OK) {
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK) {
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN I2C1_Init 2 */
@ -537,7 +577,8 @@ static void MX_I2C1_Init(void) {
* @param None
* @retval None
*/
static void MX_I2C3_Init(void) {
static void MX_I2C3_Init(void)
{
/* USER CODE BEGIN I2C3_Init 0 */
@ -555,18 +596,20 @@ static void MX_I2C3_Init(void) {
hi2c3.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c3) != HAL_OK) {
if (HAL_I2C_Init(&hi2c3) != HAL_OK)
{
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE)
!= HAL_OK) {
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK) {
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN I2C3_Init 2 */
@ -580,7 +623,8 @@ static void MX_I2C3_Init(void) {
* @param None
* @retval None
*/
static void MX_LTDC_Init(void) {
static void MX_LTDC_Init(void)
{
/* USER CODE BEGIN LTDC_Init 0 */
@ -607,7 +651,8 @@ static void MX_LTDC_Init(void) {
hltdc.Init.Backcolor.Blue = 0;
hltdc.Init.Backcolor.Green = 0;
hltdc.Init.Backcolor.Red = 0;
if (HAL_LTDC_Init(&hltdc) != HAL_OK) {
if (HAL_LTDC_Init(&hltdc) != HAL_OK)
{
Error_Handler();
}
pLayerCfg.WindowX0 = 0;
@ -625,7 +670,8 @@ static void MX_LTDC_Init(void) {
pLayerCfg.Backcolor.Blue = 0;
pLayerCfg.Backcolor.Green = 0;
pLayerCfg.Backcolor.Red = 0;
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK) {
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN LTDC_Init 2 */
@ -639,7 +685,8 @@ static void MX_LTDC_Init(void) {
* @param None
* @retval None
*/
static void MX_RTC_Init(void) {
static void MX_RTC_Init(void)
{
/* USER CODE BEGIN RTC_Init 0 */
@ -661,7 +708,8 @@ static void MX_RTC_Init(void) {
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
if (HAL_RTC_Init(&hrtc) != HAL_OK) {
if (HAL_RTC_Init(&hrtc) != HAL_OK)
{
Error_Handler();
}
@ -676,14 +724,16 @@ static void MX_RTC_Init(void) {
sTime.Seconds = 0x0;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK) {
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
{
Error_Handler();
}
sDate.WeekDay = RTC_WEEKDAY_MONDAY;
sDate.Month = RTC_MONTH_JANUARY;
sDate.Date = 0x1;
sDate.Year = 0x0;
if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK) {
if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK)
{
Error_Handler();
}
/** Enable the Alarm A
@ -699,19 +749,21 @@ static void MX_RTC_Init(void) {
sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;
sAlarm.AlarmDateWeekDay = 0x1;
sAlarm.Alarm = RTC_ALARM_A;
if (HAL_RTC_SetAlarm(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK) {
if (HAL_RTC_SetAlarm(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK)
{
Error_Handler();
}
/** Enable the Alarm B
*/
sAlarm.Alarm = RTC_ALARM_B;
if (HAL_RTC_SetAlarm(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK) {
if (HAL_RTC_SetAlarm(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK)
{
Error_Handler();
}
/** Enable the TimeStamp
*/
if (HAL_RTCEx_SetTimeStamp(&hrtc, RTC_TIMESTAMPEDGE_RISING,
RTC_TIMESTAMPPIN_POS1) != HAL_OK) {
if (HAL_RTCEx_SetTimeStamp(&hrtc, RTC_TIMESTAMPEDGE_RISING, RTC_TIMESTAMPPIN_POS1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN RTC_Init 2 */
@ -725,7 +777,8 @@ static void MX_RTC_Init(void) {
* @param None
* @retval None
*/
static void MX_SPI2_Init(void) {
static void MX_SPI2_Init(void)
{
/* USER CODE BEGIN SPI2_Init 0 */
@ -749,7 +802,8 @@ static void MX_SPI2_Init(void) {
hspi2.Init.CRCPolynomial = 7;
hspi2.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
if (HAL_SPI_Init(&hspi2) != HAL_OK) {
if (HAL_SPI_Init(&hspi2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SPI2_Init 2 */
@ -763,7 +817,8 @@ static void MX_SPI2_Init(void) {
* @param None
* @retval None
*/
static void MX_TIM1_Init(void) {
static void MX_TIM1_Init(void)
{
/* USER CODE BEGIN TIM1_Init 0 */
@ -782,18 +837,20 @@ static void MX_TIM1_Init(void) {
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim1) != HAL_OK) {
if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK) {
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig)
!= HAL_OK) {
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM1_Init 2 */
@ -807,7 +864,8 @@ static void MX_TIM1_Init(void) {
* @param None
* @retval None
*/
static void MX_TIM2_Init(void) {
static void MX_TIM2_Init(void)
{
/* USER CODE BEGIN TIM2_Init 0 */
@ -825,17 +883,19 @@ static void MX_TIM2_Init(void) {
htim2.Init.Period = 4294967295;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim2) != HAL_OK) {
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK) {
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig)
!= HAL_OK) {
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM2_Init 2 */
@ -849,7 +909,8 @@ static void MX_TIM2_Init(void) {
* @param None
* @retval None
*/
static void MX_TIM3_Init(void) {
static void MX_TIM3_Init(void)
{
/* USER CODE BEGIN TIM3_Init 0 */
@ -869,33 +930,37 @@ static void MX_TIM3_Init(void) {
htim3.Init.Period = 65535;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim3) != HAL_OK) {
if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK) {
if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK) {
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
{
Error_Handler();
}
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_DISABLE;
sSlaveConfig.InputTrigger = TIM_TS_ITR0;
if (HAL_TIM_SlaveConfigSynchro(&htim3, &sSlaveConfig) != HAL_OK) {
if (HAL_TIM_SlaveConfigSynchro(&htim3, &sSlaveConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig)
!= HAL_OK) {
if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1)
!= HAL_OK) {
if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM3_Init 2 */
@ -910,7 +975,8 @@ static void MX_TIM3_Init(void) {
* @param None
* @retval None
*/
static void MX_TIM5_Init(void) {
static void MX_TIM5_Init(void)
{
/* USER CODE BEGIN TIM5_Init 0 */
@ -928,17 +994,19 @@ static void MX_TIM5_Init(void) {
htim5.Init.Period = 4294967295;
htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim5.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim5) != HAL_OK) {
if (HAL_TIM_Base_Init(&htim5) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim5, &sClockSourceConfig) != HAL_OK) {
if (HAL_TIM_ConfigClockSource(&htim5, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig)
!= HAL_OK) {
if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM5_Init 2 */
@ -952,7 +1020,8 @@ static void MX_TIM5_Init(void) {
* @param None
* @retval None
*/
static void MX_TIM8_Init(void) {
static void MX_TIM8_Init(void)
{
/* USER CODE BEGIN TIM8_Init 0 */
@ -973,21 +1042,24 @@ static void MX_TIM8_Init(void) {
htim8.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim8.Init.RepetitionCounter = 0;
htim8.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim8) != HAL_OK) {
if (HAL_TIM_Base_Init(&htim8) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim8, &sClockSourceConfig) != HAL_OK) {
if (HAL_TIM_ConfigClockSource(&htim8, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_PWM_Init(&htim8) != HAL_OK) {
if (HAL_TIM_PWM_Init(&htim8) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig)
!= HAL_OK) {
if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
@ -996,8 +1068,8 @@ static void MX_TIM8_Init(void) {
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
if (HAL_TIM_PWM_ConfigChannel(&htim8, &sConfigOC, TIM_CHANNEL_4)
!= HAL_OK) {
if (HAL_TIM_PWM_ConfigChannel(&htim8, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
{
Error_Handler();
}
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
@ -1011,8 +1083,8 @@ static void MX_TIM8_Init(void) {
sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
sBreakDeadTimeConfig.Break2Filter = 0;
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
if (HAL_TIMEx_ConfigBreakDeadTime(&htim8, &sBreakDeadTimeConfig)
!= HAL_OK) {
if (HAL_TIMEx_ConfigBreakDeadTime(&htim8, &sBreakDeadTimeConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM8_Init 2 */
@ -1027,7 +1099,8 @@ static void MX_TIM8_Init(void) {
* @param None
* @retval None
*/
static void MX_UART7_Init(void) {
static void MX_UART7_Init(void)
{
/* USER CODE BEGIN UART7_Init 0 */
@ -1046,7 +1119,8 @@ static void MX_UART7_Init(void) {
huart7.Init.OverSampling = UART_OVERSAMPLING_16;
huart7.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart7.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart7) != HAL_OK) {
if (HAL_UART_Init(&huart7) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN UART7_Init 2 */
@ -1060,7 +1134,8 @@ static void MX_UART7_Init(void) {
* @param None
* @retval None
*/
static void MX_USART1_UART_Init(void) {
static void MX_USART1_UART_Init(void)
{
/* USER CODE BEGIN USART1_Init 0 */
@ -1079,7 +1154,8 @@ static void MX_USART1_UART_Init(void) {
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart1) != HAL_OK) {
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART1_Init 2 */
@ -1093,7 +1169,8 @@ static void MX_USART1_UART_Init(void) {
* @param None
* @retval None
*/
static void MX_USART6_UART_Init(void) {
static void MX_USART6_UART_Init(void)
{
/* USER CODE BEGIN USART6_Init 0 */
@ -1112,7 +1189,8 @@ static void MX_USART6_UART_Init(void) {
huart6.Init.OverSampling = UART_OVERSAMPLING_16;
huart6.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart6.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart6) != HAL_OK) {
if (HAL_UART_Init(&huart6) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART6_Init 2 */
@ -1122,7 +1200,8 @@ static void MX_USART6_UART_Init(void) {
}
/* FMC initialization function */
static void MX_FMC_Init(void) {
static void MX_FMC_Init(void)
{
/* USER CODE BEGIN FMC_Init 0 */
@ -1157,7 +1236,8 @@ static void MX_FMC_Init(void) {
SdramTiming.RPDelay = 16;
SdramTiming.RCDDelay = 16;
if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) {
if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK)
{
Error_Handler( );
}
@ -1171,7 +1251,8 @@ static void MX_FMC_Init(void) {
* @param None
* @retval None
*/
static void MX_GPIO_Init(void) {
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
@ -1191,8 +1272,7 @@ static void MX_GPIO_Init(void) {
HAL_GPIO_WritePin(GPIOE, LED14_Pin|LED15_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin,
GPIO_PIN_SET);
HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(LED16_GPIO_Port, LED16_Pin, GPIO_PIN_RESET);
@ -1207,9 +1287,8 @@ static void MX_GPIO_Init(void) {
HAL_GPIO_WritePin(LCD_DISP_GPIO_Port, LCD_DISP_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOH,
LED13_Pin | LED17_Pin | LED11_Pin | LED12_Pin | LED2_Pin | LED18_Pin,
GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOH, LED13_Pin|LED17_Pin|LED11_Pin|LED12_Pin
|LED2_Pin|LED18_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(EXT_RST_GPIO_Port, EXT_RST_Pin, GPIO_PIN_RESET);
@ -1352,14 +1431,15 @@ static void MX_GPIO_Init(void) {
/* USER CODE END 4 */
/* USER CODE BEGIN Header_StartDefaultTask */
/* USER CODE BEGIN Header_f_GameMaster */
/**
* @brief Function implementing the defaultTask thread.
* @brief Function implementing the GameMaster thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void const *argument) {
/* USER CODE END Header_f_GameMaster */
void f_GameMaster(void const * argument)
{
/* USER CODE BEGIN 5 */
/* Infinite loop */
for (;;) {
@ -1368,6 +1448,60 @@ void StartDefaultTask(void const *argument) {
/* USER CODE END 5 */
}
/* USER CODE BEGIN Header_f_Joueur_1 */
/**
* @brief Function implementing the Joueur_1 thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_f_Joueur_1 */
void f_Joueur_1(void const * argument)
{
/* USER CODE BEGIN f_Joueur_1 */
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END f_Joueur_1 */
}
/* USER CODE BEGIN Header_f_block_enemie */
/**
* @brief Function implementing the Block_Enemie thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_f_block_enemie */
void f_block_enemie(void const * argument)
{
/* USER CODE BEGIN f_block_enemie */
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END f_block_enemie */
}
/* USER CODE BEGIN Header_f_projectile */
/**
* @brief Function implementing the Projectile thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_f_projectile */
void f_projectile(void const * argument)
{
/* USER CODE BEGIN f_projectile */
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END f_projectile */
}
/**
* @brief Period elapsed callback in non blocking mode
* @note This function is called when TIM6 interrupt took place, inside
@ -1376,7 +1510,8 @@ void StartDefaultTask(void const *argument) {
* @param htim : TIM handle
* @retval None
*/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
/* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */
@ -1392,7 +1527,8 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void) {
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
__disable_irq();

View file

@ -11,7 +11,7 @@ ADC3.Channel-IN5=ADC_CHANNEL_5
ADC3.IPParameters=Channel-IN5,Channel-0\#ChannelRegularConversion,Channel-IN4
FREERTOS.FootprintOK=true
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
FREERTOS.Tasks01=defaultTask,0,4096,StartDefaultTask,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,sens, type,Dynamic,NULL,NULL
FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2
FREERTOS.configTOTAL_HEAP_SIZE=32768
FREERTOS.configUSE_APPLICATION_TASK_TAG=1
@ -717,20 +717,20 @@ ProjectManager.FreePins=false
ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x200
ProjectManager.KeepUserCode=true
ProjectManager.LastFirmware=true
ProjectManager.LastFirmware=false
ProjectManager.LibraryCopy=1
ProjectManager.MainLocation=Core/Src
ProjectManager.NoMain=false
ProjectManager.PreviousToolchain=
ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=test_.ioc
ProjectManager.ProjectName=test_
ProjectManager.ProjectFileName=Space_Invaders.ioc
ProjectManager.ProjectName=Space_Invaders
ProjectManager.RegisterCallBack=
ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_I2C3_Init-I2C3-false-HAL-true,6-MX_LTDC_Init-LTDC-false-HAL-true,7-MX_RTC_Init-RTC-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_TIM1_Init-TIM1-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM3_Init-TIM3-false-HAL-true,12-MX_TIM5_Init-TIM5-false-HAL-true,13-MX_TIM8_Init-TIM8-false-HAL-true,14-MX_USART1_UART_Init-USART1-false-HAL-true,15-MX_USART6_UART_Init-USART6-false-HAL-true,16-MX_ADC1_Init-ADC1-false-HAL-true,17-MX_DAC_Init-DAC-false-HAL-true,18-MX_UART7_Init-UART7-false-HAL-true,19-MX_FMC_Init-FMC-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_I2C3_Init-I2C3-false-HAL-true,6-MX_LTDC_Init-LTDC-false-HAL-true,7-MX_RTC_Init-RTC-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_TIM1_Init-TIM1-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM3_Init-TIM3-false-HAL-true,12-MX_TIM5_Init-TIM5-false-HAL-true,13-MX_TIM8_Init-TIM8-false-HAL-true,14-MX_USART1_UART_Init-USART1-false-HAL-true,15-MX_USART6_UART_Init-USART6-false-HAL-true,16-MX_ADC1_Init-ADC1-false-HAL-true,17-MX_DAC_Init-DAC-false-HAL-true,18-MX_UART7_Init-UART7-false-HAL-true,19-MX_FMC_Init-FMC-false-HAL-true,20-MX_DMA2D_Init-DMA2D-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
RCC.AHBFreq_Value=200000000
RCC.APB1CLKDivider=RCC_HCLK_DIV4
RCC.APB1Freq_Value=50000000