+default_CONFIG = CONFIG_USB_BASE=y
+
+ifeq ($(CONFIG_USB_BASE),y)
lib_LIBRARIES = usbbase
#shared_LIBRARIES =
-#include_HEADERS = usb.h usb_spec.h usbdebug.h usb_stdreq.h
+#include_HEADERS =
nobase_include_HEADERS = usb/usb.h usb/usb_spec.h usb/usb_stdreq.h usb/usbdebug.h
#lib_LOADLIBES =
#bin_PROGRAMS =
+endif #CONFIG_USB_BASE
+
+
#define DEBUG_LEVEL_HIGH 3
#define DEBUG_LEVEL_VERBOSE 4
-
+#ifndef DEBUG_STATIC_LEVEL
/* Global static debug level */
#define DEBUG_STATIC_LEVEL DEBUG_LEVEL_NONE
+#endif
/* If it is defined, current global debug level is
in 'global_debug_level' variable. Otherwise will
usage : usb_debug_print( DEBUG_LEVEL_MEDIUM,("i=%d",i));
*/
#define usb_debug_print( _lvl_, _prnargs_) \
- do { \
- if ( usb_debug_level >= _lvl_) { \
+ do { \
+ if ( usb_debug_level >= _lvl_) { \
usb_printf _prnargs_; \
- } \
+ } \
} while(0)
/* usb_debug_info( printargs) print debug info always
usage : usb_debug_info( "debug info");
*/
-#define usb_debug_info usb_printf /* !!! tohle musi byt jinak !!! */
+#define usb_debug_info usb_printf /* FIXME: this is not correct */
#else /* DEBUG */
#define usb_debug_print( _lvl_, _prnargs_)
#include <usb/usbdebug.h>
#include <usb/usb_spec.h>
-
-void usb_debug_set_level(int level) {
- #if defined(DEBUG_USE_DYNAMIC_LEVEL) && defined(DEBUG)
- usb_debug_level = level;
- #endif /*DEBUG_USE_DYNAMIC_LEVEL*/
-}
-
-
#ifdef DEBUG
/* debug can be enabled in run-time */
/*************************************************************
*** Debug infos
*************************************************************/
+
+ void usb_debug_set_level(int level) {
+ #if defined(DEBUG_USE_DYNAMIC_LEVEL) /* use dynamic debug level */
+ usb_debug_level = level;
+ #endif
+ }
+
char *usb_debug_get_req_recipient( char rqt) {
switch ( rqt & USB_RECIPIENT) {
}
return "UNKNOWN";
}
-
+
+#else /*DEBUG*/
+ void usb_debug_set_level(int level) {
+ }
#endif /* DEBUG */
+default_CONFIG = CONFIG_USB_MORE=y
+
+ifeq ($(CONFIG_USB_MORE),y)
lib_LIBRARIES = usbmore
#shared_LIBRARIES =
#lib_LOADLIBES =
#bin_PROGRAMS =
+endif #CONFIG_USB_MORE
+
// wLength - data or length of data
//int usb_msp430_loader(usb_ep_t *ep, USB_DEVICE_REQUEST *dreq);
-/*int usb_msp430_loader(struct usb_device_t *udev);*/
-int usb_msc1210_loader(usb_device_t *udev);
-
-#if 0 /* msp430 */
-int jtag_check_init(int force);
-#endif /* msc1210 */
+int usb_native_loader(struct usb_device_t *udev);
#endif /*_USB_LOADER_H*/
// ****************************
int usb_stdreq_get_status( usb_device_t *udev)
{
- unsigned char c, endp, buf[2] = { 0, 0};
+ unsigned char c, buf[2] = { 0, 0};
unsigned char epid = (unsigned char) udev->request.wIndex;
usb_debug_print( DEBUG_LEVEL_HIGH, ("GetStatus\n"));
case USB_RECIPIENT_INTERFACE:
break;
case USB_RECIPIENT_ENDPOINT:
- endp = ( unsigned char)( epid & PDI_CNT_EP);
- if ( epid & ( unsigned char) USB_ENDPOINT_DIRECTION_MASK)
- c = pdiSelectEp( endp * 2 + 1); // endpoint in
+ if ( epid & USB_ENDPOINT_DIRECTION_MASK)
+ c = pdiSelectEp(pdiEp2Idx(epid)); // endpoint in
else
- c = pdiSelectEp( endp * 2); // endpoint Out
+ c = pdiSelectEp(pdiEp2Idx(epid)); // endpoint Out
#ifdef PDIUSBD12
buf[0] = (( c & PDI_SELEP_STALL) == PDI_SELEP_STALL);
#else
int usb_stdreq_clear_feature( usb_device_t *udev)
{
- unsigned char endp;
USB_DEVICE_REQUEST *dreq = &(udev->request);
+ unsigned char epid = (unsigned char) dreq->wIndex;
usb_debug_print( DEBUG_LEVEL_HIGH, ("ClearFeature\n"));
switch( dreq->bmRequestType & USB_RECIPIENT) {
break;
case USB_RECIPIENT_ENDPOINT:
if ( dreq->wValue == USB_FEATURE_ENDPOINT_STALL) {
- endp = ( unsigned char)( dreq->wIndex & PDI_CNT_EP);
- if ( dreq->wIndex & ( unsigned char) USB_ENDPOINT_DIRECTION_MASK)
- pdiSetEpStatus( endp * 2 + 1, 0); // clear TX stall for IN on EPn
+ if ( epid & USB_ENDPOINT_DIRECTION_MASK)
+ pdiSetEpStatus(pdiEp2Idx(epid), 0); // clear TX stall for IN on EPn
else
- pdiSetEpStatus( endp * 2, 0); // clear RX stall for OUT on EPn
+ pdiSetEpStatus(pdiEp2Idx(epid), 0); // clear RX stall for OUT on EPn
usb_udev_ack_setup( udev);
return USB_COMPLETE_OK;
}
int usb_stdreq_set_feature( usb_device_t *udev)
{
- unsigned char endp;
USB_DEVICE_REQUEST *dreq = &(udev->request);
+ unsigned char epid = (unsigned char) dreq->wIndex;
usb_debug_print( DEBUG_LEVEL_HIGH, ("SetFeature\n"));
switch( dreq->bmRequestType & USB_RECIPIENT) {
break;
case USB_RECIPIENT_ENDPOINT:
if ( dreq->wValue == USB_FEATURE_ENDPOINT_STALL) {
- endp = ( unsigned char)( dreq->wIndex & PDI_CNT_EP);
- if ( dreq->wIndex & ( unsigned char) USB_ENDPOINT_DIRECTION_MASK)
- pdiSetEpStatus( endp * 2 + 1, 1); // set TX stall for IN on EPn
+ if ( epid & USB_ENDPOINT_DIRECTION_MASK)
+ pdiSetEpStatus( pdiEp2Idx(epid), 1); // set TX stall for IN on EPn
else
- pdiSetEpStatus( endp * 2, 1); // set RX stall for OUT on EPn
+ pdiSetEpStatus( pdiEp2Idx(epid), 1); // set RX stall for OUT on EPn
usb_udev_ack_setup( udev);
return USB_COMPLETE_OK;
}
-lib_LIBRARIES = usbpdi
-
-#shared_LIBRARIES =
+default_CONFIG = CONFIG_USB_PDIUSB=y
-#include_HEADERS = usb.h usb_spec.h usbdebug.h usb_stdreq.h
+ifeq ($(CONFIG_USB_PDIUSB),y)
+lib_LIBRARIES = usbpdi
nobase_include_HEADERS = usb/pdi.h usb/pdiusb.h
usbpdi_SOURCES = pdi.c pdiusb.c
-
-#lib_LOADLIBES =
-#bin_PROGRAMS =
-
+#usbpdi_SOURCES += pdi4rtems.c
+endif #CONFIG_USB_PDIUSB
usb_debug_print( DEBUG_LEVEL_HIGH, ("PDI Int=0x%04X\n", LastInt));
if ( LastInt & PDI_INT_BUSRESET) { // D12 - Bus reset reached
- /*pdiInitChipState();*/
+ pdiInitChipState();
udev->flags |= USB_FLAG_BUS_RESET;
ret = 1;
} else {
#if __BYTE_ORDER == __BIG_ENDIAN
#include <byteswap.h>
#endif
-#include "usb/pdiusb.h"
+#include <usb/pdiusb.h>
+#include <usb/usb_spec.h>
#ifdef PDI_CMD_RWD_INTERNAL
#ifndef PDIUSBD12
pdiSendCommand( PDI_CMD_SET_CHNG_BITS);
pdiWriteData( 1, &byBits);
}
-
+
#endif
PDI_MODE_SOFT_CONNECT | PDI_MODE_SINGLE_FNC | PDI_CLOCK_12M);
}
#endif
+
+/*********************************************************/
+
+ static const unsigned char epin2idx[]={
+ PDI_EP0_IN,
+ PDI_EP1_IN,
+ #if PDI_CNT_EP > 1
+ PDI_EP2_IN,
+ #if PDI_CNT_EP > 2
+ PDI_EP3_IN,
+ #endif
+ #endif
+ };
+
+ static const unsigned char epout2idx[]={
+ PDI_EP0_OUT,
+ PDI_EP1_OUT,
+ #if PDI_CNT_EP > 1
+ PDI_EP2_OUT,
+ #if PDI_CNT_EP > 2
+ PDI_EP3_OUT,
+ #endif
+ #endif
+ };
+
+ // pdiEp2Idx
+ // convert endpoint number to pdi index number
+ unsigned char pdiEp2Idx(unsigned char ep) {
+ if(ep & USB_ENDPOINT_DIRECTION_MASK)
+ return epin2idx[ep & 0xf];
+ else
+ return epout2idx[ep & 0xf];
+ }
+
/*********************************************************/
/*********************************************************/
#include <usb/usb.h>
- int usb_pdi_init( usb_device_t *udev) REENTRANT_SIGN;
+// int usb_pdi_init( usb_device_t *udev) REENTRANT_SIGN;
+ int usb_pdi_init( usb_device_t *udev);
#ifdef USB_PDI_DIRECT_FNC
#define USB_PDI_EXPORT_FNC
#else
void pdiAckSetupFncControl( unsigned char Fnc);
#endif
-
-
+
+unsigned char pdiEp2Idx(unsigned char ep);
+
/*********************************************************/
#endif // from _PDI_ERROR_NO_CONTINUE
/*********************************************************/