GithubHelp home page GithubHelp logo

niktob560 / avr-api Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 1.79 MB

API library for Atmel AVR

License: GNU General Public License v3.0

C++ 96.37% Makefile 2.56% Shell 1.07%
avr mcu hardware-abstraction library avr-gcc avr-programming avr-microcontroller hacktoberfest atmel-avr

avr-api's Introduction

AVR-API [WIP]

Basic API library for Atmel AVR that can replace Arduino library

GPIO module

Example of single pin blink

gpio::setMode(&PORTB, PB7, gpio::OUTPUT);
while(1)
{
  gpio::setState(&PORTB, {PB7, gpio::State::TOGGLE});
  delay(100);
}

Example of many pins blinking

gpio::setMode(&PORTB, PB7, gpio::OUTPUT);
gpio::setMode(&PORTB, PB5, gpio::OUTPUT);
gpio::setMode(&PORTB, PB3, gpio::OUTPUT);
gpio::setMode(&PORTB, PB1, gpio::OUTPUT);
while(1)
{
  gpio::setStates(&PORTB, {{PB1, gpio::State::TOGGLE},
                           {PB3, gpio::State::TOGGLE},
                           {PB5, gpio::State::TOGGLE},
                           {PB7, gpio::State::TOGGLE}});
  delay(100);
}

USART module

Example using USART0 on 115200 baud

usart::begin<0>(115200);
sei();
usart::println<0>();
long i = 0;
while(1)
{
    usart::print<0>("NICE");    
    usart::println<0>(i);
    i++;
    delay(200);
}

Timers and interrupts module

Warning: timers module is under refactor now, methods Will be changed

void schedule(void)
{
  //foo
}

int main() 
{
  interrupt::set(interrupt::TC0_COMPA, schedule);
  TIMER0Init(TIMER0_COMA_NPWM_NORMAL, TIMER0_WF_CTC, TIMER0_CLK_SRC_1024);
  TIMER0EnableCOMPAInterrupt();
  TIMER0SetA(255);
  while(1) asm("NOP");
}

ADC module

adc::init();
adc::setRef(adc::ref::AREF);
sei();
adc::analogRead(0);

avr-api's People

Contributors

nikto-b avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

avr-api's Issues

Bad names

Names of files are bad (using .c instead of .cpp in C++ sources and .h instead of .hpp)

No PWM

No PWM available in timer settings

[BUG] Only one ADC mode working

Only background mode of sampling working using ADC module
adc::mode::DEADLINE and adc::mode::MANUAL are not supported and there is no way to set mode

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.