Commit Graph

1153 Commits

Author SHA1 Message Date
Damien George
efa04eafd3 stmhal: Add MMA_INT/PB2 to available pins on PYBV10.
This allows you to register ExtInt on the MMA interrupt pin.
2014-10-22 19:31:27 +01:00
Dave Hylands
d46a822262 Fixed TIM2_CH1 definition.
TIM2_CH1_ETR is really bundling 2 functions to the same pin:
TIM2_CH1 (where its used as a channel)
TIM2_ETR (where iss used as an external trigger).

I fixed most of these a while back, but it looks like I missed this one.
2014-10-22 19:16:51 +01:00
Damien George
3be6984b8f stmhal: Don't return SystemExit value from parse_compile_execute.
There is no need, since we don't (currently) use the value.
2014-10-22 19:14:20 +01:00
Dave Hylands
8d62bbd46a Add pyb.hard_reset, and make sys.exit() or raise SystemExit do a soft reset. 2014-10-22 19:14:20 +01:00
Damien George
3e42570538 stmhal: Change cc3k.recv to only make 1 call to underlying recv().
Also make cc3k.send and cc3k.recv independent functions (not wrapped by
stream write/read).  Also make wiznet5k.recv more memory efficient.

This might address issue #920.
2014-10-22 01:10:53 +01:00
Damien George
481d714bd5 stmhal: Overhaul UART class to use read/write, and improve it.
UART object now uses a stream-like interface: read, readall, readline,
readinto, readchar, write, writechar.

Timeouts are configured when the UART object is initialised, using
timeout and timeout_char keyword args.

The object includes optional read buffering, using interrupts.  You can set
the buffer size dynamically using read_buf_len keyword arg.  A size of 0
disables buffering.
2014-10-21 22:15:20 +01:00
Damien George
b1e217222e Merge pull request #922 from swegener/for-upstream
stmhal: Set entry point for ELF binary debugging
2014-10-21 20:58:29 +01:00
stijn
2fe4cf7761 Implement kwargs for builtin open() and _io.FileIO
This makes open() and _io.FileIO() more CPython compliant.
The mode kwarg is fully iplemented.
The encoding kwarg is allowed but not implemented; mainly to allow
the tests to specify encoding for CPython, see #874
2014-10-21 22:10:01 +03:00
Sven Wegener
abf0f07a5a stmhal: Set entry point for ELF binary debugging
When loading the ELF binary to the board with a debugger, the debugger
needs to know at which point to start executing the code. Currently the
entry point defaults to the start of the .text section.

Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
2014-10-21 16:48:32 +02:00
Damien George
072bd07f17 stmhal: Add retry to SD card init.
This fixed an issue with a certain SD card sometimes not initialising
first time round.  See issue #822 for related, and thanks to
@iabdalkader for the idea.
2014-10-20 00:04:27 +01:00
Paul Sokolovsky
1a55b6a787 unix, stmhal: Implement file.readinto() method.
Also, usocket.readinto(). Known issue is that .readinto() should be available
only for binary files, but micropython uses single method table for both
binary and text files.
2014-10-18 22:44:07 +03:00
Damien George
4b71c056ef moduzlib: Fix fn prototype and some code style; use it in stmhal port. 2014-10-12 23:35:38 +01:00
Damien George
50062587c7 stmhal: Oops: rename mod files in Makefile. 2014-10-12 20:35:21 +01:00
Damien George
136b5cbd76 stmhal: Rename module files to keep consistency with module name. 2014-10-12 20:24:55 +01:00
Damien George
0107e90328 stmhal: Enable module weak links.
os, time, select modules are now prefixed with u, but are still
available (via weak links) as their original names.

ure and ujson now available as re and json via weak links.
2014-10-12 20:23:47 +01:00
Damien George
dd5ee9ff9c stmhal: Enable ure module (tests pass on pyboard). 2014-10-11 18:55:12 +01:00
Dave Hylands
1c795445b3 Add support for complimentary channel output and deadtime.
This patch enables output on the complimentary channels (TIMx_CHyN).
For timers 1 and 8, deadtime can also be inserted when the channels
transition. For the pyboard, TIM8_CH1/CH1N and TIM8_CH2/CH2N can
take advantage of this.
2014-10-10 13:54:03 -07:00
Damien George
9b6617ea8b stmhal: Add pyb.stop() and pyb.standby() functions. 2014-10-09 19:02:47 +01:00
Damien George
9bf5f2857d py: Add further checks for failed malloc in lexer init functions. 2014-10-09 16:53:37 +01:00
Dave Hylands
3556e45711 Allow real memory errors (from locked gc) to be reported with traceback. 2014-10-07 08:07:49 -07:00
Damien George
fec70ad369 stmhal: Remove long-obsolete pybwlan.[ch] files from old CC3k driver. 2014-10-06 15:40:25 +00:00
Damien George
d03c681608 stmhal: Use mp_uint_t where appropriate.
Found these by compiling stmhal with mp_uint_t of type uint32_t instead
of unsigned int.  This actually makes a difference to the code, but just
a curiosity.
2014-10-05 21:51:54 +01:00
Damien George
a91ac2011f py: Make compiler return a proper exception on SyntaxError. 2014-10-05 19:01:34 +01:00
Damien George
6dba992182 stmhal: Add config option to disable/enable CAN driver. 2014-10-05 18:05:26 +01:00
Damien George
ba0383a8c7 stmhal, timer: Fix timer.chanel so mode can be a keyword. 2014-10-05 17:52:45 +01:00
Damien George
55f68b3ce8 stmhal, timer: Improve accuracy of freq computation. 2014-10-05 17:52:45 +01:00
Damien George
97ef94df83 stmhal, timer: Set freq from float; get timer source freq.
Timers now have the following new features:
- can init freq using floating point; eg tim.init(freq=0.1)
- tim.source_freq() added to get freq of timer clock source
- tim.freq() added to get/set freq
- print(tim) now prints freq
2014-10-05 17:52:44 +01:00
Damien George
24119176e7 stmhal: Allow pyb.freq() function to change SYSCLK frequency.
Eg pyb.freq(120000000) sets the CPU to 120MHz.  The frequency can be set
at any point in the code, and can be changed as many times as you like.
Note that any active timers will need to be reconfigured after a freq
change.

Valid range is 24MHz to 168MHz (but not all freqs are supported).  The
code maintains a 48MHz clock for the USB at all times and it's possible
to change the frequency at a USB REPL and keep the REPL alive (well,
most of the time it stays, sometimes it resets the USB for some reason).
Note that USB does not work with pyb.freq of 24MHz.
2014-10-04 01:54:31 +01:00
Damien George
c568a2b443 stmhal: Adjust computation of SYSCLK to retain precision. 2014-10-04 01:54:02 +01:00
Damien George
3550de4ebe stmhal: Add basic CAN bus support. 2014-10-02 17:32:02 +01:00
Damien George
5fc6aa8100 stmhal: Set is_enabled=false when creating UART object; fix doc typo. 2014-10-02 17:31:37 +01:00
Damien George
0bbe4de527 stmhal: Update help text.
Remove reference to pyb.gc; add reference to pyb.millis.

There are lots of functions not listed when you run help(), but it would
be too much to list them all, so we list only some basic, useful ones.

Addresses issue #846.
2014-10-02 14:51:17 +01:00
Dave Hylands
d368611ea6 Proposed fix for USB Mass Storage. 2014-10-01 22:52:02 +01:00
Damien George
de37775a26 stmhal: Enable patch_program in cc3k driver, with key. 2014-09-30 23:43:38 +01:00
Damien George
e5cc4b2503 stmhal: Fix wiznet5k init of SPI bus. 2014-09-30 23:34:18 +01:00
Damien George
8762418d0c drivers, cc3000: Wrap exported functions in a macro for renaming. 2014-09-30 23:25:42 +01:00
Damien George
9d2bf9c405 drivers, wiznet5k: Wrap exported functions in a macro for renaming.
3rd party drivers should not export generic names like "close".
2014-09-30 22:51:47 +01:00
Damien George
3a1c4c5bc6 stmhal: Add network and usocket module.
As per issue #876, the network module is used to configure NICs
(hardware modules) and configure routing.  The usocket module is
supposed to implement the normal Python socket module and selects the
underlying NIC using routing logic.

Right now the routing logic is brain dead: first-initialised,
first-used.  And the routing table is just a list of registered NICs.

cc3k and wiznet5k work, but not at the same time due to C name clashes
(to be fixed).

Note that the usocket module has alias socket, so that one can import
socket and it works as normal.  But you can also override socket with
your own module, using usocket at the backend.
2014-09-30 22:36:47 +01:00
Damien George
bfa7b480a7 stmhal: For spi_init, add argument to select if NSS pin is enabled.
Most of the time you don't use the NSS pin of the SPI bus, and so it
shouldn't be enabled by default (this gave some bugs in the past).
2014-09-30 22:36:47 +01:00
Damien George
8b03d944e2 py: Remove IOError since it's deprecated; use OSError instead.
In CPython IOError (and EnvironmentError) is deprecated and aliased to
OSError.  All modules that used to raise IOError now raise OSError (or a
derived exception).

In Micro Python we never used IOError (except 1 place, incorrectly) and
so don't need to keep it.

See http://legacy.python.org/dev/peps/pep-3151/ for background.
2014-09-30 13:59:30 +00:00
Damien George
41249e17c3 stmhal, fatfs: Use stdlib for string fns; make all private fns static.
We save some code bytes by using builtin string functions.
2014-09-29 15:26:46 +01:00
Damien George
3a2795e200 stmhal: Add label to internal flash drive on creation. 2014-09-29 15:26:11 +01:00
Damien George
f042d7a4d7 stmhal: Fix edge case for timer PWM of 100%.
Also improve precision of calculating PWM percent in integer mode.
Also update teensy with edge case fix.
2014-09-29 14:15:01 +01:00
Damien George
853708738e Merge pull request #881 from dhylands/elapsed
Added pyb.elapsed_millis and pyb.elapsed_micros
2014-09-29 12:42:31 +01:00
Damien George
bf683e6b32 Merge pull request #877 from dhylands/timer-overflow
Fix timer overflow code.
2014-09-29 12:18:48 +01:00
Dave Hylands
a21f56b2d5 Added pyb.elapsed_millis and pyb.elapsed_micros
tested using:
stmhal: https://github.com/dhylands/upy-examples/blob/master/elapsed.py
teensy: https://github.com/dhylands/upy-examples/blob/master/teensy/elapsed.py
2014-09-28 11:24:44 -07:00
Dave Hylands
39296b40d4 Fix timer overflow code.
Teensy doesn't need to worry about overflows since all of
its timers are only 16-bit.

For PWM, the pulse width needs to be able to vary from 0..period+1
(pulse-width == period+1 corresponds to 100% PWM)

I couldn't test the 0xffffffff cases since we can't currently get a
period that big in python. With a prescaler of 0, that corresponds
to a freq of 0.039 (i.e. cycle every 25.56 seconds), and we can't
set that using freq or period.

I also tested both stmhal and teensy with floats disabled, which
required a few other code changes to compile.
2014-09-27 19:40:37 -07:00
Damien George
f90b59e610 stmhal, modcc3k: Add ioctl to cc3k sockets so select works. 2014-09-26 13:52:41 +00:00
Damien George
b766e79510 stmhal: Initial implementation of cc3k module and driver.
Pulled in and modified work done by mux/iabdalkader on cc3k driver, from
iabdalkader-cc3k-update branch.  That branch was terribly messy and had
too many conflicts to merge neatly.
2014-09-26 00:57:26 +01:00
Damien George
f996d8854f drivers, cc3k: Move cc3000 driver from stmhal to drivers directory. 2014-09-26 00:56:45 +01:00
Damien George
ac04a8a56a stmhal: Enable 8-byte stack alignment for IRQ handlers. 2014-09-25 15:47:53 +01:00
Damien George
e8ea0724da stmhal, timer: Factor code to compute PWM percent; improve 32bit case.
Also do the same for teensy timer code.
2014-09-25 15:44:10 +01:00
Damien George
3fafe730d3 Merge pull request #868 from dhylands/fix-teensy-float
Add pulse_width_percent to teensy.
2014-09-25 14:51:44 +01:00
Dave Hylands
53d5fa641f Add pulse_width_percent to teensy.
Fix stmhal and teensy print routines to report actual prescaler an period.
Fix teensy build to use soft-float
Add USE_ARDUINO_TOOLCHAIN option to teensy build
2014-09-23 23:19:36 -07:00
Damien George
52b5d76a6b py: Free non-interned strings in the parser when not needed.
mp_parse_node_free now frees the memory associated with non-interned
strings.  And the parser calls mp_parse_node_free when discarding a
non-used node (such as a doc string).

Also, the compiler now frees the parse tree explicitly just before it
exits (as opposed to relying on the caller to do this).

Addresses issue #708 as best we can.
2014-09-23 15:31:56 +00:00
Damien George
eaaebf3291 stmhal: Initialise stack pointer correctly.
Stack is full descending and must be 8-byte aligned.  It must start off
pointing to just above the last byte of RAM.

Previously, stack started pointed to last byte of RAM (eg 0x2001ffff)
and so was not 8-byte aligned.  This caused a bug in combination with
alloca.

This patch also updates some debug printing code.

Addresses issue #872 (among many other undiscovered issues).
2014-09-23 10:59:05 +01:00
Damien George
0e58c5810d stmhal: Add pulse_width_ratio to timer channel object.
This allows to set the pulse width (for PWM mode) as a ratio relative to
the period of the timer.  Eg, 0.5 is a 50% duty cycle.  You can set the
ratio in the channel init, or using channel.pulse_width_ratio; the
latter can also read the pulse width as a ratio.
2014-09-21 22:54:02 +01:00
Dave Hylands
becbc87fd7 Add Timer support (PWM, OC, IC) for stmhal and teensy 2014-09-19 09:26:13 -07:00
Damien George
2842945e76 stmhal: Fix bugs in documentation so it compiles. 2014-09-17 23:27:42 +00:00
Damien George
612045f53f py: Add native json printing using existing print framework.
Also add start of ujson module with dumps implemented.  Enabled in unix
and stmhal ports.  Test passes on both.
2014-09-17 22:56:34 +01:00
Damien George
1d7fb82f0a stmhal: Change 64-bit arithmetic to 32-bit for SD card block addressing.
By measuring SD card addresses in blocks and not bytes, one can get away
with using 32-bit numbers.

This patch also uses proper atomic lock/unlock around SD card
read/write, adds SD.info() function, and gives error code for failed
read/writes.
2014-09-15 23:49:57 +01:00
Felix Domke
6ff42c54bb stmhal/sdcard.c: add pyb.SD.write 2014-09-15 22:34:16 +01:00
Felix Domke
09de030651 stmhal/hal/src/stm32f4xx_hal_sd.c: fix SDHC card capacity 2014-09-15 22:34:07 +01:00
Damien George
b92cbe6129 py: Move definition of mp_sys_exit to core.
sys.exit always raises SystemExit so doesn't need a special
implementation for each port.  If C exit() is really needed, use the
standard os._exit function.

Also initialise mp_sys_path and mp_sys_argv in teensy port.
2014-09-15 15:53:09 +01:00
Damien George
8594ce2280 py: Implement divmod, % and proper // for floating point.
Tested and working on unix and pyboard.
2014-09-13 18:43:09 +01:00
Damien George
32781cce6d stmhal: Slightly improved memcpy; memset uses word store when aligned. 2014-09-13 00:12:41 +01:00
Damien George
5792500ccc Merge branch 'memcpy' of github.com:iabdalkader/micropython into iabdalkader-memcpy 2014-09-12 23:23:49 +01:00
Damien George
89ab3be0b1 Merge branch 'master' of github.com:micropython/micropython 2014-09-11 22:28:58 +01:00
Damien George
20beff9ae3 py and libm: Add asinf,acosf; print higher precision for float.
Also use less stack space when printing single precision float.

Addition of asinf and acosf addresses issue #851.
2014-09-11 22:24:45 +01:00
iabdalkader
d60580eb5e Optimize memcpy more 2014-09-11 19:01:48 +02:00
Hirotaka Kawata
2b4af54992 Add LIS3DSH accelometer support to staccel.py 2014-09-11 16:40:53 +09:00
iabdalkader
81b2ddf5d1 Memcpy: copy words 2014-09-11 07:49:21 +02:00
Damien George
5c00757a5c stmhal: uart ioctl uses EINVAL, and checks TXE bit for write-ability. 2014-09-07 20:57:18 +01:00
Damien George
013d53c0b4 Remove skeletal modselect from extmod and just put it in stmhal. 2014-09-07 20:42:01 +01:00
Damien George
e2a618615d stmhal: Fix modselect so non-hashable objects can be polled. 2014-09-07 20:41:09 +01:00
Damien George
a2f55fe12b stmhal: Add polling ability to UART object. 2014-09-07 20:40:32 +01:00
Damien George
6c9c7bc75a stmhal: Implement generic select.select and select.poll. 2014-09-07 20:40:32 +01:00
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
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
Damien George
e70b5dbe58 stmhal: Some reordering of code/functions. 2014-07-02 14:09:44 +01:00
Damien George
92a47b4dae Merge branch 'add-timer-deinit' of github.com:dhylands/micropython into dhylands-add-timer-deinit 2014-07-02 14:06:28 +01:00
Damien George
9cd96cf25d Merge pull request #709 from windelbouwman/master
Added hexfile target
2014-07-02 13:53:28 +01:00
Damien George
7a37f647a5 Merge branch 'teensy-new' of github.com:dhylands/micropython into dhylands-teensy-new
Conflicts:
	stmhal/pin_named_pins.c
	stmhal/readline.c

