Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DecaWave by
Diff: DW1000/DW1000.cpp
- Revision:
- 11:c87d37db2c6f
- Parent:
- 10:d077bb12d259
- Child:
- 12:985aa9843c3c
--- a/DW1000/DW1000.cpp Fri Nov 21 14:33:23 2014 +0000 +++ b/DW1000/DW1000.cpp Sun Nov 23 11:20:46 2014 +0000 @@ -5,6 +5,12 @@ spi.format(8,0); // Setup the spi for standard 8 bit data and SPI-Mode 0 (GPIO5, GPIO6 open circuit or ground on DW1000) spi.frequency(1000000); // with a 1MHz clock rate (worked up to 49MHz in our Test) + uint16_t ldeload[] = {0x0301, 0x8000, 0x0200}; + writeRegister(DW1000_PMSC, 0, (uint8_t*)&ldeload[0], 2); // initialise LDELOAD User Manual p22 + writeRegister(DW1000_OTP_IF, 0x06, (uint8_t*)&ldeload[1], 2); + wait_us(150); + writeRegister(DW1000_PMSC, 0, (uint8_t*)&ldeload[2], 2); + irq.rise(this, &DW1000::ISR); // attach Interrupt handler to rising edge resetRX(); } @@ -50,13 +56,16 @@ return receive; } -void DW1000::sendFrame(uint8_t* message, int length) { +void DW1000::sendFrame(uint8_t* message, uint16_t length) { writeRegister(DW1000_TX_BUFFER, 0, message, length); // fill buffer - uint16_t framelength = length+2; // put length of frame including 2 CRC Bytes - writeRegister(DW1000_TX_FCTRL, 0, (uint8_t*)&framelength, 1); // TODO: make that bigger frames than 256 can be sent + uint8_t backup = readRegister8(DW1000_TX_FCTRL, 1); + length += 2; // put length of frame including 2 CRC Bytes + length = ((backup & 0xFC) << 8) | (length & 0x03FF); - //writeRegister8(DW1000_SYS_CTRL, 0, 0x02); // trigger sending process by setting the TXSTRT bit + writeRegister(DW1000_TX_FCTRL, 0, (uint8_t*)&length, 2); // TODO: make that bigger frames than 256 can be sent + + writeRegister8(DW1000_SYS_CTRL, 0, 0x02); // trigger sending process by setting the TXSTRT bit } void DW1000::receiveFrame() {