/***************************************************************** * File: w3_sw_intr.c * Copyright (c) 2019 Mango Communications, all rights reserved *****************************************************************/ #include "wlan_platform_high.h" #include "wlan_mac_high.h" #include "w3_sw_intr.h" #include "sw_intr_util.h" #include "xparameters.h" // Base address of sw_intr_util pcore for software-generated interrupts #define SW_INTR_BASEADDR XPAR_HIGH_SW_INTR_UTIL_BASEADDR void _sw_intr_A_handler(); int w3_sw_intr_init() { sw_intr_init(SW_INTR_BASEADDR); // Configure sw_intr_A to assert for one-hot interrupt IDs sw_intr_set_mask_A0(SW_INTR_BASEADDR, (SW_INTR_ID_PORTAL_ETH_RX | SW_INTR_ID_PORTAL_ETH_TX | SW_INTR_ID_WLAN_EXP_ETH_TX)); // Connect the ISR - sw_intr_util outputs are low after sw_intr_init() // Core has two interrupt outputs // W3 project connects INTRA to high priority, INTRB to low-priority wlan_platform_interrupt_connect(XPAR_INTC_0_SW_INTR_UTIL_0_INTRA_OUT_VEC_ID, (wlan_intr_handler_t)_sw_intr_A_handler, NULL); wlan_platform_interrupt_enable(XPAR_INTC_0_SW_INTR_UTIL_0_INTRA_OUT_VEC_ID); return WLAN_SUCCESS; } void wlan_platform_assert_sw_intr(u32 intr_mask) { u32 x = sw_intr_get_state0(SW_INTR_BASEADDR); sw_intr_set_state0(SW_INTR_BASEADDR, x | intr_mask); } void wlan_platform_clear_sw_intr(u32 intr_mask) { u32 x = sw_intr_get_state0(SW_INTR_BASEADDR); sw_intr_set_state0(SW_INTR_BASEADDR, x & ~intr_mask); } void wlan_platform_set_sw_intr_mask(u32 intr_mask) { sw_intr_set_mask_A0(SW_INTR_BASEADDR, sw_intr_get_mask_A0(SW_INTR_BASEADDR)|intr_mask); } void wlan_platform_clear_sw_intr_mask(u32 intr_mask) { sw_intr_set_mask_A0(SW_INTR_BASEADDR, sw_intr_get_mask_A0(SW_INTR_BASEADDR)&~intr_mask); } // Local functions void _sw_intr_A_handler(void *InstancePtr) { // InstancePtr is NULL for sw_intr_util interrupts u32 intr_state = sw_intr_get_state0(SW_INTR_BASEADDR); wlan_mac_high_sw_intr_callback(intr_state); }