Пример #1
0
static inline void pic32mx_uartinitialize(void)
{
#ifdef CONFIG_PIC32MX_UART2
  /* Make sure that TRIS pins are set correctly.  Configure the UART pins as digital
   * inputs and outputs first.
   */

  pic32mx_configgpio(GPIO_U2TX);
  pic32mx_configgpio(GPIO_U2RX);

  /* Configure UART TX and RX pins to RPB10 and 11, respectively */

  putreg32(PPS_INSEL_RPB11,  PIC32MX_PPS_U2RXR);
  putreg32(PPS_OUTSEL_U2TX, PIC32MX_PPS_RPB10R);
#endif

#ifdef CONFIG_PIC32MX_UART1
  /* Make sure that TRIS pins are set correctly.  Configure the UART pins as digital
   * inputs and outputs first.
   */

  pic32mx_configgpio(GPIO_U1TX);
  pic32mx_configgpio(GPIO_U1RX);

  /* Configure UART TX and RX pins to RPB10 and 11, respectively */

  putreg32(PPS_INSEL_RPC6,  PIC32MX_PPS_U1RXR);
  putreg32(PPS_OUTSEL_U1TX, PIC32MX_PPS_RPC5R);
#endif
}
Пример #2
0
void pic32mx_ledinit(void)
{
  /* Configure output pins */

  pic32mx_configgpio(GPIO_LED_0);
  pic32mx_configgpio(GPIO_LED_1);
}
Пример #3
0
void pic32mx_led_initialize(void)
{
  /* Configure output pins */

  pic32mx_configgpio(GPIO_LED_0);
  pic32mx_configgpio(GPIO_LED_1);
  pic32mx_configgpio(GPIO_LED_2);
}
Пример #4
0
void board_userled_initialize(void)
{
  /* Configure output pins */

  pic32mx_configgpio(GPIO_LED_1);
  pic32mx_configgpio(GPIO_LED_2);
  pic32mx_configgpio(GPIO_LED_3);
}
Пример #5
0
void pic32mx_ledinit(void)
{
  /* Configure output pins */

  pic32mx_configgpio(GPIO_USB_LED);
  pic32mx_configgpio(GPIO_SD_LED);
  pic32mx_configgpio(GPIO_FLASH_LED);
  pic32mx_configgpio(GPIO_ERROR_LED);
}
Пример #6
0
void weak_function pic32mx_spiinitialize(void)
{
  /* Configure the SPI chip select, write protect, and card detect GPIOs */

#ifdef CONFIG_PIC32MX_SPI1
  pic32mx_configgpio(GPIO_SD_CS);
  pic32mx_configgpio(GPIO_SD_WP);
  pic32mx_configgpio(GPIO_SD_CD);
#endif
}
Пример #7
0
void pic32mx_lcdinitialize(void)
{
  /* Just configure the backlight control as an output and turn off the
   * backlight for now.
   */

   pic32mx_configgpio(GPIO_BLED);
}
Пример #8
0
void weak_function pic32mx_spiinitialize(void)
{
  /* Configure the SPI2 chip select (CS) GPIO output, and the card detect (CD) and
   * write protect (WP) inputs.
   */

#ifdef PIC32_HAVE_SD
  pic32mx_configgpio(GPIO_SD_CS);
  pic32mx_configgpio(GPIO_SD_CD);
  pic32mx_configgpio(GPIO_SD_WD);
#endif

#ifdef PIC32_HAVE_SOIC
  pic32mx_configgpio(GPIO_SOIC_WP);
  pic32mx_configgpio(GPIO_SOIC_CS);
#endif
}
Пример #9
0
xcpt_t pic32mx_gpioattach(uint32_t pinset, unsigned int cn, xcpt_t handler)
{
  xcpt_t oldhandler = NULL;
  irqstate_t flags;

  DEBUGASSERT(cn < IOPORT_NUMCN);

  /* First verify that the pinset is configured as an interrupting input */

  if (pic32mx_input(pinset) && pic32mx_interrupt(pinset))
    {
      /* Get the previously attached handler as the return value */

      flags = irqsave();
      oldhandler = g_cnisrs[cn];

      /* Are we attaching or detaching? */

      if (handler != NULL)
        {
          /* Attaching... Make sure that the GPIO is properly configured as
           * an input
           */

          pic32mx_configgpio(pinset);

          /* Pull-up requested? */
 
          if (pic32mx_pullup(pinset))
            {
              putreg32(1 << cn, PIC32MX_IOPORT_CNPUESET);
            }
          else
            {
              putreg32(1 << cn, PIC32MX_IOPORT_CNPUECLR);
            }
        }
      else
        {
           /* Make sure that any further interrupts are disabled.
            * (disable the pull-up as well).
            */

           putreg32(1 << cn, PIC32MX_IOPORT_CNENCLR);
           putreg32(1 << cn, PIC32MX_IOPORT_CNPUECLR);
        }

      /* Set the new handler (perhaps NULLifying the current handler) */

      g_cnisrs[cn] = handler;
      irqrestore(flags);
    }

  return oldhandler;
}
Пример #10
0
void weak_function pic32mx_spi2initialize(void)
{
  /* Make sure that TRIS pins are set correctly.  Configure the SPI pins as digital
   * inputs and outputs first.
   */

  pic32mx_configgpio(GPIO_SI);
  pic32mx_configgpio(GPIO_SO);
  pic32mx_configgpio(GPIO_SCK);

  /* Configure SPI2 data in and data out to use RPA2 and 1, respectively */

  putreg32(PPS_INSEL_RPA2,  PIC32MX_PPS_SDI2R);
  putreg32(PPS_OUTSEL_SDO2, PIC32MX_PPS_RPA1R);

  /* Configure the SPI chip select GPIOs */

  pic32mx_configgpio(GPIO_PGA117_CS);
  pic32mx_configgpio(GPIO_SST25VF032B_CS);
}
Пример #11
0
void board_button_initialize(void)
{
  int i;

  /* Configure input pins */

  for (i = 0; i < NUM_BUTTONS; i++)
    {
      pic32mx_configgpio(g_buttonset[i]);
    }
}
Пример #12
0
void board_button_initialize(void)
{
  int i;

  /* Configure input pins */

  for (i = 0; i < NUM_BUTTONS; i++)
    {
      pic32mx_configgpio(g_buttonset[i]);
    }

  /* Change AN2/AN3/AN4 to digital */

  putreg32(0xffff, PIC32MX_ADC_CFG);
}
Пример #13
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;
}