Guest User

init.c

a guest
Aug 5th, 2015
169
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_MOSI_PIN, HeaderJ1_SPI_MOSI_FUNCTION}, //MOSI
  69.         {HeaderJ1_SPI_NPCS0_PIN, HeaderJ1_SPI_NPCS0_FUNCTION}, //SS
  70.         {HeaderJ1_SPI_NPCS1_PIN, HeaderJ1_SPI_NPCS1_FUNCTION}, //SS
  71.         {HeaderJ1_SPI_NPCS2_PIN, HeaderJ1_SPI_NPCS2_FUNCTION}, //SS
  72.         {HeaderJ1_SPI_NPCS3_PIN, HeaderJ1_SPI_NPCS3_FUNCTION}}; //SS
  73.         gpio_enable_module(spi1_gpio_map,sizeof(spi1_gpio_map)/sizeof(spi1_gpio_map[0]));
  74.  
  75. #if defined(SENSORS_XPLAINED_BOARD)
  76.     /* Configure the Xplained Sensor extension board, if any, after
  77.      * the platform Xplained board has configured basic clock settings,
  78.      * GPIO pin mapping, interrupt controller options, etc.
  79.      */
  80.     sensor_board_init();
  81. #endif
  82.  
  83. //##xxx## bedeutet wohl, das etwas zum Variablennamen dazu geschrieben wird, in diesem Fall die Nummer
  84. #if defined (CONF_BOARD_AT45DBX)
  85.     static const gpio_map_t AT45DBX_SPI_GPIO_MAP = {
  86.         {AT45DBX_SPI_SCK_PIN,  AT45DBX_SPI_SCK_FUNCTION },
  87.         {AT45DBX_SPI_MISO_PIN, AT45DBX_SPI_MISO_FUNCTION},
  88.         {AT45DBX_SPI_MOSI_PIN, AT45DBX_SPI_MOSI_FUNCTION},
  89.             // \ (backslash) bedeutet Zeilenfortsetzung in der nächsten Zeile
  90. # define AT45DBX_ENABLE_NPCS_PIN(NPCS, unused) \
  91.     {AT45DBX_SPI_NPCS##NPCS##_PIN, AT45DBX_SPI_NPCS##NPCS##_FUNCTION},
  92.     MREPEAT(AT45DBX_MEM_CNT, AT45DBX_ENABLE_NPCS_PIN, ~)
  93. # undef AT45DBX_ENABLE_NPCS_PIN
  94.     };
  95.     gpio_enable_module(AT45DBX_SPI_GPIO_MAP,
  96.             sizeof(AT45DBX_SPI_GPIO_MAP) / sizeof(AT45DBX_SPI_GPIO_MAP[0]));
  97. #endif
  98.  
  99. #if defined (CONF_BOARD_SD_MMC_MCI)
  100.     static const gpio_map_t SD_MMC_MCI_GPIO_MAP = {
  101.         {SD_SLOT_8BITS_CLK_PIN, SD_SLOT_8BITS_CLK_FUNCTION},
  102.         {SD_SLOT_8BITS_CMD_PIN, SD_SLOT_8BITS_CMD_FUNCTION},
  103.         {SD_SLOT_8BITS_DATA0_PIN, SD_SLOT_8BITS_DATA0_FUNCTION},
  104.         {SD_SLOT_8BITS_DATA1_PIN, SD_SLOT_8BITS_DATA1_FUNCTION},
  105.         {SD_SLOT_8BITS_DATA2_PIN, SD_SLOT_8BITS_DATA2_FUNCTION},
  106.         {SD_SLOT_8BITS_DATA3_PIN, SD_SLOT_8BITS_DATA3_FUNCTION},
  107.         {SD_SLOT_8BITS_DATA4_PIN, SD_SLOT_8BITS_DATA4_FUNCTION},
  108.         {SD_SLOT_8BITS_DATA5_PIN, SD_SLOT_8BITS_DATA5_FUNCTION},
  109.         {SD_SLOT_8BITS_DATA6_PIN, SD_SLOT_8BITS_DATA6_FUNCTION},
  110.         {SD_SLOT_8BITS_DATA7_PIN, SD_SLOT_8BITS_DATA7_FUNCTION},
  111.     };
  112.     gpio_enable_module(SD_MMC_MCI_GPIO_MAP,
  113.             sizeof(SD_MMC_MCI_GPIO_MAP) / sizeof(SD_MMC_MCI_GPIO_MAP[0]));
  114.     gpio_enable_pin_pull_up(SD_SLOT_8BITS_CARD_DETECT);
  115.     gpio_enable_pin_pull_up(SD_SLOT_8BITS_WRITE_PROTECT);
  116. #endif
  117.  
  118. }
RAW Paste Data