![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
mbed LPC1114 emulator pre-alpha version
Dependencies: BaseV6M mbed F12RFileSystem F32RFileSystem ROMSLOT SDStorage
Fork of emu812 by
TOYOSHIKI TINY BASIC mbed Edition TTB_mbed_LPC1114.bin save as "LPC1114.IMG" .
Diff: main.cpp
- Revision:
- 1:913dfd59e25a
- Parent:
- 0:e38daa7b1a22
- Child:
- 3:5df725af50e0
--- a/main.cpp Mon Aug 10 13:04:09 2015 +0000 +++ b/main.cpp Mon Aug 10 22:52:48 2015 +0900 @@ -1,32 +1,56 @@ -#include "mbed.h" -LocalFileSystem local("local"); +// main.cpp 2015/8/10 +#include "EMU81x.h" +#include "mbed_blinky_LPC812_bin.h" DigitalOut led1(LED1); RawSerial pc(USBTX,USBRX); +LocalFileSystem local("local"); uint8_t flash[1024*16] __attribute__((section("AHBSRAM0"))); uint8_t rom[1024*8] __attribute__((section("AHBSRAM1"))); +class MyEMU812 : public EMU81x { + virtual void DigitalWrite_Callback(int port, int pin, int value) { + if (pin == 16) { // PIO0_16 + led1 = value; + } + } + virtual void SerialPutc_Callback(int ch, uint8_t c) { + pc.putc(c); + } +}; + int load(uint8_t* buf, int size, const char* filename) { pc.printf("loading[%s]... ", filename); FileHandle* fh = local.open(filename, O_RDONLY); - if (fh == NULL) { return -1; } + if (fh == NULL) { + pc.printf("fail\n"); + return -1; + } int n = fh->read(buf, size); fh->close(); pc.printf("%d bytes\n", n); return n; } - + int main() { pc.baud(115200); - pc.printf("%s\n", __FILE__); - + pc.puts("LPC812 emulator\n"); + + MyEMU812 mcu; + mcu.assign_flash(mbed_blinky_LPC812_bin); + if (load(flash, sizeof(flash), "LPC812.IMG") >= 0) { - load(rom, sizeof(rom), "LPC812.ROM"); + load(rom, sizeof(rom), "LPC812.ROM"); + mcu.assign_flash(flash); + mcu.assign_rom(rom); } - - while(1) { - led1 = !led1; - wait_ms(200); + + mcu.reset(); + for(;;) { + mcu.run(100); + mcu.clock_in(20000); } + /* NOTREACHED */ } +