Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

cpu/sam0_common: implement periph_gpio_ll and periph_gpio_ll_irq #20189

Merged
merged 3 commits into from
Jan 22, 2024

Conversation

maribu
Copy link
Member

@maribu maribu commented Dec 15, 2023

Contribution description

This implements periph_gpio_ll and periph_gpio_ll_irq for SAM0 based MCUs.

Testing procedure

make BOARD=samr21-xpro flash test-with-config -C tests/periph/gpio_ll 
make: Entering directory '/home/maribu/Repos/software/RIOT/gpio_ll_sam0/tests/periph/gpio_ll'
Building application "tests_gpio_ll" for "samr21-xpro" with MCU "samd21".

"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/pkg/cmsis/ 
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/boards/common/init
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/boards/samr21-xpro
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/core
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/core/lib
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/samd21
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/cortexm_common
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/cortexm_common/periph
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/sam0_common
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/sam0_common/periph
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/samd21/periph
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/samd21/vectors
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/drivers
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/drivers/periph_common
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/auto_init
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/div
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/frac
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/isrpipe
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/libc
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/malloc_thread_safe
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/newlib_syscalls_default
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/pm_layered
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/preprocessor
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/stdio_uart
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/test_utils/interactive_sync
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/test_utils/print_stack_usage
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/tsrb
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/ztimer
   text	  data	   bss	   dec	   hex	filename
  21788	   176	  2708	 24672	  6060	/home/maribu/Repos/software/RIOT/gpio_ll_sam0/tests/periph/gpio_ll/bin/samr21-xpro/tests_gpio_ll.elf
/home/maribu/Repos/software/RIOT/gpio_ll_sam0/dist/tools/edbg/edbg.sh flash /home/maribu/Repos/software/RIOT/gpio_ll_sam0/tests/periph/gpio_ll/bin/samr21-xpro/tests_gpio_ll.bin
### Flashing Target ###
Debugger: ATMEL EDBG CMSIS-DAP ATML2127031800009225 03.25.01B6 (S)
Clock frequency: 16.0 MHz
Target: SAM R21G18 (Rev C)
Verification...
at address 0x40 expected 0xfd, read 0xf1
Error: verification failed
Debugger: ATMEL EDBG CMSIS-DAP ATML2127031800009225 03.25.01B6 (S)
Clock frequency: 16.0 MHz
Target: SAM R21G18 (Rev C)
Programming...... done.
Verification...... done.
Done flashing
r
/home/maribu/Repos/software/RIOT/gpio_ll_sam0/dist/tools/pyterm/pyterm -p "/dev/ttyACM1" -b "115200" --no-reconnect --noprefix --no-repeat-command-on-empty-line 
Connect to serial port /dev/ttyACM1
Welcome to pyterm!
Type '/exit' to exit.
READY
s
START
main(): This is RIOT! (Version: 2024.01-devel-411-g5552b4-cpu/sam0_common/periph_gpio_ll)
Test / Hardware Details:
========================
Cabling:
(INPUT -- OUTPUT)
  P1.2 (PB2) -- P0.14 (PA14)
  P1.23 (PB23) -- P0.8 (PA8)
Number of pull resistor values supported: 1
Number of drive strengths supported: 2
Number of slew rates supported: 1
Valid GPIO ports:
- PORT 0 (PORT A)
- PORT 1 (PORT B)
- PORT 2 (PORT C)

Testing gpio_port_pack_addr()
=============================

All OK

Testing gpip_ng_init()
======================

Testing is_gpio_port_num_valid() is true for PORT_OUT and PORT_IN:

Testing input configurations for PIN_IN_0:
Support for input with pull up: yes
state: in, pull: up, schmitt trigger: on, value: on
Support for input with pull down: yes
state: in, pull: down, schmitt trigger: on, value: off
Support for input with pull to bus level: no
Support for floating input (no pull resistors): yes
state: in, pull: none, schmitt trigger: on, value: off

