2014-09-29 17:41:41 -04:00
|
|
|
# test ptr16 type
|
|
|
|
|
|
|
|
@micropython.viper
|
|
|
|
def set(dest:ptr16, val:int):
|
|
|
|
dest[0] = val
|
|
|
|
|
2015-10-13 13:24:36 -04:00
|
|
|
@micropython.viper
|
|
|
|
def set1(dest:ptr16, val:int):
|
|
|
|
dest[1] = val
|
|
|
|
|
2014-09-29 17:41:41 -04:00
|
|
|
@micropython.viper
|
|
|
|
def memset(dest:ptr16, val:int, n:int):
|
|
|
|
for i in range(n):
|
|
|
|
dest[i] = val
|
|
|
|
|
2015-10-13 13:24:36 -04:00
|
|
|
@micropython.viper
|
|
|
|
def memset2(dest_in, val:int):
|
|
|
|
dest = ptr16(dest_in)
|
|
|
|
n = int(len(dest_in)) >> 1
|
|
|
|
for i in range(n):
|
|
|
|
dest[i] = val
|
|
|
|
|
2014-09-29 17:41:41 -04:00
|
|
|
b = bytearray(4)
|
|
|
|
print(b)
|
|
|
|
|
|
|
|
set(b, 0x4242)
|
|
|
|
print(b)
|
|
|
|
|
2015-10-13 13:24:36 -04:00
|
|
|
set1(b, 0x4343)
|
|
|
|
print(b)
|
|
|
|
|
|
|
|
memset(b, 0x4444, len(b) // 2)
|
|
|
|
print(b)
|
|
|
|
|
|
|
|
memset2(b, 0x4545)
|
2014-09-29 17:41:41 -04:00
|
|
|
print(b)
|