Commit Graph

376 Commits

Author SHA1 Message Date
Damien George
bad2df3e95 stmhal, modwiznet5k: Add very minimal documentation. 2014-09-01 22:58:22 +01:00
Damien George
bcf041f1a3 stmhal: Add wiznet5k module, to control WIZnet ethernet adaptor.
Allows to create socket objects that support TCP and UDP in server and
client mode.  Interface is very close to standard Python socket class,
except bind and accept do not work the same (due to hardware not
supporting them in the usual way).

Not compiled by default.  To compile this module, use:
make MICROPY_PY_WIZNET5K=1
2014-09-01 22:52:38 +01:00
Damien George
ecc88e949c Change some parts of the core API to use mp_uint_t instead of uint/int.
Addressing issue #50, still some way to go yet.
2014-08-30 00:35:11 +01:00
Damien George
8707ea3421 lib: Add lib and libm, moving current files from stmhal.
Top-level lib directory is for standard C libraries that we want to
provide our own versions of (for efficiency and stand-alone reasons).
It currently has libm in it for math functions.

Also add atanf and atan2f, which addresses issue #837.
2014-08-29 22:42:26 +01:00
Damien George
f05b87bd63 Merge pull request #824 from dhylands/sdcard-power
Fix sdcard_power_on to not do anything if the card is already powered on...
2014-08-26 22:58:54 +01:00
Damien George
3b72da674e stmhal, STM32F4DISC: Small changes to ST accel driver. 2014-08-26 22:41:27 +01:00
Damien George
e00fb08f99 stmhal, staccel.py: Style cleanup. 2014-08-26 17:30:48 +01:00
David Siorpaes
f4ce26de5c Added LIS302DL ID check 2014-08-26 18:23:00 +02:00
Damien George
3bb7efc943 stmhal: Hookup USB_VCP.any().
Thanks to Dave Hylands for this patch.
2014-08-26 14:18:22 +01:00
Damien George
cd021bfe56 stmhal: Fix build issues with (old) CC3000 driver.
Addresses issue #825.
2014-08-26 14:13:53 +01:00
Dave Hylands
994bb4a839 Fix sdcard_power_on to not do anything if the card is already powered on. 2014-08-25 10:16:52 -07:00
Damien George
34e43c7ee9 stmhal: Improve efficiency of SysTick IRQ and HAL_Delay.
SysTick IRQ now increases millisecond counter directly (ie without
calling HAL_IncTick).  Provide our own version of HAL_Delay that does a
wfi while waiting.  This more than halves power consumption when running
a loop containing a pyb.delay call.  It used to be like this, but new
version of HAL library regressed this feature.
2014-08-25 18:12:44 +01:00
Damien George
29c92a407c stmhal: Use MP_OBJ_NEW_SMALL_INT directly in pyb.micros/millis.
Also some whitespace cleanup.
2014-08-25 17:38:55 +01:00
Dave Hylands
2bf044442e Add support for pyb.micros() by using the systick timer.
I also removed trailing spaces from modpyb.c which affected a couple
of lines technically not part of this patch.

Tested using: https://github.com/dhylands/upy-examples/blob/master/micros_test.py

which eventually fails due to wraparound issues (I could fix the test to compensate
but didn't bother)
2014-08-25 17:38:55 +01:00
Damien George
e5cbb70328 stmhal: Make enable_irq and disable_irq inline functions.
These functions are generally 1 machine instruction, and are used in
critical code, so makes sense to have them inline.

Also leave these functions uninverted (ie 0 means enable, 1 means
disable) and provide macro constants if you really need to distinguish
the states.  This makes for smaller code as well (combined with
inlining).

Applied to teensy port as well.
2014-08-25 13:24:33 +01:00
Dave Hylands
9480138f0c Add save/restore_irq
Factored irq functions into a separate file.
2014-08-25 12:22:11 +01:00
Damien George
2c4e67e32d stmhal, pin: Update documentation. 2014-08-24 18:30:22 +01:00
Dave Hylands
3d945559d4 Added python script to map AF to a pin name
Added some functions to Pin class to query mode, pull, and af
2014-08-24 18:21:08 +01:00
Damien George
8ba832456e stmhal, modtime: Small changes, reduced code size by around 80 bytes.
Also added test for modtime.
2014-08-24 17:40:24 +01:00
Dave Hylands
6678595e7e Add time.mktime and enhance time.localtime (for stmhal)
Now you can use time.localtime on the timestamps presented by os.stat
2014-08-24 17:00:03 +01:00
Damien George
3c658a4e75 py: Fix bug where GC collected native/viper/asm function data.
Because (for Thumb) a function pointer has the LSB set, pointers to
dynamic functions in RAM (eg native, viper or asm functions) were not
being traced by the GC.  This patch is a comprehensive fix for this.

Addresses issue #820.
2014-08-24 16:28:17 +01:00
Dave Hylands
3688414d9d Put some code into the first 16K of flash
This basically shrinks the remaining size of flash in the portion
that goes after the internal flash drive.
2014-08-16 08:00:12 -07:00
Damien George
b63be37be1 stmhal: In safe mode, still mount SD card and present as MSD over USB.
It's still "safe" because no scripts are run.  Remove the SD card if you
want to access the internal flash filesystem.  Addresses issue #616.

Also: remove obsolete pyb.source_dir setting, and reset pyb.main and
pyb.usb_mode settings on soft-reset.
2014-08-16 14:23:22 +01:00
Damien George
b0accc8571 stmhal: Fix printing of pin name in error message. 2014-08-16 13:56:19 +01:00
Damien George
244476e3e6 stmhal: For non-debug compile, enable CC/LD opt to remove dead code.
Saves over 35k ROM due to elimination of unused HAL functions.  All
tests pass.

Addresses issue #702.
2014-08-16 13:37:05 +01:00
Damien George
bf133f7737 stmhal: Resolve question in comment about timer clock. 2014-08-14 00:30:14 +01:00
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