Testing output configurations for PIN_OUT_0:
Support for output (push-pull) with initial value of LOW: yes
state: out-pp, drive: weak, value: off
Output is indeed LOW: yes
state: out-pp, drive: weak, value: on
Output can be pushed HIGH: yes
Support for output (push-pull) with initial value of HIGH: yes
state: out-pp, drive: weak, value: on
Output is indeed HIGH: yes
Support for output (open drain with pull up) with initial value of LOW: no
Support for output (open drain with pull up) with initial value of HIGH: no
Support for output (open drain) with initial value of LOW: no
Support for output (open drain) with initial value of HIGH: no
Support for output (open source) with initial value of LOW: no
Support for output (open source) with initial value of HIGH: no
Support for output (open source with pull up) with initial value of HIGH: no
Support for output (open source with pull up) with initial value of LOW: no
Support for disconnecting GPIO: yes
state: off, drive: weak, pull: none, schmitt trigger: off, value: off
Output can indeed be pulled LOW: yes
Output can indeed be pulled HIGH: yes

Testing Reading/Writing GPIO Ports
==================================

testing initial value of 0 after init
...OK
testing setting both outputs_optional simultaneously
...OK
testing clearing both outputs_optional simultaneously
...OK
testing toggling first output (0 --> 1)
...OK
testing toggling first output (1 --> 0)
...OK
testing toggling second output (0 --> 1)
...OK
testing toggling second output (1 --> 0)
...OK
testing setting first output and clearing second with write
...OK
testing setting second output and clearing first with write
...OK
All input/output operations worked as expected

Testing External IRQs
=====================

Testing rising edge on PIN_IN_0
... OK
Testing falling edge on PIN_IN_0
... OK
Testing both edges on PIN_IN_0
... OK
Testing masking of IRQs (still both edges on PIN_IN_0)
... OK
Testing level-triggered on HIGH on PIN_IN_0 (when input is LOW when setting up IRQ)
... OK
Testing level-triggered on HIGH on PIN_IN_0 (when input is HIGH when setting up IRQ)
... OK
Testing level-triggered on LOW on PIN_IN_0 (when input is HIGH when setting up IRQ)
... OK
Testing level-triggered on LOW on PIN_IN_0 (when input is LOW when setting up IRQ)
... OK


TEST SUCCEEDED

Issues/PRs references

@maribu maribu added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Dec 15, 2023
@github-actions github-actions bot added Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: tests Area: tests and testing framework Area: cpu Area: CPU/MCU ports Area: Kconfig Area: Kconfig integration labels Dec 15, 2023
@riot-ci
Copy link

riot-ci commented Dec 15, 2023

Murdock results

✔️ PASSED

1484d30 cpu/sam0_common: implement periph_gpio_ll_irq

Success Failures Total Runtime
8629 0 8629 10m:39s

Artifacts

@maribu maribu force-pushed the cpu/sam0_common/periph_gpio_ll branch from 5552b4d to c939c63 Compare December 15, 2023 13:23
@maribu maribu force-pushed the cpu/sam0_common/periph_gpio_ll branch from c939c63 to 06c2d95 Compare January 19, 2024 14:59
@github-actions github-actions bot added Platform: AVR Platform: This PR/issue effects AVR-based platforms Area: drivers Area: Device drivers Platform: ESP Platform: This PR/issue effects ESP-based platforms labels Jan 19, 2024
@maribu maribu added the State: waiting for other PR State: The PR requires another PR to be merged first label Jan 19, 2024
When using level triggered IRQs, a new IRQ flag may already have been
set while the IRQ callback is executed. Hence, we cannot just toggle
the output, but rather should drive it low/high for a level trigger on
high/low.

Also test `gpio_ll_query_conf()` for the disconnected state as well.
@maribu maribu force-pushed the cpu/sam0_common/periph_gpio_ll branch from 06c2d95 to 67b3815 Compare January 21, 2024 17:30
@github-actions github-actions bot removed the Platform: AVR Platform: This PR/issue effects AVR-based platforms label Jan 21, 2024
@github-actions github-actions bot removed Area: drivers Area: Device drivers Platform: ESP Platform: This PR/issue effects ESP-based platforms labels Jan 21, 2024
@maribu maribu removed State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet State: waiting for other PR State: The PR requires another PR to be merged first labels Jan 21, 2024
@maribu
Copy link
Member Author

maribu commented Jan 21, 2024

Rebased on master, test still succeeds:

git:(cpu/sam0_common/periph_gpio_ll) ~/Repos/software/RIOT/gpio_ll_sam0 ➜ make BOARD=samr21-xpro -C tests/periph/gpio_ll flash test-with-config 
make: Entering directory '/home/maribu/Repos/software/RIOT/gpio_ll_sam0/tests/periph/gpio_ll'
Building application "tests_gpio_ll" for "samr21-xpro" with MCU "samd21".

"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/pkg/cmsis/ 
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/boards/common/init
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/boards/samr21-xpro
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/core
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/core/lib
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/samd21
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/cortexm_common
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/cortexm_common/periph
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/sam0_common
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/sam0_common/periph
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/samd21/periph
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/cpu/samd21/vectors
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/drivers
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/drivers/periph_common
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/auto_init
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/div
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/frac
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/isrpipe
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/libc
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/malloc_thread_safe
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/newlib_syscalls_default
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/pm_layered
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/preprocessor
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/stdio_uart
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/test_utils/interactive_sync
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/test_utils/print_stack_usage
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/tsrb
"make" -C /home/maribu/Repos/software/RIOT/gpio_ll_sam0/sys/ztimer
   text	  data	   bss	   dec	   hex	filename
  21204	   176	  2708	 24088	  5e18	/home/maribu/Repos/software/RIOT/gpio_ll_sam0/tests/periph/gpio_ll/bin/samr21-xpro/tests_gpio_ll.elf
/home/maribu/Repos/software/RIOT/gpio_ll_sam0/dist/tools/edbg/edbg.sh flash /home/maribu/Repos/software/RIOT/gpio_ll_sam0/tests/periph/gpio_ll/bin/samr21-xpro/tests_gpio_ll.bin
### Flashing Target ###
Debugger: ATMEL EDBG CMSIS-DAP ATML2127031800009225 03.25.01B6 (S)
Clock frequency: 16.0 MHz
Target: SAM R21G18 (Rev C)
Verification...
at address 0x4 expected 0x6d, read 0x5d
Error: verification failed
Debugger: ATMEL EDBG CMSIS-DAP ATML2127031800009225 03.25.01B6 (S)
Clock frequency: 16.0 MHz
Target: SAM R21G18 (Rev C)
Programming...... done.
Verification...... done.
Done flashing
r
/home/maribu/Repos/software/RIOT/gpio_ll_sam0/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200" --no-reconnect --noprefix --no-repeat-command-on-empty-line 
Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
Y
 ��%���������х������������ɥ�сJсJ́�����READY
s
START
main(): This is RIOT! (Version: 2024.01-devel-659-g67b381-cpu/sam0_common/periph_gpio_ll)
Test / Hardware Details:
========================
Cabling:
(INPUT -- OUTPUT)
  P1.2 (PB2) -- P0.14 (PA14)
  P1.23 (PB23) -- P0.8 (PA8)
Number of pull resistor values supported: 1
Number of drive strengths supported: 2
Number of slew rates supported: 1
Valid GPIO ports:
- PORT 0 (PORT A)
- PORT 1 (PORT B)
- PORT 2 (PORT C)

Testing gpio_port_pack_addr()
=============================

All OK

Testing gpip_ng_init()
======================

Testing is_gpio_port_num_valid() is true for PORT_OUT and PORT_IN:

Testing input configurations for PIN_IN_0:
Support for input with pull up: yes
state: in, pull: up, value: on, drive: weak
Support for input with pull down: yes
state: in, pull: down, value: off, drive: weak
Support for input with pull to bus level: no
Support for floating input (no pull resistors): yes
state: in, pull: none, value: off, drive: weak

