#include "stm32f4xx.h"

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

#include "main.h"
#include "init_task.h"
#include "common_config.h"
#include "board.h"

/* Размещение стека FreeRTOS в CCRAM */
#if defined ( __ICCARM__ )
#pragma location = ".sram"
uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
#else
uint8_t ucHeap[ configTOTAL_HEAP_SIZE ] __attribute__ ((section (".mb1text")));
/* Секция размещения СRC прошивки */
uint32_t crc __attribute__ ((section (".crc"))) = 0xAABBCCDD;
/* Секция размещения HW ревизии платы */
char hw_rev[HW_REV_LEN] __attribute__ ((section (".hw_rev"))) = HW_REV;
#endif


int main()
{

  TIM_Cmd(TIM13, DISABLE);
  TIM_ClearITPendingBit(TIM13, TIM_IT_Update);

	__disable_irq();
	NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x20000);
	NVIC_SetPriorityGrouping(0);
	NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );
	__enable_irq();

	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC, ENABLE);

	/* Clear flash error flags if were set */
	FLASH_ClearFlag(FLASH_FLAG_PGPERR);
	FLASH_ClearFlag(FLASH_FLAG_PGSERR);
  
  xTaskCreate( InitTask, "InitTask", 500, NULL, tskIDLE_PRIORITY, NULL);
  
  vTaskStartScheduler();
  
  return 0;

}


