b7572ad11b
Also now returns correct POSIX errno when an IO operation fails. Addresses issues #516 and #676.
507 lines
6.3 KiB
C
507 lines
6.3 KiB
C
/*
|
|
* This file is part of the Micro Python project, http://micropython.org/
|
|
*
|
|
* The MIT License (MIT)
|
|
*
|
|
* Copyright (c) 2013, 2014 Damien P. George
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*/
|
|
|
|
// qstrs specific to this port
|
|
|
|
Q(help)
|
|
Q(pyb)
|
|
Q(unique_id)
|
|
Q(bootloader)
|
|
Q(info)
|
|
Q(sd_test)
|
|
Q(present)
|
|
Q(power)
|
|
Q(wfi)
|
|
Q(disable_irq)
|
|
Q(enable_irq)
|
|
Q(stop)
|
|
Q(standby)
|
|
Q(source_dir)
|
|
Q(main)
|
|
Q(usb_mode)
|
|
Q(sync)
|
|
Q(gc)
|
|
Q(repl_info)
|
|
Q(delay)
|
|
Q(udelay)
|
|
Q(servo)
|
|
Q(pwm)
|
|
Q(read)
|
|
Q(readall)
|
|
Q(readline)
|
|
Q(write)
|
|
Q(have_cdc)
|
|
Q(hid)
|
|
Q(time)
|
|
Q(rng)
|
|
Q(LCD)
|
|
Q(SD)
|
|
Q(SDcard)
|
|
Q(FileIO)
|
|
// Entries for sys.path
|
|
Q(0:/)
|
|
Q(0:/lib)
|
|
Q(millis)
|
|
|
|
// for file class
|
|
Q(seek)
|
|
Q(tell)
|
|
|
|
// for RTC class
|
|
Q(RTC)
|
|
Q(info)
|
|
Q(datetime)
|
|
|
|
// for Pin class
|
|
Q(Pin)
|
|
Q(PinAF)
|
|
Q(PinNamed)
|
|
Q(init)
|
|
Q(value)
|
|
Q(low)
|
|
Q(high)
|
|
Q(name)
|
|
Q(port)
|
|
Q(pin)
|
|
Q(mapper)
|
|
Q(dict)
|
|
Q(debug)
|
|
Q(board)
|
|
Q(cpu)
|
|
Q(IN)
|
|
Q(OUT_PP)
|
|
Q(OUT_OD)
|
|
Q(AF_PP)
|
|
Q(AF_OD)
|
|
Q(ANALOG)
|
|
Q(PULL_NONE)
|
|
Q(PULL_UP)
|
|
Q(PULL_DOWN)
|
|
|
|
// for LED object
|
|
Q(LED)
|
|
Q(on)
|
|
Q(off)
|
|
Q(toggle)
|
|
Q(intensity)
|
|
|
|
// for Switch class
|
|
Q(Switch)
|
|
Q(callback)
|
|
|
|
// for UART class
|
|
Q(UART)
|
|
Q(baudrate)
|
|
Q(bits)
|
|
Q(stop)
|
|
Q(parity)
|
|
Q(init)
|
|
Q(deinit)
|
|
Q(all)
|
|
Q(send)
|
|
Q(recv)
|
|
|
|
// for Timer class
|
|
Q(Timer)
|
|
Q(counter)
|
|
Q(prescaler)
|
|
Q(period)
|
|
Q(callback)
|
|
Q(freq)
|
|
Q(mode)
|
|
Q(div)
|
|
|
|
// for ExtInt class
|
|
Q(ExtInt)
|
|
Q(pin)
|
|
Q(mode)
|
|
Q(pull)
|
|
Q(callback)
|
|
Q(line)
|
|
Q(enable)
|
|
Q(disable)
|
|
Q(swint)
|
|
Q(regs)
|
|
Q(IRQ_RISING)
|
|
Q(IRQ_FALLING)
|
|
Q(IRQ_RISING_FALLING)
|
|
Q(EVT_RISING)
|
|
Q(EVT_FALLING)
|
|
Q(EVT_RISING_FALLING)
|
|
|
|
// for I2C object
|
|
Q(I2C)
|
|
Q(mode)
|
|
Q(addr)
|
|
Q(baudrate)
|
|
Q(gencall)
|
|
Q(data)
|
|
Q(memaddr)
|
|
Q(timeout)
|
|
Q(init)
|
|
Q(deinit)
|
|
Q(is_ready)
|
|
Q(scan)
|
|
Q(send)
|
|
Q(recv)
|
|
Q(mem_read)
|
|
Q(mem_write)
|
|
|
|
// for SPI class
|
|
Q(SPI)
|
|
Q(init)
|
|
Q(deinit)
|
|
Q(send)
|
|
Q(recv)
|
|
Q(send_recv)
|
|
Q(mode)
|
|
Q(baudrate)
|
|
Q(polarity)
|
|
Q(phase)
|
|
Q(dir)
|
|
Q(bits)
|
|
Q(nss)
|
|
Q(firstbit)
|
|
Q(ti)
|
|
Q(crc)
|
|
Q(MASTER)
|
|
Q(SLAVE)
|
|
Q(MSB)
|
|
Q(LSB)
|
|
|
|
// for Accel object
|
|
Q(Accel)
|
|
Q(x)
|
|
Q(y)
|
|
Q(z)
|
|
Q(tilt)
|
|
Q(filtered_xyz)
|
|
|
|
// for ADC object
|
|
Q(ADC)
|
|
Q(ADCAll)
|
|
Q(read_timed)
|
|
Q(read_channel)
|
|
Q(read_core_temp)
|
|
Q(read_core_vbat)
|
|
Q(read_core_vref)
|
|
|
|
// for DAC class
|
|
Q(DAC)
|
|
Q(noise)
|
|
Q(triangle)
|
|
Q(write)
|
|
Q(write_timed)
|
|
Q(data)
|
|
Q(freq)
|
|
Q(mode)
|
|
Q(NORMAL)
|
|
Q(CIRCULAR)
|
|
|
|
// for Servo object
|
|
Q(Servo)
|
|
Q(pulse_width)
|
|
Q(calibration)
|
|
Q(angle)
|
|
Q(speed)
|
|
|
|
// for os module
|
|
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