Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding Hadron v3 #4462

Merged
merged 24 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
29bafc7
add initial support for hadron ver3
ishtob Oct 16, 2018
76370ba
add initial support for hadron ver3
ishtob Oct 16, 2018
1ace463
pull qwiic support for micro_led to be modified for use in hadron's 6…
ishtob Nov 9, 2018
0892ad5
initial work on OLED using qwiic driver
ishtob Nov 9, 2018
4a28ab0
early work to get 128x32 oled working by redefining qwiic micro oled …
ishtob Nov 10, 2018
4d84140
moved oled defines to config.h and added ifndef to micro_oled driver
ishtob Nov 10, 2018
46a0c6f
WORKING :D - note, still work in progress to get the start location c…
ishtob Nov 12, 2018
8225cf1
added equation to automatically calculate display offset based on scr…
ishtob Nov 14, 2018
8fc38f1
adding time-out timer to oled display
ishtob Nov 16, 2018
bb80ed4
changed read lock staus via read_led_state
ishtob Nov 19, 2018
611d902
lock indications fixes
ishtob Nov 19, 2018
aa8a869
Added scroll lock indication to oled
ishtob Nov 19, 2018
4462284
add support for DRV2605 haptic driver
ishtob Nov 22, 2018
ba8888d
Improve readabiity of DRV2605 driver.
ishtob Nov 22, 2018
51fd12c
Update keyboards/hadron/ver2/keymaps/default/config.h
drashna Nov 22, 2018
13339b5
Update keyboards/hadron/ver2/keymaps/default/config.h
drashna Nov 22, 2018
1dbda91
Update keyboards/hadron/ver2/keymaps/default/config.h
drashna Nov 22, 2018
de590e8
Update keyboards/hadron/ver2/keymaps/default/config.h
drashna Nov 22, 2018
fa1548e
Fixes for PR
ishtob Nov 22, 2018
ccd3a3d
PR fixes
ishtob Nov 22, 2018
7849d4f
fix old persistent layer function to use new set_single_persistent_de…
ishtob Nov 22, 2018
230bab7
fix issues with changing makefile defines that broken per-key haptic …
ishtob Nov 23, 2018
3ab2870
Comment fixes
ishtob Nov 24, 2018
6f738da
Add definable parameter and auto-calibration based on motor choice
ishtob Nov 25, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ ifeq ($(strip $(ENCODER_ENABLE)), yes)
OPT_DEFS += -DENCODER_ENABLE
endif

ifeq ($(strip $(HAPTIC_ENABLE)), yes)
ishtob marked this conversation as resolved.
Show resolved Hide resolved
COMMON_VPATH += $(DRIVER_PATH)/haptic
SRC += DRV2605L.c
OPT_DEFS += -DHAPTIC_ENABLE
endif

ifeq ($(strip $(HD44780_ENABLE)), yes)
SRC += drivers/avr/hd44780.c
OPT_DEFS += -DHD44780_ENABLE
Expand All @@ -240,6 +246,8 @@ ifeq ($(strip $(LEADER_ENABLE)), yes)
OPT_DEFS += -DLEADER_ENABLE
endif

include $(DRIVER_PATH)/qwiic/qwiic.mk
drashna marked this conversation as resolved.
Show resolved Hide resolved

QUANTUM_SRC:= \
$(QUANTUM_DIR)/quantum.c \
$(QUANTUM_DIR)/keymap_common.c \
Expand Down
12 changes: 8 additions & 4 deletions drivers/arm/i2c_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

static uint8_t i2c_address;

