void board_userled_all(uint8_t ledset) { lpc17_gpiowrite(GPIO_LED1, (ledset & BOARD_LED1_BIT) == 0); lpc17_gpiowrite(GPIO_LED2, (ledset & BOARD_LED2_BIT) == 0); lpc17_gpiowrite(GPIO_LED3, (ledset & BOARD_LED3_BIT) == 0); lpc17_gpiowrite(GPIO_LED4, (ledset & BOARD_LED4_BIT) == 0); }
void lpc17_setleds(uint8_t ledset) { lpc17_gpiowrite(GPIO_LED1, (ledset & BOARD_LED1_BIT) == 0); lpc17_gpiowrite(GPIO_LED2, (ledset & BOARD_LED2_BIT) == 0); lpc17_gpiowrite(GPIO_LED3, (ledset & BOARD_LED3_BIT) == 0); lpc17_gpiowrite(GPIO_LED4, (ledset & BOARD_LED4_BIT) == 0); }
void lpc17_led2(enum lpc17_ledstate_e state) { bool red = (((unsigned int)state & LPC17_LEDSTATE_RED) != 0); bool green = (((unsigned int)state & LPC17_LEDSTATE_GREEN) != 0); lpc17_gpiowrite(NUCLEUS2G_LED2_A, red); lpc17_gpiowrite(NUCLEUS2G_LED2_B, green); }
void lpc17_setled(int led, bool ledon) { if (led == BOARD_LED1) { lpc17_gpiowrite(LPC1766STK_LED1, !ledon); } else if (led == BOARD_LED2) { lpc17_gpiowrite(LPC1766STK_LED2, !ledon); } }
FAR struct lcd_dev_s *up_nxdrvinit(unsigned int devno) { FAR struct spi_dev_s *spi; FAR struct lcd_dev_s *dev; /* Configure the LCD GPIOs */ lcd_dumpgpio("up_nxdrvinit: On entry"); lpc17_configgpio(LPC1766STK_LCD_RST); lpc17_configgpio(LPC1766STK_LCD_BL); lcd_dumpgpio("up_nxdrvinit: After GPIO setup"); /* Reset the LCD */ lpc17_gpiowrite(LPC1766STK_LCD_RST, false); up_udelay(10); lpc17_gpiowrite(LPC1766STK_LCD_RST, true); up_mdelay(5); /* Configure PWM1 to support the backlight */ nokia_blinitialize(); /* Get the SSP port (configure as a Freescale SPI port) */ spi = up_spiinitialize(0); if (!spi) { glldbg("Failed to initialize SSP port 0\n"); } else { /* Bind the SSP port to the LCD */ dev = nokia_lcdinitialize(spi, devno); if (!dev) { glldbg("Failed to bind SSP port 0 to LCD %d: %d\n", devno); } else { gllvdbg("Bound SSP port 0 to LCD %d\n", devno); /* And turn the LCD on (CONFIG_LCD_MAXPOWER should be 1) */ (void)dev->setpower(dev, CONFIG_LCD_MAXPOWER); return dev; } } return NULL; }
int usbmsc_archinitialize(void) { FAR struct spi_dev_s *spi; int ret; /* Enable power to the SD/MMC via a GPIO. LOW enables SD/MMC. */ lpc17_gpiowrite(LPC1766STK_MMC_PWR, false); /* Get the SPI port */ message("usbmsc_archinitialize: Initializing SPI port %d\n", LPC17XX_MMCSDSPIPORTNO); spi = up_spiinitialize(LPC17XX_MMCSDSPIPORTNO); if (!spi) { message("usbmsc_archinitialize: Failed to initialize SPI port %d\n", LPC17XX_MMCSDSPIPORTNO); ret = -ENODEV; goto errout; } message("usbmsc_archinitialize: Successfully initialized SPI port %d\n", LPC17XX_MMCSDSPIPORTNO); /* Bind the SPI port to the slot */ message("usbmsc_archinitialize: Binding SPI port %d to MMC/SD slot %d\n", LPC17XX_MMCSDSPIPORTNO, LPC17XX_MMCSDSLOTNO); ret = mmcsd_spislotinitialize(CONFIG_EXAMPLES_USBMSC_DEVMINOR1, LPC17XX_MMCSDSLOTNO, spi); if (ret < 0) { message("usbmsc_archinitialize: Failed to bind SPI port %d to MMC/SD slot %d: %d\n", LPC17XX_MMCSDSPIPORTNO, LPC17XX_MMCSDSLOTNO, ret); goto errout; } message("usbmsc_archinitialize: Successfuly bound SPI port %d to MMC/SD slot %d\n", LPC17XX_MMCSDSPIPORTNO, LPC17XX_MMCSDSLOTNO); return OK; /* Disable power to the SD/MMC via a GPIO. HIGH disables SD/MMC. */ errout: lpc17_gpiowrite(LPC1766STK_MMC_PWR, true); return ret;}
void lpc17_setled(int led, bool ledon) { if ((unsigned)led < BOARD_NLEDS) { lpc17_gpiowrite(g_ledcfg[led], ledon); } }
static int nsh_sdinitialize(void) { FAR struct spi_dev_s *ssp; int ret; /* Enable power to the SD/MMC via a GPIO. LOW enables SD/MMC. */ lpc17_gpiowrite(LPC1766STK_MMC_PWR, false); /* Get the SSP port */ ssp = lpc17_sspinitialize(CONFIG_NSH_MMCSDSPIPORTNO); if (!ssp) { message("nsh_archinitialize: Failed to initialize SSP port %d\n", CONFIG_NSH_MMCSDSPIPORTNO); ret = -ENODEV; goto errout; } message("Successfully initialized SSP port %d\n", CONFIG_NSH_MMCSDSPIPORTNO); /* Bind the SSP port to the slot */ ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, CONFIG_NSH_MMCSDSLOTNO, ssp); if (ret < 0) { message("nsh_sdinitialize: " "Failed to bind SSP port %d to MMC/SD slot %d: %d\n", CONFIG_NSH_MMCSDSPIPORTNO, CONFIG_NSH_MMCSDSLOTNO, ret); goto errout; } message("Successfuly bound SSP port %d to MMC/SD slot %d\n", CONFIG_NSH_MMCSDSPIPORTNO, CONFIG_NSH_MMCSDSLOTNO); return OK; /* Disable power to the SD/MMC via a GPIO. HIGH disables SD/MMC. */ errout: lpc17_gpiowrite(LPC1766STK_MMC_PWR, true); return ret; }
void board_led_on(int led) { /* We will control LED1 and LED2 not yet completed the boot sequence. */ if (!g_initialized) { bool led1 = false; bool led2 = false; switch (led) { case LED_STACKCREATED: g_initialized = true; case LED_STARTED: default: break; case LED_HEAPALLOCATE: led1 = true; break; case LED_IRQSENABLED: led2 = true; break; } lpc17_gpiowrite(ZKITARM_LED1, led1); lpc17_gpiowrite(ZKITARM_LED2, led2); } /* We will always control the HB LED */ switch (led) { case LED_INIRQ: case LED_SIGNAL: case LED_ASSERTION: case LED_PANIC: lpc17_gpiowrite(ZKITARM_LED2, false); g_nestcount++; default: break; } }
void up_ledoff(int led) { switch (led) { default: case 0 : /* STARTED, HEAPALLOCATE, IRQSENABLED */ case 1 : /* STACKCREATED */ lpc17_gpiowrite(LPC1766STK_LED1, true); case 2 : /* INIRQ, SIGNAL, ASSERTION, PANIC */ lpc17_gpiowrite(LPC1766STK_LED2, true); break; case 3 : /* IDLE */ lpc17_gpiowrite(LPC1766STK_LED1, g_uninitialized); break; } }
int board_lcd_initialize(void) { lpc17_configgpio(ZKITARM_OLED_RST); lpc17_configgpio(ZKITARM_OLED_RS); lpc17_gpiowrite(ZKITARM_OLED_RST, 1); lpc17_gpiowrite(ZKITARM_OLED_RS, 1); zkit_sspdev_initialize(); g_spidev = lpc17_sspbus_initialize(0); if (!g_spidev) { glldbg("Failed to initialize SSP port 0\n"); return 0; } lpc17_gpiowrite(ZKITARM_OLED_RST, 0); up_mdelay(1); lpc17_gpiowrite(ZKITARM_OLED_RST, 1); return 1; }
int up_lcdinitialize(void) { lpc17_configgpio(ZKITARM_OLED_RST); lpc17_configgpio(ZKITARM_OLED_RS); lpc17_gpiowrite(ZKITARM_OLED_RST, 1); lpc17_gpiowrite(ZKITARM_OLED_RS, 1); zkit_sspinitialize(); spi = lpc17_sspinitialize(0); if (!spi) { glldbg("Failed to initialize SSP port 0\n"); return 0; } lpc17_gpiowrite(ZKITARM_OLED_RST, 0); up_mdelay(1); lpc17_gpiowrite(ZKITARM_OLED_RST, 1); return 1; }
int lpc17_ssp1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd) { if (devid == SPIDEV_DISPLAY) { /* Set GPIO to 1 for data, 0 for command */ (void)lpc17_gpiowrite(LPCXPRESSO_OLED_DC, !cmd); return OK; } return -ENODEV; }
int lpc17_ssp0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd) { if (devid == SPIDEV_DISPLAY) { /* Set GPIO to 1 for data, 0 for command */ lpc17_gpiowrite(ZKITARM_OLED_RS, !cmd); return OK; } return -ENODEV; }
void lpc17_ssp1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) { sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); ssp_dumpgpio("lpc17_ssp1select() Entry"); if (devid == SPIDEV_MMCSD) { /* Assert/de-assert the CS pin to the card */ (void)lpc17_gpiowrite(LPCXPRESSO_SD_CS, !selected); } #ifdef CONFIG_NX_LCDDRIVER else if (devid == SPIDEV_DISPLAY) { /* Assert the CS pin to the OLED display */ (void)lpc17_gpiowrite(LPCXPRESSO_OLED_CS, !selected); } #endif ssp_dumpgpio("lpc17_ssp1select() Exit"); }
void lpc17_ssp1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) { sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); if (devid == SPIDEV_MMCSD) { /* Assert/de-assert the CS pin to the card */ ssp_dumpssp1gpio("lpc17_ssp1select() Entry"); lpc17_gpiowrite(LPC1766STK_MMC_CS, !selected); ssp_dumpssp1gpio("lpc17_ssp1select() Exit"); } }
static inline void led_setbits(unsigned int setbits) { if ((setbits & OPEN1788_LED1) != 0) { lpc17_gpiowrite(GPIO_LED1, true); } if ((setbits & OPEN1788_LED2) != 0) { lpc17_gpiowrite(GPIO_LED2, true); } if ((setbits & OPEN1788_LED3) != 0) { lpc17_gpiowrite(GPIO_LED3, true); } if ((setbits & OPEN1788_LED4) != 0) { lpc17_gpiowrite(GPIO_LED4, true); } }
static inline void led_clrbits(unsigned int clrbits) { if ((clrbits & OPEN1788_LED1) != 0) { lpc17_gpiowrite(GPIO_LED1, false); } if ((clrbits & OPEN1788_LED2) != 0) { lpc17_gpiowrite(GPIO_LED2, false); } if ((clrbits & OPEN1788_LED3) != 0) { lpc17_gpiowrite(GPIO_LED3, false); } if ((clrbits & OPEN1788_LED4) != 0) { lpc17_gpiowrite(GPIO_LED4, false); } }
void lpc17_ssp0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) { sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); ssp_dumpgpio("lpc17_ssp0select() Entry"); if (devid == SPIDEV_MMCSD) { /* Assert the CS pin to the card */ lpc17_gpiowrite(NUCLEUS2G_MMCSD_CS, !selected); } ssp_dumpgpio("lpc17_ssp0select() Exit"); }
void lpc17_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); spi_dumpgpio("lpc17_spiselect() Entry"); if (devid == SPIDEV_MMCSD) { /* Assert/de-assert the CS pin to the card */ (void)lpc17_gpiowrite(ZKITARM_SD_CS, !selected); } spi_dumpgpio("lpc17_spiselect() Exit"); }
void board_led_off(int led) { /* In all states, OFF can only mean turning off the HB LED */ if (g_nestcount <= 1) { lpc17_gpiowrite(NUCLEUS2G_HEARTBEAT, true); g_nestcount = 0; } else { g_nestcount--; } }
void board_led_off(int led) { /* In all states, OFF can only mean turning off the HB LED */ if (g_nestcount <= 1) { lpc17_gpiowrite(ZKITARM_LED2, true); g_nestcount = 0; } else { g_nestcount--; } }
void lpc17_ssp0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) { sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); ssp_dumpgpio("lpc17_spi0select() Entry"); #ifdef CONFIG_NX_LCDDRIVER if (devid == SPIDEV_DISPLAY) { /* Assert the CS pin to the OLED display */ (void)lpc17_gpiowrite(ZKITARM_OLED_CS, !selected); } #endif ssp_dumpgpio("lpc17_spi0select() Exit"); }
void board_led_on(int led) { /* We will control LED1 and LED2 not yet completed the boot sequence. */ if (!g_initialized) { enum lpc17_ledstate_e led1 = LPC17_LEDSTATE_OFF; enum lpc17_ledstate_e led2 = LPC17_LEDSTATE_OFF; switch (led) { case LED_STACKCREATED: g_initialized = true; case LED_STARTED: default: break; case LED_HEAPALLOCATE: led1 = LPC17_LEDSTATE_GREEN; break; case LED_IRQSENABLED: led2 = LPC17_LEDSTATE_GREEN; } lpc17_led1(led1); lpc17_led2(led2); } /* We will always control the HB LED */ switch (led) { default: break; case LED_INIRQ: case LED_SIGNAL: case LED_ASSERTION: case LED_PANIC: lpc17_gpiowrite(NUCLEUS2G_HEARTBEAT, false); g_nestcount++; } }
static inline int lpc17_configoutput(lpc17_pinset_t cfgset, unsigned int port, unsigned int pin) { uint32_t fiobase; uint32_t regval; /* First, configure the port as a generic input so that we have a known * starting point and consistent behavior during the re-configuration. */ (void)lpc17_configinput(DEFAULT_INPUT, port, pin); /* Check for open drain output */ if ((cfgset & GPIO_OPEN_DRAIN) != 0) { /* Set pull-up mode. This normally only applies to input pins, but does have * meaning if the port is an open drain output. */ lpc17_pullup(cfgset, port, pin); /* Select open drain output */ lpc17_setopendrain(port, pin); } /* Set the initial value of the output */ lpc17_gpiowrite(cfgset, ((cfgset & GPIO_VALUE) != GPIO_VALUE_ZERO)); /* Now, reconfigure the pin as an output */ fiobase = g_fiobase[port]; regval = getreg32(fiobase + LPC17_FIO_DIR_OFFSET); regval |= (1 << pin); putreg32(regval, fiobase + LPC17_FIO_DIR_OFFSET); return OK; }
void up_ledoff(int led) { bool off; switch (led) { case 0: case 1: off = false; break; case 2: off = g_ncstate; break; default: return; } lpc17_gpiowrite(LPCXPRESSO_LED, off); }
void board_autoled_off(int led) { bool off; switch (led) { case 0: case 1: off = false; break; case 2: off = g_ncstate; break; default: return; } lpc17_gpiowrite(C027_LED, off); }
void lpc17_led(int lednum, int state) { lpc17_gpiowrite(lednum, state); }
void ug_power(unsigned int devno, bool on) { gllvdbg("power %s\n", on ? "ON" : "OFF"); (void)lpc17_gpiowrite(LPCXPRESSO_OLED_POWER, on); }
void lpc17_backlight(bool blon) { lpc17_gpiowrite(GPIO_LCD_BL, blon); }