Example #1
0
File: main.c Project: sandves/Sonar
static void init_HC_SR04()
{
	init_gpio();
	init_timer2();
	servo_control_init();
	init_usart();
}
Example #2
0
int main(int argc, const char *argv[])
{
	unsigned char i;
	LCDInit(LS_NONE);
	LCDClear();

	// Initialize usart
	init_usart(BAUDRATE, TRANSMIT_RATE, DATA_BITS, STOP_BITS, PARITY_BITS);

	char recipe_name[RECIPE_NAME_LENGTH];

    eeprom_read_block((void*)&recipe_name, (const void*)0x00, RECIPE_NAME_LENGTH);
    
	LCDWriteString("Recipe Name:");
	LCDWriteStringXY(0,1,recipe_name);

	for(i=0;i<25;i++) _delay_loop_2(0);
	
	// Clear second row
	LCDWriteStringXY(0,1,"                ");
    eeprom_read_block((void*)&recipe_name, (const void*)0x76, RECIPE_NAME_LENGTH);

	LCDWriteString("Recipe Name:");
	LCDWriteStringXY(0,1,recipe_name);

	return 0;
}
Example #3
0
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) {
    if (data_bits == 8) {
        obj->databits = USART_WordLength_8b;
    } else {
        obj->databits = USART_WordLength_9b;
    }

    switch (parity) {
        case ParityOdd:
        case ParityForced0:
            obj->parity = USART_Parity_Odd;
            break;
        case ParityEven:
        case ParityForced1:
            obj->parity = USART_Parity_Even;
            break;
        default: // ParityNone
            obj->parity = USART_Parity_No;
            break;
    }

    if (stop_bits == 2) {
        obj->stopbits = USART_StopBits_2;
    } else {
        obj->stopbits = USART_StopBits_1;
    }

    init_usart(obj);
}
Example #4
0
int main() {
    init_clock();
    init_gpio();
    init_usart();
    init_pwm();
    while(1) {}
}
Example #5
0
static int btm_bluetooth_init(void) {
	irq_attach(OPTION_GET(NUMBER,irq_num), btm_bt_us_handler, 0, NULL, "bt reader");
	// TODO error handling?

	init_usart();
	return 0;
}
Example #6
0
void SystemInit()
{
	FLASH->ACR = 0x00000012;
	init_clock();
	init_lcd();
	init_port();
	init_usart();
}
static bool _config_cb(void *cfg_cb_arg, const size_t bits,
                       const size_t parity, const size_t stop_bits,
                       const size_t baud)
{
        USART_TypeDef *usart = cfg_cb_arg;
        init_usart(usart, bits, parity, stop_bits, baud);
        return true;
}
Example #8
0
int main(void)
{
	SREG = 0x80;	/*ENABLE GLOBAL INTERRUPTS*/
	init_oscillator();
	init_usart();
	init_twi();
 //TWI_MASTER_t twi;
 //PMIC_CTRL= //interrupt
 
	PORTC.DIR |= PIN6_bm;
	
	if(( TWIC_MASTER_STATUS & TWI_MASTER_BUSSTATE_gm) == TWI_MASTER_BUSSTATE_IDLE_gc)
{	
	//TWIC_MASTER_ADDR =0x00; 
	TWIC_MASTER_CTRLC = TWI_MASTER_CMD_REPSTART_gc;
	//TWIC_MASTER_CTRLC = TWI_MASTER_CMD_NOACT_gc;   //read data
	TWIC_MASTER_ADDR = 0xEC;  // R/W bit low to write the reg number from where we want to read
	TWIC_MASTER_ADDR = 0xA0;
	TWIC_MASTER_CTRLC = TWI_MASTER_CMD_REPSTART_gc;
	TWIC_MASTER_ADDR = 0xED; // R/W bit high indicating a read operation 
    TWIC_MASTER_CTRLC = TWI_MASTER_CMD_STOP_gc;
	 int DATA=TWIC_MASTER_DATA;
	//sendChar(DATA);
	uint16_t buffer;
	itoa(DATA, buffer, 10);
	sendString(buffer);
	sendString("\n");
	
}

		//while(TWIC_MASTER_STATUS & 0x10)  //ack/NACK recieved from slave
 
//    TWIC_MASTER_ADDR =0x00; 
//    _delay_ms(100);
//    TWIC_MASTER_ADDR = 0xE7;
//      TWIC_MASTER_ADDR = 0xE5;
// 	 _delay_ms(100);
// TWIC_MASTER_ADDR = 0xA0;
    while(1)
	//for(int i=1; i<=5 ; i++)
    {
    
	 PORTC.OUT &= ~PIN6_bm;
  //  sendString("Test\n");
	_delay_ms(1000);
	PORTC.OUT |= PIN6_bm;
	_delay_ms(1000);
 
   //TWIC_MASTER_CTRLC = TWI_MASTER_CMD_REPSTART_gc;

   int DATA=TWIC_MASTER_DATA;
	//sendChar(DATA);
	uint16_t buffer;
	itoa(DATA, buffer, 10);
//	sendString(buffer);
    }
}
Example #9
0
void serial_init(serial_t *obj, PinName tx, PinName rx) {
    // Determine the UART to use (UART_1, UART_2, ...)
    UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
    UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);

    // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object
    obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx);

    if (obj->uart == (UARTName)NC) {
        error("Serial pinout mapping failed");
    }

    // Enable USART clock
    if (obj->uart == UART_1) {
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
    }
    if (obj->uart == UART_2) {
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
    }
    if (obj->uart == UART_3) {
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
    }
    if (obj->uart == UART_4) {
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);
    }
    if (obj->uart == UART_5) {
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART5, ENABLE);
    }

    // Configure the UART pins
    pinmap_pinout(tx, PinMap_UART_TX);
    pinmap_pinout(rx, PinMap_UART_RX);
    pin_mode(tx, PullUp);
    pin_mode(rx, PullUp);

    // Configure UART
    obj->baudrate = 9600;
    obj->databits = USART_WordLength_8b;
    obj->stopbits = USART_StopBits_1;
    obj->parity = USART_Parity_No;

    init_usart(obj);

    // The index is used by irq
    if (obj->uart == UART_1) obj->index = 0;
    if (obj->uart == UART_2) obj->index = 1;
    if (obj->uart == UART_3) obj->index = 2;
    if (obj->uart == UART_4) obj->index = 3;
    if (obj->uart == UART_5) obj->index = 4;

    // For stdio management
    if (obj->uart == STDIO_UART) {
        stdio_uart_inited = 1;
        memcpy(&stdio_uart, obj, sizeof(serial_t));
    }
}
void usart_device_config(const uart_id_t id, const size_t bits,
                         const size_t parity, const size_t stop_bits,
                         const size_t baud)
{
        if (!usart_id_in_bounds(id))
                return;

        volatile struct usart_info *ui = usart_data + id;
        init_usart(ui->usart, bits, parity, stop_bits, baud);
}
void main ()
{
lcd_init();
init_usart();
	while(1)
		{Delay10KTCYx(200);
		lcd_gotoxy(1,1);
		}
	 
}
Example #12
0
int
main(void)
{

  leds_init();

  leds_on(LEDS_RED);

  /* Initialize USART */
  init_usart();
  
  /* Clock */
  clock_init();

  leds_on(LEDS_GREEN);

  ds2401_init();

  random_init(0);

  rtimer_init();

  /* Process subsystem */
  process_init();

  process_start(&etimer_process, NULL);

  ctimer_init();

  leds_on(LEDS_YELLOW);

  init_net();

  node_id_restore();
  
  printf_P(PSTR(CONTIKI_VERSION_STRING " started. Node id %u, using %s.\n"),
                                                       node_id, rime_mac->name);
  printf_P(PSTR("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n"),
	 ds2401_id[0], ds2401_id[1], ds2401_id[2], ds2401_id[3],
	 ds2401_id[4], ds2401_id[5], ds2401_id[6], ds2401_id[7]);

  leds_off(LEDS_ALL);

  /* Autostart processes */
  autostart_start(autostart_processes);

  /* Main scheduler loop */
  do {

    process_run();

  }while(1);

  return 0;
}
Example #13
0
void perform_inits(void)
{	
	g_defined_temp = 35;
	g_current_temp = 0.;
	init_usart(BAUDRATE, TRANSMIT_RATE, DATA_BITS, STOP_BITS, PARITY_BITS);
	init_peltier_port();
	init_motors();
	init_motors_timer();
	init_lcd();
	sei();
}
Example #14
0
int main(void){

	init_usart();


	while(1){
		USART_SendData(USART2, 'h'); // defined in stm32f4xx_usart.h
		Delay(0x3FFFFF);
	}

}
Example #15
0
int main(void)
{
	init_led();
	init_usart();
	init_led();
	
	while (true) {
		eth_poll();		/* out of scope of this example */
		
		pin_toggle(LED);
	}
}
Example #16
0
void main(void) {
  unsigned char received = 'c';
  init_leds();
  GPIOB->ODR |= 0xAA;
  init_usart();
  for(;;) {
    while ( (USART1->ISR & USART_ISR_RXNE) == 0); // while receive IS empty, hang
    received = USART1->RDR;
    GPIOB->ODR = received;
    USART1->TDR = received+1;
  }
}
Example #17
0
/*---------------------------------------------------------------------------*/
int
main(void)
{

  leds_init();

  leds_on(LEDS_RED);

  /* Initialize USART */
  init_usart();
  
  /* Clock */
  clock_init();

  leds_on(LEDS_GREEN);

  ds2401_init();
  
  node_id_restore();

  random_init(ds2401_id[0] + node_id);

  rtimer_init();

  /* Process subsystem */
  process_init();

  process_start(&etimer_process, NULL);

  ctimer_init();

  leds_on(LEDS_YELLOW);
  
  init_net();
  
  printf_P(PSTR(CONTIKI_VERSION_STRING " started. Node id %u\n"), node_id);

  leds_off(LEDS_ALL);

  /* Autostart processes */
  autostart_start(autostart_processes);

  mmem_init();
  /* Main scheduler loop */
  do {

    process_run();

  }while(1);

  return 0;
}
Example #18
0
int main(void) {

	SystemInit();
	init_usart(9600);
	init_GPIO();
	init_timer();
	NEC_Init();

	while (1) {

	}

	return 0;
}
Example #19
0
/**
* Initializes everything on the robot
* @author Group B1
* @param oi The open interface of the robot
* @date 12/4/2012
*/
void init_all(oi_t *oi)
{
	oi = oi_alloc();
	oi_init(oi);
	init_buttons();
	init_usart();
	lcd_init();
	timer3_init();
	ADC_init();
	init_printf(0,write_one_char);
	move_servo(0);
	wait_ms(1000);
	printf("\n");
	printf("\n");
}
Example #20
0
static int nxt_bluetooth_init(void) {
	struct sys_timer *ntx_bt_timer;

	data_pack = NULL;

	irq_attach(CONFIG_NXT_BT_US_IRQ,
		nxt_bt_us_handler, 0, NULL, "nxt bt reader");
	// TODO error handling?

	init_usart();
	init_control_pins();
	init_adc();

	//TODO may be it must set when bt has been connected?
	return timer_set(&ntx_bt_timer, TIMER_PERIODIC, 200, nxt_bt_timer_handler, NULL);
}
Example #21
0
void serial_init(serial_t *obj, PinName tx, PinName rx) {
    // Determine the UART to use (UART_1, UART_2, ...)
    UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
    UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
  
    // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object
    obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
    MBED_ASSERT(obj->uart != (UARTName)NC);

    // Enable USART clock
    if (obj->uart == UART_1) {
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
        obj->index = 0;
    }
    if (obj->uart == UART_2) {
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
        obj->index = 1;
    }
            
    // Configure the UART pins
    pinmap_pinout(tx, PinMap_UART_TX);
    pinmap_pinout(rx, PinMap_UART_RX);
    if (tx != NC) {
        pin_mode(tx, PullUp);
    }
    if (rx != NC) {
        pin_mode(rx, PullUp);
    }

    // Configure UART
    obj->baudrate = 9600;
    obj->databits = USART_WordLength_8b;
    obj->stopbits = USART_StopBits_1;
    obj->parity = USART_Parity_No;

    obj->pin_tx = tx;
    obj->pin_rx = rx;

    init_usart(obj);
    
    // For stdio management
    if (obj->uart == STDIO_UART) {
        stdio_uart_inited = 1;
        memcpy(&stdio_uart, obj, sizeof(serial_t));
    }
    
}
int main(int argc, const char *argv[])
{
    // Point stdout to serial stream (for testing to see adc value)
    stdout = &mystdout;

	// Initialize usart
	init_usart(BAUDRATE, TRANSMIT_RATE, DATA_BITS, STOP_BITS, PARITY_BITS);

	// printf("The first recipe is shown below!\n\n\n");

	char recipe_name[RECIPE_NAME_LENGTH];

    eeprom_read_block((void*)&recipe_name, (const void*)0x00, RECIPE_NAME_LENGTH);

    printf("Recipe Name: '%s'\n", recipe_name);

	return 0;
}
Example #23
0
int main(void)
{
	init_usart(BAUDRATE, TRANSMIT_RATE, DATA_BITS, STOP_BITS, PARITY_BITS);
	stdin = stdout = &usart0_str;

	char c;
	char *ing1 = malloc(3 * sizeof(char));
	char *ing2 = malloc(3 * sizeof(char));
	char *ing3 = malloc(3 * sizeof(char));
	char *ing4 = malloc(3 * sizeof(char));
	int pouring_amount;
	int temp;

	int isCooling = 1;

	while(1) {
		printf("Beginning forever loop");
		scanf(" %1c", &c);

		switch(c) {
			case 't':
				scanf(" %d", &temp);
				printf("Updated temp to: %d\n", temp);
				break;
			case 'p':
				// read the four ingredient amounts
				scanf(" %s", ing1);
				scanf(" %s", ing2);
				scanf(" %s", ing3);
				scanf(" %s", ing4);
				printf("Ingredient 1: %s\n", ing1);
				printf("Ingredient 2: %s\n", ing2);
				printf("Ingredient 3: %s\n", ing3);
				printf("Ingredient 4: %s\n", ing4);
				break;
			// default:
		}
	}
	free(ing1);
	free(ing2);
	free(ing3);
	free(ing4);
	return 0;
}
Example #24
0
int main() {
	int i=0;
	int ret,j;
	static u8 data[512];
	
	
	cur_song_init();
	init_usart();
	initSystick();
	delay(1000);
	printf("\r\n\r\n-------- start -------\r\n");
	
//	shot();
//	while (1);
	
	initSpi();
	SD_Init();
	readBlock(0,data);
	
	init_mp3();
	Mp3Reset();
	mute();
	init_fetch();
	
  //send_fetch_play_list();
  while (1) loop();

// 	println("start shot...");
// 	for(i=1;i<=3573;i++){
// 		readBlock(i,data);
// 		for(j=0;j<512;j++) {
// 			printf("%c",data[j]);
// 		}
// 	}
// 	println("shot over");

// 	println("--- 0");
//  	ret = get_millisecond();
//  	for(i=1;i<1000;i++)
//  		writeBlock(i,data);
// 	readBlock(990,data);
//  	printf("--- %d\r\n",get_millisecond() - ret);
}
Example #25
0
int main(void)
{
	uint8_t t=0;	
  SystemInit();
	systick_init();

	init_usart(usart1);
	
	//init_rtc();
	//
	
	init_net();	
	len=0;
	//buffer[0]=1;
	//send(usart1,buffer,1);
  while (1)
  {
		process_net();
		//if(t!=timer.sec)
		if(rtc_flag==1)
		{
			rtc_flag=0;
			//time_get();
			//t=timer.sec;
			//debug_format("%d-----\r\n",l);
			//l++;
			//debug_format("Time: %0.4dÄê%0.2dÔÂ%0.2dÈÕ %0.2d:%0.2d:%0.2d\r\n",timer.w_year,timer.w_month,timer.w_date,timer.hour,timer.min,timer.sec);
		}
		//send(usart4,buffer,len);
		if(delay>30)
		{
			//time_show();
			len=receive(usart1,buffer);
			if(len>0)
			{
				//send(usart1,buffer,len);
				debug_format("the receive len is %d \r\n",len);
				len=0;
			}
			delay=0;
		}
  }
}
Example #26
0
/**
 * @brief Initialize i/o ports and timer.
 *
 * @section init2 Outputs:
 *  - Solenoid Output
 *      - #SOLEN_OP_DDR   => set #SOLEN_DN and #SOLEN_UP as output 
 *      - #SOLEN_OP_PORT  => initialize #SOLEN_DN and #SOLEN_UP to 0
 *  - Board Light Output
 *      - #BOARD_DDR      => set #BOARD_LIGHT as output
 *      - #BOARD_PORT     => initialize BOARD_LIGHT to 0  
 * @section init1 Inputs:
 *  - User Buttons
 *      - #BTN_IP_DDR     => set #USHIFT_PIN and #DSHIFT_PIN as input
 *      - #BTN_IP_PORT    => set pullups for #USHIFT_PIN and #DSHIFT_PIN
 *  - Tachometer Input
 *      - #TACH_IP_DDR    => set #TACH_PIN as input
 *      - Enable external Interrupt 
 *  - Gas Pedal Input
 *      - Enable ADC
 *          - 128 Prescaler
 *          - AREF = AVCC
 *          - Left align result
 *          - Free Running mode */
