添加 USB 主机、BLE 和 Socket 数据端口驱动程序:
- 支持大容量存储类(MSC)的 USB 主机驱动程序 - BLE SPP(串行端口配置文件)客户端和服务器实现 - Socket(UDP/TCP)数据端口驱动程序 - 相关的 shell 接口用于配置和测试
This commit is contained in:
39
app/drivers/data_port/usb-host/msc/private_include/diskio_usb.h
Executable file
39
app/drivers/data_port/usb-host/msc/private_include/diskio_usb.h
Executable file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Mass storage disk initialization structure
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t block_size; /**< Block size */
|
||||
uint32_t block_count; /**< Block count */
|
||||
} usb_disk_t;
|
||||
|
||||
/**
|
||||
* @brief Register mass storage disk to fat file system
|
||||
*
|
||||
* @param[in] pdrv Number of free drive obtained from ff_diskio_get_drive() function
|
||||
* @param[in] disk usb_disk_t structure
|
||||
*/
|
||||
void ff_diskio_register_msc(uint8_t pdrv, usb_disk_t *disk);
|
||||
|
||||
/**
|
||||
* @brief Obtains number of drive assigned to usb disk upon calling ff_diskio_register_msc()
|
||||
*
|
||||
* @param[in] disk usb_disk_t structure
|
||||
* @return Drive number
|
||||
*/
|
||||
uint8_t ff_diskio_get_pdrv_disk(const usb_disk_t *disk);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif //__cplusplus
|
||||
61
app/drivers/data_port/usb-host/msc/private_include/msc_common.h
Executable file
61
app/drivers/data_port/usb-host/msc/private_include/msc_common.h
Executable file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/queue.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_check.h"
|
||||
#include "diskio_usb.h"
|
||||
#include "usb/usb_host.h"
|
||||
#include "usb/usb_types_stack.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
MSC_EP_OUT,
|
||||
MSC_EP_IN
|
||||
} msc_endpoint_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t bulk_in_mps;
|
||||
uint8_t bulk_in_ep;
|
||||
uint8_t bulk_out_ep;
|
||||
uint8_t iface_num;
|
||||
} msc_config_t;
|
||||
|
||||
typedef struct msc_host_device {
|
||||
STAILQ_ENTRY(msc_host_device) tailq_entry;
|
||||
usb_transfer_status_t transfer_status;
|
||||
SemaphoreHandle_t transfer_done;
|
||||
usb_device_handle_t handle;
|
||||
usb_transfer_t *xfer;
|
||||
msc_config_t config;
|
||||
usb_disk_t disk;
|
||||
} msc_device_t;
|
||||
|
||||
esp_err_t msc_bulk_transfer(msc_device_t *device_handle, uint8_t *data, size_t size, msc_endpoint_t ep);
|
||||
|
||||
esp_err_t msc_control_transfer(msc_device_t *device_handle, usb_transfer_t *xfer, size_t len);
|
||||
|
||||
#define MSC_GOTO_ON_ERROR(exp) ESP_GOTO_ON_ERROR(exp, fail, TAG, "")
|
||||
|
||||
#define MSC_GOTO_ON_FALSE(exp, err) ESP_GOTO_ON_FALSE( (exp), err, fail, TAG, "" )
|
||||
|
||||
#define MSC_RETURN_ON_ERROR(exp) ESP_RETURN_ON_ERROR((exp), TAG, "")
|
||||
|
||||
#define MSC_RETURN_ON_FALSE(exp, err) ESP_RETURN_ON_FALSE( (exp), (err), TAG, "")
|
||||
|
||||
#define MSC_RETURN_ON_INVALID_ARG(exp) ESP_RETURN_ON_FALSE((exp) != NULL, ESP_ERR_INVALID_ARG, TAG, "")
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
56
app/drivers/data_port/usb-host/msc/private_include/msc_scsi_bot.h
Executable file
56
app/drivers/data_port/usb-host/msc/private_include/msc_scsi_bot.h
Executable file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "msc_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint8_t key;
|
||||
uint8_t code;
|
||||
uint8_t code_q;
|
||||
} scsi_sense_data_t;
|
||||
|
||||
esp_err_t scsi_cmd_read10(msc_device_t *device,
|
||||
uint8_t *data,
|
||||
uint32_t sector_address,
|
||||
uint32_t num_sectors,
|
||||
uint32_t sector_size);
|
||||
|
||||
esp_err_t scsi_cmd_write10(msc_device_t *device,
|
||||
const uint8_t *data,
|
||||
uint32_t sector_address,
|
||||
uint32_t num_sectors,
|
||||
uint32_t sector_size);
|
||||
|
||||
esp_err_t scsi_cmd_read_capacity(msc_device_t *device,
|
||||
uint32_t *block_size,
|
||||
uint32_t *block_count);
|
||||
|
||||
esp_err_t scsi_cmd_sense(msc_device_t *device, scsi_sense_data_t *sense);
|
||||
|
||||
esp_err_t scsi_cmd_unit_ready(msc_device_t *device);
|
||||
|
||||
esp_err_t scsi_cmd_inquiry(msc_device_t *device);
|
||||
|
||||
esp_err_t scsi_cmd_prevent_removal(msc_device_t *device, bool prevent);
|
||||
|
||||
esp_err_t scsi_cmd_mode_sense(msc_device_t *device);
|
||||
|
||||
esp_err_t msc_mass_reset(msc_device_t *device);
|
||||
|
||||
esp_err_t msc_get_max_lun(msc_device_t *device, uint8_t *lun);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user