Add camera snapshot of blackline
[brmpuk.git] / sabertooth.c
blobb31d13eaefad1ff418f0d4168815e4349524c925
1 #include "brmpuk.h"
3 #include <avr/io.h>
4 #include "sabertooth.h"
6 #define BAUD 38400 // Rychlost prenosu dat
7 #define MYUBRR (F_CPU/16/BAUD-1) // Konstanta pouzita pro nastaveni prenosu
9 static void USART1_Init(uint16_t ubrr) { // fukce pro inicializaci USART1 komunikace
10 UBRR1H = (uint8_t) (ubrr >> 8);
11 UBRR1L = (uint8_t) ubrr;
13 UCSR1B = (1<<RXEN1)|(1<<TXEN1);
14 UCSR1C = (1<<UCSZ11)|(1<<UCSZ10); // nastaveni stop bitu a pocet bitu zpravy 8bit a 1stop bit
17 static void USART1_Transmit(uint8_t data) { // poslani dat po USART1
18 while (!(UCSR1A & (1<<UDRE1))) ; // cekani na odesilaci buffer
19 UDR1 = data; // zapsani dat = odeslani dat po USART1
22 void motor_init(void)
24 USART1_Init(MYUBRR);
25 motor_stop();
28 void motor_send(signed char m1, signed char m2)
30 USART1_Transmit(~0x80 & (64 - m1));
31 USART1_Transmit(0x80 | (64 - m2));
34 void motor_stop(void)
36 USART1_Transmit(0);