diff options
| author | Christian Cunningham <cc@localhost> | 2022-03-30 16:51:36 -0700 | 
|---|---|---|
| committer | Christian Cunningham <cc@localhost> | 2022-03-30 16:51:36 -0700 | 
| commit | b6ca3a4df6ca34cd40f09d4b97e54679eb95840a (patch) | |
| tree | a83556c6639cb5d605b2579e6034a889319edc7e | |
| parent | 90227ef8d65052622d09698dc80a27cd67f4bc0a (diff) | |
Timer execute once
| -rw-r--r-- | include/cpu/irq.h | 1 | ||||
| -rw-r--r-- | kernel/cpu/irq.c | 8 | ||||
| -rw-r--r-- | usr/main.c | 4 | 
3 files changed, 13 insertions, 0 deletions
diff --git a/include/cpu/irq.h b/include/cpu/irq.h index e244cc9..0fb7fbb 100644 --- a/include/cpu/irq.h +++ b/include/cpu/irq.h @@ -24,6 +24,7 @@ struct SysTimerInfo {  	unsigned long tick_rate;  	unsigned long priority;  	void* arg; +	unsigned long oneshot;  };  struct GPIOInfo { diff --git a/kernel/cpu/irq.c b/kernel/cpu/irq.c index f718b7e..2990881 100644 --- a/kernel/cpu/irq.c +++ b/kernel/cpu/irq.c @@ -61,6 +61,8 @@ unsigned long c_irq_handler(void)  			*nexttime = *timer_chi + stinfo->tick_rate;  			*timer_cs = SYS_TIMER_SC_M0;  			scheduled = 1; +			if (stinfo->oneshot) +				store32(SYS_TIMER_SC_M0, IRQ_DISABLE1);  		}  		// Check if System Time Compare 1 Triggered the Interrupt  		if (*(volatile unsigned long*)SYS_TIMER_CS & SYS_TIMER_SC_M1 && irqs[SYS_TIMER_1_IRQ].handler != 0) { @@ -72,6 +74,8 @@ unsigned long c_irq_handler(void)  			*nexttime = *timer_chi + stinfo->tick_rate;  			*timer_cs = SYS_TIMER_SC_M1;  			scheduled = 1; +			if (stinfo->oneshot) +				store32(SYS_TIMER_SC_M1, IRQ_DISABLE1);  		}  		// Check if System Time Compare 2 Triggered the Interrupt  		if (*(volatile unsigned long*)SYS_TIMER_CS & SYS_TIMER_SC_M2 && irqs[SYS_TIMER_2_IRQ].handler != 0) { @@ -83,6 +87,8 @@ unsigned long c_irq_handler(void)  			*nexttime = *timer_chi + stinfo->tick_rate;  			*timer_cs = SYS_TIMER_SC_M2;  			scheduled = 1; +			if (stinfo->oneshot) +				store32(SYS_TIMER_SC_M2, IRQ_DISABLE1);  		}  		// Check if System Time Compare 3 Triggered the Interrupt  		if (*(volatile unsigned long*)SYS_TIMER_CS & SYS_TIMER_SC_M3 && irqs[SYS_TIMER_3_IRQ].handler != 0) { @@ -94,6 +100,8 @@ unsigned long c_irq_handler(void)  			*nexttime = *timer_chi + stinfo->tick_rate;  			*timer_cs = SYS_TIMER_SC_M3;  			scheduled = 1; +			if (stinfo->oneshot) +				store32(SYS_TIMER_SC_M3, IRQ_DISABLE1);  		}  	}  	// Check if CNTV triggered the interrupt @@ -14,24 +14,28 @@ static struct SysTimerInfo stime_0 = {  	.tick_rate = 5000000,  	.priority = 0,  	.arg = 0, +	.oneshot = 0,  };  static struct SysTimerInfo stime_1 = {  	.tick_rate = 700000,  	.priority = 0,  	.arg = 0, +	.oneshot = 0,  };  static struct SysTimerInfo stime_2 = {  	.tick_rate = 300000,  	.priority = 0,  	.arg = 0, +	.oneshot = 0,  };  static struct SysTimerInfo stime_3 = {  	.tick_rate = 10,  	.priority = 0,  	.arg = 0, +	.oneshot = 0,  };  static struct UartInfo UART_INFO = {  | 
