1d4c8d3019
brew updated, travis is behind
Stephen
2017-10-09 14:14:40 -07:00
3dd9744e4d
Make I2C communication rock stable by hacking I2C_SlaveTransferHandleIRQ() of the KSDK and making the firmware use incoming bytes via userData.
László Monda
2017-10-09 04:19:26 +02:00
859a770ca3
Dump byteIn after xfer->event via SPI. Make the firmware build without using the DEBUG_OVER_SPI macro.
László Monda
2017-10-08 23:12:40 +02:00
6b0ebb1385
Add debug_over_spi.[ch]
László Monda
2017-10-08 03:38:43 +02:00
302a750621
Improve file according to our coding standards.
László Monda
2017-10-07 16:37:20 +02:00
457894ecd8
Remove redundant InitI2cV2() function prototype.
László Monda
2017-10-07 16:35:34 +02:00
8dba4df6f6
Set the heap size to 0 given that no dynamic memory is allocated in the firmware. This makes the bss go from 1252 to 740, exactly 0x200 difference.
László Monda
2017-10-07 12:57:52 +02:00
215d4c33bb
Add slave_protocol.c that I forgot to add.
László Monda
2017-10-07 12:29:44 +02:00
9f411dc1d4
Throw ParserError_InvalidKeymapCount if keymapCount == 0.
László Monda
2017-10-06 23:37:05 +02:00
3d443a8bfc
Remove semihosting related changes.
László Monda
2017-10-06 22:36:02 +02:00
1cc01c4f48
Merge pull request #58 from stephengroat/osx-brew
László Monda
2017-10-06 22:21:05 +02:00
fd7f2c3b25
Expose the currently attached module ids via getKeyboardState()
László Monda
2017-10-05 20:53:15 +02:00
8c067b9190
Use UhkModuleDriverId_* enum values instead of magic numbers wherever possible.
László Monda
2017-10-05 20:36:29 +02:00
bea13f063a
UpperCamelCase UhkModuleStates now that it's a global.
László Monda
2017-10-05 20:27:57 +02:00
9842a6ff60
Merge UhkModuleVars into uhkModuleStates. Also make uhkModuleStates globally accessible because it must be accessed by other parts of the firmware, so it's unpractical to keep it private and write accessor functions for it.
László Monda
2017-10-05 20:18:57 +02:00
f8e83b139d
Rerequest transfer if CRC is invalid.
László Monda
2017-10-05 20:02:12 +02:00
6be45c4521
Add uhk_module_state_t->isEnumerated and maintain its state.
László Monda
2017-10-05 19:56:26 +02:00
a9ba8a1907
Remove redundant module members.
László Monda
2017-10-05 19:51:15 +02:00
12c055aec7
Extract MODULE_ID.
László Monda
2017-10-05 18:00:17 +02:00
96eb2ef7a3
Make slaves send their protocol version to the master.
László Monda
2017-10-05 17:55:59 +02:00
bd76fb44c2
Make slaves send their module id to the master.
László Monda
2017-10-05 17:26:10 +02:00
21beb59cb6
Add merge sensor state to getKeyboardState()
László Monda
2017-10-05 14:21:37 +02:00
3ed3272fa3
Write the validated user config area to the EEPROM, not the staging area.
László Monda
2017-10-05 09:12:50 +02:00
377fe4a2b2
Make EEPROM transfers receive an operation and a buffer id parameter. This allows reading and writing both staging and validated user configurations which will aid future debugging. This API is also cleaner.
László Monda
2017-10-05 02:45:22 +02:00
259f4d3299
Add config_buffer_id_t.
László Monda
2017-10-04 23:57:43 +02:00
8e420f8592
Rename and rearrange some variables in config_globals.c for better readability.
László Monda
2017-10-04 22:39:40 +02:00
63674e02b7
Now rename the other guard macro, too. I thought it was renamed by the IDE.
László Monda
2017-10-04 22:36:27 +02:00
e27fb83693
Rename guard macro according to the filename.
László Monda
2017-10-04 22:35:17 +02:00
b0e706d894
Remove redundant extern modifier before function.
László Monda
2017-10-04 22:33:58 +02:00
4295793fb9
Add ATTR_* macros in the newly created attributes.h and use them wherever possible for improved readability.
László Monda
2017-10-04 22:26:48 +02:00
f348aec97a
Rename UserConfigBuffer to ValidatedUserConfigBuffer.
László Monda
2017-10-04 22:10:55 +02:00
9ecdfc0b71
Improve the readability of ApplyConfig()
László Monda
2017-10-04 22:06:45 +02:00
1bca95d366
Don't stop execution upon starting a debugging session.
László Monda
2017-10-04 19:31:28 +02:00
a84d184da4
Include stdio.h
László Monda
2017-10-04 18:34:10 +02:00
c965fe185b
Enable semihosting for the "uhk-left debug jlink" build.
László Monda
2017-10-04 18:21:02 +02:00
af52c017d8
No need to assign a value to I2C_WATCHDOG. Just define it.
László Monda
2017-10-04 13:02:40 +02:00
316602bb02
Rename the obsoleted LED_DRIVER_FORCE_UPDATE macro to LED_DRIVER_STRESS_TEST.
László Monda
2017-10-04 12:59:05 +02:00
6658d62805
Group module phases.
László Monda
2017-10-04 02:52:53 +02:00
c707f0e408
Transfer a synchronization message to make I2C recovery more robust.
László Monda
2017-10-04 02:24:34 +02:00
efb0f982d2
Only try to recover I2C if SDA is low.
László Monda
2017-10-04 01:22:22 +02:00
2027940b4c
Use the correct I2C_MAIN_BUS_{SDA,SCL}{PORT,PIN} macros at the right spots.
László Monda
2017-10-04 01:04:56 +02:00
e5595bc757
Extract I2C recovery code to recoverI2c()
László Monda
2017-10-03 23:59:27 +02:00
72812724ef
Now do send a STOP condition at the end of the I2C recovery which might make it more robust.
László Monda
2017-10-03 23:37:16 +02:00
1daf43b751
Set SDA as GPIO upon trying to recovering I2C, not just SDL.
László Monda
2017-10-03 23:23:26 +02:00
2804d3e447
Don't cycle SDA just before initialzing I2C. Merely pull it high to generate a STOP condition.
László Monda
2017-10-03 22:05:42 +02:00
ff1d5dffaa
Cycle through the I2C clock by using 20 cycles instead of 16. Should be a bit more reliable, although I can't see a definite improvement.
László Monda
2017-10-03 21:56:08 +02:00
5de396bb68
Don't mess around with SDA and SCL before cycling through the clock because it seems redundant.
László Monda
2017-10-03 21:37:35 +02:00
7af8042c93
Fine tune delay to match the I2C peripheral driven at 100kHz.
László Monda
2017-10-03 21:06:04 +02:00
51a9acbb68
Extract delay() from InitI2cMainBus()
László Monda
2017-10-03 20:54:05 +02:00
f1a8d9a330
Toggle SCL from a loop.
László Monda
2017-10-03 20:49:54 +02:00
b5f1bcc4d6
Split InitI2c() as InitI2cMainBus() and initI2cEepromBus() and invoke InitI2cMainBus() from PIT_I2C_WATCHDOG_HANDLER()
László Monda
2017-10-03 20:43:26 +02:00
7061345ec2
Fix hard faults by moving slaveConfig and slaveHandle out of InitI2c(), thereby making them always available for KSDK. Fixed by @santiagogf89.
László Monda
2017-10-03 19:15:33 +02:00
90bad68287
No need to explicitly initialize slaves before starting up the scheduler as the scheduler takes care of them.
László Monda
2017-10-02 00:03:51 +02:00
f921753b63
Call slaveSchedulerCallback() instead of the update callback of the first slave to trigger the slave protocol scheduler. Given that the callback is involved from the start this should result in a more reliable startup state.
László Monda
2017-10-01 23:54:46 +02:00
724d72132a
Rearrange slave_command_t enum values a bit to reflect their relative importance and rearrange a related case block too.
László Monda
2017-10-01 22:21:00 +02:00
858586ef2a
Fix data size by using I2C_MESSAGE_MAX_TOTAL_LENGTH instead of I2C_MESSAGE_MAX_PAYLOAD_LENGTH.
László Monda
2017-10-01 22:12:00 +02:00
ecc2d2db9a
Use I2C_MESSAGE_HEADER_LENGTH instead of magic number.
László Monda
2017-10-01 22:08:38 +02:00
6edf4113a4
Make the slave check message integrity and only process if it's valid.
László Monda
2017-10-01 22:05:20 +02:00
1b1111e9da
Rename I2C_BUFFER_MAX_LENGTH to I2C_MESSAGE_MAX_TOTAL_LENGTH.
László Monda
2017-10-01 21:55:37 +02:00
b443b56357
Rename I2C_MESSAGE_MAX_LENGTH to I2C_MESSAGE_MAX_PAYLOAD_LENGTH.
László Monda
2017-10-01 21:52:41 +02:00
4ade25d739
Add I2C_MESSAGE_HEADER_LENGTH and use it in i2cSlaveCallback() instead of magic numbers.
László Monda
2017-10-01 21:42:55 +02:00
0ba979a658
Refactor i2cSlaveCallback().
László Monda
2017-10-01 21:38:02 +02:00
42e17ca1bf
Rename masterCallback to slaveSchedulerCallback.
László Monda
2017-10-01 03:15:25 +02:00
37cf632f2a
Reindent Slaves[] because its lines have gotten overly long.
László Monda
2017-10-01 02:53:42 +02:00
3079d527b1
Add uhk_slave_t.disconnect() callback so that upon disconnecting the left keyboard half, the left LED driver IC can be marked as disconnected too, so it'll be reinitialized upon reconnect. This usually didn't happen because LED states are cached so the LED drivers are rarely spoken to.
László Monda
2017-10-01 02:47:29 +02:00
320923b41c
Properly update uhk_slave_t.isConnected by introducing isFirstIteration.
László Monda
2017-10-01 01:39:12 +02:00
b49cb30070
Try to resurrect I2C not only in the watchdog but upon initialization. This may be useful when only the right half reboots after a firmware upgrade.
László Monda
2017-09-30 22:17:44 +02:00
894103a944
Disable the watchdog of the left half because for some reason it makes I2C recovery less reliable.
László Monda
2017-09-30 20:54:27 +02:00
b87042a44a
Resurrect the state machine of frozen IS31FL3731 ICs by toggling SCL and SDA.
László Monda
2017-09-30 20:34:35 +02:00
cec8bbfe01
Clone InitI2c() as InitI2cV2() and use it in the LPTMR interrupt handler to avoid the hard fault.
László Monda
2017-09-30 17:06:17 +02:00
3e5767e141
Use KEYBOARD_MATRIX_ROWS_NUM and KEYBOARD_MATRIX_COLS_NUM to compute MODULE_KEY_COUNT.
László Monda
2017-09-30 01:11:12 +02:00
ea71253d6a
Remove KEY_STATE_SIZE in favor of the more general BOOL_BYTES_TO_BITS_COUNT() macro.
László Monda
2017-09-30 00:57:10 +02:00
abc1923897
Rename LEFT_KEYBOARD_HALF_KEY_COUNT to MODULE_KEY_COUNT.
László Monda
2017-09-30 00:47:15 +02:00
c23d327384
Rename uhkModuleId to uhkModuleDriverId in UhkModuleSlaveDriver_Init() and UhkModuleSlaveDriver_Update()
László Monda
2017-09-30 00:40:13 +02:00
a7b0dfef1d
Compute slot id based on module driver id instead of using a hardcoded value.
László Monda
2017-09-30 00:23:34 +02:00
d8de4f0b3e
Update variable names.
László Monda
2017-09-30 00:18:37 +02:00
01ef8f59c2
Create separate sections of module driver phases.
László Monda
2017-09-30 00:14:29 +02:00
04047eb128
Make modules send their features (key count and whether they have pointer input) to the master upon enumeration.
László Monda
2017-09-30 00:08:28 +02:00
e7a1d27cde
Make private LED driver variables static.
László Monda
2017-09-29 15:22:52 +02:00
877cb78b0a
Extract LedDriverValues from LedDriverStates to make them public, and make LedDriverStates values private.
László Monda
2017-09-29 15:18:01 +02:00
fad17aeb32
Add example for switch-case.
László Monda
2017-09-29 02:26:01 +02:00
0624d088b6
Remove unused LED driver BUFFER_SIZE.
László Monda
2017-09-29 02:19:12 +02:00
1ab984413a
Extract ISO key related LED driver macros.
László Monda
2017-09-29 02:07:55 +02:00
92c0da9695
For the sake of correctness, only initialize the LED driver control register of the ISO key for the left LED driver IC.
László Monda
2017-09-29 01:53:08 +02:00
07142c3ce2
Fix coding style.
László Monda
2017-09-29 01:46:51 +02:00
81de51244a
Leave some breathing room in dense code blocks.
László Monda
2017-09-29 01:39:34 +02:00
2b6762d3e0
Indent cases inside switches.
László Monda
2017-09-29 01:35:25 +02:00
28f0cdd2c0
Use LED_BRIGHTNESS_LEVEL in led_display.c instead of magic values.
László Monda
2017-09-29 01:33:21 +02:00
eb2d7ada3a
Extract LED_BRIGHTNESS_LEVEL.
László Monda
2017-09-29 01:30:02 +02:00
76a80c3090
Inline SetLeds()
László Monda
2017-09-29 01:27:34 +02:00
67c4b413b4
Remove SetLeds() from slave_scheduler.h
László Monda
2017-09-29 01:21:49 +02:00
b42fc8b3f1
Remove module declarations that won't be used.
László Monda
2017-09-29 01:19:02 +02:00
8909bb6a16
Convert MODULE_ID_* macros to ModuleId_* enum values.
László Monda
2017-09-29 01:09:41 +02:00
d6254b6903
Extract I2C_WATCHDOG_INTERVAL_USEC.
László Monda
2017-09-29 01:01:29 +02:00
7313d8d87e
Fix the grammar of watchdog interrupt related comment and don't include specific timeout as it may change later.
László Monda
2017-09-29 00:58:52 +02:00
7d1cecc2b4
Move macros from i2c_watchdog.c to i2c_watchdog.h
László Monda
2017-09-29 00:54:57 +02:00
1889f78b98
Make previousSlaveId and currentSlaveId static.
László Monda
2017-09-29 00:52:43 +02:00
827ad7e08e
Rename BridgeCounter to I2cSchedulerCounter and move it to the top of masterCallback.
László Monda
2017-09-29 00:50:56 +02:00
508ef870ae
Rename I2C_Watchdog*Counter to I2cWatchdog_*Counter.
László Monda
2017-09-29 00:44:22 +02:00
69f3c86185
Rename UhkModuleId_* to UhkModuleDriverId_*.
László Monda
2017-09-28 23:26:58 +02:00