semihost server example program
Dependencies: SWD mbed USBLocalFileSystem BaseDAP USBDAP
LPCXpresso LPC11U68 | LPCXpresso LPC1549 | FRDM-KL46Z | EA LPC4088 QSB app-board | LPC1768 app-board | LPC810 | LPC1114FN28 | |
---|---|---|---|---|---|---|---|
server | server | server | server | server | client | client | |
SWDIO | D12 | D12 | D12 | p25 | p21 | p4(P0_2) | p12 |
SWCLK | D10 | D10 | D10 | p26 | p22 | p3(P0_3) | p3 |
nRESET *option | D6 | D6 | D6 | p34 | p30 | p1(P0_5) | p23 |
GND | GND | GND | GND | p1 | p1 | p7 | p22 |
3.3V | P3V3 | P3V3 | P3V3 | p44 | p40 | p6 | p21 |
flash write | SW2(P0_1) | SW3(P1_9) | SW1 | p14 joystick center | p14 joystick center |
client example:
Import programlpc810-semihost_helloworld
semihost client example program
Revision 16:89d9621681a2, committed 2014-05-03
- 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
--- 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