Skip to content

Review analog pins numbering and pin functions #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@ Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.upload.maximum_size=262144
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.upload.maximum_data_size=32768
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.mcu=cortex-m0
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.f_cpu=8000000L
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.usb_product="NUCLEO-F091RC"
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.board=NUCLEO_F091RC
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.series=STM32F0xx
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.variant=NUCLEO_F091RC
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.cmsis_lib_gcc=arm_cortexM0l_math
#To enable USB add '-DUSBCON'
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE'
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.extra_flags=-DSTM32F091xC {build.usb_flags}
#To enable Serial1 (USART1 on PA10, PA9) add -DENABLE_SERIAL1
#To enable Serial2 (USART2 on PA1, PA0) add -DENABLE_SERIAL2
Nucleo_64.menu.Nucleo_64_board.NUCLEO_F091RC.build.extra_flags=-DSTM32F091xC

# NUCLEO_F303RE board

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

# NUCLEO_L053R8 board

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

# NUCLEO_L476RG board

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

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


Expand Down
2 changes: 1 addition & 1 deletion cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ extern void loop( void ) ;


// Include board variant
#include "variant.h"
#include "pins_arduino.h"

#include "wiring.h"
#include "wiring_digital.h"
Expand Down
4 changes: 2 additions & 2 deletions cores/arduino/Tone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static stimer_t _timer;

