2021-07-26 17:17:04 +08:00
|
|
|
#include "user_main.h"
|
|
|
|
|
2022-01-09 20:30:28 +08:00
|
|
|
#define ADC_SAMPLE_NUM 100
|
|
|
|
|
|
|
|
uint8_t fsmc_read_buf, fsmc_write_buf;
|
|
|
|
int8_t adc_result[ADC_SAMPLE_NUM];
|
2021-12-26 16:53:27 +08:00
|
|
|
|
2021-07-27 09:58:57 +08:00
|
|
|
void user_setup()
|
2021-07-26 17:17:04 +08:00
|
|
|
{
|
2021-08-31 17:38:28 +08:00
|
|
|
flash_fpga();
|
|
|
|
// ethernet_init();
|
2021-07-26 17:17:04 +08:00
|
|
|
HAL_TIM_Base_Start_IT(&htim4);
|
2021-08-31 17:38:28 +08:00
|
|
|
HAL_TIM_Base_Start(&htim3);
|
|
|
|
eem_power_init();
|
|
|
|
uint8_t str[10] = "test";
|
|
|
|
HAL_UART_Transmit(&huart4, str, 5, 100);
|
2021-07-26 17:17:04 +08:00
|
|
|
}
|
|
|
|
|
2021-12-31 10:57:11 +08:00
|
|
|
uint8_t dio_ch = 0;
|
|
|
|
uint8_t dio_io = 0;
|
2022-01-09 20:30:28 +08:00
|
|
|
uint8_t adc_sample = 0;
|
2021-07-27 09:58:57 +08:00
|
|
|
void user_loop()
|
2021-07-26 17:17:04 +08:00
|
|
|
{
|
2022-01-09 20:30:28 +08:00
|
|
|
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++;
|
|
|
|
}
|
|
|
|
}
|
2021-12-31 10:57:11 +08:00
|
|
|
// HAL_Delay(1000);
|
2021-08-31 17:38:28 +08:00
|
|
|
key_events();
|
2021-07-26 17:17:04 +08:00
|
|
|
}
|