Testing output configurations for PIN_OUT_0:
Support for output (push-pull) with initial value of LOW: yes
state: out-pp, value: off, drive: weak
Output is indeed LOW: yes
state: out-pp, value: on, drive: weak
Output can be pushed HIGH: yes
Support for output (push-pull) with initial value of HIGH: yes
state: out-pp, value: on, drive: weak
Output is indeed HIGH: yes
Support for output (open drain with pull up) with initial value of LOW: no
Support for output (open drain with pull up) with initial value of HIGH: no
Support for output (open drain) with initial value of LOW: no
Support for output (open drain) with initial value of HIGH: no
Support for output (open source) with initial value of LOW: no
Support for output (open source) with initial value of HIGH: no
Support for output (open source with pull up) with initial value of HIGH: no
Support for output (open source with pull up) with initial value of LOW: no
Support for disconnecting GPIO: yes
state: off, pull: none, value: off, drive: weak
Output can indeed be pulled LOW: yes
Output can indeed be pulled HIGH: yes

Testing Reading/Writing GPIO Ports
==================================

testing initial value of 0 after init
...OK
testing setting both outputs_optional simultaneously
...OK
testing clearing both outputs_optional simultaneously
...OK
testing toggling first output (0 --> 1)
...OK
testing toggling first output (1 --> 0)
...OK
testing toggling second output (0 --> 1)
...OK
testing toggling second output (1 --> 0)
...OK
testing setting first output and clearing second with write
...OK
testing setting second output and clearing first with write
...OK
All input/output operations worked as expected

Testing External IRQs
=====================

Testing rising edge on PIN_IN_0
... OK
Testing falling edge on PIN_IN_0
... OK
Testing both edges on PIN_IN_0
... OK
Testing masking of IRQs (still both edges on PIN_IN_0)
... OK
Testing level-triggered on HIGH on PIN_IN_0 (when input is LOW when setting up IRQ)
... OK
Testing level-triggered on HIGH on PIN_IN_0 (when input is HIGH when setting up IRQ)
... OK
Testing level-triggered on LOW on PIN_IN_0 (when input is HIGH when setting up IRQ)
... OK
Testing level-triggered on LOW on PIN_IN_0 (when input is LOW when setting up IRQ)
... OK


TEST SUCCEEDED

make: Leaving directory '/home/maribu/Repos/software/RIOT/gpio_ll_sam0/tests/periph/gpio_ll'

@benpicco
Copy link
Contributor

I tried this on saml10-xpro with

PORT_IN=0
PORT_OUT=0
PIN_IN_0=2
PIN_OUT_0=3
PIN_IN_1=21
PIN_OUT_1=10

and I get

