Commit Graph

49 Commits

Author SHA1 Message Date
Ondrej Jirman 3726b6adc2 Pull-up port 8 upper nibble of pins and keep them as inputs
This avoids pulling them low temporarily during startup.
2023-02-18 02:51:20 +01:00
Ondrej Jirman 6fbfb61c14 Revert "Add extra 50uA savings by disabling the USB 3.3V regulator"
This reverts commit c4f36fdb14.
2023-02-17 18:49:01 +01:00
Ondrej Jirman 470f230d15 Disable USB stack in stock firmware by default, for max power savings 2023-02-17 17:31:47 +01:00
Ondrej Jirman c4f36fdb14 Add extra 50uA savings by disabling the USB 3.3V regulator 2023-02-17 17:31:47 +01:00
Ondrej Jirman b24b0f1d84 Configure MCU pins properly to avoid floating inputs
This reduces the power consumption of the MCU significantly.
2023-02-17 16:46:12 +01:00
Ondrej Jirman 6145b3df0a Fix re-entry to sleep after the first keypress 2023-02-17 14:02:28 +01:00
Ondrej Jirman 61e90842de Fix no-USB build of the stock firwmare 2023-02-17 14:01:33 +01:00
Ondrej Jirman 4b3d885b61 Check that no key is pressed right after setting up IC interrupt and before going to sleep 2023-02-17 14:00:32 +01:00
Ondrej Jirman 0899765c07 Don't declare variables that are unused in certain firmware configurations 2023-02-17 13:59:18 +01:00
Ondrej Jirman 31c41b7d9e Drop I2C bit functions, to make timing easier to modify
I2C to the charger now has clean 100kHz timing. One read command now takes
400us, and one write command takes 300us to execute.
2021-09-05 02:26:55 +02:00
Ondrej Jirman 78c72fe448 Make register define order less confusing 2021-09-05 02:07:12 +02:00
Ondrej Jirman 21374993b3 Allow to reset to stock firmware from user firmware by holding pine+f+h 2021-09-05 01:58:48 +02:00
Ondrej Jirman 0b280ebc14 Fix I2C bit banging code 2021-09-05 01:57:58 +02:00
Ondrej Jirman 574d68aa89 fw: Change to bit-banging I2C implementation for charger comm
New code, compiles, but it's not tested yet!
2021-09-01 00:48:27 +02:00
Ondrej Jirman f1e3f6dce6 Drop prototype keyboard build 2021-08-31 19:00:18 +02:00
Samuel Holland 246aaaa42e firmware: Statically allocate keys array
Allocating the array on the stack before initializing the stack pointer
does not work.
2021-08-05 21:17:09 -05:00
Samuel Holland 3c6488b99e Disable I2CA in all firmware builds
It is unlikely that any future revision of the hardware will use I2CA.
2021-08-05 21:17:09 -05:00
Samuel Holland 3107546c04 Revert "firmware: Make interrupt signal shorter (10us)"
The longer duration is actually required, likely due to debouncing
applied on the SoC side. Even 50us was unreliable.

This reverts commit 3b723583e7.
2021-08-05 21:17:09 -05:00
Ondrej Jirman f8b901e832 firmware: Add final/proto-v3 builds 2021-08-05 03:40:07 +02:00
Ondrej Jirman c5c155ca68 firmware: Allow to prevent jump to user fw after powerup by pressing Pine + F + H 2021-08-05 03:33:04 +02:00
Ondrej Jirman b244ab9c9f firmware: Set stack pointer to a correct value 2021-08-05 02:51:51 +02:00
Ondrej Jirman c195dabe04 firmware: Whitespace 2021-08-05 02:29:36 +02:00
Ondrej Jirman 15d477f5ba firmware: Fix I2C A forwarding mode
- add charger INT check prior to transaction via P87
- re-route POGO int to P84
- wrong macro name, fix CONFIG_I2C_A=0 mode
2021-08-05 02:29:23 +02:00
Ondrej Jirman c55f0a44d5 firmware: Post-revert fixup 2021-08-05 02:27:39 +02:00
Ondrej Jirman 4e89074513 Revert "firmware: Move more of the USB shutdown control to usb_enable/usb_disable"
This reverts commit 134b4b6a8b.
2021-08-05 00:54:46 +02:00
Ondrej Jirman f0f49c0fbc Revert "firmware: Implement USB enabled/disable control via I2C"
This reverts commit 176a2da7e2.
2021-08-05 00:54:39 +02:00
Ondrej Jirman 7f1655be83 firmware: Don't trigger stop twice in i2c_a_read 2021-08-05 00:50:43 +02:00
Ondrej Jirman 5bef4c8832 Update TODO and I2C interface description 2021-08-02 12:13:56 +02:00
Ondrej Jirman 5fd891ecc0 firmware: Guard the timer manipulation macro argument 2021-08-02 11:53:31 +02:00
Samuel Holland 394af632aa firmware: Allow to read/write single registers from a charger
This code uses existing system command functionality. The I2C
registers are placed in front of system command register, to
allow for a single transaction proxied I2C A reads/writes.

