#include // Aliases for IO ports etc. #include // Standard data types #include "spi.h" #include "dogm.h" void DOGM_CS(uint8_t uCS) { if (uCS > 0) { DOGM_CS_PORT &= ~(DOGM_CS_PIN); } else { DOGM_CS_PORT |= (DOGM_CS_PIN); } } void DOGM_RS(uint8_t uRS) { if (uRS > 0) { DOGM_RS_PORT &= ~(DOGM_RS_PIN); } else { DOGM_RS_PORT |= (DOGM_RS_PIN); } } void DOGM_init(void) { DOGM_RS_DDR |= DOGM_RS_PIN; // Set DDR register for port as output DOGM_CS_DDR |= DOGM_CS_PIN; // Set DDR register for port as output DOGM_RS(1); DOGM_CS(1); SPI_Data(0x39); _delay_us(DOGM_DELAY_S); SPI_Data(0x1C); _delay_us(DOGM_DELAY_S); SPI_Data(0x52); _delay_us(DOGM_DELAY_S); SPI_Data(0x69); _delay_us(DOGM_DELAY_S); SPI_Data(0x74); _delay_us(DOGM_DELAY_S); SPI_Data(0x38); _delay_us(DOGM_DELAY_S); SPI_Data(0x0C); _delay_us(DOGM_DELAY_S); SPI_Data(0x01); _delay_us(DOGM_DELAY_L); SPI_Data(0x06); _delay_us(DOGM_DELAY_S); DOGM_RS(0); DOGM_CS(0); } void DOGM_putc(char cData) { DOGM_RS(0); DOGM_CS(1); SPI_Data(cData); _delay_us(DOGM_DELAY_S); DOGM_CS(0); } void DOGM_puts(char * cString) { while(*cString != '\0') DOGM_putc(*cString++); } void DOGM_gotoxy(uint8_t uX, uint8_t uY) { uint8_t addr; addr = (uY * 0x40) + uX; DOGM_RS(1); DOGM_CS(1); SPI_Data(0x80 | addr); _delay_us(DOGM_DELAY_S); DOGM_CS(0); } void DOGM_clear(void) { DOGM_RS(1); DOGM_CS(1); SPI_Data(0x01); _delay_us(DOGM_DELAY_L); DOGM_CS(0); }