From 20a71428fcb438f4959dae5e7211f46fa352b9a8 Mon Sep 17 00:00:00 2001 From: Alex Demenchuk Date: Thu, 31 May 2018 10:47:05 -0400 Subject: [PATCH 1/3] Add all protocol SUPPORT macros to CFLAGS to allow selective disabling --- extras/ssd1306/component.mk | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/extras/ssd1306/component.mk b/extras/ssd1306/component.mk index f12a292..9e1708a 100644 --- a/extras/ssd1306/component.mk +++ b/extras/ssd1306/component.mk @@ -1,17 +1,19 @@ # Component makefile for extras/ssd1306 # expected anyone using ssd1306 driver includes it as 'ssd1306/ssd1306.h' -INC_DIRS += $(ssd1306_ROOT).. +INC_DIRS += $(ROOT)extras # I2C support is on by default -SSD1306_I2C_SUPPORT ?= 1 +SSD1306_I2C_SUPPORT ?= 1 # SPI4 support is on by default -SSD1306_SPI4_SUPPORT ?= 1 +SSD1306_SPI4_SUPPORT ?= 1 +# SPI3 support is on by default +SSD1306_SPI3_SUPPORT ?= 1 # args for passing into compile rule generation ssd1306_SRC_DIR = $(ssd1306_ROOT) -ssd1306_CFLAGS = -DSSD1306_I2C_SUPPORT=${SSD1306_I2C_SUPPORT} -DSSD1306_SPI4_SUPPORT=${SSD1306_SPI4_SUPPORT} $(CFLAGS) +ssd1306_CFLAGS = -DSSD1306_I2C_SUPPORT=${SSD1306_I2C_SUPPORT} -DSSD1306_SPI4_SUPPORT=${SSD1306_SPI4_SUPPORT} -DSSD1306_SPI3_SUPPORT=${SSD1306_SPI3_SUPPORT} $(CFLAGS) -$(eval $(call component_compile_rules,ssd1306)) +$(eval $(call component_compile_rules,ssd1306)) \ No newline at end of file From c5a78b4c6f6f56fac588307d7eb4541fb4abeb71 Mon Sep 17 00:00:00 2001 From: Alex Demenchuk Date: Thu, 31 May 2018 10:54:56 -0400 Subject: [PATCH 2/3] Clean up device descriptor struct --- extras/ssd1306/ssd1306.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/extras/ssd1306/ssd1306.h b/extras/ssd1306/ssd1306.h index 86abaab..6e0e577 100644 --- a/extras/ssd1306/ssd1306.h +++ b/extras/ssd1306/ssd1306.h @@ -66,15 +66,12 @@ typedef struct { ssd1306_protocol_t protocol; ssd1306_screen_t screen; - union - { #if (SSD1306_I2C_SUPPORT) - i2c_dev_t i2c_dev; //!< I2C devuce descriptor, used by SSD1306_PROTO_I2C + i2c_dev_t i2c_dev; //!< I2C device descriptor, used by SSD1306_PROTO_I2C #endif #if (SSD1306_SPI4_SUPPORT) || (SSD1306_SPI3_SUPPORT) - uint8_t cs_pin; //!< Chip Select GPIO pin, used by SSD1306_PROTO_SPI3, SSD1306_PROTO_SPI4 + uint8_t cs_pin; //!< Chip Select GPIO pin, used by SSD1306_PROTO_SPI3, SSD1306_PROTO_SPI4 #endif - }; #if (SSD1306_SPI4_SUPPORT) uint8_t dc_pin; //!< Data/Command GPIO pin, used by SSD1306_PROTO_SPI4 #endif From ecd060c27b940c1eba22be22a560b12c5e2136bd Mon Sep 17 00:00:00 2001 From: Alex Demenchuk Date: Thu, 31 May 2018 11:00:16 -0400 Subject: [PATCH 3/3] Pack device descriptor enums to shrink the struct --- extras/ssd1306/ssd1306.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extras/ssd1306/ssd1306.h b/extras/ssd1306/ssd1306.h index 6e0e577..0f0fe1a 100644 --- a/extras/ssd1306/ssd1306.h +++ b/extras/ssd1306/ssd1306.h @@ -64,8 +64,10 @@ typedef enum */ typedef struct { - ssd1306_protocol_t protocol; - ssd1306_screen_t screen; + struct { + uint8_t protocol : 4; //!< I/O protocol + uint8_t screen : 4; //!< Screen type + }; #if (SSD1306_I2C_SUPPORT) i2c_dev_t i2c_dev; //!< I2C device descriptor, used by SSD1306_PROTO_I2C #endif