Revision: 1777
Author: jsuijs
Date: Sat Mar 13 13:16:01 2010
Log: minor changes to tests
http://code.google.com/p/jallib/source/detail?r=1777

Modified:
 /trunk/test/jal/test_startersguide.jal
 /trunk/test/peripheral/i2c/test_i2c_hw_l1.jal
 /trunk/test/peripheral/i2c/test_i2c_sw_l1.jal

=======================================
--- /trunk/test/jal/test_startersguide.jal      Sun Mar  7 11:13:17 2010
+++ /trunk/test/jal/test_startersguide.jal      Sat Mar 13 13:16:01 2010
@@ -107,10 +107,10 @@
    sgd_initialize()
    alpha = sgd_receive_function()

-   alpha   = 0b0100_0011 -- binary
-   ;bravo   = 0q203       -- octal
-   charlie = 0x43        -- hex
-   delta   = "c"         -- ascii
+   alpha   = 0b_0100_0011  -- binary
+   ;bravo   = 0q203        -- octal
+   charlie = 0x43          -- hex
+   delta   = "c"           -- ascii

    -- ----------------------------
    test_header(1) -- print header
=======================================
--- /trunk/test/peripheral/i2c/test_i2c_hw_l1.jal       Sun Mar 15 10:24:52 2009
+++ /trunk/test/peripheral/i2c/test_i2c_hw_l1.jal       Sat Mar 13 13:16:01 2010
@@ -1,7 +1,7 @@
 -- ------------------------------------------------------
 -- Title: Test program for i2c_hardware.jal
 --
--- Author: Joep Suijs, Copyright (c) 2008..2008, all rights reserved.
+-- Author: Joep Suijs, Copyright (c) 2008..2010, all rights reserved.
 --
 -- Adapted-by:
 --
@@ -28,7 +28,8 @@
 ;@jallib use chipdef
 ;@jallib use i2c

--- generic setup (see releated examples for more details)
+-- generic setup (see releated examples for more details)
+
 ;@jallib use serial
 include serial_hardware
 serial_hw_init()
@@ -37,14 +38,13 @@

 -- i2c setup
 const word _i2c_bus_speed = 1 ; * 100kHz
-const bit _i2c_level = true   ; i2c levels (not SMB)
-
-;include i2c_software
+const bit _i2c_level = true   ; i2c levels (not SMB;  i2c_hw only)
+
 include i2c_hardware
+;include i2c_software

 i2c_initialize()

-
 var byte i2c_tx_buffer[10]
 var byte i2c_rx_buffer[10]

@@ -54,15 +54,21 @@
 const byte str1[] = "Test.\r\n"
 print_string(serial_hw_data, str1)

-
 var bit r
 var byte i
-forever loop
-
-   -- Send 2 bytes address to device 0xA0 and then read 3 bytes of data
-;   i2c_tx_buffer[0] = 0  -- high byte address within i2c eeprom
-;   i2c_tx_buffer[1] = 0  -- low byte address within i2c eeprom
+
+forever loop
+
+   -- Send 2 bytes address to device 0xA0 and
+   -- then read 3 bytes of data
+;   i2c_tx_buffer[0] = 0x12  -- high byte address within i2c eeprom
+;   i2c_tx_buffer[1] = 0x34  -- low byte address within i2c eeprom
 ;   r = i2c_send_receive(0xA0, 2, 3)
+
+   -- same as above
+   -- Send 2 bytes address to device 0xA0 and
+   -- then read 3 bytes of data
+   r = i2c_receive_wordaddr(0xA0, 0x1234, 3)

    -- same as above
    r = i2c_receive_wordaddr(0xA0, 0x0000, 3)
@@ -78,8 +84,8 @@
    serial_hw_data = " "

    -- write part (increment 3rd byte at 0x0002)
-   i2c_tx_buffer[0] = 0  -- high byte address within i2c eeprom
-   i2c_tx_buffer[1] = 2  -- low byte address within i2c eeprom
+   i2c_tx_buffer[0] = 0x12     -- high byte addr within i2c eeprom
+   i2c_tx_buffer[1] = 0x34 + 2 -- low byte addr within i2c eeprom
    i2c_tx_buffer[2] = i2c_rx_buffer[2] + 1  -- data
    r = i2c_send_receive(0xA0, 3, 0)
    print_bit_truefalse(serial_hw_data, r)
=======================================
--- /trunk/test/peripheral/i2c/test_i2c_sw_l1.jal       Sun Feb 28 14:18:18 2010
+++ /trunk/test/peripheral/i2c/test_i2c_sw_l1.jal       Sat Mar 13 13:16:01 2010
@@ -1,5 +1,5 @@
 -- ------------------------------------------------------
--- Title: Test program for i2c_hardware.jal
+-- Title: Test program for i2c_software.jal
 --
 -- Author: Joep Suijs, Copyright (c) 2008..2010, all rights reserved.
 --
@@ -26,6 +26,7 @@
 -- ------------------------------------------------------

 ;@jallib use chipdef
+;@jallib use i2c

 -- generic setup (see releated examples for more details)

@@ -37,9 +38,10 @@

 -- i2c setup
 const word _i2c_bus_speed = 1 ; * 100kHz
-
-include i2c_software
+const bit _i2c_level = true   ; i2c levels (not SMB;  i2c_hw only)
+
 ;include i2c_hardware
+include i2c_software

 i2c_initialize()

@@ -57,14 +59,20 @@

 forever loop

-   -- Send 2 bytes address to device 0xA0 and then read 3 bytes of data
-   i2c_tx_buffer[0] = 0  -- high byte address within i2c eeprom
-   i2c_tx_buffer[1] = 0  -- low byte address within i2c eeprom
-   r = i2c_send_receive(0xA0, 2, 3)
-
-;   -- same as above
-;   r = i2c_receive_wordaddr(0xA0, 0x0000, 3)
-
+   -- Send 2 bytes address to device 0xA0 and
+   -- then read 3 bytes of data
+;   i2c_tx_buffer[0] = 0x12  -- high byte address within i2c eeprom
+;   i2c_tx_buffer[1] = 0x34  -- low byte address within i2c eeprom
+;   r = i2c_send_receive(0xA0, 2, 3)
+
+   -- same as above
+   -- Send 2 bytes address to device 0xA0 and
+   -- then read 3 bytes of data
+   r = i2c_receive_wordaddr(0xA0, 0x1234, 3)
+
+   -- same as above
+   r = i2c_receive_wordaddr(0xA0, 0x0000, 3)
+
    print_bit_truefalse(serial_hw_data, r)
    serial_hw_data = " "

@@ -76,8 +84,8 @@
    serial_hw_data = " "

    -- write part (increment 3rd byte at 0x0002)
-   i2c_tx_buffer[0] = 0  -- high byte address within i2c eeprom
-   i2c_tx_buffer[1] = 2  -- low byte address within i2c eeprom
+   i2c_tx_buffer[0] = 0x12     -- high byte addr within i2c eeprom
+   i2c_tx_buffer[1] = 0x34 + 2 -- low byte addr within i2c eeprom
    i2c_tx_buffer[2] = i2c_rx_buffer[2] + 1  -- data
    r = i2c_send_receive(0xA0, 3, 0)
    print_bit_truefalse(serial_hw_data, r)

--
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to