Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 40de708

Browse files
committedOct 18, 2019
Added ThunderPack board (STM32L0xx)
- Add dfu-util as a upload option to platform.txt. - https://github.com/jgillick/ThunderPack
1 parent b4c6e2e commit 40de708

File tree

8 files changed

+685
-0
lines changed

8 files changed

+685
-0
lines changed
 

‎boards.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,3 +1991,35 @@ Midatronics.menu.rtlib.nanofps=Newlib Nano + Float Printf/Scanf
19911991
Midatronics.menu.rtlib.nanofps.build.flags.ldspecs=--specs=nano.specs -u _printf_float -u _scanf_float
19921992
Midatronics.menu.rtlib.full=Newlib Standard
19931993
Midatronics.menu.rtlib.full.build.flags.ldspecs=
1994+
1995+
###############################
1996+
# ThunderPack
1997+
ThunderPack.name=ThunderPack
1998+
ThunderPack.build.core=arduino
1999+
ThunderPack.build.product_line=STM32L072xx
2000+
ThunderPack.build.board=ThunderPack
2001+
ThunderPack.build.variant=THUNDER_PACK
2002+
ThunderPack.build.mcu=cortex-m0plus
2003+
ThunderPack.build.series=STM32L0xx
2004+
ThunderPack.build.cmsis_lib_gcc=arm_cortexM0l_math
2005+
ThunderPack.build.vid=0x0483
2006+
ThunderPack.build.extra_flags={build.usb_flags} -DUSBD_USE_CDC -D{build.product_line} {build.enable_usb} {build.xSerial} -D__CORTEX_SC=0
2007+
2008+
ThunderPack.upload.maximum_size=196608
2009+
ThunderPack.upload.maximum_data_size=20480
2010+
2011+
ThunderPack.menu.upload_method.dfuUtil=DFU Util
2012+
ThunderPack.menu.upload_method.dfuUtil.upload.tool=dfu_util
2013+
ThunderPack.menu.upload_method.dfuUtil.upload.protocol=
2014+
ThunderPack.menu.upload_method.dfuUtil.upload.usbID=0483:df11
2015+
ThunderPack.menu.upload_method.dfuUtil.upload.address=0x08000000:leave
2016+
2017+
ThunderPack.menu.upload_method.swdMethod=STM32CubeProgrammer (SWD)
2018+
ThunderPack.menu.upload_method.swdMethod.upload.protocol=0
2019+
ThunderPack.menu.upload_method.swdMethod.upload.options=-g
2020+
ThunderPack.menu.upload_method.swdMethod.upload.tool=stm32CubeProg
2021+
2022+
ThunderPack.menu.upload_method.dfuMethod=STM32CubeProgrammer (DFU)
2023+
ThunderPack.menu.upload_method.dfuMethod.upload.protocol=2
2024+
ThunderPack.menu.upload_method.dfuMethod.upload.options=-g
2025+
ThunderPack.menu.upload_method.dfuMethod.upload.tool=stm32CubeProg

