Skip to content

Commit 1767dae

Browse files
author
Martino Facchin
committed
pulseIn: export PORTA
1 parent 7012587 commit 1767dae

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

hardware/arduino/avr/cores/arduino/wiring_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ extern "C"{
4343
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
4444
#endif
4545

46+
uint16_t countPulseASM_A(const uint8_t port, const uint8_t bit, uint16_t maxloops, uint8_t state);
4647
uint16_t countPulseASM_B(const uint8_t port, const uint8_t bit, uint16_t maxloops, uint8_t state);
4748
uint16_t countPulseASM_C(const uint8_t port, const uint8_t bit, uint16_t maxloops, uint8_t state);
4849
uint16_t countPulseASM_D(const uint8_t port, const uint8_t bit, uint16_t maxloops, uint8_t state);

hardware/arduino/avr/cores/arduino/wiring_pulse.S

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,40 @@
2222

2323
#include <avr/io.h>
2424

25+
.global countPulseASM_A
2526
.global countPulseASM_B
2627
.global countPulseASM_C
2728
.global countPulseASM_D
2829

2930
.section .text
3031

32+
countPulseASM_A:
33+
push r17
34+
mov r24,r1
35+
mov r25,r1
36+
loop_a:
37+
adiw r24, 1
38+
cp r24, r20
39+
cpc r25, r21
40+
breq return_zero_a
41+
//check the pin state to be consistent with the mask
42+
in r17, PINA-0x20
43+
eor r17, r18
44+
and r17, r22
45+
cpi r17, 0
46+
breq loop_a
47+
//sbic PINA-0x20, 7
48+
//rjmp loop
49+
ret_delay_a:
50+
rjmp exit_a
51+
return_zero_a:
52+
mov r24,r1
53+
mov r25,r1
54+
exit_a:
55+
pop r17
56+
ret
57+
58+
3159
countPulseASM_B:
3260
push r17
3361
mov r24,r1

0 commit comments

Comments
 (0)