Commit Graph

992 Commits

Author SHA1 Message Date
Pavol Rusnak
8f3cf6e6a8 stmhal/usb: Use correct ClassData structure for HID receive. 2016-10-04 15:38:32 +11:00
Philip Potter
eb239b8398 stmhal/usb: Add support to receive USB HID messages from host. 2016-10-04 15:38:01 +11:00
Philip Potter
03de5a13cf stmhal/usbdev: Add OUT endpoint to HID interface. 2016-10-04 15:20:11 +11:00
Dave Hylands
1f433c719b stmhal: Fix linker map for STM32L476 chips.
In particular, this makes the L4 .isr_vector section 16K in size so it's
the same as the F4/F7 MCUs.  The patch also moves the L4 filesystem to
the end of flash, which allows for 512K filesystem on the 1Mb devices
like the STM32L476DISC.
2016-10-04 14:31:19 +11:00
Damien George
bd925b59c3 stmhal/spi: Enable use of fast software SPI. 2016-10-04 13:51:30 +11:00
Damien George
b932b2dd1f extmod/machine_spi: Use delay_half, not baudrate, for internal timing.
The delay_half parameter must be specified by the port to set up the
timing of the software SPI.  This allows the port to adjust the timing
value to better suit its timing characteristics, as well as provide a
more accurate printing of the baudrate.
2016-10-04 13:43:02 +11:00
Damien George
9f1e395c16 stmhal/spi: Use software SPI if no periph id given, even if pins given.
It's simpler to just default to always using software SPI if no specific
peripheral id/name is given.  To use hardware SPI users must specify a
hardware peripheral id as the first parameter to the SPI constructor.
2016-10-04 13:38:11 +11:00
Damien George
5deedd6685 stmhal/mphalport: Fix mp_hal_pin_write to use correct pin_mask. 2016-10-03 18:06:58 +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
077dbf4a86 stmhal/mphalport: Implement mp_hal_pin_{input,output,write}. 2016-10-03 16:44:34 +11:00
Damien George
a22a67661a stmhal/spi: Simplify spi_transfer function to take only one buf len arg. 2016-10-03 12:47:56 +11:00
Damien George
5bb28c7f10 extmod/machine_spi: Simplify SPI xfer function to only take one buf len.
There is no need to take src_len and dest_len arguments.  The case of
reading-only with a single output byte (originally src_len=1, dest_len>1)
is now handled by using the output buffer as the input buffer, and using
memset to fill the output byte into this buffer.  This simplifies the
implementations of the spi_transfer protocol function.
2016-10-03 12:39:31 +11:00
Krzysztof Blazewicz
6aea34ad89 lib/cmsis: move CMSIS headers to lib/
Files in lib/cmsis are generic for all Cortex-M MCU's
files left in stmhal/cmsis are all STM32 specific.
2016-09-30 16:19:03 +10:00
Damien George
53bfcc9e84 stmhal: Remove CMSIS STM32F2xx files, they are unused/unsupported. 2016-09-28 15:09:03 +10:00
Nicholas Graumann
7165fbd8f4 stmhal: Add virtual com port support for STM32L476DISC. 2016-09-27 22:08:55 -05: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
Krzysztof Blazewicz
1f69b16d3f stmhal: Remove STM32CubeF2 HAL files, they are unused/unsupported. 2016-09-22 12:11:01 +10:00
Krzysztof Blazewicz
9310dad15d stmhal: Put common definitions from linker files to common.ld. 2016-09-22 12:03:12 +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
Stefan Agner
b0a46900de stmhal: Use attribute to avoid inlining.
Use MP_NOINLINE macro to avoid inlining of init_flash_fs. This helps
to keep stack usage of main() low.
2016-09-20 20:41:11 -07:00
Damien George
4874bde104 stmhal/boards: For OLIMEX_E407, enable UART1 and fix I2C1 mapping.
UART1 can be used even if the switch is enabled.  The schematics for this
board make I2C1 available on PB8/PB9, even though it can also be mapped
to PB6/PB7.

