Äúµ±Ç°µÄλÖãºÊ×Ò³ > IT±à³Ì > C++
| CÓïÑÔ | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | ѧÊõÓë´úÂë | cnn¾í»ýÉñ¾­ÍøÂç | gnn | ͼÏñÐÞ¸´ | Keras | Êý¾Ý¼¯ | Neo4j | ×ÔÈ»ÓïÑÔ´¦Àí | Éî¶Èѧϰ | ҽѧCAD | ҽѧӰÏñ | ³¬²ÎÊý | pointnet | pytorch | Òì³£¼ì²â | Transformers | Çé¸Ð·ÖÀà | ֪ʶͼÆ× |

×Ôѧ½Ì³Ì£ºC++ twi_master_initº¯Êý´úÂëʾÀý

51×ÔÑ§Íø 2021-06-03 09:01:35
  C++
ÕâÆª½Ì³ÌC++ twi_master_initº¯Êý´úÂëʾÀýдµÃºÜʵÓã¬Ï£ÍûÄܰﵽÄú¡£

±¾ÎÄÕûÀí»ã×ÜÁËC++ÖÐtwi_master_initº¯ÊýµÄµäÐÍÓ÷¨´úÂëʾÀý¡£Èç¹ûÄúÕý¿àÓÚÒÔÏÂÎÊÌ⣺C++ twi_master_initº¯ÊýµÄ¾ßÌåÓ÷¨£¿C++ twi_master_initÔõôÓã¿C++ twi_master_initʹÓõÄÀý×Ó£¿ÄÇô¹§Ï²Äú, ÕâÀᆱѡµÄº¯Êý´úÂëʾÀý»òÐí¿ÉÒÔΪÄúÌṩ°ïÖú¡£

ÔÚÏÂÎÄÖÐÒ»¹²Õ¹Ê¾ÁËtwi_master_initº¯ÊýµÄ30¸ö´úÂëʾÀý£¬ÕâЩÀý×ÓĬÈϸù¾ÝÊÜ»¶Ó­³Ì¶ÈÅÅÐò¡£Äú¿ÉÒÔΪϲ»¶»òÕ߸оõÓÐÓõĴúÂëµãÔÞ£¬ÄúµÄÆÀ¼Û½«ÓÐÖúÓÚÎÒÃǵÄÏµÍ³ÍÆ¼ö³ö¸ü°ôµÄC++´úÂëʾÀý¡£

ʾÀý1: change_i2c_speed

