uracoli-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[uracoli-devel] Commited ATmega644 contributions


From: uracolix
Subject: [uracoli-devel] Commited ATmega644 contributions
Date: Wed, 9 Dec 2009 07:28:02 +0100
User-agent: KMail/1.9.9

Hi Marco, 

hope you are doing well. I added your contributions to the CVS, if your board 
gets an open hardware project or public available product, board_ma644.h will 
added.

Cheers, Axel

------------------------------------------------------------------------------------------------------------------------

Index: LICENSE
===================================================================
RCS file: /sources/uracoli/uracoli/LICENSE,v
retrieving revision 1.3
diff -u -r1.3 LICENSE
--- LICENSE     25 Jun 2009 20:45:43 -0000      1.3
+++ LICENSE     9 Dec 2009 06:10:42 -0000
@@ -14,6 +14,7 @@
   Joerg Wunsch,
   Daniel Thiele,
   Karl Fessel,
+  Marco Arena,
   Axel Wachtler,
   Atmel Corporation.
   All rights reserved.
Index: Src/Lib/Inc/const.h
===================================================================
RCS file: /sources/uracoli/uracoli/Src/Lib/Inc/const.h,v
retrieving revision 1.25
diff -u -r1.25 const.h
--- Src/Lib/Inc/const.h 22 Nov 2009 19:06:49 -0000      1.25
+++ Src/Lib/Inc/const.h 9 Dec 2009 06:10:44 -0000
@@ -1,4 +1,7 @@
-/* Copyright (c) 2007 Axel Wachtler
+/* Copyright (c) 2007, 2008, 2009 
+    Marco Arena
+    Axel Wachtler
+
    All rights reserved.
 
    Redistribution and use in source and binary forms, with or without
@@ -107,6 +110,7 @@
 #define  CPU_M1287       (6) /**< Identifier for CPU ATmega1287 */
 #define  CPU_M1284       (7) /**< Identifier for CPU ATmega1284 */
 #define  CPU_M88         (8) /**< Identifier for CPU ATmega88 */
+#define  CPU_M644P       (9) /**< Identifier for CPU ATmega644P */
 
 /** @} */
 
Index: Src/Lib/Ioutil/hif_uart.h
===================================================================
RCS file: /sources/uracoli/uracoli/Src/Lib/Ioutil/hif_uart.h,v
retrieving revision 1.7
diff -u -r1.7 hif_uart.h
--- Src/Lib/Ioutil/hif_uart.h   9 Nov 2009 17:40:45 -0000       1.7
+++ Src/Lib/Ioutil/hif_uart.h   9 Dec 2009 06:10:45 -0000
@@ -1,4 +1,7 @@
-/* Copyright (c) 2007 Axel Wachtler
+/* Copyright (c) 2007,2008,2009
+    Marco Arena
+    Axel Wachtler
+
    All rights reserved.
 
    Redistribution and use in source and binary forms, with or without
@@ -123,6 +126,81 @@
 #  error "Unknown UART for CPU_M1281"
 # endif /*HIF_UART_x*/
 
+/* === UART definitions for ATmega644P === */
+#elif CPU_TYPE == CPU_M644P
+# if HIF_TYPE == HIF_UART_0
+#  define HIF_UART_STATUS   UCSR0A
+#  define HIF_UART_CONTROL  UCSR0B
+#  define HIF_UART_DATA     UDR0
+#  define HIF_UART_UDRIE    UDRIE0
+#  define HIF_UART_RX_vect  USART0_RX_vect
+#  define HIF_UART_TX_vect  USART0_UDRE_vect
+#  define HIF_UART_RX_ERROR(status) (status & (_BV(FE)|_BV(DOR)))
+#  define HIF_UART_TXIRQ_EI() (HIF_UART_CONTROL |= _BV(UDRIE0))
+#  define HIF_UART_TXIRQ_DI() (HIF_UART_CONTROL &= ~_BV(UDRIE0))
+   inline void HIF_UART_INIT(uint16_t baudrate)
+   {
+   uint16_t br;
+       /* init uart 0 mega 644p*/
+       br = ENCODE_BAUDRATE(baudrate);
+       /* Set baud rate */
+       if ( br & 0x8000 )
+       {
+                  HIF_UART_STATUS = _BV(U2X0);  //Enable 2x speed
+                  br &= ~0x8000;
+          }
+       UBRR0H = (uint8_t)(br>>8);
+       UBRR0L = (uint8_t) br;
+
+       /* Enable USART receiver and transmitter and receive complete 
interrupt */
+       HIF_UART_CONTROL = (_BV(RXCIE0)|(1<<RXEN0)|(1<<TXEN0));
+
+       /* Set frame format: asynchronous, 8data, no parity, 1stop bit */
+       #ifdef URSEL0
+       UCSR0C = (1<<URSEL0)|(3<<UCSZ00);
+       #else
+       UCSR0C = (3<<UCSZ00);
+       #endif
+
+   }
+# elif HIF_TYPE == HIF_UART_1
+#  define HIF_UART_STATUS   UCSR1A
+#  define HIF_UART_CONTROL  UCSR1B
+#  define HIF_UART_DATA     UDR1
+#  define HIF_UART_UDRIE    UDRIE1
+#  define HIF_UART_RX_vect  USART1_RX_vect
+#  define HIF_UART_TX_vect  USART1_UDRE_vect
+#  define HIF_UART_RX_ERROR(status) (status & (_BV(FE)|_BV(DOR)))
+#  define HIF_UART_TXIRQ_EI() (HIF_UART_CONTROL |= _BV(UDRIE1))
+#  define HIF_UART_TXIRQ_DI() (HIF_UART_CONTROL &= ~_BV(UDRIE1))
+   inline void HIF_UART_INIT(uint16_t baudrate)
+   {
+   /* init uart 1 mega 644p*/
+   uint16_t br;
+      br = ENCODE_BAUDRATE(baudrate);
+      /* Set baud rate */
+      if ( br & 0x8000 )
+      {
+             HIF_UART_STATUS = _BV(U2X0);  //Enable 2x speed
+             br &= ~0x8000;
+      }
+      UBRR1H = (uint8_t)(br>>8);
+      UBRR1L = (uint8_t) br;
+
+      /* Enable USART receiver and transmitter and receive complete interrupt 
*/
+      HIF_UART_CONTROL = (_BV(RXCIE1)|(1<<RXEN1)|(1<<TXEN1));
+
+      /* Set frame format: asynchronous, 8data, no parity, 1stop bit */
+      #ifdef URSEL0
+      UCSR1C = (1<<URSEL0)|(3<<UCSZ00);
+      #else
+      UCSR1C = (3<<UCSZ00);
+      #endif
+   }
+# else
+#  error "Unknown UART for CPU_M644"
+# endif /*HIF_UART_x*/
+
 /* === UART definitions for ATmega16 === */
 #elif CPU_TYPE == CPU_M16
 # if HIF_TYPE == HIF_UART_0






reply via email to

[Prev in Thread] Current Thread [Next in Thread]