Skip to content

Initial version of Globallogic ESK support #942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
@@ -1701,6 +1701,43 @@ Midatronics.menu.upload_method.dfuMethod.upload.protocol=2
Midatronics.menu.upload_method.dfuMethod.upload.options=-g
Midatronics.menu.upload_method.dfuMethod.upload.tool=stm32CubeProg

################################################################################
# Globallogic boards

Globallogic.name=Globallogic

Globallogic.build.core=arduino
Globallogic.build.board=Globallogic
Globallogic.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial}

# STM32F4Discovery board with Globallogic Embedded Starterkit Extension
Globallogic.menu.pnum.GLOBALLOGIC_ESK=Globallogic Embedded Starterkit v1.1
Globallogic.menu.pnum.GLOBALLOGIC_ESK.node=DIS_F407VG
Globallogic.menu.pnum.GLOBALLOGIC_ESK.upload.maximum_size=1048576
Globallogic.menu.pnum.GLOBALLOGIC_ESK.upload.maximum_data_size=196608
Globallogic.menu.pnum.GLOBALLOGIC_ESK.build.mcu=cortex-m4
Globallogic.menu.pnum.GLOBALLOGIC_ESK.build.flags.fp=-mfpu=fpv4-sp-d16 -mfloat-abi=hard
Globallogic.menu.pnum.GLOBALLOGIC_ESK.build.board=GLOBALLOGIC_ESK_V1_1
Globallogic.menu.pnum.GLOBALLOGIC_ESK.build.series=STM32F4xx
Globallogic.menu.pnum.GLOBALLOGIC_ESK.build.product_line=STM32F407xx
Globallogic.menu.pnum.GLOBALLOGIC_ESK.build.variant=GLOBALLOGIC_ESK
Globallogic.menu.pnum.GLOBALLOGIC_ESK.build.cmsis_lib_gcc=arm_cortexM4lf_math

# Upload menu
Globallogic.menu.upload_method.MassStorage=Mass Storage
Globallogic.menu.upload_method.MassStorage.upload.protocol=
Globallogic.menu.upload_method.MassStorage.upload.tool=massStorageCopy

Globallogic.menu.upload_method.swdMethod=STM32CubeProgrammer (SWD)
Globallogic.menu.upload_method.swdMethod.upload.protocol=0
Globallogic.menu.upload_method.swdMethod.upload.options=-g
Globallogic.menu.upload_method.swdMethod.upload.tool=stm32CubeProg

Globallogic.menu.upload_method.dfuMethod=STM32CubeProgrammer (DFU)
Globallogic.menu.upload_method.dfuMethod.upload.protocol=2
Globallogic.menu.upload_method.dfuMethod.upload.options=-g
Globallogic.menu.upload_method.dfuMethod.upload.tool=stm32CubeProg

################################################################################
# Serialx activation
Nucleo_144.menu.xserial.generic=Enabled (generic 'Serial')
@@ -1800,6 +1837,12 @@ Midatronics.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL
Midatronics.menu.xserial.disabled=Disabled (No Serial support)
Midatronics.menu.xserial.disabled.build.xSerial=

Globallogic.menu.xserial.generic=Enabled (generic 'Serial')
Globallogic.menu.xserial.none=Enabled (no generic 'Serial')
Globallogic.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE
Globallogic.menu.xserial.disabled=Disabled (no Serial support)
Globallogic.menu.xserial.disabled.build.xSerial=

# USB connectivity
Nucleo_144.menu.usb.none=None
Nucleo_144.menu.usb.CDCgen=CDC (generic 'Serial' supersede U(S)ART)
@@ -1950,6 +1993,19 @@ Midatronics.menu.xusb.HS.build.usb_speed=-DUSE_USB_HS
Midatronics.menu.xusb.HSFS=High Speed in Full Speed mode
Midatronics.menu.xusb.HSFS.build.usb_speed=-DUSE_USB_HS -DUSE_USB_HS_IN_FS

Globallogic.menu.usb.none=None
Globallogic.menu.usb.CDCgen=CDC (generic 'Serial' supersede U(S)ART)
Globallogic.menu.usb.CDCgen.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC
Globallogic.menu.usb.CDC=CDC (no generic 'Serial')
Globallogic.menu.usb.CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DDISABLE_GENERIC_SERIALUSB
Globallogic.menu.usb.HID=HID (keyboard and mouse)
Globallogic.menu.usb.HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE
Globallogic.menu.xusb.FS=Low/Full Speed
Globallogic.menu.xusb.HS=High Speed
Globallogic.menu.xusb.HS.build.usb_speed=-DUSE_USB_HS
Globallogic.menu.xusb.HSFS=High Speed in Full Speed mode
Globallogic.menu.xusb.HSFS.build.usb_speed=-DUSE_USB_HS -DUSE_USB_HS_IN_FS

# Optimizations
Nucleo_144.menu.opt.osstd=Smallest (-Os default)
Nucleo_144.menu.opt.oslto=Smallest (-Os) with LTO
@@ -2241,6 +2297,24 @@ Midatronics.menu.opt.o3lto.build.flags.optimize=-O3 -flto
Midatronics.menu.opt.ogstd=Debug (-g)
Midatronics.menu.opt.ogstd.build.flags.optimize=-g -Og

Globallogic.menu.opt.osstd=Smallest (-Os default)
Globallogic.menu.opt.oslto=Smallest (-Os) with LTO
Globallogic.menu.opt.oslto.build.flags.optimize=-Os -flto
Globallogic.menu.opt.o1std=Fast (-O1)
Globallogic.menu.opt.o1std.build.flags.optimize=-O1
Globallogic.menu.opt.o1lto=Fast (-O1) with LTO
Globallogic.menu.opt.o1lto.build.flags.optimize=-O1 -flto
Globallogic.menu.opt.o2std=Faster (-O2)
Globallogic.menu.opt.o2std.build.flags.optimize=-O2
Globallogic.menu.opt.o2lto=Faster (-O2) with LTO
Globallogic.menu.opt.o2lto.build.flags.optimize=-O2 -flto
Globallogic.menu.opt.o3std=Fastest (-O3)
Globallogic.menu.opt.o3std.build.flags.optimize=-O3
Globallogic.menu.opt.o3lto=Fastest (-O3) with LTO
Globallogic.menu.opt.o3lto.build.flags.optimize=-O3 -flto
Globallogic.menu.opt.ogstd=Debug (-g)
Globallogic.menu.opt.ogstd.build.flags.optimize=-g -Og

# C Runtime Library
Nucleo_144.menu.rtlib.nano=Newlib Nano (default)
Nucleo_144.menu.rtlib.nanofp=Newlib Nano + Float Printf
@@ -2401,3 +2475,13 @@ Midatronics.menu.rtlib.nanofps=Newlib Nano + Float Printf/Scanf
Midatronics.menu.rtlib.nanofps.build.flags.ldspecs=--specs=nano.specs -u _printf_float -u _scanf_float
Midatronics.menu.rtlib.full=Newlib Standard
Midatronics.menu.rtlib.full.build.flags.ldspecs=

