본문 바로가기

언어/라즈베리파이

lazarus에서 wiringpi로 raspberry pi GPIO핀 제어 라이브러리

출처: https://m.blog.naver.com/PostView.nhn?blogId=heennavi1004&logNo=10179141153&proxyReferer=https%3A%2F%2Fwww.google.co.kr%2F

hwiringpi.pas 는 다음과 같다.

---------------------------

원 소스: https://gitorious.net/raspberrypi-shareservice/raspberrypi-shareservice/source/4b8ef91fd63910212b476d875242dd7778bc2a8c:source/lazwiringpi/hwiringpi.pas#L7


 



unit hwiringpi;


(* Pascal wrapper unit for Gordon Henderson wiringPi library. The source can
* be found at https://projects.drogon.net/raspberry-pi/wiringpi/. Wrapper and
* pascal sample by Alex Schaller.
*
* wiringPi:
* Arduino compatable (ish) Wiring library for the Raspberry Pi
* Copyright (c) 2012 Gordon Henderson
***********************************************************************
* This file is part of wiringPi:
* https://projects.drogon.net/raspberry-pi/wiringpi/
*
* wiringPi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* wiringPi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************
*)

// Handy defines

{$link ./wiringPi/wiringPi.o} // hwiringpi.pas 가 있는 디렉토리 하부에 실제적인 코드가 있는 wiringPi 디렉토리가 있어여한다.
{$linklib c}

interface

const
NUM_PINS = 17; 
WPI_MODE_PINS = 0; 
WPI_MODE_GPIO = 1; 
INPUT = 0; 
OUTPUT = 1; 
PWM_OUTPUT = 2; 
LOW = 0; 
HIGH = 1;  

PUD_OFF = 0; 

PUD_DOWN = 1; 
PUD_UP = 2;

// Pin mappings from P1 connector to WiringPi library
// P1 커넥터를 WiringPi 라이브러리에 맞도록 핀 매핑
// Px represents to physical pin on the RaspberryPi P1 connector
// Px는 라즈베리파이 P1 커넥터 상의 물리적인 핀을 표시
// Px (보드의 핀번호), = y (WiringPi에서 사용하는 번호)
P3 = 8;
P5 = 9;
P7 = 7;
P8 = 15;
P10 = 16;
P11 = 0;
P12 = 1;
P13 = 2;
P15 = 3;
P16 = 4;
P18 = 5;
P19 = 12;
P21 = 13;
P22 = 6;
P23 = 14;
P24 = 10;
P26 = 11;



Function wiringPiSetup:longint;cdecl;external; // 초기 설정 함수

Procedure wiringPiGpioMode(mode:longint);cdecl;external; // Broadcom 모드 설정
Procedure pullUpDnControl(pin:longint; pud:longint);cdecl;external; // 핀 내부에 있는 풀다운 저항 컨트롤
Procedure pinMode(pin:longint; mode:longint);cdecl;external; // 핀모드 설정
Procedure digitalWrite(pin:longint; value:longint);cdecl;external// 핀에 신호 쓰기, HIGH, LOW
Procedure pwmWrite(pin:longint; value:longint);cdecl;external// PWM 신호 보내기
Function digitalRead(pin:longint):longint;cdecl;external// 핀신호 읽기
Procedure delay(howLong:dword);cdecl;external// 딜레이 함수
Procedure delayMicroseconds(howLong:dword);cdecl;external// 딜레이 함수 us
Function millis:dword;cdecl;external// wiringPiSetup 후 경과 시간 읽기


implementation


end.

'언어 > 라즈베리파이' 카테고리의 다른 글

라즈비안 버스터 Faster_OpenCV_4_Raspberry_Pi  (0) 2019.10.15
라즈베리파이 NodeJs 설치  (0) 2019.09.25
How to build and install OpenCV 2.4.9 on Raspberry Pi3  (0) 2018.09.10
초기설정  (0) 2018.09.08
OpenCV-for-Pi  (0) 2018.09.06