Skip to content

Commit 8661acc

Browse files
committed
Ensure uniform handling of environment parameters in all driver units
1 parent eeb115f commit 8661acc

File tree

18 files changed

+124
-92
lines changed

18 files changed

+124
-92
lines changed

source/__version.id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.6.157
1+
2.6.159

source/rtl/ultibo/core/globalconst.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ interface
5252
{Global constants}
5353
const
5454
{Version constants}
55-
ULTIBO_RELEASE_DATE = '15 November 2025';
55+
ULTIBO_RELEASE_DATE = '17 November 2025';
5656
ULTIBO_RELEASE_NAME = 'Beetroot';
57-
ULTIBO_RELEASE_VERSION = '2.6.157';
57+
ULTIBO_RELEASE_VERSION = '2.6.159';
5858
ULTIBO_RELEASE_VERSION_MAJOR = 2;
5959
ULTIBO_RELEASE_VERSION_MINOR = 6;
60-
ULTIBO_RELEASE_VERSION_REVISION = 157;
60+
ULTIBO_RELEASE_VERSION_REVISION = 159;
6161

6262
FPC_COMPILER_VERSION = {$I %FPCVERSION%}; {The version of FPC used to compile the RTL}
6363

source/rtl/ultibo/drivers/af16x2lcd.pas

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ procedure AF16x2LCDInit;
189189
{Note: Called only during system startup}
190190
var
191191
WorkInt:LongWord;
192+
WorkBool:LongBool;
192193
WorkBuffer:String;
193194
begin
194195
{}
@@ -197,20 +198,20 @@ procedure AF16x2LCDInit;
197198

198199
{Check Environment Variables}
199200
{AF16X2LCD_AUTOSTART}
200-
WorkInt:=StrToIntDef(EnvironmentGet('AF16X2LCD_AUTOSTART'),1);
201-
if WorkInt = 0 then AF16X2LCD_AUTOSTART:=False;
201+
WorkBool:=StrToBoolDef(EnvironmentGet('AF16X2LCD_AUTOSTART'),AF16X2LCD_AUTOSTART);
202+
if WorkBool <> AF16X2LCD_AUTOSTART then AF16X2LCD_AUTOSTART:=WorkBool;
202203

203204
{AF16X2LCD_MODEL}
204205
WorkInt:=StrToIntDef(EnvironmentGet('AF16X2LCD_MODEL'),AF16X2LCD_MODEL);
205206
if WorkInt <> AF16X2LCD_MODEL then AF16X2LCD_MODEL:=WorkInt;
206207

207208
{AF16X2LCD_I2C_ADDRESS}
208-
WorkInt:=StrToIntDef(EnvironmentGet('AF16X2LCD_I2C_ADDRESS'),0);
209-
if WorkInt > 0 then AF16X2LCD_I2C_ADDRESS:=WorkInt;
209+
WorkInt:=StrToIntDef(EnvironmentGet('AF16X2LCD_I2C_ADDRESS'),AF16X2LCD_I2C_ADDRESS);
210+
if WorkInt <> AF16X2LCD_I2C_ADDRESS then AF16X2LCD_I2C_ADDRESS:=WorkInt;
210211

211212
{AF16X2LCD_I2C_DEVICE}
212213
WorkBuffer:=EnvironmentGet('AF16X2LCD_I2C_DEVICE');
213-
if Length(WorkBuffer) <> 0 then AF16X2LCD_I2C_DEVICE:=WorkBuffer;
214+
if Length(WorkBuffer) > 0 then AF16X2LCD_I2C_DEVICE:=WorkBuffer;
214215

215216
{Start 16x2 LCD}
216217
if AF16X2LCD_AUTOSTART then

source/rtl/ultibo/drivers/bcmsdhost.pas

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ TBCMSDHOSTHost = record
244244

245245
{==============================================================================}
246246
{Initialization Functions}
247-
procedure BCMSDHOSTInit;
247+
procedure BCMSDHOSTInit;{$IFDEF API_EXPORT_BCMSDHOST} stdcall; public name 'bcmsdhost_init';{$ENDIF}
248248

249249
{==============================================================================}
250250
{BCMSDHOST Functions}
@@ -314,10 +314,10 @@ function BCMSDHOSTBlockInterrupt(SDHCI:PSDHCIHost;InterruptMask:LongWord):LongWo
314314
{==============================================================================}
315315
{==============================================================================}
316316
{Initialization Functions}
317-
procedure BCMSDHOSTInit;
317+
procedure BCMSDHOSTInit;{$IFDEF API_EXPORT_BCMSDHOST} stdcall;{$ENDIF}
318318
{Initialize the BCMSDHOST unit and parameters}
319319

320-
{Note: Called only during system startup}
320+
{Note: Called internally by other functions}
321321
var
322322
WorkInt:LongWord;
323323
WorkBool:LongBool;
@@ -369,6 +369,9 @@ function BCMSDHOSTCreate(Address:PtrUInt;const Name:String;IRQ,DREQ,ClockMinimum
369369
{}
370370
Result:=nil;
371371

372+
{Initialize}
373+
BCMSDHOSTInit;
374+
372375
{$IF DEFINED(BCMSDHOST_DEBUG) or DEFINED(MMC_DEBUG)}
373376
if MMC_LOG_ENABLED then MMCLogDebug(nil,'BCMSDHOST: SDHCI Create (Address=' + AddrToHex(Address) + ' Name=' + Name + ' IRQ=' + IntToStr(IRQ) + ' DREQ=' + IntToStr(DREQ) + ')');
374377
if MMC_LOG_ENABLED then MMCLogDebug(nil,'BCMSDHOST: (Clock Minimum=' + IntToStr(ClockMinimum) + ' Maximum=' + IntToStr(ClockMaximum) + ')');
@@ -3386,8 +3389,8 @@ function BCMSDHOSTSetSDHostClock(var Clock,Value1,Value2:LongWord):LongWord;
33863389
{==============================================================================}
33873390
{==============================================================================}
33883391

3389-
initialization
3390-
BCMSDHOSTInit;
3392+
{initialization}
3393+
{Nothing}
33913394

33923395
{==============================================================================}
33933396

@@ -3398,6 +3401,3 @@ initialization
33983401
{==============================================================================}
33993402

34003403
end.
3401-
3402-
3403-

source/rtl/ultibo/drivers/ds1307.pas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ implementation
255255
{==============================================================================}
256256
{Initialization Functions}
257257
procedure DS1307Init;
258+
{Initialize the DS1307 unit and parameters}
259+
260+
{Note: Called only during system startup}
258261
var
259262
WorkInt:LongWord;
260263
WorkBool:LongBool;

source/rtl/ultibo/drivers/dwcotg.pas

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ function DWCHostSetupInterrupts(Host:PDWCUSBHost):LongWord; forward;
955955
procedure DWCInit;
956956
var
957957
Status:LongWord;
958-
WorkInt:LongWord;
958+
WorkBool:LongBool;
959959
DWCHost:PDWCUSBHost;
960960
begin
961961
{}
@@ -967,16 +967,16 @@ procedure DWCInit;
967967

968968
{Check Environment Variables}
969969
{DWCOTG_FULL_SPEED_ONLY}
970-
WorkInt:=StrToIntDef(EnvironmentGet('DWCOTG_FULL_SPEED_ONLY'),0);
971-
if WorkInt <> 0 then DWCOTG_FULL_SPEED_ONLY:=True;
970+
WorkBool:=StrToBoolDef(EnvironmentGet('DWCOTG_FULL_SPEED_ONLY'),DWCOTG_FULL_SPEED_ONLY);
971+
if WorkBool <> DWCOTG_FULL_SPEED_ONLY then DWCOTG_FULL_SPEED_ONLY:=WorkBool;
972972

973973
{DWCOTG_FS_LS_LOW_POWER_CLOCK}
974-
WorkInt:=StrToIntDef(EnvironmentGet('DWCOTG_FS_LS_LOW_POWER_CLOCK'),0);
975-
if WorkInt <> 0 then DWCOTG_FS_LS_LOW_POWER_CLOCK:=True;
974+
WorkBool:=StrToBoolDef(EnvironmentGet('DWCOTG_FS_LS_LOW_POWER_CLOCK'),DWCOTG_FS_LS_LOW_POWER_CLOCK);
975+
if WorkBool <> DWCOTG_FS_LS_LOW_POWER_CLOCK then DWCOTG_FS_LS_LOW_POWER_CLOCK:=WorkBool;
976976

977977
{DWCOTG_LS_LOW_PWR_PHY_CLOCK_6MHZ}
978-
WorkInt:=StrToIntDef(EnvironmentGet('DWCOTG_LS_LOW_PWR_PHY_CLOCK_6MHZ'),0);
979-
if WorkInt <> 0 then DWCOTG_LS_LOW_PWR_PHY_CLOCK_6MHZ:=True;
978+
WorkBool:=StrToBoolDef(EnvironmentGet('DWCOTG_LS_LOW_PWR_PHY_CLOCK_6MHZ'),DWCOTG_LS_LOW_PWR_PHY_CLOCK_6MHZ);
979+
if WorkBool <> DWCOTG_LS_LOW_PWR_PHY_CLOCK_6MHZ then DWCOTG_LS_LOW_PWR_PHY_CLOCK_6MHZ:=WorkBool;
980980

981981
{Create USB Host}
982982
if DWCOTG_REGISTER_HOST then

source/rtl/ultibo/drivers/ftdiserial.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
FTDI USB to Serial Driver.
33
4-
Copyright (C) 2024 - SoftOz Pty Ltd.
4+
Copyright (C) 2025 - SoftOz Pty Ltd.
55
66
Arch
77
====
@@ -2481,8 +2481,8 @@ procedure FTDISerialInit;
24812481

24822482
{Check Environment Variables}
24832483
{FTDISERIAL_MAX_TRANSMIT}
2484-
WorkInt:=StrToIntDef(EnvironmentGet('FTDISERIAL_MAX_TRANSMIT'),0);
2485-
if WorkInt <> 0 then FTDISERIAL_MAX_TRANSMIT:=WorkInt;
2484+
WorkInt:=StrToIntDef(EnvironmentGet('FTDISERIAL_MAX_TRANSMIT'),FTDISERIAL_MAX_TRANSMIT);
2485+
if WorkInt <> FTDISERIAL_MAX_TRANSMIT then FTDISERIAL_MAX_TRANSMIT:=WorkInt;
24862486

24872487
FTDISerialInitialized:=True;
24882488
end;

source/rtl/ultibo/drivers/genet.pas

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@ TGENETStatus64 = record
953953

954954
{==============================================================================}
955955
{Initialization Functions}
956+
procedure GENETInit;{$IFDEF API_EXPORT_GENET} stdcall; public name 'genet_init';{$ENDIF}
956957

957958
{==============================================================================}
958959
{GENET Functions}
@@ -1029,8 +1030,9 @@ implementation
10291030

10301031
{==============================================================================}
10311032
{==============================================================================}
1032-
{var}
1033+
var
10331034
{GENET specific variables}
1035+
GENETInitialized:Boolean;
10341036

10351037
{==============================================================================}
10361038
{==============================================================================}
@@ -1162,6 +1164,38 @@ procedure _UniMACMDIOWrite(Network:PGENETNetwork;Offset,Value:LongWord); forward
11621164
{==============================================================================}
11631165
{==============================================================================}
11641166
{Initialization Functions}
1167+
procedure GENETInit;{$IFDEF API_EXPORT_GENET} stdcall;{$ENDIF}
1168+
{Initialize the GENET unit and parameters}
1169+
1170+
{Note: Called internally by other functions}
1171+
var
1172+
WorkInt:LongWord;
1173+
WorkBool:LongBool;
1174+
WorkBuffer:String;
1175+
begin
1176+
{}
1177+
{Check Initialized}
1178+
if GENETInitialized then Exit;
1179+
1180+
{Check Environment Variables}
1181+
{GENET_PHY_MODE}
1182+
WorkBuffer:=EnvironmentGet('GENET_PHY_MODE');
1183+
if Length(WorkBuffer) > 0 then GENET_PHY_MODE:=WorkBuffer;
1184+
1185+
{GENET_PHY_ADDR}
1186+
WorkInt:=StrToIntDef(EnvironmentGet('GENET_PHY_ADDR'),GENET_PHY_ADDR);
1187+
if WorkInt <> GENET_PHY_ADDR then GENET_PHY_ADDR:=WorkInt;
1188+
1189+
{GENET_SKIP_UMAC_RESET}
1190+
WorkBool:=StrToBoolDef(EnvironmentGet('GENET_SKIP_UMAC_RESET'),GENET_SKIP_UMAC_RESET);
1191+
if WorkBool <> GENET_SKIP_UMAC_RESET then GENET_SKIP_UMAC_RESET:=WorkBool;
1192+
1193+
{GENET_NO_PHY_INTERRUPT}
1194+
WorkBool:=StrToBoolDef(EnvironmentGet('GENET_NO_PHY_INTERRUPT'),GENET_NO_PHY_INTERRUPT);
1195+
if WorkBool <> GENET_NO_PHY_INTERRUPT then GENET_NO_PHY_INTERRUPT:=WorkBool;
1196+
1197+
GENETInitialized:=True;
1198+
end;
11651199

11661200
{==============================================================================}
11671201
{==============================================================================}
@@ -1175,13 +1209,14 @@ function GENETNetworkCreate(Address:PtrUInt;MDIOOffset:LongWord;IRQ0,IRQ1:LongWo
11751209
{Return: Pointer to the new Network device or nil if the Network device could not be created}
11761210
var
11771211
Status:LongWord;
1178-
WorkInt:LongWord;
1179-
WorkBuffer:String;
11801212
GENETNetwork:PGENETNetwork;
11811213
begin
11821214
{}
11831215
Result:=nil;
11841216

1217+
{Initialize}
1218+
GENETInit;
1219+
11851220
{$IF DEFINED(GENET_DEBUG) or DEFINED(NETWORK_DEBUG)}
11861221
if NETWORK_LOG_ENABLED then NetworkLogDebug(nil,'GENET: Network Create (Address=' + AddrToHex(Address) + ' MDIOOffset=' + IntToHex(MDIOOffset,8) + ' IRQ0=' + IntToStr(IRQ0) + ' IRQ1=' + IntToStr(IRQ1) + ')');
11871222
{$ENDIF}
@@ -1195,23 +1230,6 @@ function GENETNetworkCreate(Address:PtrUInt;MDIOOffset:LongWord;IRQ0,IRQ1:LongWo
11951230
{Check IRQ1}
11961231
{if IRQ1 = 0 then Exit;} {IRQ 0 is valid}
11971232

1198-
{Check Environment Variables}
1199-
{GENET_PHY_MODE}
1200-
WorkBuffer:=EnvironmentGet('GENET_PHY_MODE');
1201-
if Length(WorkBuffer) <> 0 then GENET_PHY_MODE:=WorkBuffer;
1202-
1203-
{GENET_PHY_ADDR}
1204-
WorkInt:=StrToIntDef(EnvironmentGet('GENET_PHY_ADDR'),GENET_PHY_ADDR);
1205-
if WorkInt <> GENET_PHY_ADDR then GENET_PHY_ADDR:=WorkInt;
1206-
1207-
{GENET_SKIP_UMAC_RESET}
1208-
WorkInt:=StrToIntDef(EnvironmentGet('GENET_SKIP_UMAC_RESET'),0);
1209-
if WorkInt <> 0 then GENET_SKIP_UMAC_RESET:=True;
1210-
1211-
{GENET_NO_PHY_INTERRUPT}
1212-
WorkInt:=StrToIntDef(EnvironmentGet('GENET_NO_PHY_INTERRUPT'),0);
1213-
if WorkInt <> 0 then GENET_NO_PHY_INTERRUPT:=True;
1214-
12151233
{Create Network}
12161234
GENETNetwork:=PGENETNetwork(NetworkDeviceCreateEx(SizeOf(TGENETNetwork)));
12171235
if GENETNetwork <> nil then

source/rtl/ultibo/drivers/goodixtouch.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ procedure GOODIXInit;{$IFDEF API_EXPORT_GOODIXTOUCH} stdcall;{$ENDIF}
297297

298298
{GOODIX_LOAD_CONFIG_FILE}
299299
WorkBuffer:=EnvironmentGet('GOODIX_LOAD_CONFIG_FILE');
300-
if Length(WorkBuffer) <> 0 then GOODIX_LOAD_CONFIG_FILE:=WorkBuffer;
300+
if Length(WorkBuffer) > 0 then GOODIX_LOAD_CONFIG_FILE:=WorkBuffer;
301301

302302
{GOODIX_RESET_CONTROLLER}
303303
WorkBool:=StrToBoolDef(EnvironmentGet('GOODIX_RESET_CONTROLLER'),GOODIX_RESET_CONTROLLER);

source/rtl/ultibo/drivers/i2clcd.pas

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ procedure I2CLCDInit;
171171
{Note: Called only during system startup}
172172
var
173173
WorkInt:LongWord;
174+
WorkBool:LongBool;
174175
WorkBuffer:String;
175176
begin
176177
{}
@@ -179,16 +180,16 @@ procedure I2CLCDInit;
179180

180181
{Check Environment Variables}
181182
{I2CLCD_AUTOSTART}
182-
WorkInt:=StrToIntDef(EnvironmentGet('I2CLCD_AUTOSTART'),1);
183-
if WorkInt = 0 then I2CLCD_AUTOSTART:=False;
183+
WorkBool:=StrToBoolDef(EnvironmentGet('I2CLCD_AUTOSTART'),I2CLCD_AUTOSTART);
184+
if WorkBool <> I2CLCD_AUTOSTART then I2CLCD_AUTOSTART:=WorkBool;
184185

185186
{I2CLCD_I2C_ADDRESS}
186-
WorkInt:=StrToIntDef(EnvironmentGet('I2CLCD_I2C_ADDRESS'),0);
187-
if WorkInt > 0 then I2CLCD_I2C_ADDRESS:=WorkInt;
187+
WorkInt:=StrToIntDef(EnvironmentGet('I2CLCD_I2C_ADDRESS'),I2CLCD_I2C_ADDRESS);
188+
if WorkInt <> I2CLCD_I2C_ADDRESS then I2CLCD_I2C_ADDRESS:=WorkInt;
188189

189190
{I2CLCD_I2C_DEVICE}
190191
WorkBuffer:=EnvironmentGet('I2CLCD_I2C_DEVICE');
191-
if Length(WorkBuffer) <> 0 then I2CLCD_I2C_DEVICE:=WorkBuffer;
192+
if Length(WorkBuffer) > 0 then I2CLCD_I2C_DEVICE:=WorkBuffer;
192193

193194
{I2CLCD_LCD_WIDTH}
194195
WorkInt:=StrToIntDef(EnvironmentGet('I2CLCD_LCD_WIDTH'),I2CLCD_LCD_WIDTH);

0 commit comments

Comments
 (0)