diff options
Diffstat (limited to 'drivers/sensors/adns5050.c')
| -rw-r--r-- | drivers/sensors/adns5050.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/drivers/sensors/adns5050.c b/drivers/sensors/adns5050.c index e7273977d..254ef2ee8 100644 --- a/drivers/sensors/adns5050.c +++ b/drivers/sensors/adns5050.c | |||
| @@ -17,7 +17,6 @@ | |||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | |||
| 21 | #include "adns5050.h" | 20 | #include "adns5050.h" |
| 22 | #include "wait.h" | 21 | #include "wait.h" |
| 23 | #include "debug.h" | 22 | #include "debug.h" |
| @@ -61,13 +60,9 @@ void adns_sync(void) { | |||
| 61 | writePinHigh(ADNS_CS_PIN); | 60 | writePinHigh(ADNS_CS_PIN); |
| 62 | } | 61 | } |
| 63 | 62 | ||
| 64 | void adns_cs_select(void) { | 63 | void adns_cs_select(void) { writePinLow(ADNS_CS_PIN); } |
| 65 | writePinLow(ADNS_CS_PIN); | ||
| 66 | } | ||
| 67 | 64 | ||
| 68 | void adns_cs_deselect(void) { | 65 | void adns_cs_deselect(void) { writePinHigh(ADNS_CS_PIN); } |
| 69 | writePinHigh(ADNS_CS_PIN); | ||
| 70 | } | ||
| 71 | 66 | ||
| 72 | uint8_t adns_serial_read(void) { | 67 | uint8_t adns_serial_read(void) { |
| 73 | setPinInput(ADNS_SDIO_PIN); | 68 | setPinInput(ADNS_SDIO_PIN); |
| @@ -121,7 +116,7 @@ uint8_t adns_read_reg(uint8_t reg_addr) { | |||
| 121 | // We don't need a minimum tSRAD here. That's because a 4ms wait time is | 116 | // We don't need a minimum tSRAD here. That's because a 4ms wait time is |
| 122 | // already included in adns_serial_write(), so we're good. | 117 | // already included in adns_serial_write(), so we're good. |
| 123 | // See page 10 and 15 of the ADNS spec sheet. | 118 | // See page 10 and 15 of the ADNS spec sheet. |
| 124 | //wait_us(4); | 119 | // wait_us(4); |
| 125 | 120 | ||
| 126 | uint8_t byte = adns_serial_read(); | 121 | uint8_t byte = adns_serial_read(); |
| 127 | 122 | ||
| @@ -138,7 +133,7 @@ uint8_t adns_read_reg(uint8_t reg_addr) { | |||
| 138 | 133 | ||
| 139 | void adns_write_reg(uint8_t reg_addr, uint8_t data) { | 134 | void adns_write_reg(uint8_t reg_addr, uint8_t data) { |
| 140 | adns_cs_select(); | 135 | adns_cs_select(); |
| 141 | adns_serial_write( 0b10000000 | reg_addr ); | 136 | adns_serial_write(0b10000000 | reg_addr); |
| 142 | adns_serial_write(data); | 137 | adns_serial_write(data); |
| 143 | adns_cs_deselect(); | 138 | adns_cs_deselect(); |
| 144 | } | 139 | } |
| @@ -155,7 +150,7 @@ report_adns_t adns_read_burst(void) { | |||
| 155 | // We don't need a minimum tSRAD here. That's because a 4ms wait time is | 150 | // We don't need a minimum tSRAD here. That's because a 4ms wait time is |
| 156 | // already included in adns_serial_write(), so we're good. | 151 | // already included in adns_serial_write(), so we're good. |
| 157 | // See page 10 and 15 of the ADNS spec sheet. | 152 | // See page 10 and 15 of the ADNS spec sheet. |
| 158 | //wait_us(4); | 153 | // wait_us(4); |
| 159 | 154 | ||
| 160 | uint8_t x = adns_serial_read(); | 155 | uint8_t x = adns_serial_read(); |
| 161 | uint8_t y = adns_serial_read(); | 156 | uint8_t y = adns_serial_read(); |
| @@ -180,13 +175,11 @@ int8_t convert_twoscomp(uint8_t data) { | |||
| 180 | } | 175 | } |
| 181 | 176 | ||
| 182 | // Don't forget to use the definitions for CPI in the header file. | 177 | // Don't forget to use the definitions for CPI in the header file. |
| 183 | void adns_set_cpi(uint8_t cpi) { | 178 | void adns_set_cpi(uint8_t cpi) { adns_write_reg(REG_MOUSE_CONTROL2, cpi); } |
| 184 | adns_write_reg(REG_MOUSE_CONTROL2, cpi); | ||
| 185 | } | ||
| 186 | 179 | ||
| 187 | bool adns_check_signature(void) { | 180 | bool adns_check_signature(void) { |
| 188 | uint8_t pid = adns_read_reg(REG_PRODUCT_ID); | 181 | uint8_t pid = adns_read_reg(REG_PRODUCT_ID); |
| 189 | uint8_t rid = adns_read_reg(REG_REVISION_ID); | 182 | uint8_t rid = adns_read_reg(REG_REVISION_ID); |
| 190 | uint8_t pid2 = adns_read_reg(REG_PRODUCT_ID2); | 183 | uint8_t pid2 = adns_read_reg(REG_PRODUCT_ID2); |
| 191 | 184 | ||
| 192 | return (pid == 0x12 && rid == 0x01 && pid2 == 0x26); | 185 | return (pid == 0x12 && rid == 0x01 && pid2 == 0x26); |
