uhh
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
|
.cache/
|
||||||
.ccls-cache/
|
.ccls-cache/
|
||||||
|
.clangd
|
||||||
build/
|
build/
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
* Copyright (c) 2025 STMicroelectronics.
|
* Copyright (c) 2025 STMicroelectronics.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component.
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
@@ -21,9 +22,10 @@ extern "C" {
|
|||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
#include <stdio.h>
|
//#include <stdio.h>
|
||||||
} // end extern "C"
|
} // end extern "C"
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
@@ -33,7 +35,7 @@ extern "C" {
|
|||||||
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN PD */
|
/* USER CODE BEGIN PD */
|
||||||
#define Print2UART1 int __io_putchar(int data)
|
#define Print2UART1 int __io_putchar(int data) // prints to serial monitor
|
||||||
//float duty = 58.52 // (((2396*4096)*65534)/65534)*100
|
//float duty = 58.52 // (((2396*4096)*65534)/65534)*100
|
||||||
//int duty = 59;
|
//int duty = 59;
|
||||||
float duty = 58.52;
|
float duty = 58.52;
|
||||||
@@ -59,11 +61,13 @@ float volts;
|
|||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
extern "C" {
|
||||||
void SystemClock_Config(void);
|
void SystemClock_Config(void);
|
||||||
static void MX_GPIO_Init(void);
|
static void MX_GPIO_Init(void);
|
||||||
static void MX_ADC1_Init(void);
|
static void MX_ADC1_Init(void);
|
||||||
static void MX_TIM1_Init(void);
|
static void MX_TIM1_Init(void);
|
||||||
static void MX_USART1_UART_Init(void);
|
static void MX_USART1_UART_Init(void);
|
||||||
|
}
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
@@ -82,7 +86,6 @@ main(void)
|
|||||||
{
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
/* MCU Configuration--------------------------------------------------------*/
|
/* MCU Configuration--------------------------------------------------------*/
|
||||||
@@ -115,14 +118,14 @@ main(void)
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
HAL_ADC_Start(&hadc1);
|
HAL_ADC_Start(&hadc1);
|
||||||
HAL_ADC_PollForConversion(&hadc1, 100);
|
HAL_ADC_PollForConversion(&hadc1, 100); //poll ADC1 periph, timeout 100ms
|
||||||
|
|
||||||
rawValue = (float)HAL_ADC_GetValue(&hadc1);
|
rawValue = HAL_ADC_GetValue(&hadc1);
|
||||||
|
|
||||||
HAL_Delay(500);
|
HAL_Delay(500);
|
||||||
|
|
||||||
//volts = rawValue; // TODO change this to an actual conversion
|
//volts = rawValue; // TODO change this to an actual conversion
|
||||||
volts = rawValue / duty;
|
volts = (float)rawValue / duty;
|
||||||
|
|
||||||
//printf("The value is %hu volts.\r\n", volts);
|
//printf("The value is %hu volts.\r\n", volts);
|
||||||
printf("The value is %f volts.\r\n", volts);
|
printf("The value is %f volts.\r\n", volts);
|
||||||
@@ -131,6 +134,7 @@ main(void)
|
|||||||
|
|
||||||
__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1, duty); // TODO dude what is going on
|
__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1, duty); // TODO dude what is going on
|
||||||
// rawValue/4096*65545
|
// rawValue/4096*65545
|
||||||
|
// i think it works now?
|
||||||
HAL_Delay(100);
|
HAL_Delay(100);
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
@@ -367,6 +371,7 @@ static void MX_GPIO_Init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 4 */
|
/* USER CODE BEGIN 4 */
|
||||||
|
/*
|
||||||
int
|
int
|
||||||
__io_putchar(int ch)
|
__io_putchar(int ch)
|
||||||
{
|
{
|
||||||
@@ -375,6 +380,15 @@ __io_putchar(int ch)
|
|||||||
//return ch;
|
//return ch;
|
||||||
return (int)NULL;
|
return (int)NULL;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern "C" int
|
||||||
|
__io_putchar(int ch)
|
||||||
|
{
|
||||||
|
uint8_t c = ch; // we just want 1 byte
|
||||||
|
HAL_UART_Transmit(&huart1, &c, 1, HAL_MAX_DELAY);
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
@@ -406,3 +420,4 @@ void assert_failed(uint8_t *file, uint32_t line)
|
|||||||
/* USER CODE END 6 */
|
/* USER CODE END 6 */
|
||||||
}
|
}
|
||||||
#endif /* USE_FULL_ASSERT */
|
#endif /* USE_FULL_ASSERT */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user