Exemplo n.º 1
0
static void lcd_wrdata(uint8_t data)
{
  /* Make sure that the LCD is available */

  lcd_waitbusy();

  /* Select DB0-15 as outputs (only DB-0-7 are actually used) */

  putreg16(0, PIC32MX_IOPORTE_TRIS);

  /* Set up to write the data */

  pic32mx_gpiowrite(GPIO_LCD_RS, true);    /* Select data */
  pic32mx_gpiowrite(GPIO_LCD_RW, false);   /* Select write */
  lcd_shortdelay(2);

  pic32mx_gpiowrite(GPIO_LCD_E, true);     /* Enable transfer */
  lcd_shortdelay(1);

  /* Write the data to the LCD */

  putreg16(data, PIC32MX_IOPORTE_PORT);    /* Write the data */
  lcd_shortdelay(1);
  pic32mx_gpiowrite(GPIO_LCD_E, false);
}
Exemplo n.º 2
0
void  pic32mx_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
  spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");

  if (devid == SPIDEV_FLASH)
    {
      pic32mx_gpiowrite(GPIO_SST25VF032B_CS, !selected);
    }
  else if (devid == SPIDEV_MUX)
    {
      pic32mx_gpiowrite(GPIO_PGA117_CS, !selected);
    }
}
Exemplo n.º 3
0
void up_setleds(FAR const struct led_setting_s *setting)
{
  /* LEDs are pulled up so writing a low value (false) illuminates them */

  if (setting->led0 != LED_NC)
    {
      pic32mx_gpiowrite(GPIO_LED_0, setting->led0 == LED_ON);
    }

  if (setting->led1 != LED_NC)
    {
      pic32mx_gpiowrite(GPIO_LED_1, setting->led1 == LED_ON);
    }
}
Exemplo n.º 4
0
void pic32mx_setled(int led, bool ledon)
{
  if ((unsigned)led < PIC32MX_STARTERKIT_NLEDS)
    {
      pic32mx_gpiowrite(g_ledpincfg[led], ledon);
    }
}
Exemplo n.º 5
0
void board_userled(int led, bool ledon)
{
  if ((unsigned)led < PIC32MX_UBW32_NLEDS)
    {
      pic32mx_gpiowrite(g_ledpincfg[led], ledon);
    }
}
Exemplo n.º 6
0
void up_setleds(FAR const struct led_setting_s *setting)
{
  if (setting->led1 != LED_NC)
    {
      pic32mx_gpiowrite(GPIO_LED_1, setting->led1 == LED_ON);
    }

  if (setting->led2 != LED_NC)
    {
      pic32mx_gpiowrite(GPIO_LED_2, setting->led2 == LED_ON);
    }

  if (setting->led3 != LED_NC)
    {
      pic32mx_gpiowrite(GPIO_LED_3, setting->led3 == LED_ON);
    }
}
Exemplo n.º 7
0
void  pic32mx_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
  spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");

  if (devid == SPIDEV_MMCSD)
    {
      pic32mx_gpiowrite(GPIO_SD_CS, !selected);
    }
}
Exemplo n.º 8
0
void pic32mx_setled(int led, bool ledon)
{
  /* LEDs are pulled up so writing a low value (false) illuminates them */

  if ((unsigned)led < PIC32MX_MIRTOO_NLEDS)
    {
      pic32mx_gpiowrite(g_ledpincfg[led], ledon);
    }
}
Exemplo n.º 9
0
void board_userled(int led, bool ledon)
{
  /* LEDs are pulled up so writing a low value (false) illuminates them */

  if ((unsigned)led < PIC32MX_PIC32MX7MMB_NLEDS)
    {
      pic32mx_gpiowrite(g_ledpincfg[led], !ledon);
    }
}
Exemplo n.º 10
0
void pic32mx_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
  spivdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");

  /* The SD card chip select is pulled high and active low */

#ifdef PIC32_HAVE_SD
  if (devid == SPIDEV_MMCSD)
    {
      pic32mx_gpiowrite(GPIO_SD_CS, !selected);
    }
#endif

#ifdef PIC32_HAVE_SOIC
  if (devid == SPIDEV_FLASH)
    {
      pic32mx_gpiowrite(GPIO_SOIC_CS, !selected);
    }
