Skip to content

Commit 1ae377b

Browse files
authoredSep 13, 2017
Merge pull request #97 from fprwi6labs/DISCO_L475VG_IOT
New board Discovery L475VG IOT
·
2018.1.181.0.1
2 parents e70c63b + 8a5dce8 commit 1ae377b

File tree

15 files changed

+2526
-2
lines changed

15 files changed

+2526
-2
lines changed
 

‎README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Arduino core support for STM32 based boards
1+
# Arduino core support for STM32 based boards
22
### Latest release [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest)
33
[![GitHub commits](https://img.shields.io/github/commits-since/stm32duino/Arduino_Core_STM32/2017.8.31.svg)](https://github.com/stm32duino/Arduino_Core_STM32/compare/2017.8.31...master)
44

@@ -8,7 +8,7 @@
88

99
## Getting Started
1010

11-
This repo is available as a package usable with [Arduino Boards Manager](https://www.arduino.cc/en/guide/cores).
11+
This repo is available as a package usable with [Arduino Boards Manager](https://www.arduino.cc/en/guide/cores).
1212

1313
For full instructions on using the "**Boards Manager**", see the [Getting Started](https://github.com/stm32duino/wiki/wiki/Getting-Started) page.
1414

@@ -50,6 +50,7 @@ For advanced user, you can use the repository: see the [Using git repository](ht
5050
* STM32L4
5151
* [Nucleo L432KC](http://www.st.com/en/evaluation-tools/nucleo-l432kc.html)
5252
* [Nucleo L476RG](http://www.st.com/en/evaluation-tools/nucleo-l476rg.html)
53+
* [B-L475E-IOT01A](http://www.st.com/en/evaluation-tools/b-l475e-iot01a.html)
5354

5455
## Troubleshooting
5556

‎boards.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,20 @@ Disco.menu.board_part_num.DISCO_F746NG.build.product_line=STM32F746xx
301301
Disco.menu.board_part_num.DISCO_F746NG.build.variant=DISCO_F746NG
302302
Disco.menu.board_part_num.DISCO_F746NG.build.cmsis_lib_gcc=arm_cortexM7l_math
303303

304+
# DISCO_L475VG_IOT board
305+
# Support: USB HID, Serial1 (USART1 on PA1, PA0)
306+
Disco.menu.board_part_num.DISCO_L475VG_IOT=STM32L475VG-DISCOVERY-IOT
307+
Disco.menu.board_part_num.DISCO_L475VG_IOT.node=DIS_L4IOT
308+
Disco.menu.board_part_num.DISCO_L475VG_IOT.upload.maximum_size=1048576
309+
Disco.menu.board_part_num.DISCO_L475VG_IOT.upload.maximum_data_size=98304
310+
Disco.menu.board_part_num.DISCO_L475VG_IOT.build.mcu=cortex-m4
311+
Disco.menu.board_part_num.DISCO_L475VG_IOT.build.f_cpu=80000000L
312+
Disco.menu.board_part_num.DISCO_L475VG_IOT.build.board=DISCO_L475VG_IOT
313+
Disco.menu.board_part_num.DISCO_L475VG_IOT.build.series=STM32L4xx
314+
Disco.menu.board_part_num.DISCO_L475VG_IOT.build.product_line=STM32L475xx
315+
Disco.menu.board_part_num.DISCO_L475VG_IOT.build.variant=DISCO_L475VG_IOT
316+
Disco.menu.board_part_num.DISCO_L475VG_IOT.build.cmsis_lib_gcc=arm_cortexM4l_math
317+
304318
# Upload menu
305319
Disco.menu.upload_method.MassStorageMethod=Mass Storage
306320
Disco.menu.upload_method.MassStorageMethod.upload.protocol=

‎cores/arduino/stm32/PeripheralPins.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,8 @@ extern const PinMap PinMap_CAN_TD[];
6868
//*** ETHERNET ***
6969
extern const PinMap PinMap_Ethernet[];
7070

71+
//*** QUADSPI ***
72+
extern const PinMap PinMap_QUADSPI[];
73+
7174
#endif
7275

‎cores/arduino/stm32/usbd_hid_composite.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ __ALIGN_BEGIN static uint8_t HID_KEYBOARD_ReportDesc[HID_KEYBOARD_REPORT_DESC_SI
369369
static uint8_t USBD_HID_Init (USBD_HandleTypeDef *pdev,
370370
uint8_t cfgidx)
371371
{
372+
UNUSED(cfgidx);
372373
uint8_t ret = 0;
373374

374375
/* Open EP IN */
@@ -407,6 +408,7 @@ static uint8_t USBD_HID_Init (USBD_HandleTypeDef *pdev,
407408
static uint8_t USBD_HID_DeInit (USBD_HandleTypeDef *pdev,
408409
uint8_t cfgidx)
409410
{
411+
UNUSED(cfgidx);
410412
/* Close HID EPs */
411413
USBD_LL_CloseEP(pdev,
412414
HID_MOUSE_EPIN_ADDR);

‎libraries/SPI/src/SPI.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,31 @@ void SPIClass::transfer(uint8_t _pin, void *_buf, size_t _count, SPITransferMode
318318
digitalWrite(_pin, HIGH);
319319
}
320320

321+
void SPIClass::transfer(byte _pin, void *_bufout, void *_bufin, size_t _count, SPITransferMode _mode)
322+
{
323+
if ((_count == 0) || (_bufout == NULL) || (_bufin == NULL) || (_pin > NUM_DIGITAL_PINS))
324+
return;
325+
326+
if(_pin != _CSpin) {
327+
uint8_t idx = pinIdx(_pin, GET_IDX);
328+
if(idx == NB_SPI_SETTINGS) {
329+
return;
330+
}
331+
spi_init(&_spi, spiSettings[idx].clk,
332+
spiSettings[idx].dMode,
333+
spiSettings[idx].msb);
334+
_CSpin = _pin;
335+
}
336+
337+
if((_pin != CS_PIN_CONTROLLED_BY_USER) && (_spi.pin_ssel == NC))
338+
digitalWrite(_pin, LOW);
339+
340+
spi_transfer(&_spi, ((uint8_t*)_bufout), ((uint8_t*)_bufin), _count, SPI_TRANSFER_TIMEOUT);
341+
342+
if((_pin != CS_PIN_CONTROLLED_BY_USER) && (_mode == SPI_LAST) && (_spi.pin_ssel == NC))
343+
digitalWrite(_pin, HIGH);
344+
}
345+
321346
void SPIClass::attachInterrupt(void) {
322347
// Should be enableInterrupt()
323348
}

‎libraries/SPI/src/SPI.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class SPIClass {
114114
byte transfer(uint8_t pin, uint8_t _data, SPITransferMode _mode = SPI_LAST);
115115
uint16_t transfer16(uint8_t pin, uint16_t _data, SPITransferMode _mode = SPI_LAST);
116116
void transfer(uint8_t pin, void *_buf, size_t _count, SPITransferMode _mode = SPI_LAST);
117+
void transfer(byte _pin, void *_bufout, void *_bufin, size_t _count, SPITransferMode _mode = SPI_LAST);
117118

118119
// Transfer functions when user controls himself the CS pin.
119120
byte transfer(uint8_t _data, SPITransferMode _mode = SPI_LAST)
@@ -131,6 +132,11 @@ class SPIClass {
131132
transfer(CS_PIN_CONTROLLED_BY_USER, _buf, _count, _mode);
132133
}
133134

135+
void transfer(void *_bufout, void *_bufin, size_t _count, SPITransferMode _mode = SPI_LAST)
136+
{
137+
transfer(CS_PIN_CONTROLLED_BY_USER, _bufout, _bufin, _count, _mode);
138+
}
139+
134140
// Transaction Functions
135141
void usingInterrupt(uint8_t interruptNumber);
136142

‎variants/DISCO_L475VG_IOT/PeripheralPins.c

Lines changed: 374 additions & 0 deletions
Large diffs are not rendered by default.

‎variants/DISCO_L475VG_IOT/ldscript.ld

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
/*
2+
*****************************************************************************
3+
**
4+
5+
** File : LinkerScript.ld
6+
**
7+
** Abstract : Linker script for STM32L475VGTx Device with
8+
** 1024KByte FLASH, 128KByte 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+
*****************************************************************************
22+
** @attention
23+
**
24+
** <h2><center>&copy; COPYRIGHT(c) 2014 Ac6</center></h2>
25+
**
26+
** Redistribution and use in source and binary forms, with or without modification,
27+
** are permitted provided that the following conditions are met:
28+
** 1. Redistributions of source code must retain the above copyright notice,
29+
** this list of conditions and the following disclaimer.
30+
** 2. Redistributions in binary form must reproduce the above copyright notice,
31+
** this list of conditions and the following disclaimer in the documentation
32+
** and/or other materials provided with the distribution.
33+
** 3. Neither the name of Ac6 nor the names of its contributors
34+
** may be used to endorse or promote products derived from this software
35+
** without specific prior written permission.
36+
**
37+
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38+
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39+
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40+
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
41+
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
43+
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
44+
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45+
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
46+
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47+
**
48+
*****************************************************************************
49+
*/
50+
51+
/* Entry Point */
52+
ENTRY(Reset_Handler)
53+
54+
/* Highest address of the user mode stack */
55+
_estack = 0x20018000; /* end of RAM */
56+
/* Generate a link error if heap and stack don't fit into RAM */
57+
_Min_Heap_Size = 0x200; /* required amount of heap */
58+
_Min_Stack_Size = 0x400; /* required amount of stack */
59+
60+
/* Specify the memory areas */
61+
MEMORY
62+
{
63+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K
64+
RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 32K
65+
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
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 ALIGN(4):
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 :
106+
{
107+
. = ALIGN(4);
108+
*(.ARM.extab* .gnu.linkonce.armextab.*)
109+
. = ALIGN(4);
110+
} >FLASH
111+
.ARM : {
112+
. = ALIGN(4);
113+
__exidx_start = .;
114+
*(.ARM.exidx*)
115+
__exidx_end = .;
116+
. = ALIGN(4);
117+
} >FLASH
118+
119+
.preinit_array :
120+
{
121+
. = ALIGN(4);
122+
PROVIDE_HIDDEN (__preinit_array_start = .);
123+
KEEP (*(.preinit_array*))
124+
PROVIDE_HIDDEN (__preinit_array_end = .);
125+
. = ALIGN(4);
126+
} >FLASH
127+
128+
.init_array :
129+
{
130+
. = ALIGN(4);
131+
PROVIDE_HIDDEN (__init_array_start = .);
132+
KEEP (*(SORT(.init_array.*)))
133+
KEEP (*(.init_array*))
134+
PROVIDE_HIDDEN (__init_array_end = .);
135+
. = ALIGN(4);
136+
} >FLASH
137+
.fini_array :
138+
{
139+
. = ALIGN(4);
140+
PROVIDE_HIDDEN (__fini_array_start = .);
141+
KEEP (*(SORT(.fini_array.*)))
142+
KEEP (*(.fini_array*))
143+
PROVIDE_HIDDEN (__fini_array_end = .);
144+
. = ALIGN(4);
145+
} >FLASH
146+
147+
/* used by the startup to initialize data */
148+
_sidata = LOADADDR(.data);
149+
150+
/* Initialized data sections goes into RAM, load LMA copy after code */
151+
.data :
152+
{
153+
. = ALIGN(4);
154+
_sdata = .; /* create a global symbol at data start */
155+
*(.data) /* .data sections */
156+
*(.data*) /* .data* sections */
157+
158+
. = ALIGN(4);
159+
_edata = .; /* define a global symbol at data end */
160+
} >RAM AT> FLASH
161+
162+
163+
/* Uninitialized data section */
164+
. = ALIGN(4);
165+
.bss :
166+
{
167+
/* This is used by the startup in order to initialize the .bss secion */
168+
_sbss = .; /* define a global symbol at bss start */
169+
__bss_start__ = _sbss;
170+
*(.bss)
171+
*(.bss*)
172+
*(COMMON)
173+
174+
. = ALIGN(4);
175+
_ebss = .; /* define a global symbol at bss end */
176+
__bss_end__ = _ebss;
177+
} >RAM
178+
179+
/* User_heap_stack section, used to check that there is enough RAM left */
180+
._user_heap_stack :
181+
{
182+
. = ALIGN(4);
183+
PROVIDE ( end = . );
184+
PROVIDE ( _end = . );
185+
. = . + _Min_Heap_Size;
186+
. = . + _Min_Stack_Size;
187+
. = ALIGN(4);
188+
} >RAM
189+
190+
191+
192+
/* Remove information from the standard libraries */
193+
/DISCARD/ :
194+
{
195+
libc.a ( * )
196+
libm.a ( * )
197+
libgcc.a ( * )
198+
}
199+
200+
.ARM.attributes 0 : { *(.ARM.attributes) }
201+
}

‎variants/DISCO_L475VG_IOT/stm32l4xx_hal_conf.h

Lines changed: 408 additions & 0 deletions
Large diffs are not rendered by default.

‎variants/DISCO_L475VG_IOT/usb/usbd_conf.c

Lines changed: 527 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/**
2+
******************************************************************************
3+
* @file USB_Device/HID_Standalone/Inc/usbd_conf.h
4+
* @author MCD Application Team
5+
* @version V1.8.0
6+
* @date 21-April-2017
7+
* @brief General low level driver configuration
8+
******************************************************************************
9+
* @attention
10+
*
11+
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics International N.V.
12+
* All rights reserved.</center></h2>
13+
*
14+
* Redistribution and use in source and binary forms, with or without
15+
* modification, are permitted, provided that the following conditions are met:
16+
*
17+
* 1. Redistribution of source code must retain the above copyright notice,
18+
* this list of conditions and the following disclaimer.
19+
* 2. Redistributions in binary form must reproduce the above copyright notice,
20+
* this list of conditions and the following disclaimer in the documentation
21+
* and/or other materials provided with the distribution.
22+
* 3. Neither the name of STMicroelectronics nor the names of other
23+
* contributors to this software may be used to endorse or promote products
24+
* derived from this software without specific written permission.
25+
* 4. This software, including modifications and/or derivative works of this
26+
* software, must execute solely and exclusively on microcontroller or
27+
* microprocessor devices manufactured by or for STMicroelectronics.
28+
* 5. Redistribution and use of this software other than as permitted under
29+
* this license is void and will automatically terminate your rights under
30+
* this license.
31+
*
32+
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
33+
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
34+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35+
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
36+
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
37+
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
38+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
40+
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
41+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
42+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
43+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44+
*
45+
******************************************************************************
46+
*/
47+
48+
/* Define to prevent recursive inclusion -------------------------------------*/
49+
#ifndef __USBD_CONF_H
50+
#define __USBD_CONF_H
51+
52+
/* Includes ------------------------------------------------------------------*/
53+
#include "stm32_def.h"
54+
#include <stdio.h>
55+
#include <stdlib.h>
56+
#include <string.h>
57+
#ifdef USBCON
58+
/* Exported types ------------------------------------------------------------*/
59+
/* Exported constants --------------------------------------------------------*/
60+
61+
#define USBD_LPM_ENABLED 0
62+
63+
/* Common Config */
64+
#define USBD_MAX_NUM_INTERFACES 2
65+
#define USBD_MAX_NUM_CONFIGURATION 1
66+
#define USBD_MAX_STR_DESC_SIZ 0x100
67+
#define USBD_SUPPORT_USER_STRING 0
68+
#define USBD_SELF_POWERED 1
69+
#define USBD_DEBUG_LEVEL 0
70+
71+
/* Exported macro ------------------------------------------------------------*/
72+
/* Memory management macros */
73+
#define USBD_malloc malloc
74+
#define USBD_free free
75+
#define USBD_memset memset
76+
#define USBD_memcpy memcpy
77+
78+
/* DEBUG macros */
79+
#if (USBD_DEBUG_LEVEL > 0)
80+
#define USBD_UsrLog(...) printf(__VA_ARGS__);\
81+
printf("\n\r");
82+
#else
83+
#define USBD_UsrLog(...)
84+
#endif
85+
86+
#if (USBD_DEBUG_LEVEL > 1)
87+
88+
#define USBD_ErrLog(...) printf("ERROR: ") ;\
89+
printf(__VA_ARGS__);\
90+
printf("\n\r");
91+
#else
92+
#define USBD_ErrLog(...)
93+
#endif
94+
95+
#if (USBD_DEBUG_LEVEL > 2)
96+
#define USBD_DbgLog(...) printf("DEBUG : ") ;\
97+
printf(__VA_ARGS__);\
98+
printf("\n\r");
99+
#else
100+
#define USBD_DbgLog(...)
101+
#endif
102+
103+
/* Exported functions ------------------------------------------------------- */
104+
105+
#endif // USBCON
106+
#endif /* __USBD_CONF_H */
107+
108+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
/**
2+
******************************************************************************
3+
* @file USB_Device/HID_Standalone/Src/usbd_desc.c
4+
* @author MCD Application Team
5+
* @version V1.8.0
6+
* @date 21-April-2017
7+
* @brief This file provides the USBD descriptors and string formating method.
8+
******************************************************************************
9+
* @attention
10+
*
11+
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics International N.V.
12+
* All rights reserved.</center></h2>
13+
*
14+
* Redistribution and use in source and binary forms, with or without
15+
* modification, are permitted, provided that the following conditions are met:
16+
*
17+
* 1. Redistribution of source code must retain the above copyright notice,
18+
* this list of conditions and the following disclaimer.
19+
* 2. Redistributions in binary form must reproduce the above copyright notice,
20+
* this list of conditions and the following disclaimer in the documentation
21+
* and/or other materials provided with the distribution.
22+
* 3. Neither the name of STMicroelectronics nor the names of other
23+
* contributors to this software may be used to endorse or promote products
24+
* derived from this software without specific written permission.
25+
* 4. This software, including modifications and/or derivative works of this
26+
* software, must execute solely and exclusively on microcontroller or
27+
* microprocessor devices manufactured by or for STMicroelectronics.
28+
* 5. Redistribution and use of this software other than as permitted under
29+
* this license is void and will automatically terminate your rights under
30+
* this license.
31+
*
32+
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
33+
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
34+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35+
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
36+
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
37+
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
38+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
40+
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
41+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
42+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
43+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44+
*
45+
******************************************************************************
46+
*/
47+
#ifdef USBCON
48+
/* Includes ------------------------------------------------------------------*/
49+
#include "usbd_core.h"
50+
#include "usbd_desc.h"
51+
#include "usbd_conf.h"
52+
#include "utils.h"
53+
54+
/* Private typedef -----------------------------------------------------------*/
55+
/* Private define ------------------------------------------------------------*/
56+
57+
//ID
58+
#define USBD_LANGID_STRING 0x409 //1033
59+
#if USBD_VID == 0x2341
60+
#define USBD_MANUFACTURER_STRING "Arduino LLC"
61+
#elif USBD_VID == 0x2A03
62+
#define USBD_MANUFACTURER_STRING "Arduino srl"
63+
#elif USBD_VID == 0x0483
64+
#define USBD_MANUFACTURER_STRING "STMicroelectronics"
65+
#elif !defined(USB_MANUFACTURER)
66+
// Fall through to unknown if no manufacturer name was provided in a macro
67+
#define USBD_MANUFACTURER_STRING "Unknown"
68+
#endif /* USBD_VID */
69+
#ifdef USBD_USE_HID_COMPOSITE
70+
#define USBD_HID_PRODUCT_FS_STRING CONCATS(USB_PRODUCT, "HID in FS Mode")
71+
#define USBD_HID_CONFIGURATION_FS_STRING CONCATS(USB_PRODUCT, "HID Config")
72+
#define USBD_HID_INTERFACE_FS_STRING CONCATS(USB_PRODUCT, "HID Interface")
73+
74+
/* Private macro -------------------------------------------------------------*/
75+
/* Private function prototypes -----------------------------------------------*/;
76+
static uint8_t *USBD_HID_ProductStrDescriptor (USBD_SpeedTypeDef speed, uint16_t *length);
77+
static uint8_t *USBD_HID_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
78+
static uint8_t *USBD_HID_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
79+
#ifdef USB_SUPPORT_USER_STRING_DESC
80+
static uint8_t *USBD_HID_USRStringDesc (USBD_SpeedTypeDef speed, uint8_t idx, uint16_t *length);
81+
#endif /* USB_SUPPORT_USER_STRING_DESC */
82+
83+
/* Private variables ---------------------------------------------------------*/
84+
USBD_DescriptorsTypeDef HID_Desc = {
85+
USBD_DeviceDescriptor,
86+
USBD_LangIDStrDescriptor,
87+
USBD_ManufacturerStrDescriptor,
88+
USBD_HID_ProductStrDescriptor,
89+
USBD_SerialStrDescriptor,
90+
USBD_HID_ConfigStrDescriptor,
91+
USBD_HID_InterfaceStrDescriptor,
92+
};
93+
#endif /* USBD_USE_HID_COMPOSITE */
94+
95+
/* USB Standard Device Descriptor */
96+
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
97+
#pragma data_alignment=4
98+
#endif
99+
__ALIGN_BEGIN static uint8_t USBD_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = {
100+
0x12, /* bLength */
101+
USB_DESC_TYPE_DEVICE, /* bDescriptorType */
102+
0x01, /* bcdUSB */
103+
0x01,
104+
0x00, /* bDeviceClass */
105+
0x00, /* bDeviceSubClass */
106+
0x00, /* bDeviceProtocol */
107+
USB_MAX_EP0_SIZE, /* bMaxPacketSize */
108+
LOBYTE(USBD_VID), /* idVendor */
109+
HIBYTE(USBD_VID), /* idVendor */
110+
LOBYTE(USBD_PID), /* idVendor */
111+
HIBYTE(USBD_PID), /* idVendor */
112+
0x01, /* bcdDevice rel. 1.1 */
113+
0x01,
114+
USBD_IDX_MFC_STR, /* Index of manufacturer string */
115+
USBD_IDX_PRODUCT_STR, /* Index of product string */
116+
USBD_IDX_SERIAL_STR, /* Index of serial number string */
117+
USBD_MAX_NUM_CONFIGURATION /* bNumConfigurations */
118+
}; /* USB_DeviceDescriptor */
119+
120+
/* USB Standard Device Descriptor */
121+
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
122+
#pragma data_alignment=4
123+
#endif
124+
__ALIGN_BEGIN static uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = {
125+
USB_LEN_LANGID_STR_DESC,
126+
USB_DESC_TYPE_STRING,
127+
LOBYTE(USBD_LANGID_STRING),
128+
HIBYTE(USBD_LANGID_STRING),
129+
};
130+
131+
static uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] =
132+
{
133+
USB_SIZ_STRING_SERIAL,
134+
USB_DESC_TYPE_STRING,
135+
};
136+
137+
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
138+
#pragma data_alignment=4
139+
#endif
140+
__ALIGN_BEGIN static uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END;
141+
142+
/* Private functions ---------------------------------------------------------*/
143+
static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len);
144+
static void Get_SerialNum(void);
145+
146+
/**
147+
* @brief Returns the device descriptor.
148+
* @param speed: Current device speed
149+
* @param length: Pointer to data length variable
150+
* @retval Pointer to descriptor buffer
151+
*/
152+
uint8_t *USBD_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
153+
{
154+
UNUSED(speed);
155+
*length = sizeof(USBD_DeviceDesc);
156+
return (uint8_t*)USBD_DeviceDesc;
157+
}
158+
159+
/**
160+
* @brief Returns the LangID string descriptor.
161+
* @param speed: Current device speed
162+
* @param length: Pointer to data length variable
163+
* @retval Pointer to descriptor buffer
164+
*/
165+
uint8_t *USBD_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
166+
{
167+
UNUSED(speed);
168+
*length = sizeof(USBD_LangIDDesc);
169+
return (uint8_t*)USBD_LangIDDesc;
170+
}
171+
172+
/**
173+
* @brief Returns the manufacturer string descriptor.
174+
* @param speed: Current device speed
175+
* @param length: Pointer to data length variable
176+
* @retval Pointer to descriptor buffer
177+
*/
178+
uint8_t *USBD_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
179+
{
180+
UNUSED(speed);
181+
USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length);
182+
return USBD_StrDesc;
183+
}
184+
185+
/**
186+
* @brief Returns the serial number string descriptor.
187+
* @param speed: Current device speed
188+
* @param length: Pointer to data length variable
189+
* @retval Pointer to descriptor buffer
190+
*/
191+
uint8_t *USBD_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
192+
{
193+
UNUSED(speed);
194+
*length = USB_SIZ_STRING_SERIAL;
195+
196+
/* Update the serial number string descriptor with the data from the unique ID*/
197+
Get_SerialNum();
198+
199+
return (uint8_t*)USBD_StringSerial;
200+
}
201+
202+
#ifdef USBD_USE_HID_COMPOSITE
203+
204+
/**
205+
* @brief Returns the product string descriptor.
206+
* @param speed: Current device speed
207+
* @param length: Pointer to data length variable
208+
* @retval Pointer to descriptor buffer
209+
*/
210+
uint8_t *USBD_HID_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
211+
{
212+
UNUSED(speed);
213+
USBD_GetString((uint8_t *)USBD_HID_PRODUCT_FS_STRING, USBD_StrDesc, length);
214+
return USBD_StrDesc;
215+
}
216+
217+
/**
218+
* @brief Returns the configuration string descriptor.
219+
* @param speed: Current device speed
220+
* @param length: Pointer to data length variable
221+
* @retval Pointer to descriptor buffer
222+
*/
223+
uint8_t *USBD_HID_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
224+
{
225+
UNUSED(speed);
226+
USBD_GetString((uint8_t *)USBD_HID_CONFIGURATION_FS_STRING, USBD_StrDesc, length);
227+
return USBD_StrDesc;
228+
}
229+
230+
/**
231+
* @brief Returns the interface string descriptor.
232+
* @param speed: Current device speed
233+
* @param length: Pointer to data length variable
234+
* @retval Pointer to descriptor buffer
235+
*/
236+
uint8_t *USBD_HID_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
237+
{
238+
UNUSED(speed);
239+
USBD_GetString((uint8_t *)USBD_HID_INTERFACE_FS_STRING, USBD_StrDesc, length);
240+
return USBD_StrDesc;
241+
}
242+
#endif //USBD_USE_HID_COMPOSITE
243+
244+
/**
245+
* @brief Create the serial number string descriptor
246+
* @param None
247+
* @retval None
248+
*/
249+
static void Get_SerialNum(void)
250+
{
251+
uint32_t deviceserial0, deviceserial1, deviceserial2;
252+
253+
deviceserial0 = *(uint32_t*)DEVICE_ID1;
254+
deviceserial1 = *(uint32_t*)DEVICE_ID2;
255+
deviceserial2 = *(uint32_t*)DEVICE_ID3;
256+
257+
deviceserial0 += deviceserial2;
258+
259+
if (deviceserial0 != 0)
260+
{
261+
IntToUnicode (deviceserial0, (uint8_t*)&USBD_StringSerial[2] ,8);
262+
IntToUnicode (deviceserial1, (uint8_t*)&USBD_StringSerial[18] ,4);
263+
}
264+
}
265+
266+
/**
267+
* @brief Convert Hex 32Bits value into char
268+
* @param value: value to convert
269+
* @param pbuf: pointer to the buffer
270+
* @param len: buffer length
271+
* @retval None
272+
*/
273+
static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len)
274+
{
275+
uint8_t idx = 0;
276+
277+
for( idx = 0 ; idx < len ; idx ++)
278+
{
279+
if( ((value >> 28)) < 0xA )
280+
{
281+
pbuf[ 2* idx] = (value >> 28) + '0';
282+
}
283+
else
284+
{
285+
pbuf[2* idx] = (value >> 28) + 'A' - 10;
286+
}
287+
288+
value = value << 4;
289+
290+
pbuf[ 2* idx + 1] = 0;
291+
}
292+
}
293+
#endif // USBCON
294+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
******************************************************************************
3+
* @file USB_Device/HID_Standalone/Inc/usbd_desc.h
4+
* @author MCD Application Team
5+
* @version V1.8.0
6+
* @date 21-April-2017
7+
* @brief Header for usbd_desc.c module
8+
******************************************************************************
9+
* @attention
10+
*
11+
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics International N.V.
12+
* All rights reserved.</center></h2>
13+
*
14+
* Redistribution and use in source and binary forms, with or without
15+
* modification, are permitted, provided that the following conditions are met:
16+
*
17+
* 1. Redistribution of source code must retain the above copyright notice,
18+
* this list of conditions and the following disclaimer.
19+
* 2. Redistributions in binary form must reproduce the above copyright notice,
20+
* this list of conditions and the following disclaimer in the documentation
21+
* and/or other materials provided with the distribution.
22+
* 3. Neither the name of STMicroelectronics nor the names of other
23+
* contributors to this software may be used to endorse or promote products
24+
* derived from this software without specific written permission.
25+
* 4. This software, including modifications and/or derivative works of this
26+
* software, must execute solely and exclusively on microcontroller or
27+
* microprocessor devices manufactured by or for STMicroelectronics.
28+
* 5. Redistribution and use of this software other than as permitted under
29+
* this license is void and will automatically terminate your rights under
30+
* this license.
31+
*
32+
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
33+
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
34+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35+
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
36+
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
37+
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
38+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
40+
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
41+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
42+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
43+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44+
*
45+
******************************************************************************
46+
*/
47+
48+
/* Define to prevent recursive inclusion -------------------------------------*/
49+
#ifndef __USBD_DESC_H
50+
#define __USBD_DESC_H
51+
#ifdef USBCON
52+
/* Includes ------------------------------------------------------------------*/
53+
#include "usbd_def.h"
54+
55+
/* Exported types ------------------------------------------------------------*/
56+
/* Exported constants --------------------------------------------------------*/
57+
#define DEVICE_ID1 (0x1FFF7A10)
58+
#define DEVICE_ID2 (0x1FFF7A14)
59+
#define DEVICE_ID3 (0x1FFF7A18)
60+
61+
#define USB_SIZ_STRING_SERIAL 0x1A
62+
/* Exported macro ------------------------------------------------------------*/
63+
/* Exported functions ------------------------------------------------------- */
64+
#ifdef USBD_USE_HID_COMPOSITE
65+
extern USBD_DescriptorsTypeDef HID_Desc;
66+
#endif
67+
68+
uint8_t *USBD_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
69+
uint8_t *USBD_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
70+
uint8_t *USBD_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
71+
uint8_t *USBD_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
72+
73+
#endif // USBCON
74+
#endif /* __USBD_DESC_H */
75+
76+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

‎variants/DISCO_L475VG_IOT/variant.cpp

Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
/*
2+
Copyright (c) 2011 Arduino. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#include "variant.h"
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
// Pin number based on UM2153
26+
const PinName digitalPin[] = {
27+
// CN3 connector
28+
PA_1, //D0 - UART4_RX
29+
PA_0, //D1 - UART4_TX
30+
PD_14, //D2
31+
PB_0, //D3 - PWM
32+
PA_3, //D4
33+
PB_4, //D5 - PWM
34+
PB_1, //D6 - PWM
35+
PA_4, //D7
36+
// CN1 connector
37+
PB_2, //D8
38+
PA_15, //D9 - PWM
39+
PA_2, //D10 - SPI_SSN/PWM
40+
PA_7, //D11 - SPI1_MOSI/PWM
41+
PA_6, //D12 - SPI1_MISO
42+
PA_5, //D13 - SPI1_SCK/LED1
43+
PB_9, //D14 - I2C1_SDA
44+
PB_8, //D15 - I2C1_SCL
45+
// Not on connector
46+
PB_14, //D16 - LED2
47+
PC_13, //D17 - USER_BTN
48+
// CN9 USB OTG FS connector
49+
PA_9, //D18 - USB_OTG_FS_VBUS
50+
PA_10, //D19 - USB_OTG_FS_ID
51+
PA_11, //D20 - USB_OTG_FS_DM
52+
PA_12, //D21 - USB_OTG_FS_DP
53+
PD_12, //D22 - USB_OTG_FS_PWR_EN
54+
PE_3, //D23 - USB_OTG_OVRCR_EXTI3
55+
// CN10 PMOD connector
56+
PD_0, //D24 - PMOD-RESET
57+
PD_1, //D25 - PMOD-SPI2_SCK
58+
PD_2, //D26 - PMOD-IRQ_EXTI2
59+
PD_3, //D27 - PMOD-UART2_CTS/SPI2_MISO
60+
PD_4, //D28 - PMOD-UART2_RTS/SPI2_MOSI
61+
PD_5, //D29 - PMOD-UART2_TX/SPI2_CSN
62+
PD_6, //D30 - PMOD-UART2_RX
63+
// Sensors / modules pins
64+
PA_8, //D31 - SPBTLE-RF-RST
65+
PB_5, //D32 - SPSGRF-915-SPI3_CSN
66+
PB_10, //D33 - INTERNAL-I2C2_SCL
67+
PB_11, //D34 - INTERNAL-I2C2_SDA
68+
PB_12, //D35 - ISM43362-BOOT0
69+
PB_13, //D36 - ISM43362-WAKEUP
70+
PB_15, //D37 - SPSGRF-915-SDN
71+
PC_6, //D38 - VL53L0X_XSHUT
72+
PC_7, //D39 - VL53L0X_GPIO1_EXTI7
73+
PC_8, //D40 - LIS3MDL_DRDY_EXTI8
74+
PC_9, //D41 - LED3 (WIFI) & LED4 (BLE)
75+
PC_10, //D42 - INTERNAL-SPI3_SCK
76+
PC_11, //D43 - INTERNAL-SPI3_MISO
77+
PC_12, //D44 - INTERNAL-SPI3_MOSI
78+
PD_7, //D45 - STSAFE-A100-RESET
79+
PD_8, //D46 - INTERNAL-UART3_TX
80+
PD_9, //D47 - INTERNAL-UART3_RX
81+
PD_10, //D48 - LPS22HB_INT_DRDY_EXTI10
82+
PD_11, //D49 - LSM6DSL_INT1_EXTI11
83+
PD_13, //D50 - SPBTLE-RF-SPI3_CSN
84+
PD_15, //D51 - HTS221_DRDY_EXTI15
85+
PE_0, //D52 - ISM43362-SPI3_CSN
86+
PE_1, //D53 - ISM43362-DRDY_EXTI1
87+
PE_2, //D54 - M24SR64-Y-RF_DISABLE
88+
PE_4, //D55 - M24SR64-Y-GPO
89+
PE_5, //D56 - SPSGRF-915-GPIO3_EXTI5
90+
PE_6, //D57 - SPBTLE-RF-IRQ_EXTI6
91+
PE_7, //D58 - DFSDM1_DATIN2
92+
PE_8, //D59 - ISM43362-RST
93+
PE_9, //D60 - DFSDM1_CKOUT
94+
PE_10, //D61 - QUADSPI_CLK
95+
PE_11, //D62 - QUADSPI_NCS
96+
PE_12, //D63 - QUADSPI_BK1_IO0
97+
PE_13, //D64 - QUADSPI_BK1_IO1
98+
PE_14, //D65 - QUADSPI_BK1_IO2
99+
PE_15, //D66 - QUADSPI_BK1_IO3
100+
// CN4 connector
101+
PC_5, //D67/A0
102+
PC_4, //D68/A1
103+
PC_3, //D69/A2
104+
PC_2, //D70/A3
105+
PC_1, //D71/A4
106+
PC_0, //D72/A5
107+
// Duplicated pins in order to be aligned with PinMap_ADC
108+
PA_1, //D73/A6
109+
PA_0, //D74/A7
110+
PB_0, //D75/A8
111+
PA_3, //D76/A9
112+
PB_1, //D77/A10
113+
PA_4, //D78/A11
114+
PA_2, //D79/A12
115+
PA_7, //D80/A13
116+
PA_6, //D81/A14
117+
PA_5 //D82/A15
118+
};
119+
120+
#ifdef __cplusplus
121+
}
122+
#endif
123+
124+
/*
125+
* UART objects
126+
*/
127+
HardwareSerial Serial(PB_7, PB_6); //Connected to ST-Link (USART1)
128+
#ifdef ENABLE_SERIAL1
129+
HardwareSerial Serial1(PA_1, PA_0); //Connected to ST-Link (USART4)
130+
#endif
131+
132+
void serialEvent() __attribute__((weak));
133+
void serialEvent() { }
134+
#ifdef ENABLE_SERIAL1
135+
void serialEvent1() __attribute__((weak));
136+
void serialEvent1() { }
137+
#endif
138+
139+
void serialEventRun(void)
140+
{
141+
if (Serial.available()) serialEvent();
142+
#ifdef ENABLE_SERIAL1
143+
if (Serial1.available()) serialEvent1();
144+
#endif
145+
}
146+
147+
// ----------------------------------------------------------------------------
148+
149+
#ifdef __cplusplus
150+
extern "C" {
151+
#endif
152+
153+
/**
154+
* @brief System Clock Configuration
155+
* The system Clock is configured as follow :
156+
* System Clock source = PLL (MSI)
157+
* SYSCLK(Hz) = 80000000
158+
* HCLK(Hz) = 80000000
159+
* AHB Prescaler = 1
160+
* APB1 Prescaler = 1
161+
* APB2 Prescaler = 1
162+
* PLL_M = 1
163+
* PLL_N = 40
164+
* PLL_P = 7
165+
* PLL_Q = 2
166+
* PLL_R = 2
167+
* Main regulator output voltage = Scale1 mode
168+
* Flash Latency(WS) = 4
169+
* @param None
170+
* @retval None
171+
*/
172+
WEAK void SystemClock_Config(void)
173+
{
174+
RCC_OscInitTypeDef RCC_OscInitStruct;
175+
RCC_ClkInitTypeDef RCC_ClkInitStruct;
176+
RCC_PeriphCLKInitTypeDef PeriphClkInit;
177+
178+
/**Configure the main internal regulator output voltage
179+
*/
180+
__HAL_RCC_PWR_CLK_ENABLE();
181+
182+
/**Configure LSE Drive Capability
183+
*/
184+
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
185+
186+
/* MSI is enabled after System reset, activate PLL with MSI as source */
187+
/* NOTE: A limitation is present on the MB1297C-01 board. The reset connexion
188+
between STM32L4 and the ST-LINK MCU (STM32F103) is not present even if
189+
schematics are correct. The software reset is available so that the hardware
190+
missing reset may not be necessary. If the hardware reset is needed, a simple
191+
workaround is available by soldering an external wire between the SB2 and SB8.
192+
*/
193+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
194+
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
195+
RCC_OscInitStruct.MSICalibrationValue = 0;
196+
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11;
197+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
198+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
199+
RCC_OscInitStruct.PLL.PLLM = 6;
200+
RCC_OscInitStruct.PLL.PLLN = 40;
201+
RCC_OscInitStruct.PLL.PLLP = 7;
202+
RCC_OscInitStruct.PLL.PLLQ = 4;
203+
RCC_OscInitStruct.PLL.PLLR = 4;
204+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
205+
{
206+
while(1);
207+
}
208+
209+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
210+
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
211+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
212+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
213+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
214+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
215+
216+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
217+
{
218+
while(1);
219+
}
220+
221+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_UART4
222+
|RCC_PERIPHCLK_I2C1|RCC_PERIPHCLK_I2C2
223+
|RCC_PERIPHCLK_USB|RCC_PERIPHCLK_ADC;
224+
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
225+
PeriphClkInit.Uart4ClockSelection = RCC_UART4CLKSOURCE_PCLK1;
226+
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
227+
PeriphClkInit.I2c2ClockSelection = RCC_I2C2CLKSOURCE_PCLK1;
228+
PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_SYSCLK;
229+
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_MSI;
230+
231+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
232+
{
233+
while(1);
234+
}
235+
236+
/**Configure the main internal regulator output voltage
237+
*/
238+
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
239+
{
240+
while(1);
241+
}
242+
243+
/**Configure the Systick interrupt time
244+
*/
245+
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
246+
247+
/**Configure the Systick
248+
*/
249+
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
250+
251+
/**Enable MSI Auto calibration
252+
*/
253+
HAL_RCCEx_EnableMSIPLLMode();
254+
255+
/* SysTick_IRQn interrupt configuration */
256+
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
257+
}
258+
259+
#ifdef __cplusplus
260+
}
261+
#endif

‎variants/DISCO_L475VG_IOT/variant.h

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
/*
2+
Copyright (c) 2011 Arduino. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#ifndef _VARIANT_ARDUINO_STM32_
20+
#define _VARIANT_ARDUINO_STM32_
21+
22+
/*----------------------------------------------------------------------------
23+
* Headers
24+
*----------------------------------------------------------------------------*/
25+
26+
#include "Arduino.h"
27+
28+
#ifdef __cplusplus
29+
extern "C"{
30+
#endif // __cplusplus
31+
32+
/*----------------------------------------------------------------------------
33+
* Pins
34+
*----------------------------------------------------------------------------*/
35+
#include "PeripheralPins.h"
36+
37+
extern const PinName digitalPin[];
38+
39+
enum {
40+
// CN3 connector
41+
PA1, //D0
42+
PA0, //D1
43+
PD14, //D2
44+
PB0, //D3
45+
PA3, //D4
46+
PB4, //D5
47+
PB1, //D6
48+
PA4, //D7
49+
// CN1 connector
50+
PB2, //D8
51+
PA15, //D9
52+
PA2, //D10
53+
PA7, //D11
54+
PA6, //D12
55+
PA5, //D13
56+
PB9, //D14
57+
PB8, //D15
58+
// Not on connector
59+
PB14, //D16
60+
PC13, //D17
61+
// CN9 USB OTG FS connector
62+
PA9, //D18
63+
PA10, //D19
64+
PA11, //D20
65+
PA12, //D21
66+
PD12, //D22
67+
PE3, //D23
68+
// CN10 PMOD connector
69+
PD0, //D24
70+
PD1, //D25
71+
PD2, //D26
72+
PD3, //D27
73+
PD4, //D28
74+
PD5, //D29
75+
PD6, //D30
76+
// Sensors / modules pins
77+
PA8, //D31
78+
PB5, //D32
79+
PB10, //D33
80+
PB11, //D34
81+
PB12, //D35
82+
PB13, //D36
83+
PB15, //D37
84+
PC6, //D38
85+
PC7, //D39
86+
PC8, //D40
87+
PC9, //D41
88+
PC10, //D42
89+
PC11, //D43
90+
PC12, //D44
91+
PD7, //D45
92+
PD8, //D46
93+
PD9, //D47
94+
PD10, //D48
95+
PD11, //D49
96+
PD13, //D50
97+
PD15, //D51
98+
PE0, //D52
99+
PE1, //D53
100+
PE2, //D54
101+
PE4, //D55
102+
PE5, //D56
103+
PE6, //D57
104+
PE7, //D58
105+
PE8, //D59
106+
PE9, //D60
107+
PE10, //D61
108+
PE11, //D62
109+
PE12, //D63
110+
PE13, //D64
111+
PE14, //D65
112+
PE15, //D66
113+
// CN4 connector
114+
PC5, //D67/A0
115+
PC4, //D68/A1
116+
PC3, //D69/A2
117+
PC2, //D70/A3
118+
PC1, //D71/A4
119+
PC0, //D72/A5
120+
// Duplicated pins in order to be aligned with PinMap_ADC
121+
PA1_2, //D73/A6
122+
PA0_2, //D74/A7
123+
PB0_2, //D75/A8
124+
PA3_2, //D76/A9
125+
PB1_2, //D77/A10
126+
PA4_2, //D78/A11
127+
PA2_2, //D79/A12
128+
PA7_2, //D80/A13
129+
PA6_2, //D81/A14
130+
PA5_2, //D82/A15
131+
PEND
132+
};
133+
134+
enum {
135+
A_START_AFTER = D66,
136+
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
137+
A10, A11, A12, A13, A14, A15,
138+
AEND
139+
};
140+
141+
//ADC resolution is 12bits
142+
#define ADC_RESOLUTION 12
143+
#define DACC_RESOLUTION 12
144+
145+
//PWR resolution
146+
#define PWM_RESOLUTION 8
147+
#define PWM_FREQUENCY 1000
148+
#define PWM_MAX_DUTY_CYCLE 255
149+
150+
//On-board LED pin number
151+
#define LED_BUILTIN 13
152+
#define LED1 LED_BUILTIN
153+
#define LED2 16
154+
#define LED3 41
155+
#define LED4 LED3
156+
157+
//On-board user button
158+
#define USER_BTN 17
159+
160+
161+
//SPI definitions
162+
#define SS 10
163+
#define SS1 4
164+
#define SS2 7
165+
#define SS3 8
166+
#define MOSI 11
167+
#define MISO 12
168+
#define SCK 13
169+
170+
//I2C Definitions
171+
#define SDA 14
172+
#define SCL 15
173+
174+
//Timer Definitions
175+
//Do not use timer used by PWM pins when possible. See PinMap_PWM.
176+
#define TIMER_TONE TIM6
177+
#define TIMER_UART_EMULATED TIM7
178+
179+
//Do not use basic timer: OC is required
180+
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
181+
182+
#define DEBUG_UART ((USART_TypeDef *) USART1)
183+
184+
// UART Emulation
185+
// #define UART_EMUL_RX PB13
186+
// #define UART_EMUL_TX PB14
187+
188+
// Serial Pin Firmata
189+
#define PIN_SERIAL_RX 0
190+
#define PIN_SERIAL_TX 1
191+
#define PIN_SERIAL1_RX 2
192+
#define PIN_SERIAL1_TX 8
193+
194+
#ifdef __cplusplus
195+
} // extern "C"
196+
#endif
197+
/*----------------------------------------------------------------------------
198+
* Arduino objects - C++ only
199+
*----------------------------------------------------------------------------*/
200+
201+
#ifdef __cplusplus
202+
extern HardwareSerial Serial;
203+
extern HardwareSerial Serial1;
204+
205+
// These serial port names are intended to allow libraries and architecture-neutral
206+
// sketches to automatically default to the correct port name for a particular type
207+
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
208+
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
209+
//
210+
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
211+
//
212+
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
213+
//
214+
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
215+
//
216+
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
217+
//
218+
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
219+
// pins are NOT connected to anything by default.
220+
#define SERIAL_PORT_MONITOR Serial
221+
#define SERIAL_PORT_HARDWARE Serial
222+
#endif
223+
224+
#endif /* _VARIANT_ARDUINO_STM32_ */

0 commit comments

Comments
 (0)
Please sign in to comment.