Hello,
I can control gpio in Raspberry Pi 4, but failed in NEO3 in same manner.
(of course, register adjusted for RK3328 )
How to fix it ? or wrong approach to control gpio ?
Is any clue in internet ?
Thanks a lot.
I can control gpio in Raspberry Pi 4, but failed in NEO3 in same manner.
(of course, register adjusted for RK3328 )
How to fix it ? or wrong approach to control gpio ?
Is any clue in internet ?
Thanks a lot.
Code: Select all
// - NanoPi NEO3 ( RockChip RK3328 )
// - Rockchip RK3288 Technical Reference Manual Part 1 rev 1.2 (pdf)
// - Ubuntu + Free Pascal (3.0.4) + Lazarus (IDE)
//
// - To toggle GPIO3-A0 ( Neo3 Pin #23)
//
procedure TForm1.Button1Click(Sender: TObject);
Const
GPIO3_Base = $FF7A0000; // addr GPIO3 Base ref. page #13
GPIO_SWPORT_DDR = $0004; // offset GPIO3 Poar Direction ref. page #422
GPIO_SWPORT_DR = $0000; // offset GPIO3 Port Output Data
GPIO_EXT_PORTA = $0050; // offset GPIO3 Port Status
Var
fd : integer;
pGPIO_Base : ^longWord; //
pGPIO_SWPORT_DDR : ^longWord; //
pGPIO_SWPORT_DR : ^longWord; //
begin
//----------------------------------------------------------------------------
// '/dev/gpiomem' Error
fd := fpopen('/dev/mem', O_RdWr or O_Sync);
If fd < 0 then exit; // exit if error
//----------------------------------------------------------------------------
pGPIO_Base := FpMmap(Nil, $1000, PROT_READ or PROT_WRITE, MAP_SHARED, fd, GPIO3_Base);
// Debug : pGPIO_Base = ^longword($0000007FF6832000)
// Err : pGPIO_Base := Pointer ($7FF6832);
pGPIO_SWPORT_DDR := Pointer ( int64(pGPIO_Base) + GPIO_SWPORT_DDR ); // Debug : $0000007FF6832004
pGPIO_SWPORT_DR := Pointer ( int64(pGPIO_Base) + GPIO_SWPORT_DR ); // Debug : $0000007FF6832000
//----------------------------------------------------------------------------
// Assumption : GRF_GPIO3C_IOMUX = 0 when reset
pGPIO_SWPORT_DDR^ := $00000001; // GPIO3_A0 ( GPIO Output Mode ) // ref. page #426
pGPIO_SWPORT_DR^ := $00000001; // GPIO3_A0 ( Set A0 = High )
end;