Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • garlichs/dw1000_driver_freertos
  • cwulf/dw1000_driver_freertos
  • cm-projects/dw1000_driver_freertos
3 results
Show changes
Commits on Source (6)
......@@ -98,7 +98,7 @@ extern "C" {
**/
#define SYS_TIME_ID 0x06 /* System Time Counter (40-bit) */
#define SYS_TIME_LEN (5) /* Note 40 bit register */
#define SYS_TIME_MASK 0x000000FFFFFFFFFFULL
/****************************************************************************//**
* @brief Bit definitions for register 0x07
......
......@@ -148,7 +148,6 @@ int dw1000_writeFrameIntoBuffer(uint16_t txBufferOffset, uint8_t *payload, uint1
int dw1000_transmitFrame(uint16_t txBufferOffset, uint16_t len);
int dw_1000_receiveFrameFromIsr(uint8_t * buffer, uint32_t length);
void dw1000_extiCallback(void);
void vTaskGlobalTimeIncrement(void *pvParameters);
void dw1000_generateConfig(uint16_t mode, dwt_config_t *config);
......
......@@ -4,6 +4,8 @@
#include <stdint.h>
#include <string.h>
#include "deca_regs.h"
#include "task.h"
#include "time_sync.h"
//#define DOUBLE_BUFFER
//DECA:Defines for enable_clocks function
......@@ -86,16 +88,16 @@ extern const uint32_t digital_bb_config[NUM_PRF][NUM_PACS];
extern const uint16_t lde_replicaCoeff[PCODES];
#define DEBUG
void dw1000Util_enableclocks(int clocks);
void dw1000Util_enableRX();
uint32_t dw1000Util_otpread(uint32_t address);
void dw1000Util_forceTrxOff(void);
void dw1000Util_reset(void);
void dw1000Util_resetRxOnly(void);
void dw1000Util_getRxTimestamp(dw1000_global_time_t *timeBuffer);
void dw1000Util_getRxTimestamp(uint64_t *rx_time);
void dw1000Util_printGlobalTimestamp(dw1000_global_time_t *time);
void dw1000Util_getSysTime(uint8_t *nt);
void lltoa(int64_t val, char *dest_buf, uint8_t base);
#ifdef DEBUG
void hexdump(uint8_t * buffer, uint8_t len);
......
......@@ -385,7 +385,7 @@ int dw1000_writeFrameIntoBuffer(uint16_t txBufferOffset, uint8_t *payload, uint1
int dw1000_transmitFrame(uint16_t txBufferOffset, uint16_t len){
//Set length and offset
uint32_t reg32 = dw1000local.txFCTRL | len+2 | (txBufferOffset << 22);
uint32_t reg32 = (dw1000local.txFCTRL) | (len + 2) | (txBufferOffset << 22);
dw1000Hal_writeSubRegister(TX_FCTRL_ID, 0, (uint8_t *) &reg32, TX_FCTRL_LEN-1);
/* WITHOUT THE NEXT PART: SECOND TIME NO SENDING POSSIBLE, BUT CAN'T BE FOUND IN ORIGINAL DRIVER */
dw1000Util_forceTrxOff();
......@@ -396,17 +396,6 @@ int dw1000_transmitFrame(uint16_t txBufferOffset, uint16_t len){
return DW1000_RET_OK;
}
void vTaskGlobalTimeIncrement(void *pvParameters) {
TickType_t xNextWakeTime;
xNextWakeTime = xTaskGetTickCount();
for(ever) {
// Task is delayed until radio timestamp approximately overflows
vTaskDelayUntil(&xNextWakeTime, GLOBAL_TIME_TICK_MS / portTICK_PERIOD_MS);
global_time++;
}
vTaskDelete( NULL);
}
void dw1000_extiCallback(void) {
dw1000Isr_handleInterrupt();
}
......
......@@ -192,6 +192,7 @@ int dw1000Hal_readRegister(uint8_t regID, uint8_t *dest, uint16_t len) {
while (hspi->State != HAL_SPI_STATE_READY) {
}
xSemaphoreGive(spiSema);
} else {
ret = HAL_LOCKED;
//trace_printf("nb");
......
......@@ -273,18 +273,42 @@ uint32_t dw1000Util_otpread(uint32_t address)
return (ret_data);
}
void dw1000Util_getRxTimestamp(dw1000_global_time_t *time_buffer){
uint8_t buf[5] = {0};
uint64_t radio_rx_time = 0;
void dw1000Util_getRxTimestamp(uint64_t *radio_rx_time){
// Read rx timestamp from radio
dw1000Hal_readSubRegisterFromIsr(RX_TIME_ID, RX_TIME_RX_STAMP_OFFSET, buf, RX_TIME_RX_STAMP_LEN);
radio_rx_time = ((uint64_t) buf[4]) << 32 |
((uint64_t) buf[3]) << 24 |
((uint64_t) buf[2]) << 16 |
((uint64_t) buf[1]) << 8 |
((uint64_t) buf[0]) << 0;
dw1000Hal_readSubRegisterFromIsr(RX_TIME_ID, RX_TIME_RX_STAMP_OFFSET, (uint8_t *)radio_rx_time, RX_TIME_RX_STAMP_LEN);
}
void lltoa(int64_t val, char *dest_buf, uint8_t base) {
uint8_t sign = 0;
char buf[64] = {0};
uint32_t i = 0;
if(val == 0) {
dest_buf[0] = '0';
dest_buf[1] = '\0';
return;
}
else if(val < 0) {
sign = 1;
val = -val;
}
for(i = 62; val && i ; --i, val /= base) {
buf[i] = "0123456789abcdef"[val % base];
}
if(sign) {
buf[i--] = '-';
}
memcpy(dest_buf, &buf[i + 1], 64);
}
void dw1000Util_printGlobalTimestamp(dw1000_global_time_t *time) {
/*
// multiply by 16 to get picoseconds (actually ~15.65 is right)
radio_rx_time <<= 4;
......@@ -303,20 +327,7 @@ void dw1000Util_getRxTimestamp(dw1000_global_time_t *time_buffer){
// Store new timestamp to be able to detect asynchronous overflows
dw1000local.last_rx_time.ms = ms_buf;
}
void lltoa(uint64_t val, char *dest_buf, uint8_t base) {
char buf[64] = {0};
uint32_t i = 62;
for(; val && i ; --i, val /= base) {
buf[i] = "0123456789abcdef"[val % base];
}
memcpy(dest_buf, &buf[i + 1], 64);
}
void dw1000Util_printGlobalTimestamp(dw1000_global_time_t *time) {
*/
char ms_buf[64] = {0};
char subms_buf[64] = {0};
......@@ -404,6 +415,16 @@ void dw1000Util_resetRxOnly(void) {
(uint8_t*) &subreg, PMSC_CTRL0_LEN);
}
void dw1000Util_getSysTime(uint8_t *nt) {
uint8_t rev_buf[SYS_TIME_LEN];
dw1000Hal_readRegister(SYS_TIME_ID, rev_buf, SYS_TIME_LEN);
for(uint8_t i = 0; i < SYS_TIME_LEN; i++) {
nt[i] = rev_buf[i];
//nt[i] = rev_buf[(SYS_TIME_LEN -1) - i];
}
}
#ifdef DEBUG
void hexdump(uint8_t * buffer, uint8_t len){
......