progress on xmega port
This commit is contained in:
@@ -199,7 +199,6 @@ ISR(UART_RECEIVE_INTERRUPT)
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
ISR(UART_TRANSMIT_INTERRUPT)
|
||||
{
|
||||
BusState&=~(1<<TransmitRequested);
|
||||
@@ -207,7 +206,11 @@ ISR(UART_TRANSMIT_INTERRUPT)
|
||||
UART_DATA=rxbuffer[DataPos];
|
||||
DataPos++;
|
||||
if (DataPos==(PacketTopIndex+1)) {
|
||||
#ifndef __AVR_ATxmega32A4__
|
||||
UART_CONTROL&=~(1<<UART_UDRIE);
|
||||
#else
|
||||
USARTD0_CTRLA &= ~(USART_DREINTLVL_gm);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,13 +225,14 @@ ISR(UART_TRANSMIT_COMPLETE_INTERRUPT)
|
||||
//TODO
|
||||
void modbusInit(void)
|
||||
{
|
||||
#ifndef __AVR_ATxmega32A4__
|
||||
UBRRH = (unsigned char)((UBRR) >> 8);
|
||||
UBRRL = (unsigned char) UBRR;
|
||||
UART_STATUS = (1<<U2X); //double speed mode.
|
||||
#ifdef URSEL // if UBRRH and UCSRC share the same I/O location , e.g. ATmega8
|
||||
UCSRC = (1<<URSEL)|(3<<UCSZ0); //Frame Size
|
||||
#else
|
||||
UCSRC = (3<<UCSZ0); //Frame Size
|
||||
UCSRC = (3<<UCSZ0); //Frame Size
|
||||
#endif
|
||||
UART_CONTROL = (1<<TXCIE)|(1<<RXCIE)|(1<<RXEN)|(1<<TXEN); // USART receiver and transmitter and receive complete interrupt
|
||||
#if PHYSICAL_TYPE == 485
|
||||
@@ -236,6 +240,13 @@ void modbusInit(void)
|
||||
transceiver_rxen();
|
||||
#endif
|
||||
BusState=(1<<TimerActive);
|
||||
#elif
|
||||
//BRR
|
||||
//RX, TX enable
|
||||
//Interrupt enable (levels)
|
||||
//Physical type
|
||||
//Busstate
|
||||
#endif
|
||||
}
|
||||
|
||||
/* @brief: Sends a response.
|
||||
@@ -243,7 +254,6 @@ void modbusInit(void)
|
||||
* Arguments: - packtop: Position of the last byte containing data.
|
||||
* modbusSendException is a good usage example.
|
||||
*/
|
||||
//TODO
|
||||
void modbusSendMessage(unsigned char packtop)
|
||||
{
|
||||
PacketTopIndex=packtop+2;
|
||||
@@ -253,7 +263,13 @@ void modbusSendMessage(unsigned char packtop)
|
||||
#if PHYSICAL_TYPE == 485
|
||||
transceiver_txen();
|
||||
#endif
|
||||
UART_CONTROL|=(1<<UART_UDRIE);
|
||||
|
||||
#ifndef __AVR_ATxmega32A4__
|
||||
UART_CONTROL|=(1<<UART_UDRIE);
|
||||
#else
|
||||
USARTD0_CTRLA |= USART_DREINTLVL_HI_gc;
|
||||
#endif
|
||||
|
||||
BusState&=~(1<<ReceiveCompleted);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user