Skip to content

Commit

Permalink
Fix comparator, and several largely trivial changes. 2.6.3 to fix bad…
Browse files Browse the repository at this point in the history
… release
  • Loading branch information
SpenceKonde committed Nov 6, 2022
1 parent 1245d48 commit 59b7ad6
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 37 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- megaavr/libraries/Wire/examples/SFRRanger_reader
- megaavr/libraries/tinyNeoPixel/examples/RGBWstrandtest
- megaavr/extras/CompileTestSketches/test_analog_read
- megaavr/libraries/Optiboot_flasher/examples/Flash_get_put
- megaavr/libraries/Wire/examples/slave_address_mask
- megaavr/libraries/Wire/examples/master_multi_address_write
available-flash-4kB-plus-true-sketch-paths: |
Expand Down Expand Up @@ -87,6 +88,11 @@ jobs:
- megaavr/libraries/Servo_megaTinyCore/examples/Knob
- megaavr/libraries/Servo_megaTinyCore/examples/ServoMaxTest
- megaavr/libraries/Servo_megaTinyCore/examples/Sweep
- megaavr/libraries/Comparator/Hysteresis
- megaavr/libraries/Comparator/Internal_reference
- megaavr/libraries/Comparator/Interrupt
- megaavr/libraries/Comparator/simple_comparator
- megaavr/libraries/Event/simple_event
IO-class-6-plus-true-sketch-paths: |
- megaavr/libraries/Logic/examples/Five_input_NOR
IO-class-2-series-1-sketch-paths: |
Expand Down
5 changes: 3 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ Changes listed here are checked in to GitHub ("master" branch unless specificall
## Released versions

### 2.6.3 (2.6.2 respin due to json error)
* Correct installation error from trying to install non-functional withdrawn version of toolchain.
* Correct missing comma in Comparator.cpp.
* Correct installation error from trying to install non-functional withdrawn version of toolchain.
* Correct issues with compiling Comparator library.
* Ensure that at least one test per library is in the CI list.

### 2.6.2 (critical update)
* Critical bugfix: Burn Bootloader corrected
Expand Down
73 changes: 69 additions & 4 deletions megaavr/cores/megatinycore/core_devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@
#ifdef __AVR_ATtinyxy2__
#define _AVR_PINCOUNT 8
#endif
#define MEGATINYCORE_NUM (((MEGATINYCORE_MAJOR << 24)+(MEGATINYCORE_MINOR << 16)+(MEGATINYCORE_PATCH << 8)+MEGATINYCORE_RELEASED))

#if MEGATINYCORE_SERIES == 0
#define _AVR_FAMILY "T0"
Expand Down Expand Up @@ -590,6 +589,8 @@

#if !defined(BACKWARD_COMBATIBILITY_MODE)
// We default to seeking compatibility. for COMBATability you would uncomment that #define, and that turns all these off.

#if defined(RTC_CLKSEL)
/* Man they just *HAD* to change the names of these values that get assigned to the same register and do the same thing didn't they?
* Worse still we can't even verify that they are present... just blindly define and pray. Enums can't be seen by macros
*/
Expand Down Expand Up @@ -693,7 +694,15 @@
#define CLKCTRL_FRQSEL_28M_gc (CLKCTRL_FREQSEL_28M_gc) /* 28 MHz system clock unofficial - this will just error out if used since it will replace one undefined symbol with another */
#define CLKCTRL_FRQSEL_32M_gc (CLKCTRL_FREQSEL_32M_gc) /* 32 MHz system clock unofficial - this will just error out if used since it will replace one undefined symbol with another */
#endif
// Note that it is intended to not hide the fact that 28 and 32 MHz are not official. If you choose it from the menu, it says "Overclocked" next to the speed too. We refer to them with the numeric constants in the wiring.c, so it doesn't matter when used that way.
// And now the most freaking boneheaded move from Microchip in a long while: They realized that they should have had some sort of delimiter between the bit number within a bitfield, and the name of the bitfield, since the names of many bitfields end in numbers,
// So they went ahead and made that change. That is what's called a "breaking change", really for no reason except codes style. Most companies even if they decided to go that route, would never do that without introducuing a compatibility layer.
// That wanton disregard for backwards compatibility is not acceptable in an Arduino core nor in a commercial product.
// Using the old names will produce warnings. These deprecated names should be fixed as support for these FOUR THOUSAND LINES of bandaids WILL BE REMOBVED in 1.6.0!
//typedef const uint8_t __attribute__ ((deprecated("\nMicrochip changed the spelling of bits within a bitfiels (macros that end in the bitnumber followed by _bm or _bp), you are using the old name, ex PERIPH_BITFIRLD1_bm.\nYou should use PERIPH_BITFIELD_1_bm; we do not guarantee that this 4000-line bandaid will not be removed in the future.\r\nWhy did they do this? Beats me. Ask their support folks - if enough of us do it, they might hesitate next time they have the urge to mass rename things in their headers"))) deprecated_constant_name;

// Okay, well that fix didn't work so well. back to plan A.
#if !defined(BACKWARD_COMBATIBILITY_MODE)
/* Add a feature - yay!
* Rename registers so people can't carry code back and forth - booo!
*/
Expand Down Expand Up @@ -4799,8 +4808,64 @@
#if !defined(WDT_WINDOW_0_bm) && defined(WDT_WINDOW0_bm)
#define WDT_WINDOW_0_bm WDT_WINDOW0_bm
#elif defined(WDT_WINDOW_0_bm)
//deprecated_constant_name WDT_WINDOW0_bm = WDT_WINDOW_0_bm;
#define WDT_WINDOW0_bm WDT_WINDOW_0_bm //Deprecated as of Q2 2022 header change.
#endif
#endif
#endif
#if !defined(WDT_WINDOW_0_bp) && defined(WDT_WINDOW0_bp)
#define WDT_WINDOW_0_bp WDT_WINDOW0_bp
#elif defined(WDT_WINDOW_0_bp)
#define WDT_WINDOW0_bp WDT_WINDOW_0_bp; //Deprecated as of Q2 2022 header change
#endif
#if !defined(WDT_WINDOW_1_bm) && defined(WDT_WINDOW1_bm)
#define WDT_WINDOW_1_bm WDT_WINDOW1_bm
#elif defined(WDT_WINDOW_1_bm)
#define WDT_WINDOW1_bm WDT_WINDOW_1_bm; //Deprecated as of Q2 2022 header change
#endif
#if !defined(WDT_WINDOW_1_bp) && defined(WDT_WINDOW1_bp)
#define WDT_WINDOW_1_bp WDT_WINDOW1_bp
#elif defined(WDT_WINDOW_1_bp)
#define WDT_WINDOW1_bp WDT_WINDOW_1_bp; //Deprecated as of Q2 2022 header change
#endif
#if !defined(WDT_WINDOW_2_bm) && defined(WDT_WINDOW2_bm)
#define WDT_WINDOW_2_bm WDT_WINDOW2_bm
#elif defined(WDT_WINDOW_2_bm)
#define WDT_WINDOW2_bm WDT_WINDOW_2_bm; //Deprecated as of Q2 2022 header change
#endif
#if !defined(WDT_WINDOW_2_bp) && defined(WDT_WINDOW2_bp)
#define WDT_WINDOW_2_bp WDT_WINDOW2_bp
#elif defined(WDT_WINDOW_2_bp)
#define WDT_WINDOW2_bp WDT_WINDOW_2_bp; //Deprecated as of Q2 2022 header change
#endif
#if !defined(WDT_WINDOW_3_bm) && defined(WDT_WINDOW3_bm)
#define WDT_WINDOW_3_bm WDT_WINDOW3_bm
#elif defined(WDT_WINDOW_3_bm)
#define WDT_WINDOW3_bm WDT_WINDOW_3_bm; //Deprecated as of Q2 2022 header change
#endif
#if !defined(WDT_WINDOW_3_bp) && defined(WDT_WINDOW3_bp)
#define WDT_WINDOW_3_bp WDT_WINDOW3_bp
#elif defined(WDT_WINDOW_3_bp)
#define WDT_WINDOW3_bp WDT_WINDOW_3_bp; //Deprecated as of Q2 2022 header change
#endif

/* ======= ZCD ======= */
#if !defined(ZCD_INTMODE_0_bm) && defined(ZCD_INTMODE0_bm)
#define ZCD_INTMODE_0_bm ZCD_INTMODE0_bm
#elif defined(ZCD_INTMODE_0_bm)
#define ZCD_INTMODE0_bm ZCD_INTMODE_0_bm; //Deprecated as of Q2 2022 header change
#endif
#if !defined(ZCD_INTMODE_0_bp) && defined(ZCD_INTMODE0_bp)
#define ZCD_INTMODE_0_bp ZCD_INTMODE0_bp
#elif defined(ZCD_INTMODE_0_bp)
#define ZCD_INTMODE0_bp ZCD_INTMODE_0_bp; //Deprecated as of Q2 2022 header change
#endif
#if !defined(ZCD_INTMODE_1_bm) && defined(ZCD_INTMODE1_bm)
#define ZCD_INTMODE_1_bm ZCD_INTMODE1_bm
#elif defined(ZCD_INTMODE_1_bm)
#define ZCD_INTMODE1_bm ZCD_INTMODE_1_bm; //Deprecated as of Q2 2022 header change
#endif
#if !defined(ZCD_INTMODE_1_bp) && defined(ZCD_INTMODE1_bp)
#define ZCD_INTMODE_1_bp ZCD_INTMODE1_bp
#elif defined(ZCD_INTMODE_1_bp)
#define ZCD_INTMODE1_bp ZCD_INTMODE_1_bp; //Deprecated as of Q2 2022 header change
#endif
#endif /* this is the end of the backwards compatibility defines */
#endif // end of core_devices
19 changes: 10 additions & 9 deletions megaavr/cores/megatinycore/core_parameters.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#ifndef __CORE_PARAMETERS_H__
#define __CORE_PARAMETERS_H__

#if !defined(MEGATINYCORE_NUM)
#if !(defined(MEGATINYCORE_MAJOR) && defined(MEGATINYCORE_MINOR) && defined(MEGATINYCORE_PATCH) && defined(MEGATINYCORE_RELEASED))
#warning "All of the version defines are missing, please correct your build environment; it is likely failing to define other critical values"
// Version related defines now handled in platform.txt
#else
#define MEGATINYCORE_NUM ((MEGATINYCORE_MAJOR << 24) + (MEGATINYCORE_MINOR << 16) + (MEGATINYCORE_PATCH << 8) + MEGATINYCORE_RELEASED)
#endif
#endif

#if !(defined(MEGATINYCORE) || defined(DXCORE) || defined(ATTIYNCORE))

// This define can get black-hole'ed somehow (reported on platformio) likely the ugly syntax to pass a string define from platform.txt via a -D
Expand All @@ -13,17 +22,9 @@
// which becomes more and more important as more code is shared between the cores.

#define MEGATINYCORE "Unknown 2.6.1+"
#if !defined(MEGATINYCORE_NUM)
#if !(defined(MEGATINYCORE_MAJOR) && defined(MEGATINYCORE_MINOR) && defined(MEGATINYCORE_PATCH) && defined(MEGATINYCORE_RELEASED))
#warning "All of the version defines are missing, please correct your build environment; it is likely failing to define other critical values"
// Version related defines now handled in platform.txt
#else
#define MEGATINYCORE_NUM ((MEGATINYCORE_MAJOR << 24) + (MEGATINYCORE_MINOR << 16) + (MEGATINYCORE_PATCH << 8) + MEGATINYCORE_RELEASED)
#endif
#endif
#else
#if defined(DXCORE) || defined(ATTINYCORE)
#error "This is megaTinyCore being compiled, but DXCORE and/or ATTINYCORE is defined already"
#error "This is megaTinyCore being compiled, but DXCORE and/or ATTINYCORE is defined already, something is way wrong."
#endif
#endif
#endif
14 changes: 10 additions & 4 deletions megaavr/cores/megatinycore/wiring_digital.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void pinMode(uint8_t pin, uint8_t mode) {
check_valid_digital_pin(pin); /* generate compile error if a constant that is not a valid pin is used as the pin */
check_valid_pin_mode(mode); /* generate compile error if a constant that is not a valid pin mode is used as the mode */
uint8_t bit_mask = digitalPinToBitMask(pin);
if ((bit_mask == NOT_A_PIN) || (mode > 3)) {
if ((bit_mask == NOT_A_PIN) || (mode > INPUT_PULLUP)) {
return; /* ignore invalid pins passed at runtime */
}
volatile uint8_t * port_base = ((volatile uint8_t *) (uint16_t)(0x0400 | portToPortBaseOffset(digitalPinToPort(pin))));
Expand Down Expand Up @@ -202,9 +202,15 @@ void pinMode(uint8_t pin, uint8_t mode) {
*port_base = bit_mask;
}



void turnOffPWM(uint8_t pin) {
/* This turns off PWM, if enabled. It is called automatically on every digitalWrite();
* This function can end up executing a heckovalotta code for one simple
* Note that it only operates on the PWM source with priority - TCA > TCD > TCB/DAC
* the order of the cases here doesn't matter - which one has priority is determined in
* digitalPinToTimerNow() in wiring_analog.c. That's why it's recommended to make sure
* that no pin you're about to move the PWM output of a TCA onto is currently outputting
* PWM. It can also be used from user code (unlike on the stock core). */
void turnOffPWM(uint8_t pin)
{
/* Actually turn off compare channel, not the timer */

/* Get pin's timer
Expand Down
25 changes: 25 additions & 0 deletions megaavr/extras/LinkingAgainstStaticLibrary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Linking against static library

In some uses cases, it might be convenient to link against a static library/archive rather than compiling the code each time. For example if you don't have access to the source files, just the headers and the archive, you want to reduce compilation time for a larger codebase or want to have a bunch of board specific code for a larger library. The downside with using a library is that the code size will increase, since things are statically linked and the compiler can do fewer tricks on what it has got at hand.

As things are with the Arduino environment at the moment, this requires your source code to be an Arduino library as well. This isn't a big deal, there are two steps:

1. Move your project to Arduino's library folder (usually in the `Documents\Arduino\libraries` folder in your home folder on Windows and in the `Arduino/libraries` folder in your home folder on linux). More information ~here~ no longer available, link that used to work is now 404.
2. Create a `library.properties` file according to this [specification](https://arduino.github.io/arduino-cli/latest/library-specification/) in the root of your library. An example is:

```text
name=your-library
version=1.0.0
author=Your name <your email>
maintainer=Your name <your email>
sentence=Test library
paragraph=Links an archive
category=Other
url=http://example.com/
architectures=*
precompiled=true
```

The `precompiled` keyword enables us to link against some archive. The archives have to be placed in `src/<board>/`, as detailed [here](https://arduino.github.io/arduino-cli/latest/library-specification/#precompiled-binaries). Board has to for example be `avr128db64`.

After this, you should be able to compile your code against the archive.
Loading

0 comments on commit 59b7ad6

Please sign in to comment.