Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of football_project by
Diff: io/MySerial.h
- Revision:
- 5:1b9734e68327
- Parent:
- 4:17b8edf264c3
- Child:
- 6:ef758ac3c928
--- a/io/MySerial.h Thu Apr 16 17:10:19 2015 +0000
+++ b/io/MySerial.h Fri Apr 17 04:20:07 2015 +0000
@@ -28,6 +28,14 @@
class MySerialBase
{
public:
+
+ enum IrqType
+ {
+ RxIrq = 0,
+ TxIrq,
+ ErrIrq
+ };
+
/** Set the baud rate of the serial port
*
* @param baudrate The baudrate of the serial port (default = 9600).
@@ -61,23 +69,23 @@
/** Attach a function to call whenever a serial interrupt is generated
*
* @param fptr A pointer to a void function, or 0 to set as none
- * @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
+ * @param type Which serial interrupt to attach the member function to (MySerial::RxIrq for receive, TxIrq for transmit buffer empty)
*/
- void attach( void (*fptr)(void), SerialBase::IrqType type=SerialBase::RxIrq );
+ void attach( void (*fptr)(void), Serial::IrqType type=Serial::RxIrq );
/** Attach a member function to call whenever a serial interrupt is generated
*
* @param tptr pointer to the object to call the member function on
* @param mptr pointer to the member function to be called
- * @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
+ * @param type Which serial interrupt to attach the member function to (MySerial::RxIrq for receive, TxIrq for transmit buffer empty)
*/
template<typename T>
- void attach( T* tptr, void (T::*mptr)(void), SerialBase::IrqType type=SerialBase::RxIrq )
+ void attach( T* tptr, void (T::*mptr)(void), Serial::IrqType type=Serial::RxIrq )
{
if( (mptr != NULL) && (tptr != NULL) )
{
_my_irq[type].attach( tptr, mptr );
- serial_irq_set( &_my_serial, (SerialIrq)type, 1 );
+ my_serial_irq_set( &_my_serial, (IrqType)type, 1 );
}
}
@@ -95,11 +103,15 @@
void my_serial_init( serial_t *obj, PinName tx, PinName rx, PinName rts, PinName cts, int baudrate );
+ void my_serial_irq_set( serial_t *obj, IrqType irq, uint32_t enable );
+
+ void error_handler();
+
int _base_getc();
int _base_putc( int c );
serial_t _my_serial;
- FunctionPointer _my_irq[2];
+ FunctionPointer _my_irq[4];
int _my_baud;
};
