python-on-a-chip online compiler

Dependencies:   mbed TSI

/media/uploads/va009039/p14p-f446re.png

more info: python-on-a-chip

platform/mbed/main_nat.cpp

Committer:
va009039
Date:
2013-03-12
Revision:
2:a2bea117e22e
Parent:
1:28afb064a41c
Child:
3:559c4bd38111

File content as of revision 2:a2bea117e22e:

#undef __FILE_ID__
#define __FILE_ID__ 0x0A
/**
 * PyMite usr native function file
 *
 * automatically created by pmImgCreator.py
 * on Tue Mar 12 20:23:40 2013
 *
 * DO NOT EDIT THIS FILE.
 * ANY CHANGES WILL BE LOST.
 *
 * @file    main_nat.cpp
 */

#define __IN_LIBNATIVE_C__
#include "pm.h"

/* From: mbed.py */
#include "mbed.h"
#include "NativeClassInterface.h"

PmReturn_t
nat_placeholder_func(pPmFrame_t *ppframe)
{

    /*
     * Use placeholder because an index 
     * value of zero denotes the stdlib.
     * This function should not be called.
     */
    PmReturn_t retval;
    PM_RAISE(retval, PM_RET_EX_SYS);
    return retval;

}

PmReturn_t
nat_01_mbed___init__(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.init<DigitalOut,PinName>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_02_mbed_write(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<DigitalOut,int,&DigitalOut::write>(OBJ_TYPE_NON, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_03_mbed_read(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<int,DigitalOut,&DigitalOut::read>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_04_mbed___init__(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.init<DigitalIn,PinName>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_05_mbed_read(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<int,DigitalIn,&DigitalIn::read>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_06_mbed___init__(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.init<DigitalInOut,PinName>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_07_mbed_read(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<int,DigitalInOut,&DigitalInOut::read>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_08_mbed_write(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<DigitalInOut,int,&DigitalInOut::write>(OBJ_TYPE_NON, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_09_mbed_input(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<DigitalInOut,&DigitalInOut::input>(OBJ_TYPE_NON);
        
}

PmReturn_t
nat_10_mbed_output(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<DigitalInOut,&DigitalInOut::output>(OBJ_TYPE_NON);
        
}

PmReturn_t
nat_11_mbed___init__(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.init<AnalogIn,PinName>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_12_mbed_read_u16(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<uint16_t,AnalogIn,&AnalogIn::read_u16>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_13_mbed_read(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<float,AnalogIn,&AnalogIn::read>(OBJ_TYPE_FLT);
        
}

PmReturn_t
nat_14_mbed___init__(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.init<AnalogOut,PinName>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_15_mbed_write_u16(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<AnalogOut,uint16_t,&AnalogOut::write_u16>(OBJ_TYPE_NON, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_16_mbed_write(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<AnalogOut,float,&AnalogOut::write>(OBJ_TYPE_NON, OBJ_TYPE_FLT);
        
}

PmReturn_t
nat_17_mbed_read(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<float,AnalogOut,&AnalogOut::read>(OBJ_TYPE_FLT);
        
}

PmReturn_t
nat_18_mbed___init__(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.init<PwmOut,PinName>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_19_mbed_write(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<PwmOut,float,&PwmOut::write>(OBJ_TYPE_NON, OBJ_TYPE_FLT);
        
}

PmReturn_t
nat_20_mbed_read(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<float,PwmOut,&PwmOut::read>(OBJ_TYPE_FLT);
        
}

PmReturn_t
nat_21_mbed_period(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<PwmOut,float,&PwmOut::period>(OBJ_TYPE_NON, OBJ_TYPE_FLT);
        
}

PmReturn_t
nat_22_mbed_period_ms(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<PwmOut,int,&PwmOut::period_ms>(OBJ_TYPE_NON, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_23_mbed_period_us(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<PwmOut,int,&PwmOut::period_us>(OBJ_TYPE_NON, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_24_mbed_pulsewidth(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<PwmOut,float,&PwmOut::pulsewidth>(OBJ_TYPE_NON, OBJ_TYPE_FLT);
        
}

PmReturn_t
nat_25_mbed_pulsewidth_ms(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<PwmOut,int,&PwmOut::pulsewidth_ms>(OBJ_TYPE_NON, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_26_mbed_pulsewidth_us(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<PwmOut,int,&PwmOut::pulsewidth_us>(OBJ_TYPE_NON, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_27_mbed___init__(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.init<Serial,PinName,PinName>(OBJ_TYPE_INT, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_28_mbed_baud(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<Serial,int,&Serial::baud>(OBJ_TYPE_NON, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_29_mbed_readable(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<int,Serial,&Serial::readable>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_30_mbed_writeable(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<int,Serial,&Serial::writeable>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_31_mbed_putc(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        Serial* obj;
        nci._load_obj<Serial>(&obj);
        int r = obj->putc(nci.argv<int>(1));
        return nci.set_return_value<int>(OBJ_TYPE_INT, r);
        //return nci.method<int,Serial,int,&Serial::putc>(OBJ_TYPE_INT, OBJ_TYPE_STR);
        
}

PmReturn_t
nat_32_mbed_puts(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        Serial* obj;
        nci._load_obj<Serial>(&obj);
        int r = obj->puts(nci.argv<const char*>(1));
        return nci.set_return_value<int>(OBJ_TYPE_INT, r);
        //return nci.method<int,Serial,char*,&Serial::puts>(OBJ_TYPE_INT, OBJ_TYPE_STR);
        
}

PmReturn_t
nat_33_mbed_getc(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        Serial* obj;
        nci._load_obj<Serial>(&obj);
        int r = obj->getc();
        return nci.set_return_value<int>(OBJ_TYPE_STR, r);
        //return nci.method<int,Serial,&Serial::getc>(OBJ_TYPE_STR);
        
}

PmReturn_t
nat_34_mbed___init__(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.init<SPI,PinName,PinName,PinName>(OBJ_TYPE_INT, OBJ_TYPE_INT, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_35_mbed_format(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<SPI,int,int,&SPI::format>(OBJ_TYPE_NON, OBJ_TYPE_INT, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_36_mbed_frequency(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<SPI,int,&SPI::frequency>(OBJ_TYPE_NON, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_37_mbed_write(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<int,SPI,int,&SPI::write>(OBJ_TYPE_INT, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_38_mbed___init__(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.init<I2C,PinName,PinName>(OBJ_TYPE_INT, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_39_mbed_frequency(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<I2C,int,&I2C::frequency>(OBJ_TYPE_NON, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_40_mbed_read(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<int,I2C,int,char*,int,bool,&I2C::read>(OBJ_TYPE_INT, 
        OBJ_TYPE_INT, OBJ_TYPE_STR, OBJ_TYPE_INT, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_41_mbed_write(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<int,I2C,int,const char*,int,bool,&I2C::write>(OBJ_TYPE_INT, 
        OBJ_TYPE_INT, OBJ_TYPE_STR, OBJ_TYPE_INT, OBJ_TYPE_INT);
        
}

PmReturn_t
nat_42_mbed___init__(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.init<Timer>();
        
}

PmReturn_t
nat_43_mbed_start(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<Timer,&Timer::start>(OBJ_TYPE_NON);
        
}

PmReturn_t
nat_44_mbed_stop(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<Timer,&Timer::stop>(OBJ_TYPE_NON);
        
}

PmReturn_t
nat_45_mbed_reset(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<Timer,&Timer::reset>(OBJ_TYPE_NON);
        
}

PmReturn_t
nat_46_mbed_read(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<float,Timer,&Timer::read>(OBJ_TYPE_FLT);
        
}

PmReturn_t
nat_47_mbed_read_ms(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<int,Timer,&Timer::read_ms>(OBJ_TYPE_INT);
        
}

PmReturn_t
nat_48_mbed_read_us(pPmFrame_t *ppframe)
{

        NativeClassInterface nci;
        return nci.method<int,Timer,&Timer::read_us>(OBJ_TYPE_INT);
        
}

/* Native function lookup table */
pPmNativeFxn_t const usr_nat_fxn_table[] =
{
    nat_placeholder_func,
    nat_01_mbed___init__,
    nat_02_mbed_write,
    nat_03_mbed_read,
    nat_04_mbed___init__,
    nat_05_mbed_read,
    nat_06_mbed___init__,
    nat_07_mbed_read,
    nat_08_mbed_write,
    nat_09_mbed_input,
    nat_10_mbed_output,
    nat_11_mbed___init__,
    nat_12_mbed_read_u16,
    nat_13_mbed_read,
    nat_14_mbed___init__,
    nat_15_mbed_write_u16,
    nat_16_mbed_write,
    nat_17_mbed_read,
    nat_18_mbed___init__,
    nat_19_mbed_write,
    nat_20_mbed_read,
    nat_21_mbed_period,
    nat_22_mbed_period_ms,
    nat_23_mbed_period_us,
    nat_24_mbed_pulsewidth,
    nat_25_mbed_pulsewidth_ms,
    nat_26_mbed_pulsewidth_us,
    nat_27_mbed___init__,
    nat_28_mbed_baud,
    nat_29_mbed_readable,
    nat_30_mbed_writeable,
    nat_31_mbed_putc,
    nat_32_mbed_puts,
    nat_33_mbed_getc,
    nat_34_mbed___init__,
    nat_35_mbed_format,
    nat_36_mbed_frequency,
    nat_37_mbed_write,
    nat_38_mbed___init__,
    nat_39_mbed_frequency,
    nat_40_mbed_read,
    nat_41_mbed_write,
    nat_42_mbed___init__,
    nat_43_mbed_start,
    nat_44_mbed_stop,
    nat_45_mbed_reset,
    nat_46_mbed_read,
    nat_47_mbed_read_ms,
    nat_48_mbed_read_us,
};