Skip to content

Commit

Permalink
variant(C0): Add support of Disco board STM32C0316-DK
Browse files Browse the repository at this point in the history
Note: SystemClock_Config() is based on LL API to spare Flash memory

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
  • Loading branch information
ABOSTM authored and fpistm committed Jan 23, 2023
1 parent 4414beb commit 5555460
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d

| Status | Device(s) | Name | Release | Notes |
| :----: | :-------: | ---- | :-----: | :---- |
| :yellow_heart: | STM32C031C6 | [STM32C0316-DK](https://www.st.com/en/evaluation-tools/stm32c0316-dk.html) | **2.5.0** | |
| :green_heart: | STM32F030R8 | [32F0308DISCOVERY](http://www.st.com/en/evaluation-tools/32f0308discovery.html) | *1.3.0* | |
| :green_heart: | STM32F072RB | [32F072BDISCOVERY](https://www.st.com/en/evaluation-tools/32f072bdiscovery.html) | *1.5.0* | |
| :green_heart: | STM32F100RB | [STM32VLDISCOVERY](https://www.st.com/en/evaluation-tools/stm32vldiscovery.html) | 0.2.1 | |
Expand Down
13 changes: 13 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,19 @@ Disco.menu.pnum.B_U585I_IOT02A.build.variant=STM32U5xx/U575A(G-I)IxQ_U585AIIxQ
Disco.menu.pnum.B_U585I_IOT02A.build.peripheral_pins=-DCUSTOM_PERIPHERAL_PINS
Disco.menu.pnum.B_U585I_IOT02A.build.cmsis_lib_gcc=arm_ARMv8MMLlfsp_math

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

# DISCO_F030R8 board
Disco.menu.pnum.DISCO_F030R8=STM32F030R8-DISCVL
Disco.menu.pnum.DISCO_F030R8.node="No_mass_storage_for_this_board_Use_STLink_upload_method"
Expand Down
97 changes: 97 additions & 0 deletions variants/STM32C0xx/C031C(4-6)(T-U)/variant_STM32C0316_DK.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
*******************************************************************************
* 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_STM32C0316_DK)
#include "pins_arduino.h"
#include "stm32yyxx_ll_utils.h"

// Digital PinName array
const PinName digitalPin[] = {

PA_3, // D0
PA_2, // D1
PC_6, // D2
PC_7, // D3
PA_0, // D4
PD_0, // D5
PD_1, // D6
PD_2, // D7
PD_3, // D8
PA_8, // D9
PB_0, // D10
PA_7, // D11
PA_6, // D12
PA_1, // D13
PA_4, // D14
PA_5, // D15
PA_10, // D16
PA_9, // D17
PB_11, // D18
PB_10, // D19
PB_6, // D20
PB_7 // D21
};

// Analog (Ax) pin number array
const uint32_t analogInputPin[] = {
14, // A4,
15, // A5,
16, // A0,
17, // A1,
18, // A2,
19 // A3,
};

// ----------------------------------------------------------------------------
#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);

/* HSI configuration and activation */
LL_RCC_HSI_Enable();
while (LL_RCC_HSI_IsReady() != 1) {
}

LL_RCC_HSI_SetCalibTrimming(64);
LL_RCC_SetHSIDiv(LL_RCC_HSI_DIV_1);
/* Set AHB prescaler*/
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);

/* Sysclk activation on the HSI */
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI) {
}

/* 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_STM32C0316_DK */
113 changes: 113 additions & 0 deletions variants/STM32C0xx/C031C(4-6)(T-U)/variant_STM32C0316_DK.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
*******************************************************************************
* 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
*----------------------------------------------------------------------------*/
#define PA3 0
#define PA2 1
#define PC6 2
#define PC7 3
#define PA0 4
#define PD0 5
#define PD1 6
#define PD2 7
#define PD3 8
#define PA8 9
#define PB0 10
#define PA7 11
#define PA6 12
#define PA1 13
#define PB10 A5
#define PB11 A4
#define PA4 A0 // Joystick
#define PA5 A1 // LED BLUE
#define PA10 A2 // SDA // No ADC capability, despite analog "A2" Silk mark on board
#define PA9 A3 // SCL // No ADC capability, despite analog "A3" Silk mark on board
#define PB6 20 // STM32_TX1
#define PB7 21 // STM32_RX1


#define NUM_DIGITAL_PINS 22
#define NUM_ANALOG_INPUTS 6

// 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 PA4
#endif

// I2C Definitions
#ifndef PIN_WIRE_SDA
#define PIN_WIRE_SDA PA10
#endif
#ifndef PIN_WIRE_SCL
#define PIN_WIRE_SCL PA9
#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 1
#endif

// Default pin used for generic 'Serial' instance
// Mandatory for Firmata
#ifndef PIN_SERIAL_RX
#define PIN_SERIAL_RX PB7
#endif
#ifndef PIN_SERIAL_TX
#define PIN_SERIAL_TX PB6
#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 5555460

Please sign in to comment.