1 /* 2 * Copyright 2022 NXP 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef FSL_ADAPTER_SDU_H 9 #define FSL_ADAPTER_SDU_H 10 11 #include <stdint.h> 12 #include "fsl_sdioslv_sdu.h" 13 14 /*! @file */ 15 16 /******************************************************************************* 17 * Definitions 18 ******************************************************************************/ 19 #define FSL_FEATURE_SOC_SDIO_COUNT (3) 20 21 #define SDU_CMD_RECEIVED (1U << 0U) 22 #define SDU_DATA_RECEIVED (1U << 1U) 23 24 typedef enum _sdu_for_read_type 25 { 26 SDU_TYPE_FOR_READ_CMD = 0, 27 SDU_TYPE_FOR_READ_EVENT= 1, 28 SDU_TYPE_FOR_READ_DATA = 2, 29 SDU_TYPE_FOR_READ_MAX, 30 } sdu_for_read_type_t; 31 32 typedef enum _sdu_for_write_type 33 { 34 SDU_TYPE_FOR_WRITE_CMD = 0, 35 SDU_TYPE_FOR_WRITE_DATA = 1, 36 SDU_TYPE_FOR_WRITE_MAX, 37 } sdu_for_write_type_t; 38 39 typedef struct _sdio_header 40 { 41 uint16_t len; 42 uint16_t type; 43 } sdio_header_t; 44 45 /******************************************************************************* 46 * APIs 47 ******************************************************************************/ 48 49 50 #if defined(__cplusplus) 51 extern "C" { 52 #endif 53 54 /*! @} */ 55 56 status_t SDU_Init(void); 57 void SDU_Deinit(void); 58 59 typedef void (*sdu_callback_t)(void *tlv, size_t tlv_sz); 60 status_t SDU_InstallCallback(sdu_for_write_type_t type, sdu_callback_t callback); 61 62 /*! 63 * @brief SDU send cmd/event/data. 64 * 65 * @param sdu_for_read_type_t type for cmd/event/data. 66 * @param data_addr Data Address. 67 * @param data_len Data Length. 68 * @retval #kStatus_Success buffer is added to data slot with problem. 69 * @retval #kStatus_InvalidArgument Invalid argument. 70 * @retval #kStatus_NoData No free buffer to use. 71 * @retval #kStatus_Fail Fail to send data. 72 */ 73 status_t SDU_Send(sdu_for_read_type_t type, uint8_t *data_addr, uint16_t data_len); 74 75 status_t SDU_RecvCmd(void); 76 status_t SDU_RecvData(void); 77 78 void SDU_DriverIRQHandler(void); 79 80 #if defined(__cplusplus) 81 } 82 #endif 83 84 /*! @} */ 85 86 #endif 87