Commit Graph

588 Commits

Author SHA1 Message Date
Paul Sokolovsky 237c519ac4 esp8266/scripts/flashbdev: Use all available Flash for filesystem.
All Flash sans firmware at the beginning and 16K SDK param block at the
end is used for filesystem (and that's calculated depending on the Flash
size).
2016-04-26 01:36:32 +03:00
Paul Sokolovsky ef2ffc0e4e esp8266/scripts/webrepl: Print client address for incoming connections. 2016-04-26 01:00:28 +03:00
Paul Sokolovsky c888831410 esp8266/scripts/webrepl: Print connection address.
Based on active network interfaces.
2016-04-26 00:59:30 +03:00
Paul Sokolovsky 6d103b6548 py: Move call_function_*_protected() functions to py/ for reuse.
They almost certainly needed by any C code which calls Python callbacks.
2016-04-25 19:31:17 +03:00
Paul Sokolovsky 4296a8dc5c esp8266/scripts/webrepl: Allow to override port. 2016-04-25 18:44:37 +03:00
Paul Sokolovsky bd66b09512 esp8266/scripts/webrepl: Don't start on import.
Explicit .start() is required now.
2016-04-25 00:33:27 +03:00
Paul Sokolovsky 8db4f363e9 esp8266/scripts/webrepl: Convert to persistent daemon. 2016-04-25 00:31:43 +03:00
Paul Sokolovsky 7c40b15a3f esp8266/scripts/webrepl: WebREPL based on C-level websocket object. 2016-04-24 23:04:21 +03:00
Paul Sokolovsky d422e56631 esp8266/scripts/websocket_helper: Disable debug output. 2016-04-22 18:19:54 +03:00
Paul Sokolovsky eb40769613 esp8266/scripts/websocket_helper: Module encapsulating handshake sequences. 2016-04-22 18:18:27 +03:00
Damien George b372156f74 esp8266: Change software SPI driver to use general pin HAL. 2016-04-22 10:44:06 +01:00
Damien George 67a6d31955 esp8266: Allow GPIO16 to be used as a pin in the uPy pin HAL.
Now I2C works with GPIO16 as the SCL or SDA pin.
2016-04-22 10:35:26 +01:00
Damien George a2d5d84ecc esp8266: Convert mp_hal_pin_obj_t from pin ptr to simple integer.
Most pin I/O can be done just knowing the pin number as a simple
integer, and it's more efficient this way (code size, speed) because it
doesn't require a memory lookup to get the pin id from the pin object.

If the full pin object is needed then it can be easily looked up in the
pin table.
2016-04-22 10:04:12 +01:00
Damien George 624738ca64 extmod/machine_i2c: Allow mp_hal_pin_obj_t to be any type, not a ptr. 2016-04-22 09:56:02 +01:00
Damien George d4f4cb6a24 esp8266/esp_mphal: Remove mp_hal_feed_watchdog.
It doesn't do anything and is not needed.  ets_loop_iter/ets_event_poll
now take care of feeding the WDT.
2016-04-21 15:30:29 +01:00
Damien George c4e26dd19a esp8266/uart: Remove obsolete UART rx buffering code.
It's now completely replaced by the ringbuf implementation.
2016-04-21 15:27:18 +01:00
Damien George d46bea9ffa esp8266: Implement UART.read functionality. 2016-04-21 15:19:19 +01:00
Damien George 7652ab77ef esp8266: Add uart_rx_wait and uart_rx_char functions. 2016-04-21 15:19:00 +01:00
Damien George 32d7cf6e44 esp8266: Implement basic deep-sleep capabilities.
Use the machine.deepsleep() function to enter the sleep mode.  Use the
RTC to configure the alarm to wake the device.

Basic use is the following:

    import machine

    # configure RTC's ALARM0 to wake device from deep sleep
    rtc = machine.RTC()
    rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)

    # do other things
    # ...

    # set ALARM0's alarm to wake after 10 seconds
    rtc.alarm(rtc.ALARM0, 10000)

    # enter deep-sleep state (system is reset upon waking)
    machine.deepsleep()

To detect if the system woke from a deep sleep use:

    if machine.reset_cause() == machine.DEEPSLEEP_RESET:
        print('woke from deep sleep')
