Skip to content

Commit 4f8d018

Browse files
committedMar 22, 2023
Fix a bunch of assorted compile issues impacting many boards, linting
1 parent 41761ba commit 4f8d018

File tree

7 files changed

+116
-103
lines changed

7 files changed

+116
-103
lines changed
 

‎avr/cores/tiny/Arduino.h

+24-13
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ void yield(void);
4848
//#define clockCyclesToMicroseconds(a) (((a) * 1000L) / (F_CPU / 1000L))
4949
//#define microsecondsToClockCycles(a) (((a) * (F_CPU / 1000L)) / 1000L)
5050

51+
// Compile-time error checking functions
52+
53+
void badArg(const char*) __attribute__((error("")));
54+
// badArg is when we can determine at compile time that an argument is inappropriate.
55+
56+
void badCall(const char*) __attribute__((error("")));
57+
// badCall is used when the function should not be called, period (for the selected part with the currently selected options for all tools submenus)
58+
// and calling it with different arguments can't change that.
5159

5260
typedef unsigned int word;
5361

@@ -83,8 +91,21 @@ void analogWrite(uint8_t, int);
8391
void setADCDiffMode(bool bipolar);
8492
void analogGain(uint8_t gain);
8593

86-
unsigned long millis(void);
87-
unsigned long micros(void);
94+
#if !defined(DISABLE_MILLIS)
95+
unsigned long millis(void);
96+
unsigned long micros(void);
97+
// So you can test #ifdef millis
98+
#define millis millis
99+
#define micros micros
100+
#else
101+
unsigned long millis(void) {
102+
bagCall("Millis is disabled from tthe tools menu");
103+
return -1;
104+
}
105+
unsigned long micros(void) {
106+
bagCall("Millis is disabled from tthe tools menu");
107+
return -1;
108+
}
88109
#endif
89110
void delay(unsigned long);
90111

@@ -127,14 +148,7 @@ void detachInterrupt(uint8_t);
127148
void setup(void);
128149
void loop(void);
129150

130-
// Compile-time error checking functions
131-
132-
void badArg(const char*) __attribute__((error("")));
133-
// badArg is when we can determine at compile time that an argument is inappropriate.
134151

135-
void badCall(const char*) __attribute__((error("")));
136-
// badCall is used when the function should not be called, period (for the selected part with the currently selected options for all tools submenus)
137-
// and calling it with different arguments can't change that.
138152

139153
// Get the bit location within the hardware port of the given virtual pin.
140154
// This comes from the pins_*.c file for the active board configuration.
@@ -285,10 +299,6 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
285299
#if defined(DISABLE_MILLIS)
286300
#define MILLIS_USE_TIMERNONE
287301
// forwards compatibility
288-
#else
289-
// So you can test #ifdef millis
290-
#define millis millis
291-
#define micros micros
292302
#endif
293303

294304
#if TIMER_TO_USE_FOR_MILLIS != 0
@@ -757,4 +767,5 @@ void loop() {
757767
#if defined(TIMER2_OVF_vect) && !defined(TIM2_OVF_vect)
758768
#define TIM2_OVF_vect TIMER2_OVF_vect
759769
#endif
770+
760771
#endif

‎avr/cores/tiny/wiring.c

+62-60
Large diffs are not rendered by default.

‎avr/cores/tiny/wiring_digital.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ void pinMode(uint8_t pin, uint8_t mode) {
3232
if (mode == INPUT) {
3333
uint8_t oldSREG = SREG;
3434
cli();
35-
*reg &= ~bit;
36-
*out &= ~bit;
35+
*reg &= ~mask;
36+
*out &= ~mask;
3737
SREG = oldSREG;
3838
} else if (mode == INPUT_PULLUP) {
3939
uint8_t oldSREG = SREG;
4040
cli();
41-
*reg &= ~bit;
42-
*out |= bit;
41+
*reg &= ~mask;
42+
*out |= mask;
4343
SREG = oldSREG;
4444
} else {
4545
uint8_t oldSREG = SREG;
4646
cli();
47-
*reg |= bit;
47+
*reg |= mask;
4848
SREG = oldSREG;
4949
}
5050
}
@@ -133,7 +133,7 @@ void digitalWrite(uint8_t pin, uint8_t val) {
133133
if (pin > 127) {pin = analogInputToDigitalPin((pin & 127));}
134134
check_valid_digital_pin(pin);
135135
uint8_t timer = digitalPinToTimer(pin);
136-
uint8_t bit = digitalPinToBitMask(pin);
136+
uint8_t mask = digitalPinToBitMask(pin);
137137
uint8_t port = digitalPinToPort(pin);
138138
volatile uint8_t *out;
139139

‎ATtiny85_doc/README.md ‎avr/extras/ATtiny85_doc/README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
<img src="https://goo.gl/7cxEmm" width="500">
55
</p>
66

7-
Follow those steps for use the Arduino as ISP:
8-
- Load the sketch "ArduinoISP" on your Arduino
9-
- Connect the Arduino with "ArduinoISP" to the ATtiny85. Use the schematic in this folder.
10-
- Open your ATtiny85 program and select:
11-
* "tools" --> "board" --> "ATtiny"
12-
* "tools" --> "processor" --> "ATtiny85"
7+
Follow those steps for use the Arduino as ISP:
8+
- Load the sketch "ArduinoISP" on your Arduino
9+
- Connect the Arduino with "ArduinoISP" to the ATtiny85. Use the schematic in this folder.
10+
- Open your ATtiny85 program and select:
11+
* "tools" --> "board" --> "ATtiny"
12+
* "tools" --> "processor" --> "ATtiny85"
1313
* "tools" --> "programmer" --> "Arduino as ISP(ATtinycore)"
1414

15-
**IF** it's the **first time** you use the ATtiny OR you want to **change the frequency** (Mhz) OR **BOD settings**, you must burn the bootloader:
16-
- "tools" --> Burn Bootloader
15+
**IF** it's the **first time** you use the ATtiny OR you want to **change the frequency** (Mhz) OR **BOD settings**, you must burn the bootloader:
16+
- "tools" --> Burn Bootloader
1717

1818
Now you can upload your sketch.
1919

2020

2121
### The 0,1 uF capacitor
22-
All ATTiny chips (as well as the vast majority of digital integrated circuits) require a 0.1uF ceramic capacitor between Vcc and Gnd for decoupling; this should be located as close to the chip as possible (minimize length of wires to cap). Devices with multiple Vcc pins, or an AVcc pin, should use a cap on those pins too. Do not be fooled by poorly written tutorials or guides that omit these.
22+
All ATTiny chips (as well as the vast majority of digital integrated circuits) require a 0.1uF ceramic capacitor between Vcc and Gnd for decoupling; this should be located as close to the chip as possible (minimize length of wires to cap). Devices with multiple Vcc pins, or an AVcc pin, should use a cap on those pins too. Do not be fooled by poorly written tutorials or guides that omit these.
2323

2424
### The 10 uF capacitor
2525
The capacitor prevents the Arduino board from resetting (which starts the bootloader), thus ensuring that the Arduino IDE talks to the ArduinoISP (not the bootloader) during the upload of sketches.
File renamed without changes.
File renamed without changes.

‎avr/extras/README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Additional more detailed sections of documentation for ATTinyCore
22

3-
* [ATtiny441, 841](avr/extras/ATtiny_x41.md) (With or without Optiboot or Micronucleus bootloader)
4-
* [ATtiny1634](avr/extras/ATtiny_1634.md) (With or without Optiboot bootloader)
5-
* [ATtiny87, 167](avr/extras/ATtiny_x7.md) (with or without Optiboot or Micronucleus bootloader)
6-
* [ATtiny25, 45, 85](avr/extras/ATtiny_x5.md) (With or without Optiboot or Micronucleus bootloader)
7-
* [ATtiny24, 44, 84](avr/extras/ATtiny_x4.md) (With or without Optiboot or Micronucleus bootloader)
8-
* [ATtiny261, 461, 861](avr/extras/ATtiny_x61.md) (With or without Optiboot bootloader)
9-
* [ATtiny48, 88](avr/extras/ATtiny_x8.md) (With or without Optiboot or Micronucleus bootloader)
10-
* [ATtiny828](avr/extras/ATtiny_828.md) (With or without Optiboot bootloader)
11-
* [ATtiny2313, 4313](avr/extras/ATtiny_x313.md) (no bootloader)
12-
* [ATtiny43](avr/extras/ATtiny_43.md) (no bootloader)
3+
* [ATtiny441, 841](ATtiny_x41.md) (With or without Optiboot or Micronucleus bootloader)
4+
* [ATtiny1634](ATtiny_1634.md) (With or without Optiboot bootloader)
5+
* [ATtiny87, 167](ATtiny_x7.md) (with or without Optiboot or Micronucleus bootloader)
6+
* [ATtiny25, 45, 85](ATtiny_x5.md) (With or without Optiboot or Micronucleus bootloader)
7+
* [ATtiny24, 44, 84](ATtiny_x4.md) (With or without Optiboot or Micronucleus bootloader)
8+
* [ATtiny261, 461, 861](ATtiny_x61.md) (With or without Optiboot bootloader)
9+
* [ATtiny48, 88](ATtiny_x8.md) (With or without Optiboot or Micronucleus bootloader)
10+
* [ATtiny828](ATtiny_828.md) (With or without Optiboot bootloader)
11+
* [ATtiny2313, 4313](ATtiny_x313.md) (no bootloader)
12+
* [ATtiny43](ATtiny_43.md) (no bootloader)
1313

1414
Variants of these are also supported (such as the ATtiny1634R, ATtiny2313A or ATtiny85V)
1515

@@ -24,7 +24,7 @@ Variants of these are also supported (such as the ATtiny1634R, ATtiny2313A or AT
2424
**Windows users must install Micronucleus drivers manually**
2525
If you want to use Micronucleus (VUSB) boards on Windows, you must manually install the drivers - Arduino does not run "post-install" tasks for third party libraries (though I am told they recognized how nonsensical this is - a malicious core could still run whatever commands it wanted to by telling the IDE that was how to compile sketches for these boards - and will be changing this in the future. Note also that the 1.5.0 release does not include working micronucleus upload tool for Windows, this is resolved in 1.5.2.
2626

27-
During the install process it will print the path of a post_install.bat that it skipped running. Running that will install the drivers - it's easiest if you copy/paste it, as after installation the drivers will be located in `C:\Users\YourUserName\AppData\Local\Arduino15\packages\ATTinyCore\tools\micronucleus\2.5-azd1\` Or they can be downloaded from: [https://azduino.com/bin/micronucleus/Drivers-Digistump(win).zip]. Unzip, run the installation batch file.
27+
During the install process it will print the path of a post_install.bat that it skipped running. Running that will install the drivers - it's easiest if you copy/paste it, as after installation the drivers will be located in `C:\Users\YourUserName\AppData\Local\Arduino15\packages\ATTinyCore\tools\micronucleus\2.5-azd1\` Or they can be downloaded from: [https://azduino.com/bin/micronucleus/Drivers-Digistump(win).zip](https://azduino.com/bin/micronucleus/Drivers-Digistump%28win%29.zip). Unzip, run the installation batch file.
2828

2929

3030
**avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor=`www.fischl.de` product='USBasp'**
@@ -84,7 +84,7 @@ Virtual boot relies on rewriting the vector table, such that the RESET vector po
8484
See the [Programming Guide](Programming.md) for more information on programming parts using Optiboot.
8585

8686
### Micronucleus - VUSB bootloader for 841, 167, 85, 88 and 84/84a
87-
It's finally here! As of 1.4.0, we now offer Micronucleus (aka Digispark) support for some of the more popular boards for these bootloaders. This allows sketches to be uploaded directly via USB, which many users find highly convenient. This comes at a cost in terms of flash - they typically use around 1.5k of flash, and they sometimes have problems connecting to specific USB ports. These boards are available from various vendors; see the part-specific documentation pages for more information on the implementation used on specific parts. For more information on using Micronucleus, see the [usage documentation](avr/extras/UsingMicronucleus.md).
87+
It's finally here! As of 1.4.0, we now offer Micronucleus (aka Digispark) support for some of the more popular boards for these bootloaders. This allows sketches to be uploaded directly via USB, which many users find highly convenient. This comes at a cost in terms of flash - they typically use around 1.5k of flash, and they sometimes have problems connecting to specific USB ports. These boards are available from various vendors; see the part-specific documentation pages for more information on the implementation used on specific parts. For more information on using Micronucleus, see the [usage documentation](UsingMicronucleus.md).
8888

8989
### Changing the ATtiny clock speed and other settings
9090

@@ -156,7 +156,7 @@ This differs from the behavior of official Arduino core - the "stock" micros() e
156156
Thanks to @cburstedde for his work on this.
157157

158158
#### Using external CLOCK (new in 1.3.3 for on 48, 88, and 828, expanded everywhere for 2.0.0)
159-
These parts do not support using an external crystal. External Clock, however, is supported - this requires an external clock source (not just a crystal) connected to the CLKI pin. **DANGER** if this clock source is not present, you must supply a clock source to CLKI pin before it can be reprogrammed, including to use a different clock source. The external CLOCK option is available through the IDE; in previous versions this was limited to parts which didn't support a crystal. With greater recognition that unbricking the parts is straightforward (we include an appriopriate sketch in the examples), as of 2.0.0, we now support this on all parts. **This is not the same as external crystal - do not use this option if you are unsure about the difference between external clock and external crystal!** External clock sources are commonly sold as "oscillators", we would recommend the KC5032A-series for it's low cost and wide operating voltage range of 1.6-5.5v (ie, the entire operating range of these parts - but they're discontinued and there is no longer any external clock for sale from any western manufacturer or subsidiary thereof that is openly marketing an external oscillator with such a wide voltage range). Every other oscillator available from Digikey has a narrower voltage range (often 3.3v or 5v +/- 10%, though some work from wider ranges). Through-hole units are available, but expensive, and all have the restrictive supply voltage requirements. If selecting your own oscillator, you want an "XO" type.
159+
These parts do not support using an external crystal. External Clock, however, is supported - this requires an external clock source (not just a crystal) connected to the CLKI pin. **DANGER** if this clock source is not present, you must supply a clock source to CLKI pin before it can be reprogrammed, including to use a different clock source. The external CLOCK option is available through the IDE; in previous versions this was limited to parts which didn't support a crystal. With greater recognition that unbricking the parts is straightforward (we include an appropriate sketch in the examples), as of 2.0.0, we now support this on all parts. **This is not the same as external crystal - do not use this option if you are unsure about the difference between external clock and external crystal!** External clock sources are commonly sold as "oscillators", we would recommend the KC5032A-series for it's low cost and wide operating voltage range of 1.6-5.5v (ie, the entire operating range of these parts - but they're discontinued and there is no longer any external clock for sale from any western manufacturer or subsidiary thereof that is openly marketing an external oscillator with such a wide voltage range). Every other oscillator available from Digikey has a narrower voltage range (often 3.3v or 5v +/- 10%, though some work from wider ranges). Through-hole units are available, but expensive, and all have the restrictive supply voltage requirements. If selecting your own oscillator, you want an "XO" type.
160160

161161
#### Using external CLOCK (instead of crystal) on other parts
162162
The use of an external clock - that is, a single wire with an appropriate clock signal is supplied to the XTAL1 pin from an external source, is possible using this core. This is an advanced feature, and is not supported directly through the IDE (except as noted above) to reduce the risk of people confusing it with external crystal and bricking their chips (if external clock is set as clock source when actually using external crystal, you must supply a clock signal on XTAL1 to program the chip again, including to set it to use a crystal again). To use an external clock:
@@ -245,7 +245,7 @@ On the following chips, full serial (UART) support is provided in hardware, as S
245245
* ATtiny1634 (two UARTs)
246246
* ATtiny828
247247

248-
On the following chips, **no hardware serial is available**, however, a built-in software serial named `Serial` is provided to maximize compatibility. This uses the analog comparator pins (to take advantage of the interrupt, since very few sketches/libraries use it, while lots of sketches/libraries use PCINTs). **TX is AIN0, RX is AIN1** - This is a software implementation - as such, you cannot receive and send at the same time. If you try, you'll get gibberish, just like using SoftwareSerial. [See also the discussion of baud rates.](avr/extras/TinySoftSerialBaud.md)
248+
On the following chips, **no hardware serial is available**, however, a built-in software serial named `Serial` is provided to maximize compatibility. This uses the analog comparator pins (to take advantage of the interrupt, since very few sketches/libraries use it, while lots of sketches/libraries use PCINTs). **TX is AIN0, RX is AIN1** - This is a software implementation - as such, you cannot receive and send at the same time. If you try, you'll get gibberish, just like using SoftwareSerial. [See also the discussion of baud rates.](TinySoftSerialBaud.md)
249249
* ATtiny x5 (25/45/85)
250250
* ATtiny x4 (24/44/84)
251251
* ATtiny x61 (261/461/861)
@@ -274,7 +274,7 @@ Most of the ATtiny parts only have two timers. The attiny841 has a third timer -
274274

275275
### Built-in tinyNeoPixel library
276276

277-
The standard NeoPixel (WS2812/etc) libraries do not support all the clock speeds that this core supports, and some of them only support certain ports. This core includes two libraries for this, both of which are tightly based on the Adafruit_NeoPixel library, tinyNeoPixel and tinyNeoPixel_Static - the latter has a few differences from the standard library (beyond supporting more clocks speeds and ports), in order to save flash. At speeds below 16MHz, you must select the port containing the pin you wish to use from the Tools -> tinyNeoPixel Port menu. This code is not fully tested at "odd" clock speeds, but definitely works at 8/10/12/16/20 MHz, and will probably work at other speeds, as long as they are 7.3728 MHz or higher. See the [tinyNeoPixel documentation](avr/extras/tinyNeoPixel.md) and included examples for more information.
277+
The standard NeoPixel (WS2812/etc) libraries do not support all the clock speeds that this core supports, and some of them only support certain ports. This core includes two libraries for this, both of which are tightly based on the Adafruit_NeoPixel library, tinyNeoPixel and tinyNeoPixel_Static - the latter has a few differences from the standard library (beyond supporting more clocks speeds and ports), in order to save flash. At speeds below 16MHz, you must select the port containing the pin you wish to use from the Tools -> tinyNeoPixel Port menu. This code is not fully tested at "odd" clock speeds, but definitely works at 8/10/12/16/20 MHz, and will probably work at other speeds, as long as they are 7.3728 MHz or higher. See the [tinyNeoPixel documentation](tinyNeoPixel.md) and included examples for more information.
278278

279279
### Retain EEPROM configuration option
280280
All non-bootloader board definitions have a menu option to control whether the contents of the EEPROM are erased when programming. This only applies to ISP programming, and you must "burn bootloader" to set the fuses to apply this. Because it only applies to ISP programming, it is not available for Bootloader board definitions. On those, EEPROM is never retained, on the reasoning that if you are burning the bootloader to a chip, you are trying to restore it to a "fresh" state.

0 commit comments

Comments
 (0)
Please sign in to comment.