avr/lcd/main.c

37 lines
1.0 KiB
C
Raw Normal View History

2022-06-26 15:38:20 +00:00
#include <avr/io.h>
#include <util/delay.h>
#include <base.h>
#include <spi.h>
2022-06-26 16:40:04 +00:00
#include <shift_register.h>
#include <display.h>
2022-06-26 15:38:20 +00:00
int main(void) {
2022-06-26 16:40:04 +00:00
display_t display = {
2022-06-26 15:38:20 +00:00
.reg = {
.output = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 5 },
.latch_clock = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 6 },
.shift_clock = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 7 },
},
.register_select = { .ddr = &DDRF, .port = &PORTF, .pin = &PINF, .addr = 1 },
.enable = { .ddr = &DDRF, .port = &PORTF, .pin = &PINF, .addr = 0 },
};
gpio_t light = { .ddr = &DDRC, .port = &PORTC, .pin = &PINC, .addr = 7 };
set_line_direction(&light, LINE_OUT);
clear_line(&light);
2022-06-26 16:40:04 +00:00
display_init(&display);
2022-06-26 15:38:20 +00:00
2022-06-26 16:40:04 +00:00
display_clear(&display);
2022-06-26 15:38:20 +00:00
_delay_ms(500);
2022-06-26 16:40:04 +00:00
const char msg[] = "Hello, my bat";
display_write_message(&display, msg);
display_enable(&display);
2022-06-26 15:38:20 +00:00
set_line(&light);
while(1) { _delay_ms(1); }
}