m5stack / M5-Max3421E-USBShield

USB driver module, integrated MAX3421E is a dual-role USB controller, which can be programmed either as a USB peripheral or host capability to any system with an SPI interface
MIT License
2 stars 0 forks source link

DIP Switch #1

Open jaylfc opened 2 months ago

jaylfc commented 2 months ago

Hi, could you let us know what DIP switch config we should use for CoreS3, the documentation isn't so clear. Thanks in advance :)

K7MDL2 commented 3 weeks ago

Here is my modified usb_helper which automatically chooses the right values for the M5Stack Core, Core2, and Core3SE. You can see the pin numbers in each line, then look at the chart on the USB shield to choose the right DIP switch to match.

/*********************************************************************
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

MIT license, check LICENSE for more information
Copyright (c) 2019 Ha Thach for Adafruit Industries
All text above, and the splash screen below must be included in
any redistribution
*********************************************************************/

#ifndef USBH_HELPER_H
#define USBH_HELPER_H

 #include <M5_Max3421E_Usb.h>

 #if defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
   // USB Host using MAX3421E: SPI, CS, INT
   #include "SPI.h"

   // Default CS and INT are pin 5, 35, these are with G34 INT switch set on USB host board
   #ifdef CONFIG_IDF_TARGET_ESP32S3
       M5_USBH_Host USBHost(&SPI, 36, 37, 35, 1, 10);  // Core3   default INT switch G35 position
     //M5_USBH_Host USBHost(&SPI, 36, 37, 35, 1, 14);  // Core3 Alt INT  G34 position
   #elif defined ( ARDUINO_M5STACK_CORE2 ) || defined ( ARDUINO_M5STACK_Core2 )  // maybe library confusing CS pins with display in places.
       M5_USBH_Host USBHost(&SPI, 18, 23, 38, 33, 35);  // Core2 default, INT G35 position  SD card uses INT=4, display INT=5 TOUCh=39 
     //M5_USBH_Host USBHost(&SPI, 18, 23, 38, 33, 34);  // Core alt , INT G34 position
   #else
     //default pins
       M5_USBH_Host USBHost(&SPI, 18, 23, 19, 5, 35);  // Core basic default, INT G35 position
     //M5_USBH_Host USBHost(&SPI, 18, 23, 19, 5, 34);  // Core basic  match to your DIP USB module switches  34 is  used for Mic data
   #endif
 #endif  // CFG_TUH_MAX3421
#endif  // USBH_HELPER_H