Guest User

init.h

a guest
Jul 29th, 2015
185
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include "conf_board.h"
  3. #include "board.h"
  4. #include "gpio.h"
  5.  
  6.  
  7.  
  8. #if defined (CONF_BOARD_AT45DBX)
  9. #   define AT45DBX_MEM_CNT          1
  10. #endif
  11.  
  12.  
  13.  
  14. void board_init (void)
  15. {
  16.     gpio_configure_pin(LED0_GPIO, GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);
  17.     gpio_configure_pin(LED1_GPIO, GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);
  18.     gpio_configure_pin(LED2_GPIO, GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);
  19.     gpio_configure_pin(LED3_GPIO, GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);
  20.  
  21.     gpio_configure_pin(GPIO_PUSH_BUTTON_0, (GPIO_DIR_INPUT | GPIO_PULL_UP));
  22.  
  23. #if defined(CONF_BOARD_TWI)
  24.     /* TWI Master GPIO pin configuration. */
  25.     const gpio_map_t TWI_GPIO_MAP =
  26.         {
  27.             {TWIMS0_TWD_PIN,  TWIMS0_TWD_FUNCTION  },
  28.             {TWIMS0_TWCK_PIN, TWIMS0_TWCK_FUNCTION }
  29.         };
  30.     gpio_enable_module(TWI_GPIO_MAP,
  31.         sizeof(TWI_GPIO_MAP) / sizeof(TWI_GPIO_MAP[0]));
  32. #endif
  33.  
  34. #if defined(CONF_BOARD_COM_PORT)
  35.     /* USART GPIO pin configuration. */
  36.     static const gpio_map_t COMPORT_GPIO_MAP =
  37.         {
  38.             {USART_RXD_PIN, USART_RXD_FUNCTION },
  39.             {USART_TXD_PIN, USART_TXD_FUNCTION }
  40.         };
  41.     gpio_enable_module(COMPORT_GPIO_MAP,
  42.             sizeof(COMPORT_GPIO_MAP) / sizeof(COMPORT_GPIO_MAP[0]));
  43. #endif
  44.  
  45. //#if defined(CONF_BOARD_ENABLE_MXT143E_XPLAINED)
  46.     ///* MXT143E GPIO pin configuration. */
  47.     //static const gpio_map_t MXT143E_GPIO_MAP =
  48.         //{
  49.             //{MXT143E_XPLAINED_SCK,  MXT143E_XPLAINED_SCK_FUNCTION  },
  50.             //{MXT143E_XPLAINED_MOSI, MXT143E_XPLAINED_MOSI_FUNCTION },
  51.             //{MXT143E_XPLAINED_MISO, MXT143E_XPLAINED_MISO_FUNCTION },
  52.         //};
  53.     //gpio_enable_module(MXT143E_GPIO_MAP,
  54.             //sizeof(MXT143E_GPIO_MAP) / sizeof(MXT143E_GPIO_MAP[0]));
  55.             //
  56.     //gpio_configure_pin(MXT143E_XPLAINED_CS, GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);
  57.     //gpio_configure_pin(MXT143E_XPLAINED_CHG, GPIO_DIR_INPUT);
  58.     //gpio_configure_pin(MXT143E_XPLAINED_DC, GPIO_DIR_OUTPUT | GPIO_INIT_LOW);
  59.     //#ifndef MXT143E_XPLAINED_BACKLIGHT_DISABLE
  60.     //gpio_configure_pin(MXT143E_XPLAINED_BACKLIGHT, GPIO_DIR_OUTPUT | GPIO_INIT_LOW);
  61.     //#endif
  62.     //gpio_configure_pin(MXT143E_XPLAINED_LCD_RESET, GPIO_DIR_OUTPUT | GPIO_INIT_LOW);
  63. //#endif
  64.  
  65.     static const gpio_map_t spi1_gpio_map = {
  66.         {HeaderJ1_SPI_SCK_PIN, HeaderJ1_SPI_SCK_FUNCTION},        //SCK
  67.         {HeaderJ1_SPI_MISO_PIN, HeaderJ1_SPI_MISO_FUNCTION}, //MISO
  68.         {HeaderJ1_SPI_NPCS0_PIN, HeaderJ1_SPI_NPCS0_FUNCTION}, //SS
  69.         {HeaderJ1_SPI_MOSI_PIN, HeaderJ1_SPI_MOSI_FUNCTION}}; //MOSI
  70.         gpio_enable_module(spi1_gpio_map,sizeof(spi1_gpio_map)/sizeof(spi1_gpio_map[0]));
  71.  
  72. #if defined(SENSORS_XPLAINED_BOARD)
  73.     /* Configure the Xplained Sensor extension board, if any, after
  74.      * the platform Xplained board has configured basic clock settings,
  75.      * GPIO pin mapping, interrupt controller options, etc.
  76.      */
  77.     sensor_board_init();
  78. #endif
  79.  
  80. //##xxx## bedeutet wohl, das etwas zum Variablennamen dazu geschrieben wird, in diesem Fall die Nummer
  81. #if defined (CONF_BOARD_AT45DBX)
  82.     static const gpio_map_t AT45DBX_SPI_GPIO_MAP = {
  83.         {AT45DBX_SPI_SCK_PIN,  AT45DBX_SPI_SCK_FUNCTION },
  84.         {AT45DBX_SPI_MISO_PIN, AT45DBX_SPI_MISO_FUNCTION},
  85.         {AT45DBX_SPI_MOSI_PIN, AT45DBX_SPI_MOSI_FUNCTION},
  86. # define AT45DBX_ENABLE_NPCS_PIN(NPCS, unused) \
  87.     {AT45DBX_SPI_NPCS##NPCS##_PIN, AT45DBX_SPI_NPCS##NPCS##_FUNCTION},
  88.     MREPEAT(AT45DBX_MEM_CNT, AT45DBX_ENABLE_NPCS_PIN, ~)
  89. # undef AT45DBX_ENABLE_NPCS_PIN
  90.     };
  91.     gpio_enable_module(AT45DBX_SPI_GPIO_MAP,
  92.             sizeof(AT45DBX_SPI_GPIO_MAP) / sizeof(AT45DBX_SPI_GPIO_MAP[0]));
  93. #endif
  94.  
  95. #if defined (CONF_BOARD_SD_MMC_MCI)
  96.     static const gpio_map_t SD_MMC_MCI_GPIO_MAP = {
  97.         {SD_SLOT_8BITS_CLK_PIN, SD_SLOT_8BITS_CLK_FUNCTION},
  98.         {SD_SLOT_8BITS_CMD_PIN, SD_SLOT_8BITS_CMD_FUNCTION},
  99.         {SD_SLOT_8BITS_DATA0_PIN, SD_SLOT_8BITS_DATA0_FUNCTION},
  100.         {SD_SLOT_8BITS_DATA1_PIN, SD_SLOT_8BITS_DATA1_FUNCTION},
  101.         {SD_SLOT_8BITS_DATA2_PIN, SD_SLOT_8BITS_DATA2_FUNCTION},
  102.         {SD_SLOT_8BITS_DATA3_PIN, SD_SLOT_8BITS_DATA3_FUNCTION},
  103.         {SD_SLOT_8BITS_DATA4_PIN, SD_SLOT_8BITS_DATA4_FUNCTION},
  104.         {SD_SLOT_8BITS_DATA5_PIN, SD_SLOT_8BITS_DATA5_FUNCTION},
  105.         {SD_SLOT_8BITS_DATA6_PIN, SD_SLOT_8BITS_DATA6_FUNCTION},
  106.         {SD_SLOT_8BITS_DATA7_PIN, SD_SLOT_8BITS_DATA7_FUNCTION},
  107.     };
  108.     gpio_enable_module(SD_MMC_MCI_GPIO_MAP,
  109.             sizeof(SD_MMC_MCI_GPIO_MAP) / sizeof(SD_MMC_MCI_GPIO_MAP[0]));
  110.     gpio_enable_pin_pull_up(SD_SLOT_8BITS_CARD_DETECT);
  111.     gpio_enable_pin_pull_up(SD_SLOT_8BITS_WRITE_PROTECT);
  112. #endif
  113.  
  114. }
RAW Paste Data