Index: EcnlProtoTool/trunk/prototool/llbruby.h
===================================================================
--- EcnlProtoTool/trunk/prototool/llbruby.h	(revision 278)
+++ EcnlProtoTool/trunk/prototool/llbruby.h	(revision 278)
@@ -0,0 +1,116 @@
+/*
+ * WRBB Main
+ *
+ * Copyright (c) 2015 Minao Yamamoto
+ *
+ * This software is released under the MIT License.
+ * 
+ * http://opensource.org/licenses/mit-license.php
+ *
+ * Light weight Lanuage Board Ruby
+ * Wakayamarb board 
+ *
+ */
+#ifndef _LLBRUBY_H_
+#define _LLBRUBY_H_  1
+
+#define RUBY_CODE_SIZE (1024 * 4)		//4kBã¾ã§å®è¡å¯è½ã¨ãã
+
+//ãã¤ãã³ã¼ããã¼ã¸ã§ã³ãå®ç¾©ãã¾ã
+#define BYTE_CODE2	2
+#define BYTE_CODE3	3
+
+//ãã¡ã¼ã ã¦ã§ã¢ã®ãã¼ã¸ã§ã³ãå®ç¾©ãã¾ã
+#define MASTER		1000
+#define JAM			1001
+#define SDBT		1002
+#define SDWF		1003
+
+
+//åºæ¿ã®è¨­è¨ãã¼ã¸ã§ã³ãå®ç¾©ãã¾ã
+#define BOARD_GR	0
+#define BOARD_P01	1
+#define BOARD_P02	2
+#define BOARD_P03	3
+#define BOARD_P04	4
+
+
+//ãã¤ãã³ã¼ããã©ã¼ãããã®è¨­å®
+#define BYTECODE	BYTE_CODE3
+
+//åºæ¿ã®ã¿ã¤ãè¨­å®
+#define BOARD	BOARD_GR
+
+//ãã¡ã¼ã ã¦ã§ã¢è¨­å®
+#define FIRMWARE	MASTER
+//#define FIRMWARE	JAM
+//#define FIRMWARE	SDBT
+//#define FIRMWARE	SDWF
+
+//#define    DEBUG                1        // Define if you want to debug
+
+#ifdef DEBUG
+#  define DEBUG_PRINT(m,v)    { Serial.print("** "); Serial.print((m)); Serial.print(":"); Serial.println((v)); }
+#else
+#  define DEBUG_PRINT(m,v)    // do nothing
+#endif
+
+#define	FILE_LOAD	PORT3.PIDR.BIT.B5		//PORT 3-5
+
+#define XML_FILENAME  "wrbb.xml"
+#define RUBY_FILENAME  "main.mrb"
+#define RUBY_FILENAME_SIZE 32
+
+#define REALTIMECLOCK	1
+
+#if BYTECODE == BYTE_CODE2
+	#if FIRMWARE == MASTER
+		#define WRBB_VERSION "SakuRuby-1.13(2015/7/19)f2"
+	#elif FIRMWARE == JAM
+		#define WRBB_VERSION "SakuraJam-1.13(2015/7/19)f2"
+	#endif
+#elif BYTECODE == BYTE_CODE3
+	#if FIRMWARE == MASTER
+		#define WRBB_VERSION "SakuRuby-1.30(2015/12/19)f3"
+	#elif FIRMWARE == JAM
+		#define WRBB_VERSION "SakuraJam-1.30(2015/12/19)f3"
+	#endif
+#endif
+
+#define RB_PIN0		0
+#define RB_PIN1		1
+#define RB_PIN18	18
+#define RB_PIN19	19
+#define RB_PIN2		2
+#define RB_PIN3		3
+#define RB_PIN4		4
+#define RB_PIN5		5
+#define RB_PIN6		6
+#define RB_PIN7		7
+#define RB_PIN8		8
+#define RB_PIN9		9
+#define RB_PIN10	10
+#define RB_PIN11	11
+#define RB_PIN12	12
+#define RB_PIN13	13
+#define RB_PIN14	14
+#define RB_PIN15	15
+#define RB_PIN16	16
+#define RB_PIN17	17
+
+#define RB_PIN20	20
+#define RB_PIN21	21
+#define RB_PIN22	22
+#define RB_PIN23	23
+#define RB_PIN24	24
+#define RB_PIN25	25
+
+#define PIN_LED0	LED1
+#define PIN_LED1	LED2
+#define PIN_LED2	LED3
+#define PIN_LED3	LED4
+#define RB_LED	PIN_LED0
+
+
+#endif // _LLBRUBY_H_
+
Index: EcnlProtoTool/trunk/prototool/makefile.init
===================================================================
--- EcnlProtoTool/trunk/prototool/makefile.init	(revision 274)
+++ 	(revision )
@@ -1,5 +1,0 @@
-################################################################################
-# Automatically-generated file. Do not edit!
-################################################################################
-
-PATH := $(PATH):C:\PROGRA~2\KPIT\GNUARM~2.01-\ARM-NO~1\ARM-NO~1\bin;C:\PROGRA~2\KPIT\GNUARM~2.01-\ARM-NO~1\ARM-NO~1\libexec\gcc\arm-none-eabi\5.2-GNUARM-NONE_v16.01
Index: EcnlProtoTool/trunk/prototool/src/arduino.c
===================================================================
--- EcnlProtoTool/trunk/prototool/src/arduino.c	(revision 278)
+++ EcnlProtoTool/trunk/prototool/src/arduino.c	(revision 278)
@@ -0,0 +1,557 @@
+#include <arduino.h>
+#include <mruby.h>
+#include "../llbruby.h"
+
+serial_t *Serial;
+serial_t *Serial1;	/*1:Serial1*/
+serial_t *Serial2;	/*2:Serial3*/
+serial_t *Serial3;	/*3:Serial2*/
+serial_t *Serial4;	/*4:Serial6*/
+serial_t *Serial5;	/*5:Serial7*/
+
+i2c_t Wire1;
+i2c_t Wire2;
+i2c_t Wire3;
+i2c_t Wire4;
+i2c_t Wire5;
+
+FATFS RomDisk;
+SD Sd;
+
+char ExeFilename[64];
+
+void arduino_init()
+{
+}
+
+void randomSeed(long seed)
+{
+}
+
+long arduino_random(long min, long max)
+{
+	return min;
+}
+
+struct pin_node pin_list;
+
+static struct pin_node *find_pin(PinType type, PinName pin)
+{
+	struct pin_node *ret = &pin_list;
+
+	while (ret != NULL) {
+		if ((ret->type == type) && (ret->pin == pin)) {
+			break;
+		}
+		ret = ret->next;
+	}
+
+	return ret;
+}
+
+static struct pin_node *new_pin(PinType type, PinName pin)
+{
+	struct pin_node *ret = calloc(1, sizeof(struct pin_node));
+
+	ret->next = pin_list.next;
+	ret->type = type;
+	ret->pin = pin;
+
+	pin_list.next = ret;
+
+	return ret;
+}
+
+struct pin_node *get_pin(PinType type, PinName pinno)
+{
+	struct pin_node *pin;
+
+	if (pinno == -1)
+		return NULL;
+
+	pin = find_pin(type, pinno);
+	if (pin != NULL)
+		return pin;
+
+	pin = new_pin(type, pinno);
+	if (pin == NULL)
+		return NULL;
+
+	switch (type) {
+	case pintype_gpio:
+		gpio_init(&pin->gpio, pinno);
+		break;
+	case pintype_dac:
+#if DEVICE_ANALOGOUT
+		analogout_init(&pin->dac, pinno);
+#endif
+		break;
+	case pintype_pwmout:
+		pwmout_init(&pin->pwmout, pinno);
+		pin->period = 491;
+		break;
+	case pintype_analogin:
+		analogin_init(&pin->analogin, pinno);
+		break;
+	}
+
+	return pin;
+}
+
+bool portToPins(SCI_PORT port, PinName *txpin, PinName *rxpin)
+{
+	switch (port) {
+	case SCI_USB0:
+		*txpin = 201;
+		*rxpin = 202;
+		break;
+	case SCI_SCI0P2x:
+		*txpin = 1;
+		*rxpin = 2;
+		break;
+	case SCI_SCI2B:
+		*txpin = 1;
+		*rxpin = 2;
+		break;
+	case SCI_SCI6B:
+		*txpin = 1;
+		*rxpin = 2;
+		break;
+	case SCI_SCI2A:
+		*txpin = 1;
+		*rxpin = 2;
+		break;
+	default:
+		*txpin = 0;
+		*rxpin = 0;
+		return false;
+	}
+
+	return true;
+}
+
+PinType get_pin_type(PinName pin)
+{
+	struct pin_node *ret = &pin_list;
+
+	while (ret != NULL) {
+		if (ret->pin == pin) {
+			return ret->type;
+		}
+	}
+
+	return pintype_none;
+}
+
+void analogReference(int mode)
+{
+
+}
+
+void setPinModeDac(int pin)
+{
+
+}
+
+void tone(int pin, int frequency, int duration)
+{
+
+}
+
+void noTone(int pin)
+{
+
+}
+
+int serial_write(serial_t *serial, const unsigned char *buf, int len)
+{
+	const char *c = (const char *)buf;
+
+	for (int i = 0; i < len; i++) {
+		serial_putc(serial, c[i]);
+	}
+
+	return len;
+}
+
+int serial_print(serial_t *serial, const char *str)
+{
+	int i;
+
+	for (i = 0; ; i++) {
+		char c = str[i];
+		if (c == '\0')
+			break;
+
+		serial_putc(serial, c);
+	}
+
+	return i;
+}
+
+int serial_println(serial_t *serial, const char *str)
+{
+	int i;
+
+	for (i = 0; ; i++) {
+		char c = str[i];
+		if (c == '\0')
+			break;
+
+		serial_putc(serial, c);
+	}
+
+	i++;
+	serial_putc(serial, '\r');
+
+	i++;
+	serial_putc(serial, '\n');
+
+	return i;
+}
+
+uint8_t EEPROM_write(int addr, uint8_t data)
+{
+	return 0;
+}
+
+uint8_t EEPROM_read(int addr)
+{
+	return 0xFF;
+}
+
+int EEP_fopen(FILEEEP *fp, const char *str, char mode)
+{
+	FRESULT ret;
+	BYTE fm;
+
+	switch (mode){
+	case 0:
+		fm = FA_READ;
+		break;
+	case 1:
+		fm = FA_READ | FA_WRITE | FA_CREATE_NEW;
+		break;
+	case 2:
+		fm = FA_READ | FA_WRITE;
+		break;
+	default:
+		return -1;
+	}
+
+	ret = f_open(&fp->fp, str, fm);
+
+	return (ret == FR_OK) ? 0 : -1;
+}
+
+int EEP_fwrite(FILEEEP *fp, byte *data, int *len)
+{
+	FRESULT ret;
+
+	ret = f_write(&fp->fp, data, (UINT)*len, (UINT *)len);
+
+	return (ret == FR_OK) ? 1 : -1;
+}
+
+int EEP_fread(FILEEEP *fp)
+{
+	FRESULT ret;
+	char c;
+	UINT br;
+
+	ret = f_read(&fp->fp, &c, 1, &br);
+	if (ret != FR_OK)
+		return -1;
+
+	return c;
+}
+
+void EEP_fclose(FILEEEP *fp)
+{
+	f_close(&fp->fp);
+}
+
+int EEP_fseek(FILEEEP *fp, int pos, int mode)
+{
+	FRESULT ret;
+
+	switch (mode){
+	case EEP_SEEKTOP:
+		ret = f_lseek(&fp->fp, pos);
+		break;
+	case EEP_SEEKCUR:
+		ret = f_lseek(&fp->fp, fp->fp.fptr + pos);
+		break;
+	case EEP_SEEKEND:
+		ret = f_lseek(&fp->fp, fp->fp.fsize - pos);
+		break;
+	default:
+		ret = FR_INVALID_PARAMETER;
+		break;
+	}
+
+	if (ret != FR_OK)
+		f_lseek(&fp->fp, 0);
+
+	return fp->fp.fptr;
+}
+
+int EEP_ffilesize(const char *str)
+{
+	FRESULT ret;
+	FILINFO fno;
+
+	ret = f_stat(str, &fno);
+	if (ret != FR_OK)
+		return 0;
+
+	return fno.fsize;
+}
+
+bool EEP_fEof(FILEEEP *fp)
+{
+	return f_tell(&fp->fp) == f_size(&fp->fp);
+}
+
+bool EEP_fexist(const char *path)
+{
+	FRESULT ret;
+	FILINFO fno;
+
+	ret = f_stat(path, &fno);
+
+	return (ret == FR_OK);
+}
+
+bool EEP_fcopy(const char *src, const char *dst)
+{
+	FIL fsrc, fdst;
+	BYTE buffer[512];
+	FRESULT res;
+	UINT br, bw;
+
+	res = f_open(&fsrc, src, FA_OPEN_EXISTING | FA_READ);
+	if (res != FR_OK)
+		return false;
+
+	res = f_open(&fdst, dst, FA_CREATE_ALWAYS | FA_WRITE);
+	if (res != FR_OK){
+		f_close(&fsrc);
+		return false;
+	}
+
+	for (;;) {
+		res = f_read(&fsrc, buffer, sizeof(buffer), &br);
+		if ((res != FR_OK) || br == 0)
+			break;
+
+		res = f_write(&fdst, buffer, br, &bw);
+		if ((res != FR_OK) || bw < br)
+			break;
+	}
+
+	f_close(&fsrc);
+	f_close(&fdst);
+
+	return (res == FR_OK);
+}
+
+bool EEP_fdelete(const char *path)
+{
+	FRESULT res;
+
+	res = f_unlink(path);
+
+	return (res == FR_OK);
+}
+
+bool SD_begin()
+{
+	DSTATUS dst;
+	FRESULT res;
+	BYTE pdrv = 1, type;
+
+	if (Sd.FatFs.fs_type != 0)
+		return true;
+
+	if ((dst = disk_initialize(pdrv)) != RES_OK) {
+		return false;
+	}
+
+	if ((dst = disk_ioctl(pdrv, MMC_GET_TYPE, &type)) != RES_OK) {
+		Sd.dst = dst;
+		Sd.type = 0;
+	}
+	else {
+		Sd.dst = RES_OK;
+		Sd.type = type;
+	}
+
+	if ((res = f_mount(&Sd.FatFs, "1:", 1)) != FR_OK) {
+		return false;
+	}
+
+	return true;
+}
+
+bool SD_open(File *file, const char *path, int mode)
+{
+	FRESULT ret;
+
+	if (!SD_begin())
+		return false;
+
+	ret = f_open(&file->fp, path, mode);
+
+	return ret == FR_OK;
+}
+
+bool SD_rmdir(const char *path)
+{
+	FRESULT ret;
+
+	if (!SD_begin())
+		return false;
+
+	ret = f_unlink(path);
+
+	return ret == FR_OK;
+}
+
+bool SD_rename(const char *path1, const char *path2)
+{
+	FRESULT ret;
+
+	if (!SD_begin())
+		return false;
+
+	ret = f_rename(path1, path2);
+	
+	return ret == FR_OK;
+}
+
+bool SD_remove(const char *path)
+{
+	FRESULT ret;
+
+	if (!SD_begin())
+		return false;
+
+	ret = f_unlink(path);
+
+	return ret == FR_OK;
+}
+
+bool SD_exists(const char *path)
+{
+	FRESULT ret;
+	FILINFO fno;
+
+	if (!SD_begin())
+		return false;
+
+	ret = f_stat(path, &fno);
+
+	return ret == FR_OK;
+}
+
+bool SD_mkdir(const char *path)
+{
+	FRESULT ret;
+
+	if (!SD_begin())
+		return false;
+
+	ret = f_mkdir(path);
+
+	return ret == FR_OK;
+}
+
+int file_write(File *fd, unsigned char *str, int len)
+{
+	FRESULT ret;
+	UINT bw;
+
+	ret = f_write(&fd->fp, str, len, &bw);
+	if (ret != FR_OK)
+		return -1;
+
+	return bw;
+}
+
+void file_close(File *fd)
+{
+	f_close(&fd->fp);
+}
+
+int file_size(File *fd)
+{
+	return f_size(&fd->fp);
+}
+
+int file_position(File *fd)
+{
+	return fd->fp.fptr;
+}
+
+void file_flush(File *fd)
+{
+	f_flush(&fd->fp);
+}
+
+bool file_seek(File *fd, int pos)
+{
+	FRESULT ret;
+
+	ret = f_lseek(&fd->fp, pos);
+
+	return ret != FR_OK;
+}
+
+int file_read(File *fd)
+{
+	FRESULT ret;
+	char c;
+	UINT br;
+
+	ret = f_read(&fd->fp, &c, 1, &br);
+	if (ret != FR_OK)
+		return -1;
+
+	return c;
+}
+
+void system_reboot(int mode)
+{
+
+}
+
+int fileloader(const char *progVer, const char *binVer)
+{
+	return 0;
+}
+
+DWORD get_fattime(void)
+{
+	time_t temp;
+	struct tm _tm;
+
+	time(&temp);
+	gmtime_r(&temp, &_tm);
+
+	return	  ((DWORD)(_tm.tm_year - 1980) << 25)
+		| ((DWORD)_tm.tm_mon << 21)
+		| ((DWORD)_tm.tm_mday << 16)
+		| ((DWORD)_tm.tm_hour << 11)
+		| ((DWORD)_tm.tm_min << 5)
+		| ((DWORD)_tm.tm_sec >> 1);
+}
+
+void mrb_gr_peach_gem_init(mrb_state *mrb)
+{
+}
+
+void mrb_gr_peach_gem_final(mrb_state *mrb)
+{
+
+}
Index: EcnlProtoTool/trunk/prototool/src/arduino.h
===================================================================
--- EcnlProtoTool/trunk/prototool/src/arduino.h	(revision 278)
+++ EcnlProtoTool/trunk/prototool/src/arduino.h	(revision 278)
@@ -0,0 +1,182 @@
+/*
+ *
+ */
+#ifndef _ARDUINO_H_
+#define _ARDUINO_H_
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <analogin_api.h>
+#include <analogout_api.h>
+#include <buffer.h>
+#include <can_api.h>
+#include <dma_api.h>
+#include <ethernet_api.h>
+#include <gpio_api.h>
+#include <gpio_irq_api.h>
+#include <i2c_api.h>
+#include <lp_ticker_api.h>
+#include <pinmap.h>
+#include <port_api.h>
+#include <pwmout_api.h>
+#include <rtc_api.h>
+#include <serial_api.h>
+#include <sleep_api.h>
+#include <spi_api.h>
+#include <ticker_api.h>
+#include <us_ticker_api.h>
+#include <wait_api.h>
+#include "diskio.h"
+#include "ff.h"
+
+#ifndef bool
+#define bool int
+#endif
+#ifndef true
+#define true 1
+#endif
+#ifndef false
+#define false 0
+#endif
+
+typedef unsigned char byte;
+
+void arduino_init(void);
+
+typedef enum pintype_e {
+	pintype_none,
+	pintype_gpio,
+	pintype_dac,
+	pintype_pwmout,
+	pintype_analogin,
+} PinType;
+
+struct pin_node {
+	struct pin_node *next;
+	PinName pin;
+	PinType type;
+	union {
+		gpio_t gpio;
+#if DEVICE_ANALOGOUT
+		dac_t dac;
+#endif
+		pwmout_t pwmout;
+		analogin_t analogin;
+	};
+	uint32_t period;
+	uint32_t pulsewidth;
+	int min;
+	int max;
+};
+
+struct pin_node *get_pin(PinType type, PinName pinno);
+PinType get_pin_type(PinName pin);
+
+#define DEFAULT 0
+#define INTERNAL 1
+#define EXTERNAL 2
+#define RAW12BIT 3
+
+void analogReference(int type);
+void setPinModeDac(int pin);
+void tone(int pin, int frequency, int duration);
+void noTone(int pin);
+void randomSeed(long seed);
+long arduino_random(long min, long max);
+
+typedef enum sci_port {
+	SCI_USB0,
+	SCI_SCI0P2x,
+	SCI_SCI2B,
+	SCI_SCI6B,
+	SCI_SCI2A,
+} SCI_PORT;
+
+bool portToPins(SCI_PORT port, PinName *txpin, PinName *rxpin);
+
+extern serial_t *Serial;
+extern serial_t *Serial1;	/*1:Serial1*/
+extern serial_t *Serial2;	/*2:Serial3*/
+extern serial_t *Serial3;	/*3:Serial2*/
+extern serial_t *Serial4;	/*4:Serial6*/
+extern serial_t *Serial5;	/*5:Serial7*/
+
+int serial_write(serial_t *serial, const unsigned char *c, int len);
+int serial_print(serial_t *serial, const char *c);
+int serial_println(serial_t *serial, const char *c);
+
+extern i2c_t Wire1;
+extern i2c_t Wire2;
+extern i2c_t Wire3;
+extern i2c_t Wire4;
+extern i2c_t Wire5;
+
+typedef struct File {
+	FIL fp;
+} File;
+
+#define FILE_READ 0x01
+#define FILE_WRITE 0x02
+
+int file_write(File *fd, unsigned char *str, int len);
+void file_close(File *fd);
+int file_size(File *fd);
+int file_position(File *fd);
+void file_flush(File *fd);
+bool file_seek(File *fd, int pos);
+int file_read(File *fd);
+
+typedef struct SD {
+	DSTATUS dst;
+	BYTE type;
+	FATFS FatFs;
+} SD;
+
+extern SD Sd;
+
+bool SD_begin();
+bool SD_open(File *file, const char *path, int mode);
+bool SD_rmdir(const char *path);
+bool SD_rename(const char *path1, const char *path2);
+bool SD_remove(const char *path);
+bool SD_exists(const char *path);
+bool SD_mkdir(const char *path);
+
+typedef struct FILEEEP {
+	FIL fp;
+} FILEEEP;
+
+int EEP_fopen(FILEEEP *fp, const char *str, char mode);
+int EEP_fwrite(FILEEEP *fp, byte *data, int *len);
+int EEP_fread(FILEEEP *fp);
+void EEP_fclose(FILEEEP *fp);
+int EEP_fseek(FILEEEP *fp, int pos, int mode);
+int EEP_ffilesize(const char *str);
+bool EEP_fEof(FILEEEP *fp);
+int EEP_fexist(const char *path);
+int EEP_fcopy(const char *src, const char *dst);
+int EEP_fdelete(const char *path);
+
+#define EEP_SEEKTOP 1
+#define EEP_SEEKCUR 2
+#define EEP_SEEKEND 3
+
+#define EEP_READ 0x01
+#define EEP_WRITE 0x02
+#define EEP_APPEND 0x4
+
+uint8_t EEPROM_write(int addr, uint8_t data);
+uint8_t EEPROM_read(int addr);
+
+#define REBOOT_USERAPP 1
+void system_reboot(int mode);
+int fileloader(const char *progVer, const char *binVer);
+
+extern volatile char ProgVer[];
+extern char RubyFilename[64];
+extern char ExeFilename[64];
+
+#endif /* _ARDUINO_H_ */
