Skip to content

Commit

Permalink
variant(C0): Add Nucleo C031C6 support
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
  • Loading branch information
ABOSTM authored and fpistm committed Jan 20, 2023
1 parent 1650f3a commit 4414beb
Show file tree
Hide file tree
Showing 4 changed files with 313 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d

| Status | Device(s) | Name | Release | Notes |
| :----: | :-------: | ---- | :-----: | :---- |
| :yellow_heart: | STM32C031C6 | [Nucleo C031C6](https://www.st.com/en/evaluation-tools/nucleo-c031c6.html) | **2.5.0** | |
| :green_heart: | STM32F030R8 | [Nucleo F030R8](http://www.st.com/en/evaluation-tools/nucleo-f030r8.html) | *0.2.0* | |
| :green_heart: | STM32F070RB | [Nucleo F070RB](http://www.st.com/en/evaluation-tools/nucleo-f070rb.html) | *2.0.0* | |
| :green_heart: | STM32F072RB | [Nucleo F072RB](http://www.st.com/en/evaluation-tools/nucleo-f072rb.html) | *1.9.0* | |
Expand Down
13 changes: 13 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,19 @@ Nucleo_64.build.st_extra_flags=-D{build.product_line} {build.enable_usb} {build.
Nucleo_64.upload.maximum_size=0
Nucleo_64.upload.maximum_data_size=0

# NUCLEO_C031C6 board
Nucleo_64.menu.pnum.NUCLEO_C031C6=Nucleo C031C6
Nucleo_64.menu.pnum.NUCLEO_C031C6.node="NOD_C031C6"
Nucleo_64.menu.pnum.NUCLEO_C031C6.upload.maximum_size=32768
Nucleo_64.menu.pnum.NUCLEO_C031C6.upload.maximum_data_size=12288
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.mcu=cortex-m0plus
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.board=NUCLEO_C031C6
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.series=STM32C0xx
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.product_line=STM32C031xx
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.variant=STM32C0xx/C031C(4-6)(T-U)
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.cmsis_lib_gcc=arm_cortexM0l_math
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.extra_flags=-D{build.product_line} {build.xSerial} -D__CORTEX_SC=0

# NUCLEO_F030R8 board
Nucleo_64.menu.pnum.NUCLEO_F030R8=Nucleo F030R8
Nucleo_64.menu.pnum.NUCLEO_F030R8.node="NODE_F030R8,NUCLEO"
Expand Down
146 changes: 146 additions & 0 deletions variants/STM32C0xx/C031C(4-6)(T-U)/variant_NUCLEO_C031C6.cpp
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 variants/STM32C0xx/C031C(4-6)(T-U)/variant_NUCLEO_C031C6.h
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

0 comments on commit 4414beb

Please sign in to comment.