• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Low Power RF & Wireless Connectivity » Low Power RF Bluetooth® Low Energy & ANT Forum » Any way to make USB stack working without the HCIParser?
Share
Low Power RF & Wireless Connectivity
  • Forums
  • Announcements
  • Files
  • E2E Wiki
Options
  • Subscribe via RSS

Forums

Any way to make USB stack working without the HCIParser?

This question has suggested answer(s)
Brown59592
Posted by Brown59592
on Mar 17 2011 09:59 AM
Expert1050 points

I want to use the USB stack provided with the CC2540 sample HostTestRelease without the HCI/serial parser from that project. I want to have other USB communication, not HCI.

The only issue which stops me doing this is the typedef void (*halUARTCBack_t) (uint8 port, uint8 event); function which is used in the HalUARTOpen/HalUARTOpenUSB config parameter (halUARTCBack_t      callBackFunc;).

This is defined in TI's precompiled code (lib), there is no documentation about it (or at least I couldn't find any), I can only see from debugger that it's called from HCI_init function (no source provided, TI lib code).

Anyone managed to make it work, has a sample or at least has a description of the possible events from that callback?

It's really annoying to have the UART USB initialization mixed up in the precompiled BLE stack.

I understand that TI does not want to give source code for the BLE stack but also doesn't want to let us using the USB port as we want to? The USB stack is already written, I would prefer to not write a new one ...

