[6319] | 1 | #include "xuartlite.h" |
---|
| 2 | |
---|
| 3 | #include "wlan_platform_high.h" |
---|
| 4 | #include "wlan_mac_high.h" |
---|
| 5 | #include "w3_high.h" |
---|
| 6 | #include "w3_uart.h" |
---|
| 7 | #include "wlan_mac_common.h" |
---|
| 8 | #include "xparameters.h" |
---|
| 9 | |
---|
| 10 | static XUartLite UartLite; |
---|
| 11 | |
---|
| 12 | // UART interface |
---|
| 13 | static u8 uart_rx_buffer[UART_BUFFER_SIZE]; ///< Buffer for received byte from UART |
---|
| 14 | |
---|
| 15 | // Private functions |
---|
| 16 | void _w3_uart_rx_handler(void *CallBackRef, unsigned int EventData); |
---|
| 17 | |
---|
| 18 | int w3_uart_init(){ |
---|
| 19 | int Status; |
---|
| 20 | |
---|
| 21 | // Initialize the UART driver |
---|
| 22 | Status = XUartLite_Initialize(&UartLite, PLATFORM_DEV_ID_UART); |
---|
| 23 | if (Status != XST_SUCCESS) { |
---|
| 24 | wlan_printf(PL_ERROR, "ERROR: Could not initialize UART\n"); |
---|
| 25 | Status = WLAN_FAILURE; |
---|
| 26 | } |
---|
| 27 | return Status; |
---|
| 28 | } |
---|
| 29 | int w3_uart_setup_interrupt() { |
---|
| 30 | int Status; |
---|
| 31 | // UART |
---|
| 32 | Status = wlan_platform_interrupt_connect(PLATFORM_INT_ID_UART, (wlan_intr_handler_t)XUartLite_InterruptHandler, &UartLite); |
---|
| 33 | if (Status != XST_SUCCESS) { |
---|
| 34 | wlan_printf(PL_ERROR, "Failed to set up UART interrupt\n"); |
---|
| 35 | return WLAN_FAILURE; |
---|
| 36 | } |
---|
| 37 | wlan_platform_interrupt_enable(PLATFORM_INT_ID_UART); |
---|
| 38 | XUartLite_SetRecvHandler(&UartLite, _w3_uart_rx_handler, &UartLite); |
---|
| 39 | XUartLite_EnableInterrupt(&UartLite); |
---|
| 40 | return WLAN_SUCCESS; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | void _w3_uart_rx_handler(void *CallBackRef, unsigned int EventData){ |
---|
| 44 | #ifdef _ISR_PERF_MON_EN_ |
---|
| 45 | wlan_mac_set_dbg_hdr_out(ISR_PERF_MON_GPIO_MASK); |
---|
| 46 | #endif |
---|
| 47 | XUartLite_Recv(&UartLite, uart_rx_buffer, UART_BUFFER_SIZE); |
---|
| 48 | wlan_mac_high_uart_rx_callback(uart_rx_buffer[0]); |
---|
| 49 | #ifdef _ISR_PERF_MON_EN_ |
---|
| 50 | wlan_mac_clear_dbg_hdr_out(ISR_PERF_MON_GPIO_MASK); |
---|
| 51 | #endif |
---|
| 52 | } |
---|