Renamed HAL_H to MICROPY_HAL_H.  Made stmhal/mphal.h which intends to
define the generic Micro Python HAL, which in stmhal sits above the ST
HAL.
2014-07-02 13:42:37 +01:00
Damien George
aa47f3968b Merge pull request #734 from iabdalkader/copysign
Add copysignf
2014-07-01 14:03:55 +01:00
Paul Sokolovsky
caa7334141 stackctrl: Add "mp_" prefix. 2014-07-01 02:14:08 +03:00
Dave Hylands
0d81c133b3 Add timer_deinit and call it just before doing a soft-restart
This fixes #733.
2014-06-30 08:07:38 -07:00
mux
5d44e6a92c Add copysignf
* Fix #692
2014-06-30 16:31:06 +02:00
Damien George
4039a26679 Merge pull request #710 from iabdalkader/assert
Fix assert_func warning/error
2014-06-30 09:09:24 +01:00
Paul Sokolovsky
5813efd634 stmhal: pyb.adc: Clarify that buffer with elements of any size can be used.
Based on forum post: http://forum.micropython.org/viewtopic.php?f=6&t=193
2014-06-29 21:34:58 +03:00
Paul Sokolovsky
8139494e54 stmhal: Include mpconfig.h before all other includes.
It defines types used by all other headers.

Fixes #691.
2014-06-28 23:32:03 +03:00
Damien George
635b60e299 unix, stmhal: Add option for STR_UNICODE to mpconfigport.h.
Unicode is disabled by default for now, since FileIO.read(n) is
currently not implemented for text-mode files, and this is an
often function.
2014-06-28 10:29:52 +01:00
Paul Sokolovsky
8a96ebea75 py: Move stack_ctrl_init() to mp_init().
As stack checking is enabled by default, ports which don't call
stack_ctrl_init() are broken now (report RuntimeError on startup). Save
them trouble and just init stack control framework in interpreter init.
2014-06-27 21:02:04 +03:00
mux
a75e382a9b Change MCU name config micro 2014-06-27 00:35:53 +02:00
Paul Sokolovsky
3659af97c5 Merge pull request #703 from iabdalkader/micro_names
Add MICROPY_HW_MICRO_NAME to boards config
2014-06-27 01:19:17 +03:00
Paul Sokolovsky
7a8ab5a730 stmhal: Use stackctrl framework. 2014-06-27 00:03:55 +03:00
Dave Hylands
f170735b73 Use mp_const_none to initialize mapper and map_dict 2014-06-25 16:01:19 -07:00
mux
89b38d96c9 Add NORETURN to __fatal_error 2014-06-21 18:43:44 +02:00
mux
5c8db48541 Fix asser_func warning/error
* Add while(1) to assert_func to avoid func returns warning
* Define a weak attr in mpconfig.h
2014-06-21 17:24:55 +02:00
Paul Sokolovsky
09e3f8f0d1 Merge pull request #707 from eblot/master-v1.1.1-build-fixes
Fix missing declaration of assert()
Replace ARRAY_SIZE with MP_ARRAY_SIZE
2014-06-20 17:29:58 +03:00
Windel Bouwman
b6af4c8104 Added hexfile target 2014-06-20 16:14:55 +02:00
Emmanuel Blot
f6932d6506 Prefix ARRAY_SIZE with micropython prefix MP_ 2014-06-19 18:54:34 +02:00
mux
fe81eea967 Add MICROPY_HW_MICRO_NAME to boards config 2014-06-19 14:40:57 +02:00
Sven Wegener
c3cabf4e33 bare-arm, stmhal, teensy: Duplicate -nostdlib to CFLAGS
As we are building with -nostdlib gcc features like the stack protector
will fail linking, because the failure handlers are in gcc's internal
libs. Such features are implicitly disabled during compilation when
-nostdlib is used in CFLAGS too.

Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
2014-06-18 13:34:07 +02:00
Sven Wegener
afc67c6dc5 bare-arm, stmhal: Fix --nostdlib to -nostdlib
-nostdlib is the correct option, gcc recognizes the double dash version
when in link-only mode, but not when compiling.

Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
2014-06-18 13:33:47 +02:00
Damien George
720f55cc4b Merge pull request #698 from dhylands/adc-fix
Fix problem with ADC reads and multiple channels
2014-06-17 20:52:47 +01:00
Damien George
bcb3ab451b stmhal: Toggle LED using ODR ^= pin_mask. 2014-06-17 19:57:17 +01:00
Dave Hylands
535b88133c Fix problem with ADC reads and multiple channels 2014-06-16 09:41:58 -07:00
Dave Hylands
4f1b7fec9f Updated teensy to build.
Refactored some stmhal files which are shared with teensy.
2014-06-15 22:48:05 -07:00
Damien George
2547928148 stmhal: Add Python function to set UART for REPL.
This adds a hook to get/set pyb_uart_global_debug from Python, using
pyb.repl_uart().  You can set it to an arbitrary UART object, and then
the REPL (in and out) is repeated on this UART object (as well as on USB
CDC).

Ultimately, this will be replaced with a proper Pythonic interface to
set sys.stdin and sys.stdout.
2014-06-15 09:47:27 +01:00
Damien George
c0711cbefa stmhal: Fix type signatures on functions that take variable args. 2014-06-15 09:32:42 +01:00
Damien George
e79c6696c5 stmhal: Fix file print methods to use print instead of printf.
Also make stdout_print_strn static (ultimately this function needs to be
merged with stdout_tx_strn).
2014-06-15 09:10:07 +01:00
Damien George
34ab8dd6dd stmhal: Update and improve LCD driver.
Still some method names to iron out, and funtionality to add, but this
will do for the first, basic version.
2014-06-15 00:41:47 +01:00
mux
5f6f47a688 Make __assert_func weak 2014-06-14 17:02:50 +02:00
mux
00db5c81e1 Add __assert_func only if DEBUG=1 2014-06-14 15:53:11 +02:00
mux
34e7b67d3c Add __assert_func
* issue #692
2014-06-14 14:41:11 +02:00
Damien George
820896746c stmhal, file: Seek to end of file if opened in 'a' mode. 2014-06-11 16:01:52 +01:00
Damien George
b7572ad11b stmhal, file: Implement a,x,+ open modes, seek and tell.
Also now returns correct POSIX errno when an IO operation fails.

Addresses issues #516 and #676.
2014-06-11 15:41:14 +01:00
Damien George
57b4dfa9c9 stmhal: Fix pyb.bootloader so it works for gcc-4.9.0.
See PR #618.
2014-06-08 14:01:43 +01:00
Damien George
4480cb3711 Provide definition of alloca() in mpconfigport.h. 2014-06-08 13:25:33 +01:00
bvernoux
82560fce75 Merge branch 'master' of https://github.com/micropython/micropython 2014-06-03 19:26:34 +02:00
bvernoux
c3c353d7f1 Cleanup/removed specific stuff specific to HydraBus (except board). 2014-06-03 18:59:24 +02:00
Dave Hylands
4e0573e5cf Add missing commas to stm32f4xx-af.csv 2014-06-02 23:11:14 -07:00
bvernoux
569aa90137 micropython port for HydraBus 2014-06-02 21:43:02 +02:00
Damien George
f1dbd78b30 stmhal: Document pyb.Accel() constructor, that it takes time to start. 2014-06-01 17:57:06 +01:00
Damien George
fb510b3bf9 Rename bultins config variables to MICROPY_PY_BUILTINS_*.
This renames:
MICROPY_PY_FROZENSET -> MICROPY_PY_BUILTINS_FROZENSET
MICROPY_PY_PROPERTY -> MICROPY_PY_BUILTINS_PROPERTY
MICROPY_PY_SLICE -> MICROPY_PY_BUILTINS_SLICE
MICROPY_ENABLE_FLOAT -> MICROPY_PY_BUILTINS_FLOAT

See issue #35 for discussion.
2014-06-01 13:32:54 +01:00
Dave Hylands
b5fb9b22e2 Add a comma to make the .csv look proper in github 2014-05-30 22:18:52 -07:00
Damien George
2617eebf2f Change const byte* to const char* where sensible.
This removes need for some casts (at least, more than it adds need
for new casts!).
2014-05-25 22:27:57 +01:00
Damien George
7a4ddd2428 Add SystemExit exception and use it in unix/ and stmhal/ ports.
Addresses issue #598.
2014-05-24 23:32:19 +01:00
Damien George
ee3fd46f13 Rename configuration variables controling Python features.
Now of the form MICROPY_PY_*.  See issue #35.
2014-05-24 23:03:12 +01:00
Damien George
58ebde4664 Tidy up some configuration options.
MP_ALLOC_* -> MICROPY_ALLOC_*
MICROPY_PATH_MAX -> MICROPY_ALLOC_PATH_MAX
MICROPY_ENABLE_REPL_HELPERS -> MICROPY_HELPER_REPL
MICROPY_ENABLE_LEXER_UNIX -> MICROPY_HELPER_LEXER_UNIX
MICROPY_EXTRA_* -> MICROPY_PORT_*

