Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

WIP: Native GPIO #1737

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/native/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FEATURES_PROVIDED += transceiver periph_cpuid config cpp
FEATURES_PROVIDED += periph_random
FEATURES_PROVIDED += periph_rtc
FEATURES_PROVIDED += periph_gpio
148 changes: 148 additions & 0 deletions cpu/native/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,154 @@
#define RTC_NUMOF (1)
/** @} */

#ifdef MODULE_NATIVE_GPIO_VIRTUAL /* virtual */
#define GPIO_0_EN (1)
#define GPIO_1_EN (1)
#define GPIO_2_EN (1)
#define GPIO_3_EN (1)
#define GPIO_4_EN (1)
#define GPIO_5_EN (1)
#define GPIO_6_EN (1)
#define GPIO_7_EN (1)
#define GPIO_8_EN (1)
#define GPIO_9_EN (1)
#define GPIO_10_EN (1)
#define GPIO_11_EN (1)
#define GPIO_12_EN (1)
#define GPIO_13_EN (1)
#define GPIO_14_EN (1)
#define GPIO_15_EN (1)
#define GPIO_16_EN (1)
#define GPIO_17_EN (1)
#define GPIO_18_EN (1)
#define GPIO_19_EN (1)
#define GPIO_20_EN (1)
#define GPIO_21_EN (1)
#define GPIO_22_EN (1)
#define GPIO_23_EN (1)
#define GPIO_24_EN (1)
#define GPIO_25_EN (1)
#define GPIO_26_EN (1)
#define GPIO_27_EN (1)
#define GPIO_28_EN (1)
#define GPIO_29_EN (1)
#define GPIO_30_EN (1)
#define GPIO_31_EN (1)
#define GPIO_NUMOF (32)

#elif defined MODULE_NATIVE_GPIO_SYSFS /* sysfs */

#ifdef NATIVE_GPIO_NUMOF
# if NATIVE_GPIO_NUMOF > 32
# define GPIO_NUMOF 32
# else
# define GPIO_NUMOF NATIVE_GPIO_NUMOF
# endif
#else
# define GPIO_NUMOF 0
#endif

#if GPIO_NUMOF > 0
# define GPIO_0_EN (1)
#endif
#if GPIO_NUMOF > 1
# define GPIO_1_EN (1)
#endif
#if GPIO_NUMOF > 2
# define GPIO_2_EN (1)
#endif
#if GPIO_NUMOF > 3
# define GPIO_3_EN (1)
#endif
#if GPIO_NUMOF > 4
# define GPIO_4_EN (1)
#endif
#if GPIO_NUMOF > 5
# define GPIO_5_EN (1)
#endif
#if GPIO_NUMOF > 6
# define GPIO_6_EN (1)
#endif
#if GPIO_NUMOF > 7
# define GPIO_7_EN (1)
#endif
#if GPIO_NUMOF > 8
# define GPIO_8_EN (1)
#endif
#if GPIO_NUMOF > 9
# define GPIO_9_EN (1)
#endif
#if GPIO_NUMOF > 10
# define GPIO_10_EN (1)
#endif
#if GPIO_NUMOF > 11
# define GPIO_11_EN (1)
#endif
#if GPIO_NUMOF > 12
# define GPIO_12_EN (1)
#endif
#if GPIO_NUMOF > 13
# define GPIO_13_EN (1)
#endif
#if GPIO_NUMOF > 14
# define GPIO_14_EN (1)
#endif
#if GPIO_NUMOF > 15
# define GPIO_15_EN (1)
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

hm, above you define, that there can be up to 32 GPIOs, but here you stop at 15...

Copy link
Member Author

Choose a reason for hiding this comment

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

Hoppla.

#if GPIO_NUMOF > 16
# define GPIO_16_EN (1)
#endif
#if GPIO_NUMOF > 17
# define GPIO_17_EN (1)
#endif
#if GPIO_NUMOF > 18
# define GPIO_18_EN (1)
#endif
#if GPIO_NUMOF > 19
# define GPIO_19_EN (1)
#endif
#if GPIO_NUMOF > 20
# define GPIO_20_EN (1)
#endif
#if GPIO_NUMOF > 21
# define GPIO_21_EN (1)
#endif
#if GPIO_NUMOF > 22
# define GPIO_22_EN (1)
#endif
#if GPIO_NUMOF > 23
# define GPIO_23_EN (1)
#endif
#if GPIO_NUMOF > 24
# define GPIO_24_EN (1)
#endif
#if GPIO_NUMOF > 25
# define GPIO_25_EN (1)
#endif
#if GPIO_NUMOF > 26
# define GPIO_26_EN (1)
#endif
#if GPIO_NUMOF > 27
# define GPIO_27_EN (1)
#endif
#if GPIO_NUMOF > 28
# define GPIO_28_EN (1)
#endif
#if GPIO_NUMOF > 29
# define GPIO_29_EN (1)
#endif
#if GPIO_NUMOF > 30
# define GPIO_30_EN (1)
#endif
#if GPIO_NUMOF > 31
# define GPIO_31_EN (1)
#endif

#else /* no GPIO device */
#define GPIO_NUMOF (0)
#endif

#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions cpu/native/periph/Makefile
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
ifneq (,$(filter native_gpio_virtual,$(USEMODULE)))
DIRS += gpio/virtual
endif
ifneq (,$(filter native_gpio_sysfs,$(USEMODULE)))
DIRS += gpio/sysfs
endif
include $(RIOTBASE)/Makefile.base
5 changes: 5 additions & 0 deletions cpu/native/periph/gpio/sysfs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MODULE = native_gpio_sysfs

include $(RIOTBASE)/Makefile.base

INCLUDES = $(NATIVEINCLUDES)
Loading