Skip to content

Commit b5c7c3e

Browse files
committed
Fix issue with header include.
#Fix 126 Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
1 parent c0e9e94 commit b5c7c3e

File tree

5 files changed

+134
-132
lines changed

5 files changed

+134
-132
lines changed

cores/arduino/Arduino.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void yield(void);
3434
} // extern "C"
3535
#endif // __cplusplus
3636

37-
// Include board variant
38-
#include "pins_arduino.h"
37+
// Include pins variant
38+
#include "pins_arduino_var.h"
3939

4040
#endif // Arduino_h

cores/arduino/pins_arduino.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "pins_arduino.h"
20+
#include "pins_arduino_var.h"
2021

2122
#ifdef __cplusplus
2223
extern "C" {

cores/arduino/pins_arduino.h

Lines changed: 23 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
#define _PINS_ARDUINO_H_
2020

2121
#include "PeripheralPins.h"
22-
#include "pins_arduino_common.h"
23-
#include "variant.h"
24-
25-
#ifdef __cplusplus
26-
extern "C" {
27-
#endif
2822

2923
/**
3024
* Libc porting layers
@@ -34,79 +28,28 @@ extern "C" {
3428
#define WEAK __attribute__ ((weak))
3529
#endif
3630

37-
#define NOT_AN_INTERRUPT NC // -1
38-
#define DEND PEND
39-
#define NUM_DIGITAL_PINS ((uint32_t)DEND)
40-
#define NUM_ANALOG_INPUTS ((uint32_t)(AEND-A0))
41-
42-
// Convert a digital pin number Dxx to a PinName PX_n
43-
// Note: Analog pin is also a digital pin.
44-
#define digitalPinToPinName(p) (((uint32_t)p < NUM_DIGITAL_PINS) ? digitalPin[p] : NC)
45-
// Convert a PinName PX_n to a digital pin number
46-
uint32_t pinNametoDigitalPin(PinName p);
47-
48-
// Convert an analog pin number to a digital pin number
49-
// Used by analogRead api to have A0 == 0
50-
#define analogInputToDigitalPin(p) (((uint32_t)p < NUM_ANALOG_INPUTS) ? (p+A0) : p)
51-
// Convert an analog pin number Axx to a PinName PX_n
52-
#define analogInputToPinName(p) (digitalPinToPinName(analogInputToDigitalPin(p)))
53-
// All pins could manage EXTI
54-
#define digitalPinToInterrupt(p) (digitalPinIsValid(p) ? p : NOT_AN_INTERRUPT)
55-
56-
#define digitalPinHasI2C(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_I2C_SDA) ||\
57-
pin_in_pinmap(digitalPinToPinName(p), PinMap_I2C_SCL))
58-
#define digitalPinHasPWM(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_PWM))
59-
#define digitalPinHasSerial(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_UART_RX) ||\
60-
pin_in_pinmap(digitalPinToPinName(p), PinMap_UART_TX))
61-
#define digitalPinHasSPI(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_SPI_MOSI) ||\
62-
pin_in_pinmap(digitalPinToPinName(p), PinMap_SPI_MISO) ||\
63-
pin_in_pinmap(digitalPinToPinName(p), PinMap_SPI_SCLK) ||\
64-
pin_in_pinmap(digitalPinToPinName(p), PinMap_SPI_SSEL))
65-
66-
67-
#define digitalPinToPort(p) (get_GPIO_Port(STM_PORT(digitalPinToPinName(p))))
68-
#define digitalPinToBitMask(p) (STM_GPIO_PIN(digitalPinToPinName(p)))
69-
70-
#define analogInPinToBit(p) (STM_PIN(digitalPinToPinName(p)))
71-
#define portOutputRegister(P) (&(P->ODR))
72-
#define portInputRegister(P) (&(P->IDR))
73-
74-
#define portSetRegister(P) (&(P->BSRR))
75-
#if defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32F7xx)
76-
// For those series reset are in the high part so << 16U needed
77-
#define portClearRegister(P) (&(P->BSRR))
78-
#else
79-
#define portClearRegister(P) (&(P->BRR))
80-
#endif
81-
82-
83-
#if defined(STM32F1xx)
84-
// Config registers split in 2 registers:
85-
// CRL: pin 0..7
86-
// CRH: pin 8..15
87-
// Return only CRL
88-
#define portModeRegister(P) (&(P->CRL))
89-
#else
90-
#define portModeRegister(P) (&(P->MODER))
91-
#endif
92-
#define portConfigRegister(P) (portModeRegister(P))
93-
94-
95-
#define digitalPinIsValid(p) (digitalPinToPinName(p) != NC)
96-
97-
// As some pin could be duplicated in digitalPin[]
98-
// return first occurence of linked PinName (PYx)
99-
#define digitalPinFirstOccurence(p) (pinNametoDigitalPin(digitalPinToPinName(p)))
100-
101-
// Specific for Firmata. As some pins could be duplicated,
102-
// ensure 'p' is not one of the serial pins
103-
#if defined(PIN_SERIAL_RX) && defined(PIN_SERIAL_TX)
104-
#define pinIsSerial(p) ((digitalPinFirstOccurence(p) == PIN_SERIAL_RX) ||\
105-
(digitalPinFirstOccurence(p) == PIN_SERIAL_TX))
106-
#endif
107-
108-
#ifdef __cplusplus
109-
}
110-
#endif
31+
// Arduino digital pin alias
32+
// GPIO port (A to K) * 16 pins: 176
33+
enum {
34+
D0, D1, D2, D3, D4, D5, D6, D7, D8, D9,
35+
D10, D11, D12, D13, D14, D15, D16, D17, D18, D19,
36+
D20, D21, D22, D23, D24, D25, D26, D27, D28, D29,
37+
D30, D31, D32, D33, D34, D35, D36, D37, D38, D39,
38+
D40, D41, D42, D43, D44, D45, D46, D47, D48, D49,
39+
D50, D51, D52, D53, D54, D55, D56, D57, D58, D59,
40+
D60, D61, D62, D63, D64, D65, D66, D67, D68, D69,
41+
D70, D71, D72, D73, D74, D75, D76, D77, D78, D79,
42+
D80, D81, D82, D83, D84, D85, D86, D87, D88, D89,
43+
D90, D91, D92, D93, D94, D95, D96, D97, D98, D99,
44+
D100, D101, D102, D103, D104, D105, D106, D107, D108, D109,
45+
D110, D111, D112, D113, D114, D115, D116, D117, D118, D119,
46+
D120, D121, D122, D123, D124, D125, D126, D127, D128, D129,
47+
D130, D131, D132, D133, D134, D135, D136, D137, D138, D139,
48+
D140, D141, D142, D143, D144, D145, D146, D147, D148, D149,
49+
D150, D151, D152, D153, D154, D155, D156, D157, D158, D159,
50+
D160, D161, D162, D163, D164, D165, D166, D167, D168, D169,
51+
D170, D171, D172, D173, D174, D175,
52+
DMAX
53+
};
11154

11255
#endif /*_PINS_ARDUINO_H_*/

cores/arduino/pins_arduino_common.h

Lines changed: 0 additions & 50 deletions
This file was deleted.

cores/arduino/pins_arduino_var.h

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* Variant pins Arduino definition
3+
*
4+
* Copyright (C) 2017, STMicroelectronics - All Rights Reserved
5+
* Author: Frederic Pillon for STMicroelectronics.
6+
*
7+
* License type: GPLv2
8+
*
9+
* This program is free software; you can redistribute it and/or modify it
10+
* under the terms of the GNU General Public License version 2 as published by
11+
* the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful, but
14+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE.
16+
* See the GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License along with
19+
* this program. If not, see
20+
* <http://www.gnu.org/licenses/>.
21+
*/
22+
#ifndef _PINS_ARDUINO_VAR_H_
23+
#define _PINS_ARDUINO_VAR_H_
24+
25+
// Include board variant
26+
#include "variant.h"
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
#define NOT_AN_INTERRUPT NC // -1
33+
#define DEND PEND
34+
#define NUM_DIGITAL_PINS ((uint32_t)DEND)
35+
#define NUM_ANALOG_INPUTS ((uint32_t)(AEND-A0))
36+
37+
// Convert a digital pin number Dxx to a PinName PX_n
38+
// Note: Analog pin is also a digital pin.
39+
#define digitalPinToPinName(p) (((uint32_t)p < NUM_DIGITAL_PINS) ? digitalPin[p] : NC)
40+
// Convert a PinName PX_n to a digital pin number
41+
uint32_t pinNametoDigitalPin(PinName p);
42+
43+
// Convert an analog pin number to a digital pin number
44+
// Used by analogRead api to have A0 == 0
45+
#define analogInputToDigitalPin(p) (((uint32_t)p < NUM_ANALOG_INPUTS) ? (p+A0) : p)
46+
// Convert an analog pin number Axx to a PinName PX_n
47+
#define analogInputToPinName(p) (digitalPinToPinName(analogInputToDigitalPin(p)))
48+
// All pins could manage EXTI
49+
#define digitalPinToInterrupt(p) (digitalPinIsValid(p) ? p : NOT_AN_INTERRUPT)
50+
51+
#define digitalPinHasI2C(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_I2C_SDA) ||\
52+
pin_in_pinmap(digitalPinToPinName(p), PinMap_I2C_SCL))
53+
#define digitalPinHasPWM(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_PWM))
54+
#define digitalPinHasSerial(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_UART_RX) ||\
55+
pin_in_pinmap(digitalPinToPinName(p), PinMap_UART_TX))
56+
#define digitalPinHasSPI(p) (pin_in_pinmap(digitalPinToPinName(p), PinMap_SPI_MOSI) ||\
57+
pin_in_pinmap(digitalPinToPinName(p), PinMap_SPI_MISO) ||\
58+
pin_in_pinmap(digitalPinToPinName(p), PinMap_SPI_SCLK) ||\
59+
pin_in_pinmap(digitalPinToPinName(p), PinMap_SPI_SSEL))
60+
61+
62+
#define digitalPinToPort(p) (get_GPIO_Port(STM_PORT(digitalPinToPinName(p))))
63+
#define digitalPinToBitMask(p) (STM_GPIO_PIN(digitalPinToPinName(p)))
64+
65+
#define analogInPinToBit(p) (STM_PIN(digitalPinToPinName(p)))
66+
#define portOutputRegister(P) (&(P->ODR))
67+
#define portInputRegister(P) (&(P->IDR))
68+
69+
#define portSetRegister(P) (&(P->BSRR))
70+
#if defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32F7xx)
71+
// For those series reset are in the high part so << 16U needed
72+
#define portClearRegister(P) (&(P->BSRR))
73+
#else
74+
#define portClearRegister(P) (&(P->BRR))
75+
#endif
76+
77+
78+
#if defined(STM32F1xx)
79+
// Config registers split in 2 registers:
80+
// CRL: pin 0..7
81+
// CRH: pin 8..15
82+
// Return only CRL
83+
#define portModeRegister(P) (&(P->CRL))
84+
#else
85+
#define portModeRegister(P) (&(P->MODER))
86+
#endif
87+
#define portConfigRegister(P) (portModeRegister(P))
88+
89+
90+
#define digitalPinIsValid(p) (digitalPinToPinName(p) != NC)
91+
92+
// As some pin could be duplicated in digitalPin[]
93+
// return first occurence of linked PinName (PYx)
94+
#define digitalPinFirstOccurence(p) (pinNametoDigitalPin(digitalPinToPinName(p)))
95+
96+
// Specific for Firmata. As some pins could be duplicated,
97+
// ensure 'p' is not one of the serial pins
98+
#if defined(PIN_SERIAL_RX) && defined(PIN_SERIAL_TX)
99+
#define pinIsSerial(p) ((digitalPinFirstOccurence(p) == PIN_SERIAL_RX) ||\
100+
(digitalPinFirstOccurence(p) == PIN_SERIAL_TX))
101+
#endif
102+
103+
#ifdef __cplusplus
104+
}
105+
#endif
106+
107+
#endif /*_PINS_ARDUINO_VAR_H_*/
108+

0 commit comments

Comments
 (0)