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

Committer:
va009039
Date:
Sun Jun 22 12:04:16 2014 +0000
Revision:
18:5ed1759e863b
Parent:
17:4e1205ce031f
add LPC11U68 interface.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 17:4e1205ce031f 1 // Semihost.h 2014/5/3
va009039 1:eb30547ba84d 2 #pragma once
va009039 1:eb30547ba84d 3 #include "Target2.h"
va009039 17:4e1205ce031f 4 #include "USBLocalFileSystem.h"
va009039 1:eb30547ba84d 5 #include "mydebug.h"
va009039 1:eb30547ba84d 6
va009039 5:2774358f5e4f 7 /** Semihosting
va009039 5:2774358f5e4f 8 */
va009039 1:eb30547ba84d 9 class Semihost {
va009039 1:eb30547ba84d 10 public:
va009039 17:4e1205ce031f 11 Semihost(Target2* target, Serial* usbpc, USBLocalFileSystem* usb);
va009039 1:eb30547ba84d 12 void mount(const char* dirpath);
va009039 1:eb30547ba84d 13 int poll();
va009039 2:32e9437348ad 14 enum Reason {
va009039 2:32e9437348ad 15 SYS_NONE = 0,
va009039 2:32e9437348ad 16 SYS_EXIT = 0x18,
va009039 2:32e9437348ad 17 };
va009039 9:7e71c20c96e4 18 int readable();
va009039 9:7e71c20c96e4 19 int getc();
va009039 9:7e71c20c96e4 20
va009039 1:eb30547ba84d 21 private:
va009039 1:eb30547ba84d 22 int exec(uint32_t reason, uint32_t arg);
va009039 1:eb30547ba84d 23
va009039 1:eb30547ba84d 24 int sys_open(uint32_t arg); // 0x01
va009039 1:eb30547ba84d 25 int sys_close(uint32_t arg); // 0x02
va009039 1:eb30547ba84d 26 int sys_writec(uint32_t arg); // 0x03
va009039 1:eb30547ba84d 27 int sys_write0(uint32_t arg); // 0x04
va009039 1:eb30547ba84d 28 int sys_write(uint32_t arg); // 0x05
va009039 1:eb30547ba84d 29 int sys_read(uint32_t arg); // 0x06
va009039 1:eb30547ba84d 30 int sys_readc(uint32_t arg); // 0x07
va009039 1:eb30547ba84d 31 int sys_istty(uint32_t arg); // 0x09
va009039 1:eb30547ba84d 32 int sys_fseek(uint32_t arg); // 0x0a
va009039 1:eb30547ba84d 33 int sys_ensure(uint32_t arg); // 0x0b
va009039 1:eb30547ba84d 34 int sys_flen(uint32_t arg); // 0x0c
va009039 1:eb30547ba84d 35 int sys_remove(uint32_t arg); // 0x0e
va009039 1:eb30547ba84d 36 int sys_rename(uint32_t arg); // 0x0f
va009039 1:eb30547ba84d 37 int sys_exit(uint32_t arg); // 0x18
va009039 1:eb30547ba84d 38
va009039 1:eb30547ba84d 39 int usr_xffind(uint32_t arg); // 0x100
va009039 1:eb30547ba84d 40 int usr_uid(uint32_t arg); // 0x101
va009039 1:eb30547ba84d 41 int usr_reset(uint32_t arg); // 0x102
va009039 1:eb30547ba84d 42 int usr_vbus(uint32_t arg); // 0x103
va009039 1:eb30547ba84d 43 int usr_powerdown(uint32_t arg); // 0x104
va009039 1:eb30547ba84d 44 int usr_disabledebug(uint32_t arg);// 0x105
va009039 1:eb30547ba84d 45
va009039 1:eb30547ba84d 46 void _build_name(char* buf, int size, uint32_t arg1, uint32_t arg2);
va009039 1:eb30547ba84d 47
va009039 1:eb30547ba84d 48 template<typename T>
va009039 1:eb30547ba84d 49 void wr(uint32_t addr, T data) {
va009039 1:eb30547ba84d 50 TEST_ASSERT(addr <= 0x10001fff);
va009039 1:eb30547ba84d 51 for(int i = 0; i < sizeof(T); i++) {
va009039 5:2774358f5e4f 52 _target->writeMemory8(addr+i, data);
va009039 5:2774358f5e4f 53 data >>= 8;
va009039 1:eb30547ba84d 54 }
va009039 1:eb30547ba84d 55 }
va009039 1:eb30547ba84d 56
va009039 1:eb30547ba84d 57 template<typename T>
va009039 1:eb30547ba84d 58 T rd(uint32_t addr) {
va009039 1:eb30547ba84d 59 TEST_ASSERT(addr <= 0x10001fff);
va009039 5:2774358f5e4f 60 T data = 0;
va009039 5:2774358f5e4f 61 for(int i = sizeof(T)-1; i >= 0; i--) {
va009039 5:2774358f5e4f 62 data <<= 8;
va009039 5:2774358f5e4f 63 data |= _target->readMemory8(addr+i);
va009039 1:eb30547ba84d 64 }
va009039 5:2774358f5e4f 65 return data;
va009039 1:eb30547ba84d 66 }
va009039 1:eb30547ba84d 67
va009039 1:eb30547ba84d 68 protected:
va009039 1:eb30547ba84d 69 Target2* _target;
va009039 1:eb30547ba84d 70 Serial* _pc;
va009039 17:4e1205ce031f 71 USBLocalFileSystem* _usb;
va009039 1:eb30547ba84d 72 char* _dirpath;
va009039 9:7e71c20c96e4 73 int _writec_buf;
va009039 1:eb30547ba84d 74 };