Commit Graph

219 Commits

Author SHA1 Message Date
Kevin O'Connor 6f4822fe96 stm32: Fix typo that broke selection of alternate serial port pin
Fix a typo in commit aea15250.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-02-09 12:01:43 -05:00
Kevin O'Connor 502e83725b stm32: Reset adc calibration prior to starting calibration
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-25 11:23:58 -05:00
Kevin O'Connor bf3fa979f9 stm32: Increase adc sample time
Increase the sample time register from 3 to 4 (which adds about ~1.5us
to each adc sample).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-25 10:50:29 -05:00
Kevin O'Connor aea15250ae stm32: Only declare alternate usart2 on stm32f0
Also, try to improve the structure of the #if/#else/#endif layout in
serial.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-23 11:39:40 -05:00
Kevin O'Connor c8a93cb3bf stm32: Don't export spi1a/spi2a on stm32f1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-23 11:36:28 -05:00
Arne Jansen 0cd4d5d5ea stm32: add alternate pinout for USART2
Added to both generic stm32 and stm32f0

Signed-off-by: Arne Jansen <arne@die-jansens.de>
2020-01-23 11:10:39 -05:00
Arne Jansen 5ce86bd005 stm32: add alternate pinouts for spi1/2
In addition to spi3, spi1 and spi2 also have alternate pins. Add them as
spi1a and spi2a, similar to spi3.

Signed-off-by: Arne Jansen <arne@die-jansens.de>
2020-01-23 11:10:39 -05:00
Arne Jansen a2c309a2b0 stm32: performance improvement for spi on stm32f0
The stm32 has a small queue for spi tx/rx. The current code only uses the
spi with a single byte buffer, effectively waiting for each byte to complete
before starting the next transfer.
This patch changes the structure of spi_transfer() to make use of the queue
and achieve back-to-back transfer of bytes on spi.

Signed-off-by: Arne Jansen <arne@die-jansens.de>
2020-01-23 11:10:39 -05:00
Arne Jansen ce35ee45d6 stm32: fix spi_transfer for stm32f0
The current code accesses the DR as 32 bit. This enabled data packing mode,
effectively adding a 00 byte between each sent byte. The receive side had
similar problems.
To prevent this, all accesses are 8 bit now, even though this is not
necessary on stmf[14].

Signed-off-by: Arne Jansen <arne@die-jansens.de>
2020-01-23 11:10:39 -05:00
Eug Krashtan a34dbc7029 stm32: STM32F0 CAN feature
Signed-off-by: Eug Krashtan <eug.krashtan@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-14 17:05:28 -05:00
Eug Krashtan 5238c3f872 stm32: HSI selection fix; Pin swap rename; Add CAN selection
Signed-off-by: Eug Krashtan <eug.krashtan@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-14 17:05:28 -05:00
Tobias Weiß 58abd2925e config: Fysetc S6 generic configuration (#2220)
Signed-off-by: Tobias Weiß <t.weiss@bk.ru>
2019-12-18 11:13:25 -05:00
Kevin O'Connor ef2c7cb363 stm32: Fix typo in setting of SMPR1 register on stm32f103
Only the stm32f4 has a SMP18 field; it's not present on the stm32f103.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-27 11:26:17 -05:00
Kevin O'Connor fc476f22b6 stm32: Fix typo in adc startup delay
Fix (harmless) typo and add comments on adc timing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-27 11:16:41 -05:00
Kevin O'Connor 8f6efe5a7b stm32: Enable chipid as usb serial number
Signed-off-by: Matt Baker <baker.matt.j@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-25 19:30:31 -05:00
Kevin O'Connor bd6c25c9f8 stm32: Allow external crystal speed to be customized in Kconfig
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-25 14:04:26 -05:00
Kevin O'Connor 9ff4f1bb2f stm32f0: Initial support for i2c on stm32f0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-14 15:54:28 -05:00
clearchris 009d14fc3e stm32: adc for new stm32f0 common code (#2120)
Derived from stm32/adc.c and stm32f0/adc.c with additional changes.

Tested on Monoprice Mini Delta (malyan) stm32f070xb board.

Signed-off-by: Chris Lombardi <clearchris@hotmail.com>
2019-11-05 10:08:32 -05:00
Kevin O'Connor cf6e8a2eee stm32: Define PGx pins on stm32f103
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-02 11:35:27 -04:00
Kevin O'Connor 1a69f38e6e flash_usb: Pass -t $CONFIG_MCU to flash_usb on all targets
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-26 18:48:00 -04:00
Kevin O'Connor 5131ec5eb0 stm32: Add support for flashing over usb on stm32f042
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-26 17:11:04 -04:00
Kevin O'Connor 2ecc8d8f62 stm32: stm32f4 usb boot check only needed when CONFIG_USBSERIAL
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-26 16:56:33 -04:00
Kevin O'Connor 5da6a62759 stm32f4: Add support for flashing over USB
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-26 13:24:59 -04:00
Kevin O'Connor 9a11286327 stm32: Implement armcm_main() in arch specific code
Move armcm_main() to stm32f0.c, stm32f1.c, and stm32f4.c.  This gives
the arch specific code more control on the early boot setup.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-24 11:35:18 -04:00
Kevin O'Connor faeaa54925 armcm_boot: Use armcm_main() instead of main() to start board code
The main() function has a special meaning to gcc and using it can
result in different code generation.  Use armcm_main() to avoid that.

Also, invoke SystemInit() from the board specific armcm_main() code.
This gives the board code more control over board initialization.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-24 11:16:10 -04:00
Kevin O'Connor 0b0c47c566 stm32: Support PA11/PA12 pin remap on stm32f042 tsop20 chip
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 21:34:48 -04:00
Kevin O'Connor a6d90bb95e stm32: Support stm32f042 build from stm32/ directory
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 21:34:48 -04:00
Kevin O'Connor 2c535106ee stm32: Initial support for stm32f070
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 21:19:03 -04:00
Kevin O'Connor a46244057c stm32: Support 16bit packet memory access on usbfs controller
The stm32f0 line uses 16bit packet memory reads/writes (as opposed to
the goofy 32bit accesses required on the stm32f103).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 21:16:35 -04:00
Kevin O'Connor c2881f7d15 stm32: Be explicit in layout of gpio banks in digital_regs variable
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 21:16:35 -04:00
Kevin O'Connor 40d076cce5 stm32: Use stm32f103xe header for stm32f103 line
Use the "e" revision so that the SPI3 device is available for use.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 15:49:00 -04:00
Kevin O'Connor 1e8582e3f6 stm32: Make sure to turn on the usb clock before writing to the packet memory
The USB clock needs to be enabled prior to writing to the USB packet
memory.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-13 14:33:23 -04:00
Kevin O'Connor 626cb71428 stm32: Only prompt for a bootloader on stm32f103 and stm32f407
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-18 12:11:52 -04:00
Kevin O'Connor 9b70c052cc armcm_boot: Export MCU definition from armcm_boot
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-18 11:59:43 -04:00
Kevin O'Connor 1c6a8267f9 armcm_reset: Add a new helper file defining command_reset()
Add a generic ARM Cortex-M implementation of the "reset" command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-18 11:59:43 -04:00
Kevin O'Connor 80e17b1e53 stm32: Move VTOR fixup from main() to chip specific code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-18 11:59:43 -04:00
Kevin O'Connor 8cb3d09484 stm32: Move usb_request_bootloader() to chip specific code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-18 11:59:43 -04:00
Kevin O'Connor 4f889ecd93 stm32: Fix usbfs rx buffer sizing
The usbfs receive buffers must also have space for the 2 byte crc at
the end of a transmission.  This fixes an error that could lead to
lost messages from mcu to host (resulting in bytes_invalid increasing
in stats) on the stm32f103.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-16 19:33:06 -04:00
Kevin O'Connor 045c938a61 stm32: Use official defines for EPR bits
Use the standard definitions for the endpoint register bits.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-16 18:39:54 -04:00
Kevin O'Connor 86cf361486 stm32: Rename USB_BTABLE to EPM in usbfs.c
Rename the internal definition so it isn't in conflict with the
USB_BTABLE register.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-16 18:39:47 -04:00
Kevin O'Connor 60ae92d143 stm32: Disable usb irqs in usbotg handlers
It appears the usbotg controller can get confused if the usb irq
handler runs while processing a usb request.  Disable usb irqs during
usb processing to avoid this.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-12 08:12:51 -04:00
Kevin O'Connor 4fa41d9c61 stm32: Rework usbotg transmit interrupts
Use the XFRC interrupt instead of TXFE.  Don't mask/unmask the tx
interrupts during runtime.  This fixes some race conditions where a tx
notification may have previously gotten lost.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-08 00:07:16 -04:00
Kevin O'Connor dc9f9ea1d6 stm32: Add support for SPI3 bus on alternate PC11,PC12,PC10 pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-05 22:42:48 -04:00
Kevin O'Connor 7031202e7c stm32: Add support for SPI1 and SPI3 busses
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-31 19:55:30 -04:00
Kevin O'Connor 017a4d8321 stm32: Fix gpio enumerations (each bank has 16 pins, not 32)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-31 18:35:01 -04:00
Kevin O'Connor c380d4639b stm32: Work around stm32f407 usbotg chip errata
It appears bogus entries can get placed on the rxqueue - detect and
clear them.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-31 15:16:46 -04:00
Kevin O'Connor 9335cc4804 stm32: Configure and enable usbotg endpoint0 during setup
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 12:15:45 -04:00
Kevin O'Connor 4a178824aa stm32: Disable and flush usbotg bulk transmit pipe on usb_set_configure()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 12:15:45 -04:00
Kevin O'Connor 7eba063ac8 stm32: Perform usbotg endpoint init during usb_set_configure()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 12:15:45 -04:00
Kevin O'Connor 917fd51057 stm32: Discard usbotg tx data until usb is ready
If the usb interface is not ready, just discard messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 12:15:45 -04:00
Kevin O'Connor 5e3acff8c7 stm32: No need to clear the usbotg address on reset
The controller automatically clears the address.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 12:15:45 -04:00
Kevin O'Connor 7229680227 stm32: Enable usbotg bulk reads during endpoint configuration
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 12:15:32 -04:00
Kevin O'Connor caeb610bb9 armcm_link: Rename armcm_boot.lds.S to armcm_link.lds.S
Rename the linker script so the build does not have any conflicts with
the armcm_boot.d dependency file.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 13:18:24 -04:00
Kevin O'Connor 4ef53ab095 stm32: Update code to use armcm_boot mechanism
Replace the stm32 provided assembler with the src/generic/armcm_boot.c
mechanism.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 09:58:58 -04:00
Kevin O'Connor a44bc950a3 stm32: Move irq handler code above irq setup
Only code movement.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 09:58:58 -04:00
Kevin O'Connor 351910c5ac Makefile: Add generic rule for precompiling linker scripts
Add a general build rule to precompile *.lds.S files to *.ld files.
Remove the custom rules in src/atsamd/Makefile and src/stm32/Makefile.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-21 12:31:12 -04:00
Kevin O'Connor 078d278611 stm32: Initial support for i2c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-20 19:39:58 -04:00
Kevin O'Connor e32be928dc stm32: Add support for configuring open drain output mode
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-20 19:39:49 -04:00
Kevin O'Connor c930fc392b stm32: Make sure to enable the gpio clock prior to setting the first value
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-20 01:10:14 -04:00
Kevin O'Connor 8aca7764c3 stm32: Simplify usbotg packet reading and writing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-16 21:03:47 -04:00
Kevin O'Connor 4ec6db7a87 stm32: Add support for additional ADC3 ports on stm32f4
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-15 23:21:41 -04:00
Kevin O'Connor aac51bdb0a stm32: Initial support for USB On-The-Go (OTG) driver on stm32f4
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-15 22:26:49 -04:00
Kevin O'Connor 841150ff00 stm32: Enable 48Mhz USB clock on stm32f446
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-14 19:33:11 -04:00
Kevin O'Connor a70055a625 stm32: Add support for the 32KiB bootloader on the SKR Pro
Signed-off-by: Gerrit Sturm <gsturm16@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-09 20:37:31 -04:00
Kevin O'Connor 96ff54e143 stm32: Add serial USART serial port option for port PD9/PD8
Signed-off-by: Gerrit Sturm <gsturm16@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-09 20:32:46 -04:00
Kevin O'Connor 8712648370 stm32: Fix memory sizing for STM32F405/7 chips
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-06 23:35:45 -04:00
Kevin O'Connor 3d0f7188df stm32: Automatically disable SWD if PA13/PA14 is used on stm32f103
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-05 11:39:42 -04:00
Kevin O'Connor fe065d72d0 stm32: Rename clock.c to stm32f4.c
Rename the clock.c file to stm32f4.c to make it more clear that the
code is specific to the stm32f4 chips.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-05 11:25:40 -04:00
Kevin O'Connor 8b9cc62359 stm32: Rename stm32f4/ directory to stm32/
Now that the code in stm32f4/ can handle both stm32f1 and stm32f4
chips, rename the directory to just "stm32".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-05 11:25:40 -04:00