-
Notifications
You must be signed in to change notification settings - Fork 986
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
variant(C0): Add Nucleo C031C6 support
Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
- Loading branch information
Showing
4 changed files
with
313 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
146 changes: 146 additions & 0 deletions
146
variants/STM32C0xx/C031C(4-6)(T-U)/variant_NUCLEO_C031C6.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,146 @@ | ||
/* | ||
******************************************************************************* | ||
* Copyright (c) 2021, 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_C031C6) | ||
#include "pins_arduino.h" | ||
#include "stm32yyxx_ll_utils.h" | ||
|
||
// Digital PinName array | ||
const PinName digitalPin[] = { | ||
// CN9 | ||
PB_7, // D0 | ||
PB_6, // D1 | ||
PA_10, // D2 | ||
PB_3, // D3 | ||
PB_10, // D4 | ||
PB_4, // D5 | ||
PB_5, // D6 | ||
PA_15, // D7 | ||
|
||
// CN5 | ||
PA_9, // D8 | ||
PC_7, // D9 | ||
PB_0, // D10 | ||
PA_7, // D11 | ||
PA_6, // D12 | ||
PA_5, // D13 // LED | ||
PB_9, // D14 | ||
PB_8, // D15 | ||
|
||
// CN7 Left Side | ||
PD_0, // D16 | ||
PD_2, // D17 | ||
PA_14, // D18 | ||
PA_13, // D19 | ||
PC_6, // D20 | ||
PC_13, // D21 // Button | ||
PC_14, // D22 // OSCX_IN | ||
PF_0, // D23 // OSC_IN | ||
PF_1, // D24 // OSC_OUT | ||
PB_11, // D25 | ||
PA_2, // D26 // VCP_TX | ||
|
||
// CN7 Right Side | ||
PD_1, // D27 | ||
|
||
// CN10 Left Side | ||
PD_3, // D28 | ||
PC_11, // D29 | ||
|
||
// CN8 Left Side | ||
PA_0, // D30 | ||
PA_1, // D31 | ||
PA_4, // D32 | ||
PB_1, // D33 | ||
PA_11, // D34 | ||
PA_12, // D35 | ||
|
||
// CN10 Right Side | ||
PA_3, // D36 // VCP_RX | ||
PC_15, // D37 // OSCX_OUT | ||
PB_12, // D38 | ||
PB_2, // D39 | ||
PF_3, // D40 | ||
PA_8, // D41 | ||
PB_15, // D42 | ||
PB_14, // D43 | ||
PB_13, // D44 | ||
|
||
// Others | ||
PF_2 // D45 // NRST | ||
}; | ||
|
||
// Analog (Ax) pin number array | ||
const uint32_t analogInputPin[] = { | ||
30, // A0 | ||
31, // A1 | ||
32, // A2 | ||
33, // A3 | ||
34, // A4 | ||
35, // A5 | ||
26, // A6 | ||
36, // A7 | ||
13, // A8 | ||
12, // A9 | ||
11, // A10 | ||
41, // A11 | ||
19, // A12 | ||
18, // A13 | ||
10, // A14 | ||
39, // A15 | ||
4, // A16 | ||
25, // A17 | ||
38 // A18 | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief System Clock Configuration | ||
* @param None | ||
* @retval None | ||
*/ | ||
WEAK void SystemClock_Config(void) | ||
{ | ||
LL_FLASH_SetLatency(LL_FLASH_LATENCY_1); | ||
|
||
/* HSE configuration and activation */ | ||
LL_RCC_HSE_Enable(); | ||
while (LL_RCC_HSE_IsReady() != 1) { | ||
} | ||
|
||
/* Set AHB prescaler*/ | ||
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); | ||
|
||
/* Sysclk activation on the HSE */ | ||
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSE); | ||
while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSE) { | ||
} | ||
|
||
/* Set APB1 prescaler*/ | ||
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); | ||
/* Update CMSIS variable (which can be updated also through SystemCoreClockUpdate function) */ | ||
LL_SetSystemCoreClock(48000000); | ||
|
||
/* Update the time base */ | ||
if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { | ||
Error_Handler(); | ||
} | ||
} | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* ARDUINO_NUCLEO_C031C6 */ |
153 changes: 153 additions & 0 deletions
153
variants/STM32C0xx/C031C(4-6)(T-U)/variant_NUCLEO_C031C6.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,153 @@ | ||
/* | ||
******************************************************************************* | ||
* Copyright (c) 2022, 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 | ||
*----------------------------------------------------------------------------*/ | ||
|
||
// CN9 | ||
#define PB7 0 | ||
#define PB6 1 | ||
#define PA10 2 | ||
#define PB3 3 | ||
#define PB10 PIN_A16 | ||
#define PB4 5 | ||
#define PB5 6 | ||
#define PA15 7 | ||
|
||
// CN5 | ||
#define PA9 8 | ||
#define PC7 9 | ||
#define PB0 PIN_A14 | ||
#define PA7 PIN_A10 | ||
#define PA6 PIN_A9 | ||
#define PA5 PIN_A8 // LED | ||
#define PB9 14 | ||
#define PB8 15 | ||
|
||
// CN7 Left Side | ||
#define PD0 16 | ||
#define PD2 17 | ||
#define PA14 PIN_A13 | ||
#define PA13 PIN_A12 | ||
#define PC6 20 | ||
#define PC13 21 // Button | ||
#define PC14 22 // OSCX_IN | ||
#define PF0 23 // OSC_IN | ||
#define PF1 24 // OSC_OUT | ||
#define PB11 PIN_A17 | ||
#define PA2 PIN_A6 // VCP_TX | ||
|
||
// CN7 Right Side | ||
#define PD1 27 | ||
|
||
// CN10 Left Side | ||
#define PD3 28 | ||
#define PC11 29 | ||
|
||
// CN8 Left Side | ||
#define PA0 PIN_A0 | ||
#define PA1 PIN_A1 | ||
#define PA4 PIN_A2 | ||
#define PB1 PIN_A3 | ||
#define PA11 PIN_A4 | ||
#define PA12 PIN_A5 | ||
|
||
// CN10 Right side | ||
#define PA3 PIN_A7 // VCP_RX | ||
#define PC15 37 // OSCX_OUT | ||
#define PB12 PIN_A18 | ||
#define PB2 PIN_A15 | ||
#define PF3 40 | ||
#define PA8 PIN_A11 | ||
#define PB15 42 | ||
#define PB14 43 | ||
#define PB13 44 | ||
|
||
// Others | ||
#define PF2 45 // NRST | ||
|
||
|
||
#define NUM_DIGITAL_PINS 46 | ||
#define NUM_ANALOG_INPUTS 19 | ||
|
||
// On-board LED pin number | ||
#define LED_GREEN PA5 | ||
#ifndef LED_BUILTIN | ||
#define LED_BUILTIN LED_GREEN | ||
#endif | ||
|
||
// On-board user button | ||
#ifndef USER_BTN | ||
#define USER_BTN PC13 | ||
#endif | ||
|
||
// I2C Definitions | ||
#ifndef PIN_WIRE_SDA | ||
#define PIN_WIRE_SDA PB9 | ||
#endif | ||
#ifndef PIN_WIRE_SCL | ||
#define PIN_WIRE_SCL PB8 | ||
#endif | ||
|
||
// Timer Definitions | ||
#ifndef TIMER_TONE | ||
#define TIMER_TONE TIM16 | ||
#endif | ||
#ifndef TIMER_SERVO | ||
#define TIMER_SERVO TIM17 | ||
#endif | ||
|
||
// UART Definitions | ||
#ifndef SERIAL_UART_INSTANCE | ||
#define SERIAL_UART_INSTANCE 2 | ||
#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 | ||
|
||
|
||
/*---------------------------------------------------------------------------- | ||
* 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 |