/** /brief method to change the bus speed of I2C * /param[in] interface on which to change bus speed * /param[in] baud rate (typically 100000 or 400000) */void change_i2c_speed( ATCAIface iface, uint32_t speed ){	ATCAIfaceCfg *cfg = atgetifacecfg(iface);	int bus = cfg->atcai2c.bus;		switch(bus)	{		case 0:			//pmc_enable_periph_clk(ID_TWI0);			//flexcom_enable(FLEXCOM0);			//flexcom_set_opmode(FLEXCOM0, FLEXCOM_TWI);			flexcom_enable(FLEX_Channel0);			flexcom_set_opmode(FLEX_Channel0, FLEXCOM_TWI);						opt_twi_master.master_clk = sysclk_get_cpu_hz();			opt_twi_master.speed      = speed;			opt_twi_master.smbus      = 0;			//twi_master_init(TWI0, &opt_twi_master);			twi_master_init(TWI_Channel0, &opt_twi_master);						break;		case 1:			//pmc_enable_periph_clk(ID_TWI1);			flexcom_enable(FLEX_Channel1);			flexcom_set_opmode(FLEX_Channel1, FLEXCOM_TWI);						opt_twi_master.master_clk = sysclk_get_cpu_hz();			opt_twi_master.speed      = speed;			opt_twi_master.smbus      = 0;			twi_master_init(TWI_Channel1, &opt_twi_master);			break;	}}
¿ª·¢ÕßID:jkman357£¬ÏîÄ¿Ãû³Æ:ATG55-Crypto£¬´úÂëÐÐÊý:37£¬


ʾÀý2: main_init

/** Main initialisation. */static voidmain_init (void){#ifndef HOST    /* Disable watchdog (enabled in bootloader). */    MCUSR &= ~(1 << WDRF);    wdt_disable ();#endif    /* Serial port */    uart0_init ();    /* Enable interrupts */    sei ();    /* Main timer */    timer_init ();    timer_wait ();    /* TWI communications */    asserv_init ();    mimot_init ();    twi_master_init ();    /* IO modules. */    pwm_init ();    contact_init ();    codebar_init ();    usdist_init ();    /* AI modules. */    clamp_init ();    logistic_init ();    path_init ();    /* Initialization done. */    proto_send0 ('z');}
¿ª·¢ÕßID:TLoebner£¬ÏîÄ¿Ãû³Æ:apbteam£¬´úÂëÐÐÊý:32£¬


ʾÀý3: fb_sleep

bool fb_sleep(uint8_t faceNum, bool sleepEnabled) {    uint8_t twiBuf[2];    bool success;    if (faceNum > 6) {	return false;    }    twi_master_init();    twiBuf[0] = FB_REGISTER_ADDR_SLEEP;    if (sleepEnabled) {	twiBuf[1] = 0x01;    } else {	twiBuf[1] = 0x00;    }    success = twi_master_transfer((faceNum << 1), twiBuf, 2, true);    /* After sending a sleep command, we do not attempt to read a response     * because doing so will wake-up the daughterboard processor. */    twi_master_deinit();    return success;}
¿ª·¢ÕßID:M-Blocks£¬ÏîÄ¿Ãû³Æ:MBlocks-MB£¬´úÂëÐÐÊý:25£¬


ʾÀý4: fb_getRxEnable

bool fb_getRxEnable(uint8_t faceNum, bool *rxEnabled) {    uint8_t twiBuf[2];    bool success = true;    if (faceNum > 6) {	return -1;    }    twi_master_init();    twiBuf[0] = FB_REGISTER_ADDR_RX_ENABLE;    success &= twi_master_transfer((faceNum << 1), twiBuf, 1, true);    success &= twi_master_transfer((faceNum << 1) | TWI_READ_BIT, twiBuf, 1, true);    twi_master_deinit();    if (twiBuf[0] & 0x01) {	*rxEnabled = true;    } else {	*rxEnabled = false;    }    return success;}
¿ª·¢ÕßID:M-Blocks£¬ÏîÄ¿Ãû³Æ:MBlocks-MB£¬´úÂëÐÐÊý:25£¬


ʾÀý5: fb_getIRTxLEDs

bool fb_getIRTxLEDs(uint8_t faceNum, bool *led1, bool *led2, bool *led3, bool *led4) {    uint8_t twiBuf[2];    bool success = true;    if ((faceNum < 1) || (faceNum > 6)) {	return -1;    }    twi_master_init();    twiBuf[0] = FB_REGISTER_ADDR_TX_LED_SELECT;    success &= twi_master_transfer((faceNum << 1), twiBuf, 1, true);    success &= twi_master_transfer((faceNum << 1) | TWI_READ_BIT, twiBuf, 1, true);    twi_master_deinit();    if (success) {	*led1 = (twiBuf[0] & 0x01) ? true : false;	*led2 = (twiBuf[0] & 0x02) ? true : false;	*led3 = (twiBuf[0] & 0x04) ? true : false;	*led4 = (twiBuf[0] & 0x08) ? true : false;    }    return success;}
¿ª·¢ÕßID:M-Blocks£¬ÏîÄ¿Ãû³Æ:MBlocks-MB£¬´úÂëÐÐÊý:26£¬


ʾÀý6: fb_getAmbientLight

int16_t fb_getAmbientLight(uint8_t faceNum) {    uint8_t twiBuf[2];    bool success = true;    int16_t ambientLight;    if ((faceNum < 1) || (faceNum > 6)) {	return -1;    }    twi_master_init();    twiBuf[0] = FB_REGISTER_ADDR_AMBIENT_LIGHT;    success &= twi_master_transfer((faceNum << 1), twiBuf, 1, true);    success &= twi_master_transfer((faceNum << 1) | TWI_READ_BIT, twiBuf, 2, true);    twi_master_deinit();    /* The 10-bit result is returned left-shifted so that it is possible to     * read just one byte and still get most of the resolution (even though     * we still read both bytes). */    ambientLight  = twiBuf[0] << 2;    ambientLight |= twiBuf[1] >> 6;    if (!success) {	ambientLight = -1;    }    return ambientLight;}
¿ª·¢ÕßID:M-Blocks£¬ÏîÄ¿Ãû³Æ:MBlocks-MB£¬´úÂëÐÐÊý:30£¬


ʾÀý7: fb_getTopLEDs

bool fb_getTopLEDs(uint8_t faceNum, bool *redOn, bool *greenOn, bool *blueOn) {    uint8_t twiBuf[2];    bool success = true;    if ((faceNum < 1) || (faceNum > 6)) {	return false;    }    twi_master_init();    twiBuf[0] = FB_REGISTER_ADDR_LEDS_TOP;    success &= twi_master_transfer((faceNum << 1), twiBuf, 1, true);    success &= twi_master_transfer((faceNum << 1) | TWI_READ_BIT, twiBuf, 1, true);    twi_master_deinit();    if (success) {	*redOn = (twiBuf[0] & 0x01) ? true : false;	*greenOn = (twiBuf[0] & 0x02) ? true : false;	*blueOn = (twiBuf[0] & 0x04) ? true : false;    }    return success;}
¿ª·¢ÕßID:M-Blocks£¬ÏîÄ¿Ãû³Æ:MBlocks-MB£¬´úÂëÐÐÊý:25£¬


ʾÀý8: initialize_all

/*==============================================Function: initialize_all(void)	Initialize oscillator, radio, bluetooth,	twi and vibration	==============================================*/static void initialize_all(){	char buf[30];	// Start 16 MHz crystal oscillator.	NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;	NRF_CLOCK->TASKS_HFCLKSTART    = 1;	        // oscillator	while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {		// busy wait until the oscilator is up and running	}		simple_uart_config(0, 23, 0, 22, 0);	simple_uart_putstring("INIT/n");		// initiliaze radio    radio_configure();     simple_uart_putstring("Configured radio/n");	// initialize bluetooth    start_ble(MUG_LIST); 	simple_uart_putstring("BLUETOOTH STARTED/n");			// initialize twi	twi_master_init();	simple_uart_putstring("TWI master init/n");	init_vibration();	simple_uart_putstring("Vibration init/n");}
¿ª·¢ÕßID:d3alek£¬ÏîÄ¿Ãû³Æ:SLIP-B£¬´úÂëÐÐÊý:41£¬


ʾÀý9: nrf6350_lcd_init

bool nrf6350_lcd_init(void){  if (!twi_master_init())  {    return false;  }  // Sometimes the first command doesn't get through, so we'll try  // sending non-important "wake up" command first and don't care if it fails.  (void)nrf6350_lcd_wake_up();  if (!nrf6350_lcd_set_instruction(0x38))                 // Function set.    return false;  if (!nrf6350_lcd_set_instruction(0x39))                 // Choose two-line mode.    return false;  if (!nrf6350_lcd_set_instruction(0x14))                 // Internal OSC frequency.    return false;  if (!nrf6350_lcd_set_contrast(LCD_CONTRAST_HIGH))       // Contrast set (low byte).    return false;  if (!nrf6350_lcd_set_instruction(0x5F))                 // Power/ICON control/.    return false;  if (!nrf6350_lcd_set_instruction(0x6A))                 // Follower control.    return false;  nrf_delay_us(200000);                                   // Need to wait 200ms here according to datasheet.  if (!nrf6350_lcd_on())                                  // Display ON.    return false;  if (!nrf6350_lcd_clear())                               // Clear display.    return false;  return nrf6350_lcd_set_instruction(0x06);               // Entry mode set.}
¿ª·¢ÕßID:1072258106£¬ÏîÄ¿Ãû³Æ:duband£¬´úÂëÐÐÊý:30£¬


ʾÀý10: twi_master_write

static bool twi_master_write(uint8_t *data, uint8_t data_length, bool issue_stop_condition){    uint32_t timeout = MAX_TIMEOUT_LOOPS;   /* max loops to wait for EVENTS_TXDSENT event*/    if (data_length == 0)    {        /* Return false for requesting data of size 0 */        return false;    }    NRF_TWI1->TXD           = *data++;    NRF_TWI1->TASKS_STARTTX = 1;    /** @snippet [TWI HW master write] */                while (true)    {        while(NRF_TWI1->EVENTS_TXDSENT == 0 && NRF_TWI1->EVENTS_ERROR == 0 && (--timeout))        {            // Do nothing.        }        if (timeout == 0 || NRF_TWI1->EVENTS_ERROR != 0)        {          // Recover the peripheral as indicated by PAN 56: "TWI: TWI module lock-up." found at           // Product Anomaly Notification document found at           // https://www.nordicsemi.com/eng/Products/Bluetooth-R-low-energy/nRF51822/#Downloads          NRF_TWI1->EVENTS_ERROR = 0;          NRF_TWI1->ENABLE       = TWI_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos;           NRF_TWI1->POWER        = 0;           nrf_delay_us(5);           NRF_TWI1->POWER        = 1;           NRF_TWI1->ENABLE       = TWI_ENABLE_ENABLE_Enabled << TWI_ENABLE_ENABLE_Pos;          (void)twi_master_init();                    return false;        }        NRF_TWI1->EVENTS_TXDSENT = 0;        if (--data_length == 0)        {            break;        }        NRF_TWI1->TXD = *data++;    }    /** @snippet [TWI HW master write] */                    if (issue_stop_condition)     {         NRF_TWI1->EVENTS_STOPPED = 0;         NRF_TWI1->TASKS_STOP     = 1;         /* Wait until stop sequence is sent */         while(NRF_TWI1->EVENTS_STOPPED == 0)         {             // Do nothing.        }         NRF_TWI1->EVENTS_STOPPED = 0;    }    return true;}
¿ª·¢ÕßID:cyrexxx£¬ÏîÄ¿Ãû³Æ:my-light-band45£¬´úÂëÐÐÊý:60£¬


ʾÀý11: main

int main(){	DDRB = 0x20;	PORTC = 1 << 4 | 1 << 5;	stdout = &mystdout;	stdin = &mystdin;	uart_init();	twi_master_init();	puts("Master Receive!");	while (twi_mr_start(0x08) != TWST_OK)	{		printf("Failed: %x/n", TW_STATUS);		twi_stop();		puts("No ACK (Enter to continue)");		getchar();	}	while (1)	{		char c = twi_read();		printf("Char: %c, Status: %x/n", c, TW_STATUS);				if (TW_STATUS != TW_MR_DATA_ACK)			break;		PINB = 0x20;	}	puts("Disconnected");	return 0;}
¿ª·¢ÕßID:joelluijmes£¬ÏîÄ¿Ãû³Æ:avr-libs£¬´úÂëÐÐÊý:33£¬


ʾÀý12: main

int main(void){    uint32_t err_code;    // Initialize.    timers_init();    err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);    APP_ERROR_CHECK(err_code);    uart_init();    ble_stack_init();    twi_master_init();    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);    nrf_delay_ms(200);    bsp_indication_set(BSP_INDICATE_IDLE);    nrf_delay_ms(200);    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);    update_sensor(0);    start_advertising();    timers_start();    // Enter main loop.    for (;; )    {        power_manage();    }}
¿ª·¢ÕßID:ix-wetterstation£¬ÏîÄ¿Ãû³Æ:sensor£¬´úÂëÐÐÊý:29£¬


ʾÀý13: init

static void init(void){	my_twi_config.twi_ppi_ch = 1;  my_twi_config.twi = NRF_TWI1;		twi_init_config_t init_config;	init_config.frequency = TWI_FREQ_400KHZ;	init_config.twi_pinselect_scl = light_TWI_SCL;	init_config.twi_pinselect_sda = light_TWI_SDA;	init_config.twi_interrupt_no = SPI1_TWI1_IRQn;	if(!twi_master_init(&init_config,&my_twi_config))	{			APP_ERROR_CHECK(666);	}		iss_struct.p_update_samp_freq = update_measurement_samp_freq;		NRF_GPIO->PIN_CNF[TSL2561_BASE_PIN] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)                                            | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)                                            | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)                                            | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos)                                            | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);		iss_struct.coord = TSL2561_COORDINATE;	iss_struct.type = BLE_UUID_ITU_SENSOR_TYPE_LIGHT;	iss_struct.make = BLE_UUID_ITU_SENSOR_MAKE_TSL2561;	iss_struct.IEEE_exponent = 0;	iss_update_config(&iss_struct);}
¿ª·¢ÕßID:EnergyFutures£¬ÏîÄ¿Ãû³Æ:ITU_BLE_Measurement_Service£¬´úÂëÐÐÊý:28£¬


ʾÀý14: main

voidmain(void){        twi_master_init();        mpu6500_init();        mpu6500_stop();        disable_i2c();        simble_init("Motion");        motion_ctx.sampling_period = DEFAULT_SAMPLING_PERIOD;        //Set the timer parameters and initialize it.        struct rtc_ctx rtc_ctx = {                .rtc_x[NOTIF_TIMER_ID] = {                        .type = PERIODIC,                        .period = motion_ctx.sampling_period,                        .enabled = false,                        .cb = notif_timer_cb,                }        };        batt_serv_init(&rtc_ctx);        rtc_init(&rtc_ctx);        ind_init();        motion_init(&motion_ctx);        simble_adv_start();        simble_process_event_loop();}
¿ª·¢ÕßID:tralamazza£¬ÏîÄ¿Ãû³Æ:relayr-firmware-nrf51-modules£¬´úÂëÐÐÊý:29£¬


ʾÀý15: hal_i2c_init

/** * /brief initialize an I2C interface using given config * * /param[in] hal - opaque ptr to HAL data * /param[in] cfg - interface configuration * * /return ATCA_STATUS */ATCA_STATUS hal_i2c_init(void *hal, ATCAIfaceCfg *cfg){	// set to default i2c bus	if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1)		cfg->atcai2c.bus = 0;	int bus = cfg->atcai2c.bus; // 0-based logical bus number	ATCAHAL_t *phal = (ATCAHAL_t*)hal;	if (i2c_bus_ref_ct == 0)    // power up state, no i2c buses will have been used		for (int i = 0; i < MAX_I2C_BUSES; i++)			i2c_hal_data[i] = NULL;	i2c_bus_ref_ct++;   // total across buses	if (bus >= 0 && bus < MAX_I2C_BUSES) {		// if this is the first time this bus and interface has been created, do the physical work of enabling it		if (i2c_hal_data[bus] == NULL) {			i2c_hal_data[bus] = malloc(sizeof(ATCAI2CMaster_t));			i2c_hal_data[bus]->ref_ct = 1;  // buses are shared, this is the first instance			switch (bus) {			case 0:				i2c_hal_data[bus]->twi_id = ID_TWI0;				i2c_hal_data[bus]->twi_master_instance = TWI0;				break;			case 1:				i2c_hal_data[bus]->twi_id = ID_TWI1;				i2c_hal_data[bus]->twi_master_instance = TWI1;				// configure TWI1 pins				gpio_configure_pin(PIO_PB4_IDX, (PIO_PERIPH_A | PIO_PULLUP));				gpio_configure_pin(PIO_PB5_IDX, (PIO_PERIPH_A | PIO_PULLUP));				// disable JTAG				MATRIX->CCFG_SYSIO |= (1 << 4) | (1 << 5);				break;			}			pmc_enable_periph_clk(i2c_hal_data[bus]->twi_id);			opt_twi_master.master_clk = sysclk_get_cpu_hz();			opt_twi_master.speed = cfg->atcai2c.baud;			opt_twi_master.smbus = 0;			twi_master_init(i2c_hal_data[bus]->twi_master_instance, &opt_twi_master);			// store this for use during the release phase			i2c_hal_data[bus]->bus_index = bus;		}else {			// otherwise, another interface already initialized the bus, so this interface will share it and any different			// cfg parameters will be ignored...first one to initialize this sets the configuration			i2c_hal_data[bus]->ref_ct++;		}		phal->hal_data = i2c_hal_data[bus];		return ATCA_SUCCESS;	}	return ATCA_COMM_FAIL;}
¿ª·¢ÕßID:ALLTERCO£¬ÏîÄ¿Ãû³Æ:mongoose-iot£¬´úÂëÐÐÊý:68£¬


ʾÀý16: init_master

u8 init_master() {  // options settings  opt.pba_hz = FPBA_HZ;  opt.speed = TWI_SPEED;  opt.chip = addr;  // initialize TWI driver with options  return twi_master_init(&AVR32_TWI, &opt);}
¿ª·¢ÕßID:Someone101£¬ÏîÄ¿Ãû³Æ:aleph£¬´úÂëÐÐÊý:8£¬


ʾÀý17: i2c400_init

void i2c400_init(void){	m_options.speed_reg = TWI_BAUD(sysclk_get_cpu_hz(),m_options.speed);	sysclk_enable_peripheral_clock(&TWI_I2C400);	twi_master_init(&TWI_I2C400,&m_options);	}
¿ª·¢ÕßID:ribbotson£¬ÏîÄ¿Ãû³Æ:rlabTelemetryTx£¬´úÂëÐÐÊý:9£¬


ʾÀý18: TWI_ConfigureMaster

/** * /brief Configures a TWI peripheral to operate in master mode, at the given * frequency (in Hz). The duty cycle of the TWI clock is set to 50%. * /param pTwi  Pointer to an Twi instance. * /param twck  Desired TWI clock frequency. * /param mck  Master clock frequency. */static void TWI_ConfigureMaster(Twi* pTwi, uint32_t dwTwCk, uint32_t dwMCk){	twi_options_t opt;	opt.speed = dwTwCk;	opt.master_clk = dwMCk;	opt.chip = opt.smbus = 0;	twi_master_init(pTwi, &opt);}
¿ª·¢ÕßID:chrishamm£¬ÏîÄ¿Ãû³Æ:ArduinoDuet£¬´úÂëÐÐÊý:16£¬


ʾÀý19: ioport_set_pin_dir

// Supporting function implementationAccelerometer::Accelerometer() {	// Initialize variables	uint8_t value;		// Configure VDDIO, SDA and SCL pins	ioport_set_pin_dir(ACCELEROMETER_VDDIO_PIN, IOPORT_DIR_OUTPUT);	ioport_set_pin_level(ACCELEROMETER_VDDIO_PIN, IOPORT_PIN_LEVEL_HIGH);	ioport_set_pin_mode(ACCELEROMETER_SDA_PIN, IOPORT_MODE_WIREDANDPULL);	ioport_set_pin_mode(ACCELEROMETER_SCL_PIN, IOPORT_MODE_WIREDANDPULL);		// Configure interface	twi_options_t options;	options.speed = BUS_SPEED;	options.chip = MASTER_ADDRESS;	options.speed_reg = TWI_BAUD(sysclk_get_cpu_hz(), BUS_SPEED);		// Initialize interface	sysclk_enable_peripheral_clock(&TWI_MASTER);	twi_master_init(&TWI_MASTER, &options);	twi_master_enable(&TWI_MASTER);	// Create packet	twi_package_t packet;	packet.addr[0] = WHO_AM_I;	packet.addr_length = 1;	packet.chip = ACCELEROMETER_ADDRESS;	packet.buffer = &value;	packet.length = 1;	packet.no_wait = false;		// Check if transmitting or receiving failed	if(twi_master_read(&TWI_MASTER, &packet) != TWI_SUCCESS || value != DEVICE_ID)			// Clear is working		isWorking = false;		// Otherwise	else {			// Reset the accelerometer		writeValue(CTRL_REG2, CTRL_REG2_RST);				// Wait enough time for accelerometer to initialize		delay_ms(1);				// Initialize settings		initializeSettings();				// Calibrate		//calibrate();			// Set is working		isWorking = true;	}}
¿ª·¢ÕßID:thankyoucaptainobvious£¬ÏîÄ¿Ãû³Æ:iMe£¬´úÂëÐÐÊý:57£¬


ʾÀý20: init_twi

static void init_twi(uint32_t fpba_hz){#if(DEFAULT_DACS == AUDIO_MIXER_DAC_ABDAC)    const gpio_map_t TPA6130_TWI_GPIO_MAP =    {        {TPA6130_TWI_SCL_PIN, TPA6130_TWI_SCL_FUNCTION},        {TPA6130_TWI_SDA_PIN, TPA6130_TWI_SDA_FUNCTION}    };    twi_options_t TPA6130_TWI_OPTIONS =    {        .speed = TPA6130_TWI_MASTER_SPEED,        .chip = TPA6130_TWI_ADDRESS    };    TPA6130_TWI_OPTIONS.pba_hz = fpba_hz;    // Assign I/Os to TWI.    gpio_enable_module(TPA6130_TWI_GPIO_MAP,                       sizeof(TPA6130_TWI_GPIO_MAP) / sizeof(TPA6130_TWI_GPIO_MAP[0]));    // Initialize as master.    twi_master_init(TPA6130_TWI, &TPA6130_TWI_OPTIONS);#elif(DEFAULT_DACS == AUDIO_MIXER_DAC_AIC23B)    static const gpio_map_t AIC23B_TWI_GPIO_MAP =    {        {AIC23B_TWI_SCL_PIN, AIC23B_TWI_SCL_FUNCTION},        {AIC23B_TWI_SDA_PIN, AIC23B_TWI_SDA_FUNCTION}    };    static twi_options_t AIC23B_TWI_OPTIONS =    {        .speed  = AIC23B_TWI_MASTER_SPEED,        .chip   = AIC23B_TWI_ADDRESS    };    AIC23B_TWI_OPTIONS.pba_hz = fpba_hz;    gpio_enable_module(AIC23B_TWI_GPIO_MAP,                       sizeof(AIC23B_TWI_GPIO_MAP) / sizeof(AIC23B_TWI_GPIO_MAP[0]));    twi_master_init(AIC23B_TWI, &AIC23B_TWI_OPTIONS);#endif}
¿ª·¢ÕßID:kerichsen£¬ÏîÄ¿Ãû³Æ:asf£¬´úÂëÐÐÊý:43£¬


ʾÀý21: rgb_lcd_init

void rgb_lcd_init(){    if (!twi_master_init()) {        APP_ERROR_CHECK(1);    }    rgb_lcd_begin();}
¿ª·¢ÕßID:aep£¬ÏîÄ¿Ãû³Æ:nrfbot£¬´úÂëÐÐÊý:10£¬


ʾÀý22: dev_init

void dev_init(void){    gpio_init();    twi_master_init();    timers_init();      //app_button_init()¤äble_conn_params_init()¤è¤ê¤âǰ¤Ëºô¤Ö¤³¤È!                        //ºô¤Ð¤Ê¤«¤Ã¤¿¤é¡¢NRF_ERROR_INVALID_STATE(8)¤¬
C++ twi_master_transferº¯Êý´úÂëʾÀý
C++ twi_initº¯Êý´úÂëʾÀý
ÍòÊÂOK×ÔÑ§Íø£º51×ÔÑ§Íø_Èí¼þ×ÔÑ§Íø_CAD×ÔÑ§Íø×Ôѧexcel¡¢×ÔѧPS¡¢×ÔѧCAD¡¢×ÔѧCÓïÑÔ¡¢×Ôѧcss3ʵÀý£¬ÊÇÒ»¸öͨ¹ýÍøÂç×ÔÖ÷ѧϰ¹¤×÷¼¼ÄܵÄ×Ôѧƽ̨£¬ÍøÓÑϲ»¶µÄÈí¼þ×ÔÑ§ÍøÕ¾¡£