Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd2867ba

Browse files
authored
Merge pull request#784 from Rocketct/master
fix ADC management for pure analog on GIGA
2 parents8c88c20 +9fb0644 commitd2867ba

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

‎cores/arduino/Arduino.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ typedef struct _AnalogPinDescription AnalogPinDescription;
8484
extern PinDescription g_APinDescription[];
8585
extern AnalogPinDescription g_AAnalogPinDescription[];
8686
extern AnalogPinDescription g_AAnalogOutPinDescription[];
87+
extern AnalogPinDescription g_pureAAnalogPinDescription[];
8788

8889
#ifdef ANALOG_CONFIG
8990
#include"hal/analogin_api.h"

‎variants/GIGA/pins_arduino.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extern PinName digitalPinToPinName(pin_size_t P);
2020
// ----
2121
#definePINS_COUNT (PINCOUNT_fn())
2222
#defineNUM_DIGITAL_PINS (103u)
23-
#defineNUM_ANALOG_INPUTS (14u)
23+
#defineNUM_ANALOG_INPUTS (10u) // these are analog pins that can also be used as digital
2424
#defineNUM_ANALOG_OUTPUTS (2u)
2525

2626
// LEDs

‎variants/GIGA/pure_analog_pins.cpp‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
#include"AnalogIn.h"
33
#include"pinDefinitions.h"
44

5-
PureAnalogPinA8(8);
6-
PureAnalogPinA9(9);
7-
PureAnalogPinA10(10);
8-
PureAnalogPinA11(11);
5+
PureAnalogPinA8(0);
6+
PureAnalogPinA9(1);
7+
PureAnalogPinA10(2);
8+
PureAnalogPinA11(3);
9+
910

1011
intgetAnalogReadResolution();
1112

1213
intanalogRead(PureAnalogPin pin) {
13-
mbed::AnalogIn* adc =g_AAnalogPinDescription[pin.get()].adc;
14-
auto name =g_AAnalogPinDescription[pin.get()].name;
14+
mbed::AnalogIn* adc =g_pureAAnalogPinDescription[pin.get()].adc;
15+
auto name =g_pureAAnalogPinDescription[pin.get()].name;
1516
if (adc ==NULL) {
1617
adc =newmbed::AnalogIn(name);
17-
g_AAnalogPinDescription[pin.get()].adc = adc;
18+
g_pureAAnalogPinDescription[pin.get()].adc = adc;
1819
}
1920
return (adc->read_u16() >> (16 -getAnalogReadResolution()));
2021
}

‎variants/GIGA/variant.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ AnalogPinDescription g_AAnalogPinDescription[] = {
1212
{ PC_2,NULL },// A5 ADC1_INP12
1313
{ PC_0,NULL },// A6 ADC1_INP10
1414
{ PA_0,NULL },// A7 ADC1_INP16
15+
{ PA_4,NULL },// A12 DAC1_OUT1
16+
{ PA_5,NULL },// A13 DAC1_OUT2
17+
};
18+
19+
AnalogPinDescription g_pureAAnalogPinDescription[] = {
1520
{ PC_2C,NULL },// A8 ADC3_INP0
1621
{ PC_3C,NULL },// A9 ADC3_INP1
1722
{ PA_1C,NULL },// A10 ADC2_INP1
1823
{ PA_0C,NULL },// A11 ADC2_INP0
19-
{ PA_4,NULL },// A12 DAC1_OUT1
20-
{ PA_5,NULL },// A13 DAC1_OUT2
2124
};
2225

2326
AnalogPinDescription g_AAnalogOutPinDescription[] = {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp