Changeset 6f22754 in avrstuff


Ignore:
Timestamp:
Sep 7, 2019, 6:17:17 PM (5 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
e5dd493
Parents:
bbcd1f8
Message:

blinkled: cleanup a bit

I get bored of editing too much things in there after a while...

Location:
blinkled
Files:
3 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • blinkled/Makefile

    rbbcd1f8 r6f22754  
    1 #Set vars
    2 MCU=atmega48p
     1# User configurable variables
     2MCU=atmega8
    33FCPU=16000000
    4 COMPILE = avr-gcc -Wall -Os -std=c99 -mmcu=$(MCU) -DF_CPU=20000000
     4PROG=stk500 -P /dev/ports/usb0
     5
     6# You should not need to change anything below
     7# -----------------------------------------------------------------------------
     8COMPILE = avr-gcc -Wall -Wextra -Werror -Os -std=c99 -mmcu=$(MCU) -DF_CPU=$(FCPU)
    59
    610#Rules
     
    1822        $(COMPILE) -mmcu=$(MCU) -std=c99 -c $< -o $@
    1923
    20 flash:
    21         avrdude -c usbasp -p $(MCU) -Uflash:w:$(MCU).hex
     24flash: $(MCU).hex
     25        avrdude -c $(PROG) -p $(MCU) -Uflash:w:$(MCU).hex
    2226
    2327clean:
  • blinkled/main.c

    rbbcd1f8 r6f22754  
    88#include <stdbool.h>
    99
    10 #ifdef __AVR_ATmega48P__
    11 #define TIFR TIFR0
     10#if defined(__AVR_ATmega8__)
     11#define _TCCA TCCR1A
     12#define _TCCB TCCR1B
     13#define _TIFR TIFR
     14#define _TOV  TOV1
     15#elif defined(__AVR_ATmega48P__)
     16#define _TCCA TCCR0A
     17#define _TCCB TCCR0B
     18#define _TIFR TIFR0
     19#define _TOV  TOV0
     20#else
     21#error Unknown device! Add it to main.c and set the timer properly
    1222#endif
    1323
     
    1525        wdt_enable(WDTO_2S);
    1626    // configure timer 0 for a rate of 16M/(256 * 256) = ~244Hz
    17     TCCR0A = 0;          // timer 0 prescaler: 256
    18         TCCR0B = 4;
     27    _TCCA = 0;          // timer 0 prescaler: 256
     28        _TCCB = 4;
    1929
    2030        //debug LED - output
     
    2838
    2939                // check timer if we need periodic reports
    30                 if (TIFR & (1 << TOV0)) {
    31                         TIFR = (1 << TOV0); // reset flag
     40                if (_TIFR & (1 << _TOV)) {
     41                        _TIFR = (1 << _TOV); // reset flag
    3242                        PORTD ^= (1<<PD6);
    3343                }
Note: See TracChangeset for help on using the changeset viewer.