Skip to content

Commit 768604c

Browse files
authored
Merge pull request #42 from fpistm/Analog_pins
Review analog pins numbering and pin functions
2 parents 448f246 + 650963b commit 768604c

33 files changed

+311
-549
lines changed

Diff for: boards.txt

+12-16
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,13 @@ Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.upload.maximum_size=262144
8080
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.upload.maximum_data_size=32768
8181
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.mcu=cortex-m0
8282
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.f_cpu=8000000L
83-
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.usb_product="NUCLEO-F091RC"
8483
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.board=NUCLEO_F091RC
8584
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.series=STM32F0xx
8685
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.variant=NUCLEO_F091RC
8786
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.cmsis_lib_gcc=arm_cortexM0l_math
88-
#To enable USB add '-DUSBCON'
89-
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE'
90-
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.extra_flags=-DSTM32F091xC {build.usb_flags}
87+
#To enable Serial1 (USART1 on PA10, PA9) add -DENABLE_SERIAL1
88+
#To enable Serial2 (USART2 on PA1, PA0) add -DENABLE_SERIAL2
89+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.extra_flags=-DSTM32F091xC
9190

9291
# NUCLEO_F303RE board
9392

@@ -97,14 +96,13 @@ Nucleo_64.menu.Nucleo_64_board.NUCLEO_F303RE.upload.maximum_size=524288
9796
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F303RE.upload.maximum_data_size=65536
9897
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F303RE.build.mcu=cortex-m4
9998
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F303RE.build.f_cpu=8000000L
100-
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F303RE.build.usb_product="NUCLEO-F303RE"
10199
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F303RE.build.board=NUCLEO_F303RE
102100
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F303RE.build.series=STM32F3xx
103101
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F303RE.build.variant=NUCLEO_F303RE
104102
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F303RE.build.cmsis_lib_gcc=arm_cortexM4l_math
105-
#To enable USB add '-DUSBCON'
106-
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE'
107-
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F303RE.build.extra_flags=-DSTM32F303xE {build.usb_flags}
103+
#To enable Serial1 (USART1 on PA10, PA9) add -DENABLE_SERIAL1
104+
#To enable Serial2 (USART2 on PA1, PA0) add -DENABLE_SERIAL2
105+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F303RE.build.extra_flags=-DSTM32F303xE
108106

109107
# NUCLEO_L053R8 board
110108

@@ -114,14 +112,12 @@ Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.upload.maximum_size=65536
114112
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.upload.maximum_data_size=8192
115113
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.build.mcu=cortex-m0
116114
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.build.f_cpu=2000000L
117-
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.build.usb_product="NUCLEO-L053R8"
118115
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.build.board=NUCLEO_L053R8
119116
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.build.series=STM32L0xx
120117
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.build.variant=NUCLEO_L053R8
121118
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.build.cmsis_lib_gcc=arm_cortexM0l_math
122-
#To enable USB add '-DUSBCON'
123-
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE'
124-
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.build.extra_flags=-DSTM32L053xx -D__CORTEX_SC=0 {build.usb_flags}
119+
#To enable Serial1 (USART1 on PA10, PA9) add -DENABLE_SERIAL1
120+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.build.extra_flags=-DSTM32L053xx -D__CORTEX_SC=0
125121

126122
# NUCLEO_L476RG board
127123

@@ -131,14 +127,12 @@ Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.upload.maximum_size=1048576
131127
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.upload.maximum_data_size=131072
132128
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.mcu=cortex-m4
133129
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.f_cpu=4000000L
134-
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.usb_product="NUCLEO-L476RG"
135130
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.board=NUCLEO_L476RG
136131
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.series=STM32L4xx
137132
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.variant=NUCLEO_L476RG
138133
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.cmsis_lib_gcc=arm_cortexM4l_math
139-
#To enable USB add '-DUSBCON'
140-
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE'
141-
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.extra_flags=-DSTM32L476xx {build.usb_flags}
134+
#To enable Serial1 (USART1 on PA10, PA9) add -DENABLE_SERIAL1
135+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.extra_flags=-DSTM32L476xx
142136

