[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] sfr_defs.h and -mint8
From: |
Tomas Vanek |
Subject: |
[avr-libc-dev] sfr_defs.h and -mint8 |
Date: |
Mon, 06 Oct 2003 11:50:20 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2a) Gecko/20020910 |
Hi all,
Please don't waste your time explaining me a global statement that
avr-libc is basically not compatible with -mint8. I know about it and I
agree with it.
<sfr_defs.h> declares 16-bits registers as unsigned int. This is big
trouble when using -mint8. If you think that it is worth to switch
<sfr_defs.h> to <inttypes.h> types, here is the patch.
The question is where and when to include <inttypes.h>. It might be
better included in <io.h>, however I'd prefer including it in
<sfr_defs.h> when __ASSEMBLER__ is not defined. I believe it makes no harm.
Tom
diff -urN avr-libc-0.99.90.20030815/include/avr/sfr_defs.h
/c/WinAVR/avr/include/avr/sfr_defs.h
--- avr-libc-0.99.90.20030815/include/avr/sfr_defs.h 2003-08-11
23:42:14.000000000 +0200
+++ /c/WinAVR/avr/include/avr/sfr_defs.h 2003-10-06 11:28:30.000000000
+0200
@@ -118,8 +118,10 @@
#ifndef __ASSEMBLER__
/* These only work in C programs. */
-#define _MMIO_BYTE(mem_addr) (*(volatile unsigned char *)(mem_addr))
-#define _MMIO_WORD(mem_addr) (*(volatile unsigned int *)(mem_addr))
+#include <inttypes.h>
+
+#define _MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr))
+#define _MMIO_WORD(mem_addr) (*(volatile uint16_t *)(mem_addr))
#endif
#if _SFR_ASM_COMPAT
@@ -157,7 +159,7 @@
#define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + 0x20)
#define _SFR_IO16(io_addr) _MMIO_WORD((io_addr) + 0x20)
-#define _SFR_MEM_ADDR(sfr) ((unsigned int) &(sfr))
+#define _SFR_MEM_ADDR(sfr) ((uint16_t) &(sfr))
#define _SFR_IO_ADDR(sfr) (_SFR_MEM_ADDR(sfr) - 0x20)
#define _SFR_IO_REG_P(sfr) (_SFR_MEM_ADDR(sfr) < 0x60)
- [avr-libc-dev] sfr_defs.h and -mint8,
Tomas Vanek <=