Skip to content

Add STM32F042K6Ux Variants #2648

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 11 commits into from
Feb 4, 2025
Merged

Add STM32F042K6Ux Variants #2648

merged 11 commits into from
Feb 4, 2025

Conversation

jackb60
Copy link
Contributor

@jackb60 jackb60 commented Feb 3, 2025

No description provided.

Signed-off-by: jackb60 <40903548+jackb60@users.noreply.github.com>
Signed-off-by: jackb60 <40903548+jackb60@users.noreply.github.com>
Signed-off-by: jackb60 <40903548+jackb60@users.noreply.github.com>
Signed-off-by: jackb60 <40903548+jackb60@users.noreply.github.com>
Signed-off-by: jackb60 <40903548+jackb60@users.noreply.github.com>
Signed-off-by: jackb60 <40903548+jackb60@users.noreply.github.com>
Signed-off-by: jackb60 <40903548+jackb60@users.noreply.github.com>
@jackb60 jackb60 changed the title Add STM32F042K6Ux Support Add STM32F042K6Ux Variants Feb 3, 2025
@fpistm fpistm added the new variant Add support of new bard label Feb 3, 2025
Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jackb60 for the PR.
One small change else it's LGTM.

@fpistm fpistm added this to the 2.10.0 milestone Feb 3, 2025
Signed-off-by: jackb60 <40903548+jackb60@users.noreply.github.com>
@jackb60
Copy link
Contributor Author

jackb60 commented Feb 3, 2025

Fixed

Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the astyle issue:

diff --git a/variants/STM32F0xx/F042K(4-6)U/generic_clock.c b/variants/STM32F0xx/F042K(4-6)U/generic_clock.c
index a5ac5e2..021aaf1 100644
--- a/variants/STM32F0xx/F042K(4-6)U/generic_clock.c
+++ b/variants/STM32F0xx/F042K(4-6)U/generic_clock.c
@@ -27,36 +27,33 @@ WEAK void SystemClock_Config(void)
   /** Initializes the RCC Oscillators according to the specified parameters
   * in the RCC_OscInitTypeDef structure.
   */
-  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI48
+  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
   RCC_OscInitStruct.HSIState = RCC_HSI_ON;
   RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
   RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
-  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
-  {
+  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
     Error_Handler();
   }
 
   /** Initializes the CPU, AHB and APB buses clocks
   */
-  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
-                              |RCC_CLOCKTYPE_PCLK1;
+  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
+                                | RCC_CLOCKTYPE_PCLK1;
   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI48;
   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
 
-  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
-  {
+  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
     Error_Handler();
   }
-  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB|RCC_PERIPHCLK_USART1
-                              |RCC_PERIPHCLK_I2C1;
+  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB | RCC_PERIPHCLK_USART1
+                                       | RCC_PERIPHCLK_I2C1;
   PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1;
   PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_HSI;
   PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
 
-  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
-  {
+  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
     Error_Handler();
   }
 }

Signed-off-by: jackb60 <40903548+jackb60@users.noreply.github.com>
@jackb60 jackb60 requested a review from fpistm February 3, 2025 14:47
Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still issues with astyle:

--- a/variants/STM32F0xx/F042K(4-6)U/generic_clock.c
+++ b/variants/STM32F0xx/F042K(4-6)U/generic_clock.c
@@ -38,8 +38,8 @@ WEAK void SystemClock_Config(void)
 
   /** Initializes the CPU, AHB and APB buses clocks
   */
-RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
-                              | RCC_CLOCKTYPE_PCLK1;
+  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
+                                | RCC_CLOCKTYPE_PCLK1;
   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI48;
   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
@@ -47,8 +47,8 @@ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
     Error_Handler();
   }
-PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB | RCC_PERIPHCLK_USART1
-                                     | RCC_PERIPHCLK_I2C1;
+  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB | RCC_PERIPHCLK_USART1
+                                       | RCC_PERIPHCLK_I2C1;
   PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1;
   PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_HSI;
   PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;

Signed-off-by: jackb60 <40903548+jackb60@users.noreply.github.com>
@jackb60 jackb60 requested a review from fpistm February 3, 2025 15:10
@fpistm fpistm merged commit ee9c0dd into stm32duino:main Feb 4, 2025
24 of 25 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
new variant Add support of new bard
Projects
Development

Successfully merging this pull request may close these issues.

2 participants