mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-21 03:30:01 +00:00
fixed defs and to compile for atmega32 also - has no TCNT3
This commit is contained in:
parent
486ea95b4f
commit
f997ec6231
@ -26,12 +26,16 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)$Id: avrdef.h,v 1.1 2007/08/16 13:20:09 bg- Exp $
|
||||
* @(#)$Id: avrdef.h,v 1.2 2007/12/11 17:21:14 joxe Exp $
|
||||
*/
|
||||
|
||||
#ifndef AVRDEF_H
|
||||
#define AVRDEF_H
|
||||
|
||||
/* SREG is defined in this file */
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#else
|
||||
|
@ -28,14 +28,16 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rtimer-arch.c,v 1.1 2007/11/29 02:44:05 fros4943 Exp $
|
||||
* $Id: rtimer-arch.c,v 1.2 2007/12/11 17:21:14 joxe Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* AVR-specific rtimer code
|
||||
* Currently only works on ATMEGAs that have Timer 3.
|
||||
* \author
|
||||
* Fredrik Osterlind <fros@sics.se>
|
||||
* Joakim Eriksson <joakime@sics.se>
|
||||
*/
|
||||
|
||||
/* OBS: 8 seconds maximum time! */
|
||||
@ -48,6 +50,7 @@
|
||||
#include "rtimer-arch.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifdef TCNT3
|
||||
SIGNAL (SIG_OUTPUT_COMPARE3A) {
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
|
||||
@ -59,6 +62,7 @@ SIGNAL (SIG_OUTPUT_COMPARE3A) {
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
||||
}
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rtimer_arch_init(void)
|
||||
@ -68,6 +72,8 @@ rtimer_arch_init(void)
|
||||
sreg = SREG;
|
||||
cli ();
|
||||
|
||||
#ifdef TCNT3
|
||||
|
||||
ETIMSK &= ~((1 << OCIE3A) | (1 << OCIE3B) | (1 << TOIE3) |
|
||||
(1 << TICIE3) | (1 << OCIE3C));
|
||||
ETIFR |= (1 << ICF3) | (1 << OCF3A) | (1 << OCF3B) | (1 << TOV3) |
|
||||
@ -84,6 +90,8 @@ rtimer_arch_init(void)
|
||||
/* Maximum prescaler */
|
||||
TCCR3B |= 5;
|
||||
|
||||
#endif
|
||||
|
||||
/* Restore interrupt state */
|
||||
SREG = sreg;
|
||||
}
|
||||
@ -96,12 +104,15 @@ rtimer_arch_schedule(rtimer_clock_t t)
|
||||
sreg = SREG;
|
||||
cli ();
|
||||
|
||||
#ifdef TCNT3
|
||||
/* Set compare register */
|
||||
OCR3A = t;
|
||||
ETIFR |= (1 << ICF3) | (1 << OCF3A) | (1 << OCF3B) | (1 << TOV3) |
|
||||
(1 << OCF3C);
|
||||
ETIMSK |= (1 << OCIE3A);
|
||||
|
||||
#endif
|
||||
|
||||
/* Restore interrupt state */
|
||||
SREG = sreg;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rtimer-arch.h,v 1.3 2007/11/29 02:44:05 fros4943 Exp $
|
||||
* $Id: rtimer-arch.h,v 1.4 2007/12/11 17:21:14 joxe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __RTIMER_ARCH_H__
|
||||
@ -38,6 +38,12 @@
|
||||
|
||||
#define RTIMER_ARCH_SECOND (8192)
|
||||
|
||||
/* Handle that not all AVRs have TCNT3 - this should be configuratble
|
||||
in contiki-conf later! */
|
||||
#ifdef TCNT3
|
||||
#define rtimer_arch_now() (TCNT3)
|
||||
#else
|
||||
#define rtimer_arch_now() (0)
|
||||
#endif
|
||||
|
||||
#endif /* __RTIMER_ARCH_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user