avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] boot.h and -mint8


From: E. Weddington
Subject: [avr-libc-dev] boot.h and -mint8
Date: Wed, 17 Sep 2003 16:03:57 -0600

Here's a patch for boot.h to bring it up to speed for -mint8.

Ted, it's your call whether you want this in for 1.0 or after.

Eric

Index: boot.h
===================================================================
RCS file: /cvsroot/avr-libc/avr-libc/include/avr/boot.h,v
retrieving revision 1.7
diff -u -r1.7 boot.h
--- boot.h      8 Sep 2003 22:06:14 -0000       1.7
+++ boot.h      17 Sep 2003 21:57:11 -0000
@@ -98,6 +98,7 @@
 
 #include <avr/eeprom.h>
 #include <avr/io.h>
+#include <inttypes.>
 #include <limits.h>
 
 /* Check for SPM Control Register in processor. */
@@ -136,31 +137,31 @@
     \def boot_spm_interrupt_enable()
     Enable the SPM interrupt. */
 
-#define boot_spm_interrupt_enable()   (__SPM_REG |= (unsigned char)_BV(SPMIE))
+#define boot_spm_interrupt_enable()   (__SPM_REG |= (uint8_t)_BV(SPMIE))
 
 /** \ingroup avr_boot
     \def boot_spm_interrupt_disable()
     Disable the SPM interrupt. */
 
-#define boot_spm_interrupt_disable()  (__SPM_REG &= (unsigned char)~_BV(SPMIE))
+#define boot_spm_interrupt_disable()  (__SPM_REG &= (uint8_t)~_BV(SPMIE))
 
 /** \ingroup avr_boot
     \def boot_is_spm_interrupt()
     Check if the SPM interrupt is enabled. */
 
-#define boot_is_spm_interrupt()       (__SPM_REG & (unsigned char)_BV(SPMIE))
+#define boot_is_spm_interrupt()       (__SPM_REG & (uint8_t)_BV(SPMIE))
 
 /** \ingroup avr_boot
     \def boot_rww_busy()
     Check if the RWW section is busy. */
 
-#define boot_rww_busy()          (__SPM_REG & (unsigned char)_BV(__COMMON_ASB))
+#define boot_rww_busy()          (__SPM_REG & (uint8_t)_BV(__COMMON_ASB))
 
 /** \ingroup avr_boot
     \def boot_spm_busy()
     Check if the SPM instruction is busy. */
 
