2012-07-17 01:05:27 +02:00
|
|
|
#include <inttypes.h>
|
|
|
|
#include <avr/io.h>
|
|
|
|
#include <avr/interrupt.h>
|
2012-10-01 21:39:25 +02:00
|
|
|
#define __DELAY_BACKWARD_COMPATIBLE__
|
2012-07-17 01:05:27 +02:00
|
|
|
#include <util/delay.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "main.h"
|
2012-09-02 21:53:11 +02:00
|
|
|
#include "lib/synth.h"
|
|
|
|
#include "lib/usart.h"
|
2012-09-02 23:49:57 +02:00
|
|
|
#include "lib/bughal.h"
|
2012-10-01 21:39:25 +02:00
|
|
|
#include "lib/util.h"
|
2012-07-26 01:34:49 +02:00
|
|
|
|
2012-08-12 01:35:00 +02:00
|
|
|
|
2012-08-27 09:43:42 +02:00
|
|
|
|
|
|
|
void __attribute__((noreturn))
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
/* hardware initialisation: */
|
2012-09-02 23:49:57 +02:00
|
|
|
init_leds();
|
2012-09-06 23:09:20 +02:00
|
|
|
init_buzzr();
|
2012-10-01 21:39:25 +02:00
|
|
|
init_switch();
|
|
|
|
USART0_Init();
|
|
|
|
init_motor();
|
|
|
|
/* software initialisation */
|
|
|
|
timer_init();
|
2012-08-27 09:43:42 +02:00
|
|
|
|
|
|
|
/* here the show begins:*/
|
2012-10-01 21:39:25 +02:00
|
|
|
sei();
|
2012-09-06 23:09:20 +02:00
|
|
|
//set_motor(MOTOR_ON);
|
2012-10-01 21:39:25 +02:00
|
|
|
timer_t t;
|
|
|
|
uint8_t ledmode =0;
|
|
|
|
uint16_t ct =0;
|
|
|
|
led_on(LED_R);
|
|
|
|
timer_set(&t, 100);
|
2012-08-07 20:08:57 +02:00
|
|
|
for(;;) /* ever */ {
|
2012-09-06 23:09:20 +02:00
|
|
|
//do something
|
2012-10-01 21:39:25 +02:00
|
|
|
//main polling loop;
|
|
|
|
if (timer_expired(&t)){
|
2012-10-01 22:27:16 +02:00
|
|
|
if (switch_l()) {led_on(LED_L);} else {led_off(LED_L);};
|
|
|
|
if (switch_r()) {led_on(LED_R);} else {led_off(LED_R);};
|
2012-10-01 22:32:52 +02:00
|
|
|
if (switch_l()&&switch_r()) {set_motor(MOTOR_ON);} else {set_motor(MOTOR_OFF);};
|
|
|
|
timer_set(&t, 5);
|
2012-10-01 21:39:25 +02:00
|
|
|
}; //end if timer expired
|
2012-08-12 01:35:00 +02:00
|
|
|
//USART0_put_uint16(0xA09F);
|
|
|
|
//USART0_crlf();
|
2012-10-01 21:39:25 +02:00
|
|
|
|
|
|
|
|
2012-08-14 22:53:25 +02:00
|
|
|
}
|
2012-07-18 15:55:20 +02:00
|
|
|
|
2012-08-14 22:53:25 +02:00
|
|
|
/* never return 0; */
|
2012-07-18 15:55:20 +02:00
|
|
|
}
|
2012-08-05 22:13:43 +02:00
|
|
|
|
|
|
|
|
2012-08-12 01:35:00 +02:00
|
|
|
|