git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@66 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
f021c6fe95
commit
fb49ce4f3a
|
@ -138,11 +138,11 @@
|
||||||
|
|
||||||
/** Configuration option: Frequency of the system timer that drives the system
|
/** Configuration option: Frequency of the system timer that drives the system
|
||||||
* ticks. This also defines the system time unit.*/
|
* 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
|
/** Configuration option: This constant is the number of ticks allowed for the
|
||||||
* threads before preemption occurs.*/
|
* 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
|
/** 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
|
* global \p currp variable. Caching this variable in a register can greatly
|
||||||
|
|
|
@ -108,6 +108,17 @@ void hwinit(void) {
|
||||||
* Enables Idle mode for SLEEP instruction.
|
* 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) {
|
void chSysPause(void) {
|
||||||
|
|
|
@ -79,8 +79,13 @@ typedef struct {
|
||||||
/**
|
/**
|
||||||
* Platform dependent part of the \p chThdCreate() API.
|
* 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 chSysHalt(void) __attribute__((noreturn)) ;
|
||||||
void chSysPause(void) __attribute__((noreturn)) ;
|
void chSysPause(void) __attribute__((noreturn)) ;
|
||||||
void chSysSwitchI(Context *oldp, Context *newp);
|
void chSysSwitchI(Context *oldp, Context *newp);
|
||||||
|
void threadstart(void);
|
||||||
|
|
||||||
#endif /* _CHCORE_H_ */
|
#endif /* _CHCORE_H_ */
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,14 @@
|
||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
.global threadstart
|
||||||
|
threadstart:
|
||||||
|
sei
|
||||||
|
movw r24, r4 // argument
|
||||||
|
movw r30, r2 // thread function
|
||||||
|
icall
|
||||||
|
call chThdExit
|
||||||
|
|
||||||
.global chSysSwitchI
|
.global chSysSwitchI
|
||||||
chSysSwitchI:
|
chSysSwitchI:
|
||||||
push r2
|
push r2
|
||||||
|
@ -113,4 +121,3 @@ noschd:
|
||||||
pop r1
|
pop r1
|
||||||
pop r0
|
pop r0
|
||||||
reti
|
reti
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue