diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..06b1ce6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,2 @@ +[submodule "Firmware/tinyusb"] + url = https://github.com/hathach/tinyusb diff --git a/Firmware/Core/Inc/main.h b/Firmware/Core/Inc/main.h index 9f48950..7cdf4c1 100644 --- a/Firmware/Core/Inc/main.h +++ b/Firmware/Core/Inc/main.h @@ -34,9 +34,9 @@ extern "C" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #define CFG_EXAMPLE_VIDEO_READONLY -#include -#include -#include +#include "stdlib.h" +#include "stdio.h" +#include "string.h" #include "stdbool.h" #include "tusb.h" #include "Cam.h" diff --git a/Firmware/Core/Src/main.c b/Firmware/Core/Src/main.c index 67a2497..0c074bc 100644 --- a/Firmware/Core/Src/main.c +++ b/Firmware/Core/Src/main.c @@ -21,7 +21,7 @@ #include "images.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ - +#include "tusb.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -47,15 +47,22 @@ DMA_HandleTypeDef hdma_spi1_tx; UART_HandleTypeDef huart2; + + PCD_HandleTypeDef hpcd_USB_FS; /* USER CODE BEGIN PV */ +//DAC_HandleTypeDef hdac1; + +//TIM_HandleTypeDef htim15; + int SPI_Rx_Done_Flag = 0; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); + static void MX_DMA_Init(void); static void MX_USART2_UART_Init(void); static void MX_SPI1_Init(void); @@ -63,7 +70,8 @@ static void MX_I2C1_Init(void); static void MX_USB_PCD_Init(void); /* USER CODE BEGIN PFP */ - +//static void MX_DAC1_Init(void); +//static void MX_TIM15_Init(void); /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ @@ -216,6 +224,7 @@ int send_CDC_Bulk(){ int main(void) { /* USER CODE BEGIN 1 */ + LED_On(); /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ @@ -243,11 +252,11 @@ int main(void) MX_I2C1_Init(); MX_USB_PCD_Init(); /* USER CODE BEGIN 2 */ - + //MX_DAC1_Init(); + //MX_TIM15_Init(); HAL_PWREx_EnableVddUSB(); HAL_Delay(1); tud_init(BOARD_DEVICE_RHPORT_NUM); - HAL_Delay(10); SPI_Init(&hspi1); @@ -264,21 +273,22 @@ int main(void) uint16_t image_size = Cam_FIFO_length(&hspi1); - //uint8_t *image_data = malloc((image_size + (image_size%10)) * sizeof(uint8_t)); uint8_t image_data[10000]; - memset(image_data, 0x00, image_size + (image_size%10)); + //memset(image_data, 0x00, image_size); Cam_Start_Burst_Read(&hspi1); HAL_SPI_Receive_DMA(&hspi1, image_data, image_size); + //HAL_SPI_Receive(&hspi1, image_data, image_size, HAL_MAX_DELAY); while (SPI_Rx_Done_Flag == 0) { // Wait for SPI transfer to finish } + LED_On(); + CS_Off(); SPI_Rx_Done_Flag = 0; - /* USER CODE END 2 */ /* Infinite loop */ @@ -288,12 +298,13 @@ int main(void) tud_task(); - if(currentSendingIndex >= 590){ + if(currentSendingIndex >= 9989){ + //if(false){ currentSendingIndex = 0; - //free(image_data); Cam_Capture(&hspi1); + image_size = Cam_FIFO_length(&hspi1); //image_data = malloc((image_size + (image_size%10)) * sizeof(uint8_t)); @@ -301,12 +312,13 @@ int main(void) Cam_Start_Burst_Read(&hspi1); - HAL_SPI_Receive_DMA(&hspi1, &(image_data[0]), image_size); - Debug_LED_On(); + HAL_SPI_Receive_DMA(&hspi1, image_data, 10000); + //Debug_LED_On(); while (SPI_Rx_Done_Flag == 0) { // Wait for SPI transfer to finish + tud_task(); } CS_Off(); SPI_Rx_Done_Flag = 0; @@ -317,7 +329,10 @@ int main(void) } else { LED_On(); - tud_cdc_write(&sendT[currentSendingIndex], 10); + //tud_cdc_write("11111111\r\n", 10); + //tud_cdc_write_flush(); + //tud_cdc_write(&sendT[currentSendingIndex], 10); + tud_cdc_write(&image_data[currentSendingIndex], 10); tud_cdc_write_flush(); currentSendingIndex = currentSendingIndex + 10; HAL_Delay(5); diff --git a/Firmware/Makefile b/Firmware/Makefile index 8c78770..e454dcb 100644 --- a/Firmware/Makefile +++ b/Firmware/Makefile @@ -1,3 +1,5 @@ +SHELL=/bin/bash + .PHONY: all build build-container cmake format format-linux flash-stlink flash-jlink format-container shell image build-container clean clean-image clean-all ############################### Native Makefile ############################### diff --git a/Receiver/Displayer.o b/Receiver/Displayer.o deleted file mode 100644 index 1a56250..0000000 Binary files a/Receiver/Displayer.o and /dev/null differ diff --git a/Receiver/ImageView.o b/Receiver/ImageView.o deleted file mode 100644 index c37b2cf..0000000 Binary files a/Receiver/ImageView.o and /dev/null differ diff --git a/Receiver/Receiver.cpp b/Receiver/Receiver.cpp index dad7a1c..f6690bc 100644 --- a/Receiver/Receiver.cpp +++ b/Receiver/Receiver.cpp @@ -11,12 +11,13 @@ void Receiver::printHex(unsigned char value) { void Receiver::openStream(){ while(1){ // Open the CDC device file for reading - cdcFile = open("/dev/ttyACM1", O_RDWR | O_NOCTTY); - if (cdcFile == -1) { + cdcFile = open("/dev/ttyACM0", O_RDWR | O_NOCTTY); + if(cdcFile == -1){ std::cerr << "Failed to open CDC device file" << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(500)); continue; } + std::cout << "successfully opened stream" << cdcFile << std::endl; break; } @@ -28,7 +29,7 @@ int Receiver::initSerial(){ std::cerr << "Error in tcgetattr" << std::endl; return -1; } - tcflush(cdcFile, TCIFLUSH); + //tcflush(cdcFile, TCIFLUSH); cfsetospeed(&tty, B115200); cfsetispeed(&tty, B115200); tty.c_cflag |= (CLOCAL | CREAD); @@ -49,7 +50,7 @@ int Receiver::initSerial(){ } std::cout << "OPENED!" << std::endl; - tcflush(cdcFile, TCIFLUSH); + //tcflush(cdcFile, TCIFLUSH); return 1; } @@ -64,15 +65,13 @@ int Receiver::readCdcData(unsigned char (*character)[10]) { std::cerr << "Error in read" << std::endl; return -1; } - /* for(int i = 0; i<10; i++) { printHex((*character)[i]); //std::cout << unsigned(character[i]); - std::cout << " "; - }*/ - - + //std::cout << " "; + } + std::cout << std::endl; return 0; } diff --git a/Receiver/Receiver.o b/Receiver/Receiver.o deleted file mode 100644 index a7af35a..0000000 Binary files a/Receiver/Receiver.o and /dev/null differ diff --git a/Receiver/Transfer.o b/Receiver/Transfer.o deleted file mode 100644 index 7c642ec..0000000 Binary files a/Receiver/Transfer.o and /dev/null differ diff --git a/Receiver/main b/Receiver/main deleted file mode 100755 index 63bb424..0000000 Binary files a/Receiver/main and /dev/null differ diff --git a/Receiver/main.cpp b/Receiver/main.cpp index 4379262..f67d53a 100644 --- a/Receiver/main.cpp +++ b/Receiver/main.cpp @@ -11,8 +11,11 @@ struct termios tty; void readLoop(Receiver ** receiverPtr){ + std::cout << "1" << std::endl; (*receiverPtr)->openStream(); + std::cout << "2" << std::endl; (*receiverPtr)->initSerial(); + std::cout << "3" << std::endl; while (true) { unsigned char character[10]; diff --git a/Receiver/main.o b/Receiver/main.o deleted file mode 100644 index 8fb3a53..0000000 Binary files a/Receiver/main.o and /dev/null differ