summaryrefslogtreecommitdiff
path: root/n/lcd
diff options
context:
space:
mode:
authorburg2006-05-22 16:06:09 +0000
committerburg2006-05-22 16:06:09 +0000
commit89a55a3a208e389f255a0e34e8619fbc52c30ebb (patch)
tree02bd567ca5afd2ace23946ad03bf02e28ea5bd1b /n/lcd
parent0c97c0770bb3c6e4f9cdd526700f30029a714f49 (diff)
I2C -> LCD : OK
KEYBD -> ES : KO :-) Faut tuner la lecture clavier... pff
Diffstat (limited to 'n/lcd')
-rw-r--r--n/lcd/src/Makefile2
-rw-r--r--n/lcd/src/avrconfig.h9
-rw-r--r--n/lcd/src/lcd.c33
3 files changed, 40 insertions, 4 deletions
diff --git a/n/lcd/src/Makefile b/n/lcd/src/Makefile
index 50de46a..ee0e875 100644
--- a/n/lcd/src/Makefile
+++ b/n/lcd/src/Makefile
@@ -1,7 +1,7 @@
BASE = ../../avr
AVR_PROGS = lcd
lcd_SOURCES = lcd.c
-MODULES = uart proto utils
+MODULES = uart proto utils twi
CONFIGFILE = avrconfig.h
# atmega8, atmega8535, atmega128...
AVR_MCU = atmega8
diff --git a/n/lcd/src/avrconfig.h b/n/lcd/src/avrconfig.h
index e08c18b..3f2fe24 100644
--- a/n/lcd/src/avrconfig.h
+++ b/n/lcd/src/avrconfig.h
@@ -83,4 +83,13 @@
/** Support for quote parameter. */
#define AC_PROTO_QUOTE 1
+/* twi slave */
+#define TWI_SL_RCPT_SIZE 16
+#define TWI_SL_SEND_SIZE 1
+
+#define TWI_SLAVE_ENABLE 1
+
+
+
+
#endif /* avrconfig_h */
diff --git a/n/lcd/src/lcd.c b/n/lcd/src/lcd.c
index 91483b8..73ae4ca 100644
--- a/n/lcd/src/lcd.c
+++ b/n/lcd/src/lcd.c
@@ -23,6 +23,7 @@
*
* }}} */
#include "common.h"
+#include "modules/twi/twi.h"
#include "modules/utils/utils.h"
#include "modules/uart/uart.h"
#include "modules/proto/proto.h"
@@ -90,6 +91,23 @@ lcd_send_string_n (const char *s, u8 i)
}
}
+//lcd_send_line(const char *s,u8 i,u8 l)
+//{
+// u8 cpt ;
+// lcd_transit_command(0x01); // suffit d'envoyer les bits de gauche à droite : D7D6D5D4 en hexa
+// utils_delay_ms(2);
+// if ( l == 0 )
+// lcd_transit_command(0x02);
+// else
+// lcd_transit_command(0xc0);
+// utils_delay_ms(2);
+// for (cpt = 0 ; cpt < 16 && cpt < i ; cpt++)
+// {
+// lcd_send_character(s[cpt]);
+// }
+//
+//}
+
/* Envois une chaîne de caractère. */
void
lcd_send_string (const char *s)
@@ -152,7 +170,7 @@ key_get (char old_key)
char i = 0;
while ( key_read () == 0 && i < 3 )
{
- utils_delay_ms(100);
+ utils_delay_ms(250); // was 100ms
if ( i == 2 )
old_key = 0;
i++;
@@ -295,17 +313,26 @@ int
main (void)
{
char old_key = 0;
+ uint8_t data_rcpt[TWI_SL_RCPT_SIZE];
sei ();
uart0_init ();
- proto_send0 ('z');
lcd_init ();
- lcd_send_string (" LCD initialise Attend Grub ");
+ twi_init(0x02);
+ proto_send0 ('z');
+ lcd_send_string (" LCD initialise ");
while (1)
{
if (uart0_poll ())
proto_accept (uart0_getc ());
utils_delay_ms(3);
old_key = key_get (old_key);
+
+ if (twi_sl_poll (data_rcpt, TWI_SL_RCPT_SIZE))
+ {
+ lcd_send_string_n(data_rcpt,32);
+ }
+
+ twi_sl_update (&old_key, TWI_SL_SEND_SIZE);
}
return 0;