Project

General

Profile

Revision 213

fixed cardbox code for new board, updated tooltron.py for new cardbox

View differences:

rs485_int.c
32 32

  
33 33
void rs485_init(uint16_t baud) {
34 34
	// Set baud rate
35
	UBRRH = (uint8_t)(baud>>8);
36
	UBRRL = (uint8_t)baud;
35
	UBRR0H = (uint8_t)(baud>>8);
36
	UBRR0L = (uint8_t)baud;
37 37
	
38 38
	// Enable RX/TX and RX/TX Interrupt
39
	UCSRB = _BV(RXCIE) | _BV(RXEN) | _BV(TXCIE) | _BV(TXEN);
39
	UCSR0B = _BV(RXCIE0) | _BV(RXEN0) | _BV(TXCIE0) | _BV(TXEN0);
40 40
 
41 41
	// Enable the TXEN pin as output
42 42
	DDRD |= TX_EN;
......
46 46
    received_byte = 0x0;
47 47

  
48 48
    // Set to receive mode
49
    rs485_toggle_transmit(TX_OFF);
49
    rs485_toggle_transmit(RS485_TX_OFF);
50 50
}
51 51

  
52 52
int8_t rs485_get_byte(uint8_t *output_byte) {
......
61 61

  
62 62
void rs485_send_byte(uint8_t data) {
63 63
	//Waits until current transmit is done
64
    while (!(UCSRA & _BV(UDRE)));
64
    while (!(UCSR0A & _BV(UDRE0)));
65 65

  
66 66
    // Enable writes and send
67
	rs485_toggle_transmit(UART_TX_ON);
68
    UDR = data;
67
	rs485_toggle_transmit(RS485_TX_ON);
68
	UDR0 = data;
69 69
	return;
70 70
}
71 71

  
72 72
void rs485_toggle_transmit(uint8_t state) {
73
	if (state == UART_TX_ON) {
73
	if (state == RS485_TX_ON) {
74 74
		PORTD |= TX_EN;
75 75
	} else {
76 76
		PORTD &= ~TX_EN;
......
78 78
}
79 79

  
80 80
ISR(USART_RX_vect) {
81
    received_byte = UDR;
81
    received_byte = UDR0;
82 82
    byte_ready = 1;    
83 83
}
84 84

  
85 85
ISR(USART_TX_vect) {
86 86
    // Re-enable reads
87
    rs485_toggle_transmit(UART_TX_OFF);
87
    rs485_toggle_transmit(RS485_TX_OFF);
88 88
}

Also available in: Unified diff