‎platform.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,14 @@ tools.maple_upload.path.linux={runtime.tools.STM32Tools.path}/tools/linux
200200
tools.maple_upload.upload.params.verbose=-d
201201
tools.maple_upload.upload.params.quiet=n
202202
tools.maple_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin"
203+
204+
# Upload using dfu-util
205+
tools.dfu_util.cmd=dfu-util
206+
tools.dfu_util.cmd.windows=dfu-util.exe
207+
tools.dfu_util.path={runtime.tools.STM32Tools.path}/tools/win/dfu-util
208+
tools.dfu_util.path.macosx={runtime.tools.STM32Tools.path}/tools/macosx/dfu-util
209+
tools.dfu_util.path.linux={runtime.tools.STM32Tools.path}/tools/linux/dfu-util
210+
tools.dfu_util.path.linux64={runtime.tools.STM32Tools.path}/tools/linux64/dfu-util
211+
tools.dfu_util.upload.params.verbose=-v
212+
tools.dfu_util.upload.params.quiet=
213+
tools.dfu_util.upload.pattern="{path}/{cmd}" --device {upload.usbID} -a 0 --dfuse-address {upload.address} -D "{build.path}/{build.project_name}.bin"
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2019, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* This software component is licensed by ST under BSD 3-Clause license,
7+
* the "License"; You may not use this file except in compliance with the
8+
* License. You may obtain a copy of the License at:
9+
* opensource.org/licenses/BSD-3-Clause
10+
*
11+
*******************************************************************************
12+
* Automatically generated from STM32L072C(B-Z)Tx.xml
13+
*/
14+
#include "Arduino.h"
15+
#include "PeripheralPins.h"
16+
17+
/* =====
18+
* Note: Commented lines are alternative possibilities which are not used per default.
19+
* If you change them, you will have to know what you do
20+
* =====
21+
*/
22+
23+
//*** ADC ***
24+
25+
#ifdef HAL_ADC_MODULE_ENABLED
26+
WEAK const PinMap PinMap_ADC[] = {
27+
{PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC_IN4
28+
{PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC_IN5
29+
{PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC_IN6
30+
{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC_IN7
31+
{NC, NP, 0}
32+
};
33+
#endif
34+
35+
//*** DAC ***
36+
37+
#ifdef HAL_DAC_MODULE_ENABLED
38+
WEAK const PinMap PinMap_DAC[] = {
39+
{PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1
40+
{PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2
41+
{NC, NP, 0}
42+
};
43+
#endif
44+
45+
//*** I2C ***
46+
47+
#ifdef HAL_I2C_MODULE_ENABLED
48+
WEAK const PinMap PinMap_I2C_SDA[] = {
49+
{PA_10, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)},
50+
{PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF1_I2C1)},
51+
{NC, NP, 0}
52+
};
53+
#endif
54+
55+
#ifdef HAL_I2C_MODULE_ENABLED
56+
WEAK const PinMap PinMap_I2C_SCL[] = {
57+
{PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF7_I2C3)},
58+
{PA_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)},
59+
{PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF1_I2C1)},
60+
{PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
61+
{NC, NP, 0}
62+
};
63+
#endif
64+
65+
//*** PWM ***
66+
67+
#ifdef HAL_TIM_MODULE_ENABLED
68+
WEAK const PinMap PinMap_PWM[] = {
69+
{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1
70+
{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 2, 0)}, // TIM2_CH2
71+
{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3
72+
// {PA_2, TIM21, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM21, 1, 0)}, // TIM21_CH1
73+
{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4
74+
// {PA_3, TIM21, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM21, 2, 0)}, // TIM21_CH2
75+
// {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM2, 1, 0)}, // TIM2_CH1
76+
{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
77+
// {PA_6, TIM22, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM22, 1, 0)}, // TIM22_CH1
78+
{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
79+
// {PA_7, TIM22, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM22, 2, 0)}, // TIM22_CH2
80+
{NC, NP, 0}
81+
};
82+
#endif
83+
84+
//*** SERIAL ***
85+
86+
#ifdef HAL_UART_MODULE_ENABLED
87+
WEAK const PinMap PinMap_UART_TX[] = {
88+
{PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)},
89+
// {PA_14, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)},
90+
{PA_14, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART2)},
91+
{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)},
92+
{NC, NP, 0}
93+
};
94+
#endif
95+
96+
#ifdef HAL_UART_MODULE_ENABLED
97+
WEAK const PinMap PinMap_UART_RX[] = {
98+
{PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)},
99+
{PA_13, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)},
100+
{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)},
101+
{NC, NP, 0}
102+
};
103+
#endif
104+
105+
#ifdef HAL_UART_MODULE_ENABLED
106+
WEAK const PinMap PinMap_UART_RTS[] = {
107+
{NC, NP, 0}
108+
};
109+
#endif
110+
111+
#ifdef HAL_UART_MODULE_ENABLED
112+
WEAK const PinMap PinMap_UART_CTS[] = {
113+
{PA_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_LPUART1)},
114+
{PB_7, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USART4)},
115+
{NC, NP, 0}
116+
};
117+
#endif
118+
119+
//*** SPI ***
120+
121+
#ifdef HAL_SPI_MODULE_ENABLED
122+
WEAK const PinMap PinMap_SPI_MOSI[] = {
123+
{PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)},
124+
{NC, NP, 0}
125+
};
126+
#endif
127+
128+
#ifdef HAL_SPI_MODULE_ENABLED
129+
WEAK const PinMap PinMap_SPI_MISO[] = {
130+
{PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)},
131+
{NC, NP, 0}
132+
};
133+
#endif
134+
135+
#ifdef HAL_SPI_MODULE_ENABLED
136+
WEAK const PinMap PinMap_SPI_SCLK[] = {
137+
{PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)},
138+
{NC, NP, 0}
139+
};
140+
#endif
141+
142+
#ifdef HAL_SPI_MODULE_ENABLED
143+
WEAK const PinMap PinMap_SPI_SSEL[] = {
144+
{PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)},
145+
{NC, NP, 0}
146+
};
147+
#endif
148+
149+
//*** No CAN ***
150+
151+
//*** No ETHERNET ***
152+
153+
//*** No QUADSPI ***
154+
155+
//*** USB ***
156+
157+
#ifdef HAL_PCD_MODULE_ENABLED
158+
WEAK const PinMap PinMap_USB[] = {
159+
{PA_11, USB, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_DM
160+
{PA_12, USB, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_DP
161+
{PA_13, USB, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_USB)}, // USB_NOE
162+
{NC, NP, 0}
163+
};
164+
#endif
165+
166+
//*** No USB_OTG_FS ***
167+
168+
//*** No USB_OTG_HS ***

‎variants/THUNDER_PACK/PinNamesVar.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* SYS_WKUP */
2+
#ifdef PWR_WAKEUP_PIN1
3+
SYS_WKUP1 = PA_0,
4+
#endif
5+
#ifdef PWR_WAKEUP_PIN2
6+
SYS_WKUP2 = PC_13,
7+
#endif
8+
#ifdef PWR_WAKEUP_PIN3
9+
SYS_WKUP3 = NC,
10+
#endif
11+
#ifdef PWR_WAKEUP_PIN4
12+
SYS_WKUP4 = NC,
13+
#endif
14+
#ifdef PWR_WAKEUP_PIN5
15+
SYS_WKUP5 = NC,
16+
#endif
17+
#ifdef PWR_WAKEUP_PIN6
18+
SYS_WKUP6 = NC,
19+
#endif
20+
#ifdef PWR_WAKEUP_PIN7
21+
SYS_WKUP7 = NC,
22+
#endif
23+
#ifdef PWR_WAKEUP_PIN8
24+
SYS_WKUP8 = NC,
25+
#endif
26+
/* USB */
27+
#ifdef USBCON
28+
USB_DM = PA_11,
29+
USB_DP = PA_12,
30+
USB_NOE = PA_13,
31+
#endif

‎variants/THUNDER_PACK/ldscript.ld

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/*
2+
******************************************************************************
3+
**
4+
5+
** File : LinkerScript.ld
6+
**
7+
** Author : Auto-generated by Ac6 System Workbench
8+
**
9+
** Abstract : Linker script for STM32L072KZTx series
10+
** 192Kbytes FLASH and 20Kbytes RAM
11+
**
12+
** Set heap size, stack size and stack location according
13+
** to application requirements.
14+
**
15+
** Set memory bank area and size if external memory is used.
16+
**
17+
** Target : STMicroelectronics STM32
18+
**
19+
** Distribution: The file is distributed “as is,” without any warranty
20+
** of any kind.
21+
**
22+
*****************************************************************************
23+
** @attention
24+
**
25+
** <h2><center>&copy; COPYRIGHT(c) 2014 Ac6</center></h2>
26+
**
27+
** Redistribution and use in source and binary forms, with or without modification,
28+
** are permitted provided that the following conditions are met:
29+
** 1. Redistributions of source code must retain the above copyright notice,
30+
** this list of conditions and the following disclaimer.
31+
** 2. Redistributions in binary form must reproduce the above copyright notice,
32+
** this list of conditions and the following disclaimer in the documentation
33+
** and/or other materials provided with the distribution.
34+
** 3. Neither the name of Ac6 nor the names of its contributors
35+
** may be used to endorse or promote products derived from this software
36+
** without specific prior written permission.
37+
**
38+
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39+
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40+
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41+
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
42+
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
44+
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
45+
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46+
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47+
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48+
**
49+
*****************************************************************************
50+
*/
51+
52+
/* Entry Point */
53+
ENTRY(Reset_Handler)
54+
55+
/* Highest address of the user mode stack */
56+
_estack = 0x20005000; /* end of RAM */
57+
/* Generate a link error if heap and stack don't fit into RAM */
58+
_Min_Heap_Size = 0x200; /* required amount of heap */
59+
_Min_Stack_Size = 0x400; /* required amount of stack */
60+
61+
/* Specify the memory areas */
62+
MEMORY
63+
{
64+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
65+
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 192K
66+
}
67+
68+
/* Define output sections */
69+
SECTIONS
70+
{
71+
/* The startup code goes first into FLASH */
72+
.isr_vector :
73+
{
74+
. = ALIGN(4);
75+
KEEP(*(.isr_vector)) /* Startup code */
76+
. = ALIGN(4);
77+
} >FLASH
78+
79+
/* The program code and other data goes into FLASH */
80+
.text :
81+
{
82+
. = ALIGN(4);
83+
*(.text) /* .text sections (code) */
84+
*(.text*) /* .text* sections (code) */
85+
*(.glue_7) /* glue arm to thumb code */
86+
*(.glue_7t) /* glue thumb to arm code */
87+
*(.eh_frame)
88+
89+
KEEP (*(.init))
90+
KEEP (*(.fini))
91+
92+
. = ALIGN(4);
93+
_etext = .; /* define a global symbols at end of code */
94+
} >FLASH
95+
96+
/* Constant data goes into FLASH */
97+
.rodata :
98+
{
99+
. = ALIGN(4);
100+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
101+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
102+
. = ALIGN(4);
103+
} >FLASH
104+
105+
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
106+
.ARM : {
107+
__exidx_start = .;
108+
*(.ARM.exidx*)
109+
__exidx_end = .;
110+
} >FLASH
111+
112+
.preinit_array :
113+
{
114+
PROVIDE_HIDDEN (__preinit_array_start = .);
115+
KEEP (*(.preinit_array*))
116+
PROVIDE_HIDDEN (__preinit_array_end = .);
117+
} >FLASH
118+
.init_array :
119+
{
120+
PROVIDE_HIDDEN (__init_array_start = .);
121+
KEEP (*(SORT(.init_array.*)))
122+
KEEP (*(.init_array*))
123+
PROVIDE_HIDDEN (__init_array_end = .);
124+
} >FLASH
125+
.fini_array :
126+
{
127+
PROVIDE_HIDDEN (__fini_array_start = .);
128+
KEEP (*(SORT(.fini_array.*)))
129+
KEEP (*(.fini_array*))
130+
PROVIDE_HIDDEN (__fini_array_end = .);
131+
} >FLASH
132+
133+
/* used by the startup to initialize data */
134+
_sidata = LOADADDR(.data);
135+
136+
/* Initialized data sections goes into RAM, load LMA copy after code */
137+
.data :
138+
{
139+
. = ALIGN(4);
140+
_sdata = .; /* create a global symbol at data start */
141+
*(.data) /* .data sections */
142+
*(.data*) /* .data* sections */
143+
144+
. = ALIGN(4);
145+
_edata = .; /* define a global symbol at data end */
146+
} >RAM AT> FLASH
147+
148+
149+
/* Uninitialized data section */
150+
. = ALIGN(4);
151+
.bss :
152+
{
153+
/* This is used by the startup in order to initialize the .bss secion */
154+
_sbss = .; /* define a global symbol at bss start */
155+
__bss_start__ = _sbss;
156+
*(.bss)
157+
*(.bss*)
158+
*(COMMON)
159+
160+
. = ALIGN(4);
161+
_ebss = .; /* define a global symbol at bss end */
162+
__bss_end__ = _ebss;
163+
} >RAM
164+
165+
/* User_heap_stack section, used to check that there is enough RAM left */
166+
._user_heap_stack :
167+
{
168+
. = ALIGN(8);
169+
PROVIDE ( end = . );
170+
PROVIDE ( _end = . );
171+
. = . + _Min_Heap_Size;
172+
. = . + _Min_Stack_Size;
173+
. = ALIGN(8);
174+
} >RAM
175+
176+
177+
178+
/* Remove information from the standard libraries */
179+
/DISCARD/ :
180+
{
181+
libc.a ( * )
182+
libm.a ( * )
183+
libgcc.a ( * )
184+
}
185+
186+
.ARM.attributes 0 : { *(.ARM.attributes) }
187+
}
188+
189+

‎variants/THUNDER_PACK/readme.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# ThunderPack
2+
A self-contained microcontroller, battery and power management system that fits in your pocket.
3+
4+
More info: https://github.com/jgillick/ThunderPack

‎variants/THUNDER_PACK/variant.cpp

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2017, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
15+
* may be used to endorse or promote products derived from this software
16+
* without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*******************************************************************************
29+
*/
30+
31+
#include "pins_arduino.h"
32+
33+
#ifdef __cplusplus
34+
extern "C" {
35+
#endif
36+
37+
// Pin number
38+
const PinName digitalPin[] = {
39+
PA_0, //D0
40+
PA_1, //D1
41+
PA_2, //D2
42+
PA_3, //D3
43+
PA_4, //D4 / A0
44+
PA_5, //D5 / A1
45+
PA_6, //D6 / A2
46+
PA_7, //D7 / A3
47+
PA_8, //D8
48+
PA_9, //D9
49+
PA_10, //D10
50+
PB_6, //D11
51+
PB_7, //D12
52+
PB_8, //D13
53+
PB_4, //D14 - User button
54+
NC, //D15
55+
NC, //D16
56+
PA_11, //D17 - USB_D-
57+
PA_12, //D18 - USB_D+
58+
PA_13, //D19 - SWD
59+
PA_14, //D20 - SWD
60+
};
61+
62+
#ifdef __cplusplus
63+
}
64+
#endif
65+
66+
// ----------------------------------------------------------------------------
67+
68+
#ifdef __cplusplus
69+
extern "C" {
70+
#endif
71+
72+
/**
73+
* @brief System Clock Configuration
74+
* @param None
75+
* @retval None
76+
*/
77+
WEAK void SystemClock_Config(void)
78+
{
79+
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
80+
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
81+
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
82+
83+
/** Configure the main internal regulator output voltage
84+
*/
85+
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
86+
/** Initializes the CPU, AHB and APB busses clocks
87+
*/
88+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI48;
89+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
90+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
91+
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
92+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
93+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
94+
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_4;
95+
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2;
96+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
97+
{
98+
_Error_Handler(__FILE__, __LINE__);
99+
}
100+
/** Initializes the CPU, AHB and APB busses clocks
101+
*/
102+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
103+
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
104+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
105+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
106+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
107+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
108+
109+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
110+
{
111+
_Error_Handler(__FILE__, __LINE__);
112+
}
113+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_I2C1
114+
|RCC_PERIPHCLK_USB;
115+
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
116+
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
117+
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
118+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
119+
{
120+
_Error_Handler(__FILE__, __LINE__);
121+
}
122+
}
123+
124+
#ifdef __cplusplus
125+
}
126+
#endif

‎variants/THUNDER_PACK/variant.h

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2017, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
15+
* may be used to endorse or promote products derived from this software
16+
* without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*******************************************************************************
29+
*/
30+
31+
#ifndef _VARIANT_ARDUINO_STM32_
32+
#define _VARIANT_ARDUINO_STM32_
33+
34+
#ifdef __cplusplus
35+
extern "C" {
36+
#endif // __cplusplus
37+
38+
/*----------------------------------------------------------------------------
39+
* Pins
40+
*----------------------------------------------------------------------------*/
41+
42+
#define PA0 0
43+
#define PA1 1
44+
#define PA2 2
45+
#define PA3 3
46+
#define PA4 4 // A0
47+
#define PA5 5 // A1
48+
#define PA6 6 // A2
49+
#define PA7 7 // A3
50+
#define PA8 8
51+
#define PA9 9
52+
#define PA10 10
53+
#define PB6 11 // TX
54+
#define PB7 12 // RX
55+
#define PB8 13
56+
#define PB4 14 // User button
57+
58+
#define PA11 17 // USB_D-
59+
#define PA12 18 // USB_D+
60+
#define PA13 19 // SWD
61+
#define PA14 20 // SWD
62+
63+
// This must be a literal
64+
#define NUM_DIGITAL_PINS 19
65+
66+
// This must be a literal with a value less than or equal to MAX_ANALOG_INPUTS
67+
#define NUM_ANALOG_INPUTS 4
68+
#define NUM_ANALOG_FIRST 4
69+
70+
// On-board LED pin number
71+
#define LED_BUILTIN 0
72+
#define LED_GREEN LED_BUILTIN
73+
#define LED_1 0
74+
#define LED_2 1
75+
#define LED_3 2
76+
#define LED_4 3
77+
78+
// On-board user button
79+
#define USER_BTN PB4
80+
81+
// Timer Definitions
82+
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
83+
#define TIMER_TONE TIM6
84+
#define TIMER_SERVO TIM7
85+
86+
// UART Definitions
87+
#define SERIAL_UART_INSTANCE 1 //ex: 2 for Serial2 (USART2)
88+
89+
// Default pin used for 'Serial' instance (ex: ST-Link)
90+
// Mandatory for Firmata
91+
#define PIN_SERIAL_RX 12
92+
#define PIN_SERIAL_TX 11
93+
94+
/* Extra HAL modules */
95+
#define HAL_DAC_MODULE_ENABLED
96+
97+
#ifdef __cplusplus
98+
} // extern "C"
99+
#endif
100+
/*----------------------------------------------------------------------------
101+
* Arduino objects - C++ only
102+
*----------------------------------------------------------------------------*/
103+
104+
#ifdef __cplusplus
105+
// These serial port names are intended to allow libraries and architecture-neutral
106+
// sketches to automatically default to the correct port name for a particular type
107+
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
108+
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
109+
//
110+
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
111+
//
112+
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
113+
//
114+
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
115+
//
116+
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
117+
//
118+
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
119+
// pins are NOT connected to anything by default.
120+
#define SERIAL_PORT_MONITOR Serial
121+
#define SERIAL_PORT_HARDWARE Serial
122+
#endif
123+
124+
#endif /* _VARIANT_ARDUINO_STM32_ */

0 commit comments

Comments
 (0)
Please sign in to comment.