| | |
| | | #define VBAT_ADDRESS (0x08) |
| | | #define VTEMP_ADDRESS (0x09) |
| | | #define XTRIM_ADDRESS (0x1E) |
| | | |
| | | u8 module_power; |
| | | int dwt_initialise(uint16_t config) |
| | | { |
| | | u32 power_temp,power_input; |
| | | uint8_t plllockdetect = EC_CTRL_PLLLCK; |
| | | uint16_t otp_addr = 0; |
| | | uint32_t ldo_tune = 0; |
| | |
| | | } |
| | | |
| | | _dwt_enableclocks(FORCE_SYS_XTI); // NOTE: set system clock to XTI - this is necessary to make sure the values read by _dwt_otpread are reliable |
| | | |
| | | dwt_write32bitreg(TX_POWER_ID, 0x1f1f1f1f); |
| | | if(module_power>67) |
| | | {module_power=67;} |
| | | if(module_power<0) |
| | | {module_power=0;} |
| | | if(module_power>36) |
| | | { |
| | | power_temp =(module_power-36); |
| | | }else{ |
| | | power_temp = ((6-(module_power/6))<<5)|(module_power%6); |
| | | } |
| | | power_input= power_temp<<24|power_temp<<16|power_temp<<8|power_temp; |
| | | dwt_write32bitreg(TX_POWER_ID, power_input); |
| | | // Configure the CPLL lock detect |
| | | dwt_writetodevice(EXT_SYNC_ID, EC_CTRL_OFFSET, 1, &plllockdetect); |
| | | |
| | |
| | | |
| | | // Read system register / store local copy |
| | | dw1000local.sysCFGreg = dwt_read32bitreg(SYS_CFG_ID) ; // Read sysconfig register |
| | | |
| | | { |
| | | uint32_t reg; |
| | | reg = dwt_read32bitreg(GPIO_CTRL_ID); |
| | | reg |= 0x00014000; |
| | | reg |= 0x00050000; |
| | | dwt_write32bitreg(GPIO_CTRL_ID,reg); |
| | | dwt_write16bitoffsetreg(PMSC_ID,PMSC_TXFINESEQ_OFFSET ,PMSC_TXFINESEQ_DIS_MASK); |
| | | |
| | | } |
| | | return DWT_SUCCESS ; |
| | | |
| | | } // end dwt_initialise() |