Skip to content

Commit 955a927

Browse files
committed
Wiring related files need to be updated for the MKR-RGB Shield to work --- jcw
1 parent 8f623f9 commit 955a927

File tree

3 files changed

+105
-13
lines changed

3 files changed

+105
-13
lines changed

cores/arduino/WVariant.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//** just starting suggestion at this point --- jcw - 9/10/20
21
/*
32
Copyright (c) 2015 Arduino LLC. All right reserved.
43

cores/arduino/wiring_private.c

Lines changed: 89 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//** just starting suggestion at this point --- jcw - 9/10/20
2-
32
/*
43
Copyright (c) 2015 Arduino LLC. All right reserved.
54
@@ -18,16 +17,75 @@
1817
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1918
*/
2019

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+
2575

76+
extern struct PinDescription g_APinDescription;
77+
// extern void pinMode(pin_size_t pinNumber, PinMode pinMode);
2678

2779
int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral )
2880
{
81+
82+
83+
2984
// 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 )
3189
// {
3290
// return -1 ;
3391
// }
@@ -44,19 +102,24 @@ int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral )
44102
// Configure pin mode, if requested
45103
if ( ulPeripheral == PIO_INPUT )
46104
{
47-
pin_mode( ulPin, INPUT ) ; // pinMode( ulPin, INPUT ) ;
105+
pin_mode( ulPin, INPUT ) ; // pinMode( ulPin, INPUT ) ;
106+
107+
// pinMode( ulPin, INPUT ) ; // pinMode( ulPin, INPUT ) ;
48108
}
49109
else
50110
{
51111
if ( ulPeripheral == PIO_INPUT_PULLUP )
52112
{
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 ) ;
54115
}
55116
else
56117
{
57118
if ( ulPeripheral == PIO_OUTPUT )
58119
{
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 ) ;
60123
}
61124
else
62125
{
@@ -123,3 +186,20 @@ int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral )
123186
return 0l ;
124187
}
125188

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+

cores/arduino/wiring_private.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,31 @@
2828
#include <stdio.h>
2929
#include <stdarg.h>
3030

31+
// #include "gpio_object.h"
32+
3133
#include "Arduino.h"
3234
#include "WVariant.h"
3335
#ifdef __cplusplus
3436
extern "C"{
3537
#endif
3638
// #include "wiring_constants.h"
37-
#include "api/Common.h" // H7 equivalent
39+
/// #include "api/Common.h" // H7 equivalent
3840
typedef void (*voidFuncPtr)(void);
39-
41+
#if 0
42+
typedef struct {
43+
uint32_t mask;
44+
__IO uint32_t *reg_in;
45+
__IO uint32_t *reg_set;
46+
__IO uint32_t *reg_clr;
47+
PinName pin;
48+
GPIO_TypeDef *gpio;
49+
uint32_t ll_pin;
50+
} gpio_t;
51+
#endif
52+
// gpio_t gpio;
4053

4154
int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral );
42-
55+
void shiftOutMatrix(pin_size_t dataPin, uint8_t clockPin, BitOrder bitOrder, uint32_t val);
4356
#ifdef __cplusplus
4457
} // extern "C"
4558
#endif

0 commit comments

Comments
 (0)