summaryrefslogtreecommitdiff
path: root/drivers/haptic/DRV2605L.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/haptic/DRV2605L.c')
-rw-r--r--drivers/haptic/DRV2605L.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/drivers/haptic/DRV2605L.c b/drivers/haptic/DRV2605L.c
index 728554b01e..5de2b354c9 100644
--- a/drivers/haptic/DRV2605L.c
+++ b/drivers/haptic/DRV2605L.c
@@ -21,8 +21,6 @@
#include <math.h>
uint8_t DRV2605L_transfer_buffer[2];
-uint8_t DRV2605L_tx_register[0];
-uint8_t DRV2605L_read_buffer[0];
uint8_t DRV2605L_read_register;
void DRV_write(uint8_t drv_register, uint8_t settings) {
@@ -32,16 +30,8 @@ void DRV_write(uint8_t drv_register, uint8_t settings) {
}
uint8_t DRV_read(uint8_t regaddress) {
-#ifdef __AVR__
- i2c_readReg(DRV2605L_BASE_ADDRESS << 1, regaddress, DRV2605L_read_buffer, 1, 100);
- DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0];
-#else
- DRV2605L_tx_register[0] = regaddress;
- if (MSG_OK != i2c_transmit_receive(DRV2605L_BASE_ADDRESS << 1, DRV2605L_tx_register, 1, DRV2605L_read_buffer, 1)) {
- printf("err reading reg \n");
- }
- DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0];
-#endif
+ i2c_readReg(DRV2605L_BASE_ADDRESS << 1, regaddress, &DRV2605L_read_register, 1, 100);
+
return DRV2605L_read_register;
}
@@ -115,18 +105,16 @@ void DRV_init(void) {
}
void DRV_rtp_init(void) {
- DRV_write(DRV_GO, 0x00);
- DRV_write(DRV_RTP_INPUT, 20); //20 is the lowest value I've found where haptics can still be felt.
- DRV_write(DRV_MODE, 0x05);
- DRV_write(DRV_GO, 0x01);
+ DRV_write(DRV_GO, 0x00);
+ DRV_write(DRV_RTP_INPUT, 20); // 20 is the lowest value I've found where haptics can still be felt.
+ DRV_write(DRV_MODE, 0x05);
+ DRV_write(DRV_GO, 0x01);
}
-void DRV_amplitude(uint8_t amplitude) {
- DRV_write(DRV_RTP_INPUT, amplitude);
-}
+void DRV_amplitude(uint8_t amplitude) { DRV_write(DRV_RTP_INPUT, amplitude); }
void DRV_pulse(uint8_t sequence) {
DRV_write(DRV_GO, 0x00);
DRV_write(DRV_WAVEFORM_SEQ_1, sequence);
DRV_write(DRV_GO, 0x01);
-} \ No newline at end of file
+}