From 51897f66e18e291c3f3d528a0678eb195341d18d Mon Sep 17 00:00:00 2001 From: Hauke Petersen 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 -#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