| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#ifndef _I2C_H_ |
| 6 |
#define _I2C_H_ |
| 7 |
|
| 8 |
#include <stdint.h> |
| 9 |
#include <stdbool.h> |
| 10 |
|
| 11 |
#ifdef __cplusplus |
| 12 |
extern "C" { |
| 13 |
#endif |
| 14 |
|
| 15 |
#define I2C_DATA_MASK 1 |
| 16 |
#define I2C_CLK_MASK 2 |
| 17 |
|
| 18 |
typedef struct { |
| 19 |
int clk_in; |
| 20 |
int data_in; |
| 21 |
int data_out; |
| 22 |
} i2c_port_t; |
| 23 |
|
| 24 |
extern i2c_port_t i2c_port; |
| 25 |
|
| 26 |
void i2c_reset_state(); |
| 27 |
void i2c_step(); |
| 28 |
|
| 29 |
void i2c_kbd_buffer_add(uint8_t value); |
| 30 |
uint8_t i2c_kbd_buffer_next(); |
| 31 |
void i2c_kbd_buffer_flush(); |
| 32 |
uint8_t i2c_kbd_buffer_count(); |
| 33 |
|
| 34 |
void i2c_mse_buffer_add(uint8_t value); |
| 35 |
uint8_t i2c_mse_buffer_next(); |
| 36 |
void i2c_mse_buffer_flush(); |
| 37 |
uint8_t i2c_mse_buffer_count(); |
| 38 |
|
| 39 |
|
| 40 |
void mouse_button_down(int num); |
| 41 |
void mouse_button_up(int num); |
| 42 |
void mouse_move(int x, int y); |
| 43 |
uint8_t mouse_read(uint8_t reg); |
| 44 |
void mouse_send_state(void); |
| 45 |
void mouse_set_wheel(int8_t y); |
| 46 |
uint8_t mouse_get_device_id(); |
| 47 |
void mouse_set_device_id(uint8_t d); |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
typedef struct { |
| 59 |
int state; |
| 60 |
bool read_mode; |
| 61 |
uint8_t value; |
| 62 |
int count; |
| 63 |
uint8_t device; |
| 64 |
char device_name[8]; |
| 65 |
int clk_in; |
| 66 |
int data_in; |
| 67 |
int data_out; |
| 68 |
uint32_t transactions_started; |
| 69 |
uint32_t transactions_completed; |
| 70 |
uint32_t bytes_read; |
| 71 |
uint32_t bytes_written; |
| 72 |
uint8_t kbd_fill; |
| 73 |
uint8_t mse_fill; |
| 74 |
} i2c_debug_state_t; |
| 75 |
|
| 76 |
void i2c_debug_get_state(i2c_debug_state_t *out); |
| 77 |
|
| 78 |
#ifdef __cplusplus |
| 79 |
} |
| 80 |
#endif |
| 81 |
|
| 82 |
#endif |