Commit Graph

30 Commits

Author SHA1 Message Date
Damien George a004554dc1 stmhal/modmachine: Remove TODO comment that is now implemented. 2017-05-16 17:44:14 +10:00
Damien George 37bd3b4f4c stmhal/modmachine: Add machine.UART class, linking to pyb.UART.
pyb.UART has a superset of machine.UART functionality so can be used to
provide compatibility with other ports that also implement machine.UART.
2017-05-16 17:40:22 +10:00
Damien George 0986675451 stmhal: Convert all module and method tables to use MP_ROM macros. 2017-05-06 17:03:40 +10:00
Damien George 6ab5512132 stmhal: Use mp_hal_delay_ms instead of HAL_Delay. 2017-03-02 15:02:57 +11:00
Damien George 05a4859585 stmhal: Implement a proper thread scheduler.
This patch changes the threading implementation from simple round-robin
with busy waits on mutexs, to proper scheduling whereby threads that are
waiting on a mutex are only scheduled when the mutex becomes available.
2017-02-15 13:28:48 +11:00
Damien George e0381424cc stmhal/modmachine: Add machine.Signal type. 2017-01-31 12:36:20 +11:00
Damien George b697c89009 extmod: Merge old fsusermount.h header into vfs.h and vfs_fat.h.
vfs.h is for generic VFS declarations, and vfs_fat.h is for VfsFat
specific things.
2017-01-30 12:26:08 +11:00
Damien George 84c614e729 stmhal: Convert to use VFS sub-system and new ooFatFs component.
This patch makes the following configuration changes:
- MICROPY_FSUSERMOUNT is disabled, removing old mounting infrastructure
- MICROPY_VFS is enabled, giving new VFS sub-system
- MICROPY_VFS_FAT is enabled, giving uos.VfsFat type
- MICROPY_FATFS_OO is enabled, to use new ooFatFs lib, R0.12b

User facing API should be almost unchanged.  Most notable changes are
removal of os.mkfs (use os.VfsFat.mkfs instead) and pyb.mount doesn't
allow unmounting by passing None as the device.
2017-01-27 23:22:15 +11:00
Damien George 57226a2b7f stmhal: Implement machine.soft_reset(). 2016-10-17 13:16:47 +11:00
Damien George 0bb3c7d3b7 stmhal: Enable machine.time_pulse_us() function. 2016-10-06 12:12:20 +11:00
Damien George d4a5ca5056 stmhal/spi: Make machine.SPI class conform to correct API.
Includes both software and hardware SPI implementations.
2016-10-03 17:12:43 +11:00
Damien George 88ca7ff565 stmhal/modmachine: Fix clearing of reset-cause flags.
To reset the flags we should write to the single bit only, not the entire
register (otherwise all other settings in the register are cleared).

Fixes #2457.
2016-09-27 15:49:35 +10:00
Damien George 93c4a6a3f7 all: Remove 'name' member from mp_obj_module_t struct.
One can instead lookup __name__ in the modules dict to get the value.
2016-09-22 00:23:16 +10:00
Damien George f3b5480be7 stmhal,cc3200,esp8266: Consistently use PWRON_RESET constant.
machine.POWER_ON is renamed to machine.PWRON_RESET to match other
reset-cause constants that all end in _RESET.  The cc3200 port keeps a
legacy definition of POWER_ON for backwards compatibility.
2016-09-08 12:50:38 +10:00
Damien George 9103cbe366 stmhal/modmachine: Implement machine.reset_cause() function, and consts. 2016-09-06 14:20:19 +10:00
Damien George 76c366df56 stmhal: Add machine.WDT class.
Usage:

    import machine
    wdt = machine.WDT(0, 5000) # 5 second timeout
    wdt.feed()

