From a23b49e2d5e38aa186729eca5be508397c71c368 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sun, 25 Jun 2023 23:20:25 +0800 Subject: [PATCH] update --- app/Core/Src/usart.c | 2 +- dep/libiflytop_micro | 2 +- src/umain.cpp | 38 ++++++++++++++++++++++++++++---------- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/app/Core/Src/usart.c b/app/Core/Src/usart.c index 89ab949..094424d 100644 --- a/app/Core/Src/usart.c +++ b/app/Core/Src/usart.c @@ -70,7 +70,7 @@ void MX_USART2_UART_Init(void) /* USER CODE END USART2_Init 1 */ huart2.Instance = USART2; - huart2.Init.BaudRate = 115200; + huart2.Init.BaudRate = 1500000; huart2.Init.WordLength = UART_WORDLENGTH_8B; huart2.Init.StopBits = UART_STOPBITS_1; huart2.Init.Parity = UART_PARITY_NONE; diff --git a/dep/libiflytop_micro b/dep/libiflytop_micro index 8042a2a..2fded79 160000 --- a/dep/libiflytop_micro +++ b/dep/libiflytop_micro @@ -1 +1 @@ -Subproject commit 8042a2a995e30ddd2907d1f77059e3dd402d1f7d +Subproject commit 2fded7932e162857e91605ea7cfcba7a003779d6 diff --git a/src/umain.cpp b/src/umain.cpp index 19ba356..8ffec6b 100644 --- a/src/umain.cpp +++ b/src/umain.cpp @@ -29,11 +29,11 @@ struct ad77681_init_param ADC_default_init_param = { /* Configuration */ .power_mode = AD77681_FAST, // power_mode .mclk_div = AD77681_MCLK_DIV_8, // mclk_div - .conv_mode = AD77681_CONV_CONTINUOUS, // conv_mode + .conv_mode = AD77681_CONV_CONTINUOUS, // conv_mode .diag_mux_sel = AD77681_POSITIVE_FS, // diag_mux_sel .conv_diag_sel = false, // conv_diag_sel .conv_len = AD77681_CONV_16BIT, // conv_len - .crc_sel = AD77681_CRC, // crc_sel + .crc_sel = AD77681_CRC, // crc_sel .status_bit = 0, // status_bit .VCM_out = AD77681_VCM_HALF_VCC, /* VCM setup*/ .AINn = AD77681_AINn_ENABLED, /* AIN- precharge buffer*/ @@ -73,23 +73,41 @@ void Main::main(int argc, char const *argv[]) { HAL_Delay(1000); m_ad77681.initialize("ad77681", &m_hardware, &hspi2, &PB12, ADC_default_init_param); -#if 0 - uint8_t adc_data[6]; - double voltage; +#if 1 + double voltage; + + static int32_t voicebuf[16 * 100]; + int off = 0; while (1) { + uint8_t adc_data[6] = {0}; + uint8_t adc_data2[6] = {0}; m_ad77681.spi_read_adc_data(adc_data, AD77681_REGISTER_DATA_READ); // m_ad77681.data_to_voltage((uint32_t *)adc_data, &voltage); - // printf("[ADC DATA]: 0x"); - // for (int i = 0; i < sizeof(adc_data); i++) { + // printf(": 0x"); + // for (int i = 0; i < 4; i++) { // printf("%02x", adc_data[i]); // } // printf("\r\n"); - // printf("{plotter}%d\n", *(int32_t *)adc_data); - // printf("{plotter}%f\n", voltage); + adc_data2[0] = adc_data[3]; + adc_data2[1] = adc_data[2]; + adc_data2[2] = adc_data[1]; + adc_data2[3] = adc_data[0]; + + voicebuf[off++] = *(int32_t *)adc_data2; + if (off >= 16 * 100) { + break; + } - HAL_Delay(1); + // printf("{plotter}%d\n", *(int32_t *)adc_data); + // printf("{plotter}%d\n", *(int32_t *)adc_data2); + // (1); + m_hardware.sleepus(100); // HAL_IWDG_Refresh(&hiwdg); } + for (size_t i = 0; i < off; i++) { + printf("{plotter}%d\n", voicebuf[i]); + } + #endif while (true) {