mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-31 01:41:18 +00:00
feat(core): set haptic actuator for T3W1
[no changelog]
This commit is contained in:
parent
4ad326aa73
commit
b75c0a844d
37
core/embed/io/haptic/drv2625/actuators/ld0625bc.h
Normal file
37
core/embed/io/haptic/drv2625/actuators/ld0625bc.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Trezor project, https://trezor.io/
|
||||||
|
*
|
||||||
|
* Copyright (c) SatoshiLabs
|
||||||
|
*
|
||||||
|
* 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 3 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
|
||||||
|
|
||||||
|
#define ACTUATOR_LRA
|
||||||
|
#define ACTUATOR_CLOSED_LOOP
|
||||||
|
|
||||||
|
#define ACTUATOR_FREQUENCY (260)
|
||||||
|
#define ACTUATOR_VOLTAGE (0.7)
|
||||||
|
|
||||||
|
#define ACTUATOR_LRA_PERIOD ((int)((1000000 / ACTUATOR_FREQUENCY) / 24.615))
|
||||||
|
|
||||||
|
// open-loop mode
|
||||||
|
// V = 21.32 * 10^(-3) * OD_CLAMP * sqrt(1 - fLRA * 800 * 10^(-6))
|
||||||
|
#define ACTUATOR_OD_CLAMP (37)
|
||||||
|
|
||||||
|
// closed-loop mode
|
||||||
|
// V = (20.58 * 10^(-3) * RATED_VOLTAGE) / sqrt (1 - (4 * tSAMPLE_TIME + 300 *
|
||||||
|
// 10^(-6)) * fLRA) where tSAMPLE_TIME = 300us, by default
|
||||||
|
#define ACTUATOR_RATED_VOLTAGE (27)
|
@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Trezor project, https://trezor.io/
|
||||||
|
*
|
||||||
|
* Copyright (c) SatoshiLabs
|
||||||
|
*
|
||||||
|
* 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 3 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
|
||||||
|
|
||||||
#define ACTUATOR_LRA
|
#define ACTUATOR_LRA
|
||||||
#define ACTUATOR_OPEN_LOOP
|
#define ACTUATOR_OPEN_LOOP
|
||||||
|
@ -150,10 +150,17 @@ bool haptic_init(void) {
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ACTUATOR_OPEN_LOOP
|
||||||
if (!drv2625_set_reg(driver->i2c_bus, DRV2625_REG_OD_CLAMP,
|
if (!drv2625_set_reg(driver->i2c_bus, DRV2625_REG_OD_CLAMP,
|
||||||
ACTUATOR_OD_CLAMP)) {
|
ACTUATOR_OD_CLAMP)) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
#elif defined ACTUATOR_CLOSED_LOOP
|
||||||
|
if (!drv2625_set_reg(driver->i2c_bus, DRV2625_REG_RATED_VOLTAGE,
|
||||||
|
ACTUATOR_RATED_VOLTAGE)) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!drv2625_set_reg(driver->i2c_bus, DRV2625_REG_LRA_WAVE_SHAPE,
|
if (!drv2625_set_reg(driver->i2c_bus, DRV2625_REG_LRA_WAVE_SHAPE,
|
||||||
DRV2625_REG_LRA_WAVE_SHAPE_SINE)) {
|
DRV2625_REG_LRA_WAVE_SHAPE_SINE)) {
|
||||||
|
@ -1,5 +1,23 @@
|
|||||||
#ifndef TREZOR_HAL_DRV_2625_H
|
/*
|
||||||
#define TREZOR_HAL_DRV_2625_H
|
* This file is part of the Trezor project, https://trezor.io/
|
||||||
|
*
|
||||||
|
* Copyright (c) SatoshiLabs
|
||||||
|
*
|
||||||
|
* 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 3 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
|
||||||
|
|
||||||
// I2C address of the DRV2625 on the I2C bus.
|
// I2C address of the DRV2625 on the I2C bus.
|
||||||
#define DRV2625_I2C_ADDRESS 0x5A
|
#define DRV2625_I2C_ADDRESS 0x5A
|
||||||
@ -47,6 +65,7 @@
|
|||||||
#define DRV2625_REG_GO_GO 0x01
|
#define DRV2625_REG_GO_GO 0x01
|
||||||
|
|
||||||
#define DRV2625_REG_OD_CLAMP 0x20
|
#define DRV2625_REG_OD_CLAMP 0x20
|
||||||
|
#define DRV2625_REG_RATED_VOLTAGE 0x20
|
||||||
|
|
||||||
#define DRV2625_REG_LRA_WAVE_SHAPE 0x2C
|
#define DRV2625_REG_LRA_WAVE_SHAPE 0x2C
|
||||||
#define DRV2625_REG_LRA_WAVE_SHAPE_SINE 0x01
|
#define DRV2625_REG_LRA_WAVE_SHAPE_SINE 0x01
|
||||||
@ -183,5 +202,3 @@ typedef enum {
|
|||||||
SMOOTH_HUM_4_40 = 122,
|
SMOOTH_HUM_4_40 = 122,
|
||||||
SMOOTH_HUM_5_20 = 123,
|
SMOOTH_HUM_5_20 = 123,
|
||||||
} drv2625_lib_effect_t;
|
} drv2625_lib_effect_t;
|
||||||
|
|
||||||
#endif // TREZOR_HAL_DRV_2625_H
|
|
||||||
|
@ -17,15 +17,14 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TREZORHAL_HAPTIC_H
|
#pragma once
|
||||||
#define TREZORHAL_HAPTIC_H
|
|
||||||
|
|
||||||
#include <trezor_types.h>
|
#include <trezor_types.h>
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
// Effect at the start of a button press
|
// Effect at the start of a button press
|
||||||
HAPTIC_BUTTON_PRESS = 0,
|
HAPTIC_BUTTON_PRESS = 0,
|
||||||
// Effect at the and of hold-to-confirm action
|
// Effect at the end of hold-to-confirm action
|
||||||
HAPTIC_HOLD_TO_CONFIRM = 1,
|
HAPTIC_HOLD_TO_CONFIRM = 1,
|
||||||
} haptic_effect_t;
|
} haptic_effect_t;
|
||||||
|
|
||||||
@ -86,5 +85,3 @@ bool haptic_play(haptic_effect_t effect);
|
|||||||
//
|
//
|
||||||
// Returns `true` if the effect was successfully started.
|
// Returns `true` if the effect was successfully started.
|
||||||
bool haptic_play_custom(int8_t amplitude_pct, uint16_t duration_ms);
|
bool haptic_play_custom(int8_t amplitude_pct, uint16_t duration_ms);
|
||||||
|
|
||||||
#endif // TREZORHAL_HAPTIC_H
|
|
||||||
|
@ -121,7 +121,7 @@
|
|||||||
#define TOUCH_INT_PIN GPIO_PIN_3
|
#define TOUCH_INT_PIN GPIO_PIN_3
|
||||||
|
|
||||||
#define DRV2625_I2C_INSTANCE 2
|
#define DRV2625_I2C_INSTANCE 2
|
||||||
#define HAPTIC_ACTUATOR "actuators/vg1040003d.h"
|
#define HAPTIC_ACTUATOR "actuators/ld0625bc.h"
|
||||||
#define DRV2625_TRIG_PIN GPIO_PIN_2
|
#define DRV2625_TRIG_PIN GPIO_PIN_2
|
||||||
#define DRV2625_TRIG_PORT GPIOA
|
#define DRV2625_TRIG_PORT GPIOA
|
||||||
#define DRV2625_TRIG_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE
|
#define DRV2625_TRIG_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE
|
||||||
|
@ -120,7 +120,7 @@
|
|||||||
#define TOUCH_INT_PIN GPIO_PIN_3
|
#define TOUCH_INT_PIN GPIO_PIN_3
|
||||||
|
|
||||||
#define DRV2625_I2C_INSTANCE 2
|
#define DRV2625_I2C_INSTANCE 2
|
||||||
#define HAPTIC_ACTUATOR "actuators/vg1040003d.h"
|
#define HAPTIC_ACTUATOR "actuators/ld0625bc.h"
|
||||||
#define DRV2625_TRIG_PIN GPIO_PIN_2
|
#define DRV2625_TRIG_PIN GPIO_PIN_2
|
||||||
#define DRV2625_TRIG_PORT GPIOA
|
#define DRV2625_TRIG_PORT GPIOA
|
||||||
#define DRV2625_TRIG_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE
|
#define DRV2625_TRIG_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE
|
||||||
|
@ -121,7 +121,7 @@
|
|||||||
#define TOUCH_INT_PIN GPIO_PIN_3
|
#define TOUCH_INT_PIN GPIO_PIN_3
|
||||||
|
|
||||||
#define DRV2625_I2C_INSTANCE 2
|
#define DRV2625_I2C_INSTANCE 2
|
||||||
#define HAPTIC_ACTUATOR "actuators/vg1040003d.h"
|
#define HAPTIC_ACTUATOR "actuators/ld0625bc.h"
|
||||||
#define DRV2625_TRIG_PIN GPIO_PIN_2
|
#define DRV2625_TRIG_PIN GPIO_PIN_2
|
||||||
#define DRV2625_TRIG_PORT GPIOA
|
#define DRV2625_TRIG_PORT GPIOA
|
||||||
#define DRV2625_TRIG_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE
|
#define DRV2625_TRIG_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE
|
||||||
|
Loading…
Reference in New Issue
Block a user