/*
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
Copyright (C) 2016..2019 Thomas Schöpping et al.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
/**
* @file
* @brief Structures and constant for the NUCLEO-F103RB module.
*
* @addtogroup NUCLEO-F103RB_module
* @{
*/
#ifndef AMIROOS_MODULE_H
#define AMIROOS_MODULE_H
#include
/*===========================================================================*/
/**
* @name Module specific functions
* @{
*/
/*===========================================================================*/
#ifdef AMIROLLD_CFG_DW1000
#ifdef __cplusplus
extern "C" {
#endif
apalGpioState_t port_CheckEXT_IRQ(void) ;
void dw1000_spi_init(void);
void process_deca_irq(void);
#ifdef __cplusplus
}
#endif
#endif /* AMIROLLD_CFG_DW1000 */
/** @} */
/*===========================================================================*/
/**
* @name ChibiOS/HAL configuration
* @{
*/
/*===========================================================================*/
/**
* @brief Serial driver of the programmer interface.
*/
#define MODULE_HAL_PROGIF SD2
/**
* @brief Configuration for the programmer serial interface driver.
*/
extern SerialConfig moduleHalProgIfConfig;
/**
* @brief Real-Time Clock driver.
*/
#define MODULE_HAL_RTC RTCD1
#ifdef AMIROLLD_CFG_DW1000
/**
* @brief SPI interface driver for the motion sensors (gyroscope and accelerometer).
*/
#define MODULE_HAL_SPI_UWB SPID2
/**
* @brief Configuration for the SPI interface driver to communicate with the LED driver.
*/
extern SPIConfig moduleHalSpiUwbHsConfig;
/**
* @brief Configuration for the SPI interface driver to communicate with the wireless transceiver.
*/
extern SPIConfig moduleHalSpiUwbLsConfig;
#endif /* AMIROLLD_CFG_DW1000 */
/** @} */
/*===========================================================================*/
/**
* @name GPIO definitions
* @{
*/
/*===========================================================================*/
/**
* @brief LED output signal GPIO.
*/
extern ROMCONST apalControlGpio_t moduleGpioLed;
#ifdef AMIROLLD_CFG_DW1000
/**
* @brief DW1000 reset output signal
* @note the reset pin should be drived as low by MCU to activate.
* Then, put back the reset pin as input to MCU (tri-state float on the air
* is not supported in AMiRo)
*/
extern ROMCONST apalControlGpio_t moduleGpioDw1000Reset;
/**
* @brief DW1000 interrupt IRQn input signal.
*/
extern ROMCONST apalControlGpio_t moduleGpioDw1000Irqn;
/**
* @brief DW1000 SPI chip select output signal.
*/
extern ROMCONST apalControlGpio_t moduleGpioSpiChipSelect ;
#endif /* AMIROLLD_CFG_DW1000 */
/**
* @brief User button input signal.
*/
extern ROMCONST apalControlGpio_t moduleGpioUserButton;
/** @} */
/*===========================================================================*/
/**
* @name AMiRo-OS core configurations
* @{
*/
/*===========================================================================*/
/**
* @brief Event flag to be call dwt_isr() interrupt.
*/
#define MODULE_OS_IOEVENTFLAGS_DW1000_IRQn AOS_IOEVENT_FLAG(GPIOB_ARD_D6)
/**
* @brief Event flag to be set on a USER_BUTTON interrupt.
*/
#define MODULE_OS_IOEVENTFLAGS_USERBUTTON AOS_IOEVENT_FLAG(GPIOC_BUTTON)
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
/**
* @brief Shell prompt text.
*/
extern ROMCONST char* moduleShellPrompt;
#endif
/**
* @brief Interrupt initialization macro.
* @note SSSP related interrupt signals are already initialized in 'aos_system.c'.
*/
#define MODULE_INIT_INTERRUPTS() { \
/* user button */ \
palSetPadCallback(moduleGpioUserButton.gpio->port, moduleGpioUserButton.gpio->pad, _intCallback, &moduleGpioUserButton.gpio->pad); \
palEnablePadEvent(moduleGpioUserButton.gpio->port, moduleGpioUserButton.gpio->pad, APAL2CH_EDGE(moduleGpioUserButton.meta.edge)); \
MODULE_INIT_INTERRUPTS_DW1000(); \
}
#ifdef AMIROLLD_CFG_DW1000
#define MODULE_INIT_INTERRUPTS_DW1000() { \
palSetPadCallback(moduleGpioDw1000Irqn.gpio->port, moduleGpioDw1000Irqn.gpio->pad, _intCallback, &moduleGpioDw1000Irqn.gpio->pad); \
palEnablePadEvent(moduleGpioDw1000Irqn.gpio->port, moduleGpioDw1000Irqn.gpio->pad, APAL2CH_EDGE(moduleGpioDw1000Irqn.meta.edge)); \
}
#else
#define MODULE_INIT_INTERRUPTS_DW1000() { \
}
#endif /* AMIROLLD_CFG_DW1000 */
/**
* @brief Unit test initialization hook.
*/
#define MODULE_INIT_TESTS() { \
/* add unit-test shell commands */ \
MODULE_INIT_TESTS_DW1000(); \
}
#ifdef AMIROLLD_CFG_DW1000
#define MODULE_INIT_TESTS_DW1000() { \
aosShellAddCommand(&aos.shell, &moduleUtAlldDw1000.shellcmd); \
}
#else
#define MODULE_INIT_TESTS_DW1000() { \
}
#endif /* AMIROLLD_CFG_DW1000 */
/**
* @brief Periphery communication interfaces initialization hook.
*/
#define MODULE_INIT_PERIPHERY_COMM() { \
/* serial driver */ \
sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \
MODULE_INIT_PERIPHERY_COMM_DW1000(); \
}
#ifdef AMIROLLD_CFG_DW1000
#define MODULE_INIT_PERIPHERY_COMM_DW1000() { \
/* SPI init */ \
dw1000_spi_init(); \
spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUwbLsConfig); \
}
#else
#define MODULE_INIT_PERIPHERY_COMM_DW1000() { \
}
#endif /* AMIROLLD_CFG_DW1000 */
/**
* @brief Periphery communication interface deinitialization hook.
*/
#define MODULE_SHUTDOWN_PERIPHERY_COMM() { \
MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000(); \
}
#ifdef AMIROLLD_CFG_DW1000
#define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() { \
/* SPI */ \
spiStop(&MODULE_HAL_SPI_UWB); \
}
#else
#define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() { \
}
#endif /* AMIROLLD_CFG_DW1000 */
/**
* @brief HOOK to call process_deca_irq() func when the dw1000 interrupt pin is activated.
*/
#define MODULE_MAIN_LOOP_IO_EVENT(eventflags) { \
if (eventflags & MODULE_OS_IOEVENTFLAGS_USERBUTTON) { \
apalControlGpioState_t buttonstate; \
apalControlGpioGet(&moduleGpioUserButton, &buttonstate); \
apalControlGpioSet(&moduleGpioLed, buttonstate); \
} \
MODULE_MAIN_LOOP_IO_EVENT_DW1000(); \
}
#ifdef AMIROLLD_CFG_DW1000
#define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
if(eventflags & MODULE_OS_IOEVENTFLAGS_DW1000_IRQn) { \
/*apalGpioToggle(moduleGpioLedGreen.gpio); // just for debug */ \
process_deca_irq(); \
} \
}
#else
#define MODULE_MAIN_LOOP_IO_EVENT_DW1000() { \
}
#endif /* AMIROLLD_CFG_DW1000 */
/** @} */
/*===========================================================================*/
/**
* @name Startup Shutdown Synchronization Protocol (SSSP)
* @{
*/
/*===========================================================================*/
/** @} */
/*===========================================================================*/
/**
* @name Low-level drivers
* @{
*/
/*===========================================================================*/
#ifdef AMIROLLD_CFG_DW1000
#include
extern DW1000Driver moduleLldDw1000;
#endif /* AMIROLLD_CFG_DW1000 */
/** @} */
/*===========================================================================*/
/**
* @name Unit tests (UT)
* @{
*/
/*===========================================================================*/
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
#if defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1)
#include
/**
* @brief DW1000 unit test object.
*/
extern aos_unittest_t moduleUtAlldDw1000;
#endif /* defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1) */
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
/** @} */
#endif /* AMIROOS_MODULE_H */
/** @} */