The Common Examples code for files from version 00.0160 has been tested and works on this board as well.
The code below adapts the GPIO example of Armpit Scheme version 00.0160 to the TI Beagle Board. The only difference is in the definition of GPIO ports and offsets that are adapted to the BeagleBoard's configuration. The board has two user LEDs labeled USR0 and USR1; they are both green.
; Armpit Scheme GPIO Example
; tested on TI-Beagle
; TI-Beagle
; define GPIO ports and offsets
(begin
(define ledport #x4905600) ; GPIO PORT 5
(define pin-status #x3C) ; output data register (DATAOUT)
(define pin-set #x94) ; bit set register (SETDATAOUT)
(define pin-clear #x90)) ; bit clear register (CLEARDATAOUT)
; functions to set and clear a pin on a gpio port
(begin
(define (set-pin port pin)
(write (ash 1 (min pin 29)) port pin-set))
(define (clear-pin port pin)
(write (ash 1 (min pin 29)) port pin-clear)))
; function to check the status of a pin on a gpio port
(define (is-set? port pin)
(not (zero? (logand (read port pin-status) (ash 1 (min pin 29))))))
; function to toggle a pin on a gpio port
(define (toggle port pin)
(if (is-set? port pin)
(clear-pin port pin)
(set-pin port pin)))
(toggle ledport 22) ; TI-Beagle USR0 green led
(toggle ledport 21) ; TI-Beagle USR1 green led
The code below adapts the Multitasking example of Armpit Scheme version 00.0160 to the TI Beagle Board. The only differences are in the definition of ports and offsets, functions to stop and start the timer, and the code needed to configure timer (all of which are in the first block of code). This example uses the LED definitions from the GPIO example above.
; Armpit MultiTasking Example [requires the GPIO example, above]
; Tested on TI-Beagle
; TI-Beagle
; define ports and offsets, functions to stop, start timer, and configure timer
(begin
(define timer0 #x4831800) ; GPTimer1 base address
(define timer0-int 37) ; GPTimer1 interrupt (bit) number
(define timer-control #x24)
(define timer-config #x10)
(define timer-period #x38)
(define timer-imask #x1c)
(define timer-count #x28)
(define (stop timer)
(write #x00 timer timer-control))
(define (restart timer)
(write #x00 timer timer-count)
(write #x41 timer timer-control))
(stop timer0)
(write #x08 timer0 timer-config)
(write 500000 timer0 timer-period)
(write #x01 timer0 timer-imask))
; Initialize the process queue
(define *queue* '())
; Set Scheme callback to switch queued thunks on Timer 0 interrupts
; note 1: although it is installed at the timer0 offset #x010000, this callback
; is used for all Scheme interrupts.
; note 2: 'case may be used instead of 'cond if interrupt (eg. timer0-int)
; is specified directly as a number (eg. 4)
(write
(lambda (int)
(cond
((= int timer0-int)
(call/cc
(lambda (resume)
(restart timer0)
(if (null? *queue*)
(resume #t)
((car *queue*) (set! *queue* (append (cdr *queue*) (list resume))))))))
(else (write int))))
timer0 #x010000)
; Start timer 0
(restart timer0)
; read the timer count (to check proper operation, read it a few times)
(read timer0 timer-count)
; function to spawn a new thunk (task)
(define (spawn thunk)
(stop timer0)
(set! *queue*
(cons
(lambda ()
(thunk)
((car *queue*) (set! *queue* (cdr *queue*))))
*queue*))
(restart timer0))
; function to toggle a gpio pin every "ticks" countdown ticks
(define (toggler port pin ticks)
(lambda ()
(let go ((n ticks))
(if (> n 0)
(go (- n 1))
(begin
(toggle port pin)
(go ticks))))))
; spawn toggler on MCU board's LED(s)
(spawn (toggler ledport 22 2000)) ; TI-Beagle USR0 green led
(spawn (toggler ledport 21 4000)) ; TI-Beagle USR1 green led
The Common Examples Runge-Kutta code for version 00.0160 has been tested and works on this board as well.
The Common Examples Expert System code for version 00.0160 has been tested and works on this board as well.
The Common Examples code for version 00.0160 is expected to work on this MCU but has not yet been tested on this board.
The Common Examples code for version 00.0160 is expected to work on this MCU but has not yet been tested on this board (use ARM mode as in the example).
The Common Examples code for version 00.0160 is expected to work on this MCU but has not yet been tested on this board.
The Common Examples code for version 00.0160 is expected to work on this MCU but has not yet been tested on this board.