This commit is contained in:
2025-06-18 09:21:10 +08:00
commit b2b79996d7
478 changed files with 82728 additions and 0 deletions

View File

@ -0,0 +1,45 @@
#include <Arduino.h>
#include "USB_STREAM.h"
/* Define the Mic frame callback function implementation */
static void onMicFrameCallback(mic_frame_t *frame, void *ptr)
{
// We should using higher baudrate here, to reduce the blocking time here
Serial.printf("mic callback! bit_resolution = %u, samples_frequence = %"PRIu32", data_bytes = %"PRIu32"\n", frame->bit_resolution, frame->samples_frequence, frame->data_bytes);
}
void setup()
{
Serial.begin(115200);
// Instantiate a Ustream object
USB_STREAM *usb = new USB_STREAM();
// Config the parameter
usb->uacConfiguration(UAC_CH_ANY, UAC_BITS_ANY, UAC_FREQUENCY_ANY, 6400, UAC_CH_ANY, UAC_BITS_ANY, UAC_FREQUENCY_ANY, 6400);
//Register the camera frame callback function
usb->uacMicRegisterCb(&onMicFrameCallback, NULL);
usb->start();
usb->connectWait(1000);
delay(5000);
usb->uacMicMute((void *)0);
delay(5000);
usb->uacMicVolume((void *)60);
usb->uacMicSuspend(NULL);
delay(5000);
usb->uacMicResume(NULL);
}
// The loop function runs repeatedly
void loop()
{
// Delay the task for 100ms
vTaskDelay(5000);
}

View File

@ -0,0 +1,50 @@
#include <Arduino.h>
#include "USB_STREAM.h"
/* Define the camera frame callback function implementation */
static void onCameraFrameCallback(uvc_frame *frame, void *user_ptr)
{
Serial.printf("uvc callback! frame_format = %d, seq = %" PRIu32 ", width = %" PRIu32", height = %" PRIu32 ", length = %u, ptr = %d\n",
frame->frame_format, frame->sequence, frame->width, frame->height, frame->data_bytes, (int)user_ptr);
}
void setup()
{
Serial.begin(115200);
// Instantiate an object
USB_STREAM *usb = new USB_STREAM();
// allocate memory
uint8_t *_xferBufferA = (uint8_t *)malloc(55 * 1024);
assert(_xferBufferA != NULL);
uint8_t *_xferBufferB = (uint8_t *)malloc(55 * 1024);
assert(_xferBufferB != NULL);
uint8_t *_frameBuffer = (uint8_t *)malloc(55 * 1024);
assert(_frameBuffer != NULL);
// Config the parameter
usb->uvcConfiguration(FRAME_RESOLUTION_ANY, FRAME_RESOLUTION_ANY, FRAME_INTERVAL_FPS_15, 55 * 1024, _xferBufferA, _xferBufferB, 55 * 1024, _frameBuffer);
//Register the camera frame callback function
usb->uvcCamRegisterCb(&onCameraFrameCallback, NULL);
usb->start();
usb->connectWait(1000);
delay(5000);
usb->uvcCamSuspend(NULL);
delay(5000);
usb->uvcCamResume(NULL);
/*Dont forget to free the allocated memory*/
// free(_xferBufferA);
// free(_xferBufferB);
// free(_frameBuffer);
}
void loop()
{
vTaskDelay(100);
}