File ns_usb.c
FileList > neuralSPOT > neuralspot > ns-usb > src > ns_usb.c
Go to the source code of this file
#include "ns_usb.h"
#include "ns_ambiqsuite_harness.h"
#include "ns_core.h"
#include "ns_timer.h"
#include "tusb.h"
Public Attributes
Type | Name |
---|---|
volatile uint8_t | gGotUSBRx = = 0 |
ns_timer_config_t | g_ns_usbTimer = = { |
.api = &ns_timer_V1_0_0, | |
.timer = NS_TIMER_USB, | |
.enableInterrupt = true, | |
.periodInMicroseconds = 1000, | |
.callback = ns_usb_service_callback} |
|
const ns_core_api_t | ns_usb_V0_0_1 |
const ns_core_api_t | ns_usb_V1_0_0 |
const ns_core_api_t | ns_usb_current_version |
const ns_core_api_t | ns_usb_oldest_supported_version |
ns_usb_config_t | usb_config = = { |
.api = &ns_usb_V1_0_0, | |
.deviceType = NS_USB_CDC_DEVICE, | |
.rx_buffer = NULL, | |
.rx_bufferLength = 0, | |
.tx_buffer = NULL, | |
.tx_bufferLength = 0, | |
.rx_cb = NULL, | |
.tx_cb = NULL, | |
.service_cb = NULL, | |
.desc_url = NULL} |
Public Functions
Type | Name |
---|---|
uint32_t | ns_get_cdc_rx_bufferLength () |
uint32_t | ns_get_cdc_tx_bufferLength () |
ns_tusb_desc_webusb_url_t * | ns_get_desc_url () |
bool | ns_usb_data_available (usb_handle_t handle) |
uint8_t * | ns_usb_get_rx_buffer () |
uint8_t * | ns_usb_get_tx_buffer () |
void | ns_usb_handle_read_error (usb_handle_t h) Flushes the USB RX fifo after a delay, resets ns_usb rx state. |
uint32_t | ns_usb_init (ns_usb_config_t * cfg, usb_handle_t * h) Initialize the USB system. |
uint32_t | ns_usb_recieve_data (usb_handle_t handle, void * buffer, uint32_t bufsize) Blocking USB Receive Data. |
void | ns_usb_register_callbacks (usb_handle_t handle, ns_usb_rx_cb rxcb, ns_usb_tx_cb txcb) Register callbacks for USB events, should be called after ns_usb_init. |
uint32_t | ns_usb_send_data (usb_handle_t handle, void * buffer, uint32_t bufsize) Blocking USB Send Data. |
Public Static Functions
Type | Name |
---|---|
void | ns_usb_service_callback (ns_timer_config_t * c) |
Public Attributes Documentation
variable gGotUSBRx
volatile uint8_t gGotUSBRx;
variable g_ns_usbTimer
ns_timer_config_t g_ns_usbTimer;
variable ns_usb_V0_0_1
const ns_core_api_t ns_usb_V0_0_1;
variable ns_usb_V1_0_0
const ns_core_api_t ns_usb_V1_0_0;
variable ns_usb_current_version
const ns_core_api_t ns_usb_current_version;
variable ns_usb_oldest_supported_version
const ns_core_api_t ns_usb_oldest_supported_version;
variable usb_config
ns_usb_config_t usb_config;
Public Functions Documentation
function ns_get_cdc_rx_bufferLength
uint32_t ns_get_cdc_rx_bufferLength ()
function ns_get_cdc_tx_bufferLength
uint32_t ns_get_cdc_tx_bufferLength ()
function ns_get_desc_url
ns_tusb_desc_webusb_url_t * ns_get_desc_url ()
function ns_usb_data_available
bool ns_usb_data_available (
usb_handle_t handle
)
function ns_usb_get_rx_buffer
uint8_t * ns_usb_get_rx_buffer ()
function ns_usb_get_tx_buffer
uint8_t * ns_usb_get_tx_buffer ()
function ns_usb_handle_read_error
Flushes the USB RX fifo after a delay, resets ns_usb rx state.
void ns_usb_handle_read_error (
usb_handle_t h
)
Parameters:
h
handle
function ns_usb_init
Initialize the USB system.
uint32_t ns_usb_init (
ns_usb_config_t * cfg,
usb_handle_t * h
)
Parameters:
cfg
handle
Returns:
uint32_t Status
function ns_usb_recieve_data
Blocking USB Receive Data.
uint32_t ns_usb_recieve_data (
usb_handle_t handle,
void * buffer,
uint32_t bufsize
)
Parameters:
handle
USB handlebuffer
Pointer to buffer where data will be placedbufsize
Requested number of bytes
Returns:
uint32_t
function ns_usb_register_callbacks
Register callbacks for USB events, should be called after ns_usb_init.
void ns_usb_register_callbacks (
usb_handle_t handle,
ns_usb_rx_cb rxcb,
ns_usb_tx_cb txcb
)
Parameters:
handle
rx_cb
tx_cb
function ns_usb_send_data
Blocking USB Send Data.
uint32_t ns_usb_send_data (
usb_handle_t handle,
void * buffer,
uint32_t bufsize
)
Parameters:
handle
USB handlebuffer
Pointer to buffer with data to be sentbufsize
Requested number of bytes
Returns:
uint32_t
Public Static Functions Documentation
function ns_usb_service_callback
static void ns_usb_service_callback (
ns_timer_config_t * c
)
The documentation for this class was generated from the following file neuralSPOT/neuralspot/ns-usb/src/ns_usb.c