This repository has been archived on 2022-10-01. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
04_zumbach/00_m644p_blink_make/main.c
2019-02-06 22:40:43 +04:00

50 lines
944 B
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* main.c
*
* Created on: 22 нояб. 2018 г.
* Author: maxx
*/
#include <avr/io.h>
#include <util/delay.h>
/*
* m1284p minimum template, with one button & one led
*/
//M644P/M1284p Users LEDS:
//LED1/PORTC.4- m644p/m1284p maxxir
#define led1_conf() DDRC |= (1<<DDC4)
#define led1_high() PORTC |= (1<<PORTC4)
#define led1_low() PORTC &= ~(1<<PORTC4)
#define led1_tgl() PORTC ^= (1<<PORTC4)
#define led1_read() (PORTC & (1<<PORTC4))
#define sw1_conf() {DDRC &= ~(1<<DDC5); PORTC |= (1<<PORTC5);}
#define sw1_read() (PINC & (1<<PINC5))
int main()
{
led1_conf();
led1_low();
sw1_conf();
while(1)
{
if(sw1_read())
{
//sw1 released
//_delay_ms(500); //1Hz
_delay_ms(50); //10Hz
led1_low();
}
else
{
//sw1 pressed
_delay_ms(500); //1Hz
//_delay_ms(50); //10Hz
led1_tgl();
}
//led1_tgl();
}
return 0;
}