void display_init() { // Setting up ports. SYSCTL_RCGC2_R |= SYSCTL_DC4_GPIOB; // Enable GPIOB //maybe delay2 here delay2(10000); SYSCTL_RCGC2_R |= SYSCTL_DC4_GPIOD; // Enable GPIOD delay2(10000); GPIO_PORTB_DIR_R |= 0x7f; GPIO_PORTD_DIR_R |= 0xe0; GPIO_PORTB_AFSEL_R &= 0xffffff80; GPIO_PORTD_AFSEL_R &= 0xffffff1f; GPIO_PORTB_DEN_R |= 0x7f; // Enable port B GPIO_PORTD_DEN_R |= 0xe0; // Enable port D // Function set commands separated by delay2s, as per cycle //delay2(100); //SysCtldelay2(5*SysCtlClockGet()/(3*1000)); //5msec delay2(5000); //5msec function_set(0, 0); //SysCtldelay2(5*SysCtlClockGet()/(3*1000)); //5msec //delay2(10); delay2(5000); //5msec function_set(0, 0); //SysCtldelay2(2*SysCtlClockGet()/(3*10000)); //200usec delay2(200); //200usec //delay2(10); function_set(0, 0); function_set(1, 0); //two lines display_off(); clear_display(); entry_mode_set(1,0); }
int main(int argc, char **argv) { int check_busy = 0; if (argc < 3) usage(); //init spi oled init_spi_oled(argv[1]); argc-=2; argv+=2; while (argc >= 1) { const char *cmd = argv[0]; int args = 0; if (strcmp(cmd, "-B") == 0) { check_busy = 0; args = 1; check_busy_flag3(atoi(argv[1])); } if (strcmp(cmd, "-b") == 0) check_busy = 1; if (check_busy) check_busy_flag(); if (strcmp(cmd, "-f") == 0) { select_font(atoi(argv[1])); args = 1; } if (strcmp(cmd, "-e") == 0) { entry_mode_set(atoi(argv[1]), atoi(argv[2])); args = 2; } if (strcmp(cmd, "-m") == 0) { display_mode(atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); args = 3; } if (strcmp(cmd, "-c") == 0) clear_display(); if (strcmp(cmd, "-g") == 0) { set_ddram_address(atoi(argv[1]) * 0x40 + atoi(argv[2])); args = 2; } if (strcmp(cmd, "-a") == 0) { set_ddram_address(strtoul(argv[1], NULL, 0)); args = 1; } if (strcmp(cmd, "-A") == 0) { set_cgram_address(strtoul(argv[1], NULL, 0)); args = 1; } if (strcmp(cmd, "-w") == 0) { write_data(strtoul(argv[1], NULL, 0)); args = 1; } if (strcmp(cmd, "-h") == 0) return_home(); if (strcmp(cmd, "-C") == 0) { shift_cursor(*argv[1] == 'r'); args = 1; } if (strcmp(cmd, "-S") == 0) { shift_display(*argv[1] == 'r'); args = 1; } if (strcmp(cmd, "-t") == 0) { write_str(argv[1]); args = 1; } if (*cmd != '-') write_str(cmd); check_busy = 1; argc -= 1 + args; argv += 1 + args; } }