From 2ec95e076d08c64230e63b2460f10277197d9003 Mon Sep 17 00:00:00 2001 From: JongHyeon Lee Date: Tue, 15 Sep 2020 18:03:44 +0900 Subject: [PATCH] Add Aurora One Variant https://www.bfykorea.com/aurora-one/ Supersede #1176 Signed-off-by: JongHyeon Lee Co-authored-by: Frederic.Pillon --- README.md | 1 + boards.txt | 9 ++ .../G030K(6-8)Tx/variant_AURORA_ONE.cpp | 119 +++++++++++++++++ .../G030K(6-8)Tx/variant_AURORA_ONE.h | 120 ++++++++++++++++++ 4 files changed, 249 insertions(+) create mode 100644 variants/STM32G0xx/G030K(6-8)Tx/variant_AURORA_ONE.cpp create mode 100644 variants/STM32G0xx/G030K(6-8)Tx/variant_AURORA_ONE.h diff --git a/README.md b/README.md index 5e9bf6b2cf..50d1d8bf86 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d | Status | Device(s) | Name | Release | Notes | | :----: | :-------: | ---- | :-----: | :---- | +| :yellow_heart: | STM32G030K8 | [Aurora One](https://www.bfykorea.com/aurora-one) | **2.0.0** | | :yellow_heart: | STM32G030K6
STM32G030K8 | Generic Board | **2.0.0** | | | :yellow_heart: | STM32G031J4
STM32G031J6 | Generic Board | **2.0.0** | | | :yellow_heart: | STM32G041J6 | Generic Board | **2.0.0** | | diff --git a/boards.txt b/boards.txt index 03e8774b8f..d535b92270 100644 --- a/boards.txt +++ b/boards.txt @@ -1677,6 +1677,15 @@ GenG0.build.series=STM32G0xx GenG0.build.cmsis_lib_gcc=arm_cortexM0l_math GenG0.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} -D__CORTEX_SC=0 +# Aurora One G030K8 +GenG0.menu.pnum.AURORA_ONE=Aurora One +GenG0.menu.pnum.AURORA_ONE.upload.maximum_size=65536 +GenG0.menu.pnum.AURORA_ONE.upload.maximum_data_size=8192 +GenG0.menu.pnum.AURORA_ONE.build.board=AURORA_ONE +GenG0.menu.pnum.AURORA_ONE.build.product_line=STM32G030xx +GenG0.menu.pnum.AURORA_ONE.build.variant=STM32G0xx/G030K(6-8)Tx +GenG0.menu.pnum.AURORA_ONE.build.variant_h=variant_{build.board}.h + # Generic G030K6Tx GenG0.menu.pnum.GENERIC_G030K6TX=Generic G030K6Tx GenG0.menu.pnum.GENERIC_G030K6TX.upload.maximum_size=32768 diff --git a/variants/STM32G0xx/G030K(6-8)Tx/variant_AURORA_ONE.cpp b/variants/STM32G0xx/G030K(6-8)Tx/variant_AURORA_ONE.cpp new file mode 100644 index 0000000000..6943671924 --- /dev/null +++ b/variants/STM32G0xx/G030K(6-8)Tx/variant_AURORA_ONE.cpp @@ -0,0 +1,119 @@ +/* + ******************************************************************************* + * 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_AURORA_ONE) +#include "pins_arduino.h" + +// Digital PinName array +const PinName digitalPin[] = { + PA_10, //D0 + PA_9, //D1 + PA_6, //D2/A6 + PA_7, //D3/A7 + PA_8, //D4 + PC_6, //D5 + PA_11, //D6/A10 + PA_12, //D7/A11 + PB_2, //D8/A12 + PB_1, //D9/A9 + PB_0, //D10/A8 + PB_5, //D11 + PB_4, //D12 + PB_3, //D13/LED + PB_7, //D14/A13 + PB_6, //D15 + PB_9, //D16/MAINSL + PB_8, //D17/MAINSL + PA_15, //D18/MAINSL + PA_14, //D19/A14/SWCLK + PA_13, //D20/A15/SWDIO + PA_0, //D21/A0 + PA_1, //D22/A1 + PA_2, //D23/A2 + PA_3, //D24/A3 + PA_4, //D25/A4 + PA_5, //D26/A5 + PA_9_R, //D27 + PA_10_R //D28 +}; + +// Analog (Ax) pin number array +const uint32_t analogInputPin[] = { + 21, //A0 + 22, //A1 + 23, //A2 + 24, //A3 + 25, //A4 + 26, //A5 + 2, //A6 + 3, //A7 + 10, //A8 + 9, //A9 + 6, //A10 + 7, //A11 + 8, //A12 + 14, //A13 + 19, //A14 + 20 //A15 +}; + +// ---------------------------------------------------------------------------- + +#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 = {}; + + /* 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_OscInitStruct.HSIState = RCC_HSI_ON; + RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1; + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; + 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 = 8; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_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(); + } +} + +#ifdef __cplusplus +} +#endif +#endif /* ARDUINO_AURORA_ONE */ diff --git a/variants/STM32G0xx/G030K(6-8)Tx/variant_AURORA_ONE.h b/variants/STM32G0xx/G030K(6-8)Tx/variant_AURORA_ONE.h new file mode 100644 index 0000000000..3865ac0e21 --- /dev/null +++ b/variants/STM32G0xx/G030K(6-8)Tx/variant_AURORA_ONE.h @@ -0,0 +1,120 @@ +/* + ******************************************************************************* + * 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 + * + ******************************************************************************* + */ +#pragma once + +/*---------------------------------------------------------------------------- + * STM32 pins number + *----------------------------------------------------------------------------*/ +#define PA10 0 +#define PA9 1 +#define PA6 A6 +#define PA7 A7 +#define PA8 4 +#define PC6 5 +#define PA11 A10 +#define PA12 A11 +#define PB2 A12 +#define PB1 A9 +#define PB0 A8 +#define PB5 11 +#define PB4 12 +#define PB3 13 // LED +#define PB7 A13 +#define PB6 15 +#define PB9 16 +#define PB8 17 +#define PA15 18 +#define PA14 A14 // SWD / BOOT0 +#define PA13 A15 // SWD +#define PA0 A0 +#define PA1 A1 +#define PA2 A2 +#define PA3 A3 +#define PA4 A4 +#define PA5 A5 +#define PA9_R 27 +#define PA10_R 28 +// #define PC14 29 // OSC32IN +// #define PC15 30 // OSC32OUT + +// Alternate pins number +#define PA6_ALT1 (PA6 | ALT1) +#define PA7_ALT1 (PA7 | ALT1) +#define PA7_ALT2 (PA7 | ALT2) +#define PA7_ALT3 (PA7 | ALT3) +#define PB0_ALT1 (PB0 | ALT1) +#define PB1_ALT1 (PB1 | ALT1) +#define PB1_ALT2 (PB1 | ALT2) +#define PB6_ALT1 (PB6 | ALT1) + +#define NUM_DIGITAL_PINS 29 +#define NUM_REMAP_PINS 2 +#define NUM_ANALOG_INPUTS 16 + +// On-board LED pin number +#ifndef LED_BUILTIN + #define LED_BUILTIN PB3 +#endif +#define LED_GREEN LED_BUILTIN + +// On-board user button +#ifndef USER_BTN + #define USER_BTN PA8 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM14 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM16 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 2 //Connected to Aurora Connect Lite +#endif + +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA10 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA9 +#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. + #define SERIAL_PORT_MONITOR Serial + #define SERIAL_PORT_HARDWARE Serial2 +#endif