Deprecating main.c & other functions in order to be a dumb terminal.
[uccvend-snackrom.git] / ROM2 / display_basic.c
1 /*
2  * display_basic.c - simple functions for writing to the screen of the vendie.
3  *
4  * Use set_msg(char[10]) to write a new message to the screen, replacing the
5  * previous one.
6  *
7  */
8
9 #include "display_basic.h"
10 #include "vend.h"
11
12 /* private prototypes */
13 void display_send_byte(char c);
14 void display_reset();
15
16 void set_msg(char newmsg[10]) {
17         int i;
18         display_reset();
19         for (i=0; i < 10; i++) {
20                 display_send_byte(newmsg[i]&0x7f);
21         }
22 }
23
24 void display_send_byte(char c) {
25         bset_misc_output(A3800_DISPLAY_WRITE);  /* enable the display clock */
26
27         _io_ports[M6811_SPDR] = c;                  /* load SPI with byte */
28         while(!(_io_ports[M6811_SPDR]&M6811_SPIE)); /* wait for completion */
29         _io_ports[M6811_SPDR];                      /* SPDR read to clear SPIE flag */
30 }
31
32 #define DISPLAY_DELAY  100 /* ms to delay between ops - could be tweaked */
33 void display_reset() {
34         /* lower the reset line for a while */
35         bclr((void*)&_io_ports[M6811_PORTA], PORTA_DISP_RESET);
36         delay(DISPLAY_DELAY);
37         bset((void*)&_io_ports[M6811_PORTA], PORTA_DISP_RESET);
38
39         spi_enable();
40         delay(DISPLAY_DELAY);
41
42         display_send_byte(0xC0 | 10);    /* tell the controller there are 10 digits */
43         display_send_byte(0xE0);    /* set duty cycle to 100%                  */
44
45         spi_disable();
46 }
47
48 void display_init() {
49         display_reset();
50 }
51

UCC git Repository :: git.ucc.asn.au