024-01-22 12:55:00,579 # main(): This is RIOT! (Version: 2024.01-devel-659-g67b381-HEAD)
2024-01-22 12:55:00,581 # Test / Hardware Details:
2024-01-22 12:55:00,584 # ========================
2024-01-22 12:55:00,584 # Cabling:
2024-01-22 12:55:00,586 # (INPUT -- OUTPUT)
2024-01-22 12:55:00,589 #   P0.2 (PA2) -- P0.3 (PA3)
2024-01-22 12:55:00,592 #   P0.21 (PA21) -- P0.10 (PA10)
2024-01-22 12:55:00,596 # Number of pull resistor values supported: 1
2024-01-22 12:55:00,600 # Number of drive strengths supported: 2
2024-01-22 12:55:00,603 # Number of slew rates supported: 1
2024-01-22 12:55:00,604 # Valid GPIO ports:
2024-01-22 12:55:00,606 # - PORT 0 (PORT A)
2024-01-22 12:55:00,606 # 
2024-01-22 12:55:00,609 # Testing gpio_port_pack_addr()
2024-01-22 12:55:00,612 # =============================
2024-01-22 12:55:00,612 # 
2024-01-22 12:55:00,612 # All OK
2024-01-22 12:55:00,613 # 
2024-01-22 12:55:00,615 # Testing gpip_ng_init()
2024-01-22 12:55:00,617 # ======================
2024-01-22 12:55:00,617 # 
2024-01-22 12:55:00,623 # Testing is_gpio_port_num_valid() is true for PORT_OUT and PORT_IN:
2024-01-22 12:55:00,623 # 
2024-01-22 12:55:00,627 # Testing input configurations for PIN_IN_0:
2024-01-22 12:55:00,630 # Support for input with pull up: yes
2024-01-22 12:55:00,634 # state: in, pull: up, value: on, drive: weak
2024-01-22 12:55:00,637 # Support for input with pull down: yes
2024-01-22 12:55:00,642 # state: in, pull: down, value: off, drive: weak
2024-01-22 12:55:00,646 # Support for input with pull to bus level: no
2024-01-22 12:55:00,650 # Support for floating input (no pull resistors): yes
2024-01-22 12:55:00,655 # state: in, pull: none, value: off, drive: weak
2024-01-22 12:55:00,655 # 
2024-01-22 12:55:00,659 # Testing output configurations for PIN_OUT_0:
2024-01-22 12:55:00,664 # Support for output (push-pull) with initial value of LOW: yes
2024-01-22 12:55:00,668 # state: out-pp, value: off, drive: weak
2024-01-22 12:55:00,671 # Output is indeed LOW: yes
2024-01-22 12:55:00,675 # state: out-pp, value: on, drive: weak
2024-01-22 12:55:00,679 # Output can be pushed HIGH: yes
2024-01-22 12:55:00,684 # Support for output (push-pull) with initial value of HIGH: yes
2024-01-22 12:55:00,688 # state: out-pp, value: on, drive: weak
2024-01-22 12:55:00,691 # Output is indeed HIGH: yes
2024-01-22 12:55:00,698 # Support for output (open drain with pull up) with initial value of LOW: no
2024-01-22 12:55:00,705 # Support for output (open drain with pull up) with initial value of HIGH: no
2024-01-22 12:55:00,711 # Support for output (open drain) with initial value of LOW: no
2024-01-22 12:55:00,716 # Support for output (open drain) with initial value of HIGH: no
2024-01-22 12:55:00,722 # Support for output (open source) with initial value of LOW: no
2024-01-22 12:55:00,728 # Support for output (open source) with initial value of HIGH: no
2024-01-22 12:55:00,735 # Support for output (open source with pull up) with initial value of HIGH: no
2024-01-22 12:55:00,742 # Support for output (open source with pull up) with initial value of LOW: no
2024-01-22 12:55:00,745 # Support for disconnecting GPIO: yes
2024-01-22 12:55:00,750 # state: off, pull: none, value: off, drive: weak
2024-01-22 12:55:00,754 # Output can indeed be pulled LOW: yes
2024-01-22 12:55:00,759 # Output can indeed be pulled HIGH: yes
2024-01-22 12:55:00,759 # 
2024-01-22 12:55:00,762 # Testing Reading/Writing GPIO Ports
2024-01-22 12:55:00,765 # ==================================
2024-01-22 12:55:00,765 # 
2024-01-22 12:55:00,768 # testing initial value of 0 after init
2024-01-22 12:55:00,770 # ...OK
2024-01-22 12:55:00,775 # testing setting both outputs_optional simultaneously
2024-01-22 12:55:00,778 # expect failed at line 526

@maribu
Copy link
Member Author

maribu commented Jan 22, 2024

PA21 seems to be connected to EDBG_ADC0, PA10 to DGI_GPIO2, and PA3 to EDBG_CDC_USART_RX.

Could you try it again with other GPIOs?

@benpicco
Copy link
Contributor

Ah indeed, works with PA04/05, PA14/15

@benpicco
Copy link
Contributor

I get a different failure on same54-xpro though with

