Author: [email protected]
Date: Wed May 13 11:37:28 2009
New Revision: 982
Modified:
trunk/include/peripheral/usb/usb_defs.jal
trunk/include/peripheral/usb/usb_drv.jal
trunk/include/peripheral/usb/usb_drv_cdc_class.jal
trunk/include/peripheral/usb/usb_drv_core.jal
trunk/include/peripheral/usb/usb_serial.jal
trunk/sample/18f2450_usb_hid_generic.jal
trunk/sample/18f2450_usb_hid_keyboard.jal
trunk/sample/18f2450_usb_hid_mouse.jal
trunk/sample/18f2450_usb_serial.jal
trunk/sample/18f4550_usb_hid_generic.jal
trunk/sample/18f4550_usb_hid_keyboard.jal
trunk/sample/18f4550_usb_hid_mouse.jal
trunk/sample/18f4550_usb_serial.jal
trunk/test/peripheral/usb/test_usb_hid_generic.jal
trunk/test/peripheral/usb/test_usb_hid_keyboard.jal
trunk/test/peripheral/usb/test_usb_hid_mouse.jal
Log:
restruct USB callbacks, fixed usb_serial receive lockup problem
Modified: trunk/include/peripheral/usb/usb_defs.jal
==============================================================================
--- trunk/include/peripheral/usb/usb_defs.jal (original)
+++ trunk/include/peripheral/usb/usb_defs.jal Wed May 13 11:37:28 2009
@@ -138,6 +138,7 @@
var byte usb_control_mode
var byte usb_address
+var volatile byte usb_bd_array[ 255 ] at ( USB_BASE_ADDRESS + 0x0000 )
var volatile byte usb_bd0out[4] at ( USB_BASE_ADDRESS + 0x0000 )
var volatile byte usb_bd0out_stat at usb_bd0out[0]
Modified: trunk/include/peripheral/usb/usb_drv.jal
==============================================================================
--- trunk/include/peripheral/usb/usb_drv.jal (original)
+++ trunk/include/peripheral/usb/usb_drv.jal Wed May 13 11:37:28 2009
@@ -121,7 +121,6 @@
block
if USB_DEBUG > 0 then
-
const byte str1[] = " HID
report "
print_string(
serial_hw_data,str1)
end if
@@ -146,18 +145,10 @@
if ( usb_delivery_bytes_to_send > 0 ) then
- var byte high_byte = wbt_length[1]
- -- -- we've got something
+ -- we've got something
usb_delivery_buffer_size = USB_EP0_IN_SIZE
-
--- serial_newline()
--- serial_hw_write( "{" )
--- print_byte_hex(serial_hw_data, wbtLength[0] )
--- print_byte_hex(serial_hw_data, highByte )
--- serial_hw_write( "}" )
- -- COMPILER ISSUE, if ( wbtLength[1] == 0 )
then does not work ????
- if ( high_byte == 0 ) then
+ if ( wbt_length[1] == 0 ) then
usb_delivery_bytes_max_send =
wbt_length[0]
else
usb_delivery_bytes_max_send = 0xFF
@@ -170,11 +161,6 @@
dts_bit = low
-- AF ISO OF PRIME
- -- serial_hw_write( ">" )
- -- print_byte_hex(serial_hw_data, 0b_1000_0000
)
- -- usb_bd0out_stat = 0b_1000_0000
- -- serial_hw_write( 10 )
-
usb_send_data_chunk()
else
@@ -218,7 +204,7 @@
usb_configure_endpoints();
-- and do a call back to let the app know we're ready
- if USB_CALLBACK_ON_DEVICE_CONFIGURED then
+ if defined( usb_device_configured_callback ) == true
then
usb_device_configured_callback()
end if
end block
@@ -382,11 +368,6 @@
usb_prime_ep0_out()
if USB_DEBUG > 0 then
- --const byte str[] = " SUP "
- --print_string( serial_hw_data,str)
-
- --serial_print_hex_hex(
usb_sdp_request_type );
- --serial_hw_write(" ");
var volatile bit dir_bit at
usb_sdp_request_type :
USB_DATA_STAGE_DIR_BIT
@@ -399,14 +380,10 @@
end if
end if
- -- print_string( serial_hw_data," len: ");
- -- print_byte_hex(serial_hw_data,
usb_sdp_length);
- -- Is it a standard request?
- -- serial_hw_write('\\');
-
- -- AGAIN A COMPILER ISSUE, first assign to
req01, then shift and mask
- var byte req01 = usb_sdp_request_type
- req01 = ( req01 >> USB_REQUEST_TYPE0_BIT ) &
0b_0000_0011
+
+ -- obtain request
+ var byte req01
+ req01 = ( usb_sdp_request_type >>
USB_REQUEST_TYPE0_BIT ) &
0b_0000_0011
case req01 of
0x00:
@@ -436,7 +413,7 @@
const byte str[] = "
class "
print_string(
serial_hw_data,str)
end if
- if USB_CALLBACK_ON_CLASS_CTRL
then
+ if defined(
usb_handle_class_request_callback ) == true then
usb_handle_class_request_callback()
end if
end block
@@ -447,7 +424,7 @@
const byte str[] = "
vendor "
print_string(
serial_hw_data,str)
end if
- if USB_CALLBACK_ON_VENDOR_CTRL
then
+ if defined(
usb_handle_vendor_request_callback ) == true then
usb_handle_vendor_request_callback()
end if
end block
@@ -524,7 +501,7 @@
print_string(
serial_hw_data,str);
end if
-- Must be more to come
- if USB_CALLBACK_ON_CLASS_CTRL
then
+ if defined(
usb_handle_class_ctrl_read_callback ) == true then
usb_handle_class_ctrl_read_callback();
end if
end block
@@ -562,7 +539,7 @@
USB_CM_CTRL_READ_DATA_STAGE_CLASS:
block
- if USB_CALLBACK_ON_CLASS_CTRL
then
+ if defined(
usb_handle_class_ctrl_read_callback ) == true then
usb_handle_class_ctrl_read_callback()
end if
end block
@@ -604,7 +581,7 @@
USB_CM_CTRL_WRITE_DATA_STAGE_CLASS:
block
- if USB_CALLBACK_ON_CLASS_CTRL
then
+ if defined(
usb_handle_class_ctrl_write_callback ) == true then
usb_handle_class_ctrl_write_callback()
-- !! should include bc
bits here for total count
-- this only works for
8 bit data packets
@@ -650,130 +627,47 @@
print_byte_hex(serial_hw_data, end_point)
serial_hw_write( " " )
end if
- if USB_EP_DATA_CALLBACK then
- var word addr
- var word bcnt
+
+ if defined( usb_ep_data_in_callback ) == true then
+ var byte idx = end_point * 8
- case end_point of
- 0:
- block
-if false then
- addr = usb_bd0in_addr
- bcnt = usb_bd0in_cnt
-end if
- end block
- 1:
- block
- if defined( USB_EP1 ) == true
then
- addr = usb_bd1in_addr
- bcnt = usb_bd1in_cnt
- end if
- end block
- 2:
- block
- if defined( USB_EP2 ) == true
then
- addr = usb_bd2in_addr
- bcnt = usb_bd2in_cnt
- end if
- end block
- 3:
- block
- if defined( USB_EP3 ) == true
then
- addr = usb_bd3in_addr
- bcnt = usb_bd3in_cnt
- end if
- end block
- 4:
- block
- if defined( USB_EP4 ) == true
then
- addr = usb_bd4in_addr
- bcnt = usb_bd4in_cnt
- end if
- end block
- otherwise
- block
- if USB_DEBUG > 0 then
- const byte str1[] = "
ENPOINT NOT SUPPORTED YET "
- print_string(
serial_hw_data,str1)
- end if
- end block
- end case
+ idx = idx + 4 -- need to access the in
structures
+
+ -- print_byte_hex( serial_hw_data,idx)
+
+ var word addr
+ var byte bcnt
+ var byte bt_addr[2] at addr
+
+ bt_addr[0] = usb_bd_array[ idx + 2 ]
+ bt_addr[1] = usb_bd_array[ idx + 3 ]
+ bcnt = usb_bd_array[ idx + 1 ]
-- call callback function
usb_ep_data_in_callback( end_point, addr, bcnt )
end if
else
--- const byte str[] = " EP DATA OUT on endpoint "
--- print_string( serial_hw_data,str)
--- print_byte_hex(serial_hw_data, end_point)
-
- if USB_EP_DATA_CALLBACK then
- var word addr
- var word bcnt
- case end_point of
- 0:
- block
-if false then
- addr = usb_bd0out_addr
- bcnt = usb_bd0out_cnt
-end if
- end block
- 1:
- block
- if defined( USB_EP1 ) == true
then
- addr = usb_bd1out_addr
- bcnt = usb_bd1out_cnt
- end if
- end block
- 2:
- block
- if defined( USB_EP2 ) == true
then
- addr = usb_bd2out_addr
- bcnt = usb_bd2out_cnt
- end if
- end block
- 3:
- block
- if defined( USB_EP3 ) == true
then
- addr = usb_bd3out_addr
- bcnt = usb_bd3out_cnt
- end if
- end block
- 4:
- block
- if defined( USB_EP4 ) == true
then
- addr = usb_bd4out_addr
- bcnt = usb_bd4out_cnt
- end if
- end block
- otherwise
- block
- if USB_DEBUG > 0 then
- const byte str1[] = "
ENPOINT NOT SUPPORTED YET "
- print_string(
serial_hw_data,str1)
- end if
- end block
- end case
- -- call callback function
+
+ if defined(usb_ep_data_out_callback) == true then
+ var byte idx = end_point * 8
+
+ var word addr
+ var byte bcnt
+ var byte bt_addr[2] at addr
+
+ bt_addr[0] = usb_bd_array[ idx + 2 ]
+ bt_addr[1] = usb_bd_array[ idx + 3 ]
+ bcnt = usb_bd_array[ idx + 1 ]
+
usb_ep_data_out_callback( end_point, addr, bcnt
)
- end if
+ else
+ usb_prime_epx_out( end_point, 0x08 )
+ end if
- case end_point of
- 0: usb_bd0out_stat = 0x80
- 1: usb_bd1out_stat = 0x80
- 2: usb_bd2out_stat = 0x80
- 3: usb_bd3out_stat = 0x80
- 4: usb_bd4out_stat = 0x80
- otherwise
- block
- if USB_DEBUG > 0 then
- const byte str1[] = " ENPOINT
NOT SUPPORTED YET "
- print_string(
serial_hw_data,str1)
- end if
- end block
- end case
+
end if
- end if
+ end if -- enpoint == 0
+
end procedure
--
--------------------------------------------------------------------------------------
@@ -941,7 +835,7 @@
if ( UIR_SOFIF ) then
-- const byte str1[] = " !SOF "
-- print_string( serial_hw_data,str1)
- if USB_CALLBACK_ON_SOF then
+ if defined( usb_sof_callback ) == true then
usb_sof_callback()
end if
UIR_SOFIF = low
@@ -972,9 +866,8 @@
PIE2_USBIE = low -- general USB interrupts
- if USB_CALLBACK_ON_SOF then
- UIE_SOFIE = high
- end if
+ UIE_SOFIE = high
+
end procedure
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 Wed May 13 11:37:28
2009
@@ -23,6 +23,8 @@
--
--
+var volatile byte tmp_cdc[7] at 0x700
+
if defined( USB_CDC_DEBUG ) == false then
const bit USB_CDC_DEBUG = false
end if
@@ -41,11 +43,11 @@
-- USB to RS232 converter
-var byte cdc_line_coding[7]
-var dword cdc_line_coding_dte_rate at cdc_line_coding[0]
-var byte cdc_line_coding_stop_bits at cdc_line_coding[4] -- 0=1 stop
bit, 1=1.5 stop bits, 2=2 stop bits
-var byte cdc_line_coding_parity at cdc_line_coding[5] -- 0=None,
1=Odd, 2=Even, 3=Mark, 4=Space
-var byte cdc_line_coding_data_bits at cdc_line_coding[6] -- 5,6,7,8 or
16 bits
+var volatile byte cdc_line_coding[7]
+var volatile dword cdc_line_coding_dte_rate at cdc_line_coding[0]
+var volatile byte cdc_line_coding_stop_bits at cdc_line_coding[4] --
0=1 stop bit, 1=1.5 stop bits, 2=2 stop bits
+var volatile byte cdc_line_coding_parity at cdc_line_coding[5] --
0=None, 1=Odd, 2=Even, 3=Mark, 4=Space
+var volatile byte cdc_line_coding_data_bits at cdc_line_coding[6] --
5,6,7,8 or 16 bits
var byte cdc_line_status = 0x00
var bit last_packet_is_full = false
@@ -70,6 +72,7 @@
var volatile byte cdc_rx_wr = 0
var volatile byte cdc_rx_rd = 0
+var volatile byte cdc_rx_free = USB_CDC_RX_BUFFER_SIZE
var volatile byte cdc_out_stat is usb_bd3out_stat
var volatile byte cdc_out_cnt is usb_bd3out_cnt
@@ -101,6 +104,13 @@
const byte str[] = " SET_LINE "
print_string(serial_hw_data,str)
end if
+
+var byte idx
+ var byte bd0_out_buffer[8] at USB_EP0_OUT_ADDR
+for 7 using idx loop
+tmp_cdc[idx ] = bd0_out_buffer[idx]
+end loop
+
usb_control_mode = USB_CM_CTRL_WRITE_DATA_STAGE_CLASS
end block
USB_REQ_GET_LINE_CODING:
@@ -109,19 +119,38 @@
const byte str[] = " GET_LINE len="
print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,len & 0xFF)
- serial_hw_write(" ")
+ serial_hw_write(" ")
end if
- --control_mode = USB_CM_CTRL_READ_DATA_STAGE_CLASS
+if false then
+
usb_control_mode = USB_CM_CTRL_READ_DATA_STAGE_CLASS
-- need to prime ep0 IN with some funky data here
usb_send_data( 0, cdc_line_coding, 7, 1 )
+else
+ usb_delivery_bytes_max_send = 0xFF
+ usb_delivery_bytes_to_send = 7
+ _usb_copy_array_to_ram(
USB_IN_DELIVERY_BUFFER_LOC, cdc_line_coding,
usb_delivery_bytes_to_send )
+ usb_delivery_buffer_size = USB_EP0_IN_SIZE
+ -- usb_delivery_bytes_to_send
+ usb_control_mode = USB_CM_CTRL_READ_DATA_STAGE
+ usb_delivery_bytes_sent = 0
+ var bit dts_bit at usb_bd0in_stat :
USB_BDSTATUS_DTS
+ dts_bit = low
+
+ -- AF ISO OF PRIME
+ usb_send_data_chunk()
+end if
+
-- actually we know this will be the last packet, so go
straight to
waiting for the status ack
- usb_control_mode = USB_CM_CTRL_READ_AWAITING_STATUS
+ --usb_control_mode = USB_CM_CTRL_READ_AWAITING_STATUS
end block
+
+
+
USB_REQ_SET_CONTROL_LINE_STATE:
block
if USB_CDC_DEBUG > 0 then
@@ -147,6 +176,7 @@
end case
end procedure
+
procedure usb_handle_class_ctrl_write_callback() is
pragma inline
@@ -159,9 +189,10 @@
var byte idx
var byte bd0_out_buffer[8] at USB_EP0_OUT_ADDR
- for count( cdc_line_coding ) loop
+ for count( cdc_line_coding ) using idx loop
cdc_line_coding[ idx ] = bd0_out_buffer[idx]
end loop
+
if USB_CDC_DEBUG > 0 then
const byte str[] = " st="
@@ -180,6 +211,10 @@
print_byte_hex(serial_hw_data,cdc_line_coding_data_bits)
end if
+
+ if defined( usb_cdc_line_coding_changed_callback ) ==
true then
+ usb_cdc_line_coding_changed_callback()
+ end if
usb_control_mode = USB_CM_CTRL_WRITE_SENDING_STATUS
usb_send_status_ack()
@@ -220,7 +255,7 @@
end case
end procedure
-procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
+procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
pragma inline
var byte cdc_rx_next
if USB_CDC_DEBUG > 0 then
@@ -264,6 +299,7 @@
cdc_rx_buffer[cdc_rx_wr] = ch
cdc_rx_wr = cdc_rx_next -- and move pointer along
+ cdc_rx_free = cdc_rx_free - 1
else
-- else... just ignore it, we've lost a byte, no room in
the fifo
end if
@@ -395,7 +431,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
+procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
pragma inline
if USB_CDC_DEBUG > 0 then
const byte str[] = " EP data in: "
@@ -449,6 +485,9 @@
-- get character from the front of the buffer
cdc_rx_char = cdc_rx_buffer[ cdc_rx_rd ]
+ -- update fifo free size
+ cdc_rx_free = cdc_rx_free + 1
+
if USB_CDC_DEBUG > 0 then
serial_hw_write("<")
print_byte_hex(serial_hw_data,cdc_rx_rd)
@@ -467,6 +506,11 @@
cdc_rx_rd = cdc_rx_rd_next
+ -- AF TEMP
+ if USB_CDC_DEBUG > 0 then
+ serial_hw_write("<")
+ end if
+
-- return the result we first thought of
return cdc_rx_char
end function
@@ -491,6 +535,14 @@
procedure usb_sof_callback() is
-- we don't care about the frame number, we only care if there's
something to send...
usb_cdc_handle_tx() -- start transmission
+
+ if ( cdc_rx_free >= 8 ) then
+ var bit uown_bit shared at cdc_out_stat:USB_BDSTATUS_UOWN
+ if ( uown_bit == false ) then
+ usb_prime_epx_out( 3, USB_EP3_OUT_SIZE )
+ end if
+ end if
+
end procedure
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 Wed May 13 11:37:28 2009
@@ -172,20 +172,22 @@
var byte idx;
- if USB_DEBUG_HIGH > 0 then
+ if USB_DEBUG > 0 then
serial_newline()
serial_hw_write("~")
+ print_byte_hex(serial_hw_data, endpoint )
+ serial_hw_write(">")
end if
for byte_cnt using idx loop
usb_delivery_buffer[idx] = data[idx]
- if USB_DEBUG_HIGH > 0 then
+ if USB_DEBUG > 0 then
print_byte_hex(serial_hw_data,
usb_delivery_buffer[idx] )
end if
end loop
- if USB_DEBUG_HIGH > 0 then
+ if USB_DEBUG > 0 then
serial_hw_write("~")
end if
@@ -197,7 +199,7 @@
var volatile bit dts_bit at usb_bd0in_stat :
USB_BDSTATUS_DTS
if is_new_sequence then
- -- serial_hw_write("N")
+-- serial_hw_write("N")
dts_bit = low
end if
@@ -229,7 +231,7 @@
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
+ dts_bit = low
end if
if ( dts_bit ) then
usb_bd1in_stat = 0b_1000_1000
@@ -242,10 +244,10 @@
block
if USB_EP2 then
_usb_copy_array_to_ram( USB_EP2_IN_ADDR, data,
byte_cnt )
- usb_bd2in_addr = USB_EP0_IN_ADDR
+ usb_bd2in_addr = USB_EP2_IN_ADDR
var volatile bit dts_bit at usb_bd2in_stat :
USB_BDSTATUS_DTS
if is_new_sequence then
- dts_bit = high
+ dts_bit = low
end if
if ( dts_bit ) then
usb_bd2in_stat = 0b_1000_1000
@@ -259,10 +261,10 @@
block
if USB_EP3 then
_usb_copy_array_to_ram( USB_EP3_IN_ADDR, data,
byte_cnt )
- usb_bd3in_addr = USB_EP0_IN_ADDR
+ usb_bd3in_addr = USB_EP3_IN_ADDR
var volatile bit dts_bit at usb_bd3in_stat :
USB_BDSTATUS_DTS
if is_new_sequence then
- dts_bit = high
+ dts_bit = low
end if
if ( dts_bit ) then
usb_bd3in_stat = 0b_1000_1000
@@ -405,6 +407,7 @@
usb_bd0out_stat = usb_bd0out_stat | 0b_1000_0100
end procedure
+
procedure usb_prime_ep0_out() is
var byte new_value
usb_bd0out_cnt = USB_EP0_OUT_SIZE
@@ -413,6 +416,13 @@
-- AF CHECK THIS STUFF TODO
if ( usb_control_mode == USB_CM_CTRL_READ_DATA_STAGE ) then
new_value = 0x8C
+ if USB_DEBUG > 0 then
+ serial_newline()
+ serial_hw_write("i")
+ print_byte_hex(serial_hw_data, usb_bd0in_stat )
+ print_byte_hex(serial_hw_data, 0)
+ end if
+ usb_bd0in_stat = 0x00
else
-- AF TODO, STALL
new_value = 0b_1100_1000
@@ -423,19 +433,17 @@
serial_hw_write("o")
print_byte_hex(serial_hw_data, usb_bd0out_stat )
print_byte_hex(serial_hw_data, new_value)
+
end if
- -- AF CHECK THIS STUFF TODO
- if ( usb_control_mode == USB_CM_CTRL_READ_DATA_STAGE ) then
+ usb_bd0out_stat = new_value
+end procedure
- if USB_DEBUG > 0 then
- serial_newline()
- serial_hw_write("i")
- print_byte_hex(serial_hw_data, usb_bd0in_stat )
- print_byte_hex(serial_hw_data, 0)
- end if
- usb_bd0in_stat = 0x00
- end if
+procedure usb_prime_epx_out( byte in end_point, byte in size ) is
+ var byte idx = end_point * 8
+ -- reset size
+ usb_bd_array[ idx + 1 ] = size
+ -- set to UOWN
+ usb_bd_array[ idx ] = 0x80
- usb_bd0out_stat = new_value
end procedure
Modified: trunk/include/peripheral/usb/usb_serial.jal
==============================================================================
--- trunk/include/peripheral/usb/usb_serial.jal (original)
+++ trunk/include/peripheral/usb/usb_serial.jal Wed May 13 11:37:28 2009
@@ -57,7 +57,7 @@
-------------------------------------------------------------------------
-- consts to enable debugging
-------------------------------------------------------------------------
---const bit USB_CDC_DEBUG = 1
+--const USB_CDC_DEBUG = 1
--const USB_DEBUG = 1
--const USB_DEBUG_HIGH = 1
--const USB_CDC_DEBUG_HIGH = 1
@@ -483,12 +483,13 @@
-- setup the USB device
usb_setup()
+
+ -- setup USB communication class
+ usb_cdc_setup()
-- enable USB device
usb_enable_module()
- -- setup USB communication class
- usb_cdc_setup()
end procedure
Modified: trunk/sample/18f2450_usb_hid_generic.jal
==============================================================================
--- trunk/sample/18f2450_usb_hid_generic.jal (original)
+++ trunk/sample/18f2450_usb_hid_generic.jal Wed May 13 11:37:28 2009
@@ -23,7 +23,7 @@
--
-- compiled with following flags: -loader18 -no-fuse -no-variable-reuse
--
--- This file has been generated on 04/06/09 23:43:02, from:
+-- This file has been generated on 05/13/09 16:40:41, from:
-- * board: board_18f2450_af.jal
-- * test : test_usb_hid_generic.jal
--
@@ -141,13 +141,6 @@
const byte HID_OUT_REPORT_SIZE = 8
-const bit USB_CALLBACK_ON_CLASS_CTRL = false
-const bit USB_CALLBACK_ON_DEVICE_CONFIGURED = false
-const bit USB_CALLBACK_ON_VENDOR_CTRL = false
-const bit USB_EP_DATA_CALLBACK = true
-const bit USB_CALLBACK_ON_SOF = false
-
-
const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
USB_DEVICE_DESCRIPTOR_SIZE, -- 18 bytes long
USB_DT_DEVICE, -- DEVICE 01h
@@ -282,13 +275,16 @@
".", 0x00
}
-const byte USB_STRING2[42] =
+const byte USB_STRING2[48] =
{
- 42, -- bLength
+ 48, -- bLength
USB_DT_STRING, -- bDescriptorType
"J", 0x00,
"A", 0x00,
"L", 0x00,
+ "L", 0x00,
+ "I", 0x00,
+ "B", 0x00,
" ", 0x00,
"G", 0x00,
"e", 0x00,
@@ -462,14 +458,14 @@
end procedure
-procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
-
+procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
+ pragma inline
if USB_HID_DEBUG_HIGH then
const byte str[] = " EP data in: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,byte_count & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
end if
-- data has been sent, so do we need to send more?
@@ -480,17 +476,19 @@
end if
end procedure
-procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
+procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
+ pragma inline
+
var byte cdc_rx_next
if USB_HID_DEBUG then
const byte str[] = " EP data out: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,byte_count)
serial_hw_write( " " )
print_byte_hex(serial_hw_data, end_point )
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
end if
-- We have some data!
@@ -543,6 +541,7 @@
0x03:
block
+ PORTB = hid_tx_buffer[ 1 ]
if defined( HAS_SERIAL_DEBUG_PORT ) == true then
end if
end block
@@ -564,6 +563,9 @@
end block
end case
end if
+
+ usb_prime_epx_out( end_point, USB_EP1_OUT_SIZE )
+
end procedure
Modified: trunk/sample/18f2450_usb_hid_keyboard.jal
==============================================================================
--- trunk/sample/18f2450_usb_hid_keyboard.jal (original)
+++ trunk/sample/18f2450_usb_hid_keyboard.jal Wed May 13 11:37:28 2009
@@ -23,7 +23,7 @@
--
--
--
--- This file has been generated on 04/06/09 23:43:05, from:
+-- This file has been generated on 05/13/09 16:40:48, from:
-- * board: board_18f2450_af.jal
-- * test : test_usb_hid_keyboard.jal
--
@@ -136,12 +136,6 @@
const byte USB_EP3_IN_SIZE = 8
const word USB_EP3_IN_ADDR = 0x0000
-const bit USB_CALLBACK_ON_CLASS_CTRL = true
-const bit USB_CALLBACK_ON_DEVICE_CONFIGURED = false
-const bit USB_CALLBACK_ON_VENDOR_CTRL = false
-const bit USB_EP_DATA_CALLBACK = true
-const bit USB_CALLBACK_ON_SOF = false
-
const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
USB_DEVICE_DESCRIPTOR_SIZE, -- 18 bytes long
USB_DT_DEVICE, -- DEVICE 01h
@@ -342,9 +336,9 @@
if USB_HID_DEBUG_HIGH then
const byte str[] = " HID CL CALLBACK REQ: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,len & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
print_byte_hex(serial_hw_data,val >> 8 )
print_byte_hex(serial_hw_data,val & 0xFF)
serial_hw_write( " " )
@@ -358,7 +352,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "GET_REPORT "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -366,7 +360,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "GET_IDLE "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -374,7 +368,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "GET_PROTOCOL "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -382,7 +376,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "SET_REPORT "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
if ( len > 0 ) then
usb_control_mode =
USB_CM_CTRL_WRITE_DATA_STAGE_CLASS
@@ -394,7 +388,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "SET_IDLE "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -402,7 +396,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "SET_PROTOCOL "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -410,7 +404,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "UNKNOWN CL REQUEST "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
end case
@@ -438,7 +432,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "SET_REPORT "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
var byte idx
@@ -459,7 +453,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "UNKNOWN CL REQUEST "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -477,9 +471,9 @@
if USB_HID_DEBUG_HIGH then
const byte str[] = " HID CL CALLBACK RD: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,len & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
print_byte_hex(serial_hw_data,val >> 8 )
print_byte_hex(serial_hw_data,val & 0xFF)
serial_hw_write( " " )
@@ -488,14 +482,15 @@
end procedure
-procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
+procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
+ pragma inline
if USB_HID_DEBUG_HIGH then
const byte str[] = " EP data in: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,byte_count & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
end if
-- data has been sent, so do we need to send more?
@@ -505,21 +500,6 @@
end if
end procedure
-procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
- var byte cdc_rx_next
- if USB_HID_DEBUG then
- const byte str[] = " EP data out: "
- const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
- print_byte_hex(serial_hw_data,byte_count)
- print_byte_hex(serial_hw_data,str1)
- end if
-
- -- We have some data!
- if (end_point == USB_HID_ENDPOINT) then
- end if
-end procedure
-
include usb_drv
@@ -585,8 +565,6 @@
-- setup the USB device
usb_setup()
-
-delay_1ms(10)
-- enable USB device
usb_enable_module()
Modified: trunk/sample/18f2450_usb_hid_mouse.jal
==============================================================================
--- trunk/sample/18f2450_usb_hid_mouse.jal (original)
+++ trunk/sample/18f2450_usb_hid_mouse.jal Wed May 13 11:37:28 2009
@@ -23,7 +23,7 @@
--
--
--
--- This file has been generated on 04/06/09 23:43:14, from:
+-- This file has been generated on 05/13/09 16:40:52, from:
-- * board: board_18f2450_af.jal
-- * test : test_usb_hid_mouse.jal
--
@@ -140,15 +140,6 @@
const byte USB_EP3_IN_SIZE = 8
const word USB_EP3_IN_ADDR = 0x0000
-
-
-const bit USB_CALLBACK_ON_CLASS_CTRL = false
-const bit USB_CALLBACK_ON_DEVICE_CONFIGURED = false
-const bit USB_CALLBACK_ON_VENDOR_CTRL = false
-const bit USB_EP_DATA_CALLBACK = true
-const bit USB_CALLBACK_ON_SOF = false
-
-
const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
USB_DEVICE_DESCRIPTOR_SIZE, -- 18 bytes long
USB_DT_DEVICE, -- DEVICE 01h
@@ -287,13 +278,16 @@
".", 0x00
}
-const byte USB_STRING2[38] =
+const byte USB_STRING2[44] =
{
- 38, -- bLength
+ 44, -- bLength
USB_DT_STRING, -- bDescriptorType
"J", 0x00,
"A", 0x00,
"L", 0x00,
+ "L", 0x00,
+ "I", 0x00,
+ "B", 0x00,
" ", 0x00,
"H", 0x00,
"I", 0x00,
@@ -311,14 +305,17 @@
"o", 0x00
}
-procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
-
+include usb_drv_core
+
+
+procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
+ pragma inline
if USB_HID_DEBUG_HIGH then
const byte str[] = " EP data in: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
- serial_print_int(byte_count & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string( serial_hw_data,str )
+ print_byte_hex( serial_hw_data, byte_count & 0xFF)
+ print_string(serial_hw_data,str1)
end if
-- data has been sent, so do we need to send more?
@@ -328,28 +325,12 @@
end if
end procedure
-procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
- var byte cdc_rx_next
- if USB_HID_DEBUG then
- const byte str[] = " EP data out: "
- const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
- serial_print_int(byte_count)
- print_byte_hex(serial_hw_data,str1)
- end if
- -- We have some data!
- if (end_point == USB_HID_ENDPOINT) then
- end if
-end procedure
-
-
-include usb_drv_core
include usb_drv
-- constants
const sbyte dir_table[] = {-4,-4,-4, 0, 4, 4, 4, 0}
-const byte str_welcome[] = "JAL USB HID MOUSE DEMO version 0.3\nplease
wait (takes ~20 seconds) before the device is fully configured"
+const byte str_welcome[] = "JALLIB USB HID MOUSE DEMO version 1.0\nplease
wait (takes ~10 seconds) before the device it is fully configured"
-- variables
var word i = 0
Modified: trunk/sample/18f2450_usb_serial.jal
==============================================================================
--- trunk/sample/18f2450_usb_serial.jal (original)
+++ trunk/sample/18f2450_usb_serial.jal Wed May 13 11:37:28 2009
@@ -47,7 +47,7 @@
-- ------------------------------------------------------
--
--
--- This file has been generated on 04/29/09 21:07:02, from:
+-- This file has been generated on 05/13/09 16:40:42, from:
-- * board: board_18f2450_af.jal
-- * test : test_usb_serial.jal
--
Modified: trunk/sample/18f4550_usb_hid_generic.jal
==============================================================================
--- trunk/sample/18f4550_usb_hid_generic.jal (original)
+++ trunk/sample/18f4550_usb_hid_generic.jal Wed May 13 11:37:28 2009
@@ -23,7 +23,7 @@
--
-- compiled with following flags: -loader18 -no-fuse -no-variable-reuse
--
--- This file has been generated on 04/06/09 23:43:19, from:
+-- This file has been generated on 05/13/09 16:40:58, from:
-- * board: board_18f4550_af.jal
-- * test : test_usb_hid_generic.jal
--
@@ -149,13 +149,6 @@
const byte HID_OUT_REPORT_SIZE = 8
-const bit USB_CALLBACK_ON_CLASS_CTRL = false
-const bit USB_CALLBACK_ON_DEVICE_CONFIGURED = false
-const bit USB_CALLBACK_ON_VENDOR_CTRL = false
-const bit USB_EP_DATA_CALLBACK = true
-const bit USB_CALLBACK_ON_SOF = false
-
-
const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
USB_DEVICE_DESCRIPTOR_SIZE, -- 18 bytes long
USB_DT_DEVICE, -- DEVICE 01h
@@ -290,13 +283,16 @@
".", 0x00
}
-const byte USB_STRING2[42] =
+const byte USB_STRING2[48] =
{
- 42, -- bLength
+ 48, -- bLength
USB_DT_STRING, -- bDescriptorType
"J", 0x00,
"A", 0x00,
"L", 0x00,
+ "L", 0x00,
+ "I", 0x00,
+ "B", 0x00,
" ", 0x00,
"G", 0x00,
"e", 0x00,
@@ -470,14 +466,14 @@
end procedure
-procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
-
+procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
+ pragma inline
if USB_HID_DEBUG_HIGH then
const byte str[] = " EP data in: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,byte_count & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
end if
-- data has been sent, so do we need to send more?
@@ -488,17 +484,19 @@
end if
end procedure
-procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
+procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
+ pragma inline
+
var byte cdc_rx_next
if USB_HID_DEBUG then
const byte str[] = " EP data out: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,byte_count)
serial_hw_write( " " )
print_byte_hex(serial_hw_data, end_point )
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
end if
-- We have some data!
@@ -551,6 +549,7 @@
0x03:
block
+ PORTB = hid_tx_buffer[ 1 ]
if defined( HAS_SERIAL_DEBUG_PORT ) == true then
end if
end block
@@ -572,6 +571,9 @@
end block
end case
end if
+
+ usb_prime_epx_out( end_point, USB_EP1_OUT_SIZE )
+
end procedure
Modified: trunk/sample/18f4550_usb_hid_keyboard.jal
==============================================================================
--- trunk/sample/18f4550_usb_hid_keyboard.jal (original)
+++ trunk/sample/18f4550_usb_hid_keyboard.jal Wed May 13 11:37:28 2009
@@ -23,7 +23,7 @@
--
--
--
--- This file has been generated on 04/06/09 23:43:22, from:
+-- This file has been generated on 05/13/09 16:41:08, from:
-- * board: board_18f4550_af.jal
-- * test : test_usb_hid_keyboard.jal
--
@@ -144,12 +144,6 @@
const byte USB_EP3_IN_SIZE = 8
const word USB_EP3_IN_ADDR = 0x0000
-const bit USB_CALLBACK_ON_CLASS_CTRL = true
-const bit USB_CALLBACK_ON_DEVICE_CONFIGURED = false
-const bit USB_CALLBACK_ON_VENDOR_CTRL = false
-const bit USB_EP_DATA_CALLBACK = true
-const bit USB_CALLBACK_ON_SOF = false
-
const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
USB_DEVICE_DESCRIPTOR_SIZE, -- 18 bytes long
USB_DT_DEVICE, -- DEVICE 01h
@@ -350,9 +344,9 @@
if USB_HID_DEBUG_HIGH then
const byte str[] = " HID CL CALLBACK REQ: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,len & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
print_byte_hex(serial_hw_data,val >> 8 )
print_byte_hex(serial_hw_data,val & 0xFF)
serial_hw_write( " " )
@@ -366,7 +360,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "GET_REPORT "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -374,7 +368,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "GET_IDLE "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -382,7 +376,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "GET_PROTOCOL "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -390,7 +384,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "SET_REPORT "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
if ( len > 0 ) then
usb_control_mode =
USB_CM_CTRL_WRITE_DATA_STAGE_CLASS
@@ -402,7 +396,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "SET_IDLE "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -410,7 +404,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "SET_PROTOCOL "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -418,7 +412,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "UNKNOWN CL REQUEST "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
end case
@@ -446,7 +440,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "SET_REPORT "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
var byte idx
@@ -467,7 +461,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "UNKNOWN CL REQUEST "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -485,9 +479,9 @@
if USB_HID_DEBUG_HIGH then
const byte str[] = " HID CL CALLBACK RD: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,len & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
print_byte_hex(serial_hw_data,val >> 8 )
print_byte_hex(serial_hw_data,val & 0xFF)
serial_hw_write( " " )
@@ -496,14 +490,15 @@
end procedure
-procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
+procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
+ pragma inline
if USB_HID_DEBUG_HIGH then
const byte str[] = " EP data in: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,byte_count & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
end if
-- data has been sent, so do we need to send more?
@@ -513,21 +508,6 @@
end if
end procedure
-procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
- var byte cdc_rx_next
- if USB_HID_DEBUG then
- const byte str[] = " EP data out: "
- const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
- print_byte_hex(serial_hw_data,byte_count)
- print_byte_hex(serial_hw_data,str1)
- end if
-
- -- We have some data!
- if (end_point == USB_HID_ENDPOINT) then
- end if
-end procedure
-
include usb_drv
@@ -593,8 +573,6 @@
-- setup the USB device
usb_setup()
-
-delay_1ms(10)
-- enable USB device
usb_enable_module()
Modified: trunk/sample/18f4550_usb_hid_mouse.jal
==============================================================================
--- trunk/sample/18f4550_usb_hid_mouse.jal (original)
+++ trunk/sample/18f4550_usb_hid_mouse.jal Wed May 13 11:37:28 2009
@@ -23,7 +23,7 @@
--
--
--
--- This file has been generated on 04/06/09 23:43:31, from:
+-- This file has been generated on 05/13/09 16:41:12, from:
-- * board: board_18f4550_af.jal
-- * test : test_usb_hid_mouse.jal
--
@@ -148,15 +148,6 @@
const byte USB_EP3_IN_SIZE = 8
const word USB_EP3_IN_ADDR = 0x0000
-
-
-const bit USB_CALLBACK_ON_CLASS_CTRL = false
-const bit USB_CALLBACK_ON_DEVICE_CONFIGURED = false
-const bit USB_CALLBACK_ON_VENDOR_CTRL = false
-const bit USB_EP_DATA_CALLBACK = true
-const bit USB_CALLBACK_ON_SOF = false
-
-
const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
USB_DEVICE_DESCRIPTOR_SIZE, -- 18 bytes long
USB_DT_DEVICE, -- DEVICE 01h
@@ -295,13 +286,16 @@
".", 0x00
}
-const byte USB_STRING2[38] =
+const byte USB_STRING2[44] =
{
- 38, -- bLength
+ 44, -- bLength
USB_DT_STRING, -- bDescriptorType
"J", 0x00,
"A", 0x00,
"L", 0x00,
+ "L", 0x00,
+ "I", 0x00,
+ "B", 0x00,
" ", 0x00,
"H", 0x00,
"I", 0x00,
@@ -319,14 +313,17 @@
"o", 0x00
}
-procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
-
+include usb_drv_core
+
+
+procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
+ pragma inline
if USB_HID_DEBUG_HIGH then
const byte str[] = " EP data in: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
- serial_print_int(byte_count & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string( serial_hw_data,str )
+ print_byte_hex( serial_hw_data, byte_count & 0xFF)
+ print_string(serial_hw_data,str1)
end if
-- data has been sent, so do we need to send more?
@@ -336,28 +333,12 @@
end if
end procedure
-procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
- var byte cdc_rx_next
- if USB_HID_DEBUG then
- const byte str[] = " EP data out: "
- const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
- serial_print_int(byte_count)
- print_byte_hex(serial_hw_data,str1)
- end if
- -- We have some data!
- if (end_point == USB_HID_ENDPOINT) then
- end if
-end procedure
-
-
-include usb_drv_core
include usb_drv
-- constants
const sbyte dir_table[] = {-4,-4,-4, 0, 4, 4, 4, 0}
-const byte str_welcome[] = "JAL USB HID MOUSE DEMO version 0.3\nplease
wait (takes ~20 seconds) before the device is fully configured"
+const byte str_welcome[] = "JALLIB USB HID MOUSE DEMO version 1.0\nplease
wait (takes ~10 seconds) before the device it is fully configured"
-- variables
var word i = 0
Modified: trunk/sample/18f4550_usb_serial.jal
==============================================================================
--- trunk/sample/18f4550_usb_serial.jal (original)
+++ trunk/sample/18f4550_usb_serial.jal Wed May 13 11:37:28 2009
@@ -47,7 +47,7 @@
-- ------------------------------------------------------
--
--
--- This file has been generated on 04/29/09 21:07:21, from:
+-- This file has been generated on 05/13/09 16:40:59, from:
-- * board: board_18f4550_af.jal
-- * test : test_usb_serial.jal
--
Modified: trunk/test/peripheral/usb/test_usb_hid_generic.jal
==============================================================================
--- trunk/test/peripheral/usb/test_usb_hid_generic.jal (original)
+++ trunk/test/peripheral/usb/test_usb_hid_generic.jal Wed May 13 11:37:28
2009
@@ -94,13 +94,6 @@
const byte HID_OUT_REPORT_SIZE = 8
-const bit USB_CALLBACK_ON_CLASS_CTRL = false
-const bit USB_CALLBACK_ON_DEVICE_CONFIGURED = false
-const bit USB_CALLBACK_ON_VENDOR_CTRL = false
-const bit USB_EP_DATA_CALLBACK = true
-const bit USB_CALLBACK_ON_SOF = false
-
-
const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
USB_DEVICE_DESCRIPTOR_SIZE, -- 18 bytes long
USB_DT_DEVICE, -- DEVICE 01h
@@ -235,13 +228,16 @@
".", 0x00
}
-const byte USB_STRING2[42] =
+const byte USB_STRING2[48] =
{
- 42, -- bLength
+ 48, -- bLength
USB_DT_STRING, -- bDescriptorType
"J", 0x00,
"A", 0x00,
"L", 0x00,
+ "L", 0x00,
+ "I", 0x00,
+ "B", 0x00,
" ", 0x00,
"G", 0x00,
"e", 0x00,
@@ -415,14 +411,14 @@
end procedure
-procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
-
+procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
+ pragma inline
if USB_HID_DEBUG_HIGH then
const byte str[] = " EP data in: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,byte_count & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
end if
-- data has been sent, so do we need to send more?
@@ -433,17 +429,19 @@
end if
end procedure
-procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
+procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
+ pragma inline
+
var byte cdc_rx_next
if USB_HID_DEBUG then
const byte str[] = " EP data out: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,byte_count)
serial_hw_write( " " )
print_byte_hex(serial_hw_data, end_point )
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
end if
-- We have some data!
@@ -496,6 +494,7 @@
0x03:
block
+ PORTB = hid_tx_buffer[ 1 ]
if defined( HAS_SERIAL_DEBUG_PORT ) == true then
end if
end block
@@ -517,6 +516,9 @@
end block
end case
end if
+
+ usb_prime_epx_out( end_point, USB_EP1_OUT_SIZE )
+
end procedure
Modified: trunk/test/peripheral/usb/test_usb_hid_keyboard.jal
==============================================================================
--- trunk/test/peripheral/usb/test_usb_hid_keyboard.jal (original)
+++ trunk/test/peripheral/usb/test_usb_hid_keyboard.jal Wed May 13 11:37:28
2009
@@ -89,12 +89,6 @@
const byte USB_EP3_IN_SIZE = 8
const word USB_EP3_IN_ADDR = 0x0000
-const bit USB_CALLBACK_ON_CLASS_CTRL = true
-const bit USB_CALLBACK_ON_DEVICE_CONFIGURED = false
-const bit USB_CALLBACK_ON_VENDOR_CTRL = false
-const bit USB_EP_DATA_CALLBACK = true
-const bit USB_CALLBACK_ON_SOF = false
-
const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
USB_DEVICE_DESCRIPTOR_SIZE, -- 18 bytes long
USB_DT_DEVICE, -- DEVICE 01h
@@ -295,9 +289,9 @@
if USB_HID_DEBUG_HIGH then
const byte str[] = " HID CL CALLBACK REQ: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,len & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
print_byte_hex(serial_hw_data,val >> 8 )
print_byte_hex(serial_hw_data,val & 0xFF)
serial_hw_write( " " )
@@ -311,7 +305,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "GET_REPORT "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -319,7 +313,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "GET_IDLE "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -327,7 +321,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "GET_PROTOCOL "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -335,7 +329,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "SET_REPORT "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
if ( len > 0 ) then
usb_control_mode =
USB_CM_CTRL_WRITE_DATA_STAGE_CLASS
@@ -347,7 +341,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "SET_IDLE "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -355,7 +349,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "SET_PROTOCOL "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -363,7 +357,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "UNKNOWN CL REQUEST "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
end case
@@ -391,7 +385,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "SET_REPORT "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
var byte idx
@@ -412,7 +406,7 @@
block
if USB_HID_DEBUG then
const byte str[] = "UNKNOWN CL REQUEST "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
end if
end block
@@ -430,9 +424,9 @@
if USB_HID_DEBUG_HIGH then
const byte str[] = " HID CL CALLBACK RD: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,len & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
print_byte_hex(serial_hw_data,val >> 8 )
print_byte_hex(serial_hw_data,val & 0xFF)
serial_hw_write( " " )
@@ -441,14 +435,15 @@
end procedure
-procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
+procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
+ pragma inline
if USB_HID_DEBUG_HIGH then
const byte str[] = " EP data in: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
+ print_string(serial_hw_data,str)
print_byte_hex(serial_hw_data,byte_count & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string(serial_hw_data,str1)
end if
-- data has been sent, so do we need to send more?
@@ -458,21 +453,6 @@
end if
end procedure
-procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
- var byte cdc_rx_next
- if USB_HID_DEBUG then
- const byte str[] = " EP data out: "
- const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
- print_byte_hex(serial_hw_data,byte_count)
- print_byte_hex(serial_hw_data,str1)
- end if
-
- -- We have some data!
- if (end_point == USB_HID_ENDPOINT) then
- end if
-end procedure
-
include usb_drv
@@ -538,8 +518,6 @@
-- setup the USB device
usb_setup()
-
-delay_1ms(10)
-- enable USB device
usb_enable_module()
Modified: trunk/test/peripheral/usb/test_usb_hid_mouse.jal
==============================================================================
--- trunk/test/peripheral/usb/test_usb_hid_mouse.jal (original)
+++ trunk/test/peripheral/usb/test_usb_hid_mouse.jal Wed May 13 11:37:28
2009
@@ -93,15 +93,6 @@
const byte USB_EP3_IN_SIZE = 8
const word USB_EP3_IN_ADDR = 0x0000
-
-
-const bit USB_CALLBACK_ON_CLASS_CTRL = false
-const bit USB_CALLBACK_ON_DEVICE_CONFIGURED = false
-const bit USB_CALLBACK_ON_VENDOR_CTRL = false
-const bit USB_EP_DATA_CALLBACK = true
-const bit USB_CALLBACK_ON_SOF = false
-
-
const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
USB_DEVICE_DESCRIPTOR_SIZE, -- 18 bytes long
USB_DT_DEVICE, -- DEVICE 01h
@@ -240,13 +231,16 @@
".", 0x00
}
-const byte USB_STRING2[38] =
+const byte USB_STRING2[44] =
{
- 38, -- bLength
+ 44, -- bLength
USB_DT_STRING, -- bDescriptorType
"J", 0x00,
"A", 0x00,
"L", 0x00,
+ "L", 0x00,
+ "I", 0x00,
+ "B", 0x00,
" ", 0x00,
"H", 0x00,
"I", 0x00,
@@ -264,14 +258,17 @@
"o", 0x00
}
-procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
-
+include usb_drv_core
+
+
+procedure usb_ep_data_in_callback(byte in end_point, word in buffer_addr,
byte in byte_count) is
+ pragma inline
if USB_HID_DEBUG_HIGH then
const byte str[] = " EP data in: "
const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
- serial_print_int(byte_count & 0xFF)
- print_byte_hex(serial_hw_data,str1)
+ print_string( serial_hw_data,str )
+ print_byte_hex( serial_hw_data, byte_count & 0xFF)
+ print_string(serial_hw_data,str1)
end if
-- data has been sent, so do we need to send more?
@@ -281,28 +278,12 @@
end if
end procedure
-procedure usb_ep_data_out_callback(byte in end_point, word in buffer_addr,
word in byte_count) is
- var byte cdc_rx_next
- if USB_HID_DEBUG then
- const byte str[] = " EP data out: "
- const byte str1[] = " bytes "
- print_byte_hex(serial_hw_data,str)
- serial_print_int(byte_count)
- print_byte_hex(serial_hw_data,str1)
- end if
- -- We have some data!
- if (end_point == USB_HID_ENDPOINT) then
- end if
-end procedure
-
-
-include usb_drv_core
include usb_drv
-- constants
const sbyte dir_table[] = {-4,-4,-4, 0, 4, 4, 4, 0}
-const byte str_welcome[] = "JAL USB HID MOUSE DEMO version 0.3\nplease
wait (takes ~20 seconds) before the device is fully configured"
+const byte str_welcome[] = "JALLIB USB HID MOUSE DEMO version 1.0\nplease
wait (takes ~10 seconds) before the device it is fully configured"
-- variables
var word i = 0
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---