Thanks to Moritz for the initial implementation.
2016-09-04 00:12:48 +10:00
Tobias Badertscher 0f846e563c stmhal: L4: Add support for machine.sleep on STM32L4 MCUs.
Also raise an exception for machine.freq and machine.deepsleep on this
MCU, since they are not yet implemented.
2016-05-05 15:28:55 +01:00
Damien George 5e247a5192 stmhal: Fix machine.unique_id() function to work for all MCUs. 2016-04-17 12:18:50 +01:00
Damien George e4f963a351 stmhal: Use new generic I2C object in machine module. 2016-04-12 14:06:54 +01:00
Damien George ea89b80ff4 stmhal: Make TIM3 available for use by the user.
TIM3 is no longer used by USB CDC for triggering outgoing data, so we
can now make it available to the user.

PWM fading on LED(4) is now gone, but will be reinstated in a new way.
2016-01-29 22:31:56 +00:00
Damien George daa1a455c6 stmhal: Remove custom mod_machine_mem_get_{read,write}_addr functions.
They are no longer needed because stm constants can now be 32 bits wide.
2016-01-07 16:34:11 +00:00
Dave Hylands b61336483b stmhal: Add mem8/mem16/mem32 operations to machine module.
This uses the newly factored machine_mem functions.
2015-12-19 01:05:44 +00:00
Paul Sokolovsky 2eb844e0b4 ports: Rename "machine" module to "umachine".
To let unix port implement "machine" functionality on Python level, and
keep consistent naming in other ports (baremetal ports will use magic
module "symlinking" to still load it on "import machine").

Fixes #1701.
2015-12-18 02:39:52 +02:00
Damien George 056abbcf31 stmhal: Fix unused variables when HW_CLK_LAST_FREQ not defined. 2015-11-23 23:52:09 +00:00
T S 86aa16bea6 stmhal: Implement delayed RTC initialization with LSI fallback.
If RTC is already running at boot then it's left alone.  Otherwise, RTC is
started at boot but startup function returns straight away.  RTC startup
is then finished the first time it is used.  Fallback to LSI if LSE fails
to start in a certain time.

Also included:
 MICROPY_HW_CLK_LAST_FREQ
        hold pyb.freq() parameters in RTC backup reg
 MICROPY_HW_RTC_USE_US
        option to present datetime sub-seconds in microseconds
 MICROPY_HW_RTC_USE_CALOUT
        option to enable RTC calibration output

CLK_LAST_FREQ and RTC_USE_CALOUT are enabled for PYBv1.0.
2015-11-23 23:23:07 +00:00
Paul Sokolovsky 16d42368a6 stmhal/modmachine: Initial attempt to add I2C & SPI classes.
In new hardware API, these classes implement master modes of interfaces,
and "mode" parameter is not accepted. Trying to implement new HW API
in terms of older pyb module leaves variuos corner cases:

In new HW API, I2C(1) means "I2C #1 in master mode" (? depends on
interpretation), while in old API, it means "I2C #1, with no settings
changes".

For I2C class, it's easy to make mode optional, because that's last
positional param, but for SPI, there's "baudrate" after it (which
is inconsistent with I2C, which requires "baudrate" to be kwonly-arg).
2015-11-14 16:14:08 +02:00
Damien George 731f359292 all: Add py/mphal.h and use it in all ports.
py/mphal.h contains declarations for generic mp_hal_XXX functions, such
as stdio and delay/ticks, which ports should provide definitions for.  A
port will also provide mphalport.h with further HAL declarations.
2015-10-31 19:14:30 +03:00
Dave Hylands b83d0b35e9 stmhal: Add define for UNIQUE_ID address (differs per MCU) 2015-10-30 12:53:14 +00:00
Damien George 2f96b1982a stmhal: Bring Pin class close to new machine module specification.
Looks like we can use the same Pin class for legacy pyb module and new
machine module.
2015-10-19 22:50:59 +01:00
Dave Hylands 504420c51d stmhal: Early version of machine module for stmhal. 2015-10-19 21:12:42 +01:00