align back to mainline (and put in missing Serial5) - not sure if USB serial LEDs were causing hangups on 1200baud bumps? :/
This commit is contained in:
parent
331b74812b
commit
b34deb4e81
6 changed files with 20 additions and 56 deletions
|
|
@ -23,8 +23,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
uint8_t USB_TXLEDticks = 0, USB_RXLEDticks = 0;
|
||||
|
||||
#ifdef CDC_ENABLED
|
||||
|
||||
#define CDC_SERIAL_BUFFER_SIZE 256
|
||||
|
|
@ -94,12 +92,6 @@ bool CDC_Setup(USBSetup& setup)
|
|||
uint8_t requestType = setup.bmRequestType;
|
||||
uint8_t r = setup.bRequest;
|
||||
|
||||
digitalWrite(PIN_LED_RXL, HIGH);
|
||||
digitalWrite(PIN_LED_TXL, HIGH);
|
||||
pinMode(PIN_LED_RXL, OUTPUT);
|
||||
pinMode(PIN_LED_TXL, OUTPUT);
|
||||
USB_TXLEDticks = USB_RXLEDticks = 0;
|
||||
|
||||
if (requestType == REQUEST_DEVICETOHOST_CLASS_INTERFACE)
|
||||
{
|
||||
if (r == CDC_GET_LINE_CODING)
|
||||
|
|
@ -186,9 +178,6 @@ int Serial_::read(void)
|
|||
{
|
||||
ring_buffer *buffer = &cdc_rx_buffer;
|
||||
|
||||
digitalWrite(PIN_LED_RXL, LOW);
|
||||
USB_RXLEDticks = 10; // how many ms to keep LED on
|
||||
|
||||
// if the head isn't ahead of the tail, we don't have any characters
|
||||
if (buffer->head == buffer->tail && !buffer->full)
|
||||
{
|
||||
|
|
@ -225,9 +214,6 @@ size_t Serial_::write(const uint8_t *buffer, size_t size)
|
|||
bytes sent before the user opens the connection or after
|
||||
the connection is closed are lost - just like with a UART. */
|
||||
|
||||
digitalWrite(PIN_LED_TXL, LOW);
|
||||
USB_TXLEDticks = 10; // how many ms to keep LED on
|
||||
|
||||
// TODO - ZE - check behavior on different OSes and test what happens if an
|
||||
// open connection isn't broken cleanly (cable is yanked out, host dies
|
||||
// or locks up, or host virtual serial port hangs)
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@
|
|||
#include "delay.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
extern uint8_t USB_TXLEDticks, USB_RXLEDticks;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -86,21 +83,6 @@ void SysTick_DefaultHandler(void)
|
|||
// Increment tick count each ms
|
||||
_ulTickCount++;
|
||||
tickReset();
|
||||
|
||||
// turn off CDC LEDs if time
|
||||
if (USB_RXLEDticks) {
|
||||
USB_RXLEDticks--;
|
||||
if (USB_RXLEDticks == 0) {
|
||||
digitalWrite(PIN_LED_RXL, HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
if (USB_TXLEDticks) {
|
||||
USB_TXLEDticks--;
|
||||
if (USB_TXLEDticks == 0) {
|
||||
digitalWrite(PIN_LED_TXL, HIGH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ uint32_t USBHost::SetPipeAddress(uint32_t addr, uint32_t ep, EpInfo **ppep, uint
|
|||
/* 01-0f = non-zero HRSLT */
|
||||
uint32_t USBHost::ctrlReq(uint32_t addr, uint32_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
|
||||
uint16_t wInd, uint16_t total, uint32_t nbytes, uint8_t* dataptr, USBReadParser *p) {
|
||||
|
||||
|
||||
uint32_t direction = 0; // Request direction, IN or OUT
|
||||
uint32_t rcode;
|
||||
SETUP_PKT setup_pkt;
|
||||
|
|
@ -194,14 +194,14 @@ uint32_t USBHost::ctrlReq(uint32_t addr, uint32_t ep, uint8_t bmReqType, uint8_t
|
|||
((USBReadParser*)p)->Parse(read, dataptr, total - left);
|
||||
}
|
||||
else // OUT transfer
|
||||
{
|
||||
{
|
||||
pep->bmSndToggle = 1; //bmSNDTOG1;
|
||||
rcode = OutTransfer(pep, nak_limit, nbytes, dataptr);
|
||||
}
|
||||
if(rcode) //return error
|
||||
return (rcode);
|
||||
}
|
||||
|
||||
|
||||
// Status stage
|
||||
UHD_Pipe_CountZero(pep->epAddr);
|
||||
USB->HOST.HostPipe[pep->epAddr].PSTATUSSET.reg = USB_HOST_PSTATUSSET_DTGL;
|
||||
|
|
@ -263,16 +263,16 @@ uint32_t USBHost::InTransfer(EpInfo *pep, uint32_t nak_limit, uint8_t *nbytesptr
|
|||
}
|
||||
if(rcode) {
|
||||
uhd_freeze_pipe(pep->epAddr);
|
||||
//printf(">>>>>>>> Problem! dispatchPkt %2.2x\r\n", rcode);
|
||||
//printf(">>>>>>>> Problem! dispatchPkt %2.2x\r\n", rcode);
|
||||
return(rcode);// break; //should be 0, indicating ACK. Else return error code.
|
||||
}
|
||||
/* check for RCVDAVIRQ and generate error if not present */
|
||||
/* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */
|
||||
|
||||
|
||||
pktsize = uhd_byte_count(pep->epAddr); // Number of received bytes
|
||||
|
||||
|
||||
USB->HOST.HostPipe[pep->epAddr].PSTATUSCLR.reg = USB_HOST_PSTATUSCLR_BK0RDY;
|
||||
|
||||
|
||||
//printf("Got %i bytes \r\n", pktsize);
|
||||
// This would be OK, but...
|
||||
//assert(pktsize <= nbytes);
|
||||
|
|
@ -297,7 +297,7 @@ uint32_t USBHost::InTransfer(EpInfo *pep, uint32_t nak_limit, uint8_t *nbytesptr
|
|||
/* 1. The device sent a short packet (L.T. maxPacketSize) */
|
||||
/* 2. 'nbytes' have been transferred. */
|
||||
if((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) // have we transferred 'nbytes' bytes?
|
||||
{
|
||||
{
|
||||
// Save toggle value
|
||||
pep->bmRcvToggle = USB_HOST_DTGL(pep->epAddr);
|
||||
//printf("\r\n");
|
||||
|
|
@ -504,7 +504,7 @@ void USBHost::Task(void) //USB state machine
|
|||
TRACE_USBHOST(printf(" + USB_DETACHED_SUBSTATE_INITIALIZE\r\n");)
|
||||
|
||||
// Init USB stack and driver
|
||||
Init();
|
||||
UHD_Init();
|
||||
|
||||
// Free all USB resources
|
||||
for (uint32_t i = 0; i < USB_NUMDEVICES; ++i)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ e-mail : support@circuitsathome.com
|
|||
// None of these should ever be included by a driver, or a user's sketch.
|
||||
|
||||
#include "variant.h"
|
||||
#define USB_HOST_SERIAL Serial1
|
||||
#define USB_HOST_SERIAL SERIAL_PORT_MONITOR
|
||||
#include "Print.h"
|
||||
#include "printhex.h"
|
||||
#include "message.h"
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ const PinDescription g_APinDescription[]=
|
|||
{ PORTA, 21, PIO_TIMER_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER_ALT), No_ADC_Channel, PWM0_CH7, TCC0_CH7, EXTERNAL_INT_5 }, // TCC0/WO[7]
|
||||
|
||||
// Digital High
|
||||
{ PORTA, 6, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER|PIN_ATTR_ANALOG), ADC_Channel6, PWM1_CH0, TCC1_CH0, EXTERNAL_INT_6 }, // TCC1/WO[0]
|
||||
{ PORTA, 7, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER|PIN_ATTR_ANALOG), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, // TCC1/WO[1]
|
||||
{ PORTA, 6, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM1_CH0, TCC1_CH0, EXTERNAL_INT_6 }, // TCC1/WO[0]
|
||||
{ PORTA, 7, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, // TCC1/WO[1]
|
||||
{ PORTA, 18, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM3_CH0, TC3_CH0, EXTERNAL_INT_2 }, // TC3/WO[0]
|
||||
{ PORTA, 16, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM2_CH0, TCC2_CH0, EXTERNAL_INT_0 }, // TCC2/WO[0]
|
||||
{ PORTA, 19, PIO_TIMER_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER_ALT), No_ADC_Channel, PWM0_CH3, TCC0_CH3, EXTERNAL_INT_3 }, // TCC0/WO[3]
|
||||
|
|
@ -208,18 +208,14 @@ SERCOM sercom4( SERCOM4 ) ;
|
|||
SERCOM sercom5( SERCOM5 ) ;
|
||||
|
||||
Uart Serial1( &sercom0, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX ) ;
|
||||
Uart Serial5( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;
|
||||
void SERCOM0_Handler()
|
||||
{
|
||||
Serial1.IrqHandler();
|
||||
}
|
||||
|
||||
|
||||
// Serial5 not available on Feather so ditch it
|
||||
|
||||
//Uart Serial5( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;
|
||||
/*
|
||||
void SERCOM5_Handler()
|
||||
{
|
||||
Serial5.IrqHandler();
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -98,12 +98,12 @@ extern "C"
|
|||
#define PIN_A7 (9ul)
|
||||
#define PIN_DAC0 (14ul)
|
||||
|
||||
static const uint8_t A0 = PIN_A0 ;
|
||||
static const uint8_t A1 = PIN_A1 ;
|
||||
static const uint8_t A2 = PIN_A2 ;
|
||||
static const uint8_t A3 = PIN_A3 ;
|
||||
static const uint8_t A4 = PIN_A4 ;
|
||||
static const uint8_t A5 = PIN_A5 ;
|
||||
static const uint8_t A0 = PIN_A0;
|
||||
static const uint8_t A1 = PIN_A1;
|
||||
static const uint8_t A2 = PIN_A2;
|
||||
static const uint8_t A3 = PIN_A3;
|
||||
static const uint8_t A4 = PIN_A4;
|
||||
static const uint8_t A5 = PIN_A5;
|
||||
static const uint8_t A6 = PIN_A6 ;
|
||||
static const uint8_t A7 = PIN_A7 ;
|
||||
static const uint8_t DAC0 = PIN_DAC0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue