Commit graph

287 commits

Author SHA1 Message Date
Ryan
33c47fe010
Add UART support for Kinetis boards (#18370)
* Add UART support for Kinetis boards

* Default PAL mode for GPIOV1
2022-09-17 02:24:03 +01:00
Joel Challis
4087251da6
Reboot wb32 devices after flashing (#18323) 2022-09-10 01:14:12 +01:00
Danny
fb6e821541
Add Elite-Pi converter (#18236)
Co-authored-by: Joel Challis <git@zvecr.com>
2022-09-08 14:59:27 -04:00
Joy Lee
b5a52b4cff
Prevent USB peripheral fault when restarting USB on WB32 MCUs (#18058)
Co-authored-by: Joy <chang.li@westberrytech.com>
2022-09-01 20:48:02 -07:00
QMK Bot
bc4ab8a433 Merge remote-tracking branch 'origin/master' into develop 2022-09-01 22:39:30 +00:00
Joel Challis
7adef85fa4
Remove non promicro pins from converters (#18239) 2022-09-01 15:38:52 -07:00
Ryan
bb6f028833
Move bootloader.mk to platforms (#18228) 2022-08-31 07:17:24 -07:00
Jeff Epler
9632360caa
Use a macro to compute the size of arrays at compile time (#18044)
* Add ARRAY_SIZE and CEILING utility macros

* Apply a coccinelle patch to use ARRAY_SIZE

* fix up some straggling items

* Fix 'make test:secure'

* Enhance ARRAY_SIZE macro to reject acting on pointers

The previous definition would not produce a diagnostic for
```
int *p;
size_t num_elem = ARRAY_SIZE(p)
```
but the new one will.

* explicitly get definition of ARRAY_SIZE

* Convert to ARRAY_SIZE when const is involved

The following spatch finds additional instances where the array is
const and the division is by the size of the type, not the size of
the first element:
```
@ rule5a using "empty.iso" @
type T;
const T[] E;
@@

- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)

@ rule6a using "empty.iso" @
type T;
const T[] E;
@@

- sizeof(E)/sizeof(T)
+ ARRAY_SIZE(E)
```

* New instances of ARRAY_SIZE added since initial spatch run

* Use `ARRAY_SIZE` in docs (found by grep)

* Manually use ARRAY_SIZE

hs_set is expected to be the same size as uint16_t, though it's made
of two 8-bit integers

* Just like char, sizeof(uint8_t) is guaranteed to be 1

This is at least true on any plausible system where qmk is actually used.

Per my understanding it's universally true, assuming that uint8_t exists:
https://stackoverflow.com/questions/48655310/can-i-assume-that-sizeofuint8-t-1

* Run qmk-format on core C files touched in this branch

Co-authored-by: Stefan Kerkmann <karlk90@pm.me>
2022-08-30 10:20:04 +02:00
Ryan
d18698a8e8
Remove deprecated USBasp and bootloadHID bootloader types (#18195) 2022-08-28 21:20:43 +01:00
Joel Challis
43fd647130
Add eeprom defaults for tinyuf2 bootloader (#18042) 2022-08-25 21:17:41 +10:00
Nick Brassel
1eac095c0c
Use the correct bootloader definition. (#18102) 2022-08-19 05:20:44 +01:00
David Hoelscher
a645301c82
Add Bonsai C4 converter (#17711) 2022-08-18 01:01:54 +01:00
Stefan Kerkmann
f74ed5fc53
Fix GD32VF103 WS2812 PWM driver (#18067)
...by adding the missing STM32 DMA defines.
2022-08-15 18:00:22 +01:00
Joel Challis
463fb72d29
Partially revert some WB32 specific changes (#18038) 2022-08-14 20:48:44 +01:00
Mega Mind
fce99f3875
[Controller] Added board config for custom controller STeMCell (#16287)
Co-authored-by: Mariappan Ramasamy <947300+Mariappan@users.noreply.github.com>
Co-authored-by: Mariappan Ramasamy <maari@basis-ai.com>
Co-authored-by: Sadek Baroudi <sadekbaroudi@gmail.com>
2022-08-14 21:27:26 +10:00
yiancar
dfc92d8f7b
Fix buffer size for WS2812 PWM driver (#17046)
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
Co-authored-by: yiancar <yiancar@gmail.com>
2022-08-13 18:36:34 -07:00
Joy Lee
c02d7ae86f
Added ws2812_pwm support for WB32 MCU. (#17142)
Co-authored-by: Joy <chang.li@westberrytech.com>
2022-08-13 18:21:46 -07:00
Joy Lee
6b1c7d20aa
Added ws2812_spi support for WB32 MCU (#17143)
Co-authored-by: Joy <chang.li@westberrytech.com>
2022-08-13 18:09:57 -07:00
Takeshi ISHII
a83afb3fcd
Improve avr wait_us() (#16879) 2022-08-14 00:04:03 +01:00
Jay Greco
4eeafbebab
Add Bit-C PRO converter (#17827) 2022-08-13 14:48:30 +01:00
Joy Lee
19ce1418ba
Added implementation of WB32 MCU wear_leveling_efl. (#17579) 2022-08-13 02:14:33 +01:00
Sergey Vlasov
9e44362179
Add minimal STM32F103C6 support (#17853)
Unfortunately, the crippled versions of “Bluepill” boards with
STM32F103C6xx chips instead of STM32F103C8xx are now sold all over the
place, sometimes advertised in a confusing way to make the difference
not noticeable until too late.  Add minimal support for these MCUs in
the common “Bluepill with stm32duino” configuration, so that it could be
possible to make something useful from those boards (although fitting
QMK into the available 24 KiB of flash may be rather hard).

(In fact, I'm not sure whether the “STM32” part of the chip name is
actually correct for those boards of uncertain origin, so the onekey
board name is `bluepill_f103c6`; another reason for that name is to
match the existing `blackpill_f401` and `blackpill_f411`.)

The EEPROM emulation support is not included on purpose, because
enabling it without having a working firmware size check would be
irresponsible with such flash size (the chance that someone would build
a firmware where the EEPROM backing store ends up overlapping some
firmware code is really high).  Other than that, enabling the EEPROM
emulation code is mostly trivial (the `wear_leveling` driver with the
`embedded_flash` backing store even works without any custom
configuration, although its code is significantly larger than the
`vendor` driver, which may also be important for such flash size).
2022-08-11 22:37:41 +01:00
Nick Brassel
d9eb152a90
Fix issue with #17904. (#17905) 2022-08-04 22:15:42 +10:00
Nick Brassel
94e8701b3e
Fixup compilation of printf-like functions with uint32_t args. (#17904) 2022-08-04 21:44:56 +10:00
Nick Brassel
543f54a483
[Core] STM32_USB_USE_OTG1 => USB_ENDPOINTS_ARE_REORDERABLE (#17647) 2022-08-04 21:05:16 +10:00
Joel Challis
98d5c77521
Remove legacy AVR ssd1306 driver (#17864) 2022-07-31 22:15:01 +01:00
Stefan Kerkmann
a204523bbb
[Core] RP2040 disable PIO IRQs on serial timeout (#17839) 2022-07-29 20:13:16 +02:00
Stefan Kerkmann
157ea96411
ChibiOS: use correct status codes in i2c_master.c (#17808)
msg_t is MSG_OK in the success case and either MSG_RESET or MSG_TIMEOUT
in case of errors. So actually use them in the comparison.
2022-07-28 02:02:10 +01:00
Stefan Kerkmann
083b42068a
Chibios: Stop I2C peripheral on transaction error (#17798)
From the ChibiOS HAL I2C driver pages:

After a timeout the driver must be stopped and restarted because the bus is in
an uncertain state.

This commit does that stopping explicitly on any error that occurred, not only
timeouts. As all the i2c functions restart the peripheral if necessary it is
safe to do so.

Co-authored-by: Dasky <32983009+daskygit@users.noreply.github.com>

Co-authored-by: Dasky <32983009+daskygit@users.noreply.github.com>
2022-07-26 21:40:14 +02:00
Albert Y
d510e80b89
Add Blok 2040 conversion (#17603) 2022-07-21 00:54:05 +01:00
Albert Y
05f30f0787
Use Pro Micro pinout for SDA/SCL (#17595) 2022-07-20 18:24:34 +01:00
Nick Brassel
dc70ba612a
Post-bootloader EFL/SPI fixes. (#17661)
* Fixup read address for EFL driver.

* Fixup sequencing of SPI.

* Lock during init of EFL backing store.
2022-07-14 00:41:08 +10:00
Nick Brassel
dfff040433
Allow MCU-specific overrides for SPI flags. (#17650) 2022-07-13 14:42:24 +10:00
jack
ffb34fc082
Include stdint.h in avr/i2c_master.h (#17639) 2022-07-12 21:55:19 +02:00
Stefan Kerkmann
45ffe42f1a
[Fix] Make ChibiOS _wait.h independent of quantum.h (#17645) 2022-07-12 21:54:33 +02:00
Stefan Kerkmann
3f5dc47296
[Core] Use polled waiting on ChibiOS platforms that support it (#17607)
* Use polled waiting on platforms that support it

Due to context switching overhead waiting a very short amount of time on
a sleeping thread is often not accurate and in fact not usable for timing
critical usage i.e. in a driver. Thus we use polled waiting for ranges
in the us range on platforms that support it instead. The fallback is
the thread sleeping mechanism.

This includes:

* ARM platforms with CYCCNT register (ARMv7, ARMv8) this is
  incremented at CPU clock frequency
* GD32VF103 RISC-V port with CSR_MCYCLE register this is incremented at
  CPU clock frequency
* RP2040 ARMv6 port which uses the integrated timer peripheral which is
  incremented with a fixed 1MHz frequency

* Use wait_us() instead of chSysPolledDelayX

...as it is powered by busy waiting now.

* Add chibios waiting methods test bench
2022-07-11 15:17:05 +02:00
Stefan Kerkmann
0348071810
Stabilize Half-duplex PIO split comms (#17612) 2022-07-11 04:05:04 -07:00
Albert Y
cca5d35321
Update PM2040 I2C pins (#17578) 2022-07-07 09:33:11 +02:00
Stefan Kerkmann
d9bb189e25
[Core] Update mpaland/printf to eyalroz/printf fork (#16163)
mpaland printf implementation was abandoned in ~2019 and the fork by
eyalroz is now regarded to be the goto replacement of it. So this commit
incoporates the changes needed to use this fork in QMK.

Note that pointer ptrdiff_t is always supported since commit
51c90f93a97fdaef895783ecbe24569be0db7cb8
2022-07-07 09:27:50 +02:00
Joel Challis
744af003be
Add kb2040 and sparkfun rp2040 converters (#17514) 2022-07-06 19:27:15 +01:00
Nick Brassel
29a2bac469
Fixup SPI. (#17534) 2022-07-05 22:41:35 +02:00
Ryan
ac5e6b6a3b
Tentative Teensy 3.5 support (#14420)
* Tentative Teensy 3.5 support

* Set firmware format to .hex for ARM Teensys

* Got to "device descriptor failed" by comparing with Teensy 3.6 code

* Drop down to 96MHz...

* Bump back up to 120MHz
2022-07-03 00:12:45 +10:00
Nick Brassel
5846b40f74
RP2040 emulated EEPROM. (#17519) 2022-07-02 15:18:50 +10:00
Stefan Kerkmann
77d960cce3
Disable clang-format for stage2_bootloaders (#17516) 2022-06-30 20:07:54 +01:00
Stefan Kerkmann
d717396708
[Core] Add Raspberry Pi RP2040 support (#14877)
* Disable RESET keycode because of naming conflicts

* Add Pico SDK as submodule

* Add RP2040 build support to QMK

* Adjust USB endpoint structs for RP2040

* Add RP2040 bootloader and double-tap reset routine

* Add generic and pro micro RP2040 boards

* Add RP2040 onekey keyboard

* Add WS2812 PIO DMA enabled driver and documentation

Supports regular and open-drain output configuration. RP2040 GPIOs are
sadly not 5V tolerant, so this is a bit use-less or needs extra hardware
or you take the risk to fry your hardware.

* Adjust SIO Driver for RP2040

* Adjust I2C Driver for RP2040

* Adjust SPI Driver for RP2040

* Add PIO serial driver and documentation

* Add general RP2040 documentation

* Apply suggestions from code review

Co-authored-by: Nick Brassel <nick@tzarc.org>

Co-authored-by: Nick Brassel <nick@tzarc.org>
2022-06-30 13:19:27 +02:00
Nick Brassel
34e244cecf
Wear-leveling EEPROM drivers: embedded_flash, spi_flash, legacy (#17376) 2022-06-30 07:42:23 +10:00
QMK Bot
e30cd0fa16 Merge remote-tracking branch 'origin/master' into develop 2022-06-25 19:35:17 +00:00
Drashna Jaelre
7fd3d76faa
[Split] Ensure SOFT_SERIAL_PIN is defined if USE_I2C isn't defined (#17466) 2022-06-25 12:34:40 -07:00
Stefan Kerkmann
9aa9155e88
[Core] Mark GD32VF103 as ChibiOS-Contrib (#17444) 2022-06-23 08:37:40 +10:00
Daniel Kao
608404f874
Fix AVR I2C master 1ms timeout (#17174)
* avr i2c_master: Fix 1ms timeout

i2c_start() produces a minimum time_slice of 1ms for use as timeout
value.
The timer granularity is 1ms, it is entirely possible for timer_count
to tick up immediately after the last timer read and falsely trigger
timeout with a '>= 1' comparison.

* avr/drivers/i2c_master: Use timer_elapsed()
2022-06-22 00:00:04 +02:00
Stefan Kerkmann
6a81cb44f2
[Fix] Fix compilation warning for non-split keebs after #17423 (#17439) 2022-06-21 09:31:20 +10:00
Stefan Kerkmann
2703ecc9e9
[BUG] Fix deadlocks on disconnected secondary half (#17423) 2022-06-21 08:24:53 +10:00
Stefan Kerkmann
fe680a8568
[Core] Split ChibiOS usart split driver in protocol and hardware driver part (#16669) 2022-06-18 08:04:17 +10:00
Stefan Kerkmann
6d67e9df4b
[Core] Allow usage of ChibiOS's SIO driver for split keyboards (#15907) 2022-06-17 22:06:44 +02:00
Nick Brassel
1085500e89
Rework paths for eeprom locations. (#17326)
* Rework paths for eeprom locations.

* File relocation.

* Wrong file move.

* Fixup test paths.
2022-06-08 09:42:35 +10:00
Stefan Kerkmann
e89478eb0f
[Core] Update C standard to GNU11, C++ to GNU++14 (#17114) 2022-06-06 08:47:22 +10:00
Thomas Preisner
bbab8eb993
Make bootloader_jump for dualbank STM32 respect STM32_BOOTLOADER_DUAL_BANK_DELAY (#17178) 2022-05-30 23:20:10 -07:00
Andrew Dunai
ecce9900c9
Improve PS/2 mouse performance (#17111) 2022-05-30 23:15:17 -07:00
Dasky
2de70e6f2d
Add uf2-split-* make targets. (#17257) 2022-05-31 08:04:50 +10:00
Joy Lee
1c7e8b9a9d
Added support for Wb32fq95 (#16871) 2022-05-23 15:57:24 +10:00
QMK Bot
ce9a5aaef3 Merge remote-tracking branch 'origin/master' into develop 2022-05-18 19:58:37 +00:00
Takeshi ISHII
80405c6d96
Fix platforms/avr/drivers/ws2812.c (#17043)
* Fix platforms/avr/drivers/ws2812.c

`platforms/avr/drivers/ws2812.c` has been changed to use `DDRx_ADDRESS()` and `PORTx_ADDRESS()` instead of `_SFR_IO8()` in #8646.  To use them, `#include <pin_defs.h>` is required.

 ## Error Log
* create new keyboard
```shell
bash-3.2$ qmk new-keyboard
Ψ Generating a new QMK keyboard directory

Name Your Keyboard Project
For more infomation, see:
https://docs.qmk.fm/#/hardware_keyboard_guidelines?id=naming-your-keyboardproject

Keyboard Name? ws2812_test
..................................
     36. WB32F3G71
Please enter your choice:  [12]
Ψ Created a new keyboard called ws2812_test.
Ψ To start working on things, `cd` into keyboards/ws2812_test,
Ψ or open the directory in your preferred text editor.
Ψ And build with qmk compile -kb ws2812_test -km default.
```
* Enable RGBLIGHT.
```shell
bash-3.2$ echo RGBLIGHT_ENABLE=yes >> ./keyboards/ws2812_test/rules.mk
bash-3.2$ echo '#define RGB_DI_PIN B1' >> ./keyboards/ws2812_test/config.h
bash-3.2$ echo '#define RGBLED_NUM 6' >> ./keyboards/ws2812_test/config.h
```
* Compile
```shell
bash-3.2$ make ws2812_test:default

QMK Firmware 0.16.9
Making ws2812_test with keymap default

avr-gcc (Homebrew AVR GCC 8.4.0_2) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

.....................
Compiling: quantum/process_keycode/process_rgb.c                                                    [OK]
Compiling: platforms/avr/drivers/ws2812.c                                                          platforms/avr/drivers/ws2812.c: In function 'ws2812_setleds':
platforms/avr/drivers/ws2812.c:40:5: error: implicit declaration of function 'DDRx_ADDRESS' [-Werror=implicit-function-declaration]
     DDRx_ADDRESS(RGB_DI_PIN) |= pinmask(RGB_DI_PIN);
     ^~~~~~~~~~~~
In file included from <command-line>:
./keyboards/ws2812_test/config.h:21:20: error: 'B1' undeclared (first use in this function); did you mean 'PB1'?
 #define RGB_DI_PIN B1
                    ^~
platforms/avr/drivers/ws2812.c:40:18: note: in expansion of macro 'RGB_DI_PIN'
     DDRx_ADDRESS(RGB_DI_PIN) |= pinmask(RGB_DI_PIN);
                  ^~~~~~~~~~
./keyboards/ws2812_test/config.h:21:20: note: each undeclared identifier is reported only once for each function it appears in
 #define RGB_DI_PIN B1
                    ^~
platforms/avr/drivers/ws2812.c:40:18: note: in expansion of macro 'RGB_DI_PIN'
     DDRx_ADDRESS(RGB_DI_PIN) |= pinmask(RGB_DI_PIN);
                  ^~~~~~~~~~
platforms/avr/drivers/ws2812.c:42:47: error: implicit declaration of function 'PORTx_ADDRESS' [-Werror=implicit-function-declaration]
     uint8_t masklo = ~(pinmask(RGB_DI_PIN)) & PORTx_ADDRESS(RGB_DI_PIN);
                                               ^~~~~~~~~~~~~
In file included from /usr/local/Cellar/avr-gcc@8/8.4.0_2/avr/include/avr/io.h:99,
                 from /usr/local/Cellar/avr-gcc@8/8.4.0_2/avr/include/avr/interrupt.h:38,
                 from platforms/avr/drivers/ws2812.c:24:
platforms/avr/drivers/ws2812.c: In function 'ws2812_sendarray_mask':
./keyboards/ws2812_test/config.h:21:20: error: 'B1' undeclared (first use in this function); did you mean 'PB1'?
 #define RGB_DI_PIN B1
                    ^~
platforms/avr/drivers/ws2812.c:167:69: note: in expansion of macro 'RGB_DI_PIN'
                      : "r"(curbyte), "I"(_SFR_IO_ADDR(PORTx_ADDRESS(RGB_DI_PIN))), "r"(maskhi), "r"(masklo));
                                                                     ^~~~~~~~~~
cc1: all warnings being treated as errors
 [ERRORS]
 |
 |
 |
make[1]: *** [.build/obj_ws2812_test_default/ws2812.o] Error 1
make: *** [ws2812_test:default] Error 1
Make finished with errors
```

* change include order
2022-05-18 20:58:03 +01:00
Joel Challis
6503987c84
Workaround for recent -Werror=array-bounds AVR issues (#17136) 2022-05-18 11:06:55 +01:00
Drashna Jaelre
787a68948f
[Core] Add Reboot keycode to core (#15990) 2022-05-14 13:35:49 +10:00
Joel Challis
d458d4a596
Move disable_jtag to platforms (#16960) 2022-04-29 01:23:50 +01:00
Stefan Kerkmann
b1681fb6a1
[Core] Allow usage of AVRs minimal printf library (#16266)
Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
2022-04-22 18:13:31 +10:00
Joel Challis
969c68a9ad
Provide better config defaults for bluepill boards (#16909) 2022-04-22 07:03:28 +10:00
QMK Bot
c3a03b6423
[CI] Format code according to conventions (#16888) 2022-04-19 21:28:14 +10:00
Joy Lee
25f849b397
Update wb32-dfu (#16438) 2022-04-19 21:21:12 +10:00
Stefan Kerkmann
7712a286dc
[Core] Use a mutex guard for split shared memory (#16647) 2022-04-19 20:56:16 +10:00
Nick Brassel
f50a623909
Fixup AVR builds. (#16875)
* Fixup AVR builds.

* Update platforms/avr/hardware_id.c

Co-authored-by: Ryan <fauxpark@gmail.com>

Co-authored-by: Joel Challis <git@zvecr.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
2022-04-18 15:39:45 +01:00
Joel Challis
b8245a5507
Expose API for hardware unique ID (#16869) 2022-04-18 20:51:40 +10:00
Joel Challis
a5e810b86c
Add non blackpill F4x1 config files (#16600)
* Add non blackpill F4x1 config files

* Move ld files

* Remove f401 i2c bodges

* more bodge?

* Update to recommended defaults
2022-04-06 01:23:04 +01:00
Joel Challis
1660b2d2e2
Refactor CTPC logic to allow future converters (#16621)
* Refactor CTPC logic to allow future converters

* Update builddefs/converters.mk

Co-authored-by: Stefan Kerkmann <karlk90@pm.me>

Co-authored-by: Stefan Kerkmann <karlk90@pm.me>
2022-04-03 18:22:52 +01:00
dn9uyen
38209c5c86
Add emulated eeprom support for STM32F303xE (#16737)
Added FEE_PAGE_SIZE and FEE_MCU_FLASH_SIZE defines for the STM32F303xE
2022-03-30 20:00:17 +01:00
Stefan Kerkmann
119abc4375
Refactor writePin to work with statements (#16738) 2022-03-27 15:07:25 -07:00
QMK Bot
5342caf172 Merge remote-tracking branch 'origin/master' into develop 2022-03-23 16:40:54 +00:00
Drashna Jaelre
4a3b4104fe
[Bug] Fix unused variable error when using ChibiOS Bitbang serial driver (#16709) 2022-03-23 09:38:51 -07:00
Ryan
9ee2effe8e
HD44780 driver rework (#16370) 2022-03-19 17:57:22 +11:00
Joel Challis
dd32cdf527
Redo workaround for pin_def errors on KINETIS (#16620)
* Redo workaround for pin_def errors on KINETIS

* Redo workaround for pin_def errors on KINETIS
2022-03-11 18:50:59 +00:00
Joel Challis
1833e65370
Workaround for pin_def errors on KINETIS (#16614) 2022-03-11 13:27:29 +00:00
Joel Challis
7e6f1c9e08
Force platform pin defs to be included (#16611)
* Force platform pin defs to be included

* Always grab first header
2022-03-10 23:53:16 +00:00
Stefan Kerkmann
2bface8f89
Add flash target for UF2 bootloaders (#16525) 2022-03-07 08:59:06 -08:00
Nick Brassel
44f1bd9b3a
ChibiOS 21.11.1 update. (#16251)
* ChibiOS 21.11.1 update.

* `uf2-tinyuf2` => `tinyuf2`

* Updated chibios-contrib, fixup preprocessor for tinyuf2 bootloader.

* Fixup keychron L433 boards.

* Makefile cleanup.

* RISC-V build fixes.

* Fixup RISC-V build.
2022-03-07 21:04:22 +11:00
QMK Bot
bcd4f34b26 Merge remote-tracking branch 'origin/master' into develop 2022-03-04 03:57:31 +00:00
Ryan
d412854e37
analog.[ch]: remove unnecessary includes (#16471) 2022-03-04 14:56:59 +11:00
Stefan Kerkmann
156f0561f2
[Core] Squeeze AVR some more with -mrelax and -mcall-prologues (#16269) 2022-02-26 19:05:03 -08:00
Joel Challis
4fd04b2371
Fix compilation of ChibiOS UART driver (#16348)
Cherry picked fix from 15724
2022-02-13 20:44:44 +00:00
QMK Bot
63646e8906
Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
Nick Brassel
d31dd6d2a0
Followup to #16220, more test error output. (#16221) 2022-02-05 12:51:23 +11:00
Joel Challis
135c935990
Initial migration of suspend callbacks (#16067)
* Initial migration of suspend logic

* Add header
2022-02-05 05:10:00 +11:00
Sergey Vlasov
580ef6d88f
ChibiOS timer fixes (#16017)
* chibios/timer: Move the 16-bit timer handling into a separate function

Extract the code which effectively makes a 32-bit tick counter from a
possibly 16-bit ChibiOS system timer into a separate function.  Does
not really change the behavior of the timer API, but makes the actions
done in `timer_clear()` and `timer_read32()` more obvious.

* chibios/timer: Rename some variable to better reflect their role

* chibios/timer: Fix 32-bit tick counter overflow handling

The QMK timer API implementation for ChibiOS used a 32-bit tick counter
(obtained from the ChibiOS system timer) and then converted the value to
milliseconds to produce the timer value for QMK.  However, the frequency
of the ChibiOS timer is above 1000 Hz in most cases (values of 10000 Hz
or even 100000 Hz are typically used), and therefore the 32-bit tick
counter was overflowing and wrapping around much earlier than expected
(after about 5 days for 10000 Hz, or about 12 hours for 100000 Hz).
When this wraparound happened, the QMK timer value was jumping back to
zero, which broke various code dealing with timers (e.g., deferred
executors).

Just making the tick counter 64-bit to avoid the overflow is not a good
solution, because the ChibiOS code which performs the conversion from
ticks to milliseconds may encounter overflows when handling a 64-bit
value.  Adjusting just the value converted to milliseconds to account
for lost 2**32 ticks is also not possible, because 2**32 ticks may not
correspond to an integer number of milliseconds.  Therefore the tick
counter overflow is handled as follows:

  - A reasonably large number of ticks (the highest multiple of the
    ChibiOS timer frequency that fits into uint32_t) is subtracted from
    the tick counter, so that its value is again brought below 2**32.
    The subtracted value is chosen so that it would correspond to an
    integer number of seconds, therefore it could be converted to
    milliseconds without any loss of precision.

  - The equivalent number of milliseconds is then added to the converted
    QMK timer value, so that the QMK timer continues to count
    milliseconds as it was before the tick counter overflow.

* chibios/timer: Add a virtual timer to make 16-bit timer updates more reliable

The code which extends the 16-bit ChibiOS system timer to a 32-bit tick
counter requires that it is called at least once for every overflow of
the system timer (otherwise the tick counter can skip one or more
overflow periods).  Normally this requirement is satisfied just from
various parts of QMK code reading the current timer value; however, in
some rare circumstances the QMK code may be blocked waiting for some
event, and when this situation is combined with having a rather high
timer frequency, this may result in improper timekeeping.

Enhance the timer reliability by adding a ChibiOS virtual timer which
invokes a callback every half of the timer overflow period.  The virtual
timer callback can be invoked even when the normal QMK code is blocked;
the only requirement is that the timer interrupts are enabled, and the
ChibiOS kernel is not locked for an excessive time (but the timer update
will eventually work correctly if the virtual timer handling is not
delayed by more than a half of the timer overflow period).

Keeping a virtual timer always active also works around a ChibiOS bug
that can manifest with a 16-bit system timer and a relatively high timer
frequency: when all active virtual timers have delays longer than the
timer overflow period, the handling of virtual timers stops completely.
In QMK this bug can result in a `wait_ms()` call with a delay larger
than the timer overflow period just hanging indefinitely.  However, when
the timer update code adds a virtual timer with a shorter delay, all
other virtual timers are also handled properly.
2022-02-05 05:08:50 +11:00
Nick Brassel
0be2eaf174
Create a build error if no bootloader is specified. (#16181)
* Create a build error if no bootloader is specified.

* Update builddefs/bootloader.mk

Co-authored-by: Ryan <fauxpark@gmail.com>

Co-authored-by: Ryan <fauxpark@gmail.com>
2022-02-03 19:22:49 +11:00
Nick Brassel
1bdc1c23c7
Fixup builds so that teensy EEPROM knows which MCU it's targeting. (#16168) 2022-02-02 16:21:07 +11:00
Nick Brassel
e22efc037a
Don't make EEPROM size assumptions with dynamic keymaps. (#16054)
* Don't make EEPROM size assumptions with dynamic keymaps.

* Add support for checking against emulated flash, error out if someone attempts to build a board without specifying EEPROM size.

* Reorder defines so that MCU is considered last.

* Refactor EEPROM definitions for simplicity.

* Fix max sizing of kabedon/kabedon980.

* Fix max sizing of mechlovin/olly/jf.

* Fix unit tests.

* Review comments, add messages with values during build failures.
2022-02-02 15:04:37 +11:00
Stefan Kerkmann
be59e8af2b
Deprecate split transactions status field (#16023) 2022-01-26 21:13:27 -08:00
Joel Challis
6a9ec74b32
Remove unused suspend_idle (#16063) 2022-01-26 14:57:28 -08:00
Ryan
c71c0fba90
Fix bootloader_jump for certain CTRL boards (#16026) 2022-01-25 09:28:13 +11:00
Nick Brassel
8f22819d47
Default EEPROM implementation should be transient when not implemented. Removed the equivalent eeprom_teensy fallback. (#16020) 2022-01-24 14:18:05 +00:00
Nick Brassel
77062e9a36
Add L432, L442. (#16016) 2022-01-24 08:49:36 +11:00
Dasky
08a42dc72c
Fix broken bootloader builds in develop. (#15880) 2022-01-15 01:04:58 +00:00
QMK Bot
ceab485e58 Merge remote-tracking branch 'origin/master' into develop 2022-01-09 21:17:55 +00:00
Michael Stapelberg
7c186ebb97
Revert "core: make the full 4096 bytes of EEPROM work on Teensy 3.6 (#12947)" (#15695)
This reverts commit 7f8faa429e.

related to https://github.com/qmk/qmk_firmware/issues/15521
2022-01-10 08:17:15 +11:00
Ryan
5fb93934d0
Fixes for bootloader refactor build failures (#15638) 2022-01-06 06:55:46 +11:00
QMK Bot
be2265d0d1
Format code according to conventions (#15593) 2021-12-27 21:20:52 +11:00
Ryan
6bc870d899
Refactor bootloader_jump() implementations (#15450)
* Refactor `bootloader_jump()` implementations

* Fix tests?

* Rename `atmel-samba` to `md-boot`
2021-12-27 21:10:07 +11:00
Nick Brassel
4d96e53222
More GPIO compilation fixes. (#15592) 2021-12-26 21:36:52 -08:00
Nick Brassel
3a3272a3d6
Defer pin operations to gpio.h (#15589) 2021-12-27 13:27:38 +11:00
Nick Brassel
6e40dfa022
Add open-drain GPIO support. (#15282)
* Add open-drain GPIO support.

* `qmk format-c`

* Wording.

* Remove port GPIO implementations as the only board that uses it has its own internal defs anyway. Will wait for first-class handling of ports in core before reimplementing.
2021-12-27 11:52:10 +11:00
Drashna Jael're
af936c6ae6
Merge remote-tracking branch 'origin/master' into develop 2021-12-08 08:17:55 -08:00
Andrew-Fahmy
755731f0ba
Fix RESET not working for keyboards with Kiibohd bootloader (#15430) 2021-12-07 20:36:39 -08:00
QMK Bot
12b9831eeb Merge remote-tracking branch 'origin/master' into develop 2021-12-05 19:52:49 +00:00
Joy Lee
679f83f9de
Modified config.h default configuration (#15387)
* Modified config.h default configuration

* Modified config.h default configuration
2021-12-06 06:52:08 +11:00
Joel Challis
3bf2403244
Tidy up existing i2c_master implementations (#15376)
* Move chibios defines out of header

* Make some avr defines internal
2021-12-02 14:32:31 +00:00
Joy Lee
193a1350a0
[Core] Added chconf.h for WB32 (#15359) 2021-11-30 09:51:44 -08:00
Nick Brassel
94d7cc3712
WB32F3G71 config migration with removal of unnecessary items. (#15309)
* Config migration with removal of unnecessary items.

* Removed as per suggestion.
2021-11-27 10:35:24 +11:00
Joy Lee
68838bb700
Westberrytech pr (#14422)
* Added support for WB32 MCU

* Modified eeprom_wb32.c

* Remove the eeprom_wb32-related code
2021-11-27 09:28:18 +11:00
Joel Challis
5e9c29da0d
Tidy up adjustable ws2812 timing (#15299) 2021-11-25 19:35:06 +00:00
Jordan Banasik
3d00620711
Add ifndef to WS2812 timing constraints (#14678)
* Add ifndef to WS2812 timing constraints

Due to the way that the PrimeKB Meridian PCB was designed, this change
is needed in order to properly adjust the LEDs.

Testing:
* Compiled primekb/meridian:default successfully
* Compiled random board (walletburner/neuron:default) successfully

* Fix linting errors

Missed some spacing

* More linting fixes

Spacing on the comments... really?

* Rename WS2812 timing parameters for clarity; add comments

* Add docs update for the WS2812 timing macros

* Fix typo on comment

* Add ifndef for WS2812_RES

* Update double backticks and table with parameters

* Move timing adjustments documentation to ws2812_drivers

* Move timings adjustment discussion to bitbang section

* Update T0H and T1H definitions in subtractions

* format

Co-authored-by: Gondolindrim <alvaro.volpato@usp.br>
Co-authored-by: zvecr <git@zvecr.com>
2021-11-25 16:55:46 +00:00
Joel Challis
282e916d86
Remove use of __flash due to LTO issues (#15268) 2021-11-24 18:38:49 +11:00
Stefan Kerkmann
5c2052fd47
[Core] RISC-V toolchain and picolibc fixes (#15109)
* [Core] Fix RISC-V toolchain installation

The risc-v toolchain is only available on distributions based on Debian 11+
so we check for their availability before installing them.

* [Core] Fix heap symbols and syscalls for picolibc

picolibc internally uses __heap_start and __heap_end instead of the
defacto chibios linker script standard __heap_base__ and __heap_end__
therefore we introduce these symbols as an alias. Usually all memory
used within QMK is statically allocated, but some algorithms make usage
of malloc and friends.

Also the timeval struct is not defined by picolibc for syscalls, therefore it
is declared as stub.
2021-11-20 20:04:16 +00:00
Joel Challis
2728603fe6
Move tmk_core/common/<plat> (#13918) 2021-11-19 10:41:02 -08:00
Drashna Jaelre
ca4b54bb30
Fix uart function prototypes (#15162) 2021-11-15 20:15:45 +11:00
Ryan
04b51e381e
Update UART driver API (#14839)
* Add uart_puts() and uart_gets()

* Add some docs

* Rework API

* Formatting

* Update docs/uart_driver.md

Co-authored-by: Sergey Vlasov <sigprof@gmail.com>

* Simplify a uart_write() loop

* Update platforms/avr/drivers/uart.c

Co-authored-by: Joel Challis <git@zvecr.com>

Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
Co-authored-by: Joel Challis <git@zvecr.com>
2021-11-13 18:23:14 +00:00
Nick Brassel
5da04fb45b
Update to ChibiOS 20.3.4, support builds against trunk (#14208)
* Add support for building against ChibiOS svn/trunk.

* Swap to 21.6.x

* Update to latest branch revision as released version is broken.

* Updated configs.

* Conf updates.

* Updated ChibiOS

* Convert STM32L422 to actual L422 ChibiOS platform.

* Downgrade to 20.3.4 as ChibiOS 21.6.x is being aborted.

* Rollback L422-based boards.
2021-11-03 08:26:40 +11:00
Joel Challis
92385e30cd
Manually format develop (#15003) 2021-11-01 19:18:33 +00:00
Joel Challis
19b9e406dc
Align usbasp flashing behaviour (#14928) 2021-10-24 14:18:57 +01:00
Joel Challis
d4be4b67a2
Relocate PS2 code (#14895)
* Relocate ps2 protocol code

* clang

* Move makefile logic
2021-10-20 21:18:49 +01:00
Stefan Kerkmann
e50867d52d
[Core] Add support for RISC-V builds and GD32VF103 MCU (#12508)
* Add support for RISC-V builds and GD32VF103 MCU

* Add toolchain selection in chibios.mk based on the mcu selected in
mcu_selection.mk
* Reorder and added comments to chibios.mk to have a streamlined makefile
* Add GD32VF103 mcu to possible targets for QMK.
* Add STM32 compatibility for GD32VF103 MCU, this is hacky but more efficent
  then rewriting every driver.
* Add GigaDevice DFU bootloader as flash target, please note that
  dfu-util of at least version 0.10 is needed.
* Add analog driver compatibility
* Add apa102 bitbang driver compatibility
* Add ws2812 bitbang driver compatibility
* Add eeprom in flash emulation compatibility
* Allow faster re-builds with ccache

* Add SiPeed Longan Nano to platform files

* Add SiPeed Longan Nano Onekeys

* Make quine compatible with other bootloaders

* Support builds with picolibc

* Add risc-v toolchain to arch and debian/ubuntu scripts
2021-10-18 16:23:20 +11:00
bwisn
7e3ff206b8
Add HT32 support to core (#14388)
* tmk_core: temporary fix to allow HT32 based keyboards to work without patched ChibiOS-contrib (AnnePro2)

* HT32: add spi support

Add persistent led support with eeprom (#9)

* adding HT32 support to chibios SPI master driver

update spi driver, fix bad merging with master

* HT32: fix formatting

HT32: Fix formatting: tmk_core/protocol/chibios/usb_main.c

Co-authored-by: Drashna Jaelre <drashna@live.com>

* HT32: Apply suggestions from fauxpark's code review

Co-authored-by: Ryan <fauxpark@gmail.com>

* HT32: update spi driver

* ht32: apply code review suggestions, remove old workaround

Co-authored-by: tech2077 <tech2077@gmail.com>
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
2021-10-18 16:17:29 +11:00
Joel Challis
40bc5a8192
Enable CLI flashing via mdloader (#14729)
* Enable CLI flashing via mdloader

* remove flag

* Update qmk flash help
2021-10-15 22:07:33 +01:00
Dasky
7b753f227a
Enable eeprom with F401xE ld (#14752) 2021-10-08 22:26:57 +01:00
Joel Challis
951331cd8d
Fix i2c_readReg16 (#14730) 2021-10-07 11:45:59 +11:00
Ryan
bc1f5ef381
i2c_master: Add support for reading/writing to 16-bit registers (#14289) 2021-10-07 10:29:35 +11:00
Drashna Jaelre
ba8f1454f4
Move Audio drivers from quantum to platform drivers folder (#14308)
* Move Audio drivers from quantum to platform drivers folder

* fix path for audio drivers

Co-authored-by: Ryan <fauxpark@gmail.com>

Co-authored-by: Ryan <fauxpark@gmail.com>
2021-10-06 12:01:45 +11:00
Joel Challis
3a2a39e5ec
Initial pass of F405 support (#14584)
* Initial pass of F405 support

* remove some conf files

* docs

* clang
2021-09-25 00:19:41 +01:00
Drashna Jaelre
7c10d00ca6
Add RGBW support to PWM and SPI drivers for ChibiOS (#14327)
* Add RGBW support to PWM and SPI drivers for ChibiOS

* Apply suggestions from code review

Co-authored-by: Ryan <fauxpark@gmail.com>

Co-authored-by: Ryan <fauxpark@gmail.com>
2021-09-18 17:28:57 +10:00
Stefan Kerkmann
efde8d657a
Use opendrain pin with external pullup again (#14474) 2021-09-17 12:12:20 +01:00
Drashna Jaelre
c060ab4e64
Add i2c defaults for Convert to Proton C (#14470)
* Add i2c defaults for Convert to Proton C

* Hide default defines behing CTPC check
2021-09-16 21:40:25 +01:00
Joel Challis
84dba25533
Make ChibiOS PAL interactions less STM32 specific - Round 2 (#14456) 2021-09-16 08:18:58 +10:00
Joel Challis
1a68feb842
Implement F4 eeprom (#14195) 2021-09-15 16:30:26 +01:00
Joel Challis
a78f0e8a0b
Refactor use of _STM32_ defines (#14439) 2021-09-15 11:19:51 +10:00
Joel Challis
0ca4a56a04
Refactor use of STM32_SYSCLK (#14430)
* Refactor use of STM32_SYSCLK

* clang
2021-09-14 12:18:36 +10:00
Joel Challis
0fa217a5b7
Align ChibiOS I2C defs with other drivers (#14399)
* Align ChibiOS I2C defs with other drivers

* Update keyboards/xelus/valor_frl_tkl/config.h

Co-authored-by: Ryan <fauxpark@gmail.com>

Co-authored-by: Ryan <fauxpark@gmail.com>
2021-09-12 15:41:33 +01:00
fauxpark
a7c972b329 Merge remote-tracking branch 'upstream/master' into develop 2021-09-10 17:36:17 +10:00
Ryan
d5cb7de5e4
Change USBasp and bootloadHID bootloaders to lowercase (#14354) 2021-09-10 17:17:54 +10:00
Ryan
d977e5d3e9
Remove Arduino-style analogRead() (#14348) 2021-09-08 14:37:59 +01:00
JX
5ed8edae49
Update ws2812_spi.c (#14237) 2021-08-30 20:34:19 +01:00
Joel Challis
48d0ad28e7
Move to correct location (#14171) 2021-08-26 14:14:48 +01:00
Drashna Jaelre
d57d9aec4f
Fix bootloadHID comments breaking :flash (#14133) 2021-08-23 23:46:06 +01:00