git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@66 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2007-10-26 15:08:54 +00:00
parent f021c6fe95
commit fb49ce4f3a
4 changed files with 47 additions and 23 deletions

View File

@ -138,11 +138,11 @@
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 100
#define CH_FREQUENCY 1000
/** Configuration option: This constant is the number of ticks allowed for the
* threads before preemption occurs.*/
#define CH_TIME_QUANTUM 10
#define CH_TIME_QUANTUM 20
/** Configuration option: Defines a CPU register to be used as storage for the
* global \p currp variable. Caching this variable in a register can greatly

View File

@ -82,32 +82,43 @@ void hwinit(void) {
/*
* I/O ports setup.
*/
DDRA = VAL_DDRA;
PORTA = VAL_PORTA;
DDRB = VAL_DDRB;
PORTB = VAL_PORTB;
DDRC = VAL_DDRC;
PORTC = VAL_PORTC;
DDRD = VAL_DDRD;
PORTD = VAL_PORTD;
DDRE = VAL_DDRE;
PORTE = VAL_PORTE;
DDRF = VAL_DDRF;
PORTF = VAL_PORTF;
DDRG = VAL_DDRG;
PORTG = VAL_PORTG;
DDRA = VAL_DDRA;
PORTA = VAL_PORTA;
DDRB = VAL_DDRB;
PORTB = VAL_PORTB;
DDRC = VAL_DDRC;
PORTC = VAL_PORTC;
DDRD = VAL_DDRD;
PORTD = VAL_PORTD;
DDRE = VAL_DDRE;
PORTE = VAL_PORTE;
DDRF = VAL_DDRF;
PORTF = VAL_PORTF;
DDRG = VAL_DDRG;
PORTG = VAL_PORTG;
/*
* External interrupts setup, all disabled initially.
*/
EICRA = 0x00;
EICRB = 0x00;
EIMSK = 0x00;
EICRA = 0x00;
EICRB = 0x00;
EIMSK = 0x00;
/*
* Enables Idle mode for SLEEP instruction.
*/
SMCR = 1;
SMCR = 1;
/*
* Timer 0 setup.
*/
TCCR0A = (1 << WGM01) | (0 << WGM00) | // CTC mode.
(0 << COM0A1) | (0 << COM0A0) | // OC0A disabled (normal I/O).
(0 << CS02) | (1 << CS01) | (1 << CS00); // CLK/64 clock source.
OCR0A = F_CPU / 64 / CH_FREQUENCY - 1;
TCNT0 = 0; // Reset counter.
TIFR0 = (1 << OCF0A); // Reset pending (if any).
TIMSK0 = (1 << OCIE0A); // Interrupt on compare.
}
void chSysPause(void) {

View File

@ -79,8 +79,13 @@ typedef struct {
/**
* Platform dependent part of the \p chThdCreate() API.
*/
#define SETUP_CONTEXT(workspace, wsize, pf, arg) \
{ \
#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
tp->p_ctx.sp--; \
tp->p_ctx.sp->r2 = (int)pf; \
tp->p_ctx.sp->r3 = (int)pf >> 8; \
tp->p_ctx.sp->r4 = (int)arg; \
tp->p_ctx.sp->r5 = (int)arg >> 8; \
tp->p_ctx.sp->pc = (UWORD16)threadstart; \
}
/*
@ -100,6 +105,7 @@ typedef struct {
void chSysHalt(void) __attribute__((noreturn)) ;
void chSysPause(void) __attribute__((noreturn)) ;
void chSysSwitchI(Context *oldp, Context *newp);
void threadstart(void);
#endif /* _CHCORE_H_ */

View File

@ -19,6 +19,14 @@
#include <avr/io.h>
.global threadstart
threadstart:
sei
movw r24, r4 // argument
movw r30, r2 // thread function
icall
call chThdExit
.global chSysSwitchI
chSysSwitchI:
push r2
@ -113,4 +121,3 @@ noschd:
pop r1
pop r0
reti