char btn_prev = 0;
char x=1;
void setup() {
char *inp = (char*)0x106;
Serial.begin(115200);
init_port();
init_timer();
while(1){
if(*inp && x){
Serial.println("hello");
}
delay1();
}
}
void init_port(){
volatile char *ddr1 = (char*)0x30;
*ddr1 = 0x03;
volatile char *ddr2 = (char*)0x107;
*ddr2 = 0x00;
}
void init_timer(){
volatile char *TCCR1_A = (char*)0x80;
volatile char *TCCR1_B = (char*)0x81;
volatile short *TCNT_1 = (short*)0x84;
volatile short *OCR1_A = (short*)0x88;
volatile char *TIMSK_1 = (char*)0x6F;
*TCCR1_A = 0x00;
*TCCR1_B = 0x0C;
*TCNT_1 = 0;
*OCR1_A = 62500;
*TIMSK_1 = 0x03;
}
ISR (TIMER1_COMPA_vect){
volatile char *btn_inp = (char*)0x106;
volatile char *out = (char*)0x31;
if(*btn_inp!=0){
x=0;
*out = 0x01;
for(volatile long i=0;i<200000;i++);
*out = 0x00;
}
if(*btn_inp==0){
x=0;
}
btn_prev = *btn_inp;
}
// void init_timer_2(){
// volatile char *TCCR3_A = (char*)0x90;
// volatile char *TCCR3_B = (char*)0x91;
// volatile short *TCNT_3 = (short*)0x94;
// volatile short *OCR3_A = (short*)0x98;
// volatile char *TIMSK_3 = (char*)0x71;
// *TCCR3_A = 0x00;
// *TCCR3_B = 0x0C;
// *TCNT_3 = 0;
// *OCR3_A = 3500;
// *TIMSK_3 = 0x03;
// }
// void ext_timer(){
// volatile char *EICR_A = (char*)0x69;
// volatile char *EI_MSK = (char*)0x3D;
// *EICR_A = 0x0F;
// *EI_MSK = 0x03;
// }
// ISR (INT0_vect){
// volatile char *out = (char*)0x31;
// *out = 0x01;
// for(volatile long i=0;i<100000;i++);
// *out = 0x00;
// }
// ISR (INT1_vect){
// volatile char *out = (char*)0x10B;
// *out = 0x01;
// for(volatile long i=0;i<100000;i++);
// *out = 0x00;
// }
void delay1(){
volatile long i;
for(i=0;i<50000;i++);
}
void loop() {
// put your main code here, to run repeatedly:
}