Untitled

 avatar
unknown
c_cpp
2 years ago
1.8 kB
1
Indexable
#include "stm32f4xx.h"
#include "stm32f4_discovery.h"

#include "stdio.h"

#include "FreeRTOS.h"
#include "task.h"

int _write(int32_t file, uint8_t *ptr, int32_t len)
{
	for(int i = 0; i < len; i++)
		ITM_SendChar((*ptr++));

	return len;
}
TaskHandle_t myTask1Handle = NULL;
TaskHandle_t myTask2Handle = NULL;


void Task1_Handler(void *params);
void Task2_Handler(void *params);

int main(void)
{
	// 1. Adım Sistem saati dahili saat olarak ayarlandı
	RCC_DeInit(); // HSI ON | HSE OFF | PLL OFF | SystemClock 16 MHz

	// 2. Adım Sistem saati 16 Mhz olarak ayarlandı
	SystemCoreClockUpdate(); // SystemCoreClock = 16000000

	printf("Starting RTOS project. \n");



	// 3. Adım Görev Oluşturma
	xTaskCreate(Task1_Handler, "Task 1", configMINIMAL_STACK_SIZE, NULL, 3, &myTask1Handle);
    xTaskCreate(Task2_Handler, "Task 2", configMINIMAL_STACK_SIZE, NULL, 4, &myTask2Handle);

    vTaskStartScheduler();

  while (1)
  {

  }


}

void Task1_Handler(void *params)
{
	while(1)
	{
		printf("Hello World From Task-1.  \n");
		vTaskDelay(pdMS_TO_TICKS(500)); // 500ms gecikme
	}
}
void Task2_Handler(void *params)
{
	while(1)
	{
		printf("Hello World From Task-2.  \n");
		vTaskDelay(pdMS_TO_TICKS(1000)); // 1000ms gecikme
	}
}




/*
 * Callback used by stm32f4_discovery_audio_codec.c.
 * Refer to stm32f4_discovery_audio_codec.h for more info.
 */
void EVAL_AUDIO_TransferComplete_CallBack(uint32_t pBuffer, uint32_t Size){
  /* TODO, implement your code here */
  return;
}

/*
 * Callback used by stm324xg_eval_audio_codec.c.
 * Refer to stm324xg_eval_audio_codec.h for more info.
 */
uint16_t EVAL_AUDIO_GetSampleCallBack(void){
  /* TODO, implement your code here */
  return -1;
}