Skip to content

Commit 37ea166

Browse files
committed
sam: refined UART/USART class inheritance
Let Usart inherit all methods from Uart.
1 parent 16d8361 commit 37ea166

File tree

3 files changed

+4
-48
lines changed

3 files changed

+4
-48
lines changed

hardware/arduino/sam/cores/arduino/UARTClass.h

+3-8
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,12 @@ class UARTClass : public HardwareSerial
4848
int read(void);
4949
void flush(void);
5050
size_t write(const uint8_t c);
51+
using Print::write; // pull in write(str) and write(buf, size) from Print
52+
5153
void setInterruptPriority(uint32_t priority);
5254
uint32_t getInterruptPriority();
5355

54-
void IrqHandler( void );
55-
56-
#if defined __GNUC__ /* GCC CS3 */
57-
using Print::write; // pull in write(str) and write(buf, size) from Print
58-
#elif defined __ICCARM__ /* IAR Ewarm 5.41+ */
59-
// virtual void write( const char *str );
60-
// virtual void write( const uint8_t *buffer, size_t size );
61-
#endif
56+
void IrqHandler(void);
6257

6358
operator bool() { return true; }; // UART always active
6459
};

hardware/arduino/sam/cores/arduino/USARTClass.cpp

-25
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,8 @@ USARTClass::USARTClass( Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId, RingBuffe
3232

3333
// Public Methods //////////////////////////////////////////////////////////////
3434

35-
void USARTClass::begin( const uint32_t dwBaudRate )
36-
{
37-
begin( dwBaudRate, SERIAL_8N1 );
38-
}
39-
4035
void USARTClass::begin( const uint32_t dwBaudRate, const uint32_t config )
4136
{
4237
UARTClass::begin(dwBaudRate, config);
4338
}
4439

45-
void USARTClass::end( void )
46-
{
47-
UARTClass::end();
48-
}
49-
50-
void USARTClass::flush( void )
51-
{
52-
UARTClass::flush();
53-
}
54-
55-
size_t USARTClass::write( const uint8_t uc_data )
56-
{
57-
return UARTClass::write(uc_data);
58-
}
59-
60-
void USARTClass::IrqHandler( void )
61-
{
62-
UARTClass::IrqHandler();
63-
}
64-

hardware/arduino/sam/cores/arduino/USARTClass.h

+1-15
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,8 @@ class USARTClass : public UARTClass
6464
public:
6565
USARTClass( Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId, RingBuffer* pRx_buffer, RingBuffer* pTx_buffer );
6666

67-
void begin( const uint32_t dwBaudRate );
6867
void begin( const uint32_t dwBaudRate , const uint32_t config );
69-
void end( void );
70-
void flush( void );
71-
size_t write( const uint8_t c );
72-
73-
void IrqHandler( void );
74-
75-
#if defined __GNUC__ /* GCC CS3 */
76-
using Print::write; // pull in write(str) and write(buf, size) from Print
77-
#elif defined __ICCARM__ /* IAR Ewarm 5.41+ */
78-
// virtual void write( const char *str );
79-
// virtual void write( const uint8_t *buffer, size_t size );
80-
#endif
81-
82-
operator bool() { return true; }; // USART always active
68+
using UARTClass::begin; // Needed only for polymorphic methods
8369
};
8470

8571
#endif // _USART_CLASS_

0 commit comments

Comments
 (0)