1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

pkg/uwb-dw1000: use mynewt-core pkg

This commit is contained in:
Francisco Molina 2021-07-05 14:30:34 +02:00
parent 0cdc5826fd
commit 7b2debcbd8
No known key found for this signature in database
GPG Key ID: 3E94EAC3DBDEEDA8
12 changed files with 3 additions and 416 deletions

View File

@ -1,10 +1,11 @@
PKG_NAME=uwb-dw1000
PKG_URL=https://github.com/Decawave/uwb-dw1000/
PKG_VERSION=6eaa85e6d429450d19a6ddeb2de05303016c0dd2
PKG_VERSION=d44078a96349b7a40e9c2393ea83ca4c2d53ab92
PKG_LICENSE=Apache-2.0
include $(RIOTBASE)/pkg/pkg.mk
CFLAGS += -Wno-enum-compare
CFLAGS += -Wno-address-of-packed-member
CFLAGS += -Wno-enum-conversion
CFLAGS += -Wno-maybe-uninitialized

View File

@ -1,13 +1,10 @@
USEMODULE += uwb-dw1000_hal
DEFAULT_MODULE += auto_init_uwb-dw1000
USEMODULE += xtimer
USEPKG += mynewt-core
FEATURES_REQUIRED += periph_gpio_irq
FEATURES_REQUIRED += periph_spi
# Some of the pkg operation would overflow on 16bit
FEATURES_REQUIRED += arch_32bit
# LLVM ARM shows issues with missing definitions for stdatomic
TOOLCHAINS_BLACKLIST += llvm

View File

@ -1,197 +0,0 @@
/*
* Copyright (C) 2020 Inria
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup pkg_uwb_dw1000
* @{
*
* @file
* @brief GPIO abstraction layer RIOT adaption
*
* @author Francisco Molina <francois-xavier.molina@inria.fr>
* @}
*/
#ifndef HAL_HAL_GPIO_H
#define HAL_HAL_GPIO_H
#include "periph/gpio.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Map hal_gpio_pull_t enum types to gpio_mode_t enum types
*/
enum {
/** Pull-up/down not enabled */
HAL_GPIO_PULL_NONE = GPIO_IN,
/** Pull-up enabled */
HAL_GPIO_PULL_UP = GPIO_IN_PU,
/** Pull-down enabled */
HAL_GPIO_PULL_DOWN = GPIO_IN_PD
};
/**
* @brief hal_gpio_pull type
*/
typedef gpio_mode_t hal_gpio_pull_t;
/**
* @brief Map hal_gpio_irq_trig_t enum types to gpio_flank_t enum types
*/
enum {
#ifdef GPIO_NONE
HAL_GPIO_TRIG_NONE = GPIO_NONE,
#endif
/** IRQ occurs on rising edge */
HAL_GPIO_TRIG_RISING = GPIO_RISING,
/** IRQ occurs on falling edge */
HAL_GPIO_TRIG_FALLING = GPIO_FALLING,
/** IRQ occurs on either edge */
HAL_GPIO_TRIG_BOTH = GPIO_BOTH,
/** IRQ occurs when line is low */
#ifdef GPIO_LOW
HAL_GPIO_TRIG_LOW = GPIO_LOW,
#endif
/** IRQ occurs when line is high */
#ifdef GPIO_HIGH
HAL_GPIO_TRIG_HIGH = GPIO_HIGH
#endif
};
/**
* @brief hal_gpio_irq_trig type
*/
typedef gpio_flank_t hal_gpio_irq_trig_t;
/**
* @brief Function proto for GPIO irq handler functions
*/
typedef gpio_cb_t hal_gpio_irq_handler_t;
/**
* Initializes the specified pin as an input
*
* @param pin Pin number to set as input
* @param pull pull type
*
* @return int 0: no error; -1 otherwise.
*/
static inline int hal_gpio_init_in(gpio_t pin, hal_gpio_pull_t pull)
{
return gpio_init(pin, pull);
}
/**
* Initialize the specified pin as an output, setting the pin to the specified
* value.
*
* @param pin Pin number to set as output
* @param val Value to set pin
*
* @return int 0: no error; -1 otherwise.
*/
static inline int hal_gpio_init_out(gpio_t pin, int val)
{
int res = gpio_init(pin, GPIO_OUT);
gpio_write(pin, val);
return res;
}
/**
* Write a value (either high or low) to the specified pin.
*
* @param pin Pin to set
* @param val Value to set pin (0:low 1:high)
*/
static inline void hal_gpio_write(gpio_t pin, int val)
{
gpio_write(pin, val);
}
/**
* Reads the specified pin.
*
* @param pin Pin number to read
*
* @return int 0: low, 1: high
*/
static inline int hal_gpio_read(gpio_t pin)
{
return gpio_read(pin);
}
/**
* Toggles the specified pin
*
* @param pin Pin number to toggle
*
* @return current gpio state int 0: low, 1: high
*/
static inline int hal_gpio_toggle(gpio_t pin)
{
gpio_toggle(pin);
return gpio_read(pin);
}
/**
* Initialize a given pin to trigger a GPIO IRQ callback.
*
* @param pin The pin to trigger GPIO interrupt on
* @param handler The handler function to call
* @param arg The argument to provide to the IRQ handler
* @param trig The trigger mode (e.g. rising, falling)
* @param pull The mode of the pin (e.g. pullup, pulldown)
*
* @return 0 on success, non-zero error code on failure.
*/
static inline int hal_gpio_irq_init(gpio_t pin,
hal_gpio_irq_handler_t handler,
void *arg,
hal_gpio_irq_trig_t trig,
hal_gpio_pull_t pull)
{
return gpio_init_int(pin, pull, trig, handler, arg);
}
/**
* Release a pin from being configured to trigger IRQ on state change.
*
* @param pin The pin to release
*/
static inline void hal_gpio_irq_release(gpio_t pin)
{
/* can't release the interrupt so ar least disable it */
gpio_irq_disable(pin);
}
/**
* Enable IRQs on the passed pin
*
* @param pin The pin to enable IRQs on
*/
static inline void hal_gpio_irq_enable(gpio_t pin)
{
gpio_irq_enable(pin);
}
/**
* Disable IRQs on the passed pin
*
* @param pin The pin to disable IRQs on
*/
static inline void hal_gpio_irq_disable(gpio_t pin)
{
gpio_irq_disable(pin);
}
#ifdef __cplusplus
}
#endif
#endif /* HAL_HAL_GPIO_H */

