예제 #1
0
    /* 
    * Wait for at least one Low Power clock edge after the power up of the Radio Power Domain *e.g. with ble_wait_lp_clk_posedge() )
    * or even better check the BLE_CNTL2_REG[WAKEUPLPSTAT] !
    * Thus you assure that BLE_WAKEUP_LP_IRQ is deasserted and BLE_SLP_IRQ is asserted.
    * After this check exit this ISE in order to proceed with BLE_SLP_Handler().
    */
	while ( GetBits32(BLE_CNTL2_REG, WAKEUPLPSTAT) || !GetBits32(BLE_INTSTAT_REG, SLPINTSTAT))
		if (t) break;

	// Now BLE_WAKEUP_LP_IRQ is deasserted and BLE_SLP_IRQ is asserted, so exit in order to proceed with BLE_SLP_Handler().
	// NOTE: If returning from BLE_WAKEUP_LP_Handler() will not cause BLE_SLP_Handler() to start, 
	//       but the code after __WFI() is executed, then THERE WAS A SW SETUP PROBLEM !!! 
	//			 so it is recommended to place a check after __WFI().
}

#if 0
// /*********************************************************************************
//  *** CSCNT ISR
//  ***/
void BLE_CSCNT_Handler(void)
{
    SetBits32(BLE_INTACK_REG, CSCNTINTACK, 1);
#if DEEP_SLEEP //Needed only for compilation. Remove when ROM code is ready.
#if RW_BLE_SUPPORT
    // Handle end of wake-up
	rwip_wakeup_end();
	/*
 	 *	Init TX and RX buffers, they are in EM but not in the retainable part
 	 *  so the pointers have to be programmed again	*
 	 */
	if(func_check_mem_flag)
	{
		if (func_check_mem_flag==2)
		{
	  //init TX/RX buffers after DEEPSLEEP	
		co_buf_init_deep_sleep();
		// Set the first RX descriptor pointer into the HW
        ble_currentrxdescptr_set(REG_BLE_EM_RX_ADDR_GET(co_buf_rx_current_get()));
		}   	
       //INIT NONE RET. HEAP after DEEPSLEEP	
       	ke_mem_init(KE_MEM_NON_RETENTION, (uint8_t*)(jump_table_struct[rwip_heap_non_ret_pos]), jump_table_struct[rwip_heap_non_ret_size]);

		func_check_mem_flag = 0;//false;
		
	}
    
 #endif //RW_BLE_SUPPORT
#endif //DEEP_SLEEP
}
예제 #2
0
void rwip_init(uint32_t error)
{
    #if (NVDS_SUPPORT && DEEP_SLEEP)
    uint8_t length = 1;
    uint8_t sleep_enable;
    uint8_t ext_wakeup_enable;
    #endif //NVDS_SUPPORT && DEEP_SLEEP

    // Reset RW environment
    memset(&rwip_env, 0, sizeof(rwip_env));
	
	ke_mem_heaps_used = KE_MEM_BLOCK_MAX;

    #if (KE_SUPPORT)
    // Initialize kernel
    ke_init();
    // Initialize memory heap used by kernel.
    #if (KE_MEM_RW)
    // Memory allocated for environment variables

    //ke_mem_init(KE_MEM_ENV,           (uint8_t*)rwip_heap_env,     RWIP_HEAP_ENV_SIZE);
    ke_mem_init(KE_MEM_ENV,(uint8_t*)(jump_table_struct[rwip_heap_env_pos]),     jump_table_struct[rwip_heap_env_size]);	
    #if 1//(BLE_HOST_PRESENT)
    // Memory allocated for Attribute database
    //ke_mem_init(KE_MEM_ATT_DB,        (uint8_t*)rwip_heap_db,      RWIP_HEAP_DB_SIZE);
    ke_mem_init(KE_MEM_ATT_DB,(uint8_t*)(jump_table_struct[rwip_heap_db_pos]),      jump_table_struct[rwip_heap_db_size]);	
    #endif // (BLE_HOST_PRESENT)
    // Memory allocated for kernel messages
    //ke_mem_init(KE_MEM_KE_MSG,        (uint8_t*)rwip_heap_msg,     RWIP_HEAP_MSG_SIZE);
    ke_mem_init(KE_MEM_KE_MSG,(uint8_t*)(jump_table_struct[rwip_heap_msg_pos]),     jump_table_struct[rwip_heap_msg_size]);
    // Non Retention memory block
    //ke_mem_init(KE_MEM_NON_RETENTION, (uint8_t*)rwip_heap_non_ret, RWIP_HEAP_NON_RET_SIZE);
    ke_mem_init(KE_MEM_NON_RETENTION, (uint8_t*)(jump_table_struct[rwip_heap_non_ret_pos]), jump_table_struct[rwip_heap_non_ret_size]);


    #endif // (KE_MEM_RW)
    #endif //KE_SUPPORT

    #if (GTL_ITF)
    // Initialize the Generic Transport Layer
    gtl_init(rwip_eif_get(RWIP_EIF_AHI));
    #endif //GTL_ITF

    // Initialize RF
    #if (BT_EMB_PRESENT || BLE_EMB_PRESENT)
    rf_init(&rwip_rf);
    SetBits32(BLE_RADIOCNTL1_REG, XRFSEL, 3);

    #endif //BT_EMB_PRESENT || BLE_EMB_PRESENT

    #if (BT_EMB_PRESENT)
    // Initialize BT
    rwbt_init();
    #endif //BT_EMB_PRESENT

    #if (BLE_EMB_PRESENT)
    // Initialize BLE
    rwble_init();
    #endif //BLE_EMB_PRESENT

    #if (BLE_HOST_PRESENT)
    // Initialize BLE Host stack
    rwble_hl_init();
    #endif //BLE_HOST_PRESENT

    #if (DISPLAY_SUPPORT)
    // Initialize display module
    display_init();

    // Add some configuration information to display
    display_add_config();
    #endif //DISPLAY_SUPPORT

    #if (NVDS_SUPPORT && DEEP_SLEEP)
    // Activate deep sleep feature if enabled in NVDS
    if(nvds_get(NVDS_TAG_SLEEP_ENABLE, &length, &sleep_enable) == NVDS_OK)
    {
        if(sleep_enable != 0)
        {
            rwip_env.sleep_enable = true;

            // Set max sleep duration depending on wake-up mode
            if(nvds_get(NVDS_TAG_EXT_WAKEUP_ENABLE, &length, &ext_wakeup_enable) == NVDS_OK)
            {
                if(ext_wakeup_enable != 0)
                {
                    //vm  rwip_env.ext_wakeup_enable = true;
                    rwip_env.ext_wakeup_enable = ext_wakeup_enable;
                }
            }
        }
    }
    #endif //NVDS_SUPPORT && DEEP_SLEEP

    // If FW initializes due to FW reset, send the message to Host
    if(error != RESET_NO_ERROR)
    {
        #if (BT_EMB_PRESENT && HCIC_ITF)
        rwbt_send_message(error);
        #elif (BLE_EMB_PRESENT && HCIC_ITF)
        rwble_send_message(error);
        #elif (BLE_HOST_PRESENT && GTL_ITF)
        rwble_hl_send_message(error);
        #endif //BT_EMB_PRESENT / BLE_EMB_PRESENT
    }

    /*
     ************************************************************************************
     * Application initialization
     ************************************************************************************
     */
    // vm moved to main
    //    if(jump_table_struct[0]==TASK_APP)
    // Initialize APP
    //    app_init();

    func_check_mem_flag = 0;//false;
}