#include "user_main.h" #define ADC_SAMPLE_NUM 100 uint8_t fsmc_read_buf, fsmc_write_buf; int8_t adc_result[ADC_SAMPLE_NUM]; void user_setup() { flash_fpga(); // ethernet_init(); HAL_TIM_Base_Start_IT(&htim4); HAL_TIM_Base_Start(&htim3); eem_power_init(); uint8_t str[10] = "test"; HAL_UART_Transmit(&huart4, str, 5, 100); } uint8_t dio_ch = 0; uint8_t dio_io = 0; uint8_t adc_sample = 0; void user_loop() { if (adc_sample) { adc_sample = 0; fsmc_write_buf = (dio_io & 0x01) | ((dio_ch & 0x03) << 1) | 0x10; fsmc_write(fsmc_write_buf, 0); } fsmc_read(0xffff, (uint8_t*)&fsmc_read_buf); if (fsmc_read_buf & 0x02) { fsmc_write_buf = (dio_io & 0x01) | ((dio_ch & 0x03) << 1); fsmc_write(fsmc_write_buf, 0); uint16_t add = 0; while (add < ADC_SAMPLE_NUM) { fsmc_read(add, (uint8_t*)(adc_result + add)); add++; } } // HAL_Delay(1000); key_events(); }