Browse Source

eeprom ok

3lead_uart_test_ok_version
zhaohe 1 year ago
parent
commit
a4e46a669a
  1. 26
      app/main.c
  2. 22
      app/src/one_conduction/one_conduction_board.c
  3. 2
      sdk

26
app/main.c

@ -43,11 +43,24 @@ void main() {
#endif
// EEPROM_TEST
#if 0
#if 1
static void test_tx_timer_cb(void* p_context) {
static uint32_t data;
data++;
// ZLOGI("test_tx_timer_cb %d", data);
static uint8_t eepromw_test_data[256];
static uint8_t eepromw_rx_data[256];
for (size_t i = 0; i < 256; i++) {
eepromw_test_data[i] = i;
}
// SingleLeadECG_eeprom_write(0, eepromw_test_data, 256);
SingleLeadECG_eeprom_read(0, eepromw_rx_data, 256);
// for (size_t i = 0; i < 256; i++) {
// ZLOGI("eepromw_rx_data[%d] = %d", i, eepromw_rx_data[i]);
// NRF_LOG_INTERNAL_FLUSH();
// }
}
extern uint32_t g_nrf_log_tx_pin;
@ -60,15 +73,10 @@ void main() {
// SingleLeadECG_beep_init();
// SingleLeadECG_beep_set_state(false);
NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
NRF_LOG_INTERNAL_FLUSH();
NRF_LOG_INTERNAL_FLUSH();
SingleLeadECG_eeprom_init();
static uint8_t eepromw_test_data[256];
static uint8_t eepromw_rx_data[256];
for (size_t i = 0; i < 256; i++) {
eepromw_test_data[i] = i;
}
SingleLeadECG_eeprom_write(0, eepromw_test_data, 256);
// nrf_delay_ms(20);
// SingleLeadECG_eeprom_read(0, eepromw_rx_data, 256);
// for (size_t i = 0; i < 256; i++) {
@ -125,7 +133,7 @@ void main() {
* ECG *
*******************************************************************************/
#if 1
#if 0
#define UART_TX_BUF_SIZE 256 /**< UART TX buffer size. */
#define UART_RX_BUF_SIZE 256 /**< UART RX buffer size. */
uint32_t err_code;

22
app/src/one_conduction/one_conduction_board.c

@ -204,13 +204,18 @@ int16_t SingleLeadECG_battery_get_adc_val() {
static const nrf_drv_twi_t m_eeprom_twi_master = NRF_DRV_TWI_INSTANCE(EEPROM_I2C_INSTANCE);
void SingleLeadECG_eeprom_init() {
const nrf_drv_twi_config_t config = {
.scl = EEPROM_I2C_SCL_M,
.sda = EEPROM_I2C_SDA_M,
.frequency = NRF_DRV_TWI_FREQ_100K,
.interrupt_priority = APP_IRQ_PRIORITY_HIGH,
.clear_bus_init = false,
};
nrf_drv_twi_config_t config = NRF_DRV_TWI_DEFAULT_CONFIG;
config.scl = EEPROM_I2C_SCL_M;
config.sda = EEPROM_I2C_SDA_M;
config.frequency = NRF_DRV_TWI_FREQ_100K;
// {
// .scl = EEPROM_I2C_SCL_M,
// .sda = EEPROM_I2C_SDA_M,
// .frequency = NRF_DRV_TWI_FREQ_100K,
// .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
// .clear_bus_init = false,
// };
ZERROR_CHECK(nrf_drv_twi_init(&m_eeprom_twi_master, &config, NULL, NULL));
nrf_drv_twi_enable(&m_eeprom_twi_master);
@ -233,8 +238,8 @@ static void assign_i2c_add(uint32_t add, bool wr, uint8_t *i2cadd, uint8_t *mema
*i2cadd = 0xA0;
uint8_t a16a17 = (add >> 16) & 0x03;
*i2cadd |= a16a17 << 1;
*i2cadd = *i2cadd >>1;
*i2cadd = wr ? *i2cadd & 0xFE : *i2cadd | 0x01;
*memadd0 = add >> 8;
*memadd1 = add & 0xFF;
@ -246,6 +251,7 @@ void SingleLeadECG_eeprom_write(uint16_t page, uint8_t *data, uint16_t len) { /
uint8_t deviceSelect = 0;
assign_i2c_add(addr, true, &deviceSelect, &eeprom_cache[0], &eeprom_cache[1]);
memcpy(&eeprom_cache[2], data, len);
ret_code_t ecode = nrf_drv_twi_tx(&m_eeprom_twi_master, deviceSelect, eeprom_cache, len + 2, false);
if (ecode != NRF_SUCCESS) {
ZLOGE("nrf_drv_twi_tx error %x", ecode);

2
sdk

@ -1 +1 @@
Subproject commit f744df9ff76d9a7a4b3739dfb571f1b3f82312ae
Subproject commit 891e025a95a79080ca47af7cb4daa2392c877cc0
Loading…
Cancel
Save