void board_userled_all(uint8_t ledset) { /* Low illuminates */ sam_gpiowrite(GPIO_LED0, (ledset & BOARD_LED0_BIT) == 0); sam_gpiowrite(GPIO_LED1, (ledset & BOARD_LED1_BIT) == 0); }
void board_led_on(int led) { bool led1on = false; bool led2on = false; switch (led) { case 0: /* LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED */ break; case 1: /* LED_STACKCREATED */ led1on = true; break; default: case 2: /* LED_INIRQ, LED_SIGNAL, LED_ASSERTION */ return; case 3: /* LED_PANIC */ led2on = true; break; } sam_gpiowrite(GPIO_D9, led1on); sam_gpiowrite(GPIO_D10, led2on); }
void board_autoled_on(int led) { switch (led) { case 0: /* LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED - off while initializing */ sam_gpiowrite(GPIO_D301, LED_D301_OFF); break; case 1: /* LED_STACKCREATED - turn on when ready */ sam_gpiowrite(GPIO_D301, LED_D301_ON); break; case 2: /* LED_INIRQ, LED_SIGNAL - turn off inside irqs/signal processing */ sam_gpiowrite(GPIO_D301, LED_D301_OFF); return; case 3: /* LED_PANIC - flash */ sam_gpiowrite(GPIO_D301, LED_D301_ON); break; default: break; } }
void sam_spi0select(enum spi_dev_e devid, bool selected) { switch (devid) { #if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_ADS7843E) /* The touchscreen chip select is implemented as a GPIO OUTPUT that must * be controlled by this function. This is because the ADS7843E driver * must be able to sample the device BUSY GPIO input between SPI transfers. * However, the AD7843E will tri-state the BUSY input whenever the chip * select is de-asserted. So the only option is to control the chip select * manually and hold it low throughout the SPI transfer. */ case SPIDEV_TOUCHSCREEN: sam_gpiowrite(GPIO_TSC_CS, !selected); break; #endif #if defined(CONFIG_MTD_AT25) /* The AT25 Serial FLASH connects using NPCS3 (PA5). */ case SPIDEV_FLASH: sam_gpiowrite(GPIO_FLASH_CS, !selected); break; #endif default: break; } }
void sam_spi0select(enum spi_dev_e devid, bool selected) { #ifdef CONFIG_SAM4L_XPLAINED_IOMODULE /* Select/de-select the SD card */ if (devid == SPIDEV_MMCSD) { /* Active low */ sam_gpiowrite(GPIO_SD_CS, !selected); } #ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE else #endif #endif #ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE /* Select/de-select the OLED */ if (devid == SPIDEV_DISPLAY) { /* Active low */ sam_gpiowrite(GPIO_OLED_CS, !selected); } #endif }
void board_led_off(int led) { switch (led) { /* 0: LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED: L=OFF TX=OFF * RX=OFF * 1: LED_STACKCREATED: L=ON TX=OFF RX=OFF * * These cases should never happen. */ default: case 1: case 0: break; /* 2: LED_INIRQ, LED_SIGNAL, LED_ASSERTION: L=N/C TX=OFF RX=N/C * * This case will occur many times. LED TX is active low. */ case 2: sam_gpiowrite(GPIO_LED_TX, true); break; /* 3: LED_PANIC: L=N/X TX=N/C RX=OFF * * This case will also occur many times. LED RX is active low. */ case 3: sam_gpiowrite(GPIO_LED_RX, true); break; } }
void up_ledon(int led) { bool blueoff = true; /* Low illuminates */ bool redon = false; /* High illuminates */ switch (led) { case 0: /* LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED */ break; case 1: /* LED_STACKCREATED */ blueoff = false; break; default: case 2: /* LED_INIRQ, LED_SIGNAL, LED_ASSERTION */ return; case 3: /* LED_PANIC */ redon = true; break; } sam_gpiowrite(GPIO_BLUE, blueoff); sam_gpiowrite(GPIO_RED, redon); }
void board_led_off(int led) { if (led != 2) { sam_gpiowrite(GPIO_D9, false); sam_gpiowrite(GPIO_D10, false); } }
void up_ledoff(int led) { if (led != 2) { sam_gpiowrite(GPIO_BLUE, true); /* Low illuminates */ sam_gpiowrite(GPIO_RED, false); /* High illuminates */ } }
void board_userled_all(uint8_t ledset) { bool ledon; ledon = ((ledset & BOARD_D9_BIT) != 0); sam_gpiowrite(GPIO_D9, ledon); ledon = ((ledset & BOARD_D10_BIT) != 0); sam_gpiowrite(GPIO_D10, ledon); }
void sam_setleds(uint8_t ledset) { bool ledon; ledon = ((ledset & BOARD_LED_L_BIT) != 0); sam_gpiowrite(GPIO_LED_L, ledon); ledon = ((ledset & BOARD_LED_RX_BIT) != 0); sam_gpiowrite(GPIO_LED_RX, ledon); ledon = ((ledset & BOARD_LED_TX_BIT) != 0); sam_gpiowrite(GPIO_LED_TX, ledon); }
void board_userled(int led, bool ledon) { if (led == BOARD_LED0) { sam_gpiowrite(GPIO_LED0, !ledon); /* Low illuminates */ } }
void board_autoled_on(int led) { bool ledstate = true; switch (led) { case 0: /* LED_STARTED: NuttX has been started LED0=OFF */ /* LED_HEAPALLOCATE: Heap has been allocated LED0=OFF */ /* LED_IRQSENABLED: Interrupts enabled LED0=OFF */ break; /* Leave ledstate == true to turn OFF */ default: case 2: /* LED_INIRQ: In an interrupt LED0=N/C */ /* LED_SIGNAL: In a signal handler LED0=N/C */ /* LED_ASSERTION: An assertion failed LED0=N/C */ return; /* Return to leave LED0 unchanged */ case 3: /* LED_PANIC: The system has crashed LED0=FLASH */ case 1: /* LED_STACKCREATED: Idle stack created LED0=ON */ ledstate = false; /* Set ledstate == false to turn ON */ break; } sam_gpiowrite(GPIO_LED0, ledstate); }
void sam_setled(int led, bool ledon) { uint32_t ledcfg; if (led == BOARD_LED_L) { ledcfg = GPIO_LED_RX; } else if (led == BOARD_LED_RX) { ledcfg = GPIO_LED_RX; ledon = !ledon; } else if (led == BOARD_LED_TX) { ledcfg = GPIO_LED_TX; ledon = !ledon; } else { return; } sam_gpiowrite(ledcfg, ledon); }
void board_autoled_off(int led) { switch (led) { /* These should not happen and are ignored */ default: case 0: /* LED_STARTED: NuttX has been started LED0=OFF */ /* LED_HEAPALLOCATE: Heap has been allocated LED0=OFF */ /* LED_IRQSENABLED: Interrupts enabled LED0=OFF */ case 1: /* LED_STACKCREATED: Idle stack created LED0=ON */ /* These result in no-change */ case 2: /* LED_INIRQ: In an interrupt LED0=N/C */ /* LED_SIGNAL: In a signal handler LED0=N/C */ /* LED_ASSERTION: An assertion failed LED0=N/C */ return; /* Return to leave LED0 unchanged */ /* Turn LED0 off set driving the output high */ case 3: /* LED_PANIC: The system has crashed LED0=FLASH */ sam_gpiowrite(GPIO_LED0, true); break; } }
void board_autoled_off(int led) { switch (led) { default: break; case 2: /* LED_INIRQ, LED_SIGNAL - return to on after irq/signal processing */ sam_gpiowrite(GPIO_D301, LED_D301_ON); return; case 3: /* LED_PANIC - flashes */ sam_gpiowrite(GPIO_D301, LED_D301_OFF); break; } }
void board_autoled_off(int led) { if (led == 3) { sam_gpiowrite(GPIO_LED1, true); /* High extinguishes */ } }
void board_autoled_on(int led) { if (led == 1 || led == 3) { sam_gpiowrite(GPIO_LED0, false); /* Low illuminates */ } }
void board_userled(int led, bool ledon) { if (led == BOARD_D301) { sam_gpiowrite(GPIO_D301, ledon ? LED_D301_ON : LED_D301_OFF); } }
void board_led_on(int led) { switch (led) { /* 0: LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED: L=OFF TX=OFF * RX=OFF * * Since the LEDs were initially all OFF and since this state only * occurs one time, nothing need be done. */ default: case 0: break; /* 1: LED_STACKCREATED: L=ON TX=OFF RX=OFF * * This case will also occur only once. Note that unlike the other * LEDs, LED L is active high. */ case 1: sam_gpiowrite(GPIO_LED_L, true); break; /* 2: LED_INIRQ, LED_SIGNAL, LED_ASSERTION: L=N/C TX=ON RX=N/C * * This case will occur many times. LED TX is active low. */ case 2: sam_gpiowrite(GPIO_LED_TX, false); break; /* 3: LED_PANIC: L=N/X TX=N/C RX=ON * * This case will also occur many times. LED RX is active low. */ case 3: sam_gpiowrite(GPIO_LED_RX, false); break; } }
FAR struct lcd_dev_s *sam_graphics_setup(unsigned int devno) { FAR struct spi_dev_s *spi; FAR struct lcd_dev_s *dev; /* Configure the OLED GPIOs. This initial configuration is RESET low, * putting the OLED into reset state. */ sam_configgpio(GPIO_SSD1306_RST); /* Wait a bit then release the OLED from the reset state */ up_mdelay(20); sam_gpiowrite(GPIO_SSD1306_RST, true); /* Get the SPI1 port interface */ spi = sam_spibus_initialize(GPIO_SSD1306_CS); if (!spi) { lcderr("ERROR: Failed to initialize SPI port 1\n"); } else { /* Bind the SPI port to the OLED */ dev = ssd1306_initialize(spi, NULL, devno); if (!dev) { lcderr("ERROR: Failed to bind SPI port 1 to OLED %d: %d\n", devno); } else { lcdinfo("Bound SPI port 1 to OLED %d\n", devno); /* And turn the OLED on */ (void)dev->setpower(dev, CONFIG_LCD_MAXPOWER); #if defined(CONFIG_VIDEO_FB) && defined(CONFIG_LCD_FRAMEBUFFER) /* Initialize and register the simulated framebuffer driver */ ret = fb_register(0, 0); if (ret < 0) { syslog(LOG_ERR, "ERROR: fb_register() failed: %d\n", ret); } #endif return dev; } } return NULL; }
void board_autoled_on(int led) { switch (led) { case 0: /* LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED */ break; case 1: /* LED_STACKCREATED */ sam_gpiowrite(GPIO_LED0, false); /* Low illuminates */ break; default: case 2: /* LED_INIRQ, LED_SIGNAL, LED_ASSERTION */ return; case 3: /* LED_PANIC */ sam_gpiowrite(GPIO_LED1, false); /* Low illuminates */ break; } }
void sam_spi0select(uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); switch (devid) { #ifdef CONFIG_IEEE802154_MRF24J40 case SPIDEV_IEEE802154(0): /* Set the GPIO low to select and high to de-select */ #if defined(CONFIG_SAMV71XULT_MB1_BEE) sam_gpiowrite(CLICK_MB1_CS, !selected); #elif defined(CONFIG_SAMV71XULT_MB2_BEE) sam_gpiowrite(CLICK_MB2_CS, !selected); #endif break; #endif default: break; } }
int sam_spic0mddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd) { #ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE if (devid == SPIDEV_DISPLAY) { /* This is the Data/Command control pad which determines whether the * data bits are data or a command. * * High: the inputs are treated as display data. * Low: the inputs are transferred to the command registers. */ (void)sam_gpiowrite(GPIO_OLED_DATA, !cmd); } #endif return OK; }
void sam_spiselect(enum spi_dev_e devid, bool selected) { /* The touchscreen chip select is implemented as a GPIO OUTPUT that must * be controlled by this function. This is because the ADS7843E driver * must be able to sample the device BUSY GPIO input between SPI transfers. * However, the AD7843E will tri-state the BUSY input whenever the chip * select is de-asserted. So the only option is to control the chip select * manually and hold it low throughout the SPI transfer. */ #if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_ADS7843E) if (devid == SPIDEV_TOUCHSCREEN) { sam_gpiowrite(GPIO_TSC_NPCS2, !selected); } #endif }
FAR struct lcd_dev_s *board_graphics_setup(unsigned int devno) { FAR struct spi_dev_s *spi; FAR struct lcd_dev_s *dev; /* Configure the OLED GPIOs. This initial configuration is RESET low, * putting the OLED into reset state. */ (void)sam_configgpio(GPIO_OLED_RST); /* Wait a bit then release the OLED from the reset state */ up_mdelay(20); sam_gpiowrite(GPIO_OLED_RST, true); /* Get the SPI1 port interface */ spi = up_spiinitialize(OLED_CSNO); if (!spi) { lcddbg("Failed to initialize SPI port 1\n"); } else { /* Bind the SPI port to the OLED */ dev = ssd1306_initialize(spi, devno); if (!dev) { lcddbg("Failed to bind SPI port 1 to OLED %d: %d\n", devno); } else { lcdvdbg("Bound SPI port 1 to OLED %d\n", devno); /* And turn the OLED on */ (void)dev->setpower(dev, CONFIG_LCD_MAXPOWER); return dev; } } return NULL; }
void board_userled(int led, bool ledon) { uint32_t ledcfg; if (led == BOARD_LED0) { ledcfg = GPIO_LED0; } else if (led == BOARD_LED1) { ledcfg = GPIO_LED1; } else { return; } sam_gpiowrite(ledcfg, !ledon); /* Low illuminates */ }
void board_userled(int led, bool ledon) { uint32_t ledcfg; if (led == BOARD_D9) { ledcfg = GPIO_D9; } else if (led == BOARD_D10) { ledcfg = GPIO_D10; } else { return; } sam_gpiowrite(ledcfg, ledon); }
static void sam_setled(gpio_pinset_t pinset, uint8_t state) { /* Assume active high. Initial state == 0 means active high */ bool polarity = ((pinset & GPIO_OUTPUT_SET) == 0); switch (state) { case LED_OFF: polarity = !polarity; case LED_ON: break; case LED_NOCHANGE: default: return; } sam_gpiowrite(pinset, polarity); }
void board_userled_all(uint8_t ledset) { sam_gpiowrite(GPIO_D301, (ledset & BOARD_D301_BIT) ? LED_D301_ON : LED_D301_OFF); }