B.

Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Willis1
    Posted by Willis1
    on Mar 17 2011 13:19 PM
    Expert8165 points

    The "single-chip" BLE libraries do not use the UART (virtual or physical) for the HCI. You should be able to create a project that uses one of these libraries along with the USB stack.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Brown59592
    Posted by Brown59592
    on Mar 18 2011 04:14 AM
    Expert1050 points

     

    I have to reject Your answer since it does in one point - and that point is crucial enough to make the whole USB stack unusable without it.

     

    Here it is the callstack:

    HalUARTOpenUSB

    HalUARTOpen(?,0x029b)

    HCI_Init()

    oaslInitTasks()

    osal_init_system()

    main()

     

    As you can see the HalUARTOpen is called from HCI_Init and what is bad for us that 0x029b parameter is a structure which contains a CALLBACK function entry address. 

     

    This callback function has the type of void (*halUARTCBack_t) (uint8 port, uint8 event); and it is implemented somewhere in the HCI code which is inside the BLE bin's. Therefore we cannot know what events can appear in that callback, how they should be treated to make the whole USB stack working.

     

    That callback is saved inside the halUARTCBack_t uartCB; variable from _hal_uart_usb.c and it's called from a few places inside the _hal_uart_usb.c with some events like HAL_UART_RX_ABOUT_FULL, HAL_UART_RX_TIMEOUT, HAL_UART_TX_EMPTY etc.

     

    Is there any description about this callback and what should do with those events?

    I've found some examples in the Z-Stack devkit (MT_UartProcessZAppData, SerialApp_CallBack, npUartCback) but it's not too helpfull since none of them are USB related. 

     

    B.

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Brown59592
    Posted by Brown59592
    on Mar 18 2011 05:38 AM
    Expert1050 points

    As a test I added empty callback there and seems to work.

    I would still be very pleased to see a description of those HAL_UART_RX, TX events.

    They are RX,TX buffer status which should be handled in some cases to avoid overruns and timeouts?

    B.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Willis1
    Posted by Willis1
    on Mar 18 2011 14:05 PM
    Suggested Answer
    Expert8165 points

    Which project are you using where you see that call stack? As I mentioned before, if you use the "single-chip" libraries and not the "network processor" libraries HCI_Init will not call HALUARTOpen. The "SimpleBLEPeripheral" project uses the "ble_single_chip_slave_pm_on.lib" library, but but does not use the USB stack. The "HostTestRelease" project uses the "network processor" library and uses the USB stack for the HCI. If you want to write a non-network processor application that uses the USB stack, you will need to create a project that uses one of the "single chip" libraries, and add the USB stack source code to the project. Your application can then initialize the USB stack like this:

      halUARTCfg_t uartConfig;

      // configure UART
      uartConfig.configured           = TRUE;
      uartConfig.baudRate             = HCI_UART_BR;
      uartConfig.flowControl          = HCI_UART_FC;
      uartConfig.flowControlThreshold = HCI_UART_FC_THRESHOLD;
      uartConfig.rx.maxBufSize        = HCI_UART_RX_BUF_SIZE;
      uartConfig.tx.maxBufSize        = HCI_UART_TX_BUF_SIZE;
      uartConfig.idleTimeout          = HCI_UART_IDLE_TIMEOUT;
      uartConfig.intEnable            = HCI_UART_INT_ENABLE;
      uartConfig.callBackFunc         = callbackFn;             // you would need to define this callback function

      // start UART
      (void)HalUARTOpen (HCI_UART_PORT, &uartConfig);

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Brown59592
    Posted by Brown59592
    on Mar 21 2011 08:26 AM
    Expert1050 points

    HostTestRelase project. As far as I know it's the only one CC2540 sample with USB stack.

    Willis
    uartConfig.callBackFunc         = callbackFn;             // you would need to define this callback function

    This is the part for what I couldn't find description or sample.

    I don't know what events could occur in that callback and what's their role. Looking into the Zigbee sdk (cc2531 kit) I've found some examples for serial communication callbacks but none for USB.

    I managed to make a simple loopback USB with empty callbackFn but those events are not treated this way which might end in bugs.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Dan Dupree
    Posted by Dan Dupree
    on Mar 24 2011 15:18 PM
    Prodigy150 points

     

    This approach may not be strickly 'by-the-book' but I was able to implement the usb stack for my peripheral device application. I brought in the entire class_cdc and library folders from the HostTestRelease reference design. Then I modified the halUartPollRx() function (in _hal_uart_usb.c)  to send a message (osal_msg_send) to my task whenever the <CR> character is detected. This works for incomming usb messages and for outgoing, I just defined the  HAL_UART compiler preprocessor flag and  use HalUARTTx to write to the usb channel. On the hardware side, I needed a pull-up on the D+ signal.  I used one of the I/O pins so that I could initialize my system before enabling the usb channel. I still use the HostTestRelease firmware and dongle to communicate with the PC.

     

    Dan

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Seso
    Posted by Seso
    on Jan 13 2012 04:52 AM
    Prodigy140 points

    Would you give me some more input, Dan? I try the same, using USB/CDC in my Peripheral-Project but my Computer says "Unknown USB-Device..."

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Chris Smowton
    Posted by Chris Smowton
    on Apr 10 2012 19:56 PM
    Prodigy30 points

    Hey all,

    I tried running the SimpleBLEPeripheral project in a similar fashion on the CC2540USB dongle, and augmented it with the recommended UART setup described above. I found that I got a "USB device not recognized" error just like Dan described.

    Well, it turned out that the error has nothing to do with USB! Stepping through in the debugger revealed it was in a tight loop inside LL_Init -- specifically in a function waiting for an oscillator to stabilise, or so its name suggested. Another thread suggested that was caused by using the power managed libraries with the USB dongle -- indeed I was using ble_single_chip_slave_pm_on.lib as SimpleBLEPeripheral does by default. I switched that to ble_single_chip_slave_pm_off.lib and voila -- the device makes it through LL_Init and the USB device is properly recognised (and works as intended!) I'd guess the device-not-recognized error was because OSAL was not getting around to servicing USB traffic, and the host controller eventually timed the device out.

    In summary, with the pm_off.lib library and SimpleBLEPeripheral modified to use the Target subtree for CC2540USB as referenced in HostTestApp, I've got a USB dongle acting like a BLE peripheral and reporting some ancillary information via the USB UART.

    Chris

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use