MODSERIAL with support for more devices

Dependents:   1D-Pong BMT-K9_encoder BMT-K9-Regelaar programma_filter ... more

Check the cookbook page for more information: https://mbed.org/cookbook/MODSERIAL

Did you add a device? Please send a pull request so we can keep everything in one library instead of many copies. In that case also send a PM, since currently mbed does not inform of new pull requests. I will then also add you to the developers of this library so you can do other changes directly.

Files at this revision

API Documentation at this revision

Comitter:
Sissors
Date:
Fri Jul 12 15:56:20 2013 +0000
Parent:
28:76793a84f9e5
Child:
30:b04ce87dc424
Commit message:
Added documentation
;

Changed in this revision

ChangeLog.c Show annotated file Show diff for this revision Revisions of this file
Device/AddingDevice.h Show annotated file Show diff for this revision Revisions of this file
Device/MODSERIAL_KL25Z.h Show annotated file Show diff for this revision Revisions of this file
INIT.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ChangeLog.c	Fri Jul 12 15:27:07 2013 +0000
+++ b/ChangeLog.c	Fri Jul 12 15:56:20 2013 +0000
@@ -1,4 +1,7 @@
 /* $Id:$
+1.29    12th July 2013
+    * Added KL25Z support + split code in device dependent and independent part
+
 1.26    10th June 2013
     * _uidx reference in DMA code replaced by _serial.index
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Device/AddingDevice.h	Fri Jul 12 15:56:20 2013 +0000
@@ -0,0 +1,34 @@
+/*
+
+To add another device some functions/macros need to be defined.
+The Device folder shows examples of other devices.
+
+1. In MACROS.h the include to the macro file need to be added.
+
+2. A <NameOfYourFile.h> file needs to be added, it needs to include the ifdef(target) statement, and definitions for:
+MODSERIAL_IRQ_REG    ---   register which enables/disables serial IRQs
+DISABLE_TX_IRQ       ---   macro that disables TX IRQs
+DISABLE_RX_IRQ       ---   macro that disables RX IRQs
+ENABLE_TX_IRQ        ---   macro that enables TX IRQs
+ENABLE_RX_IRQ        ---   macro that enables RX IRQs
+
+RESET_TX_FIFO        ---   macro that resets TX FIFO buffer, if applicable. If not, something like while(1==0) won't do anything and doesn't generate compiler warnings
+RESET_RX_FIFO        ---   macro that resets RX FIFO buffer, if no hardware options, you can also read data until no more data is available
+
+MODSERIAL_READ_REG   ---   register where RX data is in
+MODSERIAL_WRITE_REG  ---   register where TX data is in (can be same as previous)
+MODSERIAL_READABLE   ---   returns true if new data is available in read_reg
+MODSERIAL_WRITABLE   ---   returns true if we may write new data in write_reg
+
+RX_IRQ_ENABLED       ---   checks if RX IRQs are enabled by MODSERIAL. Only required if the device has no registers that tell which IRQ fired. If those registers are available (LPCs have then), may just be 'true'
+TX_IRQ_ENABLED       ---   checks if TX IRQs are enabled by MODSERIAL. See previous
+
+3. A <NameOfYourFile.cpp> file needs to be added, it needs to include the ifdef(target) statement, and functions for:
+void setBase(void)   ---   function that sets _base pointer to point to correct UART, and _IRQ pointer to point to correct IRQ.
+
+void initDevice(void)---   function that allows for setting registers after everything else is initialized, if required
+
+bool txIsBusy(void)  ---   function that returns true as long as long as device isn't done with transmitting
+
+*/
+ 
\ No newline at end of file
--- a/Device/MODSERIAL_KL25Z.h	Fri Jul 12 15:27:07 2013 +0000
+++ b/Device/MODSERIAL_KL25Z.h	Fri Jul 12 15:56:20 2013 +0000
@@ -6,14 +6,14 @@
 #define ENABLE_TX_IRQ MODSERIAL_IRQ_REG |= (1UL << UART_C2_TIE_SHIFT)
 #define ENABLE_RX_IRQ MODSERIAL_IRQ_REG |= (1UL << UART_C2_RIE_SHIFT)
 
-#define RESET_TX_FIFO while(0 == 1)
-#define RESET_RX_FIFO while(MODSERIAL_READABLE) char dummy = MODSERIAL_READ_REG
-
 #define MODSERIAL_READ_REG ((UART_Type*)_base)->D
 #define MODSERIAL_WRITE_REG ((UART_Type*)_base)->D
 #define MODSERIAL_READABLE ((((UART_Type*)_base)->S1 & (1UL<<5)) != 0)
 #define MODSERIAL_WRITABLE ((((UART_Type*)_base)->S1 & (1UL<<7)) != 0)
 
+#define RESET_TX_FIFO while(0 == 1)
+#define RESET_RX_FIFO while(MODSERIAL_READABLE) char dummy = MODSERIAL_READ_REG
+
 #define RX_IRQ_ENABLED ((MODSERIAL_IRQ_REG & (1UL << UART_C2_RIE_SHIFT)) != 0 )
 #define TX_IRQ_ENABLED ((MODSERIAL_IRQ_REG & (1UL << UART_C2_TIE_SHIFT)) != 0 )
 
--- a/INIT.cpp	Fri Jul 12 15:27:07 2013 +0000
+++ b/INIT.cpp	Fri Jul 12 15:56:20 2013 +0000
@@ -36,9 +36,10 @@
 void
 MODSERIAL::init( int txSize, int rxSize, PinName rx )
 {
+    
     NVIC_DisableIRQ(_IRQ);
     setBase();
-    
+
     callbackInfo.setSerial(this);
     
     dmaSendChannel  = -1;