Lines Matching +full:address +full:- +full:0

4  * SPDX-License-Identifier: Apache-2.0
20 zassert_not_equal(0, size, "Unexpected size of zero bytes"); in ZTEST_USER()
26 const uint8_t data[4] = { 0x01, 0x02, 0x03, 0x03 }; in ZTEST_USER()
32 rc = eeprom_write(eeprom, size - 1, data, sizeof(data)); in ZTEST_USER()
33 zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
39 const uint8_t wr_buf1[4] = { 0xFF, 0xEE, 0xDD, 0xCC }; in ZTEST_USER()
40 const uint8_t wr_buf2[sizeof(wr_buf1)] = { 0xAA, 0xBB, 0xCC, 0xDD }; in ZTEST_USER()
43 off_t address; in ZTEST_USER() local
48 address = 0; in ZTEST_USER()
49 while (address < MIN(size, 16)) { in ZTEST_USER()
50 rc = eeprom_write(eeprom, address, wr_buf1, sizeof(wr_buf1)); in ZTEST_USER()
51 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
53 rc = eeprom_read(eeprom, address, rd_buf, sizeof(rd_buf)); in ZTEST_USER()
54 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
57 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
59 address += sizeof(wr_buf1); in ZTEST_USER()
62 address = 0; in ZTEST_USER()
63 while (address < MIN(size, 16)) { in ZTEST_USER()
64 rc = eeprom_write(eeprom, address, wr_buf2, sizeof(wr_buf2)); in ZTEST_USER()
65 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
67 rc = eeprom_read(eeprom, address, rd_buf, sizeof(rd_buf)); in ZTEST_USER()
68 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
71 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
73 address += sizeof(wr_buf2); in ZTEST_USER()
77 /* Test write at fixed address */
80 const uint8_t wr_buf1[4] = { 0xFF, 0xEE, 0xDD, 0xCC }; in ZTEST_USER()
83 const off_t address = 0; in ZTEST_USER() local
88 for (int i = 0; i < 16; i++) { in ZTEST_USER()
89 rc = eeprom_write(eeprom, address, wr_buf1, sizeof(wr_buf1)); in ZTEST_USER()
90 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
92 rc = eeprom_read(eeprom, address, rd_buf, sizeof(rd_buf)); in ZTEST_USER()
93 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
96 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
103 const uint8_t wr = 0x00; in ZTEST_USER()
104 uint8_t rd = 0xff; in ZTEST_USER()
107 for (off_t address = 0; address < 16; address++) { in ZTEST_USER() local
108 rc = eeprom_write(eeprom, address, &wr, 1); in ZTEST_USER()
109 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
111 rc = eeprom_read(eeprom, address, &rd, 1); in ZTEST_USER()
112 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
114 zassert_equal(wr - rd, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
118 /* Test write a pattern of bytes at increasing address */
121 const uint8_t wr_buf1[8] = {0xEE, 0xDD, 0xCC, 0xBB, 0xFF, 0xEE, 0xDD, in ZTEST_USER()
122 0xCC }; in ZTEST_USER()
126 for (off_t address = 0; address < 4; address++) { in ZTEST_USER() local
127 rc = eeprom_write(eeprom, address, wr_buf1, sizeof(wr_buf1)); in ZTEST_USER()
128 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
130 rc = eeprom_read(eeprom, address, rd_buf, sizeof(rd_buf)); in ZTEST_USER()
131 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
134 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
141 const uint8_t wr_buf1[4] = { 0x10, 0x20, 0x30, 0x40 }; in ZTEST_USER()
142 const uint8_t wr_buf2[sizeof(wr_buf1)] = { 0xAA, 0xBB, 0xCC, 0xDD }; in ZTEST_USER()
146 rc = eeprom_write(eeprom, 0, wr_buf1, sizeof(wr_buf1)); in ZTEST_USER()
147 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
149 rc = eeprom_read(eeprom, 0, rd_buf, sizeof(rd_buf)); in ZTEST_USER()
150 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
153 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
155 rc = eeprom_write(eeprom, 0, wr_buf2, 0); in ZTEST_USER()
156 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
158 rc = eeprom_read(eeprom, 0, rd_buf, sizeof(rd_buf)); in ZTEST_USER()
159 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
162 zassert_equal(0, rc, "Unexpected error code (%d)", rc); in ZTEST_USER()
179 printk("Running tests on device \"%s\"\n", eeprom->name); in run_tests_on_eeprom()