See issue #35.
2014-05-21 20:32:59 +01:00
Damien George
6ac5dced24 py: Rename MP_OBJ_NOT_SUPPORTED to MP_OBJ_NULL.
See issue #608 for justification.
2014-05-21 19:42:43 +01:00
Damien George
6d197740cf stmhal: Stop USB before entering DFU by software. 2014-05-21 19:25:34 +01:00
Paul Sokolovsky
9e29666bf9 py: Implement proper separation between io.FileIO and io.TextIOWrapper.
io.FileIO is binary I/O, ans actually optional. Default file type is
io.TextIOWrapper, which provides str results. CPython3 explicitly describes
io.TextIOWrapper as buffered I/O, but we don't have buffering support yet
anyway.
2014-05-19 21:56:07 +03:00
Damien George
eee31288dd stmhal: Fix DAC documentation: need to convert float to int for buf. 2014-05-19 19:08:12 +01:00
Damien George
2de4d59171 stmhal: Fix write_timed function for DAC(2).
Addresses issue #617.
2014-05-19 18:58:53 +01:00
Damien George
f905ebb173 stmhal: Make pyb.bootloader take no arguments. 2014-05-19 18:26:51 +01:00
Sven Wegener
9bf4f7e3d3 stmhal: Remap system flash and adjust addresses
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
2014-05-18 13:15:02 +02:00
Sven Wegener
7ae8e4b679 stmhal: Activate bootloader with pyb.bootloader()
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
2014-05-18 12:51:21 +02:00
Damien George
89755ae67f py: Rename MICROPY_SYS_EXIT to MICROPY_MOD_SYS_EXIT.
For consistency with MICROPY_MOD_SYS_STDFILES, etc.
2014-05-11 17:35:43 +01:00
Damien George
f92a0d4d16 stmhal: Enable frozenset. Takes 292 text bytes in ROM. 2014-05-11 17:27:31 +01:00
Damien George
a7a1a38df4 stmhal: Update CC3000 driver to newer version.
Still not working properly.
2014-05-11 12:09:13 +01:00
Damien George
50073ed5d6 stmhal/cc3k: Remove spaces and tabs at end of lines. 2014-05-10 21:28:40 +01:00
Damien George
3793830ed9 tools: Move gendoc.py to tools, and make it a little more generic. 2014-05-10 19:12:47 +01:00
Damien George
09bbe7215a stmhal: Fix USB CDC not flushing packets when an exact multiple of 64.
Need to send a zero-sized packet after sending an exact multiple of 64
bytes (not just after sending 64 bytes exactly).

Addresses issue #494, part 2.
2014-05-10 18:56:16 +01:00
Damien George
b0edec61ac stmhal: Improve handling of out-of-memory in REPL.
Addresses issue #558, but it's likely that other out-of-memory errors
could crash the pyboard.  Reason is that qstrs use m_new and can raise
an exception within the parser.
2014-05-10 17:48:46 +01:00
Paul Sokolovsky
deaeaac469 modsys: Enable sys.exit() per port after all. 2014-05-10 17:26:47 +03:00
Paul Sokolovsky
0f14fdea0c stmhal: Implement draft version of sys.exit(). 2014-05-10 16:56:21 +03:00
Damien George
04b7cc4df0 stmhal: Fix setting of RTC: was BCD now BIN encoded.
Addresses issue #592.
2014-05-10 11:56:58 +01:00
Damien George
8c1c7488b2 Add gc.enable, gc.disable; remove pyb.gc. 2014-05-08 23:04:49 +01:00
Damien George
d6cbbc51ab stmhal: Add time.time() and time.localtime().
time.time: returns seconds since 1/1/2000, as an integer.

time.localtime: Returns 8-tuple: (year, month, date, hour, minute,
    second, weekday, yearday).
2014-05-08 22:25:49 +01:00
Dave Hylands
117c46d9eb Add input command for unix 2014-05-07 07:19:51 -07:00
Damien George
491cbd6a7c py: Add keyword arg support to enumerate constructor.
Need to have a policy as to how far we go adding keyword support to
built ins.  It's nice to have, and gets better CPython compatibility,
but hurts the micro nature of uPy.

Addresses issue #577.
2014-05-06 16:38:54 +00:00
Paul Sokolovsky
33b3a6905d stmhal: pyb: Use gc() function as defined by standard module "gc".
TODO: Get rid of this compatibility define and rely on standard module.
2014-05-06 02:28:49 +03:00
Dave Hylands
1145a0706c Change references (in comments) of pyb.GPIO to be pyb.Pin
The documentation at http://micropython.org/doc/module/pyb/ExtInt should also be
updated.
2014-05-05 10:58:38 -07:00
Damien George
5fc400ccdb stmhal: Document physical pins for SPI, I2C, UART busses. 2014-05-04 14:28:11 +01:00
Damien George
04b9147e15 Add license header to (almost) all files.
Blanket wide to all .c and .h files.  Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.

Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-05-03 23:27:38 +01:00
Damien George
d5f5b2f766 py, stream: Implement readlines for a stream. 2014-05-03 22:01:32 +01:00
Craig Barnes
c9f9e547d6 Add device ID to deploy make target for stmhal. 2014-05-03 19:51:47 +01:00
Damien George
6ec835dfef Don't print git hash as well as git tag in banner. 2014-05-03 19:08:02 +01:00
Damien George
977a0ce287 py: Print tag/version/git describe in uPy banner. 2014-05-03 19:02:14 +01:00
Damien George
b4bb3fdb9c Merge pull request #555 from lurch/patch-1
RTC doc fix
2014-05-03 18:44:02 +01:00
Damien George
93e51b594a stmhal: Enable cmath module. 2014-05-03 18:40:50 +01:00
Andrew Scheller
86a9a88632 Fix incorrect fix ;) 2014-05-03 18:28:11 +01:00
Damien George
bb8ba7fc90 stmhal: Add .gitignore to ignore the new build dir names. 2014-05-03 18:26:03 +01:00
Andrew Scheller
e9ff5570c3 Updated doc fix 2014-05-03 17:50:46 +01:00
Damien George
aad1204b8e stmhal: Change names: flash to firmware, flashboard to deploy.
Since firmware lives in a build directory which already specifies the
board name, no real reason to also have the firmware have the board
name.
2014-05-03 17:46:45 +01:00
Damien George
51315614e1 stmhal: Default build directory now includes board name.
BUILD is build-$(BOARD) by default.
2014-05-03 17:39:07 +01:00
Andrew Scheller
b569d690f5 RTC doc fix 2014-05-03 17:34:19 +01:00
Damien George
ae8feac598 stmhal: Wrap CC3000 driver in MICROPY_HW_ENABLE_CC3K.
This renames MICROPY_HW_HAS_WLAN to MICROPY_HW_ENABLE_CC3K (since it's a
driver, not a board feature) and wraps all CC3000 code in this #if.
It's disabled for all boards.
2014-05-03 17:32:55 +01:00
Damien George
baa2afbb58 stmhal: Fix typos in class documentation. 2014-05-03 16:42:27 +01:00
Damien George
bff1ff28ee stmhal: Fix bug where negative delay/udelay lead to huge delays.
A negative ms/us is now treated as a delay of 0 ms/us.  This patch also
improves the calibration of udelay.
2014-05-03 14:11:56 +01:00
Damien George
5874c1c92b stmhal: Remove #include <stdint.h> from mpconfigport.h.
Make include dependencies neater, and adheres to the coding convention
that headers should not include headers.
2014-05-03 13:24:21 +01:00
Damien George
ffaf8be1c6 stmhal: Add example use to RTC doc; add rtc.c to gendoc.py. 2014-05-03 12:02:21 +00:00
Damien George
451f78d156 stmhal: Add documentation for RTC class. 2014-05-03 12:40:53 +01:00
Damien George
8f472ad577 Merge pull request #548 from dhylands/fix-pin-defn
Fix PB0 ADC typo.
2014-05-03 00:16:48 +01:00
Craig Barnes
a0ddae86e5 Add device ID to autoflash script. 2014-05-02 23:03:23 +01:00
Dave Hylands
5788485cca Fix PB0 ADC typo.
This also adds a bunch of slashes separating pin that have multiple functions.
2014-05-02 14:01:23 -07:00
Damien George
003977a70b Merge branch 'master' of github.com:micropython/micropython 2014-05-02 16:58:32 +01:00
Damien George
3eb8163b16 stmhal: Add documentation for DAC and Timer classes. 2014-05-02 16:58:15 +01:00
Paul Sokolovsky
9b71b16a94 unix,stmhal: Make "mpconfig.h" be first included, as other headers depend on it. 2014-05-02 18:08:16 +03:00
Damien George
ba742ed639 Add shell script to automatically build stmhal/ for all pyboards. 2014-05-02 13:49:44 +00:00
Damien George
f2021ffe0f Merge pull request #542 from dhylands/fix-pin
Fix pin initialization when a mode argument is provided
2014-05-01 23:26:28 +01:00
Dave Hylands
e911cfdb22 Fix pin initialization when a mode argument is provided 2014-05-01 12:15:37 -07:00
Andrew Scheller
ed9d8d6354 Add flashboard target to the stmhal Makefile to run dfu-util
Which allows you to run "make -C stmhal flashboard" from the top-level directory.
Also ties in nicely with my configurable BUILD directory from #506
2014-05-01 02:51:29 +01:00
Damien George
f4b7e9bd2e stmhal, docs: Small changes to URL links; adds list of files if none given.
This documentation is now available at micropython.org/doc/
2014-04-30 23:33:30 +01:00
Damien George
4ae52d454c stmhal: Reinstate CC3000 driver from old stm/ port.
It's not enabled by default because it doesn't fully work.  It can
connect to an AP, get an IP address and do a host-lookup, but not yet do
send or recv on a socket.
2014-04-30 20:47:50 +01:00
Damien George
cab23051d9 stmhal: Make LED.intensity return the same value it was set to.
Also give proper error message when trying to construct a non-existent
LED.

