-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
We might save a few bytes (on certain platforms/chips) by using typedef to configure the datatype used to specify pin numbers on different platforms/processors.
For example:
in utility/ATTiny/RF24_arch_config.h
typedef uint8_t rf24_gpio_t;in utility/ATXMegaD3/RF24_arch_config.h
typedef uint16_t rf24_gpio_t;in RF24.h
rf24_gpio_t ce_pin; /* "Chip Enable" pin, activates the RX or TX role */
rf24_gpio_t csn_pin; /* SPI Chip select */
RF24(rf24_gpio_t _cepin, rf24_gpio_t _cspin, uint32_t _spi_speed = RF24_SPI_SPEED);I'm inclined to use uint8_t (as it was from maniacbug days) in RF24_config.h for any platform/chip that doesn't have its own utility/*/RF24_arch_config.h, but maybe it is safer to just use uint16_t for continuity.
Additional context
As usual, I have an ulterior motive here. In order to extend support to the zephyr project (which uses DeviceTree specs to declare GPIO pins), I would need a way to change what datatype is passed to the RF24 c'tor. By typedefing the gpio pins' datatype, I can more easily implement wrappers for the pinMode() and the like.