void machine_init(struct fnode * dev) { # if CONFIG_SYS_CLOCK == 48000000 rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_48MHZ]); # elif CONFIG_SYS_CLOCK == 84000000 rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_84MHZ]); # elif CONFIG_SYS_CLOCK == 120000000 rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_120MHZ]); # elif CONFIG_SYS_CLOCK == 168000000 rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]); # else #error No valid clock speed selected #endif #ifdef CONFIG_DEVGPIO gpio_init(dev, gpio_addrs, NUM_GPIOS); #endif #ifdef CONFIG_DEVUART uart_init(dev, uart_addrs, NUM_UARTS); #endif #ifdef CONFIG_RNG rng_init(dev, rng_addrs, NUM_RNGS); #endif #ifdef CONFIG_DEVSTM32SDIO stm32_sdio_rcc_init(); stm32_sdio_init(dev); #endif #ifdef CONFIG_DEVSTMETH gpio_clear(GPIOE,GPIO2); /* Clear ETH nRESET pin */ gpio_set(GPIOE,GPIO2); /* Set ETH nRESET pin */ #endif }
void mcu_arch_init(void) { #if LUFTBOOT PRINT_CONFIG_MSG("We are running luftboot, the interrupt vector is being relocated.") #if defined STM32F4 SCB_VTOR = 0x00004000; #else SCB_VTOR = 0x00002000; #endif #endif #if EXT_CLK == 8000000 #if defined(STM32F1) PRINT_CONFIG_MSG("Using 8MHz external clock to PLL it to 72MHz.") rcc_clock_setup_in_hse_8mhz_out_72mhz(); #elif defined(STM32F4) PRINT_CONFIG_MSG("Using 8MHz external clock to PLL it to 168MHz.") rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]); #endif #elif EXT_CLK == 12000000 #if defined(STM32F1) PRINT_CONFIG_MSG("Using 12MHz external clock to PLL it to 72MHz.") rcc_clock_setup_in_hse_12mhz_out_72mhz(); #elif defined(STM32F4) PRINT_CONFIG_MSG("Using 12MHz external clock to PLL it to 168MHz.") rcc_clock_setup_hse_3v3(&rcc_hse_12mhz_3v3[RCC_CLOCK_3V3_168MHZ]); #endif #elif EXT_CLK == 16000000 #if defined(STM32F4) PRINT_CONFIG_MSG("Using 16MHz external clock to PLL it to 168MHz.") rcc_clock_setup_hse_3v3(&rcc_hse_16mhz_3v3[RCC_CLOCK_3V3_168MHZ]); #endif #elif EXT_CLK == 24000000 #if defined(STM32F4) PRINT_CONFIG_MSG("Using 24MHz external clock to PLL it to 168MHz.") rcc_clock_setup_hse_3v3(&rcc_hse_24mhz_3v3[RCC_CLOCK_3V3_168MHZ]); #elif defined(STM32F1) rcc_clock_setup_in_hse_24mhz_out_24mhz_pprz(); #endif #elif EXT_CLK == 25000000 #if defined(STM32F4) PRINT_CONFIG_MSG("Using 25MHz external clock to PLL it to 168MHz.") rcc_clock_setup_hse_3v3(&rcc_hse_25mhz_3v3[RCC_CLOCK_3V3_168MHZ]); #endif #else #error EXT_CLK is either set to an unsupported frequency or not defined at all. Please check! #endif /* Configure priority grouping 0 bits for pre-emption priority and 4 bits for sub-priority. * this was previously in i2c driver * FIXME is it really needed ? */ scb_set_priority_grouping(SCB_AIRCR_PRIGROUP_NOGROUP_SUB16); }
static void setup(void) { // rcc rcc_clock_setup_hse_3v3(&rcc_hse_25mhz_3v3[RCC_CLOCK_3V3_168MHZ]); // systick systick_init(); // LED ping LED_ping_init(); // tty tty_init(&my_tty); // USB CDC/ACM cdcacm_init(); // TTY stdio tty_stdio_init(&my_tty); // connect TTY to USB. cdcacm_register_receive_callback(usb_to_tty); tty_register_send_callback(&my_tty, tty_to_usb); // wait for user to connect. cdcacm_open(); }
void mew_start_all_clock(void) { rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]); //pwr_disable_backup_domain_write_protect(); rcc_periph_clock_enable(RCC_SYSCFG); //rcc_periph_clock_enable(RCC_RTC); //rcc_periph_clock_enable(RCC_BKPSRAM); //rcc_periph_clock_enable(RCC_ADC1); rcc_periph_clock_enable(RCC_GPIOA); rcc_periph_clock_enable(RCC_GPIOB); rcc_periph_clock_enable(RCC_GPIOC); rcc_periph_clock_enable(RCC_GPIOD); rcc_periph_clock_enable(RCC_GPIOE); rcc_periph_clock_enable(RCC_DMA1); rcc_periph_clock_enable(RCC_DMA2); //rcc_periph_clock_enable(RCC_TIM2); rcc_periph_clock_enable(RCC_USART2); rcc_periph_clock_enable(RCC_USART1); rcc_periph_clock_enable(RCC_SPI1); rcc_periph_clock_enable(RCC_SPI2); rcc_periph_clock_enable(RCC_OTGFS); rcc_periph_clock_enable(RCC_I2C3); rcc_periph_clock_enable(RCC_RNG); rcc_periph_clock_enable(RCC_CRYP); rcc_periph_clock_enable(RCC_CRC); rcc_periph_clock_enable(RCC_HASH); }
/* Set STM32 to 168 MHz. */ static void clock_setup(void) { rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]); /* Enable GPIOD clock. */ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN); }
int main(void) { /* Check the force bootloader pin*/ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN); if(!gpio_get(GPIOA, GPIO0)) dfu_jump_app_if_valid(); dfu_protect_enable(); /* Set up clock*/ rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]); systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8); systick_set_reload(2100000); systick_interrupt_enable(); systick_counter_enable(); /* Handle LED */ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN); gpio_clear(GPIOA, GPIO4); gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO4); /* Set up USB*/ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN); rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_OTGFSEN); /* Set up USB Pins and alternate function*/ gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO10 | GPIO11 | GPIO12); gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO10| GPIO11 | GPIO12); dfu_init(&stm32f107_usb_driver); dfu_main(); }
int main(void) { for (u32 i = 0; i < 600000; i++) __asm__("nop"); led_setup(); rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_65_472MHz_out_3v3); debug_setup(); printf("\n\nFirmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n"); printf("--- DEBUG TEST ---\n"); debug_register_callback(0x22, &foo_callback, &foo_callback_node); debug_register_callback(0x42, &led_callback, &led_callback_node); while(1) { debug_process_messages(); for (u32 i = 0; i < 600000; i++) __asm__("nop"); } while (1); return 0; }
/* Set STM32 to 168 MHz. */ static void clock_setup(void) { rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]); /* Enable GPIOG clock. */ rcc_periph_clock_enable(RCC_GPIOG); }
int platform_init(void) { rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]); /* Enable peripherals */ rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_OTGFSEN); rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN); rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPBEN); rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN); /* Fix all flaoting pins*/ gpio_mode_setup(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_PULLDOWN, 0x1ff); gpio_mode_setup(GPIOB, GPIO_MODE_INPUT, GPIO_PUPD_PULLDOWN, 0xffe2); gpio_mode_setup(GPIOC, GPIO_MODE_INPUT, GPIO_PUPD_PULLDOWN, 0xf3ff); /* Set up USB Pins and alternate function*/ gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO10| GPIO11 | GPIO12); gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO10| GPIO11 | GPIO12); /* Set TMS/TCK/TDI to high speed*/ GPIOA_OSPEEDR &=~0xfc00; GPIOA_OSPEEDR |= 0xa800; gpio_mode_setup(JTAG_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, TMS_PIN | TCK_PIN | TDI_PIN); gpio_mode_setup(TDO_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE, TDO_PIN | TRST_PIN); gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_UART ); /* Setup heartbeat timer */ systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8); systick_set_reload(168000000/(10*8)); /* Interrupt us at 10 Hz */ SCB_SHPR(11) &= ~((15 << 4) & 0xff); SCB_SHPR(11) |= ((14 << 4) & 0xff); systick_interrupt_enable(); systick_counter_enable(); usbuart_init(); SCB_VTOR = 0x10000; // Relocate interrupt vector table here cdcacm_init(); jtag_scan(NULL); return 0; }
void system_cm3_setup ( void ) { #if 1 // go for 120MHz, built into libopencm3 // requires: external 8MHz crystal on pin5/6 with associated caps to ground rcc_clock_setup_hse_3v3 ( &hse_8mhz_3v3 [ CLOCK_3V3_168MHZ ] ); //rcc_clock_setup_hse_3v3 ( &hse_8mhz_3v3 [ CLOCK_3V3_120MHZ ] ); #endif }
static void rcc_setup(void) { rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_120MHZ]); /* Enable GPIOD clock for onboard leds. */ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN); /* Enable rng clock */ rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_RNGEN); }
void system_init(void) { rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]); leds_init(); adc_init(); cdcacm_init(); printled(4, LRED); DTC_SVM_tim_init(); }
static void rcc_setup(void) { rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_120MHZ]); /* Enable GPIOD clock for onboard leds. */ rcc_periph_clock_enable(RCC_GPIOD); /* Enable rng clock */ rcc_periph_clock_enable(RCC_RNG); }
static void setup(void) { rcc_clock_setup_hse_3v3(&MY_CLOCK); setup_systick(MY_CLOCK.ahb_frequency); setup_heartbeat(); my_ILI.begin(); }
void system_init(void) { rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]); leds_init(); hall_init(); cdcacm_init(); printled(4, LRED); tim_init(); adc_init(); test_ports_init(); stdin_init(); }
/* Set STM32 to 168 MHz. */ void clock_setup(void) { rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]); /* Enable GPIOD clock for LED & USARTs. */ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN); rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN); /* Enable clocks for USART6. */ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART6EN); }
int main(void) { for (u32 i = 0; i < 600000; i++) __asm__("nop"); led_setup(); rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_65_472MHz_out_3v3); debug_setup(); timer_setup(); // Debug pins (CC1111 TX/RX) RCC_AHB1ENR |= RCC_AHB1ENR_IOPCEN; gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO10|GPIO11); gpio_clear(GPIOC, GPIO10|GPIO11); printf("\n\nFirmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n"); printf("--- DEBUG TEST ---\n"); u32 len; for (u8 i=0; i<30; i++) { guard_below[i] = 0; guard_above[i] = 0; } for (u32 i=0; i<256; i++) buff_out[i] = (u8)i; while(1) { /* Random transmit length. */ len = (u32)rand() % 256; while(debug_send_msg(0x22, len, buff_out)); /* Check the guards for buffer over/underrun. */ for (u8 i=0; i<30; i++) { if (guard_below[i] != 0) screaming_death(); if (guard_above[i] != 0) screaming_death(); } /* Introduce some timing jitter. */ u32 jitter_delay = ((u32)rand() % 20000); for (u32 i = 0; i < jitter_delay; i++) /*for (u32 i = 0; i < 1000; i++)*/ __asm__("nop"); } while (1); return 0; }
void msc_target_init(void) { rcc_clock_setup_hse_3v3(&rcc_hse_25mhz_3v3); rcc_periph_clock_enable(RCC_GPIOA); rcc_periph_clock_enable(RCC_OTGFS); gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO11 | GPIO12); gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO11 | GPIO12); }
static void clock_setup(void) { // Set STM32 to 168 MHz rcc_clock_setup_hse_3v3(&hse_25mhz_3v3[CLOCK_3V3_168MHZ]); // Enable GPIO clock rcc_periph_clock_enable(RCC_GPIOA); rcc_periph_clock_enable(RCC_GPIOB); rcc_periph_clock_enable(RCC_GPIOC); rcc_periph_clock_enable(RCC_GPIOD); }
void clock_setup(void) { rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]); /* set up the SysTick function (1mS interrupts) */ systick_set_clocksource(STK_CSR_CLKSOURCE_AHB); STK_CVR = 0; systick_set_reload(rcc_ahb_frequency / 1000); systick_counter_enable(); systick_interrupt_enable(); }
void dac_init(void) { rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_120MHZ]); //nastaveni globalnich hodin rcc_periph_clock_enable(RCC_GPIOA); //pusteni hodin pro port A rcc_periph_clock_enable(RCC_DAC); //pusteni hodin pro DAC gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO4); //pin4 portu A nako analogovy bez pullu/pulldown dac_disable(CHANNEL_1); //zakazani kanalu 1 DAC dac_disable_waveform_generation(CHANNEL_1); //bastaveni generovani signalu na kanalu 1 DAC dac_enable(CHANNEL_1); //Povoleni DAC na kanalu 1 dac_set_trigger_source(DAC_CR_TSEL1_SW); //Triger kanalu 1 nastaven na softwarovy }
int main(void) { for (u32 i = 0; i < 600000; i++) __asm__("nop"); led_setup(); rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_65_472MHz_out_3v3); usart_setup_common(); usart_tx_dma_setup(); /*printf("\n\nFirmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n");*/ /*printf("--- USART DMA TEST ---\n");*/ #define MAX_TX ((u32)(USART_TX_BUFFER_LEN*1.2)) u8 guard_below[30]; u8 buff_out[MAX_TX]; u8 guard_above[30]; u32 len; for (u8 i=0; i<30; i++) { guard_below[i] = 0; guard_above[i] = 0; } for (u32 i=0; i<MAX_TX; i++) buff_out[i] = (u8)i; while(1) { /* Random transmit length. */ len = (u32)rand() % MAX_TX; while (len) len -= usart_write_dma(buff_out, len); /* Check the guards for buffer over/underrun. */ for (u8 i=0; i<30; i++) { if (guard_below[i] != 0) screaming_death(); if (guard_above[i] != 0) screaming_death(); } /* Introduce some timing jitter. */ for (u32 i = 0; i < ((u32)rand() % 10000); i++) __asm__("nop"); } while (1); return 0; }
static void clock_setup(void) { /* Enable high-speed clock at 120MHz */ rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_120MHZ]); /* Enable GPIOD clock for LED & USARTs. */ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN); rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN); /* Enable clocks for USART2. */ rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN); }
static void clock_setup(void) { /* Enable high-speed clock at 120MHz */ rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_120MHZ]); /* Enable GPIOD clock for LED & USARTs. */ rcc_periph_clock_enable(RCC_GPIOD); rcc_periph_clock_enable(RCC_GPIOA); /* Enable clocks for USART2. */ rcc_periph_clock_enable(RCC_USART2); }
/* * clock_setup(void) * * This function sets up both the base board clock rate * and a 1khz "system tick" count. The SYSTICK counter is * a standard feature of the Cortex-M series. */ void clock_setup(void) { /* Base board frequency, set to 168Mhz */ rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]); /* clock rate / 168000 to get 1mS interrupt rate */ systick_set_reload(168000); systick_set_clocksource(STK_CSR_CLKSOURCE_AHB); systick_counter_enable(); /* this done last */ systick_interrupt_enable(); }
void machine_init(struct fnode * dev) { # if CONFIG_SYS_CLOCK == 168000000 rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]); # elif CONFIG_SYS_CLOCK == 84000000 rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_84MHZ]); # elif CONFIG_SYS_CLOCK == 48000000 rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_48MHZ]); # else #error No valid clock speed selected for STM32F429 Discovery #endif #ifdef CONFIG_DEVGPIO gpio_init(dev, gpio_addrs, NUM_GPIOS); #endif #ifdef CONFIG_DEVUART uart_init(dev, uart_addrs, NUM_UARTS); #endif #ifdef CONFIG_RNG rng_init(dev, rng_addrs, NUM_RNGS); #endif }
/* * clock_init() - Clock initialization * * INPUT * none * OUTPUT * none * */ static void clock_init(void) { clock_scale_t clock = hse_8mhz_3v3[CLOCK_3V3_120MHZ]; rcc_clock_setup_hse_3v3(&clock); rcc_periph_clock_enable(RCC_GPIOA); rcc_periph_clock_enable(RCC_GPIOB); rcc_periph_clock_enable(RCC_GPIOC); rcc_periph_clock_enable(RCC_OTGFS); rcc_periph_clock_enable(RCC_SYSCFG); rcc_periph_clock_enable(RCC_TIM4); rcc_periph_clock_enable(RCC_RNG); rcc_periph_clock_enable(RCC_CRC); }
static void clock_setup(void) { rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]); /* Enable GPIOD clock for LED & USARTs. */ rcc_periph_clock_enable(RCC_GPIOD); rcc_periph_clock_enable(RCC_GPIOA); /* Enable clocks for USART2 and dac */ rcc_periph_clock_enable(RCC_USART2); rcc_periph_clock_enable(RCC_DAC); /* And ADC*/ rcc_periph_clock_enable(RCC_ADC1); }
void usb_gpio_init(void) { /* GPIO9 to sniff VBUS */ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN); gpio_mode_setup(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_PULLDOWN, GPIO9); rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_120MHZ]); rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN); rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_OTGFSEN); gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO11 | GPIO12); gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO11 | GPIO12); }
static void clock_setup(void) { rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]); /* Enable GPIOD clock for LED & USARTs. */ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN); rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN); /* Enable clocks for USART2 and dac */ rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN); rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_DACEN); /* And ADC*/ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_ADC1EN); }