Addresses issue #530.
2014-04-30 19:23:21 +01:00
Damien George
da9f27103d stmhal: Oops, typo. 2014-04-29 23:00:48 +01:00
Damien George
8d09640b22 stmhal: Add documentation in comments, and script to generate HTML.
Decided to write own script to pull documentation from comments in C code.
Style for writing auto generated documentation is: start line with ///
and then use standard markdown to write the comment.  Keywords
recognised by the scraper begin with backslash.  See code for examples.

Running: python gendoc.py modpyb.c accel.c adc.c dac.c extint.c i2c.c
led.c pin.c rng.c servo.c spi.c uart.c usrsw.c, will generate a HTML
structure in gendoc-out/.

gendoc.py is crude but functional.  Needed something quick, and this was
it.
2014-04-29 22:55:34 +01:00
Damien George
dbc81df5d4 Simplify names for argcheck.c / arg parsing. 2014-04-26 11:19:17 +01:00
Damien George
6d3c5e4301 Add ARRAY_SIZE macro, and use it where possible. 2014-04-26 10:47:29 +01:00
Damien George
5ea69859c9 stmhal: Update help text. 2014-04-21 20:18:22 +01:00
Damien George
350cb6bf20 stmhal: Fix bug with pin GPIO reading. 2014-04-21 20:18:06 +01:00
Damien George
ef255e47c1 stmhal, usrsw: Wrap usrsw.c in #if, for when switch is not available. 2014-04-21 18:31:40 +01:00
Damien George
b97c2f4c14 stmhal, accel: Add TODO comment. 2014-04-21 18:30:38 +01:00
Damien George
46e1f26615 stmhal, usrsw: Update comments for new switch API. 2014-04-21 18:28:23 +01:00
Damien George
6125ba4a7f stmhal: Make switch a class, to follow suit of all other modules.
Instead of pyb.switch() as a function, it's more consistent (with
respect to all the other modules and peripherals) to have
pyb.Switch() create a switch object.  This then generalises to having
multiple switches.  Call the object to get its state.  Use sw.callback
to set the callback function for when the switch is pressed.
2014-04-21 18:23:50 +01:00
Damien George
af797f476f stmhal, servo: Rename calibrate method to calibration.
It should be a noun, since it supports getting and setting depending on
the number of arguments given.
2014-04-21 18:21:07 +01:00
Damien George
6691c9e655 stmhal, timer: Remove obsolete global variable. 2014-04-21 18:19:50 +01:00
Damien George
7fdfa93700 stmhal: Add Timer class: simple TIM control, incl callback on IRQ.
Simple but functional timer control.  More sophistication will
eventually be added, or for now just use direct register access :)

Also added pyb.freq() function to get MCU clock frequencies.
2014-04-21 16:48:16 +01:00
Damien George
764af4b7c5 stmhal: Make DAC dynamically allocate instances; rename dma->write_timed. 2014-04-21 13:06:19 +01:00
Damien George
83407ad082 stmhal: Clean up rtc.c a bit. 2014-04-21 12:45:59 +01:00
Damien George
7533700393 stmhal: Rename USART to UART.
It's really a UART because there is no external clock line (and hence no
synchronous ability, at least in the implementation of this module).
USART should be reserved for a module that has "S"ynchronous capabilities.

Also, UART is shorter and easier to type :)
2014-04-21 12:03:09 +01:00
Damien George
34f01c2ca1 stmhal: Add some documentation to I2C, SPI and USART modules. 2014-04-21 01:59:43 +01:00
Damien George
3771a097da stmhal: Improve USART class, to be more like SPI and I2C.
The three classes I2C, SPI and USART now have a fairly uniform (Python)
API.  All are constructed, initialised and deinitialised in the same
way.  They can have most of their parameters set, using keyword arguments.
All have send and recv (although slightly different with I2C requiring an
address in master mode).  recv can do inplace receiving (ie store the
data in a previously-created bytearray).

It's just polling mode at the moment, but interrupt and DMA would be
nice to add.
2014-04-21 01:14:14 +01:00
Damien George
eb8bdf4df3 stmhal, SPI and I2C: Improvements to functionality and consistency. 2014-04-21 00:10:04 +01:00
Damien George
ff91156d34 stmhal: Improved configurability for I2C and SPI busses.
The HAL handles for the I2C/SPI objects are rather large, so we don't
want to unnecessarily include them.
2014-04-20 19:06:15 +01:00
Dave Hylands
f70630c58f Fix i2c and spi to compile for Netduino Plus 2 2014-04-20 00:06:03 -07:00
Damien George
fd6925b4b9 stmhal: Small bug fixes and simplifications. 2014-04-20 01:25:58 +01:00
Damien George
13c19c57a0 stmhal: Only init RNG if it's used. 2014-04-20 00:45:59 +01:00
Damien George
0a6e9f562f stmhal: Update ExtInt to allow keyword arguments in constructor. 2014-04-20 00:38:50 +01:00
Damien George
57e415859a stmhal: Tidy up and improve consistency across modules. 2014-04-20 00:30:09 +01:00
Damien George
d689430e79 stmhal: Add SPI class.
Also some updates to compile with latest changes to core py.
2014-04-20 00:16:30 +01:00
Damien George
27dd471098 Merge branch 'master' of github.com:micropython/micropython 2014-04-19 02:18:19 +01:00
Damien George
3d19137442 stmhal: Add pyb.Pin.init method to re-init GPIO pin mode. 2014-04-19 02:17:57 +01:00
Damien George
6e44381cce stmhal: Improve RTC class; make fatfs use RTC for time stamping files. 2014-04-19 02:17:30 +01:00
Damien George
ed5117f6a8 stmhal: Add pyb.unique_id, to get unique id of MCU. 2014-04-19 01:28:18 +01:00
Paul Sokolovsky
206dd2a905 stmhal: Update for mp_binary_get_size() refactor. 2014-04-19 03:27:37 +03:00
Damien George
44ee42de50 stmhal: Rename pyb.Led to pyb.LED to conform to naming rules.
It's Light Emitting Diode, so should be LED.
2014-04-19 00:54:33 +01:00
Damien George
8cf08a58a1 stmhal: Remove pyb.input (use sys.stdio.read(1) instead). 2014-04-19 00:50:50 +01:00
Damien George
f20e093b9b stmhal: Add lots of constants to stm module. 2014-04-19 00:32:25 +01:00
Damien George
38ae014e42 stmhal: Update ADC, DAC and I2C objects to use new buffer protocol.
Main reason for expanding buffer protocol API was to support writes to a
buffer in ADC module (see read_timed).  With this change you can now
create an array of arbitrary type and ADC.read_timed will store into
that array in the correct format (byte, int, float).  I wonder though if
all these changes were really worth it to support just this function.
Hopefully this enhanced buffer protocol API (with typecode specified)
will be used elsewhere.
2014-04-18 23:28:56 +01:00
Damien George
a8f5d15fc6 stmhal: Update help and comments re gpio changing to Pin. 2014-04-18 22:48:59 +01:00
Damien George
c66d86c5ce stmhal: Big cleanup; merge gpio into Pin; make names consistent.
This is an attempt to clean up the Micro Python API on the pyboard.
Gpio functionality is now in the Pin object, which seems more natural.
Constants for MODE and PULL are now in pyb.Pin.  Names of some
classes have been adjusted to conform to CamelCase.  Other
miscellaneous changes and clean up here and there.
2014-04-18 22:38:09 +01:00
Damien George
906d383850 stmhal: Remove non-ascii character from include file. 2014-04-18 16:17:40 +01:00
Damien George
5b65f0c7d3 py: Rename USE_COMPUTED_GOTOS to USE_COMPUTED_GOTO and enable on stmhal.
On stmhal, computed gotos make the binary about 1k bigger, but makes it
run faster, and we have the room, so why not.  All tests pass on
pyboard using computed gotos.
2014-04-17 23:24:13 +01:00
Damien George
d0f9f6cd3f py: Fix pfenv_print_strn to return correct number of chars printed.
With this fix, all tests in tests/basics pass on pyboard.
2014-04-17 18:58:09 +01:00
Damien George
d553be5982 build: Simplify build directory layout by putting all headers in genhdr.
Any generated headers go in $(BUILD)/genhdr/, and are #included as
'genhdr/xxx.h'.
2014-04-17 18:03:27 +01:00
Damien George
2d1f865d16 Merge branch 'relocatable-build-dir' of github.com:lurch/micropython into lurch-relocatable-build-dir 2014-04-17 17:44:52 +01:00
Damien George
5f82b50324 Merge branch 'master' of github.com:micropython/micropython 2014-04-17 17:11:58 +01:00
Damien George
fb06bfc11c stmhal: Clean up fatality indications; remove long-obsolete malloc0.c. 2014-04-17 17:04:15 +01:00
Damien George
d7a4b69039 stmhal: Change VID to 0xf055=FOSS, and PID to a random number.
Needs a better solution.
2014-04-17 01:09:32 +01:00
Damien George
b08f9212e2 Merge pull request #500 from dhylands/fix-sdcard-removed
Fix to allow usbd_msc_storage.c to compile when MICROPY_HW_HAS_SDCARD is...
2014-04-17 00:23:43 +01:00
Damien George
89831d0289 stmhal: Add more math functions.
Taken straight from musl and newlib.  License seems compatible with MIT.
2014-04-17 00:13:13 +01:00
Damien George
efc22e376f stmhal: Fix 64-byte USB packet bug properly.
A 64-byte packet is now followed by a 0-byte packet if there is nothing
more to send.  This flushes the USB endpoint.
2014-04-17 00:12:07 +01:00
Damien George
28817725fc stmhal: Replace magic number 3 with CDC_IN_EP define. 2014-04-16 23:17:29 +01:00
Damien George
6d983539bc stmhal: Improve flash storage cache management.
Internal flash used for the filesystem is now written (from the cache)
only after a 5s delay, or when a file is closed, or when the drive is
unmounted from the host.  This delay means that multiple writes can
accumulate in the cache, and leads to less writes to the flash, making
it last longer.

