/*! ---------------------------------------------------------------------------- * @file port.h * @brief HW specific definitions and functions for portability * * @attention * * Copyright 2015 (c) DecaWave Ltd, Dublin, Ireland. * * All rights reserved. * * @author DecaWave */ #ifndef PORT_H_ #define PORT_H_ #ifdef __cplusplus extern "C" { #endif #include "compiler.h" #include "deca_types.h" #include "bsp.h" #include "utils.h" //#define USB_SUPPORT /*****************************************************************************************************************//* * To enable LDC update (i.e. printing/outputting range result to LCD set this to 1 * NOTE: it takes 3.1 ms to output/write to LCD so this is limiting when performing fast ranging * (e.g. 6.8 with short slot times - wake up could be 2.25 ms, ranging exchange 1.65 ms and the LCD update 3.1 ms) */ #define LCD_UPDATE_ON (0) /*****************************************************************************************************************//* * To enable Direct Memory Access for SPI set this option to (1) * This option will increase speed of spi transactions but it will use an extra RAM memory buffer */ #define DMA_ENABLE (0) /*****************************************************************************************************************/ #define led_on(x) BSP_LED_On(x) #define led_off(x) BSP_LED_Off(x) #define portGetTickCnt() HAL_GetTick() /** * **/ #if (DMA_ENABLE == 1) #define writetospi writetospi_dma #define readfromspi readfromspi_dma void dma_init(void); #else extern int32_t writetospi_serial( uint16_t headerLength, const uint8_t *headerBuffer, uint32_t bodylength, const uint8_t *bodyBuffer ); extern int32_t readfromspi_serial( uint16_t headerLength, const uint8_t *headerBuffer, uint32_t readlength, uint8_t *readBuffer ); #define writetospi writetospi_serial #define readfromspi readfromspi_serial #endif #define port_SPIx_busy_sending() __HAL_SPI_GET_FLAG(&DWM_SpiHandle, SPI_FLAG_TXE)==RESET #define port_SPIx_no_data() __HAL_SPI_GET_FLAG(&DWM_SpiHandle, SPI_FLAG_RXNE)==RESET #define port_SPIx_send_data(x) SPI_I2S_SendData(DWM_SpiHandle,(x)) #define port_SPIx_receive_data() SPI_I2S_ReceiveData(DWM_SpiHandle) #define port_SPIx_disable() __HAL_SPI_DISABLE(&DWM_SpiHandle) #define port_SPIx_enable() __HAL_SPI_ENABLE(&DWM_SpiHandle) //#define port_SPIx_set_chip_select() HAL_GPIO_WritePin(DWM_SPIx_CS_GPIO_PORT, BSP_SPIx_CS_PIN, GPIO_PIN_SET) //#define port_SPIx_clear_chip_select() HAL_GPIO_WritePin(BSP_SPIx_CS_GPIO_PORT, BSP_SPIx_CS_PIN, GPIO_PIN_RESET) #define port_SPIx_CS_set() HAL_GPIO_WritePin(DWM_SPIx_CS_GPIO_PORT, DWM_SPIx_CS_PIN, GPIO_PIN_SET) #define port_SPIx_CS_clear() HAL_GPIO_WritePin(DWM_SPIx_CS_GPIO_PORT, DWM_SPIx_CS_PIN, GPIO_PIN_RESET) #define port_SPIx_RST_set() HAL_GPIO_WritePin(DWM_RST_PORT, DWM_RST_PIN, GPIO_PIN_SET) #define port_SPIx_RST_clear() HAL_GPIO_WritePin(DWM_RST_PORT, DWM_RST_PIN, GPIO_PIN_RESET) #define port_SPIx_WAKEUP_set() HAL_GPIO_WritePin(DWM_WAKEUP_PORT, DWM_WAKEUP_PIN, GPIO_PIN_SET) #define port_SPIx_WAKEUP_clear() HAL_GPIO_WritePin(DWM_WAKEUP_PORT, DWM_WAKEUP_PIN, GPIO_PIN_RESET) //#define port_GetEXT_IRQStatus() HAL_NVIC_GetPendingIRQ(DWM_IRQ_EXTI) #define port_GetEXT_IRQStatus() __HAL_GPIO_EXTI_GET_IT(DWM_IRQ_EXTI) #define port_DisableEXT_IRQ() HAL_NVIC_DisableIRQ(DWM_IRQ_EXTI) #define port_EnableEXT_IRQ() HAL_NVIC_EnableIRQ(DWM_IRQ_EXTI) //#define port_CheckEXT_IRQ() HAL_GPIO_ReadPin(DWM_IRQ_PORT, DWM_IRQ_PIN) #define port_CheckEXT_IRQ() __HAL_GPIO_EXTI_GET_IT(DWM_IRQ_EXTI) #define Sleep(x) Delay_ms(x) ITStatus EXTI_GetITEnStatus(uint32_t x); void __weak process_dwRSTn_irq(void); void __weak process_deca_irq(void); void SPI_ChangeRate(uint16_t scalingfactor); void SPI_ConfigFastRate(uint16_t scalingfactor); void reset_DW1000(void); void setup_DW1000RSTnIRQ(int enable); void setup_DW1000RSTnPin(uint8_t input); void write_DW1000RstnPin(uint8_t pin); uint32_t read_DW1000RstnPin(void); #ifdef __cplusplus } #endif #endif /* PORT_H_ */