View File

@ -1,169 +0,0 @@
/*
* Copyright (C) 2020 Inria
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup pkg_uwb_dw1000
* @{
*
* @file
* @brief SPI abstraction layer RIOT adaption
*
* @author Francisco Molina <francois-xavier.molina@inria.fr>
* @}
*/
#ifndef HAL_HAL_SPI_H
#define HAL_HAL_SPI_H
#include "periph/spi.h"
#ifdef __cplusplus
extern "C" {
#endif
/** SPI mode 0 */
#define HAL_SPI_MODE0 (SPI_MODE_0)
/** SPI mode 1 */
#define HAL_SPI_MODE1 (SPI_MODE_1)
/** SPI mode 2 */
#define HAL_SPI_MODE2 (SPI_MODE_2)
/** SPI mode 3 */
#define HAL_SPI_MODE3 (SPI_MODE_3)
/**
* @brief Prototype for tx/rx callback
*/
typedef void (*hal_spi_txrx_cb)(void *arg, int len);
/**
* @brief since one spi device can control multiple devices, some configuration
* can be changed on the fly from the hal
*/
struct hal_spi_settings {
/** Data mode of SPI driver, defined by HAL_SPI_MODEn */
spi_mode_t data_mode;
/** Baudrate in kHz */
spi_clk_t baudrate;
};
/**
* @brief Configure the spi. Must be called after the spi is initialized (after
* hal_spi_init is called) and when the spi is disabled (user must call
* hal_spi_disable if the spi has been enabled through hal_spi_enable prior
* to calling this function). Can also be used to reconfigure an initialized
* SPI (assuming it is disabled as described previously).
*
* @param spi_num The number of the SPI to configure.
* @param psettings The settings to configure this SPI with
*
* @return int 0 on success, non-zero error code on failure.
*/
int hal_spi_config(int spi_num, struct hal_spi_settings *psettings);
/**
* @brief Sets the txrx callback (executed at interrupt context) when the
* buffer is transferred by the master or the slave using the non-blocking API.
* Cannot be called when the spi is enabled. This callback will also be called
* when chip select is de-asserted on the slave.
*
* NOTE: This callback is only used for the non-blocking interface and must
* be called prior to using the non-blocking API.
*
* @param spi_num SPI interface on which to set callback
* @param txrx_cb Callback function
* @param arg Argument to be passed to callback function
*
* @return int 0 on success, non-zero error code on failure.
*/
int hal_spi_set_txrx_cb(int spi_num, hal_spi_txrx_cb txrx_cb, void *arg);
/**
* @brief Enables the SPI. This does not start a transmit or receive operation;
* it is used for power mgmt. Cannot be called when a SPI transfer is in
* progress.
*
* @param spi_num
*
* @return int 0 on success, non-zero error code on failure.
*/
int hal_spi_enable(int spi_num);
/**
* @brief Disables the SPI. Used for power mgmt. It will halt any current SPI transfers
* in progress.
*
* @param spi_num
*
* @return int 0 on success, non-zero error code on failure.
*/
int hal_spi_disable(int spi_num);
/**
* @brief Blocking interface to send a buffer and store the received values from the
* slave. The transmit and receive buffers are either arrays of 8-bit (uint8_t)
* values or 16-bit values depending on whether the spi is configured for 8 bit
* data or more than 8 bits per value. The 'cnt' parameter is the number of
* 8-bit or 16-bit values. Thus, if 'cnt' is 10, txbuf/rxbuf would point to an
* array of size 10 (in bytes) if the SPI is using 8-bit data; otherwise
* txbuf/rxbuf would point to an array of size 20 bytes (ten, uint16_t values).
*
* NOTE: these buffers are in the native endian-ness of the platform.
*
* MASTER: master sends all the values in the buffer and stores the
* stores the values in the receive buffer if rxbuf is not NULL.
* The txbuf parameter cannot be NULL.
* SLAVE: cannot be called for a slave; returns -1
*
* @param spi_num SPI interface to use
* @param txbuf Pointer to buffer where values to transmit are stored.
* @param rxbuf Pointer to buffer to store values received from peer.
* @param cnt Number of 8-bit or 16-bit values to be transferred.
*
* @return int 0 on success, non-zero error code on failure.
*/
int hal_spi_txrx(int spi_num, void *txbuf, void *rxbuf, int cnt);
/**
* @brief Non-blocking interface to send a buffer and store received values. Can be
* used for both master and slave SPI types. The user must configure the
* callback (using hal_spi_set_txrx_cb); the txrx callback is executed at
* interrupt context when the buffer is sent.
*
* The transmit and receive buffers are either arrays of 8-bit (uint8_t)
* values or 16-bit values depending on whether the spi is configured for 8 bit
* data or more than 8 bits per value. The 'cnt' parameter is the number of
* 8-bit or 16-bit values. Thus, if 'cnt' is 10, txbuf/rxbuf would point to an
* array of size 10 (in bytes) if the SPI is using 8-bit data; otherwise
* txbuf/rxbuf would point to an array of size 20 bytes (ten, uint16_t values).
*
* NOTE: these buffers are in the native endian-ness of the platform.
*
* MASTER: master sends all the values in the buffer and stores the
* stores the values in the receive buffer if rxbuf is not NULL.
* The txbuf parameter cannot be NULL
* SLAVE: Slave "preloads" the data to be sent to the master (values
* stored in txbuf) and places received data from master in rxbuf
* (if not NULL). The txrx callback occurs when len values are
* transferred or master de-asserts chip select. If txbuf is NULL,
* the slave transfers its default byte. Both rxbuf and txbuf cannot
* be NULL.
*
* @param spi_num SPI interface to use
* @param txbuf Pointer to buffer where values to transmit are stored.
* @param rxbuf Pointer to buffer to store values received from peer.
* @param cnt Number of 8-bit or 16-bit values to be transferred.
*
* @return int 0 on success, non-zero error code on failure.
*/
int hal_spi_txrx_noblock(int spi_num, void *txbuf, void *rxbuf, int cnt);
#ifdef __cplusplus
}
#endif
#endif /* HAL_HAL_SPI_H */

View File

@ -1,45 +0,0 @@
/*
* Copyright (C) 2020 Inria
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup pkg_uwb_dw1000
* @{
*
* @file
* @brief Timer abstraction layer RIOT adaption
*
* @author Francisco Molina <francois-xavier.molina@inria.fr>
* @}
*/
#ifndef HAL_HAL_TIMER_H
#define HAL_HAL_TIMER_H
#include "xtimer.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief HAL timer callback
*/
typedef xtimer_callback_t hal_timer_cb;
/**
* @brief The HAL timer structure.
*/
struct hal_timer {
xtimer_t timer; /**< the timer */
};
#ifdef __cplusplus
}
#endif
#endif /* HAL_HAL_TIMER_H */