Thank you!
Now it compiles.
But another question:
If I make a new project (only one form) an add rpi_hal.pas in the uses clause, compile and run the project I get an exception (SIGSEGV) when I close the program.
Without rpi_hal in the uses the program works.
What am I doin wrong?
Hi,
just uploaded new version 3.1 of rpi_hal.
You can find it here: http://shop.basis.biz/shop/Raspberry-PI/piggy-back-board/index.html
scroll down until you see rpi_sw.tgz and download the archive.
New function:
Added a bidirectional device like /dev/mydevice
you can read and write to it.
No kernel modifications necessary. Just pure user space.
Stefan
Have not had time to look into it but with Laz 1.2.4 on RPI2 even adding RPI_HAL in the uses clause of an app causes a SIGABRT. If I get ten mins I'll try with the older board and see if the same happens. There is no code using RPI_HAL at this point and I havd DCPCrypt, Sockets (my rebuilt ver) and SynaSer installed. :( Looks like I'm writing my own I2C code...
Hi,
I use pi2 and I changed the lines like previous and the compile is ok but :
RunError(211)...
What I forgot to change ?
Thanks
Hi,
I use pi2 and I changed the lines like previous and the compile is ok but :
RunError(211)...
What I forgot to change ?
Thanks
I try your source , it's NOT worked.
root@raspberrypi:/home/pi# uname -a
Linux raspberrypi 4.1.7-v7+ #817 SMP PREEMPT Sat Sep 19 15:32:00 BST 2015 armv7l GNU/Linux
Hardware : BCM2709
Raspberry Pi 2 B
source:
program testrpi; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} sysutils, rpi_hal; const piggyback = 1; piface = 2; board_installed = piggyback;//board_installed=piggyback; var isr:isr_t; begin writeln('Show CPU-Info, RPI-HW-Info and Registers:'); rpi_show_all_info; isr.gpio:=16; isr.rising_edge:=true; gpio_set_int (isr, 16,@my_isr,true); gpio_int_enable(isr); gpio_set_pin(16,true); delay_msec(200); gpio_set_pin(16,false); gpio_int_disable(isr); gpio_int_release(isr); end.
===========
but I use shell script & command line , that's worked.
/tmp/gpio_int_setup.sh 16 out rising
echo "1">/sys/class/gpio/gpio16/value
echo "O">/sys/class/gpio/gpio16/value
/tmp/gpio_int_setup.sh 16 stop
what's the matter ?
I try your source , it's NOT worked.
root@raspberrypi:/home/pi# uname -a
Linux raspberrypi 4.1.7-v7+ #817 SMP PREEMPT Sat Sep 19 15:32:00 BST 2015 armv7l GNU/Linux
Hardware : BCM2709
Raspberry Pi 2 B
source:
program testrpi; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} sysutils, rpi_hal; const piggyback = 1; piface = 2; board_installed = piggyback;//board_installed=piggyback; var isr:isr_t; begin writeln('Show CPU-Info, RPI-HW-Info and Registers:'); rpi_show_all_info; isr.gpio:=16; isr.rising_edge:=true; gpio_set_int (isr, 16,@my_isr,true); gpio_int_enable(isr); gpio_set_pin(16,true); delay_msec(200); gpio_set_pin(16,false); gpio_int_disable(isr); gpio_int_release(isr); end.
===========
but I use shell script & command line , that's worked.
/tmp/gpio_int_setup.sh 16 out rising
echo "1">/sys/class/gpio/gpio16/value
echo "O">/sys/class/gpio/gpio16/value
/tmp/gpio_int_setup.sh 16 stop
what's the matter ?
pls. use new rpi_hal V3.4, it supports the RPI2B Board
How to achieve 'soft pwm' function by rpi_hal library ? Can you show us the sample code ? :)
Thanks.
The data stream consists of one leading zero followed by three STATUS bits, followed by the 12 bits of conversion data.
The data stream consists of one leading zero followed by three STATUS bits, followed by the 12 bits of conversion data.
https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
SUPPORTED BITS PER WORD
8 - Normal
9 - This is supported using LoSSI mode.
Can I obtain 12 bits data from ADC, if 8-9 bits per word supported?
And output data type - word(2 byte-(0..65535))?
Mask.The data stream consists of one leading zero followed by three STATUS bits, followed by the 12 bits of conversion data.
https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
SUPPORTED BITS PER WORD
8 - Normal
9 - This is supported using LoSSI mode.
Can I obtain 12 bits data from ADC, if 8-9 bits per word supported?
And output data type - word(2 byte-(0..65535))?
Can you show an example of using this function (SPI BUS)?
Activate SPI channel, obtaining first measurement, next measurement, ...... , last measurement, Close SPI Channel.
What type of data (byte/integer/string/other)?
How to change / specify the frequency SCLK?
I'm using Lazarus 1.2.4, Raspbian Jessie, RPi3That is quite an old version of Lazarus. Time to upgrade!
Although rpi_hal works excellent, still I'm having one problem-closing program get SIGSEGV. Without rpi_hal everything is ok. Tried to catch it in try except, but no lucky.
Martin
pls. compile it with -B -gl (e.g. fpc -B -gl), run it and post the outpt.
Hi,Did you enable I2C in Raspi-config?
Used V4.5 on my Pi3B
Testrpi worked with fpc. 8-)
Result -->
2017-03-16 00:51:58 ERR I2C_start[0x01]: /dev/i2c-1
2017-03-16 00:51:58 ERR SPI_Dev_Init[0x00/00]: /dev/spidev0.0
2017-03-16 00:51:58 ERR SPI_Dev_Init[0x00/01]: /dev/spidev0.1
Show CPU-Info, RPI-HW-Info and Registers:
rpi Snr : 0000000019a2908f
rpi HW : BCM2709
rpi proc : 0
rpi rev : rev4;1024MB;3B;BCM2709;a02082;40~~~
But with lazarus compiles but throws an error on run -
'Project project1 raised exception class 'External: SIGABRT''
In file '../nptl/sysdeps/unix/sysv/linux/raise.c' at line 56
(its run with sudo)
Thanks
I know Raspberry Pi isn't expensive, I want to join the fun. But before I buy one, I wonder what you guys do with your Raspberry Pi?
Can anyone help me ?Is it the same if run as root?
No that's not the same as root.. Why is everybody spreading that rumor over and over again.Can anyone help me ?Is it the same if run as root?
You can find more info at http://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#Accessing_external_hardware
No that's not the same as root.. Why is everybody spreading that rumor over and over again.A little more attention could be appreciated when reading. My question "Is it the same if run as root?" was just to do basic troubleshooting and to determine if executable would run without problems if started as root. If this simple troubleshooting succeeded then, and only then we would discuss what is the best way to do it. And wiki has a lot about proper way of handling this situation.
Linux allows to create a user for a specific piece of hardware or software that requires elevation or that can be accessed and run by or through a normal user.
You don't need root. You need an update on access rights.
interface
// The following option controls whether the code is optimized for Raspberry
PI 2.
// Added 2015-10-10 by Bo Berglund following web advice to get it working on
the Pi2 hardware
{$DEFINE RPi2}
...
const
REG_GPIO = {$IFDEF RPi2} $3F000 {$ELSE} $20000 {$ENDIF};//bcm2835/bcm2836
gpio register
...
// Mapping the RPi GPIO pin functions to GPIO I/O, should be here rather
than in user code
RPI_P3 = 2; //GPIO2
RPI_P5 = 3; //GPIO3
RPI_P7 = 4; //GPIO4
RPI_P8 = 14; //GPIO14
RPI_P10 = 15; //GPIO15
RPI_P11 = 17; //GPIO17
RPI_P12 = 18; //GPIO18
RPI_P13 = 27; //GPIO27
RPI_P15 = 22; //GPIO22
RPI_P16 = 23; //GPIO23
RPI_P18 = 24; //GPIO24
RPI_P19 = 10; //GPIO10
RPI_P21 = 9; //GPIO9
RPI_P22 = 25; //GPIO25
RPI_P23 = 11; //GPIO11
RPI_P24 = 8; //GPIO8
RPI_P26 = 7; //GPIO7
...
function TIoDriver.MapIo: boolean;
begin
Result := True;
{$IFDEF RPi2}
fd := fpopen('/dev/gpiomem', O_RdWr or O_Sync); // Open the master
/dev/memory device
{$ELSE}
fd := fpopen('/dev/mem', O_RdWr or O_Sync); // Open the master
/dev/memory device
{$ENDIF}
if fd < 0 then
begin
Result := False; // unsuccessful memory mapping
end;
//
end;