PORT_IN=1
PORT_OUT=3
PIN_IN_0=14
PIN_OUT_0=0
PIN_IN_1=15
PIN_OUT_1=9
2024-01-22 14:21:11,080 # main(): This is RIOT! (Version: 2024.01-devel-659-g67b381-HEAD)
2024-01-22 14:21:11,082 # Test / Hardware Details:
2024-01-22 14:21:11,085 # ========================
2024-01-22 14:21:11,085 # Cabling:
2024-01-22 14:21:11,087 # (INPUT -- OUTPUT)
2024-01-22 14:21:11,090 #   P1.14 (PB14) -- P3.0 (PD0)
2024-01-22 14:21:11,092 #   P1.15 (PB15) -- P3.9 (PD9)
2024-01-22 14:21:11,096 # Number of pull resistor values supported: 1
2024-01-22 14:21:11,099 # Number of drive strengths supported: 2
2024-01-22 14:21:11,102 # Number of slew rates supported: 1
2024-01-22 14:21:11,104 # Valid GPIO ports:
2024-01-22 14:21:11,105 # - PORT 0 (PORT A)
2024-01-22 14:21:11,107 # - PORT 1 (PORT B)
2024-01-22 14:21:11,109 # - PORT 2 (PORT C)
2024-01-22 14:21:11,110 # - PORT 3 (PORT D)
2024-01-22 14:21:11,110 # 
2024-01-22 14:21:11,113 # Testing gpio_port_pack_addr()
2024-01-22 14:21:11,116 # =============================
2024-01-22 14:21:11,116 # 
2024-01-22 14:21:11,116 # All OK
2024-01-22 14:21:11,116 # 
2024-01-22 14:21:11,118 # Testing gpip_ng_init()
2024-01-22 14:21:11,120 # ======================
2024-01-22 14:21:11,120 # 
2024-01-22 14:21:11,126 # Testing is_gpio_port_num_valid() is true for PORT_OUT and PORT_IN:
2024-01-22 14:21:11,127 # 
2024-01-22 14:21:11,130 # Testing input configurations for PIN_IN_0:
2024-01-22 14:21:11,133 # Support for input with pull up: yes
2024-01-22 14:21:11,137 # state: in, pull: up, value: on, drive: weak
2024-01-22 14:21:11,140 # Support for input with pull down: yes
2024-01-22 14:21:11,144 # state: in, pull: down, value: off, drive: weak
2024-01-22 14:21:11,148 # Support for input with pull to bus level: no
2024-01-22 14:21:11,153 # Support for floating input (no pull resistors): yes
2024-01-22 14:21:11,157 # state: in, pull: none, value: off, drive: weak
2024-01-22 14:21:11,157 # 
2024-01-22 14:21:11,161 # Testing output configurations for PIN_OUT_0:
2024-01-22 14:21:11,166 # Support for output (push-pull) with initial value of LOW: yes
2024-01-22 14:21:11,170 # state: out-pp, value: off, drive: weak
2024-01-22 14:21:11,173 # Output is indeed LOW: yes
2024-01-22 14:21:11,176 # state: out-pp, value: on, drive: weak
2024-01-22 14:21:11,180 # Output can be pushed HIGH: yes
2024-01-22 14:21:11,186 # Support for output (push-pull) with initial value of HIGH: yes
2024-01-22 14:21:11,189 # state: out-pp, value: on, drive: weak
2024-01-22 14:21:11,192 # Output is indeed HIGH: yes
2024-01-22 14:21:11,199 # Support for output (open drain with pull up) with initial value of LOW: no
2024-01-22 14:21:11,205 # Support for output (open drain with pull up) with initial value of HIGH: no
2024-01-22 14:21:11,211 # Support for output (open drain) with initial value of LOW: no
2024-01-22 14:21:11,216 # Support for output (open drain) with initial value of HIGH: no
2024-01-22 14:21:11,222 # Support for output (open source) with initial value of LOW: no
2024-01-22 14:21:11,227 # Support for output (open source) with initial value of HIGH: no
2024-01-22 14:21:11,234 # Support for output (open source with pull up) with initial value of HIGH: no
2024-01-22 14:21:11,241 # Support for output (open source with pull up) with initial value of LOW: no
2024-01-22 14:21:11,244 # Support for disconnecting GPIO: yes
2024-01-22 14:21:11,248 # state: off, pull: none, value: off, drive: weak
2024-01-22 14:21:11,252 # Output can indeed be pulled LOW: yes
2024-01-22 14:21:11,257 # Output can indeed be pulled HIGH: yes
2024-01-22 14:21:11,257 # 
2024-01-22 14:21:11,260 # Testing Reading/Writing GPIO Ports
2024-01-22 14:21:11,263 # ==================================
2024-01-22 14:21:11,263 # 
2024-01-22 14:21:11,266 # testing initial value of 0 after init
2024-01-22 14:21:11,268 # ...OK
2024-01-22 14:21:11,272 # testing setting both outputs_optional simultaneously
2024-01-22 14:21:11,274 # ...OK
2024-01-22 14:21:11,279 # testing clearing both outputs_optional simultaneously
2024-01-22 14:21:11,280 # ...OK
2024-01-22 14:21:11,284 # testing toggling first output (0 --> 1)
2024-01-22 14:21:11,285 # ...OK
2024-01-22 14:21:11,289 # testing toggling first output (1 --> 0)
2024-01-22 14:21:11,290 # ...OK
2024-01-22 14:21:11,294 # testing toggling second output (0 --> 1)
2024-01-22 14:21:11,295 # ...OK
2024-01-22 14:21:11,299 # testing toggling second output (1 --> 0)
2024-01-22 14:21:11,300 # ...OK
2024-01-22 14:21:11,306 # testing setting first output and clearing second with write
2024-01-22 14:21:11,307 # ...OK
2024-01-22 14:21:11,312 # testing setting second output and clearing first with write
2024-01-22 14:21:11,313 # ...OK
2024-01-22 14:21:11,317 # All input/output operations worked as expected
2024-01-22 14:21:11,317 # 
2024-01-22 14:21:11,319 # Testing External IRQs
2024-01-22 14:21:11,321 # =====================
2024-01-22 14:21:11,321 # 
2024-01-22 14:21:11,324 # Testing rising edge on PIN_IN_0
2024-01-22 14:21:11,327 # ... OK
2024-01-22 14:21:11,330 # Testing falling edge on PIN_IN_0
2024-01-22 14:21:11,334 # ... OK
2024-01-22 14:21:11,337 # Testing both edges on PIN_IN_0
2024-01-22 14:21:11,340 # ... OK
2024-01-22 14:21:11,345 # Testing masking of IRQs (still both edges on PIN_IN_0)
2024-01-22 14:21:11,348 # expect failed at line 661

