Pico Computer 3 / FUZIX v0.11 - the outside world
This release is about the outside world. The machine could already draw, make a noise and compile its own BASIC; what it could not do was control anything. It can now — and pin work is between one and two orders of magnitude faster than it used to be, because it stopped being a system call.
The change underneath
There is no MMU on this board and the kernel never drops privilege, so a program could always reach the pin registers. An ioctl cost 1.488 µs against about ten nanoseconds for the store it was wrapping — so a syscall per pin was not a tax on bit-banging, it was the reason you could not do it.
So the kernel now keeps only what a program cannot do for itself — who owns a pin, and putting it back when they die — and hands over the traffic. Everything below is userland on top of that, and none of it needed a new kernel driver.
- Pins are owned.
SETPINclaims from the kernel; a pin another program holds is refused rather than quietly fought over; and only the I/O header can be claimed, so a BASIC program can no longer take a pin the SD card or display is using. - The claim is released and the pin reset when your program ends — however it ends, including being killed or crashing. A program that dies driving a relay does not leave it driven.
New in BASIC
SETPIN n, AIN/ARAW— analogue in volts or raw counts, with MMBasic's own ten-sample sort-and-discard filterSETPIN n, INTH|INTL|INTB, handler— pin interrupts, handler an ordinarySUBSETTICK— four periodic timers,PAUSE/RESUME, catch-up that drops missed ticks. Twenty 100 ms ticks measured at 1999.98 msON KEY— both forms: one fires on any key and leaves it forINKEY$, one claims a single key and eats itPWMandSERVO— MMBasic's arithmetic, scope-verified from 50 Hz to 100 kHz, and servo pulses from 0.8 ms to 2.2 msPULLUP/PULLDOWNon the input modes, and hysteresis on every input- GP32 — the DS3231's alarm line — is readable
INKEY$ works
It never had on this machine. The console's line editor was taking every keystroke before a program could see it, and nothing had exercised it hard enough to notice. A program reading keys now holds the terminal, and gives it back for INPUT and at exit. Building ON KEY is what found it.
For C programs
<sys/pc3io.h> — the pin, ADC, PWM and timer registers, shared with the BASIC runtime, with the RP2350's two traps written down: PADS_BANK0.ISO resets to 1 (so a pad is disconnected until you clear it), and SIO's GPIO_OUT/GPIO_OE must never be read-modify-written. /dev/i2c gives userland the QWIIC bus, shared with the kernel's own clock.
Also fixed
cc could be run twice at once and corrupt its own output; its progress dots ignored redirection. Both gone.
Gates
make check 27, cgate byte-identical, fcctests 27, qemu 28, ctest 165, cpptest clean, verifyimage "image matches what was staged". Appendix C is 84 statements.
Installing
Flash fuzix.uf2, write pc3-sd-cc.img.gz (gunzip first) to an SD card. At the bootdev: prompt answer hdb2, then log in as root.