aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/common/lib/hardware/1wire-crc8-test.frt
blob: 1c628d621203943186a96360dc8d13cb7bf95265 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
\ 2013-01-21  EW

marker --start--

include ewlib/1wire_crc8.fs

\ testdata from Dallas Application Note 27
\ A2 00 00 00 01 B8 1C 02
\ ^^crc        fam.code^^

: run_test
  $A2                         \ crc
  $00 $00 $00 $01 $B8 $1C $02 \ rom id 
  #7                          \ N
  .s
  1w.crc8? if
    ." crc ok"
  else
    ." crc error"
  then
  cr
  $A2 1+                      \ WRONG CRC!
  $00 $00 $00 $01 $B8 $1C $02 \ rom id 
  #7                          \ N
  .s
  1w.crc8? if
    ." crc ok"
  else
    ." crc error"
  then
  cr

  \ reverse test
  $02 $1C $B8 $01 $00 $00 $00 $A2
  #7 .s
  1w.crc8.rev? if
    ." crc ok"
  else
    ." crc error"
  then
  cr
    
  $02 $1C $B8 $01 $00 $00 $00 $A2 1+ \ WRONG CRC!
  #7 .s
  1w.crc8.rev? if
    ." crc ok"
  else
    ." crc error"
  then
  cr
    
  
;