-#define boot_spm_busy()               (__SPM_REG & (unsigned char)_BV(SPMEN))
+#define boot_spm_busy()               (__SPM_REG & (uint8_t)_BV(SPMEN))
 
 /** \ingroup avr_boot
     \def boot_spm_busy_wait()
@@ -189,9 +190,9 @@
         "spm\n\t"                                \
         "clr  r1\n\t"                            \
         : "=m" (__SPM_REG)                       \
-        : "r" ((unsigned char)__BOOT_PAGE_FILL), \
-          "r" ((unsigned short)address),         \
-          "r" ((unsigned short)data)             \
+        : "r" ((uint8_t)__BOOT_PAGE_FILL),       \
+          "r" ((uint16_t)address),               \
+          "r" ((uint16_t)data)                   \
         : "r0", "r30", "r31"                     \
     );                                           \
 })
@@ -210,9 +211,9 @@
         "nop\n\t"                                \
         "clr  r1\n\t"                            \
         : "=m" (__SPM_REG)                       \
-        : "r" ((unsigned char)__BOOT_PAGE_FILL), \
-          "r" ((unsigned short)address),         \
-          "r" ((unsigned short)data)             \
+        : "r" ((uint8_t)__BOOT_PAGE_FILL),       \
+          "r" ((uint16_t)address),               \
+          "r" ((uint16_t)data)                   \
         : "r0", "r30", "r31"                     \
     );                                           \
 })
@@ -231,9 +232,9 @@
         "clr  r1\n\t"                            \
         : "=m" (__SPM_REG),                      \
           "=m" (RAMPZ)                           \
-        : "r" ((unsigned char)__BOOT_PAGE_FILL), \
-          "r" ((unsigned long)address),          \
-          "r" ((unsigned short)data)             \
+        : "r" ((uint8_t)__BOOT_PAGE_FILL),       \
+          "r" ((uint32_t)address),               \
+          "r" ((uint16_t)data)                   \
         : "r0", "r30", "r31"                     \
     );                                           \
 })
@@ -248,8 +249,8 @@
         "sts %0, %1\n\t"                         \
         "spm\n\t"                                \
         : "=m" (__SPM_REG)                       \
-        : "r" ((unsigned char)__BOOT_PAGE_ERASE),\
-          "r" ((unsigned short)address)          \
+        : "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
+          "r" ((uint16_t)address)                \
         : "r30", "r31"                           \
     );                                           \
 })
@@ -266,8 +267,8 @@
         ".word 0xffff\n\t"                       \
         "nop\n\t"                                \
         : "=m" (__SPM_REG)                       \
-        : "r" ((unsigned char)__BOOT_PAGE_ERASE),\
-          "r" ((unsigned short)address)          \
+        : "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
+          "r" ((uint16_t)address)                \
         : "r30", "r31"                           \
     );                                           \
 })
@@ -284,8 +285,8 @@
         "spm\n\t"                                \
         : "=m" (__SPM_REG),                      \
           "=m" (RAMPZ)                           \
-        : "r" ((unsigned char)__BOOT_PAGE_ERASE),\
-          "r" ((unsigned long)address)           \
+        : "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
+          "r" ((uint32_t)address)                \
         : "r30", "r31"                           \
     );                                           \
 })
@@ -300,8 +301,8 @@
         "sts %0, %1\n\t"                         \
         "spm\n\t"                                \
         : "=m" (__SPM_REG)                       \
-        : "r" ((unsigned char)__BOOT_PAGE_WRITE),\
-          "r" ((unsigned short)address)          \
+        : "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
+          "r" ((uint16_t)address)                \
         : "r30", "r31"                           \
     );                                           \
 })
@@ -318,8 +319,8 @@
         ".word 0xffff\n\t"                       \
         "nop\n\t"                                \
         : "=m" (__SPM_REG)                       \
-        : "r" ((unsigned char)__BOOT_PAGE_WRITE),\
-          "r" ((unsigned short)address)          \
+        : "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
+          "r" ((uint16_t)address)                \
         : "r30", "r31"                           \
     );                                           \
 })
@@ -336,8 +337,8 @@
         "spm\n\t"                                \
         : "=m" (__SPM_REG),                      \
           "=m" (RAMPZ)                           \
-        : "r" ((unsigned char)__BOOT_PAGE_WRITE),\
-          "r" ((unsigned long)address)           \
+        : "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
+          "r" ((uint32_t)address)                \
         : "r30", "r31"                           \
     );                                           \
 })
@@ -351,7 +352,7 @@
         "sts %0, %1\n\t"                         \
         "spm\n\t"                                \
         : "=m" (__SPM_REG)                       \
-        : "r" ((unsigned char)__BOOT_RWW_ENABLE) \
+        : "r" ((uint8_t)__BOOT_RWW_ENABLE)       \
     );                                           \
 })
 
@@ -366,13 +367,13 @@
         ".word 0xffff\n\t"                       \
         "nop\n\t"                                \
         : "=m" (__SPM_REG)                       \
-        : "r" ((unsigned char)__BOOT_RWW_ENABLE) \
+        : "r" ((uint8_t)__BOOT_RWW_ENABLE)       \
     );                                           \
 })
 
 #define __boot_lock_bits_set(lock_bits)                    \
 ({                                                         \
-    unsigned char value = (unsigned char)(lock_bits | __BOOT_LOCK_BITS_MASK); \
+    uint8_t value = (uint8_t)(lock_bits | __BOOT_LOCK_BITS_MASK); \
     boot_spm_busy_wait();                                  \
     while(!eeprom_is_ready());                             \
     __asm__ __volatile__                                   \
@@ -383,7 +384,7 @@
         "sts %0, %1\n\t"                                   \
         "spm\n\t"                                          \
         : "=m" (__SPM_REG)                                 \
-        : "r" ((unsigned char)__BOOT_LOCK_BITS_SET),       \
+        : "r" ((uint8_t)__BOOT_LOCK_BITS_SET),             \
           "r" (value)                                      \
         : "r0", "r30", "r31"                               \
     );                                                     \
@@ -391,7 +392,7 @@
 
 #define __boot_lock_bits_set_alternate(lock_bits)          \
 ({                                                         \
-    unsigned char value = (unsigned char)(lock_bits | __BOOT_LOCK_BITS_MASK); \
+    uint8_t value = (uint8_t)(lock_bits | __BOOT_LOCK_BITS_MASK); \
     boot_spm_busy_wait();                                  \
     while(!eeprom_is_ready());                             \
     __asm__ __volatile__                                   \
@@ -404,7 +405,7 @@
         ".word 0xffff\n\t"                                 \
         "nop\n\t"                                          \
         : "=m" (__SPM_REG)                                 \
-        : "r" ((unsigned char)__BOOT_LOCK_BITS_SET),       \
+        : "r" ((uint8_t)__BOOT_LOCK_BITS_SET),       \
           "r" (value)                                      \
         : "r0", "r30", "r31"                               \
     );                                                     \

reply via email to

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