Убрано лишнее из main.c

This commit is contained in:
2025-12-28 15:40:33 +03:00
parent c63d98f431
commit c82bbdc1ca

View File

@@ -10,13 +10,8 @@
//-- Includes ------------------------------------------------------------------
#include "main.h"
void restart_receive(void);
void heartbit(void);
//-- Defines -------------------------------------------------------------------
uint8_t rxbuff[10] = {0};
uint8_t txbuff[20] = {0};
uint16_t seq0_buff[2][100] = {0};
uint16_t seq1_buff[2][100] = {0};
//-- Peripheral init functions -------------------------------------------------
void periph_init()
{
@@ -30,61 +25,20 @@ void periph_init()
#endif
NVIC_SetAllPriorities();
printf("\nAll peripherals inited, SYSCLK = %3d MHz\n", (int)(SystemCoreClock / 1E6));
UART_Start(&huart1, UART_FIFOLevel_1_8, UART_FIFOLevel_1_8);
// TMR_Set_Callback(&htmr2, TMR_Callback_Update, &heartbit);
TMR_Start(&htmr0, DISABLE);
TMR_Start(&htmr1, DISABLE);
TMR_Start(&htmr2, ENABLE);
ADC_SEQ_Set_Callback(&hadc, ADC_SEQ_Num_1, ADC_Callback_SeqCplt, &heartbit);
// ADC_SEQ_Start(&hadc, ADC_SEQ_Num_0, seq0_buff, 100);
ADC_SEQ_Start(&hadc, ADC_SEQ_Num_1, NULL, 100);
}
//-- Main ----------------------------------------------------------------------
uint32_t startmillis = 0;
uint32_t prev_tick;
int main()
{
periph_init();
// UART_Receive_IT(&huart1, rxbuff, sizeof(rxbuff));
TMR_Delay_Start(&htmr0, &prev_tick);
ADC_SEQ_SoftwareStart();
while (1) {
if(TMR_Delay_Done(&htmr0, 2000000, &prev_tick))
while (1)
{
TMR_Delay_Start(&htmr0, &prev_tick);
GPIO_ToggleBits(GPIOA, GPIO_Pin_8);
startmillis = millis();
// ADC_SEQ_SoftwareStart();
}
TMR_Delay(&htmr0, 100000);
// GPIO_ToggleBits(GPIOA, GPIO_Pin_7);
// UART_Transmit_IT(&huart1, (uint8_t*)"Hello World: ", sizeof("Hello World: ")-1);
// int len = sprintf((char*)txbuff, "\r\nValue: %d", ADC_Channel_GetValue(&hadc, ADC_CH_Num_3));
// UART_Transmit_IT(&huart1, txbuff, len);
};
//return 0;
}
void restart_receive(void)
{
// UART_Receive_IT(&huart1, rxbuff, sizeof(rxbuff));
// UART_Transmit_IT(&huart1, rxbuff, sizeof(rxbuff));
}
char tickbuff[40] = {0};
void heartbit(void)
{
static uint32_t prev_tick = 0;
int len = sprintf(tickbuff, "\r\nTick: %d, Value: %d", TMR_Get_Cnt(&htmr0) - prev_tick, ADC_Channel_GetValue(&hadc, ADC_CH_Num_3));
prev_tick = TMR_Get_Cnt(&htmr0);
UART_Transmit_IT(&huart1, (uint8_t *)tickbuff, len);
}
//-- Assert --------------------------------------------------------------------
void Error_Handler(void)
{