My code is based on the CMSIS-RTOS RTX BSP released in December (App note R01AN3104EJ0203). The call to ioif_start_device is as follows: (Note: I tweaked some of these values - mostly by guesswork. The 8-bit device address of the EEPROM I'm using is 0xA0 (although there are three address bits in there, so the device address can be anywhere from 0xA0 to 0xAE). /***********************************************************************/ /* Initialise RIIC */ /***********************************************************************/ printf("RIIC Driver Version:0x%02x\n", (uint32_t)R_RIIC_GetVersion()); for (idx = 0; idx RIIC_CH_NUM; idx++) { riic_cfg[idx].enabled = false; } riic_cfg[1].enabled = true; riic_cfg[1].int_level = 0x78; riic_cfg[1].task_pri = osPriorityNormal; /* SCL clock 50kbps */ riic_cfg[1].scl_ctl.div_rate = RIIC_PCLK_DIV_16; riic_cfg[1].scl_ctl.high_width = 22; riic_cfg[1].scl_ctl.low_width = 15; riic_cfg[1].scl_ctl.enable_filter = false; riic_cfg[1].addr_mode_set.trans_mode = RIIC_MODE_MASTER; riic_cfg[1].addr_mode_set.device_addr = 0x50; /* Microchip 24LC16B EEPROM (0xA0 1) */ riic_cfg[1].scl_timeout = RIIC_TIMEOUT_16; riic_cfg[1].enable_scl_add_output = false; riic_cfg[1].select_dma = RIIC_COPY_MODE_PIO; riic_cfg[1].rise_time = 0; riic_cfg[1].fall_time = 0; ret = ioif_start_device(R_RIIC_MakeCbTbl(), &riic_cfg, "\\dev\\riic", "", NULL); printf("ioif_start_device return %d\n", ret); if (EERROR == ret) { printf("RIIC register LastError = %d, %s\n", *ioif_get_errno(), errno2str(*ioif_get_errno())); }
↧