Skip to content
Snippets Groups Projects
Commit bf9e68e4 authored by 최 민서's avatar 최 민서
Browse files

chore: 디펜던시 및 라이브러리 설치 스크립트 추가

parent 3c3f66f9
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
URL="http://www.airspayce.com/mikem/bcm2835/bcm2835-1.75.tar.gz"
FILE="bcm2835-1.75.tar.gz"
DIR="bcm2835-1.75"
# bcm2835 라이브러리 다운로드
echo "$URL에서 bcm2835 라이브러리를 다운로드 중..."
wget -O "$FILE" "$URL"
# tar.gz 파일 압축 해제
echo "$FILE 압축 해제 중..."
tar zxvf "$FILE"
# 압축 해제된 디렉토리로 이동
cd "$DIR"
# configure 스크립트 실행
echo "./configure 실행 중..."
./configure
# 라이브러리 빌드
echo "make 실행 중..."
make
# (선택 사항) 테스트 실행
echo "sudo make check 실행 중..."
sudo make check
# 라이브러리 설치
echo "sudo make install 실행 중..."
sudo make install
# 파일 정리
cd ..
echo "정리 중..."
rm -rf "$DIR" "$FILE"
echo "bcm2835 라이브러리 설치가 성공적으로 완료되었습니다!"
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**
* Library extends MFRC522.h to support RATS for ISO-14443-4 PICC.
* RATS - Request for Answer To Select.
* @author JPG-Consulting
*/
#ifndef MFRC522Extended_h
#define MFRC522Extended_h
#include "Arduino.h"
#include "MFRC522.h"
class MFRC522Extended : public MFRC522 {
public:
// ISO/IEC 14443-4 bit rates
enum TagBitRates : byte {
BITRATE_106KBITS = 0x00,
BITRATE_212KBITS = 0x01,
BITRATE_424KBITS = 0x02,
BITRATE_848KBITS = 0x03
};
// Structure to store ISO/IEC 14443-4 ATS
typedef struct {
byte size;
byte fsc; // Frame size for proximity card
struct {
bool transmitted;
bool sameD; // Only the same D for both directions supported
TagBitRates ds; // Send D
TagBitRates dr; // Receive D
} ta1;
struct {
bool transmitted;
byte fwi; // Frame waiting time integer
byte sfgi; // Start-up frame guard time integer
} tb1;
struct {
bool transmitted;
bool supportsCID;
bool supportsNAD;
} tc1;
// Raw data from ATS
byte data[FIFO_SIZE - 2]; // ATS cannot be bigger than FSD - 2 bytes (CRC), according to ISO 14443-4 5.2.2
} Ats;
// A struct used for passing the PICC information
typedef struct {
uint16_t atqa;
Uid uid;
Ats ats;
// For Block PCB
bool blockNumber;
} TagInfo;
// A struct used for passing PCB Block
typedef struct {
struct {
byte pcb;
byte cid;
byte nad;
} prologue;
struct {
byte size;
byte *data;
} inf;
} PcbBlock;
// Member variables
TagInfo tag;
/////////////////////////////////////////////////////////////////////////////////////
// Contructors
/////////////////////////////////////////////////////////////////////////////////////
MFRC522Extended(uint8_t ss, uint8_t rst) : MFRC522(ss, rst) {};
/////////////////////////////////////////////////////////////////////////////////////
// Functions for communicating with PICCs
/////////////////////////////////////////////////////////////////////////////////////
StatusCode PICC_Select(Uid *uid, byte validBits = 0) override; // overrride
StatusCode PICC_RequestATS(Ats *ats);
StatusCode PICC_PPS(); // PPS command without bitrate parameter
StatusCode PICC_PPS(TagBitRates sendBitRate, TagBitRates receiveBitRate); // Different D values
/////////////////////////////////////////////////////////////////////////////////////
// Functions for communicating with ISO/IEC 14433-4 cards
/////////////////////////////////////////////////////////////////////////////////////
StatusCode TCL_Transceive(PcbBlock *send, PcbBlock *back);
StatusCode TCL_Transceive(TagInfo * tag, byte *sendData, byte sendLen, byte *backData = NULL, byte *backLen = NULL);
StatusCode TCL_TransceiveRBlock(TagInfo *tag, bool ack, byte *backData = NULL, byte *backLen = NULL);
StatusCode TCL_Deselect(TagInfo *tag);
/////////////////////////////////////////////////////////////////////////////////////
// Support functions
/////////////////////////////////////////////////////////////////////////////////////
static PICC_Type PICC_GetType(TagInfo *tag);
using MFRC522::PICC_GetType;// // make old PICC_GetType(byte sak) available, otherwise would be hidden by PICC_GetType(TagInfo *tag)
// Support functions for debuging
void PICC_DumpToSerial(TagInfo *tag);
using MFRC522::PICC_DumpToSerial; // make old PICC_DumpToSerial(Uid *uid) available, otherwise would be hidden by PICC_DumpToSerial(TagInfo *tag)
void PICC_DumpDetailsToSerial(TagInfo *tag);
using MFRC522::PICC_DumpDetailsToSerial; // make old PICC_DumpDetailsToSerial(Uid *uid) available, otherwise would be hidden by PICC_DumpDetailsToSerial(TagInfo *tag)
void PICC_DumpISO14443_4(TagInfo *tag);
/////////////////////////////////////////////////////////////////////////////////////
// Convenience functions - does not add extra functionality
/////////////////////////////////////////////////////////////////////////////////////
bool PICC_IsNewCardPresent() override; // overrride
bool PICC_ReadCardSerial() override; // overrride
};
#endif
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
#include <chrono>
#include <thread>
#include "Arduino.h"
auto start_time = std::chrono::high_resolution_clock::now();
unsigned long millis(void)
{
auto current_time = std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(current_time - start_time).count();
}
unsigned long micros(void)
{
auto current_time = std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<std::chrono::microseconds>(current_time - start_time).count();
}
\ No newline at end of file
/*
From different classes in https://github.com/arduino/ArduinoCore-avr/tree/master/cores/arduino
*/
#ifndef Arduino_h
#define Arduino_h
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include "bcm2835.h"
#define INPUT BCM2835_GPIO_FSEL_INPT
#define OUTPUT BCM2835_GPIO_FSEL_OUTP
#define PI 3.1415926535897932384626433832795
#define HALF_PI 1.5707963267948966192313216916398
#define TWO_PI 6.283185307179586476925286766559
#define DEG_TO_RAD 0.017453292519943295769236907684886
#define RAD_TO_DEG 57.295779513082320876798154814105
#define EULER 2.718281828459045235360287471352
#define SERIAL 0x0
#define DISPLAY 0x1
#define LSBFIRST BCM2835_SPI_BIT_ORDER_LSBFIRST
#define MSBFIRST BCM2835_SPI_BIT_ORDER_MSBFIRST
#define CHANGE 1
#define FALLING 2
#define RISING 3
// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#endif
#define abs(x) ((x) > 0 ? (x) : -(x))
#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
#define round(x) ((x) >= 0 ? (long)((x) + 0.5) : (long)((x)-0.5))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x) * (x))
#define clockCyclesPerMicrosecond() (F_CPU / 1000000L)
#define clockCyclesToMicroseconds(a) ((a) / clockCyclesPerMicrosecond())
#define microsecondsToClockCycles(a) ((a)*clockCyclesPerMicrosecond())
#define lowByte(w) ((uint8_t)((w)&0xff))
#define highByte(w) ((uint8_t)((w) >> 8))
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitToggle(value, bit) ((value) ^= (1UL << (bit)))
#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet(value, bit) : bitClear(value, bit))
#define F(s) s
#define digitalWrite(pin, val) bcm2835_gpio_write(pin, val)
#define pinMode(pin, val) bcm2835_gpio_fsel(pin, val)
#define digitalRead(pin) bcm2835_gpio_lev(pin)
typedef unsigned int word;
typedef bool boolean;
typedef uint8_t byte;
unsigned long millis(void);
unsigned long micros(void);
// // WMath prototypes
// long random(long);
// long random(long, long);
// void randomSeed(unsigned long);
// long map(long, long, long, long, long);
#endif
\ No newline at end of file
MIT License
Copyright (c) 2020 Calvin Liang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# RPi-Arduino-SPI
Supports Serial and SPI class on Raspberry Pi.
Made this while porting https://github.com/miguelbalboa/rfid to Raspberry Pi.
Used in https://github.com/CoolCyberBrain/RPi-MFRC522
Requires bcm2835
\ No newline at end of file
/*
* Copyright (c) 2010 by Cristian Maglie <c.maglie@arduino.cc>
* Copyright (c) 2014 by Paul Stoffregen <paul@pjrc.com> (Transaction API)
* Copyright (c) 2014 by Matthijs Kooijman <matthijs@stdin.nl> (SPISettings AVR)
* Copyright (c) 2014 by Andrew J. Kroll <xxxajk@gmail.com> (atomicity fixes)
* SPI Master library for arduino.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of either the GNU General Public License version 2
* or the GNU Lesser General Public License version 2.1, both as
* published by the Free Software Foundation.
*/
#ifndef _SPI_H_INCLUDED
#define _SPI_H_INCLUDED
#include <cstddef>
#include "bcm2835.h"
// SPI_HAS_TRANSACTION means SPI has beginTransaction(), endTransaction(),
// usingInterrupt(), and SPISetting(clock, bitOrder, dataMode)
#define SPI_HAS_TRANSACTION 1
// SPI_ATOMIC_VERSION means that SPI has atomicity fixes and what version.
// This way when there is a bug fix you can check this define to alert users
// of your code if it uses better version of this library.
// This also implies everything that SPI_HAS_TRANSACTION as documented above is
// available too.
#define SPI_ATOMIC_VERSION 1
// Uncomment this line to add detection of mismatched begin/end transactions.
// A mismatch occurs if other libraries fail to use SPI.endTransaction() for
// each SPI.beginTransaction(). Connect an LED to this pin. The LED will turn
// on if any mismatch is ever detected.
//#define SPI_TRANSACTION_MISMATCH_LED 5
#ifndef LSBFIRST
#define LSBFIRST BCM2835_SPI_BIT_ORDER_LSBFIRST
#endif
#ifndef MSBFIRST
#define MSBFIRST BCM2835_SPI_BIT_ORDER_MSBFIRST
#endif
#define SPI_CLOCK_DIV1 BCM2835_SPI_CLOCK_DIVIDER_1
#define SPI_CLOCK_DIV2 BCM2835_SPI_CLOCK_DIVIDER_2
#define SPI_CLOCK_DIV4 BCM2835_SPI_CLOCK_DIVIDER_4
#define SPI_CLOCK_DIV8 BCM2835_SPI_CLOCK_DIVIDER_8
#define SPI_CLOCK_DIV16 BCM2835_SPI_CLOCK_DIVIDER_16
#define SPI_CLOCK_DIV32 BCM2835_SPI_CLOCK_DIVIDER_32
#define SPI_CLOCK_DIV64 BCM2835_SPI_CLOCK_DIVIDER_64
#define SPI_CLOCK_DIV128 BCM2835_SPI_CLOCK_DIVIDER_128
#define SPI_CLOCK_DIV256 BCM2835_SPI_CLOCK_DIVIDER_256
#define SPI_CLOCK_DIV512 BCM2835_SPI_CLOCK_DIVIDER_512
#define SPI_CLOCK_DIV1024 BCM2835_SPI_CLOCK_DIVIDER_1024
#define SPI_CLOCK_DIV2048 BCM2835_SPI_CLOCK_DIVIDER_2048
#define SPI_CLOCK_DIV4096 BCM2835_SPI_CLOCK_DIVIDER_4096
#define SPI_CLOCK_DIV8192 BCM2835_SPI_CLOCK_DIVIDER_8192
#define SPI_CLOCK_DIV16384 BCM2835_SPI_CLOCK_DIVIDER_16384
#define SPI_CLOCK_DIV32768 BCM2835_SPI_CLOCK_DIVIDER_32768
#define SPI_CLOCK_DIV65536 BCM2835_SPI_CLOCK_DIVIDER_65536
#define SPI_MODE0 BCM2835_SPI_MODE0
#define SPI_MODE1 BCM2835_SPI_MODE1
#define SPI_MODE2 BCM2835_SPI_MODE2
#define SPI_MODE3 BCM2835_SPI_MODE3
class SPISettings {
public:
SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) {
_clock = clock;
_bitOrder = bitOrder;
_dataMode = dataMode;
}
SPISettings() {
_clock = SPI_CLOCK_DIV64;
_bitOrder = MSBFIRST;
_dataMode = SPI_MODE0;
}
private:
uint8_t _clock;
uint8_t _bitOrder;
uint8_t _dataMode;
friend class SPIClass;
};
class SPIClass {
public:
SPIClass() { begin(); }
~SPIClass() { end(); }
// Initialize the SPI library
inline static void begin() { bcm2835_spi_begin(); }
// Before using SPI.transfer() or asserting chip select pins,
// this function is used to gain exclusive access to the SPI bus
// and configure the correct settings.
inline static void beginTransaction(SPISettings settings) {
bcm2835_spi_setBitOrder(settings._bitOrder);
bcm2835_spi_setDataMode(settings._dataMode);
bcm2835_spi_setClockDivider(settings._clock);
bcm2835_spi_chipSelect(BCM2835_SPI_CS_NONE);
}
// Write to the SPI bus (MOSI pin) and also receive (MISO pin)
inline static uint8_t transfer(uint8_t data) {
return bcm2835_spi_transfer(data);
}
inline static void transfer(void *buf, size_t count) {
bcm2835_spi_transfern((char *)buf, count);
}
// After performing a group of transfers and releasing the chip select
// signal, this function allows others to access the SPI bus
inline static void endTransaction(void) {}
// Disable the SPI bus
inline static void end() { bcm2835_spi_end(); }
};
extern SPIClass SPI;
#endif
/*
From different classes in https://github.com/arduino/ArduinoCore-avr/tree/master/cores/arduino
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Serial.h"
// Public Methods //////////////////////////////////////////////////////////////
size_t SerialClass::write(const uint8_t *buffer, size_t size)
{
return fwrite(buffer, size, 1, stdout);
}
size_t SerialClass::write(uint8_t c)
{
return write(&c, 1);
}
size_t SerialClass::print(const std::string &s)
{
return write(s.c_str(), s.length());
}
size_t SerialClass::print(const char str[])
{
return write(str);
}
size_t SerialClass::print(char c)
{
return write(c);
}
size_t SerialClass::print(unsigned char b, int base)
{
return print((unsigned long)b, base);
}
size_t SerialClass::print(int n, int base)
{
return print((long)n, base);
}
size_t SerialClass::print(unsigned int n, int base)
{
return print((unsigned long)n, base);
}
size_t SerialClass::print(long n, int base)
{
if (base == 0)
{
return write(n);
}
else if (base == 10)
{
if (n < 0)
{
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
}
else
{
return printNumber(n, base);
}
}
size_t SerialClass::print(unsigned long n, int base)
{
if (base == 0)
return write(n);
else
return printNumber(n, base);
}
size_t SerialClass::print(double n, int digits)
{
return printFloat(n, digits);
}
size_t SerialClass::println(void)
{
return write("\r\n");
}
size_t SerialClass::println(const std::string &s)
{
size_t n = print(s);
n += println();
return n;
}
size_t SerialClass::println(const char c[])
{
size_t n = print(c);
n += println();
return n;
}
size_t SerialClass::println(char c)
{
size_t n = print(c);
n += println();
return n;
}
size_t SerialClass::println(unsigned char b, int base)
{
size_t n = print(b, base);
n += println();
return n;
}
size_t SerialClass::println(int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t SerialClass::println(unsigned int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t SerialClass::println(long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t SerialClass::println(unsigned long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t SerialClass::println(double num, int digits)
{
size_t n = print(num, digits);
n += println();
return n;
}
// Private Methods /////////////////////////////////////////////////////////////
size_t SerialClass::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2)
base = 10;
do
{
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while (n);
return write(str);
}
size_t SerialClass::printFloat(double number, uint8_t digits)
{
size_t n = 0;
if (isnan(number))
return print("nan");
if (isinf(number))
return print("inf");
if (number > 4294967040.0)
return print("ovf"); // constant determined empirically
if (number < -4294967040.0)
return print("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)
{
n += print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i = 0; i < digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
n += print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0)
{
n += print('.');
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)(remainder);
n += print(toPrint);
remainder -= toPrint;
}
return n;
}
SerialClass Serial;
\ No newline at end of file
/*
From different classes in https://github.com/arduino/ArduinoCore-avr/tree/master/cores/arduino
*/
#ifndef Serial_h
#define Serial_h
#include <string>
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
class SerialClass
{
private:
size_t printNumber(unsigned long, uint8_t);
size_t printFloat(double, uint8_t);
public:
SerialClass() {}
size_t write(uint8_t);
size_t write(const char *str)
{
if (str == NULL)
return 0;
return write((const uint8_t *)str, strlen(str));
}
size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size)
{
return write((const uint8_t *)buffer, size);
}
size_t print(const std::string &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(double, int = 2);
size_t println(const std::string &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(double, int = 2);
size_t println(void);
};
extern SerialClass Serial;
#endif
\ No newline at end of file
This diff is collapsed.
/**
* Copyright (c) 2016 by Ludwig Grill (www.rotzbua.de)
* Simple deprecated workaround for Arduino IDE
* IDE 1.6.8 use gcc 4.8 which do not support c++14 [[deprecated]]
* Later versions should support c++14, then use c++14 syntax
*/
#ifndef DEPRECATED_H
#define DEPRECATED_H
#ifdef __has_cpp_attribute
#if __has_cpp_attribute(deprecated)
#define DEPRECATED [[deprecated]]
#define DEPRECATED_MSG(msg) [[deprecated(msg)]]
#endif // __has_cpp_attribute(deprecated)
#else
#define DEPRECATED __attribute__((deprecated))
#define DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
#endif // __has_cpp_attribute
#endif // DEPRECATED_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment