This commit is contained in:
2023-11-06 21:31:51 +01:00
parent 617dd175b9
commit a7ccf2ce66
2 changed files with 143 additions and 119 deletions

View File

@@ -4,7 +4,7 @@
"name": "Win32", "name": "Win32",
"includePath": [ "includePath": [
"${workspaceFolder}/Core/Inc", "${workspaceFolder}/Core/Inc",
"${workspaceFolder}/Drivers/CMSIS/Core/Include", "${workspaceFolder}/Drivers/CMSIS/Include",
"${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32G0xx/Include", "${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32G0xx/Include",
"${workspaceFolder}/Drivers/STM32G0xx_HAL_Driver/Inc", "${workspaceFolder}/Drivers/STM32G0xx_HAL_Driver/Inc",
"${workspaceFolder}/utils/rtt" "${workspaceFolder}/utils/rtt"
@@ -13,7 +13,7 @@
"_DEBUG", "_DEBUG",
"UNICODE", "UNICODE",
"_UNICODE", "_UNICODE",
"STM32F303xE", "STM32G0B1xx",
"USE_HAL_DRIVER", "USE_HAL_DRIVER",
"ULOG_ENABLED" "ULOG_ENABLED"
], ],

View File

@@ -26,7 +26,7 @@
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
#include "SEGGER_RTT.h"
/* USER CODE END Includes */ /* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/
@@ -36,6 +36,7 @@
/* Private define ------------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */ /* USER CODE BEGIN PD */
#define ADC_DATA_LENGHT 16
/* USER CODE END PD */ /* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/
@@ -46,7 +47,9 @@
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */ /* USER CODE BEGIN PV */
uint8_t data_ready;
uint32_t soft_timer;
uint16_t adc_data[ADC_DATA_LENGHT];
/* USER CODE END PV */ /* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
@@ -97,13 +100,23 @@ int main(void)
/* Initialize interrupts */ /* Initialize interrupts */
MX_NVIC_Init(); MX_NVIC_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
soft_timer = HAL_GetTick();
// HAL_ADC_Start_DMA(&hadc1, adc_data, ADC_DATA_LENGHT);
HAL_TIM_OnePulse_Start(&htim15, TIM_CHANNEL_1);
/* USER CODE END 2 */ /* USER CODE END 2 */
/* Infinite loop */ /* Infinite loop */
/* USER CODE BEGIN WHILE */ /* USER CODE BEGIN WHILE */
while (1) while (1)
{ {
if (data_ready)
{
data_ready = 0;
for (uint8_t i = 0; i < ADC_DATA_LENGHT; i++)
{
SEGGER_RTT_printf(0, "%02d: %d\n", i, adc_data[i]);
}
}
/* USER CODE END WHILE */ /* USER CODE END WHILE */
/* USER CODE BEGIN 3 */ /* USER CODE BEGIN 3 */
@@ -145,8 +158,7 @@ void SystemClock_Config(void)
/** Initializes the CPU, AHB and APB buses clocks /** Initializes the CPU, AHB and APB buses clocks
*/ */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1;
|RCC_CLOCKTYPE_PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
@@ -172,7 +184,19 @@ static void MX_NVIC_Init(void)
} }
/* USER CODE BEGIN 4 */ /* USER CODE BEGIN 4 */
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
{
data_ready = 1;
}
void HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == 13 && soft_timer + 50 < HAL_GetTick())
{
soft_timer = HAL_GetTick();
__HAL_TIM_ENABLE(&htim15);
}
}
/* USER CODE END 4 */ /* USER CODE END 4 */
/** /**