Updated some ARM and AVR ports projects which needed changes to API for some BACnet objects. Compiled with IAR ARM and AVR compiler.
This commit is contained in:
@@ -1,49 +1,45 @@
|
||||
/*####COPYRIGHTBEGIN####
|
||||
-------------------------------------------
|
||||
Copyright (C) 2007 Steve Karg
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
The Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
As a special exception, if other files instantiate templates or
|
||||
use macros or inline functions from this file, or you compile
|
||||
this file and link it with other works to produce a work based
|
||||
on this file, this file does not by itself cause the resulting
|
||||
work to be covered by the GNU General Public License. However
|
||||
the source code for this file must still be made available in
|
||||
accordance with section (3) of the GNU General Public License.
|
||||
|
||||
This exception does not invalidate any other reasons why a work
|
||||
based on this file might be covered by the GNU General Public
|
||||
License.
|
||||
-------------------------------------------
|
||||
####COPYRIGHTEND####*/
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*********************************************************************/
|
||||
#ifndef IAR2GCC_H
|
||||
#define IAR2GCC_H
|
||||
|
||||
/* common embedded extensions for different compilers */
|
||||
|
||||
#if !defined(F_CPU)
|
||||
#define F_CPU (7372800)
|
||||
#error You must define F_CPU - clock frequency!
|
||||
#endif
|
||||
|
||||
#if defined (__CROSSWORKS_AVR)
|
||||
#include <inavr.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
/* IAR */
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ASM__)
|
||||
#if defined(__ICCAVR__)
|
||||
#include <inavr.h>
|
||||
#include <ioavr.h>
|
||||
/* BitValue is used alot in GCC examples */
|
||||
#define _BV(bit_num) (1 << (bit_num))
|
||||
#include <intrinsics.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* inline function */
|
||||
static inline void _delay_us(
|
||||
@@ -55,6 +51,56 @@ static inline void _delay_us(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#include <util/delay.h>
|
||||
#endif
|
||||
|
||||
/* adjust some definitions to common versions */
|
||||
#if defined (__CROSSWORKS_AVR)
|
||||
#if (__TARGET_PROCESSOR == ATmega644P)
|
||||
#define PRR PRR0
|
||||
#define UBRR0 UBRR0W
|
||||
#define UBRR1 UBRR1W
|
||||
|
||||
#define PA0 PORTA0
|
||||
#define PA1 PORTA1
|
||||
#define PA2 PORTA2
|
||||
#define PA3 PORTA3
|
||||
#define PA4 PORTA4
|
||||
#define PA5 PORTA5
|
||||
#define PA6 PORTA6
|
||||
#define PA7 PORTA7
|
||||
|
||||
#define PB0 PORTB0
|
||||
#define PB1 PORTB1
|
||||
#define PB2 PORTB2
|
||||
#define PB3 PORTB3
|
||||
#define PB4 PORTB4
|
||||
#define PB5 PORTB5
|
||||
#define PB6 PORTB6
|
||||
#define PB7 PORTB7
|
||||
|
||||
#define PC0 PORTC0
|
||||
#define PC1 PORTC1
|
||||
#define PC2 PORTC2
|
||||
#define PC3 PORTC3
|
||||
#define PC4 PORTC4
|
||||
#define PC5 PORTC5
|
||||
#define PC6 PORTC6
|
||||
#define PC7 PORTC7
|
||||
|
||||
#define PD0 PORTD0
|
||||
#define PD1 PORTD1
|
||||
#define PD2 PORTD2
|
||||
#define PD3 PORTD3
|
||||
#define PD4 PORTD4
|
||||
#define PD5 PORTD5
|
||||
#define PD6 PORTD6
|
||||
#define PD7 PORTD7
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Input/Output Registers */
|
||||
#if defined(__GNUC__)
|
||||
#include <avr/io.h>
|
||||
@@ -192,27 +238,54 @@ typedef struct {
|
||||
/* Interrupts */
|
||||
#if defined(__ICCAVR__)
|
||||
#define PRAGMA(x) _Pragma( #x )
|
||||
#define ISR(vec) PRAGMA( vector=vec ) __interrupt void handler_##vec(void)
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#define ISR(vec) \
|
||||
/* function prototype for use with "require protoptypes" option. */ \
|
||||
PRAGMA( vector=vec ) __interrupt void handler_##vec(void); \
|
||||
PRAGMA( vector=vec ) __interrupt void handler_##vec(void)
|
||||
#elif defined(__GNUC__)
|
||||
#include <avr/interrupt.h>
|
||||
#elif defined (__CROSSWORKS_AVR)
|
||||
#define ISR(vec) void handler_##vec(void) __interrupt[vec]
|
||||
#else
|
||||
#error ISR() not defined!
|
||||
#endif
|
||||
|
||||
/* Flash */
|
||||
#if defined(__ICCAVR__)
|
||||
#define FLASH_DECLARE(x) __flash x
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#elif defined(__GNUC__)
|
||||
#define FLASH_DECLARE(x) x __attribute__((__progmem__))
|
||||
#elif defined (__CROSSWORKS_AVR)
|
||||
#define FLASH_DECLARE (x) const __code x
|
||||
#endif
|
||||
|
||||
/* EEPROM */
|
||||
#if defined(__ICCAVR__)
|
||||
#define EEPROM_DECLARE(x) __eeprom x
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#elif defined(__GNUC__)
|
||||
#include <avr/eeprom.h>
|
||||
#define EEPROM_DECLARE(x) x __attribute__((section (".eeprom")))
|
||||
#if ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 3)) || \
|
||||
((__GNUC__ == 4) && (__GNUC_MINOR__ == 3) && (__GNUC_PATCHLEVEL__ <= 3)))
|
||||
/* bug in WinAVR - not quite IAR compatible */
|
||||
#ifndef __EEPUT
|
||||
#define __EEPUT _EEPUT
|
||||
#endif
|
||||
#ifndef __EEGET
|
||||
#define __EEGET _EEGET
|
||||
#endif
|
||||
#endif
|
||||
#elif defined (__CROSSWORKS_AVR)
|
||||
/* use functions defined in crt0.s to mimic IAR macros */
|
||||
void __uint8_eeprom_store(
|
||||
unsigned char byte,
|
||||
unsigned addr);
|
||||
unsigned char __uint8_eeprom_load(
|
||||
unsigned addr);
|
||||
#define __EEPUT(addr, var) \
|
||||
__uint8_eeprom_store((unsigned char)(var), (unsigned)(addr))
|
||||
#define __EEGET(var, addr) \
|
||||
(var) = __uint8_eeprom_load((unsigned)(addr))
|
||||
#endif
|
||||
|
||||
/* IAR intrinsic routines */
|
||||
@@ -223,4 +296,50 @@ typedef struct {
|
||||
#define __root
|
||||
#endif
|
||||
|
||||
/* watchdog defines in GCC */
|
||||
#if defined(__ICCAVR__) || defined(__CROSSWORKS_AVR)
|
||||
#define WDTO_15MS 0
|
||||
#define WDTO_30MS 1
|
||||
#define WDTO_60MS 2
|
||||
#define WDTO_120MS 3
|
||||
#define WDTO_250MS 4
|
||||
#define WDTO_500MS 5
|
||||
#define WDTO_1S 6
|
||||
#define WDTO_2S 7
|
||||
#endif
|
||||
|
||||
/* power macros in GCC-AVR */
|
||||
#if (defined(__ICCAVR__) && (defined(__ATmega644P__))) || \
|
||||
(defined(__CROSSWORKS_AVR) && (__TARGET_PROCESSOR == ATmega644P))
|
||||
#define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
|
||||
#define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
|
||||
#define power_usart0_enable() (PRR &= (uint8_t)~(1 << PRUSART0))
|
||||
#define power_usart1_enable() (PRR &= (uint8_t)~(1 << PRUSART1))
|
||||
#define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
|
||||
#define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
|
||||
#define power_timer2_enable() (PRR &= (uint8_t)~(1 << PRTIM2))
|
||||
#endif
|
||||
#if (defined(__ICCAVR__) && (defined(__ATmega1284P__))) || \
|
||||
(defined(__CROSSWORKS_AVR) && (__TARGET_PROCESSOR == ATmega1284P))
|
||||
#define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
|
||||
#define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
|
||||
#define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
|
||||
#define power_usart1_enable() (PRR0 &= (uint8_t)~(1 << PRUSART1))
|
||||
#define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
|
||||
#define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
|
||||
#define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
|
||||
#endif
|
||||
#if (defined(__GNUC__) && ((__GNUC__ == 4) && (__GNUC_MINOR__ < 5)))
|
||||
#if defined(__AVR_ATmega644P__)
|
||||
/* bug in WinAVR - fixed in later versions */
|
||||
#define power_usart1_enable() (PRR &= (uint8_t)~(1 << PRUSART1))
|
||||
#elif defined(__AVR_ATmega1284P__)
|
||||
#define power_usart1_enable() (PRR0 &= (uint8_t)~(1 << PRUSART1))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__CROSSWORKS_AVR)
|
||||
#define inline
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user