{
if (port_num >= ARRAY_SIZE(exti_config)) {
return -1;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be an assert()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call sites of get_exti_num() actually do:

    assume((unsigned)exti_num < IRQS_NUMOF);

That should cover this as well, but also gives the compiler information about what values are to be expected within exti_config.

@maribu
Copy link
Member Author

maribu commented Jan 22, 2024

I get a different failure on same54-xpro though

Good catch! That would have been a nasty race condition bug that could have caused lots of pain and tears.

For me it now works correctly.

Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash

maribu and others added 2 commits January 22, 2024 16:28
Co-authored-by: benpicco <benpicco@googlemail.com>
Co-authored-by: benpicco <benpicco@googlemail.com>
@maribu maribu force-pushed the cpu/sam0_common/periph_gpio_ll branch from cdc840e to 1484d30 Compare January 22, 2024 15:28
@maribu maribu enabled auto-merge January 22, 2024 15:37
@maribu maribu added this pull request to the merge queue Jan 22, 2024
Merged via the queue into RIOT-OS:master with commit 3159578 Jan 22, 2024
25 checks passed
@maribu maribu deleted the cpu/sam0_common/periph_gpio_ll branch January 22, 2024 18:32
@maribu
Copy link
Member Author

maribu commented Jan 22, 2024

Thx :)

@maribu
Copy link
Member Author

maribu commented Jan 23, 2024

Improving the test in 891c627 had the side effect that lots of boards now fail the test 😅

(But the issues it detects are indeed very real.)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Area: cpu Area: CPU/MCU ports Area: Kconfig Area: Kconfig integration Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants