Commit Graph

688 Commits

Author SHA1 Message Date
Damien George
3d30d605f5 stmhal: Factor out DMA initialisation code from spi.c.
This is so that the DMA can be shared by multiple peripherals.
2015-06-10 14:01:44 +01:00
Damien George
0aa5e75000 stmhal: Break immediately from USB CDC busy wait loop if IRQs disabled.
If IRQs are disabled then the USB CDC buffer will never be
drained/filled and the sys-tick timer will never increase, so we should
not busy wait in this case.
2015-06-07 23:48:07 +01:00
Damien George
53a8aeb6e7 stmhal: Fix slow SPI DMA transfers by removing wfi from DMA wait loop.
Addresses issue #1268.
2015-06-03 23:20:23 +01:00
Dave Hylands
3ac2d06bd1 stmhal: Add support for UART5
I tested this on my CERB40 board and it seems to be working fine.
2015-06-01 00:14:46 +01:00
Damien George
17d9b5006d stmhal: Fix off-by-one error when checking for valid I2C and SPI bus. 2015-05-28 11:05:44 +01:00
Damien George
70446f46c2 stmhal: Allow to name SPI busses, and give them names for pyboard. 2015-05-27 17:21:42 +01:00
Damien George
0e6f5e08e1 stmhal: Allow to name I2C busses, and give them names for pyboard. 2015-05-27 17:16:26 +01:00
Damien George
1775b65e07 stmhal: Remove PYBVxx defines and use config vars for UART/CAN names.
Now all stmhal-based boards can name their peripherals (if they want) to
any string.
2015-05-27 16:51:04 +01:00
Damien George
3c4b5d4281 stmhal: Implement sys.std{in,out,err}.buffer, for raw byte mode.
It's configurable and only enabled for stmhal port.
2015-05-24 14:31:33 +01:00
Dave Hylands
968b7dd173 stmhal: Detect disk full condition 2015-05-24 14:07:11 +01:00
Damien George
0d31bbc7fa stmhal: Make pendsv variable non-static so gcc-5 doesn't opt it away. 2015-05-23 17:42:58 +01:00
Kaspar Schleiser
f5dd6f7f37 py/binary: Make return type of mp_binary_get_size size_t instead of int.
Fixes sign-compare warning.
2015-05-17 18:12:19 +01:00
Damien George
1511dd4f84 stmhal: Add readinto and readlines methods to sys.stdin, pyb.USB_VCP().
Addresses issue #1255.
2015-05-13 20:22:11 +01:00
Josef Gajdusek
1db4253886 lib: Move time utility functions to common library. 2015-05-13 00:12:54 +01:00
Steve Zatz
c7df9c6c47 stmhal: Add os.rename function. 2015-05-12 23:43:11 +01:00
Damien George
c50772d19f py: Add mp_obj_get_int_truncated and use it where appropriate.
mp_obj_get_int_truncated will raise a TypeError if the argument is not
an integral type.  Use mp_obj_int_get_truncated only when you know the
argument is a small or big int.
2015-05-12 23:05:53 +01:00
blmorris
5df81de7af sthmal/rtc.c: Add calibration() method to get/set RTC fine-tuning value. 2015-05-11 23:48:39 +01:00
Dave Hylands
ff987ccf11 stmhal: Move debug UART repl to after uart_init0 call. 2015-05-06 22:16:49 +01:00
Damien George
c98c128fe8 pyexec: Make raw REPL work with event-driven version of pyexec.
esp8266 port now has working raw and friendly REPL, as well as working
soft reset (CTRL-D at REPL, or raise SystemExit).

tools/pyboard.py now works with esp8266 port.
2015-05-06 00:02:58 +01:00
Paul Sokolovsky
3d3ef36e97 modstruct: Rename module to "ustruct", to allow full Python-level impl. 2015-05-04 16:53:52 +03:00
Josef Gajdusek
04ee5983fe lib: Move some common mod_network_* functions to lib/netutils. 2015-05-04 11:48:40 +01:00
Eero af Heurlin
2378be4e93 stmhal: Allow to configure UART pins completely via mpconfigboard.h. 2015-05-03 13:48:26 +01:00
Dave Hylands
c3e37a0cde stmhal: Automatically re-enable IRQs on the USB REPL.
This allows errors to be seen and prevents hanging
the board from doing: pyb.disable_irq()
2015-04-29 08:27:38 +01:00
Damien George
b7a4f15b34 mp-readline: Save "prompt" string in readline state. 2015-04-29 00:32:35 +01:00
Damien George
95f53461c2 py: Replace py-version.sh with makeversionhdr.py, written in Python.
Also rename py-version.h to mpversion.h for consistency with mpconfig.h.
2015-04-28 23:52:36 +01:00
Dave Hylands
fdcb3b7ebb stmhal: Actually disable unhandled timer interrupts. 2015-04-28 00:17:05 -07:00
Dave Hylands
fd787c5e4e stmhal: Reset the timer counter to zero after changing the auto reload.
Because if the counter is above the new value of the auto-reload register
then it may be a long time until the timer wraps around.
2015-04-22 23:31:56 +01:00
Damien George
d8837cea6f stmhal: Implement os.uname() to get details of OS and hardware. 2015-04-21 14:51:49 +00:00
Damien George
f35b5d28db stmhal/pyexec.c: Make raw REPL mode 8-bit clean. 2015-04-19 21:30:49 +01:00
Damien George
404b68da88 stmhal: Provide ADC capabilities for F401 and F411 MCUs.
Simply needed to define which pins have which ADC channel on them.
2015-04-18 22:39:06 +01:00
Damien George
b42a5050fb stmhal: Add support for STM32F411 MCU. 2015-04-18 22:15:59 +01:00
Damien George
3e592531eb stmhal: For flash storage use same params for F407 as F405. 2015-04-18 22:08:16 +01:00
Damien George
90e6d0c2ac stmhal: Add support for Espruino Pico board.
To build:

make BOARD=ESPRUINO_PICO

To deploy: short the BOOT0/BTN contact on the back of the board (eg by
drawing over it with a graphite pencil), then hold down BTN while
inserting the board into the USB port.  The board should then enter DFU
mode, and the firmware can be downloaded using:

make BOARD=ESPRUINO_PICO deploy
2015-04-18 21:40:59 +01:00
Damien George
e4b4e5aa31 stmhal: Add stm32f401.ld for linking F401 targets. 2015-04-18 21:40:59 +01:00
Damien George
0435e76250 stmhal: Make ld and af files configurable within Makefile.
Each board now needs an mpconfigboard.mk file which defines AF_FILE and
LD_FILE.

Also moved stm32f405.ld to boards/ directory to keep things organised.
2015-04-18 21:40:59 +01:00
Damien George
03ec6e4d01 stmhal: Add stm32f401_af.csv, for AF definitions of F401 MCUs. 2015-04-18 21:40:59 +01:00
Damien George
9253e7bdf7 stmhal: Rename stm32f4xx_af.csv to stm32f405_af.csv.
Since this file is only valid for F405 MCUs, not generic F4xx.
2015-04-18 21:40:59 +01:00
Damien George
6be0bbb886 stmhal: Add support for flash filesystem on F401 MCUs.
It uses a 16k cache buffer and so the filesystem size is limited.
2015-04-18 21:40:59 +01:00
Damien George
5a11086d64 stmhal: Allow extint.c to compile without USB HS support. 2015-04-18 21:40:59 +01:00
Damien George
d15fe5a6b3 stmhal: Make I2C busses and their pins configurable in mpconfigboard.h. 2015-04-18 21:40:59 +01:00
Damien George
8892f71dd0 stmhal: Exclude code for UARTs that don't exist in hardware. 2015-04-18 21:40:58 +01:00
Damien George
73f1a49137 stmhal: Exclude USB HS code when USB HS mode not enabled. 2015-04-18 21:40:58 +01:00
Damien George
c92c7a69fd stmhal: Exclude code for those timers that don't exist in the hardware. 2015-04-18 21:40:58 +01:00
Damien George
7d6595fd18 stmhal: Make LCD initialiser use board pin names instead of cpu names. 2015-04-18 21:40:58 +01:00
Damien George
50ea86fe8b stmhal: For pins, define macros mapping board names to cpu names. 2015-04-18 21:40:58 +01:00
Damien George
2e5704d101 stmhal: Make a HW config option for LED4 being controlled by PWM. 2015-04-18 21:40:58 +01:00
Damien George
8bdbc20e74 stmhal: Make HSE PLL parameters configurable per board. 2015-04-18 21:40:58 +01:00
Henrik
e3cd154317 stmhal: Add support for sending and receiving CAN RTR messages. 2015-04-18 14:53:00 +01:00
Damien George
2764a8ee8d stmhal: Remove std.h. It's not needed anymore. 2015-04-18 14:28:39 +01:00
Damien George
7d5e34287c stmhal: Allow sending CAN messages with timeout=0.
Thanks to Henrik Sölver for this patch.
2015-04-16 23:52:43 +01:00
blmorris
4c45921349 stmhal: Use new %q format to print qstr's in a few more places.
Saves 68 bytes.
2015-04-16 22:30:00 +01:00
Damien George
7f9d1d6ab9 py: Overhaul and simplify printf/pfenv mechanism.
Previous to this patch the printing mechanism was a bit of a tangled
mess.  This patch attempts to consolidate printing into one interface.

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

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

With this new scheme printing is generally more efficient (less layers
to go through, less arguments to pass), and, given an mp_print_t*
structure, one can call mp_print_str for efficiency instead of
mp_printf("%s", ...).  Code size is also reduced by around 200 bytes on
Thumb2 archs.
2015-04-16 14:30:16 +00:00
Damien George
b1f68685ec stmhal: In USB HID driver, make polling interval configurable.
When setting usb_mode to "HID", hid config object now has
polling-interval (in ms) as the 4th element.  It mmust now be a 5-tuple
of the form:

(subclass, protocol, max_packet_len, polling_interval, report_desc)

The mouse and keyboard defaults have polling interval at 8ms.
2015-04-13 16:59:05 +01:00
Damien George
7a6dbaa89b stmhal: Make LED object print LED(x) for consistency with constructor. 2015-04-11 21:50:53 +01:00
Paul Sokolovsky
3a84c8b58d string0.c: Move from stmhal/ to lib/. 2015-04-05 21:57:55 +03:00
Damien George
7e758b1cf8 stmhal, qemu-arm: Enable sys.maxsize attribute. 2015-04-04 22:04:53 +01:00
Damien George
40fc01f406 stmhal: Enable new str.splitlines() method. 2015-04-04 16:02:23 +01:00
Daniel Campora
7b19e99edd lib: Update FatFs to R0.11.
There are lots of cosmetic changes, but this release brings a  very
important bug fix:
 - Fixed f_unlink() does not remove cluster chain of the file.

With R0.10c if you try to write a file that is too large to fit in the
free space of the drive, the operation fails, you delete the incomplete
file, and it seems to be erased, but the space is not really freed,
because any subsequent write operations fail because the drive is
"still" full. The only way to recover from this is by formatting the
drive. I can confirm that R0.11 fixes the problem.
2015-03-29 22:12:14 +01:00
Damien George
dfad7f471a stmhal: Optimise ADC.read_timed() so that it can sample up to 750kHz. 2015-03-23 22:36:51 +00:00
Damien George
8657342973 stmhal: Correctly clear wake-up flag before entering standby mode. 2015-03-22 21:52:20 +00:00
Damien George
cfe623ae3e stmhal: Expose all PYBv1.0 pins, include SD and USB pins.
To have proper low power mode, need to configure all unused pins in
input mode, so need to have them available.
2015-03-22 17:57:09 +00:00
Damien George
f44ace11fb stmhal: Put flash in deep power-down mode when entering stop mode.
This can get PYBv1.0 stop current down to around 290uA.
2015-03-22 17:55:50 +00:00
Dave Hylands
49d8e5ebaa stmhal: Fix a bug related to unhandled channel interrupts.
This also cleans up spurious interrupts which happen at timer
initilaization time.
2015-03-20 23:40:50 +00:00
stijn
3cc17c69ff py: Allow retrieving a function's __name__.
Disabled by default.  Enabled on unix and stmhal ports.
2015-03-20 23:13:32 +00:00
Damien George
7674da8057 stmhal: Remove some unnecessary declarations, purely for cleanup. 2015-03-20 22:27:34 +00:00
Paul Sokolovsky
0ef01d0a75 py: Implement core of OrderedDict type.
Given that there's already support for "fixed table" maps, which are
essentially ordered maps, the implementation of OrderedDict just extends
"fixed table" maps by adding an "is ordered" flag and add/remove
operations, and reuses 95% of objdict code, just making methods tolerant
to both dict and OrderedDict.

Some things are missing so far, like CPython-compatible repr and comparison.

OrderedDict is Disabled by default; enabled on unix and stmhal ports.
2015-03-20 17:26:10 +00:00
Damien George
49fe6dc89a stmhal: Add config option to use LSE/LSI for RTC.
Most boards (except the pyboard) don't have a 32kHz crystal so they
should use the LSI for the RTC.
2015-03-16 22:54:44 +00:00
Damien George
dac79324b5 stmhal: Add rtc.wakeup method, to set wakeup timer.
This allows to wake from low-power modes at a regular interval.

This method is preliminary, pending testing and API overhaul.
2015-03-15 17:15:55 +00:00
Damien George
42e0c59308 py: Add MICROPY_COMP_{DOUBLE,TRIPLE}_TUPLE_ASSIGN config options.
These allow to fine-tune the compiler to select whether it optimises
tuple assignments of the form a, b = c, d and a, b, c = d, e, f.
Sensible defaults are provided.
2015-03-14 13:11:35 +00:00
Damien George
ac4f6b804f stmhal: Fix adc.read_timed so buffer store respects element size.
Addresses issue #1154.
2015-03-13 22:11:50 +00:00
Dave Hylands
b4c9a25eab stmhal: Add support for quadrature encoder mode to pyb.TimerChannel. 2015-03-09 13:23:14 +00:00
Damien George
48ef64a729 stmhal: Make os.sync use disk_ioctl exclusively; reuse os.sync in pyb. 2015-03-04 20:38:28 +00:00
Damien George
4f94d90d4d stmhal: Include fatfs headers using lib/fatfs prefix.
This helps make files reusable across other ports.
2015-03-04 20:35:41 +00:00
Damien George
565da3f569 stmhal: Enable MICROPY_PY_ARRAY_SLICE_ASSIGN. 2015-03-02 13:45:35 +00:00
Damien George
b753009a38 stmhal: Add I2S2EXT and I2S3EXT constants to stm module. 2015-03-01 12:32:44 +00:00
Damien George
4d77e1a034 py: Use m_{new,renew,del} consistently.
This is so all memory requests go through the same interface.
2015-02-27 09:34:51 +00:00
Damien George
d38939e676 stmhal: Reset state of timer when deinit is called. 2015-02-23 13:18:14 +00:00
Dave Hylands
caf5c40c19 stmhal: Fix problem when passing callback= to timer init function.
In particular, make sure that the globals are all initialized
before enabling the interrupt, and also make sure that the timer
interrupt has been initialied before enabling the NVIC.
2015-02-22 19:58:51 -08:00
Damien George
5cbeacebdb py: Make math special functions configurable and disabled by default.
The implementation of these functions is very large (order 4k) and they
are rarely used, so we don't enable them by default.

They are however enabled in stmhal and unix, since we have the room.
2015-02-22 14:48:18 +00:00
Damien George
9ab94c468c lib/libm: Add implementations of erf, erfc, lgamma, tgamma. 2015-02-22 14:47:11 +00:00
Damien George
77fc276c08 stmhal: For UART, check that baudrate is within 5% of desired value.
Also includes documentation about minimum baudrate.

Addresses issue #1090.
2015-02-22 00:26:49 +00:00
Henrik Sölver
f80f1a7077 stmhal: Add support for CAN rx callbacks. 2015-02-15 03:10:53 +00:00
Damien George
aa730620bb stmhal: Fix setting of VID. 2015-02-13 22:25:55 +00:00
Damien George
baafb290ad stmhal: Add uart.sendbreak() method, to send a break condition. 2015-02-13 19:04:24 +00:00
Damien George
601c814603 minimal: Allow to compile without defining MICROPY_HAL_H. 2015-02-13 15:26:53 +00:00
Damien George
0b32e50365 stmhal: Make pybstdio usable by other ports, and use it.
Now all ports can use pybstdio.c to provide sys.stdin/stdout/stderr, so
long as they implement mp_hal_stdin_* and mp_hal_stdout_* functions.
2015-02-13 15:04:53 +00:00
Damien George
c385a639e6 stmhal: Remove obsolete usbdev file. 2015-02-13 14:03:44 +00:00
Damien George
b157a99a8b stmhal: Coding style cleanup in usbd_cdc_msc_hid.c. 2015-02-13 14:02:51 +00:00
Damien George
55d6218b9a stmhal: Properly define pyb.usb_mode() semantics. 2015-02-13 14:02:51 +00:00
Damien George
65af7ebdc5 stmhal: Put CDC last in config descriptors to match with iface nums.
Apparently the order of interface numbers should be sequential and
increasing in a config descriptor.  So as to retain compatibility with
Windows drivers for the CDC+MSC and CDC+HID modes, we move the CDC
configs to the end of the descriptors, instead of changing the interface
numbers.

See PR #957 for background.
2015-02-13 14:02:51 +00:00
Damien George
39ce2db181 stmhal: Add "CDC" option to pyb.usb_mode, for CDC device only. 2015-02-13 14:02:51 +00:00
Damien George
d39c7aa517 stmhal: Add Python-configurable USB HID mode.
Different HID modes can be configured in Python.  You can either use
predefined mouse or keyboard, or write your own report descriptor.
2015-02-13 14:02:51 +00:00
Damien George
b384bcc5de stmhal: Remove unused usbdev files, and move used ones up a dir.
The unused files are from the ST demos for different USB classes and are
not needed for the stmhal port.
2015-02-13 14:02:51 +00:00
Damien George
418ec8bbba stmhal: Properly deinit timer object.
Addresses issue #1113.
2015-02-13 11:57:29 +00:00
Damien George
91fc4a9ce1 stmhal: Fix ADC multiplier from 4096 to 4095; optimise fp operation. 2015-02-11 00:25:22 +00:00
Damien George
891e444fec stmhal: Add boot.py and main.py to qstr definitions, to save some RAM. 2015-02-10 22:27:47 +00:00
Damien George
5351a48185 stmhal: Change type of received chr from char to int. 2015-02-08 13:41:28 +00:00
Damien George
0bfc7638ba py: Protect mp_parse and mp_compile with nlr push/pop block.
To enable parsing constants more efficiently, mp_parse should be allowed
to raise an exception, and mp_compile can already raise a MemoryError.
So these functions need to be protected by an nlr push/pop block.

This patch adds that feature in all places.  This allows to simplify how
mp_parse and mp_compile are called: they now raise an exception if they
have an error and so explicit checking is not needed anymore.
2015-02-07 18:33:58 +00:00
blmorris
97f14606f5 stmhal/adc.c: Fix calculation of read_core_vref()
There was a stray factor of 2 (VBAT_DIV) that looks like it was copied incorrectly from the read_core_vbat() function.
The factor exists in read_core_vbat() because VBAT is measured through a 2:1 voltage divider.
read_core_vref now returns values around 1.21V (assuming that external reference voltage is 3.3V) which is in line with the datasheet values.
See comment at http://forum.micropython.org/viewtopic.php?f=6&t=533&p=2991#p2991
2015-02-06 13:56:27 -05:00
Damien George
827b0f747b py: Change vstr_null_terminate -> vstr_null_terminated_str, returns str. 2015-01-29 13:57:23 +00:00