Exemplo 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)
}
Exemplo n.º 2
0
func init() {
	setup.Performance(0)

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

	LED.SetMode(Blue, gpio.Out)
	LED.SetMode(Green, gpio.Out)
}
Exemplo n.º 3
0
func main() {
	setup.Performance(0)

	var (
		buf [20]byte
		rnd rand.XorShift64
	)

	rnd.Seed(1)

	for {
		rnd.Next()
		strconv.Utoa(buf[:], rnd.Uint32(), 10)
		st.Write(buf[:])
		st.WriteByte('\n')
	}
}
Exemplo n.º 4
0
func init() {
	setup.Performance(0)

	periph.AHBClockEnable(periph.GPIOA | periph.GPIOB)
	periph.AHBReset(periph.GPIOA | periph.GPIOB)

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

	// Setup external interrupt source: user button.
	gpio.A.SetMode(0, gpio.In)
	exti.L0.Connect(gpio.A)
	exti.L0.RiseTrigEnable()
	exti.L0.IntEnable()
	irq.Ext0.UseHandler(buttonHandler)
	irq.Ext0.Enable()
}
Exemplo n.º 5
0
func main() {
	setup.Performance(0)

	st.WriteString("Press any key (Ctrl-C to exit)\n")

	var buf [stlink.TermBufLen]byte
	num := buf[:7]

	for i := 0; ; i++ {
		n := strconv.Itoa(num, int32(i), 10)
		st.Write(num[n:])
		st.WriteString(": ")

		n, _ = st.Read(buf[:])

		st.Write(buf[:n])
		st.WriteByte('\n')
	}
}