Browse Source

pkg/u8g2: adapted patch files for SPI changes

pr/spi.typo
Hauke Petersen 6 years ago
parent
commit
3afbf13cfc
  1. 6
      pkg/u8g2/patches/0001-u8g2-add-riot-os-makefiles.patch
  2. 44
      pkg/u8g2/patches/0002-u8g2-add-riot-os-interface.patch
  3. 89
      pkg/u8g2/patches/0003-u8g2-adapted-RIOT-interface-to-SPI-changes.patch

6
pkg/u8g2/patches/0001-u8g2-add-riot-os-makefiles.patch

@ -1,7 +1,7 @@
From e9c737b4cbfcc460c0274428ece41d6654c82f90 Mon Sep 17 00:00:00 2001
From a2a2cfb145902cb36cbe82bdaf68d97686bb9724 Mon Sep 17 00:00:00 2001
From: Bas Stottelaar <basstottelaar@gmail.com>
Date: Tue, 24 May 2016 20:17:39 +0200
Subject: [PATCH 1/2] u8g2: add riot-os makefiles.
Subject: [PATCH 1/3] u8g2: add riot-os makefiles.
---
Makefile | 22 ++++++++++++++++++++++
@ -72,5 +72,5 @@ index 0000000..32e7913
+
+include $(RIOTBASE)/Makefile.base
--
2.8.1
1.9.1

44
pkg/u8g2/patches/0002-u8g2-add-riot-os-interface.patch

