说明:CC3000初始化要等ucosii操作系统跑起来后再执行,否则进不了外部中断函数。
/*
*********************************************************************************************************
* main()
*
* Description : This is the standard entry point for C code. It is assumed that your code will call
* main() once you have performed all necessary initialization.
*
* Argument(s) : none.
*
* Return(s) : none.
*********************************************************************************************************
*/
int main (void)
{
CPU_INT08U os_err;
BSP_IntDisAll(); /* Disable all ints until we are ready to accept them. */
OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel". */
os_err = OSTaskCreateExt((void (*)(void *)) App_TaskStart, /* Create the start task. */
(void * ) 0,
(OS_STK * )&App_TaskStartStk[APP_TASK_START_STK_SIZE - 1],
(INT8U ) APP_TASK_START_PRIO,
(INT16U ) APP_TASK_START_PRIO,
(OS_STK * )&App_TaskStartStk[0],
(INT32U ) APP_TASK_START_STK_SIZE,
(void * )0,
(INT16U )(OS_TASK_OPT_STK_CLR | OS_TASK_OPT_STK_CHK));
#if (OS_TASK_NAME_SIZE >= 11)
OSTaskNameSet(APP_TASK_START_PRIO, (CPU_INT08U *)"Start Task", &os_err);
#endif
OSStart(); /* Start multitasking (i.e. give control to uC/OS-II). */
return (0);
}
/*
*********************************************************************************************************
* App_TaskStart()
*
* Description : The startup task. The uC/OS-II ticker should only be initialize once multitasking starts.
*
* Argument(s) : p_arg Argument passed to 'App_TaskStart()' by 'OSTaskCreate()'.
*
* Return(s) : none.
*
* Caller(s) : This is a task.
*
* Note(s) : none.
*********************************************************************************************************
*/
static void App_TaskStart (void *p_arg)
{
(void)p_arg;
BSP_Init(); /* Initialize BSP functions. */
OS_CPU_SysTickInit(); /* Initialize the SysTick. */
#if (OS_TASK_STAT_EN > 0)
OSStatInit(); /* Determine CPU capacity. */
#endif
while (DEF_TRUE) {
OSTimeDlyHMSM(0, 0, 0, 1000);
}
}
/*
*********************************************************************************************************
* BSP_Init()
*
* Description : Initialize the Board Support Package (BSP).
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* Note(s) : (1) This function SHOULD be called before any other BSP function is called.
*********************************************************************************************************
*/
void BSP_Init (void)
{
BSP_SystemInit(); /* Initialize system clock */
delay_init();
#if (APP_DEBUG_EN == DEF_ENABLED)
BSP_USART_Init(); /* Initialize Debug Usart */
#endif
#if (APP_KEY_EN == DEF_ENABLED)
Key_Init(); /* Initialize ADCs & DMA for Keys */
#endif
#if (APP_WIFI_EN == DEF_ENABLED)
CC3000_WLAN_Setup(); // Initialize Board and CC3000
#endif
}
//CC3000使能外部中断
void WlanInterruptEnable(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
/* CC3000_WIFI_INT_GPIO and AFIO Peripheral clock enable */
RCC_APB2PeriphClockCmd(CC3000_WIFI_INT_GPIO_CLK | RCC_APB2Periph_AFIO, ENABLE);
/* Configure CC3000_WIFI pins: Interrupt */
GPIO_InitStructure.GPIO_Pin = CC3000_WIFI_INT_GPIO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(CC3000_WIFI_INT_GPIO_PORT, &GPIO_InitStructure);
/* Select the CC3000_WIFI_INT GPIO pin used as EXTI Line */
GPIO_EXTILineConfig(CC3000_WIFI_INT_EXTI_PORT_SOURCE, CC3000_WIFI_INT_EXTI_PIN_SOURCE );
/* Clear the EXTI line pending flag */
EXTI_ClearFlag(CC3000_WIFI_INT_EXTI_LINE );
/* Configure and Enable CC3000_WIFI_INT EXTI line */
EXTI_InitStructure.EXTI_Line = CC3000_WIFI_INT_EXTI_LINE;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
BSP_IntVectSet(BSP_INT_ID_EXTI9_5, EXTI9_5_IRQHandler);
BSP_IntPrioSet(BSP_INT_ID_EXTI9_5, EXTI9_5_IRQ_PRIORITY);
BSP_IntEn(BSP_INT_ID_EXTI9_5);
}
//CC3000 外部中断服务函数
void EXTI9_5_IRQHandler(void)
{
if (EXTI_GetITStatus(CC3000_WIFI_INT_EXTI_LINE) != RESET) //SPI irq
{
SPI_IRQ();
EXTI_ClearITPendingBit(CC3000_WIFI_INT_EXTI_LINE);
}
}