/** * @brief Get system tick clock frequency. * @param None * @retval None */ INT32U OS_CPU_SysTickClkFreq (void) { INT32U freq; freq = BSP_CPU_ClkFreq(); return (freq); }
void OSView_GetCPUName (INT8U *s) { INT8U cpu_clk_freq; cpu_clk_freq = (INT8U)(BSP_CPU_ClkFreq() / 1000000L); strcpy((char *)s, "ST STM32 (Cortex-M3) (xx MHz)"); s[22] = cpu_clk_freq / 10 + '0'; s[23] = cpu_clk_freq % 10 + '0'; }
CPU_INT64U CPU_TS64_to_uSec (CPU_TS64 ts_cnts) { CPU_INT64U ts_us; CPU_INT64U fclk_freq; fclk_freq = BSP_CPU_ClkFreq(); ts_us = ts_cnts / (fclk_freq / DEF_TIME_NBR_uS_PER_SEC); return (ts_us); }
void CPU_TS_TmrInit (void) { CPU_INT32U cpu_clk_freq_hz; DEM_CR |= (CPU_INT32U)DEM_CR_TRCENA; /* Enable Cortex-M3's DWT CYCCNT reg. */ DWT_CYCCNT = (CPU_INT32U)0u; DWT_CR |= (CPU_INT32U)DWT_CR_CYCCNTENA; cpu_clk_freq_hz = BSP_CPU_ClkFreq(); CPU_TS_TmrFreqSet(cpu_clk_freq_hz); }
/* ********************************************************************************************************* * 函 数 名: BSP_Init * 功能说明: 初始化CPU时钟、按键和LED灯GPIO、设置systick中断。这个函数由应用程序调用。 * 形 参:无 * 返 回 值: 无 ********************************************************************************************************* */ void BSP_Init (void) { bsp_InitLed(); /* 初始化LED的GPIO */ bsp_InitLCD(); bsp_InitTouch(); SysTick_Config(BSP_CPU_ClkFreq() / OS_TICKS_PER_SEC); }
void CPU_TS_TmrInit (void) { CPU_INT32U fclk_freq; fclk_freq = BSP_CPU_ClkFreq(); BSP_REG_DEM_CR |= (CPU_INT32U)BSP_BIT_DEM_CR_TRCENA; /* Enable Cortex-M4's DWT CYCCNT reg. */ BSP_REG_DWT_CYCCNT = (CPU_INT32U)0u; BSP_REG_DWT_CR |= (CPU_INT32U)BSP_BIT_DWT_CR_CYCCNTENA; CPU_TS_TmrFreqSet((CPU_TS_TMR_FREQ)fclk_freq); }
/* ********************************************************************************************************* * BSP_Tick_Init() * * Description : Initialize all the peripherals that required OS Tick services (OS initialized) * * Argument(s) : none. * * Return(s) : none. * * Caller(s) : Application. * * Note(s) : none. ********************************************************************************************************* */ void BSP_Tick_Init (void) { CPU_INT32U cpu_clk_freq; CPU_INT32U cnts; cpu_clk_freq = BSP_CPU_ClkFreq(); /* Determine SysTick reference freq. */ #if (OS_VERSION >= 30000u) cnts = cpu_clk_freq / (CPU_INT32U)OSCfg_TickRate_Hz; /* Determine nbr SysTick increments. */ #else cnts = cpu_clk_freq / (CPU_INT32U)OS_TICKS_PER_SEC; /* Determine nbr SysTick increments. */ #endif OS_CPU_SysTickInit(cnts); /* Init uC/OS periodic time src (SysTick). */ }
/* ********************************************************************************************************* * BSP_Tick_Init() * * Description : Initialize all the peripherals that required OS Tick services (OS initialized) * * Argument(s) : none. * * Return(s) : none. * * Caller(s) : Application. * * Note(s) : none. ********************************************************************************************************* */ void BSP_Tick_Init (void) { CPU_INT32U cpu_clk_freq; CPU_INT32U cnts; cpu_clk_freq = BSP_CPU_ClkFreq(); /* Determine SysTick reference freq. */ #if (OS_VERSION >= 30000u) cnts = cpu_clk_freq / (CPU_INT32U)OSCfg_TickRate_Hz; /* Determine nbr SysTick increments. */ #else cnts = cpu_clk_freq / (CPU_INT32U)OS_TICKS_PER_SEC; /* Determine nbr SysTick increments. */ #endif OS_CPU_SysTickInit(cnts); /* 这里默认的是最高优先级,根据实际情况修改 */ // SysTick_Config(cnts); //这里默认的是最低优先级 }
void AppTaskStart (void *p_arg) { CPU_INT32U cpu_clk_freq; CPU_INT32U cnts; (void)p_arg; cpu_clk_freq = BSP_CPU_ClkFreq(); /* Determine SysTick reference freq. */ cnts = cpu_clk_freq / (CPU_INT32U)OSCfg_TickRate_Hz; /* Determine nbr SysTick increments */ OS_CPU_SysTickInit(cnts); /* Init uC/OS periodic time src (SysTick). */ BSP_Init(); /* Initialize BSP functions */ main_loop(); }
static void AppTaskStart (void *p_arg) { CPU_INT32U cpu_clk_freq; CPU_INT32U cnts; OS_ERR err; CPU_TS ts; (void)p_arg; OSSemCreate(&AppSem, "Test Sem", 0, &err); BSP_Init(); /* Initialize BSP functions */ CPU_Init(); /* Initialize the uC/CPU services */ cpu_clk_freq = BSP_CPU_ClkFreq(); /* Determine SysTick reference freq. */ cnts = cpu_clk_freq / (CPU_INT32U)OSCfg_TickRate_Hz; /* Determine nbr SysTick increments */ OS_CPU_SysTickInit(cnts); /* Init uC/OS periodic time src (SysTick). */ #if OS_CFG_STAT_TASK_EN > 0u OSStatTaskCPUUsageInit(&err); /* Compute CPU capacity with no task running */ #endif CPU_IntDisMeasMaxCurReset(); BSP_LED_Off(0); while (DEF_TRUE) { /* Task body, always written as an infinite loop. */ BSP_LED_Toggle(0); #if 0 OSTimeDlyHMSM(0, 0, 0, 100, OS_OPT_TIME_HMSM_STRICT, &err); #endif OSSemPend(&AppSem, 100, OS_OPT_PEND_BLOCKING, &ts, &err); } }
static void AppTaskStart (void *p_arg) { CPU_INT32U clk_freq; CPU_INT32U cnts; OS_ERR err; (void)&p_arg; BSP_Init(); /* Initialize BSP functions */ CPU_Init(); /* Initialize the uC/CPU services */ clk_freq = BSP_CPU_ClkFreq(); /* Determine SysTick reference freq. */ cnts = clk_freq / (CPU_INT32U)OSCfg_TickRate_Hz; /* Determine nbr SysTick increments */ OS_CPU_SysTickInit(cnts); /* Init uC/OS periodic time src (SysTick). */ CPU_TS_TmrFreqSet(clk_freq); #if (OS_CFG_STAT_TASK_EN > 0u) OSStatTaskCPUUsageInit(&err); /* Compute CPU capacity with no task running */ #endif CPU_IntDisMeasMaxCurReset(); App_ProbeInit(); BSP_LED_On(1); BSP_LED_Off(2); AppDisplayTaskCreate(); while (DEF_ON) { /* Task body, always written as an infinite loop. */ OSTimeDlyHMSM(0u, 0u, 1u, 0u, OS_OPT_TIME_HMSM_STRICT, &err); BSP_LED_Toggle(0); /* Toggle both LEDs every second. */ bLED[0] ^= DEF_TRUE; bLED[1] ^= DEF_TRUE; } }
void BSP_Init (void) { BSP_IntInit(); /* Initialize Interrupts. */ BSP_REG_SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK /* Enable all the port Clocks */ | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK); /* Init System tick times. */ /* Clear pending interrupt. */ CPU_REG_NVIC_ST_RELOAD = (2000000UL); /* Set period. */ CPU_REG_NVIC_ST_CTRL |= SysTick_CSR_CLKSOURCE_MASK; /* Clock source - System Clock. */ CPU_REG_NVIC_ST_CTRL |= SysTick_CSR_TICKINT_MASK; /* Enable interrupt. */ CPU_REG_NVIC_ST_CTRL |= SysTick_CSR_ENABLE_MASK; /* Start Sys Timer. */ BSP_CPU_ClkFreq_MHz = BSP_CPU_ClkFreq() / (CPU_INT32U)1000000; BSP_CPU_ClkFreq_MHz = BSP_CPU_ClkFreq_MHz; /* Surpress compiler warning BSP_CPU_ClkFreq_MHz. */ BSP_PLL_Init(); BSP_LED_Init(); /* Initialize the I/Os for the LEDs. */ BSP_SW_Init(); /* Initialize the I/Os for the switches. */ BSP_TSI_Init(); /* Initialize the TSI module. */ BSP_IRC_Init(); /* Initialize the High-Speed Internal Reference Clock. */ #ifdef TRACE_EN /* See project / compiler preprocessor options. */ DBGMCU_CR |= DBGMCU_CR_TRACE_IOEN_MASK; /* Enable tracing (see Note #2). */ DBGMCU_CR &= ~DBGMCU_CR_TRACE_MODE_MASK; /* Clr trace mode sel bits. */ DBGMCU_CR |= DBGMCU_CR_TRACE_MODE_SYNC_04; /* Cfg trace mode to synch 4-bit. */ #endif }
static void AppTaskStart (void *p_arg) { CPU_INT32U cpu_clk_freq; CPU_INT32U cnts; OS_ERR err; (void)p_arg; BSP_Init(); /* Initialize BSP functions */ CPU_Init(); cpu_clk_freq = BSP_CPU_ClkFreq(); cnts = cpu_clk_freq / (CPU_INT32U)OSCfg_TickRate_Hz;/* Determine nbr SysTick increments */ OS_CPU_SysTickInit(cnts); /* Init uC/OS periodic time src (SysTick). */ #if OS_CFG_STAT_TASK_EN > 0u OSStatTaskCPUUsageInit(&err); /* Compute CPU capacity with no task running */ #endif CPU_IntDisMeasMaxCurReset(); //init USART1 BSP_Ser_Init(9600); BSP_Ser_WrStr("start"); //init ADC1, ACC sensor TERM_init_adc(); //init PWM TERM_init_pwm(); //AppTaskCreate(); /* Create application tasks */ TERM_createTask(); }
static void AppTaskStart (void *p_arg) { CPU_INT32U freq; CPU_INT32U cnts; OS_ERR err; (void)p_arg; BSP_Init(); /* Initialize BSP functions */ CPU_Init(); /* Initialize the uC/CPU services */ freq = BSP_CPU_ClkFreq(); /* Determine SysTick reference freq. */ cnts = freq / (CPU_INT32U)OSCfg_TickRate_Hz; /* Determine nbr SysTick increments */ OS_CPU_SysTickInit(cnts); /* Init uC/OS periodic time src (SysTick). */ #if OS_CFG_STAT_TASK_EN > 0u OSStatTaskCPUUsageInit(&err); /* Compute CPU capacity with no task running */ #endif #ifdef CPU_CFG_INT_DIS_MEAS_EN CPU_IntDisMeasMaxCurReset(); #endif AppEventCreate(); /* Create Application Kernel objects */ AppTaskCreate(); /* Create application tasks */ while (DEF_TRUE) { /* Task body, always written as an infinite loop. */ OSTimeDlyHMSM(0, 0, 0, 200, /* Delay task for 200 ms */ OS_OPT_TIME_HMSM_STRICT, &err); } }
void BSP_Init (void) { //gpc 2-2-2011 BSP_IntInit(); RCC_DeInit(); RCC_HSEConfig(RCC_HSE_ON); /* HSE = 25MHz ext. crystal. */ RCC_WaitForHSEStartUp(); RCC_PREDIV2Config(RCC_PREDIV2_Div5); /* Fprediv2 = HSE / 5 = 5MHz. */ RCC_PLL2Config(RCC_PLL2Mul_8); /* PLL2 = Fprediv2 * 8 = 40MHz. */ RCC_PLL2Cmd(ENABLE); RCC_PLL3Config(RCC_PLL3Mul_10); /* PLL3 = Fprediv2 * 10 = 50MHz. */ RCC_PLL3Cmd(ENABLE); RCC_HCLKConfig(RCC_SYSCLK_Div1); /* HCLK = AHBCLK = PLL1 / AHBPRES(1) = 72MHz. */ RCC_PCLK2Config(RCC_HCLK_Div1); /* APB2CLK = AHBCLK / APB2DIV(1) = 72MHz. */ RCC_PCLK1Config(RCC_HCLK_Div2); /* APB1CLK = AHBCLK / APB1DIV(2) = 36MHz (max). */ RCC_ADCCLKConfig(RCC_PCLK2_Div6); /* ADCCLK = AHBCLK / APB2DIV / 6 = 12MHz. */ RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLL1VCO_Div3); /* OTGCLK = PLL1VCO / USBPRES(3) = 144MHz / 3 = 48MHz */ FLASH_SetLatency(FLASH_Latency_2); /* 2 Flash wait states when HCLK > 48MHz. */ FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET) { /* Wait for PLL2 to lock. */ ; } while (RCC_GetFlagStatus(RCC_FLAG_PLL3RDY) == RESET) { /* Wait for PLL3 to lock. */ ; } /* Fprediv1 = PLL2 / 5 = 8MHz. */ RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div5); RCC_PLL1Config(RCC_PLL1Source_PREDIV1, RCC_PLL1Mul_9); /* PLL1 = Fprediv1 * 9 = 72Mhz. */ RCC_PLL1Cmd(ENABLE); while (RCC_GetFlagStatus(RCC_FLAG_PLL1RDY) == RESET) { /* Wait for PLL1 to lock. */ ; } RCC_SYSCLKConfig(RCC_SYSCLKSource_PLL1CLK); /* HCLK = SYSCLK = PLL1 = 72MHz. */ while (RCC_GetSYSCLKSource() != 0x08) { ; } BSP_CPU_ClkFreq_MHz = BSP_CPU_ClkFreq() / (CPU_INT32U)1000000; BSP_CPU_ClkFreq_MHz = BSP_CPU_ClkFreq_MHz; /* Surpress compiler warning BSP_CPU_ClkFreq_MHz ... */ /* ... set and not used. */ BSP_LED_Init(); /* Initialize the I/Os for the LED controls. */ BSP_StatusInit(); /* Initialize the status input(s) */ #ifdef TRACE_EN /* See project / compiler preprocessor options. */ DBGMCU_CR |= DBGMCU_CR_TRACE_IOEN_MASK; /* Enable tracing (see Note #2). */ DBGMCU_CR &= ~DBGMCU_CR_TRACE_MODE_MASK; /* Clr trace mode sel bits. */ DBGMCU_CR |= DBGMCU_CR_TRACE_MODE_SYNC_04; /* Cfg trace mode to synch 4-bit. */ #endif }
void SevenSegDisp_Init (void) { INT32U cpu_frq; INT32U bus_frq; INT8U ECT_Prescaler; DDRP |= 0x0F; /* Set the 7-Segment Enable I/O pins to output */ actBlockNum = 0; /* Set display 0 as the first active LED display block */ cpu_frq = BSP_CPU_ClkFreq(); /* Get the current CPU frequency */ bus_frq = cpu_frq / 2; /* Derive the BUS frequency from the CPU frequency */ ECT_Prescaler = TSCR2 & 0x07; /* Get the prescaler value in the control register */ ECT_Prescaler = (1 << ECT_Prescaler); /* Calculate the correct prescaler value from the reg val */ /* Calculate the # of ticks for an interrupt period of 1ms */ nbrCnts = (INT16U)((bus_frq / (ECT_Prescaler * 225)) - 1); /* 225 represents 225 ticks in 1 second, each tick ~4ms */ #if SEVEN_SEG_OC == 0 TIOS |= 0x01; /* Make channel an output compare */ TC0 = TCNT + nbrCnts; /* Set TC0 to present time + nbrCnts */ TIE |= 0x01; /* Enable OC0 interrupt. */ #endif #if SEVEN_SEG_OC == 1 TIOS |= 0x02; /* Make channel an output compare */ TC1 = TCNT + nbrCnts; /* Set TC1 to present time + nbrCnts */ TIE |= 0x02; /* Enable OC1 interrupt. */ #endif #if SEVEN_SEG_OC == 2 TIOS |= 0x04; /* Make channel an output compare */ TC2 = TCNT + nbrCnts; /* Set TC2 to present time + nbrCnts */ TIE |= 0x04; /* Enable OC2 interrupt. */ #endif #if SEVEN_SEG_OC == 3 TIOS |= 0x08; /* Make channel an output compare */ TC3 = TCNT + nbrCnts; /* Set TC3 to present time + nbrCnts */ TIE |= 0x08; /* Enable OC3 interrupt. */ #endif #if SEVEN_SEG_OC == 4 TIOS |= 0x10; /* Make channel an output compare */ TC4 = TCNT + nbrCnts; /* Set TC4 to present time + nbrCnts */ TIE |= 0x10; /* Enable OC4 interrupt. */ #endif #if SEVEN_SEG_OC == 5 TIOS |= 0x20; /* Make channel an output compare */ TC5 = TCNT + nbrCnts; /* Set TC5 to present time + nbrCnts */ TIE |= 0x20; /* Enable OC5 interrupt. */ #endif #if SEVEN_SEG_OC == 6 TIOS |= 0x40; /* Make channel an output compare */ TC6 = TCNT + nbrCnts; /* Set TC6 to present time + nbrCnts */ TIE |= 0x40; /* Enable OC6 interrupt. */ #endif #if SEVEN_SEG_OC == 7 TIOS |= 0x80; /* Make channel an output compare */ TC7 = TCNT + nbrCnts; /* Set TC7 to present time + nbrCnts */ TIE |= 0x80; /* Enable OC7 interrupt. */ #endif TSCR1 = 0xC0; /* Enable counter & disable counter in background mode */ }
void AppTaskStart (void *p_arg) { CPU_INT32U cpu_clk_freq; CPU_INT32U cnts; OS_ERR err; (void)p_arg; BSP_Init(); /* Initialize BSP functions */ cpu_clk_freq = BSP_CPU_ClkFreq(); /* Determine SysTick reference freq. */ cnts = cpu_clk_freq / (CPU_INT32U)OSCfg_TickRate_Hz; /* Determine nbr SysTick increments */ OS_CPU_SysTickInit(cnts); /* Init uC/OS periodic time src (SysTick). */ //OS_CPU_SysTickInit(720000); OSSemCreate(&AppSem, "Test Sem", 0, &err); OSTaskCreate((OS_TCB *)&LEDATaskStkTCB, (CPU_CHAR *)"leda task", (OS_TASK_PTR)leda_task_core, (void * )0, (OS_PRIO)OS_TASK_LEDA_PRIO, (CPU_STK *)&LEDATaskStk[0], (CPU_STK_SIZE)OS_LEDA_TASK_STACK_SIZE/10, (CPU_STK_SIZE)OS_LEDA_TASK_STACK_SIZE, (OS_MSG_QTY) 0, (OS_TICK) 0, (void *)0, (OS_OPT)(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), (OS_ERR*)&err); OSTaskCreate((OS_TCB *)&LEDBTaskStkTCB, (CPU_CHAR *)"ledb task", (OS_TASK_PTR)ledb_task_core, (void * )0, (OS_PRIO)OS_TASK_LEDB_PRIO, (CPU_STK *)&LEDBTaskStk[0], (CPU_STK_SIZE)OS_LEDB_TASK_STACK_SIZE/10, (CPU_STK_SIZE)OS_LEDB_TASK_STACK_SIZE, (OS_MSG_QTY) 0, (OS_TICK) 0, (void *)0, (OS_OPT)(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), (OS_ERR*)&err); #if OS_CFG_STAT_TASK_EN > 0u OSStatTaskCPUUsageInit(&err); /* Compute CPU capacity with no task running */ #endif #if OS_CFG_APP_HOOKS_EN > 0u App_OS_SetAllHooks(); #endif while (1) { /* Task body, always written as an infinite loop. */ GPIOG->ODR^=1<<0; OSTimeDlyHMSM(0, 0, 0, 500,OS_OPT_TIME_HMSM_STRICT,&err); } }
CPU_BOOLEAN BSP_SerInit (CPU_DATA port_id, CPU_INT32U baud_rate) { LM3SXXXX_STRUCT_UART *uart; CPU_INT32U idiv; CPU_INT32U fdiv; CPU_INT32U clk_freq; if (port_id > BSP_SER_PORT_NBR_MAX) { return (DEF_NO); } /* --------------- COMPUTE DIV BAUD RATE -------------- */ clk_freq = BSP_CPU_ClkFreq(); idiv = clk_freq / (16u * baud_rate); fdiv = clk_freq % (16u * baud_rate); fdiv = ((((2u * fdiv * 4u) / baud_rate) + 1u) / 2u); /* --------------------- INIT PORT -------------------- */ switch (port_id) { case BSP_SER_ID_UART0: SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralReset(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); uart = (LM3SXXXX_STRUCT_UART *)LM3SXXXX_BASE_UART0; break; #if (BSP_SER_PORT_NBR_MAX >= BSP_SER_ID_UART1) case BSP_SER_ID_UART1: SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); SysCtlPeripheralReset(SYSCTL_PERIPH_UART1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3); uart = (LM3SXXXX_STRUCT_UART *)LM3SXXXX_BASE_UART1; break; #endif #if (BSP_SER_PORT_NBR_MAX >= BSP_SER_ID_UART2) case BSP_SER_ID_UART2: SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2); SysCtlPeripheralReset(SYSCTL_PERIPH_UART2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); GPIOPinTypeUART(GPIO_PORTG_BASE, GPIO_PIN_0 | GPIO_PIN_1); uart = (LM3SXXXX_STRUCT_UART *)LM3SXXXX_BASE_UART2; break; #endif default: return (DEF_NO); } uart->IBRD = idiv; uart->FBRD = fdiv; uart->LCRH = LM3SXXXX_BIT_UARTLCRH_WLEN_8 | LM3SXXXX_BIT_UARTLCRH_FEN; uart->FR = 0x00000000; uart->CTL = LM3SXXXX_BIT_UARTCTL_RXE | LM3SXXXX_BIT_UARTCTL_TXE | LM3SXXXX_BIT_UARTCTL_UARTEN; uart->IFLS = 0x00000000; uart->ICR = LM3SXXXX_BIT_UARTINT_OE | LM3SXXXX_BIT_UARTINT_BE | LM3SXXXX_BIT_UARTINT_PE | LM3SXXXX_BIT_UARTINT_FE | LM3SXXXX_BIT_UARTINT_RT | LM3SXXXX_BIT_UARTINT_TX | LM3SXXXX_BIT_UARTINT_RX; return (DEF_YES); }
CPU_INT32U BSP_PeriphClkFreqGet (CPU_DATA pwr_clk_id) { CPU_INT32U clk_freq; CPU_INT32U clk_div; clk_freq = BSP_CPU_ClkFreq(); switch (pwr_clk_id) { case BSP_PERIPH_ID_DMA1: case BSP_PERIPH_ID_DMA2: case BSP_PERIPH_ID_SRAM: case BSP_PERIPH_ID_FLITF: case BSP_PERIPH_ID_CRC: case BSP_PERIPH_ID_FSMC: case BSP_PERIPH_ID_SDIO: return (clk_freq); case BSP_PERIPH_ID_AFIO: case BSP_PERIPH_ID_IOPA: case BSP_PERIPH_ID_IOPB: case BSP_PERIPH_ID_IOPC: case BSP_PERIPH_ID_IOPD: case BSP_PERIPH_ID_IOPE: case BSP_PERIPH_ID_IOPF: case BSP_PERIPH_ID_IOPG: case BSP_PERIPH_ID_ADC1: case BSP_PERIPH_ID_ADC2: case BSP_PERIPH_ID_TIM1: case BSP_PERIPH_ID_SPI1: case BSP_PERIPH_ID_TIM8: case BSP_PERIPH_ID_USART1: case BSP_PERIPH_ID_ADC3: clk_div = (BSP_PERIPH_REG_RCC_CFGR & 0x00003800) >> 11; if (clk_div < 4) { return (clk_freq); } clk_div = (clk_div - 3) << 1; clk_freq /= clk_div; return (clk_freq); case BSP_PERIPH_ID_TIM2: case BSP_PERIPH_ID_TIM3: case BSP_PERIPH_ID_TIM4: case BSP_PERIPH_ID_TIM5: case BSP_PERIPH_ID_TIM6: case BSP_PERIPH_ID_TIM7: case BSP_PERIPH_ID_WWDG: case BSP_PERIPH_ID_SPI2: case BSP_PERIPH_ID_SPI3: case BSP_PERIPH_ID_USART2: case BSP_PERIPH_ID_USART3: case BSP_PERIPH_ID_USART4: case BSP_PERIPH_ID_USART5: case BSP_PERIPH_ID_I2C1: case BSP_PERIPH_ID_I2C2: case BSP_PERIPH_ID_USB: case BSP_PERIPH_ID_CAN: case BSP_PERIPH_ID_BKP: case BSP_PERIPH_ID_PWR: case BSP_PERIPH_ID_DAC: clk_div = (BSP_PERIPH_REG_RCC_CFGR & 0x00000700) >> 8; if (clk_div < 4) { return (clk_freq); } clk_div = (clk_div - 3) << 1; clk_freq /= clk_div; return (clk_freq); } return ((CPU_INT32U)0); }