diff options
| author | Mikkel Jeppesen <2756925+Duckle29@users.noreply.github.com> | 2018-05-09 18:14:30 +0200 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2018-05-09 09:14:30 -0700 |
| commit | 00596d55e34c003d55a530366bedfb2ea467bedc (patch) | |
| tree | 95e02d77026987b9c34da8b7740f6d8dea5ba840 /keyboards/vitamins_included/i2c.h | |
| parent | 749916e6e233f66b554925f120c29e2ce353e90e (diff) | |
| download | qmk_firmware-00596d55e34c003d55a530366bedfb2ea467bedc.tar.gz qmk_firmware-00596d55e34c003d55a530366bedfb2ea467bedc.zip | |
Added propper support for Lets split vitamins (#2559)
* Added support for the upcomming Lets_split vitamins included
* Updated readme
* Corrected header of readme
* Enabled RGB
* Broke everything
* broke some more shit
* Revert "broke some more shit"
This reverts commit 6ad68e6269cc0d04c16564ce9598dfd3db1e23c1.
* Revert "Broke everything"
This reverts commit feeee4e40db15a726f2292b6a9406ef45c1e54a7.
* Fixed USB detection, and RGB on slave
* started modifying readme, to use msys2
* Added support for the upcomming Lets_split vitamins included
* Updated readme
* Corrected header of readme
* Enabled RGB
* Broke everything
* broke some more shit
* Revert "broke some more shit"
This reverts commit 6ad68e6269cc0d04c16564ce9598dfd3db1e23c1.
* Revert "Broke everything"
This reverts commit feeee4e40db15a726f2292b6a9406ef45c1e54a7.
* Fixed USB detection, and RGB on slave
* started modifying readme, to use msys2
* Updated readme to reflect use of msys2 Added avrdude to msys path
* added avrdude option to msys installer
* Removed extra installation of avrdude
* Renamed to vitamins_included and implemented drashnas changes
* Fixed include guard
* Fixed some includes, and added avrdude target to docs.
* Fixed default keyboard
Diffstat (limited to 'keyboards/vitamins_included/i2c.h')
| -rw-r--r-- | keyboards/vitamins_included/i2c.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/keyboards/vitamins_included/i2c.h b/keyboards/vitamins_included/i2c.h new file mode 100644 index 000000000..739d134be --- /dev/null +++ b/keyboards/vitamins_included/i2c.h | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | #ifndef I2C_H | ||
| 2 | #define I2C_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | #include "split_util.h" | ||
| 6 | |||
| 7 | #ifndef F_CPU | ||
| 8 | #define F_CPU 16000000UL | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #define I2C_READ 1 | ||
| 12 | #define I2C_WRITE 0 | ||
| 13 | |||
| 14 | #define I2C_ACK 1 | ||
| 15 | #define I2C_NACK 0 | ||
| 16 | |||
| 17 | #define SLAVE_BUFFER_SIZE 0x10 | ||
| 18 | |||
| 19 | // i2c SCL clock frequency | ||
| 20 | #define SCL_CLOCK 400000L | ||
| 21 | |||
| 22 | extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
| 23 | |||
| 24 | void i2c_master_init(void); | ||
| 25 | uint8_t i2c_master_start(uint8_t address); | ||
| 26 | void i2c_master_stop(void); | ||
| 27 | uint8_t i2c_master_write(uint8_t data); | ||
| 28 | uint8_t i2c_master_read(int); | ||
| 29 | void i2c_reset_state(void); | ||
| 30 | void i2c_slave_init(uint8_t address); | ||
| 31 | |||
| 32 | |||
| 33 | static inline unsigned char i2c_start_read(unsigned char addr) { | ||
| 34 | return i2c_master_start((addr << 1) | I2C_READ); | ||
| 35 | } | ||
| 36 | |||
| 37 | static inline unsigned char i2c_start_write(unsigned char addr) { | ||
| 38 | return i2c_master_start((addr << 1) | I2C_WRITE); | ||
| 39 | } | ||
| 40 | |||
| 41 | // from SSD1306 scrips | ||
| 42 | extern unsigned char i2c_rep_start(unsigned char addr); | ||
| 43 | extern void i2c_start_wait(unsigned char addr); | ||
| 44 | extern unsigned char i2c_readAck(void); | ||
| 45 | extern unsigned char i2c_readNak(void); | ||
| 46 | extern unsigned char i2c_read(unsigned char ack); | ||
| 47 | |||
| 48 | #define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); | ||
| 49 | |||
| 50 | #endif | ||
