Prusa MINI Firmware overview
usbhost.h
Go to the documentation of this file.
1 /**************
2  * usb_host.h *
3  **************/
4 
5 /****************************************************************************
6  * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
7  * *
8  * This program is free software: you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation, either version 3 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * To view a copy of the GNU General Public License, go to the following *
19  * location: <http://www.gnu.org/licenses/>. *
20  ****************************************************************************/
21 
22 #pragma once
23 
24 /* This the following comes from "lib/usbhost.h", but has been rewritten
25  * to use the SPI functions from Marlin's HAL */
26 
27 class MAX3421e {
28  private:
29  static uint8_t vbusState;
30  void cs();
31  void ncs();
32 
33  uint8_t GpxHandler();
34  uint8_t IntHandler();
35 
36  public:
37  bool start();
38 
39  void regWr(uint8_t reg, uint8_t data);
40  uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
41  void gpioWr(uint8_t data);
42  uint8_t regRd(uint8_t reg);
43  uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
44  uint8_t gpioRd();
45  bool reset();
46 
47  uint8_t getVbusState() {return vbusState;};
48 
49  void busprobe();
50 
51  uint8_t Task();
52 };
53 
54 #define USE_MARLIN_MAX3421E
55 
56 #if defined(__SAM3X8E__) && !defined(ARDUINO_SAM_DUE)
57  #define ARDUINO_SAM_DUE // Spoof the USB library that this is a DUE
58 #endif
MAX3421e::Task
uint8_t Task()
usbhost.h
rCPUCTL
#define rCPUCTL
Definition: max3421e.h:68
bmHOST
#define bmHOST
Definition: max3421e.h:171
LSHOST
#define LSHOST
Definition: max3421e.h:39
MAX3421e::regRd
uint8_t regRd(uint8_t reg)
spiRec
uint8_t spiRec()
spiInit
void spiInit(uint8_t spiRate)
bmFRAMEIE
#define bmFRAMEIE
Definition: max3421e.h:165
MAX3421e::bytesWr
uint8_t * bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p)
bmSE0
#define bmSE0
Definition: max3421e.h:220
MODE_LS_HOST
#define MODE_LS_HOST
Definition: max3421e.h:242
MAX3421e::getVbusState
uint8_t getVbusState()
Definition: usbhost.h:60
rHCTL
#define rHCTL
Definition: max3421e.h:182
bmSEPIRQ
#define bmSEPIRQ
Definition: max3421e.h:175
bmSAMPLEBUS
#define bmSAMPLEBUS
Definition: max3421e.h:186
SE0
#define SE0
Definition: max3421e.h:36
data
uint8_t data[8]
Definition: masstorage.h:49
rIOPINS1
#define rIOPINS1
Definition: max3421e.h:89
i
uint8_t i
Definition: screen_test_graph.c:72
SPI_SPEED
#define SPI_SPEED
Definition: Conditionals_LCD.h:572
MAX3421e::gpioWr
void gpioWr(uint8_t data)
SET_OUTPUT
#define SET_OUTPUT(IO)
Definition: fastio.h:101
bmCONDETIRQ
#define bmCONDETIRQ
Definition: max3421e.h:152
MAX3421e::start
bool start()
rUSBCTL
#define rUSBCTL
Definition: max3421e.h:63
SET_INPUT_PULLUP
#define SET_INPUT_PULLUP(IO)
Definition: fastio.h:100
rHIEN
#define rHIEN
Definition: max3421e.h:156
MAX3421e::regWr
void regWr(uint8_t reg, uint8_t data)
GPX_VBDET
#define GPX_VBDET
Definition: max3421e.h:83
MAX3421e::busprobe
void busprobe()
rHIRQ
#define rHIRQ
Definition: max3421e.h:145
bmSE1
#define bmSE1
Definition: max3421e.h:221
SPI_FULL_SPEED
#define SPI_FULL_SPEED
Definition: HAL_SPI.h:49
bmFDUPSPI
#define bmFDUPSPI
Definition: max3421e.h:76
spiSend
void spiSend(uint8_t b)
rHRSL
#define rHRSL
Definition: max3421e.h:213
bmCHIPRES
#define bmCHIPRES
Definition: max3421e.h:65
FSHOST
#define FSHOST
Definition: max3421e.h:38
SE1
#define SE1
Definition: max3421e.h:37
bmOSCOKIRQ
#define bmOSCOKIRQ
Definition: max3421e.h:55
WRITE
#define WRITE(IO, V)
Definition: fastio.h:96
spiBegin
void spiBegin()
SERIAL_ECHOLNPAIR
#define SERIAL_ECHOLNPAIR(V...)
Definition: serial.h:144
uint8_t
const uint8_t[]
Definition: 404_html.c:3
MAX3421e
Definition: usbhost.h:25
bmCONDETIE
#define bmCONDETIE
Definition: max3421e.h:164
rREVISION
#define rREVISION
Definition: max3421e.h:87
delay
void delay(uint32_t ms)
Definition: wiring_time.c:42
rUSBIRQ
#define rUSBIRQ
Definition: max3421e.h:51
bmINTLEVEL
#define bmINTLEVEL
Definition: max3421e.h:77
rIOPINS2
#define rIOPINS2
Definition: max3421e.h:101
MODE_FS_HOST
#define MODE_FS_HOST
Definition: max3421e.h:241
Usb.h
bmLOWSPEED
#define bmLOWSPEED
Definition: max3421e.h:172
bmJSTATUS
#define bmJSTATUS
Definition: max3421e.h:219
bmDPPULLDN
#define bmDPPULLDN
Definition: max3421e.h:178
SERIAL_ECHOLNPGM
#define SERIAL_ECHOLNPGM(S)
Definition: serial.h:174
MAX3421e::gpioRd
uint8_t gpioRd()
bmDMPULLDN
#define bmDMPULLDN
Definition: max3421e.h:177
bmKSTATUS
#define bmKSTATUS
Definition: max3421e.h:218
READ
#define READ(IO)
Definition: fastio.h:95
MAX3421e::bytesRd
uint8_t * bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p)
rMODE
#define rMODE
Definition: max3421e.h:168
rPINCTL
#define rPINCTL
Definition: max3421e.h:74
MAX3421e::reset
bool reset()