| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- /*! ----------------------------------------------------------------------------
- * @file instance_calib.c
- * @brief DecaWave application level configuration and calibration functions
- *
- * @attention
- *
- * Copyright 2015 (c) DecaWave Ltd, Dublin, Ireland.
- *
- * All rights reserved.
- *
- * @author DecaWave
- */
- #include "compiler.h"
- #include "deca_device_api.h"
- #include "instance.h"
- #include "port.h"
- // -------------------------------------------------------------------------------------------------------------------
- //The table below specifies the default TX spectrum configuration parameters... this has been tuned for DW EVK hardware units
- //the table is set for smart power - see below in the instance_config function how this is used when not using smart power
- const tx_struct txSpectrumConfig[8] =
- {
- //Channel 0 ----- this is just a place holder so the next array element is channel 1
- {
- 0x0, //0
- {
- 0x0, //0
- 0x0 //0
- }
- },
- //Channel 1
- {
- 0xc9, //PG_DELAY
- {
- 0x15355575, //16M prf power
- 0x07274767 //64M prf power
- }
- },
- //Channel 2
- {
- 0xc2, //PG_DELAY
- {
- 0x15355575, //16M prf power
- 0x07274767 //64M prf power
- }
- },
- //Channel 3
- {
- 0xc5, //PG_DELAY
- {
- 0x0f2f4f6f, //16M prf power
- 0x2b4b6b8b //64M prf power
- }
- },
- //Channel 4
- {
- 0x95, //PG_DELAY
- {
- 0x1f1f3f5f, //16M prf power
- 0x3a5a7a9a //64M prf power
- }
- },
- //Channel 5
- {
- 0xc0, //PG_DELAY
- {
- 0x0E082848, //16M prf power
- 0x25456585 //64M prf power
- }
- },
- //Channel 6 ----- this is just a place holder so the next array element is channel 7
- {
- 0x0, //0
- {
- 0x0, //0
- 0x0 //0
- }
- },
- //Channel 7
- {
- 0x93, //PG_DELAY
- {
- 0x32527292, //16M prf power
- 0x5171B1d1 //64M prf power
- }
- }
- };
- const tx_struct txManualSpectrumConfig[8] =
- {
- //Channel 0 ----- this is just a place holder so the next array element is channel 1
- {
- 0x0, //0
- {
- 0,
- 0
- }
- },
- //Channel 1
- {
- 0xc9, //PG_DELAY
- {
- 0x75757575,
- 0x67676767
- }
- },
- //Channel 2
- {
- 0xc2, //PG_DELAY
- {
- 0x75757575,
- 0x67676767
- }
- },
- //Channel 3
- {
- 0xc5, //PG_DELAY
- {
- 0x6F6F6F6F,
- 0x8B8B8B8B
- }
- },
- //Channel 4
- {
- 0x95, //PG_DELAY
- {
- 0x5F5F5F5F,
- 0x9A9A9A9A
- }
- },
- //Channel 5
- {
- 0xc0, //PG_DELAY
- {
- 0x48484848,
- 0x85858585
- }
- },
- //Channel 6 ----- this is just a place holder so the next array element is channel 7
- {
- 0x0, //0
- {
- 0x0, //0
- 0x0 //0
- }
- },
- //Channel 7
- {
- 0x93, //PG_DELAY
- {
- 0x92929292,
- 0xD1D1D1D1
- }
- }
- };
- const tx_struct maxSpectrumConfig[8] =
- {
- //Channel 0 ----- this is just a place holder so the next array element is channel 1
- {
- 0x0, //0
- {
- 0,
- 0
- }
- },
- //Channel 1
- {
- 0xc9, //PG_DELAY
- {
- 0x751f1f75,
- 0x671f1f67
- }
- },
- //Channel 2
- {
- 0xc2, //PG_DELAY
- {
- 0x751f1f75, //16M prf power
- 0x671f1f67 //64M prf power
- }
- },
- //Channel 3
- {
- 0xc5, //PG_DELAY
- {
- 0x6F1F1F6F,
- 0x8B1f1f8B
- }
- },
- //Channel 4
- {
- 0x95, //PG_DELAY
- {
- 0x5F1F1F5F,
- 0x9A1f1f9A
- }
- },
- //Channel 5
- {
- 0xc0, //PG_DELAY
- {
- 0x481f1f48,
- 0x851f1f85
- }
- },
- //Channel 6 ----- this is just a place holder so the next array element is channel 7
- {
- 0x0, //0
- {
- 0x0, //0
- 0x0 //0
- }
- },
- //Channel 7
- {
- 0x93, //PG_DELAY
- {
- 0x921f1f92,
- 0xD11f1fD1
- }
- }
- };
- //these are default antenna delays for EVB1000, these can be used if there is no calibration data in the DW1000,
- //or instead of the calibration data
- const uint16_t rfDelays[2] = {
- (uint16_t) ((DWT_PRF_16M_RFDLY/ 2.0) * 1e-9 / DWT_TIME_UNITS),//PRF 16
- (uint16_t) ((DWT_PRF_64M_RFDLY/ 2.0) * 1e-9 / DWT_TIME_UNITS)
- };
- //these are default TREK Tag/Anchor antenna delays
- const uint16_t rfDelaysTREK[2] = {
- (uint16_t) ((514.83f/ 2.0) * 1e-9 / DWT_TIME_UNITS),//channel 2
- (uint16_t) ((514.65f/ 2.0) * 1e-9 / DWT_TIME_UNITS) //channel 5
- };
- int instStartTXtest(int framePeriod)
- {
- //define some test data for the tx buffer
- uint8_t msg[127] = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the l";
- //NOTE: SPI frequency must be < 3MHz
- SPI_ConfigFastRate(SPI_BAUDRATEPRESCALER_32); //max SPI before PLLs configured is ~4M
- // the value here 0x1000 gives a period of 32.82
- //this is setting 0x1000 as frame period (125MHz clock cycles) (time from Tx en - to next - Tx en)
- dwt_configcontinuousframemode(framePeriod);
- dwt_writetxdata(127, (uint8_t *) msg, 0) ;//Clear tx buffer
- dwt_writetxfctrl(127, 0);
- //to start the first frame - set TXSTRT
- dwt_starttx(DWT_START_TX_IMMEDIATE);
- //measure the power
- //Spectrum Analyser set:
- //FREQ to be channel default e.g. 3.9936 GHz for channel 2
- //SPAN to 1GHz
- //SWEEP TIME 1s
- //RBW and VBW 1MHz
- //measure channel power
- return DWT_SUCCESS ;
- }
- // -------------------------------------------------------------------------------------------------------------------
- //extern instance_data_t instance_data[NUM_INST] ;
- /* ==========================================================
- Notes:
- Previously code handled multiple instances in a single console application
- Now have changed it to do a single instance only. With minimal code changes...(i.e. kept [instance] index but it is always 0.
- Windows application should call instance_init() once and then in the "main loop" call instance_run().
- */
|