Davi Souza
/
pymite
python
Fork of pymite by
platform/mbed/main_nat.cpp@12:d27ad05214e3, 2014-08-28 (annotated)
- Committer:
- kausdev
- Date:
- Thu Aug 28 19:35:16 2014 +0000
- Revision:
- 12:d27ad05214e3
- Parent:
- 8:88d4fba4ccd5
pymte
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:65f1469d6bfb | 1 | #undef __FILE_ID__ |
va009039 | 0:65f1469d6bfb | 2 | #define __FILE_ID__ 0x0A |
va009039 | 0:65f1469d6bfb | 3 | /** |
va009039 | 0:65f1469d6bfb | 4 | * PyMite usr native function file |
va009039 | 0:65f1469d6bfb | 5 | * |
va009039 | 0:65f1469d6bfb | 6 | * automatically created by pmImgCreator.py |
va009039 | 4:23becb24acb8 | 7 | * on Fri Mar 15 14:38:03 2013 |
va009039 | 0:65f1469d6bfb | 8 | * |
va009039 | 0:65f1469d6bfb | 9 | * DO NOT EDIT THIS FILE. |
va009039 | 0:65f1469d6bfb | 10 | * ANY CHANGES WILL BE LOST. |
va009039 | 0:65f1469d6bfb | 11 | * |
va009039 | 0:65f1469d6bfb | 12 | * @file main_nat.cpp |
va009039 | 0:65f1469d6bfb | 13 | */ |
va009039 | 0:65f1469d6bfb | 14 | |
va009039 | 0:65f1469d6bfb | 15 | #define __IN_LIBNATIVE_C__ |
va009039 | 0:65f1469d6bfb | 16 | #include "pm.h" |
va009039 | 0:65f1469d6bfb | 17 | |
va009039 | 0:65f1469d6bfb | 18 | /* From: mbed.py */ |
va009039 | 0:65f1469d6bfb | 19 | #include "mbed.h" |
va009039 | 2:a2bea117e22e | 20 | #include "NativeClassInterface.h" |
va009039 | 4:23becb24acb8 | 21 | #if defined(TARGET_KL25Z) |
va009039 | 4:23becb24acb8 | 22 | #include "TSISensor.h" |
va009039 | 4:23becb24acb8 | 23 | #endif |
va009039 | 0:65f1469d6bfb | 24 | |
va009039 | 8:88d4fba4ccd5 | 25 | #if DEVICE_ANALOGOUT==0 |
va009039 | 7:71a6f45bc563 | 26 | class AnalogOut { |
va009039 | 7:71a6f45bc563 | 27 | public: |
va009039 | 7:71a6f45bc563 | 28 | AnalogOut(PinName pin){} |
va009039 | 7:71a6f45bc563 | 29 | void write(float value){} |
va009039 | 7:71a6f45bc563 | 30 | void write_u16(unsigned short value){} |
va009039 | 8:88d4fba4ccd5 | 31 | float read(){ return 0.0; } |
va009039 | 7:71a6f45bc563 | 32 | }; |
va009039 | 7:71a6f45bc563 | 33 | #endif |
va009039 | 7:71a6f45bc563 | 34 | |
va009039 | 0:65f1469d6bfb | 35 | PmReturn_t |
va009039 | 0:65f1469d6bfb | 36 | nat_placeholder_func(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 37 | { |
va009039 | 0:65f1469d6bfb | 38 | |
va009039 | 0:65f1469d6bfb | 39 | /* |
va009039 | 0:65f1469d6bfb | 40 | * Use placeholder because an index |
va009039 | 0:65f1469d6bfb | 41 | * value of zero denotes the stdlib. |
va009039 | 0:65f1469d6bfb | 42 | * This function should not be called. |
va009039 | 0:65f1469d6bfb | 43 | */ |
va009039 | 0:65f1469d6bfb | 44 | PmReturn_t retval; |
va009039 | 0:65f1469d6bfb | 45 | PM_RAISE(retval, PM_RET_EX_SYS); |
va009039 | 0:65f1469d6bfb | 46 | return retval; |
va009039 | 0:65f1469d6bfb | 47 | |
va009039 | 0:65f1469d6bfb | 48 | } |
va009039 | 0:65f1469d6bfb | 49 | |
va009039 | 0:65f1469d6bfb | 50 | PmReturn_t |
va009039 | 0:65f1469d6bfb | 51 | nat_01_mbed___init__(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 52 | { |
va009039 | 0:65f1469d6bfb | 53 | |
va009039 | 2:a2bea117e22e | 54 | NativeClassInterface nci; |
va009039 | 3:559c4bd38111 | 55 | return nci.init<DigitalOut,PinName>(OBJ_TYPE_STR); |
va009039 | 1:28afb064a41c | 56 | |
va009039 | 1:28afb064a41c | 57 | } |
va009039 | 1:28afb064a41c | 58 | |
va009039 | 1:28afb064a41c | 59 | PmReturn_t |
va009039 | 1:28afb064a41c | 60 | nat_02_mbed_write(pPmFrame_t *ppframe) |
va009039 | 1:28afb064a41c | 61 | { |
va009039 | 1:28afb064a41c | 62 | |
va009039 | 2:a2bea117e22e | 63 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 64 | return nci.method<DigitalOut,int,&DigitalOut::write>(OBJ_TYPE_NON, OBJ_TYPE_INT); |
va009039 | 1:28afb064a41c | 65 | |
va009039 | 1:28afb064a41c | 66 | } |
va009039 | 1:28afb064a41c | 67 | |
va009039 | 1:28afb064a41c | 68 | PmReturn_t |
va009039 | 1:28afb064a41c | 69 | nat_03_mbed_read(pPmFrame_t *ppframe) |
va009039 | 1:28afb064a41c | 70 | { |
va009039 | 1:28afb064a41c | 71 | |
va009039 | 2:a2bea117e22e | 72 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 73 | return nci.method<int,DigitalOut,&DigitalOut::read>(OBJ_TYPE_INT); |
va009039 | 1:28afb064a41c | 74 | |
va009039 | 1:28afb064a41c | 75 | } |
va009039 | 1:28afb064a41c | 76 | |
va009039 | 1:28afb064a41c | 77 | PmReturn_t |
va009039 | 1:28afb064a41c | 78 | nat_04_mbed___init__(pPmFrame_t *ppframe) |
va009039 | 1:28afb064a41c | 79 | { |
va009039 | 1:28afb064a41c | 80 | |
va009039 | 2:a2bea117e22e | 81 | NativeClassInterface nci; |
va009039 | 3:559c4bd38111 | 82 | return nci.init<DigitalIn,PinName>(OBJ_TYPE_STR); |
va009039 | 1:28afb064a41c | 83 | |
va009039 | 1:28afb064a41c | 84 | } |
va009039 | 1:28afb064a41c | 85 | |
va009039 | 1:28afb064a41c | 86 | PmReturn_t |
va009039 | 1:28afb064a41c | 87 | nat_05_mbed_read(pPmFrame_t *ppframe) |
va009039 | 1:28afb064a41c | 88 | { |
va009039 | 1:28afb064a41c | 89 | |
va009039 | 2:a2bea117e22e | 90 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 91 | return nci.method<int,DigitalIn,&DigitalIn::read>(OBJ_TYPE_INT); |
va009039 | 1:28afb064a41c | 92 | |
va009039 | 1:28afb064a41c | 93 | } |
va009039 | 1:28afb064a41c | 94 | |
va009039 | 1:28afb064a41c | 95 | PmReturn_t |
va009039 | 1:28afb064a41c | 96 | nat_06_mbed___init__(pPmFrame_t *ppframe) |
va009039 | 1:28afb064a41c | 97 | { |
va009039 | 1:28afb064a41c | 98 | |
va009039 | 2:a2bea117e22e | 99 | NativeClassInterface nci; |
va009039 | 3:559c4bd38111 | 100 | return nci.init<DigitalInOut,PinName>(OBJ_TYPE_STR); |
va009039 | 2:a2bea117e22e | 101 | |
va009039 | 2:a2bea117e22e | 102 | } |
va009039 | 0:65f1469d6bfb | 103 | |
va009039 | 2:a2bea117e22e | 104 | PmReturn_t |
va009039 | 2:a2bea117e22e | 105 | nat_07_mbed_read(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 106 | { |
va009039 | 0:65f1469d6bfb | 107 | |
va009039 | 2:a2bea117e22e | 108 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 109 | return nci.method<int,DigitalInOut,&DigitalInOut::read>(OBJ_TYPE_INT); |
va009039 | 0:65f1469d6bfb | 110 | |
va009039 | 0:65f1469d6bfb | 111 | } |
va009039 | 0:65f1469d6bfb | 112 | |
va009039 | 0:65f1469d6bfb | 113 | PmReturn_t |
va009039 | 2:a2bea117e22e | 114 | nat_08_mbed_write(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 115 | { |
va009039 | 0:65f1469d6bfb | 116 | |
va009039 | 2:a2bea117e22e | 117 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 118 | return nci.method<DigitalInOut,int,&DigitalInOut::write>(OBJ_TYPE_NON, OBJ_TYPE_INT); |
va009039 | 0:65f1469d6bfb | 119 | |
va009039 | 0:65f1469d6bfb | 120 | } |
va009039 | 0:65f1469d6bfb | 121 | |
va009039 | 0:65f1469d6bfb | 122 | PmReturn_t |
va009039 | 2:a2bea117e22e | 123 | nat_09_mbed_input(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 124 | { |
va009039 | 0:65f1469d6bfb | 125 | |
va009039 | 2:a2bea117e22e | 126 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 127 | return nci.method<DigitalInOut,&DigitalInOut::input>(OBJ_TYPE_NON); |
va009039 | 2:a2bea117e22e | 128 | |
va009039 | 2:a2bea117e22e | 129 | } |
va009039 | 0:65f1469d6bfb | 130 | |
va009039 | 2:a2bea117e22e | 131 | PmReturn_t |
va009039 | 2:a2bea117e22e | 132 | nat_10_mbed_output(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 133 | { |
va009039 | 0:65f1469d6bfb | 134 | |
va009039 | 2:a2bea117e22e | 135 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 136 | return nci.method<DigitalInOut,&DigitalInOut::output>(OBJ_TYPE_NON); |
va009039 | 0:65f1469d6bfb | 137 | |
va009039 | 0:65f1469d6bfb | 138 | } |
va009039 | 0:65f1469d6bfb | 139 | |
va009039 | 0:65f1469d6bfb | 140 | PmReturn_t |
va009039 | 2:a2bea117e22e | 141 | nat_11_mbed___init__(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 142 | { |
va009039 | 0:65f1469d6bfb | 143 | |
va009039 | 2:a2bea117e22e | 144 | NativeClassInterface nci; |
va009039 | 3:559c4bd38111 | 145 | return nci.init<AnalogIn,PinName>(OBJ_TYPE_STR); |
va009039 | 2:a2bea117e22e | 146 | |
va009039 | 2:a2bea117e22e | 147 | } |
va009039 | 0:65f1469d6bfb | 148 | |
va009039 | 2:a2bea117e22e | 149 | PmReturn_t |
va009039 | 2:a2bea117e22e | 150 | nat_12_mbed_read_u16(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 151 | { |
va009039 | 0:65f1469d6bfb | 152 | |
va009039 | 2:a2bea117e22e | 153 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 154 | return nci.method<uint16_t,AnalogIn,&AnalogIn::read_u16>(OBJ_TYPE_INT); |
va009039 | 0:65f1469d6bfb | 155 | |
va009039 | 0:65f1469d6bfb | 156 | } |
va009039 | 0:65f1469d6bfb | 157 | |
va009039 | 0:65f1469d6bfb | 158 | PmReturn_t |
va009039 | 2:a2bea117e22e | 159 | nat_13_mbed_read(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 160 | { |
va009039 | 0:65f1469d6bfb | 161 | |
va009039 | 2:a2bea117e22e | 162 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 163 | return nci.method<float,AnalogIn,&AnalogIn::read>(OBJ_TYPE_FLT); |
va009039 | 0:65f1469d6bfb | 164 | |
va009039 | 0:65f1469d6bfb | 165 | } |
va009039 | 0:65f1469d6bfb | 166 | |
va009039 | 0:65f1469d6bfb | 167 | PmReturn_t |
va009039 | 2:a2bea117e22e | 168 | nat_14_mbed___init__(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 169 | { |
va009039 | 2:a2bea117e22e | 170 | |
va009039 | 2:a2bea117e22e | 171 | NativeClassInterface nci; |
va009039 | 3:559c4bd38111 | 172 | return nci.init<AnalogOut,PinName>(OBJ_TYPE_STR); |
va009039 | 2:a2bea117e22e | 173 | |
va009039 | 2:a2bea117e22e | 174 | } |
va009039 | 2:a2bea117e22e | 175 | |
va009039 | 2:a2bea117e22e | 176 | PmReturn_t |
va009039 | 2:a2bea117e22e | 177 | nat_15_mbed_write_u16(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 178 | { |
va009039 | 0:65f1469d6bfb | 179 | |
va009039 | 2:a2bea117e22e | 180 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 181 | return nci.method<AnalogOut,uint16_t,&AnalogOut::write_u16>(OBJ_TYPE_NON, OBJ_TYPE_INT); |
va009039 | 2:a2bea117e22e | 182 | |
va009039 | 2:a2bea117e22e | 183 | } |
va009039 | 0:65f1469d6bfb | 184 | |
va009039 | 2:a2bea117e22e | 185 | PmReturn_t |
va009039 | 2:a2bea117e22e | 186 | nat_16_mbed_write(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 187 | { |
va009039 | 0:65f1469d6bfb | 188 | |
va009039 | 2:a2bea117e22e | 189 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 190 | return nci.method<AnalogOut,float,&AnalogOut::write>(OBJ_TYPE_NON, OBJ_TYPE_FLT); |
va009039 | 0:65f1469d6bfb | 191 | |
va009039 | 0:65f1469d6bfb | 192 | } |
va009039 | 0:65f1469d6bfb | 193 | |
va009039 | 0:65f1469d6bfb | 194 | PmReturn_t |
va009039 | 2:a2bea117e22e | 195 | nat_17_mbed_read(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 196 | { |
va009039 | 0:65f1469d6bfb | 197 | |
va009039 | 2:a2bea117e22e | 198 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 199 | return nci.method<float,AnalogOut,&AnalogOut::read>(OBJ_TYPE_FLT); |
va009039 | 2:a2bea117e22e | 200 | |
va009039 | 2:a2bea117e22e | 201 | } |
va009039 | 0:65f1469d6bfb | 202 | |
va009039 | 2:a2bea117e22e | 203 | PmReturn_t |
va009039 | 2:a2bea117e22e | 204 | nat_18_mbed___init__(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 205 | { |
va009039 | 0:65f1469d6bfb | 206 | |
va009039 | 2:a2bea117e22e | 207 | NativeClassInterface nci; |
va009039 | 3:559c4bd38111 | 208 | return nci.init<PwmOut,PinName>(OBJ_TYPE_STR); |
va009039 | 0:65f1469d6bfb | 209 | |
va009039 | 0:65f1469d6bfb | 210 | } |
va009039 | 0:65f1469d6bfb | 211 | |
va009039 | 0:65f1469d6bfb | 212 | PmReturn_t |
va009039 | 2:a2bea117e22e | 213 | nat_19_mbed_write(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 214 | { |
va009039 | 0:65f1469d6bfb | 215 | |
va009039 | 2:a2bea117e22e | 216 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 217 | return nci.method<PwmOut,float,&PwmOut::write>(OBJ_TYPE_NON, OBJ_TYPE_FLT); |
va009039 | 0:65f1469d6bfb | 218 | |
va009039 | 0:65f1469d6bfb | 219 | } |
va009039 | 0:65f1469d6bfb | 220 | |
va009039 | 0:65f1469d6bfb | 221 | PmReturn_t |
va009039 | 2:a2bea117e22e | 222 | nat_20_mbed_read(pPmFrame_t *ppframe) |
va009039 | 1:28afb064a41c | 223 | { |
va009039 | 1:28afb064a41c | 224 | |
va009039 | 2:a2bea117e22e | 225 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 226 | return nci.method<float,PwmOut,&PwmOut::read>(OBJ_TYPE_FLT); |
va009039 | 1:28afb064a41c | 227 | |
va009039 | 1:28afb064a41c | 228 | } |
va009039 | 1:28afb064a41c | 229 | |
va009039 | 1:28afb064a41c | 230 | PmReturn_t |
va009039 | 2:a2bea117e22e | 231 | nat_21_mbed_period(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 232 | { |
va009039 | 0:65f1469d6bfb | 233 | |
va009039 | 2:a2bea117e22e | 234 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 235 | return nci.method<PwmOut,float,&PwmOut::period>(OBJ_TYPE_NON, OBJ_TYPE_FLT); |
va009039 | 0:65f1469d6bfb | 236 | |
va009039 | 0:65f1469d6bfb | 237 | } |
va009039 | 0:65f1469d6bfb | 238 | |
va009039 | 0:65f1469d6bfb | 239 | PmReturn_t |
va009039 | 2:a2bea117e22e | 240 | nat_22_mbed_period_ms(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 241 | { |
va009039 | 0:65f1469d6bfb | 242 | |
va009039 | 2:a2bea117e22e | 243 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 244 | return nci.method<PwmOut,int,&PwmOut::period_ms>(OBJ_TYPE_NON, OBJ_TYPE_INT); |
va009039 | 0:65f1469d6bfb | 245 | |
va009039 | 0:65f1469d6bfb | 246 | } |
va009039 | 0:65f1469d6bfb | 247 | |
va009039 | 0:65f1469d6bfb | 248 | PmReturn_t |
va009039 | 2:a2bea117e22e | 249 | nat_23_mbed_period_us(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 250 | { |
va009039 | 0:65f1469d6bfb | 251 | |
va009039 | 2:a2bea117e22e | 252 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 253 | return nci.method<PwmOut,int,&PwmOut::period_us>(OBJ_TYPE_NON, OBJ_TYPE_INT); |
va009039 | 0:65f1469d6bfb | 254 | |
va009039 | 0:65f1469d6bfb | 255 | } |
va009039 | 0:65f1469d6bfb | 256 | |
va009039 | 0:65f1469d6bfb | 257 | PmReturn_t |
va009039 | 2:a2bea117e22e | 258 | nat_24_mbed_pulsewidth(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 259 | { |
va009039 | 0:65f1469d6bfb | 260 | |
va009039 | 2:a2bea117e22e | 261 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 262 | return nci.method<PwmOut,float,&PwmOut::pulsewidth>(OBJ_TYPE_NON, OBJ_TYPE_FLT); |
va009039 | 0:65f1469d6bfb | 263 | |
va009039 | 0:65f1469d6bfb | 264 | } |
va009039 | 0:65f1469d6bfb | 265 | |
va009039 | 0:65f1469d6bfb | 266 | PmReturn_t |
va009039 | 2:a2bea117e22e | 267 | nat_25_mbed_pulsewidth_ms(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 268 | { |
va009039 | 2:a2bea117e22e | 269 | |
va009039 | 2:a2bea117e22e | 270 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 271 | return nci.method<PwmOut,int,&PwmOut::pulsewidth_ms>(OBJ_TYPE_NON, OBJ_TYPE_INT); |
va009039 | 2:a2bea117e22e | 272 | |
va009039 | 2:a2bea117e22e | 273 | } |
va009039 | 2:a2bea117e22e | 274 | |
va009039 | 2:a2bea117e22e | 275 | PmReturn_t |
va009039 | 2:a2bea117e22e | 276 | nat_26_mbed_pulsewidth_us(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 277 | { |
va009039 | 0:65f1469d6bfb | 278 | |
va009039 | 2:a2bea117e22e | 279 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 280 | return nci.method<PwmOut,int,&PwmOut::pulsewidth_us>(OBJ_TYPE_NON, OBJ_TYPE_INT); |
va009039 | 2:a2bea117e22e | 281 | |
va009039 | 2:a2bea117e22e | 282 | } |
va009039 | 0:65f1469d6bfb | 283 | |
va009039 | 2:a2bea117e22e | 284 | PmReturn_t |
va009039 | 2:a2bea117e22e | 285 | nat_27_mbed___init__(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 286 | { |
va009039 | 0:65f1469d6bfb | 287 | |
va009039 | 2:a2bea117e22e | 288 | NativeClassInterface nci; |
va009039 | 3:559c4bd38111 | 289 | return nci.init<Serial,PinName,PinName>(OBJ_TYPE_STR, OBJ_TYPE_STR); |
va009039 | 0:65f1469d6bfb | 290 | |
va009039 | 0:65f1469d6bfb | 291 | } |
va009039 | 0:65f1469d6bfb | 292 | |
va009039 | 0:65f1469d6bfb | 293 | PmReturn_t |
va009039 | 2:a2bea117e22e | 294 | nat_28_mbed_baud(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 295 | { |
va009039 | 0:65f1469d6bfb | 296 | |
va009039 | 2:a2bea117e22e | 297 | NativeClassInterface nci; |
va009039 | 5:19bd98307341 | 298 | Serial* obj; |
va009039 | 5:19bd98307341 | 299 | nci._load_obj<Serial>(&obj); |
va009039 | 5:19bd98307341 | 300 | obj->baud(nci.argv<int>(1)); |
va009039 | 5:19bd98307341 | 301 | return nci.set_return_value<int>(OBJ_TYPE_INT, 0); |
va009039 | 5:19bd98307341 | 302 | //return nci.method<Serial,int,&Serial::baud>(OBJ_TYPE_NON, OBJ_TYPE_INT); |
va009039 | 2:a2bea117e22e | 303 | |
va009039 | 2:a2bea117e22e | 304 | } |
va009039 | 0:65f1469d6bfb | 305 | |
va009039 | 2:a2bea117e22e | 306 | PmReturn_t |
va009039 | 2:a2bea117e22e | 307 | nat_29_mbed_readable(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 308 | { |
va009039 | 0:65f1469d6bfb | 309 | |
va009039 | 2:a2bea117e22e | 310 | NativeClassInterface nci; |
va009039 | 5:19bd98307341 | 311 | Serial* obj; |
va009039 | 5:19bd98307341 | 312 | nci._load_obj<Serial>(&obj); |
va009039 | 5:19bd98307341 | 313 | int r = obj->readable(); |
va009039 | 5:19bd98307341 | 314 | return nci.set_return_value<int>(OBJ_TYPE_INT, r); |
va009039 | 5:19bd98307341 | 315 | //return nci.method<int,Serial,&Serial::readable>(OBJ_TYPE_INT); |
va009039 | 5:19bd98307341 | 316 | |
va009039 | 0:65f1469d6bfb | 317 | } |
va009039 | 0:65f1469d6bfb | 318 | |
va009039 | 0:65f1469d6bfb | 319 | PmReturn_t |
va009039 | 2:a2bea117e22e | 320 | nat_30_mbed_writeable(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 321 | { |
va009039 | 0:65f1469d6bfb | 322 | |
va009039 | 2:a2bea117e22e | 323 | NativeClassInterface nci; |
va009039 | 5:19bd98307341 | 324 | Serial* obj; |
va009039 | 5:19bd98307341 | 325 | nci._load_obj<Serial>(&obj); |
va009039 | 5:19bd98307341 | 326 | int r = obj->writeable(); |
va009039 | 5:19bd98307341 | 327 | return nci.set_return_value<int>(OBJ_TYPE_INT, r); |
va009039 | 5:19bd98307341 | 328 | //return nci.method<int,Serial,&Serial::writeable>(OBJ_TYPE_INT); |
va009039 | 0:65f1469d6bfb | 329 | |
va009039 | 0:65f1469d6bfb | 330 | } |
va009039 | 0:65f1469d6bfb | 331 | |
va009039 | 0:65f1469d6bfb | 332 | PmReturn_t |
va009039 | 2:a2bea117e22e | 333 | nat_31_mbed_putc(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 334 | { |
va009039 | 0:65f1469d6bfb | 335 | |
va009039 | 2:a2bea117e22e | 336 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 337 | Serial* obj; |
va009039 | 2:a2bea117e22e | 338 | nci._load_obj<Serial>(&obj); |
va009039 | 2:a2bea117e22e | 339 | int r = obj->putc(nci.argv<int>(1)); |
va009039 | 2:a2bea117e22e | 340 | return nci.set_return_value<int>(OBJ_TYPE_INT, r); |
va009039 | 2:a2bea117e22e | 341 | //return nci.method<int,Serial,int,&Serial::putc>(OBJ_TYPE_INT, OBJ_TYPE_STR); |
va009039 | 0:65f1469d6bfb | 342 | |
va009039 | 0:65f1469d6bfb | 343 | } |
va009039 | 0:65f1469d6bfb | 344 | |
va009039 | 0:65f1469d6bfb | 345 | PmReturn_t |
va009039 | 2:a2bea117e22e | 346 | nat_32_mbed_puts(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 347 | { |
va009039 | 0:65f1469d6bfb | 348 | |
va009039 | 2:a2bea117e22e | 349 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 350 | Serial* obj; |
va009039 | 2:a2bea117e22e | 351 | nci._load_obj<Serial>(&obj); |
va009039 | 2:a2bea117e22e | 352 | int r = obj->puts(nci.argv<const char*>(1)); |
va009039 | 2:a2bea117e22e | 353 | return nci.set_return_value<int>(OBJ_TYPE_INT, r); |
va009039 | 2:a2bea117e22e | 354 | //return nci.method<int,Serial,char*,&Serial::puts>(OBJ_TYPE_INT, OBJ_TYPE_STR); |
va009039 | 0:65f1469d6bfb | 355 | |
va009039 | 0:65f1469d6bfb | 356 | } |
va009039 | 0:65f1469d6bfb | 357 | |
va009039 | 0:65f1469d6bfb | 358 | PmReturn_t |
va009039 | 2:a2bea117e22e | 359 | nat_33_mbed_getc(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 360 | { |
va009039 | 0:65f1469d6bfb | 361 | |
va009039 | 2:a2bea117e22e | 362 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 363 | Serial* obj; |
va009039 | 2:a2bea117e22e | 364 | nci._load_obj<Serial>(&obj); |
va009039 | 2:a2bea117e22e | 365 | int r = obj->getc(); |
va009039 | 2:a2bea117e22e | 366 | return nci.set_return_value<int>(OBJ_TYPE_STR, r); |
va009039 | 2:a2bea117e22e | 367 | //return nci.method<int,Serial,&Serial::getc>(OBJ_TYPE_STR); |
va009039 | 0:65f1469d6bfb | 368 | |
va009039 | 0:65f1469d6bfb | 369 | } |
va009039 | 0:65f1469d6bfb | 370 | |
va009039 | 0:65f1469d6bfb | 371 | PmReturn_t |
va009039 | 2:a2bea117e22e | 372 | nat_34_mbed___init__(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 373 | { |
va009039 | 2:a2bea117e22e | 374 | |
va009039 | 2:a2bea117e22e | 375 | NativeClassInterface nci; |
va009039 | 3:559c4bd38111 | 376 | return nci.init<SPI,PinName,PinName,PinName>(OBJ_TYPE_STR, OBJ_TYPE_STR, OBJ_TYPE_STR); |
va009039 | 2:a2bea117e22e | 377 | |
va009039 | 2:a2bea117e22e | 378 | } |
va009039 | 2:a2bea117e22e | 379 | |
va009039 | 2:a2bea117e22e | 380 | PmReturn_t |
va009039 | 2:a2bea117e22e | 381 | nat_35_mbed_format(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 382 | { |
va009039 | 0:65f1469d6bfb | 383 | |
va009039 | 2:a2bea117e22e | 384 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 385 | return nci.method<SPI,int,int,&SPI::format>(OBJ_TYPE_NON, OBJ_TYPE_INT, OBJ_TYPE_INT); |
va009039 | 2:a2bea117e22e | 386 | |
va009039 | 2:a2bea117e22e | 387 | } |
va009039 | 0:65f1469d6bfb | 388 | |
va009039 | 2:a2bea117e22e | 389 | PmReturn_t |
va009039 | 2:a2bea117e22e | 390 | nat_36_mbed_frequency(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 391 | { |
va009039 | 0:65f1469d6bfb | 392 | |
va009039 | 2:a2bea117e22e | 393 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 394 | return nci.method<SPI,int,&SPI::frequency>(OBJ_TYPE_NON, OBJ_TYPE_INT); |
va009039 | 0:65f1469d6bfb | 395 | |
va009039 | 0:65f1469d6bfb | 396 | } |
va009039 | 0:65f1469d6bfb | 397 | |
va009039 | 0:65f1469d6bfb | 398 | PmReturn_t |
va009039 | 2:a2bea117e22e | 399 | nat_37_mbed_write(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 400 | { |
va009039 | 0:65f1469d6bfb | 401 | |
va009039 | 2:a2bea117e22e | 402 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 403 | return nci.method<int,SPI,int,&SPI::write>(OBJ_TYPE_INT, OBJ_TYPE_INT); |
va009039 | 2:a2bea117e22e | 404 | |
va009039 | 2:a2bea117e22e | 405 | } |
va009039 | 0:65f1469d6bfb | 406 | |
va009039 | 2:a2bea117e22e | 407 | PmReturn_t |
va009039 | 2:a2bea117e22e | 408 | nat_38_mbed___init__(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 409 | { |
va009039 | 0:65f1469d6bfb | 410 | |
va009039 | 2:a2bea117e22e | 411 | NativeClassInterface nci; |
va009039 | 3:559c4bd38111 | 412 | return nci.init<I2C,PinName,PinName>(OBJ_TYPE_STR, OBJ_TYPE_STR); |
va009039 | 0:65f1469d6bfb | 413 | |
va009039 | 0:65f1469d6bfb | 414 | } |
va009039 | 0:65f1469d6bfb | 415 | |
va009039 | 0:65f1469d6bfb | 416 | PmReturn_t |
va009039 | 2:a2bea117e22e | 417 | nat_39_mbed_frequency(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 418 | { |
va009039 | 0:65f1469d6bfb | 419 | |
va009039 | 2:a2bea117e22e | 420 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 421 | return nci.method<I2C,int,&I2C::frequency>(OBJ_TYPE_NON, OBJ_TYPE_INT); |
va009039 | 0:65f1469d6bfb | 422 | |
va009039 | 0:65f1469d6bfb | 423 | } |
va009039 | 0:65f1469d6bfb | 424 | |
va009039 | 0:65f1469d6bfb | 425 | PmReturn_t |
va009039 | 2:a2bea117e22e | 426 | nat_40_mbed_read(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 427 | { |
va009039 | 0:65f1469d6bfb | 428 | |
va009039 | 2:a2bea117e22e | 429 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 430 | return nci.method<int,I2C,int,char*,int,bool,&I2C::read>(OBJ_TYPE_INT, |
va009039 | 2:a2bea117e22e | 431 | OBJ_TYPE_INT, OBJ_TYPE_STR, OBJ_TYPE_INT, OBJ_TYPE_INT); |
va009039 | 2:a2bea117e22e | 432 | |
va009039 | 2:a2bea117e22e | 433 | } |
va009039 | 0:65f1469d6bfb | 434 | |
va009039 | 2:a2bea117e22e | 435 | PmReturn_t |
va009039 | 2:a2bea117e22e | 436 | nat_41_mbed_write(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 437 | { |
va009039 | 0:65f1469d6bfb | 438 | |
va009039 | 2:a2bea117e22e | 439 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 440 | return nci.method<int,I2C,int,const char*,int,bool,&I2C::write>(OBJ_TYPE_INT, |
va009039 | 2:a2bea117e22e | 441 | OBJ_TYPE_INT, OBJ_TYPE_STR, OBJ_TYPE_INT, OBJ_TYPE_INT); |
va009039 | 0:65f1469d6bfb | 442 | |
va009039 | 0:65f1469d6bfb | 443 | } |
va009039 | 0:65f1469d6bfb | 444 | |
va009039 | 0:65f1469d6bfb | 445 | PmReturn_t |
va009039 | 2:a2bea117e22e | 446 | nat_42_mbed___init__(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 447 | { |
va009039 | 0:65f1469d6bfb | 448 | |
va009039 | 2:a2bea117e22e | 449 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 450 | return nci.init<Timer>(); |
va009039 | 0:65f1469d6bfb | 451 | |
va009039 | 0:65f1469d6bfb | 452 | } |
va009039 | 0:65f1469d6bfb | 453 | |
va009039 | 0:65f1469d6bfb | 454 | PmReturn_t |
va009039 | 2:a2bea117e22e | 455 | nat_43_mbed_start(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 456 | { |
va009039 | 0:65f1469d6bfb | 457 | |
va009039 | 2:a2bea117e22e | 458 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 459 | return nci.method<Timer,&Timer::start>(OBJ_TYPE_NON); |
va009039 | 2:a2bea117e22e | 460 | |
va009039 | 2:a2bea117e22e | 461 | } |
va009039 | 0:65f1469d6bfb | 462 | |
va009039 | 2:a2bea117e22e | 463 | PmReturn_t |
va009039 | 2:a2bea117e22e | 464 | nat_44_mbed_stop(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 465 | { |
va009039 | 0:65f1469d6bfb | 466 | |
va009039 | 2:a2bea117e22e | 467 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 468 | return nci.method<Timer,&Timer::stop>(OBJ_TYPE_NON); |
va009039 | 0:65f1469d6bfb | 469 | |
va009039 | 0:65f1469d6bfb | 470 | } |
va009039 | 0:65f1469d6bfb | 471 | |
va009039 | 0:65f1469d6bfb | 472 | PmReturn_t |
va009039 | 2:a2bea117e22e | 473 | nat_45_mbed_reset(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 474 | { |
va009039 | 0:65f1469d6bfb | 475 | |
va009039 | 2:a2bea117e22e | 476 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 477 | return nci.method<Timer,&Timer::reset>(OBJ_TYPE_NON); |
va009039 | 0:65f1469d6bfb | 478 | |
va009039 | 0:65f1469d6bfb | 479 | } |
va009039 | 0:65f1469d6bfb | 480 | |
va009039 | 0:65f1469d6bfb | 481 | PmReturn_t |
va009039 | 2:a2bea117e22e | 482 | nat_46_mbed_read(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 483 | { |
va009039 | 2:a2bea117e22e | 484 | |
va009039 | 2:a2bea117e22e | 485 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 486 | return nci.method<float,Timer,&Timer::read>(OBJ_TYPE_FLT); |
va009039 | 2:a2bea117e22e | 487 | |
va009039 | 2:a2bea117e22e | 488 | } |
va009039 | 2:a2bea117e22e | 489 | |
va009039 | 2:a2bea117e22e | 490 | PmReturn_t |
va009039 | 2:a2bea117e22e | 491 | nat_47_mbed_read_ms(pPmFrame_t *ppframe) |
va009039 | 0:65f1469d6bfb | 492 | { |
va009039 | 0:65f1469d6bfb | 493 | |
va009039 | 2:a2bea117e22e | 494 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 495 | return nci.method<int,Timer,&Timer::read_ms>(OBJ_TYPE_INT); |
va009039 | 2:a2bea117e22e | 496 | |
va009039 | 2:a2bea117e22e | 497 | } |
va009039 | 0:65f1469d6bfb | 498 | |
va009039 | 2:a2bea117e22e | 499 | PmReturn_t |
va009039 | 2:a2bea117e22e | 500 | nat_48_mbed_read_us(pPmFrame_t *ppframe) |
va009039 | 2:a2bea117e22e | 501 | { |
va009039 | 0:65f1469d6bfb | 502 | |
va009039 | 2:a2bea117e22e | 503 | NativeClassInterface nci; |
va009039 | 2:a2bea117e22e | 504 | return nci.method<int,Timer,&Timer::read_us>(OBJ_TYPE_INT); |
va009039 | 0:65f1469d6bfb | 505 | |
va009039 | 0:65f1469d6bfb | 506 | } |
va009039 | 0:65f1469d6bfb | 507 | |
va009039 | 4:23becb24acb8 | 508 | PmReturn_t |
va009039 | 4:23becb24acb8 | 509 | nat_49_mbed___init__(pPmFrame_t *ppframe) |
va009039 | 4:23becb24acb8 | 510 | { |
va009039 | 4:23becb24acb8 | 511 | |
va009039 | 4:23becb24acb8 | 512 | #if defined(TARGET_KL25Z) |
va009039 | 4:23becb24acb8 | 513 | NativeClassInterface nci; |
va009039 | 4:23becb24acb8 | 514 | return nci.init<TSISensor>(); |
va009039 | 4:23becb24acb8 | 515 | #endif |
va009039 | 4:23becb24acb8 | 516 | |
va009039 | 4:23becb24acb8 | 517 | } |
va009039 | 4:23becb24acb8 | 518 | |
va009039 | 4:23becb24acb8 | 519 | PmReturn_t |
va009039 | 4:23becb24acb8 | 520 | nat_50_mbed_readPercentage(pPmFrame_t *ppframe) |
va009039 | 4:23becb24acb8 | 521 | { |
va009039 | 4:23becb24acb8 | 522 | |
va009039 | 4:23becb24acb8 | 523 | #if defined(TARGET_KL25Z) |
va009039 | 4:23becb24acb8 | 524 | NativeClassInterface nci; |
va009039 | 4:23becb24acb8 | 525 | return nci.method<float,TSISensor,&TSISensor::readPercentage>(OBJ_TYPE_FLT); |
va009039 | 4:23becb24acb8 | 526 | #endif |
va009039 | 4:23becb24acb8 | 527 | |
va009039 | 4:23becb24acb8 | 528 | } |
va009039 | 4:23becb24acb8 | 529 | |
va009039 | 4:23becb24acb8 | 530 | PmReturn_t |
va009039 | 4:23becb24acb8 | 531 | nat_51_mbed_readDistance(pPmFrame_t *ppframe) |
va009039 | 4:23becb24acb8 | 532 | { |
va009039 | 4:23becb24acb8 | 533 | |
va009039 | 4:23becb24acb8 | 534 | #if defined(TARGET_KL25Z) |
va009039 | 4:23becb24acb8 | 535 | NativeClassInterface nci; |
va009039 | 4:23becb24acb8 | 536 | return nci.method<uint8_t,TSISensor,&TSISensor::readDistance>(OBJ_TYPE_INT); |
va009039 | 4:23becb24acb8 | 537 | #endif |
va009039 | 4:23becb24acb8 | 538 | |
va009039 | 4:23becb24acb8 | 539 | } |
va009039 | 4:23becb24acb8 | 540 | |
va009039 | 0:65f1469d6bfb | 541 | /* Native function lookup table */ |
va009039 | 0:65f1469d6bfb | 542 | pPmNativeFxn_t const usr_nat_fxn_table[] = |
va009039 | 0:65f1469d6bfb | 543 | { |
va009039 | 0:65f1469d6bfb | 544 | nat_placeholder_func, |
va009039 | 0:65f1469d6bfb | 545 | nat_01_mbed___init__, |
va009039 | 1:28afb064a41c | 546 | nat_02_mbed_write, |
va009039 | 0:65f1469d6bfb | 547 | nat_03_mbed_read, |
va009039 | 0:65f1469d6bfb | 548 | nat_04_mbed___init__, |
va009039 | 1:28afb064a41c | 549 | nat_05_mbed_read, |
va009039 | 1:28afb064a41c | 550 | nat_06_mbed___init__, |
va009039 | 2:a2bea117e22e | 551 | nat_07_mbed_read, |
va009039 | 2:a2bea117e22e | 552 | nat_08_mbed_write, |
va009039 | 2:a2bea117e22e | 553 | nat_09_mbed_input, |
va009039 | 2:a2bea117e22e | 554 | nat_10_mbed_output, |
va009039 | 2:a2bea117e22e | 555 | nat_11_mbed___init__, |
va009039 | 2:a2bea117e22e | 556 | nat_12_mbed_read_u16, |
va009039 | 2:a2bea117e22e | 557 | nat_13_mbed_read, |
va009039 | 2:a2bea117e22e | 558 | nat_14_mbed___init__, |
va009039 | 2:a2bea117e22e | 559 | nat_15_mbed_write_u16, |
va009039 | 2:a2bea117e22e | 560 | nat_16_mbed_write, |
va009039 | 2:a2bea117e22e | 561 | nat_17_mbed_read, |
va009039 | 2:a2bea117e22e | 562 | nat_18_mbed___init__, |
va009039 | 2:a2bea117e22e | 563 | nat_19_mbed_write, |
va009039 | 2:a2bea117e22e | 564 | nat_20_mbed_read, |
va009039 | 2:a2bea117e22e | 565 | nat_21_mbed_period, |
va009039 | 2:a2bea117e22e | 566 | nat_22_mbed_period_ms, |
va009039 | 2:a2bea117e22e | 567 | nat_23_mbed_period_us, |
va009039 | 2:a2bea117e22e | 568 | nat_24_mbed_pulsewidth, |
va009039 | 2:a2bea117e22e | 569 | nat_25_mbed_pulsewidth_ms, |
va009039 | 2:a2bea117e22e | 570 | nat_26_mbed_pulsewidth_us, |
va009039 | 2:a2bea117e22e | 571 | nat_27_mbed___init__, |
va009039 | 2:a2bea117e22e | 572 | nat_28_mbed_baud, |
va009039 | 2:a2bea117e22e | 573 | nat_29_mbed_readable, |
va009039 | 2:a2bea117e22e | 574 | nat_30_mbed_writeable, |
va009039 | 2:a2bea117e22e | 575 | nat_31_mbed_putc, |
va009039 | 2:a2bea117e22e | 576 | nat_32_mbed_puts, |
va009039 | 2:a2bea117e22e | 577 | nat_33_mbed_getc, |
va009039 | 2:a2bea117e22e | 578 | nat_34_mbed___init__, |
va009039 | 2:a2bea117e22e | 579 | nat_35_mbed_format, |
va009039 | 2:a2bea117e22e | 580 | nat_36_mbed_frequency, |
va009039 | 2:a2bea117e22e | 581 | nat_37_mbed_write, |
va009039 | 2:a2bea117e22e | 582 | nat_38_mbed___init__, |
va009039 | 2:a2bea117e22e | 583 | nat_39_mbed_frequency, |
va009039 | 2:a2bea117e22e | 584 | nat_40_mbed_read, |
va009039 | 2:a2bea117e22e | 585 | nat_41_mbed_write, |
va009039 | 2:a2bea117e22e | 586 | nat_42_mbed___init__, |
va009039 | 2:a2bea117e22e | 587 | nat_43_mbed_start, |
va009039 | 2:a2bea117e22e | 588 | nat_44_mbed_stop, |
va009039 | 2:a2bea117e22e | 589 | nat_45_mbed_reset, |
va009039 | 2:a2bea117e22e | 590 | nat_46_mbed_read, |
va009039 | 2:a2bea117e22e | 591 | nat_47_mbed_read_ms, |
va009039 | 2:a2bea117e22e | 592 | nat_48_mbed_read_us, |
va009039 | 4:23becb24acb8 | 593 | nat_49_mbed___init__, |
va009039 | 4:23becb24acb8 | 594 | nat_50_mbed_readPercentage, |
va009039 | 4:23becb24acb8 | 595 | nat_51_mbed_readDistance, |
va009039 | 0:65f1469d6bfb | 596 | }; |