-
Notifications
You must be signed in to change notification settings - Fork 981
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
variant(u0): add Nucleo U083RC support
Signed-off-by: Frederic Pillon <[email protected]>
- Loading branch information
Showing
4 changed files
with
362 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
162 changes: 162 additions & 0 deletions
162
variants/STM32U0xx/U073R(8-B-C)(I-T)_U083RC(I-T)/variant_NUCLEO_U083RC.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
/* | ||
******************************************************************************* | ||
* Copyright (c) 2024, STMicroelectronics | ||
* All rights reserved. | ||
* | ||
* This software component is licensed by ST under BSD 3-Clause license, | ||
* the "License"; You may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at: | ||
* opensource.org/licenses/BSD-3-Clause | ||
* | ||
******************************************************************************* | ||
*/ | ||
#if defined(ARDUINO_NUCLEO_U083RC) | ||
#include "pins_arduino.h" | ||
|
||
// Digital PinName array | ||
const PinName digitalPin[] = { | ||
PA_3, // D0 | ||
PA_2, // D1 | ||
PA_10, // D2 | ||
PB_3, // D3 | ||
PB_5, // D4 | ||
PB_4, // D5 | ||
PB_10, // D6 | ||
PA_8, // D7 | ||
PA_9, // D8 | ||
PC_7, // D9 | ||
PB_6, // D10/A6 | ||
PA_7, // D11/A7 | ||
PA_6, // D12/A8 | ||
PA_5, // D13 | ||
PB_9, // D14 | ||
PB_8, // D15 | ||
PA_0, // D16/A0 | ||
PA_1, // D17/A1 | ||
PA_4, // D18/A2 | ||
PB_0, // D19/A3 | ||
PC_1, // D20/A4 | ||
PC_0, // D21/A5 | ||
PC_10, // D22 | ||
PC_12, // D23 | ||
PA_13, // D24 | ||
PA_14, // D25 | ||
PA_15, // D26 | ||
PB_7, // D27 | ||
PC_13, // D28 | ||
PC_14, // D29 | ||
PC_15, // D30 | ||
PF_0, // D31 | ||
PF_1, // D32 | ||
PC_2, // D33/A9 | ||
PC_3, // D34/A10 | ||
PC_11, // D35 | ||
PD_2, // D36 | ||
PC_9, // D37 | ||
PC_8, // D38 | ||
PC_6, // D39/A11 | ||
PC_5, // D40 | ||
PA_12, // D41 | ||
PA_11, // D42 | ||
PB_12, // D43 | ||
PB_11, // D44 | ||
PB_2, // D45 | ||
PB_1, // D46/A12 | ||
PB_15, // D47 | ||
PB_14, // D48 | ||
PB_13, // D49 | ||
PC_4, // D50/A13 | ||
PF_2, // D51 | ||
PF_3 // D52 | ||
}; | ||
|
||
// Analog (Ax) pin number array | ||
const uint32_t analogInputPin[] = { | ||
16, // A0, PA0 | ||
17, // A1, PA1 | ||
18, // A2, PA4 | ||
19, // A3, PB0 | ||
20, // A4, PC1 | ||
21, // A5, PC0 | ||
11, // A6, PA7 | ||
12, // A7, PA6 | ||
13, // A8, PA5 | ||
33, // A9, PC2 | ||
34, // A10, PC3 | ||
40, // A11, PC5 | ||
46, // A12, PB1 | ||
50 // A13, PC4 | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief System Clock Configuration | ||
* @param None | ||
* @retval None | ||
*/ | ||
WEAK void SystemClock_Config(void) | ||
{ | ||
RCC_OscInitTypeDef RCC_OscInitStruct = {}; | ||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {}; | ||
RCC_PeriphCLKInitTypeDef PeriphClkInit = {}; | ||
|
||
/** Configure the main internal regulator output voltage | ||
*/ | ||
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); | ||
|
||
/** 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.HSIState = RCC_HSI_ON; | ||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; | ||
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; | ||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; | ||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; | ||
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1; | ||
RCC_OscInitStruct.PLL.PLLN = 7; | ||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; | ||
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; | ||
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; | ||
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.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; | ||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; | ||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; | ||
|
||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { | ||
Error_Handler(); | ||
} | ||
|
||
/** Initializes the peripherals clocks | ||
*/ | ||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_LPUART2 | ||
| RCC_PERIPHCLK_LPUART3 | RCC_PERIPHCLK_USB; | ||
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI; | ||
PeriphClkInit.Lpuart2ClockSelection = RCC_LPUART2CLKSOURCE_HSI; | ||
PeriphClkInit.Lpuart3ClockSelection = RCC_LPUART3CLKSOURCE_HSI; | ||
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; | ||
|
||
|
||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { | ||
Error_Handler(); | ||
} | ||
|
||
|
||
} | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* ARDUINO_NUCLEO_U083RC */ |
185 changes: 185 additions & 0 deletions
185
variants/STM32U0xx/U073R(8-B-C)(I-T)_U083RC(I-T)/variant_NUCLEO_U083RC.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
/* | ||
******************************************************************************* | ||
* Copyright (c) 2024, STMicroelectronics | ||
* All rights reserved. | ||
* | ||
* This software component is licensed by ST under BSD 3-Clause license, | ||
* the "License"; You may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at: | ||
* opensource.org/licenses/BSD-3-Clause | ||
* | ||
******************************************************************************* | ||
*/ | ||
#pragma once | ||
|
||
/*---------------------------------------------------------------------------- | ||
* STM32 pins number | ||
*----------------------------------------------------------------------------*/ | ||
#define PA3 0 // Rx | ||
#define PA2 1 // Tx | ||
#define PA10 2 | ||
#define PB3 3 | ||
#define PB5 4 | ||
#define PB4 5 | ||
#define PB10 6 | ||
#define PA8 7 | ||
#define PA9 8 | ||
#define PC7 9 | ||
#define PB6 10 | ||
#define PA7 PIN_A6 | ||
#define PA6 PIN_A7 | ||
#define PA5 PIN_A8 | ||
#define PB9 14 | ||
#define PB8 15 | ||
#define PA0 PIN_A0 | ||
#define PA1 PIN_A1 | ||
#define PA4 PIN_A2 | ||
#define PB0 PIN_A3 | ||
#define PC1 PIN_A4 | ||
#define PC0 PIN_A5 | ||
// Morpho | ||
// CN7 Left Side | ||
#define PC10 22 | ||
#define PC12 23 | ||
#define PA13 24 // SWDIO - NC by default SB15 off | ||
#define PA14 25 // SWCLK - NC by default SB17 off | ||
#define PA15 26 | ||
#define PB7 27 | ||
#define PC13 28 // USER_BTN | ||
#define PC14 29 // OSC32_IN - NC by default SB22 off | ||
#define PC15 30 // OSC32_OUT - NC by default SB24 off | ||
#define PF0 31 | ||
#define PF1 32 | ||
#define PC2 PIN_A9 | ||
#define PC3 PIN_A10 | ||
// CN7 Right Side | ||
#define PC11 35 | ||
#define PD2 36 | ||
// CN10 Left Side | ||
#define PC9 37 | ||
// CN10 Right Side | ||
#define PC8 38 | ||
#define PC6 39 | ||
#define PC5 PIN_A11 | ||
#define PA12 41 | ||
#define PA11 42 | ||
#define PB12 43 | ||
#define PB11 44 | ||
#define PB2 45 | ||
#define PB1 PIN_A12 | ||
#define PB15 47 | ||
#define PB14 48 | ||
#define PB13 49 | ||
#define PC4 PIN_A13 | ||
// Other | ||
#define PF2 51 // NRST | ||
#define PF3 52 // BOOT0 | ||
|
||
// Alternate pins number | ||
#define PA1_ALT1 (PA1 | ALT1) | ||
#define PA2_ALT1 (PA2 | ALT1) | ||
#define PA3_ALT1 (PA3 | ALT1) | ||
#define PA4_ALT1 (PA4 | ALT1) | ||
#define PA6_ALT1 (PA6 | ALT1) | ||
#define PA7_ALT1 (PA7 | ALT1) | ||
#define PA9_ALT1 (PA9 | ALT1) | ||
#define PA10_ALT1 (PA10 | ALT1) | ||
#define PA11_ALT1 (PA11 | ALT1) | ||
#define PA12_ALT1 (PA12 | ALT1) | ||
#define PA15_ALT1 (PA15 | ALT1) | ||
#define PB0_ALT1 (PB0 | ALT1) | ||
#define PB1_ALT1 (PB1 | ALT1) | ||
#define PB1_ALT2 (PB1 | ALT2) | ||
#define PB3_ALT1 (PB3 | ALT1) | ||
#define PB4_ALT1 (PB4 | ALT1) | ||
#define PB5_ALT1 (PB5 | ALT1) | ||
#define PB6_ALT1 (PB6 | ALT1) | ||
#define PB6_ALT2 (PB6 | ALT2) | ||
#define PB7_ALT1 (PB7 | ALT1) | ||
#define PB7_ALT2 (PB7 | ALT2) | ||
#define PB8_ALT1 (PB8 | ALT1) | ||
#define PB9_ALT1 (PB9 | ALT1) | ||
#define PB10_ALT1 (PB10 | ALT1) | ||
#define PB11_ALT1 (PB11 | ALT1) | ||
#define PB13_ALT1 (PB13 | ALT1) | ||
#define PB14_ALT1 (PB14 | ALT1) | ||
#define PB15_ALT1 (PB15 | ALT1) | ||
#define PC0_ALT1 (PC0 | ALT1) | ||
#define PC1_ALT1 (PC1 | ALT1) | ||
#define PC4_ALT1 (PC4 | ALT1) | ||
#define PC5_ALT1 (PC5 | ALT1) | ||
#define PC10_ALT1 (PC10 | ALT1) | ||
#define PC11_ALT1 (PC11 | ALT1) | ||
|
||
#define NUM_DIGITAL_PINS 53 | ||
#define NUM_ANALOG_INPUTS 14 | ||
|
||
// On-board LED pin number | ||
#ifndef LED_BUILTIN | ||
#define LED_BUILTIN PA5 | ||
#endif | ||
#ifndef LED_GREEN | ||
#define LED_GREEN LED_BUILTIN | ||
#endif | ||
|
||
|
||
// On-board user button | ||
#ifndef USER_BTN | ||
#define USER_BTN PC13 | ||
#endif | ||
|
||
// Timer Definitions | ||
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin | ||
#ifndef TIMER_TONE | ||
#define TIMER_TONE TIM6 | ||
#endif | ||
#ifndef TIMER_SERVO | ||
#define TIMER_SERVO TIM7 | ||
#endif | ||
|
||
// UART Definitions | ||
#ifndef SERIAL_UART_INSTANCE | ||
#define SERIAL_UART_INSTANCE 101 | ||
#endif | ||
|
||
// Default pin used for generic 'Serial' instance | ||
// Mandatory for Firmata | ||
#ifndef PIN_SERIAL_RX | ||
#define PIN_SERIAL_RX PA3 | ||
#endif | ||
#ifndef PIN_SERIAL_TX | ||
#define PIN_SERIAL_TX PA2 | ||
#endif | ||
|
||
// Extra HAL modules | ||
#if !defined(HAL_DAC_MODULE_DISABLED) | ||
#define HAL_DAC_MODULE_ENABLED | ||
#endif | ||
|
||
/*---------------------------------------------------------------------------- | ||
* Arduino objects - C++ only | ||
*----------------------------------------------------------------------------*/ | ||
|
||
#ifdef __cplusplus | ||
// These serial port names are intended to allow libraries and architecture-neutral | ||
// sketches to automatically default to the correct port name for a particular type | ||
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, | ||
// the first hardware serial port whose RX/TX pins are not dedicated to another use. | ||
// | ||
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor | ||
// | ||
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial | ||
// | ||
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library | ||
// | ||
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. | ||
// | ||
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX | ||
// pins are NOT connected to anything by default. | ||
#ifndef SERIAL_PORT_MONITOR | ||
#define SERIAL_PORT_MONITOR Serial | ||
#endif | ||
#ifndef SERIAL_PORT_HARDWARE | ||
#define SERIAL_PORT_HARDWARE Serial | ||
#endif | ||
#endif |