Wykres commitów

199 Commity (f54bcbf0997211a3d2a04bab09c79f602fa0c8e9)

Autor SHA1 Wiadomość Data
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