Revision 4172c48d
| include/DW1000/v1/alld_dw1000_v1.h | ||
|---|---|---|
| 1798 | 1798 |
void port_EnableEXT_IRQ(void); |
| 1799 | 1799 |
void port_DisableEXT_IRQ(void); |
| 1800 | 1800 |
decaIrqStatus_t port_GetEXT_IRQStatus(void); |
| 1801 |
//ITStatus port_GetEXT_IRQStatus(void); |
|
| 1802 | 1801 |
|
| 1803 | 1802 |
void port_set_dw1000_slowrate(void); |
| 1804 | 1803 |
void port_set_dw1000_fastrate(void); |
| include/DW1000/v1/deca_instance_v1.h | ||
|---|---|---|
| 474 | 474 |
int instance_init(DW1000Driver* drv); //TODO |
| 475 | 475 |
|
| 476 | 476 |
// configure the instance and DW1000 device |
| 477 |
void instance_config(instanceConfig_t *config, sfConfig_t *sfconfig) ; |
|
| 477 |
void instance_config(instanceConfig_t *config, sfConfig_t *sfconfig, DW1000Driver* drv) ;
|
|
| 478 | 478 |
|
| 479 | 479 |
// configure the MAC address |
| 480 | 480 |
void instancesetaddresses(uint16_t address) ; |
| source/DW1000/v1/alld_dw1000_v1.c | ||
|---|---|---|
| 29 | 29 |
*/ |
| 30 | 30 |
|
| 31 | 31 |
#include <alld_DW1000.h> |
| 32 |
|
|
| 33 | 32 |
#if (defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1)) || defined(__DOXYGEN__) |
| 34 | 33 |
|
| 35 | 34 |
#include <v1/alld_dw1000_regs_v1.h> |
| 36 |
|
|
| 37 | 35 |
#include <aos_thread.h> |
| 38 | 36 |
#include <assert.h> |
| 39 | 37 |
#include <string.h> |
| ... | ... | |
| 1014 | 1012 |
#define XTRIM_ADDRESS (0x1E) |
| 1015 | 1013 |
|
| 1016 | 1014 |
int dwt_initialise(const uint16_t config, DW1000Driver* drv) |
| 1017 |
//int dwt_initialise(const uint16_t config) // TODO: |
|
| 1018 | 1015 |
{
|
| 1019 | 1016 |
uint16_t otp_addr = 0; |
| 1020 | 1017 |
uint32_t ldo_tune = 0; |
| ... | ... | |
| 4441 | 4438 |
memcpy(buffer, headerBuffer, headerLength); //copy data to buffer |
| 4442 | 4439 |
memcpy(&buffer[headerLength], bodyBuffer, bodyLength); //copy data to buffer |
| 4443 | 4440 |
|
| 4444 |
apalSPITransmit(&MODULE_HAL_SPI_UWB,
|
|
| 4441 |
apalSPITransmit(pdw1000local->driver->spid,
|
|
| 4445 | 4442 |
buffer, |
| 4446 | 4443 |
bodyLength + headerLength); // send header and data |
| 4447 | 4444 |
|
| ... | ... | |
| 4464 | 4461 |
uint8_t *readBuffer) |
| 4465 | 4462 |
{
|
| 4466 | 4463 |
|
| 4467 |
apalSPITransmitAndReceive(&MODULE_HAL_SPI_UWB, // TODO: "pdw1000local->driver->spid" fails two spi configs
|
|
| 4464 |
apalSPITransmitAndReceive(pdw1000local->driver->spid,
|
|
| 4468 | 4465 |
headerBuffer, |
| 4469 | 4466 |
readBuffer, |
| 4470 | 4467 |
headerLength, |
| ... | ... | |
| 4533 | 4530 |
* |
| 4534 | 4531 |
*/ |
| 4535 | 4532 |
|
| 4533 |
/*! @brief sleep or idle the thread in millisecond */ |
|
| 4536 | 4534 |
void deca_sleep(unsigned int time_ms) |
| 4537 | 4535 |
{
|
| 4538 | 4536 |
aosThdMSleep(time_ms); |
| 4539 | 4537 |
} |
| 4540 | 4538 |
|
| 4539 |
/*! @brief sleep or idle the thread in millisecond */ |
|
| 4541 | 4540 |
void Sleep(unsigned int time_ms) |
| 4542 | 4541 |
{
|
| 4543 | 4542 |
aosThdMSleep(time_ms); |
| ... | ... | |
| 4548 | 4547 |
return; |
| 4549 | 4548 |
} |
| 4550 | 4549 |
|
| 4550 |
/*! @brief Get the current system tick time */ |
|
| 4551 | 4551 |
uint32_t portGetTickCnt(){
|
| 4552 | 4552 |
return chVTGetSystemTimeX(); |
| 4553 | 4553 |
} |
| ... | ... | |
| 4557 | 4557 |
//} |
| 4558 | 4558 |
|
| 4559 | 4559 |
|
| 4560 |
/*! @brief Disable the interrupt handler */ |
|
| 4560 | 4561 |
void port_DisableEXT_IRQ(void){
|
| 4561 | 4562 |
nvicDisableVector(DW1000_EXTI_IRQn); |
| 4562 | 4563 |
|
| 4563 | 4564 |
} |
| 4564 | 4565 |
|
| 4566 |
/*! @brief Enable the interrupt handler */ |
|
| 4565 | 4567 |
void port_EnableEXT_IRQ(void){
|
| 4566 | 4568 |
nvicEnableVector(DW1000_EXTI_IRQn, STM32_IRQ_EXTI10_15_PRIORITY); |
| 4567 | 4569 |
} |
| 4568 | 4570 |
|
| 4569 |
|
|
| 4571 |
/*! @brief Get the current status of the interrupt handler */ |
|
| 4570 | 4572 |
decaIrqStatus_t port_GetEXT_IRQStatus(void){
|
| 4571 | 4573 |
decaIrqStatus_t bitstatus = RESET; |
| 4572 | 4574 |
|
| 4573 | 4575 |
if(NVIC_GetActive(DW1000_EXTI_IRQn)|| NVIC_GetPendingIRQ(DW1000_EXTI_IRQn)){
|
| 4574 |
// if(NVIC_GetPendingIRQ(EXTI15_10_IRQn)){ //if the interrupt is pending (background )
|
|
| 4575 | 4576 |
bitstatus = SET; //Interrupt is active or panding |
| 4576 | 4577 |
} |
| 4577 | 4578 |
else {
|
| source/DW1000/v1/deca_instance_common_v1.c | ||
|---|---|---|
| 432 | 432 |
// function to initialise instance structures |
| 433 | 433 |
// |
| 434 | 434 |
// Returns 0 on success and -1 on error |
| 435 |
//int instance_init(void){ // TODO
|
|
| 436 | 435 |
int instance_init(DW1000Driver* drv){
|
| 437 | 436 |
int instance = 0 ; |
| 438 | 437 |
int i; |
| ... | ... | |
| 513 | 512 |
// |
| 514 | 513 |
// function to allow application configuration be passed into instance and affect underlying device operation |
| 515 | 514 |
// |
| 516 |
void instance_config(instanceConfig_t *config, sfConfig_t *sfConfig){
|
|
| 515 |
void instance_config(instanceConfig_t *config, sfConfig_t *sfConfig, DW1000Driver* drv){
|
|
| 517 | 516 |
int instance = 0 ; |
| 518 | 517 |
uint32_t power = 0; |
| 519 | 518 |
uint8_t otprev ; |
| ... | ... | |
| 598 | 597 |
|
| 599 | 598 |
if(config->preambleLen == DWT_PLEN_64) { //if preamble length is 64
|
| 600 | 599 |
//reduce SPI to < 3MHz |
| 601 |
setHighSpeed_SPI(FALSE); //TODO: workaround using flag to change speed
|
|
| 600 |
setHighSpeed_SPI(FALSE, drv);
|
|
| 602 | 601 |
dwt_loadopsettabfromotp(0); |
| 603 | 602 |
//increase SPI to max |
| 604 |
setHighSpeed_SPI(TRUE); //TODO: workaround using flag to change speed
|
|
| 603 |
setHighSpeed_SPI(TRUE, drv);
|
|
| 605 | 604 |
} |
| 606 | 605 |
|
| 607 | 606 |
instancesettagsleepdelay(sfConfig->pollSleepDly); //set the Tag sleep time |
| ... | ... | |
| 1647 | 1646 |
void instance_close(void){
|
| 1648 | 1647 |
//wake up device from low power mode |
| 1649 | 1648 |
//NOTE - in the ARM code just drop chip select for 200us |
| 1650 |
port_SPIx_clear_chip_select(); //CS low
|
|
| 1649 |
clear_SPI_chip_select(); //CS low
|
|
| 1651 | 1650 |
Sleep(1); //200 us to wake up then waits 5ms for DW1000 XTAL to stabilise |
| 1652 |
port_SPIx_set_chip_select(); //CS high
|
|
| 1651 |
set_SPI_chip_select(); //CS high
|
|
| 1653 | 1652 |
Sleep(5); |
| 1654 | 1653 |
dwt_entersleepaftertx(0); // clear the "enter deep sleep after tx" bit |
| 1655 | 1654 |
dwt_setinterrupt(0xFFFFFFFF, 0); //don't allow any interrupts |
Also available in: Unified diff