mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-15 17:12:04 +00:00
fix(core): fix stwlc38 deinitialization
[no changelog]
This commit is contained in:
parent
2774fb19de
commit
66b8e2a311
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include <io/i2c_bus.h>
|
#include <io/i2c_bus.h>
|
||||||
#include <sys/irq.h>
|
#include <sys/irq.h>
|
||||||
#include <sys/systick.h>
|
|
||||||
#include <sys/systimer.h>
|
#include <sys/systimer.h>
|
||||||
|
|
||||||
#include "stwlc38.h"
|
#include "stwlc38.h"
|
||||||
@ -75,6 +74,10 @@ static void stwlc38_fsm_continue(stwlc38_driver_t *drv);
|
|||||||
void stwlc38_deinit(void) {
|
void stwlc38_deinit(void) {
|
||||||
stwlc38_driver_t *drv = &g_stwlc38_driver;
|
stwlc38_driver_t *drv = &g_stwlc38_driver;
|
||||||
|
|
||||||
|
NVIC_DisableIRQ(STWLC38_EXTI_INTERRUPT_NUM);
|
||||||
|
|
||||||
|
stwlc38_enable(false);
|
||||||
|
|
||||||
i2c_bus_close(drv->i2c_bus);
|
i2c_bus_close(drv->i2c_bus);
|
||||||
systimer_delete(drv->timer);
|
systimer_delete(drv->timer);
|
||||||
memset(drv, 0, sizeof(stwlc38_driver_t));
|
memset(drv, 0, sizeof(stwlc38_driver_t));
|
||||||
@ -320,6 +323,10 @@ void STWLC38_EXTI_INTERRUPT_HANDLER(void) {
|
|||||||
// Clear the EXTI line pending bit
|
// Clear the EXTI line pending bit
|
||||||
__HAL_GPIO_EXTI_CLEAR_FLAG(STWLC38_INT_PIN);
|
__HAL_GPIO_EXTI_CLEAR_FLAG(STWLC38_INT_PIN);
|
||||||
|
|
||||||
|
if (!drv->initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (drv->state == STWLC38_STATE_POWER_DOWN) {
|
if (drv->state == STWLC38_STATE_POWER_DOWN) {
|
||||||
// Inform the powerctl module about the WPC
|
// Inform the powerctl module about the WPC
|
||||||
// wakeup_flags_set(WAKEUP_FLAGS_WPC);
|
// wakeup_flags_set(WAKEUP_FLAGS_WPC);
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
* 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_STWLC38_H
|
#pragma once
|
||||||
#define TREZORHAL_STWLC38_H
|
|
||||||
|
|
||||||
#include <trezor_types.h>
|
#include <trezor_types.h>
|
||||||
|
|
||||||
@ -120,5 +119,3 @@ bool stwlc38_patch_and_config();
|
|||||||
|
|
||||||
// Gets the current report from the STWLC38
|
// Gets the current report from the STWLC38
|
||||||
bool stwlc38_get_report(stwlc38_report_t* status);
|
bool stwlc38_get_report(stwlc38_report_t* status);
|
||||||
|
|
||||||
#endif // TREZORHAL_STWLC38_H
|
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
* 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_STWLC38_DEFS_H
|
#pragma once
|
||||||
#define TREZORHAL_STWLC38_DEFS_H
|
|
||||||
|
|
||||||
// I2C address of the STWLC38 on the I2C bus.
|
// I2C address of the STWLC38 on the I2C bus.
|
||||||
#define STWLC38_I2C_ADDRESS 0x61
|
#define STWLC38_I2C_ADDRESS 0x61
|
||||||
@ -95,5 +94,3 @@
|
|||||||
#define STWLC38_ERR_INVALID_CHIP_ID 0x80000006U
|
#define STWLC38_ERR_INVALID_CHIP_ID 0x80000006U
|
||||||
#define STWLC38_ERR_NVM_ID_MISMATCH 0x80000007U
|
#define STWLC38_ERR_NVM_ID_MISMATCH 0x80000007U
|
||||||
#define STWLC38_ERR_NVM_DATA_CORRUPTED 0x80000008U
|
#define STWLC38_ERR_NVM_DATA_CORRUPTED 0x80000008U
|
||||||
|
|
||||||
#endif // TREZORHAL_STWLC38_DEFS_H
|
|
||||||
|
@ -18,8 +18,7 @@
|
|||||||
* 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_STWLC38_INTERNAL_H
|
#pragma once
|
||||||
#define TREZORHAL_STWLC38_INTERNAL_H
|
|
||||||
|
|
||||||
#include <io/i2c_bus.h>
|
#include <io/i2c_bus.h>
|
||||||
#include <trezor_types.h>
|
#include <trezor_types.h>
|
||||||
@ -99,5 +98,3 @@ typedef struct {
|
|||||||
extern stwlc38_driver_t g_stwlc38_driver;
|
extern stwlc38_driver_t g_stwlc38_driver;
|
||||||
|
|
||||||
#endif // KERNEL_MODE
|
#endif // KERNEL_MODE
|
||||||
|
|
||||||
#endif // TREZORHAL_STWLC38_INTERNAL_H
|
|
||||||
|
Loading…
Reference in New Issue
Block a user