本帖最后由 9robot 于 2016-8-22 09:33 编辑
STM32F7已经完全抛弃了标准库的开发方式,只能采用HAL库开发。M7的性能很强大,FLASH和RAM也较大,如果只是裸跑的话,性能就有点浪费。本来打算利用STM32CUBEMX工具来移植FREERTOS,但是出现一些问题,没有成功。所以才去移植ucosii。移植的过程很大一部分参考了M4的移植教程。目前,只是初步移植,M7和M4的寄存器存在一些差别,后期还是需要修改,现在的模板可以正常运行。
static void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
/* Enable HSE Oscillator and activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 8;
RCC_OscInitStruct.PLL.PLLN = 432;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 9;
RCC_OscInitStruct.PLL.PLLR = 7;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
while(1) {};
}
/* Activate the OverDrive to reach the 216 Mhz Frequency */
if(HAL_PWREx_EnableOverDrive() != HAL_OK)
{
while(1) {};
}
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7) != HAL_OK)
{
while(1) {};
}
}
void start_task(void *pdata)
{
OS_CPU_SR cpu_sr=0;
pdata=pdata;
OSStatInit(); //¿ªÆôͳ¼ÆÈÎÎñ
OS_ENTER_CRITICAL(); //½øÈëÁÙ½çÇø(¹Ø±ÕÖжÏ)
//LED0ÈÎÎñ
OSTaskCreateExt((void(*)(void*) )led0_task,
(void* )0,
(OS_STK* )&LED0_TASK_STK[LED0_STK_SIZE-1],
(INT8U )LED0_TASK_PRIO,
(INT16U )LED0_TASK_PRIO,
(OS_STK* )&LED0_TASK_STK[0],
(INT32U )LED0_STK_SIZE,
(void* )0,
(INT16U )OS_TASK_OPT_STK_CHK|OS_TASK_OPT_STK_CLR|OS_TASK_OPT_SAVE_FP);
//LED1ÈÎÎñ
OSTaskCreateExt((void(*)(void*) )led1_task,
(void* )0,
(OS_STK* )&LED1_TASK_STK[LED1_STK_SIZE-1],
(INT8U )LED1_TASK_PRIO,
(INT16U )LED1_TASK_PRIO,
(OS_STK* )&LED1_TASK_STK[0],
(INT32U )LED1_STK_SIZE,
(void* )0,
(INT16U )OS_TASK_OPT_STK_CHK|OS_TASK_OPT_STK_CLR|OS_TASK_OPT_SAVE_FP);
OS_EXIT_CRITICAL(); //Í˳öÁÙ½çÇø(¿ªÖжÏ)
OSTaskSuspend(START_TASK_PRIO); //¹ÒÆð¿ªÊ¼ÈÎÎñ
}
//LED0ÈÎÎñ
void led0_task(void *pdata)
{
INT16U VER;
VER=OSVersion();
while(1)
{
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7);
LCD_Printf(1,2,"%d",VER);
delay_ms(300);
};
}
//LED1ÈÎÎñ
void led1_task(void *pdata)
{
unsigned char i=0;
while(1)
{
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
i++;
LCD_Printf(1,4,"%d",i);
delay_ms(1000);
};
}
|