// This configures the I2C clock to 400Mhz assuming a 72Mhz clock
// This configures the I2C clock to 400khz assuming a 72Mhz clock
// For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html
static const I2CConfig i2cconfig = {
STM32_TIMINGR_PRESC(15U) |
Expand All @@ -45,10 +45,14 @@ static const I2CConfig i2cconfig = {
__attribute__ ((weak))
void i2c_init(void)
{
setPinInput(B6); // Try releasing special pins for a short time
setPinInput(B7);
chThdSleepMilliseconds(10);
//palSetGroupMode(GPIOB, GPIOB_PIN6 | GPIOB_PIN7, 0, PAL_MODE_INPUT);

// Try releasing special pins for a short time
palSetPadMode(GPIOB, 6, PAL_MODE_INPUT);
palSetPadMode(GPIOB, 7, PAL_MODE_INPUT);

chThdSleepMilliseconds(10);

palSetPadMode(GPIOB, 6, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);
palSetPadMode(GPIOB, 7, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);

Expand Down
1 change: 1 addition & 0 deletions drivers/arm/i2c_master.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void i2c_init(void);
uint8_t i2c_start(uint8_t address);
uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
uint8_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
uint8_t i2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length);
uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
uint8_t i2c_readReg(uint8_t devaddr, uint8_t* regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
uint8_t i2c_stop(uint16_t timeout);
68 changes: 68 additions & 0 deletions drivers/haptic/DRV2605L.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* Copyright 2018 ishtob
* Driver for DRV2605L written for QMK
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DRV2605L.h"
#include <stdlib.h>

uint8_t DRV2605L_transfer_buffer[20];

void DRV_write(uint8_t drv_register, uint8_t settings) {
DRV2605L_transfer_buffer[0] = drv_register;
DRV2605L_transfer_buffer[1] = settings;
i2c_transmit(DRV2605L_BASE_ADDRESS << 1, DRV2605L_transfer_buffer, 2, 100);
}

/*void DRV_read()
{
//TODO
} */

void DRV_init(void)
ishtob marked this conversation as resolved.
Show resolved Hide resolved
{
i2c_init();
i2c_start(DRV2605L_BASE_ADDRESS);

//0x07 sets DRV2605 into calibration mode
DRV_write(DRV_FEEDBACK_CTRL,0xB8);
//DRV_write(DRV_RATED_VOLT,);
//DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, );

DRV_write(DRV_MODE,0x07);

//0x00 sets DRV2605 out of standby and to use internal trigger
//0x01 sets DRV2605 out of standby and to use external trigger
DRV_write(DRV_MODE,0x00);

//0x06: LRA library
DRV_write(DRV_LIB_SELECTION,0x06);
DRV_write(DRV_WAVEFORM_SEQ_1, 0x01);

// 0xB9: LRA, 4x brake factor, medium gain, 7.5x back EMF
// 0x39: ERM, 4x brake factor, medium gain, 1.365x back EMF

//TODO: set rest of initiation


//Play seq x1 at end of initialization
DRV_write(DRV_GO, 0x01);
}

void DRV_pulse(uint8_t sequence)
{
DRV_write(DRV_GO, 0x00);
DRV_write(DRV_WAVEFORM_SEQ_1, sequence);
DRV_write(DRV_GO, 0x01);
}
63 changes: 63 additions & 0 deletions drivers/haptic/DRV2605L.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* Copyright 2018 ishtob
* Driver for DRV2605L written for QMK
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once
#include "i2c_master.h"

//register defines --------------------------------------------------------
#define DRV2605L_BASE_ADDRESS 0x5A //!< DRV2605L Base address
#define DRV_STATUS 0x00
#define DRV_MODE 0x01
#define DRV_RTP_INPUT 0x02
#define DRV_LIB_SELECTION 0x03
#define DRV_WAVEFORM_SEQ_1 0x04
#define DRV_WAVEFORM_SEQ_2 0x05
#define DRV_WAVEFORM_SEQ_3 0x06
#define DRV_WAVEFORM_SEQ_4 0x07
#define DRV_WAVEFORM_SEQ_5 0x08
#define DRV_WAVEFORM_SEQ_6 0x09
#define DRV_WAVEFORM_SEQ_7 0x0A
#define DRV_WAVEFORM_SEQ_8 0x0B
#define DRV_GO 0x0C
#define DRV_OVERDRIVE_TIME_OFFSET 0x0D
#define DRV_SUSTAIN_TIME_OFFSET_P 0x0E
#define DRV_SUSTAIN_TIME_OFFSET_N 0x0F
#define DRV_BRAKE_TIME_OFFSET 0x10
#define DRV_AUDIO_2_VIBE_CTRL 0x11
#define DRV_AUDIO_2_VIBE_MIN_IN 0x12
#define DRV_AUDIO_2_VIBE_MAX_IN 0x13
#define DRV_AUDIO_2_VIBE_MIN_OUTDRV 0x14
#define DRV_AUDIO_2_VIBE_MAX_OUTDRV 0x15
#define DRV_RATED_VOLT 0x16
#define DRV_OVERDRIVE_CLAMP_VOLT 0x17
#define DRV_AUTO_CALIB_COMP_RESULT 0x18
#define DRV_AUTO_CALIB_BEMF_RESULT 0x19
#define DRV_FEEDBACK_CTRL 0x1A
#define DRV_CTRL_1 0x1B
#define DRV_CTRL_2 0x1C
#define DRV_CTRL_3 0x1D
#define DRV_CTRL_4 0x1E
#define DRV_CTRL_5 0x1F
#define DRV_OPEN_LOOP_PERIOD 0x20
#define DRV_VBAT_VOLT_MONITOR 0x21
#define DRV_LRA_RESONANCE_PERIOD 0x22

void DRV_init(void);
void DRV_write(const uint8_t drv_register, const uint8_t settings);
//void DRV_read(const uint8_t drv_register, const uint8_t settings);
void DRV_pulse(const uint8_t sequence);

Loading