It's implemented by a high-priority interrupt that takes care of flash
erase and write, and flushing the cache.

This is still only an interim solution for the flash filesystem.  It
eventually needs to be replaced with something that uses less RAM for
the cache, something that can use more of the flash, and something that
does proper wear levelling.
2014-04-16 23:08:36 +01:00
Andrew Scheller
70a7d7a943 build directory can now be renamed
The autogenerated header files have been moved about, and an extra
include dir has been added, which means you can give a custom
BUILD=newbuilddir option to make, and everything "just works"

Also tidied up the way the different Makefiles build their include-
directory flags
2014-04-16 22:16:28 +01:00
Dave Hylands
e553ff2f75 Fix to allow usbd_msc_storage.c to compile when MICROPY_HW_HAS_SDCARD isn't defined. 2014-04-16 10:01:17 -07:00
Damien George
f6be480bda stmhal: Add pyb.have_cdc function to check if USB CDC device is enabled. 2014-04-16 15:52:50 +01:00
Damien George
9388a90842 stmhal: Fix USB CDC buffer overrun error.
Need to wait for the low-level USB driver to send the data over the USB
in-endpoint before the buffer can be used again.  This patch adds a
check for this.
2014-04-16 15:51:27 +01:00
Damien George
bda2f70964 Merge pull request #498 from lurch/create-headers-from-files
Auto-generate the stmhal/pybcdc_inf header file from static files
2014-04-16 10:54:16 +01:00
Damien George
1381146382 stmhal: Fix C bindings of I2C.read/write. 2014-04-16 10:43:03 +01:00
Andrew Scheller
1452221aca Auto-generate the stmhal/pybcdc_inf header file from static files
The USB VID&PID are automatically extracted from usbd_desc_cdc_msc.c
and inserted into pybcdc_inf.template, ensuring that the same USB
IDs get used everywhere
2014-04-16 02:41:26 +01:00
Damien George
2822d4e6ce stmhal: Add I2C functions for pure master read/write. 2014-04-16 00:27:14 +01:00
Damien George
d5323f07ff Merge pull request #496 from dhylands/fix-debug-usart
Fix call to enable pyb_usart_global_debug.
2014-04-15 21:25:27 +01:00
Dave Hylands
00adf67179 Fix call to enable pyb_usart_global_debug. 2014-04-15 12:20:31 -07:00
Damien George
9699ea6a2f stmhal: Fix USB MSC so that it unmounts correctly on Mac OS X.
Mac OS X sends a SCSI command to remove the medium when it unmounts a
drive.  If this command is not honoured, then OS X will automatically
remount the drive, making it impossible to eject.  This patch disables
the USB MSC when the right SCSI command is sent.
2014-04-15 19:56:32 +01:00
Damien George
4d7f4eb6a9 stmhal: Add ADC function to read data at a given frequency.
Reads ADC values into a bytearray (or similar) at a fixed rate.  Needs a
better name and improved API.  Also fix up DAC dma function (which also
needs a better name and API).
2014-04-15 19:52:56 +01:00
Damien George
e95da5b784 stmhal: Add I2C.scan method, to scan all devices on the bus.
Simple way to find the address of an attached I2C device.
2014-04-15 19:24:13 +01:00
Damien George
f6d25ecf7b stmhal: Add simple README.txt to freshly-created filesystem. 2014-04-15 19:20:25 +01:00
Damien George
c13d0b3304 stmhal: Wrap skin-named-usarts in PYBV10 #if. 2014-04-15 11:52:47 +01:00
Damien George
cce7119a2b stmhal: Work around crazy bug in USB CDC.
Packets of 64 bytes length are not send to the host until the following
packet is sent.  Fixed by never sending packets of 64 bytes length.
2014-04-14 01:46:25 +01:00
Damien George
7e5be0b1b4 stmhal: Improved usart module a bit. 2014-04-14 01:45:58 +01:00
Damien George
6dba016a56 stmhal: Add pyb.wfi() function (calls __WFI). 2014-04-14 01:45:24 +01:00
Damien George
86a03044e3 stmhal: Add stdin/stdout/stderr objects.
Available via sys.std{in,out,err}.  Basic reading and writing supported.
Even sys.stdin.readline!
2014-04-13 19:00:56 +01:00
Damien George
212f89e61a stmhal: Improve USB CDC write function (increase timeout). 2014-04-13 16:39:04 +01:00
Damien George
73496fbbe4 py: Fix up source-line calculation.
Should address issue #475.
2014-04-13 14:51:56 +01:00
Damien George
cb861a5c6a stm[hal]: Init mp_sys_path and mp_sys_argv correctly. 2014-04-13 13:19:09 +01:00
Damien George
640e7e4779 Merge pull request #476 from pfalcon/static-sys
Convert sys module to static allocation
2014-04-13 12:52:39 +01:00
Damien George
8a1cab952f py: Fix mp_get_buffer, and use it in more places.
Must use mp_obj_get_type to get the type of an object.  Can't assume
mp_obj_t is castable to mp_obj_base_t.
2014-04-13 12:08:52 +01:00
Damien George
0aab675108 stmhal: Little hack to dump GC allocation table using pyb.info().
Pass a single parameter (doesn't matter what): pyb.info(1), will dump
the GC alloc table.
2014-04-13 11:10:58 +01:00
Paul Sokolovsky
4165cd1c0c stmhal: Update for static mod sys. 2014-04-13 07:02:57 +03:00
Damien George
82c7b1b1d5 stmhal: Put a USB structure in ROM; GC doesn't scan the data segment. 2014-04-12 18:50:20 +01:00
Damien George
b96c7c03ca stmhal: Move fatfs volume/partition lookup table to ROM. 2014-04-12 00:51:57 +01:00
Damien George
60427864b1 stmhal: Move I2C objects to ROM. 2014-04-12 00:51:41 +01:00
Damien George
037b3e0e21 Merge pull request #458 from lurch/patch-1
Tweak pybcdc.inf to match recent changes to pybcdc.h
2014-04-10 22:51:48 +01:00
Damien George
3f4898456b stmhal: Add stm module, which contains some constants for the MCU.
Also contains raw memory read/write functions, read8, read16, read32,
write8, write16, write32.  Can now do:

stm.write16(stm.GPIOA + stm.GPIO_BSRRL, 1 << 13)

This turns on the red LED.

With the new constant folding, the above constants for the GPIO address
are actually compiled to constants (and the addition done) at compile
time.  For viper code and inline assembler, this optimisation will make
a big difference.  In the inline assembler, using these constants would
not be possible without this constant folding.
2014-04-10 22:46:40 +01:00
Andrew Scheller
fec6f018ee Tweak pybcdc.inf to match recent changes to pybcdc.h 2014-04-10 02:07:55 +01:00
Damien George
7a5f9e94ad stmhal: Make /src/main.py just /main.py; allow SD to be used as root device. 2014-04-09 23:30:34 +01:00
Damien George
a5c18f3285 stmhal: Update windows driver; \r\n newlines and addition USB id. 2014-04-09 02:23:24 +01:00
Damien George
b99ca2cdde stmhal: Add windows cdc .inf driver to flash filesystem. 2014-04-09 01:16:49 +01:00
Damien George
8e6f98b166 stmhal: Improve help() function. 2014-04-09 01:16:29 +01:00
Damien George
229347139b stmhal: Add functionality to Servo object.
Can now calibrate, set pulse width, angle and speed.
2014-04-09 00:45:45 +01:00
Dave Hylands
3bbceeaaf7 Fix make-pins.py to support having multiple names for a pin.
SW and X17 now both map to PB3
2014-04-08 15:45:47 -07:00
Damien George
b04488151e stmhal: Make USRSW re-register the EXTI callback each time it's set. 2014-04-08 22:35:42 +01:00
Damien George
2137bc7124 stmhal: in EXTI interrupt handler wrap uPy calls in gc_lock and nlr_buf. 2014-04-08 15:21:26 +01:00
Damien George
26cf55ae05 Add a check for NULL nlr_top in nlr_jump.
If no nlr_buf has been pushed, and an nlr_jump is called, then control
is transferred to nlr_jump_fail (which should bail out with a fatal
error).
2014-04-08 14:08:14 +00:00
Damien George
97790455fe Improve REPL detecting when input needs to continue.
Full CPython compatibility with this requires actually parsing the
input so far collected, and if it fails parsing due to lack of tokens,
then continue collecting input.  It's not worth doing it this way.  Not
having compatibility at this level does not hurt the goals of Micro
Python.
2014-04-08 11:04:29 +00:00
Paul Sokolovsky
72d70cb045 unix, stmhal: Consistently use "FileIO" as class name for file objects.
They correspond to io.FileIO in io module hierarchy (with small caveat
that io.FileIO is raw file and works with bytes, not strings).
2014-04-08 04:08:16 +03:00
Andrew Scheller
902d9552c5 Replace some Makefile commands with variables in py/mkenv.mk 2014-04-07 01:35:45 +01:00
Damien George
65cad12d38 py: Add option to compiler to specify default code emitter.
Also add command line option to unix port to select emitter.
2014-04-06 11:48:15 +01:00
Damien George
27e735fd18 py: Replace stream_p with *stream_p in mp_obj_type_t.
This is to reduce ROM usage.  stream_p is used in file and socket types
only (at the moment), so seems a good idea to make the protocol
functions a pointer instead of the actual structure.

It saves 308 bytes of ROM in the stmhal/ port, 928 in unix/.
2014-04-05 23:02:23 +01:00
Damien George
7efc5b3f34 py: Make globals and locals proper dictionary objects.
Finishes addressing issue #424.

In the end this was a very neat refactor that now makes things a lot
more consistent across the py code base.  It allowed some
simplifications in certain places, now that everything is a dict object.

Also converted builtins tables to dictionaries.  This will be useful
when we need to turn builtins into a proper module.
2014-04-05 22:36:42 +01:00
Damien George
8b0535e23f py: Change module globals from mp_map_t* to mp_obj_dict_t*.
Towards addressing issue #424.

Had a small increase to ROM usage (order 60 bytes).
2014-04-05 21:53:54 +01:00
Damien George
12bab72d93 Improve GC finalisation code; add option to disable it. 2014-04-05 20:35:48 +01:00
Damien George
ea13f407a3 py: Change nlr_jump to nlr_raise, to aid in debugging.
This does not affect code size or performance when debugging turned off.

To address issue #420.
2014-04-05 18:32:08 +01:00
Damien George
e20b6b418c stmhal: autoflash now enters serial comms after flashing. 2014-04-05 17:16:00 +01:00
Damien George
38d3430320 stmhal: Add more escape seqs; add debugging output for escape seq. 2014-04-05 11:45:59 +01:00
Paul Sokolovsky
cdffa32699 stmhal readline: Parse XTERM Home/End key codes.
Which are ESC O H, ESC O F.
2014-04-05 02:47:26 +03:00
Dave Hylands
bf7d690e36 Add the git version to the banner 2014-04-03 16:55:15 -07:00
Damien George
3996611c1b stmhal: Add home/end cursor support in readline.
Home/end work in picocom and screen (different codes in those 2
programs).  Also, CTRL-A (for non-empty liny) and CTRL-E act as
home/end.
2014-04-03 23:30:24 +01:00
Damien George
3269cf2f93 Merge pull request #419 from pfalcon/stmhal-file-streams
stmhal: Reimplement file support using stream protocol API.
2014-04-03 22:48:32 +01:00
Damien George
57ad7aa66b stmhal: On soft reset, if in raw REPL mode, don't run main.py. 2014-04-03 22:44:08 +01:00
Damien George
d8b47d3e02 stmhal: Fix raw REPL so that it passes through more ASCII chars. 2014-04-03 22:11:43 +01:00
Damien George
769b23a9c6 stmhal: Add powf, logf, log2f, log10f. 2014-04-03 22:11:28 +01:00
Damien George
aba9f51fef stmhal: #undef log2f if it's defined. 2014-04-03 21:16:37 +01:00
Paul Sokolovsky
1d4d9ddd9e stmhal: Reimplement file support using stream protocol API.
This adds readline(), readall(), etc. methods. Also other fixes to make
Python API compliant and "with" support.
2014-04-03 22:14:29 +03:00
Damien George
e90eefc84b stmhal: Fix servo object; add fpclassify to math functions. 2014-04-02 19:55:08 +01:00
Damien George
a12be917a4 stmhal: Add timer module; move servo PWM from TIM2 to TIM5.
As per issue #257, servo is better on TIM5 because TIM2 is connected to
more GPIO.
2014-04-02 15:09:36 +01:00
Damien George
69dee59ce4 stmhal: Add backspace key to readline (along with delete key). 2014-04-02 14:28:58 +01:00
Dave Hylands
18d21d1abd Fix pyb.Led(n) code to work properly. 2014-04-01 10:41:22 -07:00
Dave Hylands
baf6f14deb Enhance str.format support
This adds support for almost everything (the comma isn't currently
supported).

The "unspecified" type with floats also doesn't behave exactly like
python.

Tested under unix with float and double
Spot tested on stmhal
2014-04-01 01:17:33 -07:00
Damien George
15d18069c5 py: Remove old "run time" functions that were 1 liners. 2014-03-31 16:28:13 +01:00
Damien George
df6567e634 Merge map.h into obj.h.
Pretty much everyone needs to include map.h, since it's such an integral
part of the Micro Python object implementation.  Thus, the definitions
are now in obj.h instead.  map.h is removed.
2014-03-30 13:54:02 +01:00
Damien George
d17926db71 Rename rt_* to mp_*.
Mostly just a global search and replace.  Except rt_is_true which
becomes mp_obj_is_true.

Still would like to tidy up some of the names, but this will do for now.
2014-03-30 13:35:08 +01:00
Damien George
09d207785c stmhal: Unify naming of HW config; make SD detect configurable.
All board config macros now begin with MICROPY_HW_.

Renamed PYBv10 to PYBV10, since macros should be all uppercase.

Made SDCARD_DETECT configurable in mpconfigport.h, so that the SD
detect pin can be easily configured.
2014-03-30 12:30:35 +01:00
Damien George
038df43183 stmhal: Implement selector for USB device mode; improve boot up.
Can now choose at boot up whether the USB device is CDC+MSC or CDC+HID.
Choice is made by an option in boot.py, with default being CDC+MSC.
HID+MSC is not currently supported, but should be easy to implement.

Boot up now has ability to change the reset mode: hold down USR switch
while booting and LEDs will count from 1 to 7 to indicate the boot mode.
Release USR when correct mode is selected.  Current modes are 1 (normal
boot), 2 (safe mode), 3 (reset FS mode).
2014-03-30 00:00:15 +00:00
Damien George
64563e39b3 stmhal: Add CDC+HID USB device.
The HID device must appear before the CDC in order for both to work at
the same time.

Whilst the code is working, it's not currently used.
2014-03-29 21:57:30 +00:00
Damien George
f4417a1f95 stmhal: Add Windows .inf file for USB CDC device. 2014-03-29 17:43:02 +00:00
Damien George
c9fd6645b0 stmhal: Factor out stdio and readline to separate files.
Adds readline_init() to clear readline history on soft reset.  Addresses
issue #387.
2014-03-29 14:20:05 +00:00
Damien George
3e1a5c10c5 py: Rename old const type objects to mp_type_* for consistency. 2014-03-29 13:43:38 +00:00
Damien George
bcc9298e5b stmhal: Add TODO's to exti.c; fix delay in lcd.c. 2014-03-29 01:24:44 +00:00
Damien George
eed6f26bed stmhal: Use rt_check_nargs to check number of arguments. 2014-03-26 22:46:03 +00:00
Damien George
174bca7b5a stmhal: Remove ExtiMeta object and clean up class constants. 2014-03-26 22:35:55 +00:00
Damien George
9b196cddab Remove mp_obj_type_t.methods entry and use .locals_dict instead.
Originally, .methods was used for methods in a ROM class, and
locals_dict for methods in a user-created class.  That distinction is
unnecessary, and we can use locals_dict for ROM classes now that we have
ROMable maps.

This removes an entry in the bloated mp_obj_type_t struct, saving a word
for each ROM object and each RAM object.  ROM objects that have a
methods table (now a locals_dict) need an extra word in total (removed
the methods pointer (1 word), no longer need the sentinel (2 words), but
now need an mp_obj_dict_t wrapper (4 words)).  But RAM objects save a
word because they never used the methods entry.

Overall the ROM usage is down by a few hundred bytes, and RAM usage is
down 1 word per user-defined type/class.

There is less code (no need to check 2 tables), and now consistent with
the way ROM modules have their tables initialised.

Efficiency is very close to equivaluent.
2014-03-26 21:47:19 +00:00
Damien George
c12b2213c1 Change mp_method_t.name from const char * to qstr.
Addresses issue #377.
2014-03-26 20:15:40 +00:00
Damien George
38f0c607b0 stmhal: Change Usart creation function to class make_new. 2014-03-25 23:40:54 +00:00
Damien George
3021632501 stmhal: Shuffle around some init functions in main(). 2014-03-25 23:33:47 +00:00
Damien George
6cfda3084d stmhal: Add I2C support; change accel driver to use new I2C. 2014-03-25 23:26:14 +00:00
Damien George
caac542b23 Proper support for registering builtin modules in ROM.
Comes with some refactoring of code and renaming of files.  All modules
are now named mod*.[ch].
2014-03-25 14:18:18 +00:00
Dave Hylands
f0729b19ad Fix netduino to build
Fix adc to work with resolution changes.
2014-03-24 23:26:41 -07:00
Damien George
da5e269e51 stmhal: Make pyb.ADC the ADC class (not a function). 2014-03-24 19:27:13 +00:00
Dave Hylands
1403298a65 stmhal - fixed up adc stuff
Added support for the ADC channels and mappings to make_pins.py

I'm not sure if the hal properly deals with the channel 16/18 differences
between the 40x and 42x. It seems to deal with it partially. This particular
aspect will need testing on a 42x or 43x.
2014-03-24 11:16:35 -07:00
Damien George
6609d636d0 stmhal: Add comment to DAC driver for function to implement. 2014-03-24 15:17:40 +00:00
Damien George
b13492f8ad stmhal: Add DAC driver. 2014-03-24 15:15:33 +00:00
Damien George
f704e7f20e stmhal: Improve REPL CTRL commands. 2014-03-24 12:23:37 +00:00
Damien George
2f8beb8d88 stmhal: Fix bug with USB CDC transmit buffer wrap around. 2014-03-24 12:23:03 +00:00
Damien George
0e9d96f18f stmhal: Make Led, Servo and Accel their class, not a function. 2014-03-24 11:48:39 +00:00
Damien George
5fd2ebbbdd stmhal: Update help function. 2014-03-24 11:27:56 +00:00
Damien George
f357a19202 stmhal: Fix issues with USB CDC init and receive.
Late USB enumeration could clear settings after they had been set.
Now fixed by not clearing some settings on init.

RX was blocking if received characters were not being processed, so
CTRL-C would not be picked up.  Now "fixed" by not blocking, but
instead discarding incoming characters if they overflow the buffer.
2014-03-23 18:54:48 +00:00
Damien George
9050b2ee33 stmhal: Improved interface to accelerometer. 2014-03-23 15:34:54 +00:00
Damien George
6fc5449343 stmhal: Remove servo LED debugging. 2014-03-23 14:52:46 +00:00
Damien George
90834b956d stm/stmhal: Change gammaf to tgammaf. 2014-03-23 14:00:02 +00:00
Damien George
506589a4b7 stmhal: Change flash MSD from fixed to removable drive. 2014-03-23 12:48:58 +00:00
Damien George
5a16658b21 stmhal: Copy changes to math.c from stm port. 2014-03-23 00:34:49 +00:00
Damien George
965e2bafea stmhal: Improve LED intensity get/set method. 2014-03-23 00:25:09 +00:00
Damien George
5e756c9860 stmhal: Rename servo_TIM2_Handle -> TIM2_Handle. 2014-03-22 23:57:03 +00:00
Damien George
908a670dfc stmhal: Add intensity method for blue LED.
As part of this, rejig the way TIM3 is initialised, since it's now
shared by USB CDC and the blue LED PWM.
2014-03-22 23:54:13 +00:00
Damien George
02fa035800 stmhal: Add input() and pyb.input() functions. 2014-03-22 23:53:50 +00:00
Damien George
8138205bea stm/stmhal: Add more math stubs. 2014-03-22 20:44:43 +00:00
Damien George
0119fc7532 stmhal: Servo driver can move at a given speed. 2014-03-22 18:34:16 +00:00
Damien George
626f6b8133 stmhal: Add servo driver. 2014-03-22 15:52:33 +00:00
Damien George
d311655655 stmhal: Add time module with sleep function. 2014-03-22 15:06:29 +00:00
Damien George
ad7b84a7b9 stmhal: Add os module with a few basic functions. 2014-03-22 14:56:32 +00:00
Damien George
684164a8cf stmhal: Add PYBv10 config; add RNG support. 2014-03-22 13:41:02 +00:00
Damien George
2fb37847a7 stmhal: Tidy up USB CDC+MSC device some more. 2014-03-22 13:21:58 +00:00
Damien George
fb1d6d097e sthmal: Remove obsolete files. 2014-03-22 12:51:10 +00:00
Damien George
a6787edcea stmhal: Tidy up USB device configuration. Make it use less RAM. 2014-03-22 12:46:23 +00:00
Damien George
fb25c2d95f stmhal: USB CDC and MSC device work together. 2014-03-22 12:32:54 +00:00
Damien George
8913c04831 stmhal: Add support for USB MSC device.
This gives a functioning, independent MSC device.
2014-03-21 23:32:01 +00:00
Damien George
c070ff24a9 Disable some math functions until they work correctly. 2014-03-21 20:52:54 +00:00
Damien George
f78d9b1a72 stmhal: Add accelerometer driver; fix bug with LFN. 2014-03-20 23:33:30 +00:00
Damien George
494600bc99 stmhal: Add lcd.c to Makefile, and init LCD in main. 2014-03-19 13:12:30 +00:00
Damien George
e2e9011253 stmhal: Add LCD driver. 2014-03-19 13:11:59 +00:00
Damien George
b92d3e1fde stmhal: Add fatfs support, working with flash and SD card. 2014-03-17 14:04:19 +00:00
Damien George
9e5ea4d768 stmhal: Add flash write support and flash storage driver. 2014-03-17 13:31:35 +00:00
Damien George
8a9a31e57b stmhal: Add autoflash script, to flash a DFU device automatically. 2014-03-17 13:04:51 +00:00
Damien George
fb431bf556 stmhal: Add SD card support.
Just low-level read/write support.  No filesystem yet.
2014-03-17 13:03:41 +00:00
Damien George
781687c772 stmhal: Remove unnecessary include. 2014-03-17 10:24:29 +00:00
Dave Hylands
9c122029ec stmhal - Add usart support 2014-03-16 09:02:12 -07:00
Damien George
02a8543841 stmhal: Check CDC tx buffer has free space before filling with data. 2014-03-15 16:54:23 +00:00
Damien George
6c2455f481 stmhal: Put an array in ROM. 2014-03-15 14:46:35 +00:00
Damien George
fdbc22e4d2 stmhal: Disable redundant SystemCoreClockUpdate function. 2014-03-15 14:45:51 +00:00
Damien George
280e7208d8 Add vstr_ins and vstr_cut_out; improve stmhal readline. 2014-03-15 14:33:09 +00:00
Damien George
8b96af6907 stmhal: Get RTC working. 2014-03-15 12:54:48 +00:00
Damien George
07174c6fca stmhal: Fix escape sequences in USB CDC input. 2014-03-15 12:53:51 +00:00
Damien George
e285511a23 stmhal: Get USB CDC REPL working.
New USB HAL is quite a bit improved over previous one.  Now has better
callbacks and flow control.

REPL over USB CDC now works as before, except for soft-reset (since USB
driver uses malloc...).
2014-03-15 11:52:29 +00:00
Damien George
87e423b866 stmhal: Remove obsolete #defines from mpconfigport.h.
Either not needed anymore, or defined in the board/_hal_conf.h file.
2014-03-15 09:28:08 +00:00
Dave Hylands
ca5444e6cd stmhal - add pin mapping, gpio, exti, usrsw 2014-03-14 23:41:28 -07:00
Dave Hylands
0a64c92a9c stmhal - add led support. Add netduino_plus_2 support
Tweaked a couple of the USB files to compile if neither dev nor host was defined.
Tested on netduiono plus 2 and stm32f4discovery boards
2014-03-14 09:48:49 -07:00
Damien George
33bdd2119d Merge branch 'master' of github.com:micropython/micropython
Conflicts:
	stmhal/main.c
2014-03-14 00:33:07 +00:00
Damien George
b30c02afa0 stmhal: Get USB enumerating a CDC device.
Enumerates CDC device over USB, but doesn't transmit/receive yet.
2014-03-14 00:30:37 +00:00
Dave Hylands
9db719bb57 stmhal - More systick cleanup. Fix HAL_Delay 2014-03-13 16:17:01 -07:00
Dave Hylands
ef39f2d9ca Cleanup systick for stmhal 2014-03-13 14:40:49 -07:00
Dave Hylands
f14b92b9e1 REPl working on UART6 with STMHAL 2014-03-12 18:15:55 -07:00
Damien George
f555d5deca stmhal: Set SysTick priority to highest level. 2014-03-12 22:08:19 +00:00
Damien George
4ef1dbcbf6 stmhal: Get SysTick and HSE working. 2014-03-12 21:59:33 +00:00
Dave Hylands
dd38d90724 Initial checkin with STM HAL
This compiles and links, but hasn't been tested on a board
yet and even if it was run, it doesn't currently do anything.
2014-03-11 23:55:41 -07:00