mbed libraries for KL25Z

Dependents:   FRDM_RGBLED

Revision:
7:73c5efe92a6c
Parent:
2:e9a661555b58
Child:
8:c14af7958ef5
--- a/Serial.h	Fri Oct 12 10:06:08 2012 +0000
+++ b/Serial.h	Tue Oct 23 09:20:18 2012 +0000
@@ -1,7 +1,6 @@
 /* mbed Microcontroller Library - Serial
  * Copyright (c) 2007-2011 ARM Limited. All rights reserved.
- */ 
- 
+ */
 #ifndef MBED_SERIAL_H
 #define MBED_SERIAL_H
 
@@ -10,10 +9,9 @@
 #if DEVICE_SERIAL
 
 #include "platform.h"
-#include "PinNames.h"
-#include "PeripheralNames.h"
 #include "Stream.h"
 #include "FunctionPointer.h"
+#include "serial_api.h"
 
 namespace mbed {
 
@@ -37,7 +35,6 @@
 class Serial : public Stream {
 
 public:
-
     /* Constructor: Serial
      *  Create a Serial port, connected to the specified transmit and receive pins
      *
@@ -57,19 +54,6 @@
      */
     void baud(int baudrate);
 
-    enum Parity {
-        None = 0
-        , Odd
-        , Even
-        , Forced1    
-        , Forced0
-    };
-
-    enum IrqType {
-        RxIrq = 0
-        , TxIrq
-    };
-
     /* Function: format
      *  Set the transmission format used by the Serial port
      *
@@ -78,7 +62,7 @@
      *  parity - The parity used (Serial::None, Serial::Odd, Serial::Even, Serial::Forced1, Serial::Forced0; default = Serial::None)
      *  stop - The number of stop bits (1 or 2; default = 1)
      */
-    void format(int bits = 8, Parity parity = Serial::None, int stop_bits = 1); 
+    void format(int bits = 8, SerialParity parity=ParityNone, int stop_bits=1); 
 
 #if 0 // Inhereted from Stream, for documentation only
 
@@ -145,7 +129,7 @@
      *  fptr - A pointer to a void function, or 0 to set as none
      *  type - Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
      */
-    void attach(void (*fptr)(void), IrqType type = RxIrq);
+    void attach(void (*fptr)(void), SerialIrq type=RxIrq);
 
     /* Function: attach
      *  Attach a member function to call whenever a serial interrupt is generated
@@ -156,30 +140,26 @@
      *  type - Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
      */
     template<typename T>
-    void attach(T* tptr, void (T::*mptr)(void), IrqType type = RxIrq) {
+    void attach(T* tptr, void (T::*mptr)(void), SerialIrq type=RxIrq) {
         if((mptr != NULL) && (tptr != NULL)) {
             _irq[type].attach(tptr, mptr);
-            setup_interrupt(type);
+            serial_irq_set(&_serial, type, 1);
         }
     }
-
+    
 #ifdef MBED_RPC
     virtual const struct rpc_method *get_rpc_methods();
     static struct rpc_class *get_rpc_class();
 #endif
+    
+    static void _irq_handler(uint32_t id, SerialIrq irq_type);
 
 protected:
-
-    void setup_interrupt(IrqType type);
-    void remove_interrupt(IrqType type);
-
     virtual int _getc();
     virtual int _putc(int c);
-
-    UARTName _uart;
+    
+    serial_object   _serial;
     FunctionPointer _irq[2];
-    int _uidx;
-
 };
 
 } // namespace mbed