Globallogic.menu.rtlib.nano=Newlib Nano (default)
Globallogic.menu.rtlib.nanofp=Newlib Nano + Float Printf
Globallogic.menu.rtlib.nanofp.build.flags.ldspecs=--specs=nano.specs -u _printf_float
Globallogic.menu.rtlib.nanofs=Newlib Nano + Float Scanf
Globallogic.menu.rtlib.nanofs.build.flags.ldspecs=--specs=nano.specs -u _scanf_float
Globallogic.menu.rtlib.nanofps=Newlib Nano + Float Printf/Scanf
Globallogic.menu.rtlib.nanofps.build.flags.ldspecs=--specs=nano.specs -u _printf_float -u _scanf_float
Globallogic.menu.rtlib.full=Newlib Standard
Globallogic.menu.rtlib.full.build.flags.ldspecs=
400 changes: 400 additions & 0 deletions variants/GLOBALLOGIC_ESK/PeripheralPins.c

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions variants/GLOBALLOGIC_ESK/PinNamesVar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* SYS_WKUP */
#ifdef PWR_WAKEUP_PIN1
SYS_WKUP1 = PA_0,
#endif
#ifdef PWR_WAKEUP_PIN2
SYS_WKUP2 = NC,
#endif
#ifdef PWR_WAKEUP_PIN3
SYS_WKUP3 = NC,
#endif
#ifdef PWR_WAKEUP_PIN4
SYS_WKUP4 = NC,
#endif
#ifdef PWR_WAKEUP_PIN5
SYS_WKUP5 = NC,
#endif
#ifdef PWR_WAKEUP_PIN6
SYS_WKUP6 = NC,
#endif
#ifdef PWR_WAKEUP_PIN7
SYS_WKUP7 = NC,
#endif
#ifdef PWR_WAKEUP_PIN8
SYS_WKUP8 = NC,
#endif
/* USB */
#ifdef USBCON
USB_OTG_FS_SOF = PA_8,
USB_OTG_FS_VBUS = PA_9,
USB_OTG_FS_ID = PA_10,
USB_OTG_FS_DM = PA_11,
USB_OTG_FS_DP = PA_12,
/*
USB_OTG_HS_ULPI_D0 = PA_3,
USB_OTG_HS_SOF = PA_4,
USB_OTG_HS_ULPI_CK = PA_5,
USB_OTG_HS_ULPI_D1 = PB_0,
USB_OTG_HS_ULPI_D2 = PB_1,
USB_OTG_HS_ULPI_D7 = PB_5,
USB_OTG_HS_ULPI_D3 = PB_10,
USB_OTG_HS_ULPI_D4 = PB_11,
USB_OTG_HS_ID = PB_12,
USB_OTG_HS_ULPI_D5 = PB_12,
USB_OTG_HS_ULPI_D6 = PB_13,
USB_OTG_HS_VBUS = PB_13,
USB_OTG_HS_DM = PB_14,
USB_OTG_HS_DP = PB_15,
USB_OTG_HS_ULPI_STP = PC_0,
USB_OTG_HS_ULPI_DIR = PC_2,
USB_OTG_HS_ULPI_NXT = PC_3,
*/
#endif
208 changes: 208 additions & 0 deletions variants/GLOBALLOGIC_ESK/ldscript.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
/*
*****************************************************************************
**

** File : LinkerScript.ld
**
** Abstract : Linker script for STM32F407VGTx Device with
** 1024KByte FLASH, 128KByte RAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used.
**
** Target : STMicroelectronics STM32
**
**
** Distribution: The file is distributed as is, without any warranty
** of any kind.
**
*****************************************************************************
** @attention
**
** <h2><center>&copy; COPYRIGHT(c) 2014 Ac6</center></h2>
**
** Redistribution and use in source and binary forms, with or without modification,
** are permitted provided that the following conditions are met:
** 1. Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** and/or other materials provided with the distribution.
** 3. Neither the name of Ac6 nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*****************************************************************************
*/

/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = 0x20020000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200;; /* required amount of heap */
_Min_Stack_Size = 0x400;; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
}

/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH

/* The program code and other data goes into FLASH */
.text ALIGN(4):
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)

KEEP (*(.init))
KEEP (*(.fini))

. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH

/* Constant data goes into FLASH */
.rodata ALIGN(4):
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH

.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH

.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH

/* used by the startup to initialize data */
_sidata = LOADADDR(.data);

/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */

. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH

_siccmram = LOADADDR(.ccmram);

/* CCM-RAM section
*
* IMPORTANT NOTE!
* If initialized variables will be placed in this section,
* the startup code needs to be modified to copy the init-values.
*/
.ccmram :
{
. = ALIGN(4);
_sccmram = .; /* create a global symbol at ccmram start */
*(.ccmram)
*(.ccmram*)

. = ALIGN(4);
_eccmram = .; /* create a global symbol at ccmram end */
} >CCMRAM AT> FLASH


/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)

. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM

/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(4);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(4);
} >RAM



/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}

.ARM.attributes 0 : { *(.ARM.attributes) }
}


178 changes: 178 additions & 0 deletions variants/GLOBALLOGIC_ESK/variant.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/*
*******************************************************************************
* Copyright (c) 2020, 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
*
*******************************************************************************
*
* Author: Sergey Shcherbakov 2020
* As a base used board_template/variant.cpp
*/

#include "pins_arduino.h"

#ifdef __cplusplus
extern "C" {
#endif

// Pin number
const PinName digitalPin[] = {
/* Test pins */
PC_2, // D0 - TP2
PE_6, // D1 - TP3
PC_13, // D2 - TP4
PA_3, // D3 - TP5
PE_5, // D4 - TP6
PD_6, // D5 - TP7
PD_3, // D6 - TP8
PD_2, // D7 - TP9
PB_14, // D8 - TP10
PB_15, // D9 - TP11
PA_8, // D10 - TP12

/* Button switches */
PC_11, // D11 - SW1
PA_15, // D12 - SW2
PC_9, // D13 - SW3
PC_6, // D14 - SW4
PC_8, // D15 - SW5

/* WH1602 Char Display */
PE_7, // D16 - DISP_RS
PE_10, // D17 - DISP_RW
PE_11, // D18 - DISP_ENA
PE_12, // D19 - DISP_DB4
PE_13, // D20 - DISP_DB5
PE_14, // D21 - DISP_DB6
PE_15, // D22 - DISP_DB7
PE_9, // D23 - Display backlight open-drain output

/* Ethernet */
PB_0, // D24 - ETH_UP_LED#, it's should be used by Ethernet driver
PE_8, // D25 - RMII_PHY_INT#, it's should be used by Ethernet driver _ONLY_
PD_10, // D26 - RMII_PHY_RST#, it's should be used by Ethernet driver _ONLY_

/* MEMS */
PE_4, // D27 - MEMS_INT1#_A/G
PE_2, // D28 - MEMS_INT2#_A/G
PB_8, // D29 - MEMS_INT#_M

/* USART3 */
PD_9, // D30 - USART3_RX
PD_8, // D31 - USART3_TX

/* I2C */
PB_6, // D32 - I2C1_SCL
PB_9, // D33 - I2C1_SDA

/* SPI */
PA_5, // D34 - SPI1_SCK
PB_5, // D35 - SPI1_MOSI
PB_4, // D36 - SPI1_MISO
PD_7, // D37 - SPI1_CS0#

/* CAN */
PD_0, // D38 - CAN1_RX
PD_1, // D39 - CAN1_TX

/* Other */
PB_7, // D40 - PWM_EN
PB_1, // D41 - ADC only, i.e. it's connected to Temperature Sensor

/* LEDS */
PD_12, // D42 - Green LED
PD_13, // D43 - Orange LED
PD_14, // D44 - Red LED
PD_15, // D45 - Blue LED

/* DHT11 */
PD_11, // D46 - DHT11 senor input
};

// Analog (Ax) pin number array
const uint32_t analogInputPin[] = {
41, //A0 - Temp Sensor
3, //A1 - PA3
0 //A2 - PC2
};

#ifdef __cplusplus
}
#endif

// ----------------------------------------------------------------------------

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief System Clock Configuration
* The system Clock is configured as follow :
* System Clock source = PLL (HSE)
* SYSCLK(Hz) = 144000000
* HCLK(Hz) = 144000000
* AHB Prescaler = 1
* APB1 Prescaler = 4
* APB2 Prescaler = 2
* HSE Frequency(Hz) = 8000000
* PLL_M = 8
* PLL_N = 288
* PLL_P = 2
* PLL_Q = 6
* VDD(V) = 3.3
* Main regulator output voltage = Scale1 mode
* Flash Latency(WS) = 4
* @param None
* @retval None
* @note: 144MHz frequency is used to provide standard CAN bitrates
*/
WEAK void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;

/* Enable Power Control clock */
__HAL_RCC_PWR_CLK_ENABLE();

/* The voltage scaling allows optimizing the power consumption when the device is
clocked below the maximum system frequency, to update the voltage scaling value
regarding system frequency refer to product datasheet. */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

/* Enable HSE Oscillator and activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 8;
RCC_OscInitStruct.PLL.PLLN = 288;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 6;
HAL_RCC_OscConfig(&RCC_OscInitStruct);

/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |
RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 144MHz/1 = 144MHz
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; // 144MHz/4 = 36MHz
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; // 144MHz/2 = 72MHz
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);

/* STM32F405x/407x/415x/417x Revision Z devices: prefetch is supported */
if (HAL_GetREVID() == 0x1001) {
/* Enable the Flash prefetch */
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
}
}

#ifdef __cplusplus
}
#endif
175 changes: 175 additions & 0 deletions variants/GLOBALLOGIC_ESK/variant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/*
*******************************************************************************
* Copyright (c) 2020, 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
*
*******************************************************************************
*
* Author: Sergey Shcherbakov 2020
* As a base used board_template/variant.h
*/