void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
{
PinName p = digitalToPinName(_pin);
PinName p = digitalPinToPinName(_pin);
if(p != NC) {
if((g_lastPin == NC) || (g_lastPin == p)) {
_timer.pin = p;
Expand All @@ -41,7 +41,7 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)

void noTone(uint8_t _pin)
{
PinName p = digitalToPinName(_pin);
PinName p = digitalPinToPinName(_pin);
if(p != NC) {
TimerPinDeinit(&_timer);
digitalWrite(_pin, 0);
Expand Down
4 changes: 2 additions & 2 deletions cores/arduino/WInterrupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
void attachInterrupt(uint32_t pin, void (*callback)(void), uint32_t mode)
{
uint32_t it_mode;
PinName p = digitalToPinName(pin);
PinName p = digitalPinToPinName(pin);
GPIO_TypeDef* port = set_GPIO_Port_Clock(STM_PORT(p));
if (port == NC)
return;
Expand All @@ -51,7 +51,7 @@ void attachInterrupt(uint32_t pin, void (*callback)(void), uint32_t mode)

void detachInterrupt(uint32_t pin)
{
PinName p = digitalToPinName(pin);
PinName p = digitalPinToPinName(pin);
GPIO_TypeDef* port = get_GPIO_Port(STM_PORT(p));
if (port == NC)
return;
Expand Down
36 changes: 36 additions & 0 deletions cores/arduino/pins_arduino.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright (c) 2011 Arduino. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "pins_arduino.h"

void __libc_init_array(void);

WEAK uint32_t pinNametoDigitalPin(PinName p)
{
uint32_t i = 0;
for(i = 0; i < NUM_DIGITAL_PINS; i++) {
if (digitalPin[i] == p)
break;
}
return i;
}

WEAK void init( void )
{
hw_config_init();
}
30 changes: 30 additions & 0 deletions cores/arduino/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,37 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _PINS_ARDUINO_H_
#define _PINS_ARDUINO_H_

/**
* Libc porting layers
*/
#if defined ( __GNUC__ ) /* GCC CS3 */
# include <syscalls.h> /** RedHat Newlib minimal stub */
#endif

// API compatibility
#include "variant.h"

#define NUM_DIGITAL_PINS DEND
#define NUM_ANALOG_INPUTS (AEND-A0)

// Convert a digital pin number Dxx to a PinName Pxy
// Note: Analog pin is also a digital pin.
#define digitalPinToPinName(p) ((p < NUM_DIGITAL_PINS) ? digitalPin[p] : (STM_VALID_PINNAME(p))? (PinName)p : NC)
// Convert a PinName Pxy to a digital pin number
uint32_t pinNametoDigitalPin(PinName p);

// Convert an analog pin number to a digital pin number
// Used by analogRead api to have A0 == 0
#define analogInputToDigitalPin(p) ((p < NUM_ANALOG_INPUTS) ? (p+A0) : p)
// Convert an analog pin number Axx to a PinName Pxy
#define analogInputToPinName(p) (digitalPinToPinName(analogInputToDigitalPin(p)))
// All pins could manage EXTI
#define digitalPinToInterrupt(p) (p)

#define digitalPinToPort(p) ( get_GPIO_Port(digitalPinToPinName(p)) )
#define digitalPinToBitMask(p) ( STM_GPIO_PIN(digitalPinToPinName(p)) )

#endif /*_PINS_ARDUINO_H_*/
4 changes: 2 additions & 2 deletions cores/arduino/wiring_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static inline uint32_t mapResolution(uint32_t value, uint32_t from, uint32_t to)
uint32_t analogRead(uint32_t ulPin)
{
uint32_t value = 0;
PinName p = analogToPinName(ulPin);
PinName p = analogInputToPinName(ulPin);
if(p != NC) {
value = adc_read_value(p);
value = mapResolution(value, ADC_RESOLUTION, _readResolution);
Expand All @@ -71,7 +71,7 @@ void analogOutputInit(void) {
void analogWrite(uint32_t ulPin, uint32_t ulValue) {

uint8_t do_init = 0;
PinName p = analogToPinName(ulPin);
PinName p = digitalPinToPinName(ulPin);
if(p != NC) {
#ifdef HAL_DAC_MODULE_ENABLED
if(pin_in_pinmap(p, PinMap_DAC)) {
Expand Down
6 changes: 3 additions & 3 deletions cores/arduino/wiring_digital.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern uint32_t g_anOutputPinConfigured[MAX_NB_PORT];

void pinMode( uint32_t ulPin, uint32_t ulMode )
{
PinName p = digitalToPinName(ulPin);
PinName p = digitalPinToPinName(ulPin);

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

void digitalWrite( uint32_t ulPin, uint32_t ulVal )
{
PinName p = digitalToPinName(ulPin);
PinName p = digitalPinToPinName(ulPin);
if(p != NC) {
if(is_pin_configured(p, g_digPinConfigured)) {
digital_io_write(get_GPIO_Port(STM_PORT(p)), STM_GPIO_PIN(p), ulVal);
Expand All @@ -80,7 +80,7 @@ void digitalWrite( uint32_t ulPin, uint32_t ulVal )
int digitalRead( uint32_t ulPin )
{
uint8_t level = 0;
PinName p = digitalToPinName(ulPin);
PinName p = digitalPinToPinName(ulPin);
if(p != NC) {
if(is_pin_configured(p, g_digPinConfigured)) {
level = digital_io_read(get_GPIO_Port(STM_PORT(p)), STM_GPIO_PIN(p));
Expand Down
14 changes: 7 additions & 7 deletions libraries/SPI/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ SPIClass SPI;

SPIClass::SPIClass() : g_active_id(-1)
{
_spi.pin_miso = digitalToPinName(MISO);
_spi.pin_mosi = digitalToPinName(MOSI);
_spi.pin_sclk = digitalToPinName(SCLK);
_spi.pin_miso = digitalPinToPinName(MISO);
_spi.pin_mosi = digitalPinToPinName(MOSI);
_spi.pin_sclk = digitalPinToPinName(SCLK);
_spi.pin_ssel = NC;
}

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

if(ssel != 0xFF) {
_spi.pin_ssel = digitalToPinName(ssel);
_spi.pin_ssel = digitalPinToPinName(ssel);
} else {
_spi.pin_ssel = NC;
}
Expand Down
8 changes: 4 additions & 4 deletions libraries/Wire/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ void (*TwoWire::user_onReceive)(int);

TwoWire::TwoWire()
{
_i2c.sda = digitalToPinName(SDA);
_i2c.scl = digitalToPinName(SCL);
_i2c.sda = digitalPinToPinName(SDA);
_i2c.scl = digitalPinToPinName(SCL);
}

TwoWire::TwoWire(uint8_t sda, uint8_t scl)
{
_i2c.sda = digitalToPinName(sda);
_i2c.scl = digitalToPinName(scl);
_i2c.sda = digitalPinToPinName(sda);
_i2c.scl = digitalPinToPinName(scl);
}

// Public Methods //////////////////////////////////////////////////////////////
Expand Down
12 changes: 6 additions & 6 deletions variants/DISCO_F407VG/PeripheralPins.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@
//*** ADC ***

const PinMap PinMap_ADC[] = {
{PA0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 - User Blue button
// {PA0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 - User Blue button
// {PA0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 - User Blue button
// {PA0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 - User Blue button
{PA1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1
// {PA1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1
// {PA1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1
// {PA2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2
{PA2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2
// {PA2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2
// {PA2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2
// {PA3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3
{PA3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3
// {PA3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3
// {PA3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3
// {PA4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 - I2S3_WS
// {PA4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 - I2S3_WS
Expand Down Expand Up @@ -110,7 +110,7 @@ const PinMap PinMap_I2C_SCL[] = {
//*** PWM ***

const PinMap PinMap_PWM[] = {
{PA0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - User Blue button
// {PA0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - User Blue button
// {PA0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 - User Blue button
{PA1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2
// {PA1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2
Expand Down Expand Up @@ -184,7 +184,7 @@ const PinMap PinMap_PWM[] = {
//*** SERIAL ***

const PinMap PinMap_UART_TX[] = {
{PA0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // User Blue button
// {PA0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // User Blue button
{PA2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
// {PA9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB
// {PB6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Audio_SCL
Expand Down Expand Up @@ -223,7 +223,7 @@ const PinMap PinMap_UART_RTS[] = {
};

const PinMap PinMap_UART_CTS[] = {
{PA0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // User Blue button
// {PA0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // User Blue button
// {PA11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB
{PB13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
{PD3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
Expand Down
35 changes: 10 additions & 25 deletions variants/DISCO_F407VG/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern "C" {
#endif

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

#ifdef __cplusplus
Expand All @@ -141,23 +143,6 @@ void serialEventRun(void)
extern "C" {
#endif

void __libc_init_array(void);

uint32_t pinNametoPinNumber(PinName p)
{
uint32_t i = 0;
for(i = 0; i < NUM_DIGITAL_PINS; i++) {
if (digital_arduino[i] == p)
break;
}
return i;
}

void init( void )
{
hw_config_init();
}

/**
* @brief System Clock Configuration
* The system Clock is configured as follow :
Expand Down
Loading