]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Added faster baud rate speed when using sm16cf to program Mulle.
authorr-studio <r-studio>
Fri, 9 Apr 2010 09:26:49 +0000 (09:26 +0000)
committerr-studio <r-studio>
Fri, 9 Apr 2010 09:26:49 +0000 (09:26 +0000)
Added a fix in crt.S for the trampoline bug in the M16c GCC implementation.
Fixed a bug in m16c62phardware.h with the atomic statements, the flag register was saved after the interrupts were disabled which is not correct.
Some Mulle defines in the Deluge code had accidentally been removed, added these again.
Added a faster software spi implementation for the RF230 specific Mulle code. It is still not fast enough, but it could be made faster if the RF230 chip code also would be modified. (Look into this in the future).

support/make/m16c62p/crt.S
support/make/m16c62p/m16c62p.rules
support/make/m16c62p/sm16cf.extra
tos/chips/m16c62p/m16c62phardware.h
tos/lib/net/Deluge/extra/NetProgC.nc
tos/lib/net/Deluge/extra/NetProgM.nc
tos/platforms/mulle/.platform
tos/platforms/mulle/chips/rf230/HplRF230P.nc

index 14ea172237f9dd8e378baa1d69200c09f873d5f3..6a9cbe9bd67829017c56c8c82987a4cb6a4b0ae2 100755 (executable)
@@ -47,7 +47,7 @@
 
 .text
        .global __vector_default
-
+       .global m32c_jsri16
        .extern _main
 
 .section .init0,"ax",@progbits
@@ -88,6 +88,25 @@ _start:
        /* In case we return, should realy generate a reset :/ */
        jmp.b   0
 
+m32c_jsri16:
+    add.w    #-1, sp
+    /* Read the address (16 bits) and return address (24 bits) off
+    the stack.  */
+    mov.w    4[sp], r0
+    mov.w    1[sp], r3
+    mov.b    3[sp], a0 /* This zero-extends, so the high byte has
+                          zero in it.  */
+    /* Write the return address, then new address, to the stack.  */
+    mov.w    a0, 1[sp] /* Just to get the zero in 2[sp].  */
+    mov.w    r0, 0[sp]
+    mov.w    r3, 3[sp]
+    mov.b    a0, 5[sp]
+
+    /* This "returns" to the target address, leaving the pending
+    return address on the stack.  */
+    rts
+
+
 /* We should probably not get here. */
 __vector_default:
        jmp.a   __vector_default
index 9fb993728afb002bd3ad8a4c97069140e5edba43..cc0b7bdd1a38f6e04ad12bc54302bc01d9dc319b 100755 (executable)
@@ -26,7 +26,7 @@ OBJCOPY = m32c-elf-objcopy
 OBJDUMP = m32c-elf-objdump
 SET_ID = tos-set-symbols
 NCC = ncc
-LIBS = -lm -lc -lgcc
+LIBS = #-lm -lc -lgcc
 
 AMADDR = _ActiveMessageAddressC\$$addr
 # Uncomment the next two lines if you have a toolchain without the dollar sign
index f83aa5f7f5e90aeb90bbc22fcd8e09f69f4bd8dc..4a44de2b1098a3e57052fde0117e8d0249b718d8 100755 (executable)
@@ -15,13 +15,13 @@ ifdef BOOTLOADER
        @echo "    installing $(PLATFORM) with bootloader using sm16cf"
        srec_cat $(BOOTLOADER_IMG) $(INSTALL_SREC) -exclude 0x000FFFDC 0x00100000 -o $(BUILDDIR)/main_boot.srec -CRLF
        sed '/S5/d' $(BUILDDIR)/main_boot.srec > $(BUILDDIR)/main_boot2.srec
-       $(PROGRAMMER) --device=$(SM16CF) --input-file=$(BUILDDIR)/main_boot2.srec --flash-program
+       $(PROGRAMMER) --baud-rate=57600 --device=$(SM16CF) --input-file=$(BUILDDIR)/main_boot2.srec --flash-program
        rm $(BUILDDIR)/main_boot.srec
        rm $(BUILDDIR)/main_boot2.srec
 else
 program: FORCE
        @echo "    installing $(PLATFORM) using sm16cf"
-       $(PROGRAMMER) --device=$(SM16CF) --input-file=$(INSTALL_SREC) --flash-program
+       $(PROGRAMMER) --baud-rate=57600 --device=$(SM16CF) --input-file=$(INSTALL_SREC) --flash-program
 endif
 
 program_bl: FORCE
index d85c2de298521a06771e29a822e9b32576fb5204..d4f892711d25b48175c5024166edf64974c0e6a5 100755 (executable)
@@ -119,10 +119,10 @@ typedef uint16_t __nesc_atomic_t;
 inline __nesc_atomic_t __nesc_atomic_start(void) @spontaneous()
 {
   __nesc_atomic_t result;
-  // Disable interrupts
-  __nesc_disable_interrupt();
   // Save the flag register (FLG)
   asm volatile ("stc flg, %0": "=r"(result): : "%flg");
+  // Disable interrupts
+  __nesc_disable_interrupt();
   asm volatile("" : : : "memory"); // ensure atomic section effect visibility
   return result;
 }
index 79bad7651dd654b4bde4b9323cf9de1b9687ada2..74ad31323bccb346973766e19873eb565af0ca85 100644 (file)
@@ -56,7 +56,7 @@ implementation {
   components ActiveMessageAddressC;
   NetProgM.setAmAddress -> ActiveMessageAddressC;
 
-#if !defined(PLATFORM_TINYNODE)
+#if !defined(PLATFORM_TINYNODE) && !defined(PLATFORM_MULLE)
   components CC2420ControlP;
   NetProgM.CC2420Config -> CC2420ControlP;
 #endif
index fc054cff8fc0f13e00d657a1ca6da95241129eff..94368143db2258a529b2bd941ba4b77a4ff3e79d 100644 (file)
@@ -40,7 +40,7 @@ module NetProgM {
     interface InternalFlash as IFlash;
     interface Crc;
     interface Leds;
-#if !defined(PLATFORM_TINYNODE)
+#if !defined(PLATFORM_TINYNODE) && !defined(PLATFORM_MULLE)
     interface CC2420Config;
 #endif
     async command void setAmAddress(am_addr_t a);
@@ -62,7 +62,7 @@ implementation {
       TOS_NODE_ID = bootArgs.address;
       call setAmAddress(bootArgs.address);
     }
-#if !defined(PLATFORM_TINYNODE)
+#if !defined(PLATFORM_TINYNODE) && !defined(PLATFORM_MULLE)
     call CC2420Config.setShortAddr(bootArgs.address);
     call CC2420Config.sync();
 #endif    
@@ -116,7 +116,7 @@ implementation {
     }
   }
 
-#if !defined(PLATFORM_TINYNODE)
+#if !defined(PLATFORM_TINYNODE) && !defined(PLATFORM_MULLE)
   event void CC2420Config.syncDone(error_t error) {}
 #endif
 }
index eb04440ca48ca61005bb5701c4327fa1c667a06f..3a325f0ca68d9a8a19795eb5f8cd2ba9852107a1 100755 (executable)
@@ -32,7 +32,7 @@ push( @includes, qw(
   %T/lib/timer
   %T/lib/serial
   %T/lib/diagmsg
-  %T/lib/printf
+  %T/lib/net/Deluge
 ) );
 
 @opts = qw(
index 1973c681d4e8aaa633cf633d1eb78b873dafee04..4891c5e9ba3f1d602cff491c24ff1e7c5b37e804 100755 (executable)
@@ -33,7 +33,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  * OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 /**
  * Implementation of the time capture on RF230 interrupt and the
  * FastSpiBus interface.
@@ -53,7 +53,7 @@ module HplRF230P
   uses
   {
     interface GeneralIO as PortIRQ;
-       interface GeneralIO as PortVCC;
+    interface GeneralIO as PortVCC;
     interface GpioInterrupt as GIRQ;
     interface SoftSpiBus as Spi;
     interface Alarm<TRadio, uint16_t> as Alarm;
@@ -97,30 +97,159 @@ implementation
     call GIRQ.disable();
   }
 
+  /**
+   * Faster software implementation of the SPI bus for communication
+   * with the RF230 chip.
+   */
+  uint8_t fastWrite(uint8_t byte)
+  {
+#define fwMOSIset() P1.BIT.P1_1 = 1
+#define fwMOSIclr() P1.BIT.P1_1 = 0
+#define fwSCLKset() P3.BIT.P3_3 = 1
+#define fwSCLKclr() P3.BIT.P3_3 = 0
+#define fwMISOget() P1.BIT.P1_0
+    uint8_t data = 0;
+    uint8_t mask = 0x80;
+    atomic {
+      if (byte & mask)
+      {
+        fwMOSIset();
+      }
+      else
+      {
+        fwMOSIclr();
+      }
+      fwSCLKclr();
+      if( fwMISOget() )
+        data |= mask;
+      fwSCLKset();
+      mask >>= 1;
+
+      if (byte & mask)
+      {
+        fwMOSIset();
+      }
+      else
+      {
+        fwMOSIclr();
+      }
+      fwSCLKclr();
+      if( fwMISOget() )
+        data |= mask;
+      fwSCLKset();
+      mask >>= 1;
+
+      if (byte & mask)
+      {
+        fwMOSIset();
+      }
+      else
+      {
+        fwMOSIclr();
+      }
+      fwSCLKclr();
+      if( fwMISOget() )
+        data |= mask;
+      fwSCLKset();
+      mask >>= 1;
+
+      if (byte & mask)
+      {
+        fwMOSIset();
+      }
+      else
+      {
+        fwMOSIclr();
+      }
+      fwSCLKclr();
+      if( fwMISOget() )
+        data |= mask;
+      fwSCLKset();
+      mask >>= 1;
+
+      if (byte & mask)
+      {
+        fwMOSIset();
+      }
+      else
+      {
+        fwMOSIclr();
+      }
+      fwSCLKclr();
+      if( fwMISOget() )
+        data |= mask;
+      fwSCLKset();
+      mask >>= 1;
+
+      if (byte & mask)
+      {
+        fwMOSIset();
+      }
+      else
+      {
+        fwMOSIclr();
+      }
+      fwSCLKclr();
+      if( fwMISOget() )
+        data |= mask;
+      fwSCLKset();
+      mask >>= 1;
+
+      if (byte & mask)
+      {
+        fwMOSIset();
+      }
+      else
+      {
+        fwMOSIclr();
+      }
+      fwSCLKclr();
+      if( fwMISOget() )
+        data |= mask;
+      fwSCLKset();
+      mask >>= 1;
+
+      if (byte & mask)
+      {
+        fwMOSIset();
+      }
+      else
+      {
+        fwMOSIclr();
+      }
+      fwSCLKclr();
+      if( fwMISOget() )
+        data |= mask;
+      fwSCLKset();
+      mask >>= 1;
+    }
+    return data;
+  }
+
   uint8_t tmp_data;
-  async command void FastSpiByte.splitWrite(uint8_t data)
+  inline async command void FastSpiByte.splitWrite(uint8_t data)
   {
-    atomic tmp_data = data;
+    atomic tmp_data = fastWrite(data);
   }
 
-  async command uint8_t FastSpiByte.splitRead()
+  inline async command uint8_t FastSpiByte.splitRead()
   {
-    atomic return call Spi.write(tmp_data);
+    atomic return tmp_data;
   }
 
-  async command uint8_t FastSpiByte.splitReadWrite(uint8_t data)
+  inline async command uint8_t FastSpiByte.splitReadWrite(uint8_t data)
   {
     uint8_t b;
     atomic
     {
-      b = call Spi.write(tmp_data);
-      tmp_data = data;
+      b = tmp_data;
+      tmp_data = fastWrite(data);
     }
     return b;
   }
 
-  async command uint8_t FastSpiByte.write(uint8_t data)
+  inline async command uint8_t FastSpiByte.write(uint8_t data)
   {
-    return call Spi.write(data);
+    return fastWrite(data);
   }
 }