1-Wire tester, shows ROM code and temperature on an LCD screen
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1wire-tester/main.c

57 lines
1.0 KiB

#include <avr/io.h> // register definitions
#include <avr/pgmspace.h> // storing data in program memory
#include <avr/interrupt.h> // interrupt vectors
#include <util/delay.h> // delay functions
#include <stdint.h> // C header for int types like uint8_t
#include <stdbool.h> // C header for the bool type
#include <stdlib.h>
// Include stuff from the library
#include "lib/iopins.h"
#include "lib/usart.h"
#include "lcd.h"
// Pins
#define LED 13
void _lcd_wait_bf();
void _lcd_write_byte(uint8_t bb);
// UART receive handler
ISR(USART_RX_vect)
{
// "ECHO" function:
uint8_t b = usart_rx();
usart_tx(b); // send back
}
void main()
{
usart_init(BAUD_115200);
usart_isr_rx_enable(true); // enable RX interrupt handler
// configure pins
as_output(LED);
lcd_init();
// globally enable interrupts (for the USART_RX handler)
sei();
uint8_t cnt = 0;
while (1) {
lcd_clear();
lcd_xy(cnt, 0);
lcd_putc('A'+cnt);
cnt = (cnt+1)%20;
pin_toggle(13); // blink the LED
_delay_ms(100);
}
}