void system_board_init(void) { struct port_config pin_conf; port_get_config_defaults(&pin_conf); /* Configure LEDs as outputs, turn them off */ pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(LED_0_PIN, &pin_conf); port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE); /* Set buttons as inputs */ pin_conf.direction = PORT_PIN_DIR_INPUT; pin_conf.input_pull = PORT_PIN_PULL_UP; port_pin_set_config(BUTTON_0_PIN, &pin_conf); #ifdef CONF_BOARD_AT86RFX port_get_config_defaults(&pin_conf); pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(AT86RFX_SPI_SCK, &pin_conf); port_pin_set_config(AT86RFX_SPI_MOSI, &pin_conf); port_pin_set_config(AT86RFX_SPI_CS, &pin_conf); port_pin_set_config(AT86RFX_RST_PIN, &pin_conf); port_pin_set_config(AT86RFX_SLP_PIN, &pin_conf); port_pin_set_output_level(AT86RFX_SPI_SCK, true); port_pin_set_output_level(AT86RFX_SPI_MOSI, true); port_pin_set_output_level(AT86RFX_SPI_CS, true); port_pin_set_output_level(AT86RFX_RST_PIN, true); port_pin_set_output_level(AT86RFX_SLP_PIN, true); pin_conf.direction = PORT_PIN_DIR_INPUT; port_pin_set_config(AT86RFX_SPI_MISO, &pin_conf); #endif }
/*============================================================================== hal_ctrlPinInit() =============================================================================*/ void * hal_ctrlPinInit(en_targetExtPin_t e_pinType) { struct port_config pin_conf; port_get_config_defaults(&pin_conf); pinDesc_t * p_pin = NULL; /* Configure SPI interface */ port_get_config_defaults(&pin_conf); switch (e_pinType){ case E_TARGET_RADIO_RST: pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(st_rst, &pin_conf); // RST_PIN port_pin_set_output_level(st_rst, true); // RST_PIN p_pin = &st_rst; break; case E_TARGET_RADIO_SLPTR: pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(st_slp_tr, &pin_conf); // SLP_PIN port_pin_set_output_level(st_slp_tr, true); // SLP_PIN p_pin = &st_slp_tr; break; default: free(p_pin); break; } return p_pin; } /* hal_ctrlPinInit */
uint8_t hal_gpioPinInit(uint8_t c_pin, uint8_t c_dir, uint8_t c_initState) { struct port_config pin_conf; port_get_config_defaults(&pin_conf); /* Configure SPI interface */ port_get_config_defaults(&pin_conf); pin_conf.direction = c_dir; port_pin_set_config(c_pin, &pin_conf); port_pin_set_output_level(c_pin, c_initState); return 0; }
////////////////////////////////////////////////////////////////////////// // Board peripheral function void board_led_setup(void) { struct port_config sw_input; port_get_config_defaults(&sw_input); struct port_config led_out; port_get_config_defaults(&led_out); sw_input.direction = PORT_PIN_DIR_INPUT; sw_input.input_pull = PORT_PIN_PULL_DOWN; port_pin_set_config(SW2_BUTTON, &sw_input); led_out.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(LED_DEBUG, &led_out); }
// Configure the LED selection port as output void configure_port_pins(void) { struct port_config config_port_pin; port_get_config_defaults(&config_port_pin); config_port_pin.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(PIN_PA25, &config_port_pin); }
/*---------------------------------------------------------------------------*/ static int open(int32_t baudrate, uart_rx_char_callback char_cb, uart_rx_frame_callback frame_cb) { struct usart_config config_usart; struct port_config pin_conf; usart_get_config_defaults(&config_usart); config_usart.baudrate = baudrate; config_usart.mux_setting = RS485_SERCOM_MUX_SETTING; config_usart.pinmux_pad0 = RS485_SERCOM_PINMUX_PAD0; config_usart.pinmux_pad1 = RS485_SERCOM_PINMUX_PAD1; config_usart.pinmux_pad2 = RS485_SERCOM_PINMUX_PAD2; config_usart.pinmux_pad3 = RS485_SERCOM_PINMUX_PAD3; while (usart_init(&usart_instance, RS485_MODULE, &config_usart) != STATUS_OK) {} usart_enable(&usart_instance); port_get_config_defaults(&pin_conf); pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(RS485_TXE, &pin_conf); port_pin_set_output_level(RS485_TXE, false); char_callback = char_cb; usart_register_callback(&usart_instance, usart_read_callback, USART_CALLBACK_BUFFER_RECEIVED); usart_enable_callback(&usart_instance, USART_CALLBACK_BUFFER_RECEIVED); usart_read_job(&usart_instance, &rx_char); return 1; }
void sd_mmc_spi_init(void) { sd_mmc_spi_err = SD_MMC_SPI_NO_ERR; // Initialize card detect pin struct port_config pin_conf; port_get_config_defaults(&pin_conf); // Set card detect pin as inputs pin_conf.direction = PORT_PIN_DIR_INPUT; pin_conf.input_pull = PORT_PIN_PULL_UP; port_pin_set_config(SD_MMC_0_CD_GPIO, &pin_conf); // Initialize SPI interface and enable it struct spi_config config; spi_get_config_defaults(&config); config.mux_setting = SD_MMC_SPI_PINMUX_SETTING; config.pinmux_pad0 = SD_MMC_SPI_PINMUX_PAD0; config.pinmux_pad1 = SD_MMC_SPI_PINMUX_PAD1; config.pinmux_pad2 = SD_MMC_SPI_PINMUX_PAD2; config.pinmux_pad3 = SD_MMC_SPI_PINMUX_PAD3; config.generator_source = SD_MMC_SPI_SOURCE_CLOCK; config.mode_specific.master.baudrate = SDMMC_CLOCK_INIT; spi_init(&sd_mmc_master, SD_MMC_SPI, &config); spi_enable(&sd_mmc_master); spi_slave_inst_get_config_defaults(&slave_configs[0]); slave_configs[0].ss_pin = ss_pins[0]; spi_attach_slave(&sd_mmc_spi_devices[0], &slave_configs[0]); }
/*---------------------------------------------------------------------------*/ void button_sensor_init(void) { struct extint_chan_conf config_extint_chan; struct port_config pin_conf; port_get_config_defaults(&pin_conf); pin_conf.direction = PORT_PIN_DIR_INPUT; pin_conf.input_pull = PORT_PIN_PULL_UP; port_pin_set_config(BUTTON_0_PIN, &pin_conf); // extint_enable(); extint_chan_get_config_defaults(&config_extint_chan); config_extint_chan.gpio_pin = BUTTON_0_EIC_PIN; config_extint_chan.gpio_pin_mux = BUTTON_0_EIC_MUX; config_extint_chan.gpio_pin_pull = EXTINT_PULL_UP; config_extint_chan.detection_criteria = EXTINT_DETECT_FALLING; // config_extint_chan.detection_criteria = EXTINT_DETECT_BOTH; extint_chan_set_config(BUTTON_0_EIC_LINE, &config_extint_chan); extint_register_callback((extint_callback_t)extint_detection_callback, BUTTON_0_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); extint_chan_enable_callback(BUTTON_0_EIC_LINE, EXTINT_CALLBACK_TYPE_DETECT); timer_set(&debouncetimer, 0); system_interrupt_enable_global(); /* on by default */ button_sensor_configure(0, 1); }
/** * \brief Initialize the USB peripheral and set right role according to ID pin * * \return \c true if the ID pin management has been started, otherwise \c false. */ bool usb_dual_enable(void) { if (_initialized) { return false; // Dual role already initialized } #if USB_ID_EIC _initialized = true; struct port_config pin_conf; port_get_config_defaults(&pin_conf); /* Set USB ID Pin as inputs */ pin_conf.direction = PORT_PIN_DIR_INPUT; pin_conf.input_pull = PORT_PIN_PULL_UP; port_pin_set_config(USB_ID_PIN, &pin_conf); usb_id_config(); if (_usb_is_id_device()) { UHC_MODE_CHANGE(false); udc_start(); } else { UHC_MODE_CHANGE(true); uhc_start(); } /** * End of host or device startup, * the current mode selected is already started now */ return true; // ID pin management has been enabled #else return false; // ID pin management has not been enabled #endif }
/*---------------------------------------------------------------------------*/ void i2c_master_interface_init(void) { if (!initialized) { struct i2c_master_config config_i2c_master; /* Toggle SCL for some time, this solves I2C periperhal problem */ struct port_config pin_conf; port_get_config_defaults(&pin_conf); pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(PIN_PA13, &pin_conf); for (int i = 0; i < 1000; i++) { port_pin_toggle_output_level(PIN_PA13); clock_wait(CLOCK_SECOND / 1000); } /* Initialize config structure and software module. */ i2c_master_get_config_defaults(&config_i2c_master); config_i2c_master.baud_rate = 400; config_i2c_master.pinmux_pad0 = SENSORS_I2C_SERCOM_PINMUX_PAD0; config_i2c_master.pinmux_pad1 = SENSORS_I2C_SERCOM_PINMUX_PAD1; /* Initialize and enable device with config. */ i2c_master_init(&i2c_master_instance, SENSORS_I2C_MODULE, &config_i2c_master); i2c_master_enable(&i2c_master_instance); initialized = true; } }
static void setup_led(void) { // Configure main LED as output struct port_config config_port_pin; port_get_config_defaults(&config_port_pin); config_port_pin.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(PIN_PA28, &config_port_pin); }
/** * \internal * \brief Initialize the hardware interface * * Depending on what interface used for interfacing the OLED controller this * function will initialize the necessary hardware. */ static void ssd1306_interface_init(void) { struct spi_config config; struct spi_slave_inst_config slave_config; spi_slave_inst_get_config_defaults(&slave_config); slave_config.ss_pin = SSD1306_CS_PIN; spi_attach_slave(&ssd1306_slave, &slave_config); spi_get_config_defaults(&config); config.mux_setting = SSD1306_SPI_PINMUX_SETTING; config.pinmux_pad0 = SSD1306_SPI_PINMUX_PAD0; config.pinmux_pad1 = SSD1306_SPI_PINMUX_PAD1; config.pinmux_pad2 = SSD1306_SPI_PINMUX_PAD2; config.pinmux_pad3 = SSD1306_SPI_PINMUX_PAD3; config.mode_specific.master.baudrate = SSD1306_CLOCK_SPEED; spi_init(&ssd1306_master, SSD1306_SPI, &config); spi_enable(&ssd1306_master); struct port_config pin; port_get_config_defaults(&pin); pin.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(SSD1306_DC_PIN, &pin); port_pin_set_config(SSD1306_RES_PIN, &pin); }
static void IIC_Init(void) { IIC_SCL(1); IIC_SDA(1); port_get_config_defaults(&pin_clk); pin_clk.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(PIN_I2C_CLK, &pin_clk); port_pin_set_output_level(PIN_I2C_CLK, 1); port_get_config_defaults(&pin_data); pin_data.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(PIN_I2C_DATA, &pin_clk); port_pin_set_output_level(PIN_I2C_DATA, 1); }
/** * \internal * \brief Initialize the hardware interface. */ static void ksz8851snl_interface_init(void) { struct spi_config config; struct spi_slave_inst_config slave_config; spi_slave_inst_get_config_defaults(&slave_config); slave_config.ss_pin = KSZ8851SNL_CS_PIN; spi_attach_slave(&ksz8851snl_slave, &slave_config); spi_get_config_defaults(&config); config.mux_setting = KSZ8851SNL_SPI_PINMUX_SETTING; config.pinmux_pad0 = KSZ8851SNL_SPI_PINMUX_PAD0; config.pinmux_pad1 = KSZ8851SNL_SPI_PINMUX_PAD1; config.pinmux_pad2 = KSZ8851SNL_SPI_PINMUX_PAD2; config.pinmux_pad3 = KSZ8851SNL_SPI_PINMUX_PAD3; config.mode_specific.master.baudrate = KSZ8851SNL_CLOCK_SPEED; spi_init(&ksz8851snl_master, KSZ8851SNL_SPI, &config); spi_enable(&ksz8851snl_master); /* Configure RSTN pin. */ struct port_config pin; port_get_config_defaults(&pin); pin.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(KSZ8851SNL_RSTN_PIN, &pin); }
int main(void) { system_init(); delay_init(); struct port_config pin; port_get_config_defaults(&pin); pin.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(LED0_PIN, &pin); port_pin_set_output_level(LED0_PIN, LED0_INACTIVE); while (true) { for (int i = 0; i < 5; i++) { port_pin_toggle_output_level(LED0_PIN); delay_s(1); } for (int i = 0; i < 50; i++) { port_pin_toggle_output_level(LED0_PIN); delay_ms(100); } for (int i = 0; i < 5000; i++) { port_pin_toggle_output_level(LED0_PIN); delay_cycles(100); } } }
int main(void) { system_init(); configure_usart(); configure_usart_callbacks(); struct port_config pin_conf; port_get_config_defaults(&pin_conf); /* Configure LEDs as outputs, turn them off */ pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(LED_1_PIN, &pin_conf); port_pin_set_output_level(LED_1_PIN, LED_1_INACTIVE); /* Set buttons as inputs */ pin_conf.direction = PORT_PIN_DIR_INPUT; pin_conf.input_pull = PORT_PIN_PULL_UP; port_pin_set_config(BUTTON_1_PIN, &pin_conf); #if USE_EIC == true configure_extint(); #endif #if USE_INTERRUPTS == true # if USE_EIC == false configure_systick_handler(); # else configure_eic_callback(); # endif system_interrupt_enable_global(); uint16_t temp; while (true) { /* Do nothing - use interrupts */ //if (usart_read_wait(&usart_instance, &temp) == STATUS_OK) //{ //while (usart_write_wait(&usart_instance, temp) != STATUS_OK); //} usart_read_buffer_job(&usart_instance, (uint8_t *)rx_buffer, 1); //sleepmgr_sleep(SLEEPMGR_STANDBY); } #else # if USE_EIC == false while (true) { update_led_state(); } # else while (true) { if (extint_chan_is_detected(BUTTON_1_EIC_LINE)) { extint_chan_clear_detected(BUTTON_1_EIC_LINE); update_led_state(); } } # endif #endif }
/*============================================================================== hal_ctrlPinInit() =============================================================================*/ void * hal_ctrlPinInit( en_targetExtPin_t e_pinType ) /*void * hal_pinInit(en_targetExtPin_t e_pinType)*/ { struct port_config pin_conf; port_get_config_defaults( &pin_conf ); pinDesc_t * p_pin = NULL; /* Configure SPI interface */ port_get_config_defaults( &pin_conf ); pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config( SAMD21_SPI0_SCK_PIN, &pin_conf ); // SPI_SCK port_pin_set_config( SAMD21_SPI0_MOSI_PIN, &pin_conf ); // SPI_MOSI port_pin_set_config( SAMD21_SPI0_CS_PIN, &pin_conf ); // SPI_CS port_pin_set_config( SAMD21_FEM_PD_PIN, &pin_conf ); // Power Amp port_pin_set_config( SAMD21_FEM_LNA_PIN, &pin_conf ); // Power Amp port_pin_set_output_level( SAMD21_SPI0_SCK_PIN, true ); // SPI_SCK port_pin_set_output_level( SAMD21_SPI0_MOSI_PIN, true ); // SPI_MOSI port_pin_set_output_level( SAMD21_SPI0_CS_PIN, true ); // SPI_CS port_pin_set_output_level( SAMD21_FEM_PD_PIN, true ); // Power Amp port_pin_set_output_level( SAMD21_FEM_LNA_PIN, true ); // Power Amp pin_conf.direction = PORT_PIN_DIR_INPUT; port_pin_set_config( SAMD21_SPI0_MISO_PIN, &pin_conf ); // SPI_MISO switch( e_pinType ) { case E_TARGET_RADIO_RST: pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config( st_rst, &pin_conf ); // RST_PIN port_pin_set_output_level( st_rst, true ); // RST_PIN p_pin = &st_rst; break; case E_TARGET_RADIO_SLPTR: pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config( st_slp_tr, &pin_conf ); // SLP_PIN port_pin_set_output_level( st_slp_tr, true ); // SLP_PIN p_pin = &st_slp_tr; break; default: free( p_pin ); break; } return p_pin; }
void port_init(port_t *obj, PortName port, int mask, PinDirection dir) { MBED_ASSERT(obj); struct port_config pin_conf; int i, j; int start; port_get_config_defaults(&pin_conf); switch (dir) { case PIN_INPUT : pin_conf.direction = PORT_PIN_DIR_INPUT; break; case PIN_OUTPUT: pin_conf.direction = PORT_PIN_DIR_OUTPUT; break; case PIN_INPUT_OUTPUT: pin_conf.direction = PORT_PIN_DIR_OUTPUT_WTH_READBACK; break; default: return; } PortGroup *const port_base = (PortGroup*)port_get_group_from_gpio_pin(port * 32); // 32 pins in port // function reused to get the port base if(port_base == NULL) return; /* returns NULL if invalid*/ switch (port) { case PortA: obj->mask = (uint32_t)mask & PORTA_MASK; break; case PortB: obj->mask = (uint32_t)mask & PORTB_MASK; break; #if defined(TARGET_SAMR21G18A) case PortC: obj->mask = (uint32_t)mask & PORTC_MASK; break; #endif default: return; } start = start_pin(port); if(start == NC) return; obj->port = port; obj->direction = dir; obj->powersave = pin_conf.powersave; obj->mode = PORT_PIN_PULL_UP; for (i = start, j = 0; j < 32; i++, j++) { if (obj->mask & (1<<j)) { port_pin_set_config((PinName)i, &pin_conf); } } obj->OUTCLR = &port_base->OUTCLR.reg; obj->OUTSET = &port_base->OUTSET.reg; obj->IN = &port_base->IN.reg; obj->OUT = &port_base->OUT.reg; }
/** Configure LED0, turn it off*/ static void config_led(void) { struct port_config pin_conf; port_get_config_defaults(&pin_conf); pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(LED_0_PIN, &pin_conf); port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE); }
//dir is true for output, false for input void setup_pin(bool dir,uint8_t pin){ struct port_config conf; port_get_config_defaults(&conf); if(dir){ conf.direction = PORT_PIN_DIR_OUTPUT; }else{ conf.direction = PORT_PIN_DIR_INPUT; } port_pin_set_config(pin,&conf); }
void system_board_init(void) { struct port_config pin_conf; port_get_config_defaults(&pin_conf); /* Configure LEDs as outputs, turn them off */ pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(LED_0_PIN, &pin_conf); port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE); /* Set buttons as inputs */ pin_conf.direction = PORT_PIN_DIR_INPUT; pin_conf.input_pull = PORT_PIN_PULL_UP; port_pin_set_config(BUTTON_0_PIN, &pin_conf); #ifdef CONF_BOARD_AT86RFX port_get_config_defaults(&pin_conf); pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(AT86RFX_SPI_SCK, &pin_conf); port_pin_set_config(AT86RFX_SPI_MOSI, &pin_conf); port_pin_set_config(AT86RFX_SPI_CS, &pin_conf); port_pin_set_config(AT86RFX_RST_PIN, &pin_conf); port_pin_set_config(AT86RFX_SLP_PIN, &pin_conf); port_pin_set_output_level(AT86RFX_SPI_SCK, true); port_pin_set_output_level(AT86RFX_SPI_MOSI, true); port_pin_set_output_level(AT86RFX_SPI_CS, true); port_pin_set_output_level(AT86RFX_RST_PIN, true); port_pin_set_output_level(AT86RFX_SLP_PIN, true); pin_conf.direction = PORT_PIN_DIR_INPUT; port_pin_set_config(AT86RFX_SPI_MISO, &pin_conf); PM->APBCMASK.reg |= (1<<PM_APBCMASK_RFCTRL_Pos); REG_RFCTRL_FECFG = RFCTRL_CFG_ANT_DIV; struct system_pinmux_config config_pinmux; system_pinmux_get_config_defaults(&config_pinmux); config_pinmux.mux_position = MUX_PA09F_RFCTRL_FECTRL1 ; config_pinmux.direction = SYSTEM_PINMUX_PIN_DIR_OUTPUT; system_pinmux_pin_set_config(PIN_RFCTRL1, &config_pinmux); system_pinmux_pin_set_config(PIN_RFCTRL2, &config_pinmux); #endif }
void leds_arch_init(void) { struct port_config pin_conf; port_get_config_defaults(&pin_conf); /* Configure LEDs as outputs, turn them off */ pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(LED_0_PIN, &pin_conf); port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE); }
/** * @fn nm_bsp_deinit * @brief De-iInitialize BSP * @return 0 in case of success and -1 in case of failure */ sint8 nm_bsp_deinit(void) { struct port_config pin_conf; port_get_config_defaults(&pin_conf); /* Configure control pins as input no pull up. */ pin_conf.direction = PORT_PIN_DIR_INPUT; pin_conf.input_pull = PORT_PIN_PULL_NONE; port_pin_set_output_level(CONF_WINC_PIN_CHIP_ENABLE, false); port_pin_set_output_level(CONF_WINC_PIN_RESET, false); port_pin_set_config(CONF_WINC_SPI_INT_PIN, &pin_conf); return M2M_SUCCESS; }
/* * @fn init_chip_pins * @brief Initialize reset, chip enable and wake pin */ static void init_chip_pins(void) { struct port_config pin_conf; port_get_config_defaults(&pin_conf); /* Configure control pins as output. */ pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(CONF_WINC_PIN_RESET, &pin_conf); port_pin_set_config(CONF_WINC_PIN_CHIP_ENABLE, &pin_conf); port_pin_set_config(CONF_WINC_PIN_WAKE, &pin_conf); }
void _hal_ledInit( void ) { #if LEDS_ON_BOARD == TRUE struct port_config pin_conf; port_get_config_defaults(&pin_conf); /* Configure LEDs as outputs, turn them off */ pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(LED_0_PIN, &pin_conf); port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE); #endif }
/** * \brief Configures buttons */ static void init_buttons(void) { struct port_config conf; port_get_config_defaults(&conf); conf.direction = PORT_PIN_DIR_INPUT; conf.input_pull = PORT_PIN_PULL_UP; /* Configure all three buttons as inputs */ port_pin_set_config(WING_BUTTON_1, &conf); port_pin_set_config(WING_BUTTON_2, &conf); port_pin_set_config(WING_BUTTON_3, &conf); }
bool main_cdc_enable(uint8_t port) { l("main_cdc_enable %d", port); main_b_cdc_enable = true; // DC mapping struct port_config config_port_pin; port_get_config_defaults(&config_port_pin); config_port_pin.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(PIN_PA00, &config_port_pin); // GPIO17 D/C port_pin_set_config(PIN_PA22, &config_port_pin); // GPIO04 RESET return true; }
void configure_port_pins(void){ //struct port_config pin_conf; struct port_config config_port_pin; //port_get_config_defaults(&pin_conf); port_get_config_defaults(&config_port_pin); config_port_pin.direction = PORT_PIN_DIR_OUTPUT; config_port_pin.input_pull = PORT_PIN_PULL_NONE; port_pin_set_config(PIN_PA02, &config_port_pin); port_pin_set_config(_RESET, &config_port_pin); }
void system_board_init(void) { struct port_config pin_conf; port_get_config_defaults(&pin_conf); /* Configure LEDs as outputs, turn them off */ pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(LED_0_PIN, &pin_conf); port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE); /* Set buttons as inputs */ pin_conf.direction = PORT_PIN_DIR_INPUT; pin_conf.input_pull = PORT_PIN_PULL_UP; port_pin_set_config(BUTTON_0_PIN, &pin_conf); }
/** * \internal * \brief Setup function for polled mode test. * * This function sets up the GPIO pin and the external interrupt channel. * * \param test Current test case. */ static void setup_extint_polled_mode_test(const struct test_case *test) { /* Configure the GPIO pin */ port_get_config_defaults(&pin_conf); pin_conf.direction = PORT_PIN_DIR_OUTPUT; pin_conf.input_pull = PORT_PIN_PULL_NONE; port_pin_set_config(GPIO_TEST_PIN_EXTINT, &pin_conf); port_pin_set_output_level(GPIO_TEST_PIN_EXTINT, true); /* Configure the external interrupt channel */ extint_chan_get_config_defaults(&eic_conf); eic_conf.gpio_pin = EIC_TEST_PIN; eic_conf.gpio_pin_mux = EIC_TEST_PIN_MUX; eic_conf.gpio_pin_pull = EXTINT_PULL_UP; eic_conf.detection_criteria = EXTINT_DETECT_FALLING; extint_chan_set_config(EIC_TEST_CHANNEL, &eic_conf); }