#endif
}
Exemplo n.º 11
0
static void lcd_brightness(uint8_t brightness)
{
  /* The LIGHT and COMP pins are label PWM1 and PWM2 and so are obviously
   * intended to support modulated outputs.  However, here for simplicity,
   * they are just treated as on/off discretes outputs.
   */

  if (brightness > 0)
    {
      /* Turn the LCD light on */

      pic32mx_gpiowrite(GPIO_LCD_LIGHT, true);
      NOP;NOP;NOP;
      pic32mx_gpiowrite(GPIO_LCD_COMP, true);
      NOP;NOP;
      pic32mx_gpiowrite(GPIO_LCD_PWR, true);
    }
  else
    {
      /* Turn the LCD light off */

      pic32mx_gpiowrite(GPIO_LCD_PWR, false);
      pic32mx_gpiowrite(GPIO_LCD_COMP, false);
      pic32mx_gpiowrite(GPIO_LCD_LIGHT, false);
    }

  g_lcd1602.brightness = brightness;
}
Exemplo n.º 12
0
void up_setleds(FAR const struct led_setting_s *setting)
{
  if (setting->usb != LED_NC)
    {
      pic32mx_gpiowrite(GPIO_USB_LED, setting->usb != LED_ON);
    }

  if (setting->sd != LED_NC)
    {
      pic32mx_gpiowrite(GPIO_SD_LED, setting->sd != LED_ON);
    }

  if (setting->flash != LED_NC)
    {
      pic32mx_gpiowrite(GPIO_FLASH_LED, setting->flash != LED_ON);
    }

  if (setting->error != LED_NC)
    {
      pic32mx_gpiowrite(GPIO_ERROR_LED, setting->error != LED_ON);
    }
}
Exemplo n.º 13
0
static uint8_t lcd_readstatus(void)
{
  uint8_t status;

  /* Set up to read BUSY/AD information */

  putreg16(0xff, PIC32MX_IOPORTE_TRISSET); /* Set DB0-7 as inputs */
  pic32mx_gpiowrite(GPIO_LCD_RS, false);   /* Select command */
  pic32mx_gpiowrite(GPIO_LCD_RW, true);    /* Select read */
  lcd_shortdelay(2);

  pic32mx_gpiowrite(GPIO_LCD_E, true);     /* Enable transfer */
  lcd_shortdelay(1);

  /* Read the status from the LCD */

  status = (uint8_t)getreg16(PIC32MX_IOPORTE_PORT);
  lcd_shortdelay(1);
  pic32mx_gpiowrite(GPIO_LCD_E, false);

  return status;
}
Exemplo n.º 14
0
static uint8_t lcd_rddata(void)
{
  /* Make sure that the LCD is available */

  lcd_waitbusy();

  /* Setup to read data */

  pic32mx_gpiowrite(GPIO_LCD_RS, true);    /* Select data */
  pic32mx_gpiowrite(GPIO_LCD_RW, true);    /* Select read */
  lcd_shortdelay(2);

  pic32mx_gpiowrite(GPIO_LCD_E, true);     /* Enable transfer */
  lcd_shortdelay(1);

  putreg16(0xff, PIC32MX_IOPORTE_TRISSET); /* Set DB0-7 as inputs */
  pic32mx_gpiowrite(GPIO_LCD_E, false);    /* Disable transfer */

  /* Read the data from the LCD */

  return (uint8_t)getreg16(PIC32MX_IOPORTE_PORT);
}
Exemplo n.º 15
0
int up_lcd1602_initialize(void)
{
  int ret = OK;

  /* Only initialize the driver once. */

  if (!g_lcd1602.initialized)
    {
      lcdinfo("Initializing\n");

      /* Configure GPIO pins */

      putreg16(0, PIC32MX_IOPORTE_TRIS);       /* Set DB0-15 as outputs */
      pic32mx_configgpio(GPIO_LCD_RS);         /* RS: Selects commnand or data */
      pic32mx_configgpio(GPIO_LCD_RW);         /* RW: Selects read or write */
      pic32mx_configgpio(GPIO_LCD_E);          /* E:  Starts transfer */

      /* Configure LCD power in the OFF state */

      pic32mx_configgpio(GPIO_LCD_LIGHT);       /* K */
      pic32mx_configgpio(GPIO_LCD_COMP);        /* Vo */
      pic32mx_configgpio(GPIO_LCD_PWR);         /* Vbuson/AN5/RB5 controls +5V USB */
      g_lcd1602.brightness = 0;                 /* Remember tht the light is off */

      /* A small delay is necessary between when GPIO_LCD_E was set up as an
       * output with initial value of 0 and this operation.  That delay should
       * be well covered by the intervening GPIO configurations.
       */

      pic32mx_gpiowrite(GPIO_LCD_E, true);     /* Enable transfer */

      /* Configure and enable the LCD */
      /* Delay for 4.1MS or more */

      up_mdelay(5);

      /* Select the 8-bit interface. BF cannot be checked before this command.
       * This needs to be done a few times with some magic delays.
       *
       * Function set: 5x7 Style | N=2R | DL=8D
       */

      lcd_wrcommand(HD4478OU_FUNC | HD4478OU_FUNC_F5x7 | HD4478OU_FUNC_N1 | HD4478OU_FUNC_DL8D);
      up_udelay(100);            /* Delay more than 100uS */

      lcd_wrcommand(HD4478OU_FUNC | HD4478OU_FUNC_F5x7 | HD4478OU_FUNC_N1 | HD4478OU_FUNC_DL8D);
      up_udelay(40);             /* Delay more than 40uS */
      lcd_wrcommand(HD4478OU_FUNC | HD4478OU_FUNC_F5x7 | HD4478OU_FUNC_N1 | HD4478OU_FUNC_DL8D);
      lcd_waitbusy();

      lcd_wrcommand(HD4478OU_FUNC | HD4478OU_FUNC_F5x7 | HD4478OU_FUNC_N1 | HD4478OU_FUNC_DL8D);
      lcd_waitbusy();

      /* Display ON, cursor OFF, blink OFF */

      lcd_wrcommand(HD4478OU_DISPLAY | HD4478OU_DISPLAY_ON);
      lcd_waitbusy();

      /* Clear the display and home the cursor */

      lcd_wrcommand(HD4478OU_CLEAR); /* Clear display */
      lcd_waitbusy();

      lcd_wrcommand(HD4478OU_RETURN); /* Return home: AC=0 */
      lcd_waitbusy();

      /* Entry Mode Set:
       *
       * - Increment address by one,
       * - Shift cursor to right (display is not shifted)
       */

      lcd_wrcommand(HD4478OU_INPUT | HD4478OU_INPUT_INCR);

      /* Register the LCD device driver */

      ret = register_driver("/dev/lcd1602", &g_lcdops, 0644, &g_lcd1602);
      g_lcd1602.initialized = true;
    }

  return ret;
}