@sfischer
I thought a lot before posting this. Please note that my english is very bad so I'm sinthetic, not rude at all.
I think that you have done a big job, really.
But your code is a collection of "bad practices".
I will try to explain some, because I would try to help you to develop better.
All code snippets come from version 4.2.
function I2C_word_write(baseadr,basereg:word; data:word; flip:boolean; errhdl:integer):integer;
begin I2C_word_write:=I2C_word_write(RPI_I2C_busgen,baseadr,basereg,data,flip,errhdl); end;
This code is difficult to read: after punctuation (comma, semicolon, etc) put a space!
And let the
begin and
end alone in a line.
The "Overload" modifier is not required but I think that is a very good habit to use it
http://www.freepascal.org/docs-html/ref/refsu80.htmlprocedure SPI_show_buffer(busnum,devnum:byte);
const errlvl=LOG_WARNING; maxshowbuf=35;
var i,eidx:longint; sh:string;
begin
Ouch! It's ugly, compare to this:
procedure SPI_show_buffer(busnum, devnum:byte);
const
errlvl = LOG_WARNING;
maxshowbuf = 35;
var
i, eidx : longint;
sh : string;
begin
The readability is much improved, for other people but also for you when will read the code after some time.
Learn to use "Const parameters"
http://www.freepascal.org/docs-html/ref/refsu68.htmlDon't mix "library code" with "test code": the GPIO_int_test or I2C_test functions MUST be in a separate file.
Learn to use objects: it's a different world :-) (after the first headache)
with spi_buf[busnum,devnum] do
If the parameters are outside the range (that you know but the compiler no) you will have a runtime error at best. Or, if you shut off the range check errors, a "strange" behaviour.
Use Enumerations!
Last, for now: the unit initialization code decides which peripherals to initialize and which is the default log level. But these decisions are duty of the user/programmer not yours. Better if you have an RPI_hal_Initialize(...) function that do these things and return an error code (it's not your decision when to halt the program and with which error code).
Remember an important thing (that a C programmer ignores

): a programming language is a COMMON language between YOU and your computer so it must be (easily) readable from BOTH.
NicolaP