Author: [email protected]
Date: Mon May 4 16:28:45 2009
New Revision: 970
Modified:
trunk/include/peripheral/usb/usb_drv.jal
trunk/include/peripheral/usb/usb_drv_cdc_class.jal
trunk/include/peripheral/usb/usb_drv_core.jal
Log:
small fixed and memory optimizations USB libs
Modified: trunk/include/peripheral/usb/usb_drv.jal
==============================================================================
--- trunk/include/peripheral/usb/usb_drv.jal (original)
+++ trunk/include/peripheral/usb/usb_drv.jal Mon May 4 16:28:45 2009
@@ -354,9 +354,19 @@
var byte tmp2[8] at usb_sdp_loc
var byte idx
- for 8 using idx loop
- tmp2[idx ] = tmp1[idx ]
- end loop
+ tmp2[0] = tmp1[0]
+ tmp2[1] = tmp1[1]
+ tmp2[2] = tmp1[2]
+ tmp2[3] = tmp1[3]
+ tmp2[4] = tmp1[4]
+ tmp2[5] = tmp1[5]
+ tmp2[6] = tmp1[6]
+ tmp2[7] = tmp1[7]
+
+ --tmp2 = tmp1
+ -- for 8 using idx loop
+ -- tmp2[idx ] = tmp1[idx ]
+ -- end loop
if USB_DEBUG > 0 then
serial_newline()
@@ -403,16 +413,15 @@
block
-- serial_hw_write( "S" )
-- standard request
-
- if ((usb_sdp_request_type &
0b00011111) == 0) then
- --print_string(
serial_hw_data," 2dev ");
- elsif ((usb_sdp_request_type &
0b00011111) == 1) then
- --print_string(
serial_hw_data," 2int ");
- elsif ((usb_sdp_request_type &
0b00011111) == 0b00011 ) then
- --print_string(
serial_hw_data," 2oth ");
- end if
-
if USB_DEBUG > 0 then
+ var byte masked_request
= (usb_sdp_request_type & 0b00011111)
+ if ( masked_request ==
0) then
+ --print_string(
serial_hw_data," 2dev ");
+ elsif ( masked_request
== 1) then
+ --print_string(
serial_hw_data," 2int ");
+ elsif ( masked_request
== 0b00011 ) then
+ --print_string(
serial_hw_data," 2oth ");
+ end if
const byte str[] = "
std "
-- print_string(
serial_hw_data,str);
end if
@@ -586,7 +595,7 @@
USB_CM_CTRL_READ_AWAITING_STATUS:
block
if USB_DEBUG > 0 then
- const byte str[] = "
----\n"
+ const byte str[] = "
-xx-\n"
print_string(
serial_hw_data, str )
end if
usb_control_mode = USB_CM_IDLE
@@ -648,28 +657,38 @@
case end_point of
0:
block
+if false then
addr = usb_bd0in_addr
bcnt = usb_bd0in_cnt
+end if
end block
1:
block
- addr = usb_bd1in_addr
- bcnt = usb_bd1in_cnt
+ if defined( USB_EP1 ) == true
then
+ addr = usb_bd1in_addr
+ bcnt = usb_bd1in_cnt
+ end if
end block
2:
block
- addr = usb_bd2in_addr
- bcnt = usb_bd2in_cnt
+ if defined( USB_EP2 ) == true
then
+ addr = usb_bd2in_addr
+ bcnt = usb_bd2in_cnt
+ end if
end block
3:
block
- addr = usb_bd3in_addr
- bcnt = usb_bd3in_cnt
+ if defined( USB_EP3 ) == true
then
+ addr = usb_bd3in_addr
+ bcnt = usb_bd3in_cnt
+ end if
end block
4:
block
- addr = usb_bd4in_addr
- bcnt = usb_bd4in_cnt
+ if defined( USB_EP4 ) == true
then
+ addr = usb_bd4in_addr
+ bcnt = usb_bd4in_cnt
+ end if
end block
otherwise
block
@@ -694,28 +713,38 @@
case end_point of
0:
block
+if false then
addr = usb_bd0out_addr
bcnt = usb_bd0out_cnt
+end if
end block
1:
block
- addr = usb_bd1out_addr
- bcnt = usb_bd1out_cnt
+ if defined( USB_EP1 ) == true
then
+ addr = usb_bd1out_addr
+ bcnt = usb_bd1out_cnt
+ end if
end block
2:
block
- addr = usb_bd2out_addr
- bcnt = usb_bd2out_cnt
+ if defined( USB_EP2 ) == true
then
+ addr = usb_bd2out_addr
+ bcnt = usb_bd2out_cnt
+ end if
end block
3:
block
- addr = usb_bd3out_addr
- bcnt = usb_bd3out_cnt
+ if defined( USB_EP3 ) == true
then
+ addr = usb_bd3out_addr
+ bcnt = usb_bd3out_cnt
+ end if
end block
4:
block
- addr = usb_bd4out_addr
- bcnt = usb_bd4out_cnt
+ if defined( USB_EP4 ) == true
then
+ addr = usb_bd4out_addr
+ bcnt = usb_bd4out_cnt
+ end if
end block
otherwise
block
@@ -848,6 +877,7 @@
-- Procedure can be called when the USB device has to be stalled
--
--------------------------------------------------------------------------------------
procedure usb_handle_stall() is
+ pragma inline
if USB_DEBUG > 0 then
const byte str[] = " U:Stall "
print_string( serial_hw_data, str )
@@ -862,7 +892,7 @@
-- to keep the input and output transfers flowing
--
--------------------------------------------------------------------------------------
procedure usb_handle_isr() is
-
+ pragma inline
-- const byte str1[] = " ENTER usb_handle_isr "
-- const byte str2[] = " EXIT usb_handle_isr "
--print_string( serial_hw_data,str1)
@@ -925,8 +955,6 @@
UIR_UERRIF = low
end if
end if
-
-
end procedure
@@ -991,6 +1019,7 @@
-- USB_STATE_CONFIGURED -> USB device is completely configured and ready
to rock and roll
--
--------------------------------------------------------------------------------------
function usb_get_state() return byte is
+ pragma inline
return usb_state;
end function
@@ -1012,7 +1041,7 @@
-- Procedure to turn on the USB device
--
--------------------------------------------------------------------------------------
procedure usb_enable_module() is
-
+ pragma inline
UIR = 0
UCON = 0x00
Modified: trunk/include/peripheral/usb/usb_drv_cdc_class.jal
==============================================================================
--- trunk/include/peripheral/usb/usb_drv_cdc_class.jal (original)
+++ trunk/include/peripheral/usb/usb_drv_cdc_class.jal Mon May 4 16:28:45
2009
@@ -84,6 +84,7 @@
var volatile byte cdc_in_addrh is usb_bd3in_addrh
procedure usb_handle_class_request_callback() is
+ pragma inline
-- compiler issue, do local assignment to resolve
var byte req01 = usb_sdp_request
@@ -146,8 +147,9 @@
end case
end procedure
-procedure usb_handle_class_ctrl_write_callback() is
-
+procedure usb_handle_class_ctrl_write_callback() is
+ pragma inline
+
-- compiler issue, do local assignment to resolve
var byte req01 = usb_sdp_request
@@ -219,6 +221,7 @@
end procedure
procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
+ pragma inline
var byte cdc_rx_next
if USB_CDC_DEBUG > 0 then
const byte str[] = " EP data out: "
@@ -235,8 +238,8 @@
var byte src_ptr[2] AT buffer_addr
- FSR0L = src_ptr[0]
- FSR0H = src_ptr[1]
+ FSR1L = src_ptr[0]
+ FSR1H = src_ptr[1]
for byte_count using count loop
@@ -249,7 +252,7 @@
if (cdc_rx_next != cdc_rx_rd) then
-- if space in the fifo
- var byte ch = POSTINC0
+ var byte ch = POSTINC1
if USB_CDC_DEBUG > 0 then
serial_hw_write("$")
@@ -393,7 +396,7 @@
-- This function is called when data can be transmitted via the bulk
interface
--
--------------------------------------------------------------------------------------
procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
-
+ pragma inline
if USB_CDC_DEBUG > 0 then
const byte str[] = " EP data in: "
const byte str1[] = " bytes "
Modified: trunk/include/peripheral/usb/usb_drv_core.jal
==============================================================================
--- trunk/include/peripheral/usb/usb_drv_core.jal (original)
+++ trunk/include/peripheral/usb/usb_drv_core.jal Mon May 4 16:28:45 2009
@@ -25,7 +25,7 @@
-- destination memory location. The function copies num_bytes bytes
--
--------------------------------------------------------------------------------------
procedure _usb_copy_array_to_ram( WORD in dst, byte in data[], byte in
num_bytes ) is
- --pragma inline
+ -- pragma inline
var byte index
var byte dst_ptr[2] AT dst
@@ -95,20 +95,18 @@
else
if USB_DEBUG > 0 then
print_byte_hex(serial_hw_data, 0b_1100_1000 )
- end if
+ end if
usb_bd0in_stat = 0b_1100_1000
end if
usb_delivery_bytes_sent = usb_delivery_bytes_sent + byte_cnt
if ( usb_delivery_bytes_sent == usb_delivery_bytes_to_send )
then
- usb_control_mode = USB_CM_CTRL_READ_AWAITING_STATUS --
we're done with
data stage
+ -- usb_control_mode = USB_CM_CTRL_READ_AWAITING_STATUS
-- we're done
with data stage
if USB_DEBUG > 0 then
serial_hw_write( "@" )
end if
end if
-
-
end if
end procedure
@@ -195,7 +193,7 @@
0:
block
_usb_copy_array_to_ram( USB_EP0_IN_ADDR, data, byte_cnt
)
- usb_bd1in_addr = USB_EP0_IN_ADDR
+ usb_bd0in_addr = USB_EP0_IN_ADDR
var volatile bit dts_bit at usb_bd0in_stat :
USB_BDSTATUS_DTS
if is_new_sequence then
@@ -203,11 +201,11 @@
dts_bit = low
end if
- if USB_DEBUG > 0 then
- serial_newline()
- serial_hw_write("i")
- print_byte_hex(serial_hw_data, usb_bd0in_stat )
- end if
+ if USB_DEBUG > 0 then
+ serial_newline()
+ serial_hw_write("i")
+ print_byte_hex(serial_hw_data, usb_bd0in_stat )
+ end if
if ( dts_bit ) then
if USB_DEBUG > 0 then
@@ -221,49 +219,57 @@
usb_bd0in_stat = 0b_1100_1000
end if
end block
+
1:
block
- _usb_copy_array_to_ram( USB_EP1_IN_ADDR, data, byte_cnt
)
- usb_bd1in_addr = USB_EP1_IN_ADDR
-
- usb_bd1in_cnt = byte_cnt
- var volatile bit dts_bit at usb_bd1in_stat :
USB_BDSTATUS_DTS
- if is_new_sequence then
- dts_bit = high
+ if USB_EP1 then
+ _usb_copy_array_to_ram( USB_EP1_IN_ADDR, data,
byte_cnt )
+ usb_bd1in_addr = USB_EP1_IN_ADDR
+
+ usb_bd1in_cnt = byte_cnt
+ var volatile bit dts_bit at usb_bd1in_stat :
USB_BDSTATUS_DTS
+ if is_new_sequence then
+ dts_bit = high
+ end if
+ if ( dts_bit ) then
+ usb_bd1in_stat = 0b_1000_1000
+ else
+ usb_bd1in_stat = 0b_1100_1000
+ end if
end if
- if ( dts_bit ) then
- usb_bd1in_stat = 0b_1000_1000
- else
- usb_bd1in_stat = 0b_1100_1000
- end if
end block
2:
block
- _usb_copy_array_to_ram( USB_EP2_IN_ADDR, data, byte_cnt
)
- usb_bd2in_addr = USB_EP0_IN_ADDR
- var volatile bit dts_bit at usb_bd2in_stat :
USB_BDSTATUS_DTS
- if is_new_sequence then
- dts_bit = high
+ if USB_EP2 then
+ _usb_copy_array_to_ram( USB_EP2_IN_ADDR, data,
byte_cnt )
+ usb_bd2in_addr = USB_EP0_IN_ADDR
+ var volatile bit dts_bit at usb_bd2in_stat :
USB_BDSTATUS_DTS
+ if is_new_sequence then
+ dts_bit = high
+ end if
+ if ( dts_bit ) then
+ usb_bd2in_stat = 0b_1000_1000
+ else
+ usb_bd2in_stat = 0b_1100_1000
+ end if
end if
- if ( dts_bit ) then
- usb_bd2in_stat = 0b_1000_1000
- else
- usb_bd2in_stat = 0b_1100_1000
- end if
end block
+
3:
block
- _usb_copy_array_to_ram( USB_EP3_IN_ADDR, data, byte_cnt
)
- usb_bd3in_addr = USB_EP0_IN_ADDR
- var volatile bit dts_bit at usb_bd3in_stat :
USB_BDSTATUS_DTS
- if is_new_sequence then
- dts_bit = high
+ if USB_EP3 then
+ _usb_copy_array_to_ram( USB_EP3_IN_ADDR, data,
byte_cnt )
+ usb_bd3in_addr = USB_EP0_IN_ADDR
+ var volatile bit dts_bit at usb_bd3in_stat :
USB_BDSTATUS_DTS
+ if is_new_sequence then
+ dts_bit = high
+ end if
+ if ( dts_bit ) then
+ usb_bd3in_stat = 0b_1000_1000
+ else
+ usb_bd3in_stat = 0b_1100_1000
+ end if
end if
- if ( dts_bit ) then
- usb_bd3in_stat = 0b_1000_1000
- else
- usb_bd3in_stat = 0b_1100_1000
- end if
end block
otherwise
block
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---