.gitignore | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
源码/核心板/Src/OnChipDevices/RTC.c | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
源码/核心板/Src/OnChipDevices/RTC.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
源码/核心板/Src/OnChipDevices/Rcc_Nvic_Systick.c | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
源码/核心板/Src/OnChipDevices/Rcc_Nvic_Systick.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
源码/核心板/Src/OnChipDevices/Spi.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
源码/核心板/Src/application/dw_app.c | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
源码/核心板/Src/application/dw_app.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
源码/核心板/Src/main.c | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
源码/核心板/Src/stm32f10x_it.c | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
源码/核心板/Src/stm32f10x_it.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
.gitignore
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,15 @@ *.txt *.crf *.d *.o *.ini *.dbgconf *.lst *.map *.iex *.dep *.axf *.htm *.lnp *.sct Ô´Âë/ºËÐİå/Src/OnChipDevices/RTC.c
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,68 @@ #include "RTC.h" void RTC_SET_ALARM(u32 sec) { //DEBUG_COM_STREAM("-??-",NULL); RTC_SetAlarm(RTC_GetCounter()+sec); //DEBUG_COM_STREAM("-??1-",NULL); RTC_WaitForLastTask(); //DEBUG_COM_STREAM("-??2-",NULL); RTC_ITConfig(RTC_FLAG_ALR,ENABLE); } void RTC_Configuration(void) { EXTI_InitTypeDef EXTI_InitStructure; /* Enable PWR and BKP clocks */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); /* Allow access to BKP Domain */ PWR_BackupAccessCmd(ENABLE); /* Reset Backup Domain */ //BKP_DeInit(); RCC_LSICmd(ENABLE); /* Enable LSE */ //RCC_LSEConfig(RCC_LSE_ON); /* Wait till LSE is ready */ while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET){} /* Select LSE as RTC Clock Source */ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); /* Enable RTC Clock */ RCC_RTCCLKCmd(ENABLE); /* Wait for RTC registers synchronization */ RTC_WaitForSynchro(); /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); /* Enable the RTC Second */ //RTC_ITConfig(RTC_IT_SEC, ENABLE); /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); RTC_ITConfig(RTC_IT_ALR,ENABLE); //?? RTC ??? RTC_WaitForLastTask(); /* Set RTC prescaler: set RTC period to 1sec */ RTC_SetPrescaler(40000); /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */ /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); RTC_SET_ALARM(1); //RTCå¤é¨ä¸æä½¿è½ EXTI_InitStructure.EXTI_Line = EXTI_Line17; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); } Ô´Âë/ºËÐİå/Src/OnChipDevices/RTC.h
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,10 @@ #ifndef __RTC_H_ #define __RTC_H_ #include "stm32f10x.h" void RTC_Configuration(void); #endif Ô´Âë/ºËÐİå/Src/OnChipDevices/Rcc_Nvic_Systick.c
@@ -53,6 +53,13 @@ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd =ENABLE; NVIC_Init(&NVIC_InitStructure); } Ô´Âë/ºËÐİå/Src/OnChipDevices/Rcc_Nvic_Systick.h
@@ -11,5 +11,5 @@ int Systick_Init(void); void delay_us(uint32_t nTimer); void delay_ms(uint32_t nTimer); void RTC_Configuration(void); #endif Ô´Âë/ºËÐİå/Src/OnChipDevices/Spi.h
@@ -5,7 +5,7 @@ #include "stm32f10x.h" #define SPIx_PRESCALER_SLOW SPI_BaudRatePrescaler_32 #define SPIx_PRESCALER_FAST SPI_BaudRatePrescaler_8 #define SPIx_PRESCALER_FAST SPI_BaudRatePrescaler_4 #define SPIx SPI1 #define SPIx_GPIO GPIOA Ô´Âë/ºËÐİå/Src/application/dw_app.c
@@ -49,13 +49,13 @@ #define POLL_TX_TO_RESP_RX_DLY_UUS 150 /* This is the delay from Frame RX timestamp to TX reply timestamp used for calculating/setting the DW1000's delayed TX function. This includes the * frame length of approximately 2.66 ms with above configuration. */ #define RESP_RX_TO_FINAL_TX_DLY_UUS 4100 #define RESP_RX_TO_FINAL_TX_DLY_UUS 1500 /* Receive response timeout. See NOTE 5 below. */ #define RESP_RX_TIMEOUT_UUS 14700 #define RESP_RX_TIMEOUT_UUS 2700 #define POLL_RX_TO_RESP_TX_DLY_UUS 3600 #define POLL_RX_TO_RESP_TX_DLY_UUS 420 /* This is the delay from the end of the frame transmission to the enable of the receiver, as programmed for the DW1000's wait for response feature. */ #define RESP_TX_TO_FINAL_RX_DLY_UUS 500 #define RESP_TX_TO_FINAL_RX_DLY_UUS 200 /* Receive final timeout. See NOTE 5 below. */ #define FINAL_RX_TIMEOUT_UUS 4300 @@ -78,18 +78,17 @@ /*------------------------------------ Variables ------------------------------------------*/ /* Default communication configuration. We use here EVK1000's default mode (mode 3). */ static dwt_config_t config = { 2, /* Channel number. */ DWT_PRF_64M, /* Pulse repetition frequency. */ DWT_PLEN_1024, /* Preamble length. */ DWT_PAC32, /* Preamble acquisition chunk size. Used in RX only. */ 9, /* TX preamble code. Used in TX only. */ 9, /* RX preamble code. Used in RX only. */ 1, /* Use non-standard SFD (Boolean) */ DWT_BR_110K, /* Data rate. */ DWT_PHRMODE_STD, /* PHY header mode. */ (1025 + 64 - 32) /* SFD timeout (preamble length + 1 + SFD length - PAC size). Used in RX only. */ static dwt_config_t config = { 5, /* Channel number. */ DWT_PRF_64M, /* Pulse repetition frequency. */ DWT_PLEN_128, /* Preamble length. */ DWT_PAC8, /* Preamble acquisition chunk size. Used in RX only. */ 9, /* TX preamble code. Used in TX only. */ 9, /* RX preamble code. Used in RX only. */ 0, /* Use non-standard SFD (Boolean) */ DWT_BR_6M8, /* Data rate. */ DWT_PHRMODE_STD, /* PHY header mode. */ (129 + 8 - 8) /* SFD timeout (preamble length + 1 + SFD length - PAC size). Used in RX only. */ }; /* Frames used in the ranging process. See NOTE 2 below. */ @@ -229,7 +228,9 @@ /* Configure DW1000. See NOTE 6 below. */ dwt_configure(&config);//é ç½®DW1000 /* Apply default antenna delay value. See NOTE 1 below. */ dwt_setrxantennadelay(RX_ANT_DLY); //è®¾ç½®æ¥æ¶å¤©çº¿å»¶è¿ dwt_settxantennadelay(TX_ANT_DLY); //设置åå°å¤©çº¿å»¶è¿ @@ -240,10 +241,20 @@ dwt_setrxtimeout(RESP_RX_TIMEOUT_UUS); //è®¾ç½®æ¥æ¶è¶ æ¶æ¶é´ } void tag_sleep_configuraion(void) { dwt_configuresleep(0x940, 0x7); dwt_entersleep(); } void Tag_App(void)//å鿍¡å¼(TAGæ ç¾) { uint32_t frame_len; uint32_t final_tx_time; GPIO_ResetBits(SPIx_GPIO, SPIx_CS); delay_us(2000); GPIO_SetBits(SPIx_GPIO, SPIx_CS); /* Write frame data to DW1000 and prepare transmission. See NOTE 7 below. */ tx_poll_msg[ALL_MSG_SN_IDX] = frame_seq_nb; @@ -325,7 +336,8 @@ } LED0_BLINK; /* Execute a delay between ranging exchanges. */ deca_sleep(RNG_DELAY_MS + random_delay_tim); //ä¼ç åºå®æ¶é´ dwt_entersleep(); } void Anchor_App(void) Ô´Âë/ºËÐİå/Src/application/dw_app.h
@@ -16,5 +16,6 @@ void Dw1000_Init(void); void Tag_App(void); void Anchor_App(void); void tag_sleep_configuraion(void); #endif Ô´Âë/ºËÐİå/Src/main.c
@@ -10,8 +10,8 @@ #include "serial_at_cmd_app.h" #include "global_param.h" //#define WORK_MODE_TAG #define WORK_MODE_ANCHOR #define WORK_MODE_TAG //#define WORK_MODE_ANCHOR void Device_Init(void) { @@ -19,6 +19,9 @@ SystemInit(); Nvic_Init(); Systick_Init(); #ifdef WORK_MODE_TAG RTC_Configuration(); #endif Led_Init(); Beep_Init(); DW_GPIO_Init(); @@ -44,6 +47,7 @@ * * @return none */ int main(void) { @@ -51,11 +55,21 @@ Program_Init(); Dw1000_Init(); #ifdef WORK_MODE_TAG tag_sleep_configuraion(); #endif /* Loop forever initiating ranging exchanges. */ while(1) { #ifdef WORK_MODE_TAG if(g_start_send_flag) { g_start_send_flag = 0; Tag_App(); } RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI); #else Anchor_App(); #endif Ô´Âë/ºËÐİå/Src/stm32f10x_it.c
@@ -29,6 +29,8 @@ /* Tick timer count. */ volatile uint32_t time32_incr; uint8_t tt=0; uint8_t g_start_send_flag = 0; void SysTick_Handler(void) { @@ -55,4 +57,16 @@ } } void RTCAlarm_IRQHandler(void) { EXTI_ClearITPendingBit(EXTI_Line17); RTC_ClearITPendingBit(RTC_FLAG_ALR); g_start_send_flag = 1; RTC_SET_ALARM(1); tt++; //GPIO_Toggle(GPIOA,LED_PIN); //SYS.wake_id|=1<<17; } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ Ô´Âë/ºËÐİå/Src/stm32f10x_it.h
@@ -27,6 +27,8 @@ #ifdef __cplusplus extern "C" { #endif extern uint8_t g_start_send_flag; /* * Tick timer interrupt handler to replace the default one.