@ -1,7 +1,7 @@
From 68fcbaf8eb8b2e2c1abe319fb74f75f0a75c330e Mon Sep 17 00:00:00 2001
From 5acedd785fd31b43171c6855ecd5323bfd31c9e2 Mon Sep 17 00:00:00 2001
From: Bas Stottelaar <basstottelaar@gmail.com>
Date: Wed, 22 Jun 2016 18:04:31 +0200
Subject: [PATCH 2/2] u8g2: add riot-os interface.
Subject: [PATCH 2/3] u8g2: add riot-os interface.
---
csrc/u8g2.h | 4 +-
@ -17,21 +17,21 @@ index b65c9f1..bd8c485 100644
@@ -362,6 +362,9 @@ void u8g2_ClearDisplay(u8g2_t *u8g2);
#define u8g2_SetMenuDownPin(u8g2, val) u8x8_SetMenuDownPin(u8g2_GetU8x8(u8g2), (val))
#endif
+#define u8g2_SetPins(u8x8,pins,pins_enabled) u8x8_SetPins(u8g2_GetU8x8(&u8g2), pins, pins_enabled)
+#define u8g2_SetDevice(u8x8,device) u8x8_SetDevice(u8g2_GetU8x8(&u8g2), device)
+
/*==========================================*/
/* u8g2_setup.c */
@@ -1663,4 +1666,3 @@ extern const uint8_t u8g2_font_px437wyse700b_mn[] U8G2_FONT_SECTION("u8g2_font_p
#endif
-
diff --git a/csrc/u8g2_riotos.c b/csrc/u8g2_riotos.c
new file mode 100644
index 0000000..7106e07
index 0000000..e0c042c
--- /dev/null
+++ b/csrc/u8g2_riotos.c
@@ -0,0 +1,163 @@
@ -205,27 +205,27 @@ index dd74869..7c45b6a 100644
@@ -107,6 +107,8 @@
#include <stdint.h>
#include <stddef.h>
+#include "periph/gpio.h"
+
#if defined(__GNUC__) && defined(__AVR__)
#include <avr/pgmspace.h>
#endif
#endif
@@ -154,9 +156,9 @@ extern "C" {
# define u8x8_pgm_read(adr) (*(const uint8_t *)(adr))
# define u8x8_pgm_read(adr) (*(const uint8_t *)(adr))
#endif
-#ifdef ARDUINO
-#define U8X8_USE_PINS
-#endif
+//#ifdef ARDUINO
+//#define U8X8_USE_PINS
+//#endif
/*==========================================*/
/* U8X8 typedefs and data structures */
@@ -316,6 +318,10 @@ struct u8x8_struct
#ifdef U8X8_USE_PINS
#ifdef U8X8_USE_PINS
uint8_t pins[U8X8_PIN_CNT]; /* defines a pinlist: Mainly a list of pins for the Arduino Envionment, use U8X8_PIN_xxx to access */
#endif
+
@ -233,27 +233,27 @@ index dd74869..7c45b6a 100644
+ uint32_t pins_enabled;
+ uint32_t dev;
};
#define u8x8_GetCols(u8x8) ((u8x8)->display_info->tile_width)
@@ -337,6 +343,8 @@ struct u8x8_struct
#define u8x8_SetMenuDownPin(u8x8, val) u8x8_SetPin((u8x8),U8X8_PIN_MENU_DOWN,(val))
#endif
+#define u8x8_SetPins(u8x8,pins,pins_enabled) {(u8x8)->pins = (pins); (u8x8)->pins_enabled = (pins_enabled);}
+#define u8x8_SetDevice(u8x8,device) ((u8x8)->dev = device)
/*==========================================*/
@@ -818,6 +826,9 @@ extern const uint8_t u8x8_font_pxplustandynewtv_u[] U8X8_FONT_SECTION("u8x8_font
/* end font list */
+extern uint8_t u8x8_byte_riotos_hw_spi(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr);
+extern uint8_t u8x8_gpio_and_delay_riotos(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr);
+extern uint8_t u8x8_byte_riotos_hw_i2c(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr);
#ifdef __cplusplus
}
--
2.8.1
--
1.9.1

89
pkg/u8g2/patches/0003-u8g2-adapted-RIOT-interface-to-SPI-changes.patch

@ -0,0 +1,89 @@
From 51897f66e18e291c3f3d528a0678eb195341d18d Mon Sep 17 00:00:00 2001
From: Hauke Petersen <hauke.petersen@fu-berlin.de>
Date: Wed, 25 Jan 2017 12:29:36 +0100
Subject: [PATCH 3/3] u8g2: adapted RIOT interface to SPI changes
---
csrc/u8g2_riotos.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/csrc/u8g2_riotos.c b/csrc/u8g2_riotos.c
index e0c042c..bd06ccb 100644
--- a/csrc/u8g2_riotos.c
+++ b/csrc/u8g2_riotos.c
@@ -8,29 +8,29 @@
#include <stdio.h>
-#if SPI_NUMOF
-static spi_speed_t u8x8_pulse_width_to_spi_speed(uint32_t pulse_width)
+#ifdef SPI_NUMOF
+static spi_clk_t u8x8_pulse_width_to_spi_speed(uint32_t pulse_width)
{
uint32_t cycle_time = 2 * pulse_width;
if (cycle_time < 100) {
- return SPI_SPEED_10MHZ;
+ return SPI_CLK_10MHZ;
} else if (cycle_time < 200) {
- return SPI_SPEED_5MHZ;
+ return SPI_CLK_5MHZ;
} else if (cycle_time < 1000) {
- return SPI_SPEED_1MHZ;
+ return SPI_CLK_1MHZ;
} else if (cycle_time < 2500) {
- return SPI_SPEED_400KHZ;
+ return SPI_CLK_400KHZ;
}
- return SPI_SPEED_100KHZ;
+ return SPI_CLK_100KHZ;
}
#endif /* SPI_NUMOF */
-#if SPI_NUMOF
-static spi_speed_t u8x8_spi_mode_to_spi_conf(uint32_t spi_mode)
+#ifdef SPI_NUMOF
+static spi_mode_t u8x8_spi_mode_to_spi_conf(uint32_t spi_mode)
{
- return (spi_speed_t) spi_mode;
+ return (spi_mode_t) spi_mode;
}
#endif /* SPI_NUMOF */
@@ -90,25 +90,26 @@ uint8_t u8x8_gpio_and_delay_riotos(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, v
return 1;
}
-#if SPI_NUMOF
+#ifdef SPI_NUMOF
uint8_t u8x8_byte_riotos_hw_spi(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
spi_t dev = (spi_t) u8g2->dev;
switch (msg) {
case U8X8_MSG_BYTE_SEND:
- spi_transfer_bytes(dev, (char *) arg_ptr, NULL, arg_int);
+ spi_transfer_bytes(dev, GPIO_UNDEF, true,
+ arg_ptr, NULL, (size_t)arg_int);
break;
case U8X8_MSG_BYTE_INIT:
- spi_init_master(dev,
- u8x8_spi_mode_to_spi_conf(u8g2->display_info->spi_mode),
- u8x8_pulse_width_to_spi_speed(u8g2->display_info->sck_pulse_width_ns));
+ spi_init_pins(dev);
break;
case U8X8_MSG_BYTE_SET_DC:
u8x8_gpio_SetDC(u8g2, arg_int);
break;
case U8X8_MSG_BYTE_START_TRANSFER:
- spi_acquire(dev);
+ spi_acquire(dev, GPIO_UNDEF,
+ u8x8_spi_mode_to_spi_conf(u8g2->display_info->spi_mode),
+ u8x8_pulse_width_to_spi_speed(u8g2->display_info->sck_pulse_width_ns));
u8x8_gpio_SetCS(u8g2, u8g2->display_info->chip_enable_level);
u8g2->gpio_and_delay_cb(u8g2, U8X8_MSG_DELAY_NANO, u8g2->display_info->post_chip_enable_wait_ns, NULL);
--
1.9.1
Loading…
Cancel
Save