mirror of
https://github.com/sakumisu/CherryUSB.git
synced 2025-05-09 00:21:44 +08:00
update(platform/nuttx): add more macros check for net and msc
Signed-off-by: sakumisu <1203593632@qq.com>
This commit is contained in:
parent
322595b910
commit
646e84bedc
@ -31,10 +31,6 @@
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/signal.h>
|
||||
|
||||
#if 1
|
||||
#error please modfiy all thread param (void *argument) with (int argc, char **argv), and argument = ((uintptr_t)strtoul(argv[1], NULL, 16));
|
||||
#endif
|
||||
|
||||
struct mq_adpt {
|
||||
struct file mq; /* Message queue handle */
|
||||
uint32_t msgsize; /* Message size */
|
||||
@ -56,7 +52,7 @@ usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size,
|
||||
argv[0] = arg1;
|
||||
argv[1] = NULL;
|
||||
|
||||
pid = kthread_create(name, prio, stack_size, (void *)entry,
|
||||
pid = kthread_create(name, CONFIG_SCHED_HPWORKPRIORITY - prio, stack_size, (void *)entry,
|
||||
argv);
|
||||
if (pid > 0) {
|
||||
return (usb_osal_thread_t)pid;
|
||||
|
@ -26,13 +26,18 @@
|
||||
#include "usbh_core.h"
|
||||
#include "usbh_msc.h"
|
||||
|
||||
#ifdef CONFIG_ARCH_CHIP_HPMICRO
|
||||
#include "hpm_misc.h"
|
||||
#define usbhmsc_phy2sysaddr(a) core_local_mem_to_sys_address(0, a)
|
||||
#else
|
||||
#define usbhmsc_phy2sysaddr(a) (a)
|
||||
#ifndef CONFIG_FS_FAT
|
||||
#error "CONFIG_FS_FAT must be enabled"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARCH_DCACHE
|
||||
#ifndef CONFIG_FAT_DMAMEMORY
|
||||
#error "USBH MSC requires CONFIG_FAT_DMAMEMORY"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define DEV_FORMAT "/dev/sd%c"
|
||||
|
||||
static int usbhost_open(FAR struct inode *inode);
|
||||
static int usbhost_close(FAR struct inode *inode);
|
||||
static ssize_t usbhost_read(FAR struct inode *inode, unsigned char *buffer,
|
||||
@ -86,11 +91,11 @@ static ssize_t usbhost_read(FAR struct inode *inode, unsigned char *buffer,
|
||||
msc_class = (struct usbh_msc *)inode->i_private;
|
||||
|
||||
if (msc_class->hport && msc_class->hport->connected) {
|
||||
ret = usbh_msc_scsi_read10(msc_class, startsector, (uint8_t *)usbhmsc_phy2sysaddr((uint32_t)buffer), nsectors);
|
||||
ret = usbh_msc_scsi_read10(msc_class, startsector, (uint8_t *)buffer, nsectors);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
} else {
|
||||
#ifdef CONFIG_USBHOST_MSC_DCACHE
|
||||
#ifdef CONFIG_ARCH_DCACHE
|
||||
up_invalidate_dcache((uintptr_t)buffer, (uintptr_t)(buffer + nsectors * msc_class->blocksize));
|
||||
#endif
|
||||
return nsectors;
|
||||
@ -111,10 +116,10 @@ static ssize_t usbhost_write(FAR struct inode *inode,
|
||||
msc_class = (struct usbh_msc *)inode->i_private;
|
||||
|
||||
if (msc_class->hport && msc_class->hport->connected) {
|
||||
#ifdef CONFIG_USBHOST_MSC_DCACHE
|
||||
#ifdef CONFIG_ARCH_DCACHE
|
||||
up_flush_dcache((uintptr_t)buffer, (uintptr_t)(buffer + nsectors * msc_class->blocksize));
|
||||
#endif
|
||||
ret = usbh_msc_scsi_write10(msc_class, startsector, (uint8_t *)usbhmsc_phy2sysaddr((uint32_t)buffer), nsectors);
|
||||
ret = usbh_msc_scsi_write10(msc_class, startsector, (uint8_t *)buffer, nsectors);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
} else {
|
||||
@ -168,8 +173,6 @@ static int usbhost_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define DEV_FORMAT "/dev/sd%c"
|
||||
|
||||
void usbh_msc_run(struct usbh_msc *msc_class)
|
||||
{
|
||||
char devname[32];
|
||||
|
@ -18,6 +18,26 @@
|
||||
|
||||
#include "usbh_core.h"
|
||||
|
||||
#if CONFIG_NET_ETH_PKTSIZE < 1514
|
||||
#error "CONFIG_NET_ETH_PKTSIZE must be at least 1514"
|
||||
#endif
|
||||
|
||||
#if CONFIG_IOB_BUFSIZE < 1514
|
||||
#error "CONFIG_IOB_BUFSIZE must be at least 1514"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NETDEV_LATEINIT
|
||||
#error "CONFIG_NETDEV_LATEINIT must be enabled"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NETUTILS_DHCPC
|
||||
#error "CONFIG_NETUTILS_DHCPC must be enabled"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NETINIT_DHCPC
|
||||
#error "CONFIG_NETINIT_DHCPC must be enabled"
|
||||
#endif
|
||||
|
||||
// #define CONFIG_USBHOST_PLATFORM_CDC_ECM
|
||||
#define CONFIG_USBHOST_PLATFORM_CDC_RNDIS
|
||||
// #define CONFIG_USBHOST_PLATFORM_CDC_NCM
|
||||
@ -35,7 +55,7 @@ void usbh_net_eth_output_common(struct net_driver_s *dev, uint8_t *buf)
|
||||
usb_memcpy(buf, dev->d_buf, dev->d_len);
|
||||
}
|
||||
|
||||
void usbh_net_eth_input_common(struct net_driver_s *dev, uint8_t *buf, size_t len, int (*eth_output)(uint32_t buflen))
|
||||
void usbh_net_eth_input_common(struct net_driver_s *dev, uint8_t *buf, size_t len, uint8_t* (*eth_input)(void), int (*eth_output)(uint32_t buflen))
|
||||
{
|
||||
FAR struct eth_hdr_s *hdr;
|
||||
|
||||
@ -61,7 +81,7 @@ void usbh_net_eth_input_common(struct net_driver_s *dev, uint8_t *buf, size_t le
|
||||
ipv4_input(dev);
|
||||
if (dev->d_len > 0) {
|
||||
/* And send the packet */
|
||||
usbh_net_eth_output_common(dev, usbh_rndis_get_eth_txbuf());
|
||||
usbh_net_eth_output_common(dev, eth_input());
|
||||
eth_output(dev->d_len);
|
||||
}
|
||||
} else
|
||||
@ -76,7 +96,7 @@ void usbh_net_eth_input_common(struct net_driver_s *dev, uint8_t *buf, size_t le
|
||||
|
||||
if (dev->d_len > 0) {
|
||||
/* And send the packet */
|
||||
usbh_net_eth_output_common(dev, usbh_rndis_get_eth_txbuf());
|
||||
usbh_net_eth_output_common(dev, eth_input());
|
||||
eth_output(dev->d_len);
|
||||
}
|
||||
} else
|
||||
@ -87,7 +107,7 @@ void usbh_net_eth_input_common(struct net_driver_s *dev, uint8_t *buf, size_t le
|
||||
|
||||
arp_input(dev);
|
||||
if (dev->d_len > 0) {
|
||||
usbh_net_eth_output_common(dev, usbh_rndis_get_eth_txbuf());
|
||||
usbh_net_eth_output_common(dev, eth_input());
|
||||
eth_output(dev->d_len);
|
||||
}
|
||||
} else
|
||||
@ -121,7 +141,7 @@ static int rndis_ifdown(struct net_driver_s *dev)
|
||||
|
||||
static int rndis_txpoll(struct net_driver_s *dev)
|
||||
{
|
||||
usbh_net_eth_output_common(&g_rndis_dev, usbh_rndis_get_eth_txbuf());
|
||||
usbh_net_eth_output_common(&g_rndis_dev.netdev, usbh_rndis_get_eth_txbuf());
|
||||
return usbh_rndis_eth_output(g_rndis_dev.netdev.d_len);
|
||||
}
|
||||
|
||||
@ -150,7 +170,7 @@ static int rndis_txavail(struct net_driver_s *dev)
|
||||
|
||||
void usbh_rndis_eth_input(uint8_t *buf, uint32_t buflen)
|
||||
{
|
||||
usbh_net_eth_input_common(&g_rndis_dev.netdev, buf, buflen, usbh_rndis_eth_output);
|
||||
usbh_net_eth_input_common(&g_rndis_dev.netdev, buf, buflen, usbh_rndis_get_eth_txbuf, usbh_rndis_eth_output);
|
||||
}
|
||||
|
||||
void usbh_rndis_run(struct usbh_rndis *rndis_class)
|
||||
@ -166,6 +186,8 @@ void usbh_rndis_run(struct usbh_rndis *rndis_class)
|
||||
g_rndis_dev.netdev.d_mac.ether.ether_addr_octet[j] = rndis_class->mac[j];
|
||||
}
|
||||
netdev_register(&g_rndis_dev.netdev, NET_LL_ETHERNET);
|
||||
|
||||
netinit_bringup();
|
||||
}
|
||||
|
||||
void usbh_rndis_stop(struct usbh_rndis *rndis_class)
|
||||
|
Loading…
x
Reference in New Issue
Block a user