Skip to content

Create a board variant template #62

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

Merged
merged 1 commit into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions variants/board_template/PeripheralPins.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* This file could be generated thanks a python script: genpinmap_arduino.py
*
* This script allows to generate the pins mapping of a STM32 MCU.
*
* It is included with the STM32Tools package install with this core.
* Go to:
* <local Arduino directory>\packages\STM32\tools\STM32Tools\<version>\tools\src\genpinmap\
* Tips: <local Arduino directory> is displayed in the "Preferences" dialog of the Arduino IDE.
*
* This script is able to generate the PeripheralPins.c using STM32
* xml file description in Cube MX.
* After file generation, review it carefully.
* Comment a line if the pin is generated several times for the same IP
* or if the pin should not be used
* (overlaid with some HW on the board, for instance)
*
* USAGE: genpinmap_arduino.py <BOARD_NAME> <product xml file name>
*
* <BOARD_NAME> is the name of the board as it will be named in variant folder
* <product xml file name> is the STM32 file description in Cube MX
*
* !!This xml file contains non alpha characters in its name, you should call it with quotes
*
*/
26 changes: 26 additions & 0 deletions variants/board_template/ldscript.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
*****************************************************************************
**
** File : ldscript.ld
**
** Abstract : Linker script for STM32 Device
**
** 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
**
**
*****************************************************************************
*/
/* Copy here linker script for the new STM32 Device
* or
* replace this file by the new one with the same file name
* It could be get thanks STM32CubeMX after code generation for Toolchain/IDE: 'SW4STM32',
* ldscript will be availabe in the root folder (STM32YYxxxxxx_FLASH.ld)
* or
* copied from a STM32CubeYY project examples
* where 'YY' could be F0, F1, F2, F3, F4, F7, L0, L1, L4)
*/
2 changes: 2 additions & 0 deletions variants/board_template/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
See Wiki:
https://github.com/stm32duino/wiki/wiki/Add-a-new-variant-(board)
18 changes: 18 additions & 0 deletions variants/board_template/stm32yyxx_hal_conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copy the STM32 HAL config file from the targeted MCU Series HAL
* from ../../system/Drivers/STM32YYxx_HAL_Driver/Inc/stm32yyxx_hal_conf_template.h
* to
* stm32yyxx_hal_conf.h
* where 'yy' could be f0, f1, f2, f3, f4, f7, l0, l1, l4)
*
* Example for a STM32 F4 based board:
* cp ../../system/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_conf_template.h stm32f4xx_hal_conf.h
*
* Then edit it in order to:
* - Disable undesired HAL modules by commenting line like:
* "#define HAL_XXX_MODULE_ENABLED"
* where "XXX" is the feature (ETH, I2S,...)
* - Adjust HSE/HSI Values adaptation if needed
* - Update any other configurations
*
*/
194 changes: 194 additions & 0 deletions variants/board_template/variant.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/*
*******************************************************************************
* Copyright (c) 2017, STMicroelectronics
* All rights reserved.
*
* 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 STMicroelectronics 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.
*******************************************************************************
*/

#include "variant.h"

#ifdef __cplusplus
extern "C" {
#endif

// Pin number
// This array allows to wrap Arduino pin number(Dx or x)
// to STM32 PinName (PYx)
const PinName digitalPin[] = {
//PYx, //Dx
P, //D0
P, //D1
P, //D2
P, //D3
P, //D4
P, //D5
P, //D6
P, //D7
P, //D8
P, //D9
P, //D10
P, //D11
P, //D12
P, //D13
P, //D14
P, //D15
P, //D16
P, //D17
P, //D18
P, //D19
P, //D20
P, //D21
P, //D22
P, //D23
P, //D24
P, //D25
P, //D26
P, //D27
P, //D28
P, //D29
P, //D30
P, //D31
P, //D32
P, //D33
P, //D34
P, //D35
P, //D36
P, //D37
P, //D38
P, //D39
P, //D40
P, //D41
P, //D42
P, //D43
P, //D44
P, //D45
P, //D46
P, //D47
P, //D48
P, //D49
P, //D50
P, //D51
P, //D52
P, //D53
P, //D54
P, //D55
P, //D56
P, //D57
P, //D58
P, //D59
P, //D60
P, //D61
P, //D62
P, //D63
P, //D64
P, //D65
P, //D66
P, //D67
P, //D68
P, //D69
P, //D70
P, //D71
P, //D72
P, //D73
P, //D74
P, //D75
P, //D76
P, //D77
P, //D78/A0
P, //D79/A1
P, //D80/A2
P, //D81/A3
P, //D82/A4
P, //D83/A5
P, //D84/A6
P, //D85/A7
P, //D86/A8
P, //D87/A9
// Duplicated pins in order to be aligned with PinMap_ADC
P, //D88/A10 = D
P, //D89/A11 = D
P, //D90/A12 = D
P, //D91/A13 = D
P, //D92/A14 = D
P, //D93/A15 = D
P, //D94/A16 = D
P //D95/A17 = D
};

#ifdef __cplusplus
}
#endif

/*
* UART objects
*/
// Replace PYx_Rx and PYx_Tx by UART_RX and UART_TX pin names
HardwareSerial Serial(PYx_Rx, PYx_Tx); // Connected to ST-Link

void serialEvent() __attribute__((weak));
void serialEvent() { }

// Define as many Serial instance as desired
// Replace 'SerialX' by the desired name
//#ifdef ENABLE_SERIALX
//HardwareSerial SerialX(PYx_Rx, PYx_Tx);
//
//void serialEventx() __attribute__((weak));
//void serialEventx() { }
//#endif

void serialEventRun(void)
{
if (Serial.available()) serialEvent();
//#ifdef ENABLE_SERIALX
// if (SerialX.available()) serialEventX();
//#endif
}

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

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief System Clock Configuration
* @param None
* @retval None
*/
WEAK void SystemClock_Config(void)
{
// Here copy the desired System Clock Configuration
// It could be generated thanks STM32CubeMX after code generation for Toolchain/IDE: 'SW4STM32',
// available in src/main.c
// or
// copied from a STM32CubeYY project examples
// where 'YY' could be F0, F1, F2, F3, F4, F7, L0, L1, L4
}

#ifdef __cplusplus
}
#endif
Loading