You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
2.7 KiB
103 lines
2.7 KiB
#include "one_conduction/one_conduction_main.h"
|
|
#include "three_conduction/three_conduction_main.h"
|
|
|
|
int main(void) { one_conduction_main(); }
|
|
|
|
#if 0
|
|
|
|
ZDATACHANNEL_DEF(m_zhrs, 2 /*回调事件优先级*/, 1 /*client num*/);
|
|
APP_TIMER_DEF(m_test_tx_timer);
|
|
|
|
static const char* hex2str(const uint8_t* data, int32_t len) {
|
|
static char rx[64] = {0};
|
|
memset(rx, 0, sizeof(rx));
|
|
for (int32_t i = 0; i < len; i++) {
|
|
sprintf(rx + i * 2, "%02X", data[i]);
|
|
}
|
|
return rx;
|
|
}
|
|
|
|
void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
|
|
/**
|
|
* @brief 接收到指令数据
|
|
*/
|
|
if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) {
|
|
ZLOGI("rx:%s", hex2str(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length));
|
|
}
|
|
}
|
|
|
|
static void ble_evt_handler(ble_evt_t const* p_ble_evt, void* p_context) {
|
|
switch (p_ble_evt->header.evt_id) {
|
|
case BLE_GAP_EVT_CONNECTED:
|
|
ZLOGI("Connected");
|
|
break;
|
|
|
|
case BLE_GAP_EVT_DISCONNECTED:
|
|
ZLOGI("Disconnected");
|
|
// zble_module_start_adv();
|
|
break;
|
|
}
|
|
}
|
|
|
|
void on_service_init(void) {
|
|
/**
|
|
* @brief 数据通道初始化
|
|
*/
|
|
ZLOGI("init zdatachannel service");
|
|
zdatachannel_init_t zdatachannle_init;
|
|
memset(&zdatachannle_init, 0, sizeof(zdatachannle_init));
|
|
zdatachannle_init.data_handler = zdatachannel_data_handler;
|
|
ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init));
|
|
}
|
|
|
|
static void test_tx_timer_cb(void* p_context) {
|
|
// static uint32_t data;
|
|
// uint16_t txlen = 4;
|
|
// data++;
|
|
// zdatachannel_data_send((uint8_t*)&data, &txlen);
|
|
|
|
// ZLOGI("adc channel %d %d", adc_module_heart_elect_channel_read_val(), adc_module_battery_channel_read_val());
|
|
ZLOGI("test_tx_timer_cb");
|
|
NVIC_SystemReset();
|
|
// board_spi_transfer_test();
|
|
// uint8_t data[] = {0xAA, 0xBB};
|
|
// board_i2c_write(0x3C, data, 2);
|
|
// fatfs_test_write();
|
|
}
|
|
|
|
static void board_init() {
|
|
// adc_module_init();
|
|
// adc_module_battery_channel_init(NRF_SAADC_INPUT_VDD);
|
|
// adc_module_heart_elect_channel_init(NRF_SAADC_INPUT_AIN2);
|
|
|
|
// board_spi_init();
|
|
// board_i2c_init();
|
|
}
|
|
|
|
int main(void) {
|
|
zsys_init();
|
|
NRF_LOG_INFO("compile time :%s", __TIME__);
|
|
NRF_LOG_INFO("Version :%d", VERSION);
|
|
NRF_LOG_INFO("Manufacturer :%s", MANUFACTURER_NAME);
|
|
|
|
static zble_module_cfg_t cfg = //
|
|
{
|
|
.deviceName = "iflytop_test_ble",
|
|
.on_service_init = on_service_init,
|
|
};
|
|
zble_module_init(&cfg);
|
|
board_init();
|
|
// fatfs_init();
|
|
|
|
NRF_SDH_BLE_OBSERVER(m_ble_observer, 3, ble_evt_handler, NULL);
|
|
|
|
// ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
|
|
// ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
|
|
|
|
// pwm_trigger();
|
|
// wd_init();
|
|
|
|
zble_module_start_adv();
|
|
zsys_loop();
|
|
}
|
|
#endif
|