Skip to content
Snippets Groups Projects
Commit 89222978 authored by Keno Garlichs's avatar Keno Garlichs
Browse files

merged colin's lates changes to the dw1000 driver

parent 0c235b04
No related branches found
No related tags found
No related merge requests found
...@@ -3,13 +3,15 @@ ...@@ -3,13 +3,15 @@
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include <stdint.h> #include <stdint.h>
#include "cmsis_os.h" #include "cmsis_os.h"
#include "dw1000_util.h"
#define MAXIMUM_FRAME_LENGTH 127 #define MAXIMUM_FRAME_LENGTH 127
#define FRAME_OVERHEAD sizeof(dw1000_frame_t) - MAXIMUM_FRAME_LENGTH #define FRAME_OVERHEAD sizeof(dw1000_frame_t) - MAXIMUM_FRAME_LENGTH
/** /**
* Defines for channel and prf selection and preamble Code. * Defines for channel and prf selection and Preamble Code.
* Refer to Page 204 in the dw1000 User Manual 2.04 * Refer to Page 204 in the dw1000 User Manual 2.04
*/ */
#define PRF_SHIFT 0 #define PRF_SHIFT 0
...@@ -131,6 +133,7 @@ typedef struct __attribute__((packed)){ ...@@ -131,6 +133,7 @@ typedef struct __attribute__((packed)){
uint8_t rx_timestamp[5]; uint8_t rx_timestamp[5];
uint16_t length; uint16_t length;
uint8_t buffer[MAXIMUM_FRAME_LENGTH]; uint8_t buffer[MAXIMUM_FRAME_LENGTH];
} dw1000_frame_t; } dw1000_frame_t;
/** /**
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#include "dw1000_isr.h" #include "dw1000_isr.h"
#include "deca_regs.h" #include "deca_regs.h"
#include "dw1000_util.h" #include "dw1000_util.h"
#include "stm32f4xx_hal.h"
#ifdef DEBUG #ifdef DEBUG
#include "Trace.h" #include "Trace.h"
#endif #endif
...@@ -256,6 +258,30 @@ int dw1000_sendFrame(uint8_t *frame, uint16_t frame_length) { ...@@ -256,6 +258,30 @@ int dw1000_sendFrame(uint8_t *frame, uint16_t frame_length) {
} }
/*
int dw1000_sendDelayedFrame(uint8_t *payload, uint16_t len, node_time_t tx_time) {
//Write payload to buffer
int ret = dw1000_writeFrameIntoBuffer(0, payload, len);
// Write desired tx time to register
dw1000Hal_writeSubRegister(DX_TIME_ID, 0, (uint8_t *)&tx_time, DX_TIME_LEN);
// Force receiver off
dw1000Util_forceTrxOff();
// Trigger delayed sending by setting TXSTART and TXDLYS
uint8_t temp = (uint8_t) SYS_CTRL_TXSTRT | SYS_CTRL_TXDLYS;
dw1000Hal_writeRegister(SYS_CTRL_ID, &temp, 1);
// Re-enable receiver
dw1000Util_enableRX();
return ret;
}
*/
/** /**
* See header file dw1000.h * See header file dw1000.h
*/ */
...@@ -290,8 +316,10 @@ int dw1000_transmitFrame(uint16_t tx_buffer_offset, uint16_t frame_length) { ...@@ -290,8 +316,10 @@ int dw1000_transmitFrame(uint16_t tx_buffer_offset, uint16_t frame_length) {
/* WITHOUT THE NEXT PART: SECOND TIME NO SENDING POSSIBLE, BUT CAN'T BE FOUND IN ORIGINAL DRIVER */ /* WITHOUT THE NEXT PART: SECOND TIME NO SENDING POSSIBLE, BUT CAN'T BE FOUND IN ORIGINAL DRIVER */
dw1000Util_forceTrxOff(); dw1000Util_forceTrxOff();
uint8_t temp = (uint8_t) SYS_CTRL_TXSTRT; uint8_t temp = (uint8_t) SYS_CTRL_TXSTRT;
dw1000Hal_writeRegister(SYS_CTRL_ID, (uint8_t *) &temp, 1); HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11, GPIO_PIN_SET);
dw1000Hal_writeRegister(SYS_CTRL_ID, (uint8_t *)&temp,1);
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11, GPIO_PIN_RESET);
return DW1000_RET_OK; return DW1000_RET_OK;
} }
...@@ -302,12 +330,22 @@ int dw1000_transmitFrame(uint16_t tx_buffer_offset, uint16_t frame_length) { ...@@ -302,12 +330,22 @@ int dw1000_transmitFrame(uint16_t tx_buffer_offset, uint16_t frame_length) {
void dw1000_receiveFrameFromIsr(dw1000_frame_t *frame) { void dw1000_receiveFrameFromIsr(dw1000_frame_t *frame) {
frame->length = dw1000local.frame_length; frame->length = dw1000local.frame_length;
frame->timestamp_valid = dw1000local.timestamp_valid; frame->timestamp_valid = dw1000local.timestamp_valid;
if (frame->timestamp_valid) { if(frame->timestamp_valid){
dw1000Util_getRxTimestamp((uint8_t *) &frame->rx_timestamp); dw1000Util_getRxTimestamp((uint64_t *)&frame->rx_timestamp);
} }
dw1000Hal_readRegisterFromIsr(RX_BUFFER_ID, frame->buffer, frame->length); //FromIsr important! dw1000Hal_readRegisterFromIsr(RX_BUFFER_ID, frame->buffer, frame->length); //FromIsr important!
} }
int dw1000_setPanAddr(uint16_t addr) {
return dw1000Hal_writeSubRegister(PANADR_ID, PANADR_SHORT_ADDR_OFFSET,
(uint8_t*) &addr, PANADR_SHORT_ADDR_LEN);
}
int dw1000_setPanId(uint16_t addr) {
return dw1000Hal_writeSubRegister(PANADR_ID, PANADR_PAN_ID_OFFSET,
(uint8_t*) &addr, PANADR_PAN_ID_LEN);
}
/** /**
* See header file dw1000.h * See header file dw1000.h
*/ */
...@@ -330,8 +368,8 @@ void dw1000_generateConfig(uint16_t mode, dw1000_config_t *config, uint8_t fast) ...@@ -330,8 +368,8 @@ void dw1000_generateConfig(uint16_t mode, dw1000_config_t *config, uint8_t fast)
//16MHz PRF //16MHz PRF
config->pulse_repetition_frequency = DWT_PRF_16M; config->pulse_repetition_frequency = DWT_PRF_16M;
} }
//Fixme: How to calculate SFD Timeout
config->sfd_timeout = 129; config->sfd_timeout = (129 + 8 - 8);
if (fast == 2) { if (fast == 2) {
trace_printf("Super fast\n"); trace_printf("Super fast\n");
......
...@@ -36,7 +36,9 @@ BaseType_t _handleTx(uint64_t * event, uint64_t * event_clear) { ...@@ -36,7 +36,9 @@ BaseType_t _handleTx(uint64_t * event, uint64_t * event_clear) {
BaseType_t _handleRx(uint64_t * event, uint64_t * event_clear) { BaseType_t _handleRx(uint64_t * event, uint64_t * event_clear) {
BaseType_t higher_priority_task_woken = pdFALSE; BaseType_t higher_priority_task_woken = pdFALSE;
// Get frame length //Fixme: Wann kann ein Overrun auftreten?
// Get get length
uint32_t rx_frame_info; uint32_t rx_frame_info;
dw1000Hal_readRegisterFromIsr(RX_FINFO_ID, (uint8_t *) &rx_frame_info, dw1000Hal_readRegisterFromIsr(RX_FINFO_ID, (uint8_t *) &rx_frame_info,
RX_FINFO_LEN); RX_FINFO_LEN);
...@@ -54,7 +56,8 @@ BaseType_t _handleRx(uint64_t * event, uint64_t * event_clear) { ...@@ -54,7 +56,8 @@ BaseType_t _handleRx(uint64_t * event, uint64_t * event_clear) {
// Trigger callback or notify task // Trigger callback or notify task
if (dw1000local.receive_callback != NULL) { if (dw1000local.receive_callback != NULL) {
higher_priority_task_woken = dw1000local.receive_callback(); higher_priority_task_woken = dw1000local.receive_callback();
} else if (dw1000local.task_handle != NULL) { }
if (dw1000local.task_handle != NULL) {
vTaskNotifyGiveFromISR(dw1000local.task_handle, &higher_priority_task_woken); vTaskNotifyGiveFromISR(dw1000local.task_handle, &higher_priority_task_woken);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment