Browse Source

update

hardware_test_b
zhaohe 1 year ago
parent
commit
187144300d
  1. 8
      app/src/app_basic_service/device_version_info_mgr.c
  2. 16
      app/src/board/board.h
  3. 40
      app/src/one_conduction_main.c

8
app/src/app_basic_service/device_version_info_mgr.c

@ -15,7 +15,7 @@ static void fstorage_evt_handler(nrf_fstorage_evt_t *p_evt) {
switch (p_evt->id) {
case NRF_FSTORAGE_EVT_WRITE_RESULT: {
NRF_LOG_INFO("--> Event received: wrote %d bytes at address 0x%x. %x", p_evt->len, p_evt->addr,*(uint32_t*)p_evt->p_src);
NRF_LOG_INFO("--> Event received: wrote %d bytes at address 0x%x. %x", p_evt->len, p_evt->addr, *(uint32_t *)p_evt->p_src);
} break;
case NRF_FSTORAGE_EVT_ERASE_RESULT: {
@ -54,9 +54,9 @@ void device_info_read_sn(sn_t *sn) {
uint32_t id = NRF_UICR->CUSTOMER[1];
static char sn_str[15];
if ((lot == 0 && id == 0) || lot == 0xffffffff || id == 0xffffffff) {
sprintf(sn_str, "%s%04d%05d", CATEGORY, 0, 0);
sprintf(sn_str, "HandAcid%02d%03d", 0, 0);
} else {
sprintf(sn_str, "%s%04d%05d", CATEGORY, lot, id);
sprintf(sn_str, "HandAcid%02d%03d", lot, id);
}
memcpy(sn->sn, sn_str, sizeof(sn->sn));
@ -80,7 +80,7 @@ void device_info_write_active_flag(bool val) {
} else {
data = 0;
}
ret_code_t ecode = nrf_fstorage_write(&fstorage, fstorage.start_addr, &data, sizeof(data), NULL);
ret_code_t ecode = nrf_fstorage_write(&fstorage, fstorage.start_addr, &data, sizeof(data), NULL);
if (ecode != NRF_SUCCESS) {
NRF_LOG_INFO("write active flag failed");
}

16
app/src/board/board.h

@ -0,0 +1,16 @@
#pragma once
// P0.28 NRF_DBG_LED1
// P0.31 LEDR
// P0.30 LEDG
// P0.29 LEDB
// P0.15 KEY1
// P0.17 KEY2
// P0.05 BATADC Vadc=Vbat
#define NRF_DBG_LED1 28 // Debug LED
#define LEDR 31 // Tri-color LED High effective
#define LEDG 30 //
#define LEDB 29 //
#define ADD_ACID_KEY 15 // Add Acid Key Low effective
#define REVERSE_KEY 17 // Reverse Key Low effective
#define BATADC 5 // Battery Voltage Vadc=Vbat

40
app/src/one_conduction_main.c

@ -12,6 +12,7 @@
#include "zble_module.h"
//
#include "ble_data_processer_utils.h"
#include "board/board.h"
#include "nrf_fstorage.h"
#include "nrf_fstorage_sd.h"
@ -22,6 +23,26 @@
static bool m_poweron_flag;
static uint16_t m_capture_prepare_progress = 0;
static void testlight_state(int val) {
int effect = val % 3;
if (effect == 0) {
nrf_gpio_pin_write(LEDR, 1);
nrf_gpio_pin_write(LEDG, 0);
nrf_gpio_pin_write(LEDB, 0);
nrf_gpio_pin_write(NRF_DBG_LED1, 1);
} else if (effect == 1) {
nrf_gpio_pin_write(LEDR, 0);
nrf_gpio_pin_write(LEDG, 1);
nrf_gpio_pin_write(LEDB, 0);
nrf_gpio_pin_write(NRF_DBG_LED1, 0);
} else if (effect == 2) {
nrf_gpio_pin_write(LEDR, 0);
nrf_gpio_pin_write(LEDG, 0);
nrf_gpio_pin_write(LEDB, 1);
nrf_gpio_pin_write(NRF_DBG_LED1, 0);
}
}
/*******************************************************************************
* UTILS *
*******************************************************************************/
@ -72,7 +93,11 @@ static void process_on_disconnect(void* arg) { ZLOGI("ble disconnected"); }
void on_zapp_ebus_event(void* p_event_data, uint16_t event_size) {
if (!p_event_data) return;
app_event_t* p_event = (app_event_t*)p_event_data;
ZLOGI("event:%d", p_event->eventType)
ZLOGI("event:%d add_acid_key:%d reverse_key:%d", p_event->eventType, nrf_gpio_pin_read(ADD_ACID_KEY), nrf_gpio_pin_read(REVERSE_KEY));
static int cnt = 0;
cnt++;
testlight_state(cnt);
}
/***********************************************************************************************************************
@ -105,6 +130,19 @@ void one_conduction_main() {
zapp_state_machine_reg_state_change_listener(on_state_change);
zble_module_reglistener(on_zble_event);
// ADD_ACID_KEY
// REVERSE_KEY
nrf_gpio_cfg_input(ADD_ACID_KEY, NRF_GPIO_PIN_NOPULL);
nrf_gpio_cfg_input(REVERSE_KEY, NRF_GPIO_PIN_NOPULL);
nrf_gpio_cfg_output(LEDR);
nrf_gpio_cfg_output(LEDG);
nrf_gpio_cfg_output(LEDB);
nrf_gpio_cfg_output(NRF_DBG_LED1);
// adc_mgr_init();
// hardware_power_mgr_init();

Loading…
Cancel
Save