Commit Graph

350 Commits

Author SHA1 Message Date
Damien George 1ddd844815 extmod: Finish rename of zlib to zlibd; enable zlibd on stmhal. 2014-08-12 23:23:53 +01:00
Damien George 105e32f1a5 stmhal: Enable moductypes by default.
Also fixes compiler error in moductypes when compiled without debugging.

Addresses issue #778.
2014-08-12 20:02:26 +01:00
Damien George 101d87da6a stmhal: Working STM32F4DISC accelerometer, via Python script.
Thanks to David Siorpaes.
2014-08-10 22:26:20 +01:00
Damien George 30dd23aa7f doc: Document gc, sys, math, cmath. 2014-08-10 17:50:28 +01:00
Damien George 0c64c634ca stmhal: Add sys.platform string to PYBv1.0 (it's "pyboard"). 2014-08-10 17:49:52 +01:00
Damien George 2605df3346 stmhal, pin: Save 140 bytes ROM by simplifying pin_print function. 2014-08-09 09:19:37 +01:00
Damien George 04019e365f stmhal, pin: Simplify default value for alternate function init. 2014-08-09 08:51:12 +01:00
Damien George ea439e59d9 stmhal: Start of documentation for modos and modtime. 2014-08-08 23:30:01 +01:00
Damien George 284efa89ae stmhal/teensy: Use _ instead of - in source file names.
Trying to move towards consistency, let's use _ exclusively in names of
source files (eg .c, .h, .csv).
2014-08-08 22:34:06 +01:00
Damien George 4b67463be1 stmhal: Fix documentation; remove ability to specify af by str. 2014-08-08 22:26:53 +01:00
Damien George 5b7c0c437b stmhal: Comment out unused functions. 2014-08-08 22:25:46 +01:00
Dave Hylands 6f418fc1b0 Add support for selecting pin alternate functions from python.
Converts generted pins to use qstrs instead of string pointers.

This patch also adds the following functions:
pyb.Pin.names()
pyb.Pin.af_list()
pyb.Pin.gpio()

dir(pyb.Pin.board) and dir(pyb.Pin.cpu) also produce useful results.

pyb.Pin now takes kw args.

pyb.Pin.__str__ now prints more useful information about the pin
configuration.

I found the following functions in my boot.py to be useful:
```python
def pins():
    for pin_name in dir(pyb.Pin.board):
        pin = pyb.Pin(pin_name)
        print('{:10s} {:s}'.format(pin_name, str(pin)))

def af():
    for pin_name in dir(pyb.Pin.board):
        pin = pyb.Pin(pin_name)
        print('{:10s} {:s}'.format(pin_name, str(pin.af_list())))
```
2014-08-07 23:15:41 -07:00
Damien George 3ef911345c stmhal: Update STM32Cube F4 HAL driver to V1.3.0.
This patch updates ST's HAL to the latest version, V1.3.0, dated 19 June
2014.  Files were copied verbatim from the ST package.  Only change was
to suppress compiler warning of unused variables in 4 places.

A lot of the changes from ST are cosmetic: comments and white space.
Some small code changes here and there, and addition of F411 header.

Main code change is how SysTick interrupt is set: it now has a
configuration variable to set the priority, so we no longer need to work
around this (originall in system_stm32f4xx.c).
2014-08-06 22:33:31 +01:00
Damien George 8a11d693cf stmhal: Ability to stat /flash and /sd.
Addresses issue #780.
2014-08-06 19:02:34 +01:00
Damien George 2fe2a05f9f stmhal: Put #if guards around all GPIOx_CLK_ENABLE's.
Specifically, teensy port does not have these macros defined.
2014-08-06 16:40:20 +01:00
Damien George 95ea4f0c95 stmhal: Enable relevant GPIO clock when Pin obj is init'd. 2014-08-06 16:04:57 +01:00
Damien George 7cc20e7e99 stmhal: Wrap DAC module and os.urandom in relevant #if's. 2014-08-05 23:35:21 +01:00
Damien George 56da07dcfa stmhal, math: Define _M_LN2 if not already defined.
Addresses issue #790.
2014-08-05 14:13:05 +00:00
Damien George ccacdf44b6 stmhal: Clean up reset/soft-reset code; fix bug init'ing VCP exc.
Make a clearer distinction between init functions that must be done
before any scripts can run (xxx_init0) and those that can be safely
deferred (xxx_init).

Fix bug initialising USB VCP exception.  Addresses issue #788.

Re-order some init function to improve reliability of
reset/soft-reset.
2014-08-04 11:09:51 +01:00
Damien George 8dbbbbc793 Put call to qstr_init and mp_init_emergency_exc_buf in mp_init.
qstr_init is always called exactly before mp_init, so makes sense to
just have mp_init call it.  Similarly with
mp_init_emergency_exception_buf.  Doing this makes the ports simpler and
less error prone (ie they can no longer forget to call these).
2014-08-04 10:05:16 +01:00
Damien George 8362bffb2e stmhal: Document behaviour of usb_vcp_recv_byte. 2014-08-03 17:30:26 +01:00
Damien George 2e41646eb7 stmhal: Add more documentation for USB_VCP. 2014-08-02 14:43:20 +01:00
Damien George 87bbb388db stmhal: Add documentation for LCD; update docs for USB_VCP. 2014-08-02 14:35:38 +01:00
Damien George 71bed1a9a7 stmhal: Add preliminary driver for ST32F4DISC accelerometer.
Written in Python, not currently working.  See issue #725.
2014-08-02 12:51:18 +01:00
Dave Hylands f8f963a14a Fix modos.c to compile for the STM32F4Discovery board (which doesn't have an sdcard) 2014-08-01 08:10:41 -07:00
Damien George 65dd7bc13d stmhal: Change 0:/ and 1:/ to /flash and /sd; add CWD support.
Some important changes to the way the file system is structured on the
pyboard:

1. 0: and 1: drive names are now replaced with POSIX inspired
directories, namely /flash and /sd.

2. Filesystem now supports the notion of a current working directory.
Supports the standard Python way of manipulating it: os.chdir and
os.getcwd.

3. On boot up, current directory is /flash if no SD inserted, else /sd
if SD inserted.  Then runs boot.py and main.py from the current dir.
This is the same as the old behaviour, but is much more consistent and
flexible (eg you can os.chdir in boot.py to change where main.py is run
from).

4. sys.path (for import) is now set to '' (current dir), plus /flash
and /flash/lib, and then /sd and /sd/lib if SD inserted.  This, along
with CWD, means that import now works properly.  You can import a file
from the current directory.

5. os.listdir is fixed to return just the basename, not the full path.

See issue #537 for background and discussion.
2014-07-31 23:44:04 +01:00
Damien George bb4c6f35c6 py: Make MP_OBJ_NEW_SMALL_INT cast arg to mp_int_t itself.
Addresses issue #724.
2014-07-31 10:49:14 +01:00
Damien George fa1ecda3fd stmhal, accel: Increase start-up times to 30ms; add extra 30ms delay.
For accel to start-up reliably, need to wait 30ms between on/off, and
30ms for it to enter active mode.  With this fix the accel can be read
immediately after initialising it.

Addresses issue #763.
2014-07-31 10:39:52 +01:00
Damien George 3c4db9f91c stmhal: Add USB_VCP class/object, for direct USB VCP control.
Before, pyb.stdin/pyb.stdout allowed some kind of access to the USB VCP
device, but it was basic access.

This patch adds a proper USB_VCP class and object with much more control
over the USB VCP device.  Create an object with pyb.USB_VCP(), then use
this object as if it were a UART object.  It has send, recv, read,
write, and other methods.  send and recv allow a timeout to be specified.

Addresses issue 774.
2014-07-31 10:30:42 +01:00
Damien George 94fbe9711a py: Change lexer stream API to return bytes not chars.
Lexer is now 8-bit clean inside strings.
2014-07-30 11:46:05 +01:00
Damien George 07133415d2 Merge pull request #738 from dhylands/except-args
Add support for storing args during an exception raised by an irq.
2014-07-29 23:15:35 +01:00
Damien George adf0f2ae1a py: Change stream protocol API: fns return uint; is_text for text. 2014-07-27 22:38:58 +01:00
Dave Hylands 5b7fd20fea Add support for storing args during an exception raised by an irq.
The user code should call micropython.alloc_emergency_exception_buf(size)
where size is the size of the buffer used to print the argument
passed to the exception.

With the test code from #732, and a call to
micropython.alloc_emergenncy_exception_buf(100) the following error is
now printed:
```python
>>> import heartbeat_irq
Uncaught exception in Timer(4) interrupt handler
Traceback (most recent call last):
  File "0://heartbeat_irq.py", line 14, in heartbeat_cb
NameError: name 'led' is not defined
```
2014-07-25 14:00:06 -07:00
Damien George de993f4573 Merge pull request #766 from dhylands/allow-dfu-override
Allow DFU_UTIL to be overridden from the environment.
2014-07-22 11:02:59 +01:00
blmorris 7a03b5f56a remove Myriad2 board config files from master 2014-07-21 23:12:07 -04:00
blmorris 86f0b31bcf Change boolean 'use_16bit_addr' to int 'addr_size', can be either 8 or 16 bits, default value is 8
to maintain compatibility with existing code.
2014-07-21 22:45:04 -04:00
Dave Hylands a2e7a1315d Allow DFU_UTIL to be overridden from the environment. 2014-07-21 16:28:07 -07:00
blmorris 721d6240c9 Merge https://github.com/blmorris/micropython into Myriad2 2014-07-21 12:50:10 -04:00
blmorris 4038f513ea Merge https://github.com/micropython/micropython 2014-07-21 12:47:57 -04:00
Damien George 951ed9d02f stmhal: Fix REPL printing by cooking output sent to stdout_obj.
Recent changes to builtin print meant that print was printing to the
mp_sys_stdout_obj, which was sending data raw to the USB CDC device.
The data should be cooked so that \n turns into \r\n.
2014-07-20 13:57:43 +01:00
Damien George 1163cb9cb5 stmhal: Change calls to pfenv_printf to pfenv_vprintf.
Fixes printing bugs introduced by
cb66f41ebc.
2014-07-20 13:10:18 +01:00
Paul Sokolovsky cb66f41ebc py: Make print() accept "file" argument, and actually print to stream.
And not system printf(), like it was before. For this, move pfenv_printf()
from stmhal port to py/.
2014-07-19 21:27:22 +03:00
Damien George 1694bc733d py: Add stream reading of n unicode chars; unicode support by default.
With unicode enabled, this patch allows reading a fixed number of
characters from text-mode streams; eg file.read(5) will read 5 unicode
chars, which can made of more than 5 bytes.

For an ASCII stream (ie no chars > 127) it only needs to do 1 read.  If
there are lots of non-ASCII chars in a stream, then it needs multiple
reads of the underlying object.

Adds a new test for this case.  Enables unicode support by default on
unix and stmhal ports.
2014-07-19 18:34:04 +01:00
Damien George 02bc882c3d stmhal: Add file.flush and os.stat. 2014-07-19 16:39:13 +01:00
blmorris ef204733d6 Initial commit of Myriad2 board-specific configuration files 2014-07-15 15:10:56 -04:00
blmorris 847a6b30b1 Incorporate stylistic changes suggested by @dhylands 2014-07-11 21:18:09 -04:00
blmorris e687fdbcbc Add keyword argument 'memaddr_use_16b' to i2c.mem_read and mem_write methods
to allow these methods to transmit 16 bit addresses to an i2c device
Add 'memaddr_use_16b' to qstrdefsport.h
2014-07-11 16:14:01 -04:00
Damien George 594699bc88 stmhal: Protect SD_WriteBlocks by IRQ disable/enable pair. 2014-07-07 07:29:06 +01:00
Dave Hylands 90ba80dc36 Disable IRQs around sdcard reads.
Once the code switches to using DMA, this can be removed.
2014-07-06 09:51:22 -07:00
Damien George 40f3c02682 Rename machine_(u)int_t to mp_(u)int_t.
See discussion in issue #50.
2014-07-03 13:25:24 +01:00