| | |
| | | #include "deca_sleep.h" |
| | | #include "lcd.h" |
| | | #include "port.h" |
| | | #include "Rcc_Nvic_Systick.h" |
| | | #include "Usart.h" |
| | | #include "Spi.h" |
| | | #include "dw_driver.h |
| | | #include "led.h" |
| | | |
| | | /* Example application name and version to display on LCD screen. */ |
| | | #define APP_NAME "DS TWR INIT v1.1" |
| | |
| | | uint8_t TAG_ID, ANCHOR_ID, jumptime = 0; |
| | | uint32_t rec_dist, hex_dist; |
| | | uint16_t check; |
| | | |
| | | void Device_Init(void) |
| | | { |
| | | Rcc_Init(); |
| | | Nvic_Init(); |
| | | Systick_Init(); |
| | | Led_Init(); |
| | | DW_GPIO_Init(); |
| | | Usart_Init(); |
| | | Spi_Init(); |
| | | |
| | | GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); |
| | | |
| | | } |
| | | |
| | | int main(void) |
| | | { |
| | | RCC_ClocksTypeDef RCC_Clocks; /* Start with board specific hardware init. */ |
| | | peripherals_init();//åå§åå¤è®¾ |
| | | RCC_GetClocksFreq(&RCC_Clocks); |
| | | |
| | | Device_Init(); |
| | | // RCC_ClocksTypeDef RCC_Clocks; /* Start with board specific hardware init. */ |
| | | // peripherals_init();//åå§åå¤è®¾ |
| | | // RCC_GetClocksFreq(&RCC_Clocks); |
| | | /* Display application name on LCD. */ |
| | | // lcd_display_str(APP_NAME); |
| | | |
| | | /* Reset and initialise DW1000. |
| | | * For initialisation, DW1000 clocks must be temporarily set to crystal speed. After initialisation SPI rate can be increased for optimum |
| | | * performance. */ |
| | | reset_DW1000();//éå¯DW1000 /* Target specific drive of RSTn line into DW1000 low for a period. */ |
| | | spi_set_rate_low();//éä½SPIé¢ç |
| | | Reset_DW1000();//éå¯DW1000 /* Target specific drive of RSTn line into DW1000 low for a period. */ |
| | | // spi_set_rate_low();//éä½SPIé¢ç |
| | | dwt_initialise(DWT_LOADUCODE);//åå§åDW1000 |
| | | spi_set_rate_high();//åå¤SPIé¢ç |
| | | // spi_set_rate_high();//åå¤SPIé¢ç |
| | | Spi_ChangePrescaler(SPIx_PRESCALER_FAST); //è®¾ç½®ä¸ºå¿«éæ¨¡å¼ |
| | | |
| | | /* Configure DW1000. See NOTE 6 below. */ |
| | | dwt_configure(&config);//é
ç½®DW1000 |