int main(int argc, char **argv) { if(wiringPiSetup() == -1) { printf("wiringPiSetup() failed\n"); return EXIT_FAILURE; } // 540kHz speed - recomended by ST7920 spec //if ((lcd_fd = wiringPiSPISetupMode(0, 540000, 0x07)) < 0) { if ((lcd_fd = wiringPiSPISetup(0, 540000)) < 0) { printf("Can't open the SPI bus\n"); return EXIT_FAILURE; } char mode = 0x07; ioctl(lcd_fd, SPI_IOC_WR_MODE, &mode); init_gpio(); reset_lcd(); init_lcd(); set_extended_mode(0, 0, 0); set_extended_mode(0, 1, 1); clear_lcd(); show_image(raspberry_pix); return EXIT_SUCCESS; }
static int configure_mtp_gpios(struct s5p_panel_data *pdata, bool enable) { int i; int ret = 0; if (enable) { /* wrx and csx are already requested by the spi driver */ ret = gpio_request(pdata->gpio_rdx, "tl2796_rdx"); if (ret) goto err_rdx; ret = gpio_request(pdata->gpio_dcx, "tl2796_dcx"); if (ret) goto err_dcx; ret = gpio_request(pdata->gpio_rst, "tl2796_rst"); if (ret) goto err_rst; for (i = 0; i < 8; i++) { ret = gpio_request(pdata->gpio_db[i], "tl2796_dbx"); if (ret) goto err_dbx; } for (i = 0; i < 8; i++) { s3c_gpio_cfgpin(S5PV210_GPF0(i), S3C_GPIO_OUTPUT); s3c_gpio_setpull(S5PV210_GPF0(i), S3C_GPIO_PULL_NONE); gpio_set_value(S5PV210_GPF0(i), 0); } for (i = 0; i < 8; i++) { s3c_gpio_cfgpin(S5PV210_GPF1(i), S3C_GPIO_OUTPUT); s3c_gpio_setpull(S5PV210_GPF1(i), S3C_GPIO_PULL_UP); gpio_set_value(S5PV210_GPF1(i), 0); } return 0; } for (i = 0; i < 8; i++) { s3c_gpio_cfgpin(S5PV210_GPF0(i), S3C_GPIO_SFN(2)); s3c_gpio_setpull(S5PV210_GPF0(i), S3C_GPIO_PULL_NONE); } for (i = 0; i < 8; i++) { s3c_gpio_cfgpin(S5PV210_GPF1(i), S3C_GPIO_SFN(2)); s3c_gpio_setpull(S5PV210_GPF1(i), S3C_GPIO_PULL_NONE); } reset_lcd(pdata); for (i = 7; i >= 0; i--) { gpio_free(pdata->gpio_db[i]); err_dbx: ; } gpio_free(pdata->gpio_rst); err_rst: gpio_free(pdata->gpio_dcx); err_dcx: gpio_free(pdata->gpio_rdx); err_rdx: return ret; }
void lcd_display_init(void) { reset_lcd(); identify_lcd(); if (lcd_type == LCD_V1) lcd_v1_display_init(); else lcd_v2_display_init(); }
static int lcd_power_on(void *ld, int enable) { int ret = 0; pr_info("%s: enable=%d\n", __func__, enable); #ifdef CONFIG_FB_SUPPORT_ALPM if (enable) { if (get_alpm_mode()) { pr_info("%s : skip lcd power on : alpm mode : on\n", __func__); alpm_status = LCD_STATUS_ALPM_LCD_ON; } else { pr_info("%s : panel on\n", __func__); if (alpm_status == LCD_STATUS_OFF) { pr_info("%s power on include reset\n", __func__); ret = s6e63j0x03_power_on(); reset_lcd(); } else if (alpm_status == LCD_STATUS_KNOWN) { pr_info("%s power on not include reset\n", __func__); ret = s6e63j0x03_power_on(); } alpm_status = LCD_STATUS_ON; } } else { if (get_alpm_mode()) { pr_info("%s : skip lcd power off : alpm mode : on\n", __func__); alpm_status = LCD_STATUS_ALPM_LCD_OFF; /*To keep high in sleep mode when alpm on */ s3c_gpio_slp_cfgpin(GPIO_MLCD_RST, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(GPIO_MLCD_RST, S3C_GPIO_PULL_NONE); } else { pr_info("%s : panel off\n", __func__); ret = s6e63j0x03_power_off(); s3c_gpio_slp_cfgpin(GPIO_MLCD_RST, S3C_GPIO_SLP_INPUT); s3c_gpio_slp_setpull_updown(GPIO_MLCD_RST, S3C_GPIO_PULL_DOWN); alpm_status = LCD_STATUS_OFF; } } #else if (enable) ret = s6e63j0x03_power_on(); else ret = s6e63j0x03_power_off(); #endif return ret; }
int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog sys_init(); // See 'sys_init.c' timer_init(); // See 'timer_init.c' reset_lcd(); // See 'lcd_driver.c' timer_wait(100); // See 'timer_init.c' init_ILI9340C(); // See 'lcd_config.c' RGB_test_lcd(); // See 'lcd_driver.c' P1OUT &= ~BIT6; // Turn off green LED P1OUT |= BIT0; // Turn on green LED _BIS_SR(CPUOFF); // MSP430 shutdown }
int main(int argc, char *argv[]) { int option, rc; struct sockaddr_in localAddr, servAddr; struct hostent *h; int n; for(n=0;n<CLIMB;n++) climb[n]=0.0; switch (gpsd_units()) { case imperial: altfactor = METERS_TO_FEET; altunits = "ft"; speedfactor = MPS_TO_MPH; speedunits = "mph"; break; case nautical: altfactor = METERS_TO_FEET; altunits = "ft"; speedfactor = MPS_TO_KNOTS; speedunits = "knots"; break; case metric: altfactor = 1; altunits = "m"; speedfactor = MPS_TO_KPH; speedunits = "kph"; break; default: /* leave the default alone */ break; } /* Process the options. Print help if requested. */ while ((option = getopt(argc, argv, "Vhl:su:")) != -1) { switch (option) { case 'V': (void)fprintf(stderr, "lcdgs revision " REVISION "\n"); exit(EXIT_SUCCESS); case 'h': default: usage(argv[0]); break; case 'l': switch ( optarg[0] ) { case 'd': deg_type = deg_dd; continue; case 'm': deg_type = deg_ddmm; continue; case 's': deg_type = deg_ddmmss; continue; default: (void)fprintf(stderr, "Unknown -l argument: %s\n", optarg); } break; case 's': sleep(10); continue; case 'u': switch ( optarg[0] ) { case 'i': altfactor = METERS_TO_FEET; altunits = "ft"; speedfactor = MPS_TO_MPH; speedunits = "mph"; continue; case 'n': altfactor = METERS_TO_FEET; altunits = "ft"; speedfactor = MPS_TO_KNOTS; speedunits = "knots"; continue; case 'm': altfactor = 1; altunits = "m"; speedfactor = MPS_TO_KPH; speedunits = "kph"; continue; default: (void)fprintf(stderr, "Unknown -u argument: %s\n", optarg); } } } /* Grok the server, port, and device. */ if (optind < argc) { gpsd_source_spec(argv[optind], &source); } else gpsd_source_spec(NULL, &source); /* Daemonize... */ if (daemon(0, 0) != 0) (void)fprintf(stderr, "lcdgps: demonization failed: %s\n", strerror(errno)); /* Open the stream to gpsd. */ if (gps_open(source.server, source.port, &gpsdata) != 0) { (void)fprintf( stderr, "lcdgps: no gpsd running or network error: %d, %s\n", errno, gps_errstr(errno)); exit(EXIT_FAILURE); } /* Connect to LCDd */ h = gethostbyname(LCDDHOST); if (h==NULL) { printf("%s: unknown host '%s'\n",argv[0],LCDDHOST); exit(EXIT_FAILURE); } servAddr.sin_family = h->h_addrtype; memcpy((char *) &servAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length); servAddr.sin_port = htons(LCDDPORT); /* create socket */ sd = socket(AF_INET, SOCK_STREAM, 0); if (BAD_SOCKET(sd)) { perror("cannot open socket "); exit(EXIT_FAILURE); } /* bind any port number */ localAddr.sin_family = AF_INET; localAddr.sin_addr.s_addr = htonl(INADDR_ANY); localAddr.sin_port = htons(0); /* coverity[uninit_use_in_call] */ rc = bind(sd, (struct sockaddr *) &localAddr, sizeof(localAddr)); if (rc == -1) { printf("%s: cannot bind port TCP %u\n",argv[0],LCDDPORT); perror("error "); exit(EXIT_FAILURE); } /* connect to server */ /* coverity[uninit_use_in_call] */ rc = connect(sd, (struct sockaddr *) &servAddr, sizeof(servAddr)); if (rc == -1) { perror("cannot connect "); exit(EXIT_FAILURE); } /* Do the initial field label setup. */ reset_lcd(); /* Here's where updates go. */ unsigned int flags = WATCH_ENABLE; if (source.device != NULL) flags |= WATCH_DEVICE; (void)gps_stream(&gpsdata, flags, source.device); for (;;) { /* heart of the client */ if (!gps_waiting(&gpsdata, 50000000)) { fprintf( stderr, "lcdgps: error while waiting\n"); exit(EXIT_FAILURE); } else { (void)gps_read(&gpsdata); update_lcd(&gpsdata); } } }
void lcd_display_init(void) { reset_lcd(); lcd_v1_display_init(); }