So, let's assume that you have RISC OS running on your pi already. If not, go and do it now. Or buy a new one just to run as a RISC OS desktop machine. Honestly, it's well worth it. So, RISC OS is up and running happily. First thing to do is to grab the GPIO modules handily provided by another forum member, tank. Take a look at the thread at http://www.raspberrypi.org/phpBB3/viewt ... 55&t=22250, then go to http://www.tankstage.co.uk/software.html and download the zip file. You can either just double click on the GPIO module, or create an RMload line in an obey file as detailed in the thread.
Secondly, strap up your gertboard as if you were running the supplied LED.c test program. I won't re-describe that here, as it's described elsewhere in detail, and my typing finger is already starting to hurt.
Then, enter the following BASIC:
Code: Select all
REM check we're on a Pi, just bail out if otherwise SYS "GPIO_GetBoard" TO a% IF a% = 11 OR a% = 12 THEN REM build array to map LEDs to GPIO DIM b%(11) IF a% = 12 THEN REM set pin to LED mappings for rev A b%() = 7,8,9,10,11,17,18,21,22,23,24,25 ELSE REM Set pin to LED mappings for rev B b%() = 7,8,9,10,11,17,18,27,22,23,24,25 ENDIF REM loop through LEDs one way, flashing them FOR x% = 0 TO 11 g%=b%(x%) REM read the current pin mode SYS "GPIO_ReadMode" ,g% TO a% REM is it output ? IF a% <>1 THEN REM no - set it as output SYS "GPIO_WriteMode" ,g%,1 TO a% ENDIF REM flash LED 3 times FOR z% = 1 TO 3 PROC_ledon(x%) PROC_delay(10) PROC_ledoff(x%) PROC_delay(10) NEXT NEXT REM loop through LEDs the other way, flashing them REM no need to check mode this time through FOR x% = 11 TO 0 STEP -1 REM flash LED 3 times FOR z% = 1 TO 3 PROC_ledon(x%) PROC_delay(10) PROC_ledoff(x%) PROC_delay(10) NEXT NEXT ENDIF END DEF PROC_delay(delay%) tnow%=TIME:REPEAT:UNTIL TIME>tnow%+delay% ENDPROC DEF PROC_ledon(led%) SYS "GPIO_WriteData" ,b%(led%),1 ENDPROC DEF PROC_ledoff(led%) SYS "GPIO_WriteData", b%(led%),0 ENDPROC
I'm not a RISC OS expert (I've only been using it for about a week now) so I can't offer much in the way of advice, as I'm learning myself. I've not used BASIC for about 25 years or so either... I've managed to get the C test programs to compile, but they don't work, as they reference the /dev/mem directory which doesn't exist in RISC OS. I may put a bit of effort into trying to convert these, or I may just carry on in BASIC and relive my lost youth.
Anyway. It works for me. Hope you enjoy it.