/*============================================================================== 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 */
/** * \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); }
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 }
//------------ -------------------- //-----湿度读取子程序 ------------ //---------------------- ---------- //----以下变量均为全局变量-------- //----温度高8位== U8T_data_H------ //----温度低8位== U8T_data_L------ //----湿度高8位== U8RH_data_H----- //----湿度低8位== U8RH_data_L----- //----校验 8位 == U8checkdata----- //----调用相关子程序如下---------- //---- delay_us();, delay_ms();COM(); //--------------------- ----------- void RH(void) { //主机拉低18ms port_pin_set_config(DATA, &pinc); port_pin_set_output_level(DATA, false); delay_ms(18); port_pin_set_output_level(DATA, true); //总线由上拉电阻拉高 主机延时20us delay_us(20); //主机设为输入 判断从机响应信号 port_pin_set_output_level(DATA, true); port_pin_set_config(DATA, &pini); //判断从机是否有低电平响应信号 如不响应则跳出,响应则向下运行 if(!port_pin_get_input_level(DATA)) //T ! { U8FLAG=2; //判断从机是否发出 80us 的低电平响应信号是否结束 while((!port_pin_get_input_level(DATA))&&U8FLAG++); U8FLAG=2; //判断从机是否发出 80us 的高电平,如发出则进入数据接收状态 while((port_pin_get_input_level(DATA))&&U8FLAG++); //数据接收状态 Run_COM(); U8RH_data_H_temp=U8comdata; Run_COM(); U8RH_data_L_temp=U8comdata; Run_COM(); U8T_data_H_temp=U8comdata; Run_COM(); U8T_data_L_temp=U8comdata; Run_COM(); U8checkdata_temp=U8comdata; port_pin_set_config(DATA, &pinc); port_pin_set_output_level(DATA, true); //数据校验 U8Temp=(U8T_data_H_temp+U8T_data_L_temp+U8RH_data_H_temp+U8RH_data_L_temp); if(U8Temp==U8checkdata_temp) { U8RH_data_H=U8RH_data_H_temp; U8RH_data_L=U8RH_data_L_temp; U8T_data_H=U8T_data_H_temp; U8T_data_L=U8T_data_L_temp; U8checkdata=U8checkdata_temp; }//fi }//fi }
/* * @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); }
/** * \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 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 }
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 _hal_ledInit( 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); port_pin_set_config(LED_1_PIN, &pin_conf); port_pin_set_output_level(LED_1_PIN, LED_1_INACTIVE); port_pin_set_config(LED_2_PIN, &pin_conf); port_pin_set_output_level(LED_2_PIN, LED_2_INACTIVE); }
////////////////////////////////////////////////////////////////////////// // 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); }
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 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); }
/*---------------------------------------------------------------------------*/ 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); }
void port_dir(port_t *obj, PinDirection dir) { MBED_ASSERT(obj); struct port_config pin_conf; int i, j; int start; 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; } start = start_pin(obj->port); if(start == NC) return; obj->direction = dir; pin_conf.input_pull = obj->mode; pin_conf.powersave = obj->powersave; for (i = start, j = 0; j < 32; i++, j++) { if (obj->mask & (1<<j)) { port_pin_set_config((PinName)i, &pin_conf); } } }
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); }
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); }
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]); }
// 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); }
/*---------------------------------------------------------------------------*/ 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; } }
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); } } }
/*---------------------------------------------------------------------------*/ 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; }
/** * \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 }
/** 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); }
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; }
//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 cph_deca_reset(void) { struct port_config config_port = DW_RST_PIN_CONFIG; // Safety extint_chan_disable_callback(DW_RST_LINE, EXTINT_CALLBACK_TYPE_DETECT); // Pull the pin low config_port.direction = PORT_PIN_DIR_OUTPUT; config_port.input_pull = PORT_PIN_PULL_NONE; port_pin_set_output_level(DW_RST_PIN, false); port_pin_set_config(DW_RST_PIN, &config_port); // Now release it config_port.direction = PORT_PIN_DIR_INPUT; config_port.input_pull = PORT_PIN_PULL_NONE; port_pin_set_config(DW_RST_PIN, &config_port); // Why sleep here? Left over from original code. cph_millis_delay(1); }
/** * @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; }
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; }
/*============================================================================ * Name : BitBangSPI_Master_Init * ------------------------------------------------------------------------------ * Purpose : Initialize BitBangSPI Interface * Input : n/a * Output : n/a * Notes : Called from QDebug_Init in QDebug.c * ============================================================================*/ void BitBangSPI_Master_Init(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(CONCAT(PIN_P, SPI_BB_SS, SS_BB), &config_port_pin); port_pin_set_config(CONCAT(PIN_P, SPI_BB_MOSI,MOSI_BB), &config_port_pin); port_pin_set_config(CONCAT(PIN_P, SPI_BB_SCK,SCK_BB), &config_port_pin); config_port_pin.direction = PORT_PIN_DIR_INPUT; config_port_pin.input_pull = PORT_PIN_PULL_UP; port_pin_set_config(CONCAT(PIN_P, SPI_BB_MISO,MISO_BB), &config_port_pin); port_pin_set_output_level(CONCAT(PIN_P, SPI_BB_SS, SS_BB), 0u); port_pin_set_output_level(CONCAT(PIN_P, SPI_BB_MISO, MISO_BB), 1u); port_pin_set_output_level(CONCAT(PIN_P, SPI_BB_MOSI, MOSI_BB), 0u); port_pin_set_output_level(CONCAT(PIN_P, SPI_BB_SCK, SCK_BB), 0u); }