1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-17 06:52:18 +01:00

Assigned Serial to UART and SerialUSB to USB-CDC-ACM

This commit is contained in:
Cristian Maglie 2012-09-28 16:18:22 +02:00
parent cfa77a2436
commit 2071c00ba0
9 changed files with 13 additions and 9 deletions

View File

@ -163,10 +163,10 @@ shiftOut KEYWORD2 ShiftOut
tone KEYWORD2 Tone tone KEYWORD2 Tone
Serial KEYWORD3 Serial Serial KEYWORD3 Serial
Serial1 KEYWORD3 Serial
Serial2 KEYWORD3 Serial Serial2 KEYWORD3 Serial
Serial3 KEYWORD3 Serial Serial3 KEYWORD3 Serial
Serial4 KEYWORD3 Serial Serial4 KEYWORD3 Serial
SerialUSB KEYWORD3 Serial
begin KEYWORD2 Serial_Begin begin KEYWORD2 Serial_Begin
end KEYWORD2 Serial_End end KEYWORD2 Serial_End
peek KEYWORD2 Serial_Peek peek KEYWORD2 Serial_Peek

View File

@ -34,7 +34,7 @@ class HardwareSerial : public Stream
virtual void flush(void) = 0; virtual void flush(void) = 0;
virtual size_t write(uint8_t) = 0; virtual size_t write(uint8_t) = 0;
using Print::write; // pull in write(str) and write(buf, size) from Print using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool(); virtual operator bool() = 0;
}; };
extern void serialEventRun(void) __attribute__((weak)); extern void serialEventRun(void) __attribute__((weak));

View File

@ -54,6 +54,8 @@ class UARTClass : public HardwareSerial
// virtual void write( const char *str ) ; // virtual void write( const char *str ) ;
// virtual void write( const uint8_t *buffer, size_t size ) ; // virtual void write( const uint8_t *buffer, size_t size ) ;
#endif #endif
operator bool() { return true; }; // UART always active
}; };
#endif // _UART_CLASS_ #endif // _UART_CLASS_

View File

@ -54,6 +54,8 @@ class USARTClass : public HardwareSerial
// virtual void write( const char *str ) ; // virtual void write( const char *str ) ;
// virtual void write( const uint8_t *buffer, size_t size ) ; // virtual void write( const uint8_t *buffer, size_t size ) ;
#endif #endif
operator bool() { return true; }; // USART always active
}; };
#endif // _USART_CLASS_ #endif // _USART_CLASS_

View File

@ -267,6 +267,6 @@ Serial_::operator bool()
return result; return result;
} }
Serial_ Serial; Serial_ SerialUSB;
#endif #endif

View File

@ -61,7 +61,7 @@ public:
using Print::write; // pull in write(str) from Print using Print::write; // pull in write(str) from Print
operator bool(); operator bool();
}; };
extern Serial_ Serial; extern Serial_ SerialUSB;
//================================================================================ //================================================================================
//================================================================================ //================================================================================

View File

@ -598,7 +598,7 @@ static void USB_ISR(void)
// Handle received bytes // Handle received bytes
while (USBD_Available(CDC_RX)) while (USBD_Available(CDC_RX))
Serial.accept(); SerialUSB.accept();
udd_ack_fifocon(CDC_RX); udd_ack_fifocon(CDC_RX);
} }

View File

@ -296,12 +296,12 @@ extern const PinDescription g_APinDescription[]=
*/ */
RingBuffer rx_buffer1 ; RingBuffer rx_buffer1 ;
UARTClass Serial1( UART, UART_IRQn, ID_UART, &rx_buffer1 ) ; UARTClass Serial( UART, UART_IRQn, ID_UART, &rx_buffer1 ) ;
// IT handlers // IT handlers
void UART_Handler(void) void UART_Handler(void)
{ {
Serial1.IrqHandler() ; Serial.IrqHandler() ;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -364,7 +364,7 @@ void init( void )
g_APinDescription[PINS_UART].ulPin, g_APinDescription[PINS_UART].ulPin,
g_APinDescription[PINS_UART].ulPinConfiguration); g_APinDescription[PINS_UART].ulPinConfiguration);
Serial1.begin(115200); Serial.begin(115200);
// Initialize Serial ports USART // Initialize Serial ports USART
PIO_Configure( PIO_Configure(

View File

@ -201,7 +201,7 @@ static const uint8_t CANTX0 = 69;
#ifdef __cplusplus #ifdef __cplusplus
extern UARTClass Serial1 ; extern UARTClass Serial ;
extern USARTClass Serial2 ; extern USARTClass Serial2 ;
extern USARTClass Serial3 ; extern USARTClass Serial3 ;