fix: BLE TX 먹통 해결 및 메모리 안전성 개선

- binary_tx_handler를 dr_binary_tx_safe로 전체 교체 (APP_ERROR_CHECK 제거)
- data_tx_handler APP_ERROR_CHECK → DBG_PRINTF 교체
- memset/memcpy 하드코딩 크기를 define 상수로 교체 (버퍼 오버런 수정)
- SERIAL_NO_LENGTH, HW_NO_LENGTH, PASSKEY_LENGTH를 main.h로 통합
- 미사용 HW 드라이버/EEPROM 코드 삭제, TWI를 i2c_manager.c로 통합
- EEPROM → FDS 전환, 코드 리뷰 현황 문서 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-16 16:39:26 +09:00
parent 836ebe5878
commit a1ad2a4b5b
76 changed files with 43253 additions and 16370 deletions

View File

@@ -7,14 +7,41 @@
#include "debug_print.h"
#include "nrf_delay.h"
#include "mcp4725_i2c.h"
#include "nrf_drv_twi.h"
#include "cat_interface.h"
#include "nrfx_twi.h"
#include "boards.h"
#include "system_interface.h"
bool HW_I2C_FRQ = true;
bool SW_I2C_FRQ = false;
/* 외부 EEPROM TWI 인스턴스 */
extern const nrf_drv_twi_t m_eeprom;
#define TWI_INSTANCE 0
/* TWI (I2C) 하드웨어 인스턴스 : IMU 드라이버에서 사용 - jhChun 26.03.16 */
const nrfx_twi_t m_twi = NRFX_TWI_INSTANCE(TWI_INSTANCE);
/* TWI (I2C) 해제 - jhChun 26.03.16 */
static void twi_uninitialize(void){
nrfx_twi_disable(&m_twi);
nrfx_twi_uninit(&m_twi);
}
/* TWI (I2C) 하드웨어 초기화 (SCL/SDA핀, 400kHz) - jhChun 26.03.16 */
static void twi_initialize(void){
ret_code_t err_code;
const nrfx_twi_config_t twi_config = {
.scl = ICM42670_I2C_SCL_PIN,
.sda = ICM42670_I2C_SDA_PIN,
.frequency = NRF_TWI_FREQ_400K,
.interrupt_priority = APP_IRQ_PRIORITY_HIGH,
};
err_code = nrfx_twi_init(&m_twi, &twi_config, NULL, NULL);
APP_ERROR_CHECK(err_code);
nrfx_twi_enable(&m_twi);
}
/* -------------------------------------------------------------------------- */
/* HW (TWI) 초기화 */
@@ -39,7 +66,7 @@ void hw_i2c_init_once(void)
}
// 실제 HW 초기화
eeprom_initialize();
twi_initialize();
nrf_delay_ms(2);
HW_I2C_FRQ = true;
@@ -58,8 +85,8 @@ void sw_i2c_init_once(void)
{
//DBG_PRINTF("[I2C]HW→SW\r\n");
nrf_drv_twi_disable(&m_eeprom);
nrf_drv_twi_uninit(&m_eeprom);
nrfx_twi_disable(&m_twi);
nrfx_twi_uninit(&m_twi);
nrf_delay_ms(2);
HW_I2C_FRQ = false;
@@ -73,9 +100,8 @@ void sw_i2c_init_once(void)
}
// 실제 SW 초기화
eeprom_uninitialize(); // TWI 라인 해제
twi_uninitialize(); // TWI 라인 해제
nrf_delay_ms(1);
mcp4725_init(); // Port BangBang 방식 DAC init
SW_I2C_FRQ = true;
HW_I2C_FRQ = false;