143137
Nucleo_64.menu.upload_method.MassStorageMethod=Mass Storage
144138
Nucleo_64.menu.upload_method.MassStorageMethod.upload.protocol=
@@ -193,6 +187,8 @@ Disco_board.menu.Disco_board.DISCO_F746NG.build.variant=DISCO_F746NG
193187
Disco_board.menu.Disco_board.DISCO_F746NG.build.cmsis_lib_gcc=arm_cortexM7l_math
194188
#To enable USB add '-DUSBCON'
195189
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE'
190+
#To enable Serial1 (USART6 on PC7, PC6) add -DENABLE_SERIAL1
191+
#To enable Serial2 (UART7 on PF6, PF7) add -DENABLE_SERIAL2
196192
Disco_board.menu.Disco_board.DISCO_F746NG.build.extra_flags=-DSTM32F746xx {build.usb_flags}
197193

198194

Diff for: cores/arduino/Arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ extern void loop( void ) ;
7272

7373

7474
// Include board variant
75-
#include "variant.h"
75+
#include "pins_arduino.h"
7676

7777
#include "wiring.h"
7878
#include "wiring_digital.h"

Diff for: cores/arduino/Tone.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static stimer_t _timer;
2828

2929
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
3030
{
31-
PinName p = digitalToPinName(_pin);
31+
PinName p = digitalPinToPinName(_pin);
3232
if(p != NC) {
3333
if((g_lastPin == NC) || (g_lastPin == p)) {
3434
_timer.pin = p;
@@ -41,7 +41,7 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
4141

4242
void noTone(uint8_t _pin)
4343
{
44-
PinName p = digitalToPinName(_pin);
44+
PinName p = digitalPinToPinName(_pin);
4545
if(p != NC) {
4646
TimerPinDeinit(&_timer);
4747
digitalWrite(_pin, 0);

Diff for: cores/arduino/WInterrupts.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
void attachInterrupt(uint32_t pin, void (*callback)(void), uint32_t mode)
2626
{
2727
uint32_t it_mode;
28-
PinName p = digitalToPinName(pin);
28+
PinName p = digitalPinToPinName(pin);
2929
GPIO_TypeDef* port = set_GPIO_Port_Clock(STM_PORT(p));
3030
if (port == NC)
3131
return;
@@ -51,7 +51,7 @@ void attachInterrupt(uint32_t pin, void (*callback)(void), uint32_t mode)
5151

5252
void detachInterrupt(uint32_t pin)
5353
{
54-
PinName p = digitalToPinName(pin);
54+
PinName p = digitalPinToPinName(pin);
5555
GPIO_TypeDef* port = get_GPIO_Port(STM_PORT(p));
5656
if (port == NC)
5757
return;

Diff for: cores/arduino/pins_arduino.c

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 "pins_arduino.h"
20+
21+
void __libc_init_array(void);
22+
23+
WEAK uint32_t pinNametoDigitalPin(PinName p)
24+
{
25+
uint32_t i = 0;
26+
for(i = 0; i < NUM_DIGITAL_PINS; i++) {
27+
if (digitalPin[i] == p)
28+
break;
29+
}
30+
return i;
31+
}
32+
33+
WEAK void init( void )
34+
{
35+
hw_config_init();
36+
}

Diff for: cores/arduino/pins_arduino.h

+30
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,37 @@
1515
License along with this library; if not, write to the Free Software
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
18+
#ifndef _PINS_ARDUINO_H_
19+
#define _PINS_ARDUINO_H_
20+
21+
/**
22+
* Libc porting layers
23+
*/
24+
#if defined ( __GNUC__ ) /* GCC CS3 */
25+
# include <syscalls.h> /** RedHat Newlib minimal stub */
26+
#endif
1827

1928
// API compatibility
2029
#include "variant.h"
2130

31+
#define NUM_DIGITAL_PINS DEND
32+
#define NUM_ANALOG_INPUTS (AEND-A0)
33+
34+
// Convert a digital pin number Dxx to a PinName Pxy
35+
// Note: Analog pin is also a digital pin.
36+
#define digitalPinToPinName(p) ((p < NUM_DIGITAL_PINS) ? digitalPin[p] : (STM_VALID_PINNAME(p))? (PinName)p : NC)
37+
// Convert a PinName Pxy to a digital pin number
38+
uint32_t pinNametoDigitalPin(PinName p);
39+
40+
// Convert an analog pin number to a digital pin number
41+
// Used by analogRead api to have A0 == 0
42+
#define analogInputToDigitalPin(p) ((p < NUM_ANALOG_INPUTS) ? (p+A0) : p)
43+
// Convert an analog pin number Axx to a PinName Pxy
44+
#define analogInputToPinName(p) (digitalPinToPinName(analogInputToDigitalPin(p)))
45+
// All pins could manage EXTI
46+
#define digitalPinToInterrupt(p) (p)
47+
48+
#define digitalPinToPort(p) ( get_GPIO_Port(digitalPinToPinName(p)) )
49+
#define digitalPinToBitMask(p) ( STM_GPIO_PIN(digitalPinToPinName(p)) )
50+
51+
#endif /*_PINS_ARDUINO_H_*/

Diff for: cores/arduino/wiring_analog.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static inline uint32_t mapResolution(uint32_t value, uint32_t from, uint32_t to)
5252
uint32_t analogRead(uint32_t ulPin)
5353
{
5454
uint32_t value = 0;
55-
PinName p = analogToPinName(ulPin);
55+
PinName p = analogInputToPinName(ulPin);
5656
if(p != NC) {
5757
value = adc_read_value(p);
5858
value = mapResolution(value, ADC_RESOLUTION, _readResolution);
@@ -71,7 +71,7 @@ void analogOutputInit(void) {
7171
void analogWrite(uint32_t ulPin, uint32_t ulValue) {
7272

7373
uint8_t do_init = 0;
74-
PinName p = analogToPinName(ulPin);
74+
PinName p = digitalPinToPinName(ulPin);
7575
if(p != NC) {
7676
#ifdef HAL_DAC_MODULE_ENABLED
7777
if(pin_in_pinmap(p, PinMap_DAC)) {

Diff for: cores/arduino/wiring_digital.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extern uint32_t g_anOutputPinConfigured[MAX_NB_PORT];
3030

3131
void pinMode( uint32_t ulPin, uint32_t ulMode )
3232
{
33-
PinName p = digitalToPinName(ulPin);
33+
PinName p = digitalPinToPinName(ulPin);
3434

3535
if(p != NC) {
3636
// If the pin that support PWM or DAC output, we need to turn it off
@@ -69,7 +69,7 @@ void pinMode( uint32_t ulPin, uint32_t ulMode )
6969

7070
void digitalWrite( uint32_t ulPin, uint32_t ulVal )
7171
{
72-
PinName p = digitalToPinName(ulPin);
72+
PinName p = digitalPinToPinName(ulPin);
7373
if(p != NC) {
7474
if(is_pin_configured(p, g_digPinConfigured)) {
7575
digital_io_write(get_GPIO_Port(STM_PORT(p)), STM_GPIO_PIN(p), ulVal);
@@ -80,7 +80,7 @@ void digitalWrite( uint32_t ulPin, uint32_t ulVal )
8080
int digitalRead( uint32_t ulPin )
8181
{
8282
uint8_t level = 0;
83-
PinName p = digitalToPinName(ulPin);
83+
PinName p = digitalPinToPinName(ulPin);
8484
if(p != NC) {
8585
if(is_pin_configured(p, g_digPinConfigured)) {
8686
level = digital_io_read(get_GPIO_Port(STM_PORT(p)), STM_GPIO_PIN(p));

Diff for: libraries/SPI/SPI.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ SPIClass SPI;
2020

2121
SPIClass::SPIClass() : g_active_id(-1)
2222
{
23-
_spi.pin_miso = digitalToPinName(MISO);
24-
_spi.pin_mosi = digitalToPinName(MOSI);
25-
_spi.pin_sclk = digitalToPinName(SCLK);
23+
_spi.pin_miso = digitalPinToPinName(MISO);
24+
_spi.pin_mosi = digitalPinToPinName(MOSI);
25+
_spi.pin_sclk = digitalPinToPinName(SCLK);
2626
_spi.pin_ssel = NC;
2727
}
2828

@@ -31,12 +31,12 @@ ssel pin. Enable this pin disable software CS. See microcontroller documentation
3131
for the list of available SS pins. */
3232
SPIClass::SPIClass(uint8_t mosi, uint8_t miso, uint8_t sclk, uint8_t ssel) : g_active_id(-1)
3333
{
34-
_spi.pin_miso = digitalToPinName(miso);
35-
_spi.pin_mosi = digitalToPinName(mosi);
36-
_spi.pin_sclk = digitalToPinName(sclk);
34+
_spi.pin_miso = digitalPinToPinName(miso);
35+
_spi.pin_mosi = digitalPinToPinName(mosi);
36+
_spi.pin_sclk = digitalPinToPinName(sclk);
3737

3838
if(ssel != 0xFF) {
39-
_spi.pin_ssel = digitalToPinName(ssel);
39+
_spi.pin_ssel = digitalPinToPinName(ssel);
4040
} else {
4141
_spi.pin_ssel = NC;
4242
}

Diff for: libraries/Wire/Wire.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ void (*TwoWire::user_onReceive)(int);
4545

4646
TwoWire::TwoWire()
4747
{
48-
_i2c.sda = digitalToPinName(SDA);
49-
_i2c.scl = digitalToPinName(SCL);
48+
_i2c.sda = digitalPinToPinName(SDA);
49+
_i2c.scl = digitalPinToPinName(SCL);
5050
}
5151

5252
TwoWire::TwoWire(uint8_t sda, uint8_t scl)
5353
{
54-
_i2c.sda = digitalToPinName(sda);
55-
_i2c.scl = digitalToPinName(scl);
54+
_i2c.sda = digitalPinToPinName(sda);
55+
_i2c.scl = digitalPinToPinName(scl);
5656
}
5757

5858
// Public Methods //////////////////////////////////////////////////////////////

Diff for: variants/DISCO_F407VG/PeripheralPins.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@
3838
//*** ADC ***
3939

4040
const PinMap PinMap_ADC[] = {
41-
{PA0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 - User Blue button
41+
// {PA0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 - User Blue button
4242
// {PA0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 - User Blue button
4343
// {PA0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 - User Blue button
4444
{PA1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1
4545
// {PA1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1
4646
// {PA1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1
4747
// {PA2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2
48-
{PA2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2
48+
// {PA2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2
4949
// {PA2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2
5050
// {PA3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3
51-
{PA3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3
51+
// {PA3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3
5252
// {PA3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3
5353
// {PA4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 - I2S3_WS
5454
// {PA4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 - I2S3_WS
@@ -110,7 +110,7 @@ const PinMap PinMap_I2C_SCL[] = {
110110
//*** PWM ***
111111

112112
const PinMap PinMap_PWM[] = {
113-
{PA0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - User Blue button
113+
// {PA0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - User Blue button
114114
// {PA0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 - User Blue button
115115
{PA1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2
116116
// {PA1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2
@@ -184,7 +184,7 @@ const PinMap PinMap_PWM[] = {
184184
//*** SERIAL ***
185185

186186
const PinMap PinMap_UART_TX[] = {
187-
{PA0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // User Blue button
187+
// {PA0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // User Blue button
188188
{PA2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
189189
// {PA9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB
190190
// {PB6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Audio_SCL
@@ -223,7 +223,7 @@ const PinMap PinMap_UART_RTS[] = {
223223
};
224224

225225
const PinMap PinMap_UART_CTS[] = {
226-
{PA0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // User Blue button
226+
// {PA0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // User Blue button
227227
// {PA11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB
228228
{PB13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
229229
{PD3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},

Diff for: variants/DISCO_F407VG/variant.cpp

+10-25
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern "C" {
2323
#endif
2424

2525
// Pin number
26-
const PinName digital_arduino[] = {
26+
const PinName digitalPin[] = {
2727
//P1 connector Right side
2828
PC0, //D0
2929
PC2, //D1
@@ -108,13 +108,15 @@ const PinName digital_arduino[] = {
108108
PC9, //D77
109109
PC7, //D78
110110
//Duplicated to have A0-A5 as F407 do not have Uno like connector
111-
PA0, //D79/A0
112-
PA1, //D80/A1
113-
PA2, //D81/A2
114-
PA3, //D82/A3
115-
PB0, //D83/A4
116-
PB1 //D84/A5
117-
// Here we could continue to define Analog pin if we want A6,...
111+
// and to be aligned with PinMap_ADC
112+
PC2, //D79/A0 = D1
113+
PC4, //D80/A1 = D6
114+
PB0, //D81/A2 = D7
115+
PC1, //D82/A3 = D39
116+
PC3, //D83/A4 = D40
117+
PA1, //D84/A5 = D41
118+
PC5, //D85/A6 = D45
119+
PB1 //D86/A7 = D46
118120
};
119121

120122
#ifdef __cplusplus
@@ -141,23 +143,6 @@ void serialEventRun(void)
141143
extern "C" {
142144
#endif
143145

144-
void __libc_init_array(void);
145-
146-
uint32_t pinNametoPinNumber(PinName p)
147-
{
148-
uint32_t i = 0;
149-
for(i = 0; i < NUM_DIGITAL_PINS; i++) {
150-
if (digital_arduino[i] == p)
151-
break;
152-
}
153-
return i;
154-
}
155-
156-
void init( void )
157-
{
158-
hw_config_init();
159-
}
160-
161146
/**
162147
* @brief System Clock Configuration
163148
* The system Clock is configured as follow :

0 commit comments

Comments
 (0)