mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 04:52:59 +01:00
drivers: 64 bit compatibility
Fixed compilation errors for pointer casting.
This commit is contained in:
parent
394cd0e3a8
commit
3feb1a369b
@ -35,7 +35,7 @@
|
|||||||
#define ENABLE_DEBUG 0
|
#define ENABLE_DEBUG 0
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#define MTD_FLASHPAGE_END_ADDR ((uint32_t) CPU_FLASH_BASE + (FLASHPAGE_NUMOF * FLASHPAGE_SIZE))
|
#define MTD_FLASHPAGE_END_ADDR ((uintptr_t) CPU_FLASH_BASE + (FLASHPAGE_NUMOF * FLASHPAGE_SIZE))
|
||||||
|
|
||||||
static int _init(mtd_dev_t *dev)
|
static int _init(mtd_dev_t *dev)
|
||||||
{
|
{
|
||||||
@ -44,11 +44,14 @@ static int _init(mtd_dev_t *dev)
|
|||||||
assert(dev->pages_per_sector * dev->page_size == FLASHPAGE_SIZE);
|
assert(dev->pages_per_sector * dev->page_size == FLASHPAGE_SIZE);
|
||||||
assert(!(super->offset % dev->pages_per_sector));
|
assert(!(super->offset % dev->pages_per_sector));
|
||||||
|
|
||||||
assert((int)flashpage_addr(super->offset / dev->pages_per_sector) >= (int)CPU_FLASH_BASE);
|
/* Use separate variable to avoid '>= 0 is always true' warning */
|
||||||
|
static const uintptr_t cpu_flash_base = CPU_FLASH_BASE;
|
||||||
|
|
||||||
|
assert((uintptr_t)flashpage_addr(super->offset / dev->pages_per_sector) >= cpu_flash_base);
|
||||||
assert((uintptr_t)flashpage_addr(super->offset / dev->pages_per_sector)
|
assert((uintptr_t)flashpage_addr(super->offset / dev->pages_per_sector)
|
||||||
+ dev->pages_per_sector * dev->page_size * dev->sector_count <= MTD_FLASHPAGE_END_ADDR);
|
+ dev->pages_per_sector * dev->page_size * dev->sector_count <= MTD_FLASHPAGE_END_ADDR);
|
||||||
assert((uintptr_t)flashpage_addr(super->offset / dev->pages_per_sector)
|
assert((uintptr_t)flashpage_addr(super->offset / dev->pages_per_sector)
|
||||||
+ dev->pages_per_sector * dev->page_size * dev->sector_count > CPU_FLASH_BASE);
|
+ dev->pages_per_sector * dev->page_size * dev->sector_count > cpu_flash_base);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ struct uart_ctx {
|
|||||||
|
|
||||||
static void _tx_timer_cb(void *arg, int chan)
|
static void _tx_timer_cb(void *arg, int chan)
|
||||||
{
|
{
|
||||||
soft_uart_t uart = (soft_uart_t)arg;
|
soft_uart_t uart = (soft_uart_t)(uintptr_t)arg;
|
||||||
|
|
||||||
const soft_uart_conf_t *cfg = &soft_uart_config[uart];
|
const soft_uart_conf_t *cfg = &soft_uart_config[uart];
|
||||||
struct uart_ctx *ctx = &soft_uart_ctx[uart];
|
struct uart_ctx *ctx = &soft_uart_ctx[uart];
|
||||||
@ -81,7 +81,7 @@ static void _tx_timer_cb(void *arg, int chan)
|
|||||||
|
|
||||||
static void _rx_timer_cb(void *arg, int chan)
|
static void _rx_timer_cb(void *arg, int chan)
|
||||||
{
|
{
|
||||||
soft_uart_t uart = (soft_uart_t)arg;
|
soft_uart_t uart = (soft_uart_t)(uintptr_t)arg;
|
||||||
|
|
||||||
const soft_uart_conf_t *cfg = &soft_uart_config[uart];
|
const soft_uart_conf_t *cfg = &soft_uart_config[uart];
|
||||||
struct uart_ctx *ctx = &soft_uart_ctx[uart];
|
struct uart_ctx *ctx = &soft_uart_ctx[uart];
|
||||||
@ -101,7 +101,7 @@ static void _rx_timer_cb(void *arg, int chan)
|
|||||||
|
|
||||||
static void _rx_gpio_cb(void *arg)
|
static void _rx_gpio_cb(void *arg)
|
||||||
{
|
{
|
||||||
soft_uart_t uart = (soft_uart_t)arg;
|
soft_uart_t uart = (soft_uart_t)(uintptr_t)arg;
|
||||||
|
|
||||||
const soft_uart_conf_t *cfg = &soft_uart_config[uart];
|
const soft_uart_conf_t *cfg = &soft_uart_config[uart];
|
||||||
struct uart_ctx *ctx = &soft_uart_ctx[uart];
|
struct uart_ctx *ctx = &soft_uart_ctx[uart];
|
||||||
@ -166,18 +166,18 @@ int soft_uart_init(soft_uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void
|
|||||||
ctx->state_rx = STATE_RX_IDLE;
|
ctx->state_rx = STATE_RX_IDLE;
|
||||||
|
|
||||||
if (gpio_is_valid(cfg->tx_pin)) {
|
if (gpio_is_valid(cfg->tx_pin)) {
|
||||||
timer_init(cfg->tx_timer, cfg->timer_freq, _tx_timer_cb, (void *)uart);
|
timer_init(cfg->tx_timer, cfg->timer_freq, _tx_timer_cb, (void *)(uintptr_t)uart);
|
||||||
gpio_write(cfg->tx_pin, !(cfg->flags & SOFT_UART_FLAG_INVERT_TX));
|
gpio_write(cfg->tx_pin, !(cfg->flags & SOFT_UART_FLAG_INVERT_TX));
|
||||||
gpio_init(cfg->tx_pin, GPIO_OUT);
|
gpio_init(cfg->tx_pin, GPIO_OUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rx_cb) {
|
if (rx_cb) {
|
||||||
timer_init(cfg->rx_timer, cfg->timer_freq, _rx_timer_cb, (void *)uart);
|
timer_init(cfg->rx_timer, cfg->timer_freq, _rx_timer_cb, (void *)(uintptr_t)uart);
|
||||||
timer_stop(cfg->rx_timer);
|
timer_stop(cfg->rx_timer);
|
||||||
/* timer should fire at the end of the byte */
|
/* timer should fire at the end of the byte */
|
||||||
timer_set_periodic(cfg->rx_timer, 0, ctx->bit_time * (BITS_DATA(ctx) + BITS_PARITY(ctx) + 1),
|
timer_set_periodic(cfg->rx_timer, 0, ctx->bit_time * (BITS_DATA(ctx) + BITS_PARITY(ctx) + 1),
|
||||||
TIM_FLAG_RESET_ON_MATCH | TIM_FLAG_RESET_ON_SET);
|
TIM_FLAG_RESET_ON_MATCH | TIM_FLAG_RESET_ON_SET);
|
||||||
gpio_init_int(cfg->rx_pin, GPIO_IN, GPIO_BOTH, _rx_gpio_cb, (void*) uart);
|
gpio_init_int(cfg->rx_pin, GPIO_IN, GPIO_BOTH, _rx_gpio_cb, (void*)(uintptr_t)uart);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user