semihost server example program

Dependencies:   SWD mbed USBLocalFileSystem BaseDAP USBDAP

/media/uploads/va009039/kl46z-lpc800-360x480.jpg

LPCXpresso
LPC11U68
LPCXpresso
LPC1549
FRDM-KL46ZEA LPC4088 QSB
app-board
LPC1768
app-board
LPC810LPC1114FN28
serverserverserverserverserverclientclient
SWDIOD12D12D12p25p21p4(P0_2)p12
SWCLKD10D10D10p26p22p3(P0_3)p3
nRESET
*option
D6D6D6p34p30p1(P0_5)p23
GNDGNDGNDGNDp1p1p7p22
3.3VP3V3P3V3P3V3p44p40p6p21
flash writeSW2(P0_1)SW3(P1_9)SW1p14
joystick
center
p14
joystick
center

client example:

Import programlpc810-semihost_helloworld

semihost client example program

Files at this revision

API Documentation at this revision

Comitter:
va009039
Date:
Sat May 03 03:46:26 2014 +0000
Parent:
15:d977d224189f
Child:
17:4e1205ce031f
Commit message:
fast SWSPI

Changed in this revision

SWSPI/SWSPI.cpp Show annotated file Show diff for this revision Revisions of this file
SWSPI/SWSPI.h Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/SWSPI/SWSPI.cpp	Mon Apr 28 06:01:06 2014 +0000
+++ b/SWSPI/SWSPI.cpp	Sat May 03 03:46:26 2014 +0000
@@ -23,7 +23,7 @@
 #include <mbed.h>
 #include "SWSPI.h"
 
-SWSPI::SWSPI(PinName mosi_pin, PinName miso_pin, PinName sclk_pin)
+SWSPI::SWSPI(PinName mosi_pin, PinName miso_pin, PinName sclk_pin):_fast(false)
 {
     mosi = new DigitalOut(mosi_pin);
     miso = new DigitalIn(miso_pin);
@@ -51,12 +51,16 @@
 void SWSPI::frequency(int hz)
 {
     this->freq = hz;
+    _fast = (hz >= 1000000) ? true : false;
 }
 
 #pragma Otime
 
 int SWSPI::write(int value)
 {
+    if (_fast) {
+        return fast_write(value);
+    }
     int read = 0;
     for (int bit = bits-1; bit >= 0; --bit)
     {
@@ -86,3 +90,17 @@
     return read;
 }
 
+uint8_t SWSPI::fast_write(uint8_t value)
+{
+    uint8_t data = 0;
+    for(uint8_t mask = 0x80; mask; mask >>= 1) {
+        mosi->write((value & mask) ? 1 : 0);
+        if (miso->read()) {
+            data |= mask;
+        }
+        sclk->write(1);
+        sclk->write(0);
+    }
+    return data;
+}
+
--- a/SWSPI/SWSPI.h	Mon Apr 28 06:01:06 2014 +0000
+++ b/SWSPI/SWSPI.h	Sat May 03 03:46:26 2014 +0000
@@ -49,6 +49,7 @@
 class SWSPI
 {
 private:
+    uint8_t fast_write(uint8_t value);
     DigitalOut* mosi;
     DigitalIn* miso;
     DigitalOut* sclk;
@@ -58,6 +59,7 @@
     int polarity; // idle clock value
     int phase; // 0=sample on leading (first) clock edge, 1=trailing (second)
     int freq;
+    bool _fast;
     
 public:
     /** Create SWSPI object
--- a/mbed.bld	Mon Apr 28 06:01:06 2014 +0000
+++ b/mbed.bld	Sat May 03 03:46:26 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file