2016-04-21 11:43:37 +01:00
Paul Sokolovsky 4fa1731b6e esp8266/modnetwork: .config(): Add "hidden ESSID" param. 2016-04-21 00:42:45 +03:00
Paul Sokolovsky cc1ef76f88 esp8266/scripts/flashbdev: Correct bootloader flash size to match real size.
Flash size as seen by vendor SDK doesn't depend on real size, but rather on
a particular value in firmware header, as put there by flash tool. That means
it's user responsibility to know what flash size a particular device has, and
specify correct parameters during flashing. That's not end user friendly
however, so we try to make it "flash and play" by detecting real size vs
from-header size mismatch, and correct the header accordingly.
2016-04-20 18:07:34 +03:00
Paul Sokolovsky 584406880c esp8266/scripts/_boot: Print notice when initial setup is executed. 2016-04-20 18:01:09 +03:00
Paul Sokolovsky 2494399a42 esp8266/scripts/flashbdev: Disable debug output/checks. 2016-04-20 00:35:46 +03:00
Paul Sokolovsky 46f0641fba esp8266/modnetwork: .config(): Add "channel" param. 2016-04-20 00:25:31 +03:00
Paul Sokolovsky 8dcce92606 esp8266/scripts: Don't try to create filesystem on 512KB devices or less.
There's no space for it.
2016-04-18 17:14:00 +03:00
Paul Sokolovsky 89e56a80b8 esp8266/modesp: Add flash_size() function.
Returns FlashROM size in bytes from vendor SDK's point of view, not
physical size.
2016-04-18 17:12:57 +03:00
Paul Sokolovsky 3a5a35aaec esp8266/scripts/flashbdev: Use all available space in 1MB FlashROM for FS. 2016-04-18 01:23:04 +03:00
Damien George d76ebde85e esp8266/modesp: Allow esp.deepsleep to take 2nd arg for RF wake opt. 2016-04-17 16:28:47 +01:00
Paul Sokolovsky 89aa7157d0 esp8266/README.md: Update feature list for current state of affairs. 2016-04-17 18:17:49 +03:00
Paul Sokolovsky 7e5715a6d5 esp8266/README.md: Typo fix. 2016-04-17 18:16:36 +03:00
Paul Sokolovsky 6f3b9933bd esp8266/esp_mphal: Protect dupterm_task_handler() from recursive exec. 2016-04-17 18:11:04 +03:00
Paul Sokolovsky dde9abad16 esp8266/moduos: Add dupterm_notify() function.
Should be called to notify that current dupterm object has more input
data to read.
2016-04-17 18:09:52 +03:00
Damien George 73ccb3fc5b esp8266: Adapt port to use new auto-qstr generation. 2016-04-16 13:20:02 +01:00
Paul Sokolovsky 050e645ef2 esp8266/modmachine: Add reset_cause() function. 2016-04-15 22:08:04 +03:00
Damien George 091dcaea2f esp8266/moduos: Add uos.mkdir function. 2016-04-14 23:37:15 +01:00
Damien George 7d2c685544 esp8266/scripts/_boot: Mount block device on "" instead of "/".
"" is the correct name of the root directory when mounting a device there
(as opposed to "/").  One can now do os.listdir('/') and open('/abc'), as
well as os.listdir() and open('abc').
2016-04-14 22:56:21 +01:00
Paul Sokolovsky d3ab4bc7ca esp8266/qstrdefsport.h: Mark qstr's for "esp" module. 2016-04-15 00:11:22 +03:00
Paul Sokolovsky 4f811d0e4c esp8266: Enable input() builtin. 2016-04-15 00:08:39 +03:00
Paul Sokolovsky 9b0714b24c py: Declare help, input, open builtins in core.
These are *defined* per-port, but why redeclare them again and again.
2016-04-15 00:07:56 +03:00
Paul Sokolovsky 272fad6d9c esp8266/scripts/port_diag.py: Module to collect diagnostic info.
A shortcut for users to provide background diagnostic info for bug
reports.
2016-04-14 18:54:11 +03:00
Paul Sokolovsky 0a400a6333 esp8266: Switch integer arith routines to BootROM. 2016-04-14 15:06:07 +03:00
Damien George df3b1741b6 esp8266: Separate 1-wire timing funcs from Python module to save iRAM.
esponewire.c contains low-level timing-critical functions that go in
iRAM.  modonewire.c contains Python wrapper code.
2016-04-14 12:44:26 +01:00
Damien George 674bf1bc81 esp8266: Add hard IRQ callbacks for pin change on GPIO0-15. 2016-04-14 12:44:26 +01:00
Damien George d9d408135d esp8266: Add dummy entries for non-existing pins to simplify pin logic.
Now pins can be easily looked up in the table using the pin number as the
index and vice versa.
2016-04-14 12:43:25 +01:00
Damien George a9a732af1f esp8266: Remove pin_id field from C pin object.
This field is the same as phys_port and not needed.
2016-04-14 12:43:25 +01:00
Damien George 0a2e9650f5 py: Add ability to have frozen persistent bytecode from .mpy files.
The config variable MICROPY_MODULE_FROZEN is now made of two separate
parts: MICROPY_MODULE_FROZEN_STR and MICROPY_MODULE_FROZEN_MPY.  This
allows to have none, either or both of frozen strings and frozen mpy
files (aka frozen bytecode).
2016-04-13 16:07:47 +01:00
Paul Sokolovsky 959ed931a4 esp8266/esp_mphal: call_dupterm_read(): Fix order of deactivating on EOF.
First deactivate, then print diagnostic message.
2016-04-13 16:35:50 +03:00
Paul Sokolovsky 19e3c9d53a esp8266/esp_mphal: Don't swallow exceptions in dupterm's read()/write().
The idea is that if dupterm object can handle exceptions, it will handle
them itself. Otherwise, object state can be compromised and it's better
to terminate dupterm session. For example, disconnected socket will keep
throwing exceptions and dump messages about that.
2016-04-13 16:34:17 +03:00
Paul Sokolovsky 47442d9f52 lib/utils/printf: Rework overriding printer of DEBUG_printf().
By default it uses mp_plat_print, but a port may override it to another
value with MICROPY_DEBUG_PRINTER_DEST.
2016-04-13 11:53:12 +03:00
Damien George 3177ef544f esp8266: In callback helpers, pop nlr_buf on successful call.
nlr_pop must be called if no exception was raised.

Also, return value of these callback helpers is made void because ther
is (currently) no use for it.
2016-04-13 00:01:28 +01:00
Damien George e813ea1070 esp8266: Enable framebuf module. 2016-04-12 14:06:54 +01:00
Damien George a525493e40 esp8266: Switch from using custom I2C driver to generic extmod one. 2016-04-12 14:06:54 +01:00
Damien George ac63ca7bc5 esp8266: Implement basic C-level pin HAL. 2016-04-12 14:06:54 +01:00
Damien George 1a65ff1b72 esp8266: Protect modpyb.h header file from multiple inclusions.
Also include py/obj.h so the header is self contained.
2016-04-12 14:06:54 +01:00
Damien George 3a37426b29 esp8266/scripts/inisetup.py: Use "-" in AP ESSID instead of space. 2016-04-12 00:47:21 +03:00
Paul Sokolovsky 260b839483 esp8266/scripts/inisetup.py: Set WPA/WPA2 AP mode with a predefined password. 2016-04-12 00:46:04 +03:00
Paul Sokolovsky 40f5ecd3a8 esp8266: Add Python modules for initial configuration.
Main entry point is _boot.py which checks whether FAT FS in flash mountable,
and if so, mounts it. Otherwise, it checks if flash is empty, and if so,
performs initial module setup: makes FAT FS, configures default AP name,
etc. As a last option, if flash is not empty, and could not be mounted,
it means filesystem corruption, and warning message with instructions is
printed in an infinite loop.
2016-04-12 00:37:04 +03:00
Paul Sokolovsky 2f5935269b esp8266/scripts/main.py: Remove stale file. 2016-04-12 00:35:13 +03:00
Paul Sokolovsky 54b89665fc esp8266/modnetwork: .config(): Add "password" param (W/O). 2016-04-12 00:18:40 +03:00
Paul Sokolovsky 7acc252e93 esp8266/modnetwork: .config(): Add "authmode" param. 2016-04-12 00:17:31 +03:00
Paul Sokolovsky 6f3fc9bfa1 esp8266/modnetwork: .config(): Check interface whose config is requested. 2016-04-12 00:16:16 +03:00
Paul Sokolovsky f49d63a75c esp8266: Enable websocket module. 2016-04-11 21:25:43 +03:00
Paul Sokolovsky 1cc81ed449 esp8266/modesp: Add freemem() and meminfo() functions.
They call into vendor SDK functions system_get_free_heap_size() and
system_print_meminfo() respectively.
2016-04-11 01:16:38 +03:00
Paul Sokolovsky c734de490a esp8266/main: mp_builtin_open(): Implement, using vfs_proxy_call(). 2016-04-10 16:59:19 +03:00
Damien George 6e87aeb841 esp8266: Implement multistage bootstrap sequence.
Upon start-up, _boot module is executed from frozen files to do early
initialization, e.g. create and mount the flash filesystem. Then
"boot.py" is executed if it exists in the filesystem. Finally, "main.py"
is executed if exists to allow start-on-boot user applications.

This allows a user to make a custom boot file or startup application
without recompiling the firmware, while letting to do early initialization
in Python code.

