diff options
author | Jason <jagor@microsoft.com> | 2018-06-05 12:43:20 -0700 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2018-06-05 12:43:20 -0700 |
commit | 96546c79c0e931c89e4ac60a154b669925d5d34d (patch) | |
tree | 82577992a3c9fcb312b8872016a5bae40b36ceb2 /keyboards/sx60/sx60.c | |
parent | 1ae011d91902c8a12e23ee5f1f934ac5a0238b87 (diff) |
Adding SX60 work by amnobis and configurator settings (#3122)
* Add SX60
* Add config maps and layouts as well as readmes.
* cleanup and fixes
* correct readme
* add missing closing commenty tag
* Changing includes to QMK_KEYBOARD_H
* Update settings.json
Remove config change that was added automatically by vscode.
* Update readme.md
fix readme formatting
Diffstat (limited to 'keyboards/sx60/sx60.c')
-rwxr-xr-x | keyboards/sx60/sx60.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/keyboards/sx60/sx60.c b/keyboards/sx60/sx60.c new file mode 100755 index 0000000000..ede8c07e97 --- /dev/null +++ b/keyboards/sx60/sx60.c @@ -0,0 +1,38 @@ +#include "sx60.h" +#include "i2cmaster.h" + + +bool i2c_initialized = 0; +uint8_t mcp23018_status = 0x20; + +uint8_t init_mcp23018(void) { + mcp23018_status = 0x20; + + /* I2C subsystem */ + + if (i2c_initialized == 0) { + i2c_init(); // on pins D(1,0) + i2c_initialized = true; + _delay_ms(1000); + } + + /* B Pins are Row, A pins are Columns + Set them to output */ + mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(IODIRA); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b11111111); if (mcp23018_status) goto out; + /* Now write to IODIRB */ + mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out; + i2c_stop(); + + mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(GPPUA); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b11111111); if (mcp23018_status) goto out; + /* Now write to GPPUB */ + mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out; + +out: + i2c_stop(); + + return mcp23018_status; +} |