#include "ch.h" #include "hal.h" #include "debug.h" #include #include "config.h" #include "image.h" const SerialConfig uart_config = { 115200, // baud rate 0, // CR1 register 0, // CR2 register 0 // CR3 register }; mutex_t trace_mtx; // Used internal to synchronize multiple chprintf in debug.h bool debug_on_usb = true; void debugOnUSB_Off(BaseSequentialStream *chp, int argc, char *argv[]) { (void)chp; (void)argc; (void)argv; debug_on_usb = false; } void debugOnUSB_On(BaseSequentialStream *chp, int argc, char *argv[]) { (void)chp; (void)argc; (void)argv; debug_on_usb = true; } static uint8_t usb_buffer[128*1024] __attribute__((aligned(32))); // USB image buffer void printPicture(BaseSequentialStream *chp, int argc, char *argv[]) { (void)chp; (void)argc; (void)argv; // Take picture ssdv_conf_t conf = { .res = RES_VGA, .quality = 4, .ram_buffer = usb_buffer, .ram_size = sizeof(usb_buffer), }; bool camera_found = takePicture(&conf, false); // Transmit image via USB if(camera_found) { bool start_detected = false; for(uint32_t i=0; i image/jpeg,%d", conf.size_sampled-i+1); // Flag the data on serial output streamPut(&SDU1, 0xFF); streamPut(&SDU1, 0xD8); } if(start_detected) streamPut(&SDU1, conf.ram_buffer[i]); } } else { // No camera found for(uint32_t i=0; i