Skip to content

cortl0/gpio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fast GPIO library

Minimum calculations at run time
Maximum calculations at and before compile time
C++

Project directories and files

./bash/

GPIO scripts

./src/ (cpu || board) / * .h

Board and CPU definitions

./src/ (cpu || board) / * / *_generator.cpp

Definitions generator for each CPU and Board
(calculations before compile time)

./src/ (cpu || board) / * / *_example.hpp

Example usung for each CPU and Board

./src/main.cpp

Example of using GPIO for all CPUs and Boards

./src/creator/creator.cpp

Template for new CPUs and boards

Available CPUs

Allwinner H2+ (Datasheet) (Example)
Broadcom BCM2835 (Datasheet) (Example)
Texas Instruments AM335x (Manual)

Available boards

BananaPi P2 Zero (BPI-P2 Zero) (Datasheet) (Example)
BeagleBone Black (Datasheet)
Raspberry Pi Zero rev 1.3 (Datasheet) (Example)

Example project

https://github.com/cortl0/device

Build

make
make clean
make install
make uninstall
Qt build

Usage

#include "board/bpi_p2_zero/bpi_p2_zero.h"

int main()
{
    gpio::cpu _cpu(BASE_ADDRESS_GPIO);
    
    _cpu.write_bits(CON2_P10_CFG_REG, CON2_P10_CFG_BIT, P_SELECT_INPUT, P_SELECT_LENGTH);
    _cpu.write_bits(CON2_P10_PUL_REG, CON2_P10_PUL_BIT, P_PULL_DOWN, P_PULL_LENGTH);
    bool state_CON2_P10 = _cpu.read_bit(CON2_P10_DAT_REG, CON2_P10_DAT_BIT);
    
    _cpu.write_bits(CON2_P07_CFG_REG, CON2_P07_CFG_BIT, P_SELECT_OUTPUT, P_SELECT_LENGTH);
    bool state_CON2_P07 = HIGH;
    _cpu.write_bit (CON2_P07_DAT_REG, CON2_P07_DAT_BIT, state_CON2_P07);
    
    return 0;
}

Author

Ilya Shishkin
mailto:cortl@8iter.ru

GitHub reference

https://github.com/cortl0/gpio

License

This project is licensed under the GPL v3.0 - see the LICENSE file for details

Donate