-
Notifications
You must be signed in to change notification settings - Fork 982
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 support of Disco board STM32C0316-DK
Note: SystemClock_Config() is based on LL API to spare Flash memory Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
- Loading branch information
Showing
4 changed files
with
224 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
97 changes: 97 additions & 0 deletions
97
variants/STM32C0xx/C031C(4-6)(T-U)/variant_STM32C0316_DK.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,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
113
variants/STM32C0xx/C031C(4-6)(T-U)/variant_STM32C0316_DK.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,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 |