Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #include <util/atomic.h>
- #include <util/delay.h>
- #include <stdint.h>
- #define LIGHT_DAY _BV(PC0)
- #define LIGHT_BRAKE _BV(PC1)
- #define LIGHT_DIR_R _BV(PC2)
- #define LIGHT_REV _BV(PC3)
- #define LIGHT_DIR_L _BV(PC4)
- #define LIGHT_STROBO_L _BV(PC5)
- #define LIGHT_STROBO_R _BV(PC6)
- #define LIGHT_NIGHT _BV(PC7)
- #define SET_LIGHTS(LIGHTS) PORTC |= (LIGHTS);
- #define CLR_LIGHTS(LIGHTS) PORTC &= ~(LIGHTS);
- typedef uint8_t Time;
- volatile Time systemTime = 0;
- ISR(TIMER1_COMPA_vect){
- systemTime++;
- }
- void initAll(){
- DDRC = 0xFF;
- // system clock
- TCCR1B = _BV(WGM12) | _BV(CS12);
- TCNT1 = 0;
- OCR1A = 31250;
- TIMSK = _BV(OCIE1A);
- sei();
- }
- int main(){
- initAll();
- while(1){
- PORTC = systemTime;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement