1
1
//** just starting suggestion at this point --- jcw - 9/10/20
2
-
3
2
/*
4
3
Copyright (c) 2015 Arduino LLC. All right reserved.
5
4
18
17
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
18
*/
20
19
21
- #include "Arduino.h"
22
- #include "api/Common.h"
23
- #include "wiring_private.h"
24
- #include "WVariant.h"
20
+ // #include <Arduino.h>
21
+ // #include "gpio_object.h"
22
+ // #include "Wire.h"
23
+ // #include "api/Common.h"
24
+ #include <wiring_private.h>
25
+ // #include "device.h"
26
+ // #include "pinmap.h"
27
+ // #include "WVariant.h"
28
+ // #include "pinmode_arduino.h"
29
+ #include "pins_arduino.h"
30
+ #include "mbed.h"
31
+
32
+
33
+ static uint8_t pin = 4 ;
34
+ // static gpio_t gpio;
35
+ // gpio_t gpio;
36
+
37
+ // extern PinDescription g_APinDescription[];
38
+ #if 0
39
+ PinDescription g_APinDescription [] = {
40
+ // D0 - D7
41
+ { PH_15 , NULL , NULL , NULL }, // D0
42
+ { PK_1 , NULL , NULL , NULL }, // D1
43
+ { PJ_11 , NULL , NULL , NULL }, // D2
44
+ { PG_7 , NULL , NULL , NULL }, // D3
45
+ { PC_7 , NULL , NULL , NULL }, // D4
46
+ { PC_6 , NULL , NULL , NULL }, // D5
47
+ { PA_8 , NULL , NULL , NULL }, // D6
48
+ { PI_0 , NULL , NULL , NULL }, // D7
49
+
50
+ // D8 - D14
51
+ { PC_3 , NULL , NULL , NULL }, // D8
52
+ { PI_1 , NULL , NULL , NULL }, // D9
53
+ { PC_2 , NULL , NULL , NULL }, // D10
54
+ { PH_8 , NULL , NULL , NULL }, // D11
55
+ { PH_7 , NULL , NULL , NULL }, // D12
56
+ { PA_10 , NULL , NULL , NULL }, // D13
57
+ { PA_9 , NULL , NULL , NULL }, // D14
58
+
59
+ // A0 - A6
60
+ { PA_0C , NULL , NULL , NULL }, // A0 ADC2_INP0
61
+ { PA_1C , NULL , NULL , NULL }, // A1 ADC2_INP1
62
+ { PC_2C , NULL , NULL , NULL }, // A2 ADC3_INP0
63
+ { PC_3C , NULL , NULL , NULL }, // A3 ADC3_INP1
64
+ { PC_2_ALT0 , NULL , NULL , NULL }, // A4 ADC1_INP12
65
+ { PC_3_ALT0 , NULL , NULL , NULL }, // A5 ADC1_INP13
66
+ { PA_4 , NULL , NULL , NULL }, // A6 ADC1_INP18
67
+
68
+ // LEDS
69
+ { PK_5 , NULL , NULL , NULL }, // LEDR
70
+ { PK_6 , NULL , NULL , NULL }, // LEDG
71
+ { PK_7 , NULL , NULL , NULL }, // LEDB
72
+ };
73
+ #endif
74
+
25
75
76
+ extern struct PinDescription g_APinDescription ;
77
+ // extern void pinMode(pin_size_t pinNumber, PinMode pinMode);
26
78
27
79
int pinPeripheral ( uint32_t ulPin , EPioType ulPeripheral )
28
80
{
81
+
82
+
83
+
29
84
// Handle the case the pin isn't usable as PIO
30
- // if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN )
85
+ // if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN )
86
+ // if ( g_APinDescription[ulPin].gpio == PIO_NOT_A_PIN )
87
+ // if ( g_APinDescription[pin].gpio == PIO_NOT_A_PIN )
88
+ // if ( g_APinDescription[pin] == PIO_NOT_A_PIN )
31
89
// {
32
90
// return -1 ;
33
91
// }
@@ -44,19 +102,24 @@ int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral )
44
102
// Configure pin mode, if requested
45
103
if ( ulPeripheral == PIO_INPUT )
46
104
{
47
- pin_mode ( ulPin , INPUT ) ; // pinMode( ulPin, INPUT ) ;
105
+ pin_mode ( ulPin , INPUT ) ; // pinMode( ulPin, INPUT ) ;
106
+
107
+ // pinMode( ulPin, INPUT ) ; // pinMode( ulPin, INPUT ) ;
48
108
}
49
109
else
50
110
{
51
111
if ( ulPeripheral == PIO_INPUT_PULLUP )
52
112
{
53
- pin_mode ( ulPin , INPUT_PULLUP ) ; // pinMode( ulPin, INPUT_PULLUP ) ;
113
+ pin_mode ( ulPin , INPUT_PULLUP ) ; // pinMode( ulPin, INPUT_PULLUP ) ;
114
+ // pinMode( ulPin, INPUT_PULLUP ) ; // pinMode( ulPin, INPUT_PULLUP ) ;
54
115
}
55
116
else
56
117
{
57
118
if ( ulPeripheral == PIO_OUTPUT )
58
119
{
59
- pin_mode ( ulPin , OUTPUT ) ; // pinMode( ulPin, OUTPUT ) ;
120
+ pin_mode ( ulPin , OUTPUT ) ; // pinMode( ulPin, OUTPUT ) ;
121
+ // gpio_init_out(&gpio, ulPin);
122
+ // pinMode( ulPin, OUTPUT ) ; // pinMode( ulPin, OUTPUT ) ;
60
123
}
61
124
else
62
125
{
@@ -123,3 +186,20 @@ int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral )
123
186
return 0l ;
124
187
}
125
188
189
+
190
+
191
+ void shiftOutMatrix (pin_size_t dataPin , uint8_t clockPin , BitOrder bitOrder , uint32_t val )
192
+ {
193
+ uint32_t i ;
194
+
195
+ for (i = 0 ; i < 32 ; i ++ ) {
196
+ if (bitOrder == LSBFIRST )
197
+ digitalWrite (dataPin , !!(val & (1 << i )) ? HIGH : LOW );
198
+ else
199
+ digitalWrite (dataPin , !!(val & (1 << (31 - i ))) ? HIGH : LOW );
200
+
201
+ digitalWrite (clockPin , HIGH );
202
+ digitalWrite (clockPin , LOW );
203
+ }
204
+ }
205
+
0 commit comments