Based on RFC https://github.com/micropython/micropython/issues/1955.
2016-04-10 14:24:41 +03:00
Damien George 2c407bcf20 esp8266: Switch from terse error messages to normal ones.
Adds 2k to the code size.
2016-04-07 00:38:08 +03:00
Paul Sokolovsky d85439fd19 esp8266/README: Add short troubleshooting section. 2016-04-07 00:21:04 +03:00
Damien George 1a0a323ca8 esp8266: Add initial implementation of machine.UART.
Currently UART(0) and UART(1) are exposed and only uart.write works.
2016-04-06 19:45:52 +03:00
Damien George 96eca22322 esp8266: Make destination for vendor OS debug output soft-configurable.
Use esp.osdebug(None) to disable, or esp.osdebug(uart_id) to send output
to a UART.
2016-04-06 00:12:58 +03:00
Paul Sokolovsky 2c8356c482 esp8266/modnetwork: require_if(): Report the actual interface required. 2016-04-05 16:09:03 +03:00
Paul Sokolovsky de12502d89 esp8266: Move pyb.unique_id() to machine.unique_id(). 2016-04-05 00:57:49 +03:00
Paul Sokolovsky 81fd5685fc esp8266: Move pyb.hard_reset() to machine.reset(). 2016-04-05 00:20:25 +03:00
Paul Sokolovsky 69256ac0b1 esp8266: Bump heap size to 24k. 2016-04-03 19:55:45 +03:00
Paul Sokolovsky debbaac1bd esp8266: Update flashing instructions in README. 2016-04-03 16:04:18 +03:00
Paul Sokolovsky 919b70b7ec esp8266: Switch back to flashing combined firmware (single file).
With gap between segments minimized, there's not much padding to flash,
so no big speed overhead.
2016-04-03 15:48:46 +03:00
Paul Sokolovsky 8d2bcaf3cd esp8266: Minimize gap between Inst/DataRAM segments and FlashROM segment.
With .rodata being in FlashROM now, gap can be much smaller now. InstRAM
can be max 32K, and with segment headers, that already makes it more than
32K. Then there's some .data still, and the next Flash page boundary is
0x9000. That figure should be more or less future-proof.

TODO: Refactor makeimg to take FlashROM segment offset from file name.
2016-04-03 15:45:14 +03:00
Paul Sokolovsky 9698a60591 esp8266/ets_alt_task: Comment out debug output. 2016-04-03 01:04:01 +03:00
Paul Sokolovsky fcd6862597 esp8266: Bump iROM size to 512k.
Needed for frozen scripts, and for future growth of binary.
2016-04-03 00:57:27 +03:00
Paul Sokolovsky ef0c5db2ed esp8266: Move .rodata where it belongs with -mforce-l32 help. 2016-04-03 00:51:51 +03:00
Paul Sokolovsky 333a63efaa esp8266/README: Add link to docs. 2016-04-03 00:01:31 +03:00
Damien George a0cb4eda9a esp8266: Use VM_HOOK to call ets_loop_iter within the VM.
Starting with a divisor of 10, pystone_lowmem gives a score of 256.
2016-04-02 01:34:32 +03:00
Damien George 6a051a8e0b esp8266/uart: Get ctrl-C working now that event-based REPL is disabled. 2016-04-01 14:53:01 +03:00
Damien George fb6cc96951 esp8266/uart: Comment out old, unused rx buffering code.
This was originally used for non-event based REPL processing.  Then it
was unused when event-based processing was activated.  But now that event
based is disabled, and non-event based is back, there has been new ring
buffer code to process the chars.
2016-04-01 14:30:47 +03:00
Paul Sokolovsky fc4c43a72e esp8266: Switch to non event-driven REPL to support paste mode. 2016-04-01 14:22:28 +03:00
Paul Sokolovsky 785cf9a61f esp8266: Support dedicated REPL loop (aka pull-style).
Event-driven loop (push-style) is still supported and default (controlled
by MICROPY_REPL_EVENT_DRIVEN setting, as expected).

Dedicated loop worked even without adding ets_loop_iter(), though that
needs to be revisited later.
2016-04-01 14:02:36 +03:00
Paul Sokolovsky 777232c9a5 esp8266: Disallow recursive calls to REPL.
Before this change, if REPL blocked executing some code, it was possible
to still input new statememts and excuting them, all leading to weird,
and portentially dangerous interaction.

TODO: Current implementation may have issues processing input accumulated
while REPL was blocked.
2016-04-01 12:53:50 +03:00
Paul Sokolovsky 5531437941 esp8266: Move PHY mode constants from modesp to modnetwork. 2016-04-01 12:10:11 +03:00
Damien George 4b597a1c1a esp8266: Reset term_obj on reboot.
Also, term_obj can be NULL if socket enables REPL duplication signalling
before os.dupterm is called, so it should be checked.
2016-03-31 19:56:52 +03:00
Paul Sokolovsky 98af891610 esp8266: Implement input part of dupterm handling.
The idea is following: underlying interrupt-driven or push-style data source
signals that more data is available for dupterm processing via call to
mp_hal_signal_dupterm_input(). This triggers a task which pumps data between
actual dupterm object (which may perform additional processing on data from
low-level data source) and input ring buffer.
2016-03-31 19:49:55 +03:00
Paul Sokolovsky 61fa7c8152 esp8266: Switch back to accumulating input data via ring buffer.
But now it's generic ring buffer implemented via ringbuf.h, and is intended
for any type of input, including dupterm's, not just UART. The general
process work like this: an interrupt-driven input source puts data into
input_buf, and then signals new data available via call to
mp_hal_signal_input().
2016-03-30 18:50:38 +03:00
Paul Sokolovsky 2e75a17bab esp8266: Fix issue when current repl line was garbage-collected.
Reference it from root pointers section.
2016-03-30 18:13:03 +03:00
Damien George 9475cc59e6 esp8266: Support synchronous wifi scanning.
That is: aps = if0.scan()

TODO: make sure that returned list has tuple with values in "standard"
order (whatever that standard is).
2016-03-30 11:35:03 +03:00
Paul Sokolovsky d88250c06e esp8266: Reduce heap size for now to avoid random segfaults on WiFi connect. 2016-03-29 21:14:41 +03:00
Paul Sokolovsky c4506ed869 esp8266: Let esp8266 "os" messages go to standard (REPL) UART.
That's definitely helpful for debugging.
2016-03-29 21:10:10 +03:00
Paul Sokolovsky 402a743821 esp8266/esp_mphal: Add support for debug UART-only output.
Helpful when debugging dupterm support (because otherwise all output is
spooled to dupterm too).

To use:

mp_printf(&mp_debug_print, "...");
2016-03-29 11:48:43 +03:00
Paul Sokolovsky 8fc5e56a6a esp8266: Enable uos.dupterm() method. 2016-03-29 11:41:23 +03:00
Paul Sokolovsky c961889e34 esp8266: Add basic support for duplicating REPL output. 2016-03-29 11:13:32 +03:00
Damien George 6ca17c1922 esp8266: Implement os.urandom function.
Uses what is suspected to be a hardware random number generator.
2016-03-29 10:29:57 +03:00
Paul Sokolovsky b4070ee8a4 esp8266: Allow to build without FatFs support again. 2016-03-28 21:35:41 +03:00
Paul Sokolovsky 2f02302e22 esp8266: Support importing modules from filesystem. 2016-03-28 18:39:34 +03:00
Damien George 71d40f132d esp8266: Zero out fs_user_mount state on (soft) reset.
Otherwise device stays mounted on soft reset and leads to corruption
(since block device object is now gone).
2016-03-28 13:28:41 +03:00
Paul Sokolovsky 9edd736ee6 esp8266/moduos: Add os.remove(), proxying to VFS object. 2016-03-28 12:50:07 +03:00
Paul Sokolovsky e8e116e7fc esp8266/moduos: Factor out VFS method proxy helper. 2016-03-28 12:44:36 +03:00
Paul Sokolovsky 8b08a0d9ed esp8266/moduos: Add listdir() proxy for MP_STATE_PORT(fs_user_mount)[0].
I.e. os.listdir(...) will redirect to
MP_STATE_PORT(fs_user_mount)[0].listdir(...).
2016-03-28 12:29:47 +03:00
Damien George 61230e007d esp8266/moduos: Use mp_rom_map_elem_t for static const dictionary. 2016-03-28 12:08:36 +03:00
Paul Sokolovsky b01a373adb esp8266: deploy: Use --flash_size=8m option to esptool.py.
Most esp8266 modules have at least 1MB (8Mbit) of flash. If not set, vendor
functions allow to access only first 512K.
2016-03-28 11:28:16 +03:00
Paul Sokolovsky cd6194aefc esp8266/esp8266.ld: Put FatFs to FlashROM. 2016-03-27 17:15:25 +03:00
Paul Sokolovsky 374654f2b8 esp8266: Enable FatFs support. 2016-03-27 17:13:47 +03:00
Paul Sokolovsky fe9bc0c573 esp8266/README: Update for the current status of the port. 2016-03-27 16:10:58 +03:00
Paul Sokolovsky bbc65d4eda esp8266/modesp: flash_read(): Accept buffer to read to as a second argument. 2016-03-27 15:34:35 +03:00
Paul Sokolovsky fd86bf5917 esp8266/modesp: flash_write(): Writes in multiples of 4 bytes. 2016-03-27 15:32:58 +03:00
Paul Sokolovsky 53302f1616 esp8266: Set up UART handling task soon into init process.
Otherwise, events may be posted to non-initialized task, which leads to
segfaults.
2016-03-27 14:33:17 +03:00
Paul Sokolovsky 935e021250 esp8266: Put modpybi2c.o to FlashROM. 2016-03-26 10:59:25 +02:00
Damien George c33a76059f esp8266/tests: Add neopixel.py test. 2016-03-26 10:55:29 +02:00
Damien George 3962766be0 esp8266: Add esp.neopixel_write function to bit-bang WS2812 data. 2016-03-26 10:55:21 +02:00
Damien George b62beadae0 esp8266: Link ADC class into machine module. 2016-03-26 00:41:37 +02:00
Paul Sokolovsky f71c0699a5 esp8266: Put utils.o to FlashROM. 2016-03-26 00:39:51 +02:00
Paul Sokolovsky 9c7e3353e5 esp8266: Put lexerstr32.o into FlashROM. 2016-03-26 00:39:02 +02:00
Paul Sokolovsky ba640bde55 esp8266/esppwm.c: Fix IRQ handler prototype. 2016-03-26 00:34:28 +02:00
Damien George 632d8efa05 esp8266: Add PWM support.
PWM implementation uses a timer and interrupts (FRC1), taken from
Espressif's/NodeMCU's implementation and adapted for our use.

8 channels are supported, on pins 0, 2, 4, 5, 12, 13, 14, 15.

Usage:

    import machine
    pwm0 = machine.PWM(machine.Pin(0))
    pwm0.freq(1000)
    pwm0.duty(500)

Frequency is shared (ie the same) for all channels.  Frequency is
between 1 and 1000.  Duty is between 0 and 1023.
2016-03-26 00:32:37 +02:00
Damien George 82b95f625e esp8266: Implement software SPI class.
Supports speeds up to 500k baud, polarity=0/1, phase=0/1, and using any
pins.  Only supports MSB output at the moment.
2016-03-25 23:28:13 +02:00
Paul Sokolovsky ac671546d1 esp8266/README: Remove outdated reference to initial port heap size. 2016-03-25 15:02:23 +02:00
Damien George a5d48b1162 esp8266: Add tests/onewire.py as a driver and test code for ds18b20 dev. 2016-03-24 17:35:26 +02:00
Damien George 78d0dde562 esp8266: Add onewire helper functions as C module.
Includes functions to read and write bits and bytes.
2016-03-24 17:33:42 +02:00
Damien George 0cdbd356fd esp8266: Implement bit-bang I2C read, and add i2c.readfrom method.
I2C reading tested with TSL2561 luminosity sensor.
2016-03-24 11:46:05 +02:00
Damien George 5b9f361824 esp8266: Clean up bit-bang I2C implementation.
Changed from using set_sda_scl function to independent set_sda and
set_scl functions.
2016-03-24 11:37:52 +02:00
Paul Sokolovsky 667d64b430 esp8266/modpybi2c: Add missing include. 2016-03-24 11:21:36 +02:00
Damien George dd32f02cc3 esp8266: Add basic I2C driver, with init and writeto methods.
Tested and working with SSD1306 I2C display.
2016-03-24 11:17:17 +02:00
Damien George 7059c8c23c esp8266: Expose pin object as a public structure for use as C pin API.
This is an initial attempt at making a simple C pin API for writing
things like I2C drivers in C.
2016-03-24 11:07:41 +02:00
Paul Sokolovsky a1d072df81 esp8266: Enable auto-indent in REPL. 2016-03-23 16:30:29 +02:00
Paul Sokolovsky df1f6783f2 esp8266: Add "socket" and "usocket" aliases for lwip module. 2016-03-23 16:25:55 +02:00
Paul Sokolovsky 494aea3e86 esp8266: Enable non-blocking stream support. 2016-03-23 16:15:49 +02:00
Damien George 5bc9398d9d esp8266: Enable more extmod's: uheapq, ure, uzlib. 2016-03-23 14:19:14 +02:00
Damien George 8000d51b68 esp8266: Add module weak link from json to ujson. 2016-03-23 14:16:46 +02:00
Paul Sokolovsky 1a0adf49df esp8266: Enable urandom module. 2016-03-23 13:33:17 +02:00
Damien George e673714cfe esp8266: Make mp_hal_delay_us work with new event framework. 2016-03-23 13:01:21 +02:00
Paul Sokolovsky 58e2ad42ae esp8266: Update README with the latest features. 2016-03-23 12:08:15 +02:00
Damien George 556a1df6fd esp8266/ets_alt_task: Make FIRST_PRIO=0 to cover all task priorities.
FIRST_PRIO=2 works but using 0 is hopefully safer, and can anyway be
optimised in the future.
2016-03-17 16:28:06 +00:00
Paul Sokolovsky 9d7b871f58 esp8266: Store frozen modules in FlashROM.
Requires special lexer to access their contents.
2016-03-17 23:06:47 +08:00
Paul Sokolovsky e5c39a3a9e esp8266: Switch to lwIP built from source.
Using https://github.com/pfalcon/esp-open-lwip project.
2016-03-12 11:45:53 +07:00
Christopher Arndt 3d0e3a3d3e esp8266: Mention git submodule in build instructions for esp8266 port. 2016-03-11 10:07:02 +00:00
Damien George 932f07ccf5 esp8266: Rejig Makefile so extmod/modlwip.o is placed under build/. 2016-03-11 12:00:01 +07:00
Paul Sokolovsky 4c2cb7e384 esp8266: Define MICROPY_EVENT_POLL_HOOK for the port. 2016-03-11 10:41:10 +07:00
Paul Sokolovsky 6e5c31c947 esp8266: Be sure to build ets_alt_task. 2016-03-11 09:43:39 +07:00
Paul Sokolovsky a099bfe89c esp8266/esp_mphal: Add higher-level event polling function.
ets_event_poll() polls both system events and uPy pending exception.
2016-03-11 09:42:03 +07:00
Paul Sokolovsky 54fc247f9b esp8266/ets_alt_task: Update for vendor SDK 1.5.0.
SDK 1.5.0 has a task with priority 3: ets_task(401001f4, 3, 3fff9808, 4).
Recognizing SDK version requires the latets esp-open-sdk build.
2016-03-11 09:17:57 +07:00
Paul Sokolovsky 97375f4576 esp8266/ets_alt_task: Be sure to "pop" event before calling its handler.
Otherwise, if handler calls recursive event loop, there's infinite
recursion (because the loop calls the same handler on same event again).
2016-03-11 09:16:34 +07:00
Damien George 7261f17b9e esp8266: Feed WDT in ets_loop_iter(). 2016-03-11 09:15:06 +07:00
Paul Sokolovsky 97c2628900 esp8266: Add alternative event loop implementation.
This implementation provides the same interface and uses the same
datastructures as used by BootROM, i.e. is a drop-in replacement for it.
But it offers one advantage: it allows to run single iteration of
event-pumping loop.

