mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Used fixed width integer types, so it is not architecture dependent
This commit is contained in:
parent
42948831ce
commit
5ba28d186f
10 changed files with 40 additions and 40 deletions
2
Usb.cpp
2
Usb.cpp
|
@ -426,7 +426,7 @@ void USB::Task(void) //USB state machine
|
|||
{
|
||||
uint8_t rcode;
|
||||
uint8_t tmpdata;
|
||||
static unsigned long delay = 0;
|
||||
static uint32_t delay = 0;
|
||||
//USB_DEVICE_DESCRIPTOR buf;
|
||||
bool lowspeed = false;
|
||||
|
||||
|
|
|
@ -290,8 +290,8 @@ uint8_t FTDI::SetBaudRate(uint32_t baud) {
|
|||
if(divisor3 != 0) baud_value |= 0x8000; // 0.25
|
||||
if(baud_value == 1) baud_value = 0; /* special case for maximum baud rate */
|
||||
} else {
|
||||
static const unsigned char divfrac [8] = {0, 3, 2, 0, 1, 1, 2, 3};
|
||||
static const unsigned char divindex[8] = {0, 0, 0, 1, 0, 1, 1, 1};
|
||||
static const uint8_t divfrac [8] = {0, 3, 2, 0, 1, 1, 2, 3};
|
||||
static const uint8_t divindex[8] = {0, 0, 0, 1, 0, 1, 1, 1};
|
||||
|
||||
baud_value = divisor3 >> 3;
|
||||
baud_value |= divfrac [divisor3 & 0x7] << 14;
|
||||
|
|
|
@ -24,7 +24,7 @@ USB Usb;
|
|||
USBH_MIDI Midi(&Usb);
|
||||
|
||||
void MIDI_poll();
|
||||
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime);
|
||||
void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime);
|
||||
|
||||
boolean bFirst;
|
||||
uint16_t pid, vid;
|
||||
|
@ -77,9 +77,9 @@ void MIDI_poll()
|
|||
}
|
||||
|
||||
// Delay time (max 16383 us)
|
||||
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
|
||||
void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime)
|
||||
{
|
||||
unsigned long t3;
|
||||
uint32_t t3;
|
||||
|
||||
if ( t1 > t2 ) {
|
||||
t3 = (0xFFFFFFFF - t1 + t2);
|
||||
|
|
|
@ -35,7 +35,7 @@ USB Usb;
|
|||
USBH_MIDI Midi(&Usb);
|
||||
|
||||
void MIDI_poll();
|
||||
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime);
|
||||
void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime);
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
@ -73,9 +73,9 @@ void MIDI_poll()
|
|||
}
|
||||
|
||||
// Delay time (max 16383 us)
|
||||
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
|
||||
void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime)
|
||||
{
|
||||
unsigned long t3;
|
||||
uint32_t t3;
|
||||
|
||||
if ( t1 > t2 ) {
|
||||
t3 = (0xFFFFFFFF - t1 + t2);
|
||||
|
|
|
@ -37,7 +37,7 @@ USBH_MIDI Midi1(&Usb);
|
|||
USBH_MIDI Midi2(&Usb);
|
||||
|
||||
void MIDI_poll();
|
||||
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime);
|
||||
void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime);
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
@ -81,9 +81,9 @@ void MIDI_poll()
|
|||
}
|
||||
|
||||
// Delay time (max 16383 us)
|
||||
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
|
||||
void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime)
|
||||
{
|
||||
unsigned long t3;
|
||||
uint32_t t3;
|
||||
|
||||
if ( t1 > t2 ) {
|
||||
t3 = (0xFFFFFFFF - t1 + t2);
|
||||
|
|
|
@ -43,7 +43,7 @@ USB Usb;
|
|||
USBH_MIDI Midi(&Usb);
|
||||
|
||||
void MIDI_poll();
|
||||
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime);
|
||||
void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime);
|
||||
|
||||
//If you want handle System Exclusive message, enable this #define otherwise comment out it.
|
||||
#define USBH_MIDI_SYSEX_ENABLE
|
||||
|
@ -149,9 +149,9 @@ void MIDI_poll()
|
|||
}
|
||||
|
||||
// Delay time (max 16383 us)
|
||||
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
|
||||
void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime)
|
||||
{
|
||||
unsigned long t3;
|
||||
uint32_t t3;
|
||||
|
||||
if ( t1 > t2 ) {
|
||||
t3 = (0xFFFFFFFF - t1 + t2);
|
||||
|
|
|
@ -60,14 +60,14 @@ void setup()
|
|||
delay( 200 );
|
||||
}
|
||||
|
||||
byte getdevdescr( byte addr, byte &num_conf );
|
||||
uint8_t getdevdescr( uint8_t addr, uint8_t &num_conf );
|
||||
|
||||
void PrintDescriptors(uint8_t addr)
|
||||
{
|
||||
uint8_t rcode = 0;
|
||||
byte num_conf = 0;
|
||||
uint8_t num_conf = 0;
|
||||
|
||||
rcode = getdevdescr( (byte)addr, num_conf );
|
||||
rcode = getdevdescr( (uint8_t)addr, num_conf );
|
||||
if ( rcode )
|
||||
{
|
||||
printProgStr(Gen_Error_str);
|
||||
|
@ -108,10 +108,10 @@ void loop()
|
|||
}
|
||||
}
|
||||
|
||||
byte getdevdescr( byte addr, byte &num_conf )
|
||||
uint8_t getdevdescr( uint8_t addr, uint8_t &num_conf )
|
||||
{
|
||||
USB_DEVICE_DESCRIPTOR buf;
|
||||
byte rcode;
|
||||
uint8_t rcode;
|
||||
rcode = Usb.getDevDescr( addr, 0, 0x12, ( uint8_t *)&buf );
|
||||
if ( rcode ) {
|
||||
return ( rcode );
|
||||
|
@ -195,14 +195,14 @@ void printhubdescr(uint8_t *descrptr, uint8_t addr)
|
|||
// PrintHubPortStatus(&Usb, addr, i, 1);
|
||||
}
|
||||
|
||||
byte getconfdescr( byte addr, byte conf )
|
||||
uint8_t getconfdescr( uint8_t addr, uint8_t conf )
|
||||
{
|
||||
uint8_t buf[ BUFSIZE ];
|
||||
uint8_t* buf_ptr = buf;
|
||||
byte rcode;
|
||||
byte descr_length;
|
||||
byte descr_type;
|
||||
unsigned int total_length;
|
||||
uint8_t rcode;
|
||||
uint8_t descr_length;
|
||||
uint8_t descr_type;
|
||||
uint16_t total_length;
|
||||
rcode = Usb.getConfDescr( addr, 0, 4, conf, buf ); //get total length
|
||||
LOBYTE( total_length ) = buf[ 2 ];
|
||||
HIBYTE( total_length ) = buf[ 3 ];
|
||||
|
@ -316,8 +316,8 @@ void printepdescr( uint8_t* descr_ptr )
|
|||
/*function to print unknown descriptor */
|
||||
void printunkdescr( uint8_t* descr_ptr )
|
||||
{
|
||||
byte length = *descr_ptr;
|
||||
byte i;
|
||||
uint8_t length = *descr_ptr;
|
||||
uint8_t i;
|
||||
printProgStr(Unk_Header_str);
|
||||
printProgStr(Unk_Length_str);
|
||||
print_hex( *descr_ptr, 8 );
|
||||
|
|
|
@ -130,7 +130,7 @@ void printFloat(double number, int digits)
|
|||
number += rounding;
|
||||
|
||||
// Extract the integer part of the number and print it
|
||||
unsigned long int_part = (unsigned long)number;
|
||||
uint32_t int_part = (uint32_t)number;
|
||||
double remainder = number - (double)int_part;
|
||||
Serial.print(int_part);
|
||||
|
||||
|
@ -150,12 +150,12 @@ void printFloat(double number, int digits)
|
|||
|
||||
void gpsdump(TinyGPS &gps)
|
||||
{
|
||||
long lat, lon;
|
||||
int32_t lat, lon;
|
||||
float flat, flon;
|
||||
unsigned long age, date, time, chars;
|
||||
uint32_t age, date, time, chars;
|
||||
int year;
|
||||
byte month, day, hour, minute, second, hundredths;
|
||||
unsigned short sentences, failed;
|
||||
uint16_t sentences, failed;
|
||||
|
||||
gps.get_position(&lat, &lon, &age);
|
||||
Serial.print("Lat/Long(10^-5 deg): "); Serial.print(lat); Serial.print(", "); Serial.print(lon);
|
||||
|
|
|
@ -243,9 +243,9 @@ void USBH_MIDI::parseConfigDescr( uint8_t addr, uint8_t conf )
|
|||
uint8_t rcode;
|
||||
uint8_t descr_length;
|
||||
uint8_t descr_type;
|
||||
unsigned int total_length;
|
||||
uint16_t total_length;
|
||||
USB_ENDPOINT_DESCRIPTOR *epDesc;
|
||||
boolean isMidi = false;
|
||||
bool isMidi = false;
|
||||
|
||||
// get configuration descriptor (get descriptor size only)
|
||||
rcode = pUsb->getConfDescr( addr, 0, 4, conf, buf );
|
||||
|
@ -486,9 +486,9 @@ uint8_t USBH_MIDI::lookupMsgSize(uint8_t midiMsg)
|
|||
}
|
||||
|
||||
/* SysEx data size counter */
|
||||
unsigned int USBH_MIDI::countSysExDataSize(uint8_t *dataptr)
|
||||
uint16_t USBH_MIDI::countSysExDataSize(uint8_t *dataptr)
|
||||
{
|
||||
unsigned int c = 1;
|
||||
uint16_t c = 1;
|
||||
|
||||
if( *dataptr != 0xf0 ){ //not SysEx
|
||||
return 0;
|
||||
|
@ -510,12 +510,12 @@ unsigned int USBH_MIDI::countSysExDataSize(uint8_t *dataptr)
|
|||
}
|
||||
|
||||
/* Send SysEx message to MIDI device */
|
||||
uint8_t USBH_MIDI::SendSysEx(uint8_t *dataptr, unsigned int datasize, uint8_t nCable)
|
||||
uint8_t USBH_MIDI::SendSysEx(uint8_t *dataptr, uint16_t datasize, uint8_t nCable)
|
||||
{
|
||||
uint8_t buf[64];
|
||||
uint8_t rc;
|
||||
unsigned int n = datasize;
|
||||
unsigned int pktSize = (n*10/3+7)/10*4; //Calculate total USB MIDI packet size
|
||||
uint16_t n = datasize;
|
||||
uint16_t pktSize = (n*10/3+7)/10*4; //Calculate total USB MIDI packet size
|
||||
uint8_t wptr = 0;
|
||||
uint8_t maxpkt = epInfo[epDataInIndex].maxPktSize;
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ protected:
|
|||
uint8_t readPtr;
|
||||
|
||||
void parseConfigDescr(uint8_t addr, uint8_t conf);
|
||||
unsigned int countSysExDataSize(uint8_t *dataptr);
|
||||
uint16_t countSysExDataSize(uint8_t *dataptr);
|
||||
#ifdef DEBUG_USB_HOST
|
||||
void PrintEndpointDescriptor( const USB_ENDPOINT_DESCRIPTOR* ep_ptr );
|
||||
#endif
|
||||
|
@ -70,7 +70,7 @@ public:
|
|||
uint8_t RecvData(uint8_t *outBuf);
|
||||
uint8_t SendData(uint8_t *dataptr, uint8_t nCable=0);
|
||||
uint8_t lookupMsgSize(uint8_t midiMsg);
|
||||
uint8_t SendSysEx(uint8_t *dataptr, unsigned int datasize, uint8_t nCable=0);
|
||||
uint8_t SendSysEx(uint8_t *dataptr, uint16_t datasize, uint8_t nCable=0);
|
||||
uint8_t SendRawData(uint16_t bytes_send, uint8_t *dataptr);
|
||||
// backward compatibility functions
|
||||
inline uint8_t RcvData(uint16_t *bytes_rcvd, uint8_t *dataptr){ return RecvData(bytes_rcvd, dataptr); };
|
||||
|
|
Loading…
Reference in a new issue