Пример #1
0
/**
 * @brief Fades the error LED on and off
 * @sideeffect Sets output push-pull on ERROR_LED_PIN.
 */
void throb(void) {
#ifdef HAVE_ERROR_LED
    int32  slope   = 1;
    uint32 CC      = 0x0000;
    uint32 TOP_CNT = 0x0800;
    uint32 i       = 0;

    gpio_set_mode(ERROR_LED_PIN, GPIO_OUTPUT_PP);
    /* Error fade. */
    while (1) {
        if (CC == TOP_CNT)  {
            slope = -1;
        } else if (CC == 0) {
            slope = 1;
        }

        if (i == TOP_CNT)  {
            CC += slope;
            i = 0;
        }

        if (i < CC) {
            gpio_set_pin(ERROR_LED_PIN);
        } else {
            gpio_clear_pin(ERROR_LED_PIN);
        }
        i++;
    }
#else
    /* No error LED is defined; do nothing. */
    while (1)
        ;
#endif
}
Пример #2
0
void system_setup(void) {
	init_pll_clock(PLL_SRC_HSE, 16, 336, 0, 7);	// (M, N, P ,Q) => 168 MHz PLL clock
	init_timer_2(168, 1000);
	gpio_d_clk_enable();
	gpio_init( 	GPIOD,
				GPIO_PIN_N15 | GPIO_PIN_N14 | GPIO_PIN_N13 | GPIO_PIN_N12,
				GPIO_PIN_MODE_OUTPUT,
				GPIO_PIN_OTYPE_PP,
				GPIO_PIN_PULL_NONE,
				GPIO_PIN_SPEED_VHIGH);
	gpio_clear_pin(GPIOD, GPIO_PIN_N15 | GPIO_PIN_N14 | GPIO_PIN_N13 | GPIO_PIN_N12);
	init_uart_2();									// UART 2 Rx->PD6 Tx->PD5
	init_uart_3();									// UART 3 Rx->PB11 Tx->PB10
	uart_2_send_string("STM32 initialization complete\n\r");
}