X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=target%2Fee%2Fee.c;h=9ea22cdcc41fe74081e0a94c9ea0c10c22afe1df;hp=68b6e4cc2f65a107ca8efe822775f11ce310b4a0;hb=17d2432a8b9c15963cd3b821f025ad33972ef477;hpb=7de3a43887485c3c6cf52960376ccde33fb33985 diff --git a/target/ee/ee.c b/target/ee/ee.c index 68b6e4cc..9ea22cdc 100644 --- a/target/ee/ee.c +++ b/target/ee/ee.c @@ -26,6 +26,10 @@ sfr at 0x80 P0; sfr at 0x90 P1; sfr at 0xA0 P2; sfr at 0xC6 CLKCON; +sfr at 0xbe SLEEP; + +# define SLEEP_USB_EN (1 << 7) +# define SLEEP_XOSC_STB (1 << 6) sfr at 0xF1 PERCFG; #define PERCFG_T1CFG_ALT_1 (0 << 6) @@ -170,7 +174,7 @@ uint8_t bitbang_in_bit(void) { uint8_t b; - + delay(1); SCK = 1; delay(1); @@ -273,6 +277,8 @@ usart_in_out(uint8_t byte) U0DBUF = byte; while ((U0CSR & UxCSR_TX_BYTE) == 0) ; + U0CSR &= ~UxCSR_TX_BYTE; + return U0DBUF; } void @@ -313,7 +319,7 @@ wrsr(uint8_t status) spi_out_byte(status); spi_cs(1); } - + void wren(void) { @@ -375,8 +381,11 @@ main () uint8_t buf[LENGTH]; int i; + P1DIR |= 2; CLKCON = 0; - + while (!(SLEEP & SLEEP_XOSC_STB)) + ; + spi_init(); status = rdsr(); @@ -389,10 +398,10 @@ main () */ status &= ~(1 << 7); wrsr(status); -// write(0x0, STRING, LENGTH); + write(0x0, STRING, LENGTH); for (;;) { read(0x0, buf, LENGTH); for (i = 0; i < LENGTH; i++) - debug_byte(STRING[i]); + debug_byte(buf[i]); } }