See #2396 and #2427.
2016-09-19 13:00:15 +10:00
Damien George
0fd3d8d19f stmhal/boards: Add pllvalues.py script to compute PLL values for sysclk.
The algorithm here should mirror that in the machine.freq() function.
2016-09-14 13:00:27 +10:00
Krzysztof Blazewicz
1ba516f475 stmhal/extint: Force 0 to 1 transition on swint().
If a user tries to call `swint()` while interrupt is disabled the flag in
SWIER is set but the interrupt is not triggered and therefore the SWIER bit
is not cleared.  When the interrupt is again enabled the next call to
`swint()` won't trigger the IRQ because a 0 to 1 transition will not occur.
2016-09-09 19:35:21 +10:00
Krzysztof Blazewicz
06a1194300 stmhal/{accel,lcd}: use GPIO_{set,clear}_pin
different HAL versions implement GPIO differently (BSRR vs BSRRH+BSRRL),
this way both drivers are portable between different HAL's
2016-09-09 10:38:08 +02:00
Tom Soulanille
d89de18f40 stmhal/lcd: De-assert chip select after completing SPI transmission.
The LCD interface library fails to deassert the chip select of the LCD
after an SPI transmission.  Consequently using the SPI with other
peripherals disturbs the state of the LCD.  This patch changes
lcd.lcd_out() to deassert CS after each transmission to the LCD.
2016-09-09 14:51:00 +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
b88bf6c76b stmhal/wdt: Implement keyword args to WDT constructor. 2016-09-06 14:19:40 +10:00
Peter Hinch
ef47a67cf4 stmhal/dac: Fix DAC (re-)initialisation by resetting DMA.
Fixes issue #2176.
2016-09-05 15:07:23 +10:00
Damien George
9526e24234 unix,stmhal,esp8266: When find'ing frozen files follow symbolic links.
It's useful to be able to use symbolic links to add files and directories
to the set of scripts to be frozen.
2016-09-05 12:35:05 +10:00
Delio Brignoli
e2ac8bb3f1 py: Add MICROPY_USE_INTERNAL_PRINTF option, defaults to enabled.
This new config option allows to control whether MicroPython uses its own
internal printf or not (if not, an external one should be linked in).
Accompanying this new option is the inclusion of lib/utils/printf.c in the
core list of source files, so that ports no longer need to include it
themselves.
2016-09-05 12:18:53 +10:00
Dave Hylands
fedab995ee stmhal: Set STM32F7DISC CPU Frequency to 216 MHz
This set the CPU frequency to 216 MHz (the max) and
leaves the USB Frequency at 48 MHz.

These settings were copied from one of the HAL examples.
2016-09-04 18:14:41 +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
Damien George
49406b0ac6 stmhal/spi: Support new machine SPI methods in legacy SPI object. 2016-09-01 16:40:35 +10:00
Damien George
9b64d1966b stmhal/spi: Factor out SPI transfer code to a single function. 2016-09-01 16:40:32 +10:00
Damien George
9c04ef2a67 unix,stmhal,esp8266: When find'ing frozen files don't use extra slash.
This extra forward slash for the starting-point directory is unnecessary
and leads to additional slashes on Max OS X which mean that the frozen
files cannot be imported.

Fixes #2374.
2016-08-31 15:12:57 +10:00
Philip Potter
c777b6950e stmhal: Update boot.py files to use VCP instead of CDC. 2016-08-29 15:17:34 +10:00
Krzysztof Blazewicz
fc73c9b4b2 stmhal/modusocket: set self->nic to MP_OBJ_NULL after socket close
This patch makes second and next calls to <socket>.close() a no-op.
It prevents GC from closing the underlying resource after user
already used <socket>.close() explicitly.

fixes #2355
2016-08-26 10:57:32 +02:00
Dave Hylands
a589fa3e0b stmhal: Update pin print to print new constants
This updates the print function for machine.Pin to
print out the new constants from the Hardware API defintion
rather than the legacy definitions.
2016-08-25 16:11:42 +10:00
Matt Brejza
5af6184e72 stmhal: Make ADC channel 16 available on L4 MCUs. 2016-08-25 13:49:51 +10:00
Damien George
d2d9dfcd40 stmhal: Remove obsolete code for special handling of TIM3 irq settings.
TIM3 is no longer special, or at least does not have special IRQ settings.
2016-08-22 12:24:49 +10:00
Dave Hylands
c6983e3ce0 stmhal: Fix timer capture/compare interrupt handling for TIM1 and TIM8.
It turns out that TIM1 and TIM8 have their own Capture/Compare
interrupt vector. For all of the other timers, the capture/compare
interrupt vector is the same as the update vector.

So we need to add handlers for these vectors and enable them
when using capture/compare callbacks.

During testing of this, I also found that passing a channel callback
into the channel constructor would not enable interrupts properly.

I tested using:
```
>>> pyb.Timer(1, freq=4).channel(1, pyb.Timer.OC_TOGGLE, callback=lambda t: print('.', end=''))
```
I tested the above with channels 1, 4, and 8
2016-08-22 12:18:04 +10:00
Damien George
675d1c9c60 ports: Remove typedef of machine_ptr_t, it's no longer needed.
This type was used only for the typedef of mp_obj_t, which is now defined
by the object representation.  So we can now remove this unused typedef,
to simplify the mpconfigport.h file.
2016-08-15 11:02:59 +10:00
Tobias Badertscher
af9889f99a stmhal/adc.c: Get ADC working on STM32L4 MCUs.
Fixing Issue #2243. Main problems were:

- HAL_ADC_GetState(adcHandle) may return other bits set (not only
  HAL_ADC_STATE_EOC_REG) when called - so I AND-ed it out as proposed by
  mattbrejza in Issue #2243.
- ADC Pin has to be configured as GPIO_MODE_ANALOG_ADC_CONTROL not only
  GPIO_MODE_ANALOG.
- Resolved ADC resolution L4 specific (Use L4 define ADC_RESOLUTION_12B).
- Changed setting of Init.EOCSelection toADC_EOC_SINGLE_CONV for L4.
- Added call to ADC_MultiModeTypeDef as this is done on a STM32Cube
  generated project too.
- Clean up: Configuration of ADC is done only in ONE function not the same
  is done in two functions.

Test is done on PA5 pin of STM32L4Discovery-Kit which is connected to the
DOWN button.

Thanks to mattbrejza for discovering the bug.
2016-08-11 13:01:57 +10:00
Damien George
dfb8144037 stmhal/boards: Update STM32L476 pin defs to include ADC channels.
This patch introduces proper ADC Pin definitions in stm32l476_af.csv.
Originally provided by @tobbad.
2016-08-11 13:01:57 +10:00
David Siorpaes
b67eb20ed0 stmhal: Fix I2C mappings for STM32F429DISC board. 2016-08-04 22:51:53 +10:00
Dave Hylands
460bceca39 stmhal: Make SPI NSS pin definition optional.
Some boards (like the GHI Electronics G30 Dev Board) don't use
NSS at all and rather just use GPIO chip selects.
2016-07-30 22:08:20 +03:00
Matt Brejza
afd4909a0f stmhal: fixing malloc when used with external libraries 2016-07-30 21:24:35 +03:00
dpslwk
f3636a7b46 stmhal: Enable SD card on L4 MCUs. 2016-06-29 14:29:01 +01:00
dpslwk
b03df60f32 stmhal: Correct DMA to allow SD card on L4 MCUs. 2016-06-29 14:28:49 +01:00
dpslwk
14b7c3e59c stmhal: Update HALCOMMITS due to change to hal 2016-06-29 14:28:49 +01:00
dpslwk
daa279a3a1 stmhal: Port of f4 hal commit 1d7fb82 to l4 hal 2016-06-29 14:27:55 +01:00
Paul Sokolovsky
07209f8592 all: Rename mp_obj_type_t::stream_p to protocol.
It's now used for more than just stream protocol (e.g. pin protocol), so
don't use false names.
2016-06-18 18:44:57 +03:00
Stefan Hölzl
c8332a5463 stmhal: Add board definition files for Olimex STM32-E407. 2016-06-06 10:21:02 +01:00
Tobias Badertscher
1191ec6a14 stmhal/uart.c: Fix wrong baudrate calculation for stm32l4 series. 2016-06-03 14:24:59 +01:00
Peter Hinch
641300dccb stmhal/dac: DAC deinit() method added. 2016-05-31 13:10:35 +03:00
Paul Sokolovsky
2503b59592 stmhal/moduos: getcwd(): Use mp_obj_new_exception_arg1().
Argument types were converted, but old function call of
mp_obj_new_exception_msg_varg() remained.
2016-05-29 20:04:32 +03:00
Damien George
4b37e775ea extmod/machine_i2c: Redo mp_hal_pin macros to use open_drain and od_low.
mp_hal_pin_config_od is renamed mp_hal_pin_open_drain, and mp_hal_pin_low
is mp_hal_pin_od_low.
2016-05-26 17:06:40 +01:00
Damien George
3e03d1b87e stmhal: Support frozen packages using .mpy files.
See issue #1814.
2016-05-23 13:29:56 +01:00
Damien George
87981fc517 stmhal/sdcard: Allow to do unaligned read-from/write-to SD card.
For example, the following code now works with a file on the SD card:

    f = open('test', 'rb') # test must be 1024 bytes or more in size
    f.seek(511)
    f.read(513)

Also works for writing.

Fixes issue #1863.
2016-05-13 14:45:40 +01:00
Damien George
1e388079f9 stmhal/i2c: Expose I2CHandle3 for use by custom C code.
If custom C code uses the I2C busses then it needs access to these
structures for i2c_init().
2016-05-13 11:23:32 +01:00
Damien George
1dc2862a83 stmhal/led: Allow LEDs to be in PWM mode with TIM1 and channels 1-4.
This allows PYBv3 to use PWM for LED(1) and LED(2).
2016-05-13 11:01:21 +01:00
Damien George
79a38a7a43 stmhal: For network drivers, convert to use MP_Exxx errno symbols. 2016-05-10 23:45:33 +01:00
Damien George
5ab98d5c41 stmhal: Convert to use internal errno symbols; enable uerrno module. 2016-05-10 23:30:39 +01:00
Tobias Badertscher
b924f649cd stmhal: Fix clock configuration for STM32L476-discovery; also add I2C2. 2016-05-10 09:20:30 +01:00
Henrik Sölver
c4587e2426 stmhal/can: Allow to get existing CAN obj if constructed without args.
Initialisation of CAN objects should now behave as other peripheral
objects.

Fixes issue #2001.
2016-05-08 12:47:33 +01:00
Damien George
88153dc56a stmhal/sdcard: Fix initialisation of DMA TX so that writes work.
Addresses issue #2034.
2016-05-06 10:53:25 +01:00
Dave Hylands
cbbeb786d7 stmhal/dma: Fix builds for boards with an F4 or F7 but no DAC. 2016-05-06 09:57:33 +01:00
Damien George
08d3d5d9ab stmhal: For LIMIFROG board, add early-init function to get to DFU mode. 2016-05-05 17:00:30 +01:00
Tobias Badertscher
770f169e63 stmhal: Add board files for LIMIFROG board. 2016-05-05 17:00:16 +01:00
Damien George
05d1664981 stmhal/dma: Make DAC DMA descriptors conditional on having a DAC. 2016-05-05 15:34:01 +01: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
Tobias Badertscher
7441ba7749 stmhal: L4: Make CCM/DTCM RAM start-up conditional on MCU type. 2016-05-05 15:19:33 +01:00
Tobias Badertscher
adaaf439b0 stmhal: L4: Adapt startup code, clock configuration and interrupts. 2016-05-05 15:14:42 +01:00
Tobias Badertscher
e64032d6fd stmhal: L4: Adapt DMA to be able to support STM32L4 MCU series.
The main thing is to change the DMA code in a way that the structure
DMA_Stream_TypeDef (which is similar to DMA_Channel_TypeDef on stm32l4)
is no longer used outside of dma.c, as this structure only exists for the
F4 series.  Therefore I introduced a new structure (dma_descr_t) which
handles all DMA specific stuff for configuration.  Further the periphery
(spi, i2c, sdcard, dac) does not need to know the internals of the dma.
2016-05-05 14:51:20 +01:00
Damien George
70ff7350e7 stmhal, cc3200: Change i2c.scan() method to scan addresses 0x08-0x77.
A standard I2C address is 7 bits but addresses 0b0000xxx and 0b1111xxx
are reserved.  The scan() method is changed to reflect this, along with
the docs.
2016-05-02 11:15:36 +01:00
Damien George
12c61ddddd stmhal/accel: Raise an exception if the accel couldn't be initialised.
On PYBLITEv1.0 there is no accelerometer and in this case the Accel()
constructor should not silently succeed.
2016-04-29 15:43:15 +01:00
Damien George
a63542387d extmod, stmhal: Fix typo of macro that detects if float is enabled. 2016-04-26 12:47:24 +01:00
Colin Hogben
104aa26271 cc3200, stmhal, teensy: Use pyhelp_print_obj function.
Update the help() implementations in the cc3200, stmhal and teensy
ports to use the pyhelp_print_obj function.
2016-04-25 18:54:59 +03:00
Damien George
624738ca64 extmod/machine_i2c: Allow mp_hal_pin_obj_t to be any type, not a ptr. 2016-04-22 09:56:02 +01:00
Tobias Badertscher
495da15611 stmhal: L4: Add support for external interrupts/events.
The L4 MCU supports 40 Events/IRQs lines of the type configurable and
direct.  But this L4 port only supports configurable line types which are
already supported by uPy.  For details see page 330 of RM0351, Rev 1.

The USB_FS_WAKUP event is a direct type and there is no support for it.
2016-04-21 13:11:37 +01:00
Tobias Badertscher
067fb2da14 stmhal: L4: Modify flash.c and storage.c to support L4 MCU.
The way to lookup the flash sector now uses a much simpler table for
all MCUs.
2016-04-21 13:03:38 +01:00
Tobias Badertscher
dda1a41205 stmhal: L4: Modify mphalport to support L4 MCU.
__GPIOI_CLK_ENABLE is defined in hal/l4/inc/Legacy/stm32_hal_legacy.h
as __HAL_RCC_GPIOI_CLK_ENABLE, and that latter macro is not defined
anywhere else (because the L4 does not have port GPIOI).  So the test
for GPIOI is needed, along with the test for the CLK_ENABLE macro.
2016-04-21 12:23:28 +01:00
Paul Sokolovsky
098f3e2862 stmhal: Update Makefile dependencies. 2016-04-19 11:54:07 +03:00
Damien George
5e247a5192 stmhal: Fix machine.unique_id() function to work for all MCUs. 2016-04-17 12:18:50 +01:00
Tobias Badertscher
31f5dc065a stmhal: L4: Modify timer.c to support L4 MCU. 2016-04-17 12:16:13 +01:00
Tobias Badertscher
432465b167 stmhal: L4: Modify rtc.c to support L4 MCU. 2016-04-17 12:08:07 +01:00
Damien George
aed1da913b stmhal: L4: Modify usbd_conf.c to support L4 MCU.
Original patch was authored by Tobias Badertscher / @tobbad, but it was
reworked to split UART edits from USB edits.
2016-04-17 12:02:26 +01:00
Damien George
53521152a8 stmhal: L4: Modify uart.c to support L4 MCU.
L4 does not have UART6, and has similar registers to the F7.

Original patch was authored by Tobias Badertscher / @tobbad, but it was
reworked to split UART edits from USB edits.
2016-04-17 12:01:05 +01:00
Tobias Badertscher
d49a547064 stmhal: L4: Modify adc.c to add support for STM32L4 series. 2016-04-16 23:02:36 +01:00
Tobias Badertscher
69f26c68c9 stmhal: L4: Add line to Makefile for building L4 series. 2016-04-16 22:14:12 +01:00
Tobias Badertscher
0b6e28c999 stmhal: L4: Add board definition files for STM32L476DISC. 2016-04-16 22:11:02 +01:00
Damien George
e943a407f2 stmhal: Update HALCOMMITS due to change to hal. 2016-04-16 22:00:49 +01:00
Tobias Badertscher
d4c3349957 stmhal: L4: Adapt UART HAL to avoid 64-bit integer division.
64-bit integer division brings a dependency on library functions. It is
avoided here by dividing fck and baud by a common divisior.  The error
is the better (1/(2*0x300)) as with 64 bit division (1/(0x300)).
2016-04-16 21:54:19 +01:00
Tobias Badertscher
f4942db044 stmhal: L4: Add basic STM32L4xx HAL files.
These files come from STM32Cube_FW_L4_V1.3.0, with Windows line endings
converted to unix.  Only basic HAL files are added.  In addition the QSPI
support is included to support later external QSPI flash as mass storage.
2016-04-16 21:51:40 +01:00
Tobias Badertscher
2ba6677775 stmhal: L4: Add CMSIS files to support STM32L476. 2016-04-16 21:41:52 +01:00
Damien George
040373e4c4 stmhal: For frozen bytecode generation, add dependency of qstr file. 2016-04-16 13:20:02 +01:00
Jan Čapek
d76c65f599 py: Add rules for automated extraction of qstrs from sources.
- add template rule that converts a specified source file into a qstring file

- add special rule for generating a central header that contains all
  extracted/autogenerated strings - defined by QSTR_DEFS_COLLECTED
  variable. Each platform appends a list of sources that may contain
  qstrings into a new build variable: SRC_QSTR. Any autogenerated
  prerequisities are should be appened to SRC_QSTR_AUTO_DEPS variable.

- remove most qstrings from py/qstrdefs, keep only qstrings that
  contain special characters - these cannot be easily detected in the
  sources without additional annotations

- remove most manual qstrdefs, use qstrdef autogen for: py, cc3200,
  stmhal, teensy, unix, windows, pic16bit:

   - remove all micropython generic qstrdefs except for the special strings that contain special characters (e.g. /,+,<,> etc.)
   - remove all port specific qstrdefs except for special strings
   - append sources for qstr generation in platform makefiles (SRC_QSTR)
2016-04-16 13:18:09 +01:00
Paul Sokolovsky
9b0714b24c py: Declare help, input, open builtins in core.
These are *defined* per-port, but why redeclare them again and again.
2016-04-15 00:07:56 +03:00
Damien George
733db525e2 stmhal: Add Makefile option FROZEN_MPY_DIR to support frozen bytecode. 2016-04-13 16:07:47 +01:00