| | |
| | | |
| | | int No_Configuration(void) |
| | | { |
| | | return -1; |
| | | return -1; |
| | | } |
| | | |
| | | unsigned long portGetTickCnt(void) |
| | | { |
| | | return time32_incr; |
| | | return time32_incr; |
| | | } |
| | | |
| | | int SysTick_Configuration(void) |
| | | { |
| | | if (SysTick_Config(SystemCoreClock / CLOCKS_PER_SEC)) |
| | | { |
| | | /* Capture error */ |
| | | while (1); |
| | | } |
| | | NVIC_SetPriority (SysTick_IRQn, 5); |
| | | if (SysTick_Config(SystemCoreClock / CLOCKS_PER_SEC)) |
| | | { |
| | | /* Capture error */ |
| | | while (1); |
| | | } |
| | | NVIC_SetPriority (SysTick_IRQn, 5); |
| | | |
| | | return 0; |
| | | return 0; |
| | | } |
| | | |
| | | void RTC_Configuration(void) |
| | | { |
| | | /* Enable PWR and BKP clocks */ |
| | | RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); |
| | | /* Enable PWR and BKP clocks */ |
| | | RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); |
| | | |
| | | /* Allow access to BKP Domain */ |
| | | PWR_BackupAccessCmd(ENABLE); |
| | | /* Allow access to BKP Domain */ |
| | | PWR_BackupAccessCmd(ENABLE); |
| | | |
| | | /* Reset Backup Domain */ |
| | | BKP_DeInit(); |
| | | /* Reset Backup Domain */ |
| | | BKP_DeInit(); |
| | | |
| | | /* Enable LSE */ |
| | | RCC_LSEConfig(RCC_LSE_ON); |
| | | /* Wait till LSE is ready */ |
| | | while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET){} |
| | | /* Enable LSE */ |
| | | RCC_LSEConfig(RCC_LSE_ON); |
| | | /* Wait till LSE is ready */ |
| | | while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) {} |
| | | |
| | | /* Select LSE as RTC Clock Source */ |
| | | RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); |
| | | /* Select LSE as RTC Clock Source */ |
| | | RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); |
| | | |
| | | /* Enable RTC Clock */ |
| | | RCC_RTCCLKCmd(ENABLE); |
| | | /* Enable RTC Clock */ |
| | | RCC_RTCCLKCmd(ENABLE); |
| | | |
| | | /* Wait for RTC registers synchronization */ |
| | | RTC_WaitForSynchro(); |
| | | /* Wait for RTC registers synchronization */ |
| | | RTC_WaitForSynchro(); |
| | | |
| | | /* Wait until last write operation on RTC registers has finished */ |
| | | RTC_WaitForLastTask(); |
| | | /* Wait until last write operation on RTC registers has finished */ |
| | | RTC_WaitForLastTask(); |
| | | |
| | | /* Enable the RTC Second */ |
| | | RTC_ITConfig(RTC_IT_SEC, ENABLE); |
| | | /* Enable the RTC Second */ |
| | | RTC_ITConfig(RTC_IT_SEC, ENABLE); |
| | | |
| | | /* Wait until last write operation on RTC registers has finished */ |
| | | RTC_WaitForLastTask(); |
| | | /* Wait until last write operation on RTC registers has finished */ |
| | | RTC_WaitForLastTask(); |
| | | |
| | | /* Set RTC prescaler: set RTC period to 1sec */ |
| | | RTC_SetPrescaler(32767); /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */ |
| | | /* Set RTC prescaler: set RTC period to 1sec */ |
| | | RTC_SetPrescaler(32767); /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */ |
| | | |
| | | /* Wait until last write operation on RTC registers has finished */ |
| | | RTC_WaitForLastTask(); |
| | | /* Wait until last write operation on RTC registers has finished */ |
| | | RTC_WaitForLastTask(); |
| | | } |
| | | |
| | | |
| | | int NVIC_DisableDECAIRQ(void) |
| | | { |
| | | EXTI_InitTypeDef EXTI_InitStructure; |
| | | EXTI_InitTypeDef EXTI_InitStructure; |
| | | |
| | | /* Configure EXTI line */ |
| | | EXTI_InitStructure.EXTI_Line = DECAIRQ_EXTI; |
| | | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; |
| | | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //MPW3 IRQ polarity is high by default |
| | | EXTI_InitStructure.EXTI_LineCmd = DECAIRQ_EXTI_NOIRQ; |
| | | EXTI_Init(&EXTI_InitStructure); |
| | | /* Configure EXTI line */ |
| | | EXTI_InitStructure.EXTI_Line = DECAIRQ_EXTI; |
| | | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; |
| | | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //MPW3 IRQ polarity is high by default |
| | | EXTI_InitStructure.EXTI_LineCmd = DECAIRQ_EXTI_NOIRQ; |
| | | EXTI_Init(&EXTI_InitStructure); |
| | | |
| | | return 0; |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | int NVIC_Configuration(void) |
| | | { |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | EXTI_InitTypeDef EXTI_InitStructure; |
| | | NVIC_InitTypeDef NVIC_InitStructure; |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | EXTI_InitTypeDef EXTI_InitStructure; |
| | | NVIC_InitTypeDef NVIC_InitStructure; |
| | | |
| | | // Enable GPIO used as DECA IRQ for interrupt |
| | | GPIO_InitStructure.GPIO_Pin = DECAIRQ; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //IRQ pin should be Pull Down to prevent unnecessary EXT IRQ while DW1000 goes to sleep mode |
| | | GPIO_Init(DECAIRQ_GPIO, &GPIO_InitStructure); |
| | | // Enable GPIO used as DECA IRQ for interrupt |
| | | GPIO_InitStructure.GPIO_Pin = DECAIRQ; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //IRQ pin should be Pull Down to prevent unnecessary EXT IRQ while DW1000 goes to sleep mode |
| | | GPIO_Init(DECAIRQ_GPIO, &GPIO_InitStructure); |
| | | |
| | | /* Connect EXTI Line to GPIO Pin */ |
| | | GPIO_EXTILineConfig(DECAIRQ_EXTI_PORT, DECAIRQ_EXTI_PIN); |
| | | /* Connect EXTI Line to GPIO Pin */ |
| | | GPIO_EXTILineConfig(DECAIRQ_EXTI_PORT, DECAIRQ_EXTI_PIN); |
| | | |
| | | /* Configure EXTI line */ |
| | | EXTI_InitStructure.EXTI_Line = DECAIRQ_EXTI; |
| | | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; |
| | | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //MPW3 IRQ polarity is high by default |
| | | EXTI_InitStructure.EXTI_LineCmd = DECAIRQ_EXTI_USEIRQ; |
| | | EXTI_Init(&EXTI_InitStructure); |
| | | /* Configure EXTI line */ |
| | | EXTI_InitStructure.EXTI_Line = DECAIRQ_EXTI; |
| | | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; |
| | | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //MPW3 IRQ polarity is high by default |
| | | EXTI_InitStructure.EXTI_LineCmd = DECAIRQ_EXTI_USEIRQ; |
| | | EXTI_Init(&EXTI_InitStructure); |
| | | |
| | | /* Set NVIC Grouping to 16 groups of interrupt without sub-grouping */ |
| | | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); |
| | | /* Set NVIC Grouping to 16 groups of interrupt without sub-grouping */ |
| | | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); |
| | | |
| | | /* Enable and set EXTI Interrupt to the lowest priority */ |
| | | NVIC_InitStructure.NVIC_IRQChannel = DECAIRQ_EXTI_IRQn; |
| | | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 15; |
| | | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
| | | NVIC_InitStructure.NVIC_IRQChannelCmd = DECAIRQ_EXTI_USEIRQ; |
| | | /* Enable and set EXTI Interrupt to the lowest priority */ |
| | | NVIC_InitStructure.NVIC_IRQChannel = DECAIRQ_EXTI_IRQn; |
| | | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 15; |
| | | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
| | | NVIC_InitStructure.NVIC_IRQChannelCmd = DECAIRQ_EXTI_USEIRQ; |
| | | |
| | | NVIC_Init(&NVIC_InitStructure); |
| | | NVIC_Init(&NVIC_InitStructure); |
| | | |
| | | /* Enable the RTC Interrupt */ |
| | | //NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn; |
| | | //NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 10; |
| | | //NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
| | | //NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
| | | /* Enable the RTC Interrupt */ |
| | | //NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn; |
| | | //NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 10; |
| | | //NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
| | | //NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
| | | |
| | | //NVIC_Init(&NVIC_InitStructure); |
| | | //NVIC_Init(&NVIC_InitStructure); |
| | | |
| | | return 0; |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | ITStatus EXTI_GetITEnStatus(uint32_t EXTI_Line) |
| | | { |
| | | ITStatus bitstatus = RESET; |
| | | uint32_t enablestatus = 0; |
| | | /* Check the parameters */ |
| | | assert_param(IS_GET_EXTI_LINE(EXTI_Line)); |
| | | ITStatus bitstatus = RESET; |
| | | uint32_t enablestatus = 0; |
| | | /* Check the parameters */ |
| | | assert_param(IS_GET_EXTI_LINE(EXTI_Line)); |
| | | |
| | | enablestatus = EXTI->IMR & EXTI_Line; |
| | | if (enablestatus != (uint32_t)RESET) |
| | | { |
| | | bitstatus = SET; |
| | | } |
| | | else |
| | | { |
| | | bitstatus = RESET; |
| | | } |
| | | return bitstatus; |
| | | enablestatus = EXTI->IMR & EXTI_Line; |
| | | if (enablestatus != (uint32_t)RESET) |
| | | { |
| | | bitstatus = SET; |
| | | } |
| | | else |
| | | { |
| | | bitstatus = RESET; |
| | | } |
| | | return bitstatus; |
| | | } |
| | | |
| | | int RCC_Configuration(void) |
| | | { |
| | | ErrorStatus HSEStartUpStatus; |
| | | RCC_ClocksTypeDef RCC_ClockFreq; |
| | | ErrorStatus HSEStartUpStatus; |
| | | RCC_ClocksTypeDef RCC_ClockFreq; |
| | | |
| | | /* Set HSION bit */ |
| | | RCC->CR |= (uint32_t)0x00000001; |
| | | |
| | | // select HSI as PLL source |
| | | RCC->CFGR |= (uint32_t)RCC_CFGR_PLLSRC_HSI_Div2; |
| | | |
| | | //PLLCLK=8/2*12=48M |
| | | RCC->CFGR |= (uint32_t)RCC_CFGR_PLLMULL9; |
| | | |
| | | /* HCLK = SYSCLK/1 */ |
| | | RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1; |
| | | |
| | | /* Enable PLL */ |
| | | RCC->CR |= RCC_CR_PLLON; |
| | | |
| | | /* Wait till PLL is ready */ |
| | | while((RCC->CR & RCC_CR_PLLRDY) == 0) |
| | | { |
| | | } |
| | | /* Select PLL as system clock source */ |
| | | RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); |
| | | RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL; |
| | | |
| | | /* Wait till PLL is used as system clock source */ |
| | | while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08) |
| | | { |
| | | } |
| | | SystemCoreClockUpdate(); |
| | | RCC_GetClocksFreq(&RCC_ClockFreq); |
| | | /* Set HSION bit */ |
| | | RCC->CR |= (uint32_t)0x00000001; |
| | | |
| | | /* Enable SPI1 clock */ |
| | | RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); |
| | | // select HSI as PLL source |
| | | RCC->CFGR |= (uint32_t)RCC_CFGR_PLLSRC_HSI_Div2; |
| | | |
| | | /* Enable SPI2 clock */ |
| | | RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); |
| | | //PLLCLK=8/2*12=48M |
| | | RCC->CFGR |= (uint32_t)RCC_CFGR_PLLMULL9; |
| | | |
| | | /* Enable GPIOs clocks */ |
| | | RCC_APB2PeriphClockCmd( |
| | | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | |
| | | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | |
| | | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, |
| | | ENABLE); |
| | | /* HCLK = SYSCLK/1 */ |
| | | RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1; |
| | | |
| | | return 0; |
| | | /* Enable PLL */ |
| | | RCC->CR |= RCC_CR_PLLON; |
| | | |
| | | /* Wait till PLL is ready */ |
| | | while((RCC->CR & RCC_CR_PLLRDY) == 0) |
| | | { |
| | | } |
| | | /* Select PLL as system clock source */ |
| | | RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); |
| | | RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL; |
| | | |
| | | /* Wait till PLL is used as system clock source */ |
| | | while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08) |
| | | { |
| | | } |
| | | SystemCoreClockUpdate(); |
| | | RCC_GetClocksFreq(&RCC_ClockFreq); |
| | | |
| | | /* Enable SPI1 clock */ |
| | | RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); |
| | | |
| | | /* Enable SPI2 clock */ |
| | | RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); |
| | | |
| | | /* Enable GPIOs clocks */ |
| | | RCC_APB2PeriphClockCmd( |
| | | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | |
| | | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | |
| | | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, |
| | | ENABLE); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | void usartinit(void) |
| | | { |
| | | USART_InitTypeDef USART_InitStructure; |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | USART_InitTypeDef USART_InitStructure; |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | |
| | | /* USARTx configured as follow: |
| | | - BaudRate = 115200 baud |
| | | - Word Length = 8 Bits |
| | | - One Stop Bit |
| | | - No parity |
| | | - Hardware flow control disabled (RTS and CTS signals) |
| | | - Receive and transmit enabled |
| | | */ |
| | | USART_InitStructure.USART_BaudRate = 115200 ; |
| | | USART_InitStructure.USART_WordLength = USART_WordLength_8b; |
| | | USART_InitStructure.USART_StopBits = USART_StopBits_1; |
| | | USART_InitStructure.USART_Parity = USART_Parity_No; |
| | | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; |
| | | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; |
| | | /* USARTx configured as follow: |
| | | - BaudRate = 115200 baud |
| | | - Word Length = 8 Bits |
| | | - One Stop Bit |
| | | - No parity |
| | | - Hardware flow control disabled (RTS and CTS signals) |
| | | - Receive and transmit enabled |
| | | */ |
| | | USART_InitStructure.USART_BaudRate = 115200 ; |
| | | USART_InitStructure.USART_WordLength = USART_WordLength_8b; |
| | | USART_InitStructure.USART_StopBits = USART_StopBits_1; |
| | | USART_InitStructure.USART_Parity = USART_Parity_No; |
| | | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; |
| | | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; |
| | | |
| | | /* Enable GPIO clock */ |
| | | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE); |
| | | /* Enable GPIO clock */ |
| | | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE); |
| | | |
| | | //For EVB1000 -> USART2_REMAP = 0 |
| | | //For EVB1000 -> USART2_REMAP = 0 |
| | | |
| | | /* Enable the USART2 Pins Software Remapping */ |
| | | /* Enable the USART2 Pins Software Remapping */ |
| | | |
| | | RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); |
| | | RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); |
| | | |
| | | |
| | | /* Configure USART Tx as alternate function push-pull */ |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | /* Configure USART Tx as alternate function push-pull */ |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | |
| | | /* Configure USART Rx as input floating */ |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | /* Configure USART Rx as input floating */ |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | |
| | | /* USART configuration */ |
| | | USART_Init(USART1, &USART_InitStructure); |
| | | /* USART configuration */ |
| | | USART_Init(USART1, &USART_InitStructure); |
| | | |
| | | /* Enable USART */ |
| | | USART_Cmd(USART1, ENABLE); |
| | | /* Enable USART */ |
| | | USART_Cmd(USART1, ENABLE); |
| | | } |
| | | |
| | | void SPI_ChangeRate(uint16_t scalingfactor) |
| | | { |
| | | uint16_t tmpreg = 0; |
| | | uint16_t tmpreg = 0; |
| | | |
| | | /* Get the SPIx CR1 value */ |
| | | tmpreg = SPIx->CR1; |
| | | /* Get the SPIx CR1 value */ |
| | | tmpreg = SPIx->CR1; |
| | | |
| | | /*clear the scaling bits*/ |
| | | tmpreg &= 0xFFC7; |
| | | /*clear the scaling bits*/ |
| | | tmpreg &= 0xFFC7; |
| | | |
| | | /*set the scaling bits*/ |
| | | tmpreg |= scalingfactor; |
| | | /*set the scaling bits*/ |
| | | tmpreg |= scalingfactor; |
| | | |
| | | /* Write to SPIx CR1 */ |
| | | SPIx->CR1 = tmpreg; |
| | | /* Write to SPIx CR1 */ |
| | | SPIx->CR1 = tmpreg; |
| | | } |
| | | |
| | | /*! ------------------------------------------------------------------------------------------------------------------ |
| | |
| | | |
| | | void SPI_ConfigFastRate(uint16_t scalingfactor) |
| | | { |
| | | SPI_InitTypeDef SPI_InitStructure; |
| | | SPI_InitTypeDef SPI_InitStructure; |
| | | |
| | | SPI_I2S_DeInit(SPIx); |
| | | SPI_I2S_DeInit(SPIx); |
| | | |
| | | // SPIx Mode setup |
| | | SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; |
| | | SPI_InitStructure.SPI_Mode = SPI_Mode_Master; |
| | | SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; |
| | | SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; // |
| | | //SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; // |
| | | SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; |
| | | //SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; // |
| | | //SPI_InitStructure.SPI_NSS = SPI_NSS_Hard; |
| | | SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; |
| | | SPI_InitStructure.SPI_BaudRatePrescaler = scalingfactor; //sets BR[2:0] bits - baudrate in SPI_CR1 reg bits 4-6 |
| | | SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; |
| | | SPI_InitStructure.SPI_CRCPolynomial = 7; |
| | | // SPIx Mode setup |
| | | SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; |
| | | SPI_InitStructure.SPI_Mode = SPI_Mode_Master; |
| | | SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; |
| | | SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; // |
| | | //SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; // |
| | | SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; |
| | | //SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; // |
| | | //SPI_InitStructure.SPI_NSS = SPI_NSS_Hard; |
| | | SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; |
| | | SPI_InitStructure.SPI_BaudRatePrescaler = scalingfactor; //sets BR[2:0] bits - baudrate in SPI_CR1 reg bits 4-6 |
| | | SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; |
| | | SPI_InitStructure.SPI_CRCPolynomial = 7; |
| | | |
| | | SPI_Init(SPIx, &SPI_InitStructure); |
| | | SPI_Init(SPIx, &SPI_InitStructure); |
| | | |
| | | // Enable SPIx |
| | | SPI_Cmd(SPIx, ENABLE); |
| | | // Enable SPIx |
| | | SPI_Cmd(SPIx, ENABLE); |
| | | } |
| | | |
| | | int SPI_Configuration(void) |
| | | { |
| | | SPI_InitTypeDef SPI_InitStructure; |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | SPI_InitTypeDef SPI_InitStructure; |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | |
| | | SPI_I2S_DeInit(SPIx); |
| | | SPI_I2S_DeInit(SPIx); |
| | | |
| | | // SPIx Mode setup |
| | | SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; |
| | | SPI_InitStructure.SPI_Mode = SPI_Mode_Master; |
| | | SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; |
| | | SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; // |
| | | //SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; // |
| | | SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; |
| | | //SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; // |
| | | //SPI_InitStructure.SPI_NSS = SPI_NSS_Hard; |
| | | SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; |
| | | //SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4; //sets BR[2:0] bits - baudrate in SPI_CR1 reg bits 4-6 |
| | | SPI_InitStructure.SPI_BaudRatePrescaler = SPIx_PRESCALER; |
| | | SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; |
| | | SPI_InitStructure.SPI_CRCPolynomial = 7; |
| | | // SPIx Mode setup |
| | | SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; |
| | | SPI_InitStructure.SPI_Mode = SPI_Mode_Master; |
| | | SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; |
| | | SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; // |
| | | //SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; // |
| | | SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; |
| | | //SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; // |
| | | //SPI_InitStructure.SPI_NSS = SPI_NSS_Hard; |
| | | SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; |
| | | //SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4; //sets BR[2:0] bits - baudrate in SPI_CR1 reg bits 4-6 |
| | | SPI_InitStructure.SPI_BaudRatePrescaler = SPIx_PRESCALER; |
| | | SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; |
| | | SPI_InitStructure.SPI_CRCPolynomial = 7; |
| | | |
| | | SPI_Init(SPIx, &SPI_InitStructure); |
| | | SPI_Init(SPIx, &SPI_InitStructure); |
| | | |
| | | // SPIx SCK and MOSI pin setup |
| | | GPIO_InitStructure.GPIO_Pin = SPIx_SCK | SPIx_MOSI; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | // SPIx SCK and MOSI pin setup |
| | | GPIO_InitStructure.GPIO_Pin = SPIx_SCK | SPIx_MOSI; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | |
| | | GPIO_Init(SPIx_GPIO, &GPIO_InitStructure); |
| | | GPIO_Init(SPIx_GPIO, &GPIO_InitStructure); |
| | | |
| | | // SPIx MISO pin setup |
| | | GPIO_InitStructure.GPIO_Pin = SPIx_MISO; |
| | | //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; |
| | | // SPIx MISO pin setup |
| | | GPIO_InitStructure.GPIO_Pin = SPIx_MISO; |
| | | //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; |
| | | |
| | | GPIO_Init(SPIx_GPIO, &GPIO_InitStructure); |
| | | GPIO_Init(SPIx_GPIO, &GPIO_InitStructure); |
| | | |
| | | // SPIx CS pin setup |
| | | GPIO_InitStructure.GPIO_Pin = SPIx_CS; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | // SPIx CS pin setup |
| | | GPIO_InitStructure.GPIO_Pin = SPIx_CS; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | |
| | | GPIO_Init(SPIx_CS_GPIO, &GPIO_InitStructure); |
| | | GPIO_Init(SPIx_CS_GPIO, &GPIO_InitStructure); |
| | | |
| | | // Disable SPIx SS Output |
| | | SPI_SSOutputCmd(SPIx, DISABLE); |
| | | // Disable SPIx SS Output |
| | | SPI_SSOutputCmd(SPIx, DISABLE); |
| | | |
| | | // Enable SPIx |
| | | SPI_Cmd(SPIx, ENABLE); |
| | | // Enable SPIx |
| | | SPI_Cmd(SPIx, ENABLE); |
| | | |
| | | // Set CS high |
| | | GPIO_SetBits(SPIx_CS_GPIO, SPIx_CS); |
| | | // Set CS high |
| | | GPIO_SetBits(SPIx_CS_GPIO, SPIx_CS); |
| | | |
| | | return 0; |
| | | } |
| | |
| | | |
| | | int SPI2_Configuration(void) |
| | | { |
| | | SPI_InitTypeDef SPI_InitStructure; |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | SPI_InitTypeDef SPI_InitStructure; |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | |
| | | SPI_I2S_DeInit(SPIy); |
| | | SPI_I2S_DeInit(SPIy); |
| | | |
| | | // SPIy Mode setup |
| | | //SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx; |
| | | SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; |
| | | SPI_InitStructure.SPI_Mode = SPI_Mode_Master; |
| | | SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; |
| | | //SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; // |
| | | SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; // |
| | | //SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; |
| | | SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; // |
| | | //SPI_InitStructure.SPI_NSS = SPI_NSS_Hard; |
| | | SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; |
| | | SPI_InitStructure.SPI_BaudRatePrescaler = SPIy_PRESCALER; |
| | | SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; |
| | | SPI_InitStructure.SPI_CRCPolynomial = 7; |
| | | // SPIy Mode setup |
| | | //SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx; |
| | | SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; |
| | | SPI_InitStructure.SPI_Mode = SPI_Mode_Master; |
| | | SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; |
| | | //SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; // |
| | | SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; // |
| | | //SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; |
| | | SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; // |
| | | //SPI_InitStructure.SPI_NSS = SPI_NSS_Hard; |
| | | SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; |
| | | SPI_InitStructure.SPI_BaudRatePrescaler = SPIy_PRESCALER; |
| | | SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; |
| | | SPI_InitStructure.SPI_CRCPolynomial = 7; |
| | | |
| | | SPI_Init(SPIy, &SPI_InitStructure); |
| | | SPI_Init(SPIy, &SPI_InitStructure); |
| | | |
| | | // SPIy SCK and MOSI pin setup |
| | | GPIO_InitStructure.GPIO_Pin = SPIy_SCK | SPIy_MOSI; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | // SPIy SCK and MOSI pin setup |
| | | GPIO_InitStructure.GPIO_Pin = SPIy_SCK | SPIy_MOSI; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | |
| | | GPIO_Init(SPIy_GPIO, &GPIO_InitStructure); |
| | | GPIO_Init(SPIy_GPIO, &GPIO_InitStructure); |
| | | |
| | | // SPIy MISO pin setup |
| | | GPIO_InitStructure.GPIO_Pin = SPIy_MISO; |
| | | //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; |
| | | // SPIy MISO pin setup |
| | | GPIO_InitStructure.GPIO_Pin = SPIy_MISO; |
| | | //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; |
| | | |
| | | GPIO_Init(SPIy_GPIO, &GPIO_InitStructure); |
| | | GPIO_Init(SPIy_GPIO, &GPIO_InitStructure); |
| | | |
| | | // SPIy CS pin setup |
| | | GPIO_InitStructure.GPIO_Pin = SPIy_CS; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | // SPIy CS pin setup |
| | | GPIO_InitStructure.GPIO_Pin = SPIy_CS; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | |
| | | GPIO_Init(SPIy_CS_GPIO, &GPIO_InitStructure); |
| | | GPIO_Init(SPIy_CS_GPIO, &GPIO_InitStructure); |
| | | |
| | | // Disable SPIy SS Output |
| | | SPI_SSOutputCmd(SPIy, DISABLE); |
| | | // Disable SPIy SS Output |
| | | SPI_SSOutputCmd(SPIy, DISABLE); |
| | | |
| | | // Enable SPIy |
| | | SPI_Cmd(SPIy, ENABLE); |
| | | // Enable SPIy |
| | | SPI_Cmd(SPIy, ENABLE); |
| | | |
| | | // Set CS high |
| | | GPIO_SetBits(SPIy_CS_GPIO, SPIy_CS); |
| | | // Set CS high |
| | | GPIO_SetBits(SPIy_CS_GPIO, SPIy_CS); |
| | | |
| | | // LCD_RS pin setup |
| | | GPIO_InitStructure.GPIO_Pin = LCD_RS; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | // LCD_RS pin setup |
| | | GPIO_InitStructure.GPIO_Pin = LCD_RS; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | |
| | | GPIO_Init(SPIy_GPIO, &GPIO_InitStructure); |
| | | GPIO_Init(SPIy_GPIO, &GPIO_InitStructure); |
| | | |
| | | // LCD_RW pin setup |
| | | GPIO_InitStructure.GPIO_Pin = LCD_RW; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | // LCD_RW pin setup |
| | | GPIO_InitStructure.GPIO_Pin = LCD_RW; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | |
| | | GPIO_Init(SPIy_GPIO, &GPIO_InitStructure); |
| | | GPIO_Init(SPIy_GPIO, &GPIO_InitStructure); |
| | | |
| | | return 0; |
| | | } |
| | |
| | | #define SW7 GPIO_Pin_7 |
| | | #define SW8 GPIO_Pin_8 |
| | | uint8_t Work_Mode; |
| | | extern uint8_t TAG_ID,ANCHOR_ID; |
| | | extern uint8_t TAG_ID, ANCHOR_ID; |
| | | int GPIO_Configuration(void) |
| | | { |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | |
| | | /* Configure all unused GPIO port pins in Analog Input mode (floating input |
| | | * trigger OFF), this will reduce the power consumption and increase the device |
| | | * immunity against EMI/EMC */ |
| | | /* Configure all unused GPIO port pins in Analog Input mode (floating input |
| | | * trigger OFF), this will reduce the power consumption and increase the device |
| | | * immunity against EMI/EMC */ |
| | | |
| | | // Enable GPIOs clocks |
| | | RCC_APB2PeriphClockCmd( |
| | | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | |
| | | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, |
| | | ENABLE); |
| | | // Enable GPIOs clocks |
| | | RCC_APB2PeriphClockCmd( |
| | | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | |
| | | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, |
| | | ENABLE); |
| | | |
| | | // Set all GPIO pins as analog inputs |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | GPIO_Init(GPIOB, &GPIO_InitStructure); |
| | | GPIO_Init(GPIOC, &GPIO_InitStructure); |
| | | // Set all GPIO pins as analog inputs |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | GPIO_Init(GPIOB, &GPIO_InitStructure); |
| | | GPIO_Init(GPIOC, &GPIO_InitStructure); |
| | | |
| | | GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); |
| | | //Enable GPIO used for User button |
| | | GPIO_InitStructure.GPIO_Pin = TA_BOOT1; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_Init(TA_BOOT1_GPIO, &GPIO_InitStructure); |
| | | GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); |
| | | //Enable GPIO used for User button |
| | | GPIO_InitStructure.GPIO_Pin = TA_BOOT1; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_Init(TA_BOOT1_GPIO, &GPIO_InitStructure); |
| | | |
| | | //Enable GPIO used for Response Delay setting |
| | | |
| | | GPIO_InitStructure.GPIO_Pin = SW1|SW2; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | |
| | | GPIO_InitStructure.GPIO_Pin = SW3 | SW4 | SW5 | SW6 | SW7 | SW8; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; |
| | | GPIO_Init(GPIOB, &GPIO_InitStructure); |
| | | |
| | | GPIO_InitStructure.GPIO_Pin = LED_PIN; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | //Enable GPIO used for Response Delay setting |
| | | |
| | | if (GPIO_ReadInputDataBit(GPIOA,SW1) == RESET) |
| | | { |
| | | Work_Mode = 0;//TX |
| | | GPIO_Toggle(GPIOA,LED_PIN); |
| | | }else{ |
| | | Work_Mode = 1; //RX |
| | | } |
| | | TAG_ID = 0; |
| | | if(GPIO_ReadInputDataBit(GPIOB,SW6) == RESET) |
| | | { |
| | | TAG_ID |= 1<<2; |
| | | } |
| | | if(GPIO_ReadInputDataBit(GPIOB,SW7) == RESET) |
| | | { |
| | | TAG_ID |= 1<<1; |
| | | } |
| | | if(GPIO_ReadInputDataBit(GPIOB,SW8) == RESET) |
| | | { |
| | | TAG_ID |= 1; |
| | | } |
| | | GPIO_InitStructure.GPIO_Pin = SW1 | SW2; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | |
| | | if(GPIO_ReadInputDataBit(GPIOB,SW3) == RESET) |
| | | { |
| | | ANCHOR_ID |= 1<<2; |
| | | } |
| | | if(GPIO_ReadInputDataBit(GPIOB,SW4) == RESET) |
| | | { |
| | | ANCHOR_ID |= 1<<1; |
| | | } |
| | | if(GPIO_ReadInputDataBit(GPIOB,SW5) == RESET) |
| | | { |
| | | ANCHOR_ID |= 1; |
| | | } |
| | | GPIO_InitStructure.GPIO_Pin = SW3 | SW4 | SW5 | SW6 | SW7 | SW8; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; |
| | | GPIO_Init(GPIOB, &GPIO_InitStructure); |
| | | |
| | | // Disable GPIOs clocks |
| | | //RCC_APB2PeriphClockCmd( |
| | | // RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | |
| | | // RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | |
| | | // RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, |
| | | // DISABLE); |
| | | GPIO_InitStructure.GPIO_Pin = LED_PIN; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | |
| | | // Enable GPIO used for LEDs |
| | | if (GPIO_ReadInputDataBit(GPIOA, SW1) == RESET) |
| | | { |
| | | Work_Mode = 0;//TX |
| | | GPIO_Toggle(GPIOA, LED_PIN); |
| | | } |
| | | else |
| | | { |
| | | Work_Mode = 1; //RX |
| | | } |
| | | TAG_ID = 0; |
| | | if(GPIO_ReadInputDataBit(GPIOB, SW6) == RESET) |
| | | { |
| | | TAG_ID |= 1 << 2; |
| | | } |
| | | if(GPIO_ReadInputDataBit(GPIOB, SW7) == RESET) |
| | | { |
| | | TAG_ID |= 1 << 1; |
| | | } |
| | | if(GPIO_ReadInputDataBit(GPIOB, SW8) == RESET) |
| | | { |
| | | TAG_ID |= 1; |
| | | } |
| | | |
| | | if(GPIO_ReadInputDataBit(GPIOB, SW3) == RESET) |
| | | { |
| | | ANCHOR_ID |= 1 << 2; |
| | | } |
| | | if(GPIO_ReadInputDataBit(GPIOB, SW4) == RESET) |
| | | { |
| | | ANCHOR_ID |= 1 << 1; |
| | | } |
| | | if(GPIO_ReadInputDataBit(GPIOB, SW5) == RESET) |
| | | { |
| | | ANCHOR_ID |= 1; |
| | | } |
| | | |
| | | // Disable GPIOs clocks |
| | | //RCC_APB2PeriphClockCmd( |
| | | // RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | |
| | | // RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | |
| | | // RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, |
| | | // DISABLE); |
| | | |
| | | // Enable GPIO used for LEDs |
| | | |
| | | |
| | | return 0; |
| | |
| | | |
| | | void reset_DW1000(void) |
| | | { |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | |
| | | // Enable GPIO used for DW1000 reset |
| | | GPIO_InitStructure.GPIO_Pin = DW1000_RSTn; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_Init(DW1000_RSTn_GPIO, &GPIO_InitStructure); |
| | | // Enable GPIO used for DW1000 reset |
| | | GPIO_InitStructure.GPIO_Pin = DW1000_RSTn; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_Init(DW1000_RSTn_GPIO, &GPIO_InitStructure); |
| | | |
| | | //drive the RSTn pin low |
| | | GPIO_ResetBits(DW1000_RSTn_GPIO, DW1000_RSTn); |
| | | //drive the RSTn pin low |
| | | GPIO_ResetBits(DW1000_RSTn_GPIO, DW1000_RSTn); |
| | | |
| | | //put the pin back to tri-state ... as input |
| | | GPIO_InitStructure.GPIO_Pin = DW1000_RSTn; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_Init(DW1000_RSTn_GPIO, &GPIO_InitStructure); |
| | | //put the pin back to tri-state ... as input |
| | | GPIO_InitStructure.GPIO_Pin = DW1000_RSTn; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_Init(DW1000_RSTn_GPIO, &GPIO_InitStructure); |
| | | |
| | | deca_sleep(2); |
| | | } |
| | |
| | | |
| | | void setup_DW1000RSTnIRQ(int enable) |
| | | { |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | EXTI_InitTypeDef EXTI_InitStructure; |
| | | NVIC_InitTypeDef NVIC_InitStructure; |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | EXTI_InitTypeDef EXTI_InitStructure; |
| | | NVIC_InitTypeDef NVIC_InitStructure; |
| | | |
| | | if(enable) |
| | | { |
| | | // Enable GPIO used as DECA IRQ for interrupt |
| | | GPIO_InitStructure.GPIO_Pin = DECARSTIRQ; |
| | | //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //IRQ pin should be Pull Down to prevent unnecessary EXT IRQ while DW1000 goes to sleep mode |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_Init(DECARSTIRQ_GPIO, &GPIO_InitStructure); |
| | | if(enable) |
| | | { |
| | | // Enable GPIO used as DECA IRQ for interrupt |
| | | GPIO_InitStructure.GPIO_Pin = DECARSTIRQ; |
| | | //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //IRQ pin should be Pull Down to prevent unnecessary EXT IRQ while DW1000 goes to sleep mode |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_Init(DECARSTIRQ_GPIO, &GPIO_InitStructure); |
| | | |
| | | /* Connect EXTI Line to GPIO Pin */ |
| | | GPIO_EXTILineConfig(DECARSTIRQ_EXTI_PORT, DECARSTIRQ_EXTI_PIN); |
| | | /* Connect EXTI Line to GPIO Pin */ |
| | | GPIO_EXTILineConfig(DECARSTIRQ_EXTI_PORT, DECARSTIRQ_EXTI_PIN); |
| | | |
| | | /* Configure EXTI line */ |
| | | EXTI_InitStructure.EXTI_Line = DECARSTIRQ_EXTI; |
| | | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; |
| | | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //MP IRQ polarity is high by default |
| | | EXTI_InitStructure.EXTI_LineCmd = ENABLE; |
| | | EXTI_Init(&EXTI_InitStructure); |
| | | /* Configure EXTI line */ |
| | | EXTI_InitStructure.EXTI_Line = DECARSTIRQ_EXTI; |
| | | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; |
| | | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //MP IRQ polarity is high by default |
| | | EXTI_InitStructure.EXTI_LineCmd = ENABLE; |
| | | EXTI_Init(&EXTI_InitStructure); |
| | | |
| | | /* Set NVIC Grouping to 16 groups of interrupt without sub-grouping */ |
| | | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); |
| | | /* Set NVIC Grouping to 16 groups of interrupt without sub-grouping */ |
| | | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); |
| | | |
| | | /* Enable and set EXTI Interrupt to the lowest priority */ |
| | | NVIC_InitStructure.NVIC_IRQChannel = DECARSTIRQ_EXTI_IRQn; |
| | | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 15; |
| | | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
| | | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
| | | /* Enable and set EXTI Interrupt to the lowest priority */ |
| | | NVIC_InitStructure.NVIC_IRQChannel = DECARSTIRQ_EXTI_IRQn; |
| | | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 15; |
| | | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
| | | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
| | | |
| | | NVIC_Init(&NVIC_InitStructure); |
| | | } |
| | | else |
| | | { |
| | | //put the pin back to tri-state ... as input |
| | | GPIO_InitStructure.GPIO_Pin = DW1000_RSTn; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_Init(DW1000_RSTn_GPIO, &GPIO_InitStructure); |
| | | NVIC_Init(&NVIC_InitStructure); |
| | | } |
| | | else |
| | | { |
| | | //put the pin back to tri-state ... as input |
| | | GPIO_InitStructure.GPIO_Pin = DW1000_RSTn; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_Init(DW1000_RSTn_GPIO, &GPIO_InitStructure); |
| | | |
| | | /* Configure EXTI line */ |
| | | EXTI_InitStructure.EXTI_Line = DECARSTIRQ_EXTI; |
| | | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; |
| | | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //MP IRQ polarity is high by default |
| | | EXTI_InitStructure.EXTI_LineCmd = DISABLE; |
| | | EXTI_Init(&EXTI_InitStructure); |
| | | } |
| | | /* Configure EXTI line */ |
| | | EXTI_InitStructure.EXTI_Line = DECARSTIRQ_EXTI; |
| | | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; |
| | | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //MP IRQ polarity is high by default |
| | | EXTI_InitStructure.EXTI_LineCmd = DISABLE; |
| | | EXTI_Init(&EXTI_InitStructure); |
| | | } |
| | | } |
| | | |
| | | |
| | | int ETH_GPIOConfigure(void) |
| | | { |
| | | #if 0 |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | |
| | | /* ETHERNET pins configuration */ |
| | | /* AF Output Push Pull: |
| | | - ETH_MII_MDIO / ETH_RMII_MDIO: PA2 |
| | | - ETH_MII_MDC / ETH_RMII_MDC: PC1 |
| | | - ETH_MII_TXD2: PC2 |
| | | - ETH_MII_TX_EN / ETH_RMII_TX_EN: PB11 |
| | | - ETH_MII_TXD0 / ETH_RMII_TXD0: PB12 |
| | | - ETH_MII_TXD1 / ETH_RMII_TXD1: PB13 |
| | | - ETH_MII_PPS_OUT / ETH_RMII_PPS_OUT: PB5 |
| | | - ETH_MII_TXD3: PB8 */ |
| | | /* ETHERNET pins configuration */ |
| | | /* AF Output Push Pull: |
| | | - ETH_MII_MDIO / ETH_RMII_MDIO: PA2 |
| | | - ETH_MII_MDC / ETH_RMII_MDC: PC1 |
| | | - ETH_MII_TXD2: PC2 |
| | | - ETH_MII_TX_EN / ETH_RMII_TX_EN: PB11 |
| | | - ETH_MII_TXD0 / ETH_RMII_TXD0: PB12 |
| | | - ETH_MII_TXD1 / ETH_RMII_TXD1: PB13 |
| | | - ETH_MII_PPS_OUT / ETH_RMII_PPS_OUT: PB5 |
| | | - ETH_MII_TXD3: PB8 */ |
| | | |
| | | /* Configure PA2 as alternate function push-pull */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | /* Configure PA2 as alternate function push-pull */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | |
| | | /* Configure PC1 and PC2 as alternate function push-pull */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | GPIO_Init(GPIOC, &GPIO_InitStructure); |
| | | /* Configure PC1 and PC2 as alternate function push-pull */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | GPIO_Init(GPIOC, &GPIO_InitStructure); |
| | | |
| | | /* Configure PB5, PB8, PB11, PB12 and PB13 as alternate function push-pull */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_8 | GPIO_Pin_11 | |
| | | GPIO_Pin_12 | GPIO_Pin_13; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | GPIO_Init(GPIOB, &GPIO_InitStructure); |
| | | /* Configure PB5, PB8, PB11, PB12 and PB13 as alternate function push-pull */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_8 | GPIO_Pin_11 | |
| | | GPIO_Pin_12 | GPIO_Pin_13; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | GPIO_Init(GPIOB, &GPIO_InitStructure); |
| | | |
| | | /**************************************************************/ |
| | | /* For Remapped Ethernet pins */ |
| | | /*************************************************************/ |
| | | /* Input (Reset Value): |
| | | - ETH_MII_CRS CRS: PA0 |
| | | - ETH_MII_RX_CLK / ETH_RMII_REF_CLK: PA1 |
| | | - ETH_MII_COL: PA3 |
| | | - ETH_MII_RX_DV / ETH_RMII_CRS_DV: PD8 |
| | | - ETH_MII_TX_CLK: PC3 |
| | | - ETH_MII_RXD0 / ETH_RMII_RXD0: PD9 |
| | | - ETH_MII_RXD1 / ETH_RMII_RXD1: PD10 |
| | | - ETH_MII_RXD2: PD11 |
| | | - ETH_MII_RXD3: PD12 |
| | | - ETH_MII_RX_ER: PB10 */ |
| | | /**************************************************************/ |
| | | /* For Remapped Ethernet pins */ |
| | | /*************************************************************/ |
| | | /* Input (Reset Value): |
| | | - ETH_MII_CRS CRS: PA0 |
| | | - ETH_MII_RX_CLK / ETH_RMII_REF_CLK: PA1 |
| | | - ETH_MII_COL: PA3 |
| | | - ETH_MII_RX_DV / ETH_RMII_CRS_DV: PD8 |
| | | - ETH_MII_TX_CLK: PC3 |
| | | - ETH_MII_RXD0 / ETH_RMII_RXD0: PD9 |
| | | - ETH_MII_RXD1 / ETH_RMII_RXD1: PD10 |
| | | - ETH_MII_RXD2: PD11 |
| | | - ETH_MII_RXD3: PD12 |
| | | - ETH_MII_RX_ER: PB10 */ |
| | | |
| | | /* Configure PA0, PA1 and PA3 as input */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_3; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | /* Configure PA0, PA1 and PA3 as input */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_3; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | |
| | | /* Configure PB10 as input */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_Init(GPIOB, &GPIO_InitStructure); |
| | | /* Configure PB10 as input */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_Init(GPIOB, &GPIO_InitStructure); |
| | | |
| | | /* Configure PC3 as input */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_Init(GPIOC, &GPIO_InitStructure); |
| | | /* Configure PC3 as input */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_Init(GPIOC, &GPIO_InitStructure); |
| | | |
| | | /* Configure PD8, PD9, PD10, PD11 and PD12 as input */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_Init(GPIOD, &GPIO_InitStructure); /**/ |
| | | /* Configure PD8, PD9, PD10, PD11 and PD12 as input */ |
| | | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
| | | GPIO_Init(GPIOD, &GPIO_InitStructure); /**/ |
| | | |
| | | |
| | | |
| | | /* MCO pin configuration------------------------------------------------- */ |
| | | /* Configure MCO (PA8) as alternate function push-pull */ |
| | | //GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; |
| | | //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | //GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | /* MCO pin configuration------------------------------------------------- */ |
| | | /* Configure MCO (PA8) as alternate function push-pull */ |
| | | //GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; |
| | | //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; |
| | | //GPIO_Init(GPIOA, &GPIO_InitStructure); |
| | | #endif |
| | | |
| | | return 0; |
| | | return 0; |
| | | } |
| | | |
| | | int is_button_low(uint16_t GPIOpin) |
| | | { |
| | | int result = 1; |
| | | int result = 1; |
| | | |
| | | if (GPIO_ReadInputDataBit(TA_BOOT1_GPIO, TA_BOOT1)) |
| | | result = 0; |
| | | if (GPIO_ReadInputDataBit(TA_BOOT1_GPIO, TA_BOOT1)) |
| | | result = 0; |
| | | |
| | | return result; |
| | | return result; |
| | | } |
| | | |
| | | //when switch (S1) is 'on' the pin is low |
| | | int is_switch_on(uint16_t GPIOpin) |
| | | { |
| | | int result = 1; |
| | | int result = 1; |
| | | |
| | | if (GPIO_ReadInputDataBit(TA_SW1_GPIO, GPIOpin)) |
| | | result = 0; |
| | | if (GPIO_ReadInputDataBit(TA_SW1_GPIO, GPIOpin)) |
| | | result = 0; |
| | | |
| | | return result; |
| | | return result; |
| | | } |
| | | |
| | | |
| | | void led_off (led_t led) |
| | | { |
| | | switch (led) |
| | | { |
| | | case LED_PC6: |
| | | GPIO_ResetBits(GPIOC, GPIO_Pin_6); |
| | | break; |
| | | case LED_PC7: |
| | | GPIO_ResetBits(GPIOC, GPIO_Pin_7); |
| | | break; |
| | | case LED_PC8: |
| | | GPIO_ResetBits(GPIOC, GPIO_Pin_8); |
| | | break; |
| | | case LED_PC9: |
| | | GPIO_ResetBits(GPIOC, GPIO_Pin_9); |
| | | break; |
| | | case LED_ALL: |
| | | GPIO_ResetBits(GPIOC, GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_6 | GPIO_Pin_7); |
| | | break; |
| | | default: |
| | | // do nothing for undefined led number |
| | | break; |
| | | } |
| | | switch (led) |
| | | { |
| | | case LED_PC6: |
| | | GPIO_ResetBits(GPIOC, GPIO_Pin_6); |
| | | break; |
| | | case LED_PC7: |
| | | GPIO_ResetBits(GPIOC, GPIO_Pin_7); |
| | | break; |
| | | case LED_PC8: |
| | | GPIO_ResetBits(GPIOC, GPIO_Pin_8); |
| | | break; |
| | | case LED_PC9: |
| | | GPIO_ResetBits(GPIOC, GPIO_Pin_9); |
| | | break; |
| | | case LED_ALL: |
| | | GPIO_ResetBits(GPIOC, GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_6 | GPIO_Pin_7); |
| | | break; |
| | | default: |
| | | // do nothing for undefined led number |
| | | break; |
| | | } |
| | | } |
| | | |
| | | void led_on (led_t led) |
| | | { |
| | | switch (led) |
| | | { |
| | | case LED_PC6: |
| | | GPIO_SetBits(GPIOC, GPIO_Pin_6); |
| | | break; |
| | | case LED_PC7: |
| | | GPIO_SetBits(GPIOC, GPIO_Pin_7); |
| | | break; |
| | | case LED_PC8: |
| | | GPIO_SetBits(GPIOC, GPIO_Pin_8); |
| | | break; |
| | | case LED_PC9: |
| | | GPIO_SetBits(GPIOC, GPIO_Pin_9); |
| | | break; |
| | | case LED_ALL: |
| | | GPIO_SetBits(GPIOC, GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_6 | GPIO_Pin_7); |
| | | break; |
| | | default: |
| | | // do nothing for undefined led number |
| | | break; |
| | | } |
| | | switch (led) |
| | | { |
| | | case LED_PC6: |
| | | GPIO_SetBits(GPIOC, GPIO_Pin_6); |
| | | break; |
| | | case LED_PC7: |
| | | GPIO_SetBits(GPIOC, GPIO_Pin_7); |
| | | break; |
| | | case LED_PC8: |
| | | GPIO_SetBits(GPIOC, GPIO_Pin_8); |
| | | break; |
| | | case LED_PC9: |
| | | GPIO_SetBits(GPIOC, GPIO_Pin_9); |
| | | break; |
| | | case LED_ALL: |
| | | GPIO_SetBits(GPIOC, GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_6 | GPIO_Pin_7); |
| | | break; |
| | | default: |
| | | // do nothing for undefined led number |
| | | break; |
| | | } |
| | | } |
| | | |
| | | #ifdef USART_SUPPORT |
| | |
| | | |
| | | int is_IRQ_enabled(void) |
| | | { |
| | | return (( NVIC->ISER[((uint32_t)(DECAIRQ_EXTI_IRQn) >> 5)] |
| | | & (uint32_t)0x01 << (DECAIRQ_EXTI_IRQn & (uint8_t)0x1F) ) ? 1 : 0) ; |
| | | return (( NVIC->ISER[((uint32_t)(DECAIRQ_EXTI_IRQn) >> 5)] |
| | | & (uint32_t)0x01 << (DECAIRQ_EXTI_IRQn & (uint8_t)0x1F) ) ? 1 : 0) ; |
| | | } |
| | | |
| | | /*! ------------------------------------------------------------------------------------------------------------------ |
| | |
| | | */ |
| | | void peripherals_init (void) |
| | | { |
| | | rcc_init(); |
| | | gpio_init(); |
| | | systick_init(); |
| | | spi_peripheral_init(); |
| | | usartinit(); |
| | | rcc_init(); |
| | | gpio_init(); |
| | | systick_init(); |
| | | spi_peripheral_init(); |
| | | usartinit(); |
| | | } |