void board_init(void) { // Initialize IOPORTs ioport_init(); // Put all pins to default state (input & pull-up) uint32_t pin; for (pin = PIN_PA00; pin <= PIN_PC31; pin ++) { ioport_set_pin_dir(pin, IOPORT_DIR_INPUT); ioport_set_pin_mode(pin, IOPORT_MODE_PULLUP); } #if defined (CONF_BOARD_COM_PORT) ioport_set_pin_peripheral_mode(COM_PORT_RX_PIN, COM_PORT_RX_MUX); ioport_set_pin_peripheral_mode(COM_PORT_TX_PIN, COM_PORT_TX_MUX); #endif #ifdef CONF_BOARD_GLOC_LUT0_PORT ioport_set_pin_peripheral_mode(PIN_PA20D_GLOC_IN0, MUX_PA20D_GLOC_IN0); ioport_set_pin_peripheral_mode(PIN_PA21D_GLOC_IN1, MUX_PA21D_GLOC_IN1); ioport_set_pin_peripheral_mode(PIN_PA22D_GLOC_IN2, MUX_PA22D_GLOC_IN2); ioport_set_pin_peripheral_mode(PIN_PA07D_GLOC_IN3, MUX_PA07D_GLOC_IN3); ioport_set_pin_peripheral_mode(PIN_PA24D_GLOC_OUT0, MUX_PA24D_GLOC_OUT0); #endif }
int main(void) { /* Use static volatile to make it available in debug watch */ static volatile bool pin_val; sysclk_init(); board_init(); ioport_init(); delay_init(sysclk_get_cpu_hz()); /* Set output direction on the given LED IOPORTs */ ioport_set_pin_dir(EXAMPLE_LED, IOPORT_DIR_OUTPUT); /* Set direction and pullup on the given button IOPORT */ ioport_set_pin_dir(EXAMPLE_BUTTON, IOPORT_DIR_INPUT); ioport_set_pin_mode(EXAMPLE_BUTTON, IOPORT_MODE_PULLUP); /* Set LED IOPORTs high */ ioport_set_pin_level(EXAMPLE_LED, IOPORT_PIN_LEVEL_HIGH); while (true) { /* Toggle LED IOPORTs with half a second interval */ ioport_toggle_pin_level(EXAMPLE_LED); delay_ms(500); /* Get value from button port */ /* Use watch with debugger to see it */ pin_val = ioport_get_pin_level(EXAMPLE_BUTTON); } }
int main (void) { /* Insert system clock initialization code here (sysclk_init()). */ board_init(); sysclk_init(); delay_init(sysclk_get_cpu_hz()); //gpio_configure_pin(PORTA5,1); ioport_init(); ioport_set_pin_dir(LED_GREEN,IOPORT_DIR_OUTPUT); ioport_set_pin_dir(LED_RED,IOPORT_DIR_OUTPUT); /* Insert application code here, after the board has been initialized. */ ioport_set_pin_high(LED_RED); ioport_set_pin_low(LED_GREEN); //gpio_set_pin_high(PORTA5); while(true){ ioport_toggle_pin(LED_GREEN); ioport_toggle_pin(LED_RED); delay_ms(500); } }
static void initGpio(void) { ioport_init(); // PIOB ioport_set_pin_level(LED0_GPIO, false); ioport_set_pin_dir(LED0_GPIO, IOPORT_DIR_OUTPUT); }
int main(void) { // prepare the i/o for LEDs ioport_init(); ioport_set_pin_dir(RED, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(YELLOW, IOPORT_DIR_OUTPUT); // clock init & enable system clock to all peripheral modules sysclk_init(); sysclk_enable_module(SYSCLK_PORT_GEN, 0xff); sysclk_enable_module(SYSCLK_PORT_A, 0xff); sysclk_enable_module(SYSCLK_PORT_B, 0xff); sysclk_enable_module(SYSCLK_PORT_C, 0xff); sysclk_enable_module(SYSCLK_PORT_D, 0xff); sysclk_enable_module(SYSCLK_PORT_E, 0xff); sysclk_enable_module(SYSCLK_PORT_F, 0xff); // start tasks xTaskCreate(blink1, (signed char*) "blink1", 1024, NULL, 2, NULL); xTaskCreate(blink2, (signed char*) "blink2", 1024, NULL, 2, NULL); xTaskCreate(uartLoopBack, (signed char*) "uart1", 1024, NULL, 2, NULL); xTaskCreate(twi_example, (signed char*) "twi", 1024, NULL, 2, NULL); vTaskStartScheduler(); return 0; }
/* This function is meant to contain board-specific initialization code * for, e.g., the I/O pins. The initialization can rely on application- * specific board configuration, found in conf_board.h. */ void v2x_board_init(void) { irq_initialize_vectors(); pmic_init(); sysclk_init(); //configure clock sources for core and USB sleepmgr_init(); // Initialize the sleep manager ioport_init(); //Initializes the IOPORT service pin_init(); //whole chip pin init, modes and initial conditions spi_start(); //start SPI driver PWR_init(); //sets SR to default states - holds power up cpu_irq_enable(); eeprom_init(); //verifies eeprom safe for use menu_init(); //loads menu settings time_init(); //starts the RTC button_init(); //init button stuffs ACL_init(); //configures, but does not start sampling GSM_usart_init(); //starts direct serial channel to the SIM module CAN_uart_start(); //starts direct serial channel to the ELM module canbus_serial_routing(AVR_ROUTING); //cause the serial 3-state buffer to route the serial path from the ELM to the FTDI udc_start(); //start stack and vbus monitoring PWR_hub_start(); //connect the hub to the computer //autostart all systems delay_ms(500); GSM_modem_init(); CAN_elm_init(); ACL_set_sample_on(); PWR_host_start(); }
void init_octopus(void) { sysclk_init(); ioport_init(); leds_init(); bluetooth_init(); //bluetooth_init_interrupt(); switch_init(); //usb_init(); }
// setup the board instead of board_init() as recommended by ASF.. because christmas lights, that's why. void init (void) { static usart_serial_options_t usart_options = { .baudrate = USART_SERIAL_BAUDRATE, .charlength = USART_SERIAL_CHAR_LENGTH, .paritytype = USART_SERIAL_PARITY, .stopbits = USART_SERIAL_STOP_BIT }; // initialize ASF stuff board_init(); sysclk_init(); ioport_init(); pmic_init(); pmic_set_scheduling(PMIC_SCH_FIXED_PRIORITY); // remap, enable TX, and configure USART on PORT C PORTC.REMAP |= PR_USART0_bm; PORTC.DIR |= (1 << PIN7_bp); sysclk_enable_module(SYSCLK_PORT_C, PR_USART0_bm); usart_init_rs232(USART_SERIAL, &usart_options); // setup timer for PWM tc45_enable(&TCC4); tc45_set_overflow_interrupt_callback(&TCC4, pwm_callback); tc45_set_wgm(&TCC4, TC45_WG_NORMAL); tc45_write_period(&TCC4, 256); tc45_set_overflow_interrupt_level(&TCC4, TC45_INT_LVL_MED); // enable all channels and turn off (high) ioport_set_port_dir(IOPORT_PORTA, PORTA_MASK, IOPORT_DIR_OUTPUT); ioport_set_port_dir(IOPORT_PORTD, PORTD_MASK, IOPORT_DIR_OUTPUT); ioport_set_port_dir(IOPORT_PORTR, PORTR_MASK, IOPORT_DIR_OUTPUT); ioport_set_port_level(IOPORT_PORTA, PORTA_MASK, 0xFF); ioport_set_port_level(IOPORT_PORTD, PORTD_MASK, 0xFF); ioport_set_port_level(IOPORT_PORTR, PORTR_MASK, 0xFF); for (uint8_t i=0; i<NUM_CHANNELS; i++) { compare[i] = 0; compbuff[i] = 0; } // enable status LEDs and turn off ioport_set_pin_dir(LED_STATUS, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(LED_DATA, IOPORT_DIR_OUTPUT); ioport_set_pin_level(LED_STATUS, 1); ioport_set_pin_level(LED_DATA, 1); // enable interrupts and start timer for PWM cpu_irq_enable(); tc45_write_clock_source(&TCC4, TC45_CLKSEL_DIV2_gc); }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT /* Disable the watchdog */ WDT->WDT_MR = WDT_MR_WDDIS; #endif /* GPIO has been deprecated, the old code just keeps it for compatibility. * In new designs IOPORT is used instead. * Here IOPORT must be initialized for others to use before setting up IO. */ ioport_init(); #ifdef CONFIG_CPCLK_ENABLE /* Configure the pins connected to LEDs as output and set their * default initial state to high (LEDs off). */ ioport_set_pin_dir(LED4_GPIO, IOPORT_DIR_OUTPUT); ioport_set_pin_level(LED4_GPIO, LED4_INACTIVE_LEVEL); #else #warning Please enable CONFIG_CPCLK_ENABLE in conf_clock.h to use LEDs (PIOC). #endif /* Configure UART0 pins */ #ifdef CONF_BOARD_UART_CONSOLE ioport_set_pin_peripheral_mode(PIO_PB4_IDX, IOPORT_MODE_MUX_A); ioport_set_pin_peripheral_mode(PIO_PB5_IDX, IOPORT_MODE_MUX_A); #endif /* Configure SPI pins */ #ifdef CONF_BOARD_SPI0 ioport_set_pin_peripheral_mode(SPI0_MISO_GPIO, SPI0_MISO_FLAGS); ioport_set_pin_peripheral_mode(SPI0_MOSI_GPIO, SPI0_MOSI_FLAGS); ioport_set_pin_peripheral_mode(SPI0_SPCK_GPIO, SPI0_SPCK_FLAGS); #ifdef CONF_BOARD_SPI0_NPCS1 ioport_set_pin_peripheral_mode(SPI0_NPCS1_GPIO, SPI0_NPCS1_FLAGS); #endif #ifdef CONF_BOARD_SPI0_NPCS3 ioport_set_pin_peripheral_mode(SPI0_NPCS3_GPIO, SPI0_NPCS3_FLAGS); #endif #endif /* Configure TWI pins */ #if defined(CONF_BOARD_TWI0) || defined(CONF_BOARD_AT30TSE) ioport_set_pin_peripheral_mode(TWIO_DATA_GPIO, TWIO_DATA_FLAG); ioport_set_pin_peripheral_mode(TWIO_CLK_GPIO, TWIO_CLK_FLAG); #endif }
int main (void) { U8 msg[32] = "Hi ArduSub\n\r"; pmic_init(); sysclk_init(); adc_init(); thruster_init(); ioport_init(); timer_init(10000); timer_set_counts(TIMER_HEARTBEAT,timer_ms_to_counts(250)); timer_start(TIMER_HEARTBEAT); cpu_irq_enable(); volatile U8 count = 0; ioport_set_pin_dir(LED1,IOPORT_DIR_OUTPUT); ioport_set_pin_dir(LED2,IOPORT_DIR_OUTPUT); ioport_set_pin_dir(UARTD_TX,IOPORT_DIR_OUTPUT); ioport_set_pin_dir(UARTD_RX,IOPORT_DIR_INPUT); ioport_set_pin_dir(TXEN,IOPORT_DIR_OUTPUT); board_init(); uart_init(19200); do { message_tasks(); count++; if (count > 52) { count = 0; } if(timer_is_expired(TIMER_HEARTBEAT)) { timer_reset(TIMER_HEARTBEAT); board_pres_read(); ext_temp_read(); //ioport_set_pin_level(TXEN,1); //uart_write(&msg[0],12); //while(uart_tx_count() != 0); //blink heart beat LED ioport_set_pin_level(LED2,!ioport_get_pin_level(LED2)); } } while (1); // Insert application code here, after the board has been initialized. }
/** \brief Main function. */ int main(void) { /* Set the sleep mode to initially lock. */ volatile enum sleepmgr_mode mode = SLEEPMGR_ACTIVE; /* Initialize the pins for input and output. */ board_init(); /* Initialize the clock and disable clock unused modules */ sysclk_init(); /* Initialize the IOPORT */ ioport_init(); delay_init(sysclk_get_cpu_hz()); /* Set the pin sense mode */ ioport_set_pin_sense_mode(BUTTON_PIN, IOPORT_SENSE_LEVEL); /* Enable external interrupt */ external_interrupt_enable(BUTTON_NUMBER); /* Turn off the LED */ LED_On(LED_PIN); /* Initialize the sleep manager, lock initial mode. */ sleepmgr_init(); sleepmgr_lock_mode(mode); Enable_global_interrupt(); do { /* Delay for 3 seconds to show the device is awake. */ delay_ms(3000); /* Turn off the LED and go to sleep. */ LED_Off(LED_PIN); sleepmgr_enter_sleep(); /* Turn on the LED on wake up */ LED_On(LED_PIN); /* Unlock current mode, then lock the next one. */ sleepmgr_unlock_mode(mode); if (++mode < SLEEPMGR_NR_OF_MODES) { sleepmgr_lock_mode(mode); } else { mode = SLEEPMGR_ACTIVE; sleepmgr_lock_mode(mode); } } while (1); }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT /* Disable the watchdog */ WDT->WDT_MR = WDT_MR_WDDIS; #endif /* GPIO has been deprecated, the old code just keeps it for compatibility. * In new designs IOPORT is used instead. * Here IOPORT must be initialized for others to use before setting up IO. */ ioport_init(); iopins_normal(); }
void hw_init(void) { // date_str current_date; // current_date.year=0x13; // current_date.month=0x12; // current_date.day=0x11; // current_date.hour=0x08; // current_date.min=0x55; // current_date.sec=0x00; // current_date.ampm=AM; sysclk_init(); ioport_init(); // init_temp_sens(); // init_rtc(); // usb_init(); /************************************************************************/ /* For RTC */ /************************************************************************/ rtc_init(); /************************************************************************/ /* */ /************************************************************************/ ioport_set_pin_dir(LED_RED, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(LED_BLUE, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(LED_GREEN1, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(LED_GREEN2, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(BUTTON, IOPORT_DIR_INPUT); ioport_set_pin_dir(FOCUS, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(SHUTTER, IOPORT_DIR_OUTPUT); ioport_set_pin_mode(SHUTTER,IOPORT_MODE_PULLUP); ioport_set_pin_mode(FOCUS,IOPORT_MODE_PULLUP); ioport_set_pin_level(SHUTTER,1); ioport_set_pin_level(FOCUS,1); // set_trickle(); // set_calendar(current_date);) // }
void board_init(void) { /* This function is meant to contain board-specific initialization code * for, e.g., the I/O pins. The initialization can rely on application- * specific board configuration, found in conf_board.h. */ ioport_init(); #ifdef BOARD_REV_A // USART PORTD_REMAP = USARTD_REMAP; PORTD_DIRSET = PIN7_bm; //LEDs ioport_set_pin_dir(LED_GREEN, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(LED_RED, IOPORT_DIR_OUTPUT); #endif #ifdef BOARD_REV_B // USART PORTD_REMAP = USARTD_REMAP; PORTD_DIRSET = PIN7_bm; //Button ioport_set_pin_dir(BUT_1, IOPORT_DIR_INPUT); //LEDs ioport_set_pin_dir(LED_GREEN, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(LED_RED, IOPORT_DIR_OUTPUT); #endif #ifdef ENABLE_USART // startup USART static usart_rs232_options_t usart_serial_options = { .baudrate = USART_SERIAL_BAUDRATE, .charlength = USART_SERIAL_CHAR_LENGTH, .paritytype = USART_SERIAL_PARITY, .stopbits = USART_SERIAL_STOP_BIT }; sysclk_enable_module(SYSCLK_PORT_D, PR_USART0_bm); //usart_init_rs232(USART_SERIAL, &usart_serial_options); stdio_serial_init(USART_SERIAL, &usart_serial_options); #endif }
void __init load_mmu(void) { switch(sparc_cpu_model) { case sun4c: case sun4: ld_mmu_sun4c(); break; case sun4m: case sun4d: ld_mmu_srmmu(); break; default: prom_printf("load_mmu: %d unsupported\n", (int)sparc_cpu_model); prom_halt(); } btfixup(); ioport_init(); }
int main(void) { sysclk_init(); board_init(); ioport_init(); /* Set output direction on the given LED IOPORTs */ ioport_set_pin_dir(EXAMPLE_LED, IOPORT_DIR_OUTPUT); /* Set direction and pullup on the given button IOPORT */ ioport_set_pin_dir(EXAMPLE_BUTTON, IOPORT_DIR_INPUT); ioport_set_pin_mode(EXAMPLE_BUTTON, IOPORT_MODE_PULLUP); while (true) { /* Get value from button and output it on led */ ioport_set_pin_level(EXAMPLE_LED, ioport_get_pin_level(EXAMPLE_BUTTON)); } }
int main (void) { sysclk_init(); ioport_init(); ioport_set_pin_dir(LED_BLUE, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(LED_GREEN, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(LED_WHITE, IOPORT_DIR_OUTPUT); ioport_configure_pin(BUTTON_0, IOPORT_PULL_UP); ioport_configure_pin(BUTTON_1, IOPORT_PULL_UP); force_boot_loader(); irq_initialize_vectors(); cpu_irq_enable(); udc_start(); //board_init(); while(1) { ioport_toggle_pin_level(LED_GREEN); delay_ms(100); ioport_set_pin_level(LED_BLUE, ioport_get_pin_level(BUTTON_0)); ioport_set_pin_level(LED_WHITE, ioport_get_pin_level(BUTTON_1)); char usb_in = udi_cdc_getc(); char usb_out [17]= "WHAT YOU TYPED: \r";//udi_cdc_getc(); for (int i=0;i<16;i++) { udi_cdc_putc(usb_out[i]); } udi_cdc_putc(usb_in); udi_cdc_putc('\r'); } }
int main(void) { ioport_init(); board_init(); sysclk_init(); irq_initialize_vectors(); cpu_irq_enable(); stdio_usb_init(); delay_ms(200); // Power on LED on board ioport_set_pin_level(GPIO_LED_GREEN, IOPORT_PIN_LEVEL_HIGH); ad9834_init(); while(true) { enum ad9834_waveform waveform; float frequency, vout; // start_frequency, end_frequency, //uint32_t delay; // Read command from PC Byte cmd = usb_data_read_byte(); switch (cmd) { case CMD_FREQ: frequency = usb_data_read_float(); ad9834_set_frequency(frequency); break; case CMD_VOUT: vout = usb_data_read_float(); ad9834_set_output_voltage(vout); break; case CMD_WAVEFORM: waveform = (enum ad9834_waveform)usb_data_read_byte(); ad9834_set_waveform(waveform); break; case CMD_FREQ_REG: ad9834_set_frequency_register(usb_data_read_byte()); break; /* Not implemented yet case CMD_PHASE: // ad9834_set_phase() break; case CMD_PHASE_REG: // ad9834_set_phase_register(usb_data_read_byte()) break; case CMD_SWEEP: start_frequency = usb_data_read_float(); end_frequency = usb_data_read_float(); delay = usb_data_read_uint32(); for (uint32_t frequency = start_frequency; frequency < end_frequency; frequency += 1) { ad9834_set_frequency(frequency); delay_us(delay); } usb_data_write_byte(MSG_DONE); break; case CMD_RESET: break; */ default: // Do nothing if not recognized command break; } } }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT /* Disable the watchdog */ WDT->WDT_MR = WDT_MR_WDDIS; #endif /* GPIO has been deprecated, the old code just keeps it for compatibility. * In new designs IOPORT is used instead. * Here IOPORT must be initialized for others to use before setting up IO. */ ioport_init(); /* Configure Power LED */ gpio_configure_pin(LED3_GPIO, LED3_FLAGS); gpio_set_pin_high(LED3_GPIO); /* Turned on by default */ /* Configure User LED pins */ gpio_configure_pin(LED0_GPIO, LED0_FLAGS); gpio_configure_pin(LED1_GPIO, LED1_FLAGS); gpio_configure_pin(LED2_GPIO, LED2_FLAGS); /* Configure Push Button pins */ gpio_configure_pin(GPIO_PUSH_BUTTON_1, GPIO_PUSH_BUTTON_1_FLAGS); gpio_configure_pin(GPIO_PUSH_BUTTON_2, GPIO_PUSH_BUTTON_2_FLAGS); #ifdef CONF_BOARD_UART_CONSOLE /* Configure UART pins */ gpio_configure_group(PINS_UART_PIO, PINS_UART, PINS_UART_FLAGS); #endif /* Configure ADC example pins */ #ifdef CONF_BOARD_ADC /* TC TIOA configuration */ gpio_configure_pin(PIN_TC0_TIOA0,PIN_TC0_TIOA0_FLAGS); /* ADC Trigger configuration */ gpio_configure_pin(PINS_ADC_TRIG, PINS_ADC_TRIG_FLAG); /* PWMH0 configuration */ gpio_configure_pin(PIN_PWMC_PWMH0_TRIG, PIN_PWMC_PWMH0_TRIG_FLAG); #endif #ifdef CONF_BOARD_PWM_LED0 /* Configure PWM LED0 pin */ gpio_configure_pin(PIN_PWM_LED0_GPIO, PIN_PWM_LED0_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED1 /* Configure PWM LED1 pin */ gpio_configure_pin(PIN_PWM_LED1_GPIO, PIN_PWM_LED1_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED2 /* Configure PWM LED2 pin */ gpio_configure_pin(PIN_PWM_LED2_GPIO, PIN_PWM_LED2_FLAGS); #endif /* Configure SPI0 pins */ #ifdef CONF_BOARD_SPI0 gpio_configure_pin(SPI0_MISO_GPIO, SPI0_MISO_FLAGS); gpio_configure_pin(SPI0_MOSI_GPIO, SPI0_MOSI_FLAGS); gpio_configure_pin(SPI0_SPCK_GPIO, SPI0_SPCK_FLAGS); /** * For NPCS 1, 2, and 3, different PINs can be used to access the same * NPCS line. * Depending on the application requirements, the default PIN may not be * available. * Hence a different PIN should be selected using the * CONF_BOARD_SPI_NPCS_GPIO and * CONF_BOARD_SPI_NPCS_FLAGS macros. */ # ifdef CONF_BOARD_SPI0_NPCS0 gpio_configure_pin(SPI0_NPCS0_GPIO, SPI0_NPCS0_FLAGS); # endif # ifdef CONF_BOARD_SPI0_NPCS1 # if defined(CONF_BOARD_SPI0_NPCS1_GPIO) && \ defined(CONF_BOARD_SPI0_NPCS1_FLAGS) gpio_configure_pin(CONF_BOARD_SPI0_NPCS1_GPIO, CONF_BOARD_SPI0_NPCS1_FLAGS); # else gpio_configure_pin(SPI0_NPCS1_PA29_GPIO, SPI0_NPCS1_PA29_FLAGS); # endif # endif # ifdef CONF_BOARD_SPI0_NPCS2 # if defined(CONF_BOARD_SPI0_NPCS2_GPIO) && \ defined(CONF_BOARD_SPI0_NPCS2_FLAGS) gpio_configure_pin(CONF_BOARD_SPI0_NPCS2_GPIO, CONF_BOARD_SPI0_NPCS2_FLAGS); # else gpio_configure_pin(SPI0_NPCS2_PA30_GPIO, SPI0_NPCS2_PA30_FLAGS); # endif # endif # ifdef CONF_BOARD_SPI0_NPCS3 # if defined(CONF_BOARD_SPI0_NPCS3_GPIO) && \ defined(CONF_BOARD_SPI0_NPCS3_FLAGS) gpio_configure_pin(CONF_BOARD_SPI0_NPCS3_GPIO, CONF_BOARD_SPI0_NPCS3_FLAGS); # else gpio_configure_pin(SPI0_NPCS3_PA31_GPIO, SPI0_NPCS3_PA31_FLAGS); # endif # endif #endif // #ifdef CONF_BOARD_SPI0 /* Configure SPI1 pins */ #ifdef CONF_BOARD_SPI1 gpio_configure_pin(SPI1_MISO_GPIO, SPI1_MISO_FLAGS); gpio_configure_pin(SPI1_MOSI_GPIO, SPI1_MOSI_FLAGS); gpio_configure_pin(SPI1_SPCK_GPIO, SPI1_SPCK_FLAGS); # ifdef CONF_BOARD_SPI1_NPCS0 gpio_configure_pin(SPI1_NPCS0_GPIO, SPI1_NPCS0_FLAGS); # endif # ifdef CONF_BOARD_SPI1_NPCS1 gpio_configure_pin(SPI1_NPCS1_GPIO, SPI1_NPCS1_FLAGS); # endif # ifdef CONF_BOARD_SPI1_NPCS2 gpio_configure_pin(SPI1_NPCS2_GPIO, SPI1_NPCS2_FLAGS); # endif # ifdef CONF_BOARD_SPI1_NPCS3 gpio_configure_pin(SPI1_NPCS3_GPIO, SPI1_NPCS3_FLAGS); # endif #endif #ifdef CONF_BOARD_TWI0 gpio_configure_pin(TWI0_DATA_GPIO, TWI0_DATA_FLAGS); gpio_configure_pin(TWI0_CLK_GPIO, TWI0_CLK_FLAGS); #endif #ifdef CONF_BOARD_TWI1 gpio_configure_pin(TWI1_DATA_GPIO, TWI1_DATA_FLAGS); gpio_configure_pin(TWI1_CLK_GPIO, TWI1_CLK_FLAGS); #endif #ifdef CONF_BOARD_USART_RXD /* Configure USART RXD pin */ gpio_configure_pin(PIN_USART0_RXD_IDX, PIN_USART0_RXD_FLAGS); #endif #ifdef CONF_BOARD_USART_TXD /* Configure USART TXD pin */ gpio_configure_pin(PIN_USART0_TXD_IDX, PIN_USART0_TXD_FLAGS); #endif #ifdef CONF_BOARD_USART_CTS /* Configure USART CTS pin */ gpio_configure_pin(PIN_USART0_CTS_IDX, PIN_USART0_CTS_FLAGS); #endif #ifdef CONF_BOARD_USART_RTS /* Configure USART RTS pin */ gpio_configure_pin(PIN_USART0_RTS_IDX, PIN_USART0_RTS_FLAGS); #endif #ifdef CONF_BOARD_USART_SCK /* Configure USART synchronous communication SCK pin */ gpio_configure_pin(PIN_USART0_SCK_IDX, PIN_USART0_SCK_FLAGS); #endif #ifdef CONF_BOARD_ADM3312_EN /* Configure ADM3312 enable pin */ gpio_configure_pin(PIN_USART0_EN_IDX, PIN_USART0_EN_FLAGS); gpio_set_pin_low(PIN_USART0_EN_IDX); #endif #ifdef CONF_BOARD_TFDU4300_SD /* Configure IrDA transceiver shutdown pin */ gpio_configure_pin(PIN_IRDA_SD_IDX, PIN_IRDA_SD_FLAGS); gpio_set_pin_low(PIN_IRDA_SD_IDX); #endif #ifdef CONF_BOARD_ADM3485_RE /* Configure RS485 transceiver ADM3485 RE pin */ gpio_configure_pin(PIN_RE_IDX, PIN_RE_FLAGS); gpio_set_pin_low(PIN_RE_IDX); #endif #ifdef CONF_BOARD_SMC_PSRAM gpio_configure_pin(PIN_EBI_DATA_BUS_D0, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D1, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D2, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D3, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D4, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D5, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D6, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D7, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D8, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D9, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D10, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D11, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D12, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D13, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D14, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D15, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_NRD, PIN_EBI_NRD_FLAGS); gpio_configure_pin(PIN_EBI_NWE, PIN_EBI_NWE_FLAGS); gpio_configure_pin(PIN_EBI_NCS0, PIN_EBI_NCS0_FLAGS); gpio_configure_pin(PIN_EBI_ADDR_BUS_NBS0, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_NBS1, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A1, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A2, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A3, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A4, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A5, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A6, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A7, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A8, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A9, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A10, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A11, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A12, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A13, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A14, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A15, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A16, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A17, PIN_EBI_ADDR_BUS_FLAG1); gpio_configure_pin(PIN_EBI_ADDR_BUS_A18, PIN_EBI_ADDR_BUS_FLAG2); gpio_configure_pin(PIN_EBI_ADDR_BUS_A19, PIN_EBI_ADDR_BUS_FLAG2); gpio_configure_pin(PIN_EBI_ADDR_BUS_A20, PIN_EBI_ADDR_BUS_FLAG2); #endif // #ifdef CONF_BOARD_SMC_PSRAM #ifdef CONF_BOARD_HX8347A /* Configure LCD EBI pins */ gpio_configure_pin(PIN_EBI_DATA_BUS_D0, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D1, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D2, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D3, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D4, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D5, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D6, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D7, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D8, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D9, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D10, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D11, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D12, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D13, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D14, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D15, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_NRD, PIN_EBI_NRD_FLAGS); gpio_configure_pin(PIN_EBI_NWE, PIN_EBI_NWE_FLAGS); gpio_configure_pin(PIN_EBI_NCS2, PIN_EBI_NCS2_FLAGS); gpio_configure_pin(PIN_EBI_LCD_RS, PIN_EBI_LCD_RS_FLAGS); #endif // #ifdef CONF_BOARD_HX8347A #ifdef CONF_BOARD_AAT3194 /* Configure Backlight control pin */ gpio_configure_pin(BOARD_AAT31XX_SET_GPIO, BOARD_AAT31XX_SET_FLAGS); #endif #ifdef CONF_BOARD_USB_PORT /* Configure USB_ID (UOTGID) pin */ gpio_configure_pin(USB_ID_GPIO, USB_ID_FLAGS); /* Configure USB_VBOF (UOTGVBOF) pin */ gpio_configure_pin(USB_VBOF_GPIO, USB_VBOF_FLAGS); /* Configure FAULT detect pin */ gpio_configure_pin(USB_OVERCURRENT_DETECT_GPIO, USB_OVERCURRENT_DETECT_FLAGS); #endif #ifdef CONF_BOARD_MMA7341L /* Configure MMA7341L mode set control pin */ gpio_configure_pin(PIN_MMA7341L_MODE, PIN_MMA7341L_MODE_FLAG); /* Configure MMA7341L x,y,z axis output voltage pin */ gpio_configure_pin(PIN_MMA7341L_X_AXIS, PIN_MMA7341L_X_AXIS_FLAG); gpio_configure_pin(PIN_MMA7341L_Y_AXIS, PIN_MMA7341L_Y_AXIS_FLAG); gpio_configure_pin(PIN_MMA7341L_Z_AXIS, PIN_MMA7341L_Z_AXIS_FLAG); #endif #ifdef CONF_BOARD_ADS7843 /* Configure Touchscreen SPI pins */ gpio_configure_pin(BOARD_ADS7843_IRQ_GPIO,BOARD_ADS7843_IRQ_FLAGS); gpio_configure_pin(BOARD_ADS7843_BUSY_GPIO, BOARD_ADS7843_BUSY_FLAGS); gpio_configure_pin(SPI0_MISO_GPIO, SPI0_MISO_FLAGS); gpio_configure_pin(SPI0_MOSI_GPIO, SPI0_MOSI_FLAGS); gpio_configure_pin(SPI0_SPCK_GPIO, SPI0_SPCK_FLAGS); gpio_configure_pin(SPI0_NPCS0_GPIO, SPI0_NPCS0_FLAGS); #endif #ifdef CONF_BOARD_ISO7816_RST /* Configure ISO7816 card reset pin */ gpio_configure_pin(PIN_ISO7816_RST_IDX, PIN_ISO7816_RST_FLAG); #endif #ifdef CONF_BOARD_ISO7816 /* Configure ISO7816 interface TXD & SCK pin */ gpio_configure_pin(PIN_USART0_TXD_IDX, PIN_USART0_TXD_FLAGS); gpio_configure_pin(PIN_USART0_SCK_IDX, PIN_USART0_SCK_FLAGS); #endif #ifdef CONF_BOARD_CAN0 /* Configure the CAN0 TX and RX pins. */ gpio_configure_pin(PIN_CAN0_RX_IDX, PIN_CAN0_RX_FLAGS); gpio_configure_pin(PIN_CAN0_TX_IDX, PIN_CAN0_TX_FLAGS); /* Configure the transiver0 RS & EN pins. */ gpio_configure_pin(PIN_CAN0_TR_RS_IDX, PIN_CAN0_TR_RS_FLAGS); gpio_configure_pin(PIN_CAN0_TR_EN_IDX, PIN_CAN0_TR_EN_FLAGS); #endif #ifdef CONF_BOARD_CAN1 /* Configure the CAN1 TX and RX pin. */ gpio_configure_pin(PIN_CAN1_RX_IDX, PIN_CAN1_RX_FLAGS); gpio_configure_pin(PIN_CAN1_TX_IDX, PIN_CAN1_TX_FLAGS); /* Configure the transiver1 RS & EN pins. */ gpio_configure_pin(PIN_CAN1_TR_RS_IDX, PIN_CAN1_TR_RS_FLAGS); gpio_configure_pin(PIN_CAN1_TR_EN_IDX, PIN_CAN1_TR_EN_FLAGS); #endif #ifdef CONF_BOARD_SDRAMC gpio_configure_pin(PIN_SDRAM_SDCKE, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDCS, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_RAS, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_CAS, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_BA0, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_BA1, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDWE, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_NBS0, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_NBS1, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA0, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA1, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA2, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA3, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA4, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA5, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA6, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA7, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA8, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA9, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA10, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA11, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA12, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA13, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA14, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_DATA15, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA0, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA1, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA2, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA3, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA4, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA5, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA6, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA7, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA8, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA9, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA10, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA11, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_SDA12, PIN_SDRAM_FLAGS); gpio_configure_pin(PIN_SDRAM_EN, PIN_SDRAM_EN_FLAGS); #endif #ifdef CONF_BOARD_EMAC gpio_configure_pin(PIN_EEMAC_EREFCK, PIN_EMAC_FLAGS); gpio_configure_pin(PIN_EMAC_ETX0, PIN_EMAC_FLAGS); gpio_configure_pin(PIN_EMAC_ETX1, PIN_EMAC_FLAGS); gpio_configure_pin(PIN_EMAC_ETXEN, PIN_EMAC_FLAGS); gpio_configure_pin(PIN_EMAC_ECRSDV, PIN_EMAC_FLAGS); gpio_configure_pin(PIN_EMAC_ERX0, PIN_EMAC_FLAGS); gpio_configure_pin(PIN_EMAC_ERX1, PIN_EMAC_FLAGS); gpio_configure_pin(PIN_EMAC_ERXER, PIN_EMAC_FLAGS); gpio_configure_pin(PIN_EMAC_EMDC, PIN_EMAC_FLAGS); gpio_configure_pin(PIN_EMAC_EMDIO, PIN_EMAC_FLAGS); #endif #ifdef CONF_BOARD_NAND gpio_configure_pin(PIN_EBI_NANDOE, PIN_EBI_NANDOE_FLAGS); gpio_configure_pin(PIN_EBI_NANDWE, PIN_EBI_NANDWE_FLAGS); gpio_configure_pin(PIN_EBI_NANDCLE, PIN_EBI_NANDCLE_FLAGS); gpio_configure_pin(PIN_EBI_NANDALE, PIN_EBI_NANDALE_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_0, PIN_EBI_NANDIO_0_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_1, PIN_EBI_NANDIO_1_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_2, PIN_EBI_NANDIO_2_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_3, PIN_EBI_NANDIO_3_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_4, PIN_EBI_NANDIO_4_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_5, PIN_EBI_NANDIO_5_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_6, PIN_EBI_NANDIO_6_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_7, PIN_EBI_NANDIO_7_FLAGS); gpio_configure_pin(PIN_NF_CE_IDX, PIN_NF_CE_FLAGS); gpio_configure_pin(PIN_NF_RB_IDX, PIN_NF_RB_FLAGS); #endif #ifdef CONF_BOARD_SSC gpio_configure_pin(PIN_SSC_TD, PIN_SSC_TD_FLAGS); gpio_configure_pin(PIN_SSC_TK, PIN_SSC_TK_FLAGS); gpio_configure_pin(PIN_SSC_TF, PIN_SSC_TF_FLAGS); gpio_configure_pin(PIN_SSC_RD, PIN_SSC_RD_FLAGS); gpio_configure_pin(PIN_SSC_RK, PIN_SSC_RK_FLAGS); gpio_configure_pin(PIN_SSC_RF, PIN_SSC_RF_FLAGS); #endif #ifdef CONF_BOARD_PCK0 gpio_configure_pin(PIN_PCK0, PIN_PCK0_FLAGS); #endif #if defined (CONF_BOARD_SD_MMC_HSMCI) /* Configure HSMCI pins */ gpio_configure_pin(PIN_HSMCI_MCCDA_GPIO, PIN_HSMCI_MCCDA_FLAGS); gpio_configure_pin(PIN_HSMCI_MCCK_GPIO, PIN_HSMCI_MCCK_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA0_GPIO, PIN_HSMCI_MCDA0_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA1_GPIO, PIN_HSMCI_MCDA1_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA2_GPIO, PIN_HSMCI_MCDA2_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA3_GPIO, PIN_HSMCI_MCDA3_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA4_GPIO, PIN_HSMCI_MCDA4_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA5_GPIO, PIN_HSMCI_MCDA5_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA6_GPIO, PIN_HSMCI_MCDA6_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA7_GPIO, PIN_HSMCI_MCDA7_FLAGS); /* Configure SD/MMC card detect pin */ gpio_configure_pin(SD_MMC_0_CD_GPIO, SD_MMC_0_CD_FLAGS); #endif }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT struct wdt_dev_inst wdt_inst; struct wdt_config wdt_cfg; wdt_get_config_defaults(&wdt_cfg); wdt_init(&wdt_inst, WDT, &wdt_cfg); wdt_disable(&wdt_inst); #endif /* Initialize IOPORT */ ioport_init(); /* Initialize LEDs, turned off */ ioport_set_port_dir(LED_PORT, LED_MASK, IOPORT_DIR_OUTPUT); ioport_set_port_level(LED_PORT, LED_MASK, LED_INACTIVE); ioport_set_port_mode(LED_PORT, LED_MASK, IOPORT_MODE_DRIVE_STRENGTH); /* Initialize SW0 */ ioport_set_pin_dir(BUTTON_0_PIN, IOPORT_DIR_INPUT); ioport_set_pin_mode(BUTTON_0_PIN, IOPORT_MODE_PULLUP); #ifdef CONF_BOARD_EIC /* Set push button as external interrupt pin */ ioport_set_pin_peripheral_mode(BUTTON_0_EIC_PIN, BUTTON_0_EIC_PIN_MUX | IOPORT_MODE_PULLUP); #else /* Push button as input: already done, it's the default pin state */ #endif #if defined (CONF_BOARD_COM_PORT) ioport_set_pin_peripheral_mode(COM_PORT_RX_PIN, COM_PORT_RX_MUX); ioport_set_pin_peripheral_mode(COM_PORT_TX_PIN, COM_PORT_TX_MUX); #endif #ifdef CONF_BOARD_TWIMS0 ioport_set_pin_peripheral_mode(PIN_PA23B_TWIMS0_TWD, MUX_PA23B_TWIMS0_TWD); ioport_set_pin_peripheral_mode(PIN_PA24B_TWIMS0_TWCK, MUX_PA24B_TWIMS0_TWCK); #endif #ifdef CONF_BOARD_TWIMS3 ioport_set_pin_peripheral_mode(PIN_PB14C_TWIMS3_TWD, MUX_PB14C_TWIMS3_TWD); ioport_set_pin_peripheral_mode(PIN_PB15C_TWIMS3_TWCK, MUX_PB15C_TWIMS3_TWCK); #endif #ifdef CONF_BOARD_USART0 ioport_set_pin_peripheral_mode(EXT1_PIN_UART_RX, EXT1_UART_RX_MUX); ioport_set_pin_peripheral_mode(EXT1_PIN_UART_TX, EXT1_UART_TX_MUX); #endif #if (defined CONF_BOARD_USB_PORT) ioport_set_pin_peripheral_mode(PIN_PA25A_USBC_DM, MUX_PA25A_USBC_DM); ioport_set_pin_peripheral_mode(PIN_PA26A_USBC_DP, MUX_PA26A_USBC_DP); # if defined(CONF_BOARD_USB_VBUS_DETECT) ioport_set_pin_dir(USB_VBUS_PIN, IOPORT_DIR_INPUT); # endif # if defined(CONF_BOARD_USB_ID_DETECT) ioport_set_pin_dir(USB_ID_PIN, IOPORT_DIR_INPUT); # endif # if defined(CONF_BOARD_USB_VBUS_CONTROL) ioport_set_pin_dir(USB_VBOF_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(USB_VBOF_PIN, USB_VBOF_INACTIVE_LEVEL); # endif #endif #if defined(CONF_BOARD_SPI) || defined(CONF_BOARD_SD_MMC_SPI) ioport_set_pin_peripheral_mode(PIN_PA21A_SPI_MISO, MUX_PA21A_SPI_MISO); ioport_set_pin_peripheral_mode(PIN_PA22A_SPI_MOSI, MUX_PA22A_SPI_MOSI); ioport_set_pin_peripheral_mode(PIN_PC30B_SPI_SCK, MUX_PC30B_SPI_SCK); #ifdef CONF_BOARD_SD_MMC_SPI /* Setting SD detection pin */ ioport_set_pin_dir(SD_MMC_0_CD_GPIO, IOPORT_DIR_INPUT); ioport_set_pin_mode(SD_MMC_0_CD_GPIO, IOPORT_MODE_PULLUP); /* Setting SD CS pin */ ioport_set_pin_peripheral_mode(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS); #endif #ifdef CONF_BOARD_SPI_NPCS0 ioport_set_pin_peripheral_mode(PIN_PC03A_SPI_NPCS0, MUX_PC03A_SPI_NPCS0); #endif #ifdef CONF_BOARD_SPI_NPCS1 ioport_set_pin_peripheral_mode(PIN_PB13B_SPI_NPCS1, MUX_PB13B_SPI_NPCS1); #endif #ifdef CONF_BOARD_SPI_NPCS2 ioport_set_pin_peripheral_mode(PIN_PB11B_SPI_NPCS2, MUX_PB11B_SPI_NPCS2); #endif #endif #ifdef CONF_BOARD_DACC_VOUT ioport_set_pin_peripheral_mode(DACC_VOUT_PIN, DACC_VOUT_MUX); #endif #ifdef CONF_BOARD_ACIFC ioport_set_pin_peripheral_mode(PIN_PA06E_ACIFC_ACAN0, MUX_PA06E_ACIFC_ACAN0); ioport_set_pin_peripheral_mode(PIN_PA07E_ACIFC_ACAP0, MUX_PA07E_ACIFC_ACAP0); #endif }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT /* Disable the watchdog */ WDT->WDT_MR = WDT_MR_WDDIS; #endif /* Initialize IOPORTs */ ioport_init(); /* Configure the pins connected to LEDs as output and set their * default initial state to high (LEDs off). */ ioport_set_pin_dir(LED0_GPIO, IOPORT_DIR_OUTPUT); ioport_set_pin_level(LED0_GPIO, LED0_INACTIVE_LEVEL); ioport_set_pin_dir(LED1_GPIO, IOPORT_DIR_OUTPUT); ioport_set_pin_level(LED1_GPIO, LED0_INACTIVE_LEVEL); ioport_set_pin_dir(LED2_GPIO, IOPORT_DIR_OUTPUT); ioport_set_pin_level(LED2_GPIO, LED0_INACTIVE_LEVEL); /* Configure Push Button pins */ ioport_set_pin_input_mode(GPIO_PUSH_BUTTON_1, GPIO_PUSH_BUTTON_1_FLAGS, GPIO_PUSH_BUTTON_1_SENSE); ioport_set_pin_input_mode(GPIO_PUSH_BUTTON_2, GPIO_PUSH_BUTTON_2_FLAGS, GPIO_PUSH_BUTTON_2_SENSE); ioport_set_pin_input_mode(GPIO_PUSH_BUTTON_3, GPIO_PUSH_BUTTON_3_FLAGS, GPIO_PUSH_BUTTON_3_SENSE); ioport_set_pin_input_mode(GPIO_PUSH_BUTTON_4, GPIO_PUSH_BUTTON_4_FLAGS, GPIO_PUSH_BUTTON_4_SENSE); #ifdef CONF_BOARD_UART_CONSOLE /* Configure UART pins */ ioport_set_port_peripheral_mode(PINS_UART0_PORT, PINS_UART0, PINS_UART0_MASK); #endif #ifdef CONF_BOARD_PWM_LED0 /* Configure PWM LED0 pin */ ioport_set_pin_peripheral_mode(PIN_PWM_LED0_GPIO, PIN_PWM_LED0_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED1 /* Configure PWM LED1 pin */ ioport_set_pin_peripheral_mode(PIN_PWM_LED1_GPIO, PIN_PWM_LED1_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED2 /* Configure PWM LED2 pin */ ioport_set_pin_peripheral_mode(PIN_PWM_LED2_GPIO, PIN_PWM_LED2_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED3 /* Configure PWM LED3 pin */ ioport_set_pin_peripheral_mode(PIN_PWM_LED3_GPIO, PIN_PWM_LED3_FLAGS); #endif #ifdef CONF_BOARD_USART_RXD /* Configure USART RXD pin */ ioport_set_pin_peripheral_mode(PIN_USART1_RXD_IDX, PIN_USART1_RXD_FLAGS); #endif #ifdef CONF_BOARD_USART_TXD /* Configure USART TXD pin */ ioport_set_pin_peripheral_mode(PIN_USART1_TXD_IDX, PIN_USART1_TXD_FLAGS); #endif #ifdef CONF_BOARD_USART_CTS /* Configure USART CTS pin */ ioport_set_pin_peripheral_mode(PIN_USART1_CTS_IDX, PIN_USART1_CTS_FLAGS); #endif #ifdef CONF_BOARD_USART_RTS /* Configure USART RTS pin */ ioport_set_pin_peripheral_mode(PIN_USART1_RTS_IDX, PIN_USART1_RTS_FLAGS); #endif #ifdef CONF_BOARD_USART_SCK /* Configure USART synchronous communication SCK pin */ ioport_set_pin_peripheral_mode(PIN_USART1_SCK_IDX, PIN_USART1_SCK_FLAGS); #endif #ifdef CONF_BOARD_ADM3312_EN /* Configure ADM3312 enable pin */ ioport_set_pin_dir(PIN_USART1_EN_IDX, IOPORT_DIR_OUTPUT); #ifdef CONF_BOARD_ADM3312_EN_DISABLE_AT_INIT ioport_set_pin_level(PIN_USART1_EN_IDX, PIN_USART1_EN_INACTIVE_LEVEL); #else ioport_set_pin_level(PIN_USART1_EN_IDX, PIN_USART1_EN_ACTIVE_LEVEL); #endif #endif #ifdef CONF_BOARD_CAN0 /* Configure the CAN0 TX and RX pins. */ ioport_set_pin_peripheral_mode(PIN_CAN0_RX_IDX, PIN_CAN0_RX_FLAGS); ioport_set_pin_peripheral_mode(PIN_CAN0_TX_IDX, PIN_CAN0_TX_FLAGS); /* Configure the transiver0 RS & EN pins. */ ioport_set_pin_dir(PIN_CAN0_TR_RS_IDX, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(PIN_CAN0_TR_EN_IDX, IOPORT_DIR_OUTPUT); #endif #ifdef CONF_BOARD_CAN1 /* Configure the CAN1 TX and RX pin. */ ioport_set_pin_peripheral_mode(PIN_CAN1_RX_IDX, PIN_CAN1_RX_FLAGS); ioport_set_pin_peripheral_mode(PIN_CAN1_TX_IDX, PIN_CAN1_TX_FLAGS); /* Configure the transiver1 RS & EN pins. */ ioport_set_pin_dir(PIN_CAN1_TR_RS_IDX, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(PIN_CAN1_TR_EN_IDX, IOPORT_DIR_OUTPUT); #endif #if defined(CONF_BOARD_USB_PORT) # if defined(CONF_BOARD_USB_VBUS_DETECT) gpio_configure_pin(USB_VBUS_PIN, USB_VBUS_FLAGS); # endif #endif #ifdef CONF_BOARD_SPI ioport_set_pin_peripheral_mode(SPI_MISO_GPIO, SPI_MISO_FLAGS); ioport_set_pin_peripheral_mode(SPI_MOSI_GPIO, SPI_MOSI_FLAGS); ioport_set_pin_peripheral_mode(SPI_SPCK_GPIO, SPI_SPCK_FLAGS); #ifdef CONF_BOARD_SPI_NPCS0 ioport_set_pin_peripheral_mode(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS); #endif #ifdef CONF_BOARD_SPI_NPCS3 #if defined(CONF_BOARD_SPI_NPCS3_GPIO) && defined(CONF_BOARD_SPI_NPCS3_FLAGS) ioport_set_pin_peripheral_mode(CONF_BOARD_SPI_NPCS3_GPIO, CONF_BOARD_SPI_NPCS3_FLAGS); #else ioport_set_pin_peripheral_mode(SPI_NPCS3_PA5_GPIO, SPI_NPCS3_PA5_FLAGS); #endif #endif #endif #ifdef CONF_BOARD_TWI0 ioport_set_pin_peripheral_mode(TWI0_DATA_GPIO, TWI0_DATA_FLAGS); ioport_set_pin_peripheral_mode(TWI0_CLK_GPIO, TWI0_CLK_FLAGS); #endif #if defined (CONF_BOARD_SD_MMC_HSMCI) /* Configure HSMCI pins */ ioport_set_pin_peripheral_mode(PIN_HSMCI_MCCDA_GPIO, PIN_HSMCI_MCCDA_FLAGS); ioport_set_pin_peripheral_mode(PIN_HSMCI_MCCK_GPIO, PIN_HSMCI_MCCK_FLAGS); ioport_set_pin_peripheral_mode(PIN_HSMCI_MCDA0_GPIO, PIN_HSMCI_MCDA0_FLAGS); ioport_set_pin_peripheral_mode(PIN_HSMCI_MCDA1_GPIO, PIN_HSMCI_MCDA1_FLAGS); ioport_set_pin_peripheral_mode(PIN_HSMCI_MCDA2_GPIO, PIN_HSMCI_MCDA2_FLAGS); ioport_set_pin_peripheral_mode(PIN_HSMCI_MCDA3_GPIO, PIN_HSMCI_MCDA3_FLAGS); /* Configure SD/MMC card detect pin */ ioport_set_pin_peripheral_mode(SD_MMC_0_CD_GPIO, SD_MMC_0_CD_FLAGS); #endif #ifdef CONF_BOARD_TWI1 ioport_set_pin_peripheral_mode(TWI1_DATA_GPIO, TWI1_DATA_FLAGS); ioport_set_pin_peripheral_mode(TWI1_CLK_GPIO, TWI1_CLK_FLAGS); #endif #ifdef CONF_BOARD_KSZ8051MNL ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXC_IDX, PIN_KSZ8051MNL_RXC_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_TXC_IDX, PIN_KSZ8051MNL_TXC_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_TXEN_IDX, PIN_KSZ8051MNL_TXEN_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_TXD3_IDX, PIN_KSZ8051MNL_TXD3_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_TXD2_IDX, PIN_KSZ8051MNL_TXD2_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_TXD1_IDX, PIN_KSZ8051MNL_TXD1_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_TXD0_IDX, PIN_KSZ8051MNL_TXD0_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXD3_IDX, PIN_KSZ8051MNL_RXD3_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXD2_IDX, PIN_KSZ8051MNL_RXD2_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXD1_IDX, PIN_KSZ8051MNL_RXD1_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXD0_IDX, PIN_KSZ8051MNL_RXD0_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXER_IDX, PIN_KSZ8051MNL_RXER_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXDV_IDX, PIN_KSZ8051MNL_RXDV_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_CRS_IDX, PIN_KSZ8051MNL_CRS_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_COL_IDX, PIN_KSZ8051MNL_COL_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_MDC_IDX, PIN_KSZ8051MNL_MDC_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_MDIO_IDX, PIN_KSZ8051MNL_MDIO_FLAGS); ioport_set_pin_dir(PIN_KSZ8051MNL_INTRP_IDX, IOPORT_DIR_INPUT); #endif #ifdef CONF_BOARD_TFDU4300_SD /* Configure IrDA transceiver shutdown pin */ ioport_set_pin_dir(PIN_IRDA_SD_IDX, IOPORT_DIR_OUTPUT); ioport_set_pin_level(PIN_IRDA_SD_IDX, IOPORT_PIN_LEVEL_HIGH); #endif #ifdef CONF_BOARD_ADM3485_RE /* Configure RS485 transceiver RE pin */ ioport_set_pin_dir(PIN_RE_IDX, IOPORT_DIR_OUTPUT); ioport_set_pin_level(PIN_RE_IDX, IOPORT_PIN_LEVEL_LOW); #endif #ifdef CONF_BOARD_ISO7816_RST /* Configure ISO7816 card reset pin */ ioport_set_pin_dir(PIN_ISO7816_RST_IDX, IOPORT_DIR_OUTPUT); ioport_set_pin_level(PIN_ISO7816_RST_IDX, IOPORT_PIN_LEVEL_LOW); #endif #ifdef CONF_BOARD_ISO7816 /* Configure ISO7816 interface TXD & SCK pin */ ioport_set_pin_peripheral_mode(PIN_USART1_TXD_IDX, PIN_USART1_TXD_FLAGS); ioport_set_pin_peripheral_mode(PIN_USART1_SCK_IDX, PIN_USART1_SCK_FLAGS); #endif }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT wdt_disable(WDT); #endif /* GPIO has been deprecated, the old code just keeps it for compatibility. * In new designs IOPORT is used instead. * Here IOPORT must be initialized for others to use before setting up IO. */ ioport_init(); /* Initialize LED0, turned off */ ioport_set_pin_level(LED_0_PIN, !LED_0_ACTIVE); ioport_set_pin_dir(LED_0_PIN, IOPORT_DIR_OUTPUT); /* USART TXD PIN */ ioport_set_pin_dir(USART_TXD_PIN, IOPORT_DIR_OUTPUT); /* Initialize SW0 */ ioport_set_pin_dir(BUTTON_0_PIN, IOPORT_DIR_INPUT); ioport_set_pin_mode(BUTTON_0_PIN, (BUTTON_0_ACTIVE ? IOPORT_MODE_PULLDOWN : IOPORT_MODE_PULLUP)); /* Initialize EXT3 LED0, LED1 & LED2, turned off */ ioport_set_pin_level(IO1_LED1_PIN, !IO1_LED1_ACTIVE); ioport_set_pin_dir(IO1_LED1_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(IO1_LED2_PIN, !IO1_LED2_ACTIVE); ioport_set_pin_dir(IO1_LED2_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(IO1_LED3_PIN, !IO1_LED3_ACTIVE); ioport_set_pin_dir(IO1_LED3_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(PERIODE_PIN, IOPORT_DIR_OUTPUT); //Compass gpio_configure_pin(I2C_SCL_PIN, TWI0_CLK_FLAGS); gpio_configure_pin(I2C_SDA_PIN, TWI0_DATA_FLAGS); #ifdef CONF_BOARD_UART_CONSOLE /* Configure UART pins */ gpio_configure_group(PINS_UART1_PIO, PINS_UART1, PINS_UART1_FLAGS); #endif #ifdef CONF_BOARD_TWI0 gpio_configure_pin(TWI0_DATA_GPIO, TWI0_DATA_FLAGS); gpio_configure_pin(TWI0_CLK_GPIO, TWI0_CLK_FLAGS); #endif /* Configure SPI pins */ #ifdef CONF_BOARD_SPI gpio_configure_pin(SPI_MISO_GPIO, SPI_MISO_FLAGS); gpio_configure_pin(SPI_MOSI_GPIO, SPI_MOSI_FLAGS); gpio_configure_pin(SPI_SPCK_GPIO, SPI_SPCK_FLAGS); /** * For NPCS 1, 2, and 3, different PINs can be used to access the same NPCS line. * Depending on the application requirements, the default PIN may not be available. * Hence a different PIN should be selected using the CONF_BOARD_SPI_NPCS_GPIO and * CONF_BOARD_SPI_NPCS_FLAGS macros. */ #ifdef CONF_BOARD_SPI_NPCS0 gpio_configure_pin(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS); #endif #ifdef CONF_BOARD_SPI_NPCS1 #if defined(CONF_BOARD_SPI_NPCS1_GPIO) && defined(CONF_BOARD_SPI_NPCS1_FLAGS) gpio_configure_pin(CONF_BOARD_SPI_NPCS1_GPIO, CONF_BOARD_SPI_NPCS1_FLAGS); #else gpio_configure_pin(SPI_NPCS1_PA9_GPIO, SPI_NPCS1_PA9_FLAGS); #endif #endif #ifdef CONF_BOARD_SPI_NPCS2 #if defined(CONF_BOARD_SPI_NPCS2_GPIO) && defined(CONF_BOARD_SPI_NPCS2_FLAGS) gpio_configure_pin(CONF_BOARD_SPI_NPCS2_GPIO, CONF_BOARD_SPI_NPCS2_FLAGS); #else gpio_configure_pin(SPI_NPCS2_PA10_GPIO, SPI_NPCS2_PA10_FLAGS); #endif #endif #ifdef CONF_BOARD_SPI_NPCS3 #if defined(CONF_BOARD_SPI_NPCS3_GPIO) && defined(CONF_BOARD_SPI_NPCS3_FLAGS) gpio_configure_pin(CONF_BOARD_SPI_NPCS3_GPIO, CONF_BOARD_SPI_NPCS3_FLAGS); #else gpio_configure_pin(SPI_NPCS3_PA22_GPIO, SPI_NPCS3_PA22_FLAGS); #endif #endif #endif /* CONF_BOARD_SPI */ #ifdef CONF_BOARD_OLED_UG_2832HSWEG04 gpio_configure_pin(UG_2832HSWEG04_DATA_CMD_GPIO, UG_2832HSWEG04_DATA_CMD_FLAGS); gpio_configure_pin(UG_2832HSWEG04_RESET_GPIO, UG_2832HSWEG04_RESET_FLAGS); #endif #ifdef CONF_BOARD_SD_MMC_SPI gpio_configure_pin(SD_MMC_0_CD_GPIO, SD_MMC_0_CD_FLAGS); #endif if ( BUTTON_0_ACTIVE ) { ioport_set_pin_mode(BUTTON_0_PIN, IOPORT_MODE_PULLDOWN); } else { ioport_set_pin_mode(BUTTON_0_PIN, IOPORT_MODE_PULLUP); } #ifdef CONF_BOARD_AT86RFX gpio_configure_pin(AT86RFX_SPI_MISO, SPI_MISO_FLAGS); gpio_configure_pin(AT86RFX_SPI_MOSI, SPI_MOSI_FLAGS); gpio_configure_pin(AT86RFX_SPI_SCK, SPI_SPCK_FLAGS); gpio_configure_pin(AT86RFX_SPI_CS_PIN, AT86RFX_SPI_CS_FLAGS); /* Initialize TRX_RST and SLP_TR as GPIO. */ ioport_set_pin_dir(AT86RFX_RST_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(AT86RFX_RST_PIN, IOPORT_PIN_LEVEL_HIGH); ioport_set_pin_dir(AT86RFX_SLP_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(AT86RFX_SLP_PIN, IOPORT_PIN_LEVEL_HIGH); #endif }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT struct wdt_dev_inst wdt_inst; struct wdt_config wdt_cfg; wdt_get_config_defaults(&wdt_cfg); wdt_init(&wdt_inst, WDT, &wdt_cfg); wdt_disable(&wdt_inst); #endif /* Initialize IOPORT */ ioport_init(); /* Initialize LED0, turned off */ ioport_set_pin_dir(LED_0_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(LED_0_PIN, IOPORT_PIN_LEVEL_HIGH); /* Initialize SW0 */ ioport_set_pin_dir(BUTTON_0_PIN, IOPORT_DIR_INPUT); ioport_set_pin_mode(BUTTON_0_PIN, IOPORT_MODE_PULLUP); #ifdef CONF_BOARD_EIC /* Set push button as external interrupt pin */ ioport_set_pin_peripheral_mode(BUTTON_0_EIC_PIN, BUTTON_0_EIC_PIN_MUX | IOPORT_MODE_PULLUP); #else /* Push button as input: already done, it's the default pin state */ #endif #if (defined CONF_BOARD_BL) // Configure LCD backlight ioport_set_pin_dir(LCD_BL_GPIO, IOPORT_DIR_OUTPUT); ioport_set_pin_level(LCD_BL_GPIO, LCD_BL_INACTIVE_LEVEL); #endif #if defined (CONF_BOARD_COM_PORT) ioport_set_pin_peripheral_mode(COM_PORT_RX_PIN, COM_PORT_RX_MUX); ioport_set_pin_peripheral_mode(COM_PORT_TX_PIN, COM_PORT_TX_MUX); #endif #ifdef CONF_BOARD_TWIMS0 ioport_set_pin_peripheral_mode(PIN_PA23B_TWIMS0_TWD, MUX_PA23B_TWIMS0_TWD); ioport_set_pin_peripheral_mode(PIN_PA24B_TWIMS0_TWCK, MUX_PA24B_TWIMS0_TWCK); #endif #ifdef CONF_BOARD_TWIMS3 ioport_set_pin_peripheral_mode(PIN_PB14C_TWIMS3_TWD, MUX_PB14C_TWIMS3_TWD); ioport_set_pin_peripheral_mode(PIN_PB15C_TWIMS3_TWCK, MUX_PB15C_TWIMS3_TWCK); #endif #ifdef CONF_BOARD_USART0 ioport_set_pin_peripheral_mode(EXT1_PIN_UART_RX, EXT1_UART_RX_MUX); ioport_set_pin_peripheral_mode(EXT1_PIN_UART_TX, EXT1_UART_TX_MUX); #endif #if (defined CONF_BOARD_USB_PORT) ioport_set_pin_peripheral_mode(PIN_PA25A_USBC_DM, MUX_PA25A_USBC_DM); ioport_set_pin_peripheral_mode(PIN_PA26A_USBC_DP, MUX_PA26A_USBC_DP); # if defined(CONF_BOARD_USB_VBUS_DETECT) ioport_set_pin_dir(USB_VBUS_PIN, IOPORT_DIR_INPUT); # endif # if defined(CONF_BOARD_USB_ID_DETECT) ioport_set_pin_dir(USB_ID_PIN, IOPORT_DIR_INPUT); # endif # if defined(CONF_BOARD_USB_VBUS_CONTROL) ioport_set_pin_dir(USB_VBOF_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(USB_VBOF_PIN, USB_VBOF_INACTIVE_LEVEL); # endif #endif #ifdef CONF_BOARD_AT86RFX ioport_set_pin_peripheral_mode(AT86RFX_SPI_MISO, AT86RFX_SPI_MISO_FLAGS); ioport_set_pin_peripheral_mode(AT86RFX_SPI_MOSI, AT86RFX_SPI_MOSI_FLAGS); ioport_set_pin_peripheral_mode(AT86RFX_SPI_SCK, AT86RFX_SPI_SCK_FLAGS); ioport_set_pin_peripheral_mode(AT86RFX_SPI_CS_PIN, AT86RFX_SPI_CS_FLAGS); /* Initialize TRX_RST and SLP_TR as GPIO. */ ioport_set_pin_dir(AT86RFX_RST_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(AT86RFX_RST_PIN, IOPORT_PIN_LEVEL_HIGH); ioport_set_pin_dir(AT86RFX_SLP_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(AT86RFX_SLP_PIN, IOPORT_PIN_LEVEL_HIGH); #ifdef EXT_RF_FRONT_END_CTRL ioport_set_pin_dir(AT86RFX_CPS, IOPORT_DIR_OUTPUT); ioport_set_pin_level(AT86RFX_CPS, IOPORT_PIN_LEVEL_HIGH); ioport_set_pin_dir(AT86RFX_CSD, IOPORT_DIR_OUTPUT); ioport_set_pin_level(AT86RFX_CSD, IOPORT_PIN_LEVEL_HIGH); #endif #endif #if defined(CONF_BOARD_SPI) || defined(CONF_BOARD_SD_MMC_SPI) ioport_set_pin_peripheral_mode(PIN_PA21A_SPI_MISO, MUX_PA21A_SPI_MISO); ioport_set_pin_peripheral_mode(PIN_PA22A_SPI_MOSI, MUX_PA22A_SPI_MOSI); ioport_set_pin_peripheral_mode(PIN_PC30B_SPI_SCK, MUX_PC30B_SPI_SCK); #ifdef CONF_BOARD_SD_MMC_SPI /* Setting SD detection pin */ ioport_set_pin_dir(SD_MMC_0_CD_GPIO, IOPORT_DIR_INPUT); ioport_set_pin_mode(SD_MMC_0_CD_GPIO, IOPORT_MODE_PULLUP); /* Setting SD CS pin */ ioport_set_pin_peripheral_mode(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS); #endif #ifdef CONF_BOARD_SPI_NPCS0 ioport_set_pin_peripheral_mode(PIN_PC03A_SPI_NPCS0, MUX_PC03A_SPI_NPCS0); #endif #ifdef CONF_BOARD_SPI_NPCS1 ioport_set_pin_peripheral_mode(PIN_PB13B_SPI_NPCS1, MUX_PB13B_SPI_NPCS1); #endif #ifdef CONF_BOARD_SPI_NPCS2 ioport_set_pin_peripheral_mode(PIN_PB11B_SPI_NPCS2, MUX_PB11B_SPI_NPCS2); #endif #endif #ifdef CONF_BOARD_DACC_VOUT ioport_set_pin_peripheral_mode(DACC_VOUT_PIN, DACC_VOUT_MUX); #endif #ifdef CONF_BOARD_ACIFC ioport_set_pin_peripheral_mode(PIN_PA06E_ACIFC_ACAN0, MUX_PA06E_ACIFC_ACAN0); ioport_set_pin_peripheral_mode(PIN_PA07E_ACIFC_ACAP0, MUX_PA07E_ACIFC_ACAP0); #endif #ifdef CONF_BOARD_PARC ioport_set_pin_peripheral_mode(PIN_PA17D_PARC_PCCK, MUX_PA17D_PARC_PCCK); ioport_set_pin_peripheral_mode(PIN_PA09D_PARC_PCDATA0, MUX_PA09D_PARC_PCDATA0); ioport_set_pin_peripheral_mode(PIN_PA10D_PARC_PCDATA1, MUX_PA10D_PARC_PCDATA1); ioport_set_pin_peripheral_mode(PIN_PA11D_PARC_PCDATA2, MUX_PA11D_PARC_PCDATA2); ioport_set_pin_peripheral_mode(PIN_PA12D_PARC_PCDATA3, MUX_PA12D_PARC_PCDATA3); ioport_set_pin_peripheral_mode(PIN_PA13D_PARC_PCDATA4, MUX_PA13D_PARC_PCDATA4); ioport_set_pin_peripheral_mode(PIN_PA14D_PARC_PCDATA5, MUX_PA14D_PARC_PCDATA5); ioport_set_pin_peripheral_mode(PIN_PA15D_PARC_PCDATA6, MUX_PA15D_PARC_PCDATA6); ioport_set_pin_peripheral_mode(PIN_PA16D_PARC_PCDATA7, MUX_PA16D_PARC_PCDATA7); ioport_set_pin_peripheral_mode(PIN_PA18D_PARC_PCEN1, MUX_PA18D_PARC_PCEN1); ioport_set_pin_peripheral_mode(PIN_PA19D_PARC_PCEN2, MUX_PA19D_PARC_PCEN2); #endif #ifdef CONF_BOARD_OLED_UG_2832HSWEG04 ioport_set_pin_dir(UG_2832HSWEG04_DATA_CMD_GPIO, IOPORT_DIR_OUTPUT); ioport_set_pin_mode(UG_2832HSWEG04_DATA_CMD_GPIO, IOPORT_MODE_PULLUP); ioport_set_pin_dir(UG_2832HSWEG04_RESET_GPIO, IOPORT_DIR_OUTPUT); ioport_set_pin_mode(UG_2832HSWEG04_RESET_GPIO, IOPORT_MODE_PULLUP); #endif }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT /* Disable the watchdog */ WDT->WDT_MR = WDT_MR_WDDIS; #endif /* GPIO has been deprecated, the old code just keeps it for compatibility. * In new designs IOPORT is used instead. * Here IOPORT must be initialized for others to use before setting up IO. */ ioport_init(); /* Configure LED pins */ gpio_configure_pin(LED0_GPIO, LED0_FLAGS); gpio_configure_pin(LED1_GPIO, LED1_FLAGS); /* Configure Push Button pins */ gpio_configure_pin(GPIO_PUSH_BUTTON_1, GPIO_PUSH_BUTTON_1_FLAGS); gpio_configure_pin(GPIO_PUSH_BUTTON_2, GPIO_PUSH_BUTTON_2_FLAGS); #ifdef CONF_BOARD_UART_CONSOLE /* Configure UART pins */ gpio_configure_group(PINS_UART0_PIO, PINS_UART0, PINS_UART0_FLAGS); #endif /* Configure ADC example pins */ #ifdef CONF_BOARD_ADC /* TC TIOA configuration */ gpio_configure_pin(PIN_TC0_TIOA0,PIN_TC0_TIOA0_FLAGS); /* ADC Trigger configuration */ gpio_configure_pin(PINS_ADC_TRIG, PINS_ADC_TRIG_FLAG); /* PWMH0 configuration */ gpio_configure_pin(PIN_PWMC_PWMH0_TRIG, PIN_PWMC_PWMH0_TRIG_FLAG); #endif #ifdef CONF_BOARD_PWM_LED0 /* Configure PWM LED0 pin */ gpio_configure_pin(PIN_PWM_LED0_GPIO, PIN_PWM_LED0_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED1 /* Configure PWM LED1 pin */ gpio_configure_pin(PIN_PWM_LED1_GPIO, PIN_PWM_LED1_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED2 /* Configure PWM LED2 pin */ gpio_configure_pin(PIN_PWM_LED2_GPIO, PIN_PWM_LED2_FLAGS); #endif #ifdef CONF_BOARD_TWI0 gpio_configure_pin(TWI0_DATA_GPIO, TWI0_DATA_FLAGS); gpio_configure_pin(TWI0_CLK_GPIO, TWI0_CLK_FLAGS); #endif #ifdef CONF_BOARD_TWI1 gpio_configure_pin(TWI1_DATA_GPIO, TWI1_DATA_FLAGS); gpio_configure_pin(TWI1_CLK_GPIO, TWI1_CLK_FLAGS); #endif /* Configure SPI pins */ #ifdef CONF_BOARD_SPI gpio_configure_pin(SPI_MISO_GPIO, SPI_MISO_FLAGS); gpio_configure_pin(SPI_MOSI_GPIO, SPI_MOSI_FLAGS); gpio_configure_pin(SPI_SPCK_GPIO, SPI_SPCK_FLAGS); /** * For NPCS 1, 2, and 3, different PINs can be used to access the same NPCS line. * Depending on the application requirements, the default PIN may not be available. * Hence a different PIN should be selected using the CONF_BOARD_SPI_NPCS_GPIO and * CONF_BOARD_SPI_NPCS_FLAGS macros. */ # ifdef CONF_BOARD_SPI_NPCS0 gpio_configure_pin(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS); # endif # ifdef CONF_BOARD_SPI_NPCS1 # if defined(CONF_BOARD_SPI_NPCS1_GPIO) && defined(CONF_BOARD_SPI_NPCS1_FLAGS) gpio_configure_pin(CONF_BOARD_SPI_NPCS1_GPIO, CONF_BOARD_SPI_NPCS1_FLAGS); # else gpio_configure_pin(SPI_NPCS1_PA31_GPIO, SPI_NPCS1_PA31_FLAGS); # endif # endif # ifdef CONF_BOARD_SPI_NPCS2 # if defined(CONF_BOARD_SPI_NPCS2_GPIO) && defined(CONF_BOARD_SPI_NPCS2_FLAGS) gpio_configure_pin(CONF_BOARD_SPI_NPCS2_GPIO, CONF_BOARD_SPI_NPCS2_FLAGS); # else gpio_configure_pin(SPI_NPCS2_PA30_GPIO, SPI_NPCS2_PA30_FLAGS); # endif # endif # ifdef CONF_BOARD_SPI_NPCS3 # if defined(CONF_BOARD_SPI_NPCS3_GPIO) && defined(CONF_BOARD_SPI_NPCS3_FLAGS) gpio_configure_pin(CONF_BOARD_SPI_NPCS3_GPIO, CONF_BOARD_SPI_NPCS3_FLAGS); # else gpio_configure_pin(SPI_NPCS3_PA22_GPIO, SPI_NPCS3_PA22_FLAGS); # endif # endif #endif /* CONF_BOARD_SPI */ #ifdef CONF_BOARD_USART_RXD /* Configure USART RXD pin */ gpio_configure_pin(PIN_USART1_RXD_IDX, PIN_USART1_RXD_FLAGS); #endif #ifdef CONF_BOARD_USART_TXD /* Configure USART TXD pin */ gpio_configure_pin(PIN_USART1_TXD_IDX, PIN_USART1_TXD_FLAGS); #endif #ifdef CONF_BOARD_USART_CTS /* Configure USART CTS pin */ gpio_configure_pin(PIN_USART1_CTS_IDX, PIN_USART1_CTS_FLAGS); #endif #ifdef CONF_BOARD_USART_RTS /* Configure USART RTS pin */ gpio_configure_pin(PIN_USART1_RTS_IDX, PIN_USART1_RTS_FLAGS); #endif #ifdef CONF_BOARD_USART_SCK /* Configure USART synchronous communication SCK pin */ gpio_configure_pin(PIN_USART1_SCK_IDX, PIN_USART1_SCK_FLAGS); #endif #ifdef CONF_BOARD_ADM3312_EN /* Configure ADM33312 enable pin */ gpio_configure_pin(PIN_USART1_EN_IDX, PIN_USART1_EN_FLAGS); gpio_set_pin_low(PIN_USART1_EN_IDX); #endif #ifdef CONF_BOARD_TFDU4300_SD /* Configure IrDA transceiver shutdown pin */ gpio_configure_pin(PIN_IRDA_SD_IDX, PIN_IRDA_SD_FLAGS); gpio_set_pin_low(PIN_IRDA_SD_IDX); #endif #ifdef CONF_BOARD_ADM3485_RE /* Configure RS485 transceiver RE pin */ gpio_configure_pin(PIN_RE_IDX, PIN_RE_FLAGS); gpio_set_pin_low(PIN_RE_IDX); #endif #ifdef CONF_BOARD_ILI9325 /* Configure LCD EBI pins */ gpio_configure_pin(PIN_EBI_DATA_BUS_D0, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D1, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D2, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D3, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D4, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D5, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D6, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_DATA_BUS_D7, PIN_EBI_DATA_BUS_FLAGS); gpio_configure_pin(PIN_EBI_NRD, PIN_EBI_NRD_FLAGS); gpio_configure_pin(PIN_EBI_NWE, PIN_EBI_NWE_FLAGS); gpio_configure_pin(PIN_EBI_NCS1, PIN_EBI_NCS1_FLAGS); gpio_configure_pin(PIN_EBI_LCD_RS, PIN_EBI_LCD_RS_FLAGS); #endif #ifdef CONF_BOARD_AAT3155 /* Configure Backlight control pin */ gpio_configure_pin(BOARD_AAT31XX_SET_GPIO, BOARD_AAT31XX_SET_FLAGS); #endif #ifdef CONF_BOARD_ADS7843 /* Configure Touchscreen SPI pins */ gpio_configure_pin(BOARD_ADS7843_IRQ_GPIO,BOARD_ADS7843_IRQ_FLAGS); gpio_configure_pin(BOARD_ADS7843_BUSY_GPIO, BOARD_ADS7843_BUSY_FLAGS); gpio_configure_pin(SPI_MISO_GPIO, SPI_MISO_FLAGS); gpio_configure_pin(SPI_MOSI_GPIO, SPI_MOSI_FLAGS); gpio_configure_pin(SPI_SPCK_GPIO, SPI_SPCK_FLAGS); gpio_configure_pin(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS); #endif #ifdef CONF_BOARD_MMA7341L /* Configure MMA7341L mode set control pin */ gpio_configure_pin(PIN_MMA7341L_MODE, PIN_MMA7341L_MODE_FLAG); /* Configure MMA7341L x,y,z axis output voltage pin */ gpio_configure_pin(PIN_MMA7341L_X_AXIS, PIN_MMA7341L_X_AXIS_FLAG); gpio_configure_pin(PIN_MMA7341L_Y_AXIS, PIN_MMA7341L_Y_AXIS_FLAG); gpio_configure_pin(PIN_MMA7341L_Z_AXIS, PIN_MMA7341L_Z_AXIS_FLAG); #endif #ifdef CONF_BOARD_ISO7816_RST /* Configure ISO7816 card reset pin */ gpio_configure_pin(PIN_ISO7816_RST_IDX, PIN_ISO7816_RST_FLAG); #endif #ifdef CONF_BOARD_ISO7816 /* Configure ISO7816 interface TXD & SCK pin */ gpio_configure_pin(PIN_USART1_TXD_IDX, PIN_USART1_TXD_FLAGS); gpio_configure_pin(PIN_USART1_SCK_IDX, PIN_USART1_SCK_FLAGS); #endif #ifdef CONF_BOARD_NAND gpio_configure_pin(PIN_EBI_NANDOE, PIN_EBI_NANDOE_FLAGS); gpio_configure_pin(PIN_EBI_NANDWE, PIN_EBI_NANDWE_FLAGS); gpio_configure_pin(PIN_EBI_NANDCLE, PIN_EBI_NANDCLE_FLAGS); gpio_configure_pin(PIN_EBI_NANDALE, PIN_EBI_NANDALE_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_0, PIN_EBI_NANDIO_0_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_1, PIN_EBI_NANDIO_1_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_2, PIN_EBI_NANDIO_2_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_3, PIN_EBI_NANDIO_3_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_4, PIN_EBI_NANDIO_4_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_5, PIN_EBI_NANDIO_5_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_6, PIN_EBI_NANDIO_6_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_7, PIN_EBI_NANDIO_7_FLAGS); gpio_configure_pin(PIN_NF_CE_IDX, PIN_NF_CE_FLAGS); gpio_configure_pin(PIN_NF_RB_IDX, PIN_NF_RB_FLAGS); #endif #if defined (CONF_BOARD_SD_MMC_HSMCI) /* Configure HSMCI pins */ gpio_configure_pin(PIN_HSMCI_MCCDA_GPIO, PIN_HSMCI_MCCDA_FLAGS); gpio_configure_pin(PIN_HSMCI_MCCK_GPIO, PIN_HSMCI_MCCK_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA0_GPIO, PIN_HSMCI_MCDA0_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA1_GPIO, PIN_HSMCI_MCDA1_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA2_GPIO, PIN_HSMCI_MCDA2_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA3_GPIO, PIN_HSMCI_MCDA3_FLAGS); /* Configure SD/MMC card detect pin */ gpio_configure_pin(SD_MMC_0_CD_GPIO, SD_MMC_0_CD_FLAGS); #endif #if defined(CONF_BOARD_USB_PORT) # if defined(CONF_BOARD_USB_VBUS_DETECT) gpio_configure_pin(USB_VBUS_PIN, USB_VBUS_FLAGS); # endif #endif }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT wdt_disable(WDT); #endif /* GPIO has been deprecated, the old code just keeps it for compatibility. * In new designs IOPORT is used instead. * Here IOPORT must be initialized for others to use before setting up IO. */ ioport_init(); /* Initialize LED0, turned off */ ioport_set_pin_level(LED_0_PIN, !LED_0_ACTIVE); ioport_set_pin_dir(LED_0_PIN, IOPORT_DIR_OUTPUT); /* Initialize SW0 */ ioport_set_pin_dir(BUTTON_0_PIN, IOPORT_DIR_INPUT); ioport_set_pin_mode(BUTTON_0_PIN, (BUTTON_0_ACTIVE ? IOPORT_MODE_PULLDOWN : IOPORT_MODE_PULLUP)); /* Initialize EXT3 LED0, LED1 & LED2, turned off */ ioport_set_pin_level(IO1_LED1_PIN, !IO1_LED1_ACTIVE); ioport_set_pin_dir(IO1_LED1_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(IO1_LED2_PIN, !IO1_LED2_ACTIVE); ioport_set_pin_dir(IO1_LED2_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(IO1_LED3_PIN, !IO1_LED3_ACTIVE); ioport_set_pin_dir(IO1_LED3_PIN, IOPORT_DIR_OUTPUT); #ifdef CONF_BOARD_UART_CONSOLE /* Configure UART pins */ gpio_configure_group(PINS_UART1_PIO, PINS_UART1, PINS_UART1_FLAGS); #endif #ifdef CONF_BOARD_TWI0 gpio_configure_pin(TWI0_DATA_GPIO, TWI0_DATA_FLAGS); gpio_configure_pin(TWI0_CLK_GPIO, TWI0_CLK_FLAGS); #endif /* Configure SPI pins */ #ifdef CONF_BOARD_SPI gpio_configure_pin(SPI_MISO_GPIO, SPI_MISO_FLAGS); gpio_configure_pin(SPI_MOSI_GPIO, SPI_MOSI_FLAGS); gpio_configure_pin(SPI_SPCK_GPIO, SPI_SPCK_FLAGS); /** * For NPCS 1, 2, and 3, different PINs can be used to access the same NPCS line. * Depending on the application requirements, the default PIN may not be available. * Hence a different PIN should be selected using the CONF_BOARD_SPI_NPCS_GPIO and * CONF_BOARD_SPI_NPCS_FLAGS macros. */ #ifdef CONF_BOARD_SPI_NPCS0 gpio_configure_pin(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS); #endif #ifdef CONF_BOARD_SPI_NPCS1 #if defined(CONF_BOARD_SPI_NPCS1_GPIO) && defined(CONF_BOARD_SPI_NPCS1_FLAGS) gpio_configure_pin(CONF_BOARD_SPI_NPCS1_GPIO, CONF_BOARD_SPI_NPCS1_FLAGS); #else gpio_configure_pin(SPI_NPCS1_PA9_GPIO, SPI_NPCS1_PA9_FLAGS); #endif #endif #ifdef CONF_BOARD_SPI_NPCS2 #if defined(CONF_BOARD_SPI_NPCS2_GPIO) && defined(CONF_BOARD_SPI_NPCS2_FLAGS) gpio_configure_pin(CONF_BOARD_SPI_NPCS2_GPIO, CONF_BOARD_SPI_NPCS2_FLAGS); #else gpio_configure_pin(SPI_NPCS2_PA10_GPIO, SPI_NPCS2_PA10_FLAGS); #endif #endif #ifdef CONF_BOARD_SPI_NPCS3 #if defined(CONF_BOARD_SPI_NPCS3_GPIO) && defined(CONF_BOARD_SPI_NPCS3_FLAGS) gpio_configure_pin(CONF_BOARD_SPI_NPCS3_GPIO, CONF_BOARD_SPI_NPCS3_FLAGS); #else gpio_configure_pin(SPI_NPCS3_PA22_GPIO, SPI_NPCS3_PA22_FLAGS); #endif #endif #endif /* CONF_BOARD_SPI */ #ifdef CONF_BOARD_OLED_UG_2832HSWEG04 gpio_configure_pin(UG_2832HSWEG04_DATA_CMD_GPIO, UG_2832HSWEG04_DATA_CMD_FLAGS); gpio_configure_pin(UG_2832HSWEG04_RESET_GPIO, UG_2832HSWEG04_RESET_FLAGS); #endif #ifdef CONF_BOARD_SD_MMC_SPI gpio_configure_pin(SD_MMC_0_CD_GPIO, SD_MMC_0_CD_FLAGS); #endif // CUSTOMIZATION: initialization values added // // The HSMCI pins must be initialized in order to access the full sized SD // card slot on the SAM4S Xplained Pro board. #ifdef CONF_BOARD_SD_MMC_HSMCI gpio_configure_pin(PIN_HSMCI_MCCDA_GPIO, PIN_HSMCI_MCCDA_FLAGS); gpio_configure_pin(PIN_HSMCI_MCCK_GPIO, PIN_HSMCI_MCCK_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA0_GPIO, PIN_HSMCI_MCDA0_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA1_GPIO, PIN_HSMCI_MCDA1_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA2_GPIO, PIN_HSMCI_MCDA2_FLAGS); gpio_configure_pin(PIN_HSMCI_MCDA3_GPIO, PIN_HSMCI_MCDA3_FLAGS); /* Configure SD/MMC card detect pin */ gpio_configure_pin(SD_MMC_0_CD_GPIO, SD_MMC_0_CD_FLAGS); #endif // CUSTOMIZATION: initialization values added #ifdef CONF_BOARD_NAND gpio_configure_pin(PIN_EBI_NANDOE, PIN_EBI_NANDOE_FLAGS); gpio_configure_pin(PIN_EBI_NANDWE, PIN_EBI_NANDWE_FLAGS); gpio_configure_pin(PIN_EBI_NANDCLE, PIN_EBI_NANDCLE_FLAGS); gpio_configure_pin(PIN_EBI_NANDALE, PIN_EBI_NANDALE_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_0, PIN_EBI_NANDIO_0_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_1, PIN_EBI_NANDIO_1_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_2, PIN_EBI_NANDIO_2_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_3, PIN_EBI_NANDIO_3_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_4, PIN_EBI_NANDIO_4_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_5, PIN_EBI_NANDIO_5_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_6, PIN_EBI_NANDIO_6_FLAGS); gpio_configure_pin(PIN_EBI_NANDIO_7, PIN_EBI_NANDIO_7_FLAGS); gpio_configure_pin(PIN_NF_CE_IDX, PIN_NF_CE_FLAGS); gpio_configure_pin(PIN_NF_RB_IDX, PIN_NF_RB_FLAGS); #endif if ( BUTTON_0_ACTIVE ) { ioport_set_pin_mode(BUTTON_0_PIN, IOPORT_MODE_PULLDOWN); } else { ioport_set_pin_mode(BUTTON_0_PIN, IOPORT_MODE_PULLUP); } #ifdef CONF_BOARD_AT86RFX gpio_configure_pin(AT86RFX_SPI_MISO, SPI_MISO_FLAGS); gpio_configure_pin(AT86RFX_SPI_MOSI, SPI_MOSI_FLAGS); gpio_configure_pin(AT86RFX_SPI_SCK, SPI_SPCK_FLAGS); gpio_configure_pin(AT86RFX_SPI_CS_PIN, AT86RFX_SPI_CS_FLAGS); /* Initialize TRX_RST and SLP_TR as GPIO. */ ioport_set_pin_dir(AT86RFX_RST_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(AT86RFX_RST_PIN, IOPORT_PIN_LEVEL_HIGH); ioport_set_pin_dir(AT86RFX_SLP_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(AT86RFX_SLP_PIN, IOPORT_PIN_LEVEL_HIGH); #endif }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT struct wdt_dev_inst wdt_inst; struct wdt_config wdt_cfg; wdt_get_config_defaults(&wdt_cfg); wdt_init(&wdt_inst, WDT, &wdt_cfg); wdt_disable(&wdt_inst); #endif // Initialize IOPORTs ioport_init(); // Put all pins to default state (input & pull-up) uint32_t pin; for (pin = PIN_PA00; pin <= PIN_PC31; pin ++) { // Skip output pins to configure later if (pin == LED0_GPIO || pin == LCD_BL_GPIO #ifdef CONF_BOARD_RS485 || pin == RS485_USART_CTS_PIN #endif /* PA02 is not configured as it is driven by hardware configuration */ || pin == PIN_PA02) { continue; } ioport_set_pin_dir(pin, IOPORT_DIR_INPUT); ioport_set_pin_mode(pin, IOPORT_MODE_PULLUP); } /* Configure the pins connected to LEDs as output and set their * default initial state to high (LEDs off). */ ioport_set_pin_dir(LED0_GPIO, IOPORT_DIR_OUTPUT); ioport_set_pin_level(LED0_GPIO, LED0_INACTIVE_LEVEL); #ifdef CONF_BOARD_EIC // Set push button as external interrupt pin ioport_set_pin_peripheral_mode(GPIO_PUSH_BUTTON_EIC_PIN, GPIO_PUSH_BUTTON_EIC_PIN_MUX); ioport_set_pin_peripheral_mode(GPIO_UNIT_TEST_EIC_PIN, GPIO_UNIT_TEST_EIC_PIN_MUX); #else // Push button as input: already done, it's the default pin state #endif #if (defined CONF_BOARD_BL) // Configure LCD backlight ioport_set_pin_dir(LCD_BL_GPIO, IOPORT_DIR_OUTPUT); ioport_set_pin_level(LCD_BL_GPIO, LCD_BL_INACTIVE_LEVEL); #endif #if (defined CONF_BOARD_USB_PORT) ioport_set_pin_peripheral_mode(PIN_PA25A_USBC_DM, MUX_PA25A_USBC_DM); ioport_set_pin_peripheral_mode(PIN_PA26A_USBC_DP, MUX_PA26A_USBC_DP); # if defined(CONF_BOARD_USB_VBUS_DETECT) # if defined(USB_VBUS_EIC) ioport_set_pin_peripheral_mode(USB_VBUS_EIC, USB_VBUS_EIC_MUX|USB_VBUS_FLAGS); # elif defined(USB_VBUS_PIN) ioport_set_pin_dir(USB_VBUS_PIN, IOPORT_DIR_INPUT); # else # warning USB_VBUS pin not defined # endif # endif # if defined(CONF_BOARD_USB_ID_DETECT) # if defined(USB_ID_EIC) ioport_set_pin_peripheral_mode(USB_ID_EIC, USB_ID_EIC_MUX|USB_ID_FLAGS); # elif defined(USB_ID_PIN) ioport_set_pin_dir(USB_ID_PIN, IOPORT_DIR_INPUT); # else # warning USB_ID pin not defined # endif # endif # if defined(CONF_BOARD_USB_VBUS_CONTROL) # if defined(USB_VBOF_PIN) ioport_set_pin_dir(USB_VBOF_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(USB_VBOF_PIN, USB_VBOF_INACTIVE_LEVEL); # else # warning USB_VBOF pin not defined # endif # if defined(CONF_BOARD_USB_VBUS_ERR_DETECT) # if defined(USB_VBERR_EIC) ioport_set_pin_peripheral_mode(USB_VBERR_EIC, USB_VBERR_EIC_MUX|USB_VBERR_FLAGS); # elif defined(USB_VBERR_PIN) ioport_set_pin_dir(USB_VBERR_PIN, IOPORT_DIR_INPUT); # else # warning USB_VBERR pin not defined # endif # endif # endif /* !(defined CONF_BOARD_USB_NO_VBUS_CONTROL) */ #endif /* (defined CONF_BOARD_USB_PORT) */ #if defined (CONF_BOARD_COM_PORT) ioport_set_pin_peripheral_mode(COM_PORT_RX_PIN, COM_PORT_RX_MUX); ioport_set_pin_peripheral_mode(COM_PORT_TX_PIN, COM_PORT_TX_MUX); #endif #if defined (CONF_BOARD_BM_USART) ioport_set_pin_peripheral_mode(BM_USART_RX_PIN, BM_USART_RX_MUX); ioport_set_pin_peripheral_mode(BM_USART_TX_PIN, BM_USART_TX_MUX); #endif #ifdef CONF_BOARD_SPI ioport_set_pin_peripheral_mode(PIN_PC04A_SPI_MISO, MUX_PC04A_SPI_MISO); ioport_set_pin_peripheral_mode(PIN_PC05A_SPI_MOSI, MUX_PC05A_SPI_MOSI); ioport_set_pin_peripheral_mode(PIN_PC06A_SPI_SCK, MUX_PC06A_SPI_SCK); #ifdef CONF_BOARD_SPI_NPCS0 ioport_set_pin_peripheral_mode(PIN_PA02B_SPI_NPCS0, MUX_PA02B_SPI_NPCS0); #endif #ifdef CONF_BOARD_SPI_NPCS2 ioport_set_pin_peripheral_mode(PIN_PC00A_SPI_NPCS2, MUX_PC00A_SPI_NPCS2); #endif #ifdef CONF_BOARD_SPI_NPCS3 ioport_set_pin_peripheral_mode(PIN_PC01A_SPI_NPCS3, MUX_PC01A_SPI_NPCS3); #endif #endif #ifdef CONF_BOARD_RS485 ioport_set_pin_peripheral_mode(RS485_USART_RX_PIN, RS485_USART_RX_MUX); ioport_set_pin_peripheral_mode(RS485_USART_TX_PIN, RS485_USART_TX_MUX); ioport_set_pin_peripheral_mode(RS485_USART_RTS_PIN, RS485_USART_RTS_MUX); ioport_set_pin_dir(RS485_USART_CTS_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(RS485_USART_CTS_PIN, IOPORT_PIN_LEVEL_LOW); #endif #ifdef CONF_BOARD_TWIMS1 ioport_set_pin_peripheral_mode(TWIMS1_TWI_SCL_PIN, TWIMS1_TWI_SCL_MUX); ioport_set_pin_peripheral_mode(TWIMS1_TWI_SDA_PIN, TWIMS1_TWI_SDA_MUX); #endif #ifdef CONF_BOARD_USART0 ioport_set_pin_peripheral_mode(USART0_RX_PIN, USART0_RX_MUX); ioport_set_pin_peripheral_mode(USART0_TX_PIN, USART0_TX_MUX); #endif #ifdef CONF_BOARD_DACC_VOUT ioport_set_pin_peripheral_mode(DACC_VOUT_PIN, DACC_VOUT_MUX); #endif #ifdef CONF_BOARD_ACIFC ioport_set_pin_peripheral_mode(PIN_PA06E_ACIFC_ACAN0, MUX_PA06E_ACIFC_ACAN0); ioport_set_pin_peripheral_mode(PIN_PA07E_ACIFC_ACAP0, MUX_PA07E_ACIFC_ACAP0); #endif #ifdef CONF_BOARD_ABDACB_PORT ioport_set_pin_peripheral_mode(ABDACB_AUDIO0_PIN, ABDACB_AUDIO0_MUX); ioport_set_pin_peripheral_mode(ABDACB_AUDIO1_PIN, ABDACB_AUDIO1_MUX); #endif }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT /* Disable the watchdog */ WDT->WDT_MR = WDT_MR_WDDIS; #endif /* Initialize IOPORTs */ ioport_init(); /* Configure the pins connected to LEDs as output and set their * default initial state to high (LEDs off). */ ioport_set_pin_dir(LED0_GPIO, IOPORT_DIR_OUTPUT); ioport_set_pin_level(LED0_GPIO, LED0_INACTIVE_LEVEL); ioport_set_pin_dir(LED1_GPIO, IOPORT_DIR_OUTPUT); ioport_set_pin_level(LED1_GPIO, LED0_INACTIVE_LEVEL); ioport_set_pin_dir(LED2_GPIO, IOPORT_DIR_OUTPUT); ioport_set_pin_level(LED2_GPIO, LED0_INACTIVE_LEVEL); /* Configure Push Button pins */ ioport_set_pin_input_mode(GPIO_PUSH_BUTTON_1, GPIO_PUSH_BUTTON_1_FLAGS, GPIO_PUSH_BUTTON_1_SENSE); ioport_set_pin_input_mode(GPIO_PUSH_BUTTON_2, GPIO_PUSH_BUTTON_2_FLAGS, GPIO_PUSH_BUTTON_2_SENSE); ioport_set_pin_input_mode(GPIO_PUSH_BUTTON_3, GPIO_PUSH_BUTTON_3_FLAGS, GPIO_PUSH_BUTTON_3_SENSE); ioport_set_pin_input_mode(GPIO_PUSH_BUTTON_4, GPIO_PUSH_BUTTON_4_FLAGS, GPIO_PUSH_BUTTON_4_SENSE); #ifdef CONF_BOARD_UART_CONSOLE /* Configure UART pins */ ioport_set_port_peripheral_mode(PINS_UART0_PORT, PINS_UART0, PINS_UART0_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED0 /* Configure PWM LED0 pin */ ioport_set_pin_peripheral_mode(PIN_PWM_LED0_GPIO, PIN_PWM_LED0_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED1 /* Configure PWM LED1 pin */ ioport_set_pin_peripheral_mode(PIN_PWM_LED1_GPIO, PIN_PWM_LED1_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED2 /* Configure PWM LED2 pin */ ioport_set_pin_peripheral_mode(PIN_PWM_LED2_GPIO, PIN_PWM_LED2_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED3 /* Configure PWM LED3 pin */ ioport_set_pin_peripheral_mode(PIN_PWM_LED3_GPIO, PIN_PWM_LED3_FLAGS); #endif #ifdef CONF_BOARD_USART_RXD /* Configure USART RXD pin */ ioport_set_pin_peripheral_mode(PIN_USART1_RXD_IDX, PIN_USART1_RXD_FLAGS); #endif #ifdef CONF_BOARD_USART_TXD /* Configure USART TXD pin */ ioport_set_pin_peripheral_mode(PIN_USART1_TXD_IDX, PIN_USART1_TXD_FLAGS); #endif #ifdef CONF_BOARD_USART_CTS /* Configure USART CTS pin */ ioport_set_pin_peripheral_mode(PIN_USART1_CTS_IDX, PIN_USART1_CTS_FLAGS); #endif #ifdef CONF_BOARD_USART_RTS /* Configure USART RTS pin */ ioport_set_pin_peripheral_mode(PIN_USART1_RTS_IDX, PIN_USART1_RTS_FLAGS); #endif #ifdef CONF_BOARD_USART_SCK /* Configure USART synchronous communication SCK pin */ ioport_set_pin_peripheral_mode(PIN_USART1_SCK_IDX, PIN_USART1_SCK_FLAGS); #endif #ifdef CONF_BOARD_ADM3312_EN /* Configure ADM3312 enable pin */ ioport_set_pin_dir(PIN_USART1_EN_IDX, IOPORT_DIR_OUTPUT); #ifdef CONF_BOARD_ADM3312_EN_DISABLE_AT_INIT ioport_set_pin_level(PIN_USART1_EN_IDX, PIN_USART1_EN_INACTIVE_LEVEL); #else ioport_set_pin_level(PIN_USART1_EN_IDX, PIN_USART1_EN_ACTIVE_LEVEL); #endif #endif #ifdef CONF_BOARD_ADS7843 /* Configure Touchscreen SPI pins */ ioport_set_pin_dir(BOARD_ADS7843_IRQ_GPIO, IOPORT_DIR_INPUT); ioport_set_pin_mode(BOARD_ADS7843_IRQ_GPIO, BOARD_ADS7843_IRQ_FLAGS); ioport_set_pin_dir(BOARD_ADS7843_BUSY_GPIO, IOPORT_DIR_INPUT); ioport_set_pin_mode(BOARD_ADS7843_BUSY_GPIO, BOARD_ADS7843_BUSY_FLAGS); ioport_set_pin_peripheral_mode(SPI_MISO_GPIO, SPI_MISO_FLAGS); ioport_set_pin_peripheral_mode(SPI_MOSI_GPIO, SPI_MOSI_FLAGS); ioport_set_pin_peripheral_mode(SPI_SPCK_GPIO, SPI_SPCK_FLAGS); ioport_set_pin_peripheral_mode(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS); #endif #ifdef CONF_BOARD_CAN0 /* Configure the CAN0 TX and RX pins. */ ioport_set_pin_peripheral_mode(PIN_CAN0_RX_IDX, PIN_CAN0_RX_FLAGS); ioport_set_pin_peripheral_mode(PIN_CAN0_TX_IDX, PIN_CAN0_TX_FLAGS); /* Configure the transiver0 RS & EN pins. */ ioport_set_pin_dir(PIN_CAN0_TR_RS_IDX, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(PIN_CAN0_TR_EN_IDX, IOPORT_DIR_OUTPUT); #endif #ifdef CONF_BOARD_CAN1 /* Configure the CAN1 TX and RX pin. */ ioport_set_pin_peripheral_mode(PIN_CAN1_RX_IDX, PIN_CAN1_RX_FLAGS); ioport_set_pin_peripheral_mode(PIN_CAN1_TX_IDX, PIN_CAN1_TX_FLAGS); /* Configure the transiver1 RS & EN pins. */ ioport_set_pin_dir(PIN_CAN1_TR_RS_IDX, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(PIN_CAN1_TR_EN_IDX, IOPORT_DIR_OUTPUT); #endif #if defined(CONF_BOARD_USB_PORT) # if defined(CONF_BOARD_USB_VBUS_DETECT) gpio_configure_pin(USB_VBUS_PIN, USB_VBUS_FLAGS); # endif #endif #if defined(CONF_BOARD_ILI9325) || defined(CONF_BOARD_ILI93XX) /* Configure LCD EBI pins */ ioport_set_pin_peripheral_mode(PIN_EBI_DATA_BUS_D0,PIN_EBI_DATA_BUS_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_DATA_BUS_D1,PIN_EBI_DATA_BUS_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_DATA_BUS_D2,PIN_EBI_DATA_BUS_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_DATA_BUS_D3,PIN_EBI_DATA_BUS_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_DATA_BUS_D4,PIN_EBI_DATA_BUS_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_DATA_BUS_D5,PIN_EBI_DATA_BUS_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_DATA_BUS_D6,PIN_EBI_DATA_BUS_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_DATA_BUS_D7,PIN_EBI_DATA_BUS_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NRD,PIN_EBI_NRD_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NWE,PIN_EBI_NWE_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NCS1,PIN_EBI_NCS1_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_LCD_RS,PIN_EBI_LCD_RS_FLAGS); #endif #ifdef CONF_BOARD_AAT3155 /* Configure Backlight control pin */ ioport_set_pin_dir(BOARD_AAT31XX_SET_GPIO, IOPORT_DIR_OUTPUT); #endif #ifdef CONF_BOARD_SPI ioport_set_pin_peripheral_mode(SPI_MISO_GPIO, SPI_MISO_FLAGS); ioport_set_pin_peripheral_mode(SPI_MOSI_GPIO, SPI_MOSI_FLAGS); ioport_set_pin_peripheral_mode(SPI_SPCK_GPIO, SPI_SPCK_FLAGS); #ifdef CONF_BOARD_SPI_NPCS0 ioport_set_pin_peripheral_mode(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS); #endif #ifdef CONF_BOARD_SPI_NPCS3 #if defined(CONF_BOARD_SPI_NPCS3_GPIO) && defined(CONF_BOARD_SPI_NPCS3_FLAGS) ioport_set_pin_peripheral_mode(CONF_BOARD_SPI_NPCS3_GPIO, CONF_BOARD_SPI_NPCS3_FLAGS); #else ioport_set_pin_peripheral_mode(SPI_NPCS3_PA5_GPIO, SPI_NPCS3_PA5_FLAGS); #endif #endif #endif #if (defined(CONF_BOARD_TWI0) || defined(CONF_BOARD_QTOUCH)) ioport_set_pin_peripheral_mode(TWI0_DATA_GPIO, TWI0_DATA_FLAGS); ioport_set_pin_peripheral_mode(TWI0_CLK_GPIO, TWI0_CLK_FLAGS); #endif #if defined (CONF_BOARD_SD_MMC_HSMCI) /* Configure HSMCI pins */ ioport_set_pin_peripheral_mode(PIN_HSMCI_MCCDA_GPIO, PIN_HSMCI_MCCDA_FLAGS); ioport_set_pin_peripheral_mode(PIN_HSMCI_MCCK_GPIO, PIN_HSMCI_MCCK_FLAGS); ioport_set_pin_peripheral_mode(PIN_HSMCI_MCDA0_GPIO, PIN_HSMCI_MCDA0_FLAGS); ioport_set_pin_peripheral_mode(PIN_HSMCI_MCDA1_GPIO, PIN_HSMCI_MCDA1_FLAGS); ioport_set_pin_peripheral_mode(PIN_HSMCI_MCDA2_GPIO, PIN_HSMCI_MCDA2_FLAGS); ioport_set_pin_peripheral_mode(PIN_HSMCI_MCDA3_GPIO, PIN_HSMCI_MCDA3_FLAGS); /* Configure SD/MMC card detect pin */ ioport_set_pin_peripheral_mode(SD_MMC_0_CD_GPIO, SD_MMC_0_CD_FLAGS); #endif #ifdef CONF_BOARD_TWI1 ioport_set_pin_peripheral_mode(TWI1_DATA_GPIO, TWI1_DATA_FLAGS); ioport_set_pin_peripheral_mode(TWI1_CLK_GPIO, TWI1_CLK_FLAGS); #endif #ifdef CONF_BOARD_KSZ8051MNL ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXC_IDX, PIN_KSZ8051MNL_RXC_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_TXC_IDX, PIN_KSZ8051MNL_TXC_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_TXEN_IDX, PIN_KSZ8051MNL_TXEN_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_TXD3_IDX, PIN_KSZ8051MNL_TXD3_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_TXD2_IDX, PIN_KSZ8051MNL_TXD2_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_TXD1_IDX, PIN_KSZ8051MNL_TXD1_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_TXD0_IDX, PIN_KSZ8051MNL_TXD0_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXD3_IDX, PIN_KSZ8051MNL_RXD3_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXD2_IDX, PIN_KSZ8051MNL_RXD2_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXD1_IDX, PIN_KSZ8051MNL_RXD1_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXD0_IDX, PIN_KSZ8051MNL_RXD0_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXER_IDX, PIN_KSZ8051MNL_RXER_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_RXDV_IDX, PIN_KSZ8051MNL_RXDV_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_CRS_IDX, PIN_KSZ8051MNL_CRS_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_COL_IDX, PIN_KSZ8051MNL_COL_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_MDC_IDX, PIN_KSZ8051MNL_MDC_FLAGS); ioport_set_pin_peripheral_mode(PIN_KSZ8051MNL_MDIO_IDX, PIN_KSZ8051MNL_MDIO_FLAGS); ioport_set_pin_dir(PIN_KSZ8051MNL_INTRP_IDX, IOPORT_DIR_INPUT); #endif #ifdef CONF_BOARD_TFDU4300_SD /* Configure IrDA transceiver shutdown pin */ ioport_set_pin_dir(PIN_IRDA_SD_IDX, IOPORT_DIR_OUTPUT); ioport_set_pin_level(PIN_IRDA_SD_IDX, IOPORT_PIN_LEVEL_HIGH); #endif #ifdef CONF_BOARD_ADM3485_RE /* Configure RS485 transceiver RE pin */ ioport_set_pin_dir(PIN_RE_IDX, IOPORT_DIR_OUTPUT); ioport_set_pin_level(PIN_RE_IDX, IOPORT_PIN_LEVEL_LOW); #endif #ifdef CONF_BOARD_ISO7816_RST /* Configure ISO7816 card reset pin */ ioport_set_pin_dir(PIN_ISO7816_RST_IDX, IOPORT_DIR_OUTPUT); ioport_set_pin_level(PIN_ISO7816_RST_IDX, IOPORT_PIN_LEVEL_LOW); #endif #ifdef CONF_BOARD_ISO7816 /* Configure ISO7816 interface TXD & SCK pin */ ioport_set_pin_peripheral_mode(PIN_USART1_TXD_IDX, PIN_USART1_TXD_FLAGS); ioport_set_pin_peripheral_mode(PIN_USART1_SCK_IDX, PIN_USART1_SCK_FLAGS); #endif #ifdef CONF_BOARD_NAND ioport_set_pin_peripheral_mode(PIN_EBI_NANDOE, PIN_EBI_NANDOE_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NANDWE, PIN_EBI_NANDWE_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NANDCLE, PIN_EBI_NANDCLE_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NANDALE, PIN_EBI_NANDALE_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NANDIO_0, PIN_EBI_NANDIO_0_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NANDIO_1, PIN_EBI_NANDIO_1_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NANDIO_2, PIN_EBI_NANDIO_2_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NANDIO_3, PIN_EBI_NANDIO_3_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NANDIO_4, PIN_EBI_NANDIO_4_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NANDIO_5, PIN_EBI_NANDIO_5_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NANDIO_6, PIN_EBI_NANDIO_6_FLAGS); ioport_set_pin_peripheral_mode(PIN_EBI_NANDIO_7, PIN_EBI_NANDIO_7_FLAGS); ioport_set_pin_dir(PIN_NF_CE_IDX, IOPORT_DIR_OUTPUT); ioport_set_pin_dir(PIN_NF_RB_IDX, IOPORT_DIR_INPUT); ioport_set_pin_mode(PIN_NF_RB_IDX, IOPORT_MODE_PULLUP); #endif #ifdef CONF_BOARD_QTOUCH /* Configure CHANGE pin for QTouch device */ ioport_set_pin_input_mode(BOARD_QT_CHANGE_PIN_IDX, BOARD_QT_CHANGE_PIN_FLAGS, BOARD_QT_CHANGE_PIN_SENSE); #endif }
/* * Main program loop * */ int main (void) { char cCommand[64]; char cCommand_last[64]; memset(&cCommand, 0, sizeof(cCommand)); memset(&cCommand_last, 0, sizeof(cCommand_last)); cCommand[0] = '\0'; charcount = 0; struct ip_addr x_ip_addr, x_net_mask, x_gateway; sysclk_init(); board_init(); // Set up the GPIO pin for the Mater Select jumper ioport_init(); ioport_set_pin_dir(MASTER_SEL, IOPORT_DIR_INPUT); masterselect = ioport_get_pin_level(MASTER_SEL); // true = slave stacking_init(masterselect); // Initialise the stacking connector as either master or slave // Set the IRQ line as either master or slave if(masterselect) { ioport_set_pin_dir(SPI_IRQ1, IOPORT_DIR_OUTPUT); } else { ioport_set_pin_dir(SPI_IRQ1, IOPORT_DIR_INPUT); } irq_initialize_vectors(); // Initialize interrupt vector table support. cpu_irq_enable(); // Enable interrupts stdio_usb_init(); spi_init(); eeprom_init(); temp_init(); membag_init(); loadConfig(); // Load Config IP4_ADDR(&x_ip_addr, Zodiac_Config.IP_address[0], Zodiac_Config.IP_address[1],Zodiac_Config.IP_address[2], Zodiac_Config.IP_address[3]); IP4_ADDR(&x_net_mask, Zodiac_Config.netmask[0], Zodiac_Config.netmask[1],Zodiac_Config.netmask[2], Zodiac_Config.netmask[3]); IP4_ADDR(&x_gateway, Zodiac_Config.gateway_address[0], Zodiac_Config.gateway_address[1],Zodiac_Config.gateway_address[2], Zodiac_Config.gateway_address[3]); switch_init(); /* Initialize lwIP. */ lwip_init(); /* Add data to netif */ netif_add(&gs_net_if, &x_ip_addr, &x_net_mask, &x_gateway, NULL, ethernetif_init, ethernet_input); /* Make it the default interface */ netif_set_default(&gs_net_if); netif_set_up(&gs_net_if); // Telnet to be included in v0.63 //telnet_init(); /* Initialize timer. */ sys_init_timing(); int v,p; // Create port map for (v = 0;v < MAX_VLANS;v++) { if (Zodiac_Config.vlan_list[v].uActive == 1 && Zodiac_Config.vlan_list[v].uVlanType == 1) { for(p=0;p<4;p++) { if (Zodiac_Config.vlan_list[v].portmap[p] == 1) Zodiac_Config.of_port[p] = 1; // Port is assigned to an OpenFlow VLAN } } if (Zodiac_Config.vlan_list[v].uActive == 1 && Zodiac_Config.vlan_list[v].uVlanType == 2) { for(p=0;p<4;p++) { if (Zodiac_Config.vlan_list[v].portmap[p] == 1) { Zodiac_Config.of_port[p] = 0; // Port is assigned to a Native VLAN NativePortMatrix += 1<<p; } } } } while(1) { task_switch(&gs_net_if); task_command(cCommand, cCommand_last); // Only run the following tasks if set to Master if(masterselect == false) { sys_check_timeouts(); task_openflow(); } } }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT /* Disable the watchdog */ WDT->WDT_MR = WDT_MR_WDDIS; #endif /* GPIO has been deprecated, the old code just keeps it for compatibility. * In new designs IOPORT is used instead. * Here IOPORT must be initialized for others to use before setting up IO. */ ioport_init(); /* Configure LED pins */ gpio_configure_pin(LED0_GPIO, LED0_FLAGS); gpio_configure_pin(LED1_GPIO, LED1_FLAGS); gpio_configure_pin(LED2_GPIO, LED2_FLAGS); /* Configure Push Button pins */ gpio_configure_pin(GPIO_PUSH_BUTTON_1, GPIO_PUSH_BUTTON_1_FLAGS); gpio_configure_pin(GPIO_PUSH_BUTTON_2, GPIO_PUSH_BUTTON_2_FLAGS); #ifdef CONF_BOARD_UART_CONSOLE /* Configure UART pins */ gpio_configure_group(PINS_UART_PIO, PINS_UART, PINS_UART_FLAGS); #endif /* Configure ADC example pins */ #ifdef CONF_BOARD_ADC /* TC TIOA configuration */ gpio_configure_pin(PIN_TC0_TIOA0,PIN_TC0_TIOA0_FLAGS); /* ADC Trigger configuration */ gpio_configure_pin(PINS_ADC_TRIG, PINS_ADC_TRIG_FLAG); /* PWMH0 configuration */ gpio_configure_pin(PIN_PWMC_PWMH0_TRIG, PIN_PWMC_PWMH0_TRIG_FLAG); #endif #ifdef CONF_BOARD_PWM_LED0 /* Configure PWM LED0 pin */ gpio_configure_pin(PIN_PWM_LED0_GPIO, PIN_PWM_LED0_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED1 /* Configure PWM LED1 pin */ gpio_configure_pin(PIN_PWM_LED1_GPIO, PIN_PWM_LED1_FLAGS); #endif #ifdef CONF_BOARD_PWM_LED2 /* Configure PWM LED2 pin */ gpio_configure_pin(PIN_PWM_LED2_GPIO, PIN_PWM_LED2_FLAGS); #endif /* Configure SPI0 pins */ #ifdef CONF_BOARD_SPI0 gpio_configure_pin(SPI0_MISO_GPIO, SPI0_MISO_FLAGS); gpio_configure_pin(SPI0_MOSI_GPIO, SPI0_MOSI_FLAGS); gpio_configure_pin(SPI0_SPCK_GPIO, SPI0_SPCK_FLAGS); /** * For NPCS 1, 2, and 3, different PINs can be used to access the same * NPCS line. * Depending on the application requirements, the default PIN may not be * available. * Hence a different PIN should be selected using the * CONF_BOARD_SPI_NPCS_GPIO and * CONF_BOARD_SPI_NPCS_FLAGS macros. */ # ifdef CONF_BOARD_SPI0_NPCS0 gpio_configure_pin(SPI0_NPCS0_GPIO, SPI0_NPCS0_FLAGS); # endif # ifdef CONF_BOARD_SPI0_NPCS1 gpio_configure_pin(SPI0_NPCS1_PA29_GPIO,SPI0_NPCS1_PA29_FLAGS); # endif #endif // #ifdef CONF_BOARD_SPI0 /* Configure SPI1 pins */ #ifdef CONF_BOARD_SPI1 gpio_configure_pin(SPI1_MISO_GPIO, SPI1_MISO_FLAGS); gpio_configure_pin(SPI1_MOSI_GPIO, SPI1_MOSI_FLAGS); gpio_configure_pin(SPI1_SPCK_GPIO, SPI1_SPCK_FLAGS); # ifdef CONF_BOARD_SPI1_NPCS0 gpio_configure_pin(SPI1_NPCS0_GPIO, SPI1_NPCS0_FLAGS); # endif # ifdef CONF_BOARD_SPI1_NPCS1 gpio_configure_pin(SPI1_NPCS1_GPIO, SPI1_NPCS1_FLAGS); # endif # ifdef CONF_BOARD_SPI1_NPCS2 gpio_configure_pin(SPI1_NPCS2_GPIO, SPI1_NPCS2_FLAGS); # endif # ifdef CONF_BOARD_SPI1_NPCS3 gpio_configure_pin(SPI1_NPCS3_GPIO, SPI1_NPCS3_FLAGS); # endif #endif #ifdef CONF_BOARD_TWI0 gpio_configure_pin(TWI0_DATA_GPIO, TWI0_DATA_FLAGS); gpio_configure_pin(TWI0_CLK_GPIO, TWI0_CLK_FLAGS); #endif #ifdef CONF_BOARD_TWI1 gpio_configure_pin(TWI1_DATA_GPIO, TWI1_DATA_FLAGS); gpio_configure_pin(TWI1_CLK_GPIO, TWI1_CLK_FLAGS); #endif #ifdef CONF_BOARD_USART_RXD /* Configure USART RXD pin */ gpio_configure_pin(PIN_USART0_RXD_IDX, PIN_USART0_RXD_FLAGS); #endif #ifdef CONF_BOARD_USART_TXD /* Configure USART TXD pin */ gpio_configure_pin(PIN_USART0_TXD_IDX, PIN_USART0_TXD_FLAGS); #endif #ifdef CONF_BOARD_USB_PORT /* Configure USB_ID (UOTGID) pin */ gpio_configure_pin(USB_ID_GPIO, USB_ID_FLAGS); /* Configure USB_VBOF (UOTGVBOF) pin */ gpio_configure_pin(USB_VBOF_GPIO, USB_VBOF_FLAGS); #endif #ifdef CONF_BOARD_MMA7341L /* Configure MMA7341L mode set control pin */ gpio_configure_pin(PIN_MMA7341L_MODE, PIN_MMA7341L_MODE_FLAG); /* Configure MMA7341L x,y,z axis output voltage pin */ gpio_configure_pin(PIN_MMA7341L_X_AXIS, PIN_MMA7341L_X_AXIS_FLAG); gpio_configure_pin(PIN_MMA7341L_Y_AXIS, PIN_MMA7341L_Y_AXIS_FLAG); gpio_configure_pin(PIN_MMA7341L_Z_AXIS, PIN_MMA7341L_Z_AXIS_FLAG); #endif #ifdef CONF_BOARD_ADS7843 /* Configure Touchscreen SPI pins */ gpio_configure_pin(BOARD_ADS7843_IRQ_GPIO,BOARD_ADS7843_IRQ_FLAGS); gpio_configure_pin(BOARD_ADS7843_BUSY_GPIO, BOARD_ADS7843_BUSY_FLAGS); gpio_configure_pin(SPI0_MISO_GPIO, SPI0_MISO_FLAGS); gpio_configure_pin(SPI0_MOSI_GPIO, SPI0_MOSI_FLAGS); gpio_configure_pin(SPI0_SPCK_GPIO, SPI0_SPCK_FLAGS); gpio_configure_pin(SPI0_NPCS0_GPIO, SPI0_NPCS0_FLAGS); #endif }
void board_init(void) { #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT /* Disable the watchdog */ WDT->WDT_MR = WDT_MR_WDDIS; #endif /* GPIO has been deprecated, the old code just keeps it for compatibility. * In new designs IOPORT is used instead. * Here IOPORT must be initialized for others to use before setting up IO. */ ioport_init(); /* Configure LED pins */ gpio_configure_pin(LED0_GPIO, LED0_FLAGS); gpio_configure_pin(LED1_GPIO, LED1_FLAGS); /* Configure Push Button pins */ gpio_configure_pin(GPIO_PUSH_BUTTON_1, GPIO_PUSH_BUTTON_1_FLAGS); #ifdef CONF_BOARD_UART_CONSOLE /* Configure UART pins */ gpio_configure_group(PINS_UART0_PIO, PINS_UART0, PINS_UART0_FLAGS); #endif #ifdef CONF_BOARD_TWI0 gpio_configure_pin(TWI0_DATA_GPIO, TWI0_DATA_FLAGS); gpio_configure_pin(TWI0_CLK_GPIO, TWI0_CLK_FLAGS); #endif #ifdef CONF_BOARD_TWI1 gpio_configure_pin(TWI1_DATA_GPIO, TWI1_DATA_FLAGS); gpio_configure_pin(TWI1_CLK_GPIO, TWI1_CLK_FLAGS); #endif /* Configure SPI pins */ #ifdef CONF_BOARD_SPI gpio_configure_pin(SPI_MISO_GPIO, SPI_MISO_FLAGS); gpio_configure_pin(SPI_MOSI_GPIO, SPI_MOSI_FLAGS); gpio_configure_pin(SPI_SPCK_GPIO, SPI_SPCK_FLAGS); /** * For NPCS 1, 2, and 3, different PINs can be used to access the same NPCS line. * Depending on the application requirements, the default PIN may not be available. * Hence a different PIN should be selected using the CONF_BOARD_SPI_NPCS_GPIO and * CONF_BOARD_SPI_NPCS_FLAGS macros. */ #ifdef CONF_BOARD_SPI_NPCS0 gpio_configure_pin(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS); #endif #ifdef CONF_BOARD_SPI_NPCS1 #if defined(CONF_BOARD_SPI_NPCS1_GPIO) && defined(CONF_BOARD_SPI_NPCS1_FLAGS) gpio_configure_pin(CONF_BOARD_SPI_NPCS1_GPIO, CONF_BOARD_SPI_NPCS1_FLAGS); #else gpio_configure_pin(SPI_NPCS1_PA31_GPIO, SPI_NPCS1_PA31_FLAGS); #endif #endif #ifdef CONF_BOARD_SPI_NPCS2 #if defined(CONF_BOARD_SPI_NPCS2_GPIO) && defined(CONF_BOARD_SPI_NPCS2_FLAGS) gpio_configure_pin(CONF_BOARD_SPI_NPCS2_GPIO, CONF_BOARD_SPI_NPCS2_FLAGS); #else gpio_configure_pin(SPI_NPCS2_PA30_GPIO, SPI_NPCS2_PA30_FLAGS); #endif #endif #ifdef CONF_BOARD_SPI_NPCS3 #if defined(CONF_BOARD_SPI_NPCS3_GPIO) && defined(CONF_BOARD_SPI_NPCS3_FLAGS) gpio_configure_pin(CONF_BOARD_SPI_NPCS3_GPIO, CONF_BOARD_SPI_NPCS3_FLAGS); #else gpio_configure_pin(SPI_NPCS3_PA22_GPIO, SPI_NPCS3_PA22_FLAGS); #endif #endif #endif #ifdef CONF_BOARD_USART_RXD /* Configure USART RXD pin */ gpio_configure_pin(PIN_USART1_RXD_IDX, PIN_USART1_RXD_FLAGS); #endif #ifdef CONF_BOARD_USART_TXD /* Configure USART TXD pin */ gpio_configure_pin(PIN_USART1_TXD_IDX, PIN_USART1_TXD_FLAGS); #endif #ifdef CONF_BOARD_USART_CTS /* Configure USART CTS pin */ gpio_configure_pin(PIN_USART1_CTS_IDX, PIN_USART1_CTS_FLAGS); #endif #ifdef CONF_BOARD_USART_RTS /* Configure USART RTS pin */ gpio_configure_pin(PIN_USART1_RTS_IDX, PIN_USART1_RTS_FLAGS); #endif #ifdef CONF_BOARD_USART_SCK /* Configure USART synchronous communication SCK pin */ gpio_configure_pin(PIN_USART1_SCK_IDX, PIN_USART1_SCK_FLAGS); #endif #ifdef CONF_BOARD_SRAM pio_configure_pin(PIN_EBI_NCS0, PIN_EBI_NCS0_FLAGS); pio_configure_pin(PIN_EBI_NRD, PIN_EBI_NRD_FLAGS); pio_configure_pin(PIN_EBI_NWE, PIN_EBI_NWE_FLAGS); pio_configure_pin(PIN_EBI_DATA_BUS_D0, PIN_EBI_DATA_BUS_FLAGS); pio_configure_pin(PIN_EBI_DATA_BUS_D1, PIN_EBI_DATA_BUS_FLAGS); pio_configure_pin(PIN_EBI_DATA_BUS_D2, PIN_EBI_DATA_BUS_FLAGS); pio_configure_pin(PIN_EBI_DATA_BUS_D3, PIN_EBI_DATA_BUS_FLAGS); pio_configure_pin(PIN_EBI_DATA_BUS_D4, PIN_EBI_DATA_BUS_FLAGS); pio_configure_pin(PIN_EBI_DATA_BUS_D5, PIN_EBI_DATA_BUS_FLAGS); pio_configure_pin(PIN_EBI_DATA_BUS_D6, PIN_EBI_DATA_BUS_FLAGS); pio_configure_pin(PIN_EBI_DATA_BUS_D7, PIN_EBI_DATA_BUS_FLAGS); pio_configure_pin(PIN_EBI_ADDR_BUS_A0, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A1, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A2, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A3, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A4, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A5, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A6, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A7, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A8, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A9, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A10, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A11, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A12, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A13, PIN_EBI_ADDR_BUS_FLAG1); pio_configure_pin(PIN_EBI_ADDR_BUS_A14, PIN_EBI_ADDR_BUS_FLAG2); pio_configure_pin(PIN_EBI_ADDR_BUS_A15, PIN_EBI_ADDR_BUS_FLAG2); pio_configure_pin(PIN_EBI_ADDR_BUS_A16, PIN_EBI_ADDR_BUS_FLAG2); pio_configure_pin(PIN_EBI_ADDR_BUS_A17, PIN_EBI_ADDR_BUS_FLAG2); pio_configure_pin(PIN_EBI_ADDR_BUS_A18, PIN_EBI_ADDR_BUS_FLAG2); #endif #ifdef CONF_BOARD_MMA7341L /* Configure MMA7341L mode set control pin */ gpio_configure_pin(PIN_MMA7341L_MODE, PIN_MMA7341L_MODE_FLAG); /* Configure MMA7341L x,y,z axis output voltage pin */ gpio_configure_pin(PIN_MMA7341L_X_AXIS, PIN_MMA7341L_X_AXIS_FLAG); gpio_configure_pin(PIN_MMA7341L_Y_AXIS, PIN_MMA7341L_Y_AXIS_FLAG); gpio_configure_pin(PIN_MMA7341L_Z_AXIS, PIN_MMA7341L_Z_AXIS_FLAG); #endif #if defined(CONF_BOARD_ENABLE_MXT143E_XPLAINED) pio_configure_pin(MXT143E_XPLAINED_MISO, SPI_MISO_FLAGS); pio_configure_pin(MXT143E_XPLAINED_MOSI, SPI_MOSI_FLAGS); pio_configure_pin(MXT143E_XPLAINED_SCK, SPI_SPCK_FLAGS); pio_configure_pin(MXT143E_XPLAINED_CS, (PIO_OUTPUT_0 | PIO_DEFAULT)); pio_configure_pin(MXT143E_XPLAINED_CHG, (PIO_INPUT | PIO_PULLUP)); pio_configure_pin(MXT143E_XPLAINED_DC, (PIO_OUTPUT_0 | PIO_DEFAULT)); #ifndef MXT143E_XPLAINED_BACKLIGHT_DISABLE pio_configure_pin(MXT143E_XPLAINED_BACKLIGHT, (PIO_OUTPUT_0 | PIO_DEFAULT)); #endif pio_configure_pin(MXT143E_XPLAINED_LCD_RESET, (PIO_OUTPUT_0 | PIO_DEFAULT)); pio_configure_pin(MXT143E_XPLAINED_SDA, TWI0_DATA_FLAGS); pio_configure_pin(MXT143E_XPLAINED_SCL, TWI0_CLK_FLAGS); pmc_enable_periph_clk(ID_PIOB); #endif }