Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

usart works, timer works

  • Loading branch information...
commit ebba9c2a59d773a59be28b4fe465fd52d597d901 1 parent 1590f25
@alxlo alxlo authored
View
2  firmware/lib/bughal.c
@@ -65,6 +65,8 @@ void buzzr_inv(void){
}
void init_switch(void){
+ DDRD &= ~( (1 << PORTD1) | (1<<PORTD0));
+ PORTD |= (1 << PORTD1) | (1<<PORTD0); //Pullups FTW
return;
}
View
19 firmware/lib/usart.c
@@ -48,11 +48,7 @@ ISR (USART_RX_vect)
*rxhead0 = c;
++rxhead0;
if (rxhead0 == (rxbuf0 + UART_RXBUFSIZE)) rxhead0 = rxbuf0;
-// if((diff > 100)&&(xon==0))
-// {
-// xon=1;
-// //set the CTS pin
-// }
+
}
UCSR0B |= (1 << RXCIE0);
}
@@ -62,8 +58,8 @@ void USART0_Init (void)
{
// set baudrate
#define BAUD_TOL 4
- #undef BAUD
- #define BAUD 115200
+ #undef BAUD
+ #define BAUD 115200
#include <util/setbaud.h>
UBRR0H = UBRRH_VALUE;
UBRR0L = UBRRL_VALUE;
@@ -94,7 +90,6 @@ void USART0_Init (void)
void USART0_putc (char c)
{
-
loop_until_bit_is_set(UCSR0A, UDRE0);
UDR0 = c;
}
@@ -105,14 +100,6 @@ uint8_t USART0_Getc_nb(uint8_t *c)
if (rxhead0==rxtail0) return 0;
*c = *rxtail0;
if (++rxtail0 == (rxbuf0 + UART_RXBUFSIZE)) rxtail0 = rxbuf0;
-
-// uint8_t diff = rxhead0 - rxtail0;
-// if((diff < 10)&&(xon==1))
-// {
-// xon=0;
-// //set the CTS pin
-// }
-
return 1;
}
View
37 firmware/main.c
@@ -1,6 +1,7 @@
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
+#define __DELAY_BACKWARD_COMPATIBLE__
#include <util/delay.h>
#include <stdlib.h>
@@ -8,6 +9,7 @@
#include "lib/synth.h"
#include "lib/usart.h"
#include "lib/bughal.h"
+#include "lib/util.h"
@@ -17,18 +19,45 @@ main(void)
/* hardware initialisation: */
init_leds();
init_buzzr();
- //USART0_Init();
- // init_motor();
+ init_switch();
+ USART0_Init();
+ init_motor();
+ /* software initialisation */
+ timer_init();
/* here the show begins:*/
- //sei();
+ sei();
//set_motor(MOTOR_ON);
+ timer_t t;
+ uint8_t ledmode =0;
+ uint16_t ct =0;
+ led_on(LED_R);
+ timer_set(&t, 100);
for(;;) /* ever */ {
//do something
- //synth_poll();
+ //main polling loop;
+ if (timer_expired(&t)){
+ if (0==ledmode){
+ ledmode =1;
+ led_on(LED_L);
+
+ } else {
+
+ ledmode=0;
+ led_off(LED_L);
+
+ };
+ timer_set(&t, 1);
+ USART0_crlf();
+ USART0_put_uint16(ct);
+ ct++;
+ }; //end if timer expired
+
//USART0_put_uint16(0xA09F);
//USART0_crlf();
+
+
}
/* never return 0; */
View
1  fw_test/main.c
@@ -1,6 +1,7 @@
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
+#define __DELAY_BACKWARD_COMPATIBLE__
#include <util/delay.h>
#include <stdlib.h>

0 comments on commit ebba9c2

Please sign in to comment.
Something went wrong with that request. Please try again.