Changeset 0510cfd8 in rtems
- Timestamp:
- 11/11/14 11:41:58 (9 years ago)
- Branches:
- 4.11, 5, master
- Children:
- 8100e71
- Parents:
- 67ac69fc
- git-author:
- Sebastian Huber <sebastian.huber@…> (11/11/14 11:41:58)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (11/20/14 09:30:17)
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/dev/Makefile.am
r67ac69fc r0510cfd8 10 10 include_dev_i2c_HEADERS += include/dev/i2c/gpio-nxp-pca9535.h 11 11 include_dev_i2c_HEADERS += include/dev/i2c/i2c.h 12 include_dev_i2c_HEADERS += include/dev/i2c/switch-nxp-pca9548a.h 12 13 13 14 include_linuxdir = $(includedir)/linux … … 23 24 libdev_a_SOURCES += i2c/i2c-bus.c 24 25 libdev_a_SOURCES += i2c/i2c-dev.c 26 libdev_a_SOURCES += i2c/switch-nxp-pca9548a.c 25 27 26 28 include $(srcdir)/preinstall.am -
cpukit/dev/preinstall.am
r67ac69fc r0510cfd8 36 36 PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/i2c/i2c.h 37 37 38 $(PROJECT_INCLUDE)/dev/i2c/switch-nxp-pca9548a.h: include/dev/i2c/switch-nxp-pca9548a.h $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) 39 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/i2c/switch-nxp-pca9548a.h 40 PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/i2c/switch-nxp-pca9548a.h 41 38 42 $(PROJECT_INCLUDE)/linux/$(dirstamp): 39 43 @$(MKDIR_P) $(PROJECT_INCLUDE)/linux -
testsuites/libtests/i2c01/init.c
r67ac69fc r0510cfd8 20 20 #include <dev/i2c/eeprom.h> 21 21 #include <dev/i2c/gpio-nxp-pca9535.h> 22 #include <dev/i2c/switch-nxp-pca9548a.h> 22 23 23 24 #include <sys/ioctl.h> … … 42 43 43 44 #define DEVICE_GPIO_NXP_PCA9535 (2UL << SPARE_ADDRESS_BITS) 45 46 #define DEVICE_SWITCH_NXP_PCA9548A (3UL << SPARE_ADDRESS_BITS) 44 47 45 48 #define EEPROM_SIZE 512 … … 74 77 75 78 typedef struct { 79 test_device base; 80 uint8_t control; 81 } test_device_switch_nxp_pca9548a; 82 83 typedef struct { 76 84 i2c_bus base; 77 85 unsigned long clock; 78 test_device *devices[ 3];86 test_device *devices[4]; 79 87 test_device_simple_read_write simple_read_write; 80 88 test_device_gpio_nxp_pca9535 gpio_nxp_pca9535; 81 89 test_device_eeprom eeprom; 90 test_device_switch_nxp_pca9548a switch_nxp_pca9548a; 82 91 } test_bus; 83 92 … … 87 96 88 97 static const char eeprom_path[] = "/dev/i2c-0.eeprom-0"; 98 99 static const char switch_nxp_pca9548a_path[] = 100 "/dev/i2c-0.switch-nxp-pca9548a-0"; 89 101 90 102 static void cyclic_inc(unsigned *val, unsigned cycle) … … 218 230 } 219 231 232 static int test_switch_nxp_pca9548a_transfer( 233 i2c_bus *bus, 234 i2c_msg *msgs, 235 uint32_t msg_count, 236 test_device *base 237 ) 238 { 239 test_device_switch_nxp_pca9548a *dev = (test_device_switch_nxp_pca9548a *) base; 240 uint32_t i; 241 242 for (i = 0; i < msg_count; ++i) { 243 i2c_msg *msg = &msgs[i]; 244 int j; 245 246 if ((msg->flags & I2C_M_RD) != 0) { 247 for (j = 0; j < msg->len; ++j) { 248 msg->buf[j] = dev->control; 249 } 250 } else { 251 for (j = 0; j < msg->len; ++j) { 252 dev->control = msg->buf[j]; 253 } 254 } 255 } 256 257 return 0; 258 } 259 220 260 static int test_transfer(i2c_bus *base, i2c_msg *msgs, uint32_t msg_count) 221 261 { … … 439 479 } 440 480 481 static void test_switch_nxp_pca9548a(void) 482 { 483 int rv; 484 int fd; 485 uint8_t val; 486 487 rv = i2c_dev_register_switch_nxp_pca9548a( 488 &bus_path[0], 489 &switch_nxp_pca9548a_path[0], 490 DEVICE_SWITCH_NXP_PCA9548A 491 ); 492 rtems_test_assert(rv == 0); 493 494 fd = open(&switch_nxp_pca9548a_path[0], O_RDWR); 495 rtems_test_assert(fd >= 0); 496 497 rv = switch_nxp_pca9548a_get_control(fd, &val); 498 rtems_test_assert(rv == 0); 499 rtems_test_assert(val == 0); 500 501 rv = switch_nxp_pca9548a_set_control(fd, 0xa5); 502 rtems_test_assert(rv == 0); 503 504 rv = switch_nxp_pca9548a_get_control(fd, &val); 505 rtems_test_assert(rv == 0); 506 rtems_test_assert(val == 0xa5); 507 508 rv = close(fd); 509 rtems_test_assert(rv == 0); 510 511 rv = unlink(&switch_nxp_pca9548a_path[0]); 512 rtems_test_assert(rv == 0); 513 } 514 441 515 static void test(void) 442 516 { … … 466 540 bus->devices[2] = &bus->gpio_nxp_pca9535.base; 467 541 542 bus->switch_nxp_pca9548a.base.transfer = test_switch_nxp_pca9548a_transfer; 543 bus->devices[3] = &bus->switch_nxp_pca9548a.base; 544 468 545 rv = i2c_bus_register(&bus->base, &bus_path[0]); 469 546 rtems_test_assert(rv == 0); … … 534 611 test_eeprom(); 535 612 test_gpio_nxp_pca9535(); 613 test_switch_nxp_pca9548a(); 536 614 537 615 rv = close(fd);
Note: See TracChangeset
for help on using the changeset viewer.