* * *

Author Topic: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library  (Read 42499 times)

Yoyo07

  • Newbie
  • Posts: 1
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #30 on: April 21, 2015, 07:18:16 pm »
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

pascalbythree

  • Jr. Member
  • **
  • Posts: 59
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #31 on: August 02, 2015, 08:19:26 pm »
Hello coders.

Is het possible to run:

unit rpi_hal; { V3.1 }

on the lastest version of of Raspbian Wheezy
   2015-05-05-raspbian-wheezy.zip   07-May-2015 10:54    1.0G
RPI_HAL.PAS does compile with FPC on the command line.
But testrpi.pas does not compile or give any system info by the code below here.

booting: Linux raspberrypi 3.18.11+

  program testrpi;
  uses rpi_hal;
  const piggyback=1; piface=2; board_installed=0; //board_installed=piggyback;
  begin
    writeln('Show CPU-Info, RPI-HW-Info and Registers:');
    rpi_show_all_info;


or do i need a version below

//Simple Test program, which is using rpi_hal. compile it on rpi with '#fpc testrpi.pas' and run it '#./testrpi'
//Tested on Raspbian Wheezy. Distro was occidentalis.
//#uname -a
//#Linux raspberrypi 3.6.11+ #399 PREEMPT Sun Mar 24 19:22:58 GMT 2013 armv6l

Named:

[DIR]   2013-02-09-wheezy-raspbian/   09-Feb-2013 10:35    

or it boots with

   raspbian-2015-05-07/   07-May-2015

The lastest version, that i am now booting.

Greets Wouter van Wegen

woutervanwegen@mijnplinq.nl



Or is there a difference between fpc command line and compiling it with Lazarus on X-Windows?
« Last Edit: August 02, 2015, 08:37:57 pm by pascalbythree »

Thaddy

  • Hero Member
  • *****
  • Posts: 4629
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #32 on: August 03, 2015, 10:50:23 am »
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

That's an abstract error: your code ends up in a method that has no implementation yet.
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

katonacs73

  • Newbie
  • Posts: 2
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #33 on: August 04, 2015, 09:50:42 am »
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 had the same problem, but I found a solution:
modify the Lazarus IDE compiler options:

Project -> Project Options ... -> Compiler Options -> Other

then add:
-dUseCThreads     

sfischer

  • New member
  • *
  • Posts: 35
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #34 on: August 31, 2015, 11:09:06 am »
source of rpi_hal has been moved to github:

https://github.com/rudiratlos/rpi_hal

I will release a new version soon.

tigerA15

  • New member
  • *
  • Posts: 17
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #35 on: November 28, 2015, 01:26:51 pm »
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:
Code: Pascal  [Select]
  1. program testrpi;
  2.  
  3. {$mode objfpc}{$H+}
  4. uses
  5.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  6.   cthreads,
  7.   {$ENDIF}{$ENDIF} sysutils, rpi_hal;
  8.  
  9. const
  10.   piggyback = 1;
  11.   piface = 2;
  12.   board_installed = piggyback;//board_installed=piggyback;
  13. var isr:isr_t;
  14. begin
  15.   writeln('Show CPU-Info, RPI-HW-Info and Registers:');
  16.   rpi_show_all_info;
  17.   isr.gpio:=16;
  18.   isr.rising_edge:=true;
  19.   gpio_set_int (isr, 16,@my_isr,true);
  20.   gpio_int_enable(isr);
  21.   gpio_set_pin(16,true);
  22.   delay_msec(200);
  23.   gpio_set_pin(16,false);
  24.  
  25.   gpio_int_disable(isr);
  26.   gpio_int_release(isr);
  27. 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 ?
« Last Edit: November 28, 2015, 01:58:52 pm by tigerA15 »

sfischer

  • New member
  • *
  • Posts: 35
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #36 on: November 28, 2015, 04:23:07 pm »
NEW Version V3.4 of RPI_HAL is available:

Additional support for RPI2B and Pi Zero

If you use Lazarus, then modify the Lazarus IDE compiler options:
Project -> Project Options ... -> Compiler Options -> Other and add: -dUseCThreads   

Download location:
https://github.com/rudiratlos/rpi-hal

functions:
- I2C
- SPI
- GPIO (input, output, SW-PWM, HW-PWM)
- Bitbang functions for Powerswitches (ELRO, Intertechno, Sartano, Nexa)
- Morse functions
- Rotational Encoders implemented with Threads (e.g. Keyes KY-040 Rotary Encoder)
- Servo functions
- PID Algorithmus
- functions to access PiFace Board
- Bidirectional serial device access in User space /dev/yourdevice
- USB Reset and Access
...
« Last Edit: November 28, 2015, 04:27:07 pm by sfischer »

sfischer

  • New member
  • *
  • Posts: 35
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #37 on: November 28, 2015, 04:28:33 pm »
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:
Code: Pascal  [Select]
  1. program testrpi;
  2.  
  3. {$mode objfpc}{$H+}
  4. uses
  5.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  6.   cthreads,
  7.   {$ENDIF}{$ENDIF} sysutils, rpi_hal;
  8.  
  9. const
  10.   piggyback = 1;
  11.   piface = 2;
  12.   board_installed = piggyback;//board_installed=piggyback;
  13. var isr:isr_t;
  14. begin
  15.   writeln('Show CPU-Info, RPI-HW-Info and Registers:');
  16.   rpi_show_all_info;
  17.   isr.gpio:=16;
  18.   isr.rising_edge:=true;
  19.   gpio_set_int (isr, 16,@my_isr,true);
  20.   gpio_int_enable(isr);
  21.   gpio_set_pin(16,true);
  22.   delay_msec(200);
  23.   gpio_set_pin(16,false);
  24.  
  25.   gpio_int_disable(isr);
  26.   gpio_int_release(isr);
  27. 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

tigerA15

  • New member
  • *
  • Posts: 17
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #38 on: November 29, 2015, 01:02:30 pm »
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:
Code: Pascal  [Select]
  1. program testrpi;
  2.  
  3. {$mode objfpc}{$H+}
  4. uses
  5.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  6.   cthreads,
  7.   {$ENDIF}{$ENDIF} sysutils, rpi_hal;
  8.  
  9. const
  10.   piggyback = 1;
  11.   piface = 2;
  12.   board_installed = piggyback;//board_installed=piggyback;
  13. var isr:isr_t;
  14. begin
  15.   writeln('Show CPU-Info, RPI-HW-Info and Registers:');
  16.   rpi_show_all_info;
  17.   isr.gpio:=16;
  18.   isr.rising_edge:=true;
  19.   gpio_set_int (isr, 16,@my_isr,true);
  20.   gpio_int_enable(isr);
  21.   gpio_set_pin(16,true);
  22.   delay_msec(200);
  23.   gpio_set_pin(16,false);
  24.  
  25.   gpio_int_disable(isr);
  26.   gpio_int_release(isr);
  27. 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

Itś worked! thatś greate! Thank you very much!

tigerA15

  • New member
  • *
  • Posts: 17
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #39 on: December 04, 2015, 08:31:58 am »
How to achieve 'soft pwm' function by rpi_hal library ? Can you show us the sample code ? :)
Thanks.

sfischer

  • New member
  • *
  • Posts: 35
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #40 on: December 14, 2015, 05:05:10 pm »
How to achieve 'soft pwm' function by rpi_hal library ? Can you show us the sample code ? :)
Thanks.

pls. see procedure GPIO_PWM_Test in rpi_hal. It shows the usages of HW and SWM PWM

alex1991

  • New member
  • *
  • Posts: 5
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #41 on: February 02, 2016, 07:10:16 am »
Hello!

Is it possible connect the ADC AD7866 to the  Raspberry Pi B+?
What procedure or function should be used to obtain information from the ADC?
What are the input parameters?

ADC AD7866
SCLK 20MHz, 1MSPS.
The data stream consists of one leading zero followed by three STATUS bits, followed by the 12 bits of conversion data.

P.S. SPI, of course.
« Last Edit: February 02, 2016, 07:16:18 am by alex1991 »

sfischer

  • New member
  • *
  • Posts: 35
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #42 on: February 02, 2016, 10:17:57 am »
Looks like, SPI BUS. But you can only connect one Output to SPI (DoutA or DoutB).

e.g.
rpi     to ADC

MISO to DOUTA
SCLK to SCLK
/SS   to /CS

sfischer

  • New member
  • *
  • Posts: 35
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #43 on: February 02, 2016, 10:30:20 am »
Looks like, that you can connect the ADC A0 line to an GPIO, for selecting DOUTA or DOUTB.

Connect DOUTA and DOUTB to rpi's MISO line

alex1991

  • New member
  • *
  • Posts: 5
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #44 on: February 02, 2016, 10:47:16 am »
Yes, of course. Thanks for the answer!

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?
« Last Edit: February 02, 2016, 11:00:35 am by alex1991 »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus