示例#1
0
文件: setup.c 项目: madex/stmbl
void setup(){
    //messpin
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
	GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_8 | GPIO_Pin_9;
 	GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_OUT;
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;
    GPIO_Init(GPIOB, &GPIO_InitStructure);

    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);//wird in UB_USB_CDC_Init() nochmal gesetzt!

	setup_usart();
    setup_res();

	// systick timer
	systime = 0;

	RCC_GetClocksFreq(&RCC_Clocks);
	SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
    //systick prio

    NVIC_SetPriority(SysTick_IRQn, 14);
}
示例#2
0
文件: main.c 项目: Bouni/MateDealer
int main(void) {

    setup_usart(0,38400,8,'N',1);
    setup_usart(1,9600,9,'N',1);
    
    sei();
    
    send_str_p(0,PSTR("MateDealer is up and running\r\n"));
       
    // Main Loop
    while(1) {
        mdb_cmd_handler();
        uplink_cmd_handler();
    }
    
    return 0;
}
void InitApp(void)
{
    Init_Periphs();
    setup_usart();
    go = 0;
    index_tab=0;

    Fixe_Rapport(0);
}
示例#4
0
int main(void)
{
    static unsigned int led_state = 0;

    RCC_ClocksTypeDef clockinfo;
    RCC_GetClocksFreq(&clockinfo);
    // regardless of clock speed this gives us 1000 ticks per second
    SysTick_Config(clockinfo.SYSCLK_Frequency / 1000);
    int blink_speed_ms = 400;

    setup_gpios();
    setup_adc();
    setup_usart();
    setup_button_irqs();

    kkputs("hello karl...\n");
    uint64_t lasttime = millis();
    while (1) {
        if (millis() - blink_speed_ms > lasttime) {
            if (led_state & 1) {
                switch_leds_on();
                kkputs("O");
            } else {
                switch_leds_off();
                kkputs("o");
            }
            led_state ^= 1;
            GPIO_TOGGLE(GPIOC, GPIO_Pin_3);
            lasttime = millis();
        }

        if (button_pressed) {
            button_pressed = 0;
            kkputs("button was pressed!\n");
            blink_speed_ms >>= 1;
            if (blink_speed_ms <= 50) {
                blink_speed_ms = 1000;
            }
        }

        // start and wait for adc to convert...
        ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 1, ADC_SampleTime_192Cycles);
        ADC_SoftwareStartConv(ADC1);
        while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == 0)
            ;

        uint16_t pot_val = ADC_GetConversionValue(ADC1);
        if (pot_val > 0x700) {
            GPIO_HIGH(GPIOA, GPIO_Pin_4);
        } else {
            GPIO_LOW(GPIOA, GPIO_Pin_4);
        }
    }
}
示例#5
0
/**
 * Main set up routine.
 */
void
setup(void) {
  setup_processor_clocks();
  setup_pins();
  setup_usart();
  setup_dma();

  // Enable low and medium level interrupts.
  PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm;

  /* Enable interrupts. */
  sei();
}
void InitApp(void)
{
	//stm32_Init ();
	Init_Periphs();
	 setup_usart();


	//lcd_init();
	initGenerateur(20, 800, 1000);

	cons.Vit = 0;
	//UART3->BRR = 0x823;
}