Commits

Anonymous committed 8e11751

Fixes issue 230
- Resurrected the mbed port for v10.

Comments (0)

Files changed (20)

src/platform/_unmaintained/mbed/Makefile

-# Hey Emacs, this is a -*- makefile -*-
-#
-# WinARM template makefile 
-# by Martin Thomas, Kaiserslautern, Germany 
-# <eversmith@heizung-thomas.de>
-#
-# based on the WinAVR makefile written by Eric B. Weddington, Jörg Wunsch, et al.
-# Released to the Public Domain
-# Please read the make user manual!
-#
-#
-# On command line:
-#
-# make all = Make software.
-#
-# make clean = Clean out built project files.
-#
-# make program = Download the hex file to the device
-#
-# (TODO: make filename.s = Just compile filename.c into the assembler code only)
-#
-# To rebuild project do "make clean" then "make all".
-#
-# Changelog:
-# - 17. Feb. 2005  - added thumb-interwork support (mth)
-# - 28. Apr. 2005  - added C++ support (mth)
-# - 29. Arp. 2005  - changed handling for lst-Filename (mth)
-# -  1. Nov. 2005  - exception-vector placement options (mth)
-# - 15. Nov. 2005  - added library-search-path (EXTRA_LIB...) (mth)
-# -  2. Dec. 2005  - fixed ihex and binary file extensions (mth)
-# - 22. Feb. 2006  - added AT91LIBNOWARN setting (mth)
-# - 19. Apr. 2006  - option FLASH_TOOL (default lpc21isp); variable IMGEXT (mth)
-# - 23. Jun. 2006  - option USE_THUMB_MODE -> THUMB/THUMB_IW
-# -  3. Aug. 2006  - added -ffunction-sections -fdata-sections to CFLAGS
-#                    and --gc-sections to LDFLAGS. Only available for gcc 4 (mth)
-# -  4. Aug. 2006  - pass SUBMDL-define to frontend (mth)
-# - 11. Nov. 2006  - FLASH_TOOL-config, TCHAIN-config (mth)
-# - 28. Mar. 2007  - remove .dep-Directory with rm -r -f and force "no error"
-# - 24. Aprl 2007  - added "both" option for format (.bin and .hex)
-
-# PyMite Configuration
-PLATFORM := $(notdir $(CURDIR))
-PM_LIB_ROOT = pmvm_$(PLATFORM)
-PM_LIB_FN = lib$(PM_LIB_ROOT).a
-PM_LIB_PATH = ../../vm/$(PM_LIB_FN)
-PM_USR_SOURCES = main.py mbed.py
-PMIMGCREATOR := ../../tools/pmImgCreator.py
-PMGENPMFEATURES := ../../tools/pmGenPmFeatures.py
-IPM := true
-
-# Toolchain prefix (i.e arm-elf -> arm-elf-gcc.exe)
-TCHAIN = arm-elf
-#TCHAIN = arm-none-eabi
-
-#FLASH_TOOL = UVISION
-#FLASH_TOOL = OPENOCD
-
-USE_THUMB_MODE = YES
-#USE_THUMB_MODE = NO
-
-# MCU name and submodel
-MCU      = arm7tdmi-s
-SUBMDL   = LPC2368
-
-## not supported in this example:
-## Create ROM-Image (final)
-RUN_MODE=ROM_RUN
-## Create RAM-Image (debugging) - not used in this example
-#RUN_MODE=RAM_RUN
-
-## not supported in this example:
-## Exception-Vector placement only supported for "ROM_RUN"
-## (placement settings ignored when using "RAM_RUN")
-## - Exception vectors in ROM:
-#VECTOR_LOCATION=VECTORS_IN_ROM
-## - Exception vectors in RAM:
-#VECTOR_LOCATION=VECTORS_IN_RAM
-
-
-# Target file name (without extension).
-TARGET = main
-
-# List C source files here. (C dependencies are automatically generated.)
-# use file-extension c for "c-only"-files
-SRC = $(TARGET)_nat.c $(TARGET)_img.c
-
-# List C source files here which must be compiled in ARM-Mode.
-# use file-extension c for "c-only"-files
-SRCARM = 
-
-# List C++ source files here.
-# use file-extension cpp for C++-files (use extension .cpp)
-CPPSRC = $(TARGET).cpp plat.cpp
-
-# List C++ source files here which must be compiled in ARM-Mode.
-# use file-extension cpp for C++-files (use extension .cpp)
-#CPPSRCARM = $(TARGET).cpp
-CPPSRCARM = 
-
-# List Assembler source files here.
-# Make them always end in a capital .S.  Files ending in a lowercase .s
-# will not be considered source files but generated files (assembler
-# output from the compiler), and will be deleted upon "make clean"!
-# Even though the DOS/Win* filesystem matches both .s and .S the same,
-# it will preserve the spelling of the filenames, and gcc itself does
-# care about how the name is spelled on its command-line.
-ASRC = 
-
-# List Assembler source files here which must be assembled in ARM-Mode..
-ASRCARM = 
-
-# Path to Linker-Scripts
-LINKERSCRIPTPATH = 
-
-## Output format. (can be ihex or binary or both)
-## (binary i.e. for openocd and SAM-BA, hex i.e. for lpc21isp and uVision)
-#FORMAT = ihex
-FORMAT = binary
-
-# Optimization level, can be [0, 1, 2, 3, s]. 
-# 0 = turn off optimization. s = optimize for size.
-# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
-OPT = s
-#OPT = 0
-
-## Using the Atmel AT91_lib produces warning with
-## the default warning-levels. 
-## yes - disable these warnings; no - keep default settings
-#AT91LIBNOWARN = yes
-AT91LIBNOWARN = no
-
-# Debugging format.
-# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
-# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
-#DEBUG = stabs
-DEBUG_FMT = dwarf-2
-
-# List any extra directories to look for include files here.
-#     Each directory must be seperated by a space.
-EXTRAINCDIRS = ../../vm
-
-# List any extra directories to look for library files here.
-#     Each directory must be seperated by a space.
-#EXTRA_LIBDIRS = ../arm7_efsl_0_2_4
-EXTRA_LIBDIRS = . ../../vm
-
-
-# Compiler flag to set the C Standard level.
-# c89   - "ANSI" C
-# gnu89 - c89 plus GCC extensions
-# c99   - ISO C99 standard (not yet fully implemented)
-# gnu99 - c99 plus GCC extensions
-CSTANDARD = -std=gnu99
-
-# Place -D or -U options for C here
-CDEFS =  -D$(RUN_MODE)
-# PyMite CDEFS
-ifeq ($(DEBUG),true)
-	CDEFS += -g -g$(DEBUG_FMT) -D__DEBUG__=1
-endif
-
-# Place -I options here
-CINCS = -I$(abspath .)
-
-# Place -D or -U options for ASM here
-ADEFS =  -D$(RUN_MODE)
-
-ifdef VECTOR_LOCATION
-CDEFS += -D$(VECTOR_LOCATION)
-ADEFS += -D$(VECTOR_LOCATION)
-endif
-
-CDEFS += -D__WinARM__ -D__WINARMSUBMDL_$(SUBMDL)__
-ADEFS += -D__WinARM__ -D__WINARMSUBMDL_$(SUBMDL)__
-
-# Compiler flags.
-
-ifeq ($(USE_THUMB_MODE),YES)
-THUMB    = -mthumb
-#THUMB_IW = -mthumb-interwork
-THUMB_IW = 
-else 
-THUMB    = 
-THUMB_IW = 
-endif
-
-#  -g*:          generate debugging information
-#  -O*:          optimization level
-#  -f...:        tuning, see GCC manual and avr-libc documentation
-#  -Wall...:     warning level
-#  -Wa,...:      tell GCC to pass this to the assembler.
-#    -adhlns...: create assembler listing
-#
-# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
-CFLAGS = $(CDEFS) $(CINCS)
-CFLAGS += -O$(OPT)
-#CFLAGS += -Wcast-align 
-CFLAGS += -Wall -Wimplicit 
-CFLAGS += -Wpointer-arith -Wswitch
-CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow -Wunused
-CFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<) 
-CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
-
-# flags only for C
-CONLYFLAGS += -Wnested-externs 
-CONLYFLAGS += $(CSTANDARD)
-
-ifneq ($(AT91LIBNOWARN),yes)
-#AT91-lib warnings with:
-CFLAGS += -Wcast-qual
-CONLYFLAGS += -Wmissing-prototypes 
-CONLYFLAGS += -Wstrict-prototypes
-CONLYFLAGS += -Wmissing-declarations
-endif
-
-# flags only for C++ (arm-elf-g++)
-# CPPFLAGS = -fno-rtti -fno-exceptions
-CPPFLAGS = 
-
-# Assembler flags.
-#  -Wa,...:    tell GCC to pass this to the assembler.
-#  -ahlns:     create listing
-#  -g$(DEBUG): have the assembler create line number information
-ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:.S=.lst),--g$(DEBUG_FMT)
-
-
-#Additional libraries.
-
-# Extra libraries
-#    Each library-name must be seperated by a space.
-#    To add libxyz.a, libabc.a and libefsl.a: 
-#    EXTRA_LIBS = xyz abc efsl
-#EXTRA_LIBS = efsl
-EXTRA_LIBS = $(PM_LIB_ROOT) mbed
-
-#Support for newlibc-lpc (file: libnewlibc-lpc.a)
-#NEWLIBLPC = -lnewlib-lpc
-
-MATH_LIB = -lm
-
-# CPLUSPLUS_LIB = -lstdc++
-
-
-# Linker flags.
-#  -Wl,...:     tell GCC to pass this to linker.
-#    -Map:      create map file
-#    --cref:    add cross reference to  map file
-LDFLAGS = -nostartfiles -Wl,-Map=$(TARGET).map,--cref,--gc-sections
-LDFLAGS += -lc
-LDFLAGS += $(NEWLIBLPC) $(MATH_LIB)
-LDFLAGS += -lc -lgcc 
-LDFLAGS += $(CPLUSPLUS_LIB)
-LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS))
-LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS))
-
-# Set Linker-Script Depending On Selected Memory and Controller
-ifeq ($(RUN_MODE),RAM_RUN)
-LDFLAGS +=-T$(LINKERSCRIPTPATH)/$(SUBMDL)-RAM.ld
-else 
-LDFLAGS +=-T$(LINKERSCRIPTPATH)/$(SUBMDL)-ROM.ld
-endif
-
-# ---------------------------------------------------------------------------
-# Flash-Programming support using lpc21isp by Martin Maurer 
-# only for Philips LPC and Analog ADuC ARMs
-#
-# Settings and variables:
-#LPC21ISP = lpc21isp
-LPC21ISP = lpc21isp
-LPC21ISP_PORT = com1
-LPC21ISP_BAUD = 38400
-LPC21ISP_XTAL = 12000
-# other options:
-# * verbose output: -debug
-# * enter bootloader via RS232 DTR/RTS (only if hardware supports this
-#   feature - see Philips AppNote): -control
-LPC21ISP_OPTIONS = -control
-#LPC21ISP_OPTIONS += -debug
-# ---------------------------------------------------------------------------
-
-
-# Define directories, if needed.
-## DIRARM = c:/WinARM/
-## DIRARMBIN = $(DIRAVR)/bin/
-## DIRAVRUTILS = $(DIRAVR)/utils/bin/
-
-# Define programs and commands.
-SHELL = sh
-CC = $(TCHAIN)-gcc
-CPP = $(TCHAIN)-g++
-AR = $(TCHAIN)-ar
-OBJCOPY = $(TCHAIN)-objcopy
-OBJDUMP = $(TCHAIN)-objdump
-SIZE = $(TCHAIN)-size
-NM = $(TCHAIN)-nm
-AR = $(TCHAIN)-ar
-REMOVE = rm -f
-REMOVEDIR = rm -f -r
-COPY = cp
-
-# Define Messages
-# English
-MSG_ERRORS_NONE = Errors: none
-MSG_BEGIN = "-------- begin (mode: $(RUN_MODE)) --------"
-MSG_END = --------  end  --------
-MSG_SIZE_BEFORE = Size before: 
-MSG_SIZE_AFTER = Size after:
-MSG_FLASH = Creating load file for Flash:
-MSG_EXTENDED_LISTING = Creating Extended Listing:
-MSG_SYMBOL_TABLE = Creating Symbol Table:
-MSG_LINKING = Linking:
-MSG_COMPILING = Compiling C:
-MSG_COMPILING_ARM = "Compiling C (ARM-only):"
-MSG_COMPILINGCPP = Compiling C++:
-MSG_COMPILINGCPP_ARM = "Compiling C++ (ARM-only):"
-MSG_ASSEMBLING = Assembling:
-MSG_ASSEMBLING_ARM = "Assembling (ARM-only):"
-MSG_CLEANING = Cleaning project:
-MSG_FORMATERROR = Can not handle output-format
-MSG_LPC21_RESETREMINDER = You may have to bring the target in bootloader-mode now.
-
-# Define all object files.
-COBJ      = $(SRC:.c=.o) 
-AOBJ      = $(ASRC:.S=.o)
-COBJARM   = $(SRCARM:.c=.o)
-AOBJARM   = $(ASRCARM:.S=.o)
-CPPOBJ    = $(CPPSRC:.cpp=.o) 
-CPPOBJARM = $(CPPSRCARM:.cpp=.o)
-
-# Define all listing files.
-LST = $(ASRC:.S=.lst) $(ASRCARM:.S=.lst) $(SRC:.c=.lst) $(SRCARM:.c=.lst)
-LST += $(CPPSRC:.cpp=.lst) $(CPPSRCARM:.cpp=.lst)
-
-# Compiler flags to generate dependency files.
-### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
-#GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
-
-# Combine all necessary flags and optional flags.
-# Add target processor to flags.
-ALL_CFLAGS  = -mcpu=$(MCU) $(THUMB) $(THUMB_IW) -I. $(CFLAGS) $(GENDEPFLAGS)
-ALL_ASFLAGS = -mcpu=$(MCU) $(THUMB) $(THUMB_IW) -I. -x assembler-with-cpp $(ASFLAGS)
-
-
-# Default target.
-#all: begin gccversion pmvm sizebefore build sizeafter finished end
-all: pmfeatures.h zip
-
-ifeq ($(FORMAT),ihex)
-build: elf hex bin lss sym
-hex: $(TARGET).hex
-IMGEXT=hex
-else 
-ifeq ($(FORMAT),binary)
-build: elf bin lss sym
-bin: $(TARGET).bin
-IMGEXT=bin
-else 
-ifeq ($(FORMAT),both)
-build: elf hex bin lss sym
-hex: $(TARGET).hex
-bin: $(TARGET).bin
-else 
-$(error "$(MSG_FORMATERROR) $(FORMAT)")
-endif
-endif
-endif
-
-elf: $(TARGET).elf
-lss: $(TARGET).lss 
-sym: $(TARGET).sym
-
-pmfeatures.h : pmfeatures.py $(PMGENPMFEATURES)
-	$(PMGENPMFEATURES) pmfeatures.py > $@
-
-# PyMite: Build the VM archive if it doesn't exist
-pmvm : $(PM_LIB_PATH)
-
-$(PM_LIB_PATH) :
-	make -C ../../vm
-
-# Eye candy.
-begin:
-	@echo
-	@echo $(MSG_BEGIN)
-
-finished:
-	@echo $(MSG_ERRORS_NONE)
-
-end:
-	@echo $(MSG_END)
-	@echo
-
-
-# Display size of file.
-HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
-ELFSIZE = $(SIZE) -A $(TARGET).elf
-sizebefore:
-	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
-
-sizeafter:
-	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
-
-
-# Display compiler version information.
-gccversion : 
-	@$(CC) --version
-
-# Program the device.
-ifeq ($(FLASH_TOOL),UVISION)
-# Program the device with Keil's uVision (needs configured uVision-Workspace). 
-program: $(TARGET).hex
-	@echo
-	@echo "Programming with uVision"
-#	C:\Keil\uv3\Uv3.exe -f uvisionflash.Uv2 -ouvisionflash.txt
-	$(REMOVE) ../Common_WinARM/$(TARGET).hex
-	$(COPY) $(TARGET).hex ../Common_WinARM/
-	C:\Keil\uv3\Uv3.exe -f ..\Common_WinARM\uvisionflash.Uv2
-else
-ifeq ($(FLASH_TOOL),OPENOCD)
-# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script".
-program: $(TARGET).bin
-	@echo
-	@echo "Programming with OPENOCD"
-	openocd_start_flash.cmd
-#OOCD_load_image=$(TARGET).bin
-#include oocd_flashing.mk
-#program : $(TARGET).bin oocd_programprepare oocd_programdoit
-#program : $(TARGET).bin oocd_programdoit
-else
-# Program the device.  - lpc21isp will not work for SAM7
-program: $(TARGET).hex
-	@echo
-	@echo $(MSG_LPC21_RESETREMINDER)
-	$(LPC21ISP) $(LPC21ISP_OPTIONS) $(LPC21ISP_FLASHFILE) $(LPC21ISP_PORT) $(LPC21ISP_BAUD) $(LPC21ISP_XTAL)
-endif
-endif
-
-
-# Create final output file (.hex) from ELF output file.
-%.hex: %.elf
-	@echo
-	@echo $(MSG_FLASH) $@
-	$(OBJCOPY) -O ihex $< $@
-	
-# Create final output file (.bin) from ELF output file.
-%.bin: %.elf
-	@echo
-	@echo $(MSG_FLASH) $@
-	$(OBJCOPY) -O binary $< $@
-
-
-# Create extended listing file from ELF output file.
-# testing: option -C
-%.lss: %.elf
-	@echo
-	@echo $(MSG_EXTENDED_LISTING) $@
-	$(OBJDUMP) -h -S -C $< > $@
-
-
-# Create a symbol table from ELF output file.
-%.sym: %.elf
-	@echo
-	@echo $(MSG_SYMBOL_TABLE) $@
-	$(NM) -n $< > $@
-
-
-# Link: create ELF output file from object files.
-.SECONDARY : $(TARGET).elf
-.PRECIOUS : $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)
-%.elf:  $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)
-	@echo
-	@echo $(MSG_LINKING) $@
-	$(CC) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)
-#	$(CPP) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)
-
-# Compile: create object files from C source files. ARM/Thumb
-$(COBJ) : %.o : %.c
-	@echo
-	@echo $(MSG_COMPILING) $<
-	$(CC) -c $(THUMB) $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@ 
-
-# Compile: create object files from C source files. ARM-only
-$(COBJARM) : %.o : %.c
-	@echo
-	@echo $(MSG_COMPILING_ARM) $<
-	$(CC) -c $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@ 
-
-# Compile: create object files from C++ source files. ARM/Thumb
-$(CPPOBJ) : %.o : %.cpp
-	@echo
-	@echo $(MSG_COMPILINGCPP) $<
-	$(CPP) -c $(THUMB) $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@ 
-
-# Compile: create object files from C++ source files. ARM-only
-$(CPPOBJARM) : %.o : %.cpp
-	@echo
-	@echo $(MSG_COMPILINGCPP_ARM) $<
-	$(CPP) -c $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@ 
-
-
-# Compile: create assembler files from C source files. ARM/Thumb
-## does not work - TODO - hints welcome
-##$(COBJ) : %.s : %.c
-##	$(CC) $(THUMB) -S $(ALL_CFLAGS) $< -o $@
-
-
-# Assemble: create object files from assembler source files. ARM/Thumb
-$(AOBJ) : %.o : %.S
-	@echo
-	@echo $(MSG_ASSEMBLING) $<
-	$(CC) -c $(THUMB) $(ALL_ASFLAGS) $< -o $@
-
-
-# Assemble: create object files from assembler source files. ARM-only
-$(AOBJARM) : %.o : %.S
-	@echo
-	@echo $(MSG_ASSEMBLING_ARM) $<
-	$(CC) -c $(ALL_ASFLAGS) $< -o $@
-
-
-# PyMite: Generate native code and module images from the python source
-$(TARGET)_nat.c $(TARGET)_img.c : $(PM_USR_SOURCES) pmfeatures.py
-	$(PMIMGCREATOR) -f pmfeatures.py -c -u -o $(TARGET)_img.c --native-file=$(TARGET)_nat.c $(PM_USR_SOURCES)
-
-../../vm/pmstdlib_img.c ../../vm/pmstdlib_nat.c : 
-	$(MAKE) -C ../../vm pmstdlib_img.c pmstdlib_nat.c
-
-zip: pymite_mbed.zip
-
-pymite_mbed.zip: $(TARGET)_nat.c $(TARGET)_img.c ../../vm/pmstdlib_img.c ../../vm/pmstdlib_nat.c pmfeatures.py
-	$(RM) $@
-	cd ../../.. && zip src/platform/mbed/$@ src/vm/*.c src/vm/*.h src/platform/mbed/* -x src/platform/mbed/Makefile -x src/platform/mbed/README -x src/platform/mbed/*.py -x src/platform/mbed/*.zip -x src/platform/mbed/main_nat.patch
-
-
-# Target: clean project.
-clean: begin clean_list finished end
-
-
-clean_list :
-	$(MAKE) -C ../../vm clean
-	@echo
-	@echo $(MSG_CLEANING)
-	$(REMOVE) $(TARGET).hex
-	$(REMOVE) $(TARGET).bin
-	$(REMOVE) $(TARGET).obj
-	$(REMOVE) $(TARGET).elf
-	$(REMOVE) $(TARGET).map
-	$(REMOVE) $(TARGET).obj
-	$(REMOVE) $(TARGET).a90
-	$(REMOVE) $(TARGET).sym
-	$(REMOVE) $(TARGET).lnk
-	$(REMOVE) $(TARGET).lss
-	$(REMOVE) $(COBJ)
-	$(REMOVE) $(CPPOBJ)
-	$(REMOVE) $(AOBJ)
-	$(REMOVE) $(COBJARM)
-	$(REMOVE) $(CPPOBJARM)
-	$(REMOVE) $(AOBJARM)
-	$(REMOVE) $(LST)
-	$(REMOVE) $(SRC:.c=.s)
-	$(REMOVE) $(SRC:.c=.d)
-	$(REMOVE) $(SRCARM:.c=.s)
-	$(REMOVE) $(SRCARM:.c=.d)
-	$(REMOVE) $(CPPSRC:.cpp=.s) 
-	$(REMOVE) $(CPPSRC:.cpp=.d)
-	$(REMOVE) $(CPPSRCARM:.cpp=.s) 
-	$(REMOVE) $(CPPSRCARM:.cpp=.d)
-	$(REMOVE) $(TARGET)_img.c
-	$(REMOVE) $(TARGET)_nat.c
-	$(REMOVE) pymite_mbed.zip
-	$(REMOVE) pmfeatures.h
-	$(REMOVEDIR) .dep | exit 0
-
-
-# Include the dependency files.
--include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
-
-
-# Listing of phony targets.
-.PHONY : all begin finish end sizebefore sizeafter gccversion \
-build elf hex bin lss sym clean clean_list program pmvm zip
-
-
-export CC OBJCOPY NM CFLAGS ALL_CFLAGS AR IPM PM_LIB_FN

src/platform/_unmaintained/mbed/README

-=========================
-The Mbed Platform Project
-=========================
-
-
-:Author:    Dean Hall
-:Id:        $Id$
-
-
-Purpose
--------
-
-This is a port of Python-on-a-Chip to the Mbed-002_ board, which features
-the NXP LPC2368_ microcontroller.  In addition to running the PyMite VM
-in interactive mode (ipm), a subset of the mbed API is made available to the
-Python programmer.
-
-The current mbed board that is available to the public is based on an
-NXP LPC1768_, so there may be some differences.  The PyMite VM has not been
-ported to the newer mbed board yet, but it shouldn't be a difficult process.
-
-.. _`Mbed-002`: http://mbed.org
-.. _`LPC2368`: http://ics.nxp.com/products/lpc2000/lpc23xx/
-.. _`LPC1768`: http://www.nxp.com/#/pip/pip=[pip=LPC1768_66_65_64_2]|pp=[t=pip,i=LPC1768_66_65_64_2]
-
-
-Building the Project
---------------------
-
-At the time of this writing, building for the mbed platform on your local
-computer is not yet supported.  If you are interested in building for the mbed
-on your local computer, please monitor `Issue #22`_.  Instead, you must perform
-the build using the mbed's `on-line compiler`_.  The Makefile in this directory
-has a **zip** target to assist in this process.  Step-by-step directions to
-build for the mbed are given below.
-
-.. _`Issue #22`: http://code.google.com/p/python-on-a-chip/issues/detail?id=22
-.. _`on-line compiler`: http://mbed.org/compiler
-
-The directions below assume the following:
-
-- Python 2.5 or 2.6 installed.
-- PySerial module installed (``$ easy_install pyserial``).
-- Python-on-a-Chip tree checked-out or unzipped on your HDD
-  (``$ svn co http://python-on-a-chip.googlecode.com/svn/trunk/ pymite``).
-- Mbed device on hand and website account established at http://mbed.org
-
-Building:
-
-#. ``$ cd pymite/src/platform/mbed``
-#. ``$ make zip``
-#. Go to http://mbed.org/compiler
-#. In the left-hand "Program Workspace" panel, right click and select
-   "Import program..."
-#. In the file dialog that pops up, select
-   ``pymite/src/platform/mbed/pymite_mbed.zip``
-#. In the left-hand "Program Workspace" panel, click on the new "pymite_mbed"
-   project.
-#. Click on the "Compile" button; this should compile and download the .bin file
-   to your computer.
-#. Plug the mbed device into your computer's USB port; it should mount as USB
-   mass storage device.
-#. Copy the ``pymite_mbed.bin`` file to the mbed USB mass storage space.
-#. Press the mbed's reset button (it will re-flash itself with the new binary).
-#. Visit the `Cookbook page`_ to see the things that you can do.
-
-.. _`Cookbook page`: http://mbed.org/projects/cookbook/wiki/PyMite
-
-
-.. :mode=rest:

src/platform/_unmaintained/mbed/TextLCD.lib

-http://mbed.co.uk/projects/cookbook/svn/TextLCD/trunk@495

src/platform/_unmaintained/mbed/main.cpp

-/*
-# This file is Copyright 2009 Dean Hall.
-#
-# This file is part of the Python-on-a-Chip program.
-# Python-on-a-Chip is free software: you can redistribute it and/or modify
-# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
-# 
-# Python-on-a-Chip is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
-# is seen in the file COPYING up one directory from this.
-*/
-
-
-#include "pm.h"
-
-
-#ifdef __cplusplus
-extern
-#endif
-
-#define HEAP_SIZE 0x7000
-
-unsigned char const usrlib_img[];
-
-
-int
-main(void)
-{
-    uint8_t heap[HEAP_SIZE];
-    PmReturn_t retval;
-
-    retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img);
-    PM_RETURN_IF_ERROR(retval);
-
-    /* Run the sample program */
-    retval = pm_run((uint8_t *)"main");
-
-    return (int)retval;
-}

