Author: jsuijs
Date: Wed Jan 28 00:43:21 2009
New Revision: 757

Modified:
    trunk/include/jal/queue01.jal
    trunk/include/peripheral/i2c/i2c_hw_slave_isr.jal
    trunk/include/peripheral/i2c/i2c_hw_slave_msg.jal

Log:
non-blocking pseudo-var queue access

Modified: trunk/include/jal/queue01.jal
==============================================================================
--- trunk/include/jal/queue01.jal       (original)
+++ trunk/include/jal/queue01.jal       Wed Jan 28 00:43:21 2009
@@ -102,6 +102,53 @@

  end function

+
+-- -----------------------------------------------------------------------
+-- queue01_nb'get - get one byte from queue (non-blocking)
+-- -----------------------------------------------------------------------
+-- returns byte from queue, 0 if queue empty
+-- -----------------------------------------------------------------------
+function queue01_nb'get() return byte is
+   var byte v
+
+   if (queue01_in_pointer == queue01_out_pointer) then
+      -- queue is empty
+      return 0;
+   end if
+
+   ; data in queue
+   v = queue01_data[queue01_out_pointer]
+   queue01_out_pointer = queue01_out_pointer + 1
+   if (queue01_out_pointer > queue01_size) then
+      queue01_out_pointer = 0
+   end if
+
+   return v
+
+end function
+
+
+-- -----------------------------------------------------------------------
+-- queue01_nb'put - put one byte into queue (non-blocking)
+-- -----------------------------------------------------------------------
+-- -----------------------------------------------------------------------
+procedure queue01_nb'put(byte in v) is
+
+   var byte pntr = queue01_in_pointer + 1
+   if (pntr > queue01_size) then
+      pntr = 0
+   end if
+
+   if (pntr == queue01_out_pointer) then
+      -- queue full
+      return;
+   end if
+
+   queue01_data[queue01_in_pointer] = v
+   queue01_in_pointer = pntr
+
+end procedure
+
  -- -----------------------------------------------------------------------
  -- queue01'put - put one byte into queue
  -- -----------------------------------------------------------------------

Modified: trunk/include/peripheral/i2c/i2c_hw_slave_isr.jal
==============================================================================
--- trunk/include/peripheral/i2c/i2c_hw_slave_isr.jal   (original)
+++ trunk/include/peripheral/i2c/i2c_hw_slave_isr.jal   Wed Jan 28 00:43:21  
2009
@@ -63,8 +63,8 @@
     var byte tmpstat
     tmpstat = SSPSTAT

-;   queue01 = "*"
-;   print_byte_hex(queue01, tmpstat)
+;   queue01_nb = "*"
+;   print_byte_hex(queue01_nb, tmpstat)

     -- if this constant is defined, call start & stop handlers.
     if(defined(i2c_enable_start_stop_interrupts) == true) then

Modified: trunk/include/peripheral/i2c/i2c_hw_slave_msg.jal
==============================================================================
--- trunk/include/peripheral/i2c/i2c_hw_slave_msg.jal   (original)
+++ trunk/include/peripheral/i2c/i2c_hw_slave_msg.jal   Wed Jan 28 00:43:21  
2009
@@ -69,16 +69,16 @@
  ;       _usec_delay(200000)
  ;   end loop

-   queue01 = "#"
-   queue01 = "E"
+   queue01_nb = "#"
+   queue01_nb = "E"

  end procedure

  procedure i2c_hw_slave_on_start() is
     pragma inline

-   queue01 = "#"
-   queue01 = "S"
+   queue01_nb = "#"
+   queue01_nb = "S"

  end procedure

@@ -88,8 +88,8 @@
     -- let user process buffer
     i2c_call_process_message()

-   queue01 = "#"
-   queue01 = "P"
+   queue01_nb = "#"
+   queue01_nb = "P"

  end procedure

@@ -101,8 +101,8 @@
     -- let user process buffer (there should not be one if the proper  
procedure is executed)
     i2c_call_process_message()

-   queue01 = "#"
-   queue01 = "1"
+   queue01_nb = "#"
+   queue01_nb = "1"

  end procedure

@@ -119,8 +119,8 @@
        i2c_index = i2c_index + 1   -- point to next position
     end if

-   queue01 = "#"
-   queue01 = "2"
+   queue01_nb = "#"
+   queue01_nb = "2"

  end procedure

@@ -138,8 +138,8 @@
     i2c_hw_slave_write_i2c(i2c_buffer[0])   -- send data
     i2c_index = 1                          -- point to next position

-   queue01 = "#"
-   queue01 = "3"
+   queue01_nb = "#"
+   queue01_nb = "3"

  end procedure

@@ -156,8 +156,8 @@
     i2c_hw_slave_write_i2c(i2c_buffer[i2c_index])    -- send data
     i2c_index = i2c_index + 1                    -- point to next position

-   queue01 = "#"
-   queue01 = "4"
+   queue01_nb = "#"
+   queue01_nb = "4"

  end procedure

@@ -168,8 +168,8 @@
     pragma inline
     -- data = 0

-   queue01 = "#"
-   queue01 = "5"
+   queue01_nb = "#"
+   queue01_nb = "5"

  end procedure


--~--~---------~--~----~------------~-------~--~----~
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