Not tested, yet.
2021-08-02 11:52:54 +02:00
Ondrej Jirman c3272eb4ef firmware: Drop POLL mode from the register definition
Polling mode was supposed to help with broken keyboard matrix, where
some keys are stuck, but this is handled well by the pre-existing code
already, so there's no need for this.
2021-08-02 10:23:42 +02:00
Ondrej Jirman f7c90f1f74 firmware: Fix compilation issue by moving timer code a bit higher 2021-08-02 10:22:18 +02:00
Samuel Holland 1fd0bac031 firmware: Use REG_SYS macro where appropriate
This shortens a very long line.
2021-08-02 10:17:09 +02:00
Samuel Holland ce6638eb92 firmware: Remove unused variable 2021-08-02 10:14:24 +02:00
Samuel Holland bd69a00f7a common: Improve crc8 generation
Start with 0xff instead of 0x00, so the CRC will be nonzero (and length
dependent) for data that is all zeroes.

Remove unnecessary masking, since `crc` is already an 8-bit integer.
2021-08-02 10:13:06 +02:00
Ondrej Jirman 3b723583e7 firmware: Make interrupt signal shorter (10us)
This is long enough, comparable to 100kHz I2C speeds.
2021-08-02 10:12:48 +02:00
Ondrej Jirman 2fbc2e057e firmware: Implement scanning block
This allows to disable the keyboard. The firmware will never scan
for keys pressed in this mode, and it will powerdown the MCU most of the
time.
2021-08-02 10:12:48 +02:00
Ondrej Jirman 41418cdc14 firmware: Jump to stock firmware sooner after powerup
Signed-off-by: Ondrej Jirman <megous@megous.com>
2021-08-02 10:12:48 +02:00
Ondrej Jirman 176a2da7e2 firmware: Implement USB enabled/disable control via I2C 2021-08-02 10:05:43 +02:00
Ondrej Jirman 134b4b6a8b firmware: Move more of the USB shutdown control to usb_enable/usb_disable
- make sure USB resources are re-enabled before jumping to bootloader
- make sure all USB resources are disabled prior to jumping to user fw
2021-08-02 10:03:48 +02:00
Ondrej Jirman 6a5fe581b9 Implement flashing over I2C and user/stock firmware support
I2C register layout changed a bit to make various operations easier
to implement in FW and for the user.

Flashing/debugging tools now share more code. Firmware is now more
configurable (it's now possible to compile-out various features).

Self-testing for column-shorts is implemented.

Firmware is optimized for low power consumption.
2021-06-28 15:09:47 +02:00
Ondrej Jirman 04ca071b09 Fixup/document I2C 2021-06-19 02:51:23 +02:00
Ondrej Jirman fbfa245ad4 Allow to use debug printing from interrupt handlers 2021-06-19 02:50:34 +02:00
Ondrej Jirman 2725248532 Add USB stack for easier printf() based debugging of the firmware 2021-06-18 19:43:11 +02:00
Ondrej Jirman c8d8eef090 Fix key release change detection in polling mode 2021-06-18 18:28:56 +02:00
Ondrej Jirman b9b02a5e73 Update some comments 2021-06-16 14:44:18 +02:00
Ondrej Jirman bca8c47f46 Implement polled mode and key bitmap change signalling via external interrupt
- this firmware consumes about 4-5 mA (can be probably made lower)
2021-06-16 14:09:25 +02:00
Ondrej Jirman e59f647d83 Allow to switch to bootloader mode via FN+PINE+F 2021-06-15 09:21:31 +02:00
Ondrej Jirman d3c45f58a4 Initial commit 2021-06-14 00:10:49 +02:00