Skip to content

Commit bbab064

Browse files
committed
For PR to add pinPeripheral() function - note wiring_private.c stubbed right now, will be fixed to make compatible with H7 --- jcw
1 parent 46d3418 commit bbab064

File tree

4 files changed

+86
-13
lines changed

4 files changed

+86
-13
lines changed

cores/arduino/WVariant.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//** just starting suggestion at this point --- jcw - 9/10/20
2+
/*
3+
Copyright (c) 2015 Arduino LLC. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+
See the GNU Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#pragma once
21+
22+
#include <stdint.h>
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
typedef enum _EPioType
29+
{
30+
PIO_NOT_A_PIN=-1, /* Not under control of a peripheral. */
31+
PIO_EXTINT=0, /* The pin is controlled by the associated signal of peripheral A. */
32+
PIO_ANALOG, /* The pin is controlled by the associated signal of peripheral B. */
33+
PIO_SERCOM, /* The pin is controlled by the associated signal of peripheral C. */
34+
PIO_SERCOM_ALT, /* The pin is controlled by the associated signal of peripheral D. */
35+
PIO_TIMER, /* The pin is controlled by the associated signal of peripheral E. */
36+
PIO_TIMER_ALT, /* The pin is controlled by the associated signal of peripheral F. */
37+
PIO_COM, /* The pin is controlled by the associated signal of peripheral G. */
38+
PIO_AC_CLK, /* The pin is controlled by the associated signal of peripheral H. */
39+
PIO_DIGITAL, /* The pin is controlled by PORT. */
40+
PIO_INPUT, /* The pin is controlled by PORT and is an input. */
41+
PIO_INPUT_PULLUP, /* The pin is controlled by PORT and is an input with internal pull-up resistor enabled. */
42+
PIO_OUTPUT, /* The pin is controlled by PORT and is an output. */
43+
44+
PIO_PWM=PIO_TIMER,
45+
PIO_PWM_ALT=PIO_TIMER_ALT,
46+
} EPioType ;
47+
48+
/**
49+
* Pin Attributes to be OR-ed
50+
*/
51+
#define PIN_ATTR_NONE (0UL<<0)
52+
#define PIN_ATTR_COMBO (1UL<<0)
53+
#define PIN_ATTR_ANALOG (1UL<<1)
54+
#define PIN_ATTR_DIGITAL (1UL<<2)
55+
#define PIN_ATTR_PWM (1UL<<3)
56+
#define PIN_ATTR_TIMER (1UL<<4)
57+
#define PIN_ATTR_TIMER_ALT (1UL<<5)
58+
#define PIN_ATTR_EXTINT (1UL<<6)
59+
60+
61+
#ifdef __cplusplus
62+
} // extern "C"
63+
#endif
64+

cores/arduino/wiring_constants.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ extern "C"{
4242
#define SERIAL 0x0
4343
#define DISPLAY 0x1
4444

45-
enum BitOrder {
46-
LSBFIRST = 0,
47-
MSBFIRST = 1
48-
};
45+
// enum BitOrder {
46+
// LSBFIRST = 0,
47+
// MSBFIRST = 1
48+
// };
4949

5050
// moved to WInterrupts.h
5151
//// LOW 0

cores/arduino/wiring_private.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
//** just starting suggestion at this point --- jcw - 9/10/20
2+
3+
// This file is stubbed - will fix incompatibilies with Portenta
4+
// pinMode() calls need to be fixed for a start...
5+
///**XXX** - marks what needs to be fixed
6+
7+
28
/*
39
Copyright (c) 2015 Arduino LLC. All right reserved.
410
@@ -19,14 +25,15 @@
1925

2026
#include "Arduino.h"
2127
#include "wiring_private.h"
28+
#include "WVariant.h"
2229

2330
int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral )
2431
{
2532
// Handle the case the pin isn't usable as PIO
26-
if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN )
27-
{
28-
return -1 ;
29-
}
33+
//**XXX*** STIB UNTIL FIXED --- if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN )
34+
/// {
35+
/// return -1 ;
36+
/// }
3037

3138
switch ( ulPeripheral )
3239
{
@@ -40,19 +47,19 @@ int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral )
4047
// Configure pin mode, if requested
4148
if ( ulPeripheral == PIO_INPUT )
4249
{
43-
pinMode( ulPin, INPUT ) ;
50+
///***XXX^^^ stub until fixed pinMode( ulPin, INPUT ) ;
4451
}
4552
else
4653
{
4754
if ( ulPeripheral == PIO_INPUT_PULLUP )
4855
{
49-
pinMode( ulPin, INPUT_PULLUP ) ;
56+
///***XXX^^^ stub until fixed pinMode( ulPin, INPUT_PULLUP ) ;
5057
}
5158
else
5259
{
5360
if ( ulPeripheral == PIO_OUTPUT )
5461
{
55-
pinMode( ulPin, OUTPUT ) ;
62+
///***XXX^^^ stub until fixed pinMode( ulPin, OUTPUT ) ;
5663
}
5764
else
5865
{
@@ -87,6 +94,7 @@ int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral )
8794
PORT_WRCONFIG_PINMASK( g_APinDescription[ulPin].ulPin - 16 ) ;
8895
}
8996
#else
97+
#if 0 ///***XXX^^^ stub until fixed - should be #if 1 here <-
9098
if ( g_APinDescription[ulPin].ulPin & 1 ) // is pin odd?
9199
{
92100
uint32_t temp ;
@@ -106,6 +114,7 @@ int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral )
106114
PORT->Group[g_APinDescription[ulPin].ulPort].PMUX[g_APinDescription[ulPin].ulPin >> 1].reg = temp|PORT_PMUX_PMUXE( ulPeripheral ) ;
107115
PORT->Group[g_APinDescription[ulPin].ulPort].PINCFG[g_APinDescription[ulPin].ulPin].reg |= PORT_PINCFG_PMUXEN ; // Enable port mux
108116
}
117+
#endif
109118
#endif
110119
break ;
111120

cores/arduino/wiring_private.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <stdarg.h>
3030

3131
#include "Arduino.h"
32-
32+
#include "WVariant.h"
3333
#ifdef __cplusplus
3434
extern "C"{
3535
#endif
@@ -42,5 +42,5 @@ int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral );
4242
#ifdef __cplusplus
4343
} // extern "C"
4444
#endif
45-
// #include "HardwareSerial.h"
45+
4646
#endif

0 commit comments

Comments
 (0)