Original BootROM function are renamed, prefixed with underscore. There's
a switch which allows to use forward calls to them, for compatibility
testing.

The implementation also includes workarounds for hardware timer handler,
and these workarounds may be SDK version specific.
2016-03-11 09:13:31 +07:00
Paul Sokolovsky 5239a8a82b esp8266/modnetwork: Add symbolic names for network interfaces: STA_IF & AP_IF.
These are expected to be passed to network.WLAN() to instantiate network
interface objects.
2016-03-10 10:44:15 +07:00
Paul Sokolovsky a49c16069c esp8266/modnetwork: Introduce interface .config() method.
Allows to set (in case keyword args are given) or query (in case a single
"symbolic keyword" (a string, value is the same as keyword)) arbitrary
interface paramters (i.e. extensible and adaptable to various hardware).

Example usage:

ap_if = network.WLAN(1)
ap_if.config(essid="MicroPython on Air")
print(ap_if.config("essid"))
2016-03-10 10:41:55 +07:00
Paul Sokolovsky d5a12a6608 esp8266/modnetwork: Move config defines to the top. 2016-03-10 10:39:52 +07:00
Paul Sokolovsky 1c43a0fbf8 esp8266/modnetwork: Add per-interface .active() method.
Allows to up/down interface when called with a boolean, or query current
state if called without args. This per-interface method is intended to
supersede adhoc network.wifi_mode() function.
2016-03-10 09:31:23 +07:00
Paul Sokolovsky 7378c50b2f esp8266: Move wifi_mode() and phy_mode() to network module. 2016-03-10 09:29:21 +07:00
Paul Sokolovsky 9e8396accb esp8266/modnetwork: Allow to configure STA and AP interfaces separately.
On ESP8266, there're 2 different interfaces. Pretending it's not the case
desn't make sense. So, network.WLAN() now takes interface id, and returns
interface object. Individual operations are then methods of interface
object. Some operations require i/f of specific type (e.g. .connect()
makes sense only for STA), other are defined for any (e.g. .ifconfig(),
.mac()).
2016-03-10 09:24:54 +07:00
Damien George f7be80398e esp8266: Move pyb.freq to machine.freq. 2016-03-09 09:03:59 +07:00
Paul Sokolovsky a0cd118b14 esp8266/main: Module to run on boot is "boot", not "main". 2016-03-08 12:37:24 +07:00
Damien George 3fbbbecec9 esp8266: Put more code in iROM section.
Also explicitly name the py/*.o files in the linker file, to enable easy
testing of putting certain ones in iRAM.
2016-03-08 11:31:39 +07:00
Paul Sokolovsky d684f872bd esp8266/Makefile: Add define for ESP8266 lwIP. 2016-03-08 10:29:05 +07:00
Damien George 05dda0ee9e esp8266: Enable modlwip. 2016-03-08 10:21:50 +07:00
Paul Sokolovsky 88b0490945 esp8266: Don't gc-collect BSS.
None of the other ports do, since introduction of mp_state_ctx_t. In
the case of current esp8266 port, heap is inside BSS, so scanning it
picked up a lot of dead pointers.
2016-03-08 10:16:06 +07:00
Paul Sokolovsky db984b73f3 esp8266: Enable stack overflow checking. 2016-03-07 14:15:00 +07:00
Damien George 52d7685d9a esp8266: Allow Makefile's BAUD variable to be overridden. 2016-03-06 05:57:36 +02:00
Paul Sokolovsky d9d4a72679 esp8266/uart: Add uart_flush() function. 2016-03-05 22:13:26 +02:00
Paul Sokolovsky d3a4d39687 esp8266: Support raising KeyboardInterrupt on Ctrl+C. 2016-03-05 22:01:27 +02:00
Damien George 077448328a esp8266/etshal.h: More prototypes of ESP8266 SDK/BootROM functions. 2016-03-05 21:56:32 +02:00
Paul Sokolovsky 26f0616e8f esp8266/modmachine: Add Pin class from modpyb. 2016-03-05 21:43:11 +02:00
Paul Sokolovsky eb247eacd8 esp8266/modpybpin: Add support for GPIO16.
GPIO16 is actually special-function I/O, though some boards have LED there.
2016-03-05 21:37:55 +02:00
Damien George 342d903a13 esp8266: Expose simple pin API at C level. 2016-03-05 21:36:32 +02:00
Damien George cdad2b6f4d esp8266: Implement Pin.__call__() and Pin.OPEN_DRAIN mode.
OPEN_DRAIN is of course synthesised.  All pin modes are tested and
working.
2016-03-05 21:35:32 +02:00
Paul Sokolovsky 8ab16b6af0 esp8266: Add custom _assert() function.
Enabling standard assert() (by removing -DNDEBUG) produces non-bootable
binary (because all messages go to .rodata which silently overflows).
So, for once-off debugging, have a custom _assert().
2016-03-05 11:30:15 +02:00
Paul Sokolovsky c70637bc00 esp8266/modmachine: Timer: Add ONE_SHOT and PERIODIC symbolic constants. 2016-03-04 22:26:59 +02:00
Paul Sokolovsky 98b727c931 esp8266/modmachine: Use etshal.h. 2016-03-04 19:41:15 +02:00
Paul Sokolovsky f22a4f8e0a esp8266/etshal.h: Add timer functions prototypes. 2016-03-04 19:39:24 +02:00
Paul Sokolovsky f39bcb304b esp8266/modmachine: Changing params of a timer requires disarming it first. 2016-03-04 18:41:37 +02:00
Paul Sokolovsky 7193086c03 esp8266/modmachine: Basic implementation of Timer for OS virtual timers. 2016-03-04 18:40:35 +02:00
Paul Sokolovsky 4284b3811f esp8266: Enable modmachine. 2016-03-04 17:37:13 +02:00
Paul Sokolovsky 5d7c408ba8 esp8266: Add modmachine with mem* arrays. 2016-03-04 17:34:25 +02:00
Paul Sokolovsky 6abafca1aa esp8266/modutime: Support float argument to time.sleep(). 2016-03-04 16:52:30 +02:00
Paul Sokolovsky a4c8ef9d16 esp8266: Reset "virtual RTC" on power on.
Initialize RTC period coefficients, etc. if RTC RAM doesn't contain valid
values. time.time() then will return number of seconds since power-on, unless
set to different timebase.

This reuses MEM_MAGIC for the purpose beyond its initial purpose (but the whole
modpybrtc.c need to be eventually reworked completely anyway).
2016-03-04 16:49:01 +02:00
Damien George 57884996b9 esp8266: Add time.{sleep_ms,sleep_us,ticks_ms,ticks_us,ticks_diff}.
Framework for time.ticks_cpu added, but not implemented.
2016-03-04 09:25:53 +02:00
Damien George b41a14a4b9 esp8266: Add mp_hal_delay_us function. 2016-03-04 09:25:05 +02:00
Damien George f70873db23 esp8266: Enable more features in mpconfigport.h.
This is to get the test suite running and passing.
2016-03-03 23:34:31 +02:00
Paul Sokolovsky 7480ee5892 esp8266: Enable uhashlib module. 2016-03-03 20:14:50 +02:00
Paul Sokolovsky 70fb9ee99b esp8266: Enable config settings helpful for debugging. 2016-03-03 20:12:26 +02:00
Paul Sokolovsky 259f1344ca esp8266/esp8266.ld: Link in SDK version section.
Otherwise, os.uname() returns empty string for SDK version.
2016-03-03 15:37:19 +02:00
Paul Sokolovsky ff69a1d27d esp8266: Enable ujson, ubinascii, and uctypes modules. 2016-03-03 15:35:29 +02:00
Damien George 02ea74d8f5 esp8266: Add network.ifconfig(). 2016-03-02 23:04:21 +02:00
Damien George 1febaf3ac3 esp8266: Change "soft reboot" message to work with pyboard.py. 2016-03-02 22:58:48 +02:00
Damien George d083d7d610 esp8266: Allow Makefile's PORT variable to be overridden. 2016-03-02 22:50:55 +02:00
Damien George 6f4357c28e esp8266: Enable math module. 2016-03-02 22:43:10 +02:00
Damien George 6d0629bddc esp8266: Enable float support, using 30-bit stuffed floats.
No complex numbers though.
2016-03-02 22:43:10 +02:00
Damien George ecd1272d16 esp8266: Switch bignum implementation from long-long to mpz. 2016-03-02 22:43:10 +02:00
Paul Sokolovsky 609a9c6b71 eagle.rom.addr.v6.ld: More symbols from SDK 1.5.0. 2016-02-14 13:09:42 +02:00
Paul Sokolovsky a2e39a756c esp8266/modpybrtc: Simplify multiplication by fixed-point value. 2016-02-12 23:20:52 +02:00
Paul Sokolovsky 9e78ab4b86 esp8266/README: Add hint about adding toolchain to PATH. 2016-02-08 22:35:24 +02:00
Paul Sokolovsky 814b1ae3a9 esp8266/modpybrtc: pyb_rtc_memory(): Fix copy-paste error. 2016-02-08 21:39:33 +02:00
Alex March 81407729a5 esp8266/modesp: Implement flash_write(), flash_erase(). 2016-02-08 11:42:24 +02:00
Damien George 5b3f0b7f39 py: Change first arg of type.make_new from mp_obj_t to mp_obj_type_t*.
The first argument to the type.make_new method is naturally a uPy type,
and all uses of this argument cast it directly to a pointer to a type
structure.  So it makes sense to just have it a pointer to a type from
the very beginning (and a const pointer at that).  This patch makes
such a change, and removes all unnecessary casting to/from mp_obj_t.
2016-01-11 00:49:27 +00:00
Paul Sokolovsky adfe4ff72a esp8266: Support CFLAGS_EXTRA. 2016-01-08 01:30:20 +02:00
Paul Sokolovsky 43fecb0acb esp8266/modesp: Allow to compile out proprietary espconn stuff. 2015-12-30 15:53:51 +02:00
Paul Sokolovsky fce0036a67 esp8266: mac() function belongs to network module per the latest API. 2015-12-27 10:03:32 +02:00
Damien George 84b245f187 lib/utils: Add pyexec_frozen_module to load and execute frozen module.
This is a convenience function similar to pyexec_file.  It should be used
instead of raw mp_parse_compile_execute because the latter does not catch
and report exceptions.
2015-12-26 12:32:33 +00:00
Paul Sokolovsky abd0fcfc86 esp8266: Remove superfluous includes. 2015-12-21 22:08:06 +02:00
Paul Sokolovsky e13d462f77 esp8266/modesp: flash_read() takes 2 args (fix typo). 2015-12-21 22:07:11 +02:00
Paul Sokolovsky 90202b4c0d esp8266/modesp: Implement flash_read(offset, size_bytes) function.
Based on vendor API documentation, untested on real hardware.
2015-11-24 23:29:26 +02:00
Paul Sokolovsky 73ff0687f2 lib/utils/printf: Move from stmhal/ .
This file contains various MicroPython-specific helper functions, so isn't
good fit for lib/libc/.
2015-11-10 18:58:58 +02:00
Damien George 40274fec9c lib/pyexec: Move header pyexec.h from stmhal directory. 2015-11-09 13:13:09 +00:00
Paul Sokolovsky 0ec51441de stmhal: pyexec.c is common module, move to lib/utils/ . 2015-10-31 19:35:10 +03:00
Damien George 731f359292 all: Add py/mphal.h and use it in all ports.
py/mphal.h contains declarations for generic mp_hal_XXX functions, such
as stdio and delay/ticks, which ports should provide definitions for.  A
port will also provide mphalport.h with further HAL declarations.
2015-10-31 19:14:30 +03:00
Paul Sokolovsky 6a09e7d7ae esp8266: Switch to standard mp_hal_ticks_ms() MPHAL function. 2015-10-29 19:40:05 +03:00
Paul Sokolovsky ebd9f550e8 esp8266: Switch to standard mp_hal_delay_ms() MPHAL function. 2015-10-29 13:03:59 +03:00
Paul Sokolovsky 5699fc9d0e esp8266: Switch to standard mp_hal_delay_us() MPHAL function. 2015-10-29 02:06:58 +03:00
Paul Sokolovsky 0dbd928cee Makefiles: Remove duplicate object files when linking.
Scenario: module1 depends on some common file from lib/, so specifies it
in its SRC_MOD, and the same situation with module2, then common file
from lib/ eventually ends up listed twice in $(OBJ), which leads to link
errors.

Make is equipped to deal with such situation easily, quoting the manual:
"The value of $^ omits duplicate prerequisites, while $+ retains them and
preserves their order." So, just use $^ consistently in all link targets.
2015-10-24 15:46:53 +03:00
Damien George f09f8097d5 esp8266: Put more code in irom0 section, to get it building again. 2015-10-20 22:59:31 +01:00
Paul Sokolovsky e0f5df579b all: Make netutils.h available to all ports by default.
Generally, ports should inherit INC from py.mk, append to it, not
overwrite it. TODO: Likely should do the same for other vars too.
2015-10-19 18:32:42 +03:00
Damien George 0334058fa4 Rename "Micro Python" to "MicroPython" in REPL, help, readme's and misc. 2015-10-12 00:06:25 +01:00
Bill Owens e2bfa471fa esp8266: Added wlan.isconnected() to maintain parity with other ports. 2015-09-15 20:07:50 +03:00
Damien George 229b908d2e esp8266: Remove "time" command from deploy target. 2015-09-12 22:22:30 +01:00
Bill Owens a66a99bfd8 esp8266: Added wifi_mode() to read and set WiFi operating mode. 2015-08-29 16:58:51 +03:00
Damien George 75b1d881ec esp8266: Use m_new/m_renew/m_del funcs instead of private gc_xxx. 2015-07-20 12:14:21 +01:00
Paul Sokolovsky ab14c30493 esp8266: modesp: Update for gc_realloc() refactor.
TODO: Contributed code in modesp incorrectly uses private gc_* API.
2015-07-19 00:28:16 +03:00
Paul Sokolovsky b19d273beb esp8266: Allow to easily override programming baudrate. 2015-07-04 00:36:10 +03:00
Damien George de8b585ab7 esp8266: Make pyb.RTC a type, and pyb.RTC() constructs an RTC object.
This is the standard way of doing things, one should construct a
peripheral object (even if it's a singleton).

See issue #1330.
2015-06-22 23:03:17 +01:00
Bill Owens 60ccb41fac esp8266: Move status() from esp module to network 2015-06-20 23:35:55 +03:00
Paul Sokolovsky a193ced7fa esp8266: README: Typo fix. 2015-06-19 21:09:53 +03:00
Paul Sokolovsky b6a08208e1 esp8266: Explicit warning that port is experimental and subject to change. 2015-06-18 11:46:43 +03:00
Radomir Dopieralski 0cba23716d ESP8266: Update the README.md to reflect what works 2015-06-18 11:42:05 +03:00
Bill Owens 686516f90a esp8266: Move scan from esp module to network 2015-06-17 23:13:12 +03:00
Bill Owens 3ce212e0a6 esp8266: Changed esp_scan to keep the current WiFi operating mode but throw an exception if WiFi is in AP only mode 2015-06-14 10:57:08 +03:00
Paul Sokolovsky 32eb4b9055 esp8266: Move connect/disconnect from "esp" module to network. 2015-06-12 17:45:28 +03:00
Paul Sokolovsky ee3fec3167 esp8266: Add skeleton "network" module.
MicroPython "network" module interface requires it to contains classes
to instantiate. But as we have a static network interace, make WLAN()
"constructor" just return module itself, and just make all methods
module-global functions.
2015-06-12 17:45:20 +03:00
Paul Sokolovsky 431603ad69 esp8266: esp_connect(): The function is now vararg.
Fixes regression from a previous commit.
2015-06-12 14:26:44 +03:00
Paul Sokolovsky a32538bb66 esp8266: Do not call espconn_create in constructor of esp.socket.
Turns out this is supposed to be called only for UDP connections.

Patch by Josef Gajdusek.
2015-06-02 22:40:06 +03:00
Paul Sokolovsky 2fc1e64319 esp8266: Fix lost chars problem when block-xfering data (e.g., when pasting).
Pasting more or less sizable text into ESP8266 REPL leads to random chars
missing in the received input. Apparent cause is that using RTOS messages
to pass individual chars one by one is to slow and leads to UART FIFO
overflow. So, instead of passing chars one by one, use RTOS msg to signal
that input data is available in FIFO, and then let task handler to read
data directly from FIFO.

With this change, lost chars problem is gone, but the pasted text is
truncated after some position. At least 500 chars can be pasted reliably
(at 115200 baud), but 1K never pastes completely.
2015-06-01 23:57:19 +03:00
Josef Gajdusek 7d8edeff4e esp8266: Update to SDK version 1.1.0 (MIT-licensed).
1. Updated linker script, now user app appears to contain exception vector
table and oesn't work (faults) without it.
2. Commened out support for GPIO pulldown, which was removed in this SDK
version without clear explanation, but apparently because it was released
without proper validation, and now turns out it doesn't work as expected,
or there's a different function there.
2015-05-30 20:58:59 +03:00
Josef Gajdusek 286ced4c2f esp8266: Add a bunch of miscellaneous methods 2015-05-28 21:38:46 +03:00
Josef Gajdusek 25a8a42447 esp8266: Add pyb.ADC class 2015-05-28 21:31:37 +03:00
Josef Gajdusek 492fd5cb6b esp8266: Enable setting CPU frequency to 160MHz 2015-05-28 21:28:29 +03:00
Josef Gajdusek 967f3230f5 esp8266: Move initialization to system_init_done_cb
Initializing too early caused some of the API functions (wifi_*) to fail
when called in main.py
2015-05-26 22:22:08 +03:00
Josef Gajdusek 59610c4004 esp8266: Add uos module
Currently implements only .uname()
2015-05-26 22:18:07 +03:00
Josef Gajdusek 1c132c8587 esp8266: Add configuration option for redirecting the built-in OS output 2015-05-13 18:03:00 +02:00
Josef Gajdusek 40c6d57804 esp8266: Actually use the decimal part of system_rtc_clock_cali_proc() 2015-05-13 17:59:36 +02:00
Damien George 304a96d7d6 esp8266: Put more literal and text obj data in irom0_0_seg.
With newer versions of esp_iot_sdk the iram1_0_seg started to overflow.
Now it doesn't.

Addresses issue #1254.
2015-05-13 14:49:14 +01:00
Damien George 4e7dc97bdc esp8266: Add module weak links; link time to utime. 2015-05-13 00:18:41 +01:00
Josef Gajdusek 103d12a877 esp8266: Add utime and pyb.RTC 2015-05-13 00:12:54 +01:00
Josef Gajdusek b47931978f esp8266: Update the linker script
Moved modesp.o to flash and increased size of the irom0_0_seg segment. The new
value was taken from NodeMCU linker script.
2015-05-13 00:12:54 +01:00
Josef Gajdusek 800d5cd16f esp8266: Implement time functions 2015-05-12 23:47:18 +01:00
Josef Gajdusek bda7041294 esp8266: Add support for frozen modules 2015-05-06 22:04:20 +01:00
Josef Gajdusek d39d96b700 esp8266: Add .onsent callback support
The function passed to socket.onsent() gets called after data is succesfully
sent by the socket.
2015-05-06 21:47:44 +01:00
Josef Gajdusek 2d56df67cd esp8266: Initialize socket->connlist to NULL
This was causing crashes in .onconnect()
2015-05-06 21:47:43 +01:00
Josef Gajdusek 28076f3d4b esp8266: Fix garbage collector by hard-coding stack end address.
As user_init() is not a true main functions, the stack pointer captured within
is not pointing at the base of the stack. This caused gc_collect being called
with sp being higher than stack_end, causing integer overflow and crashing as
gc tried to scan almost the entire address space.
2015-05-06 14:01:07 +01:00
Damien George c98c128fe8 pyexec: Make raw REPL work with event-driven version of pyexec.
esp8266 port now has working raw and friendly REPL, as well as working
soft reset (CTRL-D at REPL, or raise SystemExit).

tools/pyboard.py now works with esp8266 port.
2015-05-06 00:02:58 +01:00
Damien George 3d91b1f67f esp8266: Return CPU frequency in Hz. 2015-05-05 22:23:23 +01:00
Josef Gajdusek 82d08dccc6 esp8266: Fix endian of address returned by esp.getaddrinfo() 2015-05-05 22:19:48 +01:00
Josef Gajdusek 9e00ac89d5 esp8266: Add esp.socket class, with ESP-style socket functionality.
* UDP currently not supported
 * As there is no way (that I know of) the espconn_regist_connectcb()
   callback can recognize on which socket has the connection arrived,
   only one listening function at a time is supported
2015-05-04 11:48:40 +01:00
Josef Gajdusek 7e7039b53c esp8266: Export station status() constants 2015-05-03 22:07:00 +03:00
Damien George 7f9d1d6ab9 py: Overhaul and simplify printf/pfenv mechanism.
Previous to this patch the printing mechanism was a bit of a tangled
mess.  This patch attempts to consolidate printing into one interface.

All (non-debug) printing now uses the mp_print* family of functions,
mainly mp_printf.  All these functions take an mp_print_t structure as
their first argument, and this structure defines the printing backend
through the "print_strn" function of said structure.

Printing from the uPy core can reach the platform-defined print code via
two paths: either through mp_sys_stdout_obj (defined pert port) in
conjunction with mp_stream_write; or through the mp_plat_print structure
which uses the MP_PLAT_PRINT_STRN macro to define how string are printed
on the platform.  The former is only used when MICROPY_PY_IO is defined.

With this new scheme printing is generally more efficient (less layers
to go through, less arguments to pass), and, given an mp_print_t*
structure, one can call mp_print_str for efficiency instead of
mp_printf("%s", ...).  Code size is also reduced by around 200 bytes on
Thumb2 archs.
2015-04-16 14:30:16 +00:00
Paul Sokolovsky 3a84c8b58d string0.c: Move from stmhal/ to lib/. 2015-04-05 21:57:55 +03:00
Damien George 87c6250b4c esp8266: Add basic pyb.Pin class; supports output mode only. 2015-02-13 22:21:44 +00:00
Damien George 0b32e50365 stmhal: Make pybstdio usable by other ports, and use it.
Now all ports can use pybstdio.c to provide sys.stdin/stdout/stderr, so
long as they implement mp_hal_stdin_* and mp_hal_stdout_* functions.
2015-02-13 15:04:53 +00:00
Damien George 0bfc7638ba py: Protect mp_parse and mp_compile with nlr push/pop block.
To enable parsing constants more efficiently, mp_parse should be allowed
to raise an exception, and mp_compile can already raise a MemoryError.
So these functions need to be protected by an nlr push/pop block.

This patch adds that feature in all places.  This allows to simplify how
mp_parse and mp_compile are called: they now raise an exception if they
have an error and so explicit checking is not needed anymore.
2015-02-07 18:33:58 +00:00
Paul Sokolovsky d6f648d04f esp8266: modesp: Add status() function for connection status. 2015-02-05 00:39:02 +02:00
Paul Sokolovsky 1cd47c6315 esp8266: modesp: Add disconnect() function to disconnect from WiFi AP. 2015-02-03 02:02:29 +02:00
Paul Sokolovsky 471b2a8906 esp8266: modesp: Add connect() function to connect to WiFi AP. 2015-02-01 01:36:48 +02:00
Paul Sokolovsky 8fff7f8d38 esp8266: Add "reset" target to Makefile.
Just always keep jumper in bootloader position. After flashing, uPy
automatically executed. And to get back to bootloader, do "make reset".
2015-01-31 00:51:39 +02:00
Paul Sokolovsky eca9a9323a esp8266: Update ROM address map to vendor SDK 0.9.5. 2015-01-31 00:36:41 +02:00
Paul Sokolovsky 5fb775a0c0 esp8266: Handle exceptions in callback. 2015-01-25 17:41:06 +02:00
Paul Sokolovsky 6ec650b41f esp8266: Add "esp" module with esp8266-specific "cooperative" networking.
So far implements .scan(lambda x: print(x)) function to scan for WiFi access
points.
2015-01-25 17:10:06 +02:00
Paul Sokolovsky 438b3d26b5 esp8266: Add missing hard_reset qstr. 2015-01-18 00:37:46 +02:00
Paul Sokolovsky f1700a5154 esp8266:modpyb: Implement hard_reset(). 2015-01-18 00:30:14 +02:00
Paul Sokolovsky f12ea7c7ed esp8266: Implement task-based, event-driven interface with UART.
This enables proper interfacing with underlying OS - MicroPython doesn't
run the main loop, OS does, MicroPython just gets called when some event
takes place.
2015-01-16 19:20:17 +02:00
Paul Sokolovsky c6b8750c14 esp8266: Use dedicated heap allocated as static array.
We cannot assume that all memory belongs to us - it actually belongs to
ESP8266 OS.
2015-01-15 00:36:03 +02:00
Paul Sokolovsky 06e9cb688b esp8266: Update for readline module moved to lib/. 2015-01-12 04:27:36 +02:00
Damien George 4a5895c4eb py: Disable stack checking by default; enable on most ports. 2015-01-09 00:10:55 +00:00
Damien George 3b51b3e90f stmhal: Collect all root pointers together in 1 place.
A GC in stmhal port now only scans true root pointers, not entire BSS.
This reduces base GC time from 1700ms to 900ms.
2015-01-07 23:38:50 +00:00
Damien George b4b10fd350 py: Put all global state together in state structures.
This patch consolidates all global variables in py/ core into one place,
in a global structure.  Root pointers are all located together to make
GC tracing easier and more efficient.
2015-01-07 20:33:00 +00:00
Damien George fe7d542352 esp8266: Prefix includes with py/; remove need for -I../py. 2015-01-01 21:16:58 +00:00
Damien George 9ddbe291c4 py: Add include guards to mpconfig,misc,qstr,obj,runtime,parsehelper. 2014-12-29 01:02:19 +00:00
Paul Sokolovsky d4f80f58b8 esp8266/README: Fix typos. 2014-12-06 13:34:18 +02:00
Damien George b395220ef0 esp8266: Add README.md. 2014-11-29 15:06:20 +00:00
Damien George 3b603f29ec Use MP_DEFINE_CONST_DICT macro to define module dicts.
This is just a clean-up of the code.  Generated code is exactly the
same.
2014-11-29 14:39:27 +00:00
Damien George e636279fe0 esp8266: Move more rodata to irom section.
rodata can only go in iram/irom if it's accessed only using word loads
(ie no byte or half-word access).
2014-11-29 14:36:18 +00:00
Damien George d96e6b14c9 esp8266: Make default ESP_SDK variable work correctly.
When esp-open-sdk is built with STANDALONE=y (the default) then ESP_SDK
is set to the correct value, so that "make" just works.
2014-11-28 18:05:25 +00:00
Damien George fbea810043 esp8266: Change bignum from mpz to longlong; move some rodata to iram.
Some rodata items can go in iram/irom segment, but not others.  With
this patch ESP now has 24256 bytes of heap ram.  It passes 228 out of
248 tests from tests/basics directory.
2014-11-28 14:58:25 +00:00
Damien George 5f10065718 esp8266: Provide sensible default ESP_SDK; deploy 2 the images together. 2014-11-28 10:22:01 +00:00
Paul Sokolovsky 1bbc389d67 esp8266: Allow to override serial port. 2014-11-28 01:54:46 +02:00
Damien George 075d597464 esp8266: New port of Micro Python to ESP8266 wifi module. 2014-11-27 20:30:33 +00:00