Skip to content

Commit 5a112bf

Browse files
tofuman0fpistm
tofuman0
authored andcommitted
Added variant for Nucleo-F303K8
Signed-off-by: tofuman0 <none>
1 parent c0e9e94 commit 5a112bf

File tree

5 files changed

+1046
-0
lines changed

5 files changed

+1046
-0
lines changed
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2016, 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+
#include "Arduino.h"
31+
#include "PeripheralPins.h"
32+
33+
// =====
34+
// Note: Commented lines are alternative possibilities which are not used per default.
35+
// If you change them, you will have to know what you do
36+
// =====
37+
38+
39+
//*** ADC ***
40+
41+
const PinMap PinMap_ADC[] = {
42+
{PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1
43+
{PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2
44+
{PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3
45+
{PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4
46+
{PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1
47+
{PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2
48+
{PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3
49+
{PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4
50+
{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11
51+
{PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12
52+
{NC, NP, 0}
53+
};
54+
55+
//*** DAC ***
56+
57+
const PinMap PinMap_DAC[] = {
58+
{PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC1_OUT1
59+
{PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC1_OUT2
60+
{PA_6, DAC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC2_OUT1
61+
{NC, NP, 0}
62+
};
63+
64+
//*** I2C ***
65+
66+
const PinMap PinMap_I2C_SDA[] = {
67+
// {PA_14, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
68+
{PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
69+
{NC, NP, 0}
70+
};
71+
72+
const PinMap PinMap_I2C_SCL[] = {
73+
// {PA_15, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
74+
{PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
75+
{NC, NP, 0}
76+
};
77+
78+
//*** PWM ***
79+
80+
const PinMap PinMap_PWM[] = {
81+
{PA_1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM15, 1, 1)}, // TIM15_CH1N
82+
{PA_2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM15, 1, 0)}, // TIM15_CH1
83+
{PA_3, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM15, 2, 0)}, // TIM15_CH2
84+
{PA_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
85+
{PA_6, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1
86+
{PA_7, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 0)}, // TIM17_CH1
87+
{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_TIM1, 1, 0)}, // TIM1_CH1
88+
{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_TIM1, 2, 0)}, // TIM1_CH2
89+
{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_TIM1, 3, 0)}, // TIM1_CH3
90+
{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_TIM1, 4, 0)}, // TIM1_CH4
91+
{PA_12, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1
92+
{PA_13, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 1)}, // TIM16_CH1N
93+
94+
{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_TIM1, 2, 1)}, // TIM1_CH2N
95+
{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_TIM1, 3, 1)}, // TIM1_CH3N
96+
{PB_4, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1
97+
{PB_5, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_TIM17, 1, 0)}, // TIM17_CH1
98+
{PB_6, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 1)}, // TIM16_CH1N
99+
{PB_7, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 1)}, // TIM17_CH1N
100+
101+
{PF_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_TIM1, 3, 1)}, // TIM1_CH3N
102+
{NC, NP, 0}
103+
};
104+
105+
//*** SERIAL ***
106+
107+
#ifdef HAL_UART_MODULE_ENABLED
108+
const PinMap PinMap_UART_TX[] = {
109+
{PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
110+
{PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
111+
{PA_14, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
112+
{PB_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
113+
{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
114+
{NC, NP, 0}
115+
};
116+
#endif
117+
118+
#ifdef HAL_UART_MODULE_ENABLED
119+
const PinMap PinMap_UART_RX[] = {
120+
{PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
121+
{PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
122+
{PA_15, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
123+
{PB_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
124+
{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
125+
{NC, NP, 0}
126+
};
127+
#endif
128+
129+
#ifdef HAL_UART_MODULE_ENABLED
130+
const PinMap PinMap_UART_RTS[] = {
131+
{PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
132+
{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
133+
{NC, NP, 0}
134+
};
135+
#endif
136+
137+
#ifdef HAL_UART_MODULE_ENABLED
138+
const PinMap PinMap_UART_CTS[] = {
139+
{PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
140+
{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
141+
{NC, NP, 0}
142+
};
143+
#endif
144+
145+
//*** SPI ***
146+
147+
#ifdef HAL_SPI_MODULE_ENABLED
148+
const PinMap PinMap_SPI_MOSI[] = {
149+
{PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
150+
{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
151+
{NC, NP, 0}
152+
};
153+
#endif
154+
155+
#ifdef HAL_SPI_MODULE_ENABLED
156+
const PinMap PinMap_SPI_MISO[] = {
157+
{PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
158+
{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
159+
{NC, NP, 0}
160+
};
161+
#endif
162+
163+
#ifdef HAL_SPI_MODULE_ENABLED
164+
const PinMap PinMap_SPI_SCLK[] = {
165+
{PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
166+
{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
167+
{NC, NP, 0}
168+
};
169+
#endif
170+
171+
#ifdef HAL_SPI_MODULE_ENABLED
172+
const PinMap PinMap_SPI_SSEL[] = {
173+
{PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
174+
{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
175+
{NC, NP, 0}
176+
};
177+
#endif
178+
179+
//*** CAN ***
180+
181+
#ifdef HAL_CAN_MODULE_ENABLED
182+
const PinMap PinMap_CAN_RD[] = {
183+
{PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
184+
{NC, NP, 0}
185+
};
186+
#endif
187+
188+
#ifdef HAL_CAN_MODULE_ENABLED
189+
const PinMap PinMap_CAN_TD[] = {
190+
{PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
191+
{NC, NP, 0}
192+
};
193+
#endif

variants/NUCLEO_F303K8/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+
** Abstract : Linker script for STM32F303K8Tx Device with
8+
** 64KByte FLASH, 12KByte RAM
9+
**
10+
** Set heap size, stack size and stack location according
11+
** to application requirements.
12+
**
13+
** Set memory bank area and size if external memory is used.
14+
**
15+
** Target : STMicroelectronics STM32
16+
**
17+
**
18+
** Distribution: The file is distributed as is, without any warranty
19+
** of any kind.
20+
**
21+
** (c)Copyright Ac6.
22+
** You may use this file as-is or modify it according to the needs of your
23+
** project. Distribution of this file (unmodified or modified) is not
24+
** permitted. Ac6 permit registered System Workbench for MCU users the
25+
** rights to distribute the assembled, compiled & linked contents of this
26+
** file as part of an application binary file, provided that it is built
27+
** using the System Workbench for MCU toolchain.
28+
**
29+
*****************************************************************************
30+
*/
31+
32+
/* Entry Point */
33+
ENTRY(Reset_Handler)
34+
35+
/* Highest address of the user mode stack */
36+
_estack = 0x20003000; /* end of RAM */
37+
/* Generate a link error if heap and stack don't fit into RAM */
38+
_Min_Heap_Size = 0x200; /* required amount of heap */
39+
_Min_Stack_Size = 0x400; /* required amount of stack */
40+
41+
/* Specify the memory areas */
42+
MEMORY
43+
{
44+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 12K
45+
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 4K
46+
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K
47+
}
48+
49+
/* Define output sections */
50+
SECTIONS
51+
{
52+
/* The startup code goes first into FLASH */
53+
.isr_vector :
54+
{
55+
. = ALIGN(4);
56+
KEEP(*(.isr_vector)) /* Startup code */
57+
. = ALIGN(4);
58+
} >FLASH
59+
60+
/* The program code and other data goes into FLASH */
61+
.text :
62+
{
63+
. = ALIGN(4);
64+
*(.text) /* .text sections (code) */
65+
*(.text*) /* .text* sections (code) */
66+
*(.glue_7) /* glue arm to thumb code */
67+
*(.glue_7t) /* glue thumb to arm code */
68+
*(.eh_frame)
69+
70+
KEEP (*(.init))
71+
KEEP (*(.fini))
72+
73+
. = ALIGN(4);
74+
_etext = .; /* define a global symbols at end of code */
75+
} >FLASH
76+
77+
/* Constant data goes into FLASH */
78+
.rodata :
79+
{
80+
. = ALIGN(4);
81+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
82+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
83+
. = ALIGN(4);
84+
} >FLASH
85+
86+
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
87+
.ARM : {
88+
__exidx_start = .;
89+
*(.ARM.exidx*)
90+
__exidx_end = .;
91+
} >FLASH
92+
93+
.preinit_array :
94+
{
95+
PROVIDE_HIDDEN (__preinit_array_start = .);
96+
KEEP (*(.preinit_array*))
97+
PROVIDE_HIDDEN (__preinit_array_end = .);
98+
} >FLASH
99+
.init_array :
100+
{
101+
PROVIDE_HIDDEN (__init_array_start = .);
102+
KEEP (*(SORT(.init_array.*)))
103+
KEEP (*(.init_array*))
104+
PROVIDE_HIDDEN (__init_array_end = .);
105+
} >FLASH
106+
.fini_array :
107+
{
108+
PROVIDE_HIDDEN (__fini_array_start = .);
109+
KEEP (*(SORT(.fini_array.*)))
110+
KEEP (*(.fini_array*))
111+
PROVIDE_HIDDEN (__fini_array_end = .);
112+
} >FLASH
113+
114+
/* used by the startup to initialize data */
115+
_sidata = LOADADDR(.data);
116+
117+
/* Initialized data sections goes into RAM, load LMA copy after code */
118+
.data :
119+
{
120+
. = ALIGN(4);
121+
_sdata = .; /* create a global symbol at data start */
122+
*(.data) /* .data sections */
123+
*(.data*) /* .data* sections */
124+
125+
. = ALIGN(4);
126+
_edata = .; /* define a global symbol at data end */
127+
} >RAM AT> FLASH
128+
129+
_siccmram = LOADADDR(.ccmram);
130+
131+
/* CCM-RAM section
132+
*
133+
* IMPORTANT NOTE!
134+
* If initialized variables will be placed in this section,
135+
* the startup code needs to be modified to copy the init-values.
136+
*/
137+
.ccmram :
138+
{
139+
. = ALIGN(4);
140+
_sccmram = .; /* create a global symbol at ccmram start */
141+
*(.ccmram)
142+
*(.ccmram*)
143+
144+
. = ALIGN(4);
145+
_eccmram = .; /* create a global symbol at ccmram end */
146+
} >CCMRAM 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+

0 commit comments

Comments
 (0)