#ifndef _VARIANT_ARDUINO_STM32_
#define _VARIANT_ARDUINO_STM32_

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

/*----------------------------------------------------------------------------
* Pins
*----------------------------------------------------------------------------*/

/* Test pins */
#define PC2 0 // TP2
#define PE6 1 // TP3
#define PC13 2 // TP4
#define PA3 3 // TP5
#define PE5 4 // TP6
#define PD6 5 // TP7
#define PD3 6 // TP8
#define PD2 7 // TP9
#define PB14 8 // TP10
#define PB15 9 // TP11
#define PA8 10 // TP12

/* Button switches */
#define PC11 11 // SW1
#define PA15 12 // SW2
#define PC9 13 // SW3
#define PC6 14 // SW4
#define PC8 15 // SW5

/* WH1602 Char Display */
#define PE7 16 // DISP_RS
#define PE10 17 // DISP_RW
#define PE11 18 // DISP_ENA
#define PE12 19 // DISP_DB4
#define PE13 20 // DISP_DB5
#define PE14 21 // DISP_DB6
#define PE15 22 // DISP_DB7
#define PE9 23 // Display backlight open-drain output

/* Ethernet */
#define PB0 24 // ETH_UP_LED#, it's should be used by Ethernet driver
#define PE8 25 // RMII_PHY_INT#, it's should be used by Ethernet driver _ONLY_
#define PD10 26 // RMII_PHY_RST#, it's should be used by Ethernet driver _ONLY_

/* MEMS */
#define PE4 27 // MEMS_INT1#_A/G
#define PE2 28 // MEMS_INT2#_A/G
#define PB8 29 // MEMS_INT#_M

/* USART3 */
#define PD9 30 // USART3_RX
#define PD8 31 // USART3_TX

/* I2C */
#define PB6 32 // I2C1_SCL
#define PB9 33 // I2C1_SDA

/* SPI */
#define PA5 34 // SPI1_SCK
#define PB5 35 // SPI1_MOSI
#define PB4 36 // SPI1_MISO
#define PD7 37 // SPI1_CS0#

/* CAN */
#define PD0 38 // CAN1_RX
#define PD1 39 // CAN1_TX

/* Other */
#define PB7 40 // PWM_EN
#define PB1 A0 // ADC only, i.e. it's connected to Temperature Sensor

/* LEDs */
#define PD12 42 // Green LED
#define PD13 43 // Orange LED
#define PD14 44 // Red LED
#define PD15 45 // Blue LED

/* DHT11 */
#define PD11 46 // DHT11 sensor input

// This must be a literal
#define NUM_DIGITAL_PINS 47
// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS
#define NUM_ANALOG_INPUTS 3

// On-board LED pin number
#define LED_GREEN PD12
#define LED_BLUE PD15
#define LED_RED PD14
#define LED_ORANGE PD13
#define LED_BUILTIN LED_GREEN

// On-board user button
#define USER_BTN 2 /* PA0 */

// SPI Definitions
#define PIN_SPI_SS NC // No HW SS is available, PD7 pin will be used
#define PIN_SPI_MOSI PB5
#define PIN_SPI_MISO PB4
#define PIN_SPI_SCK PA5

// I2C Definitions
#define PIN_WIRE_SDA PB9
#define PIN_WIRE_SCL PB6

// CAN Definitions
#define PIN_CAN_RX PD0 // CAN1_RX
#define PIN_CAN_TX PD1 // CAN1_TX

// Timer Definitions
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
#define TIMER_TONE TIM6
#define TIMER_SERVO TIM7

// UART Definitions
#define SERIAL_UART_INSTANCE 3

// Default pin used for 'Serial' instance (ex: ST-Link)
// Mandatory for Firmata
#define PIN_SERIAL_RX PD9
#define PIN_SERIAL_TX PD8

/* Extra HAL modules */
#define HAL_ETH_MODULE_ENABLED
#define HAL_CAN_MODULE_ENABLED

#ifdef __cplusplus
} // extern "C"
#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 // Require connections for ST-LINK VCP on U2 pin 12 and 13.
// See UM §6.1.3 ST-LINK/V2-A VCP configuration)
#define SERIAL_PORT_HARDWARE_OPEN Serial
#endif

#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */

#endif /* _VARIANT_ARDUINO_STM32_ */