Skip to content

Commit 7b4dbeb

Browse files
committed
variant: f0: add NUCLEO-F042K6
Fixes #1099 Signed-off-by: Frederic Pillon <[email protected]>
1 parent 3d1c207 commit 7b4dbeb

File tree

4 files changed

+253
-0
lines changed

4 files changed

+253
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
126126
| Status | Device(s) | Name | Release | Notes |
127127
| :----: | :-------: | ---- | :-----: | :---- |
128128
| :green_heart: | STM32F031K6T | [Nucleo F031K6](https://www.st.com/en/evaluation-tools/nucleo-f031k6.html) | *1.9.0* | |
129+
| :yellow_heart: | STM32F042K6T | [Nucleo F042K6](https://www.st.com/en/evaluation-tools/nucleo-f042k6.html) | **2.1.0** | |
129130
| :green_heart: | STM32F303K8 | [Nucleo F303K8](http://www.st.com/en/evaluation-tools/nucleo-f303k8.html) | *1.1.0* | |
130131
| :green_heart: | STM32G031K8 | [Nucleo G031K8](https://www.st.com/en/evaluation-tools/nucleo-g031k8.html) | *2.0.0* |
131132
| :green_heart: | STM32G431KB | [Nucleo G431KB](https://www.st.com/en/evaluation-tools/nucleo-g431kb.html) | *1.7.0* | |

Diff for: boards.txt

+12
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,18 @@ Nucleo_32.menu.pnum.NUCLEO_F031K6.build.product_line=STM32F031x6
558558
Nucleo_32.menu.pnum.NUCLEO_F031K6.build.variant=STM32F0xx/F031K6T
559559
Nucleo_32.menu.pnum.NUCLEO_F031K6.build.cmsis_lib_gcc=arm_cortexM0l_math
560560

561+
# NUCLEO_F042K6 board
562+
Nucleo_32.menu.pnum.NUCLEO_F042K6=Nucleo F042K6
563+
Nucleo_32.menu.pnum.NUCLEO_F042K6.node=NODE_F042K6
564+
Nucleo_32.menu.pnum.NUCLEO_F042K6.upload.maximum_size=32768
565+
Nucleo_32.menu.pnum.NUCLEO_F042K6.upload.maximum_data_size=6144
566+
Nucleo_32.menu.pnum.NUCLEO_F042K6.build.mcu=cortex-m0
567+
Nucleo_32.menu.pnum.NUCLEO_F042K6.build.board=NUCLEO_F042K6
568+
Nucleo_32.menu.pnum.NUCLEO_F042K6.build.series=STM32F0xx
569+
Nucleo_32.menu.pnum.NUCLEO_F042K6.build.product_line=STM32F042x6
570+
Nucleo_32.menu.pnum.NUCLEO_F042K6.build.variant=STM32F0xx/F042K(4-6)T
571+
Nucleo_32.menu.pnum.NUCLEO_F042K6.build.cmsis_lib_gcc=arm_cortexM0l_math
572+
561573
# NUCLEO_F303K8 board
562574
Nucleo_32.menu.pnum.NUCLEO_F303K8=Nucleo F303K8
563575
Nucleo_32.menu.pnum.NUCLEO_F303K8.node=NODE_F303K8
+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* This software component is licensed by ST under BSD 3-Clause license,
7+
* the "License"; You may not use this file except in compliance with the
8+
* License. You may obtain a copy of the License at:
9+
* opensource.org/licenses/BSD-3-Clause
10+
*
11+
*******************************************************************************
12+
*/
13+
#if defined(ARDUINO_NUCLEO_F042K6)
14+
#include "pins_arduino.h"
15+
16+
// Digital PinName array
17+
const PinName digitalPin[] = {
18+
PA_10, // D0
19+
PA_9, // D1
20+
PA_12, // D2
21+
PB_0, // D3/A8
22+
PB_7, // D4
23+
PB_6, // D5
24+
PB_1, // D6/A9
25+
PF_0, // D7
26+
PF_1, // D8
27+
PA_8, // D9
28+
PA_11, // D10
29+
PB_5, // D11
30+
PB_4, // D12
31+
PB_3, // D13
32+
PA_0, // D14/A0
33+
PA_1, // D15/A1
34+
PA_3, // D16/A2
35+
PA_4, // D17/A3
36+
PA_5, // D18/A4
37+
PA_6, // D19/A5
38+
PA_7, // D20/A6
39+
PA_2, // D21/A7
40+
PA_15, // D22
41+
PA_13, // D23
42+
PA_14, // D24
43+
PB_8 // D25
44+
};
45+
46+
// Analog (Ax) pin number array
47+
const uint32_t analogInputPin[] = {
48+
14, // A0, PA0
49+
15, // A1, PA1
50+
16, // A2, PA3
51+
17, // A3, PA4
52+
18, // A4, PA5
53+
19, // A5, PA6
54+
20, // A6, PA7
55+
21, // A7, PA2
56+
3, // A8, PB0
57+
6 // A9, PB1
58+
};
59+
60+
// ----------------------------------------------------------------------------
61+
62+
#ifdef __cplusplus
63+
extern "C" {
64+
#endif
65+
66+
/**
67+
* @brief System Clock Configuration
68+
* @param None
69+
* @retval None
70+
*/
71+
WEAK void SystemClock_Config(void)
72+
{
73+
RCC_OscInitTypeDef RCC_OscInitStruct = {};
74+
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
75+
RCC_PeriphCLKInitTypeDef PeriphClkInit = {};
76+
77+
/** Initializes the RCC Oscillators according to the specified parameters
78+
* in the RCC_OscInitTypeDef structure.
79+
*/
80+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI14 | RCC_OSCILLATORTYPE_HSI48;
81+
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
82+
RCC_OscInitStruct.HSI14State = RCC_HSI14_ON;
83+
RCC_OscInitStruct.HSI14CalibrationValue = 16;
84+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
85+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
86+
Error_Handler();
87+
}
88+
/** Initializes the CPU, AHB and APB buses clocks
89+
*/
90+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
91+
| RCC_CLOCKTYPE_PCLK1;
92+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI48;
93+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
94+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
95+
96+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
97+
Error_Handler();
98+
}
99+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB | RCC_PERIPHCLK_USART1
100+
| RCC_PERIPHCLK_I2C1;
101+
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_SYSCLK;
102+
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_SYSCLK;
103+
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
104+
105+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
106+
Error_Handler();
107+
}
108+
}
109+
110+
#ifdef __cplusplus
111+
}
112+
#endif
113+
114+
#endif /* ARDUINO_NUCLEO_F042K6 */
+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* This software component is licensed by ST under BSD 3-Clause license,
7+
* the "License"; You may not use this file except in compliance with the
8+
* License. You may obtain a copy of the License at:
9+
* opensource.org/licenses/BSD-3-Clause
10+
*
11+
*******************************************************************************
12+
*/
13+
#pragma once
14+
15+
/*----------------------------------------------------------------------------
16+
* STM32 pins number
17+
*----------------------------------------------------------------------------*/
18+
// CN3
19+
#define PA10 0
20+
#define PA9 1
21+
#define PA12 2
22+
#define PB0 PIN_A8
23+
#define PB7 4 // Default, SB17 ON connected to A4
24+
#define PB6 5 // Default, SB16 ON connected to A5
25+
#define PB1 PIN_A9
26+
#define PF0 7
27+
#define PF1 8
28+
#define PA8 9
29+
#define PA11 10
30+
#define PB5 11
31+
#define PB4 12
32+
// CN4
33+
#define PB3 13 // LED
34+
#define PA0 PIN_A0
35+
#define PA1 PIN_A1
36+
#define PA3 PIN_A2
37+
#define PA4 PIN_A3
38+
#define PA5 PIN_A4
39+
#define PA6 PIN_A5
40+
#define PA7 PIN_A6
41+
#define PA2 PIN_A7 // VCP_TX
42+
#define PA15 22 // VCP_RX
43+
#define PA13 23 // SWDIO
44+
#define PA14 24 // SWCLK
45+
#define PB8 25 // Default SB12 ON (BOOT0 GND)
46+
47+
// Alternate pins number
48+
#define PA6_ALT1 (PA6 | ALT1)
49+
#define PA7_ALT1 (PA7 | ALT1)
50+
#define PA7_ALT2 (PA7 | ALT2)
51+
#define PA7_ALT3 (PA7 | ALT3)
52+
#define PB0_ALT1 (PB0 | ALT1)
53+
#define PB1_ALT1 (PB1 | ALT1)
54+
#define PB1_ALT2 (PB1 | ALT2)
55+
56+
#define NUM_DIGITAL_PINS 26
57+
#define NUM_ANALOG_INPUTS 10
58+
59+
// On-board LED pin number
60+
#ifndef LED_BUILTIN
61+
#define LED_BUILTIN PB3
62+
#endif
63+
64+
// On-board user button
65+
#ifndef USER_BTN
66+
#define USER_BTN PNUM_NOT_DEFINED
67+
#endif
68+
69+
// I2C definitions
70+
#ifndef PIN_WIRE_SDA
71+
#define PIN_WIRE_SDA PB7
72+
#endif
73+
#ifndef PIN_WIRE_SCL
74+
#define PIN_WIRE_SCL PB6
75+
#endif
76+
77+
// Timer Definitions
78+
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
79+
#ifndef TIMER_TONE
80+
#define TIMER_TONE TIM14
81+
#endif
82+
#ifndef TIMER_SERVO
83+
#define TIMER_SERVO TIM16
84+
#endif
85+
86+
// UART Definitions
87+
#ifndef SERIAL_UART_INSTANCE
88+
#define SERIAL_UART_INSTANCE 2
89+
#endif
90+
91+
// Default pin used for generic 'Serial' instance
92+
// Mandatory for Firmata
93+
#ifndef PIN_SERIAL_RX
94+
#define PIN_SERIAL_RX PA15
95+
#endif
96+
#ifndef PIN_SERIAL_TX
97+
#define PIN_SERIAL_TX PA2
98+
#endif
99+
100+
/*----------------------------------------------------------------------------
101+
* Arduino objects - C++ only
102+
*----------------------------------------------------------------------------*/
103+
104+
#ifdef __cplusplus
105+
// These serial port names are intended to allow libraries and architecture-neutral
106+
// sketches to automatically default to the correct port name for a particular type
107+
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
108+
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
109+
//
110+
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
111+
//
112+
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
113+
//
114+
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
115+
//
116+
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
117+
//
118+
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
119+
// pins are NOT connected to anything by default.
120+
#ifndef SERIAL_PORT_MONITOR
121+
#define SERIAL_PORT_MONITOR Serial
122+
#endif
123+
#ifndef SERIAL_PORT_HARDWARE
124+
#define SERIAL_PORT_HARDWARE Serial
125+
#endif
126+
#endif

0 commit comments

Comments
 (0)