Ejemplo n.º 1
0
func main() {
	setup.Performance(0)

	periph.AHBClockEnable(periph.GPIOB)
	periph.AHBReset(periph.GPIOB)

	LED.SetMode(Blue, gpio.Out)
	LED.SetMode(Green, gpio.Out)

	vt := exce.NewTable(16)
	vt[exce.NMI] = exce.VectorFor(defaultHandler)
	vt[exce.HardFault] = exce.VectorFor(defaultHandler)
	vt[exce.SysTick] = exce.VectorFor(sysTickHandler)
	exce.UseTable(vt[:])

	_, _, tenms := systick.Calib()
	tenms *= 10 // stm32l1 returns value for 1 ms not for 10ms.
	systick.SetReload(tenms * 100)
	systick.SetFlags(systick.Enable | systick.TickInt)

	// Sleep forever.
	sleep.EnableSleepOnExit()
	barrier.Sync() // not necessary on Cortex-M0,M3,M4
	sleep.WFI()

	// Execution should never reach there so the green LED
	// should never light up.
	LED.SetBit(Green)
}
Ejemplo n.º 2
0
func setSystick(sysclk int) {
	if noos.MaxTasks() == 0 {
		return
	}
	// Set tick period to 2 ms (500 context switches per second).
	const period = 2
	systick.SetReload(uint32(sysclk)*(1e6*period/1e3) - 1)
	noos.SetTickPeriod(period)
}
Ejemplo n.º 3
0
func sysTickStart() {
	// Defaults:
	// One context switch per 1e6 SysTicks (70/s for 70 Mhz, 168/s for 168 MHz)
	systick.SetReload(1e6 - 1)
	systick.WriteFlags(systick.Enable | systick.TickInt | systick.ClkCPU)
}