From 31bb05c24f2f092bd5079e28d9a7ecbf999eb7e6 Mon Sep 17 00:00:00 2001 From: James Young <18669334+noroadsleft@users.noreply.github.com> Date: Sat, 30 May 2020 13:22:56 -0700 Subject: [PATCH 01/54] Branch point for 2020 Aug 29 Breaking Change Update readme.md --- readme.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/readme.md b/readme.md index 6092f209be1a..6321681a9249 100644 --- a/readme.md +++ b/readme.md @@ -7,6 +7,12 @@ [![GitHub contributors](https://img.shields.io/github/contributors/qmk/qmk_firmware.svg)](https://github.com/qmk/qmk_firmware/pulse/monthly) [![GitHub forks](https://img.shields.io/github/forks/qmk/qmk_firmware.svg?style=social&label=Fork)](https://github.com/qmk/qmk_firmware/) +# THIS IS THE DEVELOP BRANCH + +Warning- This is the `develop` branch of QMK Firmware. You may encounter broken code here. Please see [Breaking Changes](https://docs.qmk.fm/#/breaking_changes) for more information. + +# Original readme continues + This is a keyboard firmware based on the [tmk\_keyboard firmware](https://github.com/tmk/tmk_keyboard) with some useful features for Atmel AVR and ARM controllers, and more specifically, the [OLKB product line](https://olkb.com), the [ErgoDox EZ](https://ergodox-ez.com) keyboard, and the [Clueboard product line](https://clueboard.co). ## Documentation From 24af018d8727de91043c866b3817c236a6c8bc97 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 5 Jun 2020 20:56:03 +1000 Subject: [PATCH 02/54] Remove iWRAP protocol (#9284) --- doxygen-todo | 1 - tmk_core/protocol/iwrap.mk | 32 --- tmk_core/protocol/iwrap/iWRAP4.txt | 376 ------------------------- tmk_core/protocol/iwrap/iWRAP5.txt | 356 ----------------------- tmk_core/protocol/iwrap/iwrap.c | 420 ---------------------------- tmk_core/protocol/iwrap/iwrap.h | 47 ---- tmk_core/protocol/iwrap/main.c | 412 --------------------------- tmk_core/protocol/iwrap/mux_exit.rb | 7 - tmk_core/protocol/iwrap/suart.S | 156 ----------- tmk_core/protocol/iwrap/suart.h | 8 - tmk_core/protocol/iwrap/wd.h | 161 ----------- tmk_core/readme.md | 5 +- 12 files changed, 2 insertions(+), 1979 deletions(-) delete mode 100644 tmk_core/protocol/iwrap.mk delete mode 100644 tmk_core/protocol/iwrap/iWRAP4.txt delete mode 100644 tmk_core/protocol/iwrap/iWRAP5.txt delete mode 100644 tmk_core/protocol/iwrap/iwrap.c delete mode 100644 tmk_core/protocol/iwrap/iwrap.h delete mode 100644 tmk_core/protocol/iwrap/main.c delete mode 100644 tmk_core/protocol/iwrap/mux_exit.rb delete mode 100644 tmk_core/protocol/iwrap/suart.S delete mode 100644 tmk_core/protocol/iwrap/suart.h delete mode 100644 tmk_core/protocol/iwrap/wd.h diff --git a/doxygen-todo b/doxygen-todo index 39fb498d9782..d8892e48ded7 100644 --- a/doxygen-todo +++ b/doxygen-todo @@ -1,6 +1,5 @@ tmk_core/protocol tmk_core/protocol/chibios -tmk_core/protocol/iwrap tmk_core/protocol/lufa tmk_core/protocol/midi tmk_core/protocol/midi/bytequeue diff --git a/tmk_core/protocol/iwrap.mk b/tmk_core/protocol/iwrap.mk deleted file mode 100644 index 934235bd8107..000000000000 --- a/tmk_core/protocol/iwrap.mk +++ /dev/null @@ -1,32 +0,0 @@ -IWRAP_DIR = protocol/iwrap - -OPT_DEFS += -DPROTOCOL_IWRAP - -SRC += $(IWRAP_DIR)/main.c \ - $(IWRAP_DIR)/iwrap.c \ - $(IWRAP_DIR)/suart.S \ - $(COMMON_DIR)/sendchar_uart.c \ - $(COMMON_DIR)/uart.c - -# Search Path -VPATH += $(TMK_DIR)/protocol/iwrap - - -# TODO: compatible with LUFA and PJRC -# V-USB -# -VUSB_DIR = protocol/vusb - -# Path to the V-USB library -VUSB_PATH = $(LIB_PATH)/vusb - -SRC += $(VUSB_DIR)/vusb.c \ - $(VUSB_PATH)/usbdrv/usbdrv.c \ - $(VUSB_PATH)/usbdrv/usbdrvasm.S \ - $(VUSB_PATH)/usbdrv/oddebug.c - -# Search Path -VPATH += $(TMK_PATH)/$(VUSB_DIR) -VPATH += $(VUSB_PATH) - -OPT_DEFS += -DPROTOCOL_VUSB diff --git a/tmk_core/protocol/iwrap/iWRAP4.txt b/tmk_core/protocol/iwrap/iWRAP4.txt deleted file mode 100644 index 2a062d9d98d2..000000000000 --- a/tmk_core/protocol/iwrap/iWRAP4.txt +++ /dev/null @@ -1,376 +0,0 @@ -Bulegiga WT12 -============= -WT12 is a bluetooth module from Bluegiga. http://www.bluegiga.com/ - -iWRAP - higher layer interface for bluetooth firmware - communicate with UART - -iWRAP HID -default setting - 115200 8bit/n/1/n - - -TODO ----- -KiCAD circuit/PCB design -power saving - AVR sleep(15ms by watch dog timer) - WT12 sleep - measuring current consumption - measuring battery life of normal usage/idle/intensive usage -software reset/bootloarder -LED indicator(chaging/paring/connecting) -license confirmation of suart.c -consumer page is not working -authenticate method/SSP -SPP keyboard support -SPP debug console support -mouse wheel feature request to Bluegiga - - -Problems --------- -power consumption -no consumer page support(bug?) -no mouse wheel support -no paring management -no interactive auth method - - -UART hardware flow control --------------------------- -(iWRAP4 User Guide 9.5) -Hardware flow control is enabled by default and it should not be disabled unless mandatory, because without the hardware flow control the data transmission may not be reliable. -If the hardware flow control is enabled from PS-keys, but no flow control is used, the following steps should be implemented in the hardware design: -- CTS pin must be grounded -- RTS pin must be left floating - - -Power Saving ------------- -power consume - without opimization: 4hr to shutdown(310mAh) - 2011/08/25: 9hr(310mAh) SNIFF MASTER sleep/WDTO_120MS - -measure current consumption - HHKB keyswitch matrix board - idle - scanning - Bluegiga WT12 module - SLEEP command - deep sleep on/off in config bits - -HHKB keyswich - how to power off - I/O pin configuration when sleeping - FET switch for 5V regulator - -Bluetooth module - power off when in USB mode - power off by FET switch - -AVR configuration - unused pins - ADC - - - -SET CONTROL CONFIG ------------------- - SET CONTROL CONFIG 4810 - SET CONTROL CONFIG LIST - SET CONTROL CONFIG 0000 0000 4910 DEEP_SLEEP KLUDGE INTERACTIVE_PIN UART_LATENCY - - Bit14 UART low latency - Bit11 Interactive pairing mode - Bit04 Deep sleep - - -Reconnection ------------- -SET CONTROL AUTOCALL 1124 5000 HID - 1124 HID service class - 5000 interval ms - -HID profile ------------ -This is needed to configure only once. - SET PROFILE HID ON - RESET - -HID class ---------- - SET BT CLASS 005C0 // keyboard/mouse combined devie - -Pairing Security ----------------- -Secure Simple Pairing(SSP) - SET BT SSP 2 0 // Enables SSP for keyboard and Man-in-the-middle protection - SET BT SSP 3 0 // Enables SSP just works mode - -for keyboard with SSP - SET BT AUTH * 0000 - SET BT SSP 2 0 - SET CONTROL CONFIG 800 - RESET - -for keyboard without SSP - SET BT AUTH * 0000 - SET CONTROL CONFIG 800 - RESET - -AUTH - AUTH xx:xx:xx:xx:xx:xx? // Pairing request event - AUTH xx:xx:xx:xx:xx:xx 0000 - - SSP PASSKEY 78:dd:08:b7:e4:a2 ? - SSP PASSKEY 78:dd:08:b7:e4:a2 xxxxx - (SSP COMPLETE 78:dd:08:b7:e4:a2 HCI_ERROR_AUTH_FAIL // failed) - RING 0 78:dd:08:b7:e4:a2 11 HID - -Connecton - RING xx:xx:xx:xx:xx:xx xx HID // connection event - - KILL xx:xx:xx:xx:xx:xx - -Mode ----- -Command mode -Data mode - Raw mode - (Simple mode not for a real keyboard) - -Raw mode - Keyboard: - 0x9f, length(10), 0xa1, 0x01, mods, 0x00, key1, key2, key3, key4, key5, key6 - - Mouse: - 0x9f, length(5), 0xa1, 0x02, buttons, X, Y - - Consumer page: - 0x9f, length(5), 0xa1, 0x03, bitfield1, bitfield2, bitfield3 - - consumer page suage - Bitfield 1: - 0x01 Volume Increment - 0x02 Volume Decrement - 0x04 Mute - 0x08 Play/Pause - 0x10 Scan Next Track - 0x20 Scan Previous Track - 0x40 Stop - 0x80 Eject - Bitfield 2: - 0x01 Email Reader - 0x02 Application Control Search - 0x04 AC Bookmarks - 0x08 AC Home - 0x10 AC Back - 0x20 AC Forward - 0x40 AC Stop - 0x80 AC Refresh - Bitfield 3: - 0x01 Application Launch Generic Consumer Control - 0x02 AL Internet Browser - 0x04 AL Calculator - 0x08 AL Terminal Lock / Screensaver - 0x10 AL Local Machine Browser - 0x20 AC Minimize - 0x40 Record - 0x80 Rewind - - - - - -2011/07/13 -set -SET BT BDADDR 00:07:80:47:22:14 -SET BT NAME HHKB pro BT -SET BT CLASS 0005c0 -SET BT AUTH * 0000 -SET BT IDENT BT:47 f000 4.1.0 Bluegiga iWRAP -SET BT LAP 9e8b33 -SET BT PAGEMODE 4 2000 1 -SET BT PAIR 78:dd:08:b7:e4:a2 a191189cd7e51030ad6a07848ce879bb -SET BT POWER 3 3 3 -SET BT ROLE 0 f 7d00 -SET BT SNIFF 0 20 1 8 -SET BT SSP 2 1 -SET BT MTU 667 -SET CONTROL AUTOCALL 1124 3000 HID -SET CONTROL BAUD 38400,8n1 -SET CONTROL CD 00 0 -SET CONTROL ECHO 7 -SET CONTROL ESCAPE 43 00 1 -SET CONTROL GAIN 0 5 -SET CONTROL INIT SET CONTROL MUX 0 -SET CONTROL MSC DTE 00 00 00 00 00 00 -SET CONTROL MUX 1 -SET CONTROL PIO 00 00 -SET CONTROL READY 00 -SET PROFILE HID f HID -SET - -info config - -!!! THIS IS BETA RELEASE AND MAY BE USED FOR EVALUATION PURPOSES ONLY !!! - -WRAP THOR AI (4.1.0 build 435) -Copyright (c) 2003-2011 Bluegiga Technologies Inc. -Compiled on Jun 28 2011 17:19:51, running on WT12-A module, psr v31 - AVRCP BGIO FTP HFP HFP_AG HID HID_CONSUMER_PAGE HSP LEDS MAP OTA PBAP PIO=0x00fc SSP SUBRATE TEST VOLUME - - BOCK3 version 435 (Jun 28 2011 17:19:37) (max acl/sco 7/1) - - Bluetooth version 2.1, Power class 2 - - Loader 4279, firmware 6297 (56-bit encryption), native execution mode - - up 0 days, 06:23, 2 connections (pool 2) - - User configuration: -&028a = 0001 0000 0000 0011 0024 0000 0000 0010 0000 0080 0000 0000 0080 005f 009b 0034 00fb 0006 -&028b = 0000 0bb8 -&028d = 0001 -&0295 = 0000 0005 000b 0000 0003 0000 0000 0000 0000 0000 0000 -&0298 = a006 -&0299 = 0000 0000 -&02a3 = 0030 0030 0030 0030 -&02a4 = 009d 0000 -&02a5 = 0053 0045 0054 0020 0043 004f 004e 0054 0052 004f 004c 0020 004d 0055 0058 0020 0030 -&02a7 = 0000 05c0 -&02a8 = 4910 0000 0000 -&02aa = 0004 2000 0001 0033 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 -&02ac = 0000 0000 002b 0000 0000 0000 0000 0000 0000 0000 0002 0000 0000 0000 0010 0000 0000 0000 0000 029b 0000 0000 0000 0000 -&02ad = 4848 424b 7020 6f72 4220 0054 -&02b3 = 0005 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 -&02b7 = 000f 4948 0044 -&02bb = 8000 -READY. - - - - -2011/07/07 settings: -set -SET BT BDADDR 00:07:80:47:22:14 -SET BT NAME HHKB Pro BT -SET BT CLASS 0005c0 -SET BT AUTH * 000 -SET BT IDENT BT:47 f000 4.0.0 Bluegiga iWRAP -SET BT LAP 9e8b33 -SET BT PAGEMODE 4 2000 1 -SET BT PAIR 78:dd:08:b7:e4:a2 9e54d0aabb1b4d73cfccddb1ea4ef2d6 -SET BT POWER 3 3 3 -SET BT ROLE 0 f 7d00 -SET BT SNIFF 0 20 1 8 -SET BT SSP 3 0 -SET BT MTU 667 -SET CONTROL BAUD 38400,8n1 -SET CONTROL CD 00 0 -SET CONTROL ECHO 7 -SET CONTROL ESCAPE 255 00 1 -SET CONTROL GAIN 0 5 -SET CONTROL INIT set control mux 0 -SET CONTROL MSC DTE 00 00 00 00 00 00 -SET CONTROL PREAMP 1 1 -SET CONTROL READY 00 -SET PROFILE HID HID -SET PROFILE SPP Bluetooth Serial Port -SET - -info config -WRAP THOR AI (4.0.0 build 317) -Copyright (c) 2003-2010 Bluegiga Technologies Inc. -Compiled on Apr 20 2010 16:44:28, running on WT12-A module, psr v31 - AVRCP FTP PBAP PIO=0x00fc SSP SUBRATE VOLUME - - BOCK3 version 317 (Apr 20 2010 16:44:21) (max acl/sco 7/1) - - Bluetooth version 2.1, Power class 2 - - Loader 4279, firmware 6297 (56-bit encryption), native execution mode - - up 0 days, 00:00, 0 connections (pool 1) - - User configuration: -&028c = 0001 0020 0000 0001 0008 0000 -&028d = 0000 -&0296 = 0047 0001 f000 0400 6c42 6575 6967 6167 6920 5257 5041 -&0298 = c006 -&02a3 = 0030 0030 0030 -&02a4 = 009d 0000 -&02a5 = 0073 0065 0074 0020 0063 006f 006e 0074 0072 006f 006c 0020 006d 0075 0078 0020 0030 -&02a7 = 0000 05c0 -&02a8 = 0800 0000 0000 -&02ac = 0000 0000 00ff 0000 0000 0000 0000 0000 0000 0000 0002 0000 0000 0000 0010 0000 0000 0000 0000 029b 0000 0000 0000 0000 -&02ad = 4848 424b 5020 6f72 4220 0054 -&02b3 = 0004 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 -&02b7 = 0000 -&02bb = 6c42 6575 6f74 746f 2068 6553 6972 6c61 5020 726f 0074 -READY. - - - -2011/08/23: -SET BT BDADDR 00:07:80:47:22:14 -SET BT NAME HHKB pro BT -SET BT CLASS 0005c0 -SET BT AUTH * 0000 -SET BT IDENT BT:47 f000 4.1.0 Bluegiga iWRAP -SET BT LAP 9e8b33 -SET BT PAGEMODE 4 2000 1 -SET BT PAIRCOUNT 4 -SET BT POWER 3 3 3 -SET BT ROLE 1 f 12c0 -SET BT SNIFF 10 2 1 8 -SET BT SSP 3 0 -SET BT MTU 667 -SET CONTROL BAUD 38400,8n1 -SET CONTROL CD 00 0 -SET CONTROL ECHO 7 -SET CONTROL ESCAPE 43 00 1 -SET CONTROL GAIN 0 5 -SET CONTROL INIT SET CONTROL MUX 0 -SET CONTROL MSC DTE 00 00 00 00 00 00 -SET CONTROL MUX 1 -SET CONTROL PIO 00 00 -SET CONTROL READY 00 -SET PROFILE HID 7 HIDKeyboardMouse -SET - -SET CONTROL CONFIG 0000 0004 481e CLOCK_CACHE INTERLACED_INQ INTERLACED_PAGE DEEP_SLEEP INTERACTIVE_PIN UART_LATENCY 23D_NOKLUDGE - - - -2011/08/25: -SET BT BDADDR 00:07:80:47:22:14 -SET BT NAME HHKB pro BT -SET BT CLASS 0005c0 - -SET BT IDENT BT:47 f000 4.1.0 Bluegiga iWRAP -SET BT LAP 9e8b33 -SET BT PAGEMODE 4 2000 1 -SET BT PAIRCOUNT 4 -SET BT PAIR 78:dd:08:b7:e4:a2 0be83335a03fed8ededae42e99554e28 -SET BT POWER 3 3 3 -SET BT ROLE 1 f 12c0 -SET BT SNIFF 100 20 1 8 -SET BT SSP 3 0 -SET BT MTU 667 -SET CONTROL BAUD 38400,8n1 -SET CONTROL CD 00 0 -SET CONTROL ECHO 7 -SET CONTROL ESCAPE - 20 1 -SET CONTROL GAIN 0 5 -SET CONTROL INIT SET CONTROL MUX 0 -SET CONTROL MSC DTE 00 00 00 00 00 00 -SET CONTROL MUX 1 -SET CONTROL PIO 00 00 -SET CONTROL READY 00 -SET PROFILE HID f HIDKeyboardMouse -SET - - -SET CONTROL CONFIG 0000 0000 490e CLOCK_CACHE INTERLACED_INQ INTERLACED_PAGE KLUDGE INTERACTIVE_PIN UART_LATENCY - - -2011/09/08: -SET CONTROL CONFIG 0000 0000 410e CLOCK_CACHE INTERLACED_INQ INTERLACED_PAGE KLUDGE UART_LATENCY - - Removed INTERACTIVE_PIN to avoid interactive auth and use SET BT AUTH pin(0000). - - -EOF diff --git a/tmk_core/protocol/iwrap/iWRAP5.txt b/tmk_core/protocol/iwrap/iWRAP5.txt deleted file mode 100644 index ce3310f1bf93..000000000000 --- a/tmk_core/protocol/iwrap/iWRAP5.txt +++ /dev/null @@ -1,356 +0,0 @@ -Terminology -=========== -PSM -HIDP HID Protocol -L2CAP Logical Link Control Adaptation Protocol -MTU Maximum Transmission Unit - - - -HID Protocol -============ -3 of HID_SPEC_V11.pdf - -Channel -------- -Control channel PSM=0x0011 -Interrupt channel PSM=0x0013 - -Message -------- -HANDSHAKE(0) -HID_CONTROL(1) - -GET_REPORT(4) - Host requests report(DATA payload on Control channel) from Device - Size Desc - ------------------------------------------------------------------------------ - HIDP-Hdr 1 7..4: HIDP Message TYpe(4: GET_REPORT) - 3: Size(1:2-octed buffer size, 0:size of the report) - 2: 0 - 1..0: Report Type(1:input, 2:output, 3: feature) - ReportID 1 Optional - BufferSize 2 Optional(specified when Size=1) - -SET_REPORT(5) -GET_PROTOCOL(6) -SET_PROTOCOL(7) - -DATA(A) - Input/Output Report: All DATA payloads flow on Interrupt channel. - Other: flows on Control channel. - Size Desc - ------------------------------------------------------------------------------ - HIDP-Hdr 1 7..4 0xA - 3..2 Reserved(0) - 1..0 Report Type(0:Other, 1:Input, 2:Output, 3:Feature) - Payload N Data - - - - -Boot Protocol -============= -3.3.2 -No report descriptor, fixed report descriptors defined. - -Device ReportID Size ---------------------------------- -Reserved 0 -Keyboard 1 9octets -Mouse 2 4octets -Reserved 3-255 - -Report descriptor ------------------ -Report ID is added to USB HID boot protocol descriptor. -Boot Protocol device doesn't need to supply descriptors. and can send extra data on end of boot report this data will be ignored unless host supports report descriptor. - -Report Protocol devices can have specific descriptors. Using Boot protocol descriptor followed by extra data may be useful for compatibility to Boot protocol only supported host. - -NOTE: -Bluegiga HID sample say report ID of mouse is 1 but 2? -Bluegiga HID sample say report ID of consumer page is 2 but 3? -** mouse.desc and consumer.desc were fixed. - size -keyboard.desc 67 0x43 -mouse.desc 60 0x3c -consumer.desc 82 0x52 -combo.desc 209 0xd1 - - - -SDP -=== -attributes(3.3.2) ----------- -HIDDeviceSubclass - which type is supported in Boot Protocol Mode - 7 6 - --- - 0 1 Keyboard - 1 0 Pointing device - 1 1 Combo keyboard/pointing device - -HIDBootDevice - TRUE -HIDReconnectInitiate - TRUE - - -Class of Device/Service -======================= -http://phys.sci.hokudai.ac.jp/LABS/yts/pic/GB002/Bluetooth_assigned_numbers_baseband.pdf - -0x0005C0 Keyboard and Pointing deivce(combo) - - - 23 16 15 8 7 0 - --------------------------------- - Service |Major |Minor |Format - - Format type - 1 0 - --- - 0 0 - - Minor Device Class of Peripheral Major - 7 6 - --- - 0 1 Keyboard - 1 0 Pointing device - 1 1 Combo keyboard/pointing device - - - Major device classes - 12 11 10 9 8 - -------------- - 0 0 0 0 0 Miscellaneous - 0 0 0 0 1 Computer - 0 0 0 1 0 Phone - 0 0 0 1 1 LAN /Network Access point - 0 0 1 0 0 Audio/Video (headset,speaker,stereo, video display, vcr..... - 0 0 1 0 1 *Peripheral (mouse, joystick, keyboards, ..... ) - 0 0 1 1 0 Imaging (printing, scanner, camera, display, ...) - 1 1 1 1 1 Uncategorized, specific device code not specified - X X X X X All other values reserved - - - Major service classes - bit - -------------------------------------- - 13 Limited Discoverable Mode [Ref #1] - 14 (reserved) - 15 (reserved) - 16 Positioning (Location identification) - 17 Networking (LAN, Ad hoc, ...) - 18 Rendering (Printing, Speaker, ...) - 19 Capturing (Scanner, Microphone, ...) - 20 Object Transfer (v-Inbox, v-Folder, ...) - 21 Audio (Speaker, Microphone, Headset service, ...) - 22 Telephony (Cordless telephony, Modem, Headset service, ...) - 23 Information (WEB-server, WAP-server, ...) - - - - -Authentication SSP -------------------- -SET BT SSP 2 0 PASS KEY entering -SET BT SSP 3 0 NO PASS KEY entering -SET BT SSP - : 0:display only 1:display+yes/no button 2:keyboard only 3:none -SET BT SSP 2 1 # 2:keyboard only 1:Man-in-the-middle protection is needed -SET BT SSP 2 0 # 2:keyboard only 0:Man-in-the-middle protection is not needed - - -SET BT SSP 2 1 - bond only if MITM protection is supported by host -SET BT SSP 2 0 - bond even if MITM protection is not supported by host - -On Windows 'Add device' causes SSP PASSKEY event on iWRAP - SSP PASSKEY 78:dd:08:b7:e4:a2 ? - -If device has display(0 or 1) this event occurs. User should be shown this code on the device. - SSP CONFIRM 78:dd:08:b7:e4:a2 517572 - - -SET BT SSP 3 0 - No input/output, No MITM protection. - Without procedure of authentication the divice is bond to host. - - -Connect -======= -CALL 78:dd:08:b7:e4:a2 11 HID - - -Setting -======== -Following settings need to be done before wiring into keyboard. -- UART speed: 38400bps(115200bps didn't work with software serial) -- No SSP procedure(without MITM protection) -- No Power Saving - -# clear pairing record and set default -SET BT PAIR * -SET RESET - -SET CONTROL INIT SET CONTROL MUX 0 -SET CONTROL BAUD 38400,8n1 -SET BT NAME TMK Blootooth WT12 -SET BT CLASS 0005c0 -SET BT AUTH * 0000 -SET BT SSP 3 0 -SET CONTROL CONFIG 4800 -SET PROFILE HID 0f c0 0100 00 en 0409 TMK Bluetooth keyboard(WT12) -SET PROFILE SPP - -# power saving? -SET BT SNIFF 100 20 1 8 - - -# Report Descriptor -# combo keyboard + mouse + consumer -HID SET d2 05010906a1010507850119e029e715002501750195088102950175088101950575010508850119012905910295017503910395067508150025650507190029658100c005010902a1010901a1008502050919012908150025017501950881020501093009311581257f750895028106093895018106050c0a380295018106c0c0050c0901a1018503050c1500250109e909ea09e209cd19b529b87501950881020a8a010a21020a2a021a23022a27027501950881020a83010a96010a92010a9e010a94010a060209b209b4750195088102c0 - - - -SET PROFILE HID ---------------- - SET PROFILE HID 0d c0 100 0 en 0409 HHKB pro Bluetooth keyboard - {function bit} uint8 - {subclass} uint8 - {version} uint16 - {country} uint8 - {BTlang} char[2] - {USBlang} uint16 - {name} string - - -SET BT CLASS ------------- - See Class of Device - composite device: keyboard and mouse - SET BT CLASS 005c0 - - - - - - ----------- -after setting ----------- -set -SET BT BDADDR 00:07:80:47:22:14 -SET BT NAME TMK Blootooth WT12 -SET BT CLASS 0005c0 -SET BT AUTH * 0000 -SET BT IDENT BT:47 f000 5.0.1 Bluegiga iWRAP -SET BT LAP 9e8b33 -SET BT PAGEMODE 4 2000 1 -SET BT PAIR 78:dd:08:b7:e4:a2 9e3d85c91bcae73fef8cc10bec18b42f -SET BT POWER 3 3 3 -SET BT ROLE 0 f 7d00 -SET BT SNIFF 0 20 1 8 -SET BT SSP 3 0 -SET BT MTU 667 -SET CONTROL BAUD 38400,8n1 -SET CONTROL CD 00 0 -SET CONTROL ECHO 7 -SET CONTROL ESCAPE 43 00 1 -SET CONTROL GAIN 0 5 -SET CONTROL INIT SET CONTROL MUX 0 -SET CONTROL MSC DTE 00 00 00 00 00 00 -SET CONTROL MUX 1 -SET CONTROL PIO 00 00 -SET CONTROL READY 00 -SET PROFILE HID 0f c0 0100 00 en 0409 TMK Bluetooth keyboard(WT12) -SET - -set control config list -SET CONTROL CONFIG 0000 0000 0000 4900 KLUDGE INTERACTIVE_PIN UART_LATENCY - - -info config -WRAP THOR AI (5.0.1 build 620) -Copyright (c) 2003-2012 Bluegiga Technologies Inc. -Compiled on Oct 1 2012 10:56:21, running on WT12-A module, psr v31 - BGIO FTP HFP HFP_AG HID HID_CONSUMER_PAGE HSP MAP MDP OTA PBAP PIO=0x00fc SSP SUBRATE TEST VOLUME - - BOCK4 version 620 (Oct 1 2012 10:56:03) (max acl/sco 7/1) - - Bluetooth version 3.0, Power class 2 - - Loader 8615, firmware 8825 (56-bit encryption), native execution mode - - up 0 days, 01:50, 2 connections (pool 2) - - User configuration: -&028d = 0001 -&0295 = 0000 0005 000b 0000 0003 0000 0000 0000 0000 0000 0000 -&0298 = c053 -&0299 = 0000 0000 -&02a3 = 0030 0030 0030 0030 -&02a4 = 009d 0000 -&02a5 = 0053 0045 0054 0020 0043 004f 004e 0054 0052 004f 004c 0020 004d 0055 0058 0020 0030 -&02a7 = 0000 05c0 -&02a8 = 0800 0000 0000 0000 -&02aa = 0004 2000 0001 0033 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 -&02ac = 0000 0000 002b 0000 0000 0000 0000 0000 0000 0000 0002 0000 0000 0000 0010 0000 0000 0000 0000 029b 0000 0000 0000 0000 -&02ad = 4d54 204b 6c42 6f6f 6f74 746f 2068 5457 3231 -&02b0 = fa65 b0aa 934a 077b a600 d1cc fe58 8dd5 -&02b3 = 0004 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0005 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0005 -&02b7 = 000f 00c0 0100 0000 0065 006e 0409 4d54 204b 6c42 6575 6f74 746f &02bb = 8000 -READY. ----------- - - - ------ -After 5.0.1 Firmware update -Firmware: ai-5.0.1-620-25b.bc4.dfu -PSR: wt12-a.ai-5.0.1-620-25b.psrf ------ -info config -WRAP THOR AI (5.0.1 build 620) -Copyright (c) 2003-2012 Bluegiga Technologies Inc. -Compiled on Oct 1 2012 10:56:21, running on WT12-A module, psr v31 - BGIO FTP HFP HFP_AG HID HID_CONSUMER_PAGE HSP MAP MDP OTA PBAP PIO=0x00fc SSP SUBRATE TEST VOLUME - - BOCK4 version 620 (Oct 1 2012 10:56:03) (max acl/sco 7/1) - - Bluetooth version 3.0, Power class 2 - - Loader 8615, firmware 8825 (56-bit encryption), native execution mode - - up 0 days, 00:03, 0 connections (pool 1) - - User configuration: -&0295 = 0000 0005 000b 0000 0003 0000 0000 0000 0000 0000 0000 -&0299 = 0000 0000 -&02aa = 0004 2000 0001 0033 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 -&02ac = 0000 0000 002b 0000 0000 0000 0000 0000 0000 0000 0002 0000 0000 0000 0010 0000 0000 0000 0000 029b 0000 0000 0000 0000 -&02ad = 5457 3231 412d -&02b0 = fa65 b0aa 934a 077b a600 d1cc fe58 8dd5 -READY. - -set -SET BT BDADDR 00:07:80:47:22:14 -SET BT NAME WT12-A -SET BT CLASS 001f00 -SET BT IDENT BT:47 f000 5.0.1 Bluegiga iWRAP -SET BT LAP 9e8b33 -SET BT PAGEMODE 4 2000 1 -SET BT PAIR 78:dd:08:b7:e4:a2 af18f81faa107e6dd068762ef921f48b -SET BT POWER 3 3 3 -SET BT ROLE 0 f 7d00 -SET BT SNIFF 0 20 1 8 -SET BT SSP 3 0 -SET BT MTU 667 -SET CONTROL BAUD 115200,8n1 -SET CONTROL CD 00 0 -SET CONTROL ECHO 7 -SET CONTROL ESCAPE 43 00 1 -SET CONTROL GAIN 0 5 -SET CONTROL MSC DTE 00 00 00 00 00 00 -SET CONTROL PIO 00 00 -SET CONTROL READY 00 -SET PROFILE SPP Bluetooth Serial Port -SET - -set control config list -SET CONTROL CONFIG 0000 0000 0000 0100 KLUDGE ---------- diff --git a/tmk_core/protocol/iwrap/iwrap.c b/tmk_core/protocol/iwrap/iwrap.c deleted file mode 100644 index 4d0ca5756b90..000000000000 --- a/tmk_core/protocol/iwrap/iwrap.c +++ /dev/null @@ -1,420 +0,0 @@ -/* -Copyright 2011 Jun Wako - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -/* host driver for Bulegiga iWRAP */ -/* Bluegiga BT12 - * Connections - * Hardware UART Software UART BlueTooth - * PC=====UART=======AVR=====SUART====iWRAP(BT12)-----------PC - * - * - Hardware UART for Debug Console to communicate iWRAP - * - Software UART for iWRAP control to send keyboard/mouse data - */ - -#include -#include -#include -#include -#include "keycode.h" -#include "suart.h" -#include "uart.h" -#include "report.h" -#include "host_driver.h" -#include "iwrap.h" -#include "print.h" - -/* iWRAP MUX mode utils. 3.10 HID raw mode(iWRAP_HID_Application_Note.pdf) */ -#define MUX_HEADER(LINK, LENGTH) \ - do { \ - xmit(0xbf); /* SOF */ \ - xmit(LINK); /* Link */ \ - xmit(0x00); /* Flags */ \ - xmit(LENGTH); /* Length */ \ - } while (0) -#define MUX_FOOTER(LINK) xmit(LINK ^ 0xff) - -static uint8_t connected = 0; -// static uint8_t channel = 1; - -/* iWRAP buffer */ -#define MUX_BUF_SIZE 64 -static char buf[MUX_BUF_SIZE]; -static uint8_t snd_pos = 0; - -#define MUX_RCV_BUF_SIZE 256 -static char rcv_buf[MUX_RCV_BUF_SIZE]; -static uint8_t rcv_head = 0; -static uint8_t rcv_tail = 0; - -/* receive buffer */ -static void rcv_enq(char c) { - uint8_t next = (rcv_head + 1) % MUX_RCV_BUF_SIZE; - if (next != rcv_tail) { - rcv_buf[rcv_head] = c; - rcv_head = next; - } -} - -static char rcv_deq(void) { - char c = 0; - if (rcv_head != rcv_tail) { - c = rcv_buf[rcv_tail++]; - rcv_tail %= MUX_RCV_BUF_SIZE; - } - return c; -} - -/* -static char rcv_peek(void) -{ - if (rcv_head == rcv_tail) - return 0; - return rcv_buf[rcv_tail]; -} -*/ - -static void rcv_clear(void) { rcv_tail = rcv_head = 0; } - -/* iWRAP response */ -ISR(PCINT1_vect, ISR_BLOCK) // recv() runs away in case of ISR_NOBLOCK -{ - if ((SUART_IN_PIN & (1 << SUART_IN_BIT))) return; - - static volatile uint8_t mux_state = 0xff; - static volatile uint8_t mux_link = 0xff; - uint8_t c = recv(); - switch (mux_state) { - case 0xff: // SOF - if (c == 0xbf) mux_state--; - break; - case 0xfe: // Link - mux_state--; - mux_link = c; - break; - case 0xfd: // Flags - mux_state--; - break; - case 0xfc: // Length - mux_state = c; - break; - case 0x00: - mux_state = 0xff; - mux_link = 0xff; - break; - default: - if (mux_state--) { - uart_putchar(c); - rcv_enq(c); - } - } -} - -/*------------------------------------------------------------------* - * iWRAP communication - *------------------------------------------------------------------*/ -void iwrap_init(void) { - // reset iWRAP if in already MUX mode after AVR software-reset - iwrap_send("RESET"); - iwrap_mux_send("RESET"); - _delay_ms(3000); - iwrap_send("\r\nSET CONTROL MUX 1\r\n"); - _delay_ms(500); - iwrap_check_connection(); -} - -void iwrap_mux_send(const char *s) { - rcv_clear(); - MUX_HEADER(0xff, strlen((char *)s)); - iwrap_send(s); - MUX_FOOTER(0xff); -} - -void iwrap_send(const char *s) { - while (*s) xmit(*s++); -} - -/* send buffer */ -void iwrap_buf_add(uint8_t c) { - // need space for '\0' - if (snd_pos < MUX_BUF_SIZE - 1) buf[snd_pos++] = c; -} - -void iwrap_buf_del(void) { - if (snd_pos) snd_pos--; -} - -void iwrap_buf_send(void) { - buf[snd_pos] = '\0'; - snd_pos = 0; - iwrap_mux_send(buf); -} - -void iwrap_call(void) { - char *p; - - iwrap_mux_send("SET BT PAIR"); - _delay_ms(500); - - p = rcv_buf + rcv_tail; - while (!strncmp(p, "SET BT PAIR", 11)) { - p += 7; - strncpy(p, "CALL", 4); - strncpy(p + 22, " 11 HID\n\0", 9); - print_S(p); - iwrap_mux_send(p); - // TODO: skip to next line - p += 57; - - DEBUG_LED_CONFIG; - DEBUG_LED_ON; - _delay_ms(500); - DEBUG_LED_OFF; - _delay_ms(500); - DEBUG_LED_ON; - _delay_ms(500); - DEBUG_LED_OFF; - _delay_ms(500); - DEBUG_LED_ON; - _delay_ms(500); - DEBUG_LED_OFF; - _delay_ms(500); - DEBUG_LED_ON; - _delay_ms(500); - DEBUG_LED_OFF; - _delay_ms(500); - DEBUG_LED_ON; - _delay_ms(500); - DEBUG_LED_OFF; - _delay_ms(500); - } - iwrap_check_connection(); -} - -void iwrap_kill(void) { - char c; - iwrap_mux_send("LIST"); - _delay_ms(500); - - while ((c = rcv_deq()) && c != '\n') - ; - if (strncmp(rcv_buf + rcv_tail, "LIST ", 5)) { - print("no connection to kill.\n"); - return; - } - // skip 10 'space' chars - for (uint8_t i = 10; i; i--) - while ((c = rcv_deq()) && c != ' ') - ; - - char *p = rcv_buf + rcv_tail - 5; - strncpy(p, "KILL ", 5); - strncpy(p + 22, "\n\0", 2); - print_S(p); - iwrap_mux_send(p); - _delay_ms(500); - - iwrap_check_connection(); -} - -void iwrap_unpair(void) { - iwrap_mux_send("SET BT PAIR"); - _delay_ms(500); - - char *p = rcv_buf + rcv_tail; - if (!strncmp(p, "SET BT PAIR", 11)) { - strncpy(p + 29, "\n\0", 2); - print_S(p); - iwrap_mux_send(p); - } -} - -void iwrap_sleep(void) { iwrap_mux_send("SLEEP"); } - -void iwrap_sniff(void) {} - -void iwrap_subrate(void) {} - -bool iwrap_failed(void) { - if (strncmp(rcv_buf, "SYNTAX ERROR", 12)) - return true; - else - return false; -} - -uint8_t iwrap_connected(void) { return connected; } - -uint8_t iwrap_check_connection(void) { - iwrap_mux_send("LIST"); - _delay_ms(100); - - if (strncmp(rcv_buf, "LIST ", 5) || !strncmp(rcv_buf, "LIST 0", 6)) - connected = 0; - else - connected = 1; - return connected; -} - -/*------------------------------------------------------------------* - * Host driver - *------------------------------------------------------------------*/ -static uint8_t keyboard_leds(void); -static void send_keyboard(report_keyboard_t *report); -static void send_mouse(report_mouse_t *report); -static void send_system(uint16_t data); -static void send_consumer(uint16_t data); - -static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer}; - -host_driver_t *iwrap_driver(void) { return &driver; } - -static uint8_t keyboard_leds(void) { return 0; } - -static void send_keyboard(report_keyboard_t *report) { - if (!iwrap_connected() && !iwrap_check_connection()) return; - MUX_HEADER(0x01, 0x0c); - // HID raw mode header - xmit(0x9f); - xmit(0x0a); // Length - xmit(0xa1); // DATA(Input) - xmit(0x01); // Report ID - xmit(report->mods); - xmit(0x00); // reserved byte(always 0) - xmit(report->keys[0]); - xmit(report->keys[1]); - xmit(report->keys[2]); - xmit(report->keys[3]); - xmit(report->keys[4]); - xmit(report->keys[5]); - MUX_FOOTER(0x01); -} - -static void send_mouse(report_mouse_t *report) { -#if defined(MOUSEKEY_ENABLE) || defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE) - if (!iwrap_connected() && !iwrap_check_connection()) return; - MUX_HEADER(0x01, 0x09); - // HID raw mode header - xmit(0x9f); - xmit(0x07); // Length - xmit(0xa1); // DATA(Input) - xmit(0x02); // Report ID - xmit(report->buttons); - xmit(report->x); - xmit(report->y); - xmit(report->v); - xmit(report->h); - MUX_FOOTER(0x01); -#endif -} - -static void send_system(uint16_t data) { /* not supported */ -} - -static void send_consumer(uint16_t data) { -#ifdef EXTRAKEY_ENABLE - static uint16_t last_data = 0; - uint8_t bits1 = 0; - uint8_t bits2 = 0; - uint8_t bits3 = 0; - - if (!iwrap_connected() && !iwrap_check_connection()) return; - if (data == last_data) return; - last_data = data; - - // 3.10 HID raw mode(iWRAP_HID_Application_Note.pdf) - switch (data) { - case AUDIO_VOL_UP: - bits1 = 0x01; - break; - case AUDIO_VOL_DOWN: - bits1 = 0x02; - break; - case AUDIO_MUTE: - bits1 = 0x04; - break; - case TRANSPORT_PLAY_PAUSE: - bits1 = 0x08; - break; - case TRANSPORT_NEXT_TRACK: - bits1 = 0x10; - break; - case TRANSPORT_PREV_TRACK: - bits1 = 0x20; - break; - case TRANSPORT_STOP: - bits1 = 0x40; - break; - case TRANSPORT_EJECT: - bits1 = 0x80; - break; - case AL_EMAIL: - bits2 = 0x01; - break; - case AC_SEARCH: - bits2 = 0x02; - break; - case AC_BOOKMARKS: - bits2 = 0x04; - break; - case AC_HOME: - bits2 = 0x08; - break; - case AC_BACK: - bits2 = 0x10; - break; - case AC_FORWARD: - bits2 = 0x20; - break; - case AC_STOP: - bits2 = 0x40; - break; - case AC_REFRESH: - bits2 = 0x80; - break; - case AL_CC_CONFIG: - bits3 = 0x01; - break; - case AL_CALCULATOR: - bits3 = 0x04; - break; - case AL_LOCK: - bits3 = 0x08; - break; - case AL_LOCAL_BROWSER: - bits3 = 0x10; - break; - case AC_MINIMIZE: - bits3 = 0x20; - break; - case TRANSPORT_RECORD: - bits3 = 0x40; - break; - case TRANSPORT_REWIND: - bits3 = 0x80; - break; - } - - MUX_HEADER(0x01, 0x07); - xmit(0x9f); - xmit(0x05); // Length - xmit(0xa1); // DATA(Input) - xmit(0x03); // Report ID - xmit(bits1); - xmit(bits2); - xmit(bits3); - MUX_FOOTER(0x01); -#endif -} diff --git a/tmk_core/protocol/iwrap/iwrap.h b/tmk_core/protocol/iwrap/iwrap.h deleted file mode 100644 index 51f2b5670bc8..000000000000 --- a/tmk_core/protocol/iwrap/iwrap.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright 2011 Jun Wako - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef IWRAP_H -#define IWRAP_H - -#include -#include -#include "host_driver.h" - -/* enable iWRAP MUX mode */ -#define MUX_MODE - -host_driver_t *iwrap_driver(void); - -void iwrap_init(void); -void iwrap_send(const char *s); -void iwrap_mux_send(const char *s); -void iwrap_buf_send(void); -void iwrap_buf_add(uint8_t c); -void iwrap_buf_del(void); - -void iwrap_call(void); -void iwrap_kill(void); -void iwrap_unpair(void); -void iwrap_sleep(void); -void iwrap_sniff(void); -void iwrap_subrate(void); -bool iwrap_failed(void); -uint8_t iwrap_connected(void); -uint8_t iwrap_check_connection(void); - -#endif diff --git a/tmk_core/protocol/iwrap/main.c b/tmk_core/protocol/iwrap/main.c deleted file mode 100644 index 4048a9791dc5..000000000000 --- a/tmk_core/protocol/iwrap/main.c +++ /dev/null @@ -1,412 +0,0 @@ -/* -Copyright 2011 Jun Wako - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include -#include -#include -//#include -#include "wd.h" // in order to use watchdog in interrupt mode -#include -#include -#include -#include "keyboard.h" -#include "matrix.h" -#include "host.h" -#include "action.h" -#include "iwrap.h" -#ifdef PROTOCOL_VUSB -# include "vusb.h" -# include -#endif -#include "uart.h" -#include "suart.h" -#include "timer.h" -#include "debug.h" -#include "keycode.h" -#include "command.h" - -static void sleep(uint8_t term); -static bool console(void); -static bool console_command(uint8_t c); -static uint8_t key2asc(uint8_t key); - -/* -static void set_prr(void) -{ - power_adc_disable(); - power_spi_disable(); - power_twi_disable(); -#ifndef TIMER_H - //power_timer0_disable(); // used in timer.c -#endif - power_timer1_disable(); - power_timer2_disable(); -} -*/ - -/* -static void pullup_pins(void) -{ - // DDRs are set to 0(input) by default. -#ifdef PORTA - PORTA = 0xFF; -#endif - PORTB = 0xFF; - PORTC = 0xFF; - PORTD = 0xFF; -#ifdef PORTE - PORTE = 0xFF; -#endif -#ifdef PORTE - PORTF = 0xFF; -#endif -} -*/ - -#ifdef PROTOCOL_VUSB -static void disable_vusb(void) { - // disable interrupt & disconnect to prevent host from enumerating - USB_INTR_ENABLE &= ~(1 << USB_INTR_ENABLE_BIT); - usbDeviceDisconnect(); -} - -static void enable_vusb(void) { - USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT); - usbDeviceConnect(); -} - -static void init_vusb(void) { - uint8_t i = 0; - - usbInit(); - disable_vusb(); - /* fake USB disconnect for > 250 ms */ - while (--i) { - _delay_ms(1); - } - enable_vusb(); -} -#endif - -void change_driver(host_driver_t *driver) { - /* - host_clear_keyboard_report(); - host_swap_keyboard_report(); - host_clear_keyboard_report(); - host_send_keyboard_report(); - */ - clear_keyboard(); - _delay_ms(1000); - host_set_driver(driver); -} - -static bool sleeping = false; -static bool insomniac = false; // TODO: should be false for power saving -static uint16_t last_timer = 0; - -int main(void) { - MCUSR = 0; - clock_prescale_set(clock_div_1); - WD_SET(WD_OFF); - - // power saving: the result is worse than nothing... why? - // pullup_pins(); - // set_prr(); - -#ifdef PROTOCOL_VUSB - disable_vusb(); -#endif - uart_init(115200); - keyboard_init(); - print("\nSend BREAK for UART Console Commands.\n"); - - // TODO: move to iWRAP/suart file - print("suart init\n"); - // suart init - // PC4: Tx Output IDLE(Hi) - PORTC |= (1 << 4); - DDRC |= (1 << 4); - // PC5: Rx Input(pull-up) - PORTC |= (1 << 5); - DDRC &= ~(1 << 5); - // suart receive interrut(PC5/PCINT13) - PCMSK1 = 0b00100000; - PCICR = 0b00000010; - - host_set_driver(iwrap_driver()); - - print("iwrap_init()\n"); - iwrap_init(); - iwrap_call(); - - last_timer = timer_read(); - while (true) { -#ifdef PROTOCOL_VUSB - if (host_get_driver() == vusb_driver()) usbPoll(); -#endif - keyboard_task(); -#ifdef PROTOCOL_VUSB - if (host_get_driver() == vusb_driver()) vusb_transfer_keyboard(); -#endif - // TODO: depricated - if (matrix_is_modified() || console()) { - last_timer = timer_read(); - sleeping = false; - } else if (!sleeping && timer_elapsed(last_timer) > 4000) { - sleeping = true; - iwrap_check_connection(); - } - - // TODO: suspend.h - if (host_get_driver() == iwrap_driver()) { - if (sleeping && !insomniac) { - _delay_ms(1); // wait for UART to send - iwrap_sleep(); - sleep(WDTO_60MS); - } - } - } -} - -static void sleep(uint8_t term) { - WD_SET(WD_IRQ, term); - - cli(); - set_sleep_mode(SLEEP_MODE_PWR_DOWN); - sleep_enable(); - sleep_bod_disable(); - sei(); - sleep_cpu(); - sleep_disable(); - - WD_SET(WD_OFF); -} - -static bool console(void) { - // Send to Bluetoot module WT12 - static bool breaked = false; - if (!uart_available()) - return false; - else { - uint8_t c; - c = uart_getchar(); - uart_putchar(c); - switch (c) { - case 0x00: // BREAK signal - if (!breaked) { - print("break(? for help): "); - breaked = true; - } - break; - case '\r': - uart_putchar('\n'); - iwrap_buf_send(); - break; - case '\b': - iwrap_buf_del(); - break; - default: - if (breaked) { - print("\n"); - console_command(c); - breaked = false; - } else { - iwrap_buf_add(c); - } - break; - } - return true; - } -} - -bool command_extra(uint8_t code) { return console_command(key2asc(code)); } - -static bool console_command(uint8_t c) { - switch (c) { - case 'h': - case '?': - print("\nCommands for Bluetooth(WT12/iWRAP):\n"); - print("r: reset. software reset by watchdog\n"); - print("i: insomniac. prevent KB from sleeping\n"); - print("c: iwrap_call. CALL for BT connection.\n"); -#ifdef PROTOCOL_VUSB - print("u: USB mode. switch to USB.\n"); - print("w: BT mode. switch to Bluetooth.\n"); -#endif - print("k: kill first connection.\n"); - print("Del: unpair first pairing.\n"); - print("\n"); - return 0; - case 'r': - print("reset\n"); - WD_AVR_RESET(); - return 1; - case 'i': - insomniac = !insomniac; - if (insomniac) - print("insomniac\n"); - else - print("not insomniac\n"); - return 1; - case 'c': - print("iwrap_call()\n"); - iwrap_call(); - return 1; -#ifdef PROTOCOL_VUSB - case 'u': - print("USB mode\n"); - init_vusb(); - change_driver(vusb_driver()); - // iwrap_kill(); - // iwrap_sleep(); - // disable suart receive interrut(PC5/PCINT13) - PCMSK1 &= ~(0b00100000); - PCICR &= ~(0b00000010); - return 1; - case 'w': - print("iWRAP mode\n"); - change_driver(iwrap_driver()); - disable_vusb(); - // enable suart receive interrut(PC5/PCINT13) - PCMSK1 |= 0b00100000; - PCICR |= 0b00000010; - return 1; -#endif - case 'k': - print("kill\n"); - iwrap_kill(); - return 1; - case 0x7F: // DELETE - print("unpair\n"); - iwrap_unpair(); - return 1; - } - return 0; -} - -// convert keycode into ascii charactor -static uint8_t key2asc(uint8_t key) { - switch (key) { - case KC_A: - return 'a'; - case KC_B: - return 'b'; - case KC_C: - return 'c'; - case KC_D: - return 'd'; - case KC_E: - return 'e'; - case KC_F: - return 'f'; - case KC_G: - return 'g'; - case KC_H: - return 'h'; - case KC_I: - return 'i'; - case KC_J: - return 'j'; - case KC_K: - return 'k'; - case KC_L: - return 'l'; - case KC_M: - return 'm'; - case KC_N: - return 'n'; - case KC_O: - return 'o'; - case KC_P: - return 'p'; - case KC_Q: - return 'q'; - case KC_R: - return 'r'; - case KC_S: - return 's'; - case KC_T: - return 't'; - case KC_U: - return 'u'; - case KC_V: - return 'v'; - case KC_W: - return 'w'; - case KC_X: - return 'x'; - case KC_Y: - return 'y'; - case KC_Z: - return 'z'; - case KC_1: - return '1'; - case KC_2: - return '2'; - case KC_3: - return '3'; - case KC_4: - return '4'; - case KC_5: - return '5'; - case KC_6: - return '6'; - case KC_7: - return '7'; - case KC_8: - return '8'; - case KC_9: - return '9'; - case KC_0: - return '0'; - case KC_ENTER: - return '\n'; - case KC_ESCAPE: - return 0x1B; - case KC_BSPACE: - return '\b'; - case KC_TAB: - return '\t'; - case KC_SPACE: - return ' '; - case KC_MINUS: - return '-'; - case KC_EQUAL: - return '='; - case KC_LBRACKET: - return '['; - case KC_RBRACKET: - return ']'; - case KC_BSLASH: - return '\\'; - case KC_NONUS_HASH: - return '#'; - case KC_SCOLON: - return ';'; - case KC_QUOTE: - return '\''; - case KC_GRAVE: - return '`'; - case KC_COMMA: - return ','; - case KC_DOT: - return '.'; - case KC_SLASH: - return '/'; - default: - return 0x00; - } -} diff --git a/tmk_core/protocol/iwrap/mux_exit.rb b/tmk_core/protocol/iwrap/mux_exit.rb deleted file mode 100644 index 1f6be48afdcb..000000000000 --- a/tmk_core/protocol/iwrap/mux_exit.rb +++ /dev/null @@ -1,7 +0,0 @@ -# -# Rescue from Bluegiga iWRAP MUX mode -# 6.75 of iWRAP5_User_Guid.pdf -# -[0xBF, 0xFF, 0x00, 0x11, 0x53, 0x45, 0x54, 0x20, 0x43, 0x4f, 0x4e, 0x54, 0x52, 0x4f, 0x4c, 0x20, 0x4d, 0x55, 0x58, 0x20, 0x30, 0x00].each do |x| - print x.chr -end diff --git a/tmk_core/protocol/iwrap/suart.S b/tmk_core/protocol/iwrap/suart.S deleted file mode 100644 index a873515e1041..000000000000 --- a/tmk_core/protocol/iwrap/suart.S +++ /dev/null @@ -1,156 +0,0 @@ -;---------------------------------------------------------------------------; -; Software implemented UART module ; -; (C)ChaN, 2005 (http://elm-chan.org/) ; -;---------------------------------------------------------------------------; -; Bit rate settings: -; -; 1MHz 2MHz 4MHz 6MHz 8MHz 10MHz 12MHz 16MHz 20MHz -; 2.4kbps 138 - - - - - - - - -; 4.8kbps 68 138 - - - - - - - -; 9.6kbps 33 68 138 208 - - - - - -; 19.2kbps - 33 68 102 138 173 208 - - -; 38.4kbps - - 33 50 68 85 102 138 172 -; 57.6kbps - - 21 33 44 56 68 91 114 -; 115.2kbps - - - - 21 27 33 44 56 - -.nolist -#include -.list - -#define BPS 102 /* Bit delay. (see above table) */ -#define BIDIR 0 /* 0:Separated Tx/Rx, 1:Shared Tx/Rx */ - -#define OUT_1 sbi _SFR_IO_ADDR(SUART_OUT_PORT), SUART_OUT_BIT /* Output 1 */ -#define OUT_0 cbi _SFR_IO_ADDR(SUART_OUT_PORT), SUART_OUT_BIT /* Output 0 */ -#define SKIP_IN_1 sbis _SFR_IO_ADDR(SUART_IN_PIN), SUART_IN_BIT /* Skip if 1 */ -#define SKIP_IN_0 sbic _SFR_IO_ADDR(SUART_IN_PIN), SUART_IN_BIT /* Skip if 0 */ - - - -#ifdef SPM_PAGESIZE -.macro _LPMI reg - lpm \reg, Z+ -.endm -.macro _MOVW dh,dl, sh,sl - movw \dl, \sl -.endm -#else -.macro _LPMI reg - lpm - mov \reg, r0 - adiw ZL, 1 -.endm -.macro _MOVW dh,dl, sh,sl - mov \dl, \sl - mov \dh, \sh -.endm -#endif - - - -;---------------------------------------------------------------------------; -; Transmit a byte in serial format of N81 -; -;Prototype: void xmit (uint8_t data); -;Size: 16 words - -.global xmit -.func xmit -xmit: -#if BIDIR - ldi r23, BPS-1 ;Pre-idle time for bidirectional data line -5: dec r23 ; - brne 5b ;/ -#endif - in r0, _SFR_IO_ADDR(SREG) ;Save flags - - com r24 ;C = start bit - ldi r25, 10 ;Bit counter - cli ;Start critical section - -1: ldi r23, BPS-1 ;----- Bit transferring loop -2: dec r23 ;Wait for a bit time - brne 2b ;/ - brcs 3f ;MISO = bit to be sent - OUT_1 ; -3: brcc 4f ; - OUT_0 ;/ -4: lsr r24 ;Get next bit into C - dec r25 ;All bits sent? - brne 1b ; no, coutinue - - out _SFR_IO_ADDR(SREG), r0 ;End of critical section - ret -.endfunc - - - -;---------------------------------------------------------------------------; -; Receive a byte -; -;Prototype: uint8_t rcvr (void); -;Size: 19 words - -.global rcvr -.func rcvr -rcvr: - in r0, _SFR_IO_ADDR(SREG) ;Save flags - - ldi r24, 0x80 ;Receiving shift reg - cli ;Start critical section - -1: SKIP_IN_1 ;Wait for idle - rjmp 1b -2: SKIP_IN_0 ;Wait for start bit - rjmp 2b - ldi r25, BPS/2 ;Wait for half bit time -3: dec r25 - brne 3b - -4: ldi r25, BPS ;----- Bit receiving loop -5: dec r25 ;Wait for a bit time - brne 5b ;/ - lsr r24 ;Next bit - SKIP_IN_0 ;Get a data bit into r24.7 - ori r24, 0x80 - brcc 4b ;All bits received? no, continue - - out _SFR_IO_ADDR(SREG), r0 ;End of critical section - ret -.endfunc - - -; Not wait for start bit. This should be called after detecting start bit. -.global recv -.func recv -recv: - in r0, _SFR_IO_ADDR(SREG) ;Save flags - - ldi r24, 0x80 ;Receiving shift reg - cli ;Start critical section - -;1: SKIP_IN_1 ;Wait for idle -; rjmp 1b -;2: SKIP_IN_0 ;Wait for start bit -; rjmp 2b - ldi r25, BPS/2 ;Wait for half bit time -3: dec r25 - brne 3b - -4: ldi r25, BPS ;----- Bit receiving loop -5: dec r25 ;Wait for a bit time - brne 5b ;/ - lsr r24 ;Next bit - SKIP_IN_0 ;Get a data bit into r24.7 - ori r24, 0x80 - brcc 4b ;All bits received? no, continue - - ldi r25, BPS/2 ;Wait for half bit time -6: dec r25 - brne 6b -7: SKIP_IN_1 ;Wait for stop bit - rjmp 7b - - out _SFR_IO_ADDR(SREG), r0 ;End of critical section - ret -.endfunc diff --git a/tmk_core/protocol/iwrap/suart.h b/tmk_core/protocol/iwrap/suart.h deleted file mode 100644 index c634bbc2f44c..000000000000 --- a/tmk_core/protocol/iwrap/suart.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef SUART -#define SUART - -void xmit(uint8_t); -uint8_t rcvr(void); -uint8_t recv(void); - -#endif /* SUART */ diff --git a/tmk_core/protocol/iwrap/wd.h b/tmk_core/protocol/iwrap/wd.h deleted file mode 100644 index 083d6d44d6c0..000000000000 --- a/tmk_core/protocol/iwrap/wd.h +++ /dev/null @@ -1,161 +0,0 @@ -/* This is from http://www.mtcnet.net/~henryvm/wdt/ */ -#ifndef _AVR_WD_H_ -#define _AVR_WD_H_ - -#include - -/* -Copyright (c) 2009, Curt Van Maanen - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - -include usage- - #include "wd.h" //if in same directory as project - #include //if wd.h is in avr directory - -set watchdog modes and prescale - -usage- - WD_SET(mode,[timeout]); //prescale always set - -modes- - WD_OFF disabled - WD_RST normal reset mode - WD_IRQ interrupt only mode (if supported) - WD_RST_IRQ interrupt+reset mode (if supported) - -timeout- - WDTO_15MS default if no timeout provided - WDTO_30MS - WDTO_60MS - WDTO_120MS - WDTO_250MS - WDTO_500MS - WDTO_1S - WDTO_2S - WDTO_4S (if supported) - WDTO_8S (if supported) - -examples- - WD_SET(WD_RST,WDTO_1S); //reset mode, 1s timeout - WD_SET(WD_OFF); //watchdog disabled (if not fused on) - WD_SET(WD_RST); //reset mode, 15ms (default timeout) - WD_SET(WD_IRQ,WDTO_120MS); //interrupt only mode, 120ms timeout - WD_SET(WD_RST_IRQ,WDTO_2S); //interrupt+reset mode, 2S timeout - - -for enhanced watchdogs, if the watchdog is not being used WDRF should be -cleared on every power up or reset, along with disabling the watchdog- - WD_DISABLE(); //clear WDRF, then turn off watchdog - -*/ - -// reset registers to the same name (MCUCSR) -#if !defined(MCUCSR) -# define MCUCSR MCUSR -#endif - -// watchdog registers to the same name (WDTCSR) -#if !defined(WDTCSR) -# define WDTCSR WDTCR -#endif - -// if enhanced watchdog, define irq values, create disable macro -#if defined(WDIF) -# define WD_IRQ 0xC0 -# define WD_RST_IRQ 0xC8 -# define WD_DISABLE() \ - do { \ - MCUCSR &= ~(1 << WDRF); \ - WD_SET(WD_OFF); \ - } while (0) -#endif - -// all watchdogs -#define WD_RST 8 -#define WD_OFF 0 - -// prescale values -#define WDTO_15MS 0 -#define WDTO_30MS 1 -#define WDTO_60MS 2 -#define WDTO_120MS 3 -#define WDTO_250MS 4 -#define WDTO_500MS 5 -#define WDTO_1S 6 -#define WDTO_2S 7 - -// prescale values for avrs with WDP3 -#if defined(WDP3) -# define WDTO_4S 0x20 -# define WDTO_8S 0x21 -#endif - -// watchdog reset -#define WDR() __asm__ __volatile__("wdr") - -// avr reset using watchdog -#define WD_AVR_RESET() \ - do { \ - __asm__ __volatile__("cli"); \ - WD_SET_UNSAFE(WD_RST); \ - while (1) \ - ; \ - } while (0) - -/*set the watchdog- -1. save SREG -2. turn off irq's -3. reset watchdog timer -4. enable watchdog change -5. write watchdog value -6. restore SREG (restoring irq status) -*/ -#define WD_SET(val, ...) \ - __asm__ __volatile__("in __tmp_reg__,__SREG__" \ - "\n\t" \ - "cli" \ - "\n\t" \ - "wdr" \ - "\n\t" \ - "sts %[wdreg],%[wden]" \ - "\n\t" \ - "sts %[wdreg],%[wdval]" \ - "\n\t" \ - "out __SREG__,__tmp_reg__" \ - "\n\t" \ - : \ - : [ wdreg ] "M"(&WDTCSR), [ wden ] "r"((uint8_t)(0x18)), [ wdval ] "r"((uint8_t)(val | (__VA_ARGS__ + 0))) \ - : "r0") - -/*set the watchdog when I bit in SREG known to be clear- -1. reset watchdog timer -2. enable watchdog change -5. write watchdog value -*/ -#define WD_SET_UNSAFE(val, ...) \ - __asm__ __volatile__("wdr" \ - "\n\t" \ - "sts %[wdreg],%[wden]" \ - "\n\t" \ - "sts %[wdreg],%[wdval]" \ - "\n\t" \ - : \ - : [ wdreg ] "M"(&WDTCSR), [ wden ] "r"((uint8_t)(0x18)), [ wdval ] "r"((uint8_t)(val | (__VA_ARGS__ + 0)))) - -// for compatibility with avr/wdt.h -#define wdt_enable(val) WD_SET(WD_RST, val) -#define wdt_disable() WD_SET(WD_OFF) - -#endif /* _AVR_WD_H_ */ diff --git a/tmk_core/readme.md b/tmk_core/readme.md index 5b719bca5d35..a754cfee42d0 100644 --- a/tmk_core/readme.md +++ b/tmk_core/readme.md @@ -84,8 +84,8 @@ Architecture / /| Keys/Mouse | Protocol |d| | Action | | | Protocol | /__________/ |<-----------| LUFA |r| | Layer, Tap | | | Matrix | |.--------.| | LED | V-USB |i| |-------------| | | PS/2,IBM | __________________ - || || |----------->| iWRAP(BT)|v| | Keymap | | | ADB,M0110| Keys / /_/_/_/_/_/_/_/ /| - || Host || | Console | UART |e| | Mousekey | | | SUN/NEWS |<----------/ /_/_/_/_/_/_/_/ / / + || || |----------->| UART |v| | Keymap | | | ADB,M0110| Keys / /_/_/_/_/_/_/_/ /| + || Host || | Console | |e| | Mousekey | | | SUN/NEWS |<----------/ /_/_/_/_/_/_/_/ / / ||________||/.<-----------| |r| | Report | | | X68K/PC98| Control / /_/_/_/_/_/_/_/ / / `_========_'/| |---------------------------------------------|-------->/___ /_______/ ___/ / |_o______o_|/ | Sendchar, Print, Debug, Command, ... | |_________________|/ @@ -133,7 +133,6 @@ Files and Directories ### Keyboard Protocols * lufa/ - LUFA USB stack * vusb/ - Objective Development V-USB -* iwrap/ - Bluetooth HID for Bluegiga iWRAP * ps2.c - PS/2 protocol * adb.c - Apple Desktop Bus protocol * m0110.c - Macintosh 128K/512K/Plus keyboard protocol From faa04011d1861cabec5e2ee8b4da0970faba23ba Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 6 Jun 2020 18:52:19 +1000 Subject: [PATCH 03/54] Initial work for consolidation of ChibiOS platform files (#8327) * Initial work for consolidation of board files and default ChibiOS configs. * Migrate F401/F411 black pills for testing. * Add early init bootloader jump flag. * Add support for I2C in order to use i2c_scanner keymap. * Add F401/F411 HSE bypass to get things booting. * Exempt "hooked" ChibiOS conf files from updater script. * Fix up ordering for bootloader_defs file check. * Match previous $(KEYBOARD_PATHS) value for Proton-C, updated for all board configs. --- build_keyboard.mk | 9 +- drivers/boards/BLACKPILL_STM32_F401/board.c | 250 ---- drivers/boards/BLACKPILL_STM32_F401/board.h | 568 -------- .../BLACKPILL_STM32_F401/cfg/board.chcfg | 1193 ----------------- .../BLACKPILL_STM32_F401/cfg/board.fmpp | 15 - drivers/boards/BLACKPILL_STM32_F411/board.c | 250 ---- drivers/boards/BLACKPILL_STM32_F411/board.h | 583 -------- .../BLACKPILL_STM32_F411/cfg/board.chcfg | 1193 ----------------- .../BLACKPILL_STM32_F411/cfg/board.fmpp | 15 - .../GENERIC_STM32_F072XB/cfg/board.chcfg | 703 ---------- .../GENERIC_STM32_F072XB/cfg/board.fmpp | 15 - drivers/boards/GENERIC_STM32_F303XC/board.mk | 5 - drivers/boards/IC_TEENSY_3_1/board.mk | 5 - drivers/boards/STM32_F103_STM32DUINO/board.mk | 5 - .../handwired/onekey/blackpill_f401/halconf.h | 537 +------- .../handwired/onekey/blackpill_f401/mcuconf.h | 264 +--- .../handwired/onekey/blackpill_f411/halconf.h | 537 +------- .../handwired/onekey/blackpill_f411/mcuconf.h | 264 +--- .../ixora/boards/GENERIC_STM32_F042X6/board.c | 268 ---- .../boards/GENERIC_STM32_F042X6/board.mk | 5 - .../vinta/boards/GENERIC_STM32_F042X6/board.h | 896 ------------- .../boards/GENERIC_STM32_F042X6/board.mk | 5 - keyboards/vinta/bootloader_defs.h | 7 - lib/python/qmk/cli/cformat.py | 4 +- .../BLACKPILL_STM32_F401/board/board.mk | 9 + .../BLACKPILL_STM32_F401/configs/board.h | 20 + .../BLACKPILL_STM32_F401/configs}/chconf.h | 0 .../BLACKPILL_STM32_F401/configs/config.h | 23 + .../BLACKPILL_STM32_F401/configs/halconf.h | 525 ++++++++ .../BLACKPILL_STM32_F401/configs/mcuconf.h | 253 ++++ .../BLACKPILL_STM32_F411/board/board.mk | 9 + .../BLACKPILL_STM32_F411/configs/board.h | 20 + .../BLACKPILL_STM32_F411/configs}/chconf.h | 0 .../BLACKPILL_STM32_F411/configs/config.h | 23 + .../BLACKPILL_STM32_F411/configs/halconf.h | 525 ++++++++ .../BLACKPILL_STM32_F411/configs/mcuconf.h | 253 ++++ .../GENERIC_STM32_F042X6/board}/board.c | 3 +- .../GENERIC_STM32_F042X6/board}/board.h | 0 .../GENERIC_STM32_F042X6/board}/board.mk | 4 +- .../configs}/bootloader_defs.h | 0 .../GENERIC_STM32_F072XB/board}/board.c | 0 .../GENERIC_STM32_F072XB/board}/board.h | 0 .../GENERIC_STM32_F072XB/board}/board.mk | 4 +- .../configs}/bootloader_defs.h | 0 .../GENERIC_STM32_F303XC/board}/board.c | 2 +- .../GENERIC_STM32_F303XC/board}/board.h | 0 .../GENERIC_STM32_F303XC/board}/board.mk | 4 +- .../configs}/bootloader_defs.h | 0 .../GENERIC_STM32_F303XC/configs}/chconf.h | 362 ++--- .../GENERIC_STM32_F303XC/configs}/halconf.h | 339 ++--- .../GENERIC_STM32_F303XC/configs/mcuconf.h | 273 ++++ .../GENERIC_STM32_F303XC/configs/proton_c.mk | 9 + .../chibios/IC_TEENSY_3_1/board}/board.c | 0 .../chibios/IC_TEENSY_3_1/board}/board.h | 0 .../chibios/IC_TEENSY_3_1/board/board.mk | 9 + .../STM32_F103_STM32DUINO/board}/board.c | 3 + .../STM32_F103_STM32DUINO/board}/board.h | 0 .../STM32_F103_STM32DUINO/board/board.mk | 9 + .../chibios/keyboard-config-templates/board.h | 20 + .../keyboard-config-templates/chconf.h | 20 + .../keyboard-config-templates/halconf.h | 20 + .../keyboard-config-templates/mcuconf.h | 21 + .../chibios}/ld/MKL26Z64.ld | 0 .../ld/STM32F103x8_stm32duino_bootloader.ld | 0 quantum/stm32/mcuconf.h | 273 ---- quantum/stm32/proton_c.mk | 47 - tmk_core/chibios.mk | 113 +- util/chibios-upgrader.sh | 6 +- util/travis_compiled_push.sh | 2 +- 69 files changed, 2563 insertions(+), 8236 deletions(-) delete mode 100644 drivers/boards/BLACKPILL_STM32_F401/board.c delete mode 100644 drivers/boards/BLACKPILL_STM32_F401/board.h delete mode 100644 drivers/boards/BLACKPILL_STM32_F401/cfg/board.chcfg delete mode 100644 drivers/boards/BLACKPILL_STM32_F401/cfg/board.fmpp delete mode 100644 drivers/boards/BLACKPILL_STM32_F411/board.c delete mode 100644 drivers/boards/BLACKPILL_STM32_F411/board.h delete mode 100644 drivers/boards/BLACKPILL_STM32_F411/cfg/board.chcfg delete mode 100644 drivers/boards/BLACKPILL_STM32_F411/cfg/board.fmpp delete mode 100644 drivers/boards/GENERIC_STM32_F072XB/cfg/board.chcfg delete mode 100644 drivers/boards/GENERIC_STM32_F072XB/cfg/board.fmpp delete mode 100644 drivers/boards/GENERIC_STM32_F303XC/board.mk delete mode 100644 drivers/boards/IC_TEENSY_3_1/board.mk delete mode 100644 drivers/boards/STM32_F103_STM32DUINO/board.mk delete mode 100644 keyboards/peiorisboards/ixora/boards/GENERIC_STM32_F042X6/board.c delete mode 100644 keyboards/peiorisboards/ixora/boards/GENERIC_STM32_F042X6/board.mk delete mode 100644 keyboards/vinta/boards/GENERIC_STM32_F042X6/board.h delete mode 100644 keyboards/vinta/boards/GENERIC_STM32_F042X6/board.mk delete mode 100644 keyboards/vinta/bootloader_defs.h create mode 100644 platforms/chibios/BLACKPILL_STM32_F401/board/board.mk create mode 100644 platforms/chibios/BLACKPILL_STM32_F401/configs/board.h rename {keyboards/handwired/onekey/blackpill_f401 => platforms/chibios/BLACKPILL_STM32_F401/configs}/chconf.h (100%) create mode 100644 platforms/chibios/BLACKPILL_STM32_F401/configs/config.h create mode 100644 platforms/chibios/BLACKPILL_STM32_F401/configs/halconf.h create mode 100644 platforms/chibios/BLACKPILL_STM32_F401/configs/mcuconf.h create mode 100644 platforms/chibios/BLACKPILL_STM32_F411/board/board.mk create mode 100644 platforms/chibios/BLACKPILL_STM32_F411/configs/board.h rename {keyboards/handwired/onekey/blackpill_f411 => platforms/chibios/BLACKPILL_STM32_F411/configs}/chconf.h (100%) create mode 100644 platforms/chibios/BLACKPILL_STM32_F411/configs/config.h create mode 100644 platforms/chibios/BLACKPILL_STM32_F411/configs/halconf.h create mode 100644 platforms/chibios/BLACKPILL_STM32_F411/configs/mcuconf.h rename {keyboards/vinta/boards/GENERIC_STM32_F042X6 => platforms/chibios/GENERIC_STM32_F042X6/board}/board.c (99%) rename {keyboards/peiorisboards/ixora/boards/GENERIC_STM32_F042X6 => platforms/chibios/GENERIC_STM32_F042X6/board}/board.h (100%) rename {drivers/boards/GENERIC_STM32_F072XB => platforms/chibios/GENERIC_STM32_F042X6/board}/board.mk (54%) rename {keyboards/peiorisboards/ixora => platforms/chibios/GENERIC_STM32_F042X6/configs}/bootloader_defs.h (100%) rename {drivers/boards/GENERIC_STM32_F072XB => platforms/chibios/GENERIC_STM32_F072XB/board}/board.c (100%) rename {drivers/boards/GENERIC_STM32_F072XB => platforms/chibios/GENERIC_STM32_F072XB/board}/board.h (100%) rename {drivers/boards/BLACKPILL_STM32_F411 => platforms/chibios/GENERIC_STM32_F072XB/board}/board.mk (54%) rename {drivers/boards/GENERIC_STM32_F072XB => platforms/chibios/GENERIC_STM32_F072XB/configs}/bootloader_defs.h (100%) rename {drivers/boards/GENERIC_STM32_F303XC => platforms/chibios/GENERIC_STM32_F303XC/board}/board.c (99%) rename {drivers/boards/GENERIC_STM32_F303XC => platforms/chibios/GENERIC_STM32_F303XC/board}/board.h (100%) rename {drivers/boards/BLACKPILL_STM32_F401 => platforms/chibios/GENERIC_STM32_F303XC/board}/board.mk (54%) rename {drivers/boards/GENERIC_STM32_F303XC => platforms/chibios/GENERIC_STM32_F303XC/configs}/bootloader_defs.h (100%) rename {quantum/stm32 => platforms/chibios/GENERIC_STM32_F303XC/configs}/chconf.h (68%) rename {quantum/stm32 => platforms/chibios/GENERIC_STM32_F303XC/configs}/halconf.h (62%) create mode 100644 platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h create mode 100644 platforms/chibios/GENERIC_STM32_F303XC/configs/proton_c.mk rename {drivers/boards/IC_TEENSY_3_1 => platforms/chibios/IC_TEENSY_3_1/board}/board.c (100%) rename {drivers/boards/IC_TEENSY_3_1 => platforms/chibios/IC_TEENSY_3_1/board}/board.h (100%) create mode 100644 platforms/chibios/IC_TEENSY_3_1/board/board.mk rename {drivers/boards/STM32_F103_STM32DUINO => platforms/chibios/STM32_F103_STM32DUINO/board}/board.c (93%) rename {drivers/boards/STM32_F103_STM32DUINO => platforms/chibios/STM32_F103_STM32DUINO/board}/board.h (100%) create mode 100644 platforms/chibios/STM32_F103_STM32DUINO/board/board.mk create mode 100644 platforms/chibios/keyboard-config-templates/board.h create mode 100644 platforms/chibios/keyboard-config-templates/chconf.h create mode 100644 platforms/chibios/keyboard-config-templates/halconf.h create mode 100644 platforms/chibios/keyboard-config-templates/mcuconf.h rename {drivers/boards => platforms/chibios}/ld/MKL26Z64.ld (100%) rename {drivers/boards => platforms/chibios}/ld/STM32F103x8_stm32duino_bootloader.ld (100%) delete mode 100644 quantum/stm32/mcuconf.h delete mode 100644 quantum/stm32/proton_c.mk diff --git a/build_keyboard.mk b/build_keyboard.mk index 4108704875d2..b4e1efd9ee40 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -16,7 +16,6 @@ include common.mk KEYBOARD_FILESAFE := $(subst /,_,$(KEYBOARD)) TARGET ?= $(KEYBOARD_FILESAFE)_$(KEYMAP) KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD_FILESAFE) -STM32_PATH := quantum/stm32 # Force expansion TARGET := $(TARGET) @@ -138,7 +137,7 @@ endif ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes) TARGET := $(TARGET)_proton_c - include $(STM32_PATH)/proton_c.mk + include platforms/chibios/GENERIC_STM32_F303XC/configs/proton_c.mk OPT_DEFS += -DCONVERT_TO_PROTON_C endif @@ -148,12 +147,6 @@ endif include quantum/mcu_selection.mk -ifdef MCU_FAMILY - OPT_DEFS += -DQMK_STM32 - KEYBOARD_PATHS += $(STM32_PATH) -endif - - # Find all the C source files to be compiled in subfolders. KEYBOARD_SRC := diff --git a/drivers/boards/BLACKPILL_STM32_F401/board.c b/drivers/boards/BLACKPILL_STM32_F401/board.c deleted file mode 100644 index 330e06c8aa8e..000000000000 --- a/drivers/boards/BLACKPILL_STM32_F401/board.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/* - * This file has been automatically generated using ChibiStudio board - * generator plugin. Do not edit manually. - */ - -#include "hal.h" -#include "stm32_gpio.h" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables and types. */ -/*===========================================================================*/ - -/** - * @brief Type of STM32 GPIO port setup. - */ -typedef struct { - uint32_t moder; - uint32_t otyper; - uint32_t ospeedr; - uint32_t pupdr; - uint32_t odr; - uint32_t afrl; - uint32_t afrh; -} gpio_setup_t; - -/** - * @brief Type of STM32 GPIO initialization data. - */ -typedef struct { -#if STM32_HAS_GPIOA || defined(__DOXYGEN__) - gpio_setup_t PAData; -#endif -#if STM32_HAS_GPIOB || defined(__DOXYGEN__) - gpio_setup_t PBData; -#endif -#if STM32_HAS_GPIOC || defined(__DOXYGEN__) - gpio_setup_t PCData; -#endif -#if STM32_HAS_GPIOD || defined(__DOXYGEN__) - gpio_setup_t PDData; -#endif -#if STM32_HAS_GPIOE || defined(__DOXYGEN__) - gpio_setup_t PEData; -#endif -#if STM32_HAS_GPIOF || defined(__DOXYGEN__) - gpio_setup_t PFData; -#endif -#if STM32_HAS_GPIOG || defined(__DOXYGEN__) - gpio_setup_t PGData; -#endif -#if STM32_HAS_GPIOH || defined(__DOXYGEN__) - gpio_setup_t PHData; -#endif -#if STM32_HAS_GPIOI || defined(__DOXYGEN__) - gpio_setup_t PIData; -#endif -#if STM32_HAS_GPIOJ || defined(__DOXYGEN__) - gpio_setup_t PJData; -#endif -#if STM32_HAS_GPIOK || defined(__DOXYGEN__) - gpio_setup_t PKData; -#endif -} gpio_config_t; - -/** - * @brief STM32 GPIO static initialization data. - */ -static const gpio_config_t gpio_default_config = { -#if STM32_HAS_GPIOA - {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR, VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH}, -#endif -#if STM32_HAS_GPIOB - {VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR, VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH}, -#endif -#if STM32_HAS_GPIOC - {VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR, VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH}, -#endif -#if STM32_HAS_GPIOD - {VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR, VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH}, -#endif -#if STM32_HAS_GPIOE - {VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR, VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH}, -#endif -#if STM32_HAS_GPIOF - {VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR, VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH}, -#endif -#if STM32_HAS_GPIOG - {VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR, VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH}, -#endif -#if STM32_HAS_GPIOH - {VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR, VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH}, -#endif -#if STM32_HAS_GPIOI - {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR, VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}, -#endif -#if STM32_HAS_GPIOJ - {VAL_GPIOJ_MODER, VAL_GPIOJ_OTYPER, VAL_GPIOJ_OSPEEDR, VAL_GPIOJ_PUPDR, VAL_GPIOJ_ODR, VAL_GPIOJ_AFRL, VAL_GPIOJ_AFRH}, -#endif -#if STM32_HAS_GPIOK - {VAL_GPIOK_MODER, VAL_GPIOK_OTYPER, VAL_GPIOK_OSPEEDR, VAL_GPIOK_PUPDR, VAL_GPIOK_ODR, VAL_GPIOK_AFRL, VAL_GPIOK_AFRH} -#endif -}; - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config) { - gpiop->OTYPER = config->otyper; - gpiop->OSPEEDR = config->ospeedr; - gpiop->PUPDR = config->pupdr; - gpiop->ODR = config->odr; - gpiop->AFRL = config->afrl; - gpiop->AFRH = config->afrh; - gpiop->MODER = config->moder; -} - -static void stm32_gpio_init(void) { - /* Enabling GPIO-related clocks, the mask comes from the - registry header file.*/ - rccResetAHB1(STM32_GPIO_EN_MASK); - rccEnableAHB1(STM32_GPIO_EN_MASK, true); - - /* Initializing all the defined GPIO ports.*/ -#if STM32_HAS_GPIOA - gpio_init(GPIOA, &gpio_default_config.PAData); -#endif -#if STM32_HAS_GPIOB - gpio_init(GPIOB, &gpio_default_config.PBData); -#endif -#if STM32_HAS_GPIOC - gpio_init(GPIOC, &gpio_default_config.PCData); -#endif -#if STM32_HAS_GPIOD - gpio_init(GPIOD, &gpio_default_config.PDData); -#endif -#if STM32_HAS_GPIOE - gpio_init(GPIOE, &gpio_default_config.PEData); -#endif -#if STM32_HAS_GPIOF - gpio_init(GPIOF, &gpio_default_config.PFData); -#endif -#if STM32_HAS_GPIOG - gpio_init(GPIOG, &gpio_default_config.PGData); -#endif -#if STM32_HAS_GPIOH - gpio_init(GPIOH, &gpio_default_config.PHData); -#endif -#if STM32_HAS_GPIOI - gpio_init(GPIOI, &gpio_default_config.PIData); -#endif -#if STM32_HAS_GPIOJ - gpio_init(GPIOJ, &gpio_default_config.PJData); -#endif -#if STM32_HAS_GPIOK - gpio_init(GPIOK, &gpio_default_config.PKData); -#endif -} - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -__attribute__((weak)) void enter_bootloader_mode_if_requested(void) {} - -/** - * @brief Early initialization code. - * @details GPIO ports and system clocks are initialized before everything - * else. - */ -void __early_init(void) { - enter_bootloader_mode_if_requested(); - - stm32_gpio_init(); - stm32_clock_init(); -} - -#if HAL_USE_SDC || defined(__DOXYGEN__) -/** - * @brief SDC card detection. - */ -bool sdc_lld_is_card_inserted(SDCDriver *sdcp) { - (void)sdcp; - /* TODO: Fill the implementation.*/ - return true; -} - -/** - * @brief SDC card write protection detection. - */ -bool sdc_lld_is_write_protected(SDCDriver *sdcp) { - (void)sdcp; - /* TODO: Fill the implementation.*/ - return false; -} -#endif /* HAL_USE_SDC */ - -#if HAL_USE_MMC_SPI || defined(__DOXYGEN__) -/** - * @brief MMC_SPI card detection. - */ -bool mmc_lld_is_card_inserted(MMCDriver *mmcp) { - (void)mmcp; - /* TODO: Fill the implementation.*/ - return true; -} - -/** - * @brief MMC_SPI card write protection detection. - */ -bool mmc_lld_is_write_protected(MMCDriver *mmcp) { - (void)mmcp; - /* TODO: Fill the implementation.*/ - return false; -} -#endif - -/** - * @brief Board-specific initialization code. - * @todo Add your board-specific code, if any. - */ -void boardInit(void) {} diff --git a/drivers/boards/BLACKPILL_STM32_F401/board.h b/drivers/boards/BLACKPILL_STM32_F401/board.h deleted file mode 100644 index 2d1cd9ff72dd..000000000000 --- a/drivers/boards/BLACKPILL_STM32_F401/board.h +++ /dev/null @@ -1,568 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/* - * This file has been automatically generated using ChibiStudio board - * generator plugin. Do not edit manually. - */ - -#ifndef BOARD_H -#define BOARD_H - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -/* - * Setup for STM32F401CCU6 black pill board. - */ - -/* - * Board identifier. - */ -#define BOARD_BLACKPILL_STM32_F401 -#define BOARD_NAME "STM32F401CCU6 blackpill" - -/* - * Allow Board to boot USB without extra A9 hardware/software config - */ -#define BOARD_OTG_NOVBUSSENS 1 - -/* - * Board oscillators-related settings. - */ -#if !defined(STM32_LSECLK) -# define STM32_LSECLK 32768U -#endif - -#if !defined(STM32_HSECLK) -# define STM32_HSECLK 25000000U -#endif - -/* - * Board voltages. - * Required for performance limits calculation. - */ -#define STM32_VDD 300U - -/* - * MCU type as defined in the ST header. - */ -#define STM32F401xC - -/* - * IO pins assignments. - */ -#define GPIOA_BUTTON 0U -#define GPIOA_PIN1 1U -#define GPIOA_PIN2 2U -#define GPIOA_PIN3 3U -#define GPIOA_CS43L22_LRCK 4U -#define GPIOA_L3GD20_SCL 5U -#define GPIOA_L3GD20_SD0 6U -#define GPIOA_L3GD20_SDI 7U -#define GPIOA_PIN8 8U -#define GPIOA_VBUS_FS 9U -#define GPIOA_OTG_FS_ID 10U -#define GPIOA_OTG_FS_DM 11U -#define GPIOA_OTG_FS_DP 12U -#define GPIOA_SWDIO 13U -#define GPIOA_SWCLK 14U -#define GPIOA_PIN15 15U - -#define GPIOB_PIN0 0U -#define GPIOB_PIN1 1U -#define GPIOB_PIN2 2U -#define GPIOB_SWO 3U -#define GPIOB_PIN4 4U -#define GPIOB_PIN5 5U -#define GPIOB_LSM303DLHC_SCL 6U -#define GPIOB_PIN7 7U -#define GPIOB_PIN8 8U -#define GPIOB_LSM303DLHC_SDA 9U -#define GPIOB_MP45DT02_CLK_IN 10U -#define GPIOB_PIN11 11U -#define GPIOB_PIN12 12U -#define GPIOB_PIN13 13U -#define GPIOB_PIN14 14U -#define GPIOB_PIN15 15U - -#define GPIOC_OTG_FS_POWER_ON 0U -#define GPIOC_PIN1 1U -#define GPIOC_PIN2 2U -#define GPIOC_CS43L22_AIN4x 3U -#define GPIOC_MP45DT02_PDM_OUT 3U -#define GPIOC_PIN4 4U -#define GPIOC_PIN5 5U -#define GPIOC_PIN6 6U -#define GPIOC_CS43L22_MCLK 7U -#define GPIOC_PIN8 8U -#define GPIOC_PIN9 9U -#define GPIOC_CS43L22_SCLK 10U -#define GPIOC_PIN11 11U -#define GPIOC_CS43L22_SDIN 12U -#define GPIOC_PIN13 13U -#define GPIOC_OSC32_IN 14U -#define GPIOC_OSC32_OUT 15U - -#define GPIOD_PIN0 0U -#define GPIOD_PIN1 1U -#define GPIOD_PIN2 2U -#define GPIOD_PIN3 3U -#define GPIOD_CS43L22_RESET 4U -#define GPIOD_OverCurrent 5U -#define GPIOD_PIN6 6U -#define GPIOD_PIN7 7U -#define GPIOD_PIN8 8U -#define GPIOD_PIN9 9U -#define GPIOD_PIN10 10U -#define GPIOD_PIN11 11U -#define GPIOD_LED4 12U -#define GPIOD_LED3 13U -#define GPIOD_LED5 14U -#define GPIOD_LED6 15U - -#define GPIOE_L3GD20_INT1 0U -#define GPIOE_L3GD20_INT2 1U -#define GPIOE_LSM303DLHC_DRDY 2U -#define GPIOE_L3GD20_CS 3U -#define GPIOE_LSM303DLHC_INT1 4U -#define GPIOE_LSM303DLHC_INT2 5U -#define GPIOE_PIN6 6U -#define GPIOE_PIN7 7U -#define GPIOE_PIN8 8U -#define GPIOE_PIN9 9U -#define GPIOE_PIN10 10U -#define GPIOE_PIN11 11U -#define GPIOE_PIN12 12U -#define GPIOE_PIN13 13U -#define GPIOE_PIN14 14U -#define GPIOE_PIN15 15U - -#define GPIOF_PIN0 0U -#define GPIOF_PIN1 1U -#define GPIOF_PIN2 2U -#define GPIOF_PIN3 3U -#define GPIOF_PIN4 4U -#define GPIOF_PIN5 5U -#define GPIOF_PIN6 6U -#define GPIOF_PIN7 7U -#define GPIOF_PIN8 8U -#define GPIOF_PIN9 9U -#define GPIOF_PIN10 10U -#define GPIOF_PIN11 11U -#define GPIOF_PIN12 12U -#define GPIOF_PIN13 13U -#define GPIOF_PIN14 14U -#define GPIOF_PIN15 15U - -#define GPIOG_PIN0 0U -#define GPIOG_PIN1 1U -#define GPIOG_PIN2 2U -#define GPIOG_PIN3 3U -#define GPIOG_PIN4 4U -#define GPIOG_PIN5 5U -#define GPIOG_PIN6 6U -#define GPIOG_PIN7 7U -#define GPIOG_PIN8 8U -#define GPIOG_PIN9 9U -#define GPIOG_PIN10 10U -#define GPIOG_PIN11 11U -#define GPIOG_PIN12 12U -#define GPIOG_PIN13 13U -#define GPIOG_PIN14 14U -#define GPIOG_PIN15 15U - -#define GPIOH_OSC_IN 0U -#define GPIOH_OSC_OUT 1U -#define GPIOH_PIN2 2U -#define GPIOH_PIN3 3U -#define GPIOH_PIN4 4U -#define GPIOH_PIN5 5U -#define GPIOH_PIN6 6U -#define GPIOH_PIN7 7U -#define GPIOH_PIN8 8U -#define GPIOH_PIN9 9U -#define GPIOH_PIN10 10U -#define GPIOH_PIN11 11U -#define GPIOH_PIN12 12U -#define GPIOH_PIN13 13U -#define GPIOH_PIN14 14U -#define GPIOH_PIN15 15U - -#define GPIOI_PIN0 0U -#define GPIOI_PIN1 1U -#define GPIOI_PIN2 2U -#define GPIOI_PIN3 3U -#define GPIOI_PIN4 4U -#define GPIOI_PIN5 5U -#define GPIOI_PIN6 6U -#define GPIOI_PIN7 7U -#define GPIOI_PIN8 8U -#define GPIOI_PIN9 9U -#define GPIOI_PIN10 10U -#define GPIOI_PIN11 11U -#define GPIOI_PIN12 12U -#define GPIOI_PIN13 13U -#define GPIOI_PIN14 14U -#define GPIOI_PIN15 15U - -/* - * IO lines assignments. - */ -#define LINE_BUTTON PAL_LINE(GPIOA, 0U) -#define LINE_CS43L22_LRCK PAL_LINE(GPIOA, 4U) -#define LINE_L3GD20_SCL PAL_LINE(GPIOA, 5U) -#define LINE_L3GD20_SD0 PAL_LINE(GPIOA, 6U) -#define LINE_L3GD20_SDI PAL_LINE(GPIOA, 7U) -#define LINE_VBUS_FS PAL_LINE(GPIOA, 9U) -#define LINE_OTG_FS_ID PAL_LINE(GPIOA, 10U) -#define LINE_OTG_FS_DM PAL_LINE(GPIOA, 11U) -#define LINE_OTG_FS_DP PAL_LINE(GPIOA, 12U) -#define LINE_SWDIO PAL_LINE(GPIOA, 13U) -#define LINE_SWCLK PAL_LINE(GPIOA, 14U) -#define LINE_SWO PAL_LINE(GPIOB, 3U) -#define LINE_LSM303DLHC_SCL PAL_LINE(GPIOB, 6U) -#define LINE_LSM303DLHC_SDA PAL_LINE(GPIOB, 9U) -#define LINE_MP45DT02_CLK_IN PAL_LINE(GPIOB, 10U) -#define LINE_OTG_FS_POWER_ON PAL_LINE(GPIOC, 0U) -#define LINE_CS43L22_AIN4x PAL_LINE(GPIOC, 3U) -#define LINE_MP45DT02_PDM_OUT PAL_LINE(GPIOC, 3U) -#define LINE_CS43L22_MCLK PAL_LINE(GPIOC, 7U) -#define LINE_CS43L22_SCLK PAL_LINE(GPIOC, 10U) -#define LINE_CS43L22_SDIN PAL_LINE(GPIOC, 12U) -#define LINE_OSC32_IN PAL_LINE(GPIOC, 14U) -#define LINE_OSC32_OUT PAL_LINE(GPIOC, 15U) -#define LINE_CS43L22_RESET PAL_LINE(GPIOD, 4U) -#define LINE_OverCurrent PAL_LINE(GPIOD, 5U) -#define LINE_LED4 PAL_LINE(GPIOD, 12U) -#define LINE_LED3 PAL_LINE(GPIOD, 13U) -#define LINE_LED5 PAL_LINE(GPIOD, 14U) -#define LINE_LED6 PAL_LINE(GPIOD, 15U) -#define LINE_L3GD20_INT1 PAL_LINE(GPIOE, 0U) -#define LINE_L3GD20_INT2 PAL_LINE(GPIOE, 1U) -#define LINE_LSM303DLHC_DRDY PAL_LINE(GPIOE, 2U) -#define LINE_L3GD20_CS PAL_LINE(GPIOE, 3U) -#define LINE_LSM303DLHC_INT1 PAL_LINE(GPIOE, 4U) -#define LINE_LSM303DLHC_INT2 PAL_LINE(GPIOE, 5U) -#define LINE_OSC_IN PAL_LINE(GPIOH, 0U) -#define LINE_OSC_OUT PAL_LINE(GPIOH, 1U) - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ - -/* - * I/O ports initial setup, this configuration is established soon after reset - * in the initialization code. - * Please refer to the STM32 Reference Manual for details. - */ -#define PIN_MODE_INPUT(n) (0U << ((n)*2U)) -#define PIN_MODE_OUTPUT(n) (1U << ((n)*2U)) -#define PIN_MODE_ALTERNATE(n) (2U << ((n)*2U)) -#define PIN_MODE_ANALOG(n) (3U << ((n)*2U)) -#define PIN_ODR_LOW(n) (0U << (n)) -#define PIN_ODR_HIGH(n) (1U << (n)) -#define PIN_OTYPE_PUSHPULL(n) (0U << (n)) -#define PIN_OTYPE_OPENDRAIN(n) (1U << (n)) -#define PIN_OSPEED_VERYLOW(n) (0U << ((n)*2U)) -#define PIN_OSPEED_LOW(n) (1U << ((n)*2U)) -#define PIN_OSPEED_MEDIUM(n) (2U << ((n)*2U)) -#define PIN_OSPEED_HIGH(n) (3U << ((n)*2U)) -#define PIN_PUPDR_FLOATING(n) (0U << ((n)*2U)) -#define PIN_PUPDR_PULLUP(n) (1U << ((n)*2U)) -#define PIN_PUPDR_PULLDOWN(n) (2U << ((n)*2U)) -#define PIN_AFIO_AF(n, v) ((v) << (((n) % 8U) * 4U)) - -/* - * GPIOA setup: - * - * PA0 - BUTTON (input floating). - * PA1 - PIN1 (input pullup). - * PA2 - PIN2 (input pullup). - * PA3 - PIN3 (input pullup). - * PA4 - CS43L22_LRCK (alternate 6). - * PA5 - L3GD20_SCL (alternate 5). - * PA6 - L3GD20_SD0 (alternate 5). - * PA7 - L3GD20_SDI (alternate 5). - * PA8 - PIN8 (input pullup). - * PA9 - VBUS_FS (input floating). - * PA10 - OTG_FS_ID (alternate 10). - * PA11 - OTG_FS_DM (alternate 10). - * PA12 - OTG_FS_DP (alternate 10). - * PA13 - SWDIO (alternate 0). - * PA14 - SWCLK (alternate 0). - * PA15 - PIN15 (input pullup). - */ -#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_BUTTON) | PIN_MODE_INPUT(GPIOA_PIN1) | PIN_MODE_INPUT(GPIOA_PIN2) | PIN_MODE_INPUT(GPIOA_PIN3) | PIN_MODE_ALTERNATE(GPIOA_CS43L22_LRCK) | PIN_MODE_ALTERNATE(GPIOA_L3GD20_SCL) | PIN_MODE_ALTERNATE(GPIOA_L3GD20_SD0) | PIN_MODE_ALTERNATE(GPIOA_L3GD20_SDI) | PIN_MODE_INPUT(GPIOA_PIN8) | PIN_MODE_INPUT(GPIOA_VBUS_FS) | PIN_MODE_ALTERNATE(GPIOA_OTG_FS_ID) | PIN_MODE_ALTERNATE(GPIOA_OTG_FS_DM) | PIN_MODE_ALTERNATE(GPIOA_OTG_FS_DP) | PIN_MODE_ALTERNATE(GPIOA_SWDIO) | PIN_MODE_ALTERNATE(GPIOA_SWCLK) | PIN_MODE_INPUT(GPIOA_PIN15)) -#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_BUTTON) | PIN_OTYPE_PUSHPULL(GPIOA_PIN1) | PIN_OTYPE_PUSHPULL(GPIOA_PIN2) | PIN_OTYPE_PUSHPULL(GPIOA_PIN3) | PIN_OTYPE_PUSHPULL(GPIOA_CS43L22_LRCK) | PIN_OTYPE_PUSHPULL(GPIOA_L3GD20_SCL) | PIN_OTYPE_PUSHPULL(GPIOA_L3GD20_SD0) | PIN_OTYPE_PUSHPULL(GPIOA_L3GD20_SDI) | PIN_OTYPE_PUSHPULL(GPIOA_PIN8) | PIN_OTYPE_PUSHPULL(GPIOA_VBUS_FS) | PIN_OTYPE_PUSHPULL(GPIOA_OTG_FS_ID) | PIN_OTYPE_PUSHPULL(GPIOA_OTG_FS_DM) | PIN_OTYPE_PUSHPULL(GPIOA_OTG_FS_DP) | PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) | PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) | PIN_OTYPE_PUSHPULL(GPIOA_PIN15)) -#define VAL_GPIOA_OSPEEDR (PIN_OSPEED_HIGH(GPIOA_BUTTON) | PIN_OSPEED_HIGH(GPIOA_PIN1) | PIN_OSPEED_HIGH(GPIOA_PIN2) | PIN_OSPEED_HIGH(GPIOA_PIN3) | PIN_OSPEED_HIGH(GPIOA_CS43L22_LRCK) | PIN_OSPEED_HIGH(GPIOA_L3GD20_SCL) | PIN_OSPEED_HIGH(GPIOA_L3GD20_SD0) | PIN_OSPEED_HIGH(GPIOA_L3GD20_SDI) | PIN_OSPEED_HIGH(GPIOA_PIN8) | PIN_OSPEED_HIGH(GPIOA_VBUS_FS) | PIN_OSPEED_HIGH(GPIOA_OTG_FS_ID) | PIN_OSPEED_HIGH(GPIOA_OTG_FS_DM) | PIN_OSPEED_HIGH(GPIOA_OTG_FS_DP) | PIN_OSPEED_HIGH(GPIOA_SWDIO) | PIN_OSPEED_HIGH(GPIOA_SWCLK) | PIN_OSPEED_HIGH(GPIOA_PIN15)) -#define VAL_GPIOA_PUPDR (PIN_PUPDR_FLOATING(GPIOA_BUTTON) | PIN_PUPDR_PULLUP(GPIOA_PIN1) | PIN_PUPDR_PULLUP(GPIOA_PIN2) | PIN_PUPDR_PULLUP(GPIOA_PIN3) | PIN_PUPDR_FLOATING(GPIOA_CS43L22_LRCK) | PIN_PUPDR_FLOATING(GPIOA_L3GD20_SCL) | PIN_PUPDR_PULLUP(GPIOA_L3GD20_SD0) | PIN_PUPDR_PULLUP(GPIOA_L3GD20_SDI) | PIN_PUPDR_PULLUP(GPIOA_PIN8) | PIN_PUPDR_FLOATING(GPIOA_VBUS_FS) | PIN_PUPDR_FLOATING(GPIOA_OTG_FS_ID) | PIN_PUPDR_FLOATING(GPIOA_OTG_FS_DM) | PIN_PUPDR_FLOATING(GPIOA_OTG_FS_DP) | PIN_PUPDR_FLOATING(GPIOA_SWDIO) | PIN_PUPDR_FLOATING(GPIOA_SWCLK) | PIN_PUPDR_PULLUP(GPIOA_PIN15)) -#define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_BUTTON) | PIN_ODR_HIGH(GPIOA_PIN1) | PIN_ODR_HIGH(GPIOA_PIN2) | PIN_ODR_HIGH(GPIOA_PIN3) | PIN_ODR_HIGH(GPIOA_CS43L22_LRCK) | PIN_ODR_HIGH(GPIOA_L3GD20_SCL) | PIN_ODR_HIGH(GPIOA_L3GD20_SD0) | PIN_ODR_HIGH(GPIOA_L3GD20_SDI) | PIN_ODR_HIGH(GPIOA_PIN8) | PIN_ODR_HIGH(GPIOA_VBUS_FS) | PIN_ODR_HIGH(GPIOA_OTG_FS_ID) | PIN_ODR_HIGH(GPIOA_OTG_FS_DM) | PIN_ODR_HIGH(GPIOA_OTG_FS_DP) | PIN_ODR_HIGH(GPIOA_SWDIO) | PIN_ODR_HIGH(GPIOA_SWCLK) | PIN_ODR_HIGH(GPIOA_PIN15)) -#define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_BUTTON, 0U) | PIN_AFIO_AF(GPIOA_PIN1, 0U) | PIN_AFIO_AF(GPIOA_PIN2, 0U) | PIN_AFIO_AF(GPIOA_PIN3, 0U) | PIN_AFIO_AF(GPIOA_CS43L22_LRCK, 6U) | PIN_AFIO_AF(GPIOA_L3GD20_SCL, 5U) | PIN_AFIO_AF(GPIOA_L3GD20_SD0, 5U) | PIN_AFIO_AF(GPIOA_L3GD20_SDI, 5U)) -#define VAL_GPIOA_AFRH (PIN_AFIO_AF(GPIOA_PIN8, 0U) | PIN_AFIO_AF(GPIOA_VBUS_FS, 0U) | PIN_AFIO_AF(GPIOA_OTG_FS_ID, 10U) | PIN_AFIO_AF(GPIOA_OTG_FS_DM, 10U) | PIN_AFIO_AF(GPIOA_OTG_FS_DP, 10U) | PIN_AFIO_AF(GPIOA_SWDIO, 0U) | PIN_AFIO_AF(GPIOA_SWCLK, 0U) | PIN_AFIO_AF(GPIOA_PIN15, 0U)) - -/* - * GPIOB setup: - * - * PB0 - PIN0 (input pullup). - * PB1 - PIN1 (input pullup). - * PB2 - PIN2 (input pullup). - * PB3 - SWO (alternate 0). - * PB4 - PIN4 (input pullup). - * PB5 - PIN5 (input pullup). - * PB6 - LSM303DLHC_SCL (alternate 4). - * PB7 - PIN7 (input pullup). - * PB8 - PIN8 (input pullup). - * PB9 - LSM303DLHC_SDA (alternate 4). - * PB10 - MP45DT02_CLK_IN (alternate 5). - * PB11 - PIN11 (input pullup). - * PB12 - PIN12 (input pullup). - * PB13 - PIN13 (input pullup). - * PB14 - PIN14 (input pullup). - * PB15 - PIN15 (input pullup). - */ -#define VAL_GPIOB_MODER (PIN_MODE_INPUT(GPIOB_PIN0) | PIN_MODE_INPUT(GPIOB_PIN1) | PIN_MODE_INPUT(GPIOB_PIN2) | PIN_MODE_ALTERNATE(GPIOB_SWO) | PIN_MODE_INPUT(GPIOB_PIN4) | PIN_MODE_INPUT(GPIOB_PIN5) | PIN_MODE_ALTERNATE(GPIOB_LSM303DLHC_SCL) | PIN_MODE_INPUT(GPIOB_PIN7) | PIN_MODE_INPUT(GPIOB_PIN8) | PIN_MODE_ALTERNATE(GPIOB_LSM303DLHC_SDA) | PIN_MODE_ALTERNATE(GPIOB_MP45DT02_CLK_IN) | PIN_MODE_INPUT(GPIOB_PIN11) | PIN_MODE_INPUT(GPIOB_PIN12) | PIN_MODE_INPUT(GPIOB_PIN13) | PIN_MODE_INPUT(GPIOB_PIN14) | PIN_MODE_INPUT(GPIOB_PIN15)) -#define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(GPIOB_PIN0) | PIN_OTYPE_PUSHPULL(GPIOB_PIN1) | PIN_OTYPE_PUSHPULL(GPIOB_PIN2) | PIN_OTYPE_PUSHPULL(GPIOB_SWO) | PIN_OTYPE_PUSHPULL(GPIOB_PIN4) | PIN_OTYPE_PUSHPULL(GPIOB_PIN5) | PIN_OTYPE_PUSHPULL(GPIOB_LSM303DLHC_SCL) | PIN_OTYPE_PUSHPULL(GPIOB_PIN7) | PIN_OTYPE_PUSHPULL(GPIOB_PIN8) | PIN_OTYPE_PUSHPULL(GPIOB_LSM303DLHC_SDA) | PIN_OTYPE_PUSHPULL(GPIOB_MP45DT02_CLK_IN) | PIN_OTYPE_PUSHPULL(GPIOB_PIN11) | PIN_OTYPE_PUSHPULL(GPIOB_PIN12) | PIN_OTYPE_PUSHPULL(GPIOB_PIN13) | PIN_OTYPE_PUSHPULL(GPIOB_PIN14) | PIN_OTYPE_PUSHPULL(GPIOB_PIN15)) -#define VAL_GPIOB_OSPEEDR (PIN_OSPEED_HIGH(GPIOB_PIN0) | PIN_OSPEED_HIGH(GPIOB_PIN1) | PIN_OSPEED_HIGH(GPIOB_PIN2) | PIN_OSPEED_HIGH(GPIOB_SWO) | PIN_OSPEED_HIGH(GPIOB_PIN4) | PIN_OSPEED_HIGH(GPIOB_PIN5) | PIN_OSPEED_HIGH(GPIOB_LSM303DLHC_SCL) | PIN_OSPEED_HIGH(GPIOB_PIN7) | PIN_OSPEED_HIGH(GPIOB_PIN8) | PIN_OSPEED_HIGH(GPIOB_LSM303DLHC_SDA) | PIN_OSPEED_HIGH(GPIOB_MP45DT02_CLK_IN) | PIN_OSPEED_HIGH(GPIOB_PIN11) | PIN_OSPEED_HIGH(GPIOB_PIN12) | PIN_OSPEED_HIGH(GPIOB_PIN13) | PIN_OSPEED_HIGH(GPIOB_PIN14) | PIN_OSPEED_HIGH(GPIOB_PIN15)) -#define VAL_GPIOB_PUPDR (PIN_PUPDR_PULLUP(GPIOB_PIN0) | PIN_PUPDR_PULLUP(GPIOB_PIN1) | PIN_PUPDR_PULLUP(GPIOB_PIN2) | PIN_PUPDR_PULLUP(GPIOB_SWO) | PIN_PUPDR_PULLUP(GPIOB_PIN4) | PIN_PUPDR_PULLUP(GPIOB_PIN5) | PIN_PUPDR_FLOATING(GPIOB_LSM303DLHC_SCL) | PIN_PUPDR_PULLUP(GPIOB_PIN7) | PIN_PUPDR_PULLUP(GPIOB_PIN8) | PIN_PUPDR_FLOATING(GPIOB_LSM303DLHC_SDA) | PIN_PUPDR_FLOATING(GPIOB_MP45DT02_CLK_IN) | PIN_PUPDR_PULLUP(GPIOB_PIN11) | PIN_PUPDR_PULLUP(GPIOB_PIN12) | PIN_PUPDR_PULLUP(GPIOB_PIN13) | PIN_PUPDR_PULLUP(GPIOB_PIN14) | PIN_PUPDR_PULLUP(GPIOB_PIN15)) -#define VAL_GPIOB_ODR (PIN_ODR_HIGH(GPIOB_PIN0) | PIN_ODR_HIGH(GPIOB_PIN1) | PIN_ODR_HIGH(GPIOB_PIN2) | PIN_ODR_HIGH(GPIOB_SWO) | PIN_ODR_HIGH(GPIOB_PIN4) | PIN_ODR_HIGH(GPIOB_PIN5) | PIN_ODR_HIGH(GPIOB_LSM303DLHC_SCL) | PIN_ODR_HIGH(GPIOB_PIN7) | PIN_ODR_HIGH(GPIOB_PIN8) | PIN_ODR_HIGH(GPIOB_LSM303DLHC_SDA) | PIN_ODR_HIGH(GPIOB_MP45DT02_CLK_IN) | PIN_ODR_HIGH(GPIOB_PIN11) | PIN_ODR_HIGH(GPIOB_PIN12) | PIN_ODR_HIGH(GPIOB_PIN13) | PIN_ODR_HIGH(GPIOB_PIN14) | PIN_ODR_HIGH(GPIOB_PIN15)) -#define VAL_GPIOB_AFRL (PIN_AFIO_AF(GPIOB_PIN0, 0U) | PIN_AFIO_AF(GPIOB_PIN1, 0U) | PIN_AFIO_AF(GPIOB_PIN2, 0U) | PIN_AFIO_AF(GPIOB_SWO, 0U) | PIN_AFIO_AF(GPIOB_PIN4, 0U) | PIN_AFIO_AF(GPIOB_PIN5, 0U) | PIN_AFIO_AF(GPIOB_LSM303DLHC_SCL, 4U) | PIN_AFIO_AF(GPIOB_PIN7, 0U)) -#define VAL_GPIOB_AFRH (PIN_AFIO_AF(GPIOB_PIN8, 0U) | PIN_AFIO_AF(GPIOB_LSM303DLHC_SDA, 4U) | PIN_AFIO_AF(GPIOB_MP45DT02_CLK_IN, 5U) | PIN_AFIO_AF(GPIOB_PIN11, 0U) | PIN_AFIO_AF(GPIOB_PIN12, 0U) | PIN_AFIO_AF(GPIOB_PIN13, 0U) | PIN_AFIO_AF(GPIOB_PIN14, 0U) | PIN_AFIO_AF(GPIOB_PIN15, 0U)) - -/* - * GPIOC setup: - * - * PC0 - OTG_FS_POWER_ON (output pushpull maximum). - * PC1 - PIN1 (input pullup). - * PC2 - PIN2 (input pullup). - * PC3 - CS43L22_AIN4x MP45DT02_PDM_OUT(alternate 5). - * PC4 - PIN4 (input pullup). - * PC5 - PIN5 (input pullup). - * PC6 - PIN6 (input pullup). - * PC7 - CS43L22_MCLK (alternate 6). - * PC8 - PIN8 (input pullup). - * PC9 - PIN9 (input pullup). - * PC10 - CS43L22_SCLK (alternate 6). - * PC11 - PIN11 (input pullup). - * PC12 - CS43L22_SDIN (alternate 6). - * PC13 - PIN13 (input pullup). - * PC14 - OSC32_IN (input floating). - * PC15 - OSC32_OUT (input floating). - */ -#define VAL_GPIOC_MODER (PIN_MODE_OUTPUT(GPIOC_OTG_FS_POWER_ON) | PIN_MODE_INPUT(GPIOC_PIN1) | PIN_MODE_INPUT(GPIOC_PIN2) | PIN_MODE_ALTERNATE(GPIOC_CS43L22_AIN4x) | PIN_MODE_INPUT(GPIOC_PIN4) | PIN_MODE_INPUT(GPIOC_PIN5) | PIN_MODE_INPUT(GPIOC_PIN6) | PIN_MODE_ALTERNATE(GPIOC_CS43L22_MCLK) | PIN_MODE_INPUT(GPIOC_PIN8) | PIN_MODE_INPUT(GPIOC_PIN9) | PIN_MODE_ALTERNATE(GPIOC_CS43L22_SCLK) | PIN_MODE_INPUT(GPIOC_PIN11) | PIN_MODE_ALTERNATE(GPIOC_CS43L22_SDIN) | PIN_MODE_INPUT(GPIOC_PIN13) | PIN_MODE_INPUT(GPIOC_OSC32_IN) | PIN_MODE_INPUT(GPIOC_OSC32_OUT)) -#define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(GPIOC_OTG_FS_POWER_ON) | PIN_OTYPE_PUSHPULL(GPIOC_PIN1) | PIN_OTYPE_PUSHPULL(GPIOC_PIN2) | PIN_OTYPE_PUSHPULL(GPIOC_CS43L22_AIN4x) | PIN_OTYPE_PUSHPULL(GPIOC_PIN4) | PIN_OTYPE_PUSHPULL(GPIOC_PIN5) | PIN_OTYPE_PUSHPULL(GPIOC_PIN6) | PIN_OTYPE_PUSHPULL(GPIOC_CS43L22_MCLK) | PIN_OTYPE_PUSHPULL(GPIOC_PIN8) | PIN_OTYPE_PUSHPULL(GPIOC_PIN9) | PIN_OTYPE_PUSHPULL(GPIOC_CS43L22_SCLK) | PIN_OTYPE_PUSHPULL(GPIOC_PIN11) | PIN_OTYPE_PUSHPULL(GPIOC_CS43L22_SDIN) | PIN_OTYPE_PUSHPULL(GPIOC_PIN13) | PIN_OTYPE_PUSHPULL(GPIOC_OSC32_IN) | PIN_OTYPE_PUSHPULL(GPIOC_OSC32_OUT)) -#define VAL_GPIOC_OSPEEDR (PIN_OSPEED_HIGH(GPIOC_OTG_FS_POWER_ON) | PIN_OSPEED_HIGH(GPIOC_PIN1) | PIN_OSPEED_HIGH(GPIOC_PIN2) | PIN_OSPEED_HIGH(GPIOC_CS43L22_AIN4x) | PIN_OSPEED_HIGH(GPIOC_PIN4) | PIN_OSPEED_HIGH(GPIOC_PIN5) | PIN_OSPEED_HIGH(GPIOC_PIN6) | PIN_OSPEED_HIGH(GPIOC_CS43L22_MCLK) | PIN_OSPEED_HIGH(GPIOC_PIN8) | PIN_OSPEED_HIGH(GPIOC_PIN9) | PIN_OSPEED_HIGH(GPIOC_CS43L22_SCLK) | PIN_OSPEED_HIGH(GPIOC_PIN11) | PIN_OSPEED_HIGH(GPIOC_CS43L22_SDIN) | PIN_OSPEED_HIGH(GPIOC_PIN13) | PIN_OSPEED_HIGH(GPIOC_OSC32_IN) | PIN_OSPEED_HIGH(GPIOC_OSC32_OUT)) -#define VAL_GPIOC_PUPDR (PIN_PUPDR_PULLUP(GPIOC_OTG_FS_POWER_ON) | PIN_PUPDR_PULLUP(GPIOC_PIN1) | PIN_PUPDR_PULLUP(GPIOC_PIN2) | PIN_PUPDR_FLOATING(GPIOC_CS43L22_AIN4x) | PIN_PUPDR_PULLUP(GPIOC_PIN4) | PIN_PUPDR_PULLUP(GPIOC_PIN5) | PIN_PUPDR_PULLUP(GPIOC_PIN6) | PIN_PUPDR_PULLUP(GPIOC_CS43L22_MCLK) | PIN_PUPDR_PULLUP(GPIOC_PIN8) | PIN_PUPDR_PULLUP(GPIOC_PIN9) | PIN_PUPDR_PULLUP(GPIOC_CS43L22_SCLK) | PIN_PUPDR_PULLUP(GPIOC_PIN11) | PIN_PUPDR_PULLUP(GPIOC_CS43L22_SDIN) | PIN_PUPDR_PULLUP(GPIOC_PIN13) | PIN_PUPDR_FLOATING(GPIOC_OSC32_IN) | PIN_PUPDR_FLOATING(GPIOC_OSC32_OUT)) -#define VAL_GPIOC_ODR (PIN_ODR_HIGH(GPIOC_OTG_FS_POWER_ON) | PIN_ODR_HIGH(GPIOC_PIN1) | PIN_ODR_HIGH(GPIOC_PIN2) | PIN_ODR_HIGH(GPIOC_CS43L22_AIN4x) | PIN_ODR_HIGH(GPIOC_PIN4) | PIN_ODR_HIGH(GPIOC_PIN5) | PIN_ODR_HIGH(GPIOC_PIN6) | PIN_ODR_HIGH(GPIOC_CS43L22_MCLK) | PIN_ODR_HIGH(GPIOC_PIN8) | PIN_ODR_HIGH(GPIOC_PIN9) | PIN_ODR_HIGH(GPIOC_CS43L22_SCLK) | PIN_ODR_HIGH(GPIOC_PIN11) | PIN_ODR_HIGH(GPIOC_CS43L22_SDIN) | PIN_ODR_HIGH(GPIOC_PIN13) | PIN_ODR_HIGH(GPIOC_OSC32_IN) | PIN_ODR_HIGH(GPIOC_OSC32_OUT)) -#define VAL_GPIOC_AFRL (PIN_AFIO_AF(GPIOC_OTG_FS_POWER_ON, 0U) | PIN_AFIO_AF(GPIOC_PIN1, 0U) | PIN_AFIO_AF(GPIOC_PIN2, 0U) | PIN_AFIO_AF(GPIOC_CS43L22_AIN4x, 5U) | PIN_AFIO_AF(GPIOC_PIN4, 0U) | PIN_AFIO_AF(GPIOC_PIN5, 0U) | PIN_AFIO_AF(GPIOC_PIN6, 0U) | PIN_AFIO_AF(GPIOC_CS43L22_MCLK, 6U)) -#define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_PIN8, 0U) | PIN_AFIO_AF(GPIOC_PIN9, 0U) | PIN_AFIO_AF(GPIOC_CS43L22_SCLK, 6U) | PIN_AFIO_AF(GPIOC_PIN11, 0U) | PIN_AFIO_AF(GPIOC_CS43L22_SDIN, 6U) | PIN_AFIO_AF(GPIOC_PIN13, 0U) | PIN_AFIO_AF(GPIOC_OSC32_IN, 0U) | PIN_AFIO_AF(GPIOC_OSC32_OUT, 0U)) - -/* - * GPIOD setup: - * - * PD0 - PIN0 (input pullup). - * PD1 - PIN1 (input pullup). - * PD2 - PIN2 (input pullup). - * PD3 - PIN3 (input pullup). - * PD4 - CS43L22_RESET (output pushpull maximum). - * PD5 - OverCurrent (input floating). - * PD6 - PIN6 (input pullup). - * PD7 - PIN7 (input pullup). - * PD8 - PIN8 (input pullup). - * PD9 - PIN9 (input pullup). - * PD10 - PIN10 (input pullup). - * PD11 - PIN11 (input pullup). - * PD12 - LED4 (output pushpull maximum). - * PD13 - LED3 (output pushpull maximum). - * PD14 - LED5 (output pushpull maximum). - * PD15 - LED6 (output pushpull maximum). - */ -#define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_PIN0) | PIN_MODE_INPUT(GPIOD_PIN1) | PIN_MODE_INPUT(GPIOD_PIN2) | PIN_MODE_INPUT(GPIOD_PIN3) | PIN_MODE_OUTPUT(GPIOD_CS43L22_RESET) | PIN_MODE_INPUT(GPIOD_OverCurrent) | PIN_MODE_INPUT(GPIOD_PIN6) | PIN_MODE_INPUT(GPIOD_PIN7) | PIN_MODE_INPUT(GPIOD_PIN8) | PIN_MODE_INPUT(GPIOD_PIN9) | PIN_MODE_INPUT(GPIOD_PIN10) | PIN_MODE_INPUT(GPIOD_PIN11) | PIN_MODE_OUTPUT(GPIOD_LED4) | PIN_MODE_OUTPUT(GPIOD_LED3) | PIN_MODE_OUTPUT(GPIOD_LED5) | PIN_MODE_OUTPUT(GPIOD_LED6)) -#define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) | PIN_OTYPE_PUSHPULL(GPIOD_PIN1) | PIN_OTYPE_PUSHPULL(GPIOD_PIN2) | PIN_OTYPE_PUSHPULL(GPIOD_PIN3) | PIN_OTYPE_PUSHPULL(GPIOD_CS43L22_RESET) | PIN_OTYPE_PUSHPULL(GPIOD_OverCurrent) | PIN_OTYPE_PUSHPULL(GPIOD_PIN6) | PIN_OTYPE_PUSHPULL(GPIOD_PIN7) | PIN_OTYPE_PUSHPULL(GPIOD_PIN8) | PIN_OTYPE_PUSHPULL(GPIOD_PIN9) | PIN_OTYPE_PUSHPULL(GPIOD_PIN10) | PIN_OTYPE_PUSHPULL(GPIOD_PIN11) | PIN_OTYPE_PUSHPULL(GPIOD_LED4) | PIN_OTYPE_PUSHPULL(GPIOD_LED3) | PIN_OTYPE_PUSHPULL(GPIOD_LED5) | PIN_OTYPE_PUSHPULL(GPIOD_LED6)) -#define VAL_GPIOD_OSPEEDR (PIN_OSPEED_HIGH(GPIOD_PIN0) | PIN_OSPEED_HIGH(GPIOD_PIN1) | PIN_OSPEED_HIGH(GPIOD_PIN2) | PIN_OSPEED_HIGH(GPIOD_PIN3) | PIN_OSPEED_HIGH(GPIOD_CS43L22_RESET) | PIN_OSPEED_HIGH(GPIOD_OverCurrent) | PIN_OSPEED_HIGH(GPIOD_PIN6) | PIN_OSPEED_HIGH(GPIOD_PIN7) | PIN_OSPEED_HIGH(GPIOD_PIN8) | PIN_OSPEED_HIGH(GPIOD_PIN9) | PIN_OSPEED_HIGH(GPIOD_PIN10) | PIN_OSPEED_HIGH(GPIOD_PIN11) | PIN_OSPEED_HIGH(GPIOD_LED4) | PIN_OSPEED_HIGH(GPIOD_LED3) | PIN_OSPEED_HIGH(GPIOD_LED5) | PIN_OSPEED_HIGH(GPIOD_LED6)) -#define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLUP(GPIOD_PIN0) | PIN_PUPDR_PULLUP(GPIOD_PIN1) | PIN_PUPDR_PULLUP(GPIOD_PIN2) | PIN_PUPDR_PULLUP(GPIOD_PIN3) | PIN_PUPDR_PULLUP(GPIOD_CS43L22_RESET) | PIN_PUPDR_FLOATING(GPIOD_OverCurrent) | PIN_PUPDR_PULLUP(GPIOD_PIN6) | PIN_PUPDR_PULLUP(GPIOD_PIN7) | PIN_PUPDR_PULLUP(GPIOD_PIN8) | PIN_PUPDR_PULLUP(GPIOD_PIN9) | PIN_PUPDR_PULLUP(GPIOD_PIN10) | PIN_PUPDR_PULLUP(GPIOD_PIN11) | PIN_PUPDR_FLOATING(GPIOD_LED4) | PIN_PUPDR_FLOATING(GPIOD_LED3) | PIN_PUPDR_FLOATING(GPIOD_LED5) | PIN_PUPDR_FLOATING(GPIOD_LED6)) -#define VAL_GPIOD_ODR (PIN_ODR_HIGH(GPIOD_PIN0) | PIN_ODR_HIGH(GPIOD_PIN1) | PIN_ODR_HIGH(GPIOD_PIN2) | PIN_ODR_HIGH(GPIOD_PIN3) | PIN_ODR_HIGH(GPIOD_CS43L22_RESET) | PIN_ODR_HIGH(GPIOD_OverCurrent) | PIN_ODR_HIGH(GPIOD_PIN6) | PIN_ODR_HIGH(GPIOD_PIN7) | PIN_ODR_HIGH(GPIOD_PIN8) | PIN_ODR_HIGH(GPIOD_PIN9) | PIN_ODR_HIGH(GPIOD_PIN10) | PIN_ODR_HIGH(GPIOD_PIN11) | PIN_ODR_LOW(GPIOD_LED4) | PIN_ODR_LOW(GPIOD_LED3) | PIN_ODR_LOW(GPIOD_LED5) | PIN_ODR_LOW(GPIOD_LED6)) -#define VAL_GPIOD_AFRL (PIN_AFIO_AF(GPIOD_PIN0, 0U) | PIN_AFIO_AF(GPIOD_PIN1, 0U) | PIN_AFIO_AF(GPIOD_PIN2, 0U) | PIN_AFIO_AF(GPIOD_PIN3, 0U) | PIN_AFIO_AF(GPIOD_CS43L22_RESET, 0U) | PIN_AFIO_AF(GPIOD_OverCurrent, 0U) | PIN_AFIO_AF(GPIOD_PIN6, 0U) | PIN_AFIO_AF(GPIOD_PIN7, 0U)) -#define VAL_GPIOD_AFRH (PIN_AFIO_AF(GPIOD_PIN8, 0U) | PIN_AFIO_AF(GPIOD_PIN9, 0U) | PIN_AFIO_AF(GPIOD_PIN10, 0U) | PIN_AFIO_AF(GPIOD_PIN11, 0U) | PIN_AFIO_AF(GPIOD_LED4, 0U) | PIN_AFIO_AF(GPIOD_LED3, 0U) | PIN_AFIO_AF(GPIOD_LED5, 0U) | PIN_AFIO_AF(GPIOD_LED6, 0U)) - -/* - * GPIOE setup: - * - * PE0 - L3GD20_INT1 (input pullup). - * PE1 - L3GD20_INT2 (input pullup). - * PE2 - LSM303DLHC_DRDY (input floating). - * PE3 - L3GD20_CS (output pushpull maximum). - * PE4 - LSM303DLHC_INT1 (output pushpull maximum). - * PE5 - LSM303DLHC_INT2 (output pushpull maximum). - * PE6 - PIN6 (input pullup). - * PE7 - PIN7 (input pullup). - * PE8 - PIN8 (input pullup). - * PE9 - PIN9 (input pullup). - * PE10 - PIN10 (input pullup). - * PE11 - PIN11 (input pullup). - * PE12 - PIN12 (input pullup). - * PE13 - PIN13 (input pullup). - * PE14 - PIN14 (input pullup). - * PE15 - PIN15 (input pullup). - */ -#define VAL_GPIOE_MODER (PIN_MODE_INPUT(GPIOE_L3GD20_INT1) | PIN_MODE_INPUT(GPIOE_L3GD20_INT2) | PIN_MODE_INPUT(GPIOE_LSM303DLHC_DRDY) | PIN_MODE_OUTPUT(GPIOE_L3GD20_CS) | PIN_MODE_OUTPUT(GPIOE_LSM303DLHC_INT1) | PIN_MODE_OUTPUT(GPIOE_LSM303DLHC_INT2) | PIN_MODE_INPUT(GPIOE_PIN6) | PIN_MODE_INPUT(GPIOE_PIN7) | PIN_MODE_INPUT(GPIOE_PIN8) | PIN_MODE_INPUT(GPIOE_PIN9) | PIN_MODE_INPUT(GPIOE_PIN10) | PIN_MODE_INPUT(GPIOE_PIN11) | PIN_MODE_INPUT(GPIOE_PIN12) | PIN_MODE_INPUT(GPIOE_PIN13) | PIN_MODE_INPUT(GPIOE_PIN14) | PIN_MODE_INPUT(GPIOE_PIN15)) -#define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL(GPIOE_L3GD20_INT1) | PIN_OTYPE_PUSHPULL(GPIOE_L3GD20_INT2) | PIN_OTYPE_PUSHPULL(GPIOE_LSM303DLHC_DRDY) | PIN_OTYPE_PUSHPULL(GPIOE_L3GD20_CS) | PIN_OTYPE_PUSHPULL(GPIOE_LSM303DLHC_INT1) | PIN_OTYPE_PUSHPULL(GPIOE_LSM303DLHC_INT2) | PIN_OTYPE_PUSHPULL(GPIOE_PIN6) | PIN_OTYPE_PUSHPULL(GPIOE_PIN7) | PIN_OTYPE_PUSHPULL(GPIOE_PIN8) | PIN_OTYPE_PUSHPULL(GPIOE_PIN9) | PIN_OTYPE_PUSHPULL(GPIOE_PIN10) | PIN_OTYPE_PUSHPULL(GPIOE_PIN11) | PIN_OTYPE_PUSHPULL(GPIOE_PIN12) | PIN_OTYPE_PUSHPULL(GPIOE_PIN13) | PIN_OTYPE_PUSHPULL(GPIOE_PIN14) | PIN_OTYPE_PUSHPULL(GPIOE_PIN15)) -#define VAL_GPIOE_OSPEEDR (PIN_OSPEED_HIGH(GPIOE_L3GD20_INT1) | PIN_OSPEED_HIGH(GPIOE_L3GD20_INT2) | PIN_OSPEED_HIGH(GPIOE_LSM303DLHC_DRDY) | PIN_OSPEED_HIGH(GPIOE_L3GD20_CS) | PIN_OSPEED_HIGH(GPIOE_LSM303DLHC_INT1) | PIN_OSPEED_HIGH(GPIOE_LSM303DLHC_INT2) | PIN_OSPEED_HIGH(GPIOE_PIN6) | PIN_OSPEED_HIGH(GPIOE_PIN7) | PIN_OSPEED_HIGH(GPIOE_PIN8) | PIN_OSPEED_HIGH(GPIOE_PIN9) | PIN_OSPEED_HIGH(GPIOE_PIN10) | PIN_OSPEED_HIGH(GPIOE_PIN11) | PIN_OSPEED_HIGH(GPIOE_PIN12) | PIN_OSPEED_HIGH(GPIOE_PIN13) | PIN_OSPEED_HIGH(GPIOE_PIN14) | PIN_OSPEED_HIGH(GPIOE_PIN15)) -#define VAL_GPIOE_PUPDR (PIN_PUPDR_PULLUP(GPIOE_L3GD20_INT1) | PIN_PUPDR_PULLUP(GPIOE_L3GD20_INT2) | PIN_PUPDR_FLOATING(GPIOE_LSM303DLHC_DRDY) | PIN_PUPDR_PULLUP(GPIOE_L3GD20_CS) | PIN_PUPDR_PULLUP(GPIOE_LSM303DLHC_INT1) | PIN_PUPDR_PULLUP(GPIOE_LSM303DLHC_INT2) | PIN_PUPDR_PULLUP(GPIOE_PIN6) | PIN_PUPDR_PULLUP(GPIOE_PIN7) | PIN_PUPDR_PULLUP(GPIOE_PIN8) | PIN_PUPDR_PULLUP(GPIOE_PIN9) | PIN_PUPDR_PULLUP(GPIOE_PIN10) | PIN_PUPDR_PULLUP(GPIOE_PIN11) | PIN_PUPDR_PULLUP(GPIOE_PIN12) | PIN_PUPDR_PULLUP(GPIOE_PIN13) | PIN_PUPDR_PULLUP(GPIOE_PIN14) | PIN_PUPDR_PULLUP(GPIOE_PIN15)) -#define VAL_GPIOE_ODR (PIN_ODR_HIGH(GPIOE_L3GD20_INT1) | PIN_ODR_HIGH(GPIOE_L3GD20_INT2) | PIN_ODR_HIGH(GPIOE_LSM303DLHC_DRDY) | PIN_ODR_HIGH(GPIOE_L3GD20_CS) | PIN_ODR_HIGH(GPIOE_LSM303DLHC_INT1) | PIN_ODR_HIGH(GPIOE_LSM303DLHC_INT2) | PIN_ODR_HIGH(GPIOE_PIN6) | PIN_ODR_HIGH(GPIOE_PIN7) | PIN_ODR_HIGH(GPIOE_PIN8) | PIN_ODR_HIGH(GPIOE_PIN9) | PIN_ODR_HIGH(GPIOE_PIN10) | PIN_ODR_HIGH(GPIOE_PIN11) | PIN_ODR_HIGH(GPIOE_PIN12) | PIN_ODR_HIGH(GPIOE_PIN13) | PIN_ODR_HIGH(GPIOE_PIN14) | PIN_ODR_HIGH(GPIOE_PIN15)) -#define VAL_GPIOE_AFRL (PIN_AFIO_AF(GPIOE_L3GD20_INT1, 0U) | PIN_AFIO_AF(GPIOE_L3GD20_INT2, 0U) | PIN_AFIO_AF(GPIOE_LSM303DLHC_DRDY, 0U) | PIN_AFIO_AF(GPIOE_L3GD20_CS, 0U) | PIN_AFIO_AF(GPIOE_LSM303DLHC_INT1, 0U) | PIN_AFIO_AF(GPIOE_LSM303DLHC_INT2, 0U) | PIN_AFIO_AF(GPIOE_PIN6, 0U) | PIN_AFIO_AF(GPIOE_PIN7, 0U)) -#define VAL_GPIOE_AFRH (PIN_AFIO_AF(GPIOE_PIN8, 0U) | PIN_AFIO_AF(GPIOE_PIN9, 0U) | PIN_AFIO_AF(GPIOE_PIN10, 0U) | PIN_AFIO_AF(GPIOE_PIN11, 0U) | PIN_AFIO_AF(GPIOE_PIN12, 0U) | PIN_AFIO_AF(GPIOE_PIN13, 0U) | PIN_AFIO_AF(GPIOE_PIN14, 0U) | PIN_AFIO_AF(GPIOE_PIN15, 0U)) - -/* - * GPIOF setup: - * - * PF0 - PIN0 (input pullup). - * PF1 - PIN1 (input pullup). - * PF2 - PIN2 (input pullup). - * PF3 - PIN3 (input pullup). - * PF4 - PIN4 (input pullup). - * PF5 - PIN5 (input pullup). - * PF6 - PIN6 (input pullup). - * PF7 - PIN7 (input pullup). - * PF8 - PIN8 (input pullup). - * PF9 - PIN9 (input pullup). - * PF10 - PIN10 (input pullup). - * PF11 - PIN11 (input pullup). - * PF12 - PIN12 (input pullup). - * PF13 - PIN13 (input pullup). - * PF14 - PIN14 (input pullup). - * PF15 - PIN15 (input pullup). - */ -#define VAL_GPIOF_MODER (PIN_MODE_INPUT(GPIOF_PIN0) | PIN_MODE_INPUT(GPIOF_PIN1) | PIN_MODE_INPUT(GPIOF_PIN2) | PIN_MODE_INPUT(GPIOF_PIN3) | PIN_MODE_INPUT(GPIOF_PIN4) | PIN_MODE_INPUT(GPIOF_PIN5) | PIN_MODE_INPUT(GPIOF_PIN6) | PIN_MODE_INPUT(GPIOF_PIN7) | PIN_MODE_INPUT(GPIOF_PIN8) | PIN_MODE_INPUT(GPIOF_PIN9) | PIN_MODE_INPUT(GPIOF_PIN10) | PIN_MODE_INPUT(GPIOF_PIN11) | PIN_MODE_INPUT(GPIOF_PIN12) | PIN_MODE_INPUT(GPIOF_PIN13) | PIN_MODE_INPUT(GPIOF_PIN14) | PIN_MODE_INPUT(GPIOF_PIN15)) -#define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL(GPIOF_PIN0) | PIN_OTYPE_PUSHPULL(GPIOF_PIN1) | PIN_OTYPE_PUSHPULL(GPIOF_PIN2) | PIN_OTYPE_PUSHPULL(GPIOF_PIN3) | PIN_OTYPE_PUSHPULL(GPIOF_PIN4) | PIN_OTYPE_PUSHPULL(GPIOF_PIN5) | PIN_OTYPE_PUSHPULL(GPIOF_PIN6) | PIN_OTYPE_PUSHPULL(GPIOF_PIN7) | PIN_OTYPE_PUSHPULL(GPIOF_PIN8) | PIN_OTYPE_PUSHPULL(GPIOF_PIN9) | PIN_OTYPE_PUSHPULL(GPIOF_PIN10) | PIN_OTYPE_PUSHPULL(GPIOF_PIN11) | PIN_OTYPE_PUSHPULL(GPIOF_PIN12) | PIN_OTYPE_PUSHPULL(GPIOF_PIN13) | PIN_OTYPE_PUSHPULL(GPIOF_PIN14) | PIN_OTYPE_PUSHPULL(GPIOF_PIN15)) -#define VAL_GPIOF_OSPEEDR (PIN_OSPEED_HIGH(GPIOF_PIN0) | PIN_OSPEED_HIGH(GPIOF_PIN1) | PIN_OSPEED_HIGH(GPIOF_PIN2) | PIN_OSPEED_HIGH(GPIOF_PIN3) | PIN_OSPEED_HIGH(GPIOF_PIN4) | PIN_OSPEED_HIGH(GPIOF_PIN5) | PIN_OSPEED_HIGH(GPIOF_PIN6) | PIN_OSPEED_HIGH(GPIOF_PIN7) | PIN_OSPEED_HIGH(GPIOF_PIN8) | PIN_OSPEED_HIGH(GPIOF_PIN9) | PIN_OSPEED_HIGH(GPIOF_PIN10) | PIN_OSPEED_HIGH(GPIOF_PIN11) | PIN_OSPEED_HIGH(GPIOF_PIN12) | PIN_OSPEED_HIGH(GPIOF_PIN13) | PIN_OSPEED_HIGH(GPIOF_PIN14) | PIN_OSPEED_HIGH(GPIOF_PIN15)) -#define VAL_GPIOF_PUPDR (PIN_PUPDR_PULLUP(GPIOF_PIN0) | PIN_PUPDR_PULLUP(GPIOF_PIN1) | PIN_PUPDR_PULLUP(GPIOF_PIN2) | PIN_PUPDR_PULLUP(GPIOF_PIN3) | PIN_PUPDR_PULLUP(GPIOF_PIN4) | PIN_PUPDR_PULLUP(GPIOF_PIN5) | PIN_PUPDR_PULLUP(GPIOF_PIN6) | PIN_PUPDR_PULLUP(GPIOF_PIN7) | PIN_PUPDR_PULLUP(GPIOF_PIN8) | PIN_PUPDR_PULLUP(GPIOF_PIN9) | PIN_PUPDR_PULLUP(GPIOF_PIN10) | PIN_PUPDR_PULLUP(GPIOF_PIN11) | PIN_PUPDR_PULLUP(GPIOF_PIN12) | PIN_PUPDR_PULLUP(GPIOF_PIN13) | PIN_PUPDR_PULLUP(GPIOF_PIN14) | PIN_PUPDR_PULLUP(GPIOF_PIN15)) -#define VAL_GPIOF_ODR (PIN_ODR_HIGH(GPIOF_PIN0) | PIN_ODR_HIGH(GPIOF_PIN1) | PIN_ODR_HIGH(GPIOF_PIN2) | PIN_ODR_HIGH(GPIOF_PIN3) | PIN_ODR_HIGH(GPIOF_PIN4) | PIN_ODR_HIGH(GPIOF_PIN5) | PIN_ODR_HIGH(GPIOF_PIN6) | PIN_ODR_HIGH(GPIOF_PIN7) | PIN_ODR_HIGH(GPIOF_PIN8) | PIN_ODR_HIGH(GPIOF_PIN9) | PIN_ODR_HIGH(GPIOF_PIN10) | PIN_ODR_HIGH(GPIOF_PIN11) | PIN_ODR_HIGH(GPIOF_PIN12) | PIN_ODR_HIGH(GPIOF_PIN13) | PIN_ODR_HIGH(GPIOF_PIN14) | PIN_ODR_HIGH(GPIOF_PIN15)) -#define VAL_GPIOF_AFRL (PIN_AFIO_AF(GPIOF_PIN0, 0U) | PIN_AFIO_AF(GPIOF_PIN1, 0U) | PIN_AFIO_AF(GPIOF_PIN2, 0U) | PIN_AFIO_AF(GPIOF_PIN3, 0U) | PIN_AFIO_AF(GPIOF_PIN4, 0U) | PIN_AFIO_AF(GPIOF_PIN5, 0U) | PIN_AFIO_AF(GPIOF_PIN6, 0U) | PIN_AFIO_AF(GPIOF_PIN7, 0U)) -#define VAL_GPIOF_AFRH (PIN_AFIO_AF(GPIOF_PIN8, 0U) | PIN_AFIO_AF(GPIOF_PIN9, 0U) | PIN_AFIO_AF(GPIOF_PIN10, 0U) | PIN_AFIO_AF(GPIOF_PIN11, 0U) | PIN_AFIO_AF(GPIOF_PIN12, 0U) | PIN_AFIO_AF(GPIOF_PIN13, 0U) | PIN_AFIO_AF(GPIOF_PIN14, 0U) | PIN_AFIO_AF(GPIOF_PIN15, 0U)) - -/* - * GPIOG setup: - * - * PG0 - PIN0 (input pullup). - * PG1 - PIN1 (input pullup). - * PG2 - PIN2 (input pullup). - * PG3 - PIN3 (input pullup). - * PG4 - PIN4 (input pullup). - * PG5 - PIN5 (input pullup). - * PG6 - PIN6 (input pullup). - * PG7 - PIN7 (input pullup). - * PG8 - PIN8 (input pullup). - * PG9 - PIN9 (input pullup). - * PG10 - PIN10 (input pullup). - * PG11 - PIN11 (input pullup). - * PG12 - PIN12 (input pullup). - * PG13 - PIN13 (input pullup). - * PG14 - PIN14 (input pullup). - * PG15 - PIN15 (input pullup). - */ -#define VAL_GPIOG_MODER (PIN_MODE_INPUT(GPIOG_PIN0) | PIN_MODE_INPUT(GPIOG_PIN1) | PIN_MODE_INPUT(GPIOG_PIN2) | PIN_MODE_INPUT(GPIOG_PIN3) | PIN_MODE_INPUT(GPIOG_PIN4) | PIN_MODE_INPUT(GPIOG_PIN5) | PIN_MODE_INPUT(GPIOG_PIN6) | PIN_MODE_INPUT(GPIOG_PIN7) | PIN_MODE_INPUT(GPIOG_PIN8) | PIN_MODE_INPUT(GPIOG_PIN9) | PIN_MODE_INPUT(GPIOG_PIN10) | PIN_MODE_INPUT(GPIOG_PIN11) | PIN_MODE_INPUT(GPIOG_PIN12) | PIN_MODE_INPUT(GPIOG_PIN13) | PIN_MODE_INPUT(GPIOG_PIN14) | PIN_MODE_INPUT(GPIOG_PIN15)) -#define VAL_GPIOG_OTYPER (PIN_OTYPE_PUSHPULL(GPIOG_PIN0) | PIN_OTYPE_PUSHPULL(GPIOG_PIN1) | PIN_OTYPE_PUSHPULL(GPIOG_PIN2) | PIN_OTYPE_PUSHPULL(GPIOG_PIN3) | PIN_OTYPE_PUSHPULL(GPIOG_PIN4) | PIN_OTYPE_PUSHPULL(GPIOG_PIN5) | PIN_OTYPE_PUSHPULL(GPIOG_PIN6) | PIN_OTYPE_PUSHPULL(GPIOG_PIN7) | PIN_OTYPE_PUSHPULL(GPIOG_PIN8) | PIN_OTYPE_PUSHPULL(GPIOG_PIN9) | PIN_OTYPE_PUSHPULL(GPIOG_PIN10) | PIN_OTYPE_PUSHPULL(GPIOG_PIN11) | PIN_OTYPE_PUSHPULL(GPIOG_PIN12) | PIN_OTYPE_PUSHPULL(GPIOG_PIN13) | PIN_OTYPE_PUSHPULL(GPIOG_PIN14) | PIN_OTYPE_PUSHPULL(GPIOG_PIN15)) -#define VAL_GPIOG_OSPEEDR (PIN_OSPEED_HIGH(GPIOG_PIN0) | PIN_OSPEED_HIGH(GPIOG_PIN1) | PIN_OSPEED_HIGH(GPIOG_PIN2) | PIN_OSPEED_HIGH(GPIOG_PIN3) | PIN_OSPEED_HIGH(GPIOG_PIN4) | PIN_OSPEED_HIGH(GPIOG_PIN5) | PIN_OSPEED_HIGH(GPIOG_PIN6) | PIN_OSPEED_HIGH(GPIOG_PIN7) | PIN_OSPEED_HIGH(GPIOG_PIN8) | PIN_OSPEED_HIGH(GPIOG_PIN9) | PIN_OSPEED_HIGH(GPIOG_PIN10) | PIN_OSPEED_HIGH(GPIOG_PIN11) | PIN_OSPEED_HIGH(GPIOG_PIN12) | PIN_OSPEED_HIGH(GPIOG_PIN13) | PIN_OSPEED_HIGH(GPIOG_PIN14) | PIN_OSPEED_HIGH(GPIOG_PIN15)) -#define VAL_GPIOG_PUPDR (PIN_PUPDR_PULLUP(GPIOG_PIN0) | PIN_PUPDR_PULLUP(GPIOG_PIN1) | PIN_PUPDR_PULLUP(GPIOG_PIN2) | PIN_PUPDR_PULLUP(GPIOG_PIN3) | PIN_PUPDR_PULLUP(GPIOG_PIN4) | PIN_PUPDR_PULLUP(GPIOG_PIN5) | PIN_PUPDR_PULLUP(GPIOG_PIN6) | PIN_PUPDR_PULLUP(GPIOG_PIN7) | PIN_PUPDR_PULLUP(GPIOG_PIN8) | PIN_PUPDR_PULLUP(GPIOG_PIN9) | PIN_PUPDR_PULLUP(GPIOG_PIN10) | PIN_PUPDR_PULLUP(GPIOG_PIN11) | PIN_PUPDR_PULLUP(GPIOG_PIN12) | PIN_PUPDR_PULLUP(GPIOG_PIN13) | PIN_PUPDR_PULLUP(GPIOG_PIN14) | PIN_PUPDR_PULLUP(GPIOG_PIN15)) -#define VAL_GPIOG_ODR (PIN_ODR_HIGH(GPIOG_PIN0) | PIN_ODR_HIGH(GPIOG_PIN1) | PIN_ODR_HIGH(GPIOG_PIN2) | PIN_ODR_HIGH(GPIOG_PIN3) | PIN_ODR_HIGH(GPIOG_PIN4) | PIN_ODR_HIGH(GPIOG_PIN5) | PIN_ODR_HIGH(GPIOG_PIN6) | PIN_ODR_HIGH(GPIOG_PIN7) | PIN_ODR_HIGH(GPIOG_PIN8) | PIN_ODR_HIGH(GPIOG_PIN9) | PIN_ODR_HIGH(GPIOG_PIN10) | PIN_ODR_HIGH(GPIOG_PIN11) | PIN_ODR_HIGH(GPIOG_PIN12) | PIN_ODR_HIGH(GPIOG_PIN13) | PIN_ODR_HIGH(GPIOG_PIN14) | PIN_ODR_HIGH(GPIOG_PIN15)) -#define VAL_GPIOG_AFRL (PIN_AFIO_AF(GPIOG_PIN0, 0U) | PIN_AFIO_AF(GPIOG_PIN1, 0U) | PIN_AFIO_AF(GPIOG_PIN2, 0U) | PIN_AFIO_AF(GPIOG_PIN3, 0U) | PIN_AFIO_AF(GPIOG_PIN4, 0U) | PIN_AFIO_AF(GPIOG_PIN5, 0U) | PIN_AFIO_AF(GPIOG_PIN6, 0U) | PIN_AFIO_AF(GPIOG_PIN7, 0U)) -#define VAL_GPIOG_AFRH (PIN_AFIO_AF(GPIOG_PIN8, 0U) | PIN_AFIO_AF(GPIOG_PIN9, 0U) | PIN_AFIO_AF(GPIOG_PIN10, 0U) | PIN_AFIO_AF(GPIOG_PIN11, 0U) | PIN_AFIO_AF(GPIOG_PIN12, 0U) | PIN_AFIO_AF(GPIOG_PIN13, 0U) | PIN_AFIO_AF(GPIOG_PIN14, 0U) | PIN_AFIO_AF(GPIOG_PIN15, 0U)) - -/* - * GPIOH setup: - * - * PH0 - OSC_IN (input floating). - * PH1 - OSC_OUT (input floating). - * PH2 - PIN2 (input pullup). - * PH3 - PIN3 (input pullup). - * PH4 - PIN4 (input pullup). - * PH5 - PIN5 (input pullup). - * PH6 - PIN6 (input pullup). - * PH7 - PIN7 (input pullup). - * PH8 - PIN8 (input pullup). - * PH9 - PIN9 (input pullup). - * PH10 - PIN10 (input pullup). - * PH11 - PIN11 (input pullup). - * PH12 - PIN12 (input pullup). - * PH13 - PIN13 (input pullup). - * PH14 - PIN14 (input pullup). - * PH15 - PIN15 (input pullup). - */ -#define VAL_GPIOH_MODER (PIN_MODE_INPUT(GPIOH_OSC_IN) | PIN_MODE_INPUT(GPIOH_OSC_OUT) | PIN_MODE_INPUT(GPIOH_PIN2) | PIN_MODE_INPUT(GPIOH_PIN3) | PIN_MODE_INPUT(GPIOH_PIN4) | PIN_MODE_INPUT(GPIOH_PIN5) | PIN_MODE_INPUT(GPIOH_PIN6) | PIN_MODE_INPUT(GPIOH_PIN7) | PIN_MODE_INPUT(GPIOH_PIN8) | PIN_MODE_INPUT(GPIOH_PIN9) | PIN_MODE_INPUT(GPIOH_PIN10) | PIN_MODE_INPUT(GPIOH_PIN11) | PIN_MODE_INPUT(GPIOH_PIN12) | PIN_MODE_INPUT(GPIOH_PIN13) | PIN_MODE_INPUT(GPIOH_PIN14) | PIN_MODE_INPUT(GPIOH_PIN15)) -#define VAL_GPIOH_OTYPER (PIN_OTYPE_PUSHPULL(GPIOH_OSC_IN) | PIN_OTYPE_PUSHPULL(GPIOH_OSC_OUT) | PIN_OTYPE_PUSHPULL(GPIOH_PIN2) | PIN_OTYPE_PUSHPULL(GPIOH_PIN3) | PIN_OTYPE_PUSHPULL(GPIOH_PIN4) | PIN_OTYPE_PUSHPULL(GPIOH_PIN5) | PIN_OTYPE_PUSHPULL(GPIOH_PIN6) | PIN_OTYPE_PUSHPULL(GPIOH_PIN7) | PIN_OTYPE_PUSHPULL(GPIOH_PIN8) | PIN_OTYPE_PUSHPULL(GPIOH_PIN9) | PIN_OTYPE_PUSHPULL(GPIOH_PIN10) | PIN_OTYPE_PUSHPULL(GPIOH_PIN11) | PIN_OTYPE_PUSHPULL(GPIOH_PIN12) | PIN_OTYPE_PUSHPULL(GPIOH_PIN13) | PIN_OTYPE_PUSHPULL(GPIOH_PIN14) | PIN_OTYPE_PUSHPULL(GPIOH_PIN15)) -#define VAL_GPIOH_OSPEEDR (PIN_OSPEED_HIGH(GPIOH_OSC_IN) | PIN_OSPEED_HIGH(GPIOH_OSC_OUT) | PIN_OSPEED_HIGH(GPIOH_PIN2) | PIN_OSPEED_HIGH(GPIOH_PIN3) | PIN_OSPEED_HIGH(GPIOH_PIN4) | PIN_OSPEED_HIGH(GPIOH_PIN5) | PIN_OSPEED_HIGH(GPIOH_PIN6) | PIN_OSPEED_HIGH(GPIOH_PIN7) | PIN_OSPEED_HIGH(GPIOH_PIN8) | PIN_OSPEED_HIGH(GPIOH_PIN9) | PIN_OSPEED_HIGH(GPIOH_PIN10) | PIN_OSPEED_HIGH(GPIOH_PIN11) | PIN_OSPEED_HIGH(GPIOH_PIN12) | PIN_OSPEED_HIGH(GPIOH_PIN13) | PIN_OSPEED_HIGH(GPIOH_PIN14) | PIN_OSPEED_HIGH(GPIOH_PIN15)) -#define VAL_GPIOH_PUPDR (PIN_PUPDR_FLOATING(GPIOH_OSC_IN) | PIN_PUPDR_FLOATING(GPIOH_OSC_OUT) | PIN_PUPDR_PULLUP(GPIOH_PIN2) | PIN_PUPDR_PULLUP(GPIOH_PIN3) | PIN_PUPDR_PULLUP(GPIOH_PIN4) | PIN_PUPDR_PULLUP(GPIOH_PIN5) | PIN_PUPDR_PULLUP(GPIOH_PIN6) | PIN_PUPDR_PULLUP(GPIOH_PIN7) | PIN_PUPDR_PULLUP(GPIOH_PIN8) | PIN_PUPDR_PULLUP(GPIOH_PIN9) | PIN_PUPDR_PULLUP(GPIOH_PIN10) | PIN_PUPDR_PULLUP(GPIOH_PIN11) | PIN_PUPDR_PULLUP(GPIOH_PIN12) | PIN_PUPDR_PULLUP(GPIOH_PIN13) | PIN_PUPDR_PULLUP(GPIOH_PIN14) | PIN_PUPDR_PULLUP(GPIOH_PIN15)) -#define VAL_GPIOH_ODR (PIN_ODR_HIGH(GPIOH_OSC_IN) | PIN_ODR_HIGH(GPIOH_OSC_OUT) | PIN_ODR_HIGH(GPIOH_PIN2) | PIN_ODR_HIGH(GPIOH_PIN3) | PIN_ODR_HIGH(GPIOH_PIN4) | PIN_ODR_HIGH(GPIOH_PIN5) | PIN_ODR_HIGH(GPIOH_PIN6) | PIN_ODR_HIGH(GPIOH_PIN7) | PIN_ODR_HIGH(GPIOH_PIN8) | PIN_ODR_HIGH(GPIOH_PIN9) | PIN_ODR_HIGH(GPIOH_PIN10) | PIN_ODR_HIGH(GPIOH_PIN11) | PIN_ODR_HIGH(GPIOH_PIN12) | PIN_ODR_HIGH(GPIOH_PIN13) | PIN_ODR_HIGH(GPIOH_PIN14) | PIN_ODR_HIGH(GPIOH_PIN15)) -#define VAL_GPIOH_AFRL (PIN_AFIO_AF(GPIOH_OSC_IN, 0U) | PIN_AFIO_AF(GPIOH_OSC_OUT, 0U) | PIN_AFIO_AF(GPIOH_PIN2, 0U) | PIN_AFIO_AF(GPIOH_PIN3, 0U) | PIN_AFIO_AF(GPIOH_PIN4, 0U) | PIN_AFIO_AF(GPIOH_PIN5, 0U) | PIN_AFIO_AF(GPIOH_PIN6, 0U) | PIN_AFIO_AF(GPIOH_PIN7, 0U)) -#define VAL_GPIOH_AFRH (PIN_AFIO_AF(GPIOH_PIN8, 0U) | PIN_AFIO_AF(GPIOH_PIN9, 0U) | PIN_AFIO_AF(GPIOH_PIN10, 0U) | PIN_AFIO_AF(GPIOH_PIN11, 0U) | PIN_AFIO_AF(GPIOH_PIN12, 0U) | PIN_AFIO_AF(GPIOH_PIN13, 0U) | PIN_AFIO_AF(GPIOH_PIN14, 0U) | PIN_AFIO_AF(GPIOH_PIN15, 0U)) - -/* - * GPIOI setup: - * - * PI0 - PIN0 (input pullup). - * PI1 - PIN1 (input pullup). - * PI2 - PIN2 (input pullup). - * PI3 - PIN3 (input pullup). - * PI4 - PIN4 (input pullup). - * PI5 - PIN5 (input pullup). - * PI6 - PIN6 (input pullup). - * PI7 - PIN7 (input pullup). - * PI8 - PIN8 (input pullup). - * PI9 - PIN9 (input pullup). - * PI10 - PIN10 (input pullup). - * PI11 - PIN11 (input pullup). - * PI12 - PIN12 (input pullup). - * PI13 - PIN13 (input pullup). - * PI14 - PIN14 (input pullup). - * PI15 - PIN15 (input pullup). - */ -#define VAL_GPIOI_MODER (PIN_MODE_INPUT(GPIOI_PIN0) | PIN_MODE_INPUT(GPIOI_PIN1) | PIN_MODE_INPUT(GPIOI_PIN2) | PIN_MODE_INPUT(GPIOI_PIN3) | PIN_MODE_INPUT(GPIOI_PIN4) | PIN_MODE_INPUT(GPIOI_PIN5) | PIN_MODE_INPUT(GPIOI_PIN6) | PIN_MODE_INPUT(GPIOI_PIN7) | PIN_MODE_INPUT(GPIOI_PIN8) | PIN_MODE_INPUT(GPIOI_PIN9) | PIN_MODE_INPUT(GPIOI_PIN10) | PIN_MODE_INPUT(GPIOI_PIN11) | PIN_MODE_INPUT(GPIOI_PIN12) | PIN_MODE_INPUT(GPIOI_PIN13) | PIN_MODE_INPUT(GPIOI_PIN14) | PIN_MODE_INPUT(GPIOI_PIN15)) -#define VAL_GPIOI_OTYPER (PIN_OTYPE_PUSHPULL(GPIOI_PIN0) | PIN_OTYPE_PUSHPULL(GPIOI_PIN1) | PIN_OTYPE_PUSHPULL(GPIOI_PIN2) | PIN_OTYPE_PUSHPULL(GPIOI_PIN3) | PIN_OTYPE_PUSHPULL(GPIOI_PIN4) | PIN_OTYPE_PUSHPULL(GPIOI_PIN5) | PIN_OTYPE_PUSHPULL(GPIOI_PIN6) | PIN_OTYPE_PUSHPULL(GPIOI_PIN7) | PIN_OTYPE_PUSHPULL(GPIOI_PIN8) | PIN_OTYPE_PUSHPULL(GPIOI_PIN9) | PIN_OTYPE_PUSHPULL(GPIOI_PIN10) | PIN_OTYPE_PUSHPULL(GPIOI_PIN11) | PIN_OTYPE_PUSHPULL(GPIOI_PIN12) | PIN_OTYPE_PUSHPULL(GPIOI_PIN13) | PIN_OTYPE_PUSHPULL(GPIOI_PIN14) | PIN_OTYPE_PUSHPULL(GPIOI_PIN15)) -#define VAL_GPIOI_OSPEEDR (PIN_OSPEED_HIGH(GPIOI_PIN0) | PIN_OSPEED_HIGH(GPIOI_PIN1) | PIN_OSPEED_HIGH(GPIOI_PIN2) | PIN_OSPEED_HIGH(GPIOI_PIN3) | PIN_OSPEED_HIGH(GPIOI_PIN4) | PIN_OSPEED_HIGH(GPIOI_PIN5) | PIN_OSPEED_HIGH(GPIOI_PIN6) | PIN_OSPEED_HIGH(GPIOI_PIN7) | PIN_OSPEED_HIGH(GPIOI_PIN8) | PIN_OSPEED_HIGH(GPIOI_PIN9) | PIN_OSPEED_HIGH(GPIOI_PIN10) | PIN_OSPEED_HIGH(GPIOI_PIN11) | PIN_OSPEED_HIGH(GPIOI_PIN12) | PIN_OSPEED_HIGH(GPIOI_PIN13) | PIN_OSPEED_HIGH(GPIOI_PIN14) | PIN_OSPEED_HIGH(GPIOI_PIN15)) -#define VAL_GPIOI_PUPDR (PIN_PUPDR_PULLUP(GPIOI_PIN0) | PIN_PUPDR_PULLUP(GPIOI_PIN1) | PIN_PUPDR_PULLUP(GPIOI_PIN2) | PIN_PUPDR_PULLUP(GPIOI_PIN3) | PIN_PUPDR_PULLUP(GPIOI_PIN4) | PIN_PUPDR_PULLUP(GPIOI_PIN5) | PIN_PUPDR_PULLUP(GPIOI_PIN6) | PIN_PUPDR_PULLUP(GPIOI_PIN7) | PIN_PUPDR_PULLUP(GPIOI_PIN8) | PIN_PUPDR_PULLUP(GPIOI_PIN9) | PIN_PUPDR_PULLUP(GPIOI_PIN10) | PIN_PUPDR_PULLUP(GPIOI_PIN11) | PIN_PUPDR_PULLUP(GPIOI_PIN12) | PIN_PUPDR_PULLUP(GPIOI_PIN13) | PIN_PUPDR_PULLUP(GPIOI_PIN14) | PIN_PUPDR_PULLUP(GPIOI_PIN15)) -#define VAL_GPIOI_ODR (PIN_ODR_HIGH(GPIOI_PIN0) | PIN_ODR_HIGH(GPIOI_PIN1) | PIN_ODR_HIGH(GPIOI_PIN2) | PIN_ODR_HIGH(GPIOI_PIN3) | PIN_ODR_HIGH(GPIOI_PIN4) | PIN_ODR_HIGH(GPIOI_PIN5) | PIN_ODR_HIGH(GPIOI_PIN6) | PIN_ODR_HIGH(GPIOI_PIN7) | PIN_ODR_HIGH(GPIOI_PIN8) | PIN_ODR_HIGH(GPIOI_PIN9) | PIN_ODR_HIGH(GPIOI_PIN10) | PIN_ODR_HIGH(GPIOI_PIN11) | PIN_ODR_HIGH(GPIOI_PIN12) | PIN_ODR_HIGH(GPIOI_PIN13) | PIN_ODR_HIGH(GPIOI_PIN14) | PIN_ODR_HIGH(GPIOI_PIN15)) -#define VAL_GPIOI_AFRL (PIN_AFIO_AF(GPIOI_PIN0, 0U) | PIN_AFIO_AF(GPIOI_PIN1, 0U) | PIN_AFIO_AF(GPIOI_PIN2, 0U) | PIN_AFIO_AF(GPIOI_PIN3, 0U) | PIN_AFIO_AF(GPIOI_PIN4, 0U) | PIN_AFIO_AF(GPIOI_PIN5, 0U) | PIN_AFIO_AF(GPIOI_PIN6, 0U) | PIN_AFIO_AF(GPIOI_PIN7, 0U)) -#define VAL_GPIOI_AFRH (PIN_AFIO_AF(GPIOI_PIN8, 0U) | PIN_AFIO_AF(GPIOI_PIN9, 0U) | PIN_AFIO_AF(GPIOI_PIN10, 0U) | PIN_AFIO_AF(GPIOI_PIN11, 0U) | PIN_AFIO_AF(GPIOI_PIN12, 0U) | PIN_AFIO_AF(GPIOI_PIN13, 0U) | PIN_AFIO_AF(GPIOI_PIN14, 0U) | PIN_AFIO_AF(GPIOI_PIN15, 0U)) - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#if !defined(_FROM_ASM_) -# ifdef __cplusplus -extern "C" { -# endif -void boardInit(void); -# ifdef __cplusplus -} -# endif -#endif /* _FROM_ASM_ */ - -#endif /* BOARD_H */ diff --git a/drivers/boards/BLACKPILL_STM32_F401/cfg/board.chcfg b/drivers/boards/BLACKPILL_STM32_F401/cfg/board.chcfg deleted file mode 100644 index 7559ceb938f5..000000000000 --- a/drivers/boards/BLACKPILL_STM32_F401/cfg/board.chcfg +++ /dev/null @@ -1,1193 +0,0 @@ - - - - - resources/gencfg/processors/boards/stm32f4xx/templates - .. - 5.0.x - - STMicroelectronics STM32F401C-Discovery - ST_STM32F401C_DISCOVERY - - STM32F401xC - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/drivers/boards/BLACKPILL_STM32_F401/cfg/board.fmpp b/drivers/boards/BLACKPILL_STM32_F401/cfg/board.fmpp deleted file mode 100644 index 41754c1414a9..000000000000 --- a/drivers/boards/BLACKPILL_STM32_F401/cfg/board.fmpp +++ /dev/null @@ -1,15 +0,0 @@ -sourceRoot: ../../../../../tools/ftl/processors/boards/stm32f4xx/templates -outputRoot: .. -dataRoot: . - -freemarkerLinks: { - lib: ../../../../../tools/ftl/libs -} - -data : { - doc1:xml ( - board.chcfg - { - } - ) -} diff --git a/drivers/boards/BLACKPILL_STM32_F411/board.c b/drivers/boards/BLACKPILL_STM32_F411/board.c deleted file mode 100644 index 330e06c8aa8e..000000000000 --- a/drivers/boards/BLACKPILL_STM32_F411/board.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/* - * This file has been automatically generated using ChibiStudio board - * generator plugin. Do not edit manually. - */ - -#include "hal.h" -#include "stm32_gpio.h" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables and types. */ -/*===========================================================================*/ - -/** - * @brief Type of STM32 GPIO port setup. - */ -typedef struct { - uint32_t moder; - uint32_t otyper; - uint32_t ospeedr; - uint32_t pupdr; - uint32_t odr; - uint32_t afrl; - uint32_t afrh; -} gpio_setup_t; - -/** - * @brief Type of STM32 GPIO initialization data. - */ -typedef struct { -#if STM32_HAS_GPIOA || defined(__DOXYGEN__) - gpio_setup_t PAData; -#endif -#if STM32_HAS_GPIOB || defined(__DOXYGEN__) - gpio_setup_t PBData; -#endif -#if STM32_HAS_GPIOC || defined(__DOXYGEN__) - gpio_setup_t PCData; -#endif -#if STM32_HAS_GPIOD || defined(__DOXYGEN__) - gpio_setup_t PDData; -#endif -#if STM32_HAS_GPIOE || defined(__DOXYGEN__) - gpio_setup_t PEData; -#endif -#if STM32_HAS_GPIOF || defined(__DOXYGEN__) - gpio_setup_t PFData; -#endif -#if STM32_HAS_GPIOG || defined(__DOXYGEN__) - gpio_setup_t PGData; -#endif -#if STM32_HAS_GPIOH || defined(__DOXYGEN__) - gpio_setup_t PHData; -#endif -#if STM32_HAS_GPIOI || defined(__DOXYGEN__) - gpio_setup_t PIData; -#endif -#if STM32_HAS_GPIOJ || defined(__DOXYGEN__) - gpio_setup_t PJData; -#endif -#if STM32_HAS_GPIOK || defined(__DOXYGEN__) - gpio_setup_t PKData; -#endif -} gpio_config_t; - -/** - * @brief STM32 GPIO static initialization data. - */ -static const gpio_config_t gpio_default_config = { -#if STM32_HAS_GPIOA - {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR, VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH}, -#endif -#if STM32_HAS_GPIOB - {VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR, VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH}, -#endif -#if STM32_HAS_GPIOC - {VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR, VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH}, -#endif -#if STM32_HAS_GPIOD - {VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR, VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH}, -#endif -#if STM32_HAS_GPIOE - {VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR, VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH}, -#endif -#if STM32_HAS_GPIOF - {VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR, VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH}, -#endif -#if STM32_HAS_GPIOG - {VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR, VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH}, -#endif -#if STM32_HAS_GPIOH - {VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR, VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH}, -#endif -#if STM32_HAS_GPIOI - {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR, VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}, -#endif -#if STM32_HAS_GPIOJ - {VAL_GPIOJ_MODER, VAL_GPIOJ_OTYPER, VAL_GPIOJ_OSPEEDR, VAL_GPIOJ_PUPDR, VAL_GPIOJ_ODR, VAL_GPIOJ_AFRL, VAL_GPIOJ_AFRH}, -#endif -#if STM32_HAS_GPIOK - {VAL_GPIOK_MODER, VAL_GPIOK_OTYPER, VAL_GPIOK_OSPEEDR, VAL_GPIOK_PUPDR, VAL_GPIOK_ODR, VAL_GPIOK_AFRL, VAL_GPIOK_AFRH} -#endif -}; - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config) { - gpiop->OTYPER = config->otyper; - gpiop->OSPEEDR = config->ospeedr; - gpiop->PUPDR = config->pupdr; - gpiop->ODR = config->odr; - gpiop->AFRL = config->afrl; - gpiop->AFRH = config->afrh; - gpiop->MODER = config->moder; -} - -static void stm32_gpio_init(void) { - /* Enabling GPIO-related clocks, the mask comes from the - registry header file.*/ - rccResetAHB1(STM32_GPIO_EN_MASK); - rccEnableAHB1(STM32_GPIO_EN_MASK, true); - - /* Initializing all the defined GPIO ports.*/ -#if STM32_HAS_GPIOA - gpio_init(GPIOA, &gpio_default_config.PAData); -#endif -#if STM32_HAS_GPIOB - gpio_init(GPIOB, &gpio_default_config.PBData); -#endif -#if STM32_HAS_GPIOC - gpio_init(GPIOC, &gpio_default_config.PCData); -#endif -#if STM32_HAS_GPIOD - gpio_init(GPIOD, &gpio_default_config.PDData); -#endif -#if STM32_HAS_GPIOE - gpio_init(GPIOE, &gpio_default_config.PEData); -#endif -#if STM32_HAS_GPIOF - gpio_init(GPIOF, &gpio_default_config.PFData); -#endif -#if STM32_HAS_GPIOG - gpio_init(GPIOG, &gpio_default_config.PGData); -#endif -#if STM32_HAS_GPIOH - gpio_init(GPIOH, &gpio_default_config.PHData); -#endif -#if STM32_HAS_GPIOI - gpio_init(GPIOI, &gpio_default_config.PIData); -#endif -#if STM32_HAS_GPIOJ - gpio_init(GPIOJ, &gpio_default_config.PJData); -#endif -#if STM32_HAS_GPIOK - gpio_init(GPIOK, &gpio_default_config.PKData); -#endif -} - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -__attribute__((weak)) void enter_bootloader_mode_if_requested(void) {} - -/** - * @brief Early initialization code. - * @details GPIO ports and system clocks are initialized before everything - * else. - */ -void __early_init(void) { - enter_bootloader_mode_if_requested(); - - stm32_gpio_init(); - stm32_clock_init(); -} - -#if HAL_USE_SDC || defined(__DOXYGEN__) -/** - * @brief SDC card detection. - */ -bool sdc_lld_is_card_inserted(SDCDriver *sdcp) { - (void)sdcp; - /* TODO: Fill the implementation.*/ - return true; -} - -/** - * @brief SDC card write protection detection. - */ -bool sdc_lld_is_write_protected(SDCDriver *sdcp) { - (void)sdcp; - /* TODO: Fill the implementation.*/ - return false; -} -#endif /* HAL_USE_SDC */ - -#if HAL_USE_MMC_SPI || defined(__DOXYGEN__) -/** - * @brief MMC_SPI card detection. - */ -bool mmc_lld_is_card_inserted(MMCDriver *mmcp) { - (void)mmcp; - /* TODO: Fill the implementation.*/ - return true; -} - -/** - * @brief MMC_SPI card write protection detection. - */ -bool mmc_lld_is_write_protected(MMCDriver *mmcp) { - (void)mmcp; - /* TODO: Fill the implementation.*/ - return false; -} -#endif - -/** - * @brief Board-specific initialization code. - * @todo Add your board-specific code, if any. - */ -void boardInit(void) {} diff --git a/drivers/boards/BLACKPILL_STM32_F411/board.h b/drivers/boards/BLACKPILL_STM32_F411/board.h deleted file mode 100644 index c0613b4a711f..000000000000 --- a/drivers/boards/BLACKPILL_STM32_F411/board.h +++ /dev/null @@ -1,583 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/* - * This file has been automatically generated using ChibiStudio board - * generator plugin. Do not edit manually. - */ - -#ifndef BOARD_H -#define BOARD_H - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -/* - * Setup for STM32F411CEU6 black pill board. - */ - -/* - * Board identifier. - */ -#define BOARD_BLACKPILL_STM32_F411 -#define BOARD_NAME "STM32F411CEU6 blackpill" - -/* - * Allow Board to boot USB without extra A9 hardware/software config - */ -#define BOARD_OTG_NOVBUSSENS 1 - -/* - * Board oscillators-related settings. - */ -#if !defined(STM32_LSECLK) -# define STM32_LSECLK 32768U -#endif - -#if !defined(STM32_HSECLK) -# define STM32_HSECLK 25000000U -#endif - -//#define STM32_HSE_BYPASS - -/* - * Board voltages. - * Required for performance limits calculation. - */ -#define STM32_VDD 300U - -/* - * MCU type as defined in the ST header. - */ -#define STM32F411xE - -/* - * IO pins assignments. - */ -#define GPIOA_ARD_A0 0U -#define GPIOA_ADC1_IN0 0U -#define GPIOA_ARD_A1 1U -#define GPIOA_ADC1_IN1 1U -#define GPIOA_ARD_D1 2U -#define GPIOA_USART2_TX 2U -#define GPIOA_ARD_D0 3U -#define GPIOA_USART2_RX 3U -#define GPIOA_ARD_A2 4U -#define GPIOA_ADC1_IN4 4U -#define GPIOA_LED_GREEN 5U -#define GPIOA_ARD_D13 5U -#define GPIOA_ARD_D12 6U -#define GPIOA_ARD_D11 7U -#define GPIOA_ARD_D7 8U -#define GPIOA_ARD_D8 9U -#define GPIOA_ARD_D2 10U -#define GPIOA_OTG_FS_DM 11U -#define GPIOA_OTG_FS_DP 12U -#define GPIOA_SWDIO 13U -#define GPIOA_SWCLK 14U -#define GPIOA_PIN15 15U - -#define GPIOB_ARD_A3 0U -#define GPIOB_ADC1_IN8 0U -#define GPIOB_PIN1 1U -#define GPIOB_PIN2 2U -#define GPIOB_SWO 3U -#define GPIOB_ARD_D3 3U -#define GPIOB_ARD_D5 4U -#define GPIOB_ARD_D4 5U -#define GPIOB_ARD_D10 6U -#define GPIOB_PIN7 7U -#define GPIOB_ARD_D15 8U -#define GPIOB_ARD_D14 9U -#define GPIOB_ARD_D6 10U -#define GPIOB_PIN11 11U -#define GPIOB_PIN12 12U -#define GPIOB_PIN13 13U -#define GPIOB_PIN14 14U -#define GPIOB_PIN15 15U - -#define GPIOC_ARD_A5 0U -#define GPIOC_ADC1_IN10 0U -#define GPIOC_ARD_A4 1U -#define GPIOC_ADC1_IN11 1U -#define GPIOC_PIN2 2U -#define GPIOC_PIN3 3U -#define GPIOC_PIN4 4U -#define GPIOC_PIN5 5U -#define GPIOC_PIN6 6U -#define GPIOC_ARD_D9 7U -#define GPIOC_PIN8 8U -#define GPIOC_PIN9 9U -#define GPIOC_PIN10 10U -#define GPIOC_PIN11 11U -#define GPIOC_PIN12 12U -#define GPIOC_BUTTON 13U -#define GPIOC_OSC32_IN 14U -#define GPIOC_OSC32_OUT 15U - -#define GPIOD_PIN0 0U -#define GPIOD_PIN1 1U -#define GPIOD_PIN2 2U -#define GPIOD_PIN3 3U -#define GPIOD_PIN4 4U -#define GPIOD_PIN5 5U -#define GPIOD_PIN6 6U -#define GPIOD_PIN7 7U -#define GPIOD_PIN8 8U -#define GPIOD_PIN9 9U -#define GPIOD_PIN10 10U -#define GPIOD_PIN11 11U -#define GPIOD_PIN12 12U -#define GPIOD_PIN13 13U -#define GPIOD_PIN14 14U -#define GPIOD_PIN15 15U - -#define GPIOE_PIN0 0U -#define GPIOE_PIN1 1U -#define GPIOE_PIN2 2U -#define GPIOE_PIN3 3U -#define GPIOE_PIN4 4U -#define GPIOE_PIN5 5U -#define GPIOE_PIN6 6U -#define GPIOE_PIN7 7U -#define GPIOE_PIN8 8U -#define GPIOE_PIN9 9U -#define GPIOE_PIN10 10U -#define GPIOE_PIN11 11U -#define GPIOE_PIN12 12U -#define GPIOE_PIN13 13U -#define GPIOE_PIN14 14U -#define GPIOE_PIN15 15U - -#define GPIOF_PIN0 0U -#define GPIOF_PIN1 1U -#define GPIOF_PIN2 2U -#define GPIOF_PIN3 3U -#define GPIOF_PIN4 4U -#define GPIOF_PIN5 5U -#define GPIOF_PIN6 6U -#define GPIOF_PIN7 7U -#define GPIOF_PIN8 8U -#define GPIOF_PIN9 9U -#define GPIOF_PIN10 10U -#define GPIOF_PIN11 11U -#define GPIOF_PIN12 12U -#define GPIOF_PIN13 13U -#define GPIOF_PIN14 14U -#define GPIOF_PIN15 15U - -#define GPIOG_PIN0 0U -#define GPIOG_PIN1 1U -#define GPIOG_PIN2 2U -#define GPIOG_PIN3 3U -#define GPIOG_PIN4 4U -#define GPIOG_PIN5 5U -#define GPIOG_PIN6 6U -#define GPIOG_PIN7 7U -#define GPIOG_PIN8 8U -#define GPIOG_PIN9 9U -#define GPIOG_PIN10 10U -#define GPIOG_PIN11 11U -#define GPIOG_PIN12 12U -#define GPIOG_PIN13 13U -#define GPIOG_PIN14 14U -#define GPIOG_PIN15 15U - -#define GPIOH_OSC_IN 0U -#define GPIOH_OSC_OUT 1U -#define GPIOH_PIN2 2U -#define GPIOH_PIN3 3U -#define GPIOH_PIN4 4U -#define GPIOH_PIN5 5U -#define GPIOH_PIN6 6U -#define GPIOH_PIN7 7U -#define GPIOH_PIN8 8U -#define GPIOH_PIN9 9U -#define GPIOH_PIN10 10U -#define GPIOH_PIN11 11U -#define GPIOH_PIN12 12U -#define GPIOH_PIN13 13U -#define GPIOH_PIN14 14U -#define GPIOH_PIN15 15U - -#define GPIOI_PIN0 0U -#define GPIOI_PIN1 1U -#define GPIOI_PIN2 2U -#define GPIOI_PIN3 3U -#define GPIOI_PIN4 4U -#define GPIOI_PIN5 5U -#define GPIOI_PIN6 6U -#define GPIOI_PIN7 7U -#define GPIOI_PIN8 8U -#define GPIOI_PIN9 9U -#define GPIOI_PIN10 10U -#define GPIOI_PIN11 11U -#define GPIOI_PIN12 12U -#define GPIOI_PIN13 13U -#define GPIOI_PIN14 14U -#define GPIOI_PIN15 15U - -/* - * IO lines assignments. - */ -#define LINE_ARD_A0 PAL_LINE(GPIOA, 0U) -#define LINE_ADC1_IN0 PAL_LINE(GPIOA, 0U) -#define LINE_ARD_A1 PAL_LINE(GPIOA, 1U) -#define LINE_ADC1_IN1 PAL_LINE(GPIOA, 1U) -#define LINE_ARD_D1 PAL_LINE(GPIOA, 2U) -#define LINE_USART2_TX PAL_LINE(GPIOA, 2U) -#define LINE_ARD_D0 PAL_LINE(GPIOA, 3U) -#define LINE_USART2_RX PAL_LINE(GPIOA, 3U) -#define LINE_ARD_A2 PAL_LINE(GPIOA, 4U) -#define LINE_ADC1_IN4 PAL_LINE(GPIOA, 4U) -#define LINE_LED_GREEN PAL_LINE(GPIOA, 5U) -#define LINE_ARD_D13 PAL_LINE(GPIOA, 5U) -#define LINE_ARD_D12 PAL_LINE(GPIOA, 6U) -#define LINE_ARD_D11 PAL_LINE(GPIOA, 7U) -#define LINE_ARD_D7 PAL_LINE(GPIOA, 8U) -#define LINE_ARD_D8 PAL_LINE(GPIOA, 9U) -#define LINE_ARD_D2 PAL_LINE(GPIOA, 10U) -#define LINE_OTG_FS_DM PAL_LINE(GPIOA, 11U) -#define LINE_OTG_FS_DP PAL_LINE(GPIOA, 12U) -#define LINE_SWDIO PAL_LINE(GPIOA, 13U) -#define LINE_SWCLK PAL_LINE(GPIOA, 14U) -#define LINE_ARD_A3 PAL_LINE(GPIOB, 0U) -#define LINE_ADC1_IN8 PAL_LINE(GPIOB, 0U) -#define LINE_SWO PAL_LINE(GPIOB, 3U) -#define LINE_ARD_D3 PAL_LINE(GPIOB, 3U) -#define LINE_ARD_D5 PAL_LINE(GPIOB, 4U) -#define LINE_ARD_D4 PAL_LINE(GPIOB, 5U) -#define LINE_ARD_D10 PAL_LINE(GPIOB, 6U) -#define LINE_ARD_D15 PAL_LINE(GPIOB, 8U) -#define LINE_ARD_D14 PAL_LINE(GPIOB, 9U) -#define LINE_ARD_D6 PAL_LINE(GPIOB, 10U) -#define LINE_ARD_A5 PAL_LINE(GPIOC, 0U) -#define LINE_ADC1_IN10 PAL_LINE(GPIOC, 0U) -#define LINE_ARD_A4 PAL_LINE(GPIOC, 1U) -#define LINE_ADC1_IN11 PAL_LINE(GPIOC, 1U) -#define LINE_ARD_D9 PAL_LINE(GPIOC, 7U) -#define LINE_BUTTON PAL_LINE(GPIOC, 13U) -#define LINE_OSC32_IN PAL_LINE(GPIOC, 14U) -#define LINE_OSC32_OUT PAL_LINE(GPIOC, 15U) -#define LINE_OSC_IN PAL_LINE(GPIOH, 0U) -#define LINE_OSC_OUT PAL_LINE(GPIOH, 1U) - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ - -/* - * I/O ports initial setup, this configuration is established soon after reset - * in the initialization code. - * Please refer to the STM32 Reference Manual for details. - */ -#define PIN_MODE_INPUT(n) (0U << ((n)*2U)) -#define PIN_MODE_OUTPUT(n) (1U << ((n)*2U)) -#define PIN_MODE_ALTERNATE(n) (2U << ((n)*2U)) -#define PIN_MODE_ANALOG(n) (3U << ((n)*2U)) -#define PIN_ODR_LOW(n) (0U << (n)) -#define PIN_ODR_HIGH(n) (1U << (n)) -#define PIN_OTYPE_PUSHPULL(n) (0U << (n)) -#define PIN_OTYPE_OPENDRAIN(n) (1U << (n)) -#define PIN_OSPEED_VERYLOW(n) (0U << ((n)*2U)) -#define PIN_OSPEED_LOW(n) (1U << ((n)*2U)) -#define PIN_OSPEED_MEDIUM(n) (2U << ((n)*2U)) -#define PIN_OSPEED_HIGH(n) (3U << ((n)*2U)) -#define PIN_PUPDR_FLOATING(n) (0U << ((n)*2U)) -#define PIN_PUPDR_PULLUP(n) (1U << ((n)*2U)) -#define PIN_PUPDR_PULLDOWN(n) (2U << ((n)*2U)) -#define PIN_AFIO_AF(n, v) ((v) << (((n) % 8U) * 4U)) - -/* - * GPIOA setup: - * - * PA0 - ARD_A0 ADC1_IN0 (input pullup). - * PA1 - ARD_A1 ADC1_IN1 (input pullup). - * PA2 - ARD_D1 USART2_TX (alternate 7). - * PA3 - ARD_D0 USART2_RX (alternate 7). - * PA4 - ARD_A2 ADC1_IN4 (input pullup). - * PA5 - LED_GREEN ARD_D13 (output pushpull high). - * PA6 - ARD_D12 (input pullup). - * PA7 - ARD_D11 (input pullup). - * PA8 - ARD_D7 (input pullup). - * PA9 - ARD_D8 (input pullup). - * PA10 - ARD_D2 (input pullup). - * PA11 - OTG_FS_DM (alternate 10). - * PA12 - OTG_FS_DP (alternate 10). - * PA13 - SWDIO (alternate 0). - * PA14 - SWCLK (alternate 0). - * PA15 - PIN15 (input pullup). - */ -#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_ARD_A0) | PIN_MODE_INPUT(GPIOA_ARD_A1) | PIN_MODE_ALTERNATE(GPIOA_ARD_D1) | PIN_MODE_ALTERNATE(GPIOA_ARD_D0) | PIN_MODE_INPUT(GPIOA_ARD_A2) | PIN_MODE_OUTPUT(GPIOA_LED_GREEN) | PIN_MODE_INPUT(GPIOA_ARD_D12) | PIN_MODE_INPUT(GPIOA_ARD_D11) | PIN_MODE_INPUT(GPIOA_ARD_D7) | PIN_MODE_INPUT(GPIOA_ARD_D8) | PIN_MODE_INPUT(GPIOA_ARD_D2) | PIN_MODE_ALTERNATE(GPIOA_OTG_FS_DM) | PIN_MODE_ALTERNATE(GPIOA_OTG_FS_DP) | PIN_MODE_ALTERNATE(GPIOA_SWDIO) | PIN_MODE_ALTERNATE(GPIOA_SWCLK) | PIN_MODE_INPUT(GPIOA_PIN15)) -#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_ARD_A0) | PIN_OTYPE_PUSHPULL(GPIOA_ARD_A1) | PIN_OTYPE_PUSHPULL(GPIOA_ARD_D1) | PIN_OTYPE_PUSHPULL(GPIOA_ARD_D0) | PIN_OTYPE_PUSHPULL(GPIOA_ARD_A2) | PIN_OTYPE_PUSHPULL(GPIOA_LED_GREEN) | PIN_OTYPE_PUSHPULL(GPIOA_ARD_D12) | PIN_OTYPE_PUSHPULL(GPIOA_ARD_D11) | PIN_OTYPE_PUSHPULL(GPIOA_ARD_D7) | PIN_OTYPE_PUSHPULL(GPIOA_ARD_D8) | PIN_OTYPE_PUSHPULL(GPIOA_ARD_D2) | PIN_OTYPE_PUSHPULL(GPIOA_OTG_FS_DM) | PIN_OTYPE_PUSHPULL(GPIOA_OTG_FS_DP) | PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) | PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) | PIN_OTYPE_PUSHPULL(GPIOA_PIN15)) -#define VAL_GPIOA_OSPEEDR (PIN_OSPEED_HIGH(GPIOA_ARD_A0) | PIN_OSPEED_HIGH(GPIOA_ARD_A1) | PIN_OSPEED_MEDIUM(GPIOA_ARD_D1) | PIN_OSPEED_MEDIUM(GPIOA_ARD_D0) | PIN_OSPEED_HIGH(GPIOA_ARD_A2) | PIN_OSPEED_MEDIUM(GPIOA_LED_GREEN) | PIN_OSPEED_HIGH(GPIOA_ARD_D12) | PIN_OSPEED_HIGH(GPIOA_ARD_D11) | PIN_OSPEED_HIGH(GPIOA_ARD_D7) | PIN_OSPEED_HIGH(GPIOA_ARD_D8) | PIN_OSPEED_HIGH(GPIOA_ARD_D2) | PIN_OSPEED_HIGH(GPIOA_OTG_FS_DM) | PIN_OSPEED_HIGH(GPIOA_OTG_FS_DP) | PIN_OSPEED_HIGH(GPIOA_SWDIO) | PIN_OSPEED_HIGH(GPIOA_SWCLK) | PIN_OSPEED_HIGH(GPIOA_PIN15)) -#define VAL_GPIOA_PUPDR (PIN_PUPDR_PULLUP(GPIOA_ARD_A0) | PIN_PUPDR_PULLUP(GPIOA_ARD_A1) | PIN_PUPDR_FLOATING(GPIOA_ARD_D1) | PIN_PUPDR_FLOATING(GPIOA_ARD_D0) | PIN_PUPDR_PULLUP(GPIOA_ARD_A2) | PIN_PUPDR_FLOATING(GPIOA_LED_GREEN) | PIN_PUPDR_PULLUP(GPIOA_ARD_D12) | PIN_PUPDR_PULLUP(GPIOA_ARD_D11) | PIN_PUPDR_PULLUP(GPIOA_ARD_D7) | PIN_PUPDR_PULLUP(GPIOA_ARD_D8) | PIN_PUPDR_PULLUP(GPIOA_ARD_D2) | PIN_PUPDR_FLOATING(GPIOA_OTG_FS_DM) | PIN_PUPDR_FLOATING(GPIOA_OTG_FS_DP) | PIN_PUPDR_PULLUP(GPIOA_SWDIO) | PIN_PUPDR_PULLDOWN(GPIOA_SWCLK) | PIN_PUPDR_PULLUP(GPIOA_PIN15)) -#define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_ARD_A0) | PIN_ODR_HIGH(GPIOA_ARD_A1) | PIN_ODR_HIGH(GPIOA_ARD_D1) | PIN_ODR_HIGH(GPIOA_ARD_D0) | PIN_ODR_HIGH(GPIOA_ARD_A2) | PIN_ODR_LOW(GPIOA_LED_GREEN) | PIN_ODR_HIGH(GPIOA_ARD_D12) | PIN_ODR_HIGH(GPIOA_ARD_D11) | PIN_ODR_HIGH(GPIOA_ARD_D7) | PIN_ODR_HIGH(GPIOA_ARD_D8) | PIN_ODR_HIGH(GPIOA_ARD_D2) | PIN_ODR_HIGH(GPIOA_OTG_FS_DM) | PIN_ODR_HIGH(GPIOA_OTG_FS_DP) | PIN_ODR_HIGH(GPIOA_SWDIO) | PIN_ODR_HIGH(GPIOA_SWCLK) | PIN_ODR_HIGH(GPIOA_PIN15)) -#define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_ARD_A0, 0U) | PIN_AFIO_AF(GPIOA_ARD_A1, 0U) | PIN_AFIO_AF(GPIOA_ARD_D1, 7U) | PIN_AFIO_AF(GPIOA_ARD_D0, 7U) | PIN_AFIO_AF(GPIOA_ARD_A2, 0U) | PIN_AFIO_AF(GPIOA_LED_GREEN, 0U) | PIN_AFIO_AF(GPIOA_ARD_D12, 0U) | PIN_AFIO_AF(GPIOA_ARD_D11, 0U)) -#define VAL_GPIOA_AFRH (PIN_AFIO_AF(GPIOA_ARD_D7, 0U) | PIN_AFIO_AF(GPIOA_ARD_D8, 0U) | PIN_AFIO_AF(GPIOA_ARD_D2, 0U) | PIN_AFIO_AF(GPIOA_OTG_FS_DM, 10U) | PIN_AFIO_AF(GPIOA_OTG_FS_DP, 10U) | PIN_AFIO_AF(GPIOA_SWDIO, 0U) | PIN_AFIO_AF(GPIOA_SWCLK, 0U) | PIN_AFIO_AF(GPIOA_PIN15, 0U)) - -/* - * GPIOB setup: - * - * PB0 - ARD_A3 ADC1_IN8 (input pullup). - * PB1 - PIN1 (input pullup). - * PB2 - PIN2 (input pullup). - * PB3 - SWO ARD_D3 (alternate 0). - * PB4 - ARD_D5 (input pullup). - * PB5 - ARD_D4 (input pullup). - * PB6 - ARD_D10 (input pullup). - * PB7 - PIN7 (input pullup). - * PB8 - ARD_D15 (input pullup). - * PB9 - ARD_D14 (input pullup). - * PB10 - ARD_D6 (input pullup). - * PB11 - PIN11 (input pullup). - * PB12 - PIN12 (input pullup). - * PB13 - PIN13 (input pullup). - * PB14 - PIN14 (input pullup). - * PB15 - PIN15 (input pullup). - */ -#define VAL_GPIOB_MODER (PIN_MODE_INPUT(GPIOB_ARD_A3) | PIN_MODE_INPUT(GPIOB_PIN1) | PIN_MODE_INPUT(GPIOB_PIN2) | PIN_MODE_ALTERNATE(GPIOB_SWO) | PIN_MODE_INPUT(GPIOB_ARD_D5) | PIN_MODE_INPUT(GPIOB_ARD_D4) | PIN_MODE_INPUT(GPIOB_ARD_D10) | PIN_MODE_INPUT(GPIOB_PIN7) | PIN_MODE_INPUT(GPIOB_ARD_D15) | PIN_MODE_INPUT(GPIOB_ARD_D14) | PIN_MODE_INPUT(GPIOB_ARD_D6) | PIN_MODE_INPUT(GPIOB_PIN11) | PIN_MODE_INPUT(GPIOB_PIN12) | PIN_MODE_INPUT(GPIOB_PIN13) | PIN_MODE_INPUT(GPIOB_PIN14) | PIN_MODE_INPUT(GPIOB_PIN15)) -#define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(GPIOB_ARD_A3) | PIN_OTYPE_PUSHPULL(GPIOB_PIN1) | PIN_OTYPE_PUSHPULL(GPIOB_PIN2) | PIN_OTYPE_PUSHPULL(GPIOB_SWO) | PIN_OTYPE_PUSHPULL(GPIOB_ARD_D5) | PIN_OTYPE_PUSHPULL(GPIOB_ARD_D4) | PIN_OTYPE_PUSHPULL(GPIOB_ARD_D10) | PIN_OTYPE_PUSHPULL(GPIOB_PIN7) | PIN_OTYPE_PUSHPULL(GPIOB_ARD_D15) | PIN_OTYPE_PUSHPULL(GPIOB_ARD_D14) | PIN_OTYPE_PUSHPULL(GPIOB_ARD_D6) | PIN_OTYPE_PUSHPULL(GPIOB_PIN11) | PIN_OTYPE_PUSHPULL(GPIOB_PIN12) | PIN_OTYPE_PUSHPULL(GPIOB_PIN13) | PIN_OTYPE_PUSHPULL(GPIOB_PIN14) | PIN_OTYPE_PUSHPULL(GPIOB_PIN15)) -#define VAL_GPIOB_OSPEEDR (PIN_OSPEED_HIGH(GPIOB_ARD_A3) | PIN_OSPEED_HIGH(GPIOB_PIN1) | PIN_OSPEED_HIGH(GPIOB_PIN2) | PIN_OSPEED_HIGH(GPIOB_SWO) | PIN_OSPEED_HIGH(GPIOB_ARD_D5) | PIN_OSPEED_HIGH(GPIOB_ARD_D4) | PIN_OSPEED_HIGH(GPIOB_ARD_D10) | PIN_OSPEED_HIGH(GPIOB_PIN7) | PIN_OSPEED_HIGH(GPIOB_ARD_D15) | PIN_OSPEED_HIGH(GPIOB_ARD_D14) | PIN_OSPEED_HIGH(GPIOB_ARD_D6) | PIN_OSPEED_HIGH(GPIOB_PIN11) | PIN_OSPEED_HIGH(GPIOB_PIN12) | PIN_OSPEED_HIGH(GPIOB_PIN13) | PIN_OSPEED_HIGH(GPIOB_PIN14) | PIN_OSPEED_HIGH(GPIOB_PIN15)) -#define VAL_GPIOB_PUPDR (PIN_PUPDR_PULLUP(GPIOB_ARD_A3) | PIN_PUPDR_PULLUP(GPIOB_PIN1) | PIN_PUPDR_PULLUP(GPIOB_PIN2) | PIN_PUPDR_PULLUP(GPIOB_SWO) | PIN_PUPDR_PULLUP(GPIOB_ARD_D5) | PIN_PUPDR_PULLUP(GPIOB_ARD_D4) | PIN_PUPDR_PULLUP(GPIOB_ARD_D10) | PIN_PUPDR_PULLUP(GPIOB_PIN7) | PIN_PUPDR_PULLUP(GPIOB_ARD_D15) | PIN_PUPDR_PULLUP(GPIOB_ARD_D14) | PIN_PUPDR_PULLUP(GPIOB_ARD_D6) | PIN_PUPDR_PULLUP(GPIOB_PIN11) | PIN_PUPDR_PULLUP(GPIOB_PIN12) | PIN_PUPDR_PULLUP(GPIOB_PIN13) | PIN_PUPDR_PULLUP(GPIOB_PIN14) | PIN_PUPDR_PULLUP(GPIOB_PIN15)) -#define VAL_GPIOB_ODR (PIN_ODR_HIGH(GPIOB_ARD_A3) | PIN_ODR_HIGH(GPIOB_PIN1) | PIN_ODR_HIGH(GPIOB_PIN2) | PIN_ODR_HIGH(GPIOB_SWO) | PIN_ODR_HIGH(GPIOB_ARD_D5) | PIN_ODR_HIGH(GPIOB_ARD_D4) | PIN_ODR_HIGH(GPIOB_ARD_D10) | PIN_ODR_HIGH(GPIOB_PIN7) | PIN_ODR_HIGH(GPIOB_ARD_D15) | PIN_ODR_HIGH(GPIOB_ARD_D14) | PIN_ODR_HIGH(GPIOB_ARD_D6) | PIN_ODR_HIGH(GPIOB_PIN11) | PIN_ODR_HIGH(GPIOB_PIN12) | PIN_ODR_HIGH(GPIOB_PIN13) | PIN_ODR_HIGH(GPIOB_PIN14) | PIN_ODR_HIGH(GPIOB_PIN15)) -#define VAL_GPIOB_AFRL (PIN_AFIO_AF(GPIOB_ARD_A3, 0U) | PIN_AFIO_AF(GPIOB_PIN1, 0U) | PIN_AFIO_AF(GPIOB_PIN2, 0U) | PIN_AFIO_AF(GPIOB_SWO, 0U) | PIN_AFIO_AF(GPIOB_ARD_D5, 0U) | PIN_AFIO_AF(GPIOB_ARD_D4, 0U) | PIN_AFIO_AF(GPIOB_ARD_D10, 0U) | PIN_AFIO_AF(GPIOB_PIN7, 0U)) -#define VAL_GPIOB_AFRH (PIN_AFIO_AF(GPIOB_ARD_D15, 0U) | PIN_AFIO_AF(GPIOB_ARD_D14, 0U) | PIN_AFIO_AF(GPIOB_ARD_D6, 0U) | PIN_AFIO_AF(GPIOB_PIN11, 0U) | PIN_AFIO_AF(GPIOB_PIN12, 0U) | PIN_AFIO_AF(GPIOB_PIN13, 0U) | PIN_AFIO_AF(GPIOB_PIN14, 0U) | PIN_AFIO_AF(GPIOB_PIN15, 0U)) - -/* - * GPIOC setup: - * - * PC0 - ARD_A5 ADC1_IN10 (input pullup). - * PC1 - ARD_A4 ADC1_IN11 (input pullup). - * PC2 - PIN2 (input pullup). - * PC3 - PIN3 (input pullup). - * PC4 - PIN4 (input pullup). - * PC5 - PIN5 (input pullup). - * PC6 - PIN6 (input pullup). - * PC7 - ARD_D9 (input pullup). - * PC8 - PIN8 (input pullup). - * PC9 - PIN9 (input pullup). - * PC10 - PIN10 (input pullup). - * PC11 - PIN11 (input pullup). - * PC12 - PIN12 (input pullup). - * PC13 - BUTTON (input floating). - * PC14 - OSC32_IN (input floating). - * PC15 - OSC32_OUT (input floating). - */ -#define VAL_GPIOC_MODER (PIN_MODE_INPUT(GPIOC_ARD_A5) | PIN_MODE_INPUT(GPIOC_ARD_A4) | PIN_MODE_INPUT(GPIOC_PIN2) | PIN_MODE_INPUT(GPIOC_PIN3) | PIN_MODE_INPUT(GPIOC_PIN4) | PIN_MODE_INPUT(GPIOC_PIN5) | PIN_MODE_INPUT(GPIOC_PIN6) | PIN_MODE_INPUT(GPIOC_ARD_D9) | PIN_MODE_INPUT(GPIOC_PIN8) | PIN_MODE_INPUT(GPIOC_PIN9) | PIN_MODE_INPUT(GPIOC_PIN10) | PIN_MODE_INPUT(GPIOC_PIN11) | PIN_MODE_INPUT(GPIOC_PIN12) | PIN_MODE_INPUT(GPIOC_BUTTON) | PIN_MODE_INPUT(GPIOC_OSC32_IN) | PIN_MODE_INPUT(GPIOC_OSC32_OUT)) -#define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(GPIOC_ARD_A5) | PIN_OTYPE_PUSHPULL(GPIOC_ARD_A4) | PIN_OTYPE_PUSHPULL(GPIOC_PIN2) | PIN_OTYPE_PUSHPULL(GPIOC_PIN3) | PIN_OTYPE_PUSHPULL(GPIOC_PIN4) | PIN_OTYPE_PUSHPULL(GPIOC_PIN5) | PIN_OTYPE_PUSHPULL(GPIOC_PIN6) | PIN_OTYPE_PUSHPULL(GPIOC_ARD_D9) | PIN_OTYPE_PUSHPULL(GPIOC_PIN8) | PIN_OTYPE_PUSHPULL(GPIOC_PIN9) | PIN_OTYPE_PUSHPULL(GPIOC_PIN10) | PIN_OTYPE_PUSHPULL(GPIOC_PIN11) | PIN_OTYPE_PUSHPULL(GPIOC_PIN12) | PIN_OTYPE_PUSHPULL(GPIOC_BUTTON) | PIN_OTYPE_PUSHPULL(GPIOC_OSC32_IN) | PIN_OTYPE_PUSHPULL(GPIOC_OSC32_OUT)) -#define VAL_GPIOC_OSPEEDR (PIN_OSPEED_HIGH(GPIOC_ARD_A5) | PIN_OSPEED_HIGH(GPIOC_ARD_A4) | PIN_OSPEED_HIGH(GPIOC_PIN2) | PIN_OSPEED_HIGH(GPIOC_PIN3) | PIN_OSPEED_HIGH(GPIOC_PIN4) | PIN_OSPEED_HIGH(GPIOC_PIN5) | PIN_OSPEED_HIGH(GPIOC_PIN6) | PIN_OSPEED_HIGH(GPIOC_ARD_D9) | PIN_OSPEED_HIGH(GPIOC_PIN8) | PIN_OSPEED_HIGH(GPIOC_PIN9) | PIN_OSPEED_HIGH(GPIOC_PIN10) | PIN_OSPEED_HIGH(GPIOC_PIN11) | PIN_OSPEED_HIGH(GPIOC_PIN12) | PIN_OSPEED_HIGH(GPIOC_BUTTON) | PIN_OSPEED_HIGH(GPIOC_OSC32_IN) | PIN_OSPEED_HIGH(GPIOC_OSC32_OUT)) -#define VAL_GPIOC_PUPDR (PIN_PUPDR_PULLUP(GPIOC_ARD_A5) | PIN_PUPDR_PULLUP(GPIOC_ARD_A4) | PIN_PUPDR_PULLUP(GPIOC_PIN2) | PIN_PUPDR_PULLUP(GPIOC_PIN3) | PIN_PUPDR_PULLUP(GPIOC_PIN4) | PIN_PUPDR_PULLUP(GPIOC_PIN5) | PIN_PUPDR_PULLUP(GPIOC_PIN6) | PIN_PUPDR_PULLUP(GPIOC_ARD_D9) | PIN_PUPDR_PULLUP(GPIOC_PIN8) | PIN_PUPDR_PULLUP(GPIOC_PIN9) | PIN_PUPDR_PULLUP(GPIOC_PIN10) | PIN_PUPDR_PULLUP(GPIOC_PIN11) | PIN_PUPDR_PULLUP(GPIOC_PIN12) | PIN_PUPDR_FLOATING(GPIOC_BUTTON) | PIN_PUPDR_FLOATING(GPIOC_OSC32_IN) | PIN_PUPDR_FLOATING(GPIOC_OSC32_OUT)) -#define VAL_GPIOC_ODR (PIN_ODR_HIGH(GPIOC_ARD_A5) | PIN_ODR_HIGH(GPIOC_ARD_A4) | PIN_ODR_HIGH(GPIOC_PIN2) | PIN_ODR_HIGH(GPIOC_PIN3) | PIN_ODR_HIGH(GPIOC_PIN4) | PIN_ODR_HIGH(GPIOC_PIN5) | PIN_ODR_HIGH(GPIOC_PIN6) | PIN_ODR_HIGH(GPIOC_ARD_D9) | PIN_ODR_HIGH(GPIOC_PIN8) | PIN_ODR_HIGH(GPIOC_PIN9) | PIN_ODR_HIGH(GPIOC_PIN10) | PIN_ODR_HIGH(GPIOC_PIN11) | PIN_ODR_HIGH(GPIOC_PIN12) | PIN_ODR_HIGH(GPIOC_BUTTON) | PIN_ODR_HIGH(GPIOC_OSC32_IN) | PIN_ODR_HIGH(GPIOC_OSC32_OUT)) -#define VAL_GPIOC_AFRL (PIN_AFIO_AF(GPIOC_ARD_A5, 0U) | PIN_AFIO_AF(GPIOC_ARD_A4, 0U) | PIN_AFIO_AF(GPIOC_PIN2, 0U) | PIN_AFIO_AF(GPIOC_PIN3, 0U) | PIN_AFIO_AF(GPIOC_PIN4, 0U) | PIN_AFIO_AF(GPIOC_PIN5, 0U) | PIN_AFIO_AF(GPIOC_PIN6, 0U) | PIN_AFIO_AF(GPIOC_ARD_D9, 0U)) -#define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_PIN8, 0U) | PIN_AFIO_AF(GPIOC_PIN9, 0U) | PIN_AFIO_AF(GPIOC_PIN10, 0U) | PIN_AFIO_AF(GPIOC_PIN11, 0U) | PIN_AFIO_AF(GPIOC_PIN12, 0U) | PIN_AFIO_AF(GPIOC_BUTTON, 0U) | PIN_AFIO_AF(GPIOC_OSC32_IN, 0U) | PIN_AFIO_AF(GPIOC_OSC32_OUT, 0U)) - -/* - * GPIOD setup: - * - * PD0 - PIN0 (input pullup). - * PD1 - PIN1 (input pullup). - * PD2 - PIN2 (input pullup). - * PD3 - PIN3 (input pullup). - * PD4 - PIN4 (input pullup). - * PD5 - PIN5 (input pullup). - * PD6 - PIN6 (input pullup). - * PD7 - PIN7 (input pullup). - * PD8 - PIN8 (input pullup). - * PD9 - PIN9 (input pullup). - * PD10 - PIN10 (input pullup). - * PD11 - PIN11 (input pullup). - * PD12 - PIN12 (input pullup). - * PD13 - PIN13 (input pullup). - * PD14 - PIN14 (input pullup). - * PD15 - PIN15 (input pullup). - */ -#define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_PIN0) | PIN_MODE_INPUT(GPIOD_PIN1) | PIN_MODE_INPUT(GPIOD_PIN2) | PIN_MODE_INPUT(GPIOD_PIN3) | PIN_MODE_INPUT(GPIOD_PIN4) | PIN_MODE_INPUT(GPIOD_PIN5) | PIN_MODE_INPUT(GPIOD_PIN6) | PIN_MODE_INPUT(GPIOD_PIN7) | PIN_MODE_INPUT(GPIOD_PIN8) | PIN_MODE_INPUT(GPIOD_PIN9) | PIN_MODE_INPUT(GPIOD_PIN10) | PIN_MODE_INPUT(GPIOD_PIN11) | PIN_MODE_INPUT(GPIOD_PIN12) | PIN_MODE_INPUT(GPIOD_PIN13) | PIN_MODE_INPUT(GPIOD_PIN14) | PIN_MODE_INPUT(GPIOD_PIN15)) -#define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) | PIN_OTYPE_PUSHPULL(GPIOD_PIN1) | PIN_OTYPE_PUSHPULL(GPIOD_PIN2) | PIN_OTYPE_PUSHPULL(GPIOD_PIN3) | PIN_OTYPE_PUSHPULL(GPIOD_PIN4) | PIN_OTYPE_PUSHPULL(GPIOD_PIN5) | PIN_OTYPE_PUSHPULL(GPIOD_PIN6) | PIN_OTYPE_PUSHPULL(GPIOD_PIN7) | PIN_OTYPE_PUSHPULL(GPIOD_PIN8) | PIN_OTYPE_PUSHPULL(GPIOD_PIN9) | PIN_OTYPE_PUSHPULL(GPIOD_PIN10) | PIN_OTYPE_PUSHPULL(GPIOD_PIN11) | PIN_OTYPE_PUSHPULL(GPIOD_PIN12) | PIN_OTYPE_PUSHPULL(GPIOD_PIN13) | PIN_OTYPE_PUSHPULL(GPIOD_PIN14) | PIN_OTYPE_PUSHPULL(GPIOD_PIN15)) -#define VAL_GPIOD_OSPEEDR (PIN_OSPEED_HIGH(GPIOD_PIN0) | PIN_OSPEED_HIGH(GPIOD_PIN1) | PIN_OSPEED_HIGH(GPIOD_PIN2) | PIN_OSPEED_HIGH(GPIOD_PIN3) | PIN_OSPEED_HIGH(GPIOD_PIN4) | PIN_OSPEED_HIGH(GPIOD_PIN5) | PIN_OSPEED_HIGH(GPIOD_PIN6) | PIN_OSPEED_HIGH(GPIOD_PIN7) | PIN_OSPEED_HIGH(GPIOD_PIN8) | PIN_OSPEED_HIGH(GPIOD_PIN9) | PIN_OSPEED_HIGH(GPIOD_PIN10) | PIN_OSPEED_HIGH(GPIOD_PIN11) | PIN_OSPEED_HIGH(GPIOD_PIN12) | PIN_OSPEED_HIGH(GPIOD_PIN13) | PIN_OSPEED_HIGH(GPIOD_PIN14) | PIN_OSPEED_HIGH(GPIOD_PIN15)) -#define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLUP(GPIOD_PIN0) | PIN_PUPDR_PULLUP(GPIOD_PIN1) | PIN_PUPDR_PULLUP(GPIOD_PIN2) | PIN_PUPDR_PULLUP(GPIOD_PIN3) | PIN_PUPDR_PULLUP(GPIOD_PIN4) | PIN_PUPDR_PULLUP(GPIOD_PIN5) | PIN_PUPDR_PULLUP(GPIOD_PIN6) | PIN_PUPDR_PULLUP(GPIOD_PIN7) | PIN_PUPDR_PULLUP(GPIOD_PIN8) | PIN_PUPDR_PULLUP(GPIOD_PIN9) | PIN_PUPDR_PULLUP(GPIOD_PIN10) | PIN_PUPDR_PULLUP(GPIOD_PIN11) | PIN_PUPDR_PULLUP(GPIOD_PIN12) | PIN_PUPDR_PULLUP(GPIOD_PIN13) | PIN_PUPDR_PULLUP(GPIOD_PIN14) | PIN_PUPDR_PULLUP(GPIOD_PIN15)) -#define VAL_GPIOD_ODR (PIN_ODR_HIGH(GPIOD_PIN0) | PIN_ODR_HIGH(GPIOD_PIN1) | PIN_ODR_HIGH(GPIOD_PIN2) | PIN_ODR_HIGH(GPIOD_PIN3) | PIN_ODR_HIGH(GPIOD_PIN4) | PIN_ODR_HIGH(GPIOD_PIN5) | PIN_ODR_HIGH(GPIOD_PIN6) | PIN_ODR_HIGH(GPIOD_PIN7) | PIN_ODR_HIGH(GPIOD_PIN8) | PIN_ODR_HIGH(GPIOD_PIN9) | PIN_ODR_HIGH(GPIOD_PIN10) | PIN_ODR_HIGH(GPIOD_PIN11) | PIN_ODR_HIGH(GPIOD_PIN12) | PIN_ODR_HIGH(GPIOD_PIN13) | PIN_ODR_HIGH(GPIOD_PIN14) | PIN_ODR_HIGH(GPIOD_PIN15)) -#define VAL_GPIOD_AFRL (PIN_AFIO_AF(GPIOD_PIN0, 0U) | PIN_AFIO_AF(GPIOD_PIN1, 0U) | PIN_AFIO_AF(GPIOD_PIN2, 0U) | PIN_AFIO_AF(GPIOD_PIN3, 0U) | PIN_AFIO_AF(GPIOD_PIN4, 0U) | PIN_AFIO_AF(GPIOD_PIN5, 0U) | PIN_AFIO_AF(GPIOD_PIN6, 0U) | PIN_AFIO_AF(GPIOD_PIN7, 0U)) -#define VAL_GPIOD_AFRH (PIN_AFIO_AF(GPIOD_PIN8, 0U) | PIN_AFIO_AF(GPIOD_PIN9, 0U) | PIN_AFIO_AF(GPIOD_PIN10, 0U) | PIN_AFIO_AF(GPIOD_PIN11, 0U) | PIN_AFIO_AF(GPIOD_PIN12, 0U) | PIN_AFIO_AF(GPIOD_PIN13, 0U) | PIN_AFIO_AF(GPIOD_PIN14, 0U) | PIN_AFIO_AF(GPIOD_PIN15, 0U)) - -/* - * GPIOE setup: - * - * PE0 - PIN0 (input pullup). - * PE1 - PIN1 (input pullup). - * PE2 - PIN2 (input pullup). - * PE3 - PIN3 (input pullup). - * PE4 - PIN4 (input pullup). - * PE5 - PIN5 (input pullup). - * PE6 - PIN6 (input pullup). - * PE7 - PIN7 (input pullup). - * PE8 - PIN8 (input pullup). - * PE9 - PIN9 (input pullup). - * PE10 - PIN10 (input pullup). - * PE11 - PIN11 (input pullup). - * PE12 - PIN12 (input pullup). - * PE13 - PIN13 (input pullup). - * PE14 - PIN14 (input pullup). - * PE15 - PIN15 (input pullup). - */ -#define VAL_GPIOE_MODER (PIN_MODE_INPUT(GPIOE_PIN0) | PIN_MODE_INPUT(GPIOE_PIN1) | PIN_MODE_INPUT(GPIOE_PIN2) | PIN_MODE_INPUT(GPIOE_PIN3) | PIN_MODE_INPUT(GPIOE_PIN4) | PIN_MODE_INPUT(GPIOE_PIN5) | PIN_MODE_INPUT(GPIOE_PIN6) | PIN_MODE_INPUT(GPIOE_PIN7) | PIN_MODE_INPUT(GPIOE_PIN8) | PIN_MODE_INPUT(GPIOE_PIN9) | PIN_MODE_INPUT(GPIOE_PIN10) | PIN_MODE_INPUT(GPIOE_PIN11) | PIN_MODE_INPUT(GPIOE_PIN12) | PIN_MODE_INPUT(GPIOE_PIN13) | PIN_MODE_INPUT(GPIOE_PIN14) | PIN_MODE_INPUT(GPIOE_PIN15)) -#define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL(GPIOE_PIN0) | PIN_OTYPE_PUSHPULL(GPIOE_PIN1) | PIN_OTYPE_PUSHPULL(GPIOE_PIN2) | PIN_OTYPE_PUSHPULL(GPIOE_PIN3) | PIN_OTYPE_PUSHPULL(GPIOE_PIN4) | PIN_OTYPE_PUSHPULL(GPIOE_PIN5) | PIN_OTYPE_PUSHPULL(GPIOE_PIN6) | PIN_OTYPE_PUSHPULL(GPIOE_PIN7) | PIN_OTYPE_PUSHPULL(GPIOE_PIN8) | PIN_OTYPE_PUSHPULL(GPIOE_PIN9) | PIN_OTYPE_PUSHPULL(GPIOE_PIN10) | PIN_OTYPE_PUSHPULL(GPIOE_PIN11) | PIN_OTYPE_PUSHPULL(GPIOE_PIN12) | PIN_OTYPE_PUSHPULL(GPIOE_PIN13) | PIN_OTYPE_PUSHPULL(GPIOE_PIN14) | PIN_OTYPE_PUSHPULL(GPIOE_PIN15)) -#define VAL_GPIOE_OSPEEDR (PIN_OSPEED_HIGH(GPIOE_PIN0) | PIN_OSPEED_HIGH(GPIOE_PIN1) | PIN_OSPEED_HIGH(GPIOE_PIN2) | PIN_OSPEED_HIGH(GPIOE_PIN3) | PIN_OSPEED_HIGH(GPIOE_PIN4) | PIN_OSPEED_HIGH(GPIOE_PIN5) | PIN_OSPEED_HIGH(GPIOE_PIN6) | PIN_OSPEED_HIGH(GPIOE_PIN7) | PIN_OSPEED_HIGH(GPIOE_PIN8) | PIN_OSPEED_HIGH(GPIOE_PIN9) | PIN_OSPEED_HIGH(GPIOE_PIN10) | PIN_OSPEED_HIGH(GPIOE_PIN11) | PIN_OSPEED_HIGH(GPIOE_PIN12) | PIN_OSPEED_HIGH(GPIOE_PIN13) | PIN_OSPEED_HIGH(GPIOE_PIN14) | PIN_OSPEED_HIGH(GPIOE_PIN15)) -#define VAL_GPIOE_PUPDR (PIN_PUPDR_PULLUP(GPIOE_PIN0) | PIN_PUPDR_PULLUP(GPIOE_PIN1) | PIN_PUPDR_PULLUP(GPIOE_PIN2) | PIN_PUPDR_PULLUP(GPIOE_PIN3) | PIN_PUPDR_PULLUP(GPIOE_PIN4) | PIN_PUPDR_PULLUP(GPIOE_PIN5) | PIN_PUPDR_PULLUP(GPIOE_PIN6) | PIN_PUPDR_PULLUP(GPIOE_PIN7) | PIN_PUPDR_PULLUP(GPIOE_PIN8) | PIN_PUPDR_PULLUP(GPIOE_PIN9) | PIN_PUPDR_PULLUP(GPIOE_PIN10) | PIN_PUPDR_PULLUP(GPIOE_PIN11) | PIN_PUPDR_PULLUP(GPIOE_PIN12) | PIN_PUPDR_PULLUP(GPIOE_PIN13) | PIN_PUPDR_PULLUP(GPIOE_PIN14) | PIN_PUPDR_PULLUP(GPIOE_PIN15)) -#define VAL_GPIOE_ODR (PIN_ODR_HIGH(GPIOE_PIN0) | PIN_ODR_HIGH(GPIOE_PIN1) | PIN_ODR_HIGH(GPIOE_PIN2) | PIN_ODR_HIGH(GPIOE_PIN3) | PIN_ODR_HIGH(GPIOE_PIN4) | PIN_ODR_HIGH(GPIOE_PIN5) | PIN_ODR_HIGH(GPIOE_PIN6) | PIN_ODR_HIGH(GPIOE_PIN7) | PIN_ODR_HIGH(GPIOE_PIN8) | PIN_ODR_HIGH(GPIOE_PIN9) | PIN_ODR_HIGH(GPIOE_PIN10) | PIN_ODR_HIGH(GPIOE_PIN11) | PIN_ODR_HIGH(GPIOE_PIN12) | PIN_ODR_HIGH(GPIOE_PIN13) | PIN_ODR_HIGH(GPIOE_PIN14) | PIN_ODR_HIGH(GPIOE_PIN15)) -#define VAL_GPIOE_AFRL (PIN_AFIO_AF(GPIOE_PIN0, 0U) | PIN_AFIO_AF(GPIOE_PIN1, 0U) | PIN_AFIO_AF(GPIOE_PIN2, 0U) | PIN_AFIO_AF(GPIOE_PIN3, 0U) | PIN_AFIO_AF(GPIOE_PIN4, 0U) | PIN_AFIO_AF(GPIOE_PIN5, 0U) | PIN_AFIO_AF(GPIOE_PIN6, 0U) | PIN_AFIO_AF(GPIOE_PIN7, 0U)) -#define VAL_GPIOE_AFRH (PIN_AFIO_AF(GPIOE_PIN8, 0U) | PIN_AFIO_AF(GPIOE_PIN9, 0U) | PIN_AFIO_AF(GPIOE_PIN10, 0U) | PIN_AFIO_AF(GPIOE_PIN11, 0U) | PIN_AFIO_AF(GPIOE_PIN12, 0U) | PIN_AFIO_AF(GPIOE_PIN13, 0U) | PIN_AFIO_AF(GPIOE_PIN14, 0U) | PIN_AFIO_AF(GPIOE_PIN15, 0U)) - -/* - * GPIOF setup: - * - * PF0 - PIN0 (input pullup). - * PF1 - PIN1 (input pullup). - * PF2 - PIN2 (input pullup). - * PF3 - PIN3 (input pullup). - * PF4 - PIN4 (input pullup). - * PF5 - PIN5 (input pullup). - * PF6 - PIN6 (input pullup). - * PF7 - PIN7 (input pullup). - * PF8 - PIN8 (input pullup). - * PF9 - PIN9 (input pullup). - * PF10 - PIN10 (input pullup). - * PF11 - PIN11 (input pullup). - * PF12 - PIN12 (input pullup). - * PF13 - PIN13 (input pullup). - * PF14 - PIN14 (input pullup). - * PF15 - PIN15 (input pullup). - */ -#define VAL_GPIOF_MODER (PIN_MODE_INPUT(GPIOF_PIN0) | PIN_MODE_INPUT(GPIOF_PIN1) | PIN_MODE_INPUT(GPIOF_PIN2) | PIN_MODE_INPUT(GPIOF_PIN3) | PIN_MODE_INPUT(GPIOF_PIN4) | PIN_MODE_INPUT(GPIOF_PIN5) | PIN_MODE_INPUT(GPIOF_PIN6) | PIN_MODE_INPUT(GPIOF_PIN7) | PIN_MODE_INPUT(GPIOF_PIN8) | PIN_MODE_INPUT(GPIOF_PIN9) | PIN_MODE_INPUT(GPIOF_PIN10) | PIN_MODE_INPUT(GPIOF_PIN11) | PIN_MODE_INPUT(GPIOF_PIN12) | PIN_MODE_INPUT(GPIOF_PIN13) | PIN_MODE_INPUT(GPIOF_PIN14) | PIN_MODE_INPUT(GPIOF_PIN15)) -#define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL(GPIOF_PIN0) | PIN_OTYPE_PUSHPULL(GPIOF_PIN1) | PIN_OTYPE_PUSHPULL(GPIOF_PIN2) | PIN_OTYPE_PUSHPULL(GPIOF_PIN3) | PIN_OTYPE_PUSHPULL(GPIOF_PIN4) | PIN_OTYPE_PUSHPULL(GPIOF_PIN5) | PIN_OTYPE_PUSHPULL(GPIOF_PIN6) | PIN_OTYPE_PUSHPULL(GPIOF_PIN7) | PIN_OTYPE_PUSHPULL(GPIOF_PIN8) | PIN_OTYPE_PUSHPULL(GPIOF_PIN9) | PIN_OTYPE_PUSHPULL(GPIOF_PIN10) | PIN_OTYPE_PUSHPULL(GPIOF_PIN11) | PIN_OTYPE_PUSHPULL(GPIOF_PIN12) | PIN_OTYPE_PUSHPULL(GPIOF_PIN13) | PIN_OTYPE_PUSHPULL(GPIOF_PIN14) | PIN_OTYPE_PUSHPULL(GPIOF_PIN15)) -#define VAL_GPIOF_OSPEEDR (PIN_OSPEED_HIGH(GPIOF_PIN0) | PIN_OSPEED_HIGH(GPIOF_PIN1) | PIN_OSPEED_HIGH(GPIOF_PIN2) | PIN_OSPEED_HIGH(GPIOF_PIN3) | PIN_OSPEED_HIGH(GPIOF_PIN4) | PIN_OSPEED_HIGH(GPIOF_PIN5) | PIN_OSPEED_HIGH(GPIOF_PIN6) | PIN_OSPEED_HIGH(GPIOF_PIN7) | PIN_OSPEED_HIGH(GPIOF_PIN8) | PIN_OSPEED_HIGH(GPIOF_PIN9) | PIN_OSPEED_HIGH(GPIOF_PIN10) | PIN_OSPEED_HIGH(GPIOF_PIN11) | PIN_OSPEED_HIGH(GPIOF_PIN12) | PIN_OSPEED_HIGH(GPIOF_PIN13) | PIN_OSPEED_HIGH(GPIOF_PIN14) | PIN_OSPEED_HIGH(GPIOF_PIN15)) -#define VAL_GPIOF_PUPDR (PIN_PUPDR_PULLUP(GPIOF_PIN0) | PIN_PUPDR_PULLUP(GPIOF_PIN1) | PIN_PUPDR_PULLUP(GPIOF_PIN2) | PIN_PUPDR_PULLUP(GPIOF_PIN3) | PIN_PUPDR_PULLUP(GPIOF_PIN4) | PIN_PUPDR_PULLUP(GPIOF_PIN5) | PIN_PUPDR_PULLUP(GPIOF_PIN6) | PIN_PUPDR_PULLUP(GPIOF_PIN7) | PIN_PUPDR_PULLUP(GPIOF_PIN8) | PIN_PUPDR_PULLUP(GPIOF_PIN9) | PIN_PUPDR_PULLUP(GPIOF_PIN10) | PIN_PUPDR_PULLUP(GPIOF_PIN11) | PIN_PUPDR_PULLUP(GPIOF_PIN12) | PIN_PUPDR_PULLUP(GPIOF_PIN13) | PIN_PUPDR_PULLUP(GPIOF_PIN14) | PIN_PUPDR_PULLUP(GPIOF_PIN15)) -#define VAL_GPIOF_ODR (PIN_ODR_HIGH(GPIOF_PIN0) | PIN_ODR_HIGH(GPIOF_PIN1) | PIN_ODR_HIGH(GPIOF_PIN2) | PIN_ODR_HIGH(GPIOF_PIN3) | PIN_ODR_HIGH(GPIOF_PIN4) | PIN_ODR_HIGH(GPIOF_PIN5) | PIN_ODR_HIGH(GPIOF_PIN6) | PIN_ODR_HIGH(GPIOF_PIN7) | PIN_ODR_HIGH(GPIOF_PIN8) | PIN_ODR_HIGH(GPIOF_PIN9) | PIN_ODR_HIGH(GPIOF_PIN10) | PIN_ODR_HIGH(GPIOF_PIN11) | PIN_ODR_HIGH(GPIOF_PIN12) | PIN_ODR_HIGH(GPIOF_PIN13) | PIN_ODR_HIGH(GPIOF_PIN14) | PIN_ODR_HIGH(GPIOF_PIN15)) -#define VAL_GPIOF_AFRL (PIN_AFIO_AF(GPIOF_PIN0, 0U) | PIN_AFIO_AF(GPIOF_PIN1, 0U) | PIN_AFIO_AF(GPIOF_PIN2, 0U) | PIN_AFIO_AF(GPIOF_PIN3, 0U) | PIN_AFIO_AF(GPIOF_PIN4, 0U) | PIN_AFIO_AF(GPIOF_PIN5, 0U) | PIN_AFIO_AF(GPIOF_PIN6, 0U) | PIN_AFIO_AF(GPIOF_PIN7, 0U)) -#define VAL_GPIOF_AFRH (PIN_AFIO_AF(GPIOF_PIN8, 0U) | PIN_AFIO_AF(GPIOF_PIN9, 0U) | PIN_AFIO_AF(GPIOF_PIN10, 0U) | PIN_AFIO_AF(GPIOF_PIN11, 0U) | PIN_AFIO_AF(GPIOF_PIN12, 0U) | PIN_AFIO_AF(GPIOF_PIN13, 0U) | PIN_AFIO_AF(GPIOF_PIN14, 0U) | PIN_AFIO_AF(GPIOF_PIN15, 0U)) - -/* - * GPIOG setup: - * - * PG0 - PIN0 (input pullup). - * PG1 - PIN1 (input pullup). - * PG2 - PIN2 (input pullup). - * PG3 - PIN3 (input pullup). - * PG4 - PIN4 (input pullup). - * PG5 - PIN5 (input pullup). - * PG6 - PIN6 (input pullup). - * PG7 - PIN7 (input pullup). - * PG8 - PIN8 (input pullup). - * PG9 - PIN9 (input pullup). - * PG10 - PIN10 (input pullup). - * PG11 - PIN11 (input pullup). - * PG12 - PIN12 (input pullup). - * PG13 - PIN13 (input pullup). - * PG14 - PIN14 (input pullup). - * PG15 - PIN15 (input pullup). - */ -#define VAL_GPIOG_MODER (PIN_MODE_INPUT(GPIOG_PIN0) | PIN_MODE_INPUT(GPIOG_PIN1) | PIN_MODE_INPUT(GPIOG_PIN2) | PIN_MODE_INPUT(GPIOG_PIN3) | PIN_MODE_INPUT(GPIOG_PIN4) | PIN_MODE_INPUT(GPIOG_PIN5) | PIN_MODE_INPUT(GPIOG_PIN6) | PIN_MODE_INPUT(GPIOG_PIN7) | PIN_MODE_INPUT(GPIOG_PIN8) | PIN_MODE_INPUT(GPIOG_PIN9) | PIN_MODE_INPUT(GPIOG_PIN10) | PIN_MODE_INPUT(GPIOG_PIN11) | PIN_MODE_INPUT(GPIOG_PIN12) | PIN_MODE_INPUT(GPIOG_PIN13) | PIN_MODE_INPUT(GPIOG_PIN14) | PIN_MODE_INPUT(GPIOG_PIN15)) -#define VAL_GPIOG_OTYPER (PIN_OTYPE_PUSHPULL(GPIOG_PIN0) | PIN_OTYPE_PUSHPULL(GPIOG_PIN1) | PIN_OTYPE_PUSHPULL(GPIOG_PIN2) | PIN_OTYPE_PUSHPULL(GPIOG_PIN3) | PIN_OTYPE_PUSHPULL(GPIOG_PIN4) | PIN_OTYPE_PUSHPULL(GPIOG_PIN5) | PIN_OTYPE_PUSHPULL(GPIOG_PIN6) | PIN_OTYPE_PUSHPULL(GPIOG_PIN7) | PIN_OTYPE_PUSHPULL(GPIOG_PIN8) | PIN_OTYPE_PUSHPULL(GPIOG_PIN9) | PIN_OTYPE_PUSHPULL(GPIOG_PIN10) | PIN_OTYPE_PUSHPULL(GPIOG_PIN11) | PIN_OTYPE_PUSHPULL(GPIOG_PIN12) | PIN_OTYPE_PUSHPULL(GPIOG_PIN13) | PIN_OTYPE_PUSHPULL(GPIOG_PIN14) | PIN_OTYPE_PUSHPULL(GPIOG_PIN15)) -#define VAL_GPIOG_OSPEEDR (PIN_OSPEED_HIGH(GPIOG_PIN0) | PIN_OSPEED_HIGH(GPIOG_PIN1) | PIN_OSPEED_HIGH(GPIOG_PIN2) | PIN_OSPEED_HIGH(GPIOG_PIN3) | PIN_OSPEED_HIGH(GPIOG_PIN4) | PIN_OSPEED_HIGH(GPIOG_PIN5) | PIN_OSPEED_HIGH(GPIOG_PIN6) | PIN_OSPEED_HIGH(GPIOG_PIN7) | PIN_OSPEED_HIGH(GPIOG_PIN8) | PIN_OSPEED_HIGH(GPIOG_PIN9) | PIN_OSPEED_HIGH(GPIOG_PIN10) | PIN_OSPEED_HIGH(GPIOG_PIN11) | PIN_OSPEED_HIGH(GPIOG_PIN12) | PIN_OSPEED_HIGH(GPIOG_PIN13) | PIN_OSPEED_HIGH(GPIOG_PIN14) | PIN_OSPEED_HIGH(GPIOG_PIN15)) -#define VAL_GPIOG_PUPDR (PIN_PUPDR_PULLUP(GPIOG_PIN0) | PIN_PUPDR_PULLUP(GPIOG_PIN1) | PIN_PUPDR_PULLUP(GPIOG_PIN2) | PIN_PUPDR_PULLUP(GPIOG_PIN3) | PIN_PUPDR_PULLUP(GPIOG_PIN4) | PIN_PUPDR_PULLUP(GPIOG_PIN5) | PIN_PUPDR_PULLUP(GPIOG_PIN6) | PIN_PUPDR_PULLUP(GPIOG_PIN7) | PIN_PUPDR_PULLUP(GPIOG_PIN8) | PIN_PUPDR_PULLUP(GPIOG_PIN9) | PIN_PUPDR_PULLUP(GPIOG_PIN10) | PIN_PUPDR_PULLUP(GPIOG_PIN11) | PIN_PUPDR_PULLUP(GPIOG_PIN12) | PIN_PUPDR_PULLUP(GPIOG_PIN13) | PIN_PUPDR_PULLUP(GPIOG_PIN14) | PIN_PUPDR_PULLUP(GPIOG_PIN15)) -#define VAL_GPIOG_ODR (PIN_ODR_HIGH(GPIOG_PIN0) | PIN_ODR_HIGH(GPIOG_PIN1) | PIN_ODR_HIGH(GPIOG_PIN2) | PIN_ODR_HIGH(GPIOG_PIN3) | PIN_ODR_HIGH(GPIOG_PIN4) | PIN_ODR_HIGH(GPIOG_PIN5) | PIN_ODR_HIGH(GPIOG_PIN6) | PIN_ODR_HIGH(GPIOG_PIN7) | PIN_ODR_HIGH(GPIOG_PIN8) | PIN_ODR_HIGH(GPIOG_PIN9) | PIN_ODR_HIGH(GPIOG_PIN10) | PIN_ODR_HIGH(GPIOG_PIN11) | PIN_ODR_HIGH(GPIOG_PIN12) | PIN_ODR_HIGH(GPIOG_PIN13) | PIN_ODR_HIGH(GPIOG_PIN14) | PIN_ODR_HIGH(GPIOG_PIN15)) -#define VAL_GPIOG_AFRL (PIN_AFIO_AF(GPIOG_PIN0, 0U) | PIN_AFIO_AF(GPIOG_PIN1, 0U) | PIN_AFIO_AF(GPIOG_PIN2, 0U) | PIN_AFIO_AF(GPIOG_PIN3, 0U) | PIN_AFIO_AF(GPIOG_PIN4, 0U) | PIN_AFIO_AF(GPIOG_PIN5, 0U) | PIN_AFIO_AF(GPIOG_PIN6, 0U) | PIN_AFIO_AF(GPIOG_PIN7, 0U)) -#define VAL_GPIOG_AFRH (PIN_AFIO_AF(GPIOG_PIN8, 0U) | PIN_AFIO_AF(GPIOG_PIN9, 0U) | PIN_AFIO_AF(GPIOG_PIN10, 0U) | PIN_AFIO_AF(GPIOG_PIN11, 0U) | PIN_AFIO_AF(GPIOG_PIN12, 0U) | PIN_AFIO_AF(GPIOG_PIN13, 0U) | PIN_AFIO_AF(GPIOG_PIN14, 0U) | PIN_AFIO_AF(GPIOG_PIN15, 0U)) - -/* - * GPIOH setup: - * - * PH0 - OSC_IN (input floating). - * PH1 - OSC_OUT (input floating). - * PH2 - PIN2 (input pullup). - * PH3 - PIN3 (input pullup). - * PH4 - PIN4 (input pullup). - * PH5 - PIN5 (input pullup). - * PH6 - PIN6 (input pullup). - * PH7 - PIN7 (input pullup). - * PH8 - PIN8 (input pullup). - * PH9 - PIN9 (input pullup). - * PH10 - PIN10 (input pullup). - * PH11 - PIN11 (input pullup). - * PH12 - PIN12 (input pullup). - * PH13 - PIN13 (input pullup). - * PH14 - PIN14 (input pullup). - * PH15 - PIN15 (input pullup). - */ -#define VAL_GPIOH_MODER (PIN_MODE_INPUT(GPIOH_OSC_IN) | PIN_MODE_INPUT(GPIOH_OSC_OUT) | PIN_MODE_INPUT(GPIOH_PIN2) | PIN_MODE_INPUT(GPIOH_PIN3) | PIN_MODE_INPUT(GPIOH_PIN4) | PIN_MODE_INPUT(GPIOH_PIN5) | PIN_MODE_INPUT(GPIOH_PIN6) | PIN_MODE_INPUT(GPIOH_PIN7) | PIN_MODE_INPUT(GPIOH_PIN8) | PIN_MODE_INPUT(GPIOH_PIN9) | PIN_MODE_INPUT(GPIOH_PIN10) | PIN_MODE_INPUT(GPIOH_PIN11) | PIN_MODE_INPUT(GPIOH_PIN12) | PIN_MODE_INPUT(GPIOH_PIN13) | PIN_MODE_INPUT(GPIOH_PIN14) | PIN_MODE_INPUT(GPIOH_PIN15)) -#define VAL_GPIOH_OTYPER (PIN_OTYPE_PUSHPULL(GPIOH_OSC_IN) | PIN_OTYPE_PUSHPULL(GPIOH_OSC_OUT) | PIN_OTYPE_PUSHPULL(GPIOH_PIN2) | PIN_OTYPE_PUSHPULL(GPIOH_PIN3) | PIN_OTYPE_PUSHPULL(GPIOH_PIN4) | PIN_OTYPE_PUSHPULL(GPIOH_PIN5) | PIN_OTYPE_PUSHPULL(GPIOH_PIN6) | PIN_OTYPE_PUSHPULL(GPIOH_PIN7) | PIN_OTYPE_PUSHPULL(GPIOH_PIN8) | PIN_OTYPE_PUSHPULL(GPIOH_PIN9) | PIN_OTYPE_PUSHPULL(GPIOH_PIN10) | PIN_OTYPE_PUSHPULL(GPIOH_PIN11) | PIN_OTYPE_PUSHPULL(GPIOH_PIN12) | PIN_OTYPE_PUSHPULL(GPIOH_PIN13) | PIN_OTYPE_PUSHPULL(GPIOH_PIN14) | PIN_OTYPE_PUSHPULL(GPIOH_PIN15)) -#define VAL_GPIOH_OSPEEDR (PIN_OSPEED_HIGH(GPIOH_OSC_IN) | PIN_OSPEED_HIGH(GPIOH_OSC_OUT) | PIN_OSPEED_HIGH(GPIOH_PIN2) | PIN_OSPEED_HIGH(GPIOH_PIN3) | PIN_OSPEED_HIGH(GPIOH_PIN4) | PIN_OSPEED_HIGH(GPIOH_PIN5) | PIN_OSPEED_HIGH(GPIOH_PIN6) | PIN_OSPEED_HIGH(GPIOH_PIN7) | PIN_OSPEED_HIGH(GPIOH_PIN8) | PIN_OSPEED_HIGH(GPIOH_PIN9) | PIN_OSPEED_HIGH(GPIOH_PIN10) | PIN_OSPEED_HIGH(GPIOH_PIN11) | PIN_OSPEED_HIGH(GPIOH_PIN12) | PIN_OSPEED_HIGH(GPIOH_PIN13) | PIN_OSPEED_HIGH(GPIOH_PIN14) | PIN_OSPEED_HIGH(GPIOH_PIN15)) -#define VAL_GPIOH_PUPDR (PIN_PUPDR_FLOATING(GPIOH_OSC_IN) | PIN_PUPDR_FLOATING(GPIOH_OSC_OUT) | PIN_PUPDR_PULLUP(GPIOH_PIN2) | PIN_PUPDR_PULLUP(GPIOH_PIN3) | PIN_PUPDR_PULLUP(GPIOH_PIN4) | PIN_PUPDR_PULLUP(GPIOH_PIN5) | PIN_PUPDR_PULLUP(GPIOH_PIN6) | PIN_PUPDR_PULLUP(GPIOH_PIN7) | PIN_PUPDR_PULLUP(GPIOH_PIN8) | PIN_PUPDR_PULLUP(GPIOH_PIN9) | PIN_PUPDR_PULLUP(GPIOH_PIN10) | PIN_PUPDR_PULLUP(GPIOH_PIN11) | PIN_PUPDR_PULLUP(GPIOH_PIN12) | PIN_PUPDR_PULLUP(GPIOH_PIN13) | PIN_PUPDR_PULLUP(GPIOH_PIN14) | PIN_PUPDR_PULLUP(GPIOH_PIN15)) -#define VAL_GPIOH_ODR (PIN_ODR_HIGH(GPIOH_OSC_IN) | PIN_ODR_HIGH(GPIOH_OSC_OUT) | PIN_ODR_HIGH(GPIOH_PIN2) | PIN_ODR_HIGH(GPIOH_PIN3) | PIN_ODR_HIGH(GPIOH_PIN4) | PIN_ODR_HIGH(GPIOH_PIN5) | PIN_ODR_HIGH(GPIOH_PIN6) | PIN_ODR_HIGH(GPIOH_PIN7) | PIN_ODR_HIGH(GPIOH_PIN8) | PIN_ODR_HIGH(GPIOH_PIN9) | PIN_ODR_HIGH(GPIOH_PIN10) | PIN_ODR_HIGH(GPIOH_PIN11) | PIN_ODR_HIGH(GPIOH_PIN12) | PIN_ODR_HIGH(GPIOH_PIN13) | PIN_ODR_HIGH(GPIOH_PIN14) | PIN_ODR_HIGH(GPIOH_PIN15)) -#define VAL_GPIOH_AFRL (PIN_AFIO_AF(GPIOH_OSC_IN, 0U) | PIN_AFIO_AF(GPIOH_OSC_OUT, 0U) | PIN_AFIO_AF(GPIOH_PIN2, 0U) | PIN_AFIO_AF(GPIOH_PIN3, 0U) | PIN_AFIO_AF(GPIOH_PIN4, 0U) | PIN_AFIO_AF(GPIOH_PIN5, 0U) | PIN_AFIO_AF(GPIOH_PIN6, 0U) | PIN_AFIO_AF(GPIOH_PIN7, 0U)) -#define VAL_GPIOH_AFRH (PIN_AFIO_AF(GPIOH_PIN8, 0U) | PIN_AFIO_AF(GPIOH_PIN9, 0U) | PIN_AFIO_AF(GPIOH_PIN10, 0U) | PIN_AFIO_AF(GPIOH_PIN11, 0U) | PIN_AFIO_AF(GPIOH_PIN12, 0U) | PIN_AFIO_AF(GPIOH_PIN13, 0U) | PIN_AFIO_AF(GPIOH_PIN14, 0U) | PIN_AFIO_AF(GPIOH_PIN15, 0U)) - -/* - * GPIOI setup: - * - * PI0 - PIN0 (input pullup). - * PI1 - PIN1 (input pullup). - * PI2 - PIN2 (input pullup). - * PI3 - PIN3 (input pullup). - * PI4 - PIN4 (input pullup). - * PI5 - PIN5 (input pullup). - * PI6 - PIN6 (input pullup). - * PI7 - PIN7 (input pullup). - * PI8 - PIN8 (input pullup). - * PI9 - PIN9 (input pullup). - * PI10 - PIN10 (input pullup). - * PI11 - PIN11 (input pullup). - * PI12 - PIN12 (input pullup). - * PI13 - PIN13 (input pullup). - * PI14 - PIN14 (input pullup). - * PI15 - PIN15 (input pullup). - */ -#define VAL_GPIOI_MODER (PIN_MODE_INPUT(GPIOI_PIN0) | PIN_MODE_INPUT(GPIOI_PIN1) | PIN_MODE_INPUT(GPIOI_PIN2) | PIN_MODE_INPUT(GPIOI_PIN3) | PIN_MODE_INPUT(GPIOI_PIN4) | PIN_MODE_INPUT(GPIOI_PIN5) | PIN_MODE_INPUT(GPIOI_PIN6) | PIN_MODE_INPUT(GPIOI_PIN7) | PIN_MODE_INPUT(GPIOI_PIN8) | PIN_MODE_INPUT(GPIOI_PIN9) | PIN_MODE_INPUT(GPIOI_PIN10) | PIN_MODE_INPUT(GPIOI_PIN11) | PIN_MODE_INPUT(GPIOI_PIN12) | PIN_MODE_INPUT(GPIOI_PIN13) | PIN_MODE_INPUT(GPIOI_PIN14) | PIN_MODE_INPUT(GPIOI_PIN15)) -#define VAL_GPIOI_OTYPER (PIN_OTYPE_PUSHPULL(GPIOI_PIN0) | PIN_OTYPE_PUSHPULL(GPIOI_PIN1) | PIN_OTYPE_PUSHPULL(GPIOI_PIN2) | PIN_OTYPE_PUSHPULL(GPIOI_PIN3) | PIN_OTYPE_PUSHPULL(GPIOI_PIN4) | PIN_OTYPE_PUSHPULL(GPIOI_PIN5) | PIN_OTYPE_PUSHPULL(GPIOI_PIN6) | PIN_OTYPE_PUSHPULL(GPIOI_PIN7) | PIN_OTYPE_PUSHPULL(GPIOI_PIN8) | PIN_OTYPE_PUSHPULL(GPIOI_PIN9) | PIN_OTYPE_PUSHPULL(GPIOI_PIN10) | PIN_OTYPE_PUSHPULL(GPIOI_PIN11) | PIN_OTYPE_PUSHPULL(GPIOI_PIN12) | PIN_OTYPE_PUSHPULL(GPIOI_PIN13) | PIN_OTYPE_PUSHPULL(GPIOI_PIN14) | PIN_OTYPE_PUSHPULL(GPIOI_PIN15)) -#define VAL_GPIOI_OSPEEDR (PIN_OSPEED_HIGH(GPIOI_PIN0) | PIN_OSPEED_HIGH(GPIOI_PIN1) | PIN_OSPEED_HIGH(GPIOI_PIN2) | PIN_OSPEED_HIGH(GPIOI_PIN3) | PIN_OSPEED_HIGH(GPIOI_PIN4) | PIN_OSPEED_HIGH(GPIOI_PIN5) | PIN_OSPEED_HIGH(GPIOI_PIN6) | PIN_OSPEED_HIGH(GPIOI_PIN7) | PIN_OSPEED_HIGH(GPIOI_PIN8) | PIN_OSPEED_HIGH(GPIOI_PIN9) | PIN_OSPEED_HIGH(GPIOI_PIN10) | PIN_OSPEED_HIGH(GPIOI_PIN11) | PIN_OSPEED_HIGH(GPIOI_PIN12) | PIN_OSPEED_HIGH(GPIOI_PIN13) | PIN_OSPEED_HIGH(GPIOI_PIN14) | PIN_OSPEED_HIGH(GPIOI_PIN15)) -#define VAL_GPIOI_PUPDR (PIN_PUPDR_PULLUP(GPIOI_PIN0) | PIN_PUPDR_PULLUP(GPIOI_PIN1) | PIN_PUPDR_PULLUP(GPIOI_PIN2) | PIN_PUPDR_PULLUP(GPIOI_PIN3) | PIN_PUPDR_PULLUP(GPIOI_PIN4) | PIN_PUPDR_PULLUP(GPIOI_PIN5) | PIN_PUPDR_PULLUP(GPIOI_PIN6) | PIN_PUPDR_PULLUP(GPIOI_PIN7) | PIN_PUPDR_PULLUP(GPIOI_PIN8) | PIN_PUPDR_PULLUP(GPIOI_PIN9) | PIN_PUPDR_PULLUP(GPIOI_PIN10) | PIN_PUPDR_PULLUP(GPIOI_PIN11) | PIN_PUPDR_PULLUP(GPIOI_PIN12) | PIN_PUPDR_PULLUP(GPIOI_PIN13) | PIN_PUPDR_PULLUP(GPIOI_PIN14) | PIN_PUPDR_PULLUP(GPIOI_PIN15)) -#define VAL_GPIOI_ODR (PIN_ODR_HIGH(GPIOI_PIN0) | PIN_ODR_HIGH(GPIOI_PIN1) | PIN_ODR_HIGH(GPIOI_PIN2) | PIN_ODR_HIGH(GPIOI_PIN3) | PIN_ODR_HIGH(GPIOI_PIN4) | PIN_ODR_HIGH(GPIOI_PIN5) | PIN_ODR_HIGH(GPIOI_PIN6) | PIN_ODR_HIGH(GPIOI_PIN7) | PIN_ODR_HIGH(GPIOI_PIN8) | PIN_ODR_HIGH(GPIOI_PIN9) | PIN_ODR_HIGH(GPIOI_PIN10) | PIN_ODR_HIGH(GPIOI_PIN11) | PIN_ODR_HIGH(GPIOI_PIN12) | PIN_ODR_HIGH(GPIOI_PIN13) | PIN_ODR_HIGH(GPIOI_PIN14) | PIN_ODR_HIGH(GPIOI_PIN15)) -#define VAL_GPIOI_AFRL (PIN_AFIO_AF(GPIOI_PIN0, 0U) | PIN_AFIO_AF(GPIOI_PIN1, 0U) | PIN_AFIO_AF(GPIOI_PIN2, 0U) | PIN_AFIO_AF(GPIOI_PIN3, 0U) | PIN_AFIO_AF(GPIOI_PIN4, 0U) | PIN_AFIO_AF(GPIOI_PIN5, 0U) | PIN_AFIO_AF(GPIOI_PIN6, 0U) | PIN_AFIO_AF(GPIOI_PIN7, 0U)) -#define VAL_GPIOI_AFRH (PIN_AFIO_AF(GPIOI_PIN8, 0U) | PIN_AFIO_AF(GPIOI_PIN9, 0U) | PIN_AFIO_AF(GPIOI_PIN10, 0U) | PIN_AFIO_AF(GPIOI_PIN11, 0U) | PIN_AFIO_AF(GPIOI_PIN12, 0U) | PIN_AFIO_AF(GPIOI_PIN13, 0U) | PIN_AFIO_AF(GPIOI_PIN14, 0U) | PIN_AFIO_AF(GPIOI_PIN15, 0U)) - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#if !defined(_FROM_ASM_) -# ifdef __cplusplus -extern "C" { -# endif -void boardInit(void); -# ifdef __cplusplus -} -# endif -#endif /* _FROM_ASM_ */ - -#endif /* BOARD_H */ diff --git a/drivers/boards/BLACKPILL_STM32_F411/cfg/board.chcfg b/drivers/boards/BLACKPILL_STM32_F411/cfg/board.chcfg deleted file mode 100644 index 3095409cca56..000000000000 --- a/drivers/boards/BLACKPILL_STM32_F411/cfg/board.chcfg +++ /dev/null @@ -1,1193 +0,0 @@ - - - - - resources/gencfg/processors/boards/stm32f4xx/templates - .. - 5.0.x - - STMicroelectronics STM32 Nucleo64-F411RE - ST_NUCLEO64_F411RE - - STM32F411xE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/drivers/boards/BLACKPILL_STM32_F411/cfg/board.fmpp b/drivers/boards/BLACKPILL_STM32_F411/cfg/board.fmpp deleted file mode 100644 index 41754c1414a9..000000000000 --- a/drivers/boards/BLACKPILL_STM32_F411/cfg/board.fmpp +++ /dev/null @@ -1,15 +0,0 @@ -sourceRoot: ../../../../../tools/ftl/processors/boards/stm32f4xx/templates -outputRoot: .. -dataRoot: . - -freemarkerLinks: { - lib: ../../../../../tools/ftl/libs -} - -data : { - doc1:xml ( - board.chcfg - { - } - ) -} diff --git a/drivers/boards/GENERIC_STM32_F072XB/cfg/board.chcfg b/drivers/boards/GENERIC_STM32_F072XB/cfg/board.chcfg deleted file mode 100644 index e6ceecb62e89..000000000000 --- a/drivers/boards/GENERIC_STM32_F072XB/cfg/board.chcfg +++ /dev/null @@ -1,703 +0,0 @@ - - - - - resources/gencfg/processors/boards/stm32f0xx/templates - .. - 5.0.x - - ST STM32F072B-Discovery - ST_STM32F072B_DISCOVERY - - STM32F072xB - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/drivers/boards/GENERIC_STM32_F072XB/cfg/board.fmpp b/drivers/boards/GENERIC_STM32_F072XB/cfg/board.fmpp deleted file mode 100644 index 55cd396e41cf..000000000000 --- a/drivers/boards/GENERIC_STM32_F072XB/cfg/board.fmpp +++ /dev/null @@ -1,15 +0,0 @@ -sourceRoot: ../../../../../tools/ftl/processors/boards/stm32f0xx/templates -outputRoot: .. -dataRoot: . - -freemarkerLinks: { - lib: ../../../../../tools/ftl/libs -} - -data : { - doc1:xml ( - board.chcfg - { - } - ) -} diff --git a/drivers/boards/GENERIC_STM32_F303XC/board.mk b/drivers/boards/GENERIC_STM32_F303XC/board.mk deleted file mode 100644 index 43377629a3cc..000000000000 --- a/drivers/boards/GENERIC_STM32_F303XC/board.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List of all the board related files. -BOARDSRC = $(BOARD_PATH)/boards/GENERIC_STM32_F303XC/board.c - -# Required include directories -BOARDINC = $(BOARD_PATH)/boards/GENERIC_STM32_F303XC diff --git a/drivers/boards/IC_TEENSY_3_1/board.mk b/drivers/boards/IC_TEENSY_3_1/board.mk deleted file mode 100644 index 62f5b751c7d1..000000000000 --- a/drivers/boards/IC_TEENSY_3_1/board.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List of all the board related files. -BOARDSRC = $(BOARD_PATH)/boards/IC_TEENSY_3_1/board.c - -# Required include directories -BOARDINC = $(BOARD_PATH)/boards/IC_TEENSY_3_1 diff --git a/drivers/boards/STM32_F103_STM32DUINO/board.mk b/drivers/boards/STM32_F103_STM32DUINO/board.mk deleted file mode 100644 index 81141bdfd95b..000000000000 --- a/drivers/boards/STM32_F103_STM32DUINO/board.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List of all the board related files. -BOARDSRC = $(BOARD_PATH)/boards/STM32_F103_STM32DUINO/board.c - -# Required include directories -BOARDINC = $(BOARD_PATH)/boards/STM32_F103_STM32DUINO diff --git a/keyboards/handwired/onekey/blackpill_f401/halconf.h b/keyboards/handwired/onekey/blackpill_f401/halconf.h index a8db392aaa6c..d73c214ec64c 100644 --- a/keyboards/handwired/onekey/blackpill_f401/halconf.h +++ b/keyboards/handwired/onekey/blackpill_f401/halconf.h @@ -1,525 +1,20 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file templates/halconf.h - * @brief HAL configuration header. - * @details HAL configuration file, this file allows to enable or disable the - * various device drivers from your application. You may also use - * this file in order to override the device drivers default settings. +/* Copyright 2020 Nick Brassel (tzarc) * - * @addtogroup HAL_CONF - * @{ - */ - -#ifndef HALCONF_H -#define HALCONF_H - -#define _CHIBIOS_HAL_CONF_ -#define _CHIBIOS_HAL_CONF_VER_7_0_ - -#include "mcuconf.h" - -/** - * @brief Enables the PAL subsystem. - */ -#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) -#define HAL_USE_PAL TRUE -#endif - -/** - * @brief Enables the ADC subsystem. - */ -#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) -#define HAL_USE_ADC FALSE -#endif - -/** - * @brief Enables the CAN subsystem. - */ -#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) -#define HAL_USE_CAN FALSE -#endif - -/** - * @brief Enables the cryptographic subsystem. - */ -#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__) -#define HAL_USE_CRY FALSE -#endif - -/** - * @brief Enables the DAC subsystem. - */ -#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) -#define HAL_USE_DAC FALSE -#endif - -/** - * @brief Enables the GPT subsystem. - */ -#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) -#define HAL_USE_GPT FALSE -#endif - -/** - * @brief Enables the I2C subsystem. - */ -#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) -#define HAL_USE_I2C FALSE -#endif - -/** - * @brief Enables the I2S subsystem. - */ -#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) -#define HAL_USE_I2S FALSE -#endif - -/** - * @brief Enables the ICU subsystem. - */ -#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) -#define HAL_USE_ICU FALSE -#endif - -/** - * @brief Enables the MAC subsystem. - */ -#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) -#define HAL_USE_MAC FALSE -#endif - -/** - * @brief Enables the MMC_SPI subsystem. - */ -#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) -#define HAL_USE_MMC_SPI FALSE -#endif - -/** - * @brief Enables the PWM subsystem. - */ -#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) -#define HAL_USE_PWM FALSE -#endif - -/** - * @brief Enables the RTC subsystem. - */ -#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) -#define HAL_USE_RTC FALSE -#endif - -/** - * @brief Enables the SDC subsystem. - */ -#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) -#define HAL_USE_SDC FALSE -#endif - -/** - * @brief Enables the SERIAL subsystem. - */ -#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL FALSE -#endif - -/** - * @brief Enables the SERIAL over USB subsystem. - */ -#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL_USB FALSE -#endif - -/** - * @brief Enables the SIO subsystem. - */ -#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__) -#define HAL_USE_SIO FALSE -#endif - -/** - * @brief Enables the SPI subsystem. - */ -#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) -#define HAL_USE_SPI FALSE -#endif - -/** - * @brief Enables the TRNG subsystem. - */ -#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__) -#define HAL_USE_TRNG FALSE -#endif - -/** - * @brief Enables the UART subsystem. - */ -#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) -#define HAL_USE_UART FALSE -#endif - -/** - * @brief Enables the USB subsystem. - */ -#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) -#define HAL_USE_USB TRUE -#endif - -/** - * @brief Enables the WDG subsystem. - */ -#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) -#define HAL_USE_WDG FALSE -#endif - -/** - * @brief Enables the WSPI subsystem. - */ -#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__) -#define HAL_USE_WSPI FALSE -#endif - -/*===========================================================================*/ -/* PAL driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__) -#define PAL_USE_CALLBACKS FALSE -#endif - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__) -#define PAL_USE_WAIT FALSE -#endif - -/*===========================================================================*/ -/* ADC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) -#define ADC_USE_WAIT TRUE -#endif - -/** - * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define ADC_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* CAN driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Sleep mode related APIs inclusion switch. - */ -#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) -#define CAN_USE_SLEEP_MODE TRUE -#endif - -/** - * @brief Enforces the driver to use direct callbacks rather than OSAL events. - */ -#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__) -#define CAN_ENFORCE_USE_CALLBACKS FALSE -#endif - -/*===========================================================================*/ -/* CRY driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables the SW fall-back of the cryptographic driver. - * @details When enabled, this option, activates a fall-back software - * implementation for algorithms not supported by the underlying - * hardware. - * @note Fall-back implementations may not be present for all algorithms. - */ -#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__) -#define HAL_CRY_USE_FALLBACK FALSE -#endif - -/** - * @brief Makes the driver forcibly use the fall-back implementations. - */ -#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__) -#define HAL_CRY_ENFORCE_FALLBACK FALSE -#endif - -/*===========================================================================*/ -/* DAC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__) -#define DAC_USE_WAIT TRUE -#endif - -/** - * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define DAC_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* I2C driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables the mutual exclusion APIs on the I2C bus. - */ -#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define I2C_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* MAC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables the zero-copy API. - */ -#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) -#define MAC_USE_ZERO_COPY FALSE -#endif - -/** - * @brief Enables an event sources for incoming packets. - */ -#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) -#define MAC_USE_EVENTS TRUE -#endif - -/*===========================================================================*/ -/* MMC_SPI driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - * This option is recommended also if the SPI driver does not - * use a DMA channel and heavily loads the CPU. - */ -#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) -#define MMC_NICE_WAITING TRUE -#endif - -/*===========================================================================*/ -/* SDC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Number of initialization attempts before rejecting the card. - * @note Attempts are performed at 10mS intervals. - */ -#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) -#define SDC_INIT_RETRY 100 -#endif - -/** - * @brief Include support for MMC cards. - * @note MMC support is not yet implemented so this option must be kept - * at @p FALSE. - */ -#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) -#define SDC_MMC_SUPPORT FALSE -#endif - -/** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - */ -#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) -#define SDC_NICE_WAITING TRUE -#endif - -/** - * @brief OCR initialization constant for V20 cards. - */ -#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__) -#define SDC_INIT_OCR_V20 0x50FF8000U -#endif - -/** - * @brief OCR initialization constant for non-V20 cards. - */ -#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__) -#define SDC_INIT_OCR 0x80100000U -#endif - -/*===========================================================================*/ -/* SERIAL driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Default bit rate. - * @details Configuration parameter, this is the baud rate selected for the - * default configuration. - */ -#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) -#define SERIAL_DEFAULT_BITRATE 38400 -#endif - -/** - * @brief Serial buffers size. - * @details Configuration parameter, you can change the depth of the queue - * buffers depending on the requirements of your application. - * @note The default is 16 bytes for both the transmission and receive - * buffers. - */ -#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_BUFFERS_SIZE 16 -#endif - -/*===========================================================================*/ -/* SERIAL_USB driver related setting. */ -/*===========================================================================*/ - -/** - * @brief Serial over USB buffers size. - * @details Configuration parameter, the buffer size must be a multiple of - * the USB data endpoint maximum packet size. - * @note The default is 256 bytes for both the transmission and receive - * buffers. - */ -#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_USB_BUFFERS_SIZE 256 -#endif - -/** - * @brief Serial over USB number of buffers. - * @note The default is 2 buffers. - */ -#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__) -#define SERIAL_USB_BUFFERS_NUMBER 2 -#endif - -/*===========================================================================*/ -/* SPI driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) -#define SPI_USE_WAIT TRUE -#endif - -/** - * @brief Enables circular transfers APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__) -#define SPI_USE_CIRCULAR FALSE -#endif - - -/** - * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define SPI_USE_MUTUAL_EXCLUSION TRUE -#endif - -/** - * @brief Handling method for SPI CS line. - * @note Disabling this option saves both code and data space. - */ -#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__) -#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD -#endif - -/*===========================================================================*/ -/* UART driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__) -#define UART_USE_WAIT FALSE -#endif - -/** - * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define UART_USE_MUTUAL_EXCLUSION FALSE -#endif - -/*===========================================================================*/ -/* USB driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) -#define USB_USE_WAIT TRUE -#endif - -/*===========================================================================*/ -/* WSPI driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__) -#define WSPI_USE_WAIT TRUE -#endif - -/** - * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs. - * @note Disabling this option saves both code and data space. + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define WSPI_USE_MUTUAL_EXCLUSION TRUE -#endif +#pragma once -#endif /* HALCONF_H */ +#define HAL_USE_I2C TRUE -/** @} */ +#include_next "halconf.h" diff --git a/keyboards/handwired/onekey/blackpill_f401/mcuconf.h b/keyboards/handwired/onekey/blackpill_f401/mcuconf.h index ba6e934fe7bd..33e07847b413 100644 --- a/keyboards/handwired/onekey/blackpill_f401/mcuconf.h +++ b/keyboards/handwired/onekey/blackpill_f401/mcuconf.h @@ -1,253 +1,21 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef MCUCONF_H -#define MCUCONF_H - -/* - * STM32F4xx drivers configuration. - * The following settings override the default settings present in - * the various device driver implementation headers. - * Note that the settings for each driver only have effect if the whole - * driver is enabled in halconf.h. +/* Copyright 2020 Nick Brassel (tzarc) * - * IRQ priorities: - * 15...0 Lowest...Highest. + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * DMA priorities: - * 0...3 Lowest...Highest. - */ - -#define STM32F4xx_MCUCONF - -/* - * HAL driver system settings. - */ -#define STM32_NO_INIT FALSE -#define STM32_HSI_ENABLED TRUE -#define STM32_LSI_ENABLED TRUE -#define STM32_HSE_ENABLED TRUE -#define STM32_LSE_ENABLED FALSE -#define STM32_CLOCK48_REQUIRED TRUE -#define STM32_SW STM32_SW_PLL -#define STM32_PLLSRC STM32_PLLSRC_HSE -#define STM32_PLLM_VALUE 25 -#define STM32_PLLN_VALUE 336 -#define STM32_PLLP_VALUE 4 -#define STM32_PLLQ_VALUE 7 -#define STM32_HPRE STM32_HPRE_DIV1 -#define STM32_PPRE1 STM32_PPRE1_DIV4 -#define STM32_PPRE2 STM32_PPRE2_DIV2 -#define STM32_RTCSEL STM32_RTCSEL_LSI -#define STM32_RTCPRE_VALUE 8 -#define STM32_MCO1SEL STM32_MCO1SEL_HSI -#define STM32_MCO1PRE STM32_MCO1PRE_DIV1 -#define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK -#define STM32_MCO2PRE STM32_MCO2PRE_DIV5 -#define STM32_I2SSRC STM32_I2SSRC_CKIN -#define STM32_PLLI2SN_VALUE 192 -#define STM32_PLLI2SR_VALUE 5 -#define STM32_PVD_ENABLE FALSE -#define STM32_PLS STM32_PLS_LEV0 -#define STM32_BKPRAM_ENABLE FALSE - -/* - * IRQ system settings. - */ -#define STM32_IRQ_EXTI0_PRIORITY 6 -#define STM32_IRQ_EXTI1_PRIORITY 6 -#define STM32_IRQ_EXTI2_PRIORITY 6 -#define STM32_IRQ_EXTI3_PRIORITY 6 -#define STM32_IRQ_EXTI4_PRIORITY 6 -#define STM32_IRQ_EXTI5_9_PRIORITY 6 -#define STM32_IRQ_EXTI10_15_PRIORITY 6 -#define STM32_IRQ_EXTI16_PRIORITY 6 -#define STM32_IRQ_EXTI17_PRIORITY 15 -#define STM32_IRQ_EXTI18_PRIORITY 6 -#define STM32_IRQ_EXTI19_PRIORITY 6 -#define STM32_IRQ_EXTI20_PRIORITY 6 -#define STM32_IRQ_EXTI21_PRIORITY 15 -#define STM32_IRQ_EXTI22_PRIORITY 15 - -/* - * ADC driver system settings. - */ -#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4 -#define STM32_ADC_USE_ADC1 FALSE -#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4) -#define STM32_ADC_ADC1_DMA_PRIORITY 2 -#define STM32_ADC_IRQ_PRIORITY 6 -#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6 - -/* - * GPT driver system settings. - */ -#define STM32_GPT_USE_TIM1 FALSE -#define STM32_GPT_USE_TIM2 FALSE -#define STM32_GPT_USE_TIM3 FALSE -#define STM32_GPT_USE_TIM4 FALSE -#define STM32_GPT_USE_TIM5 FALSE -#define STM32_GPT_USE_TIM9 FALSE -#define STM32_GPT_USE_TIM11 FALSE -#define STM32_GPT_TIM1_IRQ_PRIORITY 7 -#define STM32_GPT_TIM2_IRQ_PRIORITY 7 -#define STM32_GPT_TIM3_IRQ_PRIORITY 7 -#define STM32_GPT_TIM4_IRQ_PRIORITY 7 -#define STM32_GPT_TIM5_IRQ_PRIORITY 7 -#define STM32_GPT_TIM9_IRQ_PRIORITY 7 -#define STM32_GPT_TIM11_IRQ_PRIORITY 7 - -/* - * I2C driver system settings. - */ -#define STM32_I2C_USE_I2C1 FALSE -#define STM32_I2C_USE_I2C2 FALSE -#define STM32_I2C_USE_I2C3 FALSE -#define STM32_I2C_BUSY_TIMEOUT 50 -#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) -#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) -#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) -#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) -#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) -#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) -#define STM32_I2C_I2C1_IRQ_PRIORITY 5 -#define STM32_I2C_I2C2_IRQ_PRIORITY 5 -#define STM32_I2C_I2C3_IRQ_PRIORITY 5 -#define STM32_I2C_I2C1_DMA_PRIORITY 3 -#define STM32_I2C_I2C2_DMA_PRIORITY 3 -#define STM32_I2C_I2C3_DMA_PRIORITY 3 -#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") - -/* - * I2S driver system settings. - */ -#define STM32_I2S_USE_SPI2 FALSE -#define STM32_I2S_USE_SPI3 FALSE -#define STM32_I2S_SPI2_IRQ_PRIORITY 10 -#define STM32_I2S_SPI3_IRQ_PRIORITY 10 -#define STM32_I2S_SPI2_DMA_PRIORITY 1 -#define STM32_I2S_SPI3_DMA_PRIORITY 1 -#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) -#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) -#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) -#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) -#define STM32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure") - -/* - * ICU driver system settings. - */ -#define STM32_ICU_USE_TIM1 FALSE -#define STM32_ICU_USE_TIM2 FALSE -#define STM32_ICU_USE_TIM3 FALSE -#define STM32_ICU_USE_TIM4 FALSE -#define STM32_ICU_USE_TIM5 FALSE -#define STM32_ICU_USE_TIM9 FALSE -#define STM32_ICU_TIM1_IRQ_PRIORITY 7 -#define STM32_ICU_TIM2_IRQ_PRIORITY 7 -#define STM32_ICU_TIM3_IRQ_PRIORITY 7 -#define STM32_ICU_TIM4_IRQ_PRIORITY 7 -#define STM32_ICU_TIM5_IRQ_PRIORITY 7 -#define STM32_ICU_TIM9_IRQ_PRIORITY 7 - -/* - * PWM driver system settings. - */ -#define STM32_PWM_USE_ADVANCED FALSE -#define STM32_PWM_USE_TIM1 FALSE -#define STM32_PWM_USE_TIM2 FALSE -#define STM32_PWM_USE_TIM3 FALSE -#define STM32_PWM_USE_TIM4 FALSE -#define STM32_PWM_USE_TIM5 FALSE -#define STM32_PWM_USE_TIM9 FALSE -#define STM32_PWM_TIM1_IRQ_PRIORITY 7 -#define STM32_PWM_TIM2_IRQ_PRIORITY 7 -#define STM32_PWM_TIM3_IRQ_PRIORITY 7 -#define STM32_PWM_TIM4_IRQ_PRIORITY 7 -#define STM32_PWM_TIM5_IRQ_PRIORITY 7 -#define STM32_PWM_TIM9_IRQ_PRIORITY 7 - -/* - * SERIAL driver system settings. - */ -#define STM32_SERIAL_USE_USART1 FALSE -#define STM32_SERIAL_USE_USART2 FALSE -#define STM32_SERIAL_USE_USART6 FALSE -#define STM32_SERIAL_USART1_PRIORITY 12 -#define STM32_SERIAL_USART2_PRIORITY 12 -#define STM32_SERIAL_USART6_PRIORITY 12 - -/* - * SPI driver system settings. - */ -#define STM32_SPI_USE_SPI1 FALSE -#define STM32_SPI_USE_SPI2 FALSE -#define STM32_SPI_USE_SPI3 FALSE -#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0) -#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3) -#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) -#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) -#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) -#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) -#define STM32_SPI_SPI1_DMA_PRIORITY 1 -#define STM32_SPI_SPI2_DMA_PRIORITY 1 -#define STM32_SPI_SPI3_DMA_PRIORITY 1 -#define STM32_SPI_SPI1_IRQ_PRIORITY 10 -#define STM32_SPI_SPI2_IRQ_PRIORITY 10 -#define STM32_SPI_SPI3_IRQ_PRIORITY 10 -#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") - -/* - * ST driver system settings. - */ -#define STM32_ST_IRQ_PRIORITY 8 -#define STM32_ST_USE_TIMER 2 - -/* - * UART driver system settings. - */ -#define STM32_UART_USE_USART1 FALSE -#define STM32_UART_USE_USART2 FALSE -#define STM32_UART_USE_USART6 FALSE -#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) -#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) -#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5) -#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) -#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2) -#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) -#define STM32_UART_USART1_IRQ_PRIORITY 12 -#define STM32_UART_USART2_IRQ_PRIORITY 12 -#define STM32_UART_USART6_IRQ_PRIORITY 12 -#define STM32_UART_USART1_DMA_PRIORITY 0 -#define STM32_UART_USART2_DMA_PRIORITY 0 -#define STM32_UART_USART6_DMA_PRIORITY 0 -#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") - -/* - * USB driver system settings. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#define STM32_USB_USE_OTG1 TRUE -#define STM32_USB_OTG1_IRQ_PRIORITY 14 -#define STM32_USB_OTG1_RX_FIFO_SIZE 512 -#define STM32_USB_OTG_THREAD_PRIO NORMALPRIO+1 -#define STM32_USB_OTG_THREAD_STACK_SIZE 128 -#define STM32_USB_OTGFIFO_FILL_BASEPRI 0 +#pragma once -/* - * WDG driver system settings. - */ -#define STM32_WDG_USE_IWDG FALSE +#include_next "mcuconf.h" -#endif /* MCUCONF_H */ +#undef STM32_I2C_USE_I2C1 +#define STM32_I2C_USE_I2C1 TRUE diff --git a/keyboards/handwired/onekey/blackpill_f411/halconf.h b/keyboards/handwired/onekey/blackpill_f411/halconf.h index a8db392aaa6c..d73c214ec64c 100644 --- a/keyboards/handwired/onekey/blackpill_f411/halconf.h +++ b/keyboards/handwired/onekey/blackpill_f411/halconf.h @@ -1,525 +1,20 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file templates/halconf.h - * @brief HAL configuration header. - * @details HAL configuration file, this file allows to enable or disable the - * various device drivers from your application. You may also use - * this file in order to override the device drivers default settings. +/* Copyright 2020 Nick Brassel (tzarc) * - * @addtogroup HAL_CONF - * @{ - */ - -#ifndef HALCONF_H -#define HALCONF_H - -#define _CHIBIOS_HAL_CONF_ -#define _CHIBIOS_HAL_CONF_VER_7_0_ - -#include "mcuconf.h" - -/** - * @brief Enables the PAL subsystem. - */ -#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) -#define HAL_USE_PAL TRUE -#endif - -/** - * @brief Enables the ADC subsystem. - */ -#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) -#define HAL_USE_ADC FALSE -#endif - -/** - * @brief Enables the CAN subsystem. - */ -#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) -#define HAL_USE_CAN FALSE -#endif - -/** - * @brief Enables the cryptographic subsystem. - */ -#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__) -#define HAL_USE_CRY FALSE -#endif - -/** - * @brief Enables the DAC subsystem. - */ -#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) -#define HAL_USE_DAC FALSE -#endif - -/** - * @brief Enables the GPT subsystem. - */ -#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) -#define HAL_USE_GPT FALSE -#endif - -/** - * @brief Enables the I2C subsystem. - */ -#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) -#define HAL_USE_I2C FALSE -#endif - -/** - * @brief Enables the I2S subsystem. - */ -#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) -#define HAL_USE_I2S FALSE -#endif - -/** - * @brief Enables the ICU subsystem. - */ -#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) -#define HAL_USE_ICU FALSE -#endif - -/** - * @brief Enables the MAC subsystem. - */ -#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) -#define HAL_USE_MAC FALSE -#endif - -/** - * @brief Enables the MMC_SPI subsystem. - */ -#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) -#define HAL_USE_MMC_SPI FALSE -#endif - -/** - * @brief Enables the PWM subsystem. - */ -#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) -#define HAL_USE_PWM FALSE -#endif - -/** - * @brief Enables the RTC subsystem. - */ -#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) -#define HAL_USE_RTC FALSE -#endif - -/** - * @brief Enables the SDC subsystem. - */ -#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) -#define HAL_USE_SDC FALSE -#endif - -/** - * @brief Enables the SERIAL subsystem. - */ -#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL FALSE -#endif - -/** - * @brief Enables the SERIAL over USB subsystem. - */ -#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL_USB FALSE -#endif - -/** - * @brief Enables the SIO subsystem. - */ -#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__) -#define HAL_USE_SIO FALSE -#endif - -/** - * @brief Enables the SPI subsystem. - */ -#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) -#define HAL_USE_SPI FALSE -#endif - -/** - * @brief Enables the TRNG subsystem. - */ -#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__) -#define HAL_USE_TRNG FALSE -#endif - -/** - * @brief Enables the UART subsystem. - */ -#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) -#define HAL_USE_UART FALSE -#endif - -/** - * @brief Enables the USB subsystem. - */ -#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) -#define HAL_USE_USB TRUE -#endif - -/** - * @brief Enables the WDG subsystem. - */ -#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) -#define HAL_USE_WDG FALSE -#endif - -/** - * @brief Enables the WSPI subsystem. - */ -#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__) -#define HAL_USE_WSPI FALSE -#endif - -/*===========================================================================*/ -/* PAL driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__) -#define PAL_USE_CALLBACKS FALSE -#endif - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__) -#define PAL_USE_WAIT FALSE -#endif - -/*===========================================================================*/ -/* ADC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) -#define ADC_USE_WAIT TRUE -#endif - -/** - * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define ADC_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* CAN driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Sleep mode related APIs inclusion switch. - */ -#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) -#define CAN_USE_SLEEP_MODE TRUE -#endif - -/** - * @brief Enforces the driver to use direct callbacks rather than OSAL events. - */ -#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__) -#define CAN_ENFORCE_USE_CALLBACKS FALSE -#endif - -/*===========================================================================*/ -/* CRY driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables the SW fall-back of the cryptographic driver. - * @details When enabled, this option, activates a fall-back software - * implementation for algorithms not supported by the underlying - * hardware. - * @note Fall-back implementations may not be present for all algorithms. - */ -#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__) -#define HAL_CRY_USE_FALLBACK FALSE -#endif - -/** - * @brief Makes the driver forcibly use the fall-back implementations. - */ -#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__) -#define HAL_CRY_ENFORCE_FALLBACK FALSE -#endif - -/*===========================================================================*/ -/* DAC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__) -#define DAC_USE_WAIT TRUE -#endif - -/** - * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define DAC_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* I2C driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables the mutual exclusion APIs on the I2C bus. - */ -#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define I2C_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* MAC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables the zero-copy API. - */ -#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) -#define MAC_USE_ZERO_COPY FALSE -#endif - -/** - * @brief Enables an event sources for incoming packets. - */ -#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) -#define MAC_USE_EVENTS TRUE -#endif - -/*===========================================================================*/ -/* MMC_SPI driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - * This option is recommended also if the SPI driver does not - * use a DMA channel and heavily loads the CPU. - */ -#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) -#define MMC_NICE_WAITING TRUE -#endif - -/*===========================================================================*/ -/* SDC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Number of initialization attempts before rejecting the card. - * @note Attempts are performed at 10mS intervals. - */ -#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) -#define SDC_INIT_RETRY 100 -#endif - -/** - * @brief Include support for MMC cards. - * @note MMC support is not yet implemented so this option must be kept - * at @p FALSE. - */ -#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) -#define SDC_MMC_SUPPORT FALSE -#endif - -/** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - */ -#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) -#define SDC_NICE_WAITING TRUE -#endif - -/** - * @brief OCR initialization constant for V20 cards. - */ -#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__) -#define SDC_INIT_OCR_V20 0x50FF8000U -#endif - -/** - * @brief OCR initialization constant for non-V20 cards. - */ -#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__) -#define SDC_INIT_OCR 0x80100000U -#endif - -/*===========================================================================*/ -/* SERIAL driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Default bit rate. - * @details Configuration parameter, this is the baud rate selected for the - * default configuration. - */ -#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) -#define SERIAL_DEFAULT_BITRATE 38400 -#endif - -/** - * @brief Serial buffers size. - * @details Configuration parameter, you can change the depth of the queue - * buffers depending on the requirements of your application. - * @note The default is 16 bytes for both the transmission and receive - * buffers. - */ -#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_BUFFERS_SIZE 16 -#endif - -/*===========================================================================*/ -/* SERIAL_USB driver related setting. */ -/*===========================================================================*/ - -/** - * @brief Serial over USB buffers size. - * @details Configuration parameter, the buffer size must be a multiple of - * the USB data endpoint maximum packet size. - * @note The default is 256 bytes for both the transmission and receive - * buffers. - */ -#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_USB_BUFFERS_SIZE 256 -#endif - -/** - * @brief Serial over USB number of buffers. - * @note The default is 2 buffers. - */ -#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__) -#define SERIAL_USB_BUFFERS_NUMBER 2 -#endif - -/*===========================================================================*/ -/* SPI driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) -#define SPI_USE_WAIT TRUE -#endif - -/** - * @brief Enables circular transfers APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__) -#define SPI_USE_CIRCULAR FALSE -#endif - - -/** - * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define SPI_USE_MUTUAL_EXCLUSION TRUE -#endif - -/** - * @brief Handling method for SPI CS line. - * @note Disabling this option saves both code and data space. - */ -#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__) -#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD -#endif - -/*===========================================================================*/ -/* UART driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__) -#define UART_USE_WAIT FALSE -#endif - -/** - * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define UART_USE_MUTUAL_EXCLUSION FALSE -#endif - -/*===========================================================================*/ -/* USB driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) -#define USB_USE_WAIT TRUE -#endif - -/*===========================================================================*/ -/* WSPI driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__) -#define WSPI_USE_WAIT TRUE -#endif - -/** - * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs. - * @note Disabling this option saves both code and data space. + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define WSPI_USE_MUTUAL_EXCLUSION TRUE -#endif +#pragma once -#endif /* HALCONF_H */ +#define HAL_USE_I2C TRUE -/** @} */ +#include_next "halconf.h" diff --git a/keyboards/handwired/onekey/blackpill_f411/mcuconf.h b/keyboards/handwired/onekey/blackpill_f411/mcuconf.h index 0394ff56bb97..33e07847b413 100644 --- a/keyboards/handwired/onekey/blackpill_f411/mcuconf.h +++ b/keyboards/handwired/onekey/blackpill_f411/mcuconf.h @@ -1,253 +1,21 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef MCUCONF_H -#define MCUCONF_H - -/* - * STM32F4xx drivers configuration. - * The following settings override the default settings present in - * the various device driver implementation headers. - * Note that the settings for each driver only have effect if the whole - * driver is enabled in halconf.h. +/* Copyright 2020 Nick Brassel (tzarc) * - * IRQ priorities: - * 15...0 Lowest...Highest. + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * DMA priorities: - * 0...3 Lowest...Highest. - */ - -#define STM32F4xx_MCUCONF - -/* - * HAL driver system settings. - */ -#define STM32_NO_INIT FALSE -#define STM32_HSI_ENABLED TRUE -#define STM32_LSI_ENABLED TRUE -#define STM32_HSE_ENABLED TRUE -#define STM32_LSE_ENABLED FALSE -#define STM32_CLOCK48_REQUIRED TRUE -#define STM32_SW STM32_SW_PLL -#define STM32_PLLSRC STM32_PLLSRC_HSE -#define STM32_PLLM_VALUE 25 -#define STM32_PLLN_VALUE 384 -#define STM32_PLLP_VALUE 4 -#define STM32_PLLQ_VALUE 8 -#define STM32_HPRE STM32_HPRE_DIV1 -#define STM32_PPRE1 STM32_PPRE1_DIV4 -#define STM32_PPRE2 STM32_PPRE2_DIV2 -#define STM32_RTCSEL STM32_RTCSEL_LSI -#define STM32_RTCPRE_VALUE 8 -#define STM32_MCO1SEL STM32_MCO1SEL_HSI -#define STM32_MCO1PRE STM32_MCO1PRE_DIV1 -#define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK -#define STM32_MCO2PRE STM32_MCO2PRE_DIV5 -#define STM32_I2SSRC STM32_I2SSRC_CKIN -#define STM32_PLLI2SN_VALUE 192 -#define STM32_PLLI2SR_VALUE 5 -#define STM32_PVD_ENABLE FALSE -#define STM32_PLS STM32_PLS_LEV0 -#define STM32_BKPRAM_ENABLE FALSE - -/* - * IRQ system settings. - */ -#define STM32_IRQ_EXTI0_PRIORITY 6 -#define STM32_IRQ_EXTI1_PRIORITY 6 -#define STM32_IRQ_EXTI2_PRIORITY 6 -#define STM32_IRQ_EXTI3_PRIORITY 6 -#define STM32_IRQ_EXTI4_PRIORITY 6 -#define STM32_IRQ_EXTI5_9_PRIORITY 6 -#define STM32_IRQ_EXTI10_15_PRIORITY 6 -#define STM32_IRQ_EXTI16_PRIORITY 6 -#define STM32_IRQ_EXTI17_PRIORITY 15 -#define STM32_IRQ_EXTI18_PRIORITY 6 -#define STM32_IRQ_EXTI19_PRIORITY 6 -#define STM32_IRQ_EXTI20_PRIORITY 6 -#define STM32_IRQ_EXTI21_PRIORITY 15 -#define STM32_IRQ_EXTI22_PRIORITY 15 - -/* - * ADC driver system settings. - */ -#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4 -#define STM32_ADC_USE_ADC1 FALSE -#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4) -#define STM32_ADC_ADC1_DMA_PRIORITY 2 -#define STM32_ADC_IRQ_PRIORITY 6 -#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6 - -/* - * GPT driver system settings. - */ -#define STM32_GPT_USE_TIM1 FALSE -#define STM32_GPT_USE_TIM2 FALSE -#define STM32_GPT_USE_TIM3 FALSE -#define STM32_GPT_USE_TIM4 FALSE -#define STM32_GPT_USE_TIM5 FALSE -#define STM32_GPT_USE_TIM9 FALSE -#define STM32_GPT_USE_TIM11 FALSE -#define STM32_GPT_TIM1_IRQ_PRIORITY 7 -#define STM32_GPT_TIM2_IRQ_PRIORITY 7 -#define STM32_GPT_TIM3_IRQ_PRIORITY 7 -#define STM32_GPT_TIM4_IRQ_PRIORITY 7 -#define STM32_GPT_TIM5_IRQ_PRIORITY 7 -#define STM32_GPT_TIM9_IRQ_PRIORITY 7 -#define STM32_GPT_TIM11_IRQ_PRIORITY 7 - -/* - * I2C driver system settings. - */ -#define STM32_I2C_USE_I2C1 FALSE -#define STM32_I2C_USE_I2C2 FALSE -#define STM32_I2C_USE_I2C3 FALSE -#define STM32_I2C_BUSY_TIMEOUT 50 -#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) -#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) -#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) -#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) -#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) -#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) -#define STM32_I2C_I2C1_IRQ_PRIORITY 5 -#define STM32_I2C_I2C2_IRQ_PRIORITY 5 -#define STM32_I2C_I2C3_IRQ_PRIORITY 5 -#define STM32_I2C_I2C1_DMA_PRIORITY 3 -#define STM32_I2C_I2C2_DMA_PRIORITY 3 -#define STM32_I2C_I2C3_DMA_PRIORITY 3 -#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") - -/* - * I2S driver system settings. - */ -#define STM32_I2S_USE_SPI2 FALSE -#define STM32_I2S_USE_SPI3 FALSE -#define STM32_I2S_SPI2_IRQ_PRIORITY 10 -#define STM32_I2S_SPI3_IRQ_PRIORITY 10 -#define STM32_I2S_SPI2_DMA_PRIORITY 1 -#define STM32_I2S_SPI3_DMA_PRIORITY 1 -#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) -#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) -#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) -#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) -#define STM32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure") - -/* - * ICU driver system settings. - */ -#define STM32_ICU_USE_TIM1 FALSE -#define STM32_ICU_USE_TIM2 FALSE -#define STM32_ICU_USE_TIM3 FALSE -#define STM32_ICU_USE_TIM4 FALSE -#define STM32_ICU_USE_TIM5 FALSE -#define STM32_ICU_USE_TIM9 FALSE -#define STM32_ICU_TIM1_IRQ_PRIORITY 7 -#define STM32_ICU_TIM2_IRQ_PRIORITY 7 -#define STM32_ICU_TIM3_IRQ_PRIORITY 7 -#define STM32_ICU_TIM4_IRQ_PRIORITY 7 -#define STM32_ICU_TIM5_IRQ_PRIORITY 7 -#define STM32_ICU_TIM9_IRQ_PRIORITY 7 - -/* - * PWM driver system settings. - */ -#define STM32_PWM_USE_ADVANCED FALSE -#define STM32_PWM_USE_TIM1 FALSE -#define STM32_PWM_USE_TIM2 FALSE -#define STM32_PWM_USE_TIM3 FALSE -#define STM32_PWM_USE_TIM4 FALSE -#define STM32_PWM_USE_TIM5 FALSE -#define STM32_PWM_USE_TIM9 FALSE -#define STM32_PWM_TIM1_IRQ_PRIORITY 7 -#define STM32_PWM_TIM2_IRQ_PRIORITY 7 -#define STM32_PWM_TIM3_IRQ_PRIORITY 7 -#define STM32_PWM_TIM4_IRQ_PRIORITY 7 -#define STM32_PWM_TIM5_IRQ_PRIORITY 7 -#define STM32_PWM_TIM9_IRQ_PRIORITY 7 - -/* - * SERIAL driver system settings. - */ -#define STM32_SERIAL_USE_USART1 FALSE -#define STM32_SERIAL_USE_USART2 FALSE -#define STM32_SERIAL_USE_USART6 FALSE -#define STM32_SERIAL_USART1_PRIORITY 12 -#define STM32_SERIAL_USART2_PRIORITY 12 -#define STM32_SERIAL_USART6_PRIORITY 12 - -/* - * SPI driver system settings. - */ -#define STM32_SPI_USE_SPI1 FALSE -#define STM32_SPI_USE_SPI2 FALSE -#define STM32_SPI_USE_SPI3 FALSE -#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0) -#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3) -#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) -#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) -#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) -#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) -#define STM32_SPI_SPI1_DMA_PRIORITY 1 -#define STM32_SPI_SPI2_DMA_PRIORITY 1 -#define STM32_SPI_SPI3_DMA_PRIORITY 1 -#define STM32_SPI_SPI1_IRQ_PRIORITY 10 -#define STM32_SPI_SPI2_IRQ_PRIORITY 10 -#define STM32_SPI_SPI3_IRQ_PRIORITY 10 -#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") - -/* - * ST driver system settings. - */ -#define STM32_ST_IRQ_PRIORITY 8 -#define STM32_ST_USE_TIMER 2 - -/* - * UART driver system settings. - */ -#define STM32_UART_USE_USART1 FALSE -#define STM32_UART_USE_USART2 FALSE -#define STM32_UART_USE_USART6 FALSE -#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) -#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) -#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5) -#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) -#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2) -#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) -#define STM32_UART_USART1_IRQ_PRIORITY 12 -#define STM32_UART_USART2_IRQ_PRIORITY 12 -#define STM32_UART_USART6_IRQ_PRIORITY 12 -#define STM32_UART_USART1_DMA_PRIORITY 0 -#define STM32_UART_USART2_DMA_PRIORITY 0 -#define STM32_UART_USART6_DMA_PRIORITY 0 -#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") - -/* - * USB driver system settings. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#define STM32_USB_USE_OTG1 TRUE -#define STM32_USB_OTG1_IRQ_PRIORITY 14 -#define STM32_USB_OTG1_RX_FIFO_SIZE 512 -#define STM32_USB_OTG_THREAD_PRIO NORMALPRIO+1 -#define STM32_USB_OTG_THREAD_STACK_SIZE 128 -#define STM32_USB_OTGFIFO_FILL_BASEPRI 0 +#pragma once -/* - * WDG driver system settings. - */ -#define STM32_WDG_USE_IWDG FALSE +#include_next "mcuconf.h" -#endif /* MCUCONF_H */ +#undef STM32_I2C_USE_I2C1 +#define STM32_I2C_USE_I2C1 TRUE diff --git a/keyboards/peiorisboards/ixora/boards/GENERIC_STM32_F042X6/board.c b/keyboards/peiorisboards/ixora/boards/GENERIC_STM32_F042X6/board.c deleted file mode 100644 index 754dc5c4dd05..000000000000 --- a/keyboards/peiorisboards/ixora/boards/GENERIC_STM32_F042X6/board.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/* - * This file has been automatically generated using ChibiStudio board - * generator plugin. Do not edit manually. - */ - -#include "hal.h" -#include "stm32_gpio.h" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables and types. */ -/*===========================================================================*/ - -/** - * @brief Type of STM32 GPIO port setup. - */ -typedef struct { - uint32_t moder; - uint32_t otyper; - uint32_t ospeedr; - uint32_t pupdr; - uint32_t odr; - uint32_t afrl; - uint32_t afrh; -} gpio_setup_t; - -/** - * @brief Type of STM32 GPIO initialization data. - */ -typedef struct { -#if STM32_HAS_GPIOA || defined(__DOXYGEN__) - gpio_setup_t PAData; -#endif -#if STM32_HAS_GPIOB || defined(__DOXYGEN__) - gpio_setup_t PBData; -#endif -#if STM32_HAS_GPIOC || defined(__DOXYGEN__) - gpio_setup_t PCData; -#endif -#if STM32_HAS_GPIOD || defined(__DOXYGEN__) - gpio_setup_t PDData; -#endif -#if STM32_HAS_GPIOE || defined(__DOXYGEN__) - gpio_setup_t PEData; -#endif -#if STM32_HAS_GPIOF || defined(__DOXYGEN__) - gpio_setup_t PFData; -#endif -#if STM32_HAS_GPIOG || defined(__DOXYGEN__) - gpio_setup_t PGData; -#endif -#if STM32_HAS_GPIOH || defined(__DOXYGEN__) - gpio_setup_t PHData; -#endif -#if STM32_HAS_GPIOI || defined(__DOXYGEN__) - gpio_setup_t PIData; -#endif -#if STM32_HAS_GPIOJ || defined(__DOXYGEN__) - gpio_setup_t PJData; -#endif -#if STM32_HAS_GPIOK || defined(__DOXYGEN__) - gpio_setup_t PKData; -#endif -} gpio_config_t; - -/** - * @brief STM32 GPIO static initialization data. - */ -static const gpio_config_t gpio_default_config = { -#if STM32_HAS_GPIOA - {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR, - VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH}, -#endif -#if STM32_HAS_GPIOB - {VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR, - VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH}, -#endif -#if STM32_HAS_GPIOC - {VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR, - VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH}, -#endif -#if STM32_HAS_GPIOD - {VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR, - VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH}, -#endif -#if STM32_HAS_GPIOE - {VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR, - VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH}, -#endif -#if STM32_HAS_GPIOF - {VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR, - VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH}, -#endif -#if STM32_HAS_GPIOG - {VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR, - VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH}, -#endif -#if STM32_HAS_GPIOH - {VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR, - VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH}, -#endif -#if STM32_HAS_GPIOI - {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR, - VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}, -#endif -#if STM32_HAS_GPIOJ - {VAL_GPIOJ_MODER, VAL_GPIOJ_OTYPER, VAL_GPIOJ_OSPEEDR, VAL_GPIOJ_PUPDR, - VAL_GPIOJ_ODR, VAL_GPIOJ_AFRL, VAL_GPIOJ_AFRH}, -#endif -#if STM32_HAS_GPIOK - {VAL_GPIOK_MODER, VAL_GPIOK_OTYPER, VAL_GPIOK_OSPEEDR, VAL_GPIOK_PUPDR, - VAL_GPIOK_ODR, VAL_GPIOK_AFRL, VAL_GPIOK_AFRH} -#endif -}; - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config) { - - gpiop->OTYPER = config->otyper; - gpiop->OSPEEDR = config->ospeedr; - gpiop->PUPDR = config->pupdr; - gpiop->ODR = config->odr; - gpiop->AFRL = config->afrl; - gpiop->AFRH = config->afrh; - gpiop->MODER = config->moder; -} - -static void stm32_gpio_init(void) { - - /* Enabling GPIO-related clocks, the mask comes from the - registry header file.*/ - rccResetAHB(STM32_GPIO_EN_MASK); - rccEnableAHB(STM32_GPIO_EN_MASK, true); - - /* Initializing all the defined GPIO ports.*/ -#if STM32_HAS_GPIOA - gpio_init(GPIOA, &gpio_default_config.PAData); -#endif -#if STM32_HAS_GPIOB - gpio_init(GPIOB, &gpio_default_config.PBData); -#endif -#if STM32_HAS_GPIOC - gpio_init(GPIOC, &gpio_default_config.PCData); -#endif -#if STM32_HAS_GPIOD - gpio_init(GPIOD, &gpio_default_config.PDData); -#endif -#if STM32_HAS_GPIOE - gpio_init(GPIOE, &gpio_default_config.PEData); -#endif -#if STM32_HAS_GPIOF - gpio_init(GPIOF, &gpio_default_config.PFData); -#endif -#if STM32_HAS_GPIOG - gpio_init(GPIOG, &gpio_default_config.PGData); -#endif -#if STM32_HAS_GPIOH - gpio_init(GPIOH, &gpio_default_config.PHData); -#endif -#if STM32_HAS_GPIOI - gpio_init(GPIOI, &gpio_default_config.PIData); -#endif -#if STM32_HAS_GPIOJ - gpio_init(GPIOJ, &gpio_default_config.PJData); -#endif -#if STM32_HAS_GPIOK - gpio_init(GPIOK, &gpio_default_config.PKData); -#endif -} - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/** - * @brief Early initialization code. - * @details GPIO ports and system clocks are initialized before everything - * else. - */ -void __early_init(void) { - extern void enter_bootloader_mode_if_requested(void); - enter_bootloader_mode_if_requested(); - - stm32_gpio_init(); - stm32_clock_init(); -} - -#if HAL_USE_SDC || defined(__DOXYGEN__) -/** - * @brief SDC card detection. - */ -bool sdc_lld_is_card_inserted(SDCDriver *sdcp) { - - (void)sdcp; - /* TODO: Fill the implementation.*/ - return true; -} - -/** - * @brief SDC card write protection detection. - */ -bool sdc_lld_is_write_protected(SDCDriver *sdcp) { - - (void)sdcp; - /* TODO: Fill the implementation.*/ - return false; -} -#endif /* HAL_USE_SDC */ - -#if HAL_USE_MMC_SPI || defined(__DOXYGEN__) -/** - * @brief MMC_SPI card detection. - */ -bool mmc_lld_is_card_inserted(MMCDriver *mmcp) { - - (void)mmcp; - /* TODO: Fill the implementation.*/ - return true; -} - -/** - * @brief MMC_SPI card write protection detection. - */ -bool mmc_lld_is_write_protected(MMCDriver *mmcp) { - - (void)mmcp; - /* TODO: Fill the implementation.*/ - return false; -} -#endif - -/** - * @brief Board-specific initialization code. - * @todo Add your board-specific code, if any. - */ -void boardInit(void) { - -} diff --git a/keyboards/peiorisboards/ixora/boards/GENERIC_STM32_F042X6/board.mk b/keyboards/peiorisboards/ixora/boards/GENERIC_STM32_F042X6/board.mk deleted file mode 100644 index bbeb5bbff728..000000000000 --- a/keyboards/peiorisboards/ixora/boards/GENERIC_STM32_F042X6/board.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List of all the board related files. -BOARDSRC = $(BOARD_PATH)/boards/GENERIC_STM32_F042X6/board.c - -# Required include directories -BOARDINC = $(BOARD_PATH)/boards/GENERIC_STM32_F042X6 diff --git a/keyboards/vinta/boards/GENERIC_STM32_F042X6/board.h b/keyboards/vinta/boards/GENERIC_STM32_F042X6/board.h deleted file mode 100644 index 241d566afa27..000000000000 --- a/keyboards/vinta/boards/GENERIC_STM32_F042X6/board.h +++ /dev/null @@ -1,896 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ -#ifndef _BOARD_H -#define _BOARD_H - -/* - * Setup for STMicroelectronics STM32 Nucleo32-F042K6 board. - */ - -/* - * Board identifier. - */ -#define BOARD_GENERIC_STM32_F042X6 -#define BOARD_NAME "Vinta PCB" - -/* - * Board oscillators-related settings. - * NOTE: LSE not fitted. - * NOTE: HSE not fitted. - */ -#if !defined(STM32_LSECLK) -#define STM32_LSECLK 0U -#endif - -#define STM32_LSEDRV (3U << 3U) - -#if !defined(STM32_HSECLK) -#define STM32_HSECLK 0U -#endif - -/* - * MCU type as defined in the ST header. - */ -#define STM32F042x6 - -/* - * IO pins assignments. - */ -#define GPIOA_PIN0 0U -#define GPIOA_PIN1 1U -#define GPIOA_PIN2 2U -#define GPIOA_PIN3 3U -#define GPIOA_PIN4 4U -#define GPIOA_PIN5 5U -#define GPIOA_PIN6 6U -#define GPIOA_PIN7 7U -#define GPIOA_PIN8 8U -#define GPIOA_PIN9 9U -#define GPIOA_PIN10 10U -#define GPIOA_PIN11 11U -#define GPIOA_PIN12 12U -#define GPIOA_PIN13 13U -#define GPIOA_PIN14 14U -#define GPIOA_PIN15 15U - -#define GPIOB_PIN0 0U -#define GPIOB_PIN1 1U -#define GPIOB_PIN2 2U -#define GPIOB_PIN3 3U -#define GPIOB_PIN4 4U -#define GPIOB_PIN5 5U -#define GPIOB_PIN6 6U -#define GPIOB_PIN7 7U -#define GPIOB_PIN8 8U -#define GPIOB_PIN9 9U -#define GPIOB_PIN10 10U -#define GPIOB_PIN11 11U -#define GPIOB_PIN12 12U -#define GPIOB_PIN13 13U -#define GPIOB_PIN14 14U -#define GPIOB_PIN15 15U - -#define GPIOC_PIN0 0U -#define GPIOC_PIN1 1U -#define GPIOC_PIN2 2U -#define GPIOC_PIN3 3U -#define GPIOC_PIN4 4U -#define GPIOC_PIN5 5U -#define GPIOC_PIN6 6U -#define GPIOC_PIN7 7U -#define GPIOC_PIN8 8U -#define GPIOC_PIN9 9U -#define GPIOC_PIN10 10U -#define GPIOC_PIN11 11U -#define GPIOC_PIN12 12U -#define GPIOC_PIN13 13U -#define GPIOC_PIN14 14U -#define GPIOC_PIN15 15U - -#define GPIOD_PIN0 0U -#define GPIOD_PIN1 1U -#define GPIOD_PIN2 2U -#define GPIOD_PIN3 3U -#define GPIOD_PIN4 4U -#define GPIOD_PIN5 5U -#define GPIOD_PIN6 6U -#define GPIOD_PIN7 7U -#define GPIOD_PIN8 8U -#define GPIOD_PIN9 9U -#define GPIOD_PIN10 10U -#define GPIOD_PIN11 11U -#define GPIOD_PIN12 12U -#define GPIOD_PIN13 13U -#define GPIOD_PIN14 14U -#define GPIOD_PIN15 15U - -#define GPIOE_PIN0 0U -#define GPIOE_PIN1 1U -#define GPIOE_PIN2 2U -#define GPIOE_PIN3 3U -#define GPIOE_PIN4 4U -#define GPIOE_PIN5 5U -#define GPIOE_PIN6 6U -#define GPIOE_PIN7 7U -#define GPIOE_PIN8 8U -#define GPIOE_PIN9 9U -#define GPIOE_PIN10 10U -#define GPIOE_PIN11 11U -#define GPIOE_PIN12 12U -#define GPIOE_PIN13 13U -#define GPIOE_PIN14 14U -#define GPIOE_PIN15 15U - -#define GPIOF_PIN0 0U -#define GPIOF_PIN1 1U -#define GPIOF_PIN2 2U -#define GPIOF_PIN3 3U -#define GPIOF_PIN4 4U -#define GPIOF_PIN5 5U -#define GPIOF_PIN6 6U -#define GPIOF_PIN7 7U -#define GPIOF_PIN8 8U -#define GPIOF_PIN9 9U -#define GPIOF_PIN10 10U -#define GPIOF_PIN11 11U -#define GPIOF_PIN12 12U -#define GPIOF_PIN13 13U -#define GPIOF_PIN14 14U -#define GPIOF_PIN15 15U - -/* - * IO lines assignments. - */ - -#define LINE_BOOT0 PAL_LINE(GPIOB, 8U) -#define LINE_SWCLK PAL_LINE(GPIOA, 14U) -#define LINE_SWDIO PAL_LINE(GPIOA, 13U) - -/* - * I/O ports initial setup, this configuration is established soon after reset - * in the initialization code. - * Please refer to the STM32 Reference Manual for details. - */ -#define PIN_MODE_INPUT(n) (0U << ((n) * 2U)) -#define PIN_MODE_OUTPUT(n) (1U << ((n) * 2U)) -#define PIN_MODE_ALTERNATE(n) (2U << ((n) * 2U)) -#define PIN_MODE_ANALOG(n) (3U << ((n) * 2U)) -#define PIN_ODR_LOW(n) (0U << (n)) -#define PIN_ODR_HIGH(n) (1U << (n)) -#define PIN_OTYPE_PUSHPULL(n) (0U << (n)) -#define PIN_OTYPE_OPENDRAIN(n) (1U << (n)) -#define PIN_OSPEED_VERYLOW(n) (0U << ((n) * 2U)) -#define PIN_OSPEED_LOW(n) (1U << ((n) * 2U)) -#define PIN_OSPEED_MEDIUM(n) (2U << ((n) * 2U)) -#define PIN_OSPEED_HIGH(n) (3U << ((n) * 2U)) -#define PIN_PUPDR_FLOATING(n) (0U << ((n) * 2U)) -#define PIN_PUPDR_PULLUP(n) (1U << ((n) * 2U)) -#define PIN_PUPDR_PULLDOWN(n) (2U << ((n) * 2U)) -#define PIN_AFIO_AF(n, v) ((v) << (((n) % 8U) * 4U)) - -/* - * GPIOA setup: - * - * PA0 - COL5 - * PA1 - COL4 - * PA2 - COL3 - * PA3 - COL2 - * PA4 - COL1 - * PA5 - COL0 - * PA6 - ROW4 - * PA7 - ROW3 - * PA8 - NC - * PA9 - ROW1 - * PA10 - ROW0 - * PA11 - USB_DM - * PA12 - USB_DP - * PA13 - COL15/SWDIO (for now, COL15) - * PA14 - COL14/SWCLK (for now, COL14) - * PA15 - COL13 - */ -#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_PIN0) | \ - PIN_MODE_INPUT(GPIOA_PIN1) | \ - PIN_MODE_INPUT(GPIOA_PIN2) | \ - PIN_MODE_INPUT(GPIOA_PIN3) | \ - PIN_MODE_INPUT(GPIOA_PIN4) | \ - PIN_MODE_INPUT(GPIOA_PIN5) | \ - PIN_MODE_INPUT(GPIOA_PIN6) | \ - PIN_MODE_INPUT(GPIOA_PIN7) | \ - PIN_MODE_INPUT(GPIOA_PIN8) | \ - PIN_MODE_INPUT(GPIOA_PIN9) | \ - PIN_MODE_INPUT(GPIOA_PIN10) | \ - PIN_MODE_INPUT(GPIOA_PIN11) | \ - PIN_MODE_INPUT(GPIOA_PIN12) | \ - PIN_MODE_INPUT(GPIOA_PIN13) | \ - PIN_MODE_INPUT(GPIOA_PIN14) | \ - PIN_MODE_INPUT(GPIOA_PIN15)) -#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_PIN0) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN1) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN2) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN3) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN4) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN5) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN6) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN7) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN8) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN9) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN10) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN11) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN12) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN13) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN14) | \ - PIN_OTYPE_PUSHPULL(GPIOA_PIN15)) -#define VAL_GPIOA_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOA_PIN0) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN1) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN2) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN3) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN4) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN5) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN6) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN7) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN8) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN9) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN10) | \ - PIN_OSPEED_HIGH(GPIOA_PIN11) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN12) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN13) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN14) | \ - PIN_OSPEED_VERYLOW(GPIOA_PIN15)) -#define VAL_GPIOA_PUPDR (PIN_PUPDR_PULLUP(GPIOA_PIN0) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN1) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN2) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN3) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN4) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN5) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN6) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN7) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN8) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN9) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN10) | \ - PIN_PUPDR_FLOATING(GPIOA_PIN11) | \ - PIN_PUPDR_FLOATING(GPIOA_PIN12) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN13) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN14) | \ - PIN_PUPDR_PULLUP(GPIOA_PIN15)) -#define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_PIN0) | \ - PIN_ODR_HIGH(GPIOA_PIN1) | \ - PIN_ODR_HIGH(GPIOA_PIN2) | \ - PIN_ODR_HIGH(GPIOA_PIN3) | \ - PIN_ODR_HIGH(GPIOA_PIN4) | \ - PIN_ODR_HIGH(GPIOA_PIN5) | \ - PIN_ODR_HIGH(GPIOA_PIN6) | \ - PIN_ODR_HIGH(GPIOA_PIN7) | \ - PIN_ODR_HIGH(GPIOA_PIN8) | \ - PIN_ODR_HIGH(GPIOA_PIN9) | \ - PIN_ODR_HIGH(GPIOA_PIN10) | \ - PIN_ODR_HIGH(GPIOA_PIN11) | \ - PIN_ODR_HIGH(GPIOA_PIN12) | \ - PIN_ODR_HIGH(GPIOA_PIN13) | \ - PIN_ODR_HIGH(GPIOA_PIN14) | \ - PIN_ODR_HIGH(GPIOA_PIN15)) -#define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_PIN0, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN1, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN2, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN3, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN4, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN5, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN6, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN7, 0U)) -#define VAL_GPIOA_AFRH (PIN_AFIO_AF(GPIOA_PIN8, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN9, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN10, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN11, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN12, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN13, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN14, 0U) | \ - PIN_AFIO_AF(GPIOA_PIN15, 0U)) - -/* - * GPIOB setup: - * - * PB0 - ROW2 - * PB1 - RGB_D - * PB2 - PIN2 (input pullup). - * PB3 - COL12 - * PB4 - COL11 - * PB5 - COL10 - * PB6 - COL9 - * PB7 - COL8 - * PB8 - BOOT0 (set as output for STM32F042) - * PB9 - PIN9 (input pullup). - * PB10 - PIN10 (input pullup). - * PB11 - PIN11 (input pullup). - * PB12 - PIN12 (input pullup). - * PB13 - PIN13 (input pullup). - * PB14 - PIN14 (input pullup). - * PB15 - PIN15 (input pullup). - */ -#define VAL_GPIOB_MODER (PIN_MODE_INPUT(GPIOB_PIN0) | \ - PIN_MODE_OUTPUT(GPIOB_PIN1) | \ - PIN_MODE_INPUT(GPIOB_PIN2) | \ - PIN_MODE_INPUT(GPIOB_PIN3) | \ - PIN_MODE_INPUT(GPIOB_PIN4) | \ - PIN_MODE_INPUT(GPIOB_PIN5) | \ - PIN_MODE_INPUT(GPIOB_PIN6) | \ - PIN_MODE_INPUT(GPIOB_PIN7) | \ - PIN_MODE_OUTPUT(GPIOB_PIN8) | \ - PIN_MODE_INPUT(GPIOB_PIN9) | \ - PIN_MODE_INPUT(GPIOB_PIN10) | \ - PIN_MODE_INPUT(GPIOB_PIN11) | \ - PIN_MODE_INPUT(GPIOB_PIN12) | \ - PIN_MODE_INPUT(GPIOB_PIN13) | \ - PIN_MODE_INPUT(GPIOB_PIN14) | \ - PIN_MODE_INPUT(GPIOB_PIN15)) -#define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(GPIOB_PIN0) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN1) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN2) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN3) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN4) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN5) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN6) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN7) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN8) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN9) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN10) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN11) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN12) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN13) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN14) | \ - PIN_OTYPE_PUSHPULL(GPIOB_PIN15)) -#define VAL_GPIOB_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOB_PIN0) | \ - PIN_OSPEED_HIGH(GPIOB_PIN1) | \ - PIN_OSPEED_HIGH(GPIOB_PIN2) | \ - PIN_OSPEED_VERYLOW(GPIOB_PIN3) | \ - PIN_OSPEED_VERYLOW(GPIOB_PIN4) | \ - PIN_OSPEED_VERYLOW(GPIOB_PIN5) | \ - PIN_OSPEED_VERYLOW(GPIOB_PIN6) | \ - PIN_OSPEED_VERYLOW(GPIOB_PIN7) | \ - PIN_OSPEED_VERYLOW(GPIOB_PIN8) | \ - PIN_OSPEED_HIGH(GPIOB_PIN9) | \ - PIN_OSPEED_HIGH(GPIOB_PIN10) | \ - PIN_OSPEED_HIGH(GPIOB_PIN11) | \ - PIN_OSPEED_HIGH(GPIOB_PIN12) | \ - PIN_OSPEED_HIGH(GPIOB_PIN13) | \ - PIN_OSPEED_HIGH(GPIOB_PIN14) | \ - PIN_OSPEED_HIGH(GPIOB_PIN15)) -#define VAL_GPIOB_PUPDR (PIN_PUPDR_PULLUP(GPIOB_PIN0) | \ - PIN_PUPDR_FLOATING(GPIOB_PIN1) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN2) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN3) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN4) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN5) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN6) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN7) | \ - PIN_PUPDR_PULLDOWN(GPIOB_PIN8) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN9) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN10) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN11) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN12) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN13) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN14) | \ - PIN_PUPDR_PULLUP(GPIOB_PIN15)) -#define VAL_GPIOB_ODR (PIN_ODR_HIGH(GPIOB_PIN0) | \ - PIN_ODR_HIGH(GPIOB_PIN1) | \ - PIN_ODR_HIGH(GPIOB_PIN2) | \ - PIN_ODR_HIGH(GPIOB_PIN3) | \ - PIN_ODR_HIGH(GPIOB_PIN4) | \ - PIN_ODR_HIGH(GPIOB_PIN5) | \ - PIN_ODR_HIGH(GPIOB_PIN6) | \ - PIN_ODR_HIGH(GPIOB_PIN7) | \ - PIN_ODR_HIGH(GPIOB_PIN8) | \ - PIN_ODR_HIGH(GPIOB_PIN9) | \ - PIN_ODR_HIGH(GPIOB_PIN10) | \ - PIN_ODR_HIGH(GPIOB_PIN11) | \ - PIN_ODR_HIGH(GPIOB_PIN12) | \ - PIN_ODR_HIGH(GPIOB_PIN13) | \ - PIN_ODR_HIGH(GPIOB_PIN14) | \ - PIN_ODR_HIGH(GPIOB_PIN15)) -#define VAL_GPIOB_AFRL (PIN_AFIO_AF(GPIOB_PIN0, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN1, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN2, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN3, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN4, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN5, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN6, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN7, 0U)) -#define VAL_GPIOB_AFRH (PIN_AFIO_AF(GPIOB_PIN8, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN9, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN10, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN11, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN12, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN13, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN14, 0U) | \ - PIN_AFIO_AF(GPIOB_PIN15, 0U)) - -/* - * GPIOC setup: - * - * PC0 - PIN0 (input pullup). - * PC1 - PIN1 (input pullup). - * PC2 - PIN2 (input pullup). - * PC3 - PIN3 (input pullup). - * PC4 - PIN4 (input pullup). - * PC5 - PIN5 (input pullup). - * PC6 - PIN6 (input pullup). - * PC7 - PIN7 (input pullup). - * PC8 - PIN8 (input pullup). - * PC9 - PIN9 (input pullup). - * PC10 - PIN10 (input pullup). - * PC11 - PIN11 (input pullup). - * PC12 - PIN12 (input pullup). - * PC13 - PIN13 (input pullup). - * PC14 - PIN14 (input pullup). - * PC15 - PIN15 (input pullup). - */ -#define VAL_GPIOC_MODER (PIN_MODE_INPUT(GPIOC_PIN0) | \ - PIN_MODE_INPUT(GPIOC_PIN1) | \ - PIN_MODE_INPUT(GPIOC_PIN2) | \ - PIN_MODE_INPUT(GPIOC_PIN3) | \ - PIN_MODE_INPUT(GPIOC_PIN4) | \ - PIN_MODE_INPUT(GPIOC_PIN5) | \ - PIN_MODE_INPUT(GPIOC_PIN6) | \ - PIN_MODE_INPUT(GPIOC_PIN7) | \ - PIN_MODE_INPUT(GPIOC_PIN8) | \ - PIN_MODE_INPUT(GPIOC_PIN9) | \ - PIN_MODE_INPUT(GPIOC_PIN10) | \ - PIN_MODE_INPUT(GPIOC_PIN11) | \ - PIN_MODE_INPUT(GPIOC_PIN12) | \ - PIN_MODE_INPUT(GPIOC_PIN13) | \ - PIN_MODE_INPUT(GPIOC_PIN14) | \ - PIN_MODE_INPUT(GPIOC_PIN15)) -#define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(GPIOC_PIN0) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN1) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN2) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN3) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN4) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN5) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN6) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN7) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN8) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN9) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN10) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN11) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN12) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN13) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN14) | \ - PIN_OTYPE_PUSHPULL(GPIOC_PIN15)) -#define VAL_GPIOC_OSPEEDR (PIN_OSPEED_HIGH(GPIOC_PIN0) | \ - PIN_OSPEED_HIGH(GPIOC_PIN1) | \ - PIN_OSPEED_HIGH(GPIOC_PIN2) | \ - PIN_OSPEED_HIGH(GPIOC_PIN3) | \ - PIN_OSPEED_HIGH(GPIOC_PIN4) | \ - PIN_OSPEED_HIGH(GPIOC_PIN5) | \ - PIN_OSPEED_HIGH(GPIOC_PIN6) | \ - PIN_OSPEED_HIGH(GPIOC_PIN7) | \ - PIN_OSPEED_HIGH(GPIOC_PIN8) | \ - PIN_OSPEED_HIGH(GPIOC_PIN9) | \ - PIN_OSPEED_HIGH(GPIOC_PIN10) | \ - PIN_OSPEED_HIGH(GPIOC_PIN11) | \ - PIN_OSPEED_HIGH(GPIOC_PIN12) | \ - PIN_OSPEED_HIGH(GPIOC_PIN13) | \ - PIN_OSPEED_HIGH(GPIOC_PIN14) | \ - PIN_OSPEED_HIGH(GPIOC_PIN15)) -#define VAL_GPIOC_PUPDR (PIN_PUPDR_PULLUP(GPIOC_PIN0) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN1) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN2) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN3) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN4) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN5) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN6) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN7) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN8) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN9) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN10) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN11) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN12) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN13) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN14) | \ - PIN_PUPDR_PULLUP(GPIOC_PIN15)) -#define VAL_GPIOC_ODR (PIN_ODR_HIGH(GPIOC_PIN0) | \ - PIN_ODR_HIGH(GPIOC_PIN1) | \ - PIN_ODR_HIGH(GPIOC_PIN2) | \ - PIN_ODR_HIGH(GPIOC_PIN3) | \ - PIN_ODR_HIGH(GPIOC_PIN4) | \ - PIN_ODR_HIGH(GPIOC_PIN5) | \ - PIN_ODR_HIGH(GPIOC_PIN6) | \ - PIN_ODR_HIGH(GPIOC_PIN7) | \ - PIN_ODR_HIGH(GPIOC_PIN8) | \ - PIN_ODR_HIGH(GPIOC_PIN9) | \ - PIN_ODR_HIGH(GPIOC_PIN10) | \ - PIN_ODR_HIGH(GPIOC_PIN11) | \ - PIN_ODR_HIGH(GPIOC_PIN12) | \ - PIN_ODR_HIGH(GPIOC_PIN13) | \ - PIN_ODR_HIGH(GPIOC_PIN14) | \ - PIN_ODR_HIGH(GPIOC_PIN15)) -#define VAL_GPIOC_AFRL (PIN_AFIO_AF(GPIOC_PIN0, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN1, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN2, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN3, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN4, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN5, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN6, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN7, 0U)) -#define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_PIN8, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN9, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN10, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN11, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN12, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN13, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN14, 0U) | \ - PIN_AFIO_AF(GPIOC_PIN15, 0U)) - -/* - * GPIOD setup: - * - * PD0 - PIN0 (input pullup). - * PD1 - PIN1 (input pullup). - * PD2 - PIN2 (input pullup). - * PD3 - PIN3 (input pullup). - * PD4 - PIN4 (input pullup). - * PD5 - PIN5 (input pullup). - * PD6 - PIN6 (input pullup). - * PD7 - PIN7 (input pullup). - * PD8 - PIN8 (input pullup). - * PD9 - PIN9 (input pullup). - * PD10 - PIN10 (input pullup). - * PD11 - PIN11 (input pullup). - * PD12 - PIN12 (input pullup). - * PD13 - PIN13 (input pullup). - * PD14 - PIN14 (input pullup). - * PD15 - PIN15 (input pullup). - */ -#define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_PIN0) | \ - PIN_MODE_INPUT(GPIOD_PIN1) | \ - PIN_MODE_INPUT(GPIOD_PIN2) | \ - PIN_MODE_INPUT(GPIOD_PIN3) | \ - PIN_MODE_INPUT(GPIOD_PIN4) | \ - PIN_MODE_INPUT(GPIOD_PIN5) | \ - PIN_MODE_INPUT(GPIOD_PIN6) | \ - PIN_MODE_INPUT(GPIOD_PIN7) | \ - PIN_MODE_INPUT(GPIOD_PIN8) | \ - PIN_MODE_INPUT(GPIOD_PIN9) | \ - PIN_MODE_INPUT(GPIOD_PIN10) | \ - PIN_MODE_INPUT(GPIOD_PIN11) | \ - PIN_MODE_INPUT(GPIOD_PIN12) | \ - PIN_MODE_INPUT(GPIOD_PIN13) | \ - PIN_MODE_INPUT(GPIOD_PIN14) | \ - PIN_MODE_INPUT(GPIOD_PIN15)) -#define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN1) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN2) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN3) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN4) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN5) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN6) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN7) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN8) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN9) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN10) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN11) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN12) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN13) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN14) | \ - PIN_OTYPE_PUSHPULL(GPIOD_PIN15)) -#define VAL_GPIOD_OSPEEDR (PIN_OSPEED_HIGH(GPIOD_PIN0) | \ - PIN_OSPEED_HIGH(GPIOD_PIN1) | \ - PIN_OSPEED_HIGH(GPIOD_PIN2) | \ - PIN_OSPEED_HIGH(GPIOD_PIN3) | \ - PIN_OSPEED_HIGH(GPIOD_PIN4) | \ - PIN_OSPEED_HIGH(GPIOD_PIN5) | \ - PIN_OSPEED_HIGH(GPIOD_PIN6) | \ - PIN_OSPEED_HIGH(GPIOD_PIN7) | \ - PIN_OSPEED_HIGH(GPIOD_PIN8) | \ - PIN_OSPEED_HIGH(GPIOD_PIN9) | \ - PIN_OSPEED_HIGH(GPIOD_PIN10) | \ - PIN_OSPEED_HIGH(GPIOD_PIN11) | \ - PIN_OSPEED_HIGH(GPIOD_PIN12) | \ - PIN_OSPEED_HIGH(GPIOD_PIN13) | \ - PIN_OSPEED_HIGH(GPIOD_PIN14) | \ - PIN_OSPEED_HIGH(GPIOD_PIN15)) -#define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLUP(GPIOD_PIN0) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN1) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN2) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN3) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN4) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN5) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN6) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN7) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN8) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN9) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN10) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN11) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN12) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN13) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN14) | \ - PIN_PUPDR_PULLUP(GPIOD_PIN15)) -#define VAL_GPIOD_ODR (PIN_ODR_HIGH(GPIOD_PIN0) | \ - PIN_ODR_HIGH(GPIOD_PIN1) | \ - PIN_ODR_HIGH(GPIOD_PIN2) | \ - PIN_ODR_HIGH(GPIOD_PIN3) | \ - PIN_ODR_HIGH(GPIOD_PIN4) | \ - PIN_ODR_HIGH(GPIOD_PIN5) | \ - PIN_ODR_HIGH(GPIOD_PIN6) | \ - PIN_ODR_HIGH(GPIOD_PIN7) | \ - PIN_ODR_HIGH(GPIOD_PIN8) | \ - PIN_ODR_HIGH(GPIOD_PIN9) | \ - PIN_ODR_HIGH(GPIOD_PIN10) | \ - PIN_ODR_HIGH(GPIOD_PIN11) | \ - PIN_ODR_HIGH(GPIOD_PIN12) | \ - PIN_ODR_HIGH(GPIOD_PIN13) | \ - PIN_ODR_HIGH(GPIOD_PIN14) | \ - PIN_ODR_HIGH(GPIOD_PIN15)) -#define VAL_GPIOD_AFRL (PIN_AFIO_AF(GPIOD_PIN0, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN1, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN2, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN3, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN4, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN5, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN6, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN7, 0U)) -#define VAL_GPIOD_AFRH (PIN_AFIO_AF(GPIOD_PIN8, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN9, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN10, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN11, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN12, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN13, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN14, 0U) | \ - PIN_AFIO_AF(GPIOD_PIN15, 0U)) - -/* - * GPIOE setup: - * - * PE0 - PIN0 (input pullup). - * PE1 - PIN1 (input pullup). - * PE2 - PIN2 (input pullup). - * PE3 - PIN3 (input pullup). - * PE4 - PIN4 (input pullup). - * PE5 - PIN5 (input pullup). - * PE6 - PIN6 (input pullup). - * PE7 - PIN7 (input pullup). - * PE8 - PIN8 (input pullup). - * PE9 - PIN9 (input pullup). - * PE10 - PIN10 (input pullup). - * PE11 - PIN11 (input pullup). - * PE12 - PIN12 (input pullup). - * PE13 - PIN13 (input pullup). - * PE14 - PIN14 (input pullup). - * PE15 - PIN15 (input pullup). - */ -#define VAL_GPIOE_MODER (PIN_MODE_INPUT(GPIOE_PIN0) | \ - PIN_MODE_INPUT(GPIOE_PIN1) | \ - PIN_MODE_INPUT(GPIOE_PIN2) | \ - PIN_MODE_INPUT(GPIOE_PIN3) | \ - PIN_MODE_INPUT(GPIOE_PIN4) | \ - PIN_MODE_INPUT(GPIOE_PIN5) | \ - PIN_MODE_INPUT(GPIOE_PIN6) | \ - PIN_MODE_INPUT(GPIOE_PIN7) | \ - PIN_MODE_INPUT(GPIOE_PIN8) | \ - PIN_MODE_INPUT(GPIOE_PIN9) | \ - PIN_MODE_INPUT(GPIOE_PIN10) | \ - PIN_MODE_INPUT(GPIOE_PIN11) | \ - PIN_MODE_INPUT(GPIOE_PIN12) | \ - PIN_MODE_INPUT(GPIOE_PIN13) | \ - PIN_MODE_INPUT(GPIOE_PIN14) | \ - PIN_MODE_INPUT(GPIOE_PIN15)) -#define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL(GPIOE_PIN0) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN1) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN2) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN3) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN4) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN5) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN6) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN7) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN8) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN9) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN10) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN11) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN12) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN13) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN14) | \ - PIN_OTYPE_PUSHPULL(GPIOE_PIN15)) -#define VAL_GPIOE_OSPEEDR (PIN_OSPEED_HIGH(GPIOE_PIN0) | \ - PIN_OSPEED_HIGH(GPIOE_PIN1) | \ - PIN_OSPEED_HIGH(GPIOE_PIN2) | \ - PIN_OSPEED_HIGH(GPIOE_PIN3) | \ - PIN_OSPEED_HIGH(GPIOE_PIN4) | \ - PIN_OSPEED_HIGH(GPIOE_PIN5) | \ - PIN_OSPEED_HIGH(GPIOE_PIN6) | \ - PIN_OSPEED_HIGH(GPIOE_PIN7) | \ - PIN_OSPEED_HIGH(GPIOE_PIN8) | \ - PIN_OSPEED_HIGH(GPIOE_PIN9) | \ - PIN_OSPEED_HIGH(GPIOE_PIN10) | \ - PIN_OSPEED_HIGH(GPIOE_PIN11) | \ - PIN_OSPEED_HIGH(GPIOE_PIN12) | \ - PIN_OSPEED_HIGH(GPIOE_PIN13) | \ - PIN_OSPEED_HIGH(GPIOE_PIN14) | \ - PIN_OSPEED_HIGH(GPIOE_PIN15)) -#define VAL_GPIOE_PUPDR (PIN_PUPDR_PULLUP(GPIOE_PIN0) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN1) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN2) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN3) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN4) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN5) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN6) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN7) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN8) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN9) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN10) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN11) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN12) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN13) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN14) | \ - PIN_PUPDR_PULLUP(GPIOE_PIN15)) -#define VAL_GPIOE_ODR (PIN_ODR_HIGH(GPIOE_PIN0) | \ - PIN_ODR_HIGH(GPIOE_PIN1) | \ - PIN_ODR_HIGH(GPIOE_PIN2) | \ - PIN_ODR_HIGH(GPIOE_PIN3) | \ - PIN_ODR_HIGH(GPIOE_PIN4) | \ - PIN_ODR_HIGH(GPIOE_PIN5) | \ - PIN_ODR_HIGH(GPIOE_PIN6) | \ - PIN_ODR_HIGH(GPIOE_PIN7) | \ - PIN_ODR_HIGH(GPIOE_PIN8) | \ - PIN_ODR_HIGH(GPIOE_PIN9) | \ - PIN_ODR_HIGH(GPIOE_PIN10) | \ - PIN_ODR_HIGH(GPIOE_PIN11) | \ - PIN_ODR_HIGH(GPIOE_PIN12) | \ - PIN_ODR_HIGH(GPIOE_PIN13) | \ - PIN_ODR_HIGH(GPIOE_PIN14) | \ - PIN_ODR_HIGH(GPIOE_PIN15)) -#define VAL_GPIOE_AFRL (PIN_AFIO_AF(GPIOE_PIN0, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN1, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN2, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN3, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN4, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN5, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN6, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN7, 0U)) -#define VAL_GPIOE_AFRH (PIN_AFIO_AF(GPIOE_PIN8, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN9, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN10, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN11, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN12, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN13, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN14, 0U) | \ - PIN_AFIO_AF(GPIOE_PIN15, 0U)) - -/* - * GPIOF setup: - * - * PF0 - COL7 - * PF1 - COL6 - * PF2 - PIN2 (input pullup). - * PF3 - PIN3 (input pullup). - * PF4 - PIN4 (input pullup). - * PF5 - PIN5 (input pullup). - * PF6 - PIN6 (input pullup). - * PF7 - PIN7 (input pullup). - * PF8 - PIN8 (input pullup). - * PF9 - PIN9 (input pullup). - * PF10 - PIN10 (input pullup). - * PF11 - PIN11 (input pullup). - * PF12 - PIN12 (input pullup). - * PF13 - PIN13 (input pullup). - * PF14 - PIN14 (input pullup). - * PF15 - PIN15 (input pullup). - */ -#define VAL_GPIOF_MODER (PIN_MODE_INPUT(GPIOF_PIN0) | \ - PIN_MODE_INPUT(GPIOF_PIN1) | \ - PIN_MODE_INPUT(GPIOF_PIN2) | \ - PIN_MODE_INPUT(GPIOF_PIN3) | \ - PIN_MODE_INPUT(GPIOF_PIN4) | \ - PIN_MODE_INPUT(GPIOF_PIN5) | \ - PIN_MODE_INPUT(GPIOF_PIN6) | \ - PIN_MODE_INPUT(GPIOF_PIN7) | \ - PIN_MODE_INPUT(GPIOF_PIN8) | \ - PIN_MODE_INPUT(GPIOF_PIN9) | \ - PIN_MODE_INPUT(GPIOF_PIN10) | \ - PIN_MODE_INPUT(GPIOF_PIN11) | \ - PIN_MODE_INPUT(GPIOF_PIN12) | \ - PIN_MODE_INPUT(GPIOF_PIN13) | \ - PIN_MODE_INPUT(GPIOF_PIN14) | \ - PIN_MODE_INPUT(GPIOF_PIN15)) -#define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL(GPIOF_PIN0) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN1) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN2) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN3) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN4) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN5) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN6) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN7) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN8) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN9) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN10) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN11) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN12) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN13) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN14) | \ - PIN_OTYPE_PUSHPULL(GPIOF_PIN15)) -#define VAL_GPIOF_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOF_PIN0) | \ - PIN_OSPEED_VERYLOW(GPIOF_PIN1) | \ - PIN_OSPEED_HIGH(GPIOF_PIN2) | \ - PIN_OSPEED_HIGH(GPIOF_PIN3) | \ - PIN_OSPEED_HIGH(GPIOF_PIN4) | \ - PIN_OSPEED_HIGH(GPIOF_PIN5) | \ - PIN_OSPEED_HIGH(GPIOF_PIN6) | \ - PIN_OSPEED_HIGH(GPIOF_PIN7) | \ - PIN_OSPEED_HIGH(GPIOF_PIN8) | \ - PIN_OSPEED_HIGH(GPIOF_PIN9) | \ - PIN_OSPEED_HIGH(GPIOF_PIN10) | \ - PIN_OSPEED_HIGH(GPIOF_PIN11) | \ - PIN_OSPEED_HIGH(GPIOF_PIN12) | \ - PIN_OSPEED_HIGH(GPIOF_PIN13) | \ - PIN_OSPEED_HIGH(GPIOF_PIN14) | \ - PIN_OSPEED_HIGH(GPIOF_PIN15)) -#define VAL_GPIOF_PUPDR (PIN_PUPDR_PULLUP(GPIOF_PIN0) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN1) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN2) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN3) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN4) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN5) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN6) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN7) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN8) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN9) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN10) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN11) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN12) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN13) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN14) | \ - PIN_PUPDR_PULLUP(GPIOF_PIN15)) -#define VAL_GPIOF_ODR (PIN_ODR_HIGH(GPIOF_PIN0) | \ - PIN_ODR_HIGH(GPIOF_PIN1) | \ - PIN_ODR_HIGH(GPIOF_PIN2) | \ - PIN_ODR_HIGH(GPIOF_PIN3) | \ - PIN_ODR_HIGH(GPIOF_PIN4) | \ - PIN_ODR_HIGH(GPIOF_PIN5) | \ - PIN_ODR_HIGH(GPIOF_PIN6) | \ - PIN_ODR_HIGH(GPIOF_PIN7) | \ - PIN_ODR_HIGH(GPIOF_PIN8) | \ - PIN_ODR_HIGH(GPIOF_PIN9) | \ - PIN_ODR_HIGH(GPIOF_PIN10) | \ - PIN_ODR_HIGH(GPIOF_PIN11) | \ - PIN_ODR_HIGH(GPIOF_PIN12) | \ - PIN_ODR_HIGH(GPIOF_PIN13) | \ - PIN_ODR_HIGH(GPIOF_PIN14) | \ - PIN_ODR_HIGH(GPIOF_PIN15)) -#define VAL_GPIOF_AFRL (PIN_AFIO_AF(GPIOF_PIN0, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN1, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN2, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN3, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN4, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN5, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN6, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN7, 0U)) -#define VAL_GPIOF_AFRH (PIN_AFIO_AF(GPIOF_PIN8, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN9, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN10, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN11, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN12, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN13, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN14, 0U) | \ - PIN_AFIO_AF(GPIOF_PIN15, 0U)) - -#if !defined(_FROM_ASM_) -#ifdef __cplusplus -extern "C" { -#endif - void boardInit(void); -#ifdef __cplusplus -} -#endif -#endif /* _FROM_ASM_ */ - -#endif /* _BOARD_H */ diff --git a/keyboards/vinta/boards/GENERIC_STM32_F042X6/board.mk b/keyboards/vinta/boards/GENERIC_STM32_F042X6/board.mk deleted file mode 100644 index bbeb5bbff728..000000000000 --- a/keyboards/vinta/boards/GENERIC_STM32_F042X6/board.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List of all the board related files. -BOARDSRC = $(BOARD_PATH)/boards/GENERIC_STM32_F042X6/board.c - -# Required include directories -BOARDINC = $(BOARD_PATH)/boards/GENERIC_STM32_F042X6 diff --git a/keyboards/vinta/bootloader_defs.h b/keyboards/vinta/bootloader_defs.h deleted file mode 100644 index 4994be9c24c3..000000000000 --- a/keyboards/vinta/bootloader_defs.h +++ /dev/null @@ -1,7 +0,0 @@ -/* Address for jumping to bootloader on STM32 chips. */ -/* It is chip dependent, the correct number can be looked up here: - * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf - * This also requires a patch to chibios: - * /tmk_core/tool/chibios/ch-bootloader-jump.patch - */ -#define STM32_BOOTLOADER_ADDRESS 0x1FFFC400 \ No newline at end of file diff --git a/lib/python/qmk/cli/cformat.py b/lib/python/qmk/cli/cformat.py index 600161c5c53c..6bcd15a1102a 100644 --- a/lib/python/qmk/cli/cformat.py +++ b/lib/python/qmk/cli/cformat.py @@ -43,8 +43,8 @@ def cformat(cli): # Empty array for files files = [] # Core directories for formatting - core_dirs = ['drivers', 'quantum', 'tests', 'tmk_core'] - ignores = ['tmk_core/protocol/usb_hid', 'quantum/template'] + core_dirs = ['drivers', 'quantum', 'tests', 'tmk_core', 'platforms'] + ignores = ['tmk_core/protocol/usb_hid', 'quantum/template', 'platforms/chibios'] # Find the list of files to format if cli.args.files: files.extend(normpath(file) for file in cli.args.files) diff --git a/platforms/chibios/BLACKPILL_STM32_F401/board/board.mk b/platforms/chibios/BLACKPILL_STM32_F401/board/board.mk new file mode 100644 index 000000000000..fddf7dace499 --- /dev/null +++ b/platforms/chibios/BLACKPILL_STM32_F401/board/board.mk @@ -0,0 +1,9 @@ +# List of all the board related files. +BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_STM32F401C_DISCOVERY/board.c + +# Required include directories +BOARDINC = $(CHIBIOS)/os/hal/boards/ST_STM32F401C_DISCOVERY + +# Shared variables +ALLCSRC += $(BOARDSRC) +ALLINC += $(BOARDINC) diff --git a/platforms/chibios/BLACKPILL_STM32_F401/configs/board.h b/platforms/chibios/BLACKPILL_STM32_F401/configs/board.h new file mode 100644 index 000000000000..30af6b0c8608 --- /dev/null +++ b/platforms/chibios/BLACKPILL_STM32_F401/configs/board.h @@ -0,0 +1,20 @@ +/* Copyright 2020 Nick Brassel (tzarc) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#include_next "board.h" + +#undef STM32_HSE_BYPASS diff --git a/keyboards/handwired/onekey/blackpill_f401/chconf.h b/platforms/chibios/BLACKPILL_STM32_F401/configs/chconf.h similarity index 100% rename from keyboards/handwired/onekey/blackpill_f401/chconf.h rename to platforms/chibios/BLACKPILL_STM32_F401/configs/chconf.h diff --git a/platforms/chibios/BLACKPILL_STM32_F401/configs/config.h b/platforms/chibios/BLACKPILL_STM32_F401/configs/config.h new file mode 100644 index 000000000000..eb73e72ef282 --- /dev/null +++ b/platforms/chibios/BLACKPILL_STM32_F401/configs/config.h @@ -0,0 +1,23 @@ +/* Copyright 2020 Nick Brassel (tzarc) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#define BOARD_OTG_NOVBUSSENS 1 + +#define STM32_LSECLK 32768U +#define STM32_HSECLK 25000000U + +#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE diff --git a/platforms/chibios/BLACKPILL_STM32_F401/configs/halconf.h b/platforms/chibios/BLACKPILL_STM32_F401/configs/halconf.h new file mode 100644 index 000000000000..a8db392aaa6c --- /dev/null +++ b/platforms/chibios/BLACKPILL_STM32_F401/configs/halconf.h @@ -0,0 +1,525 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file templates/halconf.h + * @brief HAL configuration header. + * @details HAL configuration file, this file allows to enable or disable the + * various device drivers from your application. You may also use + * this file in order to override the device drivers default settings. + * + * @addtogroup HAL_CONF + * @{ + */ + +#ifndef HALCONF_H +#define HALCONF_H + +#define _CHIBIOS_HAL_CONF_ +#define _CHIBIOS_HAL_CONF_VER_7_0_ + +#include "mcuconf.h" + +/** + * @brief Enables the PAL subsystem. + */ +#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) +#define HAL_USE_PAL TRUE +#endif + +/** + * @brief Enables the ADC subsystem. + */ +#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) +#define HAL_USE_ADC FALSE +#endif + +/** + * @brief Enables the CAN subsystem. + */ +#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) +#define HAL_USE_CAN FALSE +#endif + +/** + * @brief Enables the cryptographic subsystem. + */ +#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__) +#define HAL_USE_CRY FALSE +#endif + +/** + * @brief Enables the DAC subsystem. + */ +#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) +#define HAL_USE_DAC FALSE +#endif + +/** + * @brief Enables the GPT subsystem. + */ +#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) +#define HAL_USE_GPT FALSE +#endif + +/** + * @brief Enables the I2C subsystem. + */ +#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) +#define HAL_USE_I2C FALSE +#endif + +/** + * @brief Enables the I2S subsystem. + */ +#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) +#define HAL_USE_I2S FALSE +#endif + +/** + * @brief Enables the ICU subsystem. + */ +#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) +#define HAL_USE_ICU FALSE +#endif + +/** + * @brief Enables the MAC subsystem. + */ +#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) +#define HAL_USE_MAC FALSE +#endif + +/** + * @brief Enables the MMC_SPI subsystem. + */ +#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) +#define HAL_USE_MMC_SPI FALSE +#endif + +/** + * @brief Enables the PWM subsystem. + */ +#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) +#define HAL_USE_PWM FALSE +#endif + +/** + * @brief Enables the RTC subsystem. + */ +#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) +#define HAL_USE_RTC FALSE +#endif + +/** + * @brief Enables the SDC subsystem. + */ +#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) +#define HAL_USE_SDC FALSE +#endif + +/** + * @brief Enables the SERIAL subsystem. + */ +#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL FALSE +#endif + +/** + * @brief Enables the SERIAL over USB subsystem. + */ +#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL_USB FALSE +#endif + +/** + * @brief Enables the SIO subsystem. + */ +#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__) +#define HAL_USE_SIO FALSE +#endif + +/** + * @brief Enables the SPI subsystem. + */ +#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) +#define HAL_USE_SPI FALSE +#endif + +/** + * @brief Enables the TRNG subsystem. + */ +#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__) +#define HAL_USE_TRNG FALSE +#endif + +/** + * @brief Enables the UART subsystem. + */ +#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) +#define HAL_USE_UART FALSE +#endif + +/** + * @brief Enables the USB subsystem. + */ +#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) +#define HAL_USE_USB TRUE +#endif + +/** + * @brief Enables the WDG subsystem. + */ +#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) +#define HAL_USE_WDG FALSE +#endif + +/** + * @brief Enables the WSPI subsystem. + */ +#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__) +#define HAL_USE_WSPI FALSE +#endif + +/*===========================================================================*/ +/* PAL driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__) +#define PAL_USE_CALLBACKS FALSE +#endif + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__) +#define PAL_USE_WAIT FALSE +#endif + +/*===========================================================================*/ +/* ADC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) +#define ADC_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define ADC_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* CAN driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Sleep mode related APIs inclusion switch. + */ +#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) +#define CAN_USE_SLEEP_MODE TRUE +#endif + +/** + * @brief Enforces the driver to use direct callbacks rather than OSAL events. + */ +#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__) +#define CAN_ENFORCE_USE_CALLBACKS FALSE +#endif + +/*===========================================================================*/ +/* CRY driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables the SW fall-back of the cryptographic driver. + * @details When enabled, this option, activates a fall-back software + * implementation for algorithms not supported by the underlying + * hardware. + * @note Fall-back implementations may not be present for all algorithms. + */ +#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__) +#define HAL_CRY_USE_FALLBACK FALSE +#endif + +/** + * @brief Makes the driver forcibly use the fall-back implementations. + */ +#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__) +#define HAL_CRY_ENFORCE_FALLBACK FALSE +#endif + +/*===========================================================================*/ +/* DAC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__) +#define DAC_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define DAC_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* I2C driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables the mutual exclusion APIs on the I2C bus. + */ +#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define I2C_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* MAC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables the zero-copy API. + */ +#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) +#define MAC_USE_ZERO_COPY FALSE +#endif + +/** + * @brief Enables an event sources for incoming packets. + */ +#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) +#define MAC_USE_EVENTS TRUE +#endif + +/*===========================================================================*/ +/* MMC_SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + * This option is recommended also if the SPI driver does not + * use a DMA channel and heavily loads the CPU. + */ +#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) +#define MMC_NICE_WAITING TRUE +#endif + +/*===========================================================================*/ +/* SDC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Number of initialization attempts before rejecting the card. + * @note Attempts are performed at 10mS intervals. + */ +#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) +#define SDC_INIT_RETRY 100 +#endif + +/** + * @brief Include support for MMC cards. + * @note MMC support is not yet implemented so this option must be kept + * at @p FALSE. + */ +#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) +#define SDC_MMC_SUPPORT FALSE +#endif + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + */ +#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) +#define SDC_NICE_WAITING TRUE +#endif + +/** + * @brief OCR initialization constant for V20 cards. + */ +#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__) +#define SDC_INIT_OCR_V20 0x50FF8000U +#endif + +/** + * @brief OCR initialization constant for non-V20 cards. + */ +#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__) +#define SDC_INIT_OCR 0x80100000U +#endif + +/*===========================================================================*/ +/* SERIAL driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Default bit rate. + * @details Configuration parameter, this is the baud rate selected for the + * default configuration. + */ +#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) +#define SERIAL_DEFAULT_BITRATE 38400 +#endif + +/** + * @brief Serial buffers size. + * @details Configuration parameter, you can change the depth of the queue + * buffers depending on the requirements of your application. + * @note The default is 16 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_BUFFERS_SIZE 16 +#endif + +/*===========================================================================*/ +/* SERIAL_USB driver related setting. */ +/*===========================================================================*/ + +/** + * @brief Serial over USB buffers size. + * @details Configuration parameter, the buffer size must be a multiple of + * the USB data endpoint maximum packet size. + * @note The default is 256 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_USB_BUFFERS_SIZE 256 +#endif + +/** + * @brief Serial over USB number of buffers. + * @note The default is 2 buffers. + */ +#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__) +#define SERIAL_USB_BUFFERS_NUMBER 2 +#endif + +/*===========================================================================*/ +/* SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) +#define SPI_USE_WAIT TRUE +#endif + +/** + * @brief Enables circular transfers APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__) +#define SPI_USE_CIRCULAR FALSE +#endif + + +/** + * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define SPI_USE_MUTUAL_EXCLUSION TRUE +#endif + +/** + * @brief Handling method for SPI CS line. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__) +#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD +#endif + +/*===========================================================================*/ +/* UART driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__) +#define UART_USE_WAIT FALSE +#endif + +/** + * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define UART_USE_MUTUAL_EXCLUSION FALSE +#endif + +/*===========================================================================*/ +/* USB driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) +#define USB_USE_WAIT TRUE +#endif + +/*===========================================================================*/ +/* WSPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__) +#define WSPI_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define WSPI_USE_MUTUAL_EXCLUSION TRUE +#endif + +#endif /* HALCONF_H */ + +/** @} */ diff --git a/platforms/chibios/BLACKPILL_STM32_F401/configs/mcuconf.h b/platforms/chibios/BLACKPILL_STM32_F401/configs/mcuconf.h new file mode 100644 index 000000000000..ba6e934fe7bd --- /dev/null +++ b/platforms/chibios/BLACKPILL_STM32_F401/configs/mcuconf.h @@ -0,0 +1,253 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef MCUCONF_H +#define MCUCONF_H + +/* + * STM32F4xx drivers configuration. + * The following settings override the default settings present in + * the various device driver implementation headers. + * Note that the settings for each driver only have effect if the whole + * driver is enabled in halconf.h. + * + * IRQ priorities: + * 15...0 Lowest...Highest. + * + * DMA priorities: + * 0...3 Lowest...Highest. + */ + +#define STM32F4xx_MCUCONF + +/* + * HAL driver system settings. + */ +#define STM32_NO_INIT FALSE +#define STM32_HSI_ENABLED TRUE +#define STM32_LSI_ENABLED TRUE +#define STM32_HSE_ENABLED TRUE +#define STM32_LSE_ENABLED FALSE +#define STM32_CLOCK48_REQUIRED TRUE +#define STM32_SW STM32_SW_PLL +#define STM32_PLLSRC STM32_PLLSRC_HSE +#define STM32_PLLM_VALUE 25 +#define STM32_PLLN_VALUE 336 +#define STM32_PLLP_VALUE 4 +#define STM32_PLLQ_VALUE 7 +#define STM32_HPRE STM32_HPRE_DIV1 +#define STM32_PPRE1 STM32_PPRE1_DIV4 +#define STM32_PPRE2 STM32_PPRE2_DIV2 +#define STM32_RTCSEL STM32_RTCSEL_LSI +#define STM32_RTCPRE_VALUE 8 +#define STM32_MCO1SEL STM32_MCO1SEL_HSI +#define STM32_MCO1PRE STM32_MCO1PRE_DIV1 +#define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK +#define STM32_MCO2PRE STM32_MCO2PRE_DIV5 +#define STM32_I2SSRC STM32_I2SSRC_CKIN +#define STM32_PLLI2SN_VALUE 192 +#define STM32_PLLI2SR_VALUE 5 +#define STM32_PVD_ENABLE FALSE +#define STM32_PLS STM32_PLS_LEV0 +#define STM32_BKPRAM_ENABLE FALSE + +/* + * IRQ system settings. + */ +#define STM32_IRQ_EXTI0_PRIORITY 6 +#define STM32_IRQ_EXTI1_PRIORITY 6 +#define STM32_IRQ_EXTI2_PRIORITY 6 +#define STM32_IRQ_EXTI3_PRIORITY 6 +#define STM32_IRQ_EXTI4_PRIORITY 6 +#define STM32_IRQ_EXTI5_9_PRIORITY 6 +#define STM32_IRQ_EXTI10_15_PRIORITY 6 +#define STM32_IRQ_EXTI16_PRIORITY 6 +#define STM32_IRQ_EXTI17_PRIORITY 15 +#define STM32_IRQ_EXTI18_PRIORITY 6 +#define STM32_IRQ_EXTI19_PRIORITY 6 +#define STM32_IRQ_EXTI20_PRIORITY 6 +#define STM32_IRQ_EXTI21_PRIORITY 15 +#define STM32_IRQ_EXTI22_PRIORITY 15 + +/* + * ADC driver system settings. + */ +#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4 +#define STM32_ADC_USE_ADC1 FALSE +#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4) +#define STM32_ADC_ADC1_DMA_PRIORITY 2 +#define STM32_ADC_IRQ_PRIORITY 6 +#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6 + +/* + * GPT driver system settings. + */ +#define STM32_GPT_USE_TIM1 FALSE +#define STM32_GPT_USE_TIM2 FALSE +#define STM32_GPT_USE_TIM3 FALSE +#define STM32_GPT_USE_TIM4 FALSE +#define STM32_GPT_USE_TIM5 FALSE +#define STM32_GPT_USE_TIM9 FALSE +#define STM32_GPT_USE_TIM11 FALSE +#define STM32_GPT_TIM1_IRQ_PRIORITY 7 +#define STM32_GPT_TIM2_IRQ_PRIORITY 7 +#define STM32_GPT_TIM3_IRQ_PRIORITY 7 +#define STM32_GPT_TIM4_IRQ_PRIORITY 7 +#define STM32_GPT_TIM5_IRQ_PRIORITY 7 +#define STM32_GPT_TIM9_IRQ_PRIORITY 7 +#define STM32_GPT_TIM11_IRQ_PRIORITY 7 + +/* + * I2C driver system settings. + */ +#define STM32_I2C_USE_I2C1 FALSE +#define STM32_I2C_USE_I2C2 FALSE +#define STM32_I2C_USE_I2C3 FALSE +#define STM32_I2C_BUSY_TIMEOUT 50 +#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) +#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) +#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) +#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) +#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) +#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) +#define STM32_I2C_I2C1_IRQ_PRIORITY 5 +#define STM32_I2C_I2C2_IRQ_PRIORITY 5 +#define STM32_I2C_I2C3_IRQ_PRIORITY 5 +#define STM32_I2C_I2C1_DMA_PRIORITY 3 +#define STM32_I2C_I2C2_DMA_PRIORITY 3 +#define STM32_I2C_I2C3_DMA_PRIORITY 3 +#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") + +/* + * I2S driver system settings. + */ +#define STM32_I2S_USE_SPI2 FALSE +#define STM32_I2S_USE_SPI3 FALSE +#define STM32_I2S_SPI2_IRQ_PRIORITY 10 +#define STM32_I2S_SPI3_IRQ_PRIORITY 10 +#define STM32_I2S_SPI2_DMA_PRIORITY 1 +#define STM32_I2S_SPI3_DMA_PRIORITY 1 +#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) +#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) +#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) +#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) +#define STM32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure") + +/* + * ICU driver system settings. + */ +#define STM32_ICU_USE_TIM1 FALSE +#define STM32_ICU_USE_TIM2 FALSE +#define STM32_ICU_USE_TIM3 FALSE +#define STM32_ICU_USE_TIM4 FALSE +#define STM32_ICU_USE_TIM5 FALSE +#define STM32_ICU_USE_TIM9 FALSE +#define STM32_ICU_TIM1_IRQ_PRIORITY 7 +#define STM32_ICU_TIM2_IRQ_PRIORITY 7 +#define STM32_ICU_TIM3_IRQ_PRIORITY 7 +#define STM32_ICU_TIM4_IRQ_PRIORITY 7 +#define STM32_ICU_TIM5_IRQ_PRIORITY 7 +#define STM32_ICU_TIM9_IRQ_PRIORITY 7 + +/* + * PWM driver system settings. + */ +#define STM32_PWM_USE_ADVANCED FALSE +#define STM32_PWM_USE_TIM1 FALSE +#define STM32_PWM_USE_TIM2 FALSE +#define STM32_PWM_USE_TIM3 FALSE +#define STM32_PWM_USE_TIM4 FALSE +#define STM32_PWM_USE_TIM5 FALSE +#define STM32_PWM_USE_TIM9 FALSE +#define STM32_PWM_TIM1_IRQ_PRIORITY 7 +#define STM32_PWM_TIM2_IRQ_PRIORITY 7 +#define STM32_PWM_TIM3_IRQ_PRIORITY 7 +#define STM32_PWM_TIM4_IRQ_PRIORITY 7 +#define STM32_PWM_TIM5_IRQ_PRIORITY 7 +#define STM32_PWM_TIM9_IRQ_PRIORITY 7 + +/* + * SERIAL driver system settings. + */ +#define STM32_SERIAL_USE_USART1 FALSE +#define STM32_SERIAL_USE_USART2 FALSE +#define STM32_SERIAL_USE_USART6 FALSE +#define STM32_SERIAL_USART1_PRIORITY 12 +#define STM32_SERIAL_USART2_PRIORITY 12 +#define STM32_SERIAL_USART6_PRIORITY 12 + +/* + * SPI driver system settings. + */ +#define STM32_SPI_USE_SPI1 FALSE +#define STM32_SPI_USE_SPI2 FALSE +#define STM32_SPI_USE_SPI3 FALSE +#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0) +#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3) +#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) +#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) +#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) +#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) +#define STM32_SPI_SPI1_DMA_PRIORITY 1 +#define STM32_SPI_SPI2_DMA_PRIORITY 1 +#define STM32_SPI_SPI3_DMA_PRIORITY 1 +#define STM32_SPI_SPI1_IRQ_PRIORITY 10 +#define STM32_SPI_SPI2_IRQ_PRIORITY 10 +#define STM32_SPI_SPI3_IRQ_PRIORITY 10 +#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") + +/* + * ST driver system settings. + */ +#define STM32_ST_IRQ_PRIORITY 8 +#define STM32_ST_USE_TIMER 2 + +/* + * UART driver system settings. + */ +#define STM32_UART_USE_USART1 FALSE +#define STM32_UART_USE_USART2 FALSE +#define STM32_UART_USE_USART6 FALSE +#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) +#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) +#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5) +#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) +#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2) +#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) +#define STM32_UART_USART1_IRQ_PRIORITY 12 +#define STM32_UART_USART2_IRQ_PRIORITY 12 +#define STM32_UART_USART6_IRQ_PRIORITY 12 +#define STM32_UART_USART1_DMA_PRIORITY 0 +#define STM32_UART_USART2_DMA_PRIORITY 0 +#define STM32_UART_USART6_DMA_PRIORITY 0 +#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") + +/* + * USB driver system settings. + */ +#define STM32_USB_USE_OTG1 TRUE +#define STM32_USB_OTG1_IRQ_PRIORITY 14 +#define STM32_USB_OTG1_RX_FIFO_SIZE 512 +#define STM32_USB_OTG_THREAD_PRIO NORMALPRIO+1 +#define STM32_USB_OTG_THREAD_STACK_SIZE 128 +#define STM32_USB_OTGFIFO_FILL_BASEPRI 0 + +/* + * WDG driver system settings. + */ +#define STM32_WDG_USE_IWDG FALSE + +#endif /* MCUCONF_H */ diff --git a/platforms/chibios/BLACKPILL_STM32_F411/board/board.mk b/platforms/chibios/BLACKPILL_STM32_F411/board/board.mk new file mode 100644 index 000000000000..bb00b1a2b0dc --- /dev/null +++ b/platforms/chibios/BLACKPILL_STM32_F411/board/board.mk @@ -0,0 +1,9 @@ +# List of all the board related files. +BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F411RE/board.c + +# Required include directories +BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F411RE + +# Shared variables +ALLCSRC += $(BOARDSRC) +ALLINC += $(BOARDINC) diff --git a/platforms/chibios/BLACKPILL_STM32_F411/configs/board.h b/platforms/chibios/BLACKPILL_STM32_F411/configs/board.h new file mode 100644 index 000000000000..30af6b0c8608 --- /dev/null +++ b/platforms/chibios/BLACKPILL_STM32_F411/configs/board.h @@ -0,0 +1,20 @@ +/* Copyright 2020 Nick Brassel (tzarc) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#include_next "board.h" + +#undef STM32_HSE_BYPASS diff --git a/keyboards/handwired/onekey/blackpill_f411/chconf.h b/platforms/chibios/BLACKPILL_STM32_F411/configs/chconf.h similarity index 100% rename from keyboards/handwired/onekey/blackpill_f411/chconf.h rename to platforms/chibios/BLACKPILL_STM32_F411/configs/chconf.h diff --git a/platforms/chibios/BLACKPILL_STM32_F411/configs/config.h b/platforms/chibios/BLACKPILL_STM32_F411/configs/config.h new file mode 100644 index 000000000000..eb73e72ef282 --- /dev/null +++ b/platforms/chibios/BLACKPILL_STM32_F411/configs/config.h @@ -0,0 +1,23 @@ +/* Copyright 2020 Nick Brassel (tzarc) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#define BOARD_OTG_NOVBUSSENS 1 + +#define STM32_LSECLK 32768U +#define STM32_HSECLK 25000000U + +#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE diff --git a/platforms/chibios/BLACKPILL_STM32_F411/configs/halconf.h b/platforms/chibios/BLACKPILL_STM32_F411/configs/halconf.h new file mode 100644 index 000000000000..a8db392aaa6c --- /dev/null +++ b/platforms/chibios/BLACKPILL_STM32_F411/configs/halconf.h @@ -0,0 +1,525 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file templates/halconf.h + * @brief HAL configuration header. + * @details HAL configuration file, this file allows to enable or disable the + * various device drivers from your application. You may also use + * this file in order to override the device drivers default settings. + * + * @addtogroup HAL_CONF + * @{ + */ + +#ifndef HALCONF_H +#define HALCONF_H + +#define _CHIBIOS_HAL_CONF_ +#define _CHIBIOS_HAL_CONF_VER_7_0_ + +#include "mcuconf.h" + +/** + * @brief Enables the PAL subsystem. + */ +#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) +#define HAL_USE_PAL TRUE +#endif + +/** + * @brief Enables the ADC subsystem. + */ +#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) +#define HAL_USE_ADC FALSE +#endif + +/** + * @brief Enables the CAN subsystem. + */ +#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) +#define HAL_USE_CAN FALSE +#endif + +/** + * @brief Enables the cryptographic subsystem. + */ +#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__) +#define HAL_USE_CRY FALSE +#endif + +/** + * @brief Enables the DAC subsystem. + */ +#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) +#define HAL_USE_DAC FALSE +#endif + +/** + * @brief Enables the GPT subsystem. + */ +#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) +#define HAL_USE_GPT FALSE +#endif + +/** + * @brief Enables the I2C subsystem. + */ +#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) +#define HAL_USE_I2C FALSE +#endif + +/** + * @brief Enables the I2S subsystem. + */ +#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) +#define HAL_USE_I2S FALSE +#endif + +/** + * @brief Enables the ICU subsystem. + */ +#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) +#define HAL_USE_ICU FALSE +#endif + +/** + * @brief Enables the MAC subsystem. + */ +#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) +#define HAL_USE_MAC FALSE +#endif + +/** + * @brief Enables the MMC_SPI subsystem. + */ +#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) +#define HAL_USE_MMC_SPI FALSE +#endif + +/** + * @brief Enables the PWM subsystem. + */ +#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) +#define HAL_USE_PWM FALSE +#endif + +/** + * @brief Enables the RTC subsystem. + */ +#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) +#define HAL_USE_RTC FALSE +#endif + +/** + * @brief Enables the SDC subsystem. + */ +#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) +#define HAL_USE_SDC FALSE +#endif + +/** + * @brief Enables the SERIAL subsystem. + */ +#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL FALSE +#endif + +/** + * @brief Enables the SERIAL over USB subsystem. + */ +#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL_USB FALSE +#endif + +/** + * @brief Enables the SIO subsystem. + */ +#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__) +#define HAL_USE_SIO FALSE +#endif + +/** + * @brief Enables the SPI subsystem. + */ +#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) +#define HAL_USE_SPI FALSE +#endif + +/** + * @brief Enables the TRNG subsystem. + */ +#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__) +#define HAL_USE_TRNG FALSE +#endif + +/** + * @brief Enables the UART subsystem. + */ +#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) +#define HAL_USE_UART FALSE +#endif + +/** + * @brief Enables the USB subsystem. + */ +#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) +#define HAL_USE_USB TRUE +#endif + +/** + * @brief Enables the WDG subsystem. + */ +#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) +#define HAL_USE_WDG FALSE +#endif + +/** + * @brief Enables the WSPI subsystem. + */ +#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__) +#define HAL_USE_WSPI FALSE +#endif + +/*===========================================================================*/ +/* PAL driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__) +#define PAL_USE_CALLBACKS FALSE +#endif + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__) +#define PAL_USE_WAIT FALSE +#endif + +/*===========================================================================*/ +/* ADC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) +#define ADC_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define ADC_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* CAN driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Sleep mode related APIs inclusion switch. + */ +#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) +#define CAN_USE_SLEEP_MODE TRUE +#endif + +/** + * @brief Enforces the driver to use direct callbacks rather than OSAL events. + */ +#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__) +#define CAN_ENFORCE_USE_CALLBACKS FALSE +#endif + +/*===========================================================================*/ +/* CRY driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables the SW fall-back of the cryptographic driver. + * @details When enabled, this option, activates a fall-back software + * implementation for algorithms not supported by the underlying + * hardware. + * @note Fall-back implementations may not be present for all algorithms. + */ +#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__) +#define HAL_CRY_USE_FALLBACK FALSE +#endif + +/** + * @brief Makes the driver forcibly use the fall-back implementations. + */ +#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__) +#define HAL_CRY_ENFORCE_FALLBACK FALSE +#endif + +/*===========================================================================*/ +/* DAC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__) +#define DAC_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define DAC_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* I2C driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables the mutual exclusion APIs on the I2C bus. + */ +#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define I2C_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* MAC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables the zero-copy API. + */ +#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) +#define MAC_USE_ZERO_COPY FALSE +#endif + +/** + * @brief Enables an event sources for incoming packets. + */ +#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) +#define MAC_USE_EVENTS TRUE +#endif + +/*===========================================================================*/ +/* MMC_SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + * This option is recommended also if the SPI driver does not + * use a DMA channel and heavily loads the CPU. + */ +#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) +#define MMC_NICE_WAITING TRUE +#endif + +/*===========================================================================*/ +/* SDC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Number of initialization attempts before rejecting the card. + * @note Attempts are performed at 10mS intervals. + */ +#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) +#define SDC_INIT_RETRY 100 +#endif + +/** + * @brief Include support for MMC cards. + * @note MMC support is not yet implemented so this option must be kept + * at @p FALSE. + */ +#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) +#define SDC_MMC_SUPPORT FALSE +#endif + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + */ +#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) +#define SDC_NICE_WAITING TRUE +#endif + +/** + * @brief OCR initialization constant for V20 cards. + */ +#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__) +#define SDC_INIT_OCR_V20 0x50FF8000U +#endif + +/** + * @brief OCR initialization constant for non-V20 cards. + */ +#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__) +#define SDC_INIT_OCR 0x80100000U +#endif + +/*===========================================================================*/ +/* SERIAL driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Default bit rate. + * @details Configuration parameter, this is the baud rate selected for the + * default configuration. + */ +#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) +#define SERIAL_DEFAULT_BITRATE 38400 +#endif + +/** + * @brief Serial buffers size. + * @details Configuration parameter, you can change the depth of the queue + * buffers depending on the requirements of your application. + * @note The default is 16 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_BUFFERS_SIZE 16 +#endif + +/*===========================================================================*/ +/* SERIAL_USB driver related setting. */ +/*===========================================================================*/ + +/** + * @brief Serial over USB buffers size. + * @details Configuration parameter, the buffer size must be a multiple of + * the USB data endpoint maximum packet size. + * @note The default is 256 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_USB_BUFFERS_SIZE 256 +#endif + +/** + * @brief Serial over USB number of buffers. + * @note The default is 2 buffers. + */ +#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__) +#define SERIAL_USB_BUFFERS_NUMBER 2 +#endif + +/*===========================================================================*/ +/* SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) +#define SPI_USE_WAIT TRUE +#endif + +/** + * @brief Enables circular transfers APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__) +#define SPI_USE_CIRCULAR FALSE +#endif + + +/** + * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define SPI_USE_MUTUAL_EXCLUSION TRUE +#endif + +/** + * @brief Handling method for SPI CS line. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__) +#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD +#endif + +/*===========================================================================*/ +/* UART driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__) +#define UART_USE_WAIT FALSE +#endif + +/** + * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define UART_USE_MUTUAL_EXCLUSION FALSE +#endif + +/*===========================================================================*/ +/* USB driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) +#define USB_USE_WAIT TRUE +#endif + +/*===========================================================================*/ +/* WSPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__) +#define WSPI_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define WSPI_USE_MUTUAL_EXCLUSION TRUE +#endif + +#endif /* HALCONF_H */ + +/** @} */ diff --git a/platforms/chibios/BLACKPILL_STM32_F411/configs/mcuconf.h b/platforms/chibios/BLACKPILL_STM32_F411/configs/mcuconf.h new file mode 100644 index 000000000000..0394ff56bb97 --- /dev/null +++ b/platforms/chibios/BLACKPILL_STM32_F411/configs/mcuconf.h @@ -0,0 +1,253 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef MCUCONF_H +#define MCUCONF_H + +/* + * STM32F4xx drivers configuration. + * The following settings override the default settings present in + * the various device driver implementation headers. + * Note that the settings for each driver only have effect if the whole + * driver is enabled in halconf.h. + * + * IRQ priorities: + * 15...0 Lowest...Highest. + * + * DMA priorities: + * 0...3 Lowest...Highest. + */ + +#define STM32F4xx_MCUCONF + +/* + * HAL driver system settings. + */ +#define STM32_NO_INIT FALSE +#define STM32_HSI_ENABLED TRUE +#define STM32_LSI_ENABLED TRUE +#define STM32_HSE_ENABLED TRUE +#define STM32_LSE_ENABLED FALSE +#define STM32_CLOCK48_REQUIRED TRUE +#define STM32_SW STM32_SW_PLL +#define STM32_PLLSRC STM32_PLLSRC_HSE +#define STM32_PLLM_VALUE 25 +#define STM32_PLLN_VALUE 384 +#define STM32_PLLP_VALUE 4 +#define STM32_PLLQ_VALUE 8 +#define STM32_HPRE STM32_HPRE_DIV1 +#define STM32_PPRE1 STM32_PPRE1_DIV4 +#define STM32_PPRE2 STM32_PPRE2_DIV2 +#define STM32_RTCSEL STM32_RTCSEL_LSI +#define STM32_RTCPRE_VALUE 8 +#define STM32_MCO1SEL STM32_MCO1SEL_HSI +#define STM32_MCO1PRE STM32_MCO1PRE_DIV1 +#define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK +#define STM32_MCO2PRE STM32_MCO2PRE_DIV5 +#define STM32_I2SSRC STM32_I2SSRC_CKIN +#define STM32_PLLI2SN_VALUE 192 +#define STM32_PLLI2SR_VALUE 5 +#define STM32_PVD_ENABLE FALSE +#define STM32_PLS STM32_PLS_LEV0 +#define STM32_BKPRAM_ENABLE FALSE + +/* + * IRQ system settings. + */ +#define STM32_IRQ_EXTI0_PRIORITY 6 +#define STM32_IRQ_EXTI1_PRIORITY 6 +#define STM32_IRQ_EXTI2_PRIORITY 6 +#define STM32_IRQ_EXTI3_PRIORITY 6 +#define STM32_IRQ_EXTI4_PRIORITY 6 +#define STM32_IRQ_EXTI5_9_PRIORITY 6 +#define STM32_IRQ_EXTI10_15_PRIORITY 6 +#define STM32_IRQ_EXTI16_PRIORITY 6 +#define STM32_IRQ_EXTI17_PRIORITY 15 +#define STM32_IRQ_EXTI18_PRIORITY 6 +#define STM32_IRQ_EXTI19_PRIORITY 6 +#define STM32_IRQ_EXTI20_PRIORITY 6 +#define STM32_IRQ_EXTI21_PRIORITY 15 +#define STM32_IRQ_EXTI22_PRIORITY 15 + +/* + * ADC driver system settings. + */ +#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4 +#define STM32_ADC_USE_ADC1 FALSE +#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4) +#define STM32_ADC_ADC1_DMA_PRIORITY 2 +#define STM32_ADC_IRQ_PRIORITY 6 +#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6 + +/* + * GPT driver system settings. + */ +#define STM32_GPT_USE_TIM1 FALSE +#define STM32_GPT_USE_TIM2 FALSE +#define STM32_GPT_USE_TIM3 FALSE +#define STM32_GPT_USE_TIM4 FALSE +#define STM32_GPT_USE_TIM5 FALSE +#define STM32_GPT_USE_TIM9 FALSE +#define STM32_GPT_USE_TIM11 FALSE +#define STM32_GPT_TIM1_IRQ_PRIORITY 7 +#define STM32_GPT_TIM2_IRQ_PRIORITY 7 +#define STM32_GPT_TIM3_IRQ_PRIORITY 7 +#define STM32_GPT_TIM4_IRQ_PRIORITY 7 +#define STM32_GPT_TIM5_IRQ_PRIORITY 7 +#define STM32_GPT_TIM9_IRQ_PRIORITY 7 +#define STM32_GPT_TIM11_IRQ_PRIORITY 7 + +/* + * I2C driver system settings. + */ +#define STM32_I2C_USE_I2C1 FALSE +#define STM32_I2C_USE_I2C2 FALSE +#define STM32_I2C_USE_I2C3 FALSE +#define STM32_I2C_BUSY_TIMEOUT 50 +#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) +#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) +#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) +#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) +#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) +#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) +#define STM32_I2C_I2C1_IRQ_PRIORITY 5 +#define STM32_I2C_I2C2_IRQ_PRIORITY 5 +#define STM32_I2C_I2C3_IRQ_PRIORITY 5 +#define STM32_I2C_I2C1_DMA_PRIORITY 3 +#define STM32_I2C_I2C2_DMA_PRIORITY 3 +#define STM32_I2C_I2C3_DMA_PRIORITY 3 +#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") + +/* + * I2S driver system settings. + */ +#define STM32_I2S_USE_SPI2 FALSE +#define STM32_I2S_USE_SPI3 FALSE +#define STM32_I2S_SPI2_IRQ_PRIORITY 10 +#define STM32_I2S_SPI3_IRQ_PRIORITY 10 +#define STM32_I2S_SPI2_DMA_PRIORITY 1 +#define STM32_I2S_SPI3_DMA_PRIORITY 1 +#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) +#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) +#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) +#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) +#define STM32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure") + +/* + * ICU driver system settings. + */ +#define STM32_ICU_USE_TIM1 FALSE +#define STM32_ICU_USE_TIM2 FALSE +#define STM32_ICU_USE_TIM3 FALSE +#define STM32_ICU_USE_TIM4 FALSE +#define STM32_ICU_USE_TIM5 FALSE +#define STM32_ICU_USE_TIM9 FALSE +#define STM32_ICU_TIM1_IRQ_PRIORITY 7 +#define STM32_ICU_TIM2_IRQ_PRIORITY 7 +#define STM32_ICU_TIM3_IRQ_PRIORITY 7 +#define STM32_ICU_TIM4_IRQ_PRIORITY 7 +#define STM32_ICU_TIM5_IRQ_PRIORITY 7 +#define STM32_ICU_TIM9_IRQ_PRIORITY 7 + +/* + * PWM driver system settings. + */ +#define STM32_PWM_USE_ADVANCED FALSE +#define STM32_PWM_USE_TIM1 FALSE +#define STM32_PWM_USE_TIM2 FALSE +#define STM32_PWM_USE_TIM3 FALSE +#define STM32_PWM_USE_TIM4 FALSE +#define STM32_PWM_USE_TIM5 FALSE +#define STM32_PWM_USE_TIM9 FALSE +#define STM32_PWM_TIM1_IRQ_PRIORITY 7 +#define STM32_PWM_TIM2_IRQ_PRIORITY 7 +#define STM32_PWM_TIM3_IRQ_PRIORITY 7 +#define STM32_PWM_TIM4_IRQ_PRIORITY 7 +#define STM32_PWM_TIM5_IRQ_PRIORITY 7 +#define STM32_PWM_TIM9_IRQ_PRIORITY 7 + +/* + * SERIAL driver system settings. + */ +#define STM32_SERIAL_USE_USART1 FALSE +#define STM32_SERIAL_USE_USART2 FALSE +#define STM32_SERIAL_USE_USART6 FALSE +#define STM32_SERIAL_USART1_PRIORITY 12 +#define STM32_SERIAL_USART2_PRIORITY 12 +#define STM32_SERIAL_USART6_PRIORITY 12 + +/* + * SPI driver system settings. + */ +#define STM32_SPI_USE_SPI1 FALSE +#define STM32_SPI_USE_SPI2 FALSE +#define STM32_SPI_USE_SPI3 FALSE +#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0) +#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3) +#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) +#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) +#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) +#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) +#define STM32_SPI_SPI1_DMA_PRIORITY 1 +#define STM32_SPI_SPI2_DMA_PRIORITY 1 +#define STM32_SPI_SPI3_DMA_PRIORITY 1 +#define STM32_SPI_SPI1_IRQ_PRIORITY 10 +#define STM32_SPI_SPI2_IRQ_PRIORITY 10 +#define STM32_SPI_SPI3_IRQ_PRIORITY 10 +#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") + +/* + * ST driver system settings. + */ +#define STM32_ST_IRQ_PRIORITY 8 +#define STM32_ST_USE_TIMER 2 + +/* + * UART driver system settings. + */ +#define STM32_UART_USE_USART1 FALSE +#define STM32_UART_USE_USART2 FALSE +#define STM32_UART_USE_USART6 FALSE +#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) +#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) +#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5) +#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) +#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2) +#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) +#define STM32_UART_USART1_IRQ_PRIORITY 12 +#define STM32_UART_USART2_IRQ_PRIORITY 12 +#define STM32_UART_USART6_IRQ_PRIORITY 12 +#define STM32_UART_USART1_DMA_PRIORITY 0 +#define STM32_UART_USART2_DMA_PRIORITY 0 +#define STM32_UART_USART6_DMA_PRIORITY 0 +#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") + +/* + * USB driver system settings. + */ +#define STM32_USB_USE_OTG1 TRUE +#define STM32_USB_OTG1_IRQ_PRIORITY 14 +#define STM32_USB_OTG1_RX_FIFO_SIZE 512 +#define STM32_USB_OTG_THREAD_PRIO NORMALPRIO+1 +#define STM32_USB_OTG_THREAD_STACK_SIZE 128 +#define STM32_USB_OTGFIFO_FILL_BASEPRI 0 + +/* + * WDG driver system settings. + */ +#define STM32_WDG_USE_IWDG FALSE + +#endif /* MCUCONF_H */ diff --git a/keyboards/vinta/boards/GENERIC_STM32_F042X6/board.c b/platforms/chibios/GENERIC_STM32_F042X6/board/board.c similarity index 99% rename from keyboards/vinta/boards/GENERIC_STM32_F042X6/board.c rename to platforms/chibios/GENERIC_STM32_F042X6/board/board.c index 754dc5c4dd05..7d93b68f9c1d 100644 --- a/keyboards/vinta/boards/GENERIC_STM32_F042X6/board.c +++ b/platforms/chibios/GENERIC_STM32_F042X6/board/board.c @@ -202,13 +202,14 @@ static void stm32_gpio_init(void) { /* Driver exported functions. */ /*===========================================================================*/ +__attribute__((weak)) void enter_bootloader_mode_if_requested(void) {} + /** * @brief Early initialization code. * @details GPIO ports and system clocks are initialized before everything * else. */ void __early_init(void) { - extern void enter_bootloader_mode_if_requested(void); enter_bootloader_mode_if_requested(); stm32_gpio_init(); diff --git a/keyboards/peiorisboards/ixora/boards/GENERIC_STM32_F042X6/board.h b/platforms/chibios/GENERIC_STM32_F042X6/board/board.h similarity index 100% rename from keyboards/peiorisboards/ixora/boards/GENERIC_STM32_F042X6/board.h rename to platforms/chibios/GENERIC_STM32_F042X6/board/board.h diff --git a/drivers/boards/GENERIC_STM32_F072XB/board.mk b/platforms/chibios/GENERIC_STM32_F042X6/board/board.mk similarity index 54% rename from drivers/boards/GENERIC_STM32_F072XB/board.mk rename to platforms/chibios/GENERIC_STM32_F042X6/board/board.mk index bd6f878269bc..842e33590594 100644 --- a/drivers/boards/GENERIC_STM32_F072XB/board.mk +++ b/platforms/chibios/GENERIC_STM32_F042X6/board/board.mk @@ -1,8 +1,8 @@ # List of all the board related files. -BOARDSRC = $(BOARD_PATH)/boards/GENERIC_STM32_F072XB/board.c +BOARDSRC = $(BOARD_PATH)/board/board.c # Required include directories -BOARDINC = $(BOARD_PATH)/boards/GENERIC_STM32_F072XB +BOARDINC = $(BOARD_PATH)/board # Shared variables ALLCSRC += $(BOARDSRC) diff --git a/keyboards/peiorisboards/ixora/bootloader_defs.h b/platforms/chibios/GENERIC_STM32_F042X6/configs/bootloader_defs.h similarity index 100% rename from keyboards/peiorisboards/ixora/bootloader_defs.h rename to platforms/chibios/GENERIC_STM32_F042X6/configs/bootloader_defs.h diff --git a/drivers/boards/GENERIC_STM32_F072XB/board.c b/platforms/chibios/GENERIC_STM32_F072XB/board/board.c similarity index 100% rename from drivers/boards/GENERIC_STM32_F072XB/board.c rename to platforms/chibios/GENERIC_STM32_F072XB/board/board.c diff --git a/drivers/boards/GENERIC_STM32_F072XB/board.h b/platforms/chibios/GENERIC_STM32_F072XB/board/board.h similarity index 100% rename from drivers/boards/GENERIC_STM32_F072XB/board.h rename to platforms/chibios/GENERIC_STM32_F072XB/board/board.h diff --git a/drivers/boards/BLACKPILL_STM32_F411/board.mk b/platforms/chibios/GENERIC_STM32_F072XB/board/board.mk similarity index 54% rename from drivers/boards/BLACKPILL_STM32_F411/board.mk rename to platforms/chibios/GENERIC_STM32_F072XB/board/board.mk index 93c1e62f5d7d..842e33590594 100644 --- a/drivers/boards/BLACKPILL_STM32_F411/board.mk +++ b/platforms/chibios/GENERIC_STM32_F072XB/board/board.mk @@ -1,8 +1,8 @@ # List of all the board related files. -BOARDSRC = $(BOARD_PATH)/boards/BLACKPILL_STM32_F411/board.c +BOARDSRC = $(BOARD_PATH)/board/board.c # Required include directories -BOARDINC = $(BOARD_PATH)/boards/BLACKPILL_STM32_F411 +BOARDINC = $(BOARD_PATH)/board # Shared variables ALLCSRC += $(BOARDSRC) diff --git a/drivers/boards/GENERIC_STM32_F072XB/bootloader_defs.h b/platforms/chibios/GENERIC_STM32_F072XB/configs/bootloader_defs.h similarity index 100% rename from drivers/boards/GENERIC_STM32_F072XB/bootloader_defs.h rename to platforms/chibios/GENERIC_STM32_F072XB/configs/bootloader_defs.h diff --git a/drivers/boards/GENERIC_STM32_F303XC/board.c b/platforms/chibios/GENERIC_STM32_F303XC/board/board.c similarity index 99% rename from drivers/boards/GENERIC_STM32_F303XC/board.c rename to platforms/chibios/GENERIC_STM32_F303XC/board/board.c index 9b0fc1b6b958..4722acd648fe 100644 --- a/drivers/boards/GENERIC_STM32_F303XC/board.c +++ b/platforms/chibios/GENERIC_STM32_F303XC/board/board.c @@ -181,7 +181,7 @@ static void stm32_gpio_init(void) { #endif } -void enter_bootloader_mode_if_requested(void); +__attribute__((weak)) void enter_bootloader_mode_if_requested(void) {} /** * @brief Early initialization code. diff --git a/drivers/boards/GENERIC_STM32_F303XC/board.h b/platforms/chibios/GENERIC_STM32_F303XC/board/board.h similarity index 100% rename from drivers/boards/GENERIC_STM32_F303XC/board.h rename to platforms/chibios/GENERIC_STM32_F303XC/board/board.h diff --git a/drivers/boards/BLACKPILL_STM32_F401/board.mk b/platforms/chibios/GENERIC_STM32_F303XC/board/board.mk similarity index 54% rename from drivers/boards/BLACKPILL_STM32_F401/board.mk rename to platforms/chibios/GENERIC_STM32_F303XC/board/board.mk index 33473ed6b1d4..842e33590594 100644 --- a/drivers/boards/BLACKPILL_STM32_F401/board.mk +++ b/platforms/chibios/GENERIC_STM32_F303XC/board/board.mk @@ -1,8 +1,8 @@ # List of all the board related files. -BOARDSRC = $(BOARD_PATH)/boards/BLACKPILL_STM32_F401/board.c +BOARDSRC = $(BOARD_PATH)/board/board.c # Required include directories -BOARDINC = $(BOARD_PATH)/boards/BLACKPILL_STM32_F401 +BOARDINC = $(BOARD_PATH)/board # Shared variables ALLCSRC += $(BOARDSRC) diff --git a/drivers/boards/GENERIC_STM32_F303XC/bootloader_defs.h b/platforms/chibios/GENERIC_STM32_F303XC/configs/bootloader_defs.h similarity index 100% rename from drivers/boards/GENERIC_STM32_F303XC/bootloader_defs.h rename to platforms/chibios/GENERIC_STM32_F303XC/configs/bootloader_defs.h diff --git a/quantum/stm32/chconf.h b/platforms/chibios/GENERIC_STM32_F303XC/configs/chconf.h similarity index 68% rename from quantum/stm32/chconf.h rename to platforms/chibios/GENERIC_STM32_F303XC/configs/chconf.h index b6e66f9e4988..aac33037058e 100644 --- a/quantum/stm32/chconf.h +++ b/platforms/chibios/GENERIC_STM32_F303XC/configs/chconf.h @@ -26,10 +26,10 @@ */ #ifndef CHCONF_H -# define CHCONF_H +#define CHCONF_H -# define _CHIBIOS_RT_CONF_ -# define _CHIBIOS_RT_CONF_VER_6_0_ +#define _CHIBIOS_RT_CONF_ +#define _CHIBIOS_RT_CONF_VER_6_0_ /*===========================================================================*/ /** @@ -42,34 +42,34 @@ * @brief System time counter resolution. * @note Allowed values are 16 or 32 bits. */ -# if !defined(CH_CFG_ST_RESOLUTION) -# define CH_CFG_ST_RESOLUTION 32 -# endif +#if !defined(CH_CFG_ST_RESOLUTION) +#define CH_CFG_ST_RESOLUTION 32 +#endif /** * @brief System tick frequency. * @details Frequency of the system timer that drives the system ticks. This * setting also defines the system tick time unit. */ -# if !defined(CH_CFG_ST_FREQUENCY) -# define CH_CFG_ST_FREQUENCY 100000 -# endif +#if !defined(CH_CFG_ST_FREQUENCY) +#define CH_CFG_ST_FREQUENCY 100000 +#endif /** * @brief Time intervals data size. * @note Allowed values are 16, 32 or 64 bits. */ -# if !defined(CH_CFG_INTERVALS_SIZE) -# define CH_CFG_INTERVALS_SIZE 32 -# endif +#if !defined(CH_CFG_INTERVALS_SIZE) +#define CH_CFG_INTERVALS_SIZE 32 +#endif /** * @brief Time types data size. * @note Allowed values are 16 or 32 bits. */ -# if !defined(CH_CFG_TIME_TYPES_SIZE) -# define CH_CFG_TIME_TYPES_SIZE 32 -# endif +#if !defined(CH_CFG_TIME_TYPES_SIZE) +#define CH_CFG_TIME_TYPES_SIZE 32 +#endif /** * @brief Time delta constant for the tick-less mode. @@ -79,9 +79,9 @@ * The value one is not valid, timeouts are rounded up to * this value. */ -# if !defined(CH_CFG_ST_TIMEDELTA) -# define CH_CFG_ST_TIMEDELTA 2 -# endif +#if !defined(CH_CFG_ST_TIMEDELTA) +#define CH_CFG_ST_TIMEDELTA 2 +#endif /** @} */ @@ -104,9 +104,9 @@ * @note The round robin preemption is not supported in tickless mode and * must be set to zero in that case. */ -# if !defined(CH_CFG_TIME_QUANTUM) -# define CH_CFG_TIME_QUANTUM 0 -# endif +#if !defined(CH_CFG_TIME_QUANTUM) +#define CH_CFG_TIME_QUANTUM 0 +#endif /** * @brief Managed RAM size. @@ -119,9 +119,9 @@ * provide the @p __heap_base__ and @p __heap_end__ symbols. * @note Requires @p CH_CFG_USE_MEMCORE. */ -# if !defined(CH_CFG_MEMCORE_SIZE) -# define CH_CFG_MEMCORE_SIZE 0 -# endif +#if !defined(CH_CFG_MEMCORE_SIZE) +#define CH_CFG_MEMCORE_SIZE 0 +#endif /** * @brief Idle thread automatic spawn suppression. @@ -130,9 +130,9 @@ * function becomes the idle thread and must implement an * infinite loop. */ -# if !defined(CH_CFG_NO_IDLE_THREAD) -# define CH_CFG_NO_IDLE_THREAD FALSE -# endif +#if !defined(CH_CFG_NO_IDLE_THREAD) +#define CH_CFG_NO_IDLE_THREAD FALSE +#endif /** @} */ @@ -151,9 +151,9 @@ * @note This is not related to the compiler optimization options. * @note The default is @p TRUE. */ -# if !defined(CH_CFG_OPTIMIZE_SPEED) -# define CH_CFG_OPTIMIZE_SPEED TRUE -# endif +#if !defined(CH_CFG_OPTIMIZE_SPEED) +#define CH_CFG_OPTIMIZE_SPEED TRUE +#endif /** @} */ @@ -171,9 +171,9 @@ * * @note The default is @p TRUE. */ -# if !defined(CH_CFG_USE_TM) -# define CH_CFG_USE_TM TRUE -# endif +#if !defined(CH_CFG_USE_TM) +#define CH_CFG_USE_TM TRUE +#endif /** * @brief Threads registry APIs. @@ -181,9 +181,9 @@ * * @note The default is @p TRUE. */ -# if !defined(CH_CFG_USE_REGISTRY) -# define CH_CFG_USE_REGISTRY TRUE -# endif +#if !defined(CH_CFG_USE_REGISTRY) +#define CH_CFG_USE_REGISTRY TRUE +#endif /** * @brief Threads synchronization APIs. @@ -192,9 +192,9 @@ * * @note The default is @p TRUE. */ -# if !defined(CH_CFG_USE_WAITEXIT) -# define CH_CFG_USE_WAITEXIT TRUE -# endif +#if !defined(CH_CFG_USE_WAITEXIT) +#define CH_CFG_USE_WAITEXIT TRUE +#endif /** * @brief Semaphores APIs. @@ -202,9 +202,9 @@ * * @note The default is @p TRUE. */ -# if !defined(CH_CFG_USE_SEMAPHORES) -# define CH_CFG_USE_SEMAPHORES TRUE -# endif +#if !defined(CH_CFG_USE_SEMAPHORES) +#define CH_CFG_USE_SEMAPHORES TRUE +#endif /** * @brief Semaphores queuing mode. @@ -215,9 +215,9 @@ * requirements. * @note Requires @p CH_CFG_USE_SEMAPHORES. */ -# if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY) -# define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE -# endif +#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY) +#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE +#endif /** * @brief Mutexes APIs. @@ -225,9 +225,9 @@ * * @note The default is @p TRUE. */ -# if !defined(CH_CFG_USE_MUTEXES) -# define CH_CFG_USE_MUTEXES TRUE -# endif +#if !defined(CH_CFG_USE_MUTEXES) +#define CH_CFG_USE_MUTEXES TRUE +#endif /** * @brief Enables recursive behavior on mutexes. @@ -237,9 +237,9 @@ * @note The default is @p FALSE. * @note Requires @p CH_CFG_USE_MUTEXES. */ -# if !defined(CH_CFG_USE_MUTEXES_RECURSIVE) -# define CH_CFG_USE_MUTEXES_RECURSIVE FALSE -# endif +#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE) +#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE +#endif /** * @brief Conditional Variables APIs. @@ -249,9 +249,9 @@ * @note The default is @p TRUE. * @note Requires @p CH_CFG_USE_MUTEXES. */ -# if !defined(CH_CFG_USE_CONDVARS) -# define CH_CFG_USE_CONDVARS TRUE -# endif +#if !defined(CH_CFG_USE_CONDVARS) +#define CH_CFG_USE_CONDVARS TRUE +#endif /** * @brief Conditional Variables APIs with timeout. @@ -261,9 +261,9 @@ * @note The default is @p TRUE. * @note Requires @p CH_CFG_USE_CONDVARS. */ -# if !defined(CH_CFG_USE_CONDVARS_TIMEOUT) -# define CH_CFG_USE_CONDVARS_TIMEOUT TRUE -# endif +#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT) +#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE +#endif /** * @brief Events Flags APIs. @@ -271,9 +271,9 @@ * * @note The default is @p TRUE. */ -# if !defined(CH_CFG_USE_EVENTS) -# define CH_CFG_USE_EVENTS TRUE -# endif +#if !defined(CH_CFG_USE_EVENTS) +#define CH_CFG_USE_EVENTS TRUE +#endif /** * @brief Events Flags APIs with timeout. @@ -283,9 +283,9 @@ * @note The default is @p TRUE. * @note Requires @p CH_CFG_USE_EVENTS. */ -# if !defined(CH_CFG_USE_EVENTS_TIMEOUT) -# define CH_CFG_USE_EVENTS_TIMEOUT TRUE -# endif +#if !defined(CH_CFG_USE_EVENTS_TIMEOUT) +#define CH_CFG_USE_EVENTS_TIMEOUT TRUE +#endif /** * @brief Synchronous Messages APIs. @@ -294,9 +294,9 @@ * * @note The default is @p TRUE. */ -# if !defined(CH_CFG_USE_MESSAGES) -# define CH_CFG_USE_MESSAGES TRUE -# endif +#if !defined(CH_CFG_USE_MESSAGES) +#define CH_CFG_USE_MESSAGES TRUE +#endif /** * @brief Synchronous Messages queuing mode. @@ -307,9 +307,9 @@ * requirements. * @note Requires @p CH_CFG_USE_MESSAGES. */ -# if !defined(CH_CFG_USE_MESSAGES_PRIORITY) -# define CH_CFG_USE_MESSAGES_PRIORITY TRUE -# endif +#if !defined(CH_CFG_USE_MESSAGES_PRIORITY) +#define CH_CFG_USE_MESSAGES_PRIORITY TRUE +#endif /** * @brief Mailboxes APIs. @@ -319,9 +319,9 @@ * @note The default is @p TRUE. * @note Requires @p CH_CFG_USE_SEMAPHORES. */ -# if !defined(CH_CFG_USE_MAILBOXES) -# define CH_CFG_USE_MAILBOXES TRUE -# endif +#if !defined(CH_CFG_USE_MAILBOXES) +#define CH_CFG_USE_MAILBOXES TRUE +#endif /** * @brief Core Memory Manager APIs. @@ -330,9 +330,9 @@ * * @note The default is @p TRUE. */ -# if !defined(CH_CFG_USE_MEMCORE) -# define CH_CFG_USE_MEMCORE TRUE -# endif +#if !defined(CH_CFG_USE_MEMCORE) +#define CH_CFG_USE_MEMCORE TRUE +#endif /** * @brief Heap Allocator APIs. @@ -344,9 +344,9 @@ * @p CH_CFG_USE_SEMAPHORES. * @note Mutexes are recommended. */ -# if !defined(CH_CFG_USE_HEAP) -# define CH_CFG_USE_HEAP TRUE -# endif +#if !defined(CH_CFG_USE_HEAP) +#define CH_CFG_USE_HEAP TRUE +#endif /** * @brief Memory Pools Allocator APIs. @@ -355,9 +355,9 @@ * * @note The default is @p TRUE. */ -# if !defined(CH_CFG_USE_MEMPOOLS) -# define CH_CFG_USE_MEMPOOLS TRUE -# endif +#if !defined(CH_CFG_USE_MEMPOOLS) +#define CH_CFG_USE_MEMPOOLS TRUE +#endif /** * @brief Objects FIFOs APIs. @@ -366,9 +366,9 @@ * * @note The default is @p TRUE. */ -# if !defined(CH_CFG_USE_OBJ_FIFOS) -# define CH_CFG_USE_OBJ_FIFOS TRUE -# endif +#if !defined(CH_CFG_USE_OBJ_FIFOS) +#define CH_CFG_USE_OBJ_FIFOS TRUE +#endif /** * @brief Pipes APIs. @@ -377,9 +377,9 @@ * * @note The default is @p TRUE. */ -# if !defined(CH_CFG_USE_PIPES) -# define CH_CFG_USE_PIPES TRUE -# endif +#if !defined(CH_CFG_USE_PIPES) +#define CH_CFG_USE_PIPES TRUE +#endif /** * @brief Dynamic Threads APIs. @@ -390,9 +390,9 @@ * @note Requires @p CH_CFG_USE_WAITEXIT. * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS. */ -# if !defined(CH_CFG_USE_DYNAMIC) -# define CH_CFG_USE_DYNAMIC TRUE -# endif +#if !defined(CH_CFG_USE_DYNAMIC) +#define CH_CFG_USE_DYNAMIC TRUE +#endif /** @} */ @@ -410,60 +410,60 @@ * * @note The default is @p FALSE. */ -# if !defined(CH_CFG_USE_FACTORY) -# define CH_CFG_USE_FACTORY TRUE -# endif +#if !defined(CH_CFG_USE_FACTORY) +#define CH_CFG_USE_FACTORY TRUE +#endif /** * @brief Maximum length for object names. * @details If the specified length is zero then the name is stored by * pointer but this could have unintended side effects. */ -# if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH) -# define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8 -# endif +#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH) +#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8 +#endif /** * @brief Enables the registry of generic objects. */ -# if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY) -# define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE -# endif +#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY) +#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE +#endif /** * @brief Enables factory for generic buffers. */ -# if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS) -# define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE -# endif +#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS) +#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE +#endif /** * @brief Enables factory for semaphores. */ -# if !defined(CH_CFG_FACTORY_SEMAPHORES) -# define CH_CFG_FACTORY_SEMAPHORES TRUE -# endif +#if !defined(CH_CFG_FACTORY_SEMAPHORES) +#define CH_CFG_FACTORY_SEMAPHORES TRUE +#endif /** * @brief Enables factory for mailboxes. */ -# if !defined(CH_CFG_FACTORY_MAILBOXES) -# define CH_CFG_FACTORY_MAILBOXES TRUE -# endif +#if !defined(CH_CFG_FACTORY_MAILBOXES) +#define CH_CFG_FACTORY_MAILBOXES TRUE +#endif /** * @brief Enables factory for objects FIFOs. */ -# if !defined(CH_CFG_FACTORY_OBJ_FIFOS) -# define CH_CFG_FACTORY_OBJ_FIFOS TRUE -# endif +#if !defined(CH_CFG_FACTORY_OBJ_FIFOS) +#define CH_CFG_FACTORY_OBJ_FIFOS TRUE +#endif /** * @brief Enables factory for Pipes. */ -# if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__) -# define CH_CFG_FACTORY_PIPES TRUE -# endif +#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__) +#define CH_CFG_FACTORY_PIPES TRUE +#endif /** @} */ @@ -479,9 +479,9 @@ * * @note The default is @p FALSE. */ -# if !defined(CH_DBG_STATISTICS) -# define CH_DBG_STATISTICS FALSE -# endif +#if !defined(CH_DBG_STATISTICS) +#define CH_DBG_STATISTICS FALSE +#endif /** * @brief Debug option, system state check. @@ -490,9 +490,9 @@ * * @note The default is @p FALSE. */ -# if !defined(CH_DBG_SYSTEM_STATE_CHECK) -# define CH_DBG_SYSTEM_STATE_CHECK FALSE -# endif +#if !defined(CH_DBG_SYSTEM_STATE_CHECK) +#define CH_DBG_SYSTEM_STATE_CHECK FALSE +#endif /** * @brief Debug option, parameters checks. @@ -501,9 +501,9 @@ * * @note The default is @p FALSE. */ -# if !defined(CH_DBG_ENABLE_CHECKS) -# define CH_DBG_ENABLE_CHECKS FALSE -# endif +#if !defined(CH_DBG_ENABLE_CHECKS) +#define CH_DBG_ENABLE_CHECKS FALSE +#endif /** * @brief Debug option, consistency checks. @@ -513,9 +513,9 @@ * * @note The default is @p FALSE. */ -# if !defined(CH_DBG_ENABLE_ASSERTS) -# define CH_DBG_ENABLE_ASSERTS FALSE -# endif +#if !defined(CH_DBG_ENABLE_ASSERTS) +#define CH_DBG_ENABLE_ASSERTS FALSE +#endif /** * @brief Debug option, trace buffer. @@ -523,18 +523,18 @@ * * @note The default is @p CH_DBG_TRACE_MASK_DISABLED. */ -# if !defined(CH_DBG_TRACE_MASK) -# define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED -# endif +#if !defined(CH_DBG_TRACE_MASK) +#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED +#endif /** * @brief Trace buffer entries. * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is * different from @p CH_DBG_TRACE_MASK_DISABLED. */ -# if !defined(CH_DBG_TRACE_BUFFER_SIZE) -# define CH_DBG_TRACE_BUFFER_SIZE 128 -# endif +#if !defined(CH_DBG_TRACE_BUFFER_SIZE) +#define CH_DBG_TRACE_BUFFER_SIZE 128 +#endif /** * @brief Debug option, stack checks. @@ -546,9 +546,9 @@ * @note The default failure mode is to halt the system with the global * @p panic_msg variable set to @p NULL. */ -# if !defined(CH_DBG_ENABLE_STACK_CHECK) -# define CH_DBG_ENABLE_STACK_CHECK TRUE -# endif +#if !defined(CH_DBG_ENABLE_STACK_CHECK) +#define CH_DBG_ENABLE_STACK_CHECK TRUE +#endif /** * @brief Debug option, stacks initialization. @@ -558,9 +558,9 @@ * * @note The default is @p FALSE. */ -# if !defined(CH_DBG_FILL_THREADS) -# define CH_DBG_FILL_THREADS FALSE -# endif +#if !defined(CH_DBG_FILL_THREADS) +#define CH_DBG_FILL_THREADS FALSE +#endif /** * @brief Debug option, threads profiling. @@ -571,9 +571,9 @@ * @note This debug option is not currently compatible with the * tickless mode. */ -# if !defined(CH_DBG_THREADS_PROFILING) -# define CH_DBG_THREADS_PROFILING FALSE -# endif +#if !defined(CH_DBG_THREADS_PROFILING) +#define CH_DBG_THREADS_PROFILING FALSE +#endif /** @} */ @@ -588,22 +588,24 @@ * @brief System structure extension. * @details User fields added to the end of the @p ch_system_t structure. */ -# define CH_CFG_SYSTEM_EXTRA_FIELDS /* Add threads custom fields here.*/ +#define CH_CFG_SYSTEM_EXTRA_FIELDS \ + /* Add threads custom fields here.*/ /** * @brief System initialization hook. * @details User initialization code added to the @p chSysInit() function * just before interrupts are enabled globally. */ -# define CH_CFG_SYSTEM_INIT_HOOK() \ - { /* Add threads initialization code here.*/ \ - } +#define CH_CFG_SYSTEM_INIT_HOOK() { \ + /* Add threads initialization code here.*/ \ +} /** * @brief Threads descriptor structure extension. * @details User fields added to the end of the @p thread_t structure. */ -# define CH_CFG_THREAD_EXTRA_FIELDS /* Add threads custom fields here.*/ +#define CH_CFG_THREAD_EXTRA_FIELDS \ + /* Add threads custom fields here.*/ /** * @brief Threads initialization hook. @@ -612,39 +614,39 @@ * @note It is invoked from within @p _thread_init() and implicitly from all * the threads creation APIs. */ -# define CH_CFG_THREAD_INIT_HOOK(tp) \ - { /* Add threads initialization code here.*/ \ - } +#define CH_CFG_THREAD_INIT_HOOK(tp) { \ + /* Add threads initialization code here.*/ \ +} /** * @brief Threads finalization hook. * @details User finalization code added to the @p chThdExit() API. */ -# define CH_CFG_THREAD_EXIT_HOOK(tp) \ - { /* Add threads finalization code here.*/ \ - } +#define CH_CFG_THREAD_EXIT_HOOK(tp) { \ + /* Add threads finalization code here.*/ \ +} /** * @brief Context switch hook. * @details This hook is invoked just before switching between threads. */ -# define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) \ - { /* Context switch code here.*/ \ - } +#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \ + /* Context switch code here.*/ \ +} /** * @brief ISR enter hook. */ -# define CH_CFG_IRQ_PROLOGUE_HOOK() \ - { /* IRQ prologue code here.*/ \ - } +#define CH_CFG_IRQ_PROLOGUE_HOOK() { \ + /* IRQ prologue code here.*/ \ +} /** * @brief ISR exit hook. */ -# define CH_CFG_IRQ_EPILOGUE_HOOK() \ - { /* IRQ epilogue code here.*/ \ - } +#define CH_CFG_IRQ_EPILOGUE_HOOK() { \ + /* IRQ epilogue code here.*/ \ +} /** * @brief Idle thread enter hook. @@ -652,9 +654,9 @@ * should be invoked from here. * @note This macro can be used to activate a power saving mode. */ -# define CH_CFG_IDLE_ENTER_HOOK() \ - { /* Idle-enter code here.*/ \ - } +#define CH_CFG_IDLE_ENTER_HOOK() { \ + /* Idle-enter code here.*/ \ +} /** * @brief Idle thread leave hook. @@ -662,44 +664,44 @@ * should be invoked from here. * @note This macro can be used to deactivate a power saving mode. */ -# define CH_CFG_IDLE_LEAVE_HOOK() \ - { /* Idle-leave code here.*/ \ - } +#define CH_CFG_IDLE_LEAVE_HOOK() { \ + /* Idle-leave code here.*/ \ +} /** * @brief Idle Loop hook. * @details This hook is continuously invoked by the idle thread loop. */ -# define CH_CFG_IDLE_LOOP_HOOK() \ - { /* Idle loop code here.*/ \ - } +#define CH_CFG_IDLE_LOOP_HOOK() { \ + /* Idle loop code here.*/ \ +} /** * @brief System tick event hook. * @details This hook is invoked in the system tick handler immediately * after processing the virtual timers queue. */ -# define CH_CFG_SYSTEM_TICK_HOOK() \ - { /* System tick event code here.*/ \ - } +#define CH_CFG_SYSTEM_TICK_HOOK() { \ + /* System tick event code here.*/ \ +} /** * @brief System halt hook. * @details This hook is invoked in case to a system halting error before * the system is halted. */ -# define CH_CFG_SYSTEM_HALT_HOOK(reason) \ - { /* System halt code here.*/ \ - } +#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \ + /* System halt code here.*/ \ +} /** * @brief Trace hook. * @details This hook is invoked each time a new record is written in the * trace buffer. */ -# define CH_CFG_TRACE_HOOK(tep) \ - { /* Trace code here.*/ \ - } +#define CH_CFG_TRACE_HOOK(tep) { \ + /* Trace code here.*/ \ +} /** @} */ @@ -707,6 +709,6 @@ /* Port-specific settings (override port settings defaulted in chcore.h). */ /*===========================================================================*/ -#endif /* CHCONF_H */ +#endif /* CHCONF_H */ /** @} */ diff --git a/quantum/stm32/halconf.h b/platforms/chibios/GENERIC_STM32_F303XC/configs/halconf.h similarity index 62% rename from quantum/stm32/halconf.h rename to platforms/chibios/GENERIC_STM32_F303XC/configs/halconf.h index b6c7b392ca71..6b48e289f90e 100644 --- a/quantum/stm32/halconf.h +++ b/platforms/chibios/GENERIC_STM32_F303XC/configs/halconf.h @@ -26,173 +26,173 @@ */ #ifndef HALCONF_H -# define HALCONF_H +#define HALCONF_H -# define _CHIBIOS_HAL_CONF_ -# define _CHIBIOS_HAL_CONF_VER_7_0_ +#define _CHIBIOS_HAL_CONF_ +#define _CHIBIOS_HAL_CONF_VER_7_0_ -# include "mcuconf.h" +#include "mcuconf.h" /** * @brief Enables the PAL subsystem. */ -# if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) -# define HAL_USE_PAL TRUE -# endif +#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) +#define HAL_USE_PAL TRUE +#endif /** * @brief Enables the ADC subsystem. */ -# if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) -# define HAL_USE_ADC FALSE -# endif +#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) +#define HAL_USE_ADC FALSE +#endif /** * @brief Enables the CAN subsystem. */ -# if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) -# define HAL_USE_CAN FALSE -# endif +#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) +#define HAL_USE_CAN FALSE +#endif /** * @brief Enables the cryptographic subsystem. */ -# if !defined(HAL_USE_CRY) || defined(__DOXYGEN__) -# define HAL_USE_CRY FALSE -# endif +#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__) +#define HAL_USE_CRY FALSE +#endif /** * @brief Enables the DAC subsystem. */ -# if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) -# define HAL_USE_DAC TRUE -# endif +#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) +#define HAL_USE_DAC TRUE +#endif /** * @brief Enables the GPT subsystem. */ -# if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) -# define HAL_USE_GPT TRUE -# endif +#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) +#define HAL_USE_GPT TRUE +#endif /** * @brief Enables the I2C subsystem. */ -# if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) -# define HAL_USE_I2C TRUE -# endif +#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) +#define HAL_USE_I2C TRUE +#endif /** * @brief Enables the I2S subsystem. */ -# if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) -# define HAL_USE_I2S FALSE -# endif +#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) +#define HAL_USE_I2S FALSE +#endif /** * @brief Enables the ICU subsystem. */ -# if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) -# define HAL_USE_ICU FALSE -# endif +#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) +#define HAL_USE_ICU FALSE +#endif /** * @brief Enables the MAC subsystem. */ -# if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) -# define HAL_USE_MAC FALSE -# endif +#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) +#define HAL_USE_MAC FALSE +#endif /** * @brief Enables the MMC_SPI subsystem. */ -# if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) -# define HAL_USE_MMC_SPI FALSE -# endif +#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) +#define HAL_USE_MMC_SPI FALSE +#endif /** * @brief Enables the PWM subsystem. */ -# if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) -# define HAL_USE_PWM TRUE -# endif +#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) +#define HAL_USE_PWM TRUE +#endif /** * @brief Enables the RTC subsystem. */ -# if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) -# define HAL_USE_RTC FALSE -# endif +#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) +#define HAL_USE_RTC FALSE +#endif /** * @brief Enables the SDC subsystem. */ -# if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) -# define HAL_USE_SDC FALSE -# endif +#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) +#define HAL_USE_SDC FALSE +#endif /** * @brief Enables the SERIAL subsystem. */ -# if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -# define HAL_USE_SERIAL FALSE -# endif +#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL FALSE +#endif /** * @brief Enables the SERIAL over USB subsystem. */ -# if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) -# define HAL_USE_SERIAL_USB TRUE -# endif +#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL_USB TRUE +#endif /** * @brief Enables the SIO subsystem. */ -# if !defined(HAL_USE_SIO) || defined(__DOXYGEN__) -# define HAL_USE_SIO FALSE -# endif +#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__) +#define HAL_USE_SIO FALSE +#endif /** * @brief Enables the SPI subsystem. */ -# if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) -# define HAL_USE_SPI TRUE -# endif +#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) +#define HAL_USE_SPI TRUE +#endif /** * @brief Enables the TRNG subsystem. */ -# if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__) -# define HAL_USE_TRNG FALSE -# endif +#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__) +#define HAL_USE_TRNG FALSE +#endif /** * @brief Enables the UART subsystem. */ -# if !defined(HAL_USE_UART) || defined(__DOXYGEN__) -# define HAL_USE_UART FALSE -# endif +#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) +#define HAL_USE_UART FALSE +#endif /** * @brief Enables the USB subsystem. */ -# if !defined(HAL_USE_USB) || defined(__DOXYGEN__) -# define HAL_USE_USB TRUE -# endif +#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) +#define HAL_USE_USB TRUE +#endif /** * @brief Enables the WDG subsystem. */ -# if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) -# define HAL_USE_WDG FALSE -# endif +#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) +#define HAL_USE_WDG FALSE +#endif /** * @brief Enables the WSPI subsystem. */ -# if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__) -# define HAL_USE_WSPI FALSE -# endif +#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__) +#define HAL_USE_WSPI FALSE +#endif /*===========================================================================*/ /* PAL driver related settings. */ @@ -202,17 +202,17 @@ * @brief Enables synchronous APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__) -# define PAL_USE_CALLBACKS TRUE -# endif +#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__) +#define PAL_USE_CALLBACKS TRUE +#endif /** * @brief Enables synchronous APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__) -# define PAL_USE_WAIT TRUE -# endif +#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__) +#define PAL_USE_WAIT TRUE +#endif /*===========================================================================*/ /* ADC driver related settings. */ @@ -222,17 +222,17 @@ * @brief Enables synchronous APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) -# define ADC_USE_WAIT TRUE -# endif +#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) +#define ADC_USE_WAIT TRUE +#endif /** * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -# define ADC_USE_MUTUAL_EXCLUSION TRUE -# endif +#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define ADC_USE_MUTUAL_EXCLUSION TRUE +#endif /*===========================================================================*/ /* CAN driver related settings. */ @@ -241,16 +241,16 @@ /** * @brief Sleep mode related APIs inclusion switch. */ -# if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) -# define CAN_USE_SLEEP_MODE TRUE -# endif +#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) +#define CAN_USE_SLEEP_MODE TRUE +#endif /** * @brief Enforces the driver to use direct callbacks rather than OSAL events. */ -# if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__) -# define CAN_ENFORCE_USE_CALLBACKS FALSE -# endif +#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__) +#define CAN_ENFORCE_USE_CALLBACKS FALSE +#endif /*===========================================================================*/ /* CRY driver related settings. */ @@ -263,16 +263,16 @@ * hardware. * @note Fall-back implementations may not be present for all algorithms. */ -# if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__) -# define HAL_CRY_USE_FALLBACK FALSE -# endif +#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__) +#define HAL_CRY_USE_FALLBACK FALSE +#endif /** * @brief Makes the driver forcibly use the fall-back implementations. */ -# if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__) -# define HAL_CRY_ENFORCE_FALLBACK FALSE -# endif +#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__) +#define HAL_CRY_ENFORCE_FALLBACK FALSE +#endif /*===========================================================================*/ /* DAC driver related settings. */ @@ -282,17 +282,17 @@ * @brief Enables synchronous APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__) -# define DAC_USE_WAIT TRUE -# endif +#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__) +#define DAC_USE_WAIT TRUE +#endif /** * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -# define DAC_USE_MUTUAL_EXCLUSION TRUE -# endif +#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define DAC_USE_MUTUAL_EXCLUSION TRUE +#endif /*===========================================================================*/ /* I2C driver related settings. */ @@ -301,9 +301,9 @@ /** * @brief Enables the mutual exclusion APIs on the I2C bus. */ -# if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -# define I2C_USE_MUTUAL_EXCLUSION TRUE -# endif +#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define I2C_USE_MUTUAL_EXCLUSION TRUE +#endif /*===========================================================================*/ /* MAC driver related settings. */ @@ -312,16 +312,16 @@ /** * @brief Enables the zero-copy API. */ -# if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) -# define MAC_USE_ZERO_COPY FALSE -# endif +#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) +#define MAC_USE_ZERO_COPY FALSE +#endif /** * @brief Enables an event sources for incoming packets. */ -# if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) -# define MAC_USE_EVENTS TRUE -# endif +#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) +#define MAC_USE_EVENTS TRUE +#endif /*===========================================================================*/ /* MMC_SPI driver related settings. */ @@ -335,9 +335,9 @@ * This option is recommended also if the SPI driver does not * use a DMA channel and heavily loads the CPU. */ -# if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) -# define MMC_NICE_WAITING TRUE -# endif +#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) +#define MMC_NICE_WAITING TRUE +#endif /*===========================================================================*/ /* SDC driver related settings. */ @@ -347,18 +347,18 @@ * @brief Number of initialization attempts before rejecting the card. * @note Attempts are performed at 10mS intervals. */ -# if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) -# define SDC_INIT_RETRY 100 -# endif +#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) +#define SDC_INIT_RETRY 100 +#endif /** * @brief Include support for MMC cards. * @note MMC support is not yet implemented so this option must be kept * at @p FALSE. */ -# if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) -# define SDC_MMC_SUPPORT FALSE -# endif +#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) +#define SDC_MMC_SUPPORT FALSE +#endif /** * @brief Delays insertions. @@ -366,23 +366,23 @@ * routines releasing some extra CPU time for the threads with * lower priority, this may slow down the driver a bit however. */ -# if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) -# define SDC_NICE_WAITING TRUE -# endif +#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) +#define SDC_NICE_WAITING TRUE +#endif /** * @brief OCR initialization constant for V20 cards. */ -# if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__) -# define SDC_INIT_OCR_V20 0x50FF8000U -# endif +#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__) +#define SDC_INIT_OCR_V20 0x50FF8000U +#endif /** * @brief OCR initialization constant for non-V20 cards. */ -# if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__) -# define SDC_INIT_OCR 0x80100000U -# endif +#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__) +#define SDC_INIT_OCR 0x80100000U +#endif /*===========================================================================*/ /* SERIAL driver related settings. */ @@ -393,9 +393,9 @@ * @details Configuration parameter, this is the baud rate selected for the * default configuration. */ -# if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) -# define SERIAL_DEFAULT_BITRATE 38400 -# endif +#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) +#define SERIAL_DEFAULT_BITRATE 38400 +#endif /** * @brief Serial buffers size. @@ -404,9 +404,9 @@ * @note The default is 16 bytes for both the transmission and receive * buffers. */ -# if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) -# define SERIAL_BUFFERS_SIZE 16 -# endif +#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_BUFFERS_SIZE 16 +#endif /*===========================================================================*/ /* SERIAL_USB driver related setting. */ @@ -419,17 +419,17 @@ * @note The default is 256 bytes for both the transmission and receive * buffers. */ -# if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) -# define SERIAL_USB_BUFFERS_SIZE 1 -# endif +#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_USB_BUFFERS_SIZE 1 +#endif /** * @brief Serial over USB number of buffers. * @note The default is 2 buffers. */ -# if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__) -# define SERIAL_USB_BUFFERS_NUMBER 2 -# endif +#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__) +#define SERIAL_USB_BUFFERS_NUMBER 2 +#endif /*===========================================================================*/ /* SPI driver related settings. */ @@ -439,33 +439,34 @@ * @brief Enables synchronous APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) -# define SPI_USE_WAIT TRUE -# endif +#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) +#define SPI_USE_WAIT TRUE +#endif /** * @brief Enables circular transfers APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__) -# define SPI_USE_CIRCULAR FALSE -# endif +#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__) +#define SPI_USE_CIRCULAR FALSE +#endif + /** * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -# define SPI_USE_MUTUAL_EXCLUSION TRUE -# endif +#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define SPI_USE_MUTUAL_EXCLUSION TRUE +#endif /** * @brief Handling method for SPI CS line. * @note Disabling this option saves both code and data space. */ -# if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__) -# define SPI_SELECT_MODE SPI_SELECT_MODE_PAD -# endif +#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__) +#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD +#endif /*===========================================================================*/ /* UART driver related settings. */ @@ -475,17 +476,17 @@ * @brief Enables synchronous APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(UART_USE_WAIT) || defined(__DOXYGEN__) -# define UART_USE_WAIT FALSE -# endif +#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__) +#define UART_USE_WAIT FALSE +#endif /** * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -# define UART_USE_MUTUAL_EXCLUSION FALSE -# endif +#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define UART_USE_MUTUAL_EXCLUSION FALSE +#endif /*===========================================================================*/ /* USB driver related settings. */ @@ -495,9 +496,9 @@ * @brief Enables synchronous APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) -# define USB_USE_WAIT TRUE -# endif +#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) +#define USB_USE_WAIT TRUE +#endif /*===========================================================================*/ /* WSPI driver related settings. */ @@ -507,17 +508,17 @@ * @brief Enables synchronous APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__) -# define WSPI_USE_WAIT TRUE -# endif +#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__) +#define WSPI_USE_WAIT TRUE +#endif /** * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs. * @note Disabling this option saves both code and data space. */ -# if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -# define WSPI_USE_MUTUAL_EXCLUSION TRUE -# endif +#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define WSPI_USE_MUTUAL_EXCLUSION TRUE +#endif #endif /* HALCONF_H */ diff --git a/platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h b/platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h new file mode 100644 index 000000000000..3b15883485e5 --- /dev/null +++ b/platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h @@ -0,0 +1,273 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef MCUCONF_H +#define MCUCONF_H + +/* + * STM32F3xx drivers configuration. + * The following settings override the default settings present in + * the various device driver implementation headers. + * Note that the settings for each driver only have effect if the whole + * driver is enabled in halconf.h. + * + * IRQ priorities: + * 15...0 Lowest...Highest. + * + * DMA priorities: + * 0...3 Lowest...Highest. + */ + +#define STM32F3xx_MCUCONF +#define STM32F303_MCUCONF + +/* + * HAL driver system settings. + */ +#define STM32_NO_INIT FALSE +#define STM32_PVD_ENABLE FALSE +#define STM32_PLS STM32_PLS_LEV0 +#define STM32_HSI_ENABLED TRUE +#define STM32_LSI_ENABLED TRUE +#define STM32_HSE_ENABLED TRUE +#define STM32_LSE_ENABLED FALSE +#define STM32_SW STM32_SW_PLL +#define STM32_PLLSRC STM32_PLLSRC_HSE +#define STM32_PREDIV_VALUE 1 +#define STM32_PLLMUL_VALUE 9 +#define STM32_HPRE STM32_HPRE_DIV1 +#define STM32_PPRE1 STM32_PPRE1_DIV2 +#define STM32_PPRE2 STM32_PPRE2_DIV2 +#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK +#define STM32_ADC12PRES STM32_ADC12PRES_DIV1 +#define STM32_ADC34PRES STM32_ADC34PRES_DIV1 +#define STM32_USART1SW STM32_USART1SW_PCLK +#define STM32_USART2SW STM32_USART2SW_PCLK +#define STM32_USART3SW STM32_USART3SW_PCLK +#define STM32_UART4SW STM32_UART4SW_PCLK +#define STM32_UART5SW STM32_UART5SW_PCLK +#define STM32_I2C1SW STM32_I2C1SW_SYSCLK +#define STM32_I2C2SW STM32_I2C2SW_SYSCLK +#define STM32_TIM1SW STM32_TIM1SW_PCLK2 +#define STM32_TIM8SW STM32_TIM8SW_PCLK2 +#define STM32_RTCSEL STM32_RTCSEL_LSI +#define STM32_USB_CLOCK_REQUIRED TRUE +#define STM32_USBPRE STM32_USBPRE_DIV1P5 + +/* + * IRQ system settings. + */ +#define STM32_IRQ_EXTI0_PRIORITY 6 +#define STM32_IRQ_EXTI1_PRIORITY 6 +#define STM32_IRQ_EXTI2_PRIORITY 6 +#define STM32_IRQ_EXTI3_PRIORITY 6 +#define STM32_IRQ_EXTI4_PRIORITY 6 +#define STM32_IRQ_EXTI5_9_PRIORITY 6 +#define STM32_IRQ_EXTI10_15_PRIORITY 6 +#define STM32_IRQ_EXTI16_PRIORITY 6 +#define STM32_IRQ_EXTI17_PRIORITY 15 +#define STM32_IRQ_EXTI18_PRIORITY 6 +#define STM32_IRQ_EXTI19_PRIORITY 15 +#define STM32_IRQ_EXTI20_PRIORITY 15 +#define STM32_IRQ_EXTI21_22_29_PRIORITY 6 +#define STM32_IRQ_EXTI30_32_PRIORITY 6 +#define STM32_IRQ_EXTI33_PRIORITY 6 +#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7 +#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7 +#define STM32_IRQ_TIM1_TRGCO_TIM17_PRIORITY 7 +#define STM32_IRQ_TIM1_CC_PRIORITY 7 + +/* + * ADC driver system settings. + */ +#define STM32_ADC_DUAL_MODE FALSE +#define STM32_ADC_COMPACT_SAMPLES FALSE +#define STM32_ADC_USE_ADC1 FALSE +#define STM32_ADC_USE_ADC2 FALSE +#define STM32_ADC_USE_ADC3 FALSE +#define STM32_ADC_USE_ADC4 FALSE +#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1) +#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 1) +#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) +#define STM32_ADC_ADC4_DMA_STREAM STM32_DMA_STREAM_ID(2, 2) +#define STM32_ADC_ADC1_DMA_PRIORITY 2 +#define STM32_ADC_ADC2_DMA_PRIORITY 2 +#define STM32_ADC_ADC3_DMA_PRIORITY 2 +#define STM32_ADC_ADC4_DMA_PRIORITY 2 +#define STM32_ADC_ADC12_IRQ_PRIORITY 5 +#define STM32_ADC_ADC3_IRQ_PRIORITY 5 +#define STM32_ADC_ADC4_IRQ_PRIORITY 5 +#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5 +#define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 5 +#define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 5 +#define STM32_ADC_ADC4_DMA_IRQ_PRIORITY 5 +#define STM32_ADC_ADC12_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1 +#define STM32_ADC_ADC34_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1 + +/* + * CAN driver system settings. + */ +#define STM32_CAN_USE_CAN1 FALSE +#define STM32_CAN_CAN1_IRQ_PRIORITY 11 + +/* + * DAC driver system settings. + */ +#define STM32_DAC_DUAL_MODE FALSE +#define STM32_DAC_USE_DAC1_CH1 TRUE +#define STM32_DAC_USE_DAC1_CH2 TRUE +#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10 +#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10 +#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2 +#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2 + +/* + * GPT driver system settings. + */ +#define STM32_GPT_USE_TIM1 FALSE +#define STM32_GPT_USE_TIM2 FALSE +#define STM32_GPT_USE_TIM3 FALSE +#define STM32_GPT_USE_TIM4 FALSE +#define STM32_GPT_USE_TIM6 TRUE +#define STM32_GPT_USE_TIM7 TRUE +#define STM32_GPT_USE_TIM8 TRUE +#define STM32_GPT_USE_TIM15 FALSE +#define STM32_GPT_USE_TIM16 FALSE +#define STM32_GPT_USE_TIM17 FALSE +#define STM32_GPT_TIM1_IRQ_PRIORITY 7 +#define STM32_GPT_TIM2_IRQ_PRIORITY 7 +#define STM32_GPT_TIM3_IRQ_PRIORITY 7 +#define STM32_GPT_TIM4_IRQ_PRIORITY 7 +#define STM32_GPT_TIM6_IRQ_PRIORITY 7 +#define STM32_GPT_TIM7_IRQ_PRIORITY 7 +#define STM32_GPT_TIM8_IRQ_PRIORITY 7 + +/* + * I2C driver system settings. + */ +#define STM32_I2C_USE_I2C1 TRUE +#define STM32_I2C_USE_I2C2 FALSE +#define STM32_I2C_BUSY_TIMEOUT 50 +#define STM32_I2C_I2C1_IRQ_PRIORITY 10 +#define STM32_I2C_I2C2_IRQ_PRIORITY 10 +#define STM32_I2C_USE_DMA TRUE +#define STM32_I2C_I2C1_DMA_PRIORITY 1 +#define STM32_I2C_I2C2_DMA_PRIORITY 1 +#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") + +/* + * ICU driver system settings. + */ +#define STM32_ICU_USE_TIM1 FALSE +#define STM32_ICU_USE_TIM2 FALSE +#define STM32_ICU_USE_TIM3 FALSE +#define STM32_ICU_USE_TIM4 FALSE +#define STM32_ICU_USE_TIM8 FALSE +#define STM32_ICU_USE_TIM15 FALSE +#define STM32_ICU_TIM1_IRQ_PRIORITY 7 +#define STM32_ICU_TIM2_IRQ_PRIORITY 7 +#define STM32_ICU_TIM3_IRQ_PRIORITY 7 +#define STM32_ICU_TIM4_IRQ_PRIORITY 7 +#define STM32_ICU_TIM8_IRQ_PRIORITY 7 + +/* + * PWM driver system settings. + */ +#define STM32_PWM_USE_ADVANCED FALSE +#define STM32_PWM_USE_TIM1 FALSE +#define STM32_PWM_USE_TIM2 FALSE +#define STM32_PWM_USE_TIM3 TRUE +#define STM32_PWM_USE_TIM4 TRUE +#define STM32_PWM_USE_TIM8 FALSE +#define STM32_PWM_USE_TIM15 FALSE +#define STM32_PWM_USE_TIM16 FALSE +#define STM32_PWM_USE_TIM17 FALSE +#define STM32_PWM_TIM1_IRQ_PRIORITY 7 +#define STM32_PWM_TIM2_IRQ_PRIORITY 7 +#define STM32_PWM_TIM3_IRQ_PRIORITY 7 +#define STM32_PWM_TIM4_IRQ_PRIORITY 7 +#define STM32_PWM_TIM8_IRQ_PRIORITY 7 + +/* + * RTC driver system settings. + */ +#define STM32_RTC_PRESA_VALUE 32 +#define STM32_RTC_PRESS_VALUE 1024 +#define STM32_RTC_CR_INIT 0 +#define STM32_RTC_TAMPCR_INIT 0 + +/* + * SERIAL driver system settings. + */ +#define STM32_SERIAL_USE_USART1 FALSE +#define STM32_SERIAL_USE_USART2 TRUE +#define STM32_SERIAL_USE_USART3 FALSE +#define STM32_SERIAL_USE_UART4 FALSE +#define STM32_SERIAL_USE_UART5 FALSE +#define STM32_SERIAL_USART1_PRIORITY 12 +#define STM32_SERIAL_USART2_PRIORITY 12 +#define STM32_SERIAL_USART3_PRIORITY 12 +#define STM32_SERIAL_UART4_PRIORITY 12 +#define STM32_SERIAL_UART5_PRIORITY 12 + +/* + * SPI driver system settings. + */ +#define STM32_SPI_USE_SPI1 FALSE +#define STM32_SPI_USE_SPI2 TRUE +#define STM32_SPI_USE_SPI3 FALSE +#define STM32_SPI_SPI1_DMA_PRIORITY 1 +#define STM32_SPI_SPI2_DMA_PRIORITY 1 +#define STM32_SPI_SPI3_DMA_PRIORITY 1 +#define STM32_SPI_SPI1_IRQ_PRIORITY 10 +#define STM32_SPI_SPI2_IRQ_PRIORITY 10 +#define STM32_SPI_SPI3_IRQ_PRIORITY 10 +#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") + +/* + * ST driver system settings. + */ +#define STM32_ST_IRQ_PRIORITY 8 +#define STM32_ST_USE_TIMER 2 + +/* + * UART driver system settings. + */ +#define STM32_UART_USE_USART1 FALSE +#define STM32_UART_USE_USART2 FALSE +#define STM32_UART_USE_USART3 FALSE +#define STM32_UART_USART1_IRQ_PRIORITY 12 +#define STM32_UART_USART2_IRQ_PRIORITY 12 +#define STM32_UART_USART3_IRQ_PRIORITY 12 +#define STM32_UART_USART1_DMA_PRIORITY 0 +#define STM32_UART_USART2_DMA_PRIORITY 0 +#define STM32_UART_USART3_DMA_PRIORITY 0 +#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") + +/* + * USB driver system settings. + */ +#define STM32_USB_USE_USB1 TRUE +#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE +#define STM32_USB_USB1_HP_IRQ_PRIORITY 13 +#define STM32_USB_USB1_LP_IRQ_PRIORITY 14 + +/* + * WDG driver system settings. + */ +#define STM32_WDG_USE_IWDG FALSE + +#endif /* MCUCONF_H */ diff --git a/platforms/chibios/GENERIC_STM32_F303XC/configs/proton_c.mk b/platforms/chibios/GENERIC_STM32_F303XC/configs/proton_c.mk new file mode 100644 index 000000000000..23907c810a3a --- /dev/null +++ b/platforms/chibios/GENERIC_STM32_F303XC/configs/proton_c.mk @@ -0,0 +1,9 @@ +# Proton C MCU settings for converting AVR projects +MCU = STM32F303 + +# These are defaults based on what has been implemented for ARM boards +AUDIO_ENABLE = yes +WS2812_DRIVER = bitbang + +# Force task driven PWM until ARM can provide automatic configuration +BACKLIGHT_DRIVER = software diff --git a/drivers/boards/IC_TEENSY_3_1/board.c b/platforms/chibios/IC_TEENSY_3_1/board/board.c similarity index 100% rename from drivers/boards/IC_TEENSY_3_1/board.c rename to platforms/chibios/IC_TEENSY_3_1/board/board.c diff --git a/drivers/boards/IC_TEENSY_3_1/board.h b/platforms/chibios/IC_TEENSY_3_1/board/board.h similarity index 100% rename from drivers/boards/IC_TEENSY_3_1/board.h rename to platforms/chibios/IC_TEENSY_3_1/board/board.h diff --git a/platforms/chibios/IC_TEENSY_3_1/board/board.mk b/platforms/chibios/IC_TEENSY_3_1/board/board.mk new file mode 100644 index 000000000000..842e33590594 --- /dev/null +++ b/platforms/chibios/IC_TEENSY_3_1/board/board.mk @@ -0,0 +1,9 @@ +# List of all the board related files. +BOARDSRC = $(BOARD_PATH)/board/board.c + +# Required include directories +BOARDINC = $(BOARD_PATH)/board + +# Shared variables +ALLCSRC += $(BOARDSRC) +ALLINC += $(BOARDINC) diff --git a/drivers/boards/STM32_F103_STM32DUINO/board.c b/platforms/chibios/STM32_F103_STM32DUINO/board/board.c similarity index 93% rename from drivers/boards/STM32_F103_STM32DUINO/board.c rename to platforms/chibios/STM32_F103_STM32DUINO/board/board.c index 8c5a87f35f8b..9135f613646f 100644 --- a/drivers/boards/STM32_F103_STM32DUINO/board.c +++ b/platforms/chibios/STM32_F103_STM32DUINO/board/board.c @@ -35,12 +35,15 @@ const PALConfig pal_default_config = }; #endif +__attribute__((weak)) void enter_bootloader_mode_if_requested(void) {} + /* * Early initialization code. * This initialization must be performed just after stack setup and before * any other initialization. */ void __early_init(void) { + enter_bootloader_mode_if_requested(); stm32_clock_init(); } diff --git a/drivers/boards/STM32_F103_STM32DUINO/board.h b/platforms/chibios/STM32_F103_STM32DUINO/board/board.h similarity index 100% rename from drivers/boards/STM32_F103_STM32DUINO/board.h rename to platforms/chibios/STM32_F103_STM32DUINO/board/board.h diff --git a/platforms/chibios/STM32_F103_STM32DUINO/board/board.mk b/platforms/chibios/STM32_F103_STM32DUINO/board/board.mk new file mode 100644 index 000000000000..842e33590594 --- /dev/null +++ b/platforms/chibios/STM32_F103_STM32DUINO/board/board.mk @@ -0,0 +1,9 @@ +# List of all the board related files. +BOARDSRC = $(BOARD_PATH)/board/board.c + +# Required include directories +BOARDINC = $(BOARD_PATH)/board + +# Shared variables +ALLCSRC += $(BOARDSRC) +ALLINC += $(BOARDINC) diff --git a/platforms/chibios/keyboard-config-templates/board.h b/platforms/chibios/keyboard-config-templates/board.h new file mode 100644 index 000000000000..967ec13a1c32 --- /dev/null +++ b/platforms/chibios/keyboard-config-templates/board.h @@ -0,0 +1,20 @@ +/* Copyright 2020 Nick Brassel (tzarc) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#include_next "board.h" + +// #undef STM32_HSE_BYPASS diff --git a/platforms/chibios/keyboard-config-templates/chconf.h b/platforms/chibios/keyboard-config-templates/chconf.h new file mode 100644 index 000000000000..7c2af93f5ea7 --- /dev/null +++ b/platforms/chibios/keyboard-config-templates/chconf.h @@ -0,0 +1,20 @@ +/* Copyright 2020 Nick Brassel (tzarc) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +// #define CH_CFG_OPTIMIZE_SPEED TRUE + +#include_next "chconf.h" diff --git a/platforms/chibios/keyboard-config-templates/halconf.h b/platforms/chibios/keyboard-config-templates/halconf.h new file mode 100644 index 000000000000..ab5f738f97d1 --- /dev/null +++ b/platforms/chibios/keyboard-config-templates/halconf.h @@ -0,0 +1,20 @@ +/* Copyright 2020 Nick Brassel (tzarc) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +// #define HAL_USE_DAC TRUE + +#include_next "halconf.h" diff --git a/platforms/chibios/keyboard-config-templates/mcuconf.h b/platforms/chibios/keyboard-config-templates/mcuconf.h new file mode 100644 index 000000000000..5b42747b952e --- /dev/null +++ b/platforms/chibios/keyboard-config-templates/mcuconf.h @@ -0,0 +1,21 @@ +/* Copyright 2020 Nick Brassel (tzarc) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#include_next "mcuconf.h" + +// #undef STM32_HSE_ENABLED +// #define STM32_HSE_ENABLED FALSE diff --git a/drivers/boards/ld/MKL26Z64.ld b/platforms/chibios/ld/MKL26Z64.ld similarity index 100% rename from drivers/boards/ld/MKL26Z64.ld rename to platforms/chibios/ld/MKL26Z64.ld diff --git a/drivers/boards/ld/STM32F103x8_stm32duino_bootloader.ld b/platforms/chibios/ld/STM32F103x8_stm32duino_bootloader.ld similarity index 100% rename from drivers/boards/ld/STM32F103x8_stm32duino_bootloader.ld rename to platforms/chibios/ld/STM32F103x8_stm32duino_bootloader.ld diff --git a/quantum/stm32/mcuconf.h b/quantum/stm32/mcuconf.h deleted file mode 100644 index 71994a98e098..000000000000 --- a/quantum/stm32/mcuconf.h +++ /dev/null @@ -1,273 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef MCUCONF_H -#define MCUCONF_H - -/* - * STM32F3xx drivers configuration. - * The following settings override the default settings present in - * the various device driver implementation headers. - * Note that the settings for each driver only have effect if the whole - * driver is enabled in halconf.h. - * - * IRQ priorities: - * 15...0 Lowest...Highest. - * - * DMA priorities: - * 0...3 Lowest...Highest. - */ - -#define STM32F3xx_MCUCONF -#define STM32F303_MCUCONF - -/* - * HAL driver system settings. - */ -#define STM32_NO_INIT FALSE -#define STM32_PVD_ENABLE FALSE -#define STM32_PLS STM32_PLS_LEV0 -#define STM32_HSI_ENABLED TRUE -#define STM32_LSI_ENABLED TRUE -#define STM32_HSE_ENABLED TRUE -#define STM32_LSE_ENABLED FALSE -#define STM32_SW STM32_SW_PLL -#define STM32_PLLSRC STM32_PLLSRC_HSE -#define STM32_PREDIV_VALUE 1 -#define STM32_PLLMUL_VALUE 9 -#define STM32_HPRE STM32_HPRE_DIV1 -#define STM32_PPRE1 STM32_PPRE1_DIV2 -#define STM32_PPRE2 STM32_PPRE2_DIV2 -#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK -#define STM32_ADC12PRES STM32_ADC12PRES_DIV1 -#define STM32_ADC34PRES STM32_ADC34PRES_DIV1 -#define STM32_USART1SW STM32_USART1SW_PCLK -#define STM32_USART2SW STM32_USART2SW_PCLK -#define STM32_USART3SW STM32_USART3SW_PCLK -#define STM32_UART4SW STM32_UART4SW_PCLK -#define STM32_UART5SW STM32_UART5SW_PCLK -#define STM32_I2C1SW STM32_I2C1SW_SYSCLK -#define STM32_I2C2SW STM32_I2C2SW_SYSCLK -#define STM32_TIM1SW STM32_TIM1SW_PCLK2 -#define STM32_TIM8SW STM32_TIM8SW_PCLK2 -#define STM32_RTCSEL STM32_RTCSEL_LSI -#define STM32_USB_CLOCK_REQUIRED TRUE -#define STM32_USBPRE STM32_USBPRE_DIV1P5 - -/* - * IRQ system settings. - */ -#define STM32_IRQ_EXTI0_PRIORITY 6 -#define STM32_IRQ_EXTI1_PRIORITY 6 -#define STM32_IRQ_EXTI2_PRIORITY 6 -#define STM32_IRQ_EXTI3_PRIORITY 6 -#define STM32_IRQ_EXTI4_PRIORITY 6 -#define STM32_IRQ_EXTI5_9_PRIORITY 6 -#define STM32_IRQ_EXTI10_15_PRIORITY 6 -#define STM32_IRQ_EXTI16_PRIORITY 6 -#define STM32_IRQ_EXTI17_PRIORITY 15 -#define STM32_IRQ_EXTI18_PRIORITY 6 -#define STM32_IRQ_EXTI19_PRIORITY 15 -#define STM32_IRQ_EXTI20_PRIORITY 15 -#define STM32_IRQ_EXTI21_22_29_PRIORITY 6 -#define STM32_IRQ_EXTI30_32_PRIORITY 6 -#define STM32_IRQ_EXTI33_PRIORITY 6 -#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7 -#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7 -#define STM32_IRQ_TIM1_TRGCO_TIM17_PRIORITY 7 -#define STM32_IRQ_TIM1_CC_PRIORITY 7 - -/* - * ADC driver system settings. - */ -#define STM32_ADC_DUAL_MODE FALSE -#define STM32_ADC_COMPACT_SAMPLES FALSE -#define STM32_ADC_USE_ADC1 FALSE -#define STM32_ADC_USE_ADC2 FALSE -#define STM32_ADC_USE_ADC3 FALSE -#define STM32_ADC_USE_ADC4 FALSE -#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1) -#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 1) -#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) -#define STM32_ADC_ADC4_DMA_STREAM STM32_DMA_STREAM_ID(2, 2) -#define STM32_ADC_ADC1_DMA_PRIORITY 2 -#define STM32_ADC_ADC2_DMA_PRIORITY 2 -#define STM32_ADC_ADC3_DMA_PRIORITY 2 -#define STM32_ADC_ADC4_DMA_PRIORITY 2 -#define STM32_ADC_ADC12_IRQ_PRIORITY 5 -#define STM32_ADC_ADC3_IRQ_PRIORITY 5 -#define STM32_ADC_ADC4_IRQ_PRIORITY 5 -#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5 -#define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 5 -#define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 5 -#define STM32_ADC_ADC4_DMA_IRQ_PRIORITY 5 -#define STM32_ADC_ADC12_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1 -#define STM32_ADC_ADC34_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1 - -/* - * CAN driver system settings. - */ -#define STM32_CAN_USE_CAN1 FALSE -#define STM32_CAN_CAN1_IRQ_PRIORITY 11 - -/* - * DAC driver system settings. - */ -#define STM32_DAC_DUAL_MODE FALSE -#define STM32_DAC_USE_DAC1_CH1 TRUE -#define STM32_DAC_USE_DAC1_CH2 TRUE -#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10 -#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10 -#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2 -#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2 - -/* - * GPT driver system settings. - */ -#define STM32_GPT_USE_TIM1 FALSE -#define STM32_GPT_USE_TIM2 FALSE -#define STM32_GPT_USE_TIM3 FALSE -#define STM32_GPT_USE_TIM4 FALSE -#define STM32_GPT_USE_TIM6 TRUE -#define STM32_GPT_USE_TIM7 TRUE -#define STM32_GPT_USE_TIM8 TRUE -#define STM32_GPT_USE_TIM15 FALSE -#define STM32_GPT_USE_TIM16 FALSE -#define STM32_GPT_USE_TIM17 FALSE -#define STM32_GPT_TIM1_IRQ_PRIORITY 7 -#define STM32_GPT_TIM2_IRQ_PRIORITY 7 -#define STM32_GPT_TIM3_IRQ_PRIORITY 7 -#define STM32_GPT_TIM4_IRQ_PRIORITY 7 -#define STM32_GPT_TIM6_IRQ_PRIORITY 7 -#define STM32_GPT_TIM7_IRQ_PRIORITY 7 -#define STM32_GPT_TIM8_IRQ_PRIORITY 7 - -/* - * I2C driver system settings. - */ -#define STM32_I2C_USE_I2C1 TRUE -#define STM32_I2C_USE_I2C2 FALSE -#define STM32_I2C_BUSY_TIMEOUT 50 -#define STM32_I2C_I2C1_IRQ_PRIORITY 10 -#define STM32_I2C_I2C2_IRQ_PRIORITY 10 -#define STM32_I2C_USE_DMA TRUE -#define STM32_I2C_I2C1_DMA_PRIORITY 1 -#define STM32_I2C_I2C2_DMA_PRIORITY 1 -#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") - -/* - * ICU driver system settings. - */ -#define STM32_ICU_USE_TIM1 FALSE -#define STM32_ICU_USE_TIM2 FALSE -#define STM32_ICU_USE_TIM3 FALSE -#define STM32_ICU_USE_TIM4 FALSE -#define STM32_ICU_USE_TIM8 FALSE -#define STM32_ICU_USE_TIM15 FALSE -#define STM32_ICU_TIM1_IRQ_PRIORITY 7 -#define STM32_ICU_TIM2_IRQ_PRIORITY 7 -#define STM32_ICU_TIM3_IRQ_PRIORITY 7 -#define STM32_ICU_TIM4_IRQ_PRIORITY 7 -#define STM32_ICU_TIM8_IRQ_PRIORITY 7 - -/* - * PWM driver system settings. - */ -#define STM32_PWM_USE_ADVANCED FALSE -#define STM32_PWM_USE_TIM1 FALSE -#define STM32_PWM_USE_TIM2 FALSE -#define STM32_PWM_USE_TIM3 TRUE -#define STM32_PWM_USE_TIM4 TRUE -#define STM32_PWM_USE_TIM8 FALSE -#define STM32_PWM_USE_TIM15 FALSE -#define STM32_PWM_USE_TIM16 FALSE -#define STM32_PWM_USE_TIM17 FALSE -#define STM32_PWM_TIM1_IRQ_PRIORITY 7 -#define STM32_PWM_TIM2_IRQ_PRIORITY 7 -#define STM32_PWM_TIM3_IRQ_PRIORITY 7 -#define STM32_PWM_TIM4_IRQ_PRIORITY 7 -#define STM32_PWM_TIM8_IRQ_PRIORITY 7 - -/* - * RTC driver system settings. - */ -#define STM32_RTC_PRESA_VALUE 32 -#define STM32_RTC_PRESS_VALUE 1024 -#define STM32_RTC_CR_INIT 0 -#define STM32_RTC_TAMPCR_INIT 0 - -/* - * SERIAL driver system settings. - */ -#define STM32_SERIAL_USE_USART1 FALSE -#define STM32_SERIAL_USE_USART2 TRUE -#define STM32_SERIAL_USE_USART3 FALSE -#define STM32_SERIAL_USE_UART4 FALSE -#define STM32_SERIAL_USE_UART5 FALSE -#define STM32_SERIAL_USART1_PRIORITY 12 -#define STM32_SERIAL_USART2_PRIORITY 12 -#define STM32_SERIAL_USART3_PRIORITY 12 -#define STM32_SERIAL_UART4_PRIORITY 12 -#define STM32_SERIAL_UART5_PRIORITY 12 - -/* - * SPI driver system settings. - */ -#define STM32_SPI_USE_SPI1 FALSE -#define STM32_SPI_USE_SPI2 TRUE -#define STM32_SPI_USE_SPI3 FALSE -#define STM32_SPI_SPI1_DMA_PRIORITY 1 -#define STM32_SPI_SPI2_DMA_PRIORITY 1 -#define STM32_SPI_SPI3_DMA_PRIORITY 1 -#define STM32_SPI_SPI1_IRQ_PRIORITY 10 -#define STM32_SPI_SPI2_IRQ_PRIORITY 10 -#define STM32_SPI_SPI3_IRQ_PRIORITY 10 -#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") - -/* - * ST driver system settings. - */ -#define STM32_ST_IRQ_PRIORITY 8 -#define STM32_ST_USE_TIMER 2 - -/* - * UART driver system settings. - */ -#define STM32_UART_USE_USART1 FALSE -#define STM32_UART_USE_USART2 FALSE -#define STM32_UART_USE_USART3 FALSE -#define STM32_UART_USART1_IRQ_PRIORITY 12 -#define STM32_UART_USART2_IRQ_PRIORITY 12 -#define STM32_UART_USART3_IRQ_PRIORITY 12 -#define STM32_UART_USART1_DMA_PRIORITY 0 -#define STM32_UART_USART2_DMA_PRIORITY 0 -#define STM32_UART_USART3_DMA_PRIORITY 0 -#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") - -/* - * USB driver system settings. - */ -#define STM32_USB_USE_USB1 TRUE -#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE -#define STM32_USB_USB1_HP_IRQ_PRIORITY 13 -#define STM32_USB_USB1_LP_IRQ_PRIORITY 14 - -/* - * WDG driver system settings. - */ -#define STM32_WDG_USE_IWDG FALSE - -#endif /* MCUCONF_H */ diff --git a/quantum/stm32/proton_c.mk b/quantum/stm32/proton_c.mk deleted file mode 100644 index b25b5550458e..000000000000 --- a/quantum/stm32/proton_c.mk +++ /dev/null @@ -1,47 +0,0 @@ -# Proton C MCU settings for converting AVR projects - -# These are defaults based on what has been implemented for ARM boards -AUDIO_ENABLE = yes -WS2812_DRIVER = bitbang - -# Force task driven PWM until ARM can provide automatic configuration -BACKLIGHT_DRIVER = software - -# The rest of these settings shouldn't change - -## chip/board settings -# - the next two should match the directories in -# /os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) -MCU_FAMILY = STM32 -MCU_SERIES = STM32F3xx - -# Linker script to use -# - it should exist either in /os/common/ports/ARMCMx/compilers/GCC/ld/ -# or /ld/ -MCU_LDSCRIPT = STM32F303xC - -# Startup code to use -# - it should exist in /os/common/startup/ARMCMx/compilers/GCC/mk/ -MCU_STARTUP = stm32f3xx - -# Board: it should exist either in /os/hal/boards/ -# or /boards -BOARD = GENERIC_STM32_F303XC - -# Cortex version -MCU = cortex-m4 - -# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7 -ARMV = 7 - -USE_FPU = yes - -# Vector table for application -# 0x00000000-0x00001000 area is occupied by bootlaoder.*/ -# The CORTEX_VTOR... is needed only for MCHCK/Infinity KB -# OPT_DEFS = -DCORTEX_VTOR_INIT=0x08005000 -OPT_DEFS = - -# Options to pass to dfu-util when flashing -DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave -DFU_SUFFIX_ARGS = -p df11 -v 0483 diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk index 09aaddeef052..4e8abc9be6c4 100644 --- a/tmk_core/chibios.mk +++ b/tmk_core/chibios.mk @@ -50,11 +50,42 @@ PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLAT endif include $(PLATFORM_MK) +BOARD_MK := + +ifneq ("$(wildcard $(KEYBOARD_PATH_5)/boards/$(BOARD)/board.mk)","") + BOARD_PATH = $(KEYBOARD_PATH_5) + BOARD_MK += $(KEYBOARD_PATH_5)/boards/$(BOARD)/board.mk +else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/boards/$(BOARD)/board.mk)","") + BOARD_PATH = $(KEYBOARD_PATH_4) + BOARD_MK += $(KEYBOARD_PATH_4)/boards/$(BOARD)/board.mk +else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/boards/$(BOARD)/board.mk)","") + BOARD_PATH = $(KEYBOARD_PATH_3) + BOARD_MK += $(KEYBOARD_PATH_3)/boards/$(BOARD)/board.mk +else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/boards/$(BOARD)/board.mk)","") + BOARD_PATH = $(KEYBOARD_PATH_2) + BOARD_MK += $(KEYBOARD_PATH_2)/boards/$(BOARD)/board.mk +else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/boards/$(BOARD)/board.mk)","") + BOARD_PATH = $(KEYBOARD_PATH_1) + BOARD_MK += $(KEYBOARD_PATH_1)/boards/$(BOARD)/board.mk +else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/board/board.mk)","") + BOARD_PATH = $(TOP_DIR)/platforms/chibios/$(BOARD) + BOARD_MK += $(TOP_DIR)/platforms/chibios/$(BOARD)/board/board.mk + KEYBOARD_PATHS += $(BOARD_PATH)/configs +endif + +ifeq ("$(wildcard $(BOARD_MK))","") + BOARD_MK = $(CHIBIOS)/os/hal/boards/$(BOARD)/board.mk + ifeq ("$(wildcard $(BOARD_MK))","") + BOARD_MK = $(CHIBIOS_CONTRIB)/os/hal/boards/$(BOARD)/board.mk + endif +endif + # Bootloader address ifdef STM32_BOOTLOADER_ADDRESS OPT_DEFS += -DSTM32_BOOTLOADER_ADDRESS=$(STM32_BOOTLOADER_ADDRESS) endif +# Work out if we need to set up the include for the bootloader definitions ifneq ("$(wildcard $(KEYBOARD_PATH_5)/bootloader_defs.h)","") OPT_DEFS += -include $(KEYBOARD_PATH_5)/bootloader_defs.h else ifneq ("$(wildcard $(KEYBOARD_PATH_5)/boards/$(BOARD)/bootloader_defs.h)","") @@ -75,38 +106,52 @@ else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/bootloader_defs.h)","") OPT_DEFS += -include $(KEYBOARD_PATH_1)/bootloader_defs.h else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/boards/$(BOARD)/bootloader_defs.h)","") OPT_DEFS += -include $(KEYBOARD_PATH_1)/boards/$(BOARD)/bootloader_defs.h -else ifneq ("$(wildcard $(TOP_DIR)/drivers/boards/$(BOARD)/bootloader_defs.h)","") - OPT_DEFS += -include $(TOP_DIR)/drivers/boards/$(BOARD)/bootloader_defs.h +else ifneq ("$(wildcard $(BOARD_PATH)/configs/bootloader_defs.h)","") + OPT_DEFS += -include $(BOARD_PATH)/configs/bootloader_defs.h endif -BOARD_MK := +# Work out the config file directories +ifneq ("$(wildcard $(KEYBOARD_PATH_5)/chconf.h)","") + CHCONFDIR = $(KEYBOARD_PATH_5) +else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/chconf.h)","") + CHCONFDIR = $(KEYBOARD_PATH_4) +else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/chconf.h)","") + CHCONFDIR = $(KEYBOARD_PATH_3) +else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/chconf.h)","") + CHCONFDIR = $(KEYBOARD_PATH_2) +else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/chconf.h)","") + CHCONFDIR = $(KEYBOARD_PATH_1) +else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/configs/chconf.h)","") + CHCONFDIR = $(TOP_DIR)/platforms/chibios/$(BOARD)/configs +endif -ifneq ("$(wildcard $(KEYBOARD_PATH_5)/boards/$(BOARD)/board.mk)","") - BOARD_PATH = $(KEYBOARD_PATH_5) - BOARD_MK += $(KEYBOARD_PATH_5)/boards/$(BOARD)/board.mk -else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/boards/$(BOARD)/board.mk)","") - BOARD_PATH = $(KEYBOARD_PATH_4) - BOARD_MK += $(KEYBOARD_PATH_4)/boards/$(BOARD)/board.mk -else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/boards/$(BOARD)/board.mk)","") - BOARD_PATH = $(KEYBOARD_PATH_3) - BOARD_MK += $(KEYBOARD_PATH_3)/boards/$(BOARD)/board.mk -else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/boards/$(BOARD)/board.mk)","") - BOARD_PATH = $(KEYBOARD_PATH_2) - BOARD_MK += $(KEYBOARD_PATH_2)/boards/$(BOARD)/board.mk -else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/boards/$(BOARD)/board.mk)","") - BOARD_PATH = $(KEYBOARD_PATH_1) - BOARD_MK += $(KEYBOARD_PATH_1)/boards/$(BOARD)/board.mk -else ifneq ("$(wildcard $(TOP_DIR)/drivers/boards/$(BOARD)/board.mk)","") - BOARD_PATH = $(TOP_DIR)/drivers - BOARD_MK += $(TOP_DIR)/drivers/boards/$(BOARD)/board.mk +ifneq ("$(wildcard $(KEYBOARD_PATH_5)/halconf.h)","") + HALCONFDIR = $(KEYBOARD_PATH_5) +else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/halconf.h)","") + HALCONFDIR = $(KEYBOARD_PATH_4) +else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/halconf.h)","") + HALCONFDIR = $(KEYBOARD_PATH_3) +else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/halconf.h)","") + HALCONFDIR = $(KEYBOARD_PATH_2) +else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/halconf.h)","") + HALCONFDIR = $(KEYBOARD_PATH_1) +else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/configs/halconf.h)","") + HALCONFDIR = $(TOP_DIR)/platforms/chibios/$(BOARD)/configs endif -ifeq ("$(wildcard $(BOARD_MK))","") - BOARD_MK = $(CHIBIOS)/os/hal/boards/$(BOARD)/board.mk - ifeq ("$(wildcard $(BOARD_MK))","") - BOARD_MK = $(CHIBIOS_CONTRIB)/os/hal/boards/$(BOARD)/board.mk - endif +# HAL-OSAL files (optional). +include $(CHIBIOS)/os/hal/hal.mk + +ifeq ("$(PLATFORM_NAME)","") + PLATFORM_NAME = platform +endif + +PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk +ifeq ("$(wildcard $(PLATFORM_MK))","") +PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk endif +include $(PLATFORM_MK) + include $(BOARD_MK) -include $(CHIBIOS)/os/hal/osal/rt/osal.mk # ChibiOS <= 19.x @@ -138,8 +183,8 @@ else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/ld/$(MCU_LDSCRIPT).ld)","") LDSCRIPT = $(KEYBOARD_PATH_2)/ld/$(MCU_LDSCRIPT).ld else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld)","") LDSCRIPT = $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld -else ifneq ("$(wildcard $(TOP_DIR)/drivers/boards/ld/$(MCU_LDSCRIPT).ld)","") - LDSCRIPT = $(TOP_DIR)/drivers/boards/ld/$(MCU_LDSCRIPT).ld +else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/ld/$(MCU_LDSCRIPT).ld)","") + LDSCRIPT = $(TOP_DIR)/platforms/chibios/ld/$(MCU_LDSCRIPT).ld else ifneq ("$(wildcard $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld)","") LDSCRIPT = $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld USE_CHIBIOS_CONTRIB = yes @@ -163,6 +208,7 @@ QUANTUM_LIB_SRC += $(STARTUPASM) $(PORTASM) $(OSALASM) CHIBISRC := $(patsubst $(TOP_DIR)/%,%,$(CHIBISRC)) EXTRAINCDIRS += $(CHIBIOS)/os/license $(CHIBIOS)/os/oslib/include \ + $(TOP_DIR)/platforms/chibios/$(BOARD)/configs \ $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \ $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \ $(STREAMSINC) $(CHIBIOS)/os/various $(COMMON_VPATH) @@ -182,6 +228,8 @@ else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/halconf_community.h)","") USE_CHIBIOS_CONTRIB = yes else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/halconf_community.h)","") USE_CHIBIOS_CONTRIB = yes +else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/configs/halconf_community.h)","") + USE_CHIBIOS_CONTRIB = yes endif ifeq ($(strip $(USE_CHIBIOS_CONTRIB)),yes) @@ -194,6 +242,15 @@ endif # Project, sources and paths ############################################################################## +############################################################################## +# Injected configs +# +ifneq ("$(wildcard $(BOARD_PATH)/configs/config.h)","") + CONFIG_H += $(BOARD_PATH)/configs/config.h +endif +ifneq ("$(wildcard $(BOARD_PATH)/configs/post_config.h)","") + POST_CONFIG_H += $(BOARD_PATH)/configs/post_config.h +endif ############################################################################## # Compiler settings diff --git a/util/chibios-upgrader.sh b/util/chibios-upgrader.sh index 2174da3cf133..ebc12abe7d52 100755 --- a/util/chibios-upgrader.sh +++ b/util/chibios-upgrader.sh @@ -38,7 +38,11 @@ find_chibi_files() { local search_path="$1" shift local conditions=( "$@" ) - find -L "$search_path" -not -path '*/lib/chibios*' -and -not -path '*/lib/ugfx*' -and -not -path '*/util/*' -and \( "${conditions[@]}" \) | sort + for file in $(find -L "$search_path" -not -path '*/lib/chibios*' -and -not -path '*/lib/ugfx*' -and -not -path '*/util/*' -and \( "${conditions[@]}" \) | sort) ; do + if [ -z "$(grep 'include_next' "$file")" ] ; then + echo $file + fi + done } revert_chibi_files() { diff --git a/util/travis_compiled_push.sh b/util/travis_compiled_push.sh index 68f6d5c1149f..195a87208b69 100755 --- a/util/travis_compiled_push.sh +++ b/util/travis_compiled_push.sh @@ -13,7 +13,7 @@ if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]] ; the # fix formatting git checkout master git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | xargs -0 dos2unix -git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} '*.c' '*.h' '*.cpp' | grep -z -e '^drivers' -e '^quantum' -e '^tests' -e '^tmk_core' | grep -zv -e 'quantum/template' -e 'tmk_core/protocol/usb_hid' | xargs -0 clang-format-7 -i +git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} '*.c' '*.h' '*.cpp' | grep -z -e '^drivers' -e '^quantum' -e '^tests' -e '^tmk_core' | grep -zv -e 'quantum/template' -e 'tmk_core/protocol/usb_hid' -e 'platforms/chibios' | xargs -0 clang-format-7 -i git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | xargs -0 git add git commit -m "format code according to conventions [skip ci]" && git push git@github.com:qmk/qmk_firmware.git master From 1aa2a0d23fac0f78dfcc71739108a4441ab584f7 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 7 Jun 2020 15:00:21 +1000 Subject: [PATCH 04/54] Various tidyups for USB descriptor code (#9005) --- tmk_core/protocol/chibios/usb_main.c | 8 +- tmk_core/protocol/lufa/lufa.c | 120 ++++++++++++++------------- tmk_core/protocol/lufa/lufa.h | 4 - tmk_core/protocol/usb_descriptor.c | 10 +-- tmk_core/protocol/usb_descriptor.h | 5 -- tmk_core/protocol/vusb/vusb.c | 24 +++--- 6 files changed, 80 insertions(+), 91 deletions(-) diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 65bd291bec59..9d68419f42e6 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -62,7 +62,7 @@ extern keymap_config_t keymap_config; uint8_t keyboard_idle __attribute__((aligned(2))) = 0; uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; -uint8_t keyboard_led_stats = 0; +uint8_t keyboard_led_state = 0; volatile uint16_t keyboard_idle_count = 0; static virtual_timer_t keyboard_idle_timer; static void keyboard_idle_timer_cb(void *arg); @@ -386,10 +386,10 @@ static void set_led_transfer_cb(USBDriver *usbp) { if (usbp->setup[6] == 2) { /* LSB(wLength) */ uint8_t report_id = set_report_buf[0]; if ((report_id == REPORT_ID_KEYBOARD) || (report_id == REPORT_ID_NKRO)) { - keyboard_led_stats = set_report_buf[1]; + keyboard_led_state = set_report_buf[1]; } } else { - keyboard_led_stats = set_report_buf[0]; + keyboard_led_state = set_report_buf[0]; } } @@ -610,7 +610,7 @@ static void keyboard_idle_timer_cb(void *arg) { } /* LED status */ -uint8_t keyboard_leds(void) { return keyboard_led_stats; } +uint8_t keyboard_leds(void) { return keyboard_led_state; } /* prepare and start sending a report IN * not callable from ISR or locked state */ diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 374add20f977..19f417770fae 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -88,7 +88,7 @@ extern keymap_config_t keymap_config; uint8_t keyboard_idle = 0; /* 0: Boot Protocol, 1: Report Protocol(default) */ uint8_t keyboard_protocol = 1; -static uint8_t keyboard_led_stats = 0; +static uint8_t keyboard_led_state = 0; static report_keyboard_t keyboard_report_sent; @@ -103,30 +103,30 @@ host_driver_t lufa_driver = { }; #ifdef VIRTSER_ENABLE +// clang-format off + USB_ClassInfo_CDC_Device_t cdc_device = { - .Config = - { - .ControlInterfaceNumber = CCI_INTERFACE, - .DataINEndpoint = - { - .Address = CDC_IN_EPADDR, - .Size = CDC_EPSIZE, - .Banks = 1, - }, - .DataOUTEndpoint = - { - .Address = CDC_OUT_EPADDR, - .Size = CDC_EPSIZE, - .Banks = 1, - }, - .NotificationEndpoint = - { - .Address = CDC_NOTIFICATION_EPADDR, - .Size = CDC_NOTIFICATION_EPSIZE, - .Banks = 1, - }, + .Config = { + .ControlInterfaceNumber = CCI_INTERFACE, + .DataINEndpoint = { + .Address = (CDC_IN_EPNUM | ENDPOINT_DIR_IN), + .Size = CDC_EPSIZE, + .Banks = 1 + }, + .DataOUTEndpoint = { + .Address = (CDC_OUT_EPNUM | ENDPOINT_DIR_OUT), + .Size = CDC_EPSIZE, + .Banks = 1 }, + .NotificationEndpoint = { + .Address = (CDC_NOTIFICATION_EPNUM | ENDPOINT_DIR_IN), + .Size = CDC_NOTIFICATION_EPSIZE, + .Banks = 1 + } + } }; + +// clang-format on #endif #ifdef RAW_ENABLE @@ -254,7 +254,7 @@ static void Console_Task(void) { // fill empty bank while (Endpoint_IsReadWriteAllowed()) Endpoint_Write_8(0); - // flash senchar packet + // flush sendchar packet if (Endpoint_IsINReady()) { Endpoint_ClearIN(); } @@ -370,45 +370,46 @@ void EVENT_USB_Device_StartOfFrame(void) { void EVENT_USB_Device_ConfigurationChanged(void) { bool ConfigSuccess = true; - /* Setup Keyboard HID Report Endpoints */ #ifndef KEYBOARD_SHARED_EP - ConfigSuccess &= ENDPOINT_CONFIG(KEYBOARD_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, KEYBOARD_EPSIZE, ENDPOINT_BANK_SINGLE); + /* Setup keyboard report endpoint */ + ConfigSuccess &= Endpoint_ConfigureEndpoint((KEYBOARD_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, KEYBOARD_EPSIZE, 1); #endif #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) - /* Setup Mouse HID Report Endpoint */ - ConfigSuccess &= ENDPOINT_CONFIG(MOUSE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, MOUSE_EPSIZE, ENDPOINT_BANK_SINGLE); + /* Setup mouse report endpoint */ + ConfigSuccess &= Endpoint_ConfigureEndpoint((MOUSE_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, MOUSE_EPSIZE, 1); #endif #ifdef SHARED_EP_ENABLE - /* Setup Shared HID Report Endpoint */ - ConfigSuccess &= ENDPOINT_CONFIG(SHARED_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, SHARED_EPSIZE, ENDPOINT_BANK_SINGLE); + /* Setup shared report endpoint */ + ConfigSuccess &= Endpoint_ConfigureEndpoint((SHARED_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, SHARED_EPSIZE, 1); #endif #ifdef RAW_ENABLE - /* Setup Raw HID Report Endpoints */ - ConfigSuccess &= ENDPOINT_CONFIG(RAW_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, RAW_EPSIZE, ENDPOINT_BANK_SINGLE); - ConfigSuccess &= ENDPOINT_CONFIG(RAW_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, RAW_EPSIZE, ENDPOINT_BANK_SINGLE); + /* Setup raw HID endpoints */ + ConfigSuccess &= Endpoint_ConfigureEndpoint((RAW_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, RAW_EPSIZE, 1); + ConfigSuccess &= Endpoint_ConfigureEndpoint((RAW_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_INTERRUPT, RAW_EPSIZE, 1); #endif #ifdef CONSOLE_ENABLE - /* Setup Console HID Report Endpoints */ - ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); + /* Setup console endpoint */ + ConfigSuccess &= Endpoint_ConfigureEndpoint((CONSOLE_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, CONSOLE_EPSIZE, 1); # if 0 - ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, - CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); + ConfigSuccess &= Endpoint_ConfigureEndpoint((CONSOLE_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_INTERRUPT, CONSOLE_EPSIZE, 1); # endif #endif #ifdef MIDI_ENABLE - ConfigSuccess &= Endpoint_ConfigureEndpoint(MIDI_STREAM_IN_EPADDR, EP_TYPE_BULK, MIDI_STREAM_EPSIZE, ENDPOINT_BANK_SINGLE); - ConfigSuccess &= Endpoint_ConfigureEndpoint(MIDI_STREAM_OUT_EPADDR, EP_TYPE_BULK, MIDI_STREAM_EPSIZE, ENDPOINT_BANK_SINGLE); + /* Setup MIDI stream endpoints */ + ConfigSuccess &= Endpoint_ConfigureEndpoint((MIDI_STREAM_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, MIDI_STREAM_EPSIZE, 1); + ConfigSuccess &= Endpoint_ConfigureEndpoint((MIDI_STREAM_OUT_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, MIDI_STREAM_EPSIZE, 1); #endif #ifdef VIRTSER_ENABLE - ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPADDR, EP_TYPE_INTERRUPT, CDC_NOTIFICATION_EPSIZE, ENDPOINT_BANK_SINGLE); - ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_OUT_EPADDR, EP_TYPE_BULK, CDC_EPSIZE, ENDPOINT_BANK_SINGLE); - ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_IN_EPADDR, EP_TYPE_BULK, CDC_EPSIZE, ENDPOINT_BANK_SINGLE); + /* Setup virtual serial endpoints */ + ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_NOTIFICATION_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, CDC_NOTIFICATION_EPSIZE, 1); + ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_BULK, CDC_EPSIZE, 1); + ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, CDC_EPSIZE, 1); #endif } @@ -472,10 +473,10 @@ void EVENT_USB_Device_ControlRequest(void) { uint8_t report_id = Endpoint_Read_8(); if (report_id == REPORT_ID_KEYBOARD || report_id == REPORT_ID_NKRO) { - keyboard_led_stats = Endpoint_Read_8(); + keyboard_led_state = Endpoint_Read_8(); } } else { - keyboard_led_stats = Endpoint_Read_8(); + keyboard_led_state = Endpoint_Read_8(); } Endpoint_ClearOUT(); @@ -545,7 +546,7 @@ void EVENT_USB_Device_ControlRequest(void) { * * FIXME: Needs doc */ -static uint8_t keyboard_leds(void) { return keyboard_led_stats; } +static uint8_t keyboard_leds(void) { return keyboard_led_state; } /** \brief Send Keyboard * @@ -808,25 +809,26 @@ int8_t sendchar(uint8_t c) { ******************************************************************************/ #ifdef MIDI_ENABLE +// clang-format off + USB_ClassInfo_MIDI_Device_t USB_MIDI_Interface = { - .Config = - { - .StreamingInterfaceNumber = AS_INTERFACE, - .DataINEndpoint = - { - .Address = MIDI_STREAM_IN_EPADDR, - .Size = MIDI_STREAM_EPSIZE, - .Banks = 1, - }, - .DataOUTEndpoint = - { - .Address = MIDI_STREAM_OUT_EPADDR, - .Size = MIDI_STREAM_EPSIZE, - .Banks = 1, - }, + .Config = { + .StreamingInterfaceNumber = AS_INTERFACE, + .DataINEndpoint = { + .Address = (MIDI_STREAM_IN_EPNUM | ENDPOINT_DIR_IN), + .Size = MIDI_STREAM_EPSIZE, + .Banks = 1 }, + .DataOUTEndpoint = { + .Address = (MIDI_STREAM_OUT_EPNUM | ENDPOINT_DIR_OUT), + .Size = MIDI_STREAM_EPSIZE, + .Banks = 1 + } + } }; +// clang-format on + void send_midi_packet(MIDI_EventPacket_t *event) { MIDI_Device_SendEventPacket(&USB_MIDI_Interface, event); } bool recv_midi_packet(MIDI_EventPacket_t *const event) { return MIDI_Device_ReceiveEventPacket(&USB_MIDI_Interface, event); } diff --git a/tmk_core/protocol/lufa/lufa.h b/tmk_core/protocol/lufa/lufa.h index 82a5f8e05fcb..71fd7aad854b 100644 --- a/tmk_core/protocol/lufa/lufa.h +++ b/tmk_core/protocol/lufa/lufa.h @@ -69,8 +69,4 @@ extern host_driver_t lufa_driver; # define MIDI_SYSEX_BUFFER (API_SYSEX_MAX_SIZE + API_SYSEX_MAX_SIZE / 7 + (API_SYSEX_MAX_SIZE % 7 ? 1 : 0)) #endif -#define ENDPOINT_BANK_SINGLE 1 -#define ENDPOINT_BANK_DOUBLE 2 -#define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint((epdir) | (epnum), eptype, epsize, epbank) - #endif diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index 8c71dd1dda77..bcca24586766 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -673,7 +673,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint }, - .EndpointAddress = MIDI_STREAM_OUT_EPADDR, + .EndpointAddress = (ENDPOINT_DIR_OUT | MIDI_STREAM_OUT_EPNUM), .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = MIDI_STREAM_EPSIZE, .PollingIntervalMS = 0x05 @@ -696,7 +696,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint }, - .EndpointAddress = MIDI_STREAM_IN_EPADDR, + .EndpointAddress = (ENDPOINT_DIR_IN | MIDI_STREAM_IN_EPNUM), .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = MIDI_STREAM_EPSIZE, .PollingIntervalMS = 0x05 @@ -774,7 +774,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint }, - .EndpointAddress = CDC_NOTIFICATION_EPADDR, + .EndpointAddress = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM), .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = CDC_NOTIFICATION_EPSIZE, .PollingIntervalMS = 0xFF @@ -797,7 +797,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint }, - .EndpointAddress = CDC_OUT_EPADDR, + .EndpointAddress = (ENDPOINT_DIR_OUT | CDC_OUT_EPNUM), .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = CDC_EPSIZE, .PollingIntervalMS = 0x05 @@ -807,7 +807,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint }, - .EndpointAddress = CDC_IN_EPADDR, + .EndpointAddress = (ENDPOINT_DIR_IN | CDC_IN_EPNUM), .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = CDC_EPSIZE, .PollingIntervalMS = 0x05 diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h index b2423fa7e662..34a85978a6b3 100644 --- a/tmk_core/protocol/usb_descriptor.h +++ b/tmk_core/protocol/usb_descriptor.h @@ -212,17 +212,12 @@ enum usb_endpoints { #ifdef MIDI_ENABLE MIDI_STREAM_IN_EPNUM = NEXT_EPNUM, MIDI_STREAM_OUT_EPNUM = NEXT_EPNUM, -# define MIDI_STREAM_IN_EPADDR (ENDPOINT_DIR_IN | MIDI_STREAM_IN_EPNUM) -# define MIDI_STREAM_OUT_EPADDR (ENDPOINT_DIR_OUT | MIDI_STREAM_OUT_EPNUM) #endif #ifdef VIRTSER_ENABLE CDC_NOTIFICATION_EPNUM = NEXT_EPNUM, CDC_IN_EPNUM = NEXT_EPNUM, CDC_OUT_EPNUM = NEXT_EPNUM, -# define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM) -# define CDC_IN_EPADDR (ENDPOINT_DIR_IN | CDC_IN_EPNUM) -# define CDC_OUT_EPADDR (ENDPOINT_DIR_OUT | CDC_OUT_EPNUM) #endif }; diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 5feff889a1a1..f4727a0c38a2 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -65,7 +65,7 @@ enum usb_interfaces { # error There are not enough available interfaces to support all functions. Please disable one or more of the following: Mouse Keys, Extra Keys, Raw HID, Console #endif -static uint8_t vusb_keyboard_leds = 0; +static uint8_t keyboard_led_state = 0; static uint8_t vusb_idle_rate = 0; /* Keyboard report send buffer */ @@ -74,13 +74,7 @@ static report_keyboard_t kbuf[KBUF_SIZE]; static uint8_t kbuf_head = 0; static uint8_t kbuf_tail = 0; -typedef struct { - uint8_t modifier; - uint8_t reserved; - uint8_t keycode[6]; -} keyboard_report_t; - -static keyboard_report_t keyboard_report; // sent to PC +static report_keyboard_t keyboard_report_sent; #define VUSB_TRANSFER_KEYBOARD_MAX_TRIES 10 @@ -218,7 +212,7 @@ static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_sy host_driver_t *vusb_driver(void) { return &driver; } -static uint8_t keyboard_leds(void) { return vusb_keyboard_leds; } +static uint8_t keyboard_leds(void) { return keyboard_led_state; } static void send_keyboard(report_keyboard_t *report) { uint8_t next = (kbuf_head + 1) % KBUF_SIZE; @@ -232,6 +226,7 @@ static void send_keyboard(report_keyboard_t *report) { // NOTE: send key strokes of Macro usbPoll(); vusb_transfer_keyboard(); + keyboard_report_sent = *report; } typedef struct { @@ -289,9 +284,10 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { if ((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS) { /* class request type */ if (rq->bRequest == USBRQ_HID_GET_REPORT) { debug("GET_REPORT:"); - /* we only have one report type, so don't look at wValue */ - usbMsgPtr = (usbMsgPtr_t)&keyboard_report; - return sizeof(keyboard_report); + if (rq->wIndex.word == KEYBOARD_INTERFACE) { + usbMsgPtr = (usbMsgPtr_t)&keyboard_report_sent; + return sizeof(keyboard_report_sent); + } } else if (rq->bRequest == USBRQ_HID_GET_IDLE) { debug("GET_IDLE: "); // debug_hex(vusb_idle_rate); @@ -304,7 +300,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { } else if (rq->bRequest == USBRQ_HID_SET_REPORT) { debug("SET_REPORT: "); // Report Type: 0x02(Out)/ReportID: 0x00(none) && Interface: 0(keyboard) - if (rq->wValue.word == 0x0200 && rq->wIndex.word == 0) { + if (rq->wValue.word == 0x0200 && rq->wIndex.word == KEYBOARD_INTERFACE) { debug("SET_LED: "); last_req.kind = SET_LED; last_req.len = rq->wLength.word; @@ -330,7 +326,7 @@ uchar usbFunctionWrite(uchar *data, uchar len) { debug("SET_LED: "); debug_hex(data[0]); debug("\n"); - vusb_keyboard_leds = data[0]; + keyboard_led_state = data[0]; last_req.len = 0; return 1; break; From f3c6924887ae6d52359e55828dedc2455f8e4989 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 7 Jun 2020 15:00:59 +1000 Subject: [PATCH 05/54] Convert `CONSUMER2BLUEFRUIT()` and `CONSUMER2RN42()` macros to static inline functions (#9055) --- tmk_core/common/report.h | 7 ++- tmk_core/protocol/lufa/bluetooth.h | 98 ++++++++++++++++++++++-------- tmk_core/protocol/lufa/lufa.c | 2 +- 3 files changed, 79 insertions(+), 28 deletions(-) diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index c2b1b7c7101f..1b2f13bdde27 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h @@ -46,8 +46,9 @@ enum mouse_buttons { * See https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf#page=75 */ enum consumer_usages { - // 15.5 Display Controls (https://www.usb.org/sites/default/files/hutrr41_0.pdf) - BRIGHTNESS_UP = 0x06F, + // 15.5 Display Controls + SNAPSHOT = 0x065, + BRIGHTNESS_UP = 0x06F, // https://www.usb.org/sites/default/files/hutrr41_0.pdf BRIGHTNESS_DOWN = 0x070, // 15.7 Transport Controls TRANSPORT_RECORD = 0x0B2, @@ -57,6 +58,7 @@ enum consumer_usages { TRANSPORT_PREV_TRACK = 0x0B6, TRANSPORT_STOP = 0x0B7, TRANSPORT_EJECT = 0x0B8, + TRANSPORT_RANDOM_PLAY = 0x0B9, TRANSPORT_STOP_EJECT = 0x0CC, TRANSPORT_PLAY_PAUSE = 0x0CD, // 15.9.1 Audio Controls - Volume @@ -71,6 +73,7 @@ enum consumer_usages { AL_LOCK = 0x19E, AL_CONTROL_PANEL = 0x19F, AL_ASSISTANT = 0x1CB, + AL_KEYBOARD_LAYOUT = 0x1AE, // 15.16 Generic GUI Application Controls AC_MINIMIZE = 0x206, AC_SEARCH = 0x221, diff --git a/tmk_core/protocol/lufa/bluetooth.h b/tmk_core/protocol/lufa/bluetooth.h index 081271a4e646..67f031439e92 100644 --- a/tmk_core/protocol/lufa/bluetooth.h +++ b/tmk_core/protocol/lufa/bluetooth.h @@ -15,34 +15,82 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef BLUETOOTH_H -#define BLUETOOTH_H +#pragma once #include "../serial.h" void bluefruit_serial_send(uint8_t data); -/* -+-----------------+-------------------+-------+ -| Consumer Key | Bit Map | Hex | -+-----------------+-------------------+-------+ -| Home | 00000001 00000000 | 01 00 | -| KeyboardLayout | 00000010 00000000 | 02 00 | -| Search | 00000100 00000000 | 04 00 | -| Snapshot | 00001000 00000000 | 08 00 | -| VolumeUp | 00010000 00000000 | 10 00 | -| VolumeDown | 00100000 00000000 | 20 00 | -| Play/Pause | 01000000 00000000 | 40 00 | -| Fast Forward | 10000000 00000000 | 80 00 | -| Rewind | 00000000 00000001 | 00 01 | -| Scan Next Track | 00000000 00000010 | 00 02 | -| Scan Prev Track | 00000000 00000100 | 00 04 | -| Random Play | 00000000 00001000 | 00 08 | -| Stop | 00000000 00010000 | 00 10 | -+-------------------------------------+-------+ -*/ -#define CONSUMER2BLUEFRUIT(usage) (usage == AUDIO_MUTE ? 0x0000 : (usage == AUDIO_VOL_UP ? 0x1000 : (usage == AUDIO_VOL_DOWN ? 0x2000 : (usage == TRANSPORT_NEXT_TRACK ? 0x0002 : (usage == TRANSPORT_PREV_TRACK ? 0x0004 : (usage == TRANSPORT_STOP ? 0x0010 : (usage == TRANSPORT_STOP_EJECT ? 0x0000 : (usage == TRANSPORT_PLAY_PAUSE ? 0x4000 : (usage == AL_CC_CONFIG ? 0x0000 : (usage == AL_EMAIL ? 0x0000 : (usage == AL_CALCULATOR ? 0x0000 : (usage == AL_LOCAL_BROWSER ? 0x0000 : (usage == AC_SEARCH ? 0x0400 : (usage == AC_HOME ? 0x0100 : (usage == AC_BACK ? 0x0000 : (usage == AC_FORWARD ? 0x0000 : (usage == AC_STOP ? 0x0000 : (usage == AC_REFRESH ? 0x0000 : (usage == AC_BOOKMARKS ? 0x0000 : 0))))))))))))))))))) - -#define CONSUMER2RN42(usage) (usage == AUDIO_MUTE ? 0x0040 : (usage == AUDIO_VOL_UP ? 0x0010 : (usage == AUDIO_VOL_DOWN ? 0x0020 : (usage == TRANSPORT_NEXT_TRACK ? 0x0100 : (usage == TRANSPORT_PREV_TRACK ? 0x0200 : (usage == TRANSPORT_STOP ? 0x0400 : (usage == TRANSPORT_STOP_EJECT ? 0x0800 : (usage == TRANSPORT_PLAY_PAUSE ? 0x0080 : (usage == AL_EMAIL ? 0x0200 : (usage == AL_LOCAL_BROWSER ? 0x8000 : (usage == AC_SEARCH ? 0x0400 : (usage == AC_HOME ? 0x0100 : 0)))))))))))) +// https://learn.adafruit.com/introducing-bluefruit-ez-key-diy-bluetooth-hid-keyboard/sending-keys-via-serial#raw-hid-consumer-reports-8-14 +static inline uint16_t CONSUMER2BLUEFRUIT(uint16_t usage) { + switch (usage) { + case AC_HOME: + return 0x0001; + case AL_KEYBOARD_LAYOUT: + return 0x0002; + case AC_SEARCH: + return 0x0004; + case SNAPSHOT: + return 0x0008; + case AUDIO_VOL_UP: + return 0x0010; + case AUDIO_VOL_DOWN: + return 0x0020; + case TRANSPORT_PLAY_PAUSE: + return 0x0040; + case TRANSPORT_FAST_FORWARD: + return 0x0080; + case TRANSPORT_REWIND: + return 0x0100; + case TRANSPORT_NEXT_TRACK: + return 0x0200; + case TRANSPORT_PREV_TRACK: + return 0x0400; + case TRANSPORT_RANDOM_PLAY: + return 0x0800; + case TRANSPORT_STOP: + return 0x1000; + default: + return 0; + } +} -#endif +// https://cdn.sparkfun.com/datasheets/Wireless/Bluetooth/bluetooth_cr_UG-v1.0r.pdf#G7.663734 +static inline uint16_t CONSUMER2RN42(uint16_t usage) { + switch (usage) { + case AC_HOME: + return 0x0001; + case AL_EMAIL: + return 0x0002; + case AC_SEARCH: + return 0x0004; + case AL_KEYBOARD_LAYOUT: + return 0x0008; + case AUDIO_VOL_UP: + return 0x0010; + case AUDIO_VOL_DOWN: + return 0x0020; + case AUDIO_MUTE: + return 0x0040; + case TRANSPORT_PLAY_PAUSE: + return 0x0080; + case TRANSPORT_NEXT_TRACK: + return 0x0100; + case TRANSPORT_PREV_TRACK: + return 0x0200; + case TRANSPORT_STOP: + return 0x0400; + case TRANSPORT_EJECT: + return 0x0800; + case TRANSPORT_FAST_FORWARD: + return 0x1000; + case TRANSPORT_REWIND: + return 0x2000; + case TRANSPORT_STOP_EJECT: + return 0x4000; + case AL_LOCAL_BROWSER: + return 0x8000; + default: + return 0; + } +} diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 19f417770fae..3ca1a809d1da 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -720,8 +720,8 @@ static void send_consumer(uint16_t data) { bluefruit_serial_send(0xFD); bluefruit_serial_send(0x00); bluefruit_serial_send(0x02); - bluefruit_serial_send((bitmap >> 8) & 0xFF); bluefruit_serial_send(bitmap & 0xFF); + bluefruit_serial_send((bitmap >> 8) & 0xFF); bluefruit_serial_send(0x00); bluefruit_serial_send(0x00); bluefruit_serial_send(0x00); From e45716748d4f3c02cdc483d1ef895e617ea09b42 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Mon, 8 Jun 2020 12:20:43 +1000 Subject: [PATCH 06/54] Attempt to fix CI for non-master branches. (#9308) --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d137a4209607..f2e8a8411df3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ addons: install: - npm install -g moxygen script: + - git fetch --depth=50 origin $TRAVIS_BRANCH:$TRAVIS_BRANCH - git rev-parse --short HEAD - git diff --name-only HEAD $TRAVIS_BRANCH - bash util/travis_test.sh From ab99c81755d85e995db518e7ef8a75c57f687d28 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 10 Jun 2020 06:30:37 +1000 Subject: [PATCH 07/54] Additional cleanups for V-USB code (#9310) --- quantum/mcu_selection.mk | 3 - tmk_core/common.mk | 4 - tmk_core/protocol/vusb.mk | 7 -- tmk_core/protocol/vusb/main.c | 37 +++------ tmk_core/protocol/vusb/sendchar_usart.c | 19 ----- tmk_core/protocol/vusb/vusb.c | 102 ++++++++++-------------- 6 files changed, 53 insertions(+), 119 deletions(-) delete mode 100644 tmk_core/protocol/vusb/sendchar_usart.c diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk index a1d2c5fbf6f0..61fd7b6e4c04 100644 --- a/quantum/mcu_selection.mk +++ b/quantum/mcu_selection.mk @@ -266,7 +266,6 @@ ifneq (,$(filter $(MCU),atmega32a)) F_CPU ?= 12000000 # unsupported features for now - NO_UART ?= yes NO_SUSPEND_POWER_DOWN ?= yes endif @@ -284,7 +283,6 @@ ifneq (,$(filter $(MCU),atmega328p)) F_CPU ?= 16000000 # unsupported features for now - NO_UART ?= yes NO_SUSPEND_POWER_DOWN ?= yes endif @@ -317,6 +315,5 @@ ifneq (,$(filter $(MCU),attiny85)) F_CPU ?= 16500000 # unsupported features for now - NO_UART ?= yes NO_SUSPEND_POWER_DOWN ?= yes endif diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 63de7c7edeeb..b7fe45afd6d8 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -113,10 +113,6 @@ ifeq ($(strip $(SLEEP_LED_ENABLE)), yes) TMK_COMMON_DEFS += -DNO_SUSPEND_POWER_DOWN endif -ifeq ($(strip $(NO_UART)), yes) - TMK_COMMON_DEFS += -DNO_UART -endif - ifeq ($(strip $(NO_SUSPEND_POWER_DOWN)), yes) TMK_COMMON_DEFS += -DNO_SUSPEND_POWER_DOWN endif diff --git a/tmk_core/protocol/vusb.mk b/tmk_core/protocol/vusb.mk index 5e564f748056..1de60030899e 100644 --- a/tmk_core/protocol/vusb.mk +++ b/tmk_core/protocol/vusb.mk @@ -9,13 +9,6 @@ SRC += $(VUSB_DIR)/main.c \ $(VUSB_PATH)/usbdrv/usbdrvasm.S \ $(VUSB_PATH)/usbdrv/oddebug.c -ifneq ($(strip $(CONSOLE_ENABLE)), yes) -ifndef NO_UART -SRC += $(COMMON_DIR)/sendchar_uart.c \ - $(COMMON_DIR)/uart.c -endif -endif - # Search Path VPATH += $(TMK_PATH)/$(VUSB_DIR) VPATH += $(VUSB_PATH) diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c index b4063273daa9..a57df5ce06a7 100644 --- a/tmk_core/protocol/vusb/main.c +++ b/tmk_core/protocol/vusb/main.c @@ -7,19 +7,22 @@ * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * This Revision: $Id: main.c 790 2010-05-30 21:00:26Z cs $ */ + #include + #include +#include #include #include -#include + #include -#include + #include "vusb.h" + #include "keyboard.h" #include "host.h" #include "timer.h" -#include "uart.h" -#include "debug.h" +#include "print.h" #include "suspend.h" #include "wait.h" #include "sendchar.h" @@ -28,8 +31,6 @@ # include "sleep_led.h" #endif -#define UART_BAUD_RATE 115200 - #ifdef CONSOLE_ENABLE void console_task(void); #endif @@ -47,7 +48,7 @@ static void initForUsbConnectivity(void) { usbDeviceDisconnect(); /* do this while interrupts are disabled */ while (--i) { /* fake USB disconnect for > 250 ms */ wdt_reset(); - _delay_ms(1); + wait_ms(1); } usbDeviceConnect(); } @@ -60,7 +61,7 @@ static void usb_remote_wakeup(void) { USBDDR = ddr_orig | USBMASK; USBOUT ^= USBMASK; - _delay_ms(25); + wait_ms(25); USBOUT ^= USBMASK; USBDDR = ddr_orig; @@ -74,7 +75,6 @@ static void usb_remote_wakeup(void) { * FIXME: Needs doc */ static void setup_usb(void) { - // debug("initForUsbConnectivity()\n"); initForUsbConnectivity(); // for Console_Task @@ -95,10 +95,7 @@ int main(void) { #ifdef CLKPR // avoid unintentional changes of clock frequency in devices that have a // clock prescaler - CLKPR = 0x80, CLKPR = 0; -#endif -#ifndef NO_UART - uart_init(UART_BAUD_RATE); + clock_prescale_set(clock_div_1); #endif keyboard_setup(); @@ -113,7 +110,6 @@ int main(void) { sleep_led_init(); #endif - debug("main loop\n"); while (1) { #if USB_COUNT_SOF if (usbSofCount != 0) { @@ -130,19 +126,6 @@ int main(void) { # ifdef SLEEP_LED_ENABLE sleep_led_enable(); # endif - /* - uart_putchar('S'); - _delay_ms(1); - cli(); - set_sleep_mode(SLEEP_MODE_PWR_DOWN); - sleep_enable(); - sleep_bod_disable(); - sei(); - sleep_cpu(); - sleep_disable(); - _delay_ms(10); - uart_putchar('W'); - */ } } #endif diff --git a/tmk_core/protocol/vusb/sendchar_usart.c b/tmk_core/protocol/vusb/sendchar_usart.c deleted file mode 100644 index a920a9a536b3..000000000000 --- a/tmk_core/protocol/vusb/sendchar_usart.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH - * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - */ -#include -#include -#include "sendchar.h" - -#if DEBUG_LEVEL > 0 -/* from oddebug.c */ -int8_t sendchar(uint8_t c) { - while (!(ODDBG_USR & (1 << ODDBG_UDRE))) - ; /* wait for data register empty */ - ODDBG_UDR = c; - return 1; -} -#else -int8_t sendchar(uint8_t c) { return 1; } -#endif diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index f4727a0c38a2..735a1c1d307f 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -15,10 +15,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include -#include #include + +#include + #include + #include "usbconfig.h" #include "host.h" #include "report.h" @@ -26,6 +28,7 @@ along with this program. If not, see . #include "vusb.h" #include "print.h" #include "debug.h" +#include "wait.h" #include "usb_descriptor_common.h" #ifdef RAW_ENABLE @@ -56,7 +59,7 @@ enum usb_interfaces { #ifdef CONSOLE_ENABLE CONSOLE_INTERFACE = NEXT_INTERFACE, #endif - TOTAL_INTERFACES = NEXT_INTERFACE, + TOTAL_INTERFACES = NEXT_INTERFACE }; #define MAX_INTERFACES 2 @@ -86,19 +89,13 @@ void vusb_transfer_keyboard(void) { usbSetInterrupt((void *)&kbuf[kbuf_tail], sizeof(report_keyboard_t)); kbuf_tail = (kbuf_tail + 1) % KBUF_SIZE; if (debug_keyboard) { - print("V-USB: kbuf["); - pdec(kbuf_tail); - print("->"); - pdec(kbuf_head); - print("]("); - phex((kbuf_head < kbuf_tail) ? (KBUF_SIZE - kbuf_tail + kbuf_head) : (kbuf_head - kbuf_tail)); - print(")\n"); + dprintf("V-USB: kbuf[%d->%d](%02X)\n", kbuf_tail, kbuf_head, (kbuf_head < kbuf_tail) ? (KBUF_SIZE - kbuf_tail + kbuf_head) : (kbuf_head - kbuf_tail)); } } break; } usbPoll(); - _delay_ms(1); + wait_ms(1); } } @@ -220,7 +217,7 @@ static void send_keyboard(report_keyboard_t *report) { kbuf[kbuf_head] = *report; kbuf_head = next; } else { - debug("kbuf: full\n"); + dprint("kbuf: full\n"); } // NOTE: send key strokes of Macro @@ -283,37 +280,35 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { if ((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS) { /* class request type */ if (rq->bRequest == USBRQ_HID_GET_REPORT) { - debug("GET_REPORT:"); + dprint("GET_REPORT:"); if (rq->wIndex.word == KEYBOARD_INTERFACE) { usbMsgPtr = (usbMsgPtr_t)&keyboard_report_sent; return sizeof(keyboard_report_sent); } } else if (rq->bRequest == USBRQ_HID_GET_IDLE) { - debug("GET_IDLE: "); - // debug_hex(vusb_idle_rate); + dprint("GET_IDLE:"); usbMsgPtr = (usbMsgPtr_t)&vusb_idle_rate; return 1; } else if (rq->bRequest == USBRQ_HID_SET_IDLE) { vusb_idle_rate = rq->wValue.bytes[1]; - debug("SET_IDLE: "); - debug_hex(vusb_idle_rate); + dprintf("SET_IDLE: %02X", vusb_idle_rate); } else if (rq->bRequest == USBRQ_HID_SET_REPORT) { - debug("SET_REPORT: "); + dprint("SET_REPORT:"); // Report Type: 0x02(Out)/ReportID: 0x00(none) && Interface: 0(keyboard) if (rq->wValue.word == 0x0200 && rq->wIndex.word == KEYBOARD_INTERFACE) { - debug("SET_LED: "); + dprint("SET_LED:"); last_req.kind = SET_LED; last_req.len = rq->wLength.word; } return USB_NO_MSG; // to get data in usbFunctionWrite } else { - debug("UNKNOWN:"); + dprint("UNKNOWN:"); } } else { - debug("VENDOR:"); + dprint("VENDOR:"); /* no vendor specific requests implemented */ } - debug("\n"); + dprint("\n"); return 0; /* default for not implemented requests: return no data back to host */ } @@ -323,9 +318,7 @@ uchar usbFunctionWrite(uchar *data, uchar len) { } switch (last_req.kind) { case SET_LED: - debug("SET_LED: "); - debug_hex(data[0]); - debug("\n"); + dprintf("SET_LED: %02X\n", data[0]); keyboard_led_state = data[0]; last_req.len = 0; return 1; @@ -342,13 +335,13 @@ void usbFunctionWriteOut(uchar *data, uchar len) { #ifdef RAW_ENABLE // Data from host must be divided every 8bytes if (len != 8) { - debug("RAW: invalid length"); + dprint("RAW: invalid length\n"); raw_output_received_bytes = 0; return; } if (raw_output_received_bytes + len > RAW_BUFFER_SIZE) { - debug("RAW: buffer full"); + dprint("RAW: buffer full\n"); raw_output_received_bytes = 0; } else { for (uint8_t i = 0; i < 8; i++) { @@ -404,29 +397,6 @@ const PROGMEM uchar keyboard_hid_report[] = { 0xC0 // End Collection }; -#ifdef RAW_ENABLE -const PROGMEM uchar raw_hid_report[] = { - 0x06, RAW_USAGE_PAGE_LO, RAW_USAGE_PAGE_HI, // Usage Page (Vendor Defined) - 0x09, RAW_USAGE_ID, // Usage (Vendor Defined) - 0xA1, 0x01, // Collection (Application) - // Data to host - 0x09, 0x62, // Usage (Vendor Defined) - 0x15, 0x00, // Logical Minimum (0) - 0x26, 0xFF, 0x00, // Logical Maximum (255) - 0x95, RAW_BUFFER_SIZE, // Report Count - 0x75, 0x08, // Report Size (8) - 0x81, 0x02, // Input (Data, Variable, Absolute) - // Data from host - 0x09, 0x63, // Usage (Vendor Defined) - 0x15, 0x00, // Logical Minimum (0) - 0x26, 0xFF, 0x00, // Logical Maximum (255) - 0x95, RAW_BUFFER_SIZE, // Report Count - 0x75, 0x08, // Report Size (8) - 0x91, 0x02, // Output (Data, Variable, Absolute) - 0xC0 // End Collection -}; -#endif - #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) const PROGMEM uchar mouse_extra_hid_report[] = { # ifdef MOUSE_ENABLE @@ -511,6 +481,29 @@ const PROGMEM uchar mouse_extra_hid_report[] = { }; #endif +#ifdef RAW_ENABLE +const PROGMEM uchar raw_hid_report[] = { + 0x06, RAW_USAGE_PAGE_LO, RAW_USAGE_PAGE_HI, // Usage Page (Vendor Defined) + 0x09, RAW_USAGE_ID, // Usage (Vendor Defined) + 0xA1, 0x01, // Collection (Application) + // Data to host + 0x09, 0x62, // Usage (Vendor Defined) + 0x15, 0x00, // Logical Minimum (0) + 0x26, 0xFF, 0x00, // Logical Maximum (255) + 0x95, RAW_BUFFER_SIZE, // Report Count + 0x75, 0x08, // Report Size (8) + 0x81, 0x02, // Input (Data, Variable, Absolute) + // Data from host + 0x09, 0x63, // Usage (Vendor Defined) + 0x15, 0x00, // Logical Minimum (0) + 0x26, 0xFF, 0x00, // Logical Maximum (255) + 0x95, RAW_BUFFER_SIZE, // Report Count + 0x75, 0x08, // Report Size (8) + 0x91, 0x02, // Output (Data, Variable, Absolute) + 0xC0 // End Collection +}; +#endif + #if defined(CONSOLE_ENABLE) const PROGMEM uchar console_hid_report[] = { 0x06, 0x31, 0xFF, // Usage Page (Vendor Defined - PJRC Teensy compatible) @@ -801,14 +794,6 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = { USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) { usbMsgLen_t len = 0; - /* - debug("usbFunctionDescriptor: "); - debug_hex(rq->bmRequestType); debug(" "); - debug_hex(rq->bRequest); debug(" "); - debug_hex16(rq->wValue.word); debug(" "); - debug_hex16(rq->wIndex.word); debug(" "); - debug_hex16(rq->wLength.word); debug("\n"); - */ switch (rq->wValue.bytes[1]) { case USBDESCR_DEVICE: usbMsgPtr = (usbMsgPtr_t)&usbDeviceDescriptor; @@ -892,6 +877,5 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) { } break; } - // debug("desc len: "); debug_hex(len); debug("\n"); return len; } From 4887279bc72f02b78a8257d8f939afb04d89630b Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 17 Jun 2020 21:42:27 +1000 Subject: [PATCH 08/54] Remove inclusion of adafruit_ble.h from ssd1306.c (#9355) --- drivers/avr/ssd1306.c | 3 --- keyboards/claw44/ssd1306.c | 3 --- keyboards/comet46/ssd1306.c | 3 --- keyboards/crkbd/ssd1306.c | 3 --- keyboards/helix/local_drivers/ssd1306.c | 3 --- keyboards/yosino58/ssd1306.c | 3 --- 6 files changed, 18 deletions(-) diff --git a/drivers/avr/ssd1306.c b/drivers/avr/ssd1306.c index 61d7a9953113..205f749502b8 100644 --- a/drivers/avr/ssd1306.c +++ b/drivers/avr/ssd1306.c @@ -5,9 +5,6 @@ # include # include "print.h" # include "glcdfont.c" -# ifdef ADAFRUIT_BLE_ENABLE -# include "adafruit_ble.h" -# endif # ifdef PROTOCOL_LUFA # include "lufa.h" # endif diff --git a/keyboards/claw44/ssd1306.c b/keyboards/claw44/ssd1306.c index e32fc091c244..e04a431357c3 100644 --- a/keyboards/claw44/ssd1306.c +++ b/keyboards/claw44/ssd1306.c @@ -4,9 +4,6 @@ #include "i2c.h" #include #include "print.h" -#ifdef ADAFRUIT_BLE_ENABLE -#include "adafruit_ble.h" -#endif #ifdef PROTOCOL_LUFA #include "lufa.h" #endif diff --git a/keyboards/comet46/ssd1306.c b/keyboards/comet46/ssd1306.c index 20c2738db774..abbed4a49fb9 100644 --- a/keyboards/comet46/ssd1306.c +++ b/keyboards/comet46/ssd1306.c @@ -4,9 +4,6 @@ #include "i2c.h" #include #include "print.h" -#ifdef ADAFRUIT_BLE_ENABLE -#include "adafruit_ble.h" -#endif #ifdef PROTOCOL_LUFA #include "lufa.h" #endif diff --git a/keyboards/crkbd/ssd1306.c b/keyboards/crkbd/ssd1306.c index 622e44e35f59..b2676f386f24 100644 --- a/keyboards/crkbd/ssd1306.c +++ b/keyboards/crkbd/ssd1306.c @@ -4,9 +4,6 @@ #include "i2c.h" #include #include "print.h" -#ifdef ADAFRUIT_BLE_ENABLE -#include "adafruit_ble.h" -#endif #ifdef PROTOCOL_LUFA #include "lufa.h" #endif diff --git a/keyboards/helix/local_drivers/ssd1306.c b/keyboards/helix/local_drivers/ssd1306.c index dd3290ba0cc8..00b2fb0eec36 100644 --- a/keyboards/helix/local_drivers/ssd1306.c +++ b/keyboards/helix/local_drivers/ssd1306.c @@ -10,9 +10,6 @@ #else #include #endif -#ifdef ADAFRUIT_BLE_ENABLE -#include "adafruit_ble.h" -#endif #ifdef PROTOCOL_LUFA #include "lufa.h" #endif diff --git a/keyboards/yosino58/ssd1306.c b/keyboards/yosino58/ssd1306.c index 3353f615f581..ff6ba210d1fb 100644 --- a/keyboards/yosino58/ssd1306.c +++ b/keyboards/yosino58/ssd1306.c @@ -4,9 +4,6 @@ #include "i2c.h" #include #include "print.h" -#ifdef ADAFRUIT_BLE_ENABLE -#include "adafruit_ble.h" -#endif #ifdef PROTOCOL_LUFA #include "lufa.h" #endif From ccb1fafcb4e4e7685c56e0f1ae3376f207001c69 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 17 Jun 2020 21:43:20 +1000 Subject: [PATCH 09/54] Don't compile outputselect.c if Bluetooth is disabled (#9356) --- quantum/quantum.c | 4 ++-- tmk_core/protocol/lufa.mk | 21 ++++++++++++--------- tmk_core/protocol/lufa/lufa.c | 16 +++++++++------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/quantum/quantum.c b/quantum/quantum.c index 044a15612845..9d63f4de2788 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -17,7 +17,7 @@ #include #include "quantum.h" -#ifdef PROTOCOL_LUFA +#ifdef BLUETOOTH_ENABLE # include "outputselect.h" #endif @@ -618,7 +618,7 @@ void matrix_init_quantum() { #ifdef HAPTIC_ENABLE haptic_init(); #endif -#ifdef OUTPUT_AUTO_ENABLE +#if defined(BLUETOOTH_ENABLE) && defined(OUTPUT_AUTO_ENABLE) set_output(OUTPUT_AUTO); #endif diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk index d87802992e93..9bc972c266b7 100644 --- a/tmk_core/protocol/lufa.mk +++ b/tmk_core/protocol/lufa.mk @@ -15,9 +15,8 @@ else endif LUFA_SRC = lufa.c \ - usb_descriptor.c \ - outputselect.c \ - $(LUFA_SRC_USB) + usb_descriptor.c \ + $(LUFA_SRC_USB) ifeq ($(strip $(MIDI_ENABLE)), yes) include $(TMK_PATH)/protocol/midi.mk @@ -25,23 +24,27 @@ endif ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ - $(TMK_DIR)/protocol/serial_uart.c + outputselect.c \ + $(TMK_DIR)/protocol/serial_uart.c endif ifeq ($(strip $(BLUETOOTH)), AdafruitBLE) - LUFA_SRC += spi_master.c - LUFA_SRC += analog.c - LUFA_SRC += $(LUFA_DIR)/adafruit_ble.cpp + LUFA_SRC += spi_master.c \ + analog.c \ + outputselect.c \ + $(LUFA_DIR)/adafruit_ble.cpp endif ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey) LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ - $(TMK_DIR)/protocol/serial_uart.c + outputselect.c \ + $(TMK_DIR)/protocol/serial_uart.c endif ifeq ($(strip $(BLUETOOTH)), RN42) LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ - $(TMK_DIR)/protocol/serial_uart.c + outputselect.c \ + $(TMK_DIR)/protocol/serial_uart.c endif ifeq ($(strip $(VIRTSER_ENABLE)), yes) diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 3ca1a809d1da..ca3384ba2552 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -53,7 +53,6 @@ #include "lufa.h" #include "quantum.h" #include -#include "outputselect.h" #ifdef NKRO_ENABLE # include "keycode_config.h" @@ -66,6 +65,7 @@ extern keymap_config_t keymap_config; #endif #ifdef BLUETOOTH_ENABLE +# include "outputselect.h" # ifdef MODULE_ADAFRUIT_BLE # include "adafruit_ble.h" # else @@ -554,9 +554,10 @@ static uint8_t keyboard_leds(void) { return keyboard_led_state; } */ static void send_keyboard(report_keyboard_t *report) { uint8_t timeout = 255; - uint8_t where = where_to_send(); #ifdef BLUETOOTH_ENABLE + uint8_t where = where_to_send(); + if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { # ifdef MODULE_ADAFRUIT_BLE adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); @@ -578,11 +579,11 @@ static void send_keyboard(report_keyboard_t *report) { } # endif } -#endif if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { return; } +#endif /* Select the Keyboard Report Endpoint */ uint8_t ep = KEYBOARD_IN_EPNUM; @@ -618,9 +619,10 @@ static void send_keyboard(report_keyboard_t *report) { static void send_mouse(report_mouse_t *report) { #ifdef MOUSE_ENABLE uint8_t timeout = 255; - uint8_t where = where_to_send(); # ifdef BLUETOOTH_ENABLE + uint8_t where = where_to_send(); + if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { # ifdef MODULE_ADAFRUIT_BLE // FIXME: mouse buttons @@ -637,11 +639,11 @@ static void send_mouse(report_mouse_t *report) { bluefruit_serial_send(0x00); # endif } -# endif if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { return; } +# endif /* Select the Mouse Report Endpoint */ Endpoint_SelectEndpoint(MOUSE_IN_EPNUM); @@ -696,9 +698,9 @@ static void send_system(uint16_t data) { */ static void send_consumer(uint16_t data) { #ifdef EXTRAKEY_ENABLE +# ifdef BLUETOOTH_ENABLE uint8_t where = where_to_send(); -# ifdef BLUETOOTH_ENABLE if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { # ifdef MODULE_ADAFRUIT_BLE adafruit_ble_send_consumer_key(data, 0); @@ -728,11 +730,11 @@ static void send_consumer(uint16_t data) { bluefruit_serial_send(0x00); # endif } -# endif if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { return; } +# endif send_extra(REPORT_ID_CONSUMER, data); #endif From 970ad01181b9e211e18e7d9c85dda0610398d951 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Mon, 22 Jun 2020 11:22:00 +1000 Subject: [PATCH 10/54] `qmk cformat` on `develop` (#9501) --- tmk_core/protocol/chibios/usb_main.c | 4 +--- tmk_core/protocol/lufa/lufa.c | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 9d68419f42e6..21e9f14e50a8 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -796,9 +796,7 @@ int8_t sendchar(uint8_t c) { } #endif /* CONSOLE_ENABLE */ -void _putchar(char character) { - sendchar(character); -} +void _putchar(char character) { sendchar(character); } #ifdef RAW_ENABLE void raw_hid_send(uint8_t *data, uint8_t length) { diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index ca3384ba2552..6776a964e976 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -556,7 +556,7 @@ static void send_keyboard(report_keyboard_t *report) { uint8_t timeout = 255; #ifdef BLUETOOTH_ENABLE - uint8_t where = where_to_send(); + uint8_t where = where_to_send(); if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { # ifdef MODULE_ADAFRUIT_BLE @@ -621,7 +621,7 @@ static void send_mouse(report_mouse_t *report) { uint8_t timeout = 255; # ifdef BLUETOOTH_ENABLE - uint8_t where = where_to_send(); + uint8_t where = where_to_send(); if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { # ifdef MODULE_ADAFRUIT_BLE From 563728ee3c845817864073b14740b8e54ddbcff7 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 2 Jul 2020 13:12:34 +1000 Subject: [PATCH 11/54] Change analogRead calls to analogReadPin (#9023) * Change analogRead calls to analogReadPin * Add ChangeLog * Update docs, remove mention of `analogRead()` * Retarget changelog for next round --- docs/ChangeLog/20200829/PR9023.md | 5 +++ docs/adc_driver.md | 39 ++++++++++----------- keyboards/handwired/promethium/config.h | 1 - keyboards/handwired/promethium/promethium.c | 3 +- tmk_core/protocol/lufa/adafruit_ble.cpp | 4 +-- 5 files changed, 27 insertions(+), 25 deletions(-) create mode 100644 docs/ChangeLog/20200829/PR9023.md diff --git a/docs/ChangeLog/20200829/PR9023.md b/docs/ChangeLog/20200829/PR9023.md new file mode 100644 index 000000000000..79ca2cb2f843 --- /dev/null +++ b/docs/ChangeLog/20200829/PR9023.md @@ -0,0 +1,5 @@ +# Deprecation of `analogRead()` + +[#9023](https://github.com/qmk/qmk_firmware/pull/9023) + +This function takes Arduino pin numbers (eg. `9` vs. `B5`), which is at odds with the rest of the codebase. The replacement for this function is `analogReadPin()`. diff --git a/docs/adc_driver.md b/docs/adc_driver.md index f8fb94094e84..6e3d513863bb 100644 --- a/docs/adc_driver.md +++ b/docs/adc_driver.md @@ -45,9 +45,9 @@ Then place this include at the top of your code: Note that some of these pins are doubled-up on ADCs with the same channel. This is because the pins can be used for either ADC. -Also note that the F0 and F3 use different numbering schemes. The F0 has a single ADC and the channels are 0-based, whereas the F3 has 4 ADCs and the channels are 1 based. This is because the F0 uses the `ADCv1` implementation of the ADC, whereas the F3 uses the `ADCv3` implementation. +Also note that the F0 and F3 use different numbering schemes. The F0 has a single ADC and the channels are 0-indexed, whereas the F3 has 4 ADCs and the channels are 1-indexed. This is because the F0 uses the `ADCv1` implementation of the ADC, whereas the F3 uses the `ADCv3` implementation. -|ADC|Channel|STM32F0XX|STM32F3XX| +|ADC|Channel|STM32F0xx|STM32F3xx| |---|-------|---------|---------| |1 |0 |`A0` | | |1 |1 |`A1` |`A0` | @@ -122,32 +122,29 @@ Also note that the F0 and F3 use different numbering schemes. The F0 has a singl |Function |Description | |----------------------------|-------------------------------------------------------------------------------------------------------------------| |`analogReference(mode)` |Sets the analog voltage reference source. Must be one of `ADC_REF_EXTERNAL`, `ADC_REF_POWER` or `ADC_REF_INTERNAL`.| -|`analogRead(pin)` |Reads the value from the specified Arduino pin, eg. `4` for ADC6 on the ATmega32U4. | -|`analogReadPin(pin)` |Reads the value from the specified QMK pin, eg. `F6` for ADC6 on the ATmega32U4. | -|`pinToMux(pin)` |Translates a given QMK pin to a mux value. If an unsupported pin is given, returns the mux value for "0V (GND)". | +|`analogReadPin(pin)` |Reads the value from the specified pin, eg. `F6` for ADC6 on the ATmega32U4. | +|`pinToMux(pin)` |Translates a given pin to a mux value. If an unsupported pin is given, returns the mux value for "0V (GND)". | |`adc_read(mux)` |Reads the value from the ADC according to the specified mux. See your MCU's datasheet for more information. | ### ARM -Note that care was taken to match all of the functions used for AVR devices, however complications in the ARM platform prevent that from always being possible. For example, the `STM32` chips do not have assigned Arduino pins. We could use the default pin numbers, but those numbers change based on the package type of the device. For this reason, please specify your target pins with their identifiers (`A0`, `F3`, etc.). Also note that there are some variants of functions that accept the target ADC for the pin. Some pins can be used for multiple ADCs, and this specified can help you pick which ADC will be used to interact with that pin. - -|Function |Description | -|----------------------------|--------------------------------------------------------------------------------------------------------------------| -|`analogReadPin(pin)` |Reads the value from the specified QMK pin, eg. `A0` for channel 0 on the STM32F0 and ADC1 channel 1 on the STM32F3. Note that if a pin can be used for multiple ADCs, it will pick the lower numbered ADC for this function. eg. `C0` will be channel 6 of ADC 1 when it could be used for ADC 2 as well.| -|`analogReadPinAdc(pin, adc)`|Reads the value from the specified QMK pin and ADC, eg. `C0, 1` will read from channel 6, ADC 2 instead of ADC 1. Note that the ADCs are 0-indexed for this function.| -|`pinToMux(pin)` |Translates a given QMK pin to a channel and ADC combination. If an unsupported pin is given, returns the mux value for "0V (GND)".| -|`adc_read(mux)` |Reads the value from the ADC according to the specified pin and adc combination. See your MCU's datasheet for more information.| +|Function |Description | +|----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +|`analogReadPin(pin)` |Reads the value from the specified pin, eg. `A0` for channel 0 on the STM32F0 and ADC1 channel 1 on the STM32F3. Note that if a pin can be used for multiple ADCs, it will pick the lower numbered ADC for this function. eg. `C0` will be channel 6 of ADC 1 when it could be used for ADC 2 as well.| +|`analogReadPinAdc(pin, adc)`|Reads the value from the specified pin and ADC, eg. `C0, 1` will read from channel 6, ADC 2 instead of ADC 1. Note that the ADCs are 0-indexed for this function. | +|`pinToMux(pin)` |Translates a given pin to a channel and ADC combination. If an unsupported pin is given, returns the mux value for "0V (GND)". | +|`adc_read(mux)` |Reads the value from the ADC according to the specified pin and ADC combination. See your MCU's datasheet for more information. | ## Configuration ## ARM -The ARM implementation of the ADC has a few additional options that you can override in your own keyboards and keymaps to change how it operates. +The ARM implementation of the ADC has a few additional options that you can override in your own keyboards and keymaps to change how it operates. Please consult the corresponding `hal_adc_lld.h` in ChibiOS for your specific microcontroller for further documentation on your available options. -|`#define` |Type |Default |Description| -|-------------------|------|---------------------|-----------| -|ADC_CIRCULAR_BUFFER|`bool`|`false` |If `TRUE`, then the implementation will use a circular buffer.| -|ADC_NUM_CHANNELS |`int` |`1` |Sets the number of channels that will be scanned as part of an ADC operation. The current implementation only supports `1`.| -|ADC_BUFFER_DEPTH |`int` |`2` |Sets the depth of each result. Since we are only getting a 12-bit result by default, we set this to `2` bytes so we can contain our one value. This could be set to 1 if you opt for a 8-bit or lower result.| -|ADC_SAMPLING_RATE |`int` |`ADC_SMPR_SMP_1P5` |Sets the sampling rate of the ADC. By default, it is set to the fastest setting. Please consult the corresponding `hal_adc_lld.h` in ChibiOS for your specific microcontroller for further documentation on your available options.| -|ADC_RESOLUTION |`int` |`ADC_CFGR1_RES_12BIT`|The resolution of your result. We choose 12 bit by default, but you can opt for 12, 10, 8, or 6 bit. Please consult the corresponding `hal_adc_lld.h` in ChibiOS for your specific microcontroller for further documentation on your available options.| +|`#define` |Type |Default |Description | +|---------------------|------|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +|`ADC_CIRCULAR_BUFFER`|`bool`|`false` |If `true`, then the implementation will use a circular buffer. | +|`ADC_NUM_CHANNELS` |`int` |`1` |Sets the number of channels that will be scanned as part of an ADC operation. The current implementation only supports `1`. | +|`ADC_BUFFER_DEPTH` |`int` |`2` |Sets the depth of each result. Since we are only getting a 12-bit result by default, we set this to 2 bytes so we can contain our one value. This could be set to 1 if you opt for an 8-bit or lower result.| +|`ADC_SAMPLING_RATE` |`int` |`ADC_SMPR_SMP_1P5` |Sets the sampling rate of the ADC. By default, it is set to the fastest setting. | +|`ADC_RESOLUTION` |`int` |`ADC_CFGR1_RES_12BIT`|The resolution of your result. We choose 12 bit by default, but you can opt for 12, 10, 8, or 6 bit. | diff --git a/keyboards/handwired/promethium/config.h b/keyboards/handwired/promethium/config.h index f9560206b49c..20c5e6a855b9 100644 --- a/keyboards/handwired/promethium/config.h +++ b/keyboards/handwired/promethium/config.h @@ -150,7 +150,6 @@ along with this program. If not, see . //#define NO_ACTION_FUNCTION #define PS2_MOUSE_INIT_DELAY 2000 -#define BATTERY_PIN 9 #define BATTERY_POLL 30000 #define MAX_VOLTAGE 4.2 #define MIN_VOLTAGE 3.2 diff --git a/keyboards/handwired/promethium/promethium.c b/keyboards/handwired/promethium/promethium.c index 3cc0f5a8c829..96bcf3ce1480 100644 --- a/keyboards/handwired/promethium/promethium.c +++ b/keyboards/handwired/promethium/promethium.c @@ -3,6 +3,7 @@ #include "timer.h" #include "matrix.h" #include "musical_notes.h" +#include "adafruit_ble.h" float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_A4, 0.0625); float fauxclicky_released_note[2] = MUSICAL_NOTE(_A4, 0.0625); @@ -11,7 +12,7 @@ float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C6, 0.25); // cubic fit {3.3, 0}, {3.5, 2.9}, {3.6, 5}, {3.7, 8.6}, {3.8, 36}, {3.9, 62}, {4.0, 73}, {4.05, 83}, {4.1, 89}, {4.15, 94}, {4.2, 100} uint8_t battery_level(void) { - float voltage = analogRead(BATTERY_PIN) * 2 * 3.3 / 1024; + float voltage = adafruit_ble_read_battery_voltage() * 2 * 3.3 / 1024; if (voltage < MIN_VOLTAGE) return 0; if (voltage > MAX_VOLTAGE) return 255; return (voltage - MIN_VOLTAGE) / (MAX_VOLTAGE - MIN_VOLTAGE) * 255; diff --git a/tmk_core/protocol/lufa/adafruit_ble.cpp b/tmk_core/protocol/lufa/adafruit_ble.cpp index b07407f38775..79b35fca317e 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.cpp +++ b/tmk_core/protocol/lufa/adafruit_ble.cpp @@ -38,7 +38,7 @@ #ifdef SAMPLE_BATTERY # ifndef BATTERY_LEVEL_PIN -# define BATTERY_LEVEL_PIN 7 +# define BATTERY_LEVEL_PIN B5 # endif #endif @@ -556,7 +556,7 @@ void adafruit_ble_task(void) { if (timer_elapsed(state.last_battery_update) > BatteryUpdateInterval && resp_buf.empty()) { state.last_battery_update = timer_read(); - state.vbat = analogRead(BATTERY_LEVEL_PIN); + state.vbat = analogReadPin(BATTERY_LEVEL_PIN); } #endif } From 208c2f2cb73d7d6103dca23a7810c6c91c32a81f Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Thu, 16 Jul 2020 16:39:49 +1000 Subject: [PATCH 12/54] Add support for DMAMUX-capable MCU configuration with WS2812 PWM driver. (#9471) --- docs/ws2812_driver.md | 3 ++- drivers/chibios/ws2812_pwm.c | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/ws2812_driver.md b/docs/ws2812_driver.md index 941e1bde084a..c1b96329e9c4 100644 --- a/docs/ws2812_driver.md +++ b/docs/ws2812_driver.md @@ -92,6 +92,7 @@ Configure the hardware via your config.h: #define WS2812_PWM_PAL_MODE 2 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 2 #define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU. #define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU. +#define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM2_UP // DMAMUX configuration for TIMx_UP -- only required if your MCU has a DMAMUX peripheral, see the respective reference manual for the appropriate values for your MCU. ``` You must also turn on the PWM feature in your halconf.h and mcuconf.h @@ -117,5 +118,5 @@ Note: This only applies to STM32 boards. To configure the `RGB_DI_PIN` to open drain configuration add this to your config.h file: ```c - #define WS2812_EXTERNAL_PULLUP +#define WS2812_EXTERNAL_PULLUP ``` diff --git a/drivers/chibios/ws2812_pwm.c b/drivers/chibios/ws2812_pwm.c index 7113db11e0b9..d93fa24735d5 100644 --- a/drivers/chibios/ws2812_pwm.c +++ b/drivers/chibios/ws2812_pwm.c @@ -23,6 +23,9 @@ #ifndef WS2812_DMA_CHANNEL # define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP #endif +#if (STM32_DMA_SUPPORTS_DMAMUX == TRUE) && !defined(WS2812_DMAMUX_ID) +# error "please consult your MCU's datasheet and specify in your config.h: #define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM?_UP" +#endif // Push Pull or Open Drain Configuration // Default Push Pull @@ -184,6 +187,11 @@ void ws2812_init(void) { dmaStreamSetMode(WS2812_DMA_STREAM, STM32_DMA_CR_CHSEL(WS2812_DMA_CHANNEL) | STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_PSIZE_WORD | STM32_DMA_CR_MSIZE_WORD | STM32_DMA_CR_MINC | STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(3)); // M2P: Memory 2 Periph; PL: Priority Level +#if (STM32_DMA_SUPPORTS_DMAMUX == TRUE) + // If the MCU has a DMAMUX we need to assign the correct resource + dmaSetRequestSource(WS2812_DMA_STREAM, WS2812_DMAMUX_ID); +#endif + // Start DMA dmaStreamEnable(WS2812_DMA_STREAM); From 21a884c87d7c9c7c1b0dd1ba8df57733a3de1f84 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Thu, 16 Jul 2020 16:44:55 +1000 Subject: [PATCH 13/54] F303/Proton-C migration. (#9315) --- .../GENERIC_STM32_F303XC/board/board.c | 242 --------- .../GENERIC_STM32_F303XC/board/board.h | 475 ------------------ .../GENERIC_STM32_F303XC/board/board.mk | 4 +- .../GENERIC_STM32_F303XC/configs/board.h | 37 ++ .../GENERIC_STM32_F303XC/configs/config.h | 18 + 5 files changed, 57 insertions(+), 719 deletions(-) delete mode 100644 platforms/chibios/GENERIC_STM32_F303XC/board/board.c delete mode 100644 platforms/chibios/GENERIC_STM32_F303XC/board/board.h create mode 100644 platforms/chibios/GENERIC_STM32_F303XC/configs/board.h create mode 100644 platforms/chibios/GENERIC_STM32_F303XC/configs/config.h diff --git a/platforms/chibios/GENERIC_STM32_F303XC/board/board.c b/platforms/chibios/GENERIC_STM32_F303XC/board/board.c deleted file mode 100644 index 4722acd648fe..000000000000 --- a/platforms/chibios/GENERIC_STM32_F303XC/board/board.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/* - * This file has been automatically generated using ChibiStudio board - * generator plugin. Do not edit manually. - */ - -#include "hal.h" -#include "stm32_gpio.h" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables and types. */ -/*===========================================================================*/ - -/** - * @brief Type of STM32 GPIO port setup. - */ -typedef struct { - uint32_t moder; - uint32_t otyper; - uint32_t ospeedr; - uint32_t pupdr; - uint32_t odr; - uint32_t afrl; - uint32_t afrh; -} gpio_setup_t; - -/** - * @brief Type of STM32 GPIO initialization data. - */ -typedef struct { -#if STM32_HAS_GPIOA || defined(__DOXYGEN__) - gpio_setup_t PAData; -#endif -#if STM32_HAS_GPIOB || defined(__DOXYGEN__) - gpio_setup_t PBData; -#endif -#if STM32_HAS_GPIOC || defined(__DOXYGEN__) - gpio_setup_t PCData; -#endif -#if STM32_HAS_GPIOD || defined(__DOXYGEN__) - gpio_setup_t PDData; -#endif -#if STM32_HAS_GPIOE || defined(__DOXYGEN__) - gpio_setup_t PEData; -#endif -#if STM32_HAS_GPIOF || defined(__DOXYGEN__) - gpio_setup_t PFData; -#endif -#if STM32_HAS_GPIOG || defined(__DOXYGEN__) - gpio_setup_t PGData; -#endif -#if STM32_HAS_GPIOH || defined(__DOXYGEN__) - gpio_setup_t PHData; -#endif -#if STM32_HAS_GPIOI || defined(__DOXYGEN__) - gpio_setup_t PIData; -#endif -#if STM32_HAS_GPIOJ || defined(__DOXYGEN__) - gpio_setup_t PJData; -#endif -#if STM32_HAS_GPIOK || defined(__DOXYGEN__) - gpio_setup_t PKData; -#endif -} gpio_config_t; - -/** - * @brief STM32 GPIO static initialization data. - */ -static const gpio_config_t gpio_default_config = { -#if STM32_HAS_GPIOA - {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR, VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH}, -#endif -#if STM32_HAS_GPIOB - {VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR, VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH}, -#endif -#if STM32_HAS_GPIOC - {VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR, VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH}, -#endif -#if STM32_HAS_GPIOD - {VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR, VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH}, -#endif -#if STM32_HAS_GPIOE - {VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR, VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH}, -#endif -#if STM32_HAS_GPIOF - {VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR, VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH}, -#endif -#if STM32_HAS_GPIOG - {VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR, VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH}, -#endif -#if STM32_HAS_GPIOH - {VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR, VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH}, -#endif -#if STM32_HAS_GPIOI - {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR, VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}, -#endif -#if STM32_HAS_GPIOJ - {VAL_GPIOJ_MODER, VAL_GPIOJ_OTYPER, VAL_GPIOJ_OSPEEDR, VAL_GPIOJ_PUPDR, VAL_GPIOJ_ODR, VAL_GPIOJ_AFRL, VAL_GPIOJ_AFRH}, -#endif -#if STM32_HAS_GPIOK - {VAL_GPIOK_MODER, VAL_GPIOK_OTYPER, VAL_GPIOK_OSPEEDR, VAL_GPIOK_PUPDR, VAL_GPIOK_ODR, VAL_GPIOK_AFRL, VAL_GPIOK_AFRH} -#endif -}; - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config) { - gpiop->OTYPER = config->otyper; - gpiop->OSPEEDR = config->ospeedr; - gpiop->PUPDR = config->pupdr; - gpiop->ODR = config->odr; - gpiop->AFRL = config->afrl; - gpiop->AFRH = config->afrh; - gpiop->MODER = config->moder; -} - -static void stm32_gpio_init(void) { - /* Enabling GPIO-related clocks, the mask comes from the - registry header file.*/ - rccResetAHB(STM32_GPIO_EN_MASK); - rccEnableAHB(STM32_GPIO_EN_MASK, true); - - /* Initializing all the defined GPIO ports.*/ -#if STM32_HAS_GPIOA - gpio_init(GPIOA, &gpio_default_config.PAData); -#endif -#if STM32_HAS_GPIOB - gpio_init(GPIOB, &gpio_default_config.PBData); -#endif -#if STM32_HAS_GPIOC - gpio_init(GPIOC, &gpio_default_config.PCData); -#endif -#if STM32_HAS_GPIOD - gpio_init(GPIOD, &gpio_default_config.PDData); -#endif -#if STM32_HAS_GPIOE - gpio_init(GPIOE, &gpio_default_config.PEData); -#endif -#if STM32_HAS_GPIOF - gpio_init(GPIOF, &gpio_default_config.PFData); -#endif -#if STM32_HAS_GPIOG - gpio_init(GPIOG, &gpio_default_config.PGData); -#endif -#if STM32_HAS_GPIOH - gpio_init(GPIOH, &gpio_default_config.PHData); -#endif -#if STM32_HAS_GPIOI - gpio_init(GPIOI, &gpio_default_config.PIData); -#endif -#if STM32_HAS_GPIOJ - gpio_init(GPIOJ, &gpio_default_config.PJData); -#endif -#if STM32_HAS_GPIOK - gpio_init(GPIOK, &gpio_default_config.PKData); -#endif -} - -__attribute__((weak)) void enter_bootloader_mode_if_requested(void) {} - -/** - * @brief Early initialization code. - * @details This initialization must be performed just after stack setup - * and before any other initialization. - */ -void __early_init(void) { - enter_bootloader_mode_if_requested(); - - stm32_gpio_init(); - stm32_clock_init(); -} - -#if HAL_USE_SDC || defined(__DOXYGEN__) -/** - * @brief SDC card detection. - */ -bool sdc_lld_is_card_inserted(SDCDriver *sdcp) { - (void)sdcp; - /* TODO: Fill the implementation.*/ - return true; -} - -/** - * @brief SDC card write protection detection. - */ -bool sdc_lld_is_write_protected(SDCDriver *sdcp) { - (void)sdcp; - /* TODO: Fill the implementation.*/ - return false; -} -#endif /* HAL_USE_SDC */ - -#if HAL_USE_MMC_SPI || defined(__DOXYGEN__) -/** - * @brief MMC_SPI card detection. - */ -bool mmc_lld_is_card_inserted(MMCDriver *mmcp) { - (void)mmcp; - /* TODO: Fill the implementation.*/ - return true; -} - -/** - * @brief MMC_SPI card write protection detection. - */ -bool mmc_lld_is_write_protected(MMCDriver *mmcp) { - (void)mmcp; - /* TODO: Fill the implementation.*/ - return false; -} -#endif - -/** - * @brief Board-specific initialization code. - * @todo Add your board-specific code, if any. - */ -void boardInit(void) {} diff --git a/platforms/chibios/GENERIC_STM32_F303XC/board/board.h b/platforms/chibios/GENERIC_STM32_F303XC/board/board.h deleted file mode 100644 index 3579c82770ec..000000000000 --- a/platforms/chibios/GENERIC_STM32_F303XC/board/board.h +++ /dev/null @@ -1,475 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _BOARD_H_ -#define _BOARD_H_ - -/* - * Setup for Generic STM32_F303 Board - */ - -/* - * Board identifier. - */ -#define BOARD_GENERIC_STM32_F303XC -#define BOARD_NAME "STM32_F303" - -/* - * Board oscillators-related settings. - * NOTE: LSE not fitted. - */ -#if !defined(STM32_LSECLK) -# define STM32_LSECLK 0U -#endif - -#define STM32_LSEDRV (3U << 3U) - -#if !defined(STM32_HSECLK) -# define STM32_HSECLK 8000000U -#endif - -// #define STM32_HSE_BYPASS - -/* - * MCU type as defined in the ST header. - */ -#define STM32F303xC - -/* - * IO pins assignments. - */ -#define GPIOA_PIN0 0U -#define GPIOA_PIN1 1U -#define GPIOA_PIN2 2U -#define GPIOA_PIN3 3U -#define GPIOA_PIN4 4U -#define GPIOA_PIN5 5U -#define GPIOA_PIN6 6U -#define GPIOA_PIN7 7U -#define GPIOA_PIN8 8U -#define GPIOA_PIN9 9U -#define GPIOA_PIN10 10U -#define GPIOA_USB_DM 11U -#define GPIOA_USB_DP 12U -#define GPIOA_SWDIO 13U -#define GPIOA_SWCLK 14U -#define GPIOA_PIN15 15U - -#define GPIOB_PIN0 0U -#define GPIOB_PIN1 1U -#define GPIOB_PIN2 2U -#define GPIOB_PIN3 3U -#define GPIOB_PIN4 4U -#define GPIOB_PIN5 5U -#define GPIOB_PIN6 6U -#define GPIOB_PIN7 7U -#define GPIOB_PIN8 8U -#define GPIOB_PIN9 9U -#define GPIOB_PIN10 10U -#define GPIOB_PIN11 11U -#define GPIOB_PIN12 12U -#define GPIOB_PIN13 13U -#define GPIOB_PIN14 14U -#define GPIOB_PIN15 15U - -#define GPIOC_PIN0 0U -#define GPIOC_PIN1 1U -#define GPIOC_PIN2 2U -#define GPIOC_PIN3 3U -#define GPIOC_PIN4 4U -#define GPIOC_PIN5 5U -#define GPIOC_PIN6 6U -#define GPIOC_PIN7 7U -#define GPIOC_PIN8 8U -#define GPIOC_PIN9 9U -#define GPIOC_PIN10 10U -#define GPIOC_PIN11 11U -#define GPIOC_PIN12 12U -#define GPIOC_PIN13 13U -#define GPIOC_PIN14 14U -#define GPIOC_PIN15 15U - -#define GPIOD_PIN0 0U -#define GPIOD_PIN1 1U -#define GPIOD_PIN2 2U -#define GPIOD_PIN3 3U -#define GPIOD_PIN4 4U -#define GPIOD_PIN5 5U -#define GPIOD_PIN6 6U -#define GPIOD_PIN7 7U -#define GPIOD_PIN8 8U -#define GPIOD_PIN9 9U -#define GPIOD_PIN10 10U -#define GPIOD_PIN11 11U -#define GPIOD_PIN12 12U -#define GPIOD_PIN13 13U -#define GPIOD_PIN14 14U -#define GPIOD_PIN15 15U - -#define GPIOE_PIN0 0U -#define GPIOE_PIN1 1U -#define GPIOE_PIN2 2U -#define GPIOE_PIN3 3U -#define GPIOE_PIN4 4U -#define GPIOE_PIN5 5U -#define GPIOE_PIN6 6U -#define GPIOE_PIN7 7U -#define GPIOE_PIN8 8U -#define GPIOE_PIN9 9U -#define GPIOE_PIN10 10U -#define GPIOE_PIN11 11U -#define GPIOE_PIN12 12U -#define GPIOE_PIN13 13U -#define GPIOE_PIN14 14U -#define GPIOE_PIN15 15U - -#define GPIOF_I2C2_SDA 0U -#define GPIOF_I2C2_SCL 1U -#define GPIOF_PIN2 2U -#define GPIOF_PIN3 3U -#define GPIOF_PIN4 4U -#define GPIOF_PIN5 5U -#define GPIOF_PIN6 6U -#define GPIOF_PIN7 7U -#define GPIOF_PIN8 8U -#define GPIOF_PIN9 9U -#define GPIOF_PIN10 10U -#define GPIOF_PIN11 11U -#define GPIOF_PIN12 12U -#define GPIOF_PIN13 13U -#define GPIOF_PIN14 14U -#define GPIOF_PIN15 15U - -#define GPIOG_PIN0 0U -#define GPIOG_PIN1 1U -#define GPIOG_PIN2 2U -#define GPIOG_PIN3 3U -#define GPIOG_PIN4 4U -#define GPIOG_PIN5 5U -#define GPIOG_PIN6 6U -#define GPIOG_PIN7 7U -#define GPIOG_PIN8 8U -#define GPIOG_PIN9 9U -#define GPIOG_PIN10 10U -#define GPIOG_PIN11 11U -#define GPIOG_PIN12 12U -#define GPIOG_PIN13 13U -#define GPIOG_PIN14 14U -#define GPIOG_PIN15 15U - -#define GPIOH_PIN0 0U -#define GPIOH_PIN1 1U -#define GPIOH_PIN2 2U -#define GPIOH_PIN3 3U -#define GPIOH_PIN4 4U -#define GPIOH_PIN5 5U -#define GPIOH_PIN6 6U -#define GPIOH_PIN7 7U -#define GPIOH_PIN8 8U -#define GPIOH_PIN9 9U -#define GPIOH_PIN10 10U -#define GPIOH_PIN11 11U -#define GPIOH_PIN12 12U -#define GPIOH_PIN13 13U -#define GPIOH_PIN14 14U -#define GPIOH_PIN15 15U - -/* - * IO lines assignments. - */ -#define LINE_L3GD20_SDI PAL_LINE(GPIOA, 7U) -#define LINE_USB_DM PAL_LINE(GPIOA, 11U) -#define LINE_USB_DP PAL_LINE(GPIOA, 12U) -#define LINE_SWDIO PAL_LINE(GPIOA, 13U) -#define LINE_SWCLK PAL_LINE(GPIOA, 14U) - -#define LINE_PIN6 PAL_LINE(GPIOF, 0U) -#define LINE_PIN7 PAL_LINE(GPIOF, 1U) - -#define LINE_CAPS_LOCK PAL_LINE(GPIOB, 7U) - -/* - * I/O ports initial setup, this configuration is established soon after reset - * in the initialization code. - * Please refer to the STM32 Reference Manual for details. - */ -#define PIN_MODE_INPUT(n) (0U << ((n)*2U)) -#define PIN_MODE_OUTPUT(n) (1U << ((n)*2U)) -#define PIN_MODE_ALTERNATE(n) (2U << ((n)*2U)) -#define PIN_MODE_ANALOG(n) (3U << ((n)*2U)) -#define PIN_ODR_LOW(n) (0U << (n)) -#define PIN_ODR_HIGH(n) (1U << (n)) -#define PIN_OTYPE_PUSHPULL(n) (0U << (n)) -#define PIN_OTYPE_OPENDRAIN(n) (1U << (n)) -#define PIN_OSPEED_VERYLOW(n) (0U << ((n)*2U)) -#define PIN_OSPEED_LOW(n) (1U << ((n)*2U)) -#define PIN_OSPEED_MEDIUM(n) (2U << ((n)*2U)) -#define PIN_OSPEED_HIGH(n) (3U << ((n)*2U)) -#define PIN_PUPDR_FLOATING(n) (0U << ((n)*2U)) -#define PIN_PUPDR_PULLUP(n) (1U << ((n)*2U)) -#define PIN_PUPDR_PULLDOWN(n) (2U << ((n)*2U)) -#define PIN_AFIO_AF(n, v) ((v) << (((n) % 8U) * 4U)) - -/* - * GPIOA setup: - * - * PA0 - NC - * PA1 - NC - * PA2 - COL1 - * PA3 - COL2 - * PA4 - SPEAKER1 - * PA5 - SPEAKER2 - * PA6 - COL3 - * PA7 - COL8 - * PA8 - COL6 - * PA9 - COL7 - * PA10 - ROW5 - * PA11 - USB_DM (alternate 14). - * PA12 - USB_DP (alternate 14). - * PA13 - SWDIO (alternate 0). - * PA14 - SWCLK (alternate 0). - * PA15 - ROW4 - */ -#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_PIN0) | PIN_MODE_ALTERNATE(GPIOA_PIN1) | PIN_MODE_INPUT(GPIOA_PIN2) | PIN_MODE_INPUT(GPIOA_PIN3) | PIN_MODE_INPUT(GPIOA_PIN4) | PIN_MODE_INPUT(GPIOA_PIN5) | PIN_MODE_INPUT(GPIOA_PIN6) | PIN_MODE_INPUT(GPIOA_PIN7) | PIN_MODE_INPUT(GPIOA_PIN8) | PIN_MODE_INPUT(GPIOA_PIN9) | PIN_MODE_INPUT(GPIOA_PIN10) | PIN_MODE_ALTERNATE(GPIOA_USB_DM) | PIN_MODE_ALTERNATE(GPIOA_USB_DP) | PIN_MODE_ALTERNATE(GPIOA_SWDIO) | PIN_MODE_ALTERNATE(GPIOA_SWCLK) | PIN_MODE_INPUT(GPIOA_PIN15)) -#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_PIN0) | PIN_OTYPE_PUSHPULL(GPIOA_PIN1) | PIN_OTYPE_PUSHPULL(GPIOA_PIN2) | PIN_OTYPE_PUSHPULL(GPIOA_PIN3) | PIN_OTYPE_PUSHPULL(GPIOA_PIN4) | PIN_OTYPE_PUSHPULL(GPIOA_PIN5) | PIN_OTYPE_PUSHPULL(GPIOA_PIN6) | PIN_OTYPE_PUSHPULL(GPIOA_PIN7) | PIN_OTYPE_PUSHPULL(GPIOA_PIN8) | PIN_OTYPE_PUSHPULL(GPIOA_PIN9) | PIN_OTYPE_PUSHPULL(GPIOA_PIN10) | PIN_OTYPE_PUSHPULL(GPIOA_USB_DM) | PIN_OTYPE_PUSHPULL(GPIOA_USB_DP) | PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) | PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) | PIN_OTYPE_PUSHPULL(GPIOA_PIN15)) -#define VAL_GPIOA_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOA_PIN0) | PIN_OSPEED_HIGH(GPIOA_PIN1) | PIN_OSPEED_VERYLOW(GPIOA_PIN2) | PIN_OSPEED_VERYLOW(GPIOA_PIN3) | PIN_OSPEED_VERYLOW(GPIOA_PIN4) | PIN_OSPEED_VERYLOW(GPIOA_PIN5) | PIN_OSPEED_VERYLOW(GPIOA_PIN6) | PIN_OSPEED_VERYLOW(GPIOA_PIN7) | PIN_OSPEED_VERYLOW(GPIOA_PIN8) | PIN_OSPEED_VERYLOW(GPIOA_PIN9) | PIN_OSPEED_VERYLOW(GPIOA_PIN10) | PIN_OSPEED_HIGH(GPIOA_USB_DM) | PIN_OSPEED_VERYLOW(GPIOA_USB_DP) | PIN_OSPEED_HIGH(GPIOA_SWDIO) | PIN_OSPEED_HIGH(GPIOA_SWCLK) | PIN_OSPEED_VERYLOW(GPIOA_PIN15)) -#define VAL_GPIOA_PUPDR (PIN_PUPDR_FLOATING(GPIOA_PIN0) | PIN_PUPDR_FLOATING(GPIOA_PIN1) | PIN_PUPDR_PULLUP(GPIOA_PIN2) | PIN_PUPDR_PULLUP(GPIOA_PIN3) | PIN_PUPDR_PULLUP(GPIOA_PIN4) | PIN_PUPDR_PULLUP(GPIOA_PIN5) | PIN_PUPDR_PULLUP(GPIOA_PIN6) | PIN_PUPDR_FLOATING(GPIOA_PIN7) | PIN_PUPDR_PULLUP(GPIOA_PIN8) | PIN_PUPDR_PULLUP(GPIOA_PIN9) | PIN_PUPDR_PULLUP(GPIOA_PIN10) | PIN_PUPDR_FLOATING(GPIOA_USB_DM) | PIN_PUPDR_FLOATING(GPIOA_USB_DP) | PIN_PUPDR_PULLUP(GPIOA_SWDIO) | PIN_PUPDR_PULLDOWN(GPIOA_SWCLK) | PIN_PUPDR_PULLUP(GPIOA_PIN15)) -#define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_PIN0) | PIN_ODR_HIGH(GPIOA_PIN1) | PIN_ODR_HIGH(GPIOA_PIN2) | PIN_ODR_HIGH(GPIOA_PIN3) | PIN_ODR_HIGH(GPIOA_PIN4) | PIN_ODR_HIGH(GPIOA_PIN5) | PIN_ODR_HIGH(GPIOA_PIN6) | PIN_ODR_HIGH(GPIOA_PIN7) | PIN_ODR_HIGH(GPIOA_PIN8) | PIN_ODR_HIGH(GPIOA_PIN9) | PIN_ODR_HIGH(GPIOA_PIN10) | PIN_ODR_HIGH(GPIOA_USB_DM) | PIN_ODR_HIGH(GPIOA_USB_DP) | PIN_ODR_HIGH(GPIOA_SWDIO) | PIN_ODR_HIGH(GPIOA_SWCLK) | PIN_ODR_HIGH(GPIOA_PIN15)) -#define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_PIN0, 0) | PIN_AFIO_AF(GPIOA_PIN1, 1) | PIN_AFIO_AF(GPIOA_PIN2, 0) | PIN_AFIO_AF(GPIOA_PIN3, 0) | PIN_AFIO_AF(GPIOA_PIN4, 0) | PIN_AFIO_AF(GPIOA_PIN5, 5) | PIN_AFIO_AF(GPIOA_PIN6, 5) | PIN_AFIO_AF(GPIOA_PIN7, 5)) -#define VAL_GPIOA_AFRH (PIN_AFIO_AF(GPIOA_PIN8, 0) | PIN_AFIO_AF(GPIOA_PIN9, 0) | PIN_AFIO_AF(GPIOA_PIN10, 0) | PIN_AFIO_AF(GPIOA_USB_DM, 14) | PIN_AFIO_AF(GPIOA_USB_DP, 14) | PIN_AFIO_AF(GPIOA_SWDIO, 0) | PIN_AFIO_AF(GPIOA_SWCLK, 0) | PIN_AFIO_AF(GPIOA_PIN15, 0)) - -/* - * GPIOB setup: - * - * PB0 - PIN0 (input pullup). - * PB1 - PIN1 (input pullup). - * PB2 - PIN2 (input pullup). - * PB3 - PIN3 (alternate 0). - * PB4 - PIN4 (input pullup). - * PB5 - PIN5 (input pullup). - * PB6 - PIN6 LSM303DLHC_SCL (alternate 4). - * PB7 - PIN7 LSM303DLHC_SDA (alternate 4). - * PB8 - PIN8 (input pullup). - * PB9 - PIN9 (input pullup). - * PB10 - PIN10 (input pullup). - * PB11 - PIN11 (input pullup). - * PB12 - PIN12 (input pullup). - * PB13 - PIN13 (input pullup). - * PB14 - PIN14 (input pullup). - * PB15 - PIN15 (input pullup). - */ -#define VAL_GPIOB_MODER (PIN_MODE_INPUT(GPIOB_PIN0) | PIN_MODE_INPUT(GPIOB_PIN1) | PIN_MODE_INPUT(GPIOB_PIN2) | PIN_MODE_ALTERNATE(GPIOB_PIN3) | PIN_MODE_INPUT(GPIOB_PIN4) | PIN_MODE_INPUT(GPIOB_PIN5) | PIN_MODE_ALTERNATE(GPIOB_PIN6) | PIN_MODE_OUTPUT(GPIOB_PIN7) | PIN_MODE_INPUT(GPIOB_PIN8) | PIN_MODE_INPUT(GPIOB_PIN9) | PIN_MODE_INPUT(GPIOB_PIN10) | PIN_MODE_INPUT(GPIOB_PIN11) | PIN_MODE_INPUT(GPIOB_PIN12) | PIN_MODE_INPUT(GPIOB_PIN13) | PIN_MODE_INPUT(GPIOB_PIN14) | PIN_MODE_INPUT(GPIOB_PIN15)) -#define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(GPIOB_PIN0) | PIN_OTYPE_PUSHPULL(GPIOB_PIN1) | PIN_OTYPE_PUSHPULL(GPIOB_PIN2) | PIN_OTYPE_PUSHPULL(GPIOB_PIN3) | PIN_OTYPE_PUSHPULL(GPIOB_PIN4) | PIN_OTYPE_PUSHPULL(GPIOB_PIN5) | PIN_OTYPE_OPENDRAIN(GPIOB_PIN6) | PIN_OTYPE_PUSHPULL(GPIOB_PIN7) | PIN_OTYPE_PUSHPULL(GPIOB_PIN8) | PIN_OTYPE_PUSHPULL(GPIOB_PIN9) | PIN_OTYPE_PUSHPULL(GPIOB_PIN10) | PIN_OTYPE_PUSHPULL(GPIOB_PIN11) | PIN_OTYPE_PUSHPULL(GPIOB_PIN12) | PIN_OTYPE_PUSHPULL(GPIOB_PIN13) | PIN_OTYPE_PUSHPULL(GPIOB_PIN14) | PIN_OTYPE_PUSHPULL(GPIOB_PIN15)) -#define VAL_GPIOB_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOB_PIN0) | PIN_OSPEED_VERYLOW(GPIOB_PIN1) | PIN_OSPEED_VERYLOW(GPIOB_PIN2) | PIN_OSPEED_HIGH(GPIOB_PIN3) | PIN_OSPEED_VERYLOW(GPIOB_PIN4) | PIN_OSPEED_VERYLOW(GPIOB_PIN5) | PIN_OSPEED_HIGH(GPIOB_PIN6) | PIN_OSPEED_VERYLOW(GPIOB_PIN7) | PIN_OSPEED_VERYLOW(GPIOB_PIN8) | PIN_OSPEED_VERYLOW(GPIOB_PIN9) | PIN_OSPEED_VERYLOW(GPIOB_PIN10) | PIN_OSPEED_VERYLOW(GPIOB_PIN11) | PIN_OSPEED_VERYLOW(GPIOB_PIN12) | PIN_OSPEED_VERYLOW(GPIOB_PIN13) | PIN_OSPEED_VERYLOW(GPIOB_PIN14) | PIN_OSPEED_VERYLOW(GPIOB_PIN15)) -#define VAL_GPIOB_PUPDR (PIN_PUPDR_PULLUP(GPIOB_PIN0) | PIN_PUPDR_PULLUP(GPIOB_PIN1) | PIN_PUPDR_PULLUP(GPIOB_PIN2) | PIN_PUPDR_FLOATING(GPIOB_PIN3) | PIN_PUPDR_PULLUP(GPIOB_PIN4) | PIN_PUPDR_PULLUP(GPIOB_PIN5) | PIN_PUPDR_FLOATING(GPIOB_PIN6) | PIN_PUPDR_PULLDOWN(GPIOB_PIN7) | PIN_PUPDR_PULLUP(GPIOB_PIN8) | PIN_PUPDR_PULLUP(GPIOB_PIN9) | PIN_PUPDR_PULLUP(GPIOB_PIN10) | PIN_PUPDR_PULLUP(GPIOB_PIN11) | PIN_PUPDR_PULLUP(GPIOB_PIN12) | PIN_PUPDR_PULLUP(GPIOB_PIN13) | PIN_PUPDR_PULLUP(GPIOB_PIN14) | PIN_PUPDR_PULLUP(GPIOB_PIN15)) -#define VAL_GPIOB_ODR (PIN_ODR_HIGH(GPIOB_PIN0) | PIN_ODR_HIGH(GPIOB_PIN1) | PIN_ODR_HIGH(GPIOB_PIN2) | PIN_ODR_HIGH(GPIOB_PIN3) | PIN_ODR_HIGH(GPIOB_PIN4) | PIN_ODR_HIGH(GPIOB_PIN5) | PIN_ODR_HIGH(GPIOB_PIN6) | PIN_ODR_LOW(GPIOB_PIN7) | PIN_ODR_HIGH(GPIOB_PIN8) | PIN_ODR_HIGH(GPIOB_PIN9) | PIN_ODR_HIGH(GPIOB_PIN10) | PIN_ODR_HIGH(GPIOB_PIN11) | PIN_ODR_HIGH(GPIOB_PIN12) | PIN_ODR_HIGH(GPIOB_PIN13) | PIN_ODR_HIGH(GPIOB_PIN14) | PIN_ODR_HIGH(GPIOB_PIN15)) -#define VAL_GPIOB_AFRL (PIN_AFIO_AF(GPIOB_PIN0, 0) | PIN_AFIO_AF(GPIOB_PIN1, 0) | PIN_AFIO_AF(GPIOB_PIN2, 0) | PIN_AFIO_AF(GPIOB_PIN3, 0) | PIN_AFIO_AF(GPIOB_PIN4, 0) | PIN_AFIO_AF(GPIOB_PIN5, 0) | PIN_AFIO_AF(GPIOB_PIN6, 4) | PIN_AFIO_AF(GPIOB_PIN7, 0)) -#define VAL_GPIOB_AFRH (PIN_AFIO_AF(GPIOB_PIN8, 0) | PIN_AFIO_AF(GPIOB_PIN9, 0) | PIN_AFIO_AF(GPIOB_PIN10, 0) | PIN_AFIO_AF(GPIOB_PIN11, 0) | PIN_AFIO_AF(GPIOB_PIN12, 0) | PIN_AFIO_AF(GPIOB_PIN13, 0) | PIN_AFIO_AF(GPIOB_PIN14, 0) | PIN_AFIO_AF(GPIOB_PIN15, 0)) - -/* - * GPIOC setup: - * - * PC0 - PIN0 (input pullup). - * PC1 - PIN1 (input pullup). - * PC2 - PIN2 (input pullup). - * PC3 - PIN3 (input pullup). - * PC4 - PIN4 (input pullup). - * PC5 - PIN5 (input pullup). - * PC6 - PIN6 (input pullup). - * PC7 - PIN7 (input pullup). - * PC8 - PIN8 (input pullup). - * PC9 - PIN9 (input pullup). - * PC10 - PIN10 (input pullup). - * PC11 - PIN11 (input pullup). - * PC12 - PIN12 (input pullup). - * PC13 - PIN13 (input pullup). - * PC14 - PIN14 (input floating). - * PC15 - PIN15 (input floating). - */ -#define VAL_GPIOC_MODER (PIN_MODE_INPUT(GPIOC_PIN0) | PIN_MODE_INPUT(GPIOC_PIN1) | PIN_MODE_INPUT(GPIOC_PIN2) | PIN_MODE_INPUT(GPIOC_PIN3) | PIN_MODE_INPUT(GPIOC_PIN4) | PIN_MODE_INPUT(GPIOC_PIN5) | PIN_MODE_INPUT(GPIOC_PIN6) | PIN_MODE_INPUT(GPIOC_PIN7) | PIN_MODE_INPUT(GPIOC_PIN8) | PIN_MODE_INPUT(GPIOC_PIN9) | PIN_MODE_INPUT(GPIOC_PIN10) | PIN_MODE_INPUT(GPIOC_PIN11) | PIN_MODE_INPUT(GPIOC_PIN12) | PIN_MODE_INPUT(GPIOC_PIN13) | PIN_MODE_INPUT(GPIOC_PIN14) | PIN_MODE_INPUT(GPIOC_PIN15)) -#define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(GPIOC_PIN0) | PIN_OTYPE_PUSHPULL(GPIOC_PIN1) | PIN_OTYPE_PUSHPULL(GPIOC_PIN2) | PIN_OTYPE_PUSHPULL(GPIOC_PIN3) | PIN_OTYPE_PUSHPULL(GPIOC_PIN4) | PIN_OTYPE_PUSHPULL(GPIOC_PIN5) | PIN_OTYPE_PUSHPULL(GPIOC_PIN6) | PIN_OTYPE_PUSHPULL(GPIOC_PIN7) | PIN_OTYPE_PUSHPULL(GPIOC_PIN8) | PIN_OTYPE_PUSHPULL(GPIOC_PIN9) | PIN_OTYPE_PUSHPULL(GPIOC_PIN10) | PIN_OTYPE_PUSHPULL(GPIOC_PIN11) | PIN_OTYPE_PUSHPULL(GPIOC_PIN12) | PIN_OTYPE_PUSHPULL(GPIOC_PIN13) | PIN_OTYPE_PUSHPULL(GPIOC_PIN14) | PIN_OTYPE_PUSHPULL(GPIOC_PIN15)) -#define VAL_GPIOC_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOC_PIN0) | PIN_OSPEED_VERYLOW(GPIOC_PIN1) | PIN_OSPEED_VERYLOW(GPIOC_PIN2) | PIN_OSPEED_VERYLOW(GPIOC_PIN3) | PIN_OSPEED_VERYLOW(GPIOC_PIN4) | PIN_OSPEED_VERYLOW(GPIOC_PIN5) | PIN_OSPEED_VERYLOW(GPIOC_PIN6) | PIN_OSPEED_VERYLOW(GPIOC_PIN7) | PIN_OSPEED_VERYLOW(GPIOC_PIN8) | PIN_OSPEED_VERYLOW(GPIOC_PIN9) | PIN_OSPEED_VERYLOW(GPIOC_PIN10) | PIN_OSPEED_VERYLOW(GPIOC_PIN11) | PIN_OSPEED_VERYLOW(GPIOC_PIN12) | PIN_OSPEED_VERYLOW(GPIOC_PIN13) | PIN_OSPEED_HIGH(GPIOC_PIN14) | PIN_OSPEED_HIGH(GPIOC_PIN15)) -#define VAL_GPIOC_PUPDR (PIN_PUPDR_PULLUP(GPIOC_PIN0) | PIN_PUPDR_PULLUP(GPIOC_PIN1) | PIN_PUPDR_PULLUP(GPIOC_PIN2) | PIN_PUPDR_PULLUP(GPIOC_PIN3) | PIN_PUPDR_PULLUP(GPIOC_PIN4) | PIN_PUPDR_PULLUP(GPIOC_PIN5) | PIN_PUPDR_PULLUP(GPIOC_PIN6) | PIN_PUPDR_PULLUP(GPIOC_PIN7) | PIN_PUPDR_PULLUP(GPIOC_PIN8) | PIN_PUPDR_PULLUP(GPIOC_PIN9) | PIN_PUPDR_PULLUP(GPIOC_PIN10) | PIN_PUPDR_PULLUP(GPIOC_PIN11) | PIN_PUPDR_PULLUP(GPIOC_PIN12) | PIN_PUPDR_PULLUP(GPIOC_PIN13) | PIN_PUPDR_FLOATING(GPIOC_PIN14) | PIN_PUPDR_FLOATING(GPIOC_PIN15)) -#define VAL_GPIOC_ODR (PIN_ODR_HIGH(GPIOC_PIN0) | PIN_ODR_HIGH(GPIOC_PIN1) | PIN_ODR_HIGH(GPIOC_PIN2) | PIN_ODR_HIGH(GPIOC_PIN3) | PIN_ODR_HIGH(GPIOC_PIN4) | PIN_ODR_HIGH(GPIOC_PIN5) | PIN_ODR_HIGH(GPIOC_PIN6) | PIN_ODR_HIGH(GPIOC_PIN7) | PIN_ODR_HIGH(GPIOC_PIN8) | PIN_ODR_HIGH(GPIOC_PIN9) | PIN_ODR_HIGH(GPIOC_PIN10) | PIN_ODR_HIGH(GPIOC_PIN11) | PIN_ODR_HIGH(GPIOC_PIN12) | PIN_ODR_HIGH(GPIOC_PIN13) | PIN_ODR_HIGH(GPIOC_PIN14) | PIN_ODR_HIGH(GPIOC_PIN15)) -#define VAL_GPIOC_AFRL (PIN_AFIO_AF(GPIOC_PIN0, 0) | PIN_AFIO_AF(GPIOC_PIN1, 0) | PIN_AFIO_AF(GPIOC_PIN2, 0) | PIN_AFIO_AF(GPIOC_PIN3, 0) | PIN_AFIO_AF(GPIOC_PIN4, 0) | PIN_AFIO_AF(GPIOC_PIN5, 0) | PIN_AFIO_AF(GPIOC_PIN6, 0) | PIN_AFIO_AF(GPIOC_PIN7, 0)) -#define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_PIN8, 0) | PIN_AFIO_AF(GPIOC_PIN9, 0) | PIN_AFIO_AF(GPIOC_PIN10, 0) | PIN_AFIO_AF(GPIOC_PIN11, 0) | PIN_AFIO_AF(GPIOC_PIN12, 0) | PIN_AFIO_AF(GPIOC_PIN13, 0) | PIN_AFIO_AF(GPIOC_PIN14, 0) | PIN_AFIO_AF(GPIOC_PIN15, 0)) - -/* - * GPIOD setup: - * - * PD0 - PIN0 (input pullup). - * PD1 - PIN1 (input pullup). - * PD2 - PIN2 (input pullup). - * PD3 - PIN3 (input pullup). - * PD4 - PIN4 (input pullup). - * PD5 - PIN5 (input pullup). - * PD6 - PIN6 (input pullup). - * PD7 - PIN7 (input pullup). - * PD8 - PIN8 (input pullup). - * PD9 - PIN9 (input pullup). - * PD11 - PIN10 (input pullup). - * PD11 - PIN11 (input pullup). - * PD12 - PIN12 (input pullup). - * PD13 - PIN13 (input pullup). - * PD14 - PIN14 (input pullup). - * PD15 - PIN15 (input pullup). - */ -#define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_PIN0) | PIN_MODE_INPUT(GPIOD_PIN1) | PIN_MODE_INPUT(GPIOD_PIN2) | PIN_MODE_INPUT(GPIOD_PIN3) | PIN_MODE_INPUT(GPIOD_PIN4) | PIN_MODE_INPUT(GPIOD_PIN5) | PIN_MODE_INPUT(GPIOD_PIN6) | PIN_MODE_INPUT(GPIOD_PIN7) | PIN_MODE_INPUT(GPIOD_PIN8) | PIN_MODE_INPUT(GPIOD_PIN9) | PIN_MODE_INPUT(GPIOD_PIN10) | PIN_MODE_INPUT(GPIOD_PIN11) | PIN_MODE_INPUT(GPIOD_PIN12) | PIN_MODE_INPUT(GPIOD_PIN13) | PIN_MODE_INPUT(GPIOD_PIN14) | PIN_MODE_INPUT(GPIOD_PIN15)) -#define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) | PIN_OTYPE_PUSHPULL(GPIOD_PIN1) | PIN_OTYPE_PUSHPULL(GPIOD_PIN2) | PIN_OTYPE_PUSHPULL(GPIOD_PIN3) | PIN_OTYPE_PUSHPULL(GPIOD_PIN4) | PIN_OTYPE_PUSHPULL(GPIOD_PIN5) | PIN_OTYPE_PUSHPULL(GPIOD_PIN6) | PIN_OTYPE_PUSHPULL(GPIOD_PIN7) | PIN_OTYPE_PUSHPULL(GPIOD_PIN8) | PIN_OTYPE_PUSHPULL(GPIOD_PIN9) | PIN_OTYPE_PUSHPULL(GPIOD_PIN10) | PIN_OTYPE_PUSHPULL(GPIOD_PIN11) | PIN_OTYPE_PUSHPULL(GPIOD_PIN12) | PIN_OTYPE_PUSHPULL(GPIOD_PIN13) | PIN_OTYPE_PUSHPULL(GPIOD_PIN14) | PIN_OTYPE_PUSHPULL(GPIOD_PIN15)) -#define VAL_GPIOD_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOD_PIN0) | PIN_OSPEED_VERYLOW(GPIOD_PIN1) | PIN_OSPEED_VERYLOW(GPIOD_PIN2) | PIN_OSPEED_VERYLOW(GPIOD_PIN3) | PIN_OSPEED_VERYLOW(GPIOD_PIN4) | PIN_OSPEED_VERYLOW(GPIOD_PIN5) | PIN_OSPEED_VERYLOW(GPIOD_PIN6) | PIN_OSPEED_VERYLOW(GPIOD_PIN7) | PIN_OSPEED_VERYLOW(GPIOD_PIN8) | PIN_OSPEED_VERYLOW(GPIOD_PIN9) | PIN_OSPEED_VERYLOW(GPIOD_PIN10) | PIN_OSPEED_VERYLOW(GPIOD_PIN11) | PIN_OSPEED_VERYLOW(GPIOD_PIN12) | PIN_OSPEED_VERYLOW(GPIOD_PIN13) | PIN_OSPEED_VERYLOW(GPIOD_PIN14) | PIN_OSPEED_VERYLOW(GPIOD_PIN15)) -#define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLUP(GPIOD_PIN0) | PIN_PUPDR_PULLUP(GPIOD_PIN1) | PIN_PUPDR_PULLUP(GPIOD_PIN2) | PIN_PUPDR_PULLUP(GPIOD_PIN3) | PIN_PUPDR_PULLUP(GPIOD_PIN4) | PIN_PUPDR_PULLUP(GPIOD_PIN5) | PIN_PUPDR_PULLUP(GPIOD_PIN6) | PIN_PUPDR_PULLUP(GPIOD_PIN7) | PIN_PUPDR_PULLUP(GPIOD_PIN8) | PIN_PUPDR_PULLUP(GPIOD_PIN9) | PIN_PUPDR_PULLUP(GPIOD_PIN10) | PIN_PUPDR_PULLUP(GPIOD_PIN11) | PIN_PUPDR_PULLUP(GPIOD_PIN12) | PIN_PUPDR_PULLUP(GPIOD_PIN13) | PIN_PUPDR_PULLUP(GPIOD_PIN14) | PIN_PUPDR_PULLUP(GPIOD_PIN15)) -#define VAL_GPIOD_ODR (PIN_ODR_HIGH(GPIOD_PIN0) | PIN_ODR_HIGH(GPIOD_PIN1) | PIN_ODR_HIGH(GPIOD_PIN2) | PIN_ODR_HIGH(GPIOD_PIN3) | PIN_ODR_HIGH(GPIOD_PIN4) | PIN_ODR_HIGH(GPIOD_PIN5) | PIN_ODR_HIGH(GPIOD_PIN6) | PIN_ODR_HIGH(GPIOD_PIN7) | PIN_ODR_HIGH(GPIOD_PIN8) | PIN_ODR_HIGH(GPIOD_PIN9) | PIN_ODR_HIGH(GPIOD_PIN10) | PIN_ODR_HIGH(GPIOD_PIN11) | PIN_ODR_HIGH(GPIOD_PIN12) | PIN_ODR_HIGH(GPIOD_PIN13) | PIN_ODR_HIGH(GPIOD_PIN14) | PIN_ODR_HIGH(GPIOD_PIN15)) -#define VAL_GPIOD_AFRL (PIN_AFIO_AF(GPIOD_PIN0, 0) | PIN_AFIO_AF(GPIOD_PIN1, 0) | PIN_AFIO_AF(GPIOD_PIN2, 0) | PIN_AFIO_AF(GPIOD_PIN3, 0) | PIN_AFIO_AF(GPIOD_PIN4, 0) | PIN_AFIO_AF(GPIOD_PIN5, 0) | PIN_AFIO_AF(GPIOD_PIN6, 0) | PIN_AFIO_AF(GPIOD_PIN7, 0)) -#define VAL_GPIOD_AFRH (PIN_AFIO_AF(GPIOD_PIN8, 0) | PIN_AFIO_AF(GPIOD_PIN9, 0) | PIN_AFIO_AF(GPIOD_PIN10, 0) | PIN_AFIO_AF(GPIOD_PIN11, 0) | PIN_AFIO_AF(GPIOD_PIN12, 0) | PIN_AFIO_AF(GPIOD_PIN13, 0) | PIN_AFIO_AF(GPIOD_PIN14, 0) | PIN_AFIO_AF(GPIOD_PIN15, 0)) - -/* - * GPIOE setup: - * - * PE0 - PIN0 (input pullup). - * PE1 - PIN1 (input pullup). - * PE2 - PIN2 (input pullup). - * PE3 - PIN3 L3GD20_CS (output pushpull maximum). - * PE4 - PIN4 (input pullup). - * PE5 - PIN5 (input pullup). - * PE6 - PIN6 (input pullup). - * PE7 - PIN7 (input pullup). - * PE8 - PIN8 (output pushpull maximum). - * PE9 - PIN9 (output pushpull maximum). - * PE10 - PIN10 (output pushpull maximum). - * PE11 - PIN11 (output pushpull maximum). - * PE12 - PIN12 (output pushpull maximum). - * PE13 - PIN13 (output pushpull maximum). - * PE14 - PIN14 (output pushpull maximum). - * PE15 - PIN15 (output pushpull maximum). - */ -#define VAL_GPIOE_MODER (PIN_MODE_INPUT(GPIOE_PIN0) | PIN_MODE_INPUT(GPIOE_PIN1) | PIN_MODE_INPUT(GPIOE_PIN2) | PIN_MODE_OUTPUT(GPIOE_PIN3) | PIN_MODE_INPUT(GPIOE_PIN4) | PIN_MODE_INPUT(GPIOE_PIN5) | PIN_MODE_INPUT(GPIOE_PIN6) | PIN_MODE_INPUT(GPIOE_PIN7) | PIN_MODE_OUTPUT(GPIOE_PIN8) | PIN_MODE_OUTPUT(GPIOE_PIN9) | PIN_MODE_OUTPUT(GPIOE_PIN10) | PIN_MODE_OUTPUT(GPIOE_PIN11) | PIN_MODE_OUTPUT(GPIOE_PIN12) | PIN_MODE_OUTPUT(GPIOE_PIN13) | PIN_MODE_OUTPUT(GPIOE_PIN14) | PIN_MODE_OUTPUT(GPIOE_PIN15)) -#define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL(GPIOE_PIN0) | PIN_OTYPE_PUSHPULL(GPIOE_PIN1) | PIN_OTYPE_PUSHPULL(GPIOE_PIN2) | PIN_OTYPE_PUSHPULL(GPIOE_PIN3) | PIN_OTYPE_PUSHPULL(GPIOE_PIN4) | PIN_OTYPE_PUSHPULL(GPIOE_PIN5) | PIN_OTYPE_PUSHPULL(GPIOE_PIN6) | PIN_OTYPE_PUSHPULL(GPIOE_PIN7) | PIN_OTYPE_PUSHPULL(GPIOE_PIN8) | PIN_OTYPE_PUSHPULL(GPIOE_PIN9) | PIN_OTYPE_PUSHPULL(GPIOE_PIN10) | PIN_OTYPE_PUSHPULL(GPIOE_PIN11) | PIN_OTYPE_PUSHPULL(GPIOE_PIN12) | PIN_OTYPE_PUSHPULL(GPIOE_PIN13) | PIN_OTYPE_PUSHPULL(GPIOE_PIN14) | PIN_OTYPE_PUSHPULL(GPIOE_PIN15)) -#define VAL_GPIOE_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOE_PIN0) | PIN_OSPEED_VERYLOW(GPIOE_PIN1) | PIN_OSPEED_VERYLOW(GPIOE_PIN2) | PIN_OSPEED_HIGH(GPIOE_PIN3) | PIN_OSPEED_VERYLOW(GPIOE_PIN4) | PIN_OSPEED_VERYLOW(GPIOE_PIN5) | PIN_OSPEED_VERYLOW(GPIOE_PIN6) | PIN_OSPEED_VERYLOW(GPIOE_PIN7) | PIN_OSPEED_HIGH(GPIOE_PIN8) | PIN_OSPEED_HIGH(GPIOE_PIN9) | PIN_OSPEED_HIGH(GPIOE_PIN10) | PIN_OSPEED_HIGH(GPIOE_PIN11) | PIN_OSPEED_HIGH(GPIOE_PIN12) | PIN_OSPEED_HIGH(GPIOE_PIN13) | PIN_OSPEED_HIGH(GPIOE_PIN14) | PIN_OSPEED_HIGH(GPIOE_PIN15)) -#define VAL_GPIOE_PUPDR (PIN_PUPDR_PULLUP(GPIOE_PIN0) | PIN_PUPDR_PULLUP(GPIOE_PIN1) | PIN_PUPDR_PULLUP(GPIOE_PIN2) | PIN_PUPDR_FLOATING(GPIOE_PIN3) | PIN_PUPDR_PULLUP(GPIOE_PIN4) | PIN_PUPDR_PULLUP(GPIOE_PIN5) | PIN_PUPDR_PULLUP(GPIOE_PIN6) | PIN_PUPDR_PULLUP(GPIOE_PIN7) | PIN_PUPDR_PULLUP(GPIOE_PIN8) | PIN_PUPDR_PULLUP(GPIOE_PIN9) | PIN_PUPDR_PULLUP(GPIOE_PIN10) | PIN_PUPDR_FLOATING(GPIOE_PIN11) | PIN_PUPDR_PULLUP(GPIOE_PIN12) | PIN_PUPDR_FLOATING(GPIOE_PIN13) | PIN_PUPDR_FLOATING(GPIOE_PIN14) | PIN_PUPDR_FLOATING(GPIOE_PIN15)) -#define VAL_GPIOE_ODR (PIN_ODR_HIGH(GPIOE_PIN0) | PIN_ODR_HIGH(GPIOE_PIN1) | PIN_ODR_HIGH(GPIOE_PIN2) | PIN_ODR_HIGH(GPIOE_PIN3) | PIN_ODR_HIGH(GPIOE_PIN4) | PIN_ODR_HIGH(GPIOE_PIN5) | PIN_ODR_HIGH(GPIOE_PIN6) | PIN_ODR_HIGH(GPIOE_PIN7) | PIN_ODR_LOW(GPIOE_PIN8) | PIN_ODR_LOW(GPIOE_PIN9) | PIN_ODR_LOW(GPIOE_PIN10) | PIN_ODR_LOW(GPIOE_PIN11) | PIN_ODR_LOW(GPIOE_PIN12) | PIN_ODR_LOW(GPIOE_PIN13) | PIN_ODR_LOW(GPIOE_PIN14) | PIN_ODR_LOW(GPIOE_PIN15)) -#define VAL_GPIOE_AFRL (PIN_AFIO_AF(GPIOE_PIN0, 0) | PIN_AFIO_AF(GPIOE_PIN1, 0) | PIN_AFIO_AF(GPIOE_PIN2, 0) | PIN_AFIO_AF(GPIOE_PIN3, 0) | PIN_AFIO_AF(GPIOE_PIN4, 0) | PIN_AFIO_AF(GPIOE_PIN5, 0) | PIN_AFIO_AF(GPIOE_PIN6, 0) | PIN_AFIO_AF(GPIOE_PIN7, 0)) -#define VAL_GPIOE_AFRH (PIN_AFIO_AF(GPIOE_PIN8, 0) | PIN_AFIO_AF(GPIOE_PIN9, 0) | PIN_AFIO_AF(GPIOE_PIN10, 0) | PIN_AFIO_AF(GPIOE_PIN11, 0) | PIN_AFIO_AF(GPIOE_PIN12, 0) | PIN_AFIO_AF(GPIOE_PIN13, 0) | PIN_AFIO_AF(GPIOE_PIN14, 0) | PIN_AFIO_AF(GPIOE_PIN15, 0)) - -/* - * GPIOF setup: - * - * PF0 - I2C2_SDA (input floating). - * PF1 - I2C2_SCL (input floating). - * PF2 - PIN2 (input pullup). - * PF3 - PIN3 (input pullup). - * PF4 - PIN4 (input pullup). - * PF5 - PIN5 (input pullup). - * PF6 - PIN6 (input pullup). - * PF7 - PIN7 (input pullup). - * PF8 - PIN8 (input pullup). - * PF9 - PIN9 (input pullup). - * PF10 - PIN10 (input pullup). - * PF11 - PIN11 (input pullup). - * PF12 - PIN12 (input pullup). - * PF13 - PIN13 (input pullup). - * PF14 - PIN14 (input pullup). - * PF15 - PIN15 (input pullup). - */ -#define VAL_GPIOF_MODER (PIN_MODE_INPUT(GPIOF_I2C2_SDA) | PIN_MODE_INPUT(GPIOF_I2C2_SCL) | PIN_MODE_INPUT(GPIOF_PIN2) | PIN_MODE_INPUT(GPIOF_PIN3) | PIN_MODE_INPUT(GPIOF_PIN4) | PIN_MODE_INPUT(GPIOF_PIN5) | PIN_MODE_INPUT(GPIOF_PIN6) | PIN_MODE_INPUT(GPIOF_PIN7) | PIN_MODE_INPUT(GPIOF_PIN8) | PIN_MODE_INPUT(GPIOF_PIN9) | PIN_MODE_INPUT(GPIOF_PIN10) | PIN_MODE_INPUT(GPIOF_PIN11) | PIN_MODE_INPUT(GPIOF_PIN12) | PIN_MODE_INPUT(GPIOF_PIN13) | PIN_MODE_INPUT(GPIOF_PIN14) | PIN_MODE_INPUT(GPIOF_PIN15)) -#define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL(GPIOF_I2C2_SDA) | PIN_OTYPE_PUSHPULL(GPIOF_I2C2_SCL) | PIN_OTYPE_PUSHPULL(GPIOF_PIN2) | PIN_OTYPE_PUSHPULL(GPIOF_PIN3) | PIN_OTYPE_PUSHPULL(GPIOF_PIN4) | PIN_OTYPE_PUSHPULL(GPIOF_PIN5) | PIN_OTYPE_PUSHPULL(GPIOF_PIN6) | PIN_OTYPE_PUSHPULL(GPIOF_PIN7) | PIN_OTYPE_PUSHPULL(GPIOF_PIN8) | PIN_OTYPE_PUSHPULL(GPIOF_PIN9) | PIN_OTYPE_PUSHPULL(GPIOF_PIN10) | PIN_OTYPE_PUSHPULL(GPIOF_PIN11) | PIN_OTYPE_PUSHPULL(GPIOF_PIN12) | PIN_OTYPE_PUSHPULL(GPIOF_PIN13) | PIN_OTYPE_PUSHPULL(GPIOF_PIN14) | PIN_OTYPE_PUSHPULL(GPIOF_PIN15)) -#define VAL_GPIOF_OSPEEDR (PIN_OSPEED_HIGH(GPIOF_I2C2_SDA) | PIN_OSPEED_HIGH(GPIOF_I2C2_SCL) | PIN_OSPEED_VERYLOW(GPIOF_PIN2) | PIN_OSPEED_VERYLOW(GPIOF_PIN3) | PIN_OSPEED_VERYLOW(GPIOF_PIN4) | PIN_OSPEED_VERYLOW(GPIOF_PIN5) | PIN_OSPEED_VERYLOW(GPIOF_PIN6) | PIN_OSPEED_VERYLOW(GPIOF_PIN7) | PIN_OSPEED_VERYLOW(GPIOF_PIN8) | PIN_OSPEED_VERYLOW(GPIOF_PIN9) | PIN_OSPEED_VERYLOW(GPIOF_PIN10) | PIN_OSPEED_VERYLOW(GPIOF_PIN11) | PIN_OSPEED_VERYLOW(GPIOF_PIN12) | PIN_OSPEED_VERYLOW(GPIOF_PIN13) | PIN_OSPEED_VERYLOW(GPIOF_PIN14) | PIN_OSPEED_VERYLOW(GPIOF_PIN15)) -#define VAL_GPIOF_PUPDR (PIN_PUPDR_FLOATING(GPIOF_I2C2_SDA) | PIN_PUPDR_FLOATING(GPIOF_I2C2_SCL) | PIN_PUPDR_PULLUP(GPIOF_PIN2) | PIN_PUPDR_PULLUP(GPIOF_PIN3) | PIN_PUPDR_PULLUP(GPIOF_PIN4) | PIN_PUPDR_PULLUP(GPIOF_PIN5) | PIN_PUPDR_PULLUP(GPIOF_PIN6) | PIN_PUPDR_PULLUP(GPIOF_PIN7) | PIN_PUPDR_PULLUP(GPIOF_PIN8) | PIN_PUPDR_PULLUP(GPIOF_PIN9) | PIN_PUPDR_PULLUP(GPIOF_PIN10) | PIN_PUPDR_PULLUP(GPIOF_PIN11) | PIN_PUPDR_PULLUP(GPIOF_PIN12) | PIN_PUPDR_PULLUP(GPIOF_PIN13) | PIN_PUPDR_PULLUP(GPIOF_PIN14) | PIN_PUPDR_PULLUP(GPIOF_PIN15)) -#define VAL_GPIOF_ODR (PIN_ODR_HIGH(GPIOF_I2C2_SDA) | PIN_ODR_HIGH(GPIOF_I2C2_SCL) | PIN_ODR_HIGH(GPIOF_PIN2) | PIN_ODR_HIGH(GPIOF_PIN3) | PIN_ODR_HIGH(GPIOF_PIN4) | PIN_ODR_HIGH(GPIOF_PIN5) | PIN_ODR_HIGH(GPIOF_PIN6) | PIN_ODR_HIGH(GPIOF_PIN7) | PIN_ODR_HIGH(GPIOF_PIN8) | PIN_ODR_HIGH(GPIOF_PIN9) | PIN_ODR_HIGH(GPIOF_PIN10) | PIN_ODR_HIGH(GPIOF_PIN11) | PIN_ODR_HIGH(GPIOF_PIN12) | PIN_ODR_HIGH(GPIOF_PIN13) | PIN_ODR_HIGH(GPIOF_PIN14) | PIN_ODR_HIGH(GPIOF_PIN15)) -#define VAL_GPIOF_AFRL (PIN_AFIO_AF(GPIOF_I2C2_SDA, 0) | PIN_AFIO_AF(GPIOF_I2C2_SCL, 0) | PIN_AFIO_AF(GPIOF_PIN2, 0) | PIN_AFIO_AF(GPIOF_PIN3, 0) | PIN_AFIO_AF(GPIOF_PIN4, 0) | PIN_AFIO_AF(GPIOF_PIN5, 0) | PIN_AFIO_AF(GPIOF_PIN6, 0) | PIN_AFIO_AF(GPIOF_PIN7, 0)) -#define VAL_GPIOF_AFRH (PIN_AFIO_AF(GPIOF_PIN8, 0) | PIN_AFIO_AF(GPIOF_PIN9, 0) | PIN_AFIO_AF(GPIOF_PIN10, 0) | PIN_AFIO_AF(GPIOF_PIN11, 0) | PIN_AFIO_AF(GPIOF_PIN12, 0) | PIN_AFIO_AF(GPIOF_PIN13, 0) | PIN_AFIO_AF(GPIOF_PIN14, 0) | PIN_AFIO_AF(GPIOF_PIN15, 0)) - -/* - * GPIOG setup: - * - * PG0 - PIN0 (input pullup). - * PG1 - PIN1 (input pullup). - * PG2 - PIN2 (input pullup). - * PG3 - PIN3 (input pullup). - * PG4 - PIN4 (input pullup). - * PG5 - PIN5 (input pullup). - * PG6 - PIN6 (input pullup). - * PG7 - PIN7 (input pullup). - * PG8 - PIN8 (input pullup). - * PG9 - PIN9 (input pullup). - * PG10 - PIN10 (input pullup). - * PG11 - PIN11 (input pullup). - * PG12 - PIN12 (input pullup). - * PG13 - PIN13 (input pullup). - * PG14 - PIN14 (input pullup). - * PG15 - PIN15 (input pullup). - */ -#define VAL_GPIOG_MODER (PIN_MODE_INPUT(GPIOG_PIN0) | PIN_MODE_INPUT(GPIOG_PIN1) | PIN_MODE_INPUT(GPIOG_PIN2) | PIN_MODE_INPUT(GPIOG_PIN3) | PIN_MODE_INPUT(GPIOG_PIN4) | PIN_MODE_INPUT(GPIOG_PIN5) | PIN_MODE_INPUT(GPIOG_PIN6) | PIN_MODE_INPUT(GPIOG_PIN7) | PIN_MODE_INPUT(GPIOG_PIN8) | PIN_MODE_INPUT(GPIOG_PIN9) | PIN_MODE_INPUT(GPIOG_PIN10) | PIN_MODE_INPUT(GPIOG_PIN11) | PIN_MODE_INPUT(GPIOG_PIN12) | PIN_MODE_INPUT(GPIOG_PIN13) | PIN_MODE_INPUT(GPIOG_PIN14) | PIN_MODE_INPUT(GPIOG_PIN15)) -#define VAL_GPIOG_OTYPER (PIN_OTYPE_PUSHPULL(GPIOG_PIN0) | PIN_OTYPE_PUSHPULL(GPIOG_PIN1) | PIN_OTYPE_PUSHPULL(GPIOG_PIN2) | PIN_OTYPE_PUSHPULL(GPIOG_PIN3) | PIN_OTYPE_PUSHPULL(GPIOG_PIN4) | PIN_OTYPE_PUSHPULL(GPIOG_PIN5) | PIN_OTYPE_PUSHPULL(GPIOG_PIN6) | PIN_OTYPE_PUSHPULL(GPIOG_PIN7) | PIN_OTYPE_PUSHPULL(GPIOG_PIN8) | PIN_OTYPE_PUSHPULL(GPIOG_PIN9) | PIN_OTYPE_PUSHPULL(GPIOG_PIN10) | PIN_OTYPE_PUSHPULL(GPIOG_PIN11) | PIN_OTYPE_PUSHPULL(GPIOG_PIN12) | PIN_OTYPE_PUSHPULL(GPIOG_PIN13) | PIN_OTYPE_PUSHPULL(GPIOG_PIN14) | PIN_OTYPE_PUSHPULL(GPIOG_PIN15)) -#define VAL_GPIOG_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOG_PIN0) | PIN_OSPEED_VERYLOW(GPIOG_PIN1) | PIN_OSPEED_VERYLOW(GPIOG_PIN2) | PIN_OSPEED_VERYLOW(GPIOG_PIN3) | PIN_OSPEED_VERYLOW(GPIOG_PIN4) | PIN_OSPEED_VERYLOW(GPIOG_PIN5) | PIN_OSPEED_VERYLOW(GPIOG_PIN6) | PIN_OSPEED_VERYLOW(GPIOG_PIN7) | PIN_OSPEED_VERYLOW(GPIOG_PIN8) | PIN_OSPEED_VERYLOW(GPIOG_PIN9) | PIN_OSPEED_VERYLOW(GPIOG_PIN10) | PIN_OSPEED_VERYLOW(GPIOG_PIN11) | PIN_OSPEED_VERYLOW(GPIOG_PIN12) | PIN_OSPEED_VERYLOW(GPIOG_PIN13) | PIN_OSPEED_VERYLOW(GPIOG_PIN14) | PIN_OSPEED_VERYLOW(GPIOG_PIN15)) -#define VAL_GPIOG_PUPDR (PIN_PUPDR_PULLUP(GPIOG_PIN0) | PIN_PUPDR_PULLUP(GPIOG_PIN1) | PIN_PUPDR_PULLUP(GPIOG_PIN2) | PIN_PUPDR_PULLUP(GPIOG_PIN3) | PIN_PUPDR_PULLUP(GPIOG_PIN4) | PIN_PUPDR_PULLUP(GPIOG_PIN5) | PIN_PUPDR_PULLUP(GPIOG_PIN6) | PIN_PUPDR_PULLUP(GPIOG_PIN7) | PIN_PUPDR_PULLUP(GPIOG_PIN8) | PIN_PUPDR_PULLUP(GPIOG_PIN9) | PIN_PUPDR_PULLUP(GPIOG_PIN10) | PIN_PUPDR_PULLUP(GPIOG_PIN11) | PIN_PUPDR_PULLUP(GPIOG_PIN12) | PIN_PUPDR_PULLUP(GPIOG_PIN13) | PIN_PUPDR_PULLUP(GPIOG_PIN14) | PIN_PUPDR_PULLUP(GPIOG_PIN15)) -#define VAL_GPIOG_ODR (PIN_ODR_HIGH(GPIOG_PIN0) | PIN_ODR_HIGH(GPIOG_PIN1) | PIN_ODR_HIGH(GPIOG_PIN2) | PIN_ODR_HIGH(GPIOG_PIN3) | PIN_ODR_HIGH(GPIOG_PIN4) | PIN_ODR_HIGH(GPIOG_PIN5) | PIN_ODR_HIGH(GPIOG_PIN6) | PIN_ODR_HIGH(GPIOG_PIN7) | PIN_ODR_HIGH(GPIOG_PIN8) | PIN_ODR_HIGH(GPIOG_PIN9) | PIN_ODR_HIGH(GPIOG_PIN10) | PIN_ODR_HIGH(GPIOG_PIN11) | PIN_ODR_HIGH(GPIOG_PIN12) | PIN_ODR_HIGH(GPIOG_PIN13) | PIN_ODR_HIGH(GPIOG_PIN14) | PIN_ODR_HIGH(GPIOG_PIN15)) -#define VAL_GPIOG_AFRL (PIN_AFIO_AF(GPIOG_PIN0, 0) | PIN_AFIO_AF(GPIOG_PIN1, 0) | PIN_AFIO_AF(GPIOG_PIN2, 0) | PIN_AFIO_AF(GPIOG_PIN3, 0) | PIN_AFIO_AF(GPIOG_PIN4, 0) | PIN_AFIO_AF(GPIOG_PIN5, 0) | PIN_AFIO_AF(GPIOG_PIN6, 0) | PIN_AFIO_AF(GPIOG_PIN7, 0)) -#define VAL_GPIOG_AFRH (PIN_AFIO_AF(GPIOG_PIN8, 0) | PIN_AFIO_AF(GPIOG_PIN9, 0) | PIN_AFIO_AF(GPIOG_PIN10, 0) | PIN_AFIO_AF(GPIOG_PIN11, 0) | PIN_AFIO_AF(GPIOG_PIN12, 0) | PIN_AFIO_AF(GPIOG_PIN13, 0) | PIN_AFIO_AF(GPIOG_PIN14, 0) | PIN_AFIO_AF(GPIOG_PIN15, 0)) - -/* - * GPIOH setup: - * - * PH0 - PIN0 (input pullup). - * PH1 - PIN1 (input pullup). - * PH2 - PIN2 (input pullup). - * PH3 - PIN3 (input pullup). - * PH4 - PIN4 (input pullup). - * PH5 - PIN5 (input pullup). - * PH6 - PIN6 (input pullup). - * PH7 - PIN7 (input pullup). - * PH8 - PIN8 (input pullup). - * PH9 - PIN9 (input pullup). - * PH10 - PIN10 (input pullup). - * PH11 - PIN11 (input pullup). - * PH12 - PIN12 (input pullup). - * PH13 - PIN13 (input pullup). - * PH14 - PIN14 (input pullup). - * PH15 - PIN15 (input pullup). - */ -#define VAL_GPIOH_MODER (PIN_MODE_INPUT(GPIOH_PIN0) | PIN_MODE_INPUT(GPIOH_PIN1) | PIN_MODE_INPUT(GPIOH_PIN2) | PIN_MODE_INPUT(GPIOH_PIN3) | PIN_MODE_INPUT(GPIOH_PIN4) | PIN_MODE_INPUT(GPIOH_PIN5) | PIN_MODE_INPUT(GPIOH_PIN6) | PIN_MODE_INPUT(GPIOH_PIN7) | PIN_MODE_INPUT(GPIOH_PIN8) | PIN_MODE_INPUT(GPIOH_PIN9) | PIN_MODE_INPUT(GPIOH_PIN10) | PIN_MODE_INPUT(GPIOH_PIN11) | PIN_MODE_INPUT(GPIOH_PIN12) | PIN_MODE_INPUT(GPIOH_PIN13) | PIN_MODE_INPUT(GPIOH_PIN14) | PIN_MODE_INPUT(GPIOH_PIN15)) -#define VAL_GPIOH_OTYPER (PIN_OTYPE_PUSHPULL(GPIOH_PIN0) | PIN_OTYPE_PUSHPULL(GPIOH_PIN1) | PIN_OTYPE_PUSHPULL(GPIOH_PIN2) | PIN_OTYPE_PUSHPULL(GPIOH_PIN3) | PIN_OTYPE_PUSHPULL(GPIOH_PIN4) | PIN_OTYPE_PUSHPULL(GPIOH_PIN5) | PIN_OTYPE_PUSHPULL(GPIOH_PIN6) | PIN_OTYPE_PUSHPULL(GPIOH_PIN7) | PIN_OTYPE_PUSHPULL(GPIOH_PIN8) | PIN_OTYPE_PUSHPULL(GPIOH_PIN9) | PIN_OTYPE_PUSHPULL(GPIOH_PIN10) | PIN_OTYPE_PUSHPULL(GPIOH_PIN11) | PIN_OTYPE_PUSHPULL(GPIOH_PIN12) | PIN_OTYPE_PUSHPULL(GPIOH_PIN13) | PIN_OTYPE_PUSHPULL(GPIOH_PIN14) | PIN_OTYPE_PUSHPULL(GPIOH_PIN15)) -#define VAL_GPIOH_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOH_PIN0) | PIN_OSPEED_VERYLOW(GPIOH_PIN1) | PIN_OSPEED_VERYLOW(GPIOH_PIN2) | PIN_OSPEED_VERYLOW(GPIOH_PIN3) | PIN_OSPEED_VERYLOW(GPIOH_PIN4) | PIN_OSPEED_VERYLOW(GPIOH_PIN5) | PIN_OSPEED_VERYLOW(GPIOH_PIN6) | PIN_OSPEED_VERYLOW(GPIOH_PIN7) | PIN_OSPEED_VERYLOW(GPIOH_PIN8) | PIN_OSPEED_VERYLOW(GPIOH_PIN9) | PIN_OSPEED_VERYLOW(GPIOH_PIN10) | PIN_OSPEED_VERYLOW(GPIOH_PIN11) | PIN_OSPEED_VERYLOW(GPIOH_PIN12) | PIN_OSPEED_VERYLOW(GPIOH_PIN13) | PIN_OSPEED_VERYLOW(GPIOH_PIN14) | PIN_OSPEED_VERYLOW(GPIOH_PIN15)) -#define VAL_GPIOH_PUPDR (PIN_PUPDR_PULLUP(GPIOH_PIN0) | PIN_PUPDR_PULLUP(GPIOH_PIN1) | PIN_PUPDR_PULLUP(GPIOH_PIN2) | PIN_PUPDR_PULLUP(GPIOH_PIN3) | PIN_PUPDR_PULLUP(GPIOH_PIN4) | PIN_PUPDR_PULLUP(GPIOH_PIN5) | PIN_PUPDR_PULLUP(GPIOH_PIN6) | PIN_PUPDR_PULLUP(GPIOH_PIN7) | PIN_PUPDR_PULLUP(GPIOH_PIN8) | PIN_PUPDR_PULLUP(GPIOH_PIN9) | PIN_PUPDR_PULLUP(GPIOH_PIN10) | PIN_PUPDR_PULLUP(GPIOH_PIN11) | PIN_PUPDR_PULLUP(GPIOH_PIN12) | PIN_PUPDR_PULLUP(GPIOH_PIN13) | PIN_PUPDR_PULLUP(GPIOH_PIN14) | PIN_PUPDR_PULLUP(GPIOH_PIN15)) -#define VAL_GPIOH_ODR (PIN_ODR_HIGH(GPIOH_PIN0) | PIN_ODR_HIGH(GPIOH_PIN1) | PIN_ODR_HIGH(GPIOH_PIN2) | PIN_ODR_HIGH(GPIOH_PIN3) | PIN_ODR_HIGH(GPIOH_PIN4) | PIN_ODR_HIGH(GPIOH_PIN5) | PIN_ODR_HIGH(GPIOH_PIN6) | PIN_ODR_HIGH(GPIOH_PIN7) | PIN_ODR_HIGH(GPIOH_PIN8) | PIN_ODR_HIGH(GPIOH_PIN9) | PIN_ODR_HIGH(GPIOH_PIN10) | PIN_ODR_HIGH(GPIOH_PIN11) | PIN_ODR_HIGH(GPIOH_PIN12) | PIN_ODR_HIGH(GPIOH_PIN13) | PIN_ODR_HIGH(GPIOH_PIN14) | PIN_ODR_HIGH(GPIOH_PIN15)) -#define VAL_GPIOH_AFRL (PIN_AFIO_AF(GPIOH_PIN0, 0) | PIN_AFIO_AF(GPIOH_PIN1, 0) | PIN_AFIO_AF(GPIOH_PIN2, 0) | PIN_AFIO_AF(GPIOH_PIN3, 0) | PIN_AFIO_AF(GPIOH_PIN4, 0) | PIN_AFIO_AF(GPIOH_PIN5, 0) | PIN_AFIO_AF(GPIOH_PIN6, 0) | PIN_AFIO_AF(GPIOH_PIN7, 0)) -#define VAL_GPIOH_AFRH (PIN_AFIO_AF(GPIOH_PIN8, 0) | PIN_AFIO_AF(GPIOH_PIN9, 0) | PIN_AFIO_AF(GPIOH_PIN10, 0) | PIN_AFIO_AF(GPIOH_PIN11, 0) | PIN_AFIO_AF(GPIOH_PIN12, 0) | PIN_AFIO_AF(GPIOH_PIN13, 0) | PIN_AFIO_AF(GPIOH_PIN14, 0) | PIN_AFIO_AF(GPIOH_PIN15, 0)) - -/* - * USB bus activation macro, required by the USB driver. - */ -// #define usb_lld_connect_bus(usbp) -#define usb_lld_connect_bus(usbp) (palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_ALTERNATE(14))) -// #define usb_lld_connect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_INPUT) -/* - * USB bus de-activation macro, required by the USB driver. - */ -// #define usb_lld_disconnect_bus(usbp) -#define usb_lld_disconnect_bus(usbp) \ - (palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_OUTPUT_PUSHPULL)); \ - palClearPad(GPIOA, GPIOA_USB_DP) -// #define usb_lld_disconnect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(GPIOA, 12) - -#if !defined(_FROM_ASM_) -# ifdef __cplusplus -extern "C" { -# endif -void boardInit(void); -# ifdef __cplusplus -} -# endif -#endif /* _FROM_ASM_ */ - -#endif /* _BOARD_H_ */ diff --git a/platforms/chibios/GENERIC_STM32_F303XC/board/board.mk b/platforms/chibios/GENERIC_STM32_F303XC/board/board.mk index 842e33590594..f891e6524763 100644 --- a/platforms/chibios/GENERIC_STM32_F303XC/board/board.mk +++ b/platforms/chibios/GENERIC_STM32_F303XC/board/board.mk @@ -1,8 +1,8 @@ # List of all the board related files. -BOARDSRC = $(BOARD_PATH)/board/board.c +BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_STM32F3_DISCOVERY/board.c # Required include directories -BOARDINC = $(BOARD_PATH)/board +BOARDINC = $(CHIBIOS)/os/hal/boards/ST_STM32F3_DISCOVERY # Shared variables ALLCSRC += $(BOARDSRC) diff --git a/platforms/chibios/GENERIC_STM32_F303XC/configs/board.h b/platforms/chibios/GENERIC_STM32_F303XC/configs/board.h new file mode 100644 index 000000000000..97159964d054 --- /dev/null +++ b/platforms/chibios/GENERIC_STM32_F303XC/configs/board.h @@ -0,0 +1,37 @@ +/* Copyright 2020 Nick Brassel (tzarc) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#include_next "board.h" + +#undef STM32_HSE_BYPASS + +/* + * USB bus activation macro, required by the USB driver. + */ +#define usb_lld_connect_bus(usbp) \ + do { \ + palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_ALTERNATE(14)); \ + } while (0) + +/* + * USB bus de-activation macro, required by the USB driver. + */ +#define usb_lld_disconnect_bus(usbp) \ + do { \ + palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_OUTPUT_PUSHPULL); \ + palClearPad(GPIOA, GPIOA_USB_DP); \ + } while (0) diff --git a/platforms/chibios/GENERIC_STM32_F303XC/configs/config.h b/platforms/chibios/GENERIC_STM32_F303XC/configs/config.h new file mode 100644 index 000000000000..48a7a900930a --- /dev/null +++ b/platforms/chibios/GENERIC_STM32_F303XC/configs/config.h @@ -0,0 +1,18 @@ +/* Copyright 2020 Nick Brassel (tzarc) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE From 31a0264443255d296322ab703f9628c5cd6ba611 Mon Sep 17 00:00:00 2001 From: dhong44 Date: Thu, 16 Jul 2020 02:47:43 -0400 Subject: [PATCH 14/54] Fix the mousekey scrolling (#9174) Mousekey scrolling should have a separate repeat variable to keep track of scrolling acceleration, instead of being tied to mouse movement scolling in mousekeys. The send function should record when the last movement was made since this is when movement is actually sent. Doing this fixes the bug where the initial press of a mousekey scroll button causes a double scroll. Signed-off-by: Daniel Hong --- tmk_core/common/mousekey.c | 82 ++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/tmk_core/common/mousekey.c b/tmk_core/common/mousekey.c index 42bf231f4c19..390c74e0f147 100644 --- a/tmk_core/common/mousekey.c +++ b/tmk_core/common/mousekey.c @@ -35,7 +35,7 @@ static report_mouse_t mouse_report = {0}; static void mousekey_debug(void); static uint8_t mousekey_accel = 0; static uint8_t mousekey_repeat = 0; -static uint16_t last_timer = 0; +static uint8_t mousekey_wheel_repeat = 0; #ifndef MK_3_SPEED @@ -94,12 +94,12 @@ static uint8_t wheel_unit(void) { unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed) / 2; } else if (mousekey_accel & (1 << 2)) { unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed); - } else if (mousekey_repeat == 0) { + } else if (mousekey_wheel_repeat == 0) { unit = MOUSEKEY_WHEEL_DELTA; - } else if (mousekey_repeat >= mk_wheel_time_to_max) { + } else if (mousekey_wheel_repeat >= mk_wheel_time_to_max) { unit = MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed; } else { - unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed * mousekey_repeat) / mk_wheel_time_to_max; + unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed * mousekey_wheel_repeat) / mk_wheel_time_to_max; } return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit)); } @@ -147,14 +147,17 @@ static uint8_t wheel_unit(void) { void mousekey_task(void) { // report cursor and scroll movement independently report_mouse_t const tmpmr = mouse_report; - if ((mouse_report.x || mouse_report.y) && timer_elapsed(last_timer_c) > (mousekey_repeat ? mk_interval : mk_delay * 10)) { + + mouse_report.x = 0; + mouse_report.y = 0; + mouse_report.v = 0; + mouse_report.h = 0; + + if ((tmpmr.x || tmpmr.y) && timer_elapsed(last_timer_c) > (mousekey_repeat ? mk_interval : mk_delay * 10)) { if (mousekey_repeat != UINT8_MAX) mousekey_repeat++; - mouse_report.v = 0; - mouse_report.h = 0; - if (mouse_report.x > 0) mouse_report.x = move_unit(); - if (mouse_report.x < 0) mouse_report.x = move_unit() * -1; - if (mouse_report.y > 0) mouse_report.y = move_unit(); - if (mouse_report.y < 0) mouse_report.y = move_unit() * -1; + if (tmpmr.x != 0) mouse_report.x = move_unit() * ((tmpmr.x > 0) ? 1 : -1); + if (tmpmr.y != 0) mouse_report.y = move_unit() * ((tmpmr.y > 0) ? 1 : -1); + /* diagonal move [1/sqrt(2)] */ if (mouse_report.x && mouse_report.y) { mouse_report.x = times_inv_sqrt2(mouse_report.x); @@ -166,18 +169,12 @@ void mousekey_task(void) { mouse_report.y = 1; } } - mousekey_send(); - last_timer_c = last_timer; - mouse_report = tmpmr; } - if ((mouse_report.v || mouse_report.h) && timer_elapsed(last_timer_w) > (mousekey_repeat ? mk_wheel_interval : mk_wheel_delay * 10)) { - if (mousekey_repeat != UINT8_MAX) mousekey_repeat++; - mouse_report.x = 0; - mouse_report.y = 0; - if (mouse_report.v > 0) mouse_report.v = wheel_unit(); - if (mouse_report.v < 0) mouse_report.v = wheel_unit() * -1; - if (mouse_report.h > 0) mouse_report.h = wheel_unit(); - if (mouse_report.h < 0) mouse_report.h = wheel_unit() * -1; + if ((tmpmr.v || tmpmr.h) && timer_elapsed(last_timer_w) > (mousekey_wheel_repeat ? mk_wheel_interval : mk_wheel_delay * 10)) { + if (mousekey_wheel_repeat != UINT8_MAX) mousekey_wheel_repeat++; + if (tmpmr.v != 0) mouse_report.v = wheel_unit() * ((tmpmr.v > 0) ? 1 : -1); + if (tmpmr.h != 0) mouse_report.h = wheel_unit() * ((tmpmr.h > 0) ? 1 : -1); + /* diagonal move [1/sqrt(2)] */ if (mouse_report.v && mouse_report.h) { mouse_report.v = times_inv_sqrt2(mouse_report.v); @@ -189,10 +186,10 @@ void mousekey_task(void) { mouse_report.h = 1; } } - mousekey_send(); - last_timer_w = last_timer; - mouse_report = tmpmr; } + + if (mouse_report.x || mouse_report.y || mouse_report.v || mouse_report.h) mousekey_send(); + mouse_report = tmpmr; } void mousekey_on(uint8_t code) { @@ -228,6 +225,7 @@ void mousekey_on(uint8_t code) { mousekey_accel |= (1 << 1); else if (code == KC_MS_ACCEL2) mousekey_accel |= (1 << 2); + } void mousekey_off(uint8_t code) { @@ -263,7 +261,8 @@ void mousekey_off(uint8_t code) { mousekey_accel &= ~(1 << 1); else if (code == KC_MS_ACCEL2) mousekey_accel &= ~(1 << 2); - if (mouse_report.x == 0 && mouse_report.y == 0 && mouse_report.v == 0 && mouse_report.h == 0) mousekey_repeat = 0; + if (mouse_report.x == 0 && mouse_report.y == 0) mousekey_repeat = 0; + if (mouse_report.v == 0 && mouse_report.h == 0) mousekey_wheel_repeat = 0; } #else /* #ifndef MK_3_SPEED */ @@ -285,20 +284,22 @@ uint16_t w_intervals[mkspd_COUNT] = {MK_W_INTERVAL_UNMOD, MK_W_INTERVAL_0 void mousekey_task(void) { // report cursor and scroll movement independently report_mouse_t const tmpmr = mouse_report; - if ((mouse_report.x || mouse_report.y) && timer_elapsed(last_timer_c) > c_intervals[mk_speed]) { - mouse_report.h = 0; - mouse_report.v = 0; - mousekey_send(); - last_timer_c = last_timer; - mouse_report = tmpmr; + mouse_report.x = 0; + mouse_report.y = 0; + mouse_report.v = 0; + mouse_report.h = 0; + + if ((tmpmr.x || tmpmr.y) && timer_elapsed(last_timer_c) > c_intervals[mk_speed]) { + mouse_report.x = tmpmr.x; + mouse_report.y = tmpmr.y; } - if ((mouse_report.h || mouse_report.v) && timer_elapsed(last_timer_w) > w_intervals[mk_speed]) { - mouse_report.x = 0; - mouse_report.y = 0; - mousekey_send(); - last_timer_w = last_timer; - mouse_report = tmpmr; + if ((tmpmr.h || tmpmr.v) && timer_elapsed(last_timer_w) > w_intervals[mk_speed]) { + mouse_report.v = tmpmr.v; + mouse_report.h = tmpmr.h; } + + if (mouse_report.x || mouse_report.y || mouse_report.v || mouse_report.h) mousekey_send(); + mouse_report = tmpmr; } void adjust_speed(void) { @@ -413,13 +414,16 @@ void mousekey_off(uint8_t code) { void mousekey_send(void) { mousekey_debug(); + uint16_t time = timer_read(); + if (mouse_report.x || mouse_report.y) last_timer_c = time; + if (mouse_report.v || mouse_report.h) last_timer_w = time; host_mouse_send(&mouse_report); - last_timer = timer_read(); } void mousekey_clear(void) { mouse_report = (report_mouse_t){}; mousekey_repeat = 0; + mousekey_wheel_repeat = 0; mousekey_accel = 0; } From c023f1b6443db42dff415bc8fb5d081c1416871d Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Thu, 16 Jul 2020 16:58:14 +1000 Subject: [PATCH 15/54] Add dual-bank STM32 bootloader support, given GPIO toggle on BOOT0 to charge RC circuit. (#8778) --- docs/platformdev_chibios_earlyinit.md | 19 ++++-- tmk_core/common/chibios/bootloader.c | 84 ++++++++++++++++++++++----- tmk_core/protocol/chibios/main.c | 1 + 3 files changed, 85 insertions(+), 19 deletions(-) diff --git a/docs/platformdev_chibios_earlyinit.md b/docs/platformdev_chibios_earlyinit.md index 699c223771bd..5fd78bb33648 100644 --- a/docs/platformdev_chibios_earlyinit.md +++ b/docs/platformdev_chibios_earlyinit.md @@ -4,17 +4,28 @@ This page describes a part of QMK that is a somewhat advanced concept, and is on QMK uses ChibiOS as the underlying layer to support a multitude of Arm-based devices. Each ChibiOS-supported keyboard has a low-level board definition which is responsible for initializing hardware peripherals such as the clocks, and GPIOs. -Older QMK revisions required duplication of these board definitions inside your keyboard's directory in order to override such early initialization points; this is now abstracted into the following APIs, and allows usage of the board definitions supplied with ChibiOS itself. Check `/lib/chibios/os/hal/boards` for the list of official definitions. If your keyboard needs extra initialization at a very early stage, consider providing keyboard-level overrides of the following APIs: +Older QMK revisions required duplication of these board definitions inside your keyboard's directory in order to override such early initialization points; this is now abstracted into the following APIs, and allows usage of the board definitions supplied with ChibiOS itself. Check `/lib/chibios/os/hal/boards` for the list of official definitions. If your keyboard needs extra initialization at a very early stage, consider providing keyboard-level overrides of the following APIs instead of duplicating the board definitions: ## `early_hardware_init_pre()` :id=early-hardware-init-pre The function `early_hardware_init_pre` is the earliest possible code that can be executed by a keyboard firmware. This is intended as a replacement for the ChibiOS board definition's `__early_init` function, and is the equivalent of executing at the start of the function. -This is executed before RAM gets cleared, and before clocks or GPIOs are configured; any delays or preparation using GPIOs is not likely to work at this point. After executing this function, RAM on the MCU may be zero'ed. Assigning values to variables during execution of this function may be overwritten. +This is executed before RAM gets cleared, and before clocks or GPIOs are configured; for example, ChibiOS delays are not likely to work at this point. After executing this function, RAM on the MCU may be zero'ed. Assigning values to variables during execution of this function may be overwritten. -As such, if you wish to override this API consider limiting use to writing to low-level registers. The default implementation of this function can be configured to jump to bootloader if a `RESET` key was pressed, by ensuring `#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE` is in the keyboard's `config.h` file. +As such, if you wish to override this API consider limiting use to writing to low-level registers. The default implementation of this function can be configured to jump to bootloader if a `RESET` key was pressed: -To implement your own version of this function, in your keyboard's source files: +| `config.h` override | Description | Default | +|-----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| +| `#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP` | Whether or not bootloader is to be executed during the early initialisation code of QMK. | `FALSE` | +| `#define STM32_BOOTLOADER_ADDRESS` | Relevant for single-bank STM32 MCUs, signifies the memory address to jump to bootloader. Consult [AN2606](https://www.st.com/content/st_com/en/search.html#q=an2606-t=resources-page=1) for the _System Memory_ address for your MCU. This value should be of the format `0x11111111`. | `` | +| `#define STM32_BOOTLOADER_DUAL_BANK` | Relevant for dual-bank STM32 MCUs, signifies that a GPIO is to be toggled in order to enter bootloader mode. | `FALSE` | +| `#define STM32_BOOTLOADER_DUAL_BANK_GPIO` | Relevant for dual-bank STM32 MCUs, the pin to toggle when attempting to enter bootloader mode, e.g. `B8` | `` | +| `#define STM32_BOOTLOADER_DUAL_BANK_POLARITY` | Relevant for dual-bank STM32 MCUs, the value to set the pin to in order to trigger charging of the RC circuit. e.g. `0` or `1`. | `0` | +| `#define STM32_BOOTLOADER_DUAL_BANK_DELAY` | Relevant for dual-bank STM32 MCUs, an arbitrary measurement of time to delay before resetting the MCU. Increasing number increases the delay. | `100000` | + +Kinetis MCUs have no configurable options. + +Alternatively, to implement your own version of this function, in your keyboard's source files: ```c void early_hardware_init_pre(void) { diff --git a/tmk_core/common/chibios/bootloader.c b/tmk_core/common/chibios/bootloader.c index 4cf5dae7e645..dceeaa6b19c8 100644 --- a/tmk_core/common/chibios/bootloader.c +++ b/tmk_core/common/chibios/bootloader.c @@ -3,28 +3,82 @@ #include "ch.h" #include "hal.h" -#ifdef STM32_BOOTLOADER_ADDRESS -/* STM32 */ - /* This code should be checked whether it runs correctly on platforms */ -# define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0)) +#define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0)) +#define BOOTLOADER_MAGIC 0xDEADBEEF +#define MAGIC_ADDR (unsigned long *)(SYMVAL(__ram0_end__) - 4) + +#ifndef STM32_BOOTLOADER_DUAL_BANK +# define STM32_BOOTLOADER_DUAL_BANK FALSE +#endif + +#if STM32_BOOTLOADER_DUAL_BANK + +// Need pin definitions +# include "config_common.h" + +# ifndef STM32_BOOTLOADER_DUAL_BANK_GPIO +# error "No STM32_BOOTLOADER_DUAL_BANK_GPIO defined, don't know which pin to toggle" +# endif + +# ifndef STM32_BOOTLOADER_DUAL_BANK_POLARITY +# define STM32_BOOTLOADER_DUAL_BANK_POLARITY 0 +# endif + +# ifndef STM32_BOOTLOADER_DUAL_BANK_DELAY +# define STM32_BOOTLOADER_DUAL_BANK_DELAY 100000 +# endif + +extern uint32_t __ram0_end__; + +# define bootdelay(loopcount) \ + do { \ + for (int i = 0; i < loopcount; ++i) { \ + __asm__ volatile("nop\n\t" \ + "nop\n\t" \ + "nop\n\t"); \ + } \ + } while (0) + +void bootloader_jump(void) { + *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader + NVIC_SystemReset(); +} + +void enter_bootloader_mode_if_requested(void) { + unsigned long *check = MAGIC_ADDR; + if (*check == BOOTLOADER_MAGIC) { + *check = 0; + + // For STM32 MCUs with dual-bank flash, and we're incapable of jumping to the bootloader. The first valid flash + // bank is executed unconditionally after a reset, so it doesn't enter DFU unless BOOT0 is high. Instead, we do + // it with hardware...in this case, we pull a GPIO high/low depending on the configuration, connects 3.3V to + // BOOT0's RC charging circuit, lets it charge the capacitor, and issue a system reset. See the QMK discord + // #hardware channel pins for an example circuit. + palSetPadMode(PAL_PORT(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_PAD(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_MODE_OUTPUT_PUSHPULL); +# if STM32_BOOTLOADER_DUAL_BANK_POLARITY + palSetPad(PAL_PORT(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_PAD(STM32_BOOTLOADER_DUAL_BANK_GPIO)); +# else + palClearPad(PAL_PORT(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_PAD(STM32_BOOTLOADER_DUAL_BANK_GPIO)); +# endif + + // Wait for a while for the capacitor to charge + bootdelay(STM32_BOOTLOADER_DUAL_BANK_DELAY); + + // Issue a system reset to get the ROM bootloader to execute, with BOOT0 high + NVIC_SystemReset(); + } +} + +#elif defined(STM32_BOOTLOADER_ADDRESS) // STM32_BOOTLOADER_DUAL_BANK + extern uint32_t __ram0_end__; -# define BOOTLOADER_MAGIC 0xDEADBEEF -# define MAGIC_ADDR (unsigned long *)(SYMVAL(__ram0_end__) - 4) -/** \brief Jump to the bootloader - * - * FIXME: needs doc - */ void bootloader_jump(void) { *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader NVIC_SystemReset(); } -/** \brief Enter bootloader mode if requested - * - * FIXME: needs doc - */ void enter_bootloader_mode_if_requested(void) { unsigned long *check = MAGIC_ADDR; if (*check == BOOTLOADER_MAGIC) { @@ -41,7 +95,7 @@ void enter_bootloader_mode_if_requested(void) { } } -#elif defined(KL2x) || defined(K20x) /* STM32_BOOTLOADER_ADDRESS */ +#elif defined(KL2x) || defined(K20x) // STM32_BOOTLOADER_DUAL_BANK // STM32_BOOTLOADER_ADDRESS /* Kinetis */ # if defined(KIIBOHD_BOOTLOADER) diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c index 7d32c16ed8c5..a0d28f9afc08 100644 --- a/tmk_core/protocol/chibios/main.c +++ b/tmk_core/protocol/chibios/main.c @@ -35,6 +35,7 @@ #ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP // Change this to be TRUE once we've migrated keyboards to the new init system +// Remember to change docs/platformdev_chibios_earlyinit.md as well. # define EARLY_INIT_PERFORM_BOOTLOADER_JUMP FALSE #endif From d982abee3d8907ef53ca104bd85971099840b60c Mon Sep 17 00:00:00 2001 From: Pete Sevander Date: Thu, 16 Jul 2020 15:39:01 +0300 Subject: [PATCH 16/54] Bigger combo index (#9318) * Add change log * Change combo index from uint8_t to uint16_t --- docs/ChangeLog/20200829/PR9318.md | 11 +++++++++++ keyboards/ashpil/modelm_usbc/keymaps/ashpil/keymap.c | 2 +- .../converter/usb_usb/keymaps/chriskopher/combo.c | 2 +- keyboards/converter/usb_usb/keymaps/narze/keymap.c | 2 +- keyboards/ergodox_infinity/keymaps/narze/keymap.c | 2 +- keyboards/gboards/g/keymap_combo.h | 2 +- keyboards/maxr1998/pulse4k/pulse4k.c | 2 +- keyboards/minidox/keymaps/rsthd_combos/keymap.c | 2 +- keyboards/planck/keymaps/narze/keymap.c | 2 +- keyboards/xd75/keymaps/4sstylz/keymap.c | 2 +- quantum/process_keycode/process_combo.c | 6 +++--- quantum/process_keycode/process_combo.h | 2 +- users/issmirnov/issmirnov.c | 2 +- users/kuchosauronad0/combo.c | 2 +- users/ninjonas/combos.c | 2 +- users/yet-another-developer/combo.c | 2 +- 16 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 docs/ChangeLog/20200829/PR9318.md diff --git a/docs/ChangeLog/20200829/PR9318.md b/docs/ChangeLog/20200829/PR9318.md new file mode 100644 index 000000000000..c238f6e4491e --- /dev/null +++ b/docs/ChangeLog/20200829/PR9318.md @@ -0,0 +1,11 @@ +### Bigger integer type when looping over combos. + +[#9318](https://github.com/qmk/qmk_firmware/pull/9318) + +Changes `uint8_t` to `uint16_t` so it is possible have more than 256 combos. + +Any fork that uses `process_combo_event` needs to update the function's first argument to `uint16_t`. + +| Old function | New Function | +|---------------------------------------------------------------|----------------------------------------------------------------| +| `void process_combo_event(uint8_t combo_index, bool pressed)` | `void process_combo_event(uint16_t combo_index, bool pressed)` | diff --git a/keyboards/ashpil/modelm_usbc/keymaps/ashpil/keymap.c b/keyboards/ashpil/modelm_usbc/keymaps/ashpil/keymap.c index 35b45e9ccf8c..30e6af7f6e6a 100644 --- a/keyboards/ashpil/modelm_usbc/keymaps/ashpil/keymap.c +++ b/keyboards/ashpil/modelm_usbc/keymaps/ashpil/keymap.c @@ -36,7 +36,7 @@ combo_t key_combos[COMBO_COUNT] = { [CTRL_PAUS_RESET] = COMBO_ACTION(reset_combo), }; -void process_combo_event(uint8_t combo_index, bool pressed) { +void process_combo_event(uint16_t combo_index, bool pressed) { switch(combo_index) { case CTRL_PAUS_RESET: if (pressed) { diff --git a/keyboards/converter/usb_usb/keymaps/chriskopher/combo.c b/keyboards/converter/usb_usb/keymaps/chriskopher/combo.c index c0a354eb55b3..68a3eda04c4a 100644 --- a/keyboards/converter/usb_usb/keymaps/chriskopher/combo.c +++ b/keyboards/converter/usb_usb/keymaps/chriskopher/combo.c @@ -33,7 +33,7 @@ combo_t key_combos[COMBO_COUNT] = { }; // Called after a combo event is triggered -void process_combo_event(uint8_t combo_index, bool pressed) { +void process_combo_event(uint16_t combo_index, bool pressed) { switch (combo_index) { case SD_LAYER_COMBO: if (pressed) { diff --git a/keyboards/converter/usb_usb/keymaps/narze/keymap.c b/keyboards/converter/usb_usb/keymaps/narze/keymap.c index b5938fa359f4..510b93b7ad84 100644 --- a/keyboards/converter/usb_usb/keymaps/narze/keymap.c +++ b/keyboards/converter/usb_usb/keymaps/narze/keymap.c @@ -153,7 +153,7 @@ void matrix_setup(void) { set_superduper_key_combos(); } -void process_combo_event(uint8_t combo_index, bool pressed) { +void process_combo_event(uint16_t combo_index, bool pressed) { if (pressed) { switch(combo_index) { case CB_SUPERDUPER: diff --git a/keyboards/ergodox_infinity/keymaps/narze/keymap.c b/keyboards/ergodox_infinity/keymaps/narze/keymap.c index 4a4e8ab9411c..dcabd657b03c 100644 --- a/keyboards/ergodox_infinity/keymaps/narze/keymap.c +++ b/keyboards/ergodox_infinity/keymaps/narze/keymap.c @@ -683,7 +683,7 @@ void matrix_scan_user(void) { // Combos -void process_combo_event(uint8_t combo_index, bool pressed) { +void process_combo_event(uint16_t combo_index, bool pressed) { if (pressed) { switch(combo_index) { case CB_SUPERDUPER: diff --git a/keyboards/gboards/g/keymap_combo.h b/keyboards/gboards/g/keymap_combo.h index 1302c460352c..58e99863eaeb 100644 --- a/keyboards/gboards/g/keymap_combo.h +++ b/keyboards/gboards/g/keymap_combo.h @@ -60,7 +60,7 @@ int COMBO_LEN = sizeof(key_combos) / sizeof(key_combos[0]); #define COMB BLANK #define SUBS A_ACTI #define TOGG A_TOGG -void process_combo_event(uint8_t combo_index, bool pressed) { +void process_combo_event(uint16_t combo_index, bool pressed) { switch (combo_index) { #include "combos.def" } diff --git a/keyboards/maxr1998/pulse4k/pulse4k.c b/keyboards/maxr1998/pulse4k/pulse4k.c index 61a18af7438e..37c558db727d 100644 --- a/keyboards/maxr1998/pulse4k/pulse4k.c +++ b/keyboards/maxr1998/pulse4k/pulse4k.c @@ -30,7 +30,7 @@ combo_t key_combos[COMBO_COUNT] = { bool led_adjust_active = false; -void process_combo_event(uint8_t combo_index, bool pressed) { +void process_combo_event(uint16_t combo_index, bool pressed) { if (combo_index == LED_ADJUST) { led_adjust_active = pressed; } diff --git a/keyboards/minidox/keymaps/rsthd_combos/keymap.c b/keyboards/minidox/keymaps/rsthd_combos/keymap.c index a3ba423c699e..d80febecafd5 100644 --- a/keyboards/minidox/keymaps/rsthd_combos/keymap.c +++ b/keyboards/minidox/keymaps/rsthd_combos/keymap.c @@ -45,7 +45,7 @@ combo_t key_combos[COMBO_COUNT] = { [BOT_CTR] = COMBO_ACTION(bx_combo), }; - void process_combo_event(uint8_t combo_index, bool pressed) { + void process_combo_event(uint16_t combo_index, bool pressed) { switch(combo_index) { case MID_R: if (pressed) { diff --git a/keyboards/planck/keymaps/narze/keymap.c b/keyboards/planck/keymaps/narze/keymap.c index c878cf9e4421..7fead3205889 100644 --- a/keyboards/planck/keymaps/narze/keymap.c +++ b/keyboards/planck/keymaps/narze/keymap.c @@ -357,7 +357,7 @@ void matrix_setup(void) { void matrix_scan_user(void) { } -void process_combo_event(uint8_t combo_index, bool pressed) { +void process_combo_event(uint16_t combo_index, bool pressed) { if (pressed) { switch(combo_index) { case CB_SUPERDUPER: diff --git a/keyboards/xd75/keymaps/4sstylz/keymap.c b/keyboards/xd75/keymaps/4sstylz/keymap.c index d722da9c588f..497ca40a9863 100644 --- a/keyboards/xd75/keymaps/4sstylz/keymap.c +++ b/keyboards/xd75/keymaps/4sstylz/keymap.c @@ -129,7 +129,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } -void process_combo_event(uint8_t combo_index, bool pressed) { +void process_combo_event(uint16_t combo_index, bool pressed) { switch(combo_index) { case SCR_LCK: if (pressed) { diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index c4e299958af2..1f715f43b94d 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c @@ -24,10 +24,10 @@ extern combo_t key_combos[]; extern int COMBO_LEN; #endif -__attribute__((weak)) void process_combo_event(uint8_t combo_index, bool pressed) {} +__attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {} static uint16_t timer = 0; -static uint8_t current_combo_index = 0; +static uint16_t current_combo_index = 0; static bool drop_buffer = false; static bool is_active = false; static bool b_combo_enable = true; // defaults to enabled @@ -83,7 +83,7 @@ static inline void dump_key_buffer(bool emit) { static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record) { uint8_t count = 0; - uint8_t index = -1; + uint16_t index = -1; /* Find index of keycode and number of combo keys */ for (const uint16_t *keys = combo->keys;; ++count) { uint16_t key = pgm_read_word(&keys[count]); diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h index e21ee19609f6..0f01aae93edd 100644 --- a/quantum/process_keycode/process_combo.h +++ b/quantum/process_keycode/process_combo.h @@ -56,7 +56,7 @@ typedef struct { bool process_combo(uint16_t keycode, keyrecord_t *record); void matrix_scan_combo(void); -void process_combo_event(uint8_t combo_index, bool pressed); +void process_combo_event(uint16_t combo_index, bool pressed); void combo_enable(void); void combo_disable(void); diff --git a/users/issmirnov/issmirnov.c b/users/issmirnov/issmirnov.c index 665afbcfd7da..45ef7b19a7b9 100644 --- a/users/issmirnov/issmirnov.c +++ b/users/issmirnov/issmirnov.c @@ -26,7 +26,7 @@ combo_t key_combos[COMBO_COUNT] = { }; -void process_combo_event(uint8_t combo_index, bool pressed) { +void process_combo_event(uint16_t combo_index, bool pressed) { switch(combo_index) { case XC_COPY: if (pressed) { diff --git a/users/kuchosauronad0/combo.c b/users/kuchosauronad0/combo.c index b4e8e84ae51a..0a58e0277005 100644 --- a/users/kuchosauronad0/combo.c +++ b/users/kuchosauronad0/combo.c @@ -1,6 +1,6 @@ #include "combo.h" -void process_combo_event(uint8_t combo_index, bool pressed){ +void process_combo_event(uint16_t combo_index, bool pressed){ switch(combo_index) { case ZV_COPY: if (pressed) { diff --git a/users/ninjonas/combos.c b/users/ninjonas/combos.c index 9453ba84dc2b..8d1cd6510f0e 100644 --- a/users/ninjonas/combos.c +++ b/users/ninjonas/combos.c @@ -23,7 +23,7 @@ combo_t key_combos[COMBO_COUNT] = { [XV_PASTE] = COMBO_ACTION(paste_combo), }; -void process_combo_event(uint8_t combo_index, bool pressed) { +void process_combo_event(uint16_t combo_index, bool pressed) { switch(combo_index) { case EQ_QUIT: if (pressed) { diff --git a/users/yet-another-developer/combo.c b/users/yet-another-developer/combo.c index b4e8e84ae51a..0a58e0277005 100644 --- a/users/yet-another-developer/combo.c +++ b/users/yet-another-developer/combo.c @@ -1,6 +1,6 @@ #include "combo.h" -void process_combo_event(uint8_t combo_index, bool pressed){ +void process_combo_event(uint16_t combo_index, bool pressed){ switch(combo_index) { case ZV_COPY: if (pressed) { From 83fc2499b639e16eef217430cba3de9f5a2586aa Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Fri, 17 Jul 2020 06:19:18 +1000 Subject: [PATCH 17/54] Re-fix the STM32 dual-bank bootloader stuff. (#9738) * Re-fix the dual-bank bootloader stuff. * Use wait_ms() instead of using nop's for a delay, as ChibiOS is actually running at the time of bootloader jump. --- tmk_core/common/chibios/bootloader.c | 46 +++++++++------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/tmk_core/common/chibios/bootloader.c b/tmk_core/common/chibios/bootloader.c index dceeaa6b19c8..743448ee18f0 100644 --- a/tmk_core/common/chibios/bootloader.c +++ b/tmk_core/common/chibios/bootloader.c @@ -2,6 +2,7 @@ #include "ch.h" #include "hal.h" +#include "wait.h" /* This code should be checked whether it runs correctly on platforms */ #define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0)) @@ -31,45 +32,28 @@ extern uint32_t __ram0_end__; -# define bootdelay(loopcount) \ - do { \ - for (int i = 0; i < loopcount; ++i) { \ - __asm__ volatile("nop\n\t" \ - "nop\n\t" \ - "nop\n\t"); \ - } \ - } while (0) - void bootloader_jump(void) { - *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader - NVIC_SystemReset(); -} - -void enter_bootloader_mode_if_requested(void) { - unsigned long *check = MAGIC_ADDR; - if (*check == BOOTLOADER_MAGIC) { - *check = 0; - - // For STM32 MCUs with dual-bank flash, and we're incapable of jumping to the bootloader. The first valid flash - // bank is executed unconditionally after a reset, so it doesn't enter DFU unless BOOT0 is high. Instead, we do - // it with hardware...in this case, we pull a GPIO high/low depending on the configuration, connects 3.3V to - // BOOT0's RC charging circuit, lets it charge the capacitor, and issue a system reset. See the QMK discord - // #hardware channel pins for an example circuit. - palSetPadMode(PAL_PORT(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_PAD(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_MODE_OUTPUT_PUSHPULL); + // For STM32 MCUs with dual-bank flash, and we're incapable of jumping to the bootloader. The first valid flash + // bank is executed unconditionally after a reset, so it doesn't enter DFU unless BOOT0 is high. Instead, we do + // it with hardware...in this case, we pull a GPIO high/low depending on the configuration, connects 3.3V to + // BOOT0's RC charging circuit, lets it charge the capacitor, and issue a system reset. See the QMK discord + // #hardware channel pins for an example circuit. + palSetPadMode(PAL_PORT(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_PAD(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_MODE_OUTPUT_PUSHPULL); # if STM32_BOOTLOADER_DUAL_BANK_POLARITY - palSetPad(PAL_PORT(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_PAD(STM32_BOOTLOADER_DUAL_BANK_GPIO)); + palSetPad(PAL_PORT(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_PAD(STM32_BOOTLOADER_DUAL_BANK_GPIO)); # else - palClearPad(PAL_PORT(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_PAD(STM32_BOOTLOADER_DUAL_BANK_GPIO)); + palClearPad(PAL_PORT(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_PAD(STM32_BOOTLOADER_DUAL_BANK_GPIO)); # endif - // Wait for a while for the capacitor to charge - bootdelay(STM32_BOOTLOADER_DUAL_BANK_DELAY); + // Wait for a while for the capacitor to charge + wait_ms(100); - // Issue a system reset to get the ROM bootloader to execute, with BOOT0 high - NVIC_SystemReset(); - } + // Issue a system reset to get the ROM bootloader to execute, with BOOT0 high + NVIC_SystemReset(); } +void enter_bootloader_mode_if_requested(void) {} // not needed at all, but if anybody attempts to invoke it.... + #elif defined(STM32_BOOTLOADER_ADDRESS) // STM32_BOOTLOADER_DUAL_BANK extern uint32_t __ram0_end__; From de57f336bb2eb8c1fd926ae2338d5996d5ef3f7f Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 22 Jul 2020 13:57:47 -0700 Subject: [PATCH 18/54] Disable NKRO on V-USB controllers (#9054) * Disable NKRO on V-USB controllers * not _currently_ supported text Co-authored-by: Ryan Co-authored-by: Ryan --- tmk_core/common.mk | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tmk_core/common.mk b/tmk_core/common.mk index b7fe45afd6d8..56ed4a85779d 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -99,8 +99,12 @@ ifeq ($(strip $(COMMAND_ENABLE)), yes) endif ifeq ($(strip $(NKRO_ENABLE)), yes) - TMK_COMMON_DEFS += -DNKRO_ENABLE - SHARED_EP_ENABLE = yes + ifneq ($(PROTOCOL),VUSB) + TMK_COMMON_DEFS += -DNKRO_ENABLE + SHARED_EP_ENABLE = yes + else + $(info NKRO is not currently supported on V-USB, and has been disabled.) + endif endif ifeq ($(strip $(USB_6KRO_ENABLE)), yes) From fca5b6f5564d66fbcbfb8976cc7f3c9afde78023 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 24 Jul 2020 20:05:27 -0700 Subject: [PATCH 19/54] Update features to use Custom Tapping Term when appropriate (#6259) * Update Space Cadet to use Custom Tapping Term functionality * Detect correct keycode for space cadet tapping term * Update tap dancing to use global custom tapping term * Update documentation for Tap Dances * formatting pass * Apply suggestions from code review Co-Authored-By: fauxpark * Update docs/feature_tap_dance.md Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> * Update for future * Update user keymaps for space cadet * Fix typos * Clean up tapping term stuff * Fix compiler issue if NO_ACTION_TAPPING is enabled Co-authored-by: fauxpark Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> --- docs/feature_tap_dance.md | 4 +++- .../converter/usb_usb/keymaps/narze/keymap.c | 6 ++--- .../ergodox_infinity/keymaps/narze/keymap.c | 6 ++--- keyboards/planck/keymaps/narze/keymap.c | 4 ++-- quantum/process_keycode/process_space_cadet.c | 23 ++++++++++--------- quantum/process_keycode/process_space_cadet.h | 5 +++- quantum/process_keycode/process_tap_dance.c | 6 +---- 7 files changed, 28 insertions(+), 26 deletions(-) diff --git a/docs/feature_tap_dance.md b/docs/feature_tap_dance.md index 877c37336ec3..d2da39ad2b77 100644 --- a/docs/feature_tap_dance.md +++ b/docs/feature_tap_dance.md @@ -28,7 +28,9 @@ After this, you'll want to use the `tap_dance_actions` array to specify what act * `ACTION_TAP_DANCE_LAYER_TOGGLE(kc, layer)`: Sends the `kc` keycode when tapped once, or toggles the state of `layer`. (this functions like the `TG` layer keycode). * `ACTION_TAP_DANCE_FN(fn)`: Calls the specified function - defined in the user keymap - with the final tap count of the tap dance action. * `ACTION_TAP_DANCE_FN_ADVANCED(on_each_tap_fn, on_dance_finished_fn, on_dance_reset_fn)`: Calls the first specified function - defined in the user keymap - on every tap, the second function when the dance action finishes (like the previous option), and the last function when the tap dance action resets. -* `ACTION_TAP_DANCE_FN_ADVANCED_TIME(on_each_tap_fn, on_dance_finished_fn, on_dance_reset_fn, tap_specific_tapping_term)`: This functions identically to the `ACTION_TAP_DANCE_FN_ADVANCED` function, but uses a custom tapping term for it, instead of the predefined `TAPPING_TERM`. +* ~~`ACTION_TAP_DANCE_FN_ADVANCED_TIME(on_each_tap_fn, on_dance_finished_fn, on_dance_reset_fn, tap_specific_tapping_term)`~~: This functions identically to the `ACTION_TAP_DANCE_FN_ADVANCED` function, but uses a custom tapping term for it, instead of the predefined `TAPPING_TERM`. + * This is deprecated in favor of the Per Key Tapping Term functionality, as outlined [here](custom_quantum_functions.md#Custom_Tapping_Term). You'd want to check for the specific `TD()` macro that you want to use (such as `TD(TD_ESC_CAPS)`) instead of using this specific Tap Dance function. + The first option is enough for a lot of cases, that just want dual roles. For example, `ACTION_TAP_DANCE_DOUBLE(KC_SPC, KC_ENT)` will result in `Space` being sent on single-tap, `Enter` otherwise. diff --git a/keyboards/converter/usb_usb/keymaps/narze/keymap.c b/keyboards/converter/usb_usb/keymaps/narze/keymap.c index 510b93b7ad84..a84d613a2d36 100644 --- a/keyboards/converter/usb_usb/keymaps/narze/keymap.c +++ b/keyboards/converter/usb_usb/keymaps/narze/keymap.c @@ -130,17 +130,17 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { // 1. Hold for LGUI, tap for Underscore case GUI_UNDS: - perform_space_cadet(record, KC_LGUI, KC_LSFT, KC_MINS); + perform_space_cadet(record, keycode, KC_LGUI, KC_LSFT, KC_MINS); return false; // 2. Hold for LSHIFT, tap for Parens open case LSFT_LPRN: - perform_space_cadet(record, KC_LSFT, KC_LSFT, KC_9); + perform_space_cadet(record, keycode, KC_LSFT, KC_LSFT, KC_9); return false; // 3. Hold for RSHIFT, tap for Parens close case RSFT_RPRN: - perform_space_cadet(record, KC_RSFT, KC_RSFT, KC_0); + perform_space_cadet(record, keycode, KC_RSFT, KC_RSFT, KC_0); return false; default: diff --git a/keyboards/ergodox_infinity/keymaps/narze/keymap.c b/keyboards/ergodox_infinity/keymaps/narze/keymap.c index dcabd657b03c..d9499f00376c 100644 --- a/keyboards/ergodox_infinity/keymaps/narze/keymap.c +++ b/keyboards/ergodox_infinity/keymaps/narze/keymap.c @@ -635,17 +635,17 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { // 1. Hold for LGUI, tap for Underscore case GUI_UNDS: - perform_space_cadet(record, KC_LGUI, KC_LSFT, KC_MINS); + perform_space_cadet(record, keycode, KC_LGUI, KC_LSFT, KC_MINS); return false; // 2. Hold for LSHIFT, tap for Parens open case LSFT_LPRN: - perform_space_cadet(record, KC_LSFT, KC_LSFT, KC_9); + perform_space_cadet(record, keycode, KC_LSFT, KC_LSFT, KC_9); return false; // 3. Hold for RSHIFT, tap for Parens close case RSFT_RPRN: - perform_space_cadet(record, KC_RSFT, KC_RSFT, KC_0); + perform_space_cadet(record, keycode, KC_RSFT, KC_RSFT, KC_0); return false; } diff --git a/keyboards/planck/keymaps/narze/keymap.c b/keyboards/planck/keymaps/narze/keymap.c index 7fead3205889..81cb68ecc910 100644 --- a/keyboards/planck/keymaps/narze/keymap.c +++ b/keyboards/planck/keymaps/narze/keymap.c @@ -330,12 +330,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { // 1. Hold for LGUI, tap for Underscore case GUI_UNDS: - perform_space_cadet(record, KC_LGUI, KC_LSFT, KC_MINS); + perform_space_cadet(record, keycode, KC_LGUI, KC_LSFT, KC_MINS); return false; // 2. Hold for LSHIFT, tap for Parens open case LSFT_LPRN: - perform_space_cadet(record, KC_LSFT, KC_LSFT, KC_9); + perform_space_cadet(record, keycode, KC_LSFT, KC_LSFT, KC_9); return false; default: diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c index 6833fdb9fb38..bcaf62a964ec 100644 --- a/quantum/process_keycode/process_space_cadet.c +++ b/quantum/process_keycode/process_space_cadet.c @@ -14,9 +14,10 @@ * along with this program. If not, see . */ #include "process_space_cadet.h" +#include "action_tapping.h" -#ifndef TAPPING_TERM -# define TAPPING_TERM 200 +#ifdef NO_ACTION_TAPPING +__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { return TAPPING_TERM; }; #endif // ********** OBSOLETE DEFINES, STOP USING! (pls?) ********** @@ -85,7 +86,7 @@ static uint16_t sc_timer = 0; static uint8_t sc_mods = 0; #endif -void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) { +void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) { if (record->event.pressed) { sc_last = holdMod; sc_timer = timer_read(); @@ -96,7 +97,7 @@ void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, u register_mods(MOD_BIT(holdMod)); } } else { - if (sc_last == holdMod && timer_elapsed(sc_timer) < TAPPING_TERM) { + if (sc_last == holdMod && timer_elapsed(sc_timer) < get_tapping_term(sc_keycode, record)) { if (holdMod != tapMod) { if (IS_MOD(holdMod)) { unregister_mods(MOD_BIT(holdMod)); @@ -126,31 +127,31 @@ void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, u bool process_space_cadet(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case KC_LSPO: { - perform_space_cadet(record, LSPO_KEYS); + perform_space_cadet(record, keycode, LSPO_KEYS); return false; } case KC_RSPC: { - perform_space_cadet(record, RSPC_KEYS); + perform_space_cadet(record, keycode, RSPC_KEYS); return false; } case KC_LCPO: { - perform_space_cadet(record, LCPO_KEYS); + perform_space_cadet(record, keycode, LCPO_KEYS); return false; } case KC_RCPC: { - perform_space_cadet(record, RCPC_KEYS); + perform_space_cadet(record, keycode, RCPC_KEYS); return false; } case KC_LAPO: { - perform_space_cadet(record, LAPO_KEYS); + perform_space_cadet(record, keycode, LAPO_KEYS); return false; } case KC_RAPC: { - perform_space_cadet(record, RAPC_KEYS); + perform_space_cadet(record, keycode, RAPC_KEYS); return false; } case KC_SFTENT: { - perform_space_cadet(record, SFTENT_KEYS); + perform_space_cadet(record, keycode, SFTENT_KEYS); return false; } default: { diff --git a/quantum/process_keycode/process_space_cadet.h b/quantum/process_keycode/process_space_cadet.h index c8231435046a..3ace073997af 100644 --- a/quantum/process_keycode/process_space_cadet.h +++ b/quantum/process_keycode/process_space_cadet.h @@ -17,5 +17,8 @@ #include "quantum.h" -void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode); +void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdMod, uint8_t tapMod, uint8_t keycode); bool process_space_cadet(uint16_t keycode, keyrecord_t *record); +#ifdef NO_ACTION_TAPPING +uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record); +#endif diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c index 16756e59c204..0c7b6353eb51 100644 --- a/quantum/process_keycode/process_tap_dance.c +++ b/quantum/process_keycode/process_tap_dance.c @@ -16,10 +16,6 @@ #include "quantum.h" #include "action_tapping.h" -#ifndef TAPPING_TERM -# define TAPPING_TERM 200 -#endif - #ifndef NO_ACTION_ONESHOT uint8_t get_oneshot_mods(void); #endif @@ -171,7 +167,7 @@ void matrix_scan_tap_dance() { if (action->custom_tapping_term > 0) { tap_user_defined = action->custom_tapping_term; } else { - tap_user_defined = TAPPING_TERM; + tap_user_defined = get_tapping_term(action->state.keycode, NULL); } if (action->state.count && timer_elapsed(action->state.timer) > tap_user_defined) { process_tap_dance_action_on_dance_finished(action); From ace17e48b2572834fc12e46ac7ec838f3de7f7a0 Mon Sep 17 00:00:00 2001 From: a-chol Date: Sat, 25 Jul 2020 14:01:15 +0200 Subject: [PATCH 20/54] Hid joystick interface (#4226) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add support for hid gamepad interface add documentation for HID joystick Add joystick_task to read analog axes values even when no key is pressed or release. update doc Update docs/feature_joystick.md Manage pin setup and read to maintain matrix scan after analog read * Incorporates patches and changes to HID reporting There are some patches provided by @a-chol incorporated on this commit, and also some changes I made to the HID Report structure. The most interesting is the one dealing with number of buttons: Linux doesn't seem to care, but Windows requires the HID structure to be byte aligned (that's in the spec). So if one declares 8/16/32... buttons they should not have any issues, but this is what happens when you have 9 buttons: ``` bits |0|1|2|3|4|5|6|7| |*|*|*|*|*|*|*|*| axis 0 (report size 8) |*|*|*|*|*|*|*|*| ... |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| axis 6 |*|*|*|*|*|*|*|*| first 8 buttons (report size 1) |*| | | | | | | | last of 9 buttons, not aligned ``` So for that I added a conditonal that will add a number of reports with size 1 to make sure it aligns to the next multiple of 8. Those reports send dummy inputs that don't do anything aside from aligning the data. Tested on Linux, Windows 10 and Street Fighter (where the joystick is recognized as direct-input) * Add save and restore of each pin used in reading joystick (AVR). Allow output pin to be JS_VIRTUAL_AXIS if the axis is connected to Vcc instead of an output pin from the MCU. Fix joystick report id Fix broken v-usb hid joystick interface. Make it more resilient to unusual settings (none multiple of eight button count, 0 buttons or 0 axes) Correct adc reading for multiple axes. Piecewise range conversion for uncentered raw value range. Input, output and ground pin configuration per axis. Documentation fixes * Fix port addressing for joystick analog read * The other required set of changes As per the PR, the changes still holding it up. Add onekey for testing. Fix ARM builds. Fix device descriptor when either axes or buttons is zero. Add compile-time check for at least one axis or button. Move definition to try to fix conflict. PR review comments. qmk cformat * avoid float functions to compute range mapping for axis adc reading * Remove V-USB support for now. Updated docs accordingly. * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan * Add support for joystick adc reading for stm32 MCUs. Fix joystick hid report sending for chibios * Fix HID joystick report sending for ChibiOS. Add one analog axis to the onekey:joystick keymap. Fix pin state save and restore during joystick analog read for STM32 MCUs. * Update tmk_core/protocol/chibios/usb_main.c Co-Authored-By: Ryan * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan * Add missing mcuconf.h and halconf.h to onekey:joystick keymap. Add suggested fixes from PR. * Switch saveState and restoreState signature to use pin_t type. onekey:joystick : add a second axis, virtual and programmatically animated. * Update docs/feature_joystick.md Co-Authored-By: Ryan * Update docs/feature_joystick.md Co-Authored-By: Ryan * Add PR corrections * Remove halconf.h and mcuconf.h from onekey keymaps * Change ADC_PIN to A0 Co-authored-by: achol Co-authored-by: José Júnior Co-authored-by: a-chol Co-authored-by: Nick Brassel Co-authored-by: Ryan --- common_features.mk | 7 + docs/_summary.md | 1 + docs/feature_joystick.md | 145 +++++++++++++++ drivers/avr/analog.c | 10 +- .../onekey/keymaps/joystick/config.h | 3 + .../onekey/keymaps/joystick/keymap.c | 25 +++ .../onekey/keymaps/joystick/rules.mk | 1 + quantum/joystick.c | 13 ++ quantum/joystick.h | 54 ++++++ quantum/process_keycode/process_joystick.c | 168 ++++++++++++++++++ quantum/process_keycode/process_joystick.h | 11 ++ quantum/quantum.c | 3 + quantum/quantum.h | 4 + quantum/quantum_keycodes.h | 35 ++++ tmk_core/common/keyboard.c | 7 + tmk_core/common/report.h | 13 +- tmk_core/protocol/chibios/usb_main.c | 69 +++++++ tmk_core/protocol/lufa/lufa.c | 67 +++++++ tmk_core/protocol/usb_descriptor.c | 111 +++++++++++- tmk_core/protocol/usb_descriptor.h | 15 ++ 20 files changed, 758 insertions(+), 4 deletions(-) create mode 100644 docs/feature_joystick.md create mode 100644 keyboards/handwired/onekey/keymaps/joystick/config.h create mode 100644 keyboards/handwired/onekey/keymaps/joystick/keymap.c create mode 100644 keyboards/handwired/onekey/keymaps/joystick/rules.mk create mode 100644 quantum/joystick.c create mode 100644 quantum/joystick.h create mode 100644 quantum/process_keycode/process_joystick.c create mode 100644 quantum/process_keycode/process_joystick.h diff --git a/common_features.mk b/common_features.mk index 8443a759b3a7..f9fca4669ceb 100644 --- a/common_features.mk +++ b/common_features.mk @@ -529,3 +529,10 @@ ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes) OPT_DEFS += -DAUTO_SHIFT_MODIFIERS endif endif + +ifeq ($(strip $(JOYSTICK_ENABLE)), yes) + OPT_DEFS += -DJOYSTICK_ENABLE + SRC += $(QUANTUM_DIR)/process_keycode/process_joystick.c + SRC += $(QUANTUM_DIR)/joystick.c + SRC += analog.c +endif diff --git a/docs/_summary.md b/docs/_summary.md index 9ed55a3d062f..0c43712159fa 100644 --- a/docs/_summary.md +++ b/docs/_summary.md @@ -103,6 +103,7 @@ * [DIP Switch](feature_dip_switch.md) * [Encoders](feature_encoders.md) * [Haptic Feedback](feature_haptic_feedback.md) + * [Joystick](feature_joystick.md) * [Proton C Conversion](proton_c_conversion.md) * [PS/2 Mouse](feature_ps2_mouse.md) * [Split Keyboard](feature_split_keyboard.md) diff --git a/docs/feature_joystick.md b/docs/feature_joystick.md new file mode 100644 index 000000000000..58dfc7b8df55 --- /dev/null +++ b/docs/feature_joystick.md @@ -0,0 +1,145 @@ +## Joystick + +The keyboard can be made to be recognized as a joystick HID device by the operating system. + +This is enabled by adding the following to `rules.mk`: + +```makefile +JOYSTICK_ENABLE = yes +``` + +!> Joystick support is not currently available on V-USB devices. + +The joystick feature provides two services: + * reading analog input devices (eg. potentiometers) + * sending gamepad HID reports + +Both services can be used without the other, depending on whether you just want to read a device but not send gamepad reports (for volume control for instance) +or send gamepad reports based on values computed by the keyboard. + +### Analog Input + +An analog device such as a potentiometer found on a gamepad's analog axes is based on a [voltage divider](https://en.wikipedia.org/wiki/Voltage_divider). +It is composed of three connectors linked to the ground, the power input and power output (usually the middle one). The power output holds the voltage that varies based on the position of the cursor, +which value will be read using your MCU's [ADC](https://en.wikipedia.org/wiki/Analog-to-digital_converter). +Depending on which pins are already used by your keyboard's matrix, the rest of the circuit can get a little bit more complicated, +feeding the power input and ground connection through pins and using diodes to avoid bad interactions with the matrix scanning procedures. + +### Configuring the Joystick + +By default, two axes and eight buttons are defined. This can be changed in your `config.h`: + +```c +// Max 32 +#define JOYSTICK_BUTTON_COUNT 16 +// Max 6: X, Y, Z, Rx, Ry, Rz +#define JOYSTICK_AXES_COUNT 3 +``` + +When defining axes for your joystick, you have to provide a definition array. You can do this from your keymap.c file. +A joystick will either be read from an input pin that allows the use of the ADC, or can be virtual, so that its value is provided by your code. +You have to define an array of type ''joystick_config_t'' and of proper size. + +There are three ways for your circuit to work with the ADC, that relies on the use of 1, 2 or 3 pins of the MCU: + * 1 pin: your analog device is directly connected to your device GND and VCC. The only pin used is the ADC pin of your choice. + * 2 pins: your analog device is powered through a pin that allows toggling it on or off. The other pin is used to read the input value through the ADC. + * 3 pins: both the power input and ground are connected to pins that must be set to a proper state before reading and restored afterwards. + +The configuration of each axis is performed using one of four macros: + * `JOYSTICK_AXIS_VIRTUAL`: no ADC reading must be performed, that value will be provided by keyboard/keymap-level code + * `JOYSTICK_AXIS_IN(INPUT_PIN, LOW, REST, HIGH)`: a voltage will be read on the provided pin, which must be an ADC-capable pin. + * `JOYSTICK_AXIS_IN_OUT(INPUT_PIN, OUTPUT_PIN, LOW, REST, HIGH)`: the provided `OUTPUT_PIN` will be set high before `INPUT_PIN` is read. + * `JOYSTICK_AXIS_IN_OUT_GROUND(INPUT_PIN, OUTPUT_PIN, GROUND_PIN, LOW, REST, HIGH)`: the `OUTPUT_PIN` will be set high and `GROUND_PIN` will be set low before reading from `INPUT_PIN`. + +In any case where an ADC reading takes place (when `INPUT_PIN` is provided), additional `LOW`, `REST` and `HIGH` parameters are used. +These implement the calibration of the analog device by defining the range of read values that will be mapped to the lowest, resting position and highest possible value for the axis (-127 to 127). +In practice, you have to provide the lowest/highest raw ADC reading, and the raw reading at resting position, when no deflection is applied. You can provide inverted `LOW` and `HIGH` to invert the axis. + +For instance, an axes configuration can be defined in the following way: + +```c +//joystick config +joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = { + [0] = JOYSTICK_AXIS_IN_OUT_GROUND(A4, B0, A7, 900, 575, 285), + [1] = JOYSTICK_AXIS_VIRTUAL +}; +``` + +When the ADC reads 900 or higher, the returned axis value will be -127, whereas it will be 127 when the ADC reads 285 or lower. Zero is returned when 575 is read. + +In this example, the first axis will be read from the `A4` pin while `B0` is set high and `A7` is set low, using `analogReadPin()`, whereas the second axis will not be read. + +In order to give a value to the second axis, you can do so in any customizable entry point: as an action, in `process_record_user()` or in `matrix_scan_user()`, or even in `joystick_task()` which is called even when no key has been pressed. +You assign a value by writing to `joystick_status.axes[axis_index]` a signed 8-bit value (ranging from -127 to 127). Then it is necessary to assign the flag `JS_UPDATED` to `joystick_status.status` in order for an updated HID report to be sent. + +The following example writes two axes based on keypad presses, with `KC_P5` as a precision modifier: + +```c +#ifdef JOYSTICK_ENABLE +static uint8_t precision_val = 70; +static uint8_t axesFlags = 0; +enum axes { + Precision = 1, + Axis1High = 2, + Axis1Low = 4, + Axis2High = 8, + Axis2Low = 16 +}; +#endif + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch(keycode) { +#ifdef JOYSTICK_ENABLE + // virtual joystick +# if JOYSTICK_AXES_COUNT > 1 + case KC_P8: + if (record->event.pressed) { + axesFlags |= Axis2Low; + } else { + axesFlags &= ~Axis2Low; + } + joystick_status.status |= JS_UPDATED; + break; + case KC_P2: + if (record->event.pressed) { + axesFlags |= Axis2High; + } else { + axesFlags &= ~Axis2High; + } + joystick_status.status |= JS_UPDATED; + break; +# endif + case KC_P4: + if (record->event.pressed) { + axesFlags |= Axis1Low; + } else { + axesFlags &= ~Axis1Low; + } + joystick_status.status |= JS_UPDATED; + break; + case KC_P6: + if (record->event.pressed) { + axesFlags |= Axis1High; + } else { + axesFlags &= ~Axis1High; + } + joystick_status.status |= JS_UPDATED; + break; + case KC_P5: + if (record->event.pressed) { + axesFlags |= Precision; + } else { + axesFlags &= ~Precision; + } + joystick_status.status |= JS_UPDATED; + break; +#endif + } + return true; +} +``` + +### Triggering Joystick Buttons + +Joystick buttons are normal Quantum keycodes, defined as `JS_BUTTON0` to `JS_BUTTON31`, depending on the number of buttons you have configured. +To trigger a joystick button, just add the corresponding keycode to your keymap. diff --git a/drivers/avr/analog.c b/drivers/avr/analog.c index 9b8397b933f3..8d299ffdb923 100644 --- a/drivers/avr/analog.c +++ b/drivers/avr/analog.c @@ -97,10 +97,11 @@ uint8_t pinToMux(pin_t pin) { #endif // clang-format on } + return 0; } int16_t adc_read(uint8_t mux) { - uint8_t low; + uint16_t low; // Enable ADC and configure prescaler ADCSRA = _BV(ADEN) | ADC_PRESCALER; @@ -128,5 +129,10 @@ int16_t adc_read(uint8_t mux) { // Must read LSB first low = ADCL; // Must read MSB only once! - return (ADCH << 8) | low; + low |= (ADCH << 8); + + // turn off the ADC + ADCSRA &= ~(1 << ADEN); + + return low; } diff --git a/keyboards/handwired/onekey/keymaps/joystick/config.h b/keyboards/handwired/onekey/keymaps/joystick/config.h new file mode 100644 index 000000000000..5701d80c84c0 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/joystick/config.h @@ -0,0 +1,3 @@ +#pragma once +#define JOYSTICK_AXES_COUNT 2 +#define JOYSTICK_BUTTON_COUNT 1 diff --git a/keyboards/handwired/onekey/keymaps/joystick/keymap.c b/keyboards/handwired/onekey/keymaps/joystick/keymap.c new file mode 100644 index 000000000000..60802f464a90 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/joystick/keymap.c @@ -0,0 +1,25 @@ +#include QMK_KEYBOARD_H + +#include "joystick.h" + +#ifndef ADC_PIN +# define ADC_PIN F6 +#endif + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + LAYOUT( JS_BUTTON0 ) +}; + +void matrix_scan_user() { + int16_t val = (((uint32_t)timer_read()%5000 - 2500) * 255) / 5000; + if (val != joystick_status.axes[1]) { + joystick_status.axes[1] = val; + joystick_status.status |= JS_UPDATED; + } +} + +//joystick config +joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = { + [0] = JOYSTICK_AXIS_IN(ADC_PIN, 0, 512, 1023) + , [1] = JOYSTICK_AXIS_VIRTUAL +}; \ No newline at end of file diff --git a/keyboards/handwired/onekey/keymaps/joystick/rules.mk b/keyboards/handwired/onekey/keymaps/joystick/rules.mk new file mode 100644 index 000000000000..fbddbc6de118 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/joystick/rules.mk @@ -0,0 +1 @@ +JOYSTICK_ENABLE = yes diff --git a/quantum/joystick.c b/quantum/joystick.c new file mode 100644 index 000000000000..7b87201aef98 --- /dev/null +++ b/quantum/joystick.c @@ -0,0 +1,13 @@ +#include "joystick.h" + +joystick_t joystick_status = {.buttons = {0}, + .axes = + { +#if JOYSTICK_AXES_COUNT > 0 + 0 +#endif + }, + .status = 0}; + +// array defining the reading of analog values for each axis +__attribute__((weak)) joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {}; diff --git a/quantum/joystick.h b/quantum/joystick.h new file mode 100644 index 000000000000..a95472b9fd44 --- /dev/null +++ b/quantum/joystick.h @@ -0,0 +1,54 @@ +#pragma once + +#ifndef JOYSTICK_BUTTON_COUNT +# define JOYSTICK_BUTTON_COUNT 8 +#endif + +#ifndef JOYSTICK_AXES_COUNT +# define JOYSTICK_AXES_COUNT 4 +#endif + +#include "quantum.h" + +#include + +// configure on input_pin of the joystick_axes array entry to JS_VIRTUAL_AXIS +// to prevent it from being read from the ADC. This allows outputing forged axis value. +// +#define JS_VIRTUAL_AXIS 0xFF + +#define JOYSTICK_AXIS_VIRTUAL \ + { JS_VIRTUAL_AXIS, JS_VIRTUAL_AXIS, JS_VIRTUAL_AXIS, 0, 1023 } +#define JOYSTICK_AXIS_IN(INPUT_PIN, LOW, REST, HIGH) \ + { JS_VIRTUAL_AXIS, INPUT_PIN, JS_VIRTUAL_AXIS, LOW, REST, HIGH } +#define JOYSTICK_AXIS_IN_OUT(INPUT_PIN, OUTPUT_PIN, LOW, REST, HIGH) \ + { OUTPUT_PIN, INPUT_PIN, JS_VIRTUAL_AXIS, LOW, REST, HIGH } +#define JOYSTICK_AXIS_IN_OUT_GROUND(INPUT_PIN, OUTPUT_PIN, GROUND_PIN, LOW, REST, HIGH) \ + { OUTPUT_PIN, INPUT_PIN, GROUND_PIN, LOW, REST, HIGH } + +typedef struct { + pin_t output_pin; + pin_t input_pin; + pin_t ground_pin; + + // the AVR ADC offers 10 bit precision, with significant bits on the higher part + uint16_t min_digit; + uint16_t mid_digit; + uint16_t max_digit; +} joystick_config_t; + +extern joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT]; + +enum joystick_status { JS_INITIALIZED = 1, JS_UPDATED = 2 }; + +typedef struct { + uint8_t buttons[JOYSTICK_BUTTON_COUNT / 8 + 1]; + + int16_t axes[JOYSTICK_AXES_COUNT]; + uint8_t status : 2; +} joystick_t; + +extern joystick_t joystick_status; + +// to be implemented in the hid protocol library +void send_joystick_packet(joystick_t *joystick); diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c new file mode 100644 index 000000000000..c12f7568544f --- /dev/null +++ b/quantum/process_keycode/process_joystick.c @@ -0,0 +1,168 @@ +#include "joystick.h" +#include "process_joystick.h" + +#include "analog.h" + +#include +#include + +bool process_joystick_buttons(uint16_t keycode, keyrecord_t *record); + +bool process_joystick(uint16_t keycode, keyrecord_t *record) { + if (process_joystick_buttons(keycode, record) && (joystick_status.status & JS_UPDATED) > 0) { + send_joystick_packet(&joystick_status); + joystick_status.status &= ~JS_UPDATED; + } + + return true; +} + +__attribute__((weak)) +void joystick_task(void) { + if (process_joystick_analogread() && (joystick_status.status & JS_UPDATED)) { + send_joystick_packet(&joystick_status); + joystick_status.status &= ~JS_UPDATED; + } +} + +bool process_joystick_buttons(uint16_t keycode, keyrecord_t *record) { + if (keycode < JS_BUTTON0 || keycode > JS_BUTTON_MAX) { + return true; + } else { + if (record->event.pressed) { + joystick_status.buttons[(keycode - JS_BUTTON0) / 8] |= 1 << (keycode % 8); + } else { + joystick_status.buttons[(keycode - JS_BUTTON0) / 8] &= ~(1 << (keycode % 8)); + } + + joystick_status.status |= JS_UPDATED; + } + + return true; +} + +uint16_t savePinState(pin_t pin) { +#ifdef __AVR__ + uint8_t pinNumber = pin & 0xF; + return ((PORTx_ADDRESS(pin) >> pinNumber) & 0x1) << 1 | ((DDRx_ADDRESS(pin) >> pinNumber) & 0x1); +#elif defined(PROTOCOL_CHIBIOS) + /* + The pin configuration is backed up in the following format : + bit 15 9 8 7 6 5 4 3 2 1 0 + |unused|ODR|IDR|PUPDR|OSPEEDR|OTYPER|MODER| + */ + return (( PAL_PORT(pin)->MODER >> (2*PAL_PAD(pin))) & 0x3) + | (((PAL_PORT(pin)->OTYPER >> (1*PAL_PAD(pin))) & 0x1) << 2) + | (((PAL_PORT(pin)->OSPEEDR >> (2*PAL_PAD(pin))) & 0x3) << 3) + | (((PAL_PORT(pin)->PUPDR >> (2*PAL_PAD(pin))) & 0x3) << 5) + | (((PAL_PORT(pin)->IDR >> (1*PAL_PAD(pin))) & 0x1) << 7) + | (((PAL_PORT(pin)->ODR >> (1*PAL_PAD(pin))) & 0x1) << 8); +#else + return 0; +#endif +} + +void restorePinState(pin_t pin, uint16_t restoreState) { +#if defined(PROTOCOL_LUFA) + uint8_t pinNumber = pin & 0xF; + PORTx_ADDRESS(pin) = (PORTx_ADDRESS(pin) & ~_BV(pinNumber)) | (((restoreState >> 1) & 0x1) << pinNumber); + DDRx_ADDRESS(pin) = (DDRx_ADDRESS(pin) & ~_BV(pinNumber)) | ((restoreState & 0x1) << pinNumber); +#elif defined(PROTOCOL_CHIBIOS) + PAL_PORT(pin)->MODER = (PAL_PORT(pin)->MODER & ~(0x3<< (2*PAL_PAD(pin)))) | (restoreState & 0x3) << (2*PAL_PAD(pin)); + PAL_PORT(pin)->OTYPER = (PAL_PORT(pin)->OTYPER & ~(0x1<< (1*PAL_PAD(pin)))) | ((restoreState>>2) & 0x1) << (1*PAL_PAD(pin)); + PAL_PORT(pin)->OSPEEDR= (PAL_PORT(pin)->OSPEEDR & ~(0x3<< (2*PAL_PAD(pin)))) | ((restoreState>>3) & 0x3) << (2*PAL_PAD(pin)); + PAL_PORT(pin)->PUPDR = (PAL_PORT(pin)->PUPDR & ~(0x3<< (2*PAL_PAD(pin)))) | ((restoreState>>5) & 0x3) << (2*PAL_PAD(pin)); + PAL_PORT(pin)->IDR = (PAL_PORT(pin)->IDR & ~(0x1<< (1*PAL_PAD(pin)))) | ((restoreState>>7) & 0x1) << (1*PAL_PAD(pin)); + PAL_PORT(pin)->ODR = (PAL_PORT(pin)->ODR & ~(0x1<< (1*PAL_PAD(pin)))) | ((restoreState>>8) & 0x1) << (1*PAL_PAD(pin)); +#else + return; +#endif +} + +__attribute__((weak)) bool process_joystick_analogread() { return process_joystick_analogread_quantum(); } + +bool process_joystick_analogread_quantum() { +#if JOYSTICK_AXES_COUNT > 0 + for (int axis_index = 0; axis_index < JOYSTICK_AXES_COUNT; ++axis_index) { + if (joystick_axes[axis_index].input_pin == JS_VIRTUAL_AXIS) { + continue; + } + + // save previous input pin status as well + uint16_t inputSavedState = savePinState(joystick_axes[axis_index].input_pin); + + // disable pull-up resistor + writePinLow(joystick_axes[axis_index].input_pin); + + // if pin was a pull-up input, we need to uncharge it by turning it low + // before making it a low input + setPinOutput(joystick_axes[axis_index].input_pin); + + wait_us(10); + + // save and apply output pin status + uint16_t outputSavedState = 0; + if (joystick_axes[axis_index].output_pin != JS_VIRTUAL_AXIS) { + // save previous output pin status + outputSavedState = savePinState(joystick_axes[axis_index].output_pin); + + setPinOutput(joystick_axes[axis_index].output_pin); + writePinHigh(joystick_axes[axis_index].output_pin); + } + + uint16_t groundSavedState = 0; + if (joystick_axes[axis_index].ground_pin != JS_VIRTUAL_AXIS) { + // save previous output pin status + groundSavedState = savePinState(joystick_axes[axis_index].ground_pin); + + setPinOutput(joystick_axes[axis_index].ground_pin); + writePinLow(joystick_axes[axis_index].ground_pin); + } + + wait_us(10); + + setPinInput(joystick_axes[axis_index].input_pin); + + wait_us(10); + +# if defined(__AVR__) || defined(PROTOCOL_CHIBIOS) + int16_t axis_val = analogReadPin(joystick_axes[axis_index].input_pin); +# else + // default to resting position + int16_t axis_val = joystick_axes[axis_index].mid_digit; +# endif + + //test the converted value against the lower range + int32_t ref = joystick_axes[axis_index].mid_digit; + int32_t range = joystick_axes[axis_index].min_digit; + int32_t ranged_val = ((axis_val - ref) * -127) / (range - ref) ; + + if (ranged_val > 0) { + //the value is in the higher range + range = joystick_axes[axis_index].max_digit; + ranged_val = ((axis_val - ref) * 127) / (range - ref); + } + + //clamp the result in the valid range + ranged_val = ranged_val < -127 ? -127 : ranged_val; + ranged_val = ranged_val > 127 ? 127 : ranged_val; + + if (ranged_val != joystick_status.axes[axis_index]) { + joystick_status.axes[axis_index] = ranged_val; + joystick_status.status |= JS_UPDATED; + } + + // restore output, ground and input status + if (joystick_axes[axis_index].output_pin != JS_VIRTUAL_AXIS) { + restorePinState(joystick_axes[axis_index].output_pin, outputSavedState); + } + if (joystick_axes[axis_index].ground_pin != JS_VIRTUAL_AXIS) { + restorePinState(joystick_axes[axis_index].ground_pin, groundSavedState); + } + + restorePinState(joystick_axes[axis_index].input_pin, inputSavedState); + } + +#endif + return true; +} diff --git a/quantum/process_keycode/process_joystick.h b/quantum/process_keycode/process_joystick.h new file mode 100644 index 000000000000..7a8b82913aa1 --- /dev/null +++ b/quantum/process_keycode/process_joystick.h @@ -0,0 +1,11 @@ +#pragma once + +#include +#include "quantum.h" + +bool process_joystick(uint16_t keycode, keyrecord_t *record); + +void joystick_task(void); + +bool process_joystick_analogread(void); +bool process_joystick_analogread_quantum(void); diff --git a/quantum/quantum.c b/quantum/quantum.c index 9d63f4de2788..dab6c9172fc0 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -276,6 +276,9 @@ bool process_record_quantum(keyrecord_t *record) { #endif #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) process_rgb(keycode, record) && +#endif +#ifdef JOYSTICK_ENABLE + process_joystick(keycode, record) && #endif true)) { return false; diff --git a/quantum/quantum.h b/quantum/quantum.h index 51deac0cd525..a2c0ec9a286b 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -142,6 +142,10 @@ extern layer_state_t layer_state; # include "process_magic.h" #endif +#ifdef JOYSTICK_ENABLE +# include "process_joystick.h" +#endif + #ifdef GRAVE_ESC_ENABLE # include "process_grave_esc.h" #endif diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index d8f1fa4bbbc2..0de297b8753e 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -512,6 +512,41 @@ enum quantum_keycodes { DYN_MACRO_PLAY1, DYN_MACRO_PLAY2, + JS_BUTTON0, + JS_BUTTON_MIN = JS_BUTTON0, + JS_BUTTON1, + JS_BUTTON2, + JS_BUTTON3, + JS_BUTTON4, + JS_BUTTON5, + JS_BUTTON6, + JS_BUTTON7, + JS_BUTTON8, + JS_BUTTON9, + JS_BUTTON10, + JS_BUTTON11, + JS_BUTTON12, + JS_BUTTON13, + JS_BUTTON14, + JS_BUTTON15, + JS_BUTTON16, + JS_BUTTON17, + JS_BUTTON18, + JS_BUTTON19, + JS_BUTTON20, + JS_BUTTON21, + JS_BUTTON22, + JS_BUTTON23, + JS_BUTTON24, + JS_BUTTON25, + JS_BUTTON26, + JS_BUTTON27, + JS_BUTTON28, + JS_BUTTON29, + JS_BUTTON30, + JS_BUTTON31, + JS_BUTTON_MAX = JS_BUTTON31, + // always leave at the end SAFE_RANGE }; diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 714c3d048f07..a45af56dfdbb 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -74,6 +74,9 @@ along with this program. If not, see . #ifdef MIDI_ENABLE # include "process_midi.h" #endif +#ifdef JOYSTICK_ENABLE +# include "process_joystick.h" +#endif #ifdef HD44780_ENABLE # include "hd44780.h" #endif @@ -420,6 +423,10 @@ void keyboard_task(void) { } #endif +#ifdef JOYSTICK_ENABLE + joystick_task(); +#endif + // update LED if (led_status != host_keyboard_leds()) { led_status = host_keyboard_leds(); diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index 1b2f13bdde27..1aa33c998d1e 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h @@ -29,7 +29,8 @@ enum hid_report_ids { REPORT_ID_MOUSE, REPORT_ID_SYSTEM, REPORT_ID_CONSUMER, - REPORT_ID_NKRO + REPORT_ID_NKRO, + REPORT_ID_JOYSTICK }; /* Mouse buttons */ @@ -189,6 +190,16 @@ typedef struct { int8_t h; } __attribute__((packed)) report_mouse_t; +typedef struct { +#if JOYSTICK_AXES_COUNT > 0 + int8_t axes[JOYSTICK_AXES_COUNT]; +#endif + +#if JOYSTICK_BUTTON_COUNT > 0 + uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1]; +#endif +} __attribute__((packed)) joystick_report_t; + /* keycode to system usage */ static inline uint16_t KEYCODE2SYSTEM(uint8_t key) { switch (key) { diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 21e9f14e50a8..68c61cf55084 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -47,6 +47,10 @@ extern keymap_config_t keymap_config; #endif +#ifdef JOYSTICK_ENABLE +# include "joystick.h" +#endif + /* --------------------------------------------------------- * Global interface variables and declarations * --------------------------------------------------------- @@ -246,6 +250,9 @@ typedef struct { #endif #ifdef VIRTSER_ENABLE usb_driver_config_t serial_driver; +#endif +#ifdef JOYSTICK_ENABLE + usb_driver_config_t joystick_driver; #endif }; usb_driver_config_t array[0]; @@ -283,6 +290,14 @@ static usb_driver_configs_t drivers = { # define CDC_OUT_MODE USB_EP_MODE_TYPE_BULK .serial_driver = QMK_USB_DRIVER_CONFIG(CDC, CDC_NOTIFICATION_EPNUM, false), #endif + +#ifdef JOYSTICK_ENABLE +# define JOYSTICK_IN_CAPACITY 4 +# define JOYSTICK_OUT_CAPACITY 4 +# define JOYSTICK_IN_MODE USB_EP_MODE_TYPE_BULK +# define JOYSTICK_OUT_MODE USB_EP_MODE_TYPE_BULK + .joystick_driver = QMK_USB_DRIVER_CONFIG(JOYSTICK, 0, false), +#endif }; #define NUM_USB_DRIVERS (sizeof(drivers) / sizeof(usb_driver_config_t)) @@ -867,3 +882,57 @@ void virtser_task(void) { } #endif + +#ifdef JOYSTICK_ENABLE + +void send_joystick_packet(joystick_t *joystick) { + joystick_report_t rep = { +# if JOYSTICK_AXES_COUNT > 0 + .axes = {joystick->axes[0], + +# if JOYSTICK_AXES_COUNT >= 2 + joystick->axes[1], +# endif +# if JOYSTICK_AXES_COUNT >= 3 + joystick->axes[2], +# endif +# if JOYSTICK_AXES_COUNT >= 4 + joystick->axes[3], +# endif +# if JOYSTICK_AXES_COUNT >= 5 + joystick->axes[4], +# endif +# if JOYSTICK_AXES_COUNT >= 6 + joystick->axes[5], +# endif + }, +# endif // JOYSTICK_AXES_COUNT>0 + +# if JOYSTICK_BUTTON_COUNT > 0 + .buttons = {joystick->buttons[0], + +# if JOYSTICK_BUTTON_COUNT > 8 + joystick->buttons[1], +# endif +# if JOYSTICK_BUTTON_COUNT > 16 + joystick->buttons[2], +# endif +# if JOYSTICK_BUTTON_COUNT > 24 + joystick->buttons[3], +# endif + } +# endif // JOYSTICK_BUTTON_COUNT>0 + }; + + // chnWrite(&drivers.joystick_driver.driver, (uint8_t *)&rep, sizeof(rep)); + osalSysLock(); + if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { + osalSysUnlock(); + return; + } + + usbStartTransmitI(&USB_DRIVER, JOYSTICK_IN_EPNUM, (uint8_t *)&rep, sizeof(joystick_report_t)); + osalSysUnlock(); +} + +#endif diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 6776a964e976..85603646db98 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -85,6 +85,10 @@ extern keymap_config_t keymap_config; # include "raw_hid.h" #endif +#ifdef JOYSTICK_ENABLE +# include "joystick.h" +#endif + uint8_t keyboard_idle = 0; /* 0: Boot Protocol, 1: Report Protocol(default) */ uint8_t keyboard_protocol = 1; @@ -263,6 +267,66 @@ static void Console_Task(void) { } #endif +/******************************************************************************* + * Joystick + ******************************************************************************/ +#ifdef JOYSTICK_ENABLE +void send_joystick_packet(joystick_t *joystick) { + uint8_t timeout = 255; + + joystick_report_t r = { +# if JOYSTICK_AXES_COUNT > 0 + .axes = {joystick->axes[0], + +# if JOYSTICK_AXES_COUNT >= 2 + joystick->axes[1], +# endif +# if JOYSTICK_AXES_COUNT >= 3 + joystick->axes[2], +# endif +# if JOYSTICK_AXES_COUNT >= 4 + joystick->axes[3], +# endif +# if JOYSTICK_AXES_COUNT >= 5 + joystick->axes[4], +# endif +# if JOYSTICK_AXES_COUNT >= 6 + joystick->axes[5], +# endif + }, +# endif // JOYSTICK_AXES_COUNT>0 + +# if JOYSTICK_BUTTON_COUNT > 0 + .buttons = {joystick->buttons[0], + +# if JOYSTICK_BUTTON_COUNT > 8 + joystick->buttons[1], +# endif +# if JOYSTICK_BUTTON_COUNT > 16 + joystick->buttons[2], +# endif +# if JOYSTICK_BUTTON_COUNT > 24 + joystick->buttons[3], +# endif + } +# endif // JOYSTICK_BUTTON_COUNT>0 + }; + + /* Select the Joystick Report Endpoint */ + Endpoint_SelectEndpoint(JOYSTICK_IN_EPNUM); + + /* Check if write ready for a polling interval around 10ms */ + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); + if (!Endpoint_IsReadWriteAllowed()) return; + + /* Write Joystick Report Data */ + Endpoint_Write_Stream_LE(&r, sizeof(joystick_report_t), NULL); + + /* Finalize the stream transfer to send the last packet */ + Endpoint_ClearIN(); +} +#endif + /******************************************************************************* * USB Events ******************************************************************************/ @@ -411,6 +475,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) { ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_BULK, CDC_EPSIZE, 1); ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, CDC_EPSIZE, 1); #endif +#ifdef JOYSTICK_ENABLE + ConfigSuccess &= ENDPOINT_CONFIG(JOYSTICK_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, JOYSTICK_EPSIZE, ENDPOINT_BANK_SINGLE); +#endif } /* FIXME: Expose this table in the docs somehow diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index bcca24586766..f5d32445de50 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -279,6 +279,63 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = { }; #endif +#ifdef JOYSTICK_ENABLE +# if JOYSTICK_AXES_COUNT == 0 && JOYSTICK_BUTTON_COUNT == 0 +# error Need at least one axis or button for joystick +# endif +const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] = { + HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop + HID_RI_USAGE(8, 0x04), // Joystick + HID_RI_COLLECTION(8, 0x01), // Application + HID_RI_COLLECTION(8, 0x00), // Physical + HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop +# if JOYSTICK_AXES_COUNT >= 1 + HID_RI_USAGE(8, 0x30), // X +# endif +# if JOYSTICK_AXES_COUNT >= 2 + HID_RI_USAGE(8, 0x31), // Y +# endif +# if JOYSTICK_AXES_COUNT >= 3 + HID_RI_USAGE(8, 0x32), // Z +# endif +# if JOYSTICK_AXES_COUNT >= 4 + HID_RI_USAGE(8, 0x33), // Rx +# endif +# if JOYSTICK_AXES_COUNT >= 5 + HID_RI_USAGE(8, 0x34), // Ry +# endif +# if JOYSTICK_AXES_COUNT >= 6 + HID_RI_USAGE(8, 0x35), // Rz +# endif +# if JOYSTICK_AXES_COUNT >= 1 + HID_RI_LOGICAL_MINIMUM(8, -127), + HID_RI_LOGICAL_MAXIMUM(8, 127), + HID_RI_REPORT_COUNT(8, JOYSTICK_AXES_COUNT), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), +# endif + +# if JOYSTICK_BUTTON_COUNT >= 1 + HID_RI_USAGE_PAGE(8, 0x09), // Button + HID_RI_USAGE_MINIMUM(8, 0x01), + HID_RI_USAGE_MAXIMUM(8, JOYSTICK_BUTTON_COUNT), + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0x01), + HID_RI_REPORT_COUNT(8, JOYSTICK_BUTTON_COUNT), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + +# if (JOYSTICK_BUTTON_COUNT % 8) != 0 + HID_RI_REPORT_COUNT(8, 8 - (JOYSTICK_BUTTON_COUNT % 8)), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_INPUT(8, HID_IOF_CONSTANT), +# endif +# endif + HID_RI_END_COLLECTION(0), + HID_RI_END_COLLECTION(0) +}; +#endif + /* * Device descriptor */ @@ -288,7 +345,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = { .Type = DTYPE_Device }, .USBSpecification = VERSION_BCD(1, 1, 0), - + #if VIRTSER_ENABLE .Class = USB_CSCP_IADDeviceClass, .SubClass = USB_CSCP_IADDeviceSubclass, @@ -813,6 +870,46 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .PollingIntervalMS = 0x05 }, #endif + + /* + * Joystick + */ +#ifdef JOYSTICK_ENABLE + .Joystick_Interface = { + .Header = { + .Size = sizeof(USB_Descriptor_Interface_t), + .Type = DTYPE_Interface + }, + .InterfaceNumber = JOYSTICK_INTERFACE, + .AlternateSetting = 0x00, + .TotalEndpoints = 1, + .Class = HID_CSCP_HIDClass, + .SubClass = HID_CSCP_NonBootSubclass, + .Protocol = HID_CSCP_NonBootProtocol, + .InterfaceStrIndex = NO_DESCRIPTOR + }, + .Joystick_HID = { + .Header = { + .Size = sizeof(USB_HID_Descriptor_HID_t), + .Type = HID_DTYPE_HID + }, + .HIDSpec = VERSION_BCD(1, 1, 1), + .CountryCode = 0x00, + .TotalReportDescriptors = 1, + .HIDReportType = HID_DTYPE_Report, + .HIDReportLength = sizeof(JoystickReport) + }, + .Joystick_INEndpoint = { + .Header = { + .Size = sizeof(USB_Descriptor_Endpoint_t), + .Type = DTYPE_Endpoint + }, + .EndpointAddress = (ENDPOINT_DIR_IN | JOYSTICK_IN_EPNUM), + .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = JOYSTICK_EPSIZE, + .PollingIntervalMS = USB_POLLING_INTERVAL_MS + } +#endif }; /* @@ -945,6 +1042,12 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const break; #endif +#ifdef JOYSTICK_ENABLE + case JOYSTICK_INTERFACE: + Address = &ConfigurationDescriptor.Joystick_HID; + Size = sizeof(USB_HID_Descriptor_HID_t); + break; +#endif } break; @@ -989,6 +1092,12 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const break; #endif +#ifdef JOYSTICK_ENABLE + case JOYSTICK_INTERFACE: + Address = &JoystickReport; + Size = sizeof(JoystickReport); + break; +#endif } break; diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h index 34a85978a6b3..79dd87014f99 100644 --- a/tmk_core/protocol/usb_descriptor.h +++ b/tmk_core/protocol/usb_descriptor.h @@ -123,6 +123,13 @@ typedef struct { USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; USB_Descriptor_Endpoint_t CDC_DataInEndpoint; #endif + +#ifdef JOYSTICK_ENABLE + // Joystick HID Interface + USB_Descriptor_Interface_t Joystick_Interface; + USB_HID_Descriptor_HID_t Joystick_HID; + USB_Descriptor_Endpoint_t Joystick_INEndpoint; +#endif } USB_Descriptor_Configuration_t; /* @@ -164,6 +171,9 @@ enum usb_interfaces { CDI_INTERFACE, #endif +#if defined(JOYSTICK_ENABLE) + JOYSTICK_INTERFACE, +#endif TOTAL_INTERFACES }; @@ -219,6 +229,10 @@ enum usb_endpoints { CDC_IN_EPNUM = NEXT_EPNUM, CDC_OUT_EPNUM = NEXT_EPNUM, #endif +#ifdef JOYSTICK_ENABLE + JOYSTICK_IN_EPNUM = NEXT_EPNUM, + JOYSTICK_OUT_EPNUM = NEXT_EPNUM, +#endif }; #ifdef PROTOCOL_LUFA @@ -243,6 +257,7 @@ enum usb_endpoints { #define MIDI_STREAM_EPSIZE 64 #define CDC_NOTIFICATION_EPSIZE 8 #define CDC_EPSIZE 16 +#define JOYSTICK_EPSIZE 8 uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const void** const DescriptorAddress); #endif From f9267ec27f48412bc93ca77be855064694997a91 Mon Sep 17 00:00:00 2001 From: Max Rumpf Date: Sun, 26 Jul 2020 01:00:33 +0200 Subject: [PATCH 21/54] Tweak the Christmas animation effect to be less harsh on the eyes (#7648) * Tweak the Christmas animation effect to be less harsh on the eyes * Further improve the tweaked Christmas animation code - Use constants where it makes sense - Instead of complicated math, use a static variable to keep track if it's animating from or to red - Don't use pow (but a simple macro instead) - Using floating point math is necessary for the fraction in the cubic bezier function to work * Update docs for the tweaked Christmas animation effect * Further improve memory usage - Don't use floats, but 32 bit ints instead (where needed) - Replace limits.h with constant * Fix typo --- docs/feature_rgblight.md | 24 ++++++++++++------------ quantum/rgblight.c | 31 +++++++++++++++++++++++++++---- quantum/rgblight.h | 2 +- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md index a81b50e828a9..51fd79da2fd2 100644 --- a/docs/feature_rgblight.md +++ b/docs/feature_rgblight.md @@ -126,19 +126,19 @@ Use these defines to add or remove animations from the firmware. When you are ru The following options are used to tweak the various animations: -|Define |Default |Description | -|------------------------------------|-------------|-------------------------------------------------------------------------------------| +|Define |Default |Description | +|------------------------------------|-------------|-----------------------------------------------------------------------------------------------| |`RGBLIGHT_EFFECT_BREATHE_CENTER` |*Not defined*|If defined, used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7 | -|`RGBLIGHT_EFFECT_BREATHE_MAX` |`255` |The maximum brightness for the breathing mode. Valid values are 1 to 255 | -|`RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL`|`1000` |How long to wait between light changes for the "Christmas" animation, in milliseconds| -|`RGBLIGHT_EFFECT_CHRISTMAS_STEP` |`2` |The number of LEDs to group the red/green colors by for the "Christmas" animation | -|`RGBLIGHT_EFFECT_KNIGHT_LED_NUM` |`RGBLED_NUM` |The number of LEDs to have the "Knight" animation travel | -|`RGBLIGHT_EFFECT_KNIGHT_LENGTH` |`3` |The number of LEDs to light up for the "Knight" animation | -|`RGBLIGHT_EFFECT_KNIGHT_OFFSET` |`0` |The number of LEDs to start the "Knight" animation from the start of the strip by | -|`RGBLIGHT_RAINBOW_SWIRL_RANGE` |`255` |Range adjustment for the rainbow swirl effect to get different swirls | -|`RGBLIGHT_EFFECT_SNAKE_LENGTH` |`4` |The number of LEDs to light up for the "Snake" animation | -|`RGBLIGHT_EFFECT_TWINKLE_LIFE` |`75` |Adjusts how quickly each LED brightens and dims when twinkling (in animation steps) | -|`RGBLIGHT_EFFECT_TWINKLE_PROBABILITY`|`1/127` |Adjusts how likely each LED is to twinkle (on each animation step) | +|`RGBLIGHT_EFFECT_BREATHE_MAX` |`255` |The maximum brightness for the breathing mode. Valid values are 1 to 255 | +|`RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL`|`40` |How long (in milliseconds) to wait between animation steps for the "Christmas" animation | +|`RGBLIGHT_EFFECT_CHRISTMAS_STEP` |`2` |The number of LEDs to group the red/green colors by for the "Christmas" animation | +|`RGBLIGHT_EFFECT_KNIGHT_LED_NUM` |`RGBLED_NUM` |The number of LEDs to have the "Knight" animation travel | +|`RGBLIGHT_EFFECT_KNIGHT_LENGTH` |`3` |The number of LEDs to light up for the "Knight" animation | +|`RGBLIGHT_EFFECT_KNIGHT_OFFSET` |`0` |The number of LEDs to start the "Knight" animation from the start of the strip by | +|`RGBLIGHT_RAINBOW_SWIRL_RANGE` |`255` |Range adjustment for the rainbow swirl effect to get different swirls | +|`RGBLIGHT_EFFECT_SNAKE_LENGTH` |`4` |The number of LEDs to light up for the "Snake" animation | +|`RGBLIGHT_EFFECT_TWINKLE_LIFE` |`75` |Adjusts how quickly each LED brightens and dims when twinkling (in animation steps) | +|`RGBLIGHT_EFFECT_TWINKLE_PROBABILITY`|`1/127` |Adjusts how likely each LED is to twinkle (on each animation step) | ### Example Usage to Reduce Memory Footprint 1. Remove `RGBLIGHT_ANIMATIONS` from `config.h`. diff --git a/quantum/rgblight.c b/quantum/rgblight.c index d33484ccfdf2..0c919bb44f4d 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -1152,16 +1152,39 @@ void rgblight_effect_knight(animation_status_t *anim) { #endif #ifdef RGBLIGHT_EFFECT_CHRISTMAS +# define CUBED(x) ((x) * (x) * (x)) + +/** + * Christmas lights effect, with a smooth animation between red & green. + */ void rgblight_effect_christmas(animation_status_t *anim) { - uint8_t hue; + static int8_t increment = 1; + const uint8_t max_pos = 32; + const uint8_t hue_green = 85; + + uint32_t xa; + uint8_t hue, val; uint8_t i; - anim->current_offset = (anim->current_offset + 1) % 2; + // The effect works by animating anim->pos from 0 to 32 and back to 0. + // The pos is used in a cubic bezier formula to ease-in-out between red and green, leaving the interpolated colors visible as short as possible. + xa = CUBED((uint32_t) anim->pos); + hue = ((uint32_t) hue_green) * xa / (xa + CUBED((uint32_t) (max_pos - anim->pos))); + // Additionally, these interpolated colors get shown with a slightly darker value, to make them less prominent than the main colors. + val = 255 - (3 * (hue < hue_green / 2 ? hue : hue_green - hue) / 2); + for (i = 0; i < rgblight_ranges.effect_num_leds; i++) { - hue = 0 + ((i / RGBLIGHT_EFFECT_CHRISTMAS_STEP + anim->current_offset) % 2) * 85; - sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]); + uint8_t local_hue = (i / RGBLIGHT_EFFECT_CHRISTMAS_STEP) % 2 ? hue : hue_green - hue; + sethsv(local_hue, rgblight_config.sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]); } rgblight_set(); + + if (anim->pos == 0) { + increment = 1; + } else if (anim->pos == max_pos) { + increment = -1; + } + anim->pos += increment; } #endif diff --git a/quantum/rgblight.h b/quantum/rgblight.h index c36b328a35f8..f3314c4aaf31 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h @@ -142,7 +142,7 @@ enum RGBLIGHT_EFFECT_MODE { # endif # ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL -# define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000 +# define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 40 # endif # ifndef RGBLIGHT_EFFECT_CHRISTMAS_STEP From d189a57d2de31682bf10e135b617275e156c753c Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 27 Jul 2020 14:46:39 -0700 Subject: [PATCH 22/54] Initialize Layer State on startup (#8318) * Initialize Layer State on startup Right now, on startup, the default layer state gets called and set, triggering the callback functions for the default layer state. However, the normal layer state never actually gets initialized. It's set to 0 directly, by default, but the callback functions are never actually called. This creates some inconsistency in the behavior for end users. This adds a simple "clear" that triggers the callback on startup. This should produce more consisten behavior between the two functions and layer masks. * Stupid hack * Fix type casting? * Fix compile issues with magic is disabled --- tmk_core/common/action_layer.h | 6 ++++-- tmk_core/common/bootmagic.c | 2 ++ tmk_core/common/magic.c | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h index 16922c1ff921..9b9173c33bae 100644 --- a/tmk_core/common/action_layer.h +++ b/tmk_core/common/action_layer.h @@ -85,6 +85,8 @@ void layer_invert(uint8_t layer); void layer_or(layer_state_t state); void layer_and(layer_state_t state); void layer_xor(layer_state_t state); +layer_state_t layer_state_set_user(layer_state_t state); +layer_state_t layer_state_set_kb(layer_state_t state); #else # define layer_state 0 @@ -101,10 +103,10 @@ void layer_xor(layer_state_t state); # define layer_or(state) (void)state # define layer_and(state) (void)state # define layer_xor(state) (void)state +# define layer_state_set_kb(state) (void)state +# define layer_state_set_user(state) (void)state #endif -layer_state_t layer_state_set_user(layer_state_t state); -layer_state_t layer_state_set_kb(layer_state_t state); /* pressed actions cache */ #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) diff --git a/tmk_core/common/bootmagic.c b/tmk_core/common/bootmagic.c index bb2aa0db8cdd..c1b3adf94df1 100644 --- a/tmk_core/common/bootmagic.c +++ b/tmk_core/common/bootmagic.c @@ -122,6 +122,8 @@ void bootmagic(void) { default_layer = eeconfig_read_default_layer(); default_layer_set((layer_state_t)default_layer); } + /* Also initialize layer state to trigger callback functions for layer_state */ + layer_state_set_kb((layer_state_t)layer_state); /* EE_HANDS handedness */ if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_LEFT)) { diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c index d8ab52573511..e14994164e22 100644 --- a/tmk_core/common/magic.c +++ b/tmk_core/common/magic.c @@ -33,4 +33,7 @@ void magic(void) { uint8_t default_layer = 0; default_layer = eeconfig_read_default_layer(); default_layer_set((layer_state_t)default_layer); + + /* Also initialize layer state to trigger callback functions for layer_state */ + layer_state_set_kb((layer_state_t)layer_state); } From 5484b63bf1082326991bfaac06c5f9f570383977 Mon Sep 17 00:00:00 2001 From: TerryMathews Date: Tue, 28 Jul 2020 01:34:18 -0400 Subject: [PATCH 23/54] The Key Company project consolidation (#9547) * Consolidate TKC projects and increase VIA keymap count to 4. * Updated readme files. * Removed config.h via limitation of 2 dynamic keymaps * Reduce dynamic keymaps from 4 to 3 due to EEPROM space limitations. * Update dynamic_keymap.c * Restore 4 dynamic keymaps for VIA in TKC projects. * Update quantum/dynamic_keymap.c --- keyboards/m0lly/keymaps/via/config.h | 1 - .../{ => tkc}/candybar/bootloader_defs.h | 0 keyboards/{ => tkc}/candybar/chconf.h | 0 keyboards/{ => tkc}/candybar/halconf.h | 0 keyboards/{ => tkc}/candybar/lefty/config.h | 0 keyboards/{ => tkc}/candybar/lefty/info.json | 0 .../candybar/lefty/keymaps/default/keymap.c | 0 .../candybar/lefty/keymaps/via/keymap.c | 14 ++++++++++ .../candybar/lefty/keymaps/via/rules.mk | 0 keyboards/{ => tkc}/candybar/lefty/lefty.c | 0 keyboards/{ => tkc}/candybar/lefty/lefty.h | 0 keyboards/{ => tkc}/candybar/lefty/readme.md | 2 +- keyboards/{ => tkc}/candybar/lefty/rules.mk | 0 keyboards/{ => tkc}/candybar/mcuconf.h | 0 keyboards/{ => tkc}/candybar/righty/config.h | 0 keyboards/{ => tkc}/candybar/righty/info.json | 0 .../candybar/righty/keymaps/default/keymap.c | 0 .../candybar/righty/keymaps/via/keymap.c | 14 ++++++++++ .../candybar/righty/keymaps/via/rules.mk | 0 keyboards/{ => tkc}/candybar/righty/readme.md | 2 +- keyboards/{ => tkc}/candybar/righty/righty.c | 0 keyboards/{ => tkc}/candybar/righty/righty.h | 0 keyboards/{ => tkc}/candybar/righty/rules.mk | 0 keyboards/{ => tkc}/m0lly/README.md | 2 +- keyboards/{ => tkc}/m0lly/config.h | 0 keyboards/{ => tkc}/m0lly/info.json | 0 .../{ => tkc}/m0lly/keymaps/default/keymap.c | 0 .../{ => tkc}/m0lly/keymaps/via/keymap.c | 22 ++++++++++++++++ .../{ => tkc}/m0lly/keymaps/via/rules.mk | 0 keyboards/{ => tkc}/m0lly/m0lly.c | 0 keyboards/{ => tkc}/m0lly/m0lly.h | 0 keyboards/{ => tkc}/m0lly/rules.mk | 0 keyboards/{ => tkc}/tkc1800/README.md | 2 +- keyboards/{ => tkc}/tkc1800/config.h | 0 keyboards/{ => tkc}/tkc1800/info.json | 0 .../tkc1800/keymaps/default/keymap.c | 0 .../{ => tkc}/tkc1800/keymaps/smt/keymap.c | 0 .../{ => tkc}/tkc1800/keymaps/via/keymap.c | 26 +++++++++++++++++++ .../{ => tkc}/tkc1800/keymaps/via/rules.mk | 0 .../{ => tkc}/tkc1800/keymaps/wkl/keymap.c | 0 .../tkc1800/keymaps/yanfali/keymap.c | 0 .../tkc1800/keymaps/yanfali/rules.mk | 0 keyboards/{ => tkc}/tkc1800/rules.mk | 0 keyboards/{ => tkc}/tkc1800/tkc1800.c | 0 keyboards/{ => tkc}/tkc1800/tkc1800.h | 0 keyboards/tkc1800/keymaps/via/config.h | 1 - quantum/dynamic_keymap.c | 6 ++++- 47 files changed, 85 insertions(+), 7 deletions(-) delete mode 100644 keyboards/m0lly/keymaps/via/config.h rename keyboards/{ => tkc}/candybar/bootloader_defs.h (100%) rename keyboards/{ => tkc}/candybar/chconf.h (100%) rename keyboards/{ => tkc}/candybar/halconf.h (100%) rename keyboards/{ => tkc}/candybar/lefty/config.h (100%) rename keyboards/{ => tkc}/candybar/lefty/info.json (100%) rename keyboards/{ => tkc}/candybar/lefty/keymaps/default/keymap.c (100%) rename keyboards/{ => tkc}/candybar/lefty/keymaps/via/keymap.c (62%) rename keyboards/{ => tkc}/candybar/lefty/keymaps/via/rules.mk (100%) rename keyboards/{ => tkc}/candybar/lefty/lefty.c (100%) rename keyboards/{ => tkc}/candybar/lefty/lefty.h (100%) rename keyboards/{ => tkc}/candybar/lefty/readme.md (94%) rename keyboards/{ => tkc}/candybar/lefty/rules.mk (100%) rename keyboards/{ => tkc}/candybar/mcuconf.h (100%) rename keyboards/{ => tkc}/candybar/righty/config.h (100%) rename keyboards/{ => tkc}/candybar/righty/info.json (100%) rename keyboards/{ => tkc}/candybar/righty/keymaps/default/keymap.c (100%) rename keyboards/{ => tkc}/candybar/righty/keymaps/via/keymap.c (65%) rename keyboards/{ => tkc}/candybar/righty/keymaps/via/rules.mk (100%) rename keyboards/{ => tkc}/candybar/righty/readme.md (94%) rename keyboards/{ => tkc}/candybar/righty/righty.c (100%) rename keyboards/{ => tkc}/candybar/righty/righty.h (100%) rename keyboards/{ => tkc}/candybar/righty/rules.mk (100%) rename keyboards/{ => tkc}/m0lly/README.md (96%) rename keyboards/{ => tkc}/m0lly/config.h (100%) rename keyboards/{ => tkc}/m0lly/info.json (100%) rename keyboards/{ => tkc}/m0lly/keymaps/default/keymap.c (100%) rename keyboards/{ => tkc}/m0lly/keymaps/via/keymap.c (73%) rename keyboards/{ => tkc}/m0lly/keymaps/via/rules.mk (100%) rename keyboards/{ => tkc}/m0lly/m0lly.c (100%) rename keyboards/{ => tkc}/m0lly/m0lly.h (100%) rename keyboards/{ => tkc}/m0lly/rules.mk (100%) rename keyboards/{ => tkc}/tkc1800/README.md (96%) rename keyboards/{ => tkc}/tkc1800/config.h (100%) rename keyboards/{ => tkc}/tkc1800/info.json (100%) rename keyboards/{ => tkc}/tkc1800/keymaps/default/keymap.c (100%) rename keyboards/{ => tkc}/tkc1800/keymaps/smt/keymap.c (100%) rename keyboards/{ => tkc}/tkc1800/keymaps/via/keymap.c (72%) rename keyboards/{ => tkc}/tkc1800/keymaps/via/rules.mk (100%) rename keyboards/{ => tkc}/tkc1800/keymaps/wkl/keymap.c (100%) rename keyboards/{ => tkc}/tkc1800/keymaps/yanfali/keymap.c (100%) rename keyboards/{ => tkc}/tkc1800/keymaps/yanfali/rules.mk (100%) rename keyboards/{ => tkc}/tkc1800/rules.mk (100%) rename keyboards/{ => tkc}/tkc1800/tkc1800.c (100%) rename keyboards/{ => tkc}/tkc1800/tkc1800.h (100%) delete mode 100644 keyboards/tkc1800/keymaps/via/config.h diff --git a/keyboards/m0lly/keymaps/via/config.h b/keyboards/m0lly/keymaps/via/config.h deleted file mode 100644 index 579212d4a3a0..000000000000 --- a/keyboards/m0lly/keymaps/via/config.h +++ /dev/null @@ -1 +0,0 @@ -#define DYNAMIC_KEYMAP_LAYER_COUNT 2 diff --git a/keyboards/candybar/bootloader_defs.h b/keyboards/tkc/candybar/bootloader_defs.h similarity index 100% rename from keyboards/candybar/bootloader_defs.h rename to keyboards/tkc/candybar/bootloader_defs.h diff --git a/keyboards/candybar/chconf.h b/keyboards/tkc/candybar/chconf.h similarity index 100% rename from keyboards/candybar/chconf.h rename to keyboards/tkc/candybar/chconf.h diff --git a/keyboards/candybar/halconf.h b/keyboards/tkc/candybar/halconf.h similarity index 100% rename from keyboards/candybar/halconf.h rename to keyboards/tkc/candybar/halconf.h diff --git a/keyboards/candybar/lefty/config.h b/keyboards/tkc/candybar/lefty/config.h similarity index 100% rename from keyboards/candybar/lefty/config.h rename to keyboards/tkc/candybar/lefty/config.h diff --git a/keyboards/candybar/lefty/info.json b/keyboards/tkc/candybar/lefty/info.json similarity index 100% rename from keyboards/candybar/lefty/info.json rename to keyboards/tkc/candybar/lefty/info.json diff --git a/keyboards/candybar/lefty/keymaps/default/keymap.c b/keyboards/tkc/candybar/lefty/keymaps/default/keymap.c similarity index 100% rename from keyboards/candybar/lefty/keymaps/default/keymap.c rename to keyboards/tkc/candybar/lefty/keymaps/default/keymap.c diff --git a/keyboards/candybar/lefty/keymaps/via/keymap.c b/keyboards/tkc/candybar/lefty/keymaps/via/keymap.c similarity index 62% rename from keyboards/candybar/lefty/keymaps/via/keymap.c rename to keyboards/tkc/candybar/lefty/keymaps/via/keymap.c index 153fd99c507e..fd927195b224 100644 --- a/keyboards/candybar/lefty/keymaps/via/keymap.c +++ b/keyboards/tkc/candybar/lefty/keymaps/via/keymap.c @@ -18,6 +18,8 @@ #define _BL 0 #define _FL 1 +#define _AL 2 +#define _LL 3 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Keymap _BL: Base Layer (Default Layer) @@ -35,4 +37,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_P4 , KC_P5, KC_P6 , KC_VOLD, KC_TAB , KC_A , KC_SLCK, KC_D, KC_F , KC_G , KC_H, KC_J , KC_K , KC_L , KC_QUOT, KC_BSLS , \ KC_P1 , KC_P2, KC_P3 , KC_PEQL, KC_LSFT, KC_Z , KC_X, KC_CAPS, KC_V , KC_B, KC_NLCK, KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_PGUP , \ KC_END, KC_P0, KC_PDOT, KC_PENT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC , KC_BSPC, KC_APP , MO(_FL), KC_HOME, KC_PGDN), + + [_AL] = LAYOUT( + KC_P7 , KC_P8, KC_P9 , KC_VOLU, RESET , KC_Q , KC_W , KC_E, KC_R , KC_T , KC_Y, KC_U , KC_I , KC_LBRC, KC_RBRC, KC_INS , KC_BSPC , \ + KC_P4 , KC_P5, KC_P6 , KC_VOLD, KC_TAB , KC_A , KC_SLCK, KC_D, KC_F , KC_G , KC_H, KC_J , KC_K , KC_L , KC_QUOT, KC_BSLS , \ + KC_P1 , KC_P2, KC_P3 , KC_PEQL, KC_LSFT, KC_Z , KC_X, KC_CAPS, KC_V , KC_B, KC_NLCK, KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_PGUP , \ + KC_END, KC_P0, KC_PDOT, KC_PENT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC , KC_BSPC, KC_APP , MO(_FL), KC_HOME, KC_PGDN), + + [_LL] = LAYOUT( + KC_P7 , KC_P8, KC_P9 , KC_VOLU, RESET , KC_Q , KC_W , KC_E, KC_R , KC_T , KC_Y, KC_U , KC_I , KC_LBRC, KC_RBRC, KC_INS , KC_BSPC , \ + KC_P4 , KC_P5, KC_P6 , KC_VOLD, KC_TAB , KC_A , KC_SLCK, KC_D, KC_F , KC_G , KC_H, KC_J , KC_K , KC_L , KC_QUOT, KC_BSLS , \ + KC_P1 , KC_P2, KC_P3 , KC_PEQL, KC_LSFT, KC_Z , KC_X, KC_CAPS, KC_V , KC_B, KC_NLCK, KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_PGUP , \ + KC_END, KC_P0, KC_PDOT, KC_PENT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC , KC_BSPC, KC_APP , MO(_FL), KC_HOME, KC_PGDN), }; diff --git a/keyboards/candybar/lefty/keymaps/via/rules.mk b/keyboards/tkc/candybar/lefty/keymaps/via/rules.mk similarity index 100% rename from keyboards/candybar/lefty/keymaps/via/rules.mk rename to keyboards/tkc/candybar/lefty/keymaps/via/rules.mk diff --git a/keyboards/candybar/lefty/lefty.c b/keyboards/tkc/candybar/lefty/lefty.c similarity index 100% rename from keyboards/candybar/lefty/lefty.c rename to keyboards/tkc/candybar/lefty/lefty.c diff --git a/keyboards/candybar/lefty/lefty.h b/keyboards/tkc/candybar/lefty/lefty.h similarity index 100% rename from keyboards/candybar/lefty/lefty.h rename to keyboards/tkc/candybar/lefty/lefty.h diff --git a/keyboards/candybar/lefty/readme.md b/keyboards/tkc/candybar/lefty/readme.md similarity index 94% rename from keyboards/candybar/lefty/readme.md rename to keyboards/tkc/candybar/lefty/readme.md index 5954720679ba..75ca1cbd80df 100644 --- a/keyboards/candybar/lefty/readme.md +++ b/keyboards/tkc/candybar/lefty/readme.md @@ -10,6 +10,6 @@ The Key Company Candybar is a staggered 40% board with a numpad utilizing the ST Make example for this keyboard (after setting up your build environment): - make candybar/lefty:default:dfu-util + make tkc/candybar/lefty:default:dfu-util See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). diff --git a/keyboards/candybar/lefty/rules.mk b/keyboards/tkc/candybar/lefty/rules.mk similarity index 100% rename from keyboards/candybar/lefty/rules.mk rename to keyboards/tkc/candybar/lefty/rules.mk diff --git a/keyboards/candybar/mcuconf.h b/keyboards/tkc/candybar/mcuconf.h similarity index 100% rename from keyboards/candybar/mcuconf.h rename to keyboards/tkc/candybar/mcuconf.h diff --git a/keyboards/candybar/righty/config.h b/keyboards/tkc/candybar/righty/config.h similarity index 100% rename from keyboards/candybar/righty/config.h rename to keyboards/tkc/candybar/righty/config.h diff --git a/keyboards/candybar/righty/info.json b/keyboards/tkc/candybar/righty/info.json similarity index 100% rename from keyboards/candybar/righty/info.json rename to keyboards/tkc/candybar/righty/info.json diff --git a/keyboards/candybar/righty/keymaps/default/keymap.c b/keyboards/tkc/candybar/righty/keymaps/default/keymap.c similarity index 100% rename from keyboards/candybar/righty/keymaps/default/keymap.c rename to keyboards/tkc/candybar/righty/keymaps/default/keymap.c diff --git a/keyboards/candybar/righty/keymaps/via/keymap.c b/keyboards/tkc/candybar/righty/keymaps/via/keymap.c similarity index 65% rename from keyboards/candybar/righty/keymaps/via/keymap.c rename to keyboards/tkc/candybar/righty/keymaps/via/keymap.c index 8f4cc08c7467..fb8ac93d464c 100644 --- a/keyboards/candybar/righty/keymaps/via/keymap.c +++ b/keyboards/tkc/candybar/righty/keymaps/via/keymap.c @@ -18,6 +18,8 @@ #define _BL 0 #define _FL 1 +#define _AL 2 +#define _LL 3 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Keymap _BL: Base Layer (Default Layer) @@ -35,4 +37,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TAB,KC_A,KC_SLCK,KC_D,KC_F,KC_G,KC_H,KC_J,KC_K,KC_L,KC_QUOT,KC_BSLS,KC_P4,KC_P5,KC_P6,KC_VOLD, \ KC_LSFT,KC_Z,KC_X,KC_CAPS,KC_V,KC_B,KC_NLCK,KC_M,KC_COMM,KC_DOT,KC_SLSH,KC_PGUP,KC_P1,KC_P2,KC_P3,KC_PEQL, \ KC_LCTL,KC_LGUI,KC_LALT,KC_SPC,KC_SPC,KC_BSPC,KC_APP,MO(_FL),KC_HOME,KC_PGDN,KC_END,KC_P0,KC_PDOT,KC_PENT), + + [_AL] = LAYOUT( + RESET,KC_Q,KC_W,KC_E,KC_R,KC_T,KC_Y,KC_U,KC_I,KC_LBRC,KC_RBRC,KC_INS,KC_BSPC,KC_P7,KC_P8,KC_P9,KC_VOLU, \ + KC_TAB,KC_A,KC_SLCK,KC_D,KC_F,KC_G,KC_H,KC_J,KC_K,KC_L,KC_QUOT,KC_BSLS,KC_P4,KC_P5,KC_P6,KC_VOLD, \ + KC_LSFT,KC_Z,KC_X,KC_CAPS,KC_V,KC_B,KC_NLCK,KC_M,KC_COMM,KC_DOT,KC_SLSH,KC_PGUP,KC_P1,KC_P2,KC_P3,KC_PEQL, \ + KC_LCTL,KC_LGUI,KC_LALT,KC_SPC,KC_SPC,KC_BSPC,KC_APP,MO(_FL),KC_HOME,KC_PGDN,KC_END,KC_P0,KC_PDOT,KC_PENT), + + [_LL] = LAYOUT( + RESET,KC_Q,KC_W,KC_E,KC_R,KC_T,KC_Y,KC_U,KC_I,KC_LBRC,KC_RBRC,KC_INS,KC_BSPC,KC_P7,KC_P8,KC_P9,KC_VOLU, \ + KC_TAB,KC_A,KC_SLCK,KC_D,KC_F,KC_G,KC_H,KC_J,KC_K,KC_L,KC_QUOT,KC_BSLS,KC_P4,KC_P5,KC_P6,KC_VOLD, \ + KC_LSFT,KC_Z,KC_X,KC_CAPS,KC_V,KC_B,KC_NLCK,KC_M,KC_COMM,KC_DOT,KC_SLSH,KC_PGUP,KC_P1,KC_P2,KC_P3,KC_PEQL, \ + KC_LCTL,KC_LGUI,KC_LALT,KC_SPC,KC_SPC,KC_BSPC,KC_APP,MO(_FL),KC_HOME,KC_PGDN,KC_END,KC_P0,KC_PDOT,KC_PENT), }; diff --git a/keyboards/candybar/righty/keymaps/via/rules.mk b/keyboards/tkc/candybar/righty/keymaps/via/rules.mk similarity index 100% rename from keyboards/candybar/righty/keymaps/via/rules.mk rename to keyboards/tkc/candybar/righty/keymaps/via/rules.mk diff --git a/keyboards/candybar/righty/readme.md b/keyboards/tkc/candybar/righty/readme.md similarity index 94% rename from keyboards/candybar/righty/readme.md rename to keyboards/tkc/candybar/righty/readme.md index d3aa867303b0..4e2a0f8474e8 100644 --- a/keyboards/candybar/righty/readme.md +++ b/keyboards/tkc/candybar/righty/readme.md @@ -10,6 +10,6 @@ The Key Company Candybar is a staggered 40% board with a numpad utilizing the ST Make example for this keyboard (after setting up your build environment): - make candybar/righty:default:dfu-util + make tkc/candybar/righty:default:dfu-util See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). diff --git a/keyboards/candybar/righty/righty.c b/keyboards/tkc/candybar/righty/righty.c similarity index 100% rename from keyboards/candybar/righty/righty.c rename to keyboards/tkc/candybar/righty/righty.c diff --git a/keyboards/candybar/righty/righty.h b/keyboards/tkc/candybar/righty/righty.h similarity index 100% rename from keyboards/candybar/righty/righty.h rename to keyboards/tkc/candybar/righty/righty.h diff --git a/keyboards/candybar/righty/rules.mk b/keyboards/tkc/candybar/righty/rules.mk similarity index 100% rename from keyboards/candybar/righty/rules.mk rename to keyboards/tkc/candybar/righty/rules.mk diff --git a/keyboards/m0lly/README.md b/keyboards/tkc/m0lly/README.md similarity index 96% rename from keyboards/m0lly/README.md rename to keyboards/tkc/m0lly/README.md index e0c8b45d95f0..9af80c7e9877 100644 --- a/keyboards/m0lly/README.md +++ b/keyboards/tkc/m0lly/README.md @@ -12,6 +12,6 @@ Hardware Availability: [TheKey.Company](https://thekey.company) Make example for this keyboard (after setting up your build environment): - make m0lly:default + make tkc/m0lly:default See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). diff --git a/keyboards/m0lly/config.h b/keyboards/tkc/m0lly/config.h similarity index 100% rename from keyboards/m0lly/config.h rename to keyboards/tkc/m0lly/config.h diff --git a/keyboards/m0lly/info.json b/keyboards/tkc/m0lly/info.json similarity index 100% rename from keyboards/m0lly/info.json rename to keyboards/tkc/m0lly/info.json diff --git a/keyboards/m0lly/keymaps/default/keymap.c b/keyboards/tkc/m0lly/keymaps/default/keymap.c similarity index 100% rename from keyboards/m0lly/keymaps/default/keymap.c rename to keyboards/tkc/m0lly/keymaps/default/keymap.c diff --git a/keyboards/m0lly/keymaps/via/keymap.c b/keyboards/tkc/m0lly/keymaps/via/keymap.c similarity index 73% rename from keyboards/m0lly/keymaps/via/keymap.c rename to keyboards/tkc/m0lly/keymaps/via/keymap.c index 2e5900f16632..b72b8f035be0 100644 --- a/keyboards/m0lly/keymaps/via/keymap.c +++ b/keyboards/tkc/m0lly/keymaps/via/keymap.c @@ -21,6 +21,8 @@ enum { BASE = 0, FUNCTION, + ALTERNATE, + LAST, }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -66,6 +68,20 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, XXXXXXX, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, BL_STEP, _______, _______, XXXXXXX, _______, _______, _______, XXXXXXX, _______, _______, _______, _______, _______, _______, MO(FUNCTION), _______, _______, XXXXXXX, _______, _______ ), + [ALTERNATE] = LAYOUT_all( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, XXXXXXX, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX, _______, _______, _______, _______, _______, + _______, XXXXXXX, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, BL_STEP, _______, _______, XXXXXXX, _______, _______, _______, XXXXXXX, + _______, _______, _______, _______, _______, _______, MO(FUNCTION), _______, _______, XXXXXXX, _______, _______ + ), + [LAST] = LAYOUT_all( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, XXXXXXX, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX, _______, _______, _______, _______, _______, + _______, XXXXXXX, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, BL_STEP, _______, _______, XXXXXXX, _______, _______, _______, XXXXXXX, + _______, _______, _______, _______, _______, _______, MO(FUNCTION), _______, _______, XXXXXXX, _______, _______ + ), }; #ifdef OLED_DRIVER_ENABLE @@ -80,6 +96,12 @@ void oled_task_user(void) { break; case FUNCTION: oled_write_P(PSTR("Function\n"), false); + break; + case ALTERNATE: + oled_write_P(PSTR("Alternate\n"), false); + break; + case LAST: + oled_write_P(PSTR("Last\n"), false); break; default: // Or use the write_ln shortcut over adding '\n' to the end of your string diff --git a/keyboards/m0lly/keymaps/via/rules.mk b/keyboards/tkc/m0lly/keymaps/via/rules.mk similarity index 100% rename from keyboards/m0lly/keymaps/via/rules.mk rename to keyboards/tkc/m0lly/keymaps/via/rules.mk diff --git a/keyboards/m0lly/m0lly.c b/keyboards/tkc/m0lly/m0lly.c similarity index 100% rename from keyboards/m0lly/m0lly.c rename to keyboards/tkc/m0lly/m0lly.c diff --git a/keyboards/m0lly/m0lly.h b/keyboards/tkc/m0lly/m0lly.h similarity index 100% rename from keyboards/m0lly/m0lly.h rename to keyboards/tkc/m0lly/m0lly.h diff --git a/keyboards/m0lly/rules.mk b/keyboards/tkc/m0lly/rules.mk similarity index 100% rename from keyboards/m0lly/rules.mk rename to keyboards/tkc/m0lly/rules.mk diff --git a/keyboards/tkc1800/README.md b/keyboards/tkc/tkc1800/README.md similarity index 96% rename from keyboards/tkc1800/README.md rename to keyboards/tkc/tkc1800/README.md index e154770d72f3..5382b91b3c68 100644 --- a/keyboards/tkc1800/README.md +++ b/keyboards/tkc/tkc1800/README.md @@ -12,6 +12,6 @@ Hardware Availability: [TheKey.Company](https://thekey.company/collections/tkc-1 Make example for this keyboard (after setting up your build environment): - make tkc1800:default + make tkc/tkc1800:default See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). diff --git a/keyboards/tkc1800/config.h b/keyboards/tkc/tkc1800/config.h similarity index 100% rename from keyboards/tkc1800/config.h rename to keyboards/tkc/tkc1800/config.h diff --git a/keyboards/tkc1800/info.json b/keyboards/tkc/tkc1800/info.json similarity index 100% rename from keyboards/tkc1800/info.json rename to keyboards/tkc/tkc1800/info.json diff --git a/keyboards/tkc1800/keymaps/default/keymap.c b/keyboards/tkc/tkc1800/keymaps/default/keymap.c similarity index 100% rename from keyboards/tkc1800/keymaps/default/keymap.c rename to keyboards/tkc/tkc1800/keymaps/default/keymap.c diff --git a/keyboards/tkc1800/keymaps/smt/keymap.c b/keyboards/tkc/tkc1800/keymaps/smt/keymap.c similarity index 100% rename from keyboards/tkc1800/keymaps/smt/keymap.c rename to keyboards/tkc/tkc1800/keymaps/smt/keymap.c diff --git a/keyboards/tkc1800/keymaps/via/keymap.c b/keyboards/tkc/tkc1800/keymaps/via/keymap.c similarity index 72% rename from keyboards/tkc1800/keymaps/via/keymap.c rename to keyboards/tkc/tkc1800/keymaps/via/keymap.c index 76fdf054064e..55c2874c6291 100644 --- a/keyboards/tkc1800/keymaps/via/keymap.c +++ b/keyboards/tkc/tkc1800/keymaps/via/keymap.c @@ -20,6 +20,8 @@ enum { BASE = 0, FUNCTION, + ALTERNATE, + LAST, }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -75,6 +77,24 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, XXXXXXX, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, BL_STEP, _______, _______, _______, _______, _______, _______, XXXXXXX, \ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ ), + [ALTERNATE] = LAYOUT( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, XXXXXXX, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX, _______, _______, _______, _______, _______, \ + _______, XXXXXXX, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, BL_STEP, _______, _______, _______, _______, _______, _______, XXXXXXX, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ + ), + [LAST] = LAYOUT( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, XXXXXXX, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX, _______, _______, _______, _______, _______, \ + _______, XXXXXXX, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, BL_STEP, _______, _______, _______, _______, _______, _______, XXXXXXX, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ + ), }; #ifdef OLED_DRIVER_ENABLE @@ -89,6 +109,12 @@ void oled_task_user(void) { break; case FUNCTION: oled_write_P(PSTR("Function\n"), false); + break; + case ALTERNATE: + oled_write_P(PSTR("Alternate\n"), false); + break; + case LAST: + oled_write_P(PSTR("Last\n"), false); break; default: // Or use the write_ln shortcut over adding '\n' to the end of your string diff --git a/keyboards/tkc1800/keymaps/via/rules.mk b/keyboards/tkc/tkc1800/keymaps/via/rules.mk similarity index 100% rename from keyboards/tkc1800/keymaps/via/rules.mk rename to keyboards/tkc/tkc1800/keymaps/via/rules.mk diff --git a/keyboards/tkc1800/keymaps/wkl/keymap.c b/keyboards/tkc/tkc1800/keymaps/wkl/keymap.c similarity index 100% rename from keyboards/tkc1800/keymaps/wkl/keymap.c rename to keyboards/tkc/tkc1800/keymaps/wkl/keymap.c diff --git a/keyboards/tkc1800/keymaps/yanfali/keymap.c b/keyboards/tkc/tkc1800/keymaps/yanfali/keymap.c similarity index 100% rename from keyboards/tkc1800/keymaps/yanfali/keymap.c rename to keyboards/tkc/tkc1800/keymaps/yanfali/keymap.c diff --git a/keyboards/tkc1800/keymaps/yanfali/rules.mk b/keyboards/tkc/tkc1800/keymaps/yanfali/rules.mk similarity index 100% rename from keyboards/tkc1800/keymaps/yanfali/rules.mk rename to keyboards/tkc/tkc1800/keymaps/yanfali/rules.mk diff --git a/keyboards/tkc1800/rules.mk b/keyboards/tkc/tkc1800/rules.mk similarity index 100% rename from keyboards/tkc1800/rules.mk rename to keyboards/tkc/tkc1800/rules.mk diff --git a/keyboards/tkc1800/tkc1800.c b/keyboards/tkc/tkc1800/tkc1800.c similarity index 100% rename from keyboards/tkc1800/tkc1800.c rename to keyboards/tkc/tkc1800/tkc1800.c diff --git a/keyboards/tkc1800/tkc1800.h b/keyboards/tkc/tkc1800/tkc1800.h similarity index 100% rename from keyboards/tkc1800/tkc1800.h rename to keyboards/tkc/tkc1800/tkc1800.h diff --git a/keyboards/tkc1800/keymaps/via/config.h b/keyboards/tkc1800/keymaps/via/config.h deleted file mode 100644 index 579212d4a3a0..000000000000 --- a/keyboards/tkc1800/keymaps/via/config.h +++ /dev/null @@ -1 +0,0 @@ -#define DYNAMIC_KEYMAP_LAYER_COUNT 2 diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index 10d8c9eb661e..27ee6a284055 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -35,7 +35,11 @@ // Explicitly override it if the keyboard uses a microcontroller with // more EEPROM *and* it makes sense to increase it. #ifndef DYNAMIC_KEYMAP_EEPROM_MAX_ADDR -# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 1023 +# if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) +# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047 +# else +# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 1023 +# endif #endif // If DYNAMIC_KEYMAP_EEPROM_ADDR not explicitly defined in config.h, From 80ff2ba8a0a924f8641211d369c9477783650f8c Mon Sep 17 00:00:00 2001 From: flehrad <20124416+flehrad@users.noreply.github.com> Date: Fri, 31 Jul 2020 08:04:49 +1000 Subject: [PATCH 24/54] [Keyboard] relocating boards by flehrad (#9635) Co-authored-by: flehrad --- keyboards/{ => flehrad}/bigswitch/README.md | 2 ++ keyboards/{ => flehrad}/bigswitch/bigswitch.c | 0 keyboards/{ => flehrad}/bigswitch/bigswitch.h | 0 keyboards/{ => flehrad}/bigswitch/config.h | 0 keyboards/{ => flehrad}/bigswitch/info.json | 0 keyboards/{ => flehrad}/bigswitch/keymaps/333fred/config.h | 0 keyboards/{ => flehrad}/bigswitch/keymaps/333fred/keymap.c | 0 keyboards/{ => flehrad}/bigswitch/keymaps/333fred/rules.mk | 0 keyboards/{ => flehrad}/bigswitch/keymaps/default/keymap.c | 0 keyboards/{ => flehrad}/bigswitch/keymaps/wanleg/config.h | 0 keyboards/{ => flehrad}/bigswitch/keymaps/wanleg/keymap.c | 0 keyboards/{ => flehrad}/bigswitch/keymaps/wanleg/rules.mk | 0 keyboards/{ => flehrad}/bigswitch/rules.mk | 0 keyboards/{handwired => flehrad}/downbubble/config.h | 0 keyboards/{handwired => flehrad}/downbubble/downbubble.c | 0 keyboards/{handwired => flehrad}/downbubble/downbubble.h | 0 keyboards/{handwired => flehrad}/downbubble/info.json | 0 .../{handwired => flehrad}/downbubble/keymaps/default/config.h | 0 .../{handwired => flehrad}/downbubble/keymaps/default/keymap.c | 0 .../{handwired => flehrad}/downbubble/keymaps/default/readme.md | 0 keyboards/{handwired => flehrad}/downbubble/license | 0 keyboards/{handwired => flehrad}/downbubble/readme.md | 2 +- keyboards/{handwired => flehrad}/downbubble/rules.mk | 0 keyboards/{handwired => flehrad}/numbrero/config.h | 0 keyboards/{handwired => flehrad}/numbrero/info.json | 0 .../{handwired => flehrad}/numbrero/keymaps/default/keymap.c | 0 keyboards/{handwired => flehrad}/numbrero/license | 0 keyboards/{handwired => flehrad}/numbrero/numbrero.c | 0 keyboards/{handwired => flehrad}/numbrero/numbrero.h | 0 keyboards/{handwired => flehrad}/numbrero/readme.md | 2 +- keyboards/{handwired => flehrad}/numbrero/rules.mk | 0 keyboards/{ => flehrad}/snagpad/config.h | 0 keyboards/{ => flehrad}/snagpad/info.json | 0 keyboards/{ => flehrad}/snagpad/keymaps/default/keymap.c | 0 keyboards/{ => flehrad}/snagpad/keymaps/via/keymap.c | 0 keyboards/{ => flehrad}/snagpad/keymaps/via/rules.mk | 0 keyboards/{handwired/tradestation => flehrad/snagpad}/license | 0 keyboards/{ => flehrad}/snagpad/readme.md | 2 +- keyboards/{ => flehrad}/snagpad/rules.mk | 0 keyboards/{ => flehrad}/snagpad/snagpad.c | 0 keyboards/{ => flehrad}/snagpad/snagpad.h | 0 keyboards/{handwired => flehrad}/tradestation/config.h | 0 keyboards/{handwired => flehrad}/tradestation/info.json | 0 .../tradestation/keymaps/default/keymap.c | 0 keyboards/{snagpad => flehrad/tradestation}/license | 0 keyboards/{handwired => flehrad}/tradestation/readme.md | 2 +- keyboards/{handwired => flehrad}/tradestation/rules.mk | 0 keyboards/{handwired => flehrad}/tradestation/tradestation.c | 0 keyboards/{handwired => flehrad}/tradestation/tradestation.h | 0 49 files changed, 6 insertions(+), 4 deletions(-) rename keyboards/{ => flehrad}/bigswitch/README.md (93%) rename keyboards/{ => flehrad}/bigswitch/bigswitch.c (100%) rename keyboards/{ => flehrad}/bigswitch/bigswitch.h (100%) mode change 100755 => 100644 rename keyboards/{ => flehrad}/bigswitch/config.h (100%) mode change 100755 => 100644 rename keyboards/{ => flehrad}/bigswitch/info.json (100%) rename keyboards/{ => flehrad}/bigswitch/keymaps/333fred/config.h (100%) rename keyboards/{ => flehrad}/bigswitch/keymaps/333fred/keymap.c (100%) rename keyboards/{ => flehrad}/bigswitch/keymaps/333fred/rules.mk (100%) rename keyboards/{ => flehrad}/bigswitch/keymaps/default/keymap.c (100%) mode change 100755 => 100644 rename keyboards/{ => flehrad}/bigswitch/keymaps/wanleg/config.h (100%) rename keyboards/{ => flehrad}/bigswitch/keymaps/wanleg/keymap.c (100%) rename keyboards/{ => flehrad}/bigswitch/keymaps/wanleg/rules.mk (100%) rename keyboards/{ => flehrad}/bigswitch/rules.mk (100%) mode change 100755 => 100644 rename keyboards/{handwired => flehrad}/downbubble/config.h (100%) rename keyboards/{handwired => flehrad}/downbubble/downbubble.c (100%) rename keyboards/{handwired => flehrad}/downbubble/downbubble.h (100%) rename keyboards/{handwired => flehrad}/downbubble/info.json (100%) rename keyboards/{handwired => flehrad}/downbubble/keymaps/default/config.h (100%) rename keyboards/{handwired => flehrad}/downbubble/keymaps/default/keymap.c (100%) rename keyboards/{handwired => flehrad}/downbubble/keymaps/default/readme.md (100%) rename keyboards/{handwired => flehrad}/downbubble/license (100%) rename keyboards/{handwired => flehrad}/downbubble/readme.md (95%) rename keyboards/{handwired => flehrad}/downbubble/rules.mk (100%) rename keyboards/{handwired => flehrad}/numbrero/config.h (100%) rename keyboards/{handwired => flehrad}/numbrero/info.json (100%) rename keyboards/{handwired => flehrad}/numbrero/keymaps/default/keymap.c (100%) rename keyboards/{handwired => flehrad}/numbrero/license (100%) rename keyboards/{handwired => flehrad}/numbrero/numbrero.c (100%) rename keyboards/{handwired => flehrad}/numbrero/numbrero.h (100%) rename keyboards/{handwired => flehrad}/numbrero/readme.md (94%) rename keyboards/{handwired => flehrad}/numbrero/rules.mk (100%) rename keyboards/{ => flehrad}/snagpad/config.h (100%) rename keyboards/{ => flehrad}/snagpad/info.json (100%) rename keyboards/{ => flehrad}/snagpad/keymaps/default/keymap.c (100%) rename keyboards/{ => flehrad}/snagpad/keymaps/via/keymap.c (100%) rename keyboards/{ => flehrad}/snagpad/keymaps/via/rules.mk (100%) rename keyboards/{handwired/tradestation => flehrad/snagpad}/license (100%) rename keyboards/{ => flehrad}/snagpad/readme.md (97%) rename keyboards/{ => flehrad}/snagpad/rules.mk (100%) rename keyboards/{ => flehrad}/snagpad/snagpad.c (100%) rename keyboards/{ => flehrad}/snagpad/snagpad.h (100%) rename keyboards/{handwired => flehrad}/tradestation/config.h (100%) rename keyboards/{handwired => flehrad}/tradestation/info.json (100%) rename keyboards/{handwired => flehrad}/tradestation/keymaps/default/keymap.c (100%) rename keyboards/{snagpad => flehrad/tradestation}/license (100%) rename keyboards/{handwired => flehrad}/tradestation/readme.md (97%) rename keyboards/{handwired => flehrad}/tradestation/rules.mk (100%) rename keyboards/{handwired => flehrad}/tradestation/tradestation.c (100%) rename keyboards/{handwired => flehrad}/tradestation/tradestation.h (100%) diff --git a/keyboards/bigswitch/README.md b/keyboards/flehrad/bigswitch/README.md similarity index 93% rename from keyboards/bigswitch/README.md rename to keyboards/flehrad/bigswitch/README.md index 65213af7c4bc..1a0fb155a792 100644 --- a/keyboards/bigswitch/README.md +++ b/keyboards/flehrad/bigswitch/README.md @@ -7,6 +7,8 @@ Designed by Don of the Board Podcast and sold as a kit by [keeb.io](https://keeb https://github.com/flehrad/Big-Switch-PCB +make: flehrad/bigswitch:default + ### Technical Specifications * Uses a atmega32u4 pro micro or pin compatible MCU diff --git a/keyboards/bigswitch/bigswitch.c b/keyboards/flehrad/bigswitch/bigswitch.c similarity index 100% rename from keyboards/bigswitch/bigswitch.c rename to keyboards/flehrad/bigswitch/bigswitch.c diff --git a/keyboards/bigswitch/bigswitch.h b/keyboards/flehrad/bigswitch/bigswitch.h old mode 100755 new mode 100644 similarity index 100% rename from keyboards/bigswitch/bigswitch.h rename to keyboards/flehrad/bigswitch/bigswitch.h diff --git a/keyboards/bigswitch/config.h b/keyboards/flehrad/bigswitch/config.h old mode 100755 new mode 100644 similarity index 100% rename from keyboards/bigswitch/config.h rename to keyboards/flehrad/bigswitch/config.h diff --git a/keyboards/bigswitch/info.json b/keyboards/flehrad/bigswitch/info.json similarity index 100% rename from keyboards/bigswitch/info.json rename to keyboards/flehrad/bigswitch/info.json diff --git a/keyboards/bigswitch/keymaps/333fred/config.h b/keyboards/flehrad/bigswitch/keymaps/333fred/config.h similarity index 100% rename from keyboards/bigswitch/keymaps/333fred/config.h rename to keyboards/flehrad/bigswitch/keymaps/333fred/config.h diff --git a/keyboards/bigswitch/keymaps/333fred/keymap.c b/keyboards/flehrad/bigswitch/keymaps/333fred/keymap.c similarity index 100% rename from keyboards/bigswitch/keymaps/333fred/keymap.c rename to keyboards/flehrad/bigswitch/keymaps/333fred/keymap.c diff --git a/keyboards/bigswitch/keymaps/333fred/rules.mk b/keyboards/flehrad/bigswitch/keymaps/333fred/rules.mk similarity index 100% rename from keyboards/bigswitch/keymaps/333fred/rules.mk rename to keyboards/flehrad/bigswitch/keymaps/333fred/rules.mk diff --git a/keyboards/bigswitch/keymaps/default/keymap.c b/keyboards/flehrad/bigswitch/keymaps/default/keymap.c old mode 100755 new mode 100644 similarity index 100% rename from keyboards/bigswitch/keymaps/default/keymap.c rename to keyboards/flehrad/bigswitch/keymaps/default/keymap.c diff --git a/keyboards/bigswitch/keymaps/wanleg/config.h b/keyboards/flehrad/bigswitch/keymaps/wanleg/config.h similarity index 100% rename from keyboards/bigswitch/keymaps/wanleg/config.h rename to keyboards/flehrad/bigswitch/keymaps/wanleg/config.h diff --git a/keyboards/bigswitch/keymaps/wanleg/keymap.c b/keyboards/flehrad/bigswitch/keymaps/wanleg/keymap.c similarity index 100% rename from keyboards/bigswitch/keymaps/wanleg/keymap.c rename to keyboards/flehrad/bigswitch/keymaps/wanleg/keymap.c diff --git a/keyboards/bigswitch/keymaps/wanleg/rules.mk b/keyboards/flehrad/bigswitch/keymaps/wanleg/rules.mk similarity index 100% rename from keyboards/bigswitch/keymaps/wanleg/rules.mk rename to keyboards/flehrad/bigswitch/keymaps/wanleg/rules.mk diff --git a/keyboards/bigswitch/rules.mk b/keyboards/flehrad/bigswitch/rules.mk old mode 100755 new mode 100644 similarity index 100% rename from keyboards/bigswitch/rules.mk rename to keyboards/flehrad/bigswitch/rules.mk diff --git a/keyboards/handwired/downbubble/config.h b/keyboards/flehrad/downbubble/config.h similarity index 100% rename from keyboards/handwired/downbubble/config.h rename to keyboards/flehrad/downbubble/config.h diff --git a/keyboards/handwired/downbubble/downbubble.c b/keyboards/flehrad/downbubble/downbubble.c similarity index 100% rename from keyboards/handwired/downbubble/downbubble.c rename to keyboards/flehrad/downbubble/downbubble.c diff --git a/keyboards/handwired/downbubble/downbubble.h b/keyboards/flehrad/downbubble/downbubble.h similarity index 100% rename from keyboards/handwired/downbubble/downbubble.h rename to keyboards/flehrad/downbubble/downbubble.h diff --git a/keyboards/handwired/downbubble/info.json b/keyboards/flehrad/downbubble/info.json similarity index 100% rename from keyboards/handwired/downbubble/info.json rename to keyboards/flehrad/downbubble/info.json diff --git a/keyboards/handwired/downbubble/keymaps/default/config.h b/keyboards/flehrad/downbubble/keymaps/default/config.h similarity index 100% rename from keyboards/handwired/downbubble/keymaps/default/config.h rename to keyboards/flehrad/downbubble/keymaps/default/config.h diff --git a/keyboards/handwired/downbubble/keymaps/default/keymap.c b/keyboards/flehrad/downbubble/keymaps/default/keymap.c similarity index 100% rename from keyboards/handwired/downbubble/keymaps/default/keymap.c rename to keyboards/flehrad/downbubble/keymaps/default/keymap.c diff --git a/keyboards/handwired/downbubble/keymaps/default/readme.md b/keyboards/flehrad/downbubble/keymaps/default/readme.md similarity index 100% rename from keyboards/handwired/downbubble/keymaps/default/readme.md rename to keyboards/flehrad/downbubble/keymaps/default/readme.md diff --git a/keyboards/handwired/downbubble/license b/keyboards/flehrad/downbubble/license similarity index 100% rename from keyboards/handwired/downbubble/license rename to keyboards/flehrad/downbubble/license diff --git a/keyboards/handwired/downbubble/readme.md b/keyboards/flehrad/downbubble/readme.md similarity index 95% rename from keyboards/handwired/downbubble/readme.md rename to keyboards/flehrad/downbubble/readme.md index e6623451277a..f1c83b8aa862 100644 --- a/keyboards/handwired/downbubble/readme.md +++ b/keyboards/flehrad/downbubble/readme.md @@ -10,6 +10,6 @@ Hardware Availability: The Board Podcast Slack Make example for this keyboard (after setting up your build environment): - make downbubble:default + make flehrad/downbubble:default See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). diff --git a/keyboards/handwired/downbubble/rules.mk b/keyboards/flehrad/downbubble/rules.mk similarity index 100% rename from keyboards/handwired/downbubble/rules.mk rename to keyboards/flehrad/downbubble/rules.mk diff --git a/keyboards/handwired/numbrero/config.h b/keyboards/flehrad/numbrero/config.h similarity index 100% rename from keyboards/handwired/numbrero/config.h rename to keyboards/flehrad/numbrero/config.h diff --git a/keyboards/handwired/numbrero/info.json b/keyboards/flehrad/numbrero/info.json similarity index 100% rename from keyboards/handwired/numbrero/info.json rename to keyboards/flehrad/numbrero/info.json diff --git a/keyboards/handwired/numbrero/keymaps/default/keymap.c b/keyboards/flehrad/numbrero/keymaps/default/keymap.c similarity index 100% rename from keyboards/handwired/numbrero/keymaps/default/keymap.c rename to keyboards/flehrad/numbrero/keymaps/default/keymap.c diff --git a/keyboards/handwired/numbrero/license b/keyboards/flehrad/numbrero/license similarity index 100% rename from keyboards/handwired/numbrero/license rename to keyboards/flehrad/numbrero/license diff --git a/keyboards/handwired/numbrero/numbrero.c b/keyboards/flehrad/numbrero/numbrero.c similarity index 100% rename from keyboards/handwired/numbrero/numbrero.c rename to keyboards/flehrad/numbrero/numbrero.c diff --git a/keyboards/handwired/numbrero/numbrero.h b/keyboards/flehrad/numbrero/numbrero.h similarity index 100% rename from keyboards/handwired/numbrero/numbrero.h rename to keyboards/flehrad/numbrero/numbrero.h diff --git a/keyboards/handwired/numbrero/readme.md b/keyboards/flehrad/numbrero/readme.md similarity index 94% rename from keyboards/handwired/numbrero/readme.md rename to keyboards/flehrad/numbrero/readme.md index 931c601274fa..823a81fbef39 100644 --- a/keyboards/handwired/numbrero/readme.md +++ b/keyboards/flehrad/numbrero/readme.md @@ -8,6 +8,6 @@ Hardware Availability: The Board Podcast Slack Make example for this keyboard (after setting up your build environment): - make handwired/numbrero:default + make flehrad/numbrero:default See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). diff --git a/keyboards/handwired/numbrero/rules.mk b/keyboards/flehrad/numbrero/rules.mk similarity index 100% rename from keyboards/handwired/numbrero/rules.mk rename to keyboards/flehrad/numbrero/rules.mk diff --git a/keyboards/snagpad/config.h b/keyboards/flehrad/snagpad/config.h similarity index 100% rename from keyboards/snagpad/config.h rename to keyboards/flehrad/snagpad/config.h diff --git a/keyboards/snagpad/info.json b/keyboards/flehrad/snagpad/info.json similarity index 100% rename from keyboards/snagpad/info.json rename to keyboards/flehrad/snagpad/info.json diff --git a/keyboards/snagpad/keymaps/default/keymap.c b/keyboards/flehrad/snagpad/keymaps/default/keymap.c similarity index 100% rename from keyboards/snagpad/keymaps/default/keymap.c rename to keyboards/flehrad/snagpad/keymaps/default/keymap.c diff --git a/keyboards/snagpad/keymaps/via/keymap.c b/keyboards/flehrad/snagpad/keymaps/via/keymap.c similarity index 100% rename from keyboards/snagpad/keymaps/via/keymap.c rename to keyboards/flehrad/snagpad/keymaps/via/keymap.c diff --git a/keyboards/snagpad/keymaps/via/rules.mk b/keyboards/flehrad/snagpad/keymaps/via/rules.mk similarity index 100% rename from keyboards/snagpad/keymaps/via/rules.mk rename to keyboards/flehrad/snagpad/keymaps/via/rules.mk diff --git a/keyboards/handwired/tradestation/license b/keyboards/flehrad/snagpad/license similarity index 100% rename from keyboards/handwired/tradestation/license rename to keyboards/flehrad/snagpad/license diff --git a/keyboards/snagpad/readme.md b/keyboards/flehrad/snagpad/readme.md similarity index 97% rename from keyboards/snagpad/readme.md rename to keyboards/flehrad/snagpad/readme.md index b59bd758860d..cefd65e570f3 100644 --- a/keyboards/snagpad/readme.md +++ b/keyboards/flehrad/snagpad/readme.md @@ -8,7 +8,7 @@ Hardware Availability: [GitHub](https://github.com/flehrad/Snagpad) Make example for this keyboard (after setting up your build environment): - make snagpad:default + make flehrad/snagpad:default See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). diff --git a/keyboards/snagpad/rules.mk b/keyboards/flehrad/snagpad/rules.mk similarity index 100% rename from keyboards/snagpad/rules.mk rename to keyboards/flehrad/snagpad/rules.mk diff --git a/keyboards/snagpad/snagpad.c b/keyboards/flehrad/snagpad/snagpad.c similarity index 100% rename from keyboards/snagpad/snagpad.c rename to keyboards/flehrad/snagpad/snagpad.c diff --git a/keyboards/snagpad/snagpad.h b/keyboards/flehrad/snagpad/snagpad.h similarity index 100% rename from keyboards/snagpad/snagpad.h rename to keyboards/flehrad/snagpad/snagpad.h diff --git a/keyboards/handwired/tradestation/config.h b/keyboards/flehrad/tradestation/config.h similarity index 100% rename from keyboards/handwired/tradestation/config.h rename to keyboards/flehrad/tradestation/config.h diff --git a/keyboards/handwired/tradestation/info.json b/keyboards/flehrad/tradestation/info.json similarity index 100% rename from keyboards/handwired/tradestation/info.json rename to keyboards/flehrad/tradestation/info.json diff --git a/keyboards/handwired/tradestation/keymaps/default/keymap.c b/keyboards/flehrad/tradestation/keymaps/default/keymap.c similarity index 100% rename from keyboards/handwired/tradestation/keymaps/default/keymap.c rename to keyboards/flehrad/tradestation/keymaps/default/keymap.c diff --git a/keyboards/snagpad/license b/keyboards/flehrad/tradestation/license similarity index 100% rename from keyboards/snagpad/license rename to keyboards/flehrad/tradestation/license diff --git a/keyboards/handwired/tradestation/readme.md b/keyboards/flehrad/tradestation/readme.md similarity index 97% rename from keyboards/handwired/tradestation/readme.md rename to keyboards/flehrad/tradestation/readme.md index 3a8c39e26327..d2a9c4d18d49 100644 --- a/keyboards/handwired/tradestation/readme.md +++ b/keyboards/flehrad/tradestation/readme.md @@ -22,6 +22,6 @@ Hardware Supported: Tradestation PCB, Pro Micro Make example for this keyboard (after setting up your build environment): - make tradestation:default + make flehrad/tradestation:default See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). diff --git a/keyboards/handwired/tradestation/rules.mk b/keyboards/flehrad/tradestation/rules.mk similarity index 100% rename from keyboards/handwired/tradestation/rules.mk rename to keyboards/flehrad/tradestation/rules.mk diff --git a/keyboards/handwired/tradestation/tradestation.c b/keyboards/flehrad/tradestation/tradestation.c similarity index 100% rename from keyboards/handwired/tradestation/tradestation.c rename to keyboards/flehrad/tradestation/tradestation.c diff --git a/keyboards/handwired/tradestation/tradestation.h b/keyboards/flehrad/tradestation/tradestation.h similarity index 100% rename from keyboards/handwired/tradestation/tradestation.h rename to keyboards/flehrad/tradestation/tradestation.h From 7de0f1771e830c54e3622ca6d6e5b9cd5305d06f Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Wed, 5 Aug 2020 15:11:06 +1000 Subject: [PATCH 25/54] Add support for hsv->rgb conversion without using CIE curve. (#9856) * Add support for hsv->rgb conversion without using CIE curve. * Modify anavi/macropad8 to disable unicode (was unused), otherwise firmware size is too large. --- keyboards/anavi/macropad8/rules.mk | 1 - quantum/color.c | 26 +++++++++++++++++++++++--- quantum/color.h | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/keyboards/anavi/macropad8/rules.mk b/keyboards/anavi/macropad8/rules.mk index 498c27a209f0..d4443e3fe6ed 100644 --- a/keyboards/anavi/macropad8/rules.mk +++ b/keyboards/anavi/macropad8/rules.mk @@ -23,7 +23,6 @@ NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: ht BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality MIDI_ENABLE = no # MIDI controls AUDIO_ENABLE = no # Audio output on port C6 -UNICODE_ENABLE = yes # Unicode BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. OLED_DRIVER_ENABLE = yes # Enable Support for SSD1306 or SH1106 OLED Displays; Communicating over I2C diff --git a/quantum/color.c b/quantum/color.c index c050300627ba..1c5128e4a2b0 100644 --- a/quantum/color.c +++ b/quantum/color.c @@ -18,14 +18,20 @@ #include "led_tables.h" #include "progmem.h" -RGB hsv_to_rgb(HSV hsv) { +RGB hsv_to_rgb_impl(HSV hsv, bool use_cie) { RGB rgb; uint8_t region, remainder, p, q, t; uint16_t h, s, v; if (hsv.s == 0) { #ifdef USE_CIE1931_CURVE - rgb.r = rgb.g = rgb.b = pgm_read_byte(&CIE1931_CURVE[hsv.v]); + if (use_cie) { + rgb.r = rgb.g = rgb.b = pgm_read_byte(&CIE1931_CURVE[hsv.v]); + } else { + rgb.r = hsv.v; + rgb.g = hsv.v; + rgb.b = hsv.v; + } #else rgb.r = hsv.v; rgb.g = hsv.v; @@ -37,7 +43,11 @@ RGB hsv_to_rgb(HSV hsv) { h = hsv.h; s = hsv.s; #ifdef USE_CIE1931_CURVE - v = pgm_read_byte(&CIE1931_CURVE[hsv.v]); + if (use_cie) { + v = pgm_read_byte(&CIE1931_CURVE[hsv.v]); + } else { + v = hsv.v; + } #else v = hsv.v; #endif @@ -86,6 +96,16 @@ RGB hsv_to_rgb(HSV hsv) { return rgb; } +RGB hsv_to_rgb(HSV hsv) { +#ifdef USE_CIE1931_CURVE + return hsv_to_rgb_impl(hsv, true); +#else + return hsv_to_rgb_impl(hsv, false); +#endif +} + +RGB hsv_to_rgb_nocie(HSV hsv) { return hsv_to_rgb_impl(hsv, false); } + #ifdef RGBW # ifndef MIN # define MIN(a, b) ((a) < (b) ? (a) : (b)) diff --git a/quantum/color.h b/quantum/color.h index 58d4f0407fab..5c5a0f0ebd32 100644 --- a/quantum/color.h +++ b/quantum/color.h @@ -64,6 +64,7 @@ typedef struct PACKED { #endif RGB hsv_to_rgb(HSV hsv); +RGB hsv_to_rgb_nocie(HSV hsv); #ifdef RGBW void convert_rgb_to_rgbw(LED_TYPE *led); #endif From c4d3b244367442051d4ed1d9b17f0c287e961767 Mon Sep 17 00:00:00 2001 From: Tynan Beatty <38031130+tynanbe@users.noreply.github.com> Date: Fri, 7 Aug 2020 16:43:57 -0500 Subject: [PATCH 26/54] Noeeprom functions for rgb_matrix (#9487) * Add eeprom_helpers for toggle, mode, sethsv, speed; add set_speed; add noeeprom versions of toggle, step, hue, sat, val, and speed * qmk cformat rgb_matrix * Add rgb_matrix_set_speed and *_noeeprom functions * Do not expose rgb_matrix_*_eeprom_helper functions --- docs/feature_rgb_matrix.md | 20 ++++- quantum/rgb_matrix.c | 155 +++++++++++++++++++++---------------- quantum/rgb_matrix.h | 64 ++++++++++----- 3 files changed, 149 insertions(+), 90 deletions(-) diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md index 2cde3ec56950..a8fad59a191a 100644 --- a/docs/feature_rgb_matrix.md +++ b/docs/feature_rgb_matrix.md @@ -422,8 +422,8 @@ Where `28` is an unused index from `eeconfig.h`. |`rgb_matrix_toggle_noeeprom()` |Toggle effect range LEDs between on and off (not written to EEPROM) | |`rgb_matrix_enable()` |Turn effect range LEDs on, based on their previous state | |`rgb_matrix_enable_noeeprom()` |Turn effect range LEDs on, based on their previous state (not written to EEPROM) | -|`rgb_matrix_disable()` |Turn effect range LEDs off | -|`rgb_matrix_disable_noeeprom()` |Turn effect range LEDs off (not written to EEPROM) | +|`rgb_matrix_disable()` |Turn effect range LEDs off, based on their previous state | +|`rgb_matrix_disable_noeeprom()` |Turn effect range LEDs off, based on their previous state (not written to EEPROM) | ### Change Effect Mode :id=change-effect-mode |Function |Description | @@ -431,19 +431,31 @@ Where `28` is an unused index from `eeconfig.h`. |`rgb_matrix_mode(mode)` |Set the mode, if RGB animations are enabled | |`rgb_matrix_mode_noeeprom(mode)` |Set the mode, if RGB animations are enabled (not written to EEPROM) | |`rgb_matrix_step()` |Change the mode to the next RGB animation in the list of enabled RGB animations | +|`rgb_matrix_step_noeeprom()` |Change the mode to the next RGB animation in the list of enabled RGB animations (not written to EEPROM) | |`rgb_matrix_step_reverse()` |Change the mode to the previous RGB animation in the list of enabled RGB animations | -|`rgb_matrix_increase_speed()` |Increases the speed of the animations | -|`rgb_matrix_decrease_speed()` |Decreases the speed of the animations | +|`rgb_matrix_step_reverse_noeeprom()` |Change the mode to the previous RGB animation in the list of enabled RGB animations (not written to EEPROM) | +|`rgb_matrix_increase_speed()` |Increase the speed of the animations | +|`rgb_matrix_increase_speed_noeeprom()` |Increase the speed of the animations (not written to EEPROM) | +|`rgb_matrix_decrease_speed()` |Decrease the speed of the animations | +|`rgb_matrix_decrease_speed_noeeprom()` |Decrease the speed of the animations (not written to EEPROM) | +|`rgb_matrix_set_speed(speed)` |Set the speed of the animations to the given value where `speed` is between 0 and 255 | +|`rgb_matrix_set_speed_noeeprom(speed)` |Set the speed of the animations to the given value where `speed` is between 0 and 255 (not written to EEPROM) | ### Change Color :id=change-color |Function |Description | |--------------------------------------------|-------------| |`rgb_matrix_increase_hue()` |Increase the hue for effect range LEDs. This wraps around at maximum hue | +|`rgb_matrix_increase_hue_noeeprom()` |Increase the hue for effect range LEDs. This wraps around at maximum hue (not written to EEPROM) | |`rgb_matrix_decrease_hue()` |Decrease the hue for effect range LEDs. This wraps around at minimum hue | +|`rgb_matrix_decrease_hue_noeeprom()` |Decrease the hue for effect range LEDs. This wraps around at minimum hue (not written to EEPROM) | |`rgb_matrix_increase_sat()` |Increase the saturation for effect range LEDs. This wraps around at maximum saturation | +|`rgb_matrix_increase_sat_noeeprom()` |Increase the saturation for effect range LEDs. This wraps around at maximum saturation (not written to EEPROM) | |`rgb_matrix_decrease_sat()` |Decrease the saturation for effect range LEDs. This wraps around at minimum saturation | +|`rgb_matrix_decrease_sat_noeeprom()` |Decrease the saturation for effect range LEDs. This wraps around at minimum saturation (not written to EEPROM) | |`rgb_matrix_increase_val()` |Increase the value for effect range LEDs. This wraps around at maximum value | +|`rgb_matrix_increase_val_noeeprom()` |Increase the value for effect range LEDs. This wraps around at maximum value (not written to EEPROM) | |`rgb_matrix_decrease_val()` |Decrease the value for effect range LEDs. This wraps around at minimum value | +|`rgb_matrix_decrease_val_noeeprom()` |Decrease the value for effect range LEDs. This wraps around at minimum value (not written to EEPROM) | |`rgb_matrix_sethsv(h, s, v)` |Set LEDs to the given HSV value where `h`/`s`/`v` are between 0 and 255 | |`rgb_matrix_sethsv_noeeprom(h, s, v)` |Set LEDs to the given HSV value where `h`/`s`/`v` are between 0 and 255 (not written to EEPROM) | diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 615b4b0a7bf6..802c5afcee21 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -155,7 +155,7 @@ void eeconfig_update_rgb_matrix_default(void) { } void eeconfig_debug_rgb_matrix(void) { - dprintf("rgb_matrix_config eprom\n"); + dprintf("rgb_matrix_config EEPROM\n"); dprintf("rgb_matrix_config.enable = %d\n", rgb_matrix_config.enable); dprintf("rgb_matrix_config.mode = %d\n", rgb_matrix_config.mode); dprintf("rgb_matrix_config.hsv.h = %d\n", rgb_matrix_config.hsv.h); @@ -462,11 +462,16 @@ void rgb_matrix_set_suspend_state(bool state) { bool rgb_matrix_get_suspend_state(void) { return g_suspend_state; } -void rgb_matrix_toggle(void) { +void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) { rgb_matrix_config.enable ^= 1; rgb_task_state = STARTING; - eeconfig_update_rgb_matrix(); + if (write_to_eeprom) { + eeconfig_update_rgb_matrix(); + } + dprintf("rgb matrix toggle [%s]: rgb_matrix_config.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.enable); } +void rgb_matrix_toggle_noeeprom(void) { rgb_matrix_toggle_eeprom_helper(false); } +void rgb_matrix_toggle(void) { rgb_matrix_toggle_eeprom_helper(true); } void rgb_matrix_enable(void) { rgb_matrix_enable_noeeprom(); @@ -490,90 +495,106 @@ void rgb_matrix_disable_noeeprom(void) { uint8_t rgb_matrix_is_enabled(void) { return rgb_matrix_config.enable; } -void rgb_matrix_step(void) { - rgb_matrix_config.mode++; - if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX) rgb_matrix_config.mode = 1; +void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { + if (!rgb_matrix_config.enable) { + return; + } + if (mode < 1) { + rgb_matrix_config.mode = 1; + } else if (mode >= RGB_MATRIX_EFFECT_MAX) { + rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1; + } else { + rgb_matrix_config.mode = mode; + } rgb_task_state = STARTING; - eeconfig_update_rgb_matrix(); + if (write_to_eeprom) { + eeconfig_update_rgb_matrix(); + } + dprintf("rgb matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.mode); } +void rgb_matrix_mode_noeeprom(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, false); } +void rgb_matrix_mode(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, true); } -void rgb_matrix_step_reverse(void) { - rgb_matrix_config.mode--; - if (rgb_matrix_config.mode < 1) rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1; - rgb_task_state = STARTING; - eeconfig_update_rgb_matrix(); -} +uint8_t rgb_matrix_get_mode(void) { return rgb_matrix_config.mode; } -void rgb_matrix_increase_hue(void) { - rgb_matrix_config.hsv.h += RGB_MATRIX_HUE_STEP; - eeconfig_update_rgb_matrix(); +void rgb_matrix_step_helper(bool write_to_eeprom) { + uint8_t mode = rgb_matrix_config.mode + 1; + rgb_matrix_mode_eeprom_helper((mode < RGB_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom); } +void rgb_matrix_step_noeeprom(void) { rgb_matrix_step_helper(false); } +void rgb_matrix_step(void) { rgb_matrix_step_helper(true); } -void rgb_matrix_decrease_hue(void) { - rgb_matrix_config.hsv.h -= RGB_MATRIX_HUE_STEP; - eeconfig_update_rgb_matrix(); +void rgb_matrix_step_reverse_helper(bool write_to_eeprom) { + uint8_t mode = rgb_matrix_config.mode - 1; + rgb_matrix_mode_eeprom_helper((mode < 1) ? RGB_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom); } +void rgb_matrix_step_reverse_noeeprom(void) { rgb_matrix_step_reverse_helper(false); } +void rgb_matrix_step_reverse(void) { rgb_matrix_step_reverse_helper(true); } -void rgb_matrix_increase_sat(void) { - rgb_matrix_config.hsv.s = qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP); - eeconfig_update_rgb_matrix(); -} - -void rgb_matrix_decrease_sat(void) { - rgb_matrix_config.hsv.s = qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP); - eeconfig_update_rgb_matrix(); +void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { + if (!rgb_matrix_config.enable) { + return; + } + rgb_matrix_config.hsv.h = hue; + rgb_matrix_config.hsv.s = sat; + rgb_matrix_config.hsv.v = (val > RGB_MATRIX_MAXIMUM_BRIGHTNESS) ? RGB_MATRIX_MAXIMUM_BRIGHTNESS : val; + if (write_to_eeprom) { + eeconfig_update_rgb_matrix(); + } + dprintf("rgb matrix set hsv [%s]: %u,%u,%u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); } +void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_sethsv_eeprom_helper(hue, sat, val, false); } +void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_sethsv_eeprom_helper(hue, sat, val, true); } -void rgb_matrix_increase_val(void) { - rgb_matrix_config.hsv.v = qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP); - if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS; - eeconfig_update_rgb_matrix(); -} +HSV rgb_matrix_get_hsv(void) { return rgb_matrix_config.hsv; } +uint8_t rgb_matrix_get_hue(void) { return rgb_matrix_config.hsv.h; } +uint8_t rgb_matrix_get_sat(void) { return rgb_matrix_config.hsv.s; } +uint8_t rgb_matrix_get_val(void) { return rgb_matrix_config.hsv.v; } -void rgb_matrix_decrease_val(void) { - rgb_matrix_config.hsv.v = qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP); - eeconfig_update_rgb_matrix(); -} +void rgb_matrix_increase_hue_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h + RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); } +void rgb_matrix_increase_hue_noeeprom(void) { rgb_matrix_increase_hue_helper(false); } +void rgb_matrix_increase_hue(void) { rgb_matrix_increase_hue_helper(true); } -void rgb_matrix_increase_speed(void) { - rgb_matrix_config.speed = qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP); - eeconfig_update_rgb_matrix(); -} +void rgb_matrix_decrease_hue_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h - RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); } +void rgb_matrix_decrease_hue_noeeprom(void) { rgb_matrix_decrease_hue_helper(false); } +void rgb_matrix_decrease_hue(void) { rgb_matrix_decrease_hue_helper(true); } -void rgb_matrix_decrease_speed(void) { - rgb_matrix_config.speed = qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP); - eeconfig_update_rgb_matrix(); -} +void rgb_matrix_increase_sat_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); } +void rgb_matrix_increase_sat_noeeprom(void) { rgb_matrix_increase_sat_helper(false); } +void rgb_matrix_increase_sat(void) { rgb_matrix_increase_sat_helper(true); } -uint8_t rgb_matrix_get_speed(void) { return rgb_matrix_config.speed; } +void rgb_matrix_decrease_sat_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); } +void rgb_matrix_decrease_sat_noeeprom(void) { rgb_matrix_decrease_sat_helper(false); } +void rgb_matrix_decrease_sat(void) { rgb_matrix_decrease_sat_helper(true); } -led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; } +void rgb_matrix_increase_val_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); } +void rgb_matrix_increase_val_noeeprom(void) { rgb_matrix_increase_val_helper(false); } +void rgb_matrix_increase_val(void) { rgb_matrix_increase_val_helper(true); } -void rgb_matrix_set_flags(led_flags_t flags) { rgb_effect_params.flags = flags; } +void rgb_matrix_decrease_val_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); } +void rgb_matrix_decrease_val_noeeprom(void) { rgb_matrix_decrease_val_helper(false); } +void rgb_matrix_decrease_val(void) { rgb_matrix_decrease_val_helper(true); } -void rgb_matrix_mode(uint8_t mode) { - rgb_matrix_config.mode = mode; - rgb_task_state = STARTING; - eeconfig_update_rgb_matrix(); +void rgb_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { + rgb_matrix_config.speed = speed; + if (write_to_eeprom) { + eeconfig_update_rgb_matrix(); + } + dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.speed); } +void rgb_matrix_set_speed_noeeprom(uint8_t speed) { rgb_matrix_set_speed_eeprom_helper(speed, false); } +void rgb_matrix_set_speed(uint8_t speed) { rgb_matrix_set_speed_eeprom_helper(speed, true); } -void rgb_matrix_mode_noeeprom(uint8_t mode) { rgb_matrix_config.mode = mode; } +uint8_t rgb_matrix_get_speed(void) { return rgb_matrix_config.speed; } -uint8_t rgb_matrix_get_mode(void) { return rgb_matrix_config.mode; } +void rgb_matrix_increase_speed_helper(bool write_to_eeprom) { rgb_matrix_set_speed_eeprom_helper(qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); } +void rgb_matrix_increase_speed_noeeprom(void) { rgb_matrix_increase_speed_helper(false); } +void rgb_matrix_increase_speed(void) { rgb_matrix_increase_speed_helper(true); } -void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { - rgb_matrix_sethsv_noeeprom(hue, sat, val); - eeconfig_update_rgb_matrix(); -} +void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { rgb_matrix_set_speed_eeprom_helper(qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); } +void rgb_matrix_decrease_speed_noeeprom(void) { rgb_matrix_decrease_speed_helper(false); } +void rgb_matrix_decrease_speed(void) { rgb_matrix_decrease_speed_helper(true); } -void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { - rgb_matrix_config.hsv.h = hue; - rgb_matrix_config.hsv.s = sat; - rgb_matrix_config.hsv.v = val; - if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS; -} +led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; } -HSV rgb_matrix_get_hsv(void) { return rgb_matrix_config.hsv; } -uint8_t rgb_matrix_get_hue(void) { return rgb_matrix_config.hsv.h; } -uint8_t rgb_matrix_get_sat(void) { return rgb_matrix_config.hsv.s; } -uint8_t rgb_matrix_get_val(void) { return rgb_matrix_config.hsv.v; } +void rgb_matrix_set_flags(led_flags_t flags) { rgb_effect_params.flags = flags; } diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index 03e9e8572c57..733333349faa 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h @@ -108,61 +108,87 @@ void rgb_matrix_init(void); void rgb_matrix_set_suspend_state(bool state); bool rgb_matrix_get_suspend_state(void); void rgb_matrix_toggle(void); +void rgb_matrix_toggle_noeeprom(void); void rgb_matrix_enable(void); void rgb_matrix_enable_noeeprom(void); void rgb_matrix_disable(void); void rgb_matrix_disable_noeeprom(void); uint8_t rgb_matrix_is_enabled(void); +void rgb_matrix_mode(uint8_t mode); +void rgb_matrix_mode_noeeprom(uint8_t mode); +uint8_t rgb_matrix_get_mode(void); void rgb_matrix_step(void); +void rgb_matrix_step_noeeprom(void); void rgb_matrix_step_reverse(void); +void rgb_matrix_step_reverse_noeeprom(void); +void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val); +void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); +HSV rgb_matrix_get_hsv(void); +uint8_t rgb_matrix_get_hue(void); +uint8_t rgb_matrix_get_sat(void); +uint8_t rgb_matrix_get_val(void); void rgb_matrix_increase_hue(void); +void rgb_matrix_increase_hue_noeeprom(void); void rgb_matrix_decrease_hue(void); +void rgb_matrix_decrease_hue_noeeprom(void); void rgb_matrix_increase_sat(void); +void rgb_matrix_increase_sat_noeeprom(void); void rgb_matrix_decrease_sat(void); +void rgb_matrix_decrease_sat_noeeprom(void); void rgb_matrix_increase_val(void); +void rgb_matrix_increase_val_noeeprom(void); void rgb_matrix_decrease_val(void); +void rgb_matrix_decrease_val_noeeprom(void); +void rgb_matrix_set_speed(uint8_t speed); +void rgb_matrix_set_speed_noeeprom(uint8_t speed); +uint8_t rgb_matrix_get_speed(void); void rgb_matrix_increase_speed(void); +void rgb_matrix_increase_speed_noeeprom(void); void rgb_matrix_decrease_speed(void); -uint8_t rgb_matrix_get_speed(void); +void rgb_matrix_decrease_speed_noeeprom(void); led_flags_t rgb_matrix_get_flags(void); void rgb_matrix_set_flags(led_flags_t flags); -void rgb_matrix_mode(uint8_t mode); -void rgb_matrix_mode_noeeprom(uint8_t mode); -uint8_t rgb_matrix_get_mode(void); -void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val); -void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); -HSV rgb_matrix_get_hsv(void); -uint8_t rgb_matrix_get_hue(void); -uint8_t rgb_matrix_get_sat(void); -uint8_t rgb_matrix_get_val(void); #ifndef RGBLIGHT_ENABLE # define rgblight_toggle rgb_matrix_toggle +# define rgblight_toggle_noeeprom rgb_matrix_toggle_noeeprom # define rgblight_enable rgb_matrix_enable # define rgblight_enable_noeeprom rgb_matrix_enable_noeeprom # define rgblight_disable rgb_matrix_disable # define rgblight_disable_noeeprom rgb_matrix_disable_noeeprom # define rgblight_is_enabled rgb_matrix_is_enabled +# define rgblight_mode rgb_matrix_mode +# define rgblight_mode_noeeprom rgb_matrix_mode_noeeprom +# define rgblight_get_mode rgb_matrix_get_mode +# define rgblight_get_hue rgb_matrix_get_hue +# define rgblight_get_sat rgb_matrix_get_sat +# define rgblight_get_val rgb_matrix_get_val +# define rgblight_get_hsv rgb_matrix_get_hsv # define rgblight_step rgb_matrix_step +# define rgblight_step_noeeprom rgb_matrix_step_noeeprom +# define rgblight_step_reverse rgb_matrix_step_reverse +# define rgblight_step_reverse_noeeprom rgb_matrix_step_reverse_noeeprom # define rgblight_sethsv rgb_matrix_sethsv # define rgblight_sethsv_noeeprom rgb_matrix_sethsv_noeeprom -# define rgblight_step_reverse rgb_matrix_step_reverse # define rgblight_increase_hue rgb_matrix_increase_hue +# define rgblight_increase_hue_noeeprom rgb_matrix_increase_hue_noeeprom # define rgblight_decrease_hue rgb_matrix_decrease_hue +# define rgblight_decrease_hue_noeeprom rgb_matrix_decrease_hue_noeeprom # define rgblight_increase_sat rgb_matrix_increase_sat +# define rgblight_increase_sat_noeeprom rgb_matrix_increase_sat_noeeprom # define rgblight_decrease_sat rgb_matrix_decrease_sat +# define rgblight_decrease_sat_noeeprom rgb_matrix_decrease_sat_noeeprom # define rgblight_increase_val rgb_matrix_increase_val +# define rgblight_increase_val_noeeprom rgb_matrix_increase_val_noeeprom # define rgblight_decrease_val rgb_matrix_decrease_val +# define rgblight_decrease_val_noeeprom rgb_matrix_decrease_val_noeeprom +# define rgblight_set_speed rgb_matrix_set_speed +# define rgblight_set_speed_noeeprom rgb_matrix_set_speed_noeeprom +# define rgblight_get_speed rgb_matrix_get_speed # define rgblight_increase_speed rgb_matrix_increase_speed +# define rgblight_increase_speed_noeeprom rgb_matrix_increase_speed_noeeprom # define rgblight_decrease_speed rgb_matrix_decrease_speed -# define rgblight_get_speed rgb_matrix_get_speed -# define rgblight_mode rgb_matrix_mode -# define rgblight_mode_noeeprom rgb_matrix_mode_noeeprom -# define rgblight_get_mode rgb_matrix_get_mode -# define rgblight_get_hue rgb_matrix_get_hue -# define rgblight_get_sat rgb_matrix_get_sat -# define rgblight_get_val rgb_matrix_get_val -# define rgblight_get_hsv rgb_matrix_get_hsv +# define rgblight_decrease_speed_noeeprom rgb_matrix_decrease_speed_noeeprom #endif typedef struct { From 6bd3bf2bdd82526f97aa76b127d654b565cf6179 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 8 Aug 2020 10:24:29 +1000 Subject: [PATCH 27/54] Fix joystick compile issues (#9949) --- .../onekey/keymaps/joystick/config.h | 1 + .../onekey/keymaps/joystick/keymap.c | 21 ++++++++++--------- tmk_core/protocol/lufa/lufa.c | 4 +++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/keyboards/handwired/onekey/keymaps/joystick/config.h b/keyboards/handwired/onekey/keymaps/joystick/config.h index 5701d80c84c0..ac09aa7cfb28 100644 --- a/keyboards/handwired/onekey/keymaps/joystick/config.h +++ b/keyboards/handwired/onekey/keymaps/joystick/config.h @@ -1,3 +1,4 @@ #pragma once + #define JOYSTICK_AXES_COUNT 2 #define JOYSTICK_BUTTON_COUNT 1 diff --git a/keyboards/handwired/onekey/keymaps/joystick/keymap.c b/keyboards/handwired/onekey/keymaps/joystick/keymap.c index 60802f464a90..f427b9d77d40 100644 --- a/keyboards/handwired/onekey/keymaps/joystick/keymap.c +++ b/keyboards/handwired/onekey/keymaps/joystick/keymap.c @@ -7,19 +7,20 @@ #endif const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - LAYOUT( JS_BUTTON0 ) + LAYOUT_ortho_1x1(JS_BUTTON0) }; void matrix_scan_user() { - int16_t val = (((uint32_t)timer_read()%5000 - 2500) * 255) / 5000; - if (val != joystick_status.axes[1]) { - joystick_status.axes[1] = val; - joystick_status.status |= JS_UPDATED; - } + int16_t val = (((uint32_t)timer_read() % 5000 - 2500) * 255) / 5000; + + if (val != joystick_status.axes[1]) { + joystick_status.axes[1] = val; + joystick_status.status |= JS_UPDATED; + } } -//joystick config +// Joystick config joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = { - [0] = JOYSTICK_AXIS_IN(ADC_PIN, 0, 512, 1023) - , [1] = JOYSTICK_AXIS_VIRTUAL -}; \ No newline at end of file + [0] = JOYSTICK_AXIS_IN(ADC_PIN, 0, 512, 1023), + [1] = JOYSTICK_AXIS_VIRTUAL +}; diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 85603646db98..8410eb483ff7 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -475,8 +475,10 @@ void EVENT_USB_Device_ConfigurationChanged(void) { ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_BULK, CDC_EPSIZE, 1); ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, CDC_EPSIZE, 1); #endif + #ifdef JOYSTICK_ENABLE - ConfigSuccess &= ENDPOINT_CONFIG(JOYSTICK_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, JOYSTICK_EPSIZE, ENDPOINT_BANK_SINGLE); + /* Setup joystick endpoint */ + ConfigSuccess &= Endpoint_ConfigureEndpoint((JOYSTICK_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, JOYSTICK_EPSIZE, 1); #endif } From 8b7b3cedaf40e92452282b784c714daf93184f13 Mon Sep 17 00:00:00 2001 From: David Kosorin Date: Tue, 11 Aug 2020 04:26:34 +0200 Subject: [PATCH 28/54] Fix Czech keycodes (#9987) --- quantum/keymap_extras/keymap_czech.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quantum/keymap_extras/keymap_czech.h b/quantum/keymap_extras/keymap_czech.h index 7e9d299f499c..43ba2a14ffb5 100644 --- a/quantum/keymap_extras/keymap_czech.h +++ b/quantum/keymap_extras/keymap_czech.h @@ -94,7 +94,7 @@ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │ * │      │   │   │   │   │   │   │   │   │   │ " │ ! │ ' │    │ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤ - * │    │ | │   │   │   │   │   │   │   │ ; │ : │ _ │          │ + * │    │ | │   │   │   │   │   │   │   │ ? │ : │ _ │          │ * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ * │    │    │    │                        │    │    │    │    │ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ @@ -122,7 +122,7 @@ #define CZ_QUOT S(CZ_DIAE) // ' // Row 4 #define CZ_PIPE S(CZ_BSLS) // | -#define CZ_SCLN S(CZ_COMM) // ; +#define CZ_QUES S(CZ_COMM) // ? #define CZ_COLN S(CZ_DOT) // : #define CZ_UNDS S(CZ_MINS) // _ From d98e04431215b3ee4efb198ba3f22f27c67ccebb Mon Sep 17 00:00:00 2001 From: Danny Date: Wed, 12 Aug 2020 11:37:34 -0400 Subject: [PATCH 29/54] Keebio RGB wiring update (#7754) * Change RGB wiring for Levinson * Update RGB wiring for Iris * Update RGB wiring for Nyquist * Update RGB wiring for Quefrency * Update RGB wiring for Viterbi * Update RGB wiring for Fourier * Update RGB wiring for BFO * Handle redefinition of RGBLED_SPLIT --- keyboards/keebio/bfo9000/config.h | 1 + keyboards/keebio/fourier/config.h | 1 + keyboards/keebio/iris/rev2/config.h | 1 + keyboards/keebio/levinson/rev1/config.h | 2 +- keyboards/keebio/levinson/rev2/config.h | 2 +- keyboards/keebio/nyquist/rev1/config.h | 4 ++-- keyboards/keebio/nyquist/rev2/config.h | 4 ++-- keyboards/keebio/quefrency/keymaps/drashna_ms/config.h | 1 + keyboards/keebio/quefrency/rev1/config.h | 1 + keyboards/keebio/viterbi/rev1/config.h | 1 + keyboards/keebio/viterbi/rev2/config.h | 1 + 11 files changed, 13 insertions(+), 6 deletions(-) diff --git a/keyboards/keebio/bfo9000/config.h b/keyboards/keebio/bfo9000/config.h index 0b279bc34368..671575536e8a 100644 --- a/keyboards/keebio/bfo9000/config.h +++ b/keyboards/keebio/bfo9000/config.h @@ -53,6 +53,7 @@ along with this program. If not, see . /* ws2812 RGB LED */ #define RGB_DI_PIN B4 #define RGBLED_NUM 20 // Number of LEDs +#define RGBLED_SPLIT { 10, 10 } /* * Feature disable options diff --git a/keyboards/keebio/fourier/config.h b/keyboards/keebio/fourier/config.h index a0e85a3b1e78..b9db50aac541 100644 --- a/keyboards/keebio/fourier/config.h +++ b/keyboards/keebio/fourier/config.h @@ -65,6 +65,7 @@ along with this program. If not, see . #define RGB_DI_PIN D3 #define RGBLIGHT_ANIMATIONS #define RGBLED_NUM 14 // Number of LEDs +#define RGBLED_SPLIT { 7, 7 } /* * Feature disable options diff --git a/keyboards/keebio/iris/rev2/config.h b/keyboards/keebio/iris/rev2/config.h index 4ead367d3ca4..c3da1321c38f 100644 --- a/keyboards/keebio/iris/rev2/config.h +++ b/keyboards/keebio/iris/rev2/config.h @@ -60,4 +60,5 @@ along with this program. If not, see . /* ws2812 RGB LED */ #define RGB_DI_PIN D3 #define RGBLED_NUM 12 // Number of LEDs +#define RGBLED_SPLIT { 6, 6 } #define RGBLIGHT_ANIMATIONS diff --git a/keyboards/keebio/levinson/rev1/config.h b/keyboards/keebio/levinson/rev1/config.h index 5b23f18c1d36..a8854b1357eb 100644 --- a/keyboards/keebio/levinson/rev1/config.h +++ b/keyboards/keebio/levinson/rev1/config.h @@ -51,8 +51,8 @@ along with this program. If not, see . /* ws2812 RGB LED */ #define RGB_DI_PIN D3 - #define RGBLED_NUM 12 // Number of LEDs +#define RGBLED_SPLIT { 6, 6 } /* Backlight LEDs */ #define BACKLIGHT_PIN C6 diff --git a/keyboards/keebio/levinson/rev2/config.h b/keyboards/keebio/levinson/rev2/config.h index e8e7294dd867..5b1ae6fe1ec1 100644 --- a/keyboards/keebio/levinson/rev2/config.h +++ b/keyboards/keebio/levinson/rev2/config.h @@ -51,8 +51,8 @@ along with this program. If not, see . /* ws2812 RGB LED */ #define RGB_DI_PIN D3 - #define RGBLED_NUM 12 // Number of LEDs +#define RGBLED_SPLIT { 6, 6 } /* Backlight LEDs */ #define BACKLIGHT_PIN B5 diff --git a/keyboards/keebio/nyquist/rev1/config.h b/keyboards/keebio/nyquist/rev1/config.h index 75fa43b5874c..0822f91ad9ed 100644 --- a/keyboards/keebio/nyquist/rev1/config.h +++ b/keyboards/keebio/nyquist/rev1/config.h @@ -56,8 +56,8 @@ along with this program. If not, see . /* ws2812 RGB LED */ #define RGB_DI_PIN D3 - -#define RGBLED_NUM 16 // Number of LEDs +#define RGBLED_NUM 12 +#define RGBLED_SPLIT { 6, 6 } /* * Feature disable options diff --git a/keyboards/keebio/nyquist/rev2/config.h b/keyboards/keebio/nyquist/rev2/config.h index 9775113c6317..2810bde7a2ef 100644 --- a/keyboards/keebio/nyquist/rev2/config.h +++ b/keyboards/keebio/nyquist/rev2/config.h @@ -53,8 +53,8 @@ along with this program. If not, see . /* ws2812 RGB LED */ #define RGB_DI_PIN D3 - -#define RGBLED_NUM 16 // Number of LEDs +#define RGBLED_NUM 12 +#define RGBLED_SPLIT { 6, 6 } /* Backlight LEDs */ #define BACKLIGHT_PIN B6 diff --git a/keyboards/keebio/quefrency/keymaps/drashna_ms/config.h b/keyboards/keebio/quefrency/keymaps/drashna_ms/config.h index ec2a2ea164e5..089c8cf79e52 100644 --- a/keyboards/keebio/quefrency/keymaps/drashna_ms/config.h +++ b/keyboards/keebio/quefrency/keymaps/drashna_ms/config.h @@ -29,6 +29,7 @@ along with this program. If not, see . #define RGBLIGHT_SPLIT #undef RGBLED_NUM #define RGBLED_NUM 17 + #undef RGBLED_SPLIT #define RGBLED_SPLIT { 9, 8 } #define RGBLIGHT_SLEEP #endif diff --git a/keyboards/keebio/quefrency/rev1/config.h b/keyboards/keebio/quefrency/rev1/config.h index e9379ab2ff5f..b67507187466 100644 --- a/keyboards/keebio/quefrency/rev1/config.h +++ b/keyboards/keebio/quefrency/rev1/config.h @@ -55,6 +55,7 @@ along with this program. If not, see . #define RGB_DI_PIN D3 #define RGBLIGHT_ANIMATIONS #define RGBLED_NUM 16 // Number of LEDs +#define RGBLED_SPLIT { 8, 8 } // Set 65% column (option 1) and Macro (option 2) on by default #define VIA_EEPROM_LAYOUT_OPTIONS_DEFAULT 0x60 diff --git a/keyboards/keebio/viterbi/rev1/config.h b/keyboards/keebio/viterbi/rev1/config.h index 12a61448d16f..131bf8fbc68d 100644 --- a/keyboards/keebio/viterbi/rev1/config.h +++ b/keyboards/keebio/viterbi/rev1/config.h @@ -51,3 +51,4 @@ along with this program. If not, see . /* ws2812 RGB LED */ #define RGB_DI_PIN D3 #define RGBLED_NUM 14 +#define RGBLED_SPLIT { 7, 7 } diff --git a/keyboards/keebio/viterbi/rev2/config.h b/keyboards/keebio/viterbi/rev2/config.h index 0b78604d8f7f..83de01f32f85 100644 --- a/keyboards/keebio/viterbi/rev2/config.h +++ b/keyboards/keebio/viterbi/rev2/config.h @@ -50,6 +50,7 @@ along with this program. If not, see . /* ws2812 RGB LED */ #define RGB_DI_PIN D3 #define RGBLED_NUM 14 +#define RGBLED_SPLIT { 7, 7 } /* Backlight LEDs */ #define BACKLIGHT_PIN B6 From 6a8cbaa16c32cf96e95a4fee28d706866f5582cb Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Wed, 12 Aug 2020 18:53:53 +0300 Subject: [PATCH 30/54] Add `st-flash` flash target (#9964) * Add `st-flash` flash target Add support for flashing the firmware via the `st-flash` utility from the STLink Tools package (https://github.com/stlink-org/stlink). * Add `st-flash` to the `qmk flash -b` output --- docs/flashing.md | 1 + lib/python/qmk/cli/flash.py | 1 + tmk_core/chibios.mk | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/docs/flashing.md b/docs/flashing.md index 1f71c253c3a0..5c245c567546 100644 --- a/docs/flashing.md +++ b/docs/flashing.md @@ -239,3 +239,4 @@ There are a number of DFU commands that you can use to flash firmware to a STM32 * `:dfu-util-split-left` - This flashes the normal firmware, just like the default option (`:dfu-util`). However, this also configures the "Left Side" EEPROM setting for split keyboards. * `:dfu-util-split-right` - This flashes the normal firmware, just like the default option (`:dfu-util`). However, this also configures the "Right Side" EEPROM setting for split keyboards. * `:st-link-cli` - This allows you to flash the firmware via ST-LINK's CLI utility, rather than dfu-util. +* `:st-flash` - This allows you to flash the firmware via the `st-flash` utility from [STLink Tools](https://github.com/stlink-org/stlink), rather than dfu-util. diff --git a/lib/python/qmk/cli/flash.py b/lib/python/qmk/cli/flash.py index f8497071efd5..cefb9ca31a5e 100644 --- a/lib/python/qmk/cli/flash.py +++ b/lib/python/qmk/cli/flash.py @@ -27,6 +27,7 @@ def print_bootloader_help(): cli.echo('\tdfu-util-split-left') cli.echo('\tdfu-util-split-right') cli.echo('\tst-link-cli') + cli.echo('\tst-flash') cli.echo('For more info, visit https://docs.qmk.fm/#/flashing') diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk index 4e8abc9be6c4..a218488a194f 100644 --- a/tmk_core/chibios.mk +++ b/tmk_core/chibios.mk @@ -318,12 +318,14 @@ ifneq ("$(SERIAL)","") endif ST_LINK_ARGS ?= +ST_FLASH_ARGS ?= # List any extra directories to look for libraries here. EXTRALIBDIRS = $(RULESPATH)/ld DFU_UTIL ?= dfu-util ST_LINK_CLI ?= st-link_cli +ST_FLASH ?= st-flash define EXEC_DFU_UTIL until $(DFU_UTIL) -l | grep -q "Found DFU"; do\ @@ -357,6 +359,9 @@ dfu-util-split-right: dfu-util st-link-cli: $(BUILD_DIR)/$(TARGET).hex sizeafter $(ST_LINK_CLI) $(ST_LINK_ARGS) -q -c SWD -p $(BUILD_DIR)/$(TARGET).hex -Rst +st-flash: $(BUILD_DIR)/$(TARGET).hex sizeafter + $(ST_FLASH) $(ST_FLASH_ARGS) --reset --format ihex write $(BUILD_DIR)/$(TARGET).hex + # Autodetect teensy loader ifndef TEENSY_LOADER_CLI From 5cb57c706d3db79a7175c4cd72aa56a6b6383d96 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sun, 16 Aug 2020 06:51:35 +1000 Subject: [PATCH 31/54] Add ability to dump all makefile variables for the specified target. (#8256) --- tmk_core/rules.mk | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index 9bb341ecb115..a7053d185c60 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk @@ -396,6 +396,12 @@ show_path: @echo SRC=$(SRC) @echo OBJ=$(OBJ) +dump_vars: ERROR_IF_EMPTY="" +dump_vars: ERROR_IF_NONBOOL="" +dump_vars: ERROR_IF_UNSET="" +dump_vars: + @$(foreach V,$(sort $(.VARIABLES)),$(if $(filter-out environment% default automatic,$(origin $V)),$(info $V=$($V)))) + objs-size: for i in $(OBJ); do echo $$i; done | sort | xargs $(SIZE) @@ -436,7 +442,7 @@ $(eval $(foreach OUTPUT,$(OUTPUTS),$(shell mkdir -p $(OUTPUT) 2>/dev/null))) # Listing of phony targets. -.PHONY : all finish sizebefore sizeafter qmkversion \ +.PHONY : all dump_vars finish sizebefore sizeafter qmkversion \ gccversion build elf hex eep lss sym coff extcoff \ clean clean_list debug gdb-config show_path \ program teensy dfu dfu-ee dfu-start \ From a9d4e67cef417f9376aeb80316471bc672743247 Mon Sep 17 00:00:00 2001 From: Greg Wright Date: Sat, 15 Aug 2020 16:55:13 -0400 Subject: [PATCH 32/54] #define AUTO_SHIFT_SETUP (#8441) * #define AUTO_SHIFT_SETUP * Clarification Changed `#ifndef` to `#ifdef` and moved enable disable outside AUTO_SHIFT_SETUP * AUTO_SHIFT_NO_SETUp --- docs/feature_auto_shift.md | 2 +- quantum/process_keycode/process_auto_shift.c | 70 +++++++++++--------- quantum/quantum_keycodes.h | 4 +- 3 files changed, 41 insertions(+), 35 deletions(-) diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md index f0b507bc618a..b21a7690d9e4 100644 --- a/docs/feature_auto_shift.md +++ b/docs/feature_auto_shift.md @@ -139,7 +139,7 @@ completely normal and with no intention of shifted keys. `KC_ASRP`. The keyboard will type by itself the value of your `AUTO_SHIFT_TIMEOUT`. 7. Update `AUTO_SHIFT_TIMEOUT` in your `config.h` with the value reported. -8. Remove `AUTO_SHIFT_SETUP` from your `config.h`. +8. Add `AUTO_SHIFT_NO_SETUP` to your `config.h`. 9. Remove the key bindings `KC_ASDN`, `KC_ASUP` and `KC_ASRP`. 10. Compile and upload your new firmware. diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index b474bda6912c..330037cefbb0 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -25,19 +25,6 @@ static uint16_t autoshift_time = 0; static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; static uint16_t autoshift_lastkey = KC_NO; -void autoshift_timer_report(void) { - char display[8]; - - snprintf(display, 8, "\n%d\n", autoshift_timeout); - - send_string((const char *)display); -} - -void autoshift_on(uint16_t keycode) { - autoshift_time = timer_read(); - autoshift_lastkey = keycode; -} - void autoshift_flush(void) { if (autoshift_lastkey != KC_NO) { uint16_t elapsed = timer_elapsed(autoshift_time); @@ -53,21 +40,36 @@ void autoshift_flush(void) { } } -void autoshift_enable(void) { autoshift_enabled = true; } -void autoshift_disable(void) { +void autoshift_on(uint16_t keycode) { + autoshift_time = timer_read(); + autoshift_lastkey = keycode; +} + +void autoshift_toggle(void) { + if (autoshift_enabled) { autoshift_enabled = false; autoshift_flush(); + } else { + autoshift_enabled = true; + } } -void autoshift_toggle(void) { - if (autoshift_enabled) { - autoshift_enabled = false; - autoshift_flush(); - } else { - autoshift_enabled = true; - } +void autoshift_enable(void) { autoshift_enabled = true; } +void autoshift_disable(void) { + autoshift_enabled = false; + autoshift_flush(); } +#ifndef AUTO_SHIFT_NO_SETUP +void autoshift_timer_report(void) { + char display[8]; + + snprintf(display, 8, "\n%d\n", autoshift_timeout); + + send_string((const char *)display); +} +#endif + bool get_autoshift_state(void) { return autoshift_enabled; } uint16_t get_autoshift_timeout(void) { return autoshift_timeout; } @@ -77,21 +79,11 @@ void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; } bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { - case KC_ASUP: - autoshift_timeout += 5; - return true; - - case KC_ASDN: - autoshift_timeout -= 5; - return true; - - case KC_ASRP: - autoshift_timer_report(); - return true; case KC_ASTG: autoshift_toggle(); return true; + case KC_ASON: autoshift_enable(); return true; @@ -99,6 +91,18 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { autoshift_disable(); return true; +# ifndef AUTO_SHIFT_NO_SETUP + case KC_ASUP: + autoshift_timeout += 5; + return true; + case KC_ASDN: + autoshift_timeout -= 5; + return true; + + case KC_ASRP: + autoshift_timer_report(); + return true; +# endif # ifndef NO_AUTO_SHIFT_ALPHA case KC_A ... KC_Z: # endif diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 0de297b8753e..b3e139ae1fe7 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -123,10 +123,12 @@ enum quantum_keycodes { KC_LEAD, #endif - // Auto Shift setup +// Auto Shift setup +#ifndef AUTO_SHIFT_NO_SETUP KC_ASUP, KC_ASDN, KC_ASRP, +#endif KC_ASTG, KC_ASON, KC_ASOFF, From 489dcfa91b457367d17f7df41591443f8c7040a1 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sat, 15 Aug 2020 22:22:11 +0100 Subject: [PATCH 33/54] ARM backlight - timer implementation (#8291) * Add GPT timer based backlight driver * Update to tim15 to avoid conflict with audio * Update quantum/backlight/backlight_timer.c --- common_features.mk | 2 +- .../GENERIC_STM32_F303XC/configs/mcuconf.h | 2 +- quantum/backlight/backlight_timer.c | 167 ++++++++++++++++++ 3 files changed, 169 insertions(+), 2 deletions(-) create mode 100644 quantum/backlight/backlight_timer.c diff --git a/common_features.mk b/common_features.mk index f9fca4669ceb..2806544f8b5b 100644 --- a/common_features.mk +++ b/common_features.mk @@ -264,7 +264,7 @@ ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes) BACKLIGHT_DRIVER := custom endif -VALID_BACKLIGHT_TYPES := pwm software custom +VALID_BACKLIGHT_TYPES := pwm timer software custom BACKLIGHT_ENABLE ?= no BACKLIGHT_DRIVER ?= pwm diff --git a/platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h b/platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h index 3b15883485e5..ac2d9a1eed5d 100644 --- a/platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h +++ b/platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h @@ -144,7 +144,7 @@ #define STM32_GPT_USE_TIM6 TRUE #define STM32_GPT_USE_TIM7 TRUE #define STM32_GPT_USE_TIM8 TRUE -#define STM32_GPT_USE_TIM15 FALSE +#define STM32_GPT_USE_TIM15 TRUE #define STM32_GPT_USE_TIM16 FALSE #define STM32_GPT_USE_TIM17 FALSE #define STM32_GPT_TIM1_IRQ_PRIORITY 7 diff --git a/quantum/backlight/backlight_timer.c b/quantum/backlight/backlight_timer.c new file mode 100644 index 000000000000..c32c35c1543a --- /dev/null +++ b/quantum/backlight/backlight_timer.c @@ -0,0 +1,167 @@ +#include "quantum.h" +#include "backlight.h" +#include "backlight_driver_common.h" +#include "debug.h" + +#ifndef BACKLIGHT_GPT_DRIVER +# define BACKLIGHT_GPT_DRIVER GPTD15 +#endif + +// Platform specific implementations +static void backlight_timer_configure(bool enable); +static void backlight_timer_set_duty(uint16_t duty); +static uint16_t backlight_timer_get_duty(void); + +// See http://jared.geek.nz/2013/feb/linear-led-pwm +static uint16_t cie_lightness(uint16_t v) { + if (v <= 5243) // if below 8% of max + return v / 9; // same as dividing by 900% + else { + uint32_t y = (((uint32_t)v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare + // to get a useful result with integer division, we shift left in the expression above + // and revert what we've done again after squaring. + y = y * y * y >> 8; + if (y > 0xFFFFUL) // prevent overflow + return 0xFFFFU; + else + return (uint16_t)y; + } +} + +void backlight_init_ports(void) { + backlight_pins_init(); + + backlight_set(get_backlight_level()); + +#ifdef BACKLIGHT_BREATHING + if (is_backlight_breathing()) { + breathing_enable(); + } +#endif +} + +void backlight_set(uint8_t level) { + if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS; + + backlight_pins_off(); + + backlight_timer_set_duty(cie_lightness(0xFFFFU / BACKLIGHT_LEVELS * level)); + backlight_timer_configure(level != 0); +} + +static void backlight_timer_top(void) { +#ifdef BACKLIGHT_BREATHING + if (is_breathing()) { + breathing_task(); + } +#endif + + if (backlight_timer_get_duty() > 256) { + backlight_pins_on(); + } +} + +static void backlight_timer_cmp(void) { backlight_pins_off(); } + +void backlight_task(void) {} + +#ifdef BACKLIGHT_BREATHING +# define BREATHING_STEPS 128 + +static bool breathing = false; +static uint16_t breathing_counter = 0; + +/* To generate breathing curve in python: + * from math import sin, pi; [int(sin(x/128.0*pi)**4*255) for x in range(128)] + */ +static const uint8_t breathing_table[BREATHING_STEPS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +// Use this before the cie_lightness function. +static inline uint16_t scale_backlight(uint16_t v) { return v / BACKLIGHT_LEVELS * get_backlight_level(); } + +void breathing_task(void) { + uint8_t breathing_period = get_breathing_period(); + uint16_t interval = (uint16_t)breathing_period * 256 / BREATHING_STEPS; + // resetting after one period to prevent ugly reset at overflow. + breathing_counter = (breathing_counter + 1) % (breathing_period * 256); + uint8_t index = breathing_counter / interval % BREATHING_STEPS; + + // printf("index:%u\n", index); + + backlight_timer_set_duty(cie_lightness(scale_backlight((uint16_t)breathing_table[index] * 256))); +} + +bool is_breathing(void) { return breathing; } + +void breathing_enable(void) { + breathing_counter = 0; + breathing = true; +} +void breathing_disable(void) { breathing = false; } + +void breathing_pulse(void) { + backlight_set(is_backlight_enabled() ? 0 : BACKLIGHT_LEVELS); + wait_ms(10); + backlight_set(is_backlight_enabled() ? get_backlight_level() : 0); +} +#endif + +#ifdef PROTOCOL_CHIBIOS +// On Platforms where timers fire every tick and have no capture/top events +// - fake event in the normal timer callback +uint16_t s_duty = 0; + +static void timerCallback(void) { + /* Software PWM + * timer:1111 1111 1111 1111 + * \______/| \_______/____ count(0-255) + * \ \______________ unused(1) + * \__________________ index of step table(0-127) + */ + + // this works for cca 65536 irqs/sec + static union { + uint16_t raw; + struct { + uint16_t count : 8; + uint8_t dummy : 1; + uint8_t index : 7; + } pwm; + } timer = {.raw = 0}; + + timer.raw++; + + if (timer.pwm.count == 0) { + // LED on + backlight_timer_top(); + } else if (timer.pwm.count == (s_duty / 256)) { + // LED off + backlight_timer_cmp(); + } +} + +static void backlight_timer_set_duty(uint16_t duty) { s_duty = duty; } +static uint16_t backlight_timer_get_duty(void) { return s_duty; } + +// ChibiOS - Map GPT timer onto Software PWM +static void gptTimerCallback(GPTDriver *gptp) { + (void)gptp; + timerCallback(); +} + +static void backlight_timer_configure(bool enable) { + static const GPTConfig gptcfg = {1000000, gptTimerCallback, 0, 0}; + + static bool s_init = false; + if (!s_init) { + gptStart(&BACKLIGHT_GPT_DRIVER, &gptcfg); + s_init = true; + } + + if (enable) { + gptStartContinuous(&BACKLIGHT_GPT_DRIVER, gptcfg.frequency / 0xFFFF); + } else { + gptStopTimer(&BACKLIGHT_GPT_DRIVER); + } +} +#endif From 9dc51c0a680382033c13eedfe19c5c9e319e6b02 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sun, 16 Aug 2020 11:13:45 +0100 Subject: [PATCH 34/54] Remove f072 backlight warning (#10040) * Remove f072 backlight warning * Remove f072 backlight warning from docs --- docs/feature_backlight.md | 2 -- quantum/backlight/backlight.c | 4 ---- 2 files changed, 6 deletions(-) diff --git a/docs/feature_backlight.md b/docs/feature_backlight.md index 9e467c708a28..6bb2bbed844b 100644 --- a/docs/feature_backlight.md +++ b/docs/feature_backlight.md @@ -160,8 +160,6 @@ See the ST datasheet for your particular MCU to determine these values. Unless y Currently only hardware PWM is supported, not timer assisted, and does not provide automatic configuration. -?> Backlight support for STM32F072 has had limited testing, so YMMV. If unsure, set `BACKLIGHT_ENABLE = no` in your `rules.mk`. - ### Software PWM Driver :id=software-pwm-driver In this mode, PWM is "emulated" while running other keyboard tasks. It offers maximum hardware compatibility without extra platform configuration. The tradeoff is the backlight might jitter when the keyboard is busy. To enable, add this to your `rules.mk`: diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c index 34dd8cbdb5a7..113beb832f61 100644 --- a/quantum/backlight/backlight.c +++ b/quantum/backlight/backlight.c @@ -20,10 +20,6 @@ along with this program. If not, see . #include "eeconfig.h" #include "debug.h" -#if defined(STM32F0XX) || defined(STM32F0xx) -# pragma message("Backlight support for STMF072 has had limited testing, YMMV. If unsure, set 'BACKLIGHT_ENABLE = no' in your rules.mk") -#endif - backlight_config_t backlight_config; #ifdef BACKLIGHT_BREATHING From f13d8970b9bc099a1e3b9e73872e3a409186f806 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 18 Aug 2020 13:02:01 +1000 Subject: [PATCH 35/54] Remove unused CORTEX_VTOR_INIT (#10053) --- keyboards/cannonkeys/ortho48/rules.mk | 1 - keyboards/cannonkeys/ortho60/rules.mk | 1 - keyboards/cannonkeys/ortho75/rules.mk | 1 - keyboards/cannonkeys/practice60/rules.mk | 1 - keyboards/cannonkeys/practice65/rules.mk | 1 - keyboards/converter/siemens_tastatur/rules.mk | 1 - keyboards/ergodox_infinity/rules.mk | 5 ----- .../bluepill/ld/STM32F103x8_stm32duino_bootloader.ld | 3 --- keyboards/handwired/onekey/bluepill/rules.mk | 1 - keyboards/handwired/z150/rules.mk | 1 - keyboards/infinity60/rules.mk | 5 ----- keyboards/wolfmarkclub/wm1/ld/wm1_f103.ld | 3 --- keyboards/wolfmarkclub/wm1/rules.mk | 1 - keyboards/zvecr/split_blackpill/rules.mk | 1 - platforms/chibios/ld/STM32F103x8_stm32duino_bootloader.ld | 3 --- 15 files changed, 29 deletions(-) diff --git a/keyboards/cannonkeys/ortho48/rules.mk b/keyboards/cannonkeys/ortho48/rules.mk index f2fc3e128e4d..5e18d91ca488 100644 --- a/keyboards/cannonkeys/ortho48/rules.mk +++ b/keyboards/cannonkeys/ortho48/rules.mk @@ -2,7 +2,6 @@ MCU = STM32F103 # GENERIC STM32F103C8T6 board - stm32duino bootloader -OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader BOARD = STM32_F103_STM32DUINO diff --git a/keyboards/cannonkeys/ortho60/rules.mk b/keyboards/cannonkeys/ortho60/rules.mk index aaa14c2dbeff..80b31a12f4d4 100644 --- a/keyboards/cannonkeys/ortho60/rules.mk +++ b/keyboards/cannonkeys/ortho60/rules.mk @@ -2,7 +2,6 @@ MCU = STM32F103 # GENERIC STM32F103C8T6 board - stm32duino bootloader -OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader BOARD = STM32_F103_STM32DUINO diff --git a/keyboards/cannonkeys/ortho75/rules.mk b/keyboards/cannonkeys/ortho75/rules.mk index fe9cec84c18d..ae196fd85019 100644 --- a/keyboards/cannonkeys/ortho75/rules.mk +++ b/keyboards/cannonkeys/ortho75/rules.mk @@ -2,7 +2,6 @@ MCU = STM32F103 # GENERIC STM32F103C8T6 board - stm32duino bootloader -OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader BOARD = STM32_F103_STM32DUINO diff --git a/keyboards/cannonkeys/practice60/rules.mk b/keyboards/cannonkeys/practice60/rules.mk index 395913736828..3713b6078df7 100644 --- a/keyboards/cannonkeys/practice60/rules.mk +++ b/keyboards/cannonkeys/practice60/rules.mk @@ -2,7 +2,6 @@ MCU = STM32F103 # GENERIC STM32F103C8T6 board - stm32duino bootloader -OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader BOARD = STM32_F103_STM32DUINO diff --git a/keyboards/cannonkeys/practice65/rules.mk b/keyboards/cannonkeys/practice65/rules.mk index d6d2b3fe7ef1..5fd4892dc591 100644 --- a/keyboards/cannonkeys/practice65/rules.mk +++ b/keyboards/cannonkeys/practice65/rules.mk @@ -2,7 +2,6 @@ MCU = STM32F103 # GENERIC STM32F103C8T6 board - stm32duino bootloader -OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader BOARD = STM32_F103_STM32DUINO diff --git a/keyboards/converter/siemens_tastatur/rules.mk b/keyboards/converter/siemens_tastatur/rules.mk index bc5875962bb5..03e6b0f49d4a 100644 --- a/keyboards/converter/siemens_tastatur/rules.mk +++ b/keyboards/converter/siemens_tastatur/rules.mk @@ -2,7 +2,6 @@ MCU = STM32F103 # GENERIC STM32F103C8T6 board - stm32duino bootloader -OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader BOARD = STM32_F103_STM32DUINO diff --git a/keyboards/ergodox_infinity/rules.mk b/keyboards/ergodox_infinity/rules.mk index 31bc20454c30..29e5c6dd7360 100644 --- a/keyboards/ergodox_infinity/rules.mk +++ b/keyboards/ergodox_infinity/rules.mk @@ -13,11 +13,6 @@ MCU = MK20DX256 # - MK20DX256BLDR8 for Infinity ErgoDox with Kiibohd bootloader MCU_LDSCRIPT = MK20DX256BLDR8 -# Vector table for application -# 0x00000000-0x00001000 area is occupied by bootlaoder.*/ -# The CORTEX_VTOR... is needed only for MCHCK/Infinity KB -OPT_DEFS += -DCORTEX_VTOR_INIT=0x00002000 - BOOTLOADER = dfu # Build Options diff --git a/keyboards/handwired/bluepill/ld/STM32F103x8_stm32duino_bootloader.ld b/keyboards/handwired/bluepill/ld/STM32F103x8_stm32duino_bootloader.ld index f9bfe9c00527..23e44bd63af0 100644 --- a/keyboards/handwired/bluepill/ld/STM32F103x8_stm32duino_bootloader.ld +++ b/keyboards/handwired/bluepill/ld/STM32F103x8_stm32duino_bootloader.ld @@ -16,9 +16,6 @@ /* * ST32F103xB memory setup for use with the maplemini bootloader. - * You will have to - * #define CORTEX_VTOR_INIT 0x5000 - * in your projects chconf.h */ MEMORY { diff --git a/keyboards/handwired/onekey/bluepill/rules.mk b/keyboards/handwired/onekey/bluepill/rules.mk index 83a81a56b185..66ce517445db 100644 --- a/keyboards/handwired/onekey/bluepill/rules.mk +++ b/keyboards/handwired/onekey/bluepill/rules.mk @@ -2,7 +2,6 @@ MCU = STM32F103 # GENERIC STM32F103C8T6 board - stm32duino bootloader -OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader BOARD = STM32_F103_STM32DUINO diff --git a/keyboards/handwired/z150/rules.mk b/keyboards/handwired/z150/rules.mk index 08bd7908eb5d..fd1d3820337d 100644 --- a/keyboards/handwired/z150/rules.mk +++ b/keyboards/handwired/z150/rules.mk @@ -1,7 +1,6 @@ MCU = STM32F103 # GENERIC STM32F103C8T6 board - stm32duino bootloader -OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader BOARD = STM32_F103_STM32DUINO STM32_BOOTLOADER_ADDRESS = 0x80000000 diff --git a/keyboards/infinity60/rules.mk b/keyboards/infinity60/rules.mk index 579eab0f3fa2..e6b234d821c6 100644 --- a/keyboards/infinity60/rules.mk +++ b/keyboards/infinity60/rules.mk @@ -21,11 +21,6 @@ MCU_LDSCRIPT = MK20DX128BLDR4 # - MCHCK_K20 for Infinity KB BOARD = MCHCK_K20 -# Vector table for application -# 0x00000000-0x00001000 area is occupied by bootlaoder.*/ -# The CORTEX_VTOR... is needed only for MCHCK/Infinity KB -OPT_DEFS = -DCORTEX_VTOR_INIT=0x00001000 - BOOTLOADER = dfu # Build Options diff --git a/keyboards/wolfmarkclub/wm1/ld/wm1_f103.ld b/keyboards/wolfmarkclub/wm1/ld/wm1_f103.ld index 41362282bc6b..3959f395ac88 100644 --- a/keyboards/wolfmarkclub/wm1/ld/wm1_f103.ld +++ b/keyboards/wolfmarkclub/wm1/ld/wm1_f103.ld @@ -16,9 +16,6 @@ /* * STM32F103xC memory setup for use with the WM1 mass-storage device bootloader. - * You will have to change: - * OPT_DEFS = -DCORTEX_VTOR_INIT=0x10000 - * in your board's rules.mk */ MEMORY { diff --git a/keyboards/wolfmarkclub/wm1/rules.mk b/keyboards/wolfmarkclub/wm1/rules.mk index 14ddab26d9dc..fcd4da1affc9 100644 --- a/keyboards/wolfmarkclub/wm1/rules.mk +++ b/keyboards/wolfmarkclub/wm1/rules.mk @@ -2,7 +2,6 @@ MCU = STM32F103 # GENERIC STM32F103C8T6 board - mass storage bootloader -OPT_DEFS = -DCORTEX_VTOR_INIT=0x10000 MCU_LDSCRIPT = wm1_f103 BOARD = STM32_F103_STM32DUINO diff --git a/keyboards/zvecr/split_blackpill/rules.mk b/keyboards/zvecr/split_blackpill/rules.mk index 95d901ee06a8..151ed15d8498 100644 --- a/keyboards/zvecr/split_blackpill/rules.mk +++ b/keyboards/zvecr/split_blackpill/rules.mk @@ -2,7 +2,6 @@ MCU = STM32F103 # GENERIC STM32F103C8T6 board - stm32duino bootloader -OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader BOARD = STM32_F103_STM32DUINO STM32_BOOTLOADER_ADDRESS = 0x80000000 diff --git a/platforms/chibios/ld/STM32F103x8_stm32duino_bootloader.ld b/platforms/chibios/ld/STM32F103x8_stm32duino_bootloader.ld index d0688ef60164..bb852422a34a 100644 --- a/platforms/chibios/ld/STM32F103x8_stm32duino_bootloader.ld +++ b/platforms/chibios/ld/STM32F103x8_stm32duino_bootloader.ld @@ -16,9 +16,6 @@ /* * ST32F103xB memory setup for use with the maplemini bootloader. - * You will have to - * #define CORTEX_VTOR_INIT 0x5000 - * in your projects chconf.h */ MEMORY { From a1c9df057288aaf82064c2a5f0a2bc26ae84d488 Mon Sep 17 00:00:00 2001 From: Dean Scarff Date: Sun, 26 Jul 2020 01:23:38 +1000 Subject: [PATCH 36/54] Auto shift: support repeats and early registration (#7048) Instead of waiting for the next record to tap the autoshiftable key, expose a matrix_scan function that will check the timeout and register the key immediately if the timeout period has elapsed. This means the user gets immediate feedback about their press and doesn't have to guess whether it's been long enough. Additionally, don't unregister the keypress immediately. This means that auto-shifted keys can be held down. Fixes qmk/qmk_firmware#7048 --- quantum/process_keycode/process_auto_shift.c | 214 +++++++++++++------ quantum/process_keycode/process_auto_shift.h | 1 + 2 files changed, 152 insertions(+), 63 deletions(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 330037cefbb0..2697b6b76f49 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -16,61 +16,166 @@ #ifdef AUTO_SHIFT_ENABLE +# include # include # include "process_auto_shift.h" -static bool autoshift_enabled = true; static uint16_t autoshift_time = 0; static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; static uint16_t autoshift_lastkey = KC_NO; +static struct { + // Whether autoshift is enabled. + bool enabled : 1; + // Whether the auto-shifted keypress has been registered. + bool registered : 1; + // Whether autoshift is currently "holding" the shift key. + bool holding_shift : 1; +} autoshift_flags = {true, false, false}; -void autoshift_flush(void) { - if (autoshift_lastkey != KC_NO) { - uint16_t elapsed = timer_elapsed(autoshift_time); +# ifndef AUTO_SHIFT_NO_SETUP +void autoshift_timer_report(void) { + char display[8]; + + snprintf(display, 8, "\n%d\n", autoshift_timeout); + + send_string((const char *)display); +} +# endif + +/** \brief Resets the autoshift state and releases the shift key */ +static void autoshift_flush(void) { + if (autoshift_flags.holding_shift) { + // Release the shift key if it was simulated. + unregister_code(KC_LSFT); + } + autoshift_lastkey = KC_NO; + autoshift_flags.holding_shift = false; + autoshift_flags.registered = false; +} + +/** \brief Record the press of an autoshiftable key + * + * \return Whether the record should be further processed. + */ +static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { + if (!autoshift_flags.enabled) { + return true; + } + + autoshift_flush(); + +# ifndef AUTO_SHIFT_MODIFIERS + if (get_mods()) { + return true; + } +# endif + + // Record the keycode so we can simulate it later. + autoshift_time = record->event.time; + autoshift_lastkey = keycode; + +# if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) + clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); +# endif + return false; +} - if (elapsed > autoshift_timeout) { - tap_code16(LSFT(autoshift_lastkey)); - } else { - tap_code(autoshift_lastkey); +/** \brief Registers an autoshiftable key under the right conditions + * + * If the autoshift delay has elapsed and no shift has already been registered, + * register a shift and the key. + */ +void autoshift_check_timeout(uint16_t now) { + const uint16_t elapsed = TIMER_DIFF_16(now, autoshift_time); + if (elapsed >= autoshift_timeout) { + // The timeout has expired, so simulate the keypress. + if (!(get_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)))) { + // Simulate pressing the shift key. + register_code(KC_LSFT); + autoshift_flags.holding_shift = true; } + register_code(autoshift_lastkey); + autoshift_flags.registered = true; - autoshift_time = 0; - autoshift_lastkey = KC_NO; +# if TAP_CODE_DELAY > 0 + wait_ms(TAP_CODE_DELAY); +# endif } } -void autoshift_on(uint16_t keycode) { - autoshift_time = timer_read(); - autoshift_lastkey = keycode; +/** \brief Registers an autoshiftable key under the right conditions + * + * If the autoshift delay has elapsed and no shift has already been registered, + * register a shift and the key. + * + * If the autoshift key is released before the delay has elapsed, register the + * key without a shift. + */ +static void autoshift_check_record(uint16_t keycode, keyrecord_t *record) { + if (autoshift_lastkey == KC_NO) { + return; + } + + // Process the release of the autoshiftable key. + if (keycode == autoshift_lastkey && !record->event.pressed) { + // Time since the initial press was recorded. + const uint16_t elapsed = TIMER_DIFF_16(record->event.time, autoshift_time); + if (elapsed < autoshift_timeout) { + // Auto-shiftable key is being released before the shift timeout; + // simulate the original press then let the usual processing take + // care of the release. + register_code(keycode); +# if TAP_CODE_DELAY > 0 + wait_ms(TAP_CODE_DELAY); +# endif + } + autoshift_flush(); + } else if (keycode == KC_LSFT && record->event.pressed) { + // If the user presses shift, auto-shift will not hold shift for + // them. + autoshift_flags.holding_shift = false; + } else { + // Use an unrelated event as an opportunity to check if the autoshift + // timeout has expired. + autoshift_check_timeout(record->event.time); + } } -void autoshift_toggle(void) { - if (autoshift_enabled) { - autoshift_enabled = false; +/** \brief Simulates auto-shifted key presses + * + * Can be called from \c matrix_scan_user so that auto-shifted keys are sent + * immediately after the timeout has expired, rather than waiting for the key + * to be released. + */ +void autoshift_matrix_scan(void) { + if (autoshift_lastkey == KC_NO || autoshift_flags.registered) { + return; + } + + autoshift_check_timeout(timer_read()); +} + +void autoshift_enable(void) { + autoshift_flags.enabled = true; autoshift_flush(); - } else { - autoshift_enabled = true; - } } -void autoshift_enable(void) { autoshift_enabled = true; } void autoshift_disable(void) { - autoshift_enabled = false; - autoshift_flush(); + autoshift_flags.enabled = false; + autoshift_flush(); } -#ifndef AUTO_SHIFT_NO_SETUP -void autoshift_timer_report(void) { - char display[8]; - - snprintf(display, 8, "\n%d\n", autoshift_timeout); - - send_string((const char *)display); +void autoshift_toggle(void) { + if (autoshift_flags.enabled) { + autoshift_flags.enabled = false; + autoshift_flush(); + } else { + autoshift_flags.enabled = true; + } } -#endif -bool get_autoshift_state(void) { return autoshift_enabled; } +bool get_autoshift_state(void) { return autoshift_flags.enabled; } uint16_t get_autoshift_timeout(void) { return autoshift_timeout; } @@ -79,11 +184,22 @@ void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; } bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { +# ifndef AUTO_SHIFT_NO_SETUP + case KC_ASUP: + autoshift_timeout += 5; + return true; + + case KC_ASDN: + autoshift_timeout -= 5; + return true; + case KC_ASRP: + autoshift_timer_report(); + return true; +# endif case KC_ASTG: autoshift_toggle(); return true; - case KC_ASON: autoshift_enable(); return true; @@ -91,18 +207,6 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { autoshift_disable(); return true; -# ifndef AUTO_SHIFT_NO_SETUP - case KC_ASUP: - autoshift_timeout += 5; - return true; - case KC_ASDN: - autoshift_timeout -= 5; - return true; - - case KC_ASRP: - autoshift_timer_report(); - return true; -# endif # ifndef NO_AUTO_SHIFT_ALPHA case KC_A ... KC_Z: # endif @@ -114,30 +218,14 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { case KC_MINUS ... KC_SLASH: case KC_NONUS_BSLASH: # endif - autoshift_flush(); - if (!autoshift_enabled) return true; - -# ifndef AUTO_SHIFT_MODIFIERS - if (get_mods()) { - return true; - } -# endif - autoshift_on(keycode); - - // We need some extra handling here for OSL edge cases -# if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) - clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); -# endif - return false; + return autoshift_press(keycode, record); default: - autoshift_flush(); - return true; + break; } - } else { - autoshift_flush(); } + autoshift_check_record(keycode, record); return true; } diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h index e86c4658e98d..5b2718f11ca6 100644 --- a/quantum/process_keycode/process_auto_shift.h +++ b/quantum/process_keycode/process_auto_shift.h @@ -30,3 +30,4 @@ void autoshift_toggle(void); bool get_autoshift_state(void); uint16_t get_autoshift_timeout(void); void set_autoshift_timeout(uint16_t timeout); +void autoshift_matrix_scan(void); From ff95c13160d61d21d46b0c313aabd2985c932e1b Mon Sep 17 00:00:00 2001 From: Dean Scarff Date: Sun, 26 Jul 2020 03:25:20 +1000 Subject: [PATCH 37/54] Add auto shift matrix scan to quantum --- quantum/quantum.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/quantum/quantum.c b/quantum/quantum.c index dab6c9172fc0..be418c082fdb 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -59,6 +59,10 @@ float bell_song[][2] = SONG(TERMINAL_SOUND); # endif #endif +#ifdef AUTO_SHIFT_ENABLE +# include "process_auto_shift.h" +#endif + static void do_code16(uint16_t code, void (*f)(uint8_t)) { switch (code) { case QK_MODS ... QK_MODS_MAX: @@ -661,6 +665,10 @@ void matrix_scan_quantum() { dip_switch_read(false); #endif +#ifdef AUTO_SHIFT_ENABLE + autoshift_matrix_scan(); +#endif + matrix_scan_kb(); } From 809465ad1c6aea7e407a7b082a37644c58bfd690 Mon Sep 17 00:00:00 2001 From: Dean Scarff Date: Sun, 26 Jul 2020 02:10:45 +1000 Subject: [PATCH 38/54] Support tap-then-hold for auto shift Make auto-shift keys like dual-function keys insofar as they can be repeated by tapping then immediately (within TAPPING_TERM) holding again. --- quantum/process_keycode/process_auto_shift.c | 44 ++++++++++++++------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 2697b6b76f49..621dc0357e52 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -27,11 +27,16 @@ static uint16_t autoshift_lastkey = KC_NO; static struct { // Whether autoshift is enabled. bool enabled : 1; + // Whether the last autoshifted key was released after the timeout. This + // is used to replicate the last key for a tap-then-hold. + bool lastshifted : 1; + // Whether an auto-shiftable key is currently being pressed. + bool in_progress : 1; // Whether the auto-shifted keypress has been registered. bool registered : 1; // Whether autoshift is currently "holding" the shift key. bool holding_shift : 1; -} autoshift_flags = {true, false, false}; +} autoshift_flags = {true, false, false, false, false}; # ifndef AUTO_SHIFT_NO_SETUP void autoshift_timer_report(void) { @@ -44,12 +49,14 @@ void autoshift_timer_report(void) { # endif /** \brief Resets the autoshift state and releases the shift key */ -static void autoshift_flush(void) { +static void autoshift_flush(uint16_t now) { if (autoshift_flags.holding_shift) { // Release the shift key if it was simulated. unregister_code(KC_LSFT); } - autoshift_lastkey = KC_NO; + // Roll the autoshift_time forward for detecting tap-and-hold. + autoshift_time = now; + autoshift_flags.in_progress = false; autoshift_flags.holding_shift = false; autoshift_flags.registered = false; } @@ -63,7 +70,7 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { return true; } - autoshift_flush(); + autoshift_flush(record->event.time); # ifndef AUTO_SHIFT_MODIFIERS if (get_mods()) { @@ -71,9 +78,20 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { } # endif + const uint16_t elapsed = TIMER_DIFF_16(record->event.time, autoshift_time); + +# ifndef TAPPING_FORCE_HOLD + if (elapsed < TAPPING_TERM && keycode == autoshift_lastkey && !autoshift_flags.lastshifted) { + // Allow a tap-then-hold to hold the unshifted key. + autoshift_lastkey = KC_NO; + return true; + } +# endif + // Record the keycode so we can simulate it later. - autoshift_time = record->event.time; - autoshift_lastkey = keycode; + autoshift_time = record->event.time; + autoshift_lastkey = keycode; + autoshift_flags.in_progress = true; # if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); @@ -93,6 +111,7 @@ void autoshift_check_timeout(uint16_t now) { if (!(get_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)))) { // Simulate pressing the shift key. register_code(KC_LSFT); + autoshift_flags.lastshifted = true; autoshift_flags.holding_shift = true; } register_code(autoshift_lastkey); @@ -113,7 +132,7 @@ void autoshift_check_timeout(uint16_t now) { * key without a shift. */ static void autoshift_check_record(uint16_t keycode, keyrecord_t *record) { - if (autoshift_lastkey == KC_NO) { + if (!autoshift_flags.in_progress) { return; } @@ -122,6 +141,7 @@ static void autoshift_check_record(uint16_t keycode, keyrecord_t *record) { // Time since the initial press was recorded. const uint16_t elapsed = TIMER_DIFF_16(record->event.time, autoshift_time); if (elapsed < autoshift_timeout) { + autoshift_flags.lastshifted = false; // Auto-shiftable key is being released before the shift timeout; // simulate the original press then let the usual processing take // care of the release. @@ -130,7 +150,7 @@ static void autoshift_check_record(uint16_t keycode, keyrecord_t *record) { wait_ms(TAP_CODE_DELAY); # endif } - autoshift_flush(); + autoshift_flush(record->event.time); } else if (keycode == KC_LSFT && record->event.pressed) { // If the user presses shift, auto-shift will not hold shift for // them. @@ -149,7 +169,7 @@ static void autoshift_check_record(uint16_t keycode, keyrecord_t *record) { * to be released. */ void autoshift_matrix_scan(void) { - if (autoshift_lastkey == KC_NO || autoshift_flags.registered) { + if (!autoshift_flags.in_progress || autoshift_flags.registered) { return; } @@ -158,18 +178,18 @@ void autoshift_matrix_scan(void) { void autoshift_enable(void) { autoshift_flags.enabled = true; - autoshift_flush(); + autoshift_flush(0); } void autoshift_disable(void) { autoshift_flags.enabled = false; - autoshift_flush(); + autoshift_flush(0); } void autoshift_toggle(void) { if (autoshift_flags.enabled) { autoshift_flags.enabled = false; - autoshift_flush(); + autoshift_flush(0); } else { autoshift_flags.enabled = true; } From a80ff49f1e07b3d784312ef2e057e09a13326b7a Mon Sep 17 00:00:00 2001 From: Dean Scarff Date: Sun, 26 Jul 2020 03:35:13 +1000 Subject: [PATCH 39/54] Flush auto-shifted key When processing a different keypress record, register the outstanding key from the auto-shift. --- quantum/process_keycode/process_auto_shift.c | 32 ++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 621dc0357e52..4fa710e5ae8c 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -50,7 +50,13 @@ void autoshift_timer_report(void) { /** \brief Resets the autoshift state and releases the shift key */ static void autoshift_flush(uint16_t now) { - if (autoshift_flags.holding_shift) { + if (autoshift_flags.in_progress && !autoshift_flags.registered) { + // Register the key. + register_code(autoshift_lastkey); +# if TAP_CODE_DELAY > 0 + wait_ms(TAP_CODE_DELAY); +# endif + } else if (autoshift_flags.holding_shift) { // Release the shift key if it was simulated. unregister_code(KC_LSFT); } @@ -103,6 +109,8 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { * * If the autoshift delay has elapsed and no shift has already been registered, * register a shift and the key. + * + * \return True if the timeout had elapsed. */ void autoshift_check_timeout(uint16_t now) { const uint16_t elapsed = TIMER_DIFF_16(now, autoshift_time); @@ -130,6 +138,8 @@ void autoshift_check_timeout(uint16_t now) { * * If the autoshift key is released before the delay has elapsed, register the * key without a shift. + * + * If another key is pressed, register the key. */ static void autoshift_check_record(uint16_t keycode, keyrecord_t *record) { if (!autoshift_flags.in_progress) { @@ -146,19 +156,23 @@ static void autoshift_check_record(uint16_t keycode, keyrecord_t *record) { // simulate the original press then let the usual processing take // care of the release. register_code(keycode); + autoshift_flags.registered = true; # if TAP_CODE_DELAY > 0 wait_ms(TAP_CODE_DELAY); # endif } autoshift_flush(record->event.time); - } else if (keycode == KC_LSFT && record->event.pressed) { - // If the user presses shift, auto-shift will not hold shift for - // them. - autoshift_flags.holding_shift = false; - } else { - // Use an unrelated event as an opportunity to check if the autoshift - // timeout has expired. - autoshift_check_timeout(record->event.time); + } else if (record->event.pressed) { + if (keycode == KC_LSFT) { + // If the user presses shift, auto-shift will not hold shift for + // them. + autoshift_flags.holding_shift = false; + } else if (!autoshift_flags.registered) { + // If the key isn't registered yet, it means the timeout hasn't + // elapsed, so register the unshifted key. + autoshift_flush(0); + autoshift_lastkey = KC_NO; + } } } From eb13f2039dbb9d3371716e7145bb5fee8349bc33 Mon Sep 17 00:00:00 2001 From: Dean Scarff Date: Sun, 26 Jul 2020 05:23:50 +1000 Subject: [PATCH 40/54] Don't register extra keys on release --- quantum/process_keycode/process_auto_shift.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 4fa710e5ae8c..75f794afd522 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -150,7 +150,7 @@ static void autoshift_check_record(uint16_t keycode, keyrecord_t *record) { if (keycode == autoshift_lastkey && !record->event.pressed) { // Time since the initial press was recorded. const uint16_t elapsed = TIMER_DIFF_16(record->event.time, autoshift_time); - if (elapsed < autoshift_timeout) { + if (!autoshift_flags.registered && elapsed < autoshift_timeout) { autoshift_flags.lastshifted = false; // Auto-shiftable key is being released before the shift timeout; // simulate the original press then let the usual processing take From b02fcd5b29e7ac0b1459ea01fe367a09570c77fd Mon Sep 17 00:00:00 2001 From: Dean Scarff Date: Sun, 26 Jul 2020 06:32:12 +1000 Subject: [PATCH 41/54] Fix flaky unshifting --- quantum/process_keycode/process_auto_shift.c | 36 +++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 75f794afd522..d9f333e6aec9 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -48,7 +48,7 @@ void autoshift_timer_report(void) { } # endif -/** \brief Resets the autoshift state and releases the shift key */ +/** \brief Resets the autoshift state */ static void autoshift_flush(uint16_t now) { if (autoshift_flags.in_progress && !autoshift_flags.registered) { // Register the key. @@ -56,17 +56,22 @@ static void autoshift_flush(uint16_t now) { # if TAP_CODE_DELAY > 0 wait_ms(TAP_CODE_DELAY); # endif - } else if (autoshift_flags.holding_shift) { - // Release the shift key if it was simulated. - unregister_code(KC_LSFT); } // Roll the autoshift_time forward for detecting tap-and-hold. autoshift_time = now; autoshift_flags.in_progress = false; - autoshift_flags.holding_shift = false; autoshift_flags.registered = false; } +/** \brief Releases the shift key if it was held by auto-shift */ +static void autoshift_flush_shift(void) { + if (autoshift_flags.holding_shift) { + // Release the shift key if it was simulated. + unregister_code(KC_LSFT); + } + autoshift_flags.holding_shift = false; +} + /** \brief Record the press of an autoshiftable key * * \return Whether the record should be further processed. @@ -76,16 +81,14 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { return true; } + const uint16_t elapsed = TIMER_DIFF_16(record->event.time, autoshift_time); autoshift_flush(record->event.time); # ifndef AUTO_SHIFT_MODIFIERS - if (get_mods()) { + if (get_mods() ^ (autoshift_flags.holding_shift ? MOD_BIT(KC_LSFT) : 0)) { return true; } # endif - - const uint16_t elapsed = TIMER_DIFF_16(record->event.time, autoshift_time); - # ifndef TAPPING_FORCE_HOLD if (elapsed < TAPPING_TERM && keycode == autoshift_lastkey && !autoshift_flags.lastshifted) { // Allow a tap-then-hold to hold the unshifted key. @@ -95,7 +98,6 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { # endif // Record the keycode so we can simulate it later. - autoshift_time = record->event.time; autoshift_lastkey = keycode; autoshift_flags.in_progress = true; @@ -148,15 +150,16 @@ static void autoshift_check_record(uint16_t keycode, keyrecord_t *record) { // Process the release of the autoshiftable key. if (keycode == autoshift_lastkey && !record->event.pressed) { + autoshift_flush_shift(); // Time since the initial press was recorded. const uint16_t elapsed = TIMER_DIFF_16(record->event.time, autoshift_time); if (!autoshift_flags.registered && elapsed < autoshift_timeout) { - autoshift_flags.lastshifted = false; // Auto-shiftable key is being released before the shift timeout; // simulate the original press then let the usual processing take // care of the release. register_code(keycode); - autoshift_flags.registered = true; + autoshift_flags.lastshifted = false; + autoshift_flags.registered = true; # if TAP_CODE_DELAY > 0 wait_ms(TAP_CODE_DELAY); # endif @@ -169,9 +172,13 @@ static void autoshift_check_record(uint16_t keycode, keyrecord_t *record) { autoshift_flags.holding_shift = false; } else if (!autoshift_flags.registered) { // If the key isn't registered yet, it means the timeout hasn't - // elapsed, so register the unshifted key. + // elapsed, so register the key without additional shifting. autoshift_flush(0); autoshift_lastkey = KC_NO; + } else { + // The key is registered; flush any shift state for the + // non-autoshiftable key. + autoshift_flush_shift(); } } } @@ -192,17 +199,20 @@ void autoshift_matrix_scan(void) { void autoshift_enable(void) { autoshift_flags.enabled = true; + autoshift_flush_shift(); autoshift_flush(0); } void autoshift_disable(void) { autoshift_flags.enabled = false; + autoshift_flush_shift(); autoshift_flush(0); } void autoshift_toggle(void) { if (autoshift_flags.enabled) { autoshift_flags.enabled = false; + autoshift_flush_shift(); autoshift_flush(0); } else { autoshift_flags.enabled = true; From 5ef01bd37b1db1a202a84a90ce57efa90c0b6f9f Mon Sep 17 00:00:00 2001 From: Dean Scarff Date: Sun, 26 Jul 2020 04:43:44 +1000 Subject: [PATCH 42/54] Update docs for auto shift Update the auto shift docs to reflect that repeats now work. --- docs/feature_auto_shift.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md index b21a7690d9e4..cee78f0f6fba 100644 --- a/docs/feature_auto_shift.md +++ b/docs/feature_auto_shift.md @@ -15,25 +15,25 @@ problem. When you tap a key, it stays depressed for a short period of time before it is then released. This depressed time is a different length for everyone. Auto Shift defines a constant `AUTO_SHIFT_TIMEOUT` which is typically set to twice your -normal pressed state time. When you press a key, a timer starts and then stops -when you release the key. If the time depressed is greater than or equal to the -`AUTO_SHIFT_TIMEOUT`, then a shifted version of the key is emitted. If the time -is less than the `AUTO_SHIFT_TIMEOUT` time, then the normal state is emitted. +normal pressed state time. When you press a key, a timer starts, and if you +have not released the key after the `AUTO_SHIFT_TIMEOUT` period, then a shifted +version of the key is emitted. If the time is less than the `AUTO_SHIFT_TIMEOUT` +time, or you press another key, then the normal state is emitted. + +If you hold the key down, it will repeat the shifted key. If you want to repeat +the normal key, then tap it once then immediately (within `TAPPING_TERM`) hold +it down again. The ability to repeat the normal key like this will be disabled +if `TAPPING_FORCE_HOLD` is set. ## Are There Limitations to Auto Shift? Yes, unfortunately. -1. Key repeat will cease to work. For example, before if you wanted 20 'a' - characters, you could press and hold the 'a' key for a second or two. This no - longer works with Auto Shift because it is timing your depressed time instead - of emitting a depressed key state to your operating system. -2. You will have characters that are shifted when you did not intend on shifting, and - other characters you wanted shifted, but were not. This simply comes down to - practice. As we get in a hurry, we think we have hit the key long enough - for a shifted version, but we did not. On the other hand, we may think we are - tapping the keys, but really we have held it for a little longer than - anticipated. +You will have characters that are shifted when you did not intend on shifting, and +other characters you wanted shifted, but were not. This simply comes down to +practice. As we get in a hurry, we think we have hit the key long enough for a +shifted version, but we did not. On the other hand, we may think we are tapping +the keys, but really we have held it for a little longer than anticipated. ## How Do I Enable Auto Shift? From a0b88546119a4da13c5659da49cfbfac2b73bc63 Mon Sep 17 00:00:00 2001 From: IsaacElenbaas Date: Mon, 27 Jul 2020 20:47:23 -0400 Subject: [PATCH 43/54] Cleanup and refactoring, mostly prepared for custom values --- quantum/process_keycode/process_auto_shift.c | 205 ++++++++----------- 1 file changed, 88 insertions(+), 117 deletions(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index d9f333e6aec9..09c629a17597 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -27,16 +27,14 @@ static uint16_t autoshift_lastkey = KC_NO; static struct { // Whether autoshift is enabled. bool enabled : 1; - // Whether the last autoshifted key was released after the timeout. This + // Whether the last auto-shifted key was released after the timeout. This // is used to replicate the last key for a tap-then-hold. bool lastshifted : 1; - // Whether an auto-shiftable key is currently being pressed. + // Whether an auto-shiftable key has been pressed but not processed. bool in_progress : 1; // Whether the auto-shifted keypress has been registered. - bool registered : 1; - // Whether autoshift is currently "holding" the shift key. bool holding_shift : 1; -} autoshift_flags = {true, false, false, false, false}; +} autoshift_flags = {true, false, false, false}; # ifndef AUTO_SHIFT_NO_SETUP void autoshift_timer_report(void) { @@ -48,27 +46,9 @@ void autoshift_timer_report(void) { } # endif -/** \brief Resets the autoshift state */ -static void autoshift_flush(uint16_t now) { - if (autoshift_flags.in_progress && !autoshift_flags.registered) { - // Register the key. - register_code(autoshift_lastkey); -# if TAP_CODE_DELAY > 0 - wait_ms(TAP_CODE_DELAY); -# endif - } - // Roll the autoshift_time forward for detecting tap-and-hold. - autoshift_time = now; - autoshift_flags.in_progress = false; - autoshift_flags.registered = false; -} - -/** \brief Releases the shift key if it was held by auto-shift */ +/** \brief Releases the shift key if it was held by autoshift */ static void autoshift_flush_shift(void) { - if (autoshift_flags.holding_shift) { - // Release the shift key if it was simulated. - unregister_code(KC_LSFT); - } + del_weak_mods(MOD_BIT(KC_LSFT)); autoshift_flags.holding_shift = false; } @@ -81,24 +61,37 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { return true; } - const uint16_t elapsed = TIMER_DIFF_16(record->event.time, autoshift_time); - autoshift_flush(record->event.time); # ifndef AUTO_SHIFT_MODIFIERS - if (get_mods() ^ (autoshift_flags.holding_shift ? MOD_BIT(KC_LSFT) : 0)) { + if (get_mods() & (~MOD_BIT(KC_LSFT))) { return true; } # endif -# ifndef TAPPING_FORCE_HOLD - if (elapsed < TAPPING_TERM && keycode == autoshift_lastkey && !autoshift_flags.lastshifted) { - // Allow a tap-then-hold to hold the unshifted key. - autoshift_lastkey = KC_NO; - return true; +# ifndef AUTO_SHIFT_NO_REPEAT + const uint16_t elapsed = TIMER_DIFF_16(record->event.time, autoshift_time); +# ifndef AUTO_SHIFT_NO_AUTO_REPEAT + if (!autoshift_flags.lastshifted) { +# endif + if (elapsed < TAPPING_TERM && keycode == autoshift_lastkey) { + // Allow a tap-then-hold for keyrepeat. + if (!autoshift_flags.lastshifted) { + // Change this and below to 16 if custom keys are added. + register_code(autoshift_lastkey); + } else { + // Simulate pressing the shift key. + add_weak_mods(MOD_BIT(KC_LSFT)); + register_code(autoshift_lastkey); + } + return false; + } +# ifndef AUTO_SHIFT_NO_AUTO_REPEAT } +# endif # endif // Record the keycode so we can simulate it later. autoshift_lastkey = keycode; + autoshift_time = record->event.time; autoshift_flags.in_progress = true; # if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) @@ -109,113 +102,83 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { /** \brief Registers an autoshiftable key under the right conditions * - * If the autoshift delay has elapsed and no shift has already been registered, - * register a shift and the key. - * - * \return True if the timeout had elapsed. - */ -void autoshift_check_timeout(uint16_t now) { - const uint16_t elapsed = TIMER_DIFF_16(now, autoshift_time); - if (elapsed >= autoshift_timeout) { - // The timeout has expired, so simulate the keypress. - if (!(get_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)))) { - // Simulate pressing the shift key. - register_code(KC_LSFT); - autoshift_flags.lastshifted = true; - autoshift_flags.holding_shift = true; - } - register_code(autoshift_lastkey); - autoshift_flags.registered = true; - -# if TAP_CODE_DELAY > 0 - wait_ms(TAP_CODE_DELAY); -# endif - } -} - -/** \brief Registers an autoshiftable key under the right conditions - * - * If the autoshift delay has elapsed and no shift has already been registered, - * register a shift and the key. + * If the autoshift delay has elapsed, register a shift and the key. * * If the autoshift key is released before the delay has elapsed, register the * key without a shift. - * - * If another key is pressed, register the key. */ -static void autoshift_check_record(uint16_t keycode, keyrecord_t *record) { - if (!autoshift_flags.in_progress) { - return; - } +static void autoshift_end(uint16_t keycode, uint16_t now, bool matrixTrigger) { + // Called on key down with KC_NO, auto-shifted key up, and timeout. + if (autoshift_flags.in_progress) { + // Process the auto-shiftable key. + autoshift_flags.in_progress = false; - // Process the release of the autoshiftable key. - if (keycode == autoshift_lastkey && !record->event.pressed) { - autoshift_flush_shift(); // Time since the initial press was recorded. - const uint16_t elapsed = TIMER_DIFF_16(record->event.time, autoshift_time); - if (!autoshift_flags.registered && elapsed < autoshift_timeout) { - // Auto-shiftable key is being released before the shift timeout; - // simulate the original press then let the usual processing take - // care of the release. - register_code(keycode); + const uint16_t elapsed = TIMER_DIFF_16(now, autoshift_time); + if (elapsed < autoshift_timeout) { + // Change this and below to 16 if custom keys are added. + register_code(autoshift_lastkey); autoshift_flags.lastshifted = false; - autoshift_flags.registered = true; -# if TAP_CODE_DELAY > 0 - wait_ms(TAP_CODE_DELAY); + } else { + // Simulate pressing the shift key. + add_weak_mods(MOD_BIT(KC_LSFT)); + register_code(autoshift_lastkey); + autoshift_flags.lastshifted = true; +# if !defined(AUTO_SHIFT_NO_REPEAT) && !defined(AUTO_SHIFT_NO_AUTO_REPEAT) + if (matrixTrigger) { + // Prevents release. + return; + } # endif } - autoshift_flush(record->event.time); - } else if (record->event.pressed) { - if (keycode == KC_LSFT) { - // If the user presses shift, auto-shift will not hold shift for - // them. - autoshift_flags.holding_shift = false; - } else if (!autoshift_flags.registered) { - // If the key isn't registered yet, it means the timeout hasn't - // elapsed, so register the key without additional shifting. - autoshift_flush(0); - autoshift_lastkey = KC_NO; - } else { - // The key is registered; flush any shift state for the - // non-autoshiftable key. + +# if TAP_CODE_DELAY > 0 + wait_ms(TAP_CODE_DELAY); +# endif + unregister_code(autoshift_lastkey); + autoshift_flush_shift(); + } + else { + // Release after keyrepeat. + unregister_code(keycode); + if (keycode == autoshift_lastkey) { + // This will only fire when the key was the last auto-shiftable + // pressed. That prevents aaaaBBBB then releasing a from unshifting + // later Bs (if B wasn't auto-shiftable). autoshift_flush_shift(); } } + // Roll the autoshift_time forward for detecting tap-and-hold. + autoshift_time = now; } -/** \brief Simulates auto-shifted key presses +/** \brief Simulates auto-shifted key releases when timeout is hit * * Can be called from \c matrix_scan_user so that auto-shifted keys are sent * immediately after the timeout has expired, rather than waiting for the key * to be released. */ void autoshift_matrix_scan(void) { - if (!autoshift_flags.in_progress || autoshift_flags.registered) { - return; + const uint16_t now = timer_read(); + const uint16_t elapsed = TIMER_DIFF_16(now, autoshift_time); + if (autoshift_flags.in_progress && elapsed >= autoshift_timeout) { + autoshift_end(autoshift_lastkey, now, true); } - - autoshift_check_timeout(timer_read()); } void autoshift_enable(void) { autoshift_flags.enabled = true; - autoshift_flush_shift(); - autoshift_flush(0); } void autoshift_disable(void) { autoshift_flags.enabled = false; autoshift_flush_shift(); - autoshift_flush(0); } void autoshift_toggle(void) { - if (autoshift_flags.enabled) { - autoshift_flags.enabled = false; + autoshift_flags.enabled = !autoshift_flags.enabled; + if (!autoshift_flags.enabled) { autoshift_flush_shift(); - autoshift_flush(0); - } else { - autoshift_flags.enabled = true; } } @@ -227,6 +190,12 @@ void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; } bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { + if (autoshift_flags.in_progress) { + autoshift_end(KC_NO, record->event.time, false); + } + // For pressing another key while keyrepeating shifted autoshift + autoshift_flush_shift(); + switch (keycode) { # ifndef AUTO_SHIFT_NO_SETUP case KC_ASUP: @@ -250,26 +219,28 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { case KC_ASOFF: autoshift_disable(); return true; + } + } + switch (keycode) { # ifndef NO_AUTO_SHIFT_ALPHA - case KC_A ... KC_Z: + case KC_A ... KC_Z: # endif # ifndef NO_AUTO_SHIFT_NUMERIC - case KC_1 ... KC_0: + case KC_1 ... KC_0: # endif # ifndef NO_AUTO_SHIFT_SPECIAL - case KC_TAB: - case KC_MINUS ... KC_SLASH: - case KC_NONUS_BSLASH: + case KC_TAB: + case KC_MINUS ... KC_SLASH: + case KC_NONUS_BSLASH: # endif + if (record->event.pressed) { return autoshift_press(keycode, record); - - default: - break; - } + } else { + autoshift_end(keycode, record->event.time, false); + return false; + } } - - autoshift_check_record(keycode, record); return true; } From 92bafff79fa6b909c980eda359467dc03daf04c0 Mon Sep 17 00:00:00 2001 From: IsaacElenbaas Date: Tue, 28 Jul 2020 07:52:05 -0400 Subject: [PATCH 44/54] snake_case --- quantum/process_keycode/process_auto_shift.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 09c629a17597..f789bbbbcded 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -107,7 +107,7 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { * If the autoshift key is released before the delay has elapsed, register the * key without a shift. */ -static void autoshift_end(uint16_t keycode, uint16_t now, bool matrixTrigger) { +static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { // Called on key down with KC_NO, auto-shifted key up, and timeout. if (autoshift_flags.in_progress) { // Process the auto-shiftable key. @@ -125,7 +125,7 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrixTrigger) { register_code(autoshift_lastkey); autoshift_flags.lastshifted = true; # if !defined(AUTO_SHIFT_NO_REPEAT) && !defined(AUTO_SHIFT_NO_AUTO_REPEAT) - if (matrixTrigger) { + if (matrix_trigger) { // Prevents release. return; } From ea50e83753f5f21835f3b23208260c56c58fb5e1 Mon Sep 17 00:00:00 2001 From: IsaacElenbaas Date: Tue, 28 Jul 2020 08:25:49 -0400 Subject: [PATCH 45/54] cformat, requested changes --- quantum/process_keycode/process_auto_shift.c | 28 +++++++++----------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index f789bbbbcded..2181cd930253 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -61,7 +61,6 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { return true; } - # ifndef AUTO_SHIFT_MODIFIERS if (get_mods() & (~MOD_BIT(KC_LSFT))) { return true; @@ -75,7 +74,6 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { if (elapsed < TAPPING_TERM && keycode == autoshift_lastkey) { // Allow a tap-then-hold for keyrepeat. if (!autoshift_flags.lastshifted) { - // Change this and below to 16 if custom keys are added. register_code(autoshift_lastkey); } else { // Simulate pressing the shift key. @@ -91,7 +89,7 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { // Record the keycode so we can simulate it later. autoshift_lastkey = keycode; - autoshift_time = record->event.time; + autoshift_time = record->event.time; autoshift_flags.in_progress = true; # if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) @@ -116,7 +114,6 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { // Time since the initial press was recorded. const uint16_t elapsed = TIMER_DIFF_16(now, autoshift_time); if (elapsed < autoshift_timeout) { - // Change this and below to 16 if custom keys are added. register_code(autoshift_lastkey); autoshift_flags.lastshifted = false; } else { @@ -133,12 +130,11 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { } # if TAP_CODE_DELAY > 0 - wait_ms(TAP_CODE_DELAY); + wait_ms(TAP_CODE_DELAY); # endif unregister_code(autoshift_lastkey); autoshift_flush_shift(); - } - else { + } else { // Release after keyrepeat. unregister_code(keycode); if (keycode == autoshift_lastkey) { @@ -159,16 +155,16 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { * to be released. */ void autoshift_matrix_scan(void) { - const uint16_t now = timer_read(); - const uint16_t elapsed = TIMER_DIFF_16(now, autoshift_time); - if (autoshift_flags.in_progress && elapsed >= autoshift_timeout) { - autoshift_end(autoshift_lastkey, now, true); + if (autoshift_flags.in_progress) { + const uint16_t now = timer_read(); + const uint16_t elapsed = TIMER_DIFF_16(now, autoshift_time); + if (elapsed >= autoshift_timeout) { + autoshift_end(autoshift_lastkey, now, true); + } } } -void autoshift_enable(void) { - autoshift_flags.enabled = true; -} +void autoshift_enable(void) { autoshift_flags.enabled = true; } void autoshift_disable(void) { autoshift_flags.enabled = false; @@ -191,9 +187,11 @@ void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; } bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { if (autoshift_flags.in_progress) { + // Evaluate previous key if there is one. Doing this elsewhere is + // more complicated and easier to break. autoshift_end(KC_NO, record->event.time, false); } - // For pressing another key while keyrepeating shifted autoshift + // For pressing another key while keyrepeating shifted autoshift. autoshift_flush_shift(); switch (keycode) { From cae2d316c9abfefd7aac4833a5df219a9d2d3845 Mon Sep 17 00:00:00 2001 From: IsaacElenbaas Date: Thu, 30 Jul 2020 10:45:28 -0400 Subject: [PATCH 46/54] Docs and changed defines to not be breaking change --- docs/feature_auto_shift.md | 22 ++++++++++++++++---- quantum/process_keycode/process_auto_shift.c | 4 ++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md index cee78f0f6fba..8e04d9dd38cf 100644 --- a/docs/feature_auto_shift.md +++ b/docs/feature_auto_shift.md @@ -20,10 +20,11 @@ have not released the key after the `AUTO_SHIFT_TIMEOUT` period, then a shifted version of the key is emitted. If the time is less than the `AUTO_SHIFT_TIMEOUT` time, or you press another key, then the normal state is emitted. -If you hold the key down, it will repeat the shifted key. If you want to repeat -the normal key, then tap it once then immediately (within `TAPPING_TERM`) hold -it down again. The ability to repeat the normal key like this will be disabled -if `TAPPING_FORCE_HOLD` is set. +If `AUTO_SHIFT_REPEAT` is defined, there is keyrepeat support. Holding the key +down will repeat the shifted key, though this can be disabled with +`AUTO_SHIFT_NO_AUTO_REPEAT`. If you want to repeat the normal key, then tap it +once then immediately (within `TAPPING_TERM`) hold it down again (this works +with the shifted value as well if auto-repeat is disabled). ## Are There Limitations to Auto Shift? @@ -35,6 +36,11 @@ practice. As we get in a hurry, we think we have hit the key long enough for a shifted version, but we did not. On the other hand, we may think we are tapping the keys, but really we have held it for a little longer than anticipated. +Additionally, with keyrepeat the desired shift state can get mixed up. It will +always 'belong' to the last key pressed. For example, keyrepeating a capital +and then tapping something lowercase (whether or not it's an Auto Shift key) +will result in the capital's *key* still being held, but shift not. + ## How Do I Enable Auto Shift? Add to your `rules.mk` in the keymap folder: @@ -103,6 +109,14 @@ Do not Auto Shift numeric keys, zero through nine. Do not Auto Shift alpha characters, which include A through Z. +### AUTO_SHIFT_REPEAT (simple define) + +Enables keyrepeat. + +### AUTO_SHIFT_NO_AUTO_REPEAT (simple define) + +Disables automatically keyrepeating when `AUTO_SHIFT_TIMEOUT` is exceeded. + ## Using Auto Shift Setup This will enable you to define three keys temporarily to increase, decrease and report your `AUTO_SHIFT_TIMEOUT`. diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 2181cd930253..005af1790757 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -66,7 +66,7 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { return true; } # endif -# ifndef AUTO_SHIFT_NO_REPEAT +# ifdef AUTO_SHIFT_REPEAT const uint16_t elapsed = TIMER_DIFF_16(record->event.time, autoshift_time); # ifndef AUTO_SHIFT_NO_AUTO_REPEAT if (!autoshift_flags.lastshifted) { @@ -121,7 +121,7 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { add_weak_mods(MOD_BIT(KC_LSFT)); register_code(autoshift_lastkey); autoshift_flags.lastshifted = true; -# if !defined(AUTO_SHIFT_NO_REPEAT) && !defined(AUTO_SHIFT_NO_AUTO_REPEAT) +# if defined(AUTO_SHIFT_REPEAT) && !defined(AUTO_SHIFT_NO_AUTO_REPEAT) if (matrix_trigger) { // Prevents release. return; From 76457def075ceafcf67ccebe4c1a454e8a4e9220 Mon Sep 17 00:00:00 2001 From: IsaacElenbaas Date: Thu, 30 Jul 2020 22:22:51 -0400 Subject: [PATCH 47/54] Fixed shift not being released and removed unnecessary flush_shift. --- quantum/process_keycode/process_auto_shift.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 005af1790757..061678f52068 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -46,12 +46,6 @@ void autoshift_timer_report(void) { } # endif -/** \brief Releases the shift key if it was held by autoshift */ -static void autoshift_flush_shift(void) { - del_weak_mods(MOD_BIT(KC_LSFT)); - autoshift_flags.holding_shift = false; -} - /** \brief Record the press of an autoshiftable key * * \return Whether the record should be further processed. @@ -133,7 +127,7 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { wait_ms(TAP_CODE_DELAY); # endif unregister_code(autoshift_lastkey); - autoshift_flush_shift(); + del_weak_mods(MOD_BIT(KC_LSFT)); } else { // Release after keyrepeat. unregister_code(keycode); @@ -141,9 +135,10 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { // This will only fire when the key was the last auto-shiftable // pressed. That prevents aaaaBBBB then releasing a from unshifting // later Bs (if B wasn't auto-shiftable). - autoshift_flush_shift(); + del_weak_mods(MOD_BIT(KC_LSFT)); } } + send_keyboard_report(); // del_weak_mods doesn't send one. // Roll the autoshift_time forward for detecting tap-and-hold. autoshift_time = now; } @@ -168,14 +163,12 @@ void autoshift_enable(void) { autoshift_flags.enabled = true; } void autoshift_disable(void) { autoshift_flags.enabled = false; - autoshift_flush_shift(); + del_weak_mods(MOD_BIT(KC_LSFT)); } void autoshift_toggle(void) { autoshift_flags.enabled = !autoshift_flags.enabled; - if (!autoshift_flags.enabled) { - autoshift_flush_shift(); - } + del_weak_mods(MOD_BIT(KC_LSFT)); } bool get_autoshift_state(void) { return autoshift_flags.enabled; } @@ -192,7 +185,7 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { autoshift_end(KC_NO, record->event.time, false); } // For pressing another key while keyrepeating shifted autoshift. - autoshift_flush_shift(); + del_weak_mods(MOD_BIT(KC_LSFT)); switch (keycode) { # ifndef AUTO_SHIFT_NO_SETUP From 339fe5bfc49569ca8969024a75b3aab0a272e9a9 Mon Sep 17 00:00:00 2001 From: Dean Scarff Date: Tue, 18 Aug 2020 21:11:32 +1000 Subject: [PATCH 48/54] clang-format --- quantum/process_keycode/process_auto_shift.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 061678f52068..66a52d474557 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -138,7 +138,7 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { del_weak_mods(MOD_BIT(KC_LSFT)); } } - send_keyboard_report(); // del_weak_mods doesn't send one. + send_keyboard_report(); // del_weak_mods doesn't send one. // Roll the autoshift_time forward for detecting tap-and-hold. autoshift_time = now; } From 2a561849e257b10f2d72f8068a0ec9ad2f1be805 Mon Sep 17 00:00:00 2001 From: IsaacElenbaas Date: Wed, 29 Jul 2020 12:07:51 -0400 Subject: [PATCH 49/54] Custom autoshifts and easy extension! --- quantum/process_keycode/process_auto_shift.c | 64 +++++++++++++------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 66a52d474557..8aa6cb692916 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -24,6 +24,10 @@ static uint16_t autoshift_time = 0; static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; static uint16_t autoshift_lastkey = KC_NO; +// Keys take 8 bits if modifiers are excluded. This records the shift state +// when pressed for each key, so that can be passed to the release function +// and it knows which key needs to be released (if shifted is different base). +static bool autoshift_shift_states[256]; static struct { // Whether autoshift is enabled. bool enabled : 1; @@ -36,6 +40,22 @@ static struct { bool holding_shift : 1; } autoshift_flags = {true, false, false, false}; +__attribute__((weak)) bool autoshift_is_custom(uint16_t keycode) { return false; } + +// Called on autoshift key physical press. +__attribute__((weak)) void autoshift_press_user(uint16_t keycode) {} + +// Called when an autoshift key needs to be pressed. +__attribute__((weak)) void autoshift_end_user(uint16_t keycode, bool shifted) { + if (shifted) { + add_weak_mods(MOD_BIT(KC_LSFT)); + } + register_code(keycode); +} + +// Called when an autoshift key needs to be released. +__attribute__((weak)) void autoshift_release_user(uint16_t keycode, bool shifted) { unregister_code(keycode); } + # ifndef AUTO_SHIFT_NO_SETUP void autoshift_timer_report(void) { char display[8]; @@ -67,13 +87,8 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { # endif if (elapsed < TAPPING_TERM && keycode == autoshift_lastkey) { // Allow a tap-then-hold for keyrepeat. - if (!autoshift_flags.lastshifted) { - register_code(autoshift_lastkey); - } else { - // Simulate pressing the shift key. - add_weak_mods(MOD_BIT(KC_LSFT)); - register_code(autoshift_lastkey); - } + // autoshift_shift_state doesn't need to be changed. + autoshift_end_user(autoshift_lastkey, autoshift_flags.lastshifted); return false; } # ifndef AUTO_SHIFT_NO_AUTO_REPEAT @@ -85,6 +100,7 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { autoshift_lastkey = keycode; autoshift_time = record->event.time; autoshift_flags.in_progress = true; + autoshift_press_user(keycode); # if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); @@ -106,31 +122,25 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { autoshift_flags.in_progress = false; // Time since the initial press was recorded. - const uint16_t elapsed = TIMER_DIFF_16(now, autoshift_time); - if (elapsed < autoshift_timeout) { - register_code(autoshift_lastkey); - autoshift_flags.lastshifted = false; - } else { - // Simulate pressing the shift key. - add_weak_mods(MOD_BIT(KC_LSFT)); - register_code(autoshift_lastkey); - autoshift_flags.lastshifted = true; + const uint16_t elapsed = TIMER_DIFF_16(now, autoshift_time); + autoshift_flags.lastshifted = !(elapsed < autoshift_timeout) || get_mods() & MOD_BIT(KC_LSFT); + autoshift_shift_states[autoshift_lastkey & 0xFF] = autoshift_flags.lastshifted; + autoshift_end_user(autoshift_lastkey, autoshift_flags.lastshifted); # if defined(AUTO_SHIFT_REPEAT) && !defined(AUTO_SHIFT_NO_AUTO_REPEAT) - if (matrix_trigger) { - // Prevents release. - return; - } -# endif + if (matrix_trigger) { + // Prevents release. + return; } +# endif # if TAP_CODE_DELAY > 0 wait_ms(TAP_CODE_DELAY); # endif - unregister_code(autoshift_lastkey); + autoshift_release_user(autoshift_lastkey, autoshift_shift_states[autoshift_lastkey & 0xFF]); del_weak_mods(MOD_BIT(KC_LSFT)); } else { // Release after keyrepeat. - unregister_code(keycode); + autoshift_release_user(autoshift_lastkey, autoshift_shift_states[autoshift_lastkey & 0xFF]); if (keycode == autoshift_lastkey) { // This will only fire when the key was the last auto-shiftable // pressed. That prevents aaaaBBBB then releasing a from unshifting @@ -213,6 +223,14 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { } } + if (autoshift_is_custom(keycode)) { + if (record->event.pressed) { + return autoshift_press(keycode, record); + } else { + autoshift_end(keycode, record->event.time, false); + return false; + } + } switch (keycode) { # ifndef NO_AUTO_SHIFT_ALPHA case KC_A ... KC_Z: From f58ead5fc2c60e3f304ec41638734efb0e7f10db Mon Sep 17 00:00:00 2001 From: IsaacElenbaas Date: Wed, 29 Jul 2020 15:54:30 -0400 Subject: [PATCH 50/54] Manual shift fixes --- quantum/process_keycode/process_auto_shift.c | 54 +++++++++++++++++--- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 8aa6cb692916..1636593fbafc 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -38,7 +38,10 @@ static struct { bool in_progress : 1; // Whether the auto-shifted keypress has been registered. bool holding_shift : 1; -} autoshift_flags = {true, false, false, false}; + // Whether the user is holding a shift and we removed it. + bool cancelling_lshift : 1; + bool cancelling_rshift : 1; +} autoshift_flags = {true, false, false, false, false, false}; __attribute__((weak)) bool autoshift_is_custom(uint16_t keycode) { return false; } @@ -66,6 +69,21 @@ void autoshift_timer_report(void) { } # endif +/** \brief Releases the shift key if it was held by autoshift */ +static void autoshift_flush_shift(void) { + autoshift_flags.holding_shift = false; + del_weak_mods(MOD_BIT(KC_LSFT)); + if (autoshift_flags.cancelling_lshift) { + autoshift_flags.cancelling_lshift = false; + add_mods(MOD_BIT(KC_LSFT)); + } + if (autoshift_flags.cancelling_rshift) { + autoshift_flags.cancelling_rshift = false; + add_mods(MOD_BIT(KC_RSFT)); + } + send_keyboard_report(); +} + /** \brief Record the press of an autoshiftable key * * \return Whether the record should be further processed. @@ -87,6 +105,14 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { # endif if (elapsed < TAPPING_TERM && keycode == autoshift_lastkey) { // Allow a tap-then-hold for keyrepeat. + if (get_mods() & MOD_BIT(KC_LSFT)) { + autoshift_flags.cancelling_lshift = true; + del_mods(MOD_BIT(KC_LSFT)); + } + if (get_mods() & MOD_BIT(KC_RSFT)) { + autoshift_flags.cancelling_rshift = true; + del_mods(MOD_BIT(KC_RSFT)); + } // autoshift_shift_state doesn't need to be changed. autoshift_end_user(autoshift_lastkey, autoshift_flags.lastshifted); return false; @@ -125,6 +151,14 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { const uint16_t elapsed = TIMER_DIFF_16(now, autoshift_time); autoshift_flags.lastshifted = !(elapsed < autoshift_timeout) || get_mods() & MOD_BIT(KC_LSFT); autoshift_shift_states[autoshift_lastkey & 0xFF] = autoshift_flags.lastshifted; + if (get_mods() & MOD_BIT(KC_LSFT)) { + autoshift_flags.cancelling_lshift = true; + del_mods(MOD_BIT(KC_LSFT)); + } + if (get_mods() & MOD_BIT(KC_RSFT)) { + autoshift_flags.cancelling_rshift = true; + del_mods(MOD_BIT(KC_RSFT)); + } autoshift_end_user(autoshift_lastkey, autoshift_flags.lastshifted); # if defined(AUTO_SHIFT_REPEAT) && !defined(AUTO_SHIFT_NO_AUTO_REPEAT) if (matrix_trigger) { @@ -137,15 +171,15 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { wait_ms(TAP_CODE_DELAY); # endif autoshift_release_user(autoshift_lastkey, autoshift_shift_states[autoshift_lastkey & 0xFF]); - del_weak_mods(MOD_BIT(KC_LSFT)); + autoshift_flush_shift(); } else { // Release after keyrepeat. - autoshift_release_user(autoshift_lastkey, autoshift_shift_states[autoshift_lastkey & 0xFF]); + autoshift_release_user(keycode, autoshift_shift_states[autoshift_lastkey & 0xFF]); if (keycode == autoshift_lastkey) { // This will only fire when the key was the last auto-shiftable // pressed. That prevents aaaaBBBB then releasing a from unshifting // later Bs (if B wasn't auto-shiftable). - del_weak_mods(MOD_BIT(KC_LSFT)); + autoshift_flush_shift(); } } send_keyboard_report(); // del_weak_mods doesn't send one. @@ -173,12 +207,12 @@ void autoshift_enable(void) { autoshift_flags.enabled = true; } void autoshift_disable(void) { autoshift_flags.enabled = false; - del_weak_mods(MOD_BIT(KC_LSFT)); + autoshift_flush_shift(); } void autoshift_toggle(void) { autoshift_flags.enabled = !autoshift_flags.enabled; - del_weak_mods(MOD_BIT(KC_LSFT)); + autoshift_flush_shift(); } bool get_autoshift_state(void) { return autoshift_flags.enabled; } @@ -195,7 +229,7 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { autoshift_end(KC_NO, record->event.time, false); } // For pressing another key while keyrepeating shifted autoshift. - del_weak_mods(MOD_BIT(KC_LSFT)); + autoshift_flush_shift(); switch (keycode) { # ifndef AUTO_SHIFT_NO_SETUP @@ -221,6 +255,12 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { autoshift_disable(); return true; } + } else { + if (keycode == KC_LSFT) { + autoshift_flags.cancelling_lshift = false; + } else if (keycode == KC_RSFT) { + autoshift_flags.cancelling_rshift = false; + } } if (autoshift_is_custom(keycode)) { From 33871104092357e8ce2075f9636418c30bb0d2f5 Mon Sep 17 00:00:00 2001 From: IsaacElenbaas Date: Thu, 30 Jul 2020 14:34:46 -0400 Subject: [PATCH 51/54] A few changes. - Functions working how I want them to - Fixed press->press->(release first) releasing both AS keys - Updated docs, though I'm not sure if they're clear enough --- docs/feature_auto_shift.md | 108 ++++++++++++++++++- quantum/process_keycode/process_auto_shift.c | 74 ++++++------- 2 files changed, 142 insertions(+), 40 deletions(-) diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md index 8e04d9dd38cf..a72c9ba3e9ee 100644 --- a/docs/feature_auto_shift.md +++ b/docs/feature_auto_shift.md @@ -86,7 +86,8 @@ A sample is This controls how long you have to hold a key before you get the shifted state. Obviously, this is different for everyone. For the common person, a setting of 135 to 150 works great. However, one should start with a value of at least 175, which -is the default value. Then work down from there. The idea is to have the shortest time required to get the shifted state without having false positives. +is the default value. Then work down from there. The idea is to have the shortest +time required to get the shifted state without having false positives. Play with this value until things are perfect. Many find that all will work well at a given value, but one or two keys will still emit the shifted state on @@ -117,6 +118,111 @@ Enables keyrepeat. Disables automatically keyrepeating when `AUTO_SHIFT_TIMEOUT` is exceeded. +### Custom Keys and Custom Shifted Values + +Especially on small keyboards, the default shifted value for many keys is not +optimal. To provide more customizability, there are three user-definable +functions. The first, `autoshift_is_custom`, is called on every key event and +returns whether it should be a part of Auto Shift. The other two are +`autoshift_press/release_user`, and press or release the passed key. If one +does not require custom shift values, only `autoshift_is_custom` is required. +Below is an example adding period to Auto Shift and making its shifted value +exclamation point. Make sure to use weak mods - setting real would make any +keys following it use their shifted values as if you were holding the key. +Clearing of modifiers is handled by Auto Shift, and the shift value is always +that of the last key pressed (whether or not it's an Auto Shift key). + +You can also have non-shifted keys for the shifted values (or even no shifted +value), just don't set a shift modifier! + +```c +bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record) { + switch(keycode) { + case KC_DOT: + break; + default: + return false; + } + return true; +} +void autoshift_press_user(uint16_t keycode, bool shifted) { + switch(keycode) { + case KC_DOT: + if (!shifted) { + register_code(KC_DOT); + } else { + add_weak_mods(MOD_BIT(KC_LSFT)); + register_code(KC_1); + } + default: + if (shifted) { add_weak_mods(MOD_BIT(KC_LSFT)); } + register_code(keycode); + } +} +void autoshift_release_user(uint16_t keycode, bool shifted) { + switch(keycode) { + case KC_DOT: + unregister_code((!shifted) ? KC_DOT : KC_1); + default: + unregister_code(keycode); + } +} +``` + +Because of how much information you can get from these functions, even more is +possible. Below is a mod-tap-like key that also is a part of Auto Shift (note +the setting of weak mods and user mods, to not confuse Auto Shift). Note this +won't work with keyrepeat, and presses the modifier anyway while held so won't +work with super if you're on Windows (the start menu would open on release). + +```c +// Stores whether to hit the key at all, and whether it should be shifted. +bool as_colon[2]; +bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record) { + switch(keycode) { + case KC_SCLN: + if (record->event.pressed) { + add_mods(MOD_BIT(KC_LSFT)); + as_colon[0] = true; + } else { + // Evaluate on the physical key up. + del_mods(MOD_BIT(KC_LSFT)); + if (as_colon[0]) { + if (as_colon[1]) { add_weak_mods(MOD_BIT(KC_LSFT)); } + tap_code(KC_SCLN); + del_weak_mods(MOD_BIT(KC_LSFT)); + } + } + break; + default: + // If there are any key events between the press and release, don't send the key. + as_colon[0] = false; + return false; + } + return true; +} +void autoshift_press_user(uint16_t keycode, bool shifted) { + switch(keycode) { + case KC_SCLN: + // We don't want to send the key until it's released, but need to know the shift state. + as_colon[1] = shifted; + return; + default: + if (shifted) { add_weak_mods(MOD_BIT(KC_LSFT)); } + register_code(keycode); + } +} +void autoshift_release_user(uint16_t keycode, bool shifted) { + switch(keycode) { + case KC_SCLN: + // We never pressed the key. + return; + default: + unregister_code(keycode); + } +} +``` + ## Using Auto Shift Setup This will enable you to define three keys temporarily to increase, decrease and report your `AUTO_SHIFT_TIMEOUT`. diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 1636593fbafc..6905aa5b54ff 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -43,16 +43,12 @@ static struct { bool cancelling_rshift : 1; } autoshift_flags = {true, false, false, false, false, false}; -__attribute__((weak)) bool autoshift_is_custom(uint16_t keycode) { return false; } - -// Called on autoshift key physical press. -__attribute__((weak)) void autoshift_press_user(uint16_t keycode) {} +// Called on physical press, returns whether is autoshift key. +__attribute__((weak)) bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record) { return false; } // Called when an autoshift key needs to be pressed. -__attribute__((weak)) void autoshift_end_user(uint16_t keycode, bool shifted) { - if (shifted) { - add_weak_mods(MOD_BIT(KC_LSFT)); - } +__attribute__((weak)) void autoshift_press_user(uint16_t keycode, bool shifted) { + if (shifted) { add_weak_mods(MOD_BIT(KC_LSFT)); } register_code(keycode); } @@ -89,10 +85,6 @@ static void autoshift_flush_shift(void) { * \return Whether the record should be further processed. */ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { - if (!autoshift_flags.enabled) { - return true; - } - # ifndef AUTO_SHIFT_MODIFIERS if (get_mods() & (~MOD_BIT(KC_LSFT))) { return true; @@ -114,7 +106,7 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { del_mods(MOD_BIT(KC_RSFT)); } // autoshift_shift_state doesn't need to be changed. - autoshift_end_user(autoshift_lastkey, autoshift_flags.lastshifted); + autoshift_press_user(autoshift_lastkey, autoshift_flags.lastshifted); return false; } # ifndef AUTO_SHIFT_NO_AUTO_REPEAT @@ -126,7 +118,6 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { autoshift_lastkey = keycode; autoshift_time = record->event.time; autoshift_flags.in_progress = true; - autoshift_press_user(keycode); # if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); @@ -140,10 +131,13 @@ static bool autoshift_press(uint16_t keycode, keyrecord_t *record) { * * If the autoshift key is released before the delay has elapsed, register the * key without a shift. + * + * Called on key down with KC_NO, auto-shifted key up, and timeout. Keycode is + * always the key that needs to be evaluated, not the key that may have + * cancelled it. */ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { - // Called on key down with KC_NO, auto-shifted key up, and timeout. - if (autoshift_flags.in_progress) { + if (autoshift_flags.in_progress && keycode == autoshift_lastkey) { // Process the auto-shiftable key. autoshift_flags.in_progress = false; @@ -159,7 +153,7 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { autoshift_flags.cancelling_rshift = true; del_mods(MOD_BIT(KC_RSFT)); } - autoshift_end_user(autoshift_lastkey, autoshift_flags.lastshifted); + autoshift_press_user(autoshift_lastkey, autoshift_flags.lastshifted); # if defined(AUTO_SHIFT_REPEAT) && !defined(AUTO_SHIFT_NO_AUTO_REPEAT) if (matrix_trigger) { // Prevents release. @@ -173,8 +167,8 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { autoshift_release_user(autoshift_lastkey, autoshift_shift_states[autoshift_lastkey & 0xFF]); autoshift_flush_shift(); } else { - // Release after keyrepeat. - autoshift_release_user(keycode, autoshift_shift_states[autoshift_lastkey & 0xFF]); + // Release after keyrepeat or evaluated early. + autoshift_release_user(keycode, autoshift_shift_states[keycode & 0xFF]); if (keycode == autoshift_lastkey) { // This will only fire when the key was the last auto-shiftable // pressed. That prevents aaaaBBBB then releasing a from unshifting @@ -226,7 +220,7 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { if (autoshift_flags.in_progress) { // Evaluate previous key if there is one. Doing this elsewhere is // more complicated and easier to break. - autoshift_end(KC_NO, record->event.time, false); + autoshift_end(autoshift_lastkey, record->event.time, false); } // For pressing another key while keyrepeating shifted autoshift. autoshift_flush_shift(); @@ -263,32 +257,34 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { } } - if (autoshift_is_custom(keycode)) { - if (record->event.pressed) { - return autoshift_press(keycode, record); - } else { - autoshift_end(keycode, record->event.time, false); - return false; + if (autoshift_flags.enabled) { + if (autoshift_is_custom(keycode, record)) { + if (record->event.pressed) { + return autoshift_press(keycode, record); + } else { + autoshift_end(keycode, record->event.time, false); + return false; + } } - } - switch (keycode) { + switch (keycode) { # ifndef NO_AUTO_SHIFT_ALPHA - case KC_A ... KC_Z: + case KC_A ... KC_Z: # endif # ifndef NO_AUTO_SHIFT_NUMERIC - case KC_1 ... KC_0: + case KC_1 ... KC_0: # endif # ifndef NO_AUTO_SHIFT_SPECIAL - case KC_TAB: - case KC_MINUS ... KC_SLASH: - case KC_NONUS_BSLASH: + case KC_TAB: + case KC_MINUS ... KC_SLASH: + case KC_NONUS_BSLASH: # endif - if (record->event.pressed) { - return autoshift_press(keycode, record); - } else { - autoshift_end(keycode, record->event.time, false); - return false; - } + if (record->event.pressed) { + return autoshift_press(keycode, record); + } else { + autoshift_end(keycode, record->event.time, false); + return false; + } + } } return true; } From 8d98342b089667ba2ecd55b9a67119b2a15f1d9a Mon Sep 17 00:00:00 2001 From: IsaacElenbaas Date: Thu, 30 Jul 2020 15:56:36 -0400 Subject: [PATCH 52/54] Added a way to have mod-tap-shift cancel if held very long. --- docs/feature_auto_shift.md | 18 ++++++++++++------ quantum/process_keycode/process_auto_shift.c | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md index a72c9ba3e9ee..49baf8d5166f 100644 --- a/docs/feature_auto_shift.md +++ b/docs/feature_auto_shift.md @@ -129,14 +129,15 @@ does not require custom shift values, only `autoshift_is_custom` is required. Below is an example adding period to Auto Shift and making its shifted value exclamation point. Make sure to use weak mods - setting real would make any keys following it use their shifted values as if you were holding the key. -Clearing of modifiers is handled by Auto Shift, and the shift value is always -that of the last key pressed (whether or not it's an Auto Shift key). +Clearing of modifiers is handled by Auto Shift, and the os-sent shift value +if keyrepeating multiple keys is always that of the last key pressed (whether +or not it's an Auto Shift key). You can also have non-shifted keys for the shifted values (or even no shifted value), just don't set a shift modifier! ```c -bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record) { +bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record, uint16_t elapsed) { switch(keycode) { case KC_DOT: break; @@ -178,16 +179,17 @@ work with super if you're on Windows (the start menu would open on release). ```c // Stores whether to hit the key at all, and whether it should be shifted. bool as_colon[2]; -bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record) { +bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record, uint16_t elapsed) { switch(keycode) { case KC_SCLN: if (record->event.pressed) { - add_mods(MOD_BIT(KC_LSFT)); + //add_mods(MOD_BIT(KC_LSFT)); // Can go here for other modifiers if you want. as_colon[0] = true; } else { // Evaluate on the physical key up. del_mods(MOD_BIT(KC_LSFT)); - if (as_colon[0]) { + // Also cancels if you held it for very long, so one can use it with the mouse. + if (as_colon[0] && elapsed < 3*AUTO_SHIFT_TIMEOUT) { if (as_colon[1]) { add_weak_mods(MOD_BIT(KC_LSFT)); } tap_code(KC_SCLN); del_weak_mods(MOD_BIT(KC_LSFT)); @@ -204,6 +206,10 @@ bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record) { void autoshift_press_user(uint16_t keycode, bool shifted) { switch(keycode) { case KC_SCLN: + // Has to be here for shift mods, as otherwise it is set halfway through an action and + // Auto Shift thinks you're holding the mod and restores it on release (causing it to + // be stuck until you hit this or another shift key again). + add_mods(MOD_BIT(KC_LSFT)); // We don't want to send the key until it's released, but need to know the shift state. as_colon[1] = shifted; return; diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 6905aa5b54ff..f5542d24dbb2 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -44,7 +44,7 @@ static struct { } autoshift_flags = {true, false, false, false, false, false}; // Called on physical press, returns whether is autoshift key. -__attribute__((weak)) bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record) { return false; } +__attribute__((weak)) bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record, uint16_t elapsed) { return false; } // Called when an autoshift key needs to be pressed. __attribute__((weak)) void autoshift_press_user(uint16_t keycode, bool shifted) { @@ -258,7 +258,7 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { } if (autoshift_flags.enabled) { - if (autoshift_is_custom(keycode, record)) { + if (autoshift_is_custom(keycode, record, TIMER_DIFF_16(record->event.time, autoshift_time))) { if (record->event.pressed) { return autoshift_press(keycode, record); } else { From 280b8017a1ba44caa2d8dad8a319b0ae3f775efe Mon Sep 17 00:00:00 2001 From: IsaacElenbaas Date: Fri, 7 Aug 2020 06:52:52 -0400 Subject: [PATCH 53/54] Remove mod-tap support in favor of upstream 9889 --- docs/feature_auto_shift.md | 74 +++----------------- quantum/process_keycode/process_auto_shift.c | 4 +- 2 files changed, 10 insertions(+), 68 deletions(-) diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md index 49baf8d5166f..aa87a9c528ab 100644 --- a/docs/feature_auto_shift.md +++ b/docs/feature_auto_shift.md @@ -125,19 +125,19 @@ optimal. To provide more customizability, there are three user-definable functions. The first, `autoshift_is_custom`, is called on every key event and returns whether it should be a part of Auto Shift. The other two are `autoshift_press/release_user`, and press or release the passed key. If one -does not require custom shift values, only `autoshift_is_custom` is required. -Below is an example adding period to Auto Shift and making its shifted value -exclamation point. Make sure to use weak mods - setting real would make any -keys following it use their shifted values as if you were holding the key. -Clearing of modifiers is handled by Auto Shift, and the os-sent shift value -if keyrepeating multiple keys is always that of the last key pressed (whether -or not it's an Auto Shift key). +does not require custom shift values but wants custom keys, only +`autoshift_is_custom` is required. Below is an example adding period to Auto +Shift and making its shifted value exclamation point. Make sure to use weak +mods - setting real would make any keys following it use their shifted values +as if you were holding the key. Clearing of modifiers is handled by Auto Shift, +and the os-sent shift value if keyrepeating multiple keys is always that of +the last key pressed (whether or not it's an Auto Shift key). You can also have non-shifted keys for the shifted values (or even no shifted value), just don't set a shift modifier! ```c -bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record, uint16_t elapsed) { +bool autoshift_is_custom(uint16_t keycode) { switch(keycode) { case KC_DOT: break; @@ -170,64 +170,6 @@ void autoshift_release_user(uint16_t keycode, bool shifted) { } ``` -Because of how much information you can get from these functions, even more is -possible. Below is a mod-tap-like key that also is a part of Auto Shift (note -the setting of weak mods and user mods, to not confuse Auto Shift). Note this -won't work with keyrepeat, and presses the modifier anyway while held so won't -work with super if you're on Windows (the start menu would open on release). - -```c -// Stores whether to hit the key at all, and whether it should be shifted. -bool as_colon[2]; -bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record, uint16_t elapsed) { - switch(keycode) { - case KC_SCLN: - if (record->event.pressed) { - //add_mods(MOD_BIT(KC_LSFT)); // Can go here for other modifiers if you want. - as_colon[0] = true; - } else { - // Evaluate on the physical key up. - del_mods(MOD_BIT(KC_LSFT)); - // Also cancels if you held it for very long, so one can use it with the mouse. - if (as_colon[0] && elapsed < 3*AUTO_SHIFT_TIMEOUT) { - if (as_colon[1]) { add_weak_mods(MOD_BIT(KC_LSFT)); } - tap_code(KC_SCLN); - del_weak_mods(MOD_BIT(KC_LSFT)); - } - } - break; - default: - // If there are any key events between the press and release, don't send the key. - as_colon[0] = false; - return false; - } - return true; -} -void autoshift_press_user(uint16_t keycode, bool shifted) { - switch(keycode) { - case KC_SCLN: - // Has to be here for shift mods, as otherwise it is set halfway through an action and - // Auto Shift thinks you're holding the mod and restores it on release (causing it to - // be stuck until you hit this or another shift key again). - add_mods(MOD_BIT(KC_LSFT)); - // We don't want to send the key until it's released, but need to know the shift state. - as_colon[1] = shifted; - return; - default: - if (shifted) { add_weak_mods(MOD_BIT(KC_LSFT)); } - register_code(keycode); - } -} -void autoshift_release_user(uint16_t keycode, bool shifted) { - switch(keycode) { - case KC_SCLN: - // We never pressed the key. - return; - default: - unregister_code(keycode); - } -} -``` ## Using Auto Shift Setup diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index f5542d24dbb2..6882035a97c5 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -44,7 +44,7 @@ static struct { } autoshift_flags = {true, false, false, false, false, false}; // Called on physical press, returns whether is autoshift key. -__attribute__((weak)) bool autoshift_is_custom(uint16_t keycode, keyrecord_t *record, uint16_t elapsed) { return false; } +__attribute__((weak)) bool autoshift_is_custom(uint16_t keycode) { return false; } // Called when an autoshift key needs to be pressed. __attribute__((weak)) void autoshift_press_user(uint16_t keycode, bool shifted) { @@ -258,7 +258,7 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { } if (autoshift_flags.enabled) { - if (autoshift_is_custom(keycode, record, TIMER_DIFF_16(record->event.time, autoshift_time))) { + if (autoshift_is_custom(keycode)) { if (record->event.pressed) { return autoshift_press(keycode, record); } else { From eb96a3bed464e010b027fe94386b551f071ae1d9 Mon Sep 17 00:00:00 2001 From: IsaacElenbaas Date: Fri, 7 Aug 2020 06:59:36 -0400 Subject: [PATCH 54/54] Minor comment changes. --- quantum/process_keycode/process_auto_shift.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 6882035a97c5..6dfade66ecf2 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -171,8 +171,8 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { autoshift_release_user(keycode, autoshift_shift_states[keycode & 0xFF]); if (keycode == autoshift_lastkey) { // This will only fire when the key was the last auto-shiftable - // pressed. That prevents aaaaBBBB then releasing a from unshifting - // later Bs (if B wasn't auto-shiftable). + // pressed. That prevents 'aaaaBBBB' then releasing 'a' from + // unshifting later 'B's (if 'B' wasn't auto-shiftable). autoshift_flush_shift(); } } @@ -223,6 +223,8 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { autoshift_end(autoshift_lastkey, record->event.time, false); } // For pressing another key while keyrepeating shifted autoshift. + // Workaround until #9941 is merged, won't break anything after + // it is. autoshift_flush_shift(); switch (keycode) {