src/platform/_unmaintained/mbed/main.py

-# This file is Copyright 2009 Dean Hall.
-#
-# This file is part of the Python-on-a-Chip program.
-# Python-on-a-Chip is free software: you can redistribute it and/or modify
-# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
-# 
-# Python-on-a-Chip is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
-# is seen in the file COPYING up one directory from this.
-
-import ipm
-ipm.ipm(globals())

src/platform/_unmaintained/mbed/mbed.lib

-http://mbed.co.uk/projects/libraries/svn/mbed/trunk@13

src/platform/_unmaintained/mbed/mbed.py

-# This file is Copyright 2009 Dean Hall.
-#
-# This file is part of the Python-on-a-Chip program.
-# Python-on-a-Chip is free software: you can redistribute it and/or modify
-# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
-#
-# Python-on-a-Chip is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
-# is seen in the file COPYING up one directory from this.
-
-
-"""__NATIVE__
-#include "mbed.h"
-#include "TextLCD.h"
-
-static DigitalOut led1(LED1);
-static DigitalOut led2(LED2);
-static DigitalOut led3(LED3);
-static DigitalOut led4(LED4);
-
-/* PinName lookup table.  Converts pin number to PinName. */
-static PinName const pinNumToName[] = {
-    NC, NC, NC, NC, NC, p5, p6, p7, p8, p9,
-    p10, p11, p12, p13, p14, p15, p16, p17, p18, p19,
-    p20, p21, p22, p23, p24, p25, p26, p27, p28, p29,
-    p30
-};
-"""
-
-
-class AnalogIn(object):
-
-    def __init__(self, n):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogIn *adc;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        adc = new AnalogIn(pinNumToName[((pPmInt_t)pn)->val]);
-
-        /* Save the pointer to adc as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)adc, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def read_u16(self,):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogIn *adc;
-        int32_t n;
-
-        /* If wrong number of args, throw type exception */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        adc = (AnalogIn *)((pPmInt_t)pn)->val;
-
-        /* Return input value on the stack */
-        n = adc->read_u16();
-        retval = int_new(n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
-        """
-        pass
-
-
-    def read(self,):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogIn *adc;
-        float n;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        adc = (AnalogIn *)((pPmInt_t)pn)->val;
-
-        /* Return input value on the stack */
-        n = adc->read();
-        retval = float_new(n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
-        """
-        pass
-
-
-class AnalogOut(object):
-
-    def __init__(self, n):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogOut *dac;
-
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the object */
-        dac = new AnalogOut(pinNumToName[((pPmInt_t)pn)->val]);
-
-        /* Save the pointer to adc as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)dac, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def write_u16(self, n):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogOut *dac;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        dac = (AnalogOut *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        dac->write_u16(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def write(self, n):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogOut *dac;
-        float n;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_FLT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        dac = (AnalogOut *)((pPmInt_t)pn)->val;
-
-        /* Saturate and write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        n = ((pPmFloat_t)pn)->val;
-        if (n < 0.0)
-        {
-            n = 0.0;
-        }
-        else if (n > 1.0)
-        {
-            n = 1.0;
-        }
-        dac->write(n);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def read(self,):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogOut *dac;
-        float n;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        dac = (AnalogOut *)((pPmInt_t)pn)->val;
-
-        /* Return output value on the stack */
-        n = dac->read();
-        retval = float_new(n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
-        """
-        pass
-
-
-class DigitalIn(object):
-
-    def __init__(self, n):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        DigitalIn *din;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        din = new DigitalIn(pinNumToName[((pPmInt_t)pn)->val]);
-
-        /* Save the pointer to adc as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)din, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def read(self,):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        DigitalIn *din;
-        int32_t n;
-
-        /* If wrong number of args, throw type exception */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        din = (DigitalIn *)((pPmInt_t)pn)->val;
-
-        /* Return input value on the stack */
-        n = din->read();
-        retval = int_new(n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
-        """
-        pass
-
-
-class DigitalOut(object):
-
-    def __init__(self, n):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        DigitalOut *dout;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        dout = new DigitalOut(pinNumToName[((pPmInt_t)pn)->val]);
-
-        /* Save the pointer to adc as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)dout, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def read(self,):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        DigitalOut *dout;
-        int32_t n;
-
-        /* If wrong number of args, throw type exception */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        dout = (DigitalOut *)((pPmInt_t)pn)->val;
-
-        /* Return input value on the stack */
-        n = dout->read();
-        retval = int_new(n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
-        """
-        pass
-
-
-    def write(self, n):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        DigitalOut *dout;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        dout = (DigitalOut *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        dout->write(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-class PwmOut(object):
-
-    def __init__(self, n):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        PwmOut *pwm;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        pwm = new PwmOut(pinNumToName[((pPmInt_t)pn)->val]);
-
-        /* Save the pointer to pwm as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)pwm, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def read(self,):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        DigitalOut *dout;
-        int32_t n;
-
-        /* If wrong number of args, throw type exception */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        dout = (DigitalOut *)((pPmInt_t)pn)->val;
-
-        /* Return input value on the stack */
-        n = dout->read();
-        retval = int_new(n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
-        """
-        pass
-
-
-    def period(self, t):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        PwmOut *pwm;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        pwm->period(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def period_ms(self, t):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        PwmOut *pwm;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        pwm->period_ms(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def period_us(self, t):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        PwmOut *pwm;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        pwm->period_us(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def pulsewidth(self, n):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        PwmOut *pwm;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        pwm->pulsewidth(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def puslewidth_ms(self, n):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        PwmOut *pwm;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        pwm->pulsewidth_ms(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def pulsewidth_us(self, n):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        PwmOut *pwm;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        pwm->pulsewidth_us(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-class Serial(object):
-
-    def __init__(self, tx, rx):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t ptx;
-        pPmObj_t prx;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        Serial *ser;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 3)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        ptx = NATIVE_GET_LOCAL(1);
-        prx = NATIVE_GET_LOCAL(2);
-        if ((OBJ_GET_TYPE(ptx) != OBJ_TYPE_INT)
-            || (OBJ_GET_TYPE(prx) != OBJ_TYPE_INT))
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        ser = new Serial(pinNumToName[((pPmInt_t)ptx)->val],
-                         pinNumToName[((pPmInt_t)prx)->val]);
-
-        /* Save the pointer to ser as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)ser, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def putc(self, s):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        Serial *ser;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_STR)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        ser = (Serial *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        ser->putc(((pPmString_t)pn)->val[0]);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def puts(self, s):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        Serial *ser;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_STR)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        ser = (Serial *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        ser->puts((const char *)((pPmString_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def getc(self,):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        Serial *ser;
-        int32_t n;
-
-        /* If wrong number of args, throw type exception */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        ser = (Serial *)((pPmInt_t)pn)->val;
-
-        /* Return char (as string) on the stack */
-        n = ser->getc();
-        retval = string_newFromChar((uint8_t)n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
-        """
-        pass
-
-
-class SPI(object):
-
-    def __init__(self, mosi, miso, sclk):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pmosi;
-        pPmObj_t pmiso;
-        pPmObj_t psclk;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        SPI *spi;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 4)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pmosi = NATIVE_GET_LOCAL(1);
-        pmiso = NATIVE_GET_LOCAL(2);
-        psclk = NATIVE_GET_LOCAL(3);
-        if ((OBJ_GET_TYPE(pmosi) != OBJ_TYPE_INT)
-            || (OBJ_GET_TYPE(pmiso) != OBJ_TYPE_INT)
-            || (OBJ_GET_TYPE(psclk) != OBJ_TYPE_INT))
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        spi = new SPI(pinNumToName[((pPmInt_t)pmosi)->val],
-                      pinNumToName[((pPmInt_t)pmiso)->val],
-                      pinNumToName[((pPmInt_t)psclk)->val]);
-
-        /* Save the pointer to ser as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)spi, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def format(self, bits, mode=0):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pbits;
-        pPmObj_t pmode;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        SPI *spi;
-
-        /* Raise TypeError if wrong number of args */
-        if ((NATIVE_GET_NUM_ARGS() < 2) || (NATIVE_GET_NUM_ARGS() > 3))
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pbits = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pbits) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the mode arg if it exists */
-        pmode = PM_ZERO;
-        if (NATIVE_GET_NUM_ARGS() == 3)
-        {
-            pmode = NATIVE_GET_LOCAL(3);
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        spi = (SPI *)((pPmInt_t)pn)->val;
-
-        /* Set format args */
-        spi->format(((pPmInt_t)pbits)->val, ((pPmInt_t)pmode)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def frequency(self, hz):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t phz;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        SPI *spi;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        phz = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(phz) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        spi = (SPI *)((pPmInt_t)pn)->val;
-
-        /* Set frequency */
-        spi->frequency(((pPmInt_t)phz)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def write(self, v):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pv;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        SPI *spi;
-        int32_t r;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pv = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pv) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        spi = (SPI *)((pPmInt_t)pn)->val;
-
-        /* Write the value and return the response */
-        r = spi->write(((pPmInt_t)pv)->val);
-        retval = int_new(r, &pn);
-        NATIVE_SET_TOS(pn);
-        return retval;
-        """
-        pass
-
-
-class I2C(object):
-
-    def __init__(self, sda, scl):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t psda;
-        pPmObj_t pscl;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        I2C *i2c;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 3)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        psda = NATIVE_GET_LOCAL(1);
-        pscl = NATIVE_GET_LOCAL(2);
-        if ((OBJ_GET_TYPE(psda) != OBJ_TYPE_INT)
-            || (OBJ_GET_TYPE(pscl) != OBJ_TYPE_INT))
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        i2c = new I2C(pinNumToName[((pPmInt_t)psda)->val],
-                      pinNumToName[((pPmInt_t)pscl)->val]);
-
-        /* Save the pointer to ser as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)i2c, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def frequency(self, hz):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t phz;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        I2C *i2c;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        phz = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(phz) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        i2c = (I2C *)((pPmInt_t)pn)->val;
-
-        /* Set frequency */
-        i2c->frequency(((pPmInt_t)phz)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        """
-        pass
-
-
-    def read(self, addr, data, length):
-        """__NATIVE__
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t paddr;
-        pPmObj_t pdata;
-        pPmObj_t plen;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        I2C *i2c;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 4)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        paddr = NATIVE_GET_LOCAL(1);
-        pdata = NATIVE_GET_LOCAL(2);
-        plen = NATIVE_GET_LOCAL(3);
-        if ((OBJ_GET_TYPE(paddr) != OBJ_TYPE_INT)
-            || (OBJ_GET_TYPE(pdata) != OBJ_TYPE_STR)
-            || (OBJ_GET_TYPE(plen) != OBJ_TYPE_INT))
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        i2c = (I2C *)((pPmInt_t)pn)->val;
-
-        /* Read the bytes into the string */
-        /* WARNING: Changing the bytes of a string object is BAD. */
-        i2c->read(((pPmInt_t)paddr)->val,
-                  (char *)((pPmString_t)pdata)->val,