inline void io_init(void)
{
    //Setup outputs
    //Solenoid output
    SOLEN_OP_DDR |= _BV(SOLEN_DN)|_BV(SOLEN_UP);
    SOLEN_OP_PORT &= ~(_BV(SOLEN_DN)|_BV(SOLEN_UP));

    //Setup board light
    BOARD_DDR |= _BV(BOARD_LIGHT);
    BOARD_PORT &= ~_BV(BOARD_LIGHT);

    init_usart(Baud9600);    
    
    //Setup inputs
    //User buttons
    BTN_IP_DDR  &= ~(_BV(USHIFT_PIN)|_BV(DSHIFT_PIN));
    BTN_IP_PORT |= _BV(USHIFT_PIN)|_BV(DSHIFT_PIN);
    BTN_IP_DDR  &= ~(_BV(AUTOMATIC_PIN)|_BV(SEMIAUTO_PIN));
    BTN_IP_PORT |= _BV(AUTOMATIC_PIN)|_BV(SEMIAUTO_PIN);
    
    //Ignition Interrupt
    ECU_DDR |= _BV(IGNITION_INT);
    ECU_PORT &= ~_BV(IGNITION_INT);
    //#else
    //Tachometer input
    ECU_DDR &= ~_BV(TACH_PIN);
    EICRA |= _BV(ISC01)|_BV(ISC00); //Interrupt0 Rising Edge
    EIMSK |= _BV(INT0);             //enable Interrupt0
//#endif
   
//#ifdef SIMULATE
    //Gas Pedal input (ADC)
    ADCSRA |= _BV(ADPS2)|_BV(ADPS1)|_BV(ADPS0); //select 128 prescaler
    ADCSRA |= _BV(ADATE);
    ADMUX |= _BV(REFS0);    //Set ADC reference to AVCC
    ADMUX |= _BV(ADLAR);    //Left align result
    ADMUX &= ~(_BV(MUX3)|_BV(MUX2)|_BV(MUX1)|_BV(MUX0));  //Select ADC0
    ADCSRB &= ~(_BV(ADTS2)|_BV(ADTS1)|_BV(ADTS0)); //Select Free Running
    ADCSRA |= _BV(ADEN);     //Enable ADC
    ADCSRA |= _BV(ADIE);     //Enable ADC Interrupt
    sei();
}
/* Auxilary port */
static void usart_device_init_1(size_t bits, size_t parity,
                                size_t stopBits, size_t baud)
{
        volatile struct usart_info* ui = usart_data + UART_AUX;

        RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
        RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

        initGPIO(GPIOD, (GPIO_Pin_8 | GPIO_Pin_9));
        GPIO_PinAFConfig(GPIOD, GPIO_PinSource8, GPIO_AF_USART3);
        GPIO_PinAFConfig(GPIOD, GPIO_PinSource9, GPIO_AF_USART3);

        init_usart(ui->usart, bits, parity, stopBits, baud);

        enable_dma_rx(RCC_AHB1Periph_DMA1, DMA1_Stream1_IRQn,
                      DMA_IRQ_PRIORITY, DMA_IT_TC | DMA_IT_HT, ui);

        enable_dma_tx(RCC_AHB1Periph_DMA1, DMA1_Stream3_IRQn,
                      DMA_IRQ_PRIORITY, DMA_IT_TC, ui);
}
/* GPS */
static void usart_device_init_2(size_t bits, size_t parity,
                                size_t stopBits, size_t baud)
{
        volatile struct usart_info* ui = usart_data + UART_GPS;

        RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
        RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

        initGPIO(GPIOD, (GPIO_Pin_5 | GPIO_Pin_6));
        GPIO_PinAFConfig(GPIOD, GPIO_PinSource5, GPIO_AF_USART2);
        GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_USART2);

        init_usart(ui->usart, bits, parity, stopBits, baud);
        /* No TX DMA here becasue I2C is using that stream */
        enableRxTxIrq(ui->usart, USART2_IRQn, UART_GPS_IRQ_PRIORITY,
                      UART_TX_IRQ);

        enable_dma_rx(RCC_AHB1Periph_DMA1, DMA1_Stream5_IRQn,
                      DMA_IRQ_PRIORITY, DMA_IT_TC | DMA_IT_HT, ui);
}
/* Cellular */
static void usart_device_init_3(size_t bits, size_t parity,
                                size_t stopBits, size_t baud)
{
        volatile struct usart_info* ui = usart_data + UART_TELEMETRY;

        RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);
        RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

        initGPIO(GPIOA, (GPIO_Pin_0 | GPIO_Pin_1));
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource0, GPIO_AF_UART4);
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_UART4);

        init_usart(ui->usart, bits, parity, stopBits, baud);

        enable_dma_rx(RCC_AHB1Periph_DMA1, DMA1_Stream2_IRQn,
                      DMA_IRQ_PRIORITY, DMA_IT_TC | DMA_IT_HT, ui);

        enable_dma_tx(RCC_AHB1Periph_DMA1, DMA1_Stream4_IRQn,
                      DMA_IRQ_PRIORITY, DMA_IT_TC, ui);
}
/* Bluetooth */
static void usart_device_init_0(size_t bits, size_t parity,
                                size_t stopBits, size_t baud)
{
        volatile struct usart_info* ui = usart_data + UART_WIRELESS;

        RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
        RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

        initGPIO(GPIOA, (GPIO_Pin_9 | GPIO_Pin_10));
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);

        init_usart(ui->usart, bits, parity, stopBits, baud);

        enable_dma_rx(RCC_AHB1Periph_DMA2, DMA2_Stream5_IRQn,
                      DMA_IRQ_PRIORITY, DMA_IT_TC | DMA_IT_HT, ui);

        enable_dma_tx(RCC_AHB1Periph_DMA1, DMA2_Stream7_IRQn,
                      DMA_IRQ_PRIORITY, DMA_IT_TC, ui);

}