main.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. ******************************************************************************
  3. * @file main.c
  4. * @author LI
  5. * @version V3.5.0
  6. * @date 08-April-2015
  7. * @brief Main program body
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  12. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  13. * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  14. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  15. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  16. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  17. *
  18. * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  19. ******************************************************************************
  20. */
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "includes.h"
  23. /* Private typedef -----------------------------------------------------------*/
  24. /* Private define ------------------------------------------------------------*/
  25. /* Private macro -------------------------------------------------------------*/
  26. /* Private variables ---------------------------------------------------------*/
  27. /* Private function prototypes -----------------------------------------------*/
  28. /* Private functions ---------------------------------------------------------*/
  29. void AppTaskStart(void *p_arg);
  30. OS_TCB AppTaskStartTCB;
  31. CPU_STK AppTaskStartStk[APP_TASK_START_STK_SIZE];
  32. int main(void)
  33. {
  34. /*!< At this stage the microcontroller clock setting is already configured,
  35. this is done through SystemInit() function which is called from startup
  36. file (startup_stm32f10x_xx.s) before to branch to application main.
  37. To reconfigure the default setting of SystemInit() function, refer to
  38. system_stm32f10x.c file*/
  39. OS_ERR err;
  40. OSInit(&err); // Init uC/OS-III.
  41. OSTaskCreate((OS_TCB *)&AppTaskStartTCB, // Create the start task
  42. (CPU_CHAR *)"App Task Start",
  43. (OS_TASK_PTR )AppTaskStart,
  44. (void *)0,
  45. (OS_PRIO )APP_TASK_START_PRIO,
  46. (CPU_STK *)&AppTaskStartStk[0],
  47. (CPU_STK_SIZE)APP_TASK_START_STK_SIZE / 10,
  48. (CPU_STK_SIZE)APP_TASK_START_STK_SIZE,
  49. (OS_MSG_QTY )0,
  50. (OS_TICK )0,
  51. (void *)0,
  52. (OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
  53. (OS_ERR *)&err);
  54. #ifdef _DEBUG__
  55. NVIC_SetVectorTable(FLASH_BASE, 0x00000);//0x10000
  56. #else
  57. NVIC_SetVectorTable(FLASH_BASE, 0x20000);//0x10000
  58. #endif
  59. __ASM volatile ("cpsie i");
  60. OSStart(&err);
  61. }