Skip to content

Commit 747d853

Browse files
committedAug 13, 2023
Fix a much of PWM, serial issues, update doc on PWM
PWM frequencies were not being correctly chosen #778 #787 #762 #779
1 parent fa72ab8 commit 747d853

21 files changed

+1365
-897
lines changed
 

‎CODE_OF_CONDUCT.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contributor Code of Conduct
2+
3+
As contributors and maintainers of this project, we all pledge to treat
4+
all people who contribute through reporting issues, posting feature
5+
requests, updating documentation, submitting pull requests or patches,
6+
and other activities with common decency at minimum.
7+
8+
To this end, there is to be no harassment, personal attacks, or other
9+
trashtalking directed at any member of the community, whether over any
10+
racial, sexual, religious, national identity, over personal grudges
11+
towards other members from here or elsewhere. In general, most of these
12+
forms of prohibited content involve either off topic posts, spam, or
13+
being an asshole or a plagerist - so stay on topic, don't post spam and
14+
don't be an asshole either to others or in general.
15+
16+
Note that mild trashtalk of organizations or companies as a whole (but
17+
not individuals working there) - Microchip, Atmel, and Arduino are
18+
certainly valid targets - but only insofar as it relates to a technical
19+
matter already being discussed.
20+
21+
Also, obviously, images that are disturbing, sexual, or harassing (or
22+
otherwise which have nothing to do with the repo) should not be posted.
23+
No content that is illegal is to be included in any post, commit or PR.
24+
No intimidating, threatening, advertising (whether goods, services or
25+
political opinions - this does not prohibit brief mentions of products
26+
sold by contributors which are that are relevant to an existing
27+
discussion - but only if it constitutes a small portion of the post,
28+
and the post is concerned primarily with the matter at hand, not your
29+
commercial product).
30+
31+
No content that is not open source is to be submitted by anyone other
32+
than the copyright holder. Open source code with a license incompatible
33+
with LGPL 2.1 may be permitted, but only if it's particularly valuable,
34+
as was done for the code from adafruitNeopixel which became tinyNeopixel.
35+
36+
Project maintainers have the right and responsibility to remove, edit,
37+
or reject comments, commits, code, issues, and other contributions that
38+
are not aligned to this Code of Conduct. Project maintainers or contributors
39+
who do not follow the Code of Conduct may be banned temporarally or
40+
permanently, depending on the severity of the offence. To date we have not
41+
had any instances of such behavior.
42+
43+
Instances of abusive, harassing, or otherwise unacceptable behavior may
44+
be reported by emailing `spencekonde@gmail. com>` which only goes to to
45+
Spence Konde.
46+
47+
This Code of Conduct is adapted from the `Contributor
48+
Covenant <http://contributor-covenant.org>` version 1.0.0, available at
49+
http://contributor-covenant.org/version/1/0/0/

‎avr/cores/tiny/HardwareSerial.cpp

+5-60
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
volatile uint8_t *udr) {
4747
_rx_buffer = rx_buffer;
4848
_tx_buffer = tx_buffer;
49+
_ubrrh = ubrrh;
50+
_ubrrl = ubrrl;
51+
_ucsra = ucsra;
52+
_ucsrb = ucsrb;
53+
_udr = udr;
4954
}
5055
#else
5156
) {
@@ -90,66 +95,6 @@
9095
*_ubrrl = baud_setting;
9196
*_ucsrb = (_rxen | _txen | _rxcie);
9297

93-
// For fucks sake, the USART registers aren't in low I/O space!
94-
// Even if they WERE, SBI and CBI only work when both arguments are compiletimne known
95-
// here they *would* be except that classes completely stymie LTO. the 4 lines of SBI and CBI that were here got turned into this:
96-
/*
97-
sbi(*_ucsrb, _rxen);
98-
376: a0 91 4a 01 lds r26, 0x014A ; 0x80014a <Serial+0x16>
99-
37a: b0 91 4b 01 lds r27, 0x014B ; 0x80014b <Serial+0x17>
100-
37e: 8c 91 ld r24, X
101-
380: 90 91 4e 01 lds r25, 0x014E ; 0x80014e <Serial+0x1a>
102-
384: 9f 01 movw r18, r30
103-
386: 01 c0 rjmp .+2 ; 0x38a <__stack+0x8b>
104-
388: 22 0f add r18, r18
105-
38a: 9a 95 dec r25 ; this is a LOOP. Why is there a loop here? to lefthift the bit position into a bitmask.
106-
; CLASSES ARE KYRPYONITE TO LTO. Even though we know that all the places where the bit positions
107-
; get passed to the constructor, it takes the same value.... the compiler isn't smart enough to see that.
108-
38c: ea f7 brpl .-6 ; 0x388 <__stack+0x89>
109-
38e: 82 2b or r24, r18
110-
390: 8c 93 st X, r24
111-
C:\Users\Spence\Documents\Arduino\hardware\ATTinyCore\avr\cores\tiny/HardwareSerial.cpp:121
112-
sbi(*_ucsrb, _txen);
113-
392: a0 91 4a 01 lds r26, 0x014A ; 0x80014a <Serial+0x16>
114-
396: b0 91 4b 01 lds r27, 0x014B ; 0x80014b <Serial+0x17>
115-
39a: 8c 91 ld r24, X
116-
39c: 90 91 4f 01 lds r25, 0x014F ; 0x80014f <Serial+0x1b>
117-
3a0: 9f 01 movw r18, r30
118-
3a2: 01 c0 rjmp .+2 ; 0x3a6 <__stack+0xa7>
119-
3a4: 22 0f add r18, r18
120-
3a6: 9a 95 dec r25 ; THIS IS ANOTHER BLOODY LOOP TO ACHIEVE A LEFTSHIFT!
121-
3a8: ea f7 brpl .-6 ; 0x3a4 <__stack+0xa5>
122-
3aa: 82 2b or r24, r18
123-
3ac: 8c 93 st X, r24
124-
C:\Users\Spence\Documents\Arduino\hardware\ATTinyCore\avr\cores\tiny/HardwareSerial.cpp:122
125-
sbi(*_ucsrb, _rxcie);
126-
3ae: a0 91 4a 01 lds r26, 0x014A ; 0x80014a <Serial+0x16>
127-
3b2: b0 91 4b 01 lds r27, 0x014B ; 0x80014b <Serial+0x17>
128-
3b6: 8c 91 ld r24, X
129-
3b8: 90 91 50 01 lds r25, 0x0150 ; 0x800150 <Serial+0x1c>
130-
3bc: 9f 01 movw r18, r30
131-
3be: 01 c0 rjmp .+2 ; 0x3c2 <__stack+0xc3>
132-
3c0: 22 0f add r18, r18
133-
3c2: 9a 95 dec r25 ; THIS IS ANOTHER BLOODY LOOP TO ACHIEVE A LEFTSHIFT!
134-
3c4: ea f7 brpl .-6 ; 0x3c0 <__stack+0xc1>
135-
3c6: 82 2b or r24, r18
136-
3c8: 8c 93 st X, r24
137-
C:\Users\Spence\Documents\Arduino\hardware\ATTinyCore\avr\cores\tiny/HardwareSerial.cpp:123
138-
cbi(*_ucsrb, _udrie);
139-
3ca: a0 91 4a 01 lds r26, 0x014A ; 0x80014a <Serial+0x16>
140-
3ce: b0 91 4b 01 lds r27, 0x014B ; 0x80014b <Serial+0x17>
141-
3d2: 8c 91 ld r24, X
142-
3d4: 90 91 51 01 lds r25, 0x0151 ; 0x800151 <Serial+0x1d>
143-
3d8: 01 c0 rjmp .+2 ; 0x3dc <__stack+0xdd>
144-
3da: ee 0f add r30, r30
145-
3dc: 9a 95 dec r25 ; THIS IS ANOTHER BLOODY LOOP TO ACHIEVE A LEFTSHIFT!
146-
3de: ea f7 brpl .-6 ; 0x3da <__stack+0xdb>
147-
3e0: e0 95 com r30
148-
3e2: e8 23 and r30, r24
149-
3e4: ec 93 st X, r30
150-
3e6: ff cf rjmp .-2 ; 0x3e6 <__stack+0xe7>
151-
So in total that flagraqnt SBI/CBI abuse swallowed 112 bytes flash and had execution time of around 150 clocks
152-
*/
15398
#else
15499
LINCR = (1 << LSWRES);
155100
LINBRR = (((F_CPU * 10L / 16L / baud) + 5L) / 10L) - 1;

0 commit comments

Comments
 (0)
Please sign in to comment.