|
|
@ -50,6 +50,7 @@ DMA_HandleTypeDef hdma_spi1_rx;
|
|
|
|
DMA_HandleTypeDef hdma_spi1_tx;
|
|
|
|
DMA_HandleTypeDef hdma_spi1_tx;
|
|
|
|
|
|
|
|
|
|
|
|
UART_HandleTypeDef huart1;
|
|
|
|
UART_HandleTypeDef huart1;
|
|
|
|
|
|
|
|
UART_HandleTypeDef huart3;
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN PV */
|
|
|
|
/* USER CODE BEGIN PV */
|
|
|
|
|
|
|
|
|
|
|
@ -62,6 +63,7 @@ static void MX_DMA_Init(void);
|
|
|
|
static void MX_I2C1_Init(void);
|
|
|
|
static void MX_I2C1_Init(void);
|
|
|
|
static void MX_SPI1_Init(void);
|
|
|
|
static void MX_SPI1_Init(void);
|
|
|
|
static void MX_USART1_UART_Init(void);
|
|
|
|
static void MX_USART1_UART_Init(void);
|
|
|
|
|
|
|
|
static void MX_USART3_UART_Init(void);
|
|
|
|
/* USER CODE BEGIN PFP */
|
|
|
|
/* USER CODE BEGIN PFP */
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END PFP */
|
|
|
|
/* USER CODE END PFP */
|
|
|
@ -89,23 +91,28 @@ void Image_capture(OV2640 *camera, ButCube_imager *transmitter){
|
|
|
|
int main(void){
|
|
|
|
int main(void){
|
|
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
/* USER CODE END 1 */
|
|
|
|
/* USER CODE END 1 */
|
|
|
|
|
|
|
|
|
|
|
|
/* MCU Configuration--------------------------------------------------------*/
|
|
|
|
/* MCU Configuration--------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
|
|
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
|
|
|
HAL_Init();
|
|
|
|
HAL_Init();
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN Init */
|
|
|
|
/* USER CODE BEGIN Init */
|
|
|
|
/* USER CODE END Init */
|
|
|
|
/* USER CODE END Init */
|
|
|
|
|
|
|
|
|
|
|
|
/* Configure the system clock */
|
|
|
|
/* Configure the system clock */
|
|
|
|
SystemClock_Config();
|
|
|
|
SystemClock_Config();
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN SysInit */
|
|
|
|
/* USER CODE BEGIN SysInit */
|
|
|
|
/* USER CODE END SysInit */
|
|
|
|
/* USER CODE END SysInit */
|
|
|
|
|
|
|
|
|
|
|
|
/* Initialize all configured peripherals */
|
|
|
|
/* Initialize all configured peripherals */
|
|
|
|
MX_GPIO_Init();
|
|
|
|
MX_GPIO_Init();
|
|
|
|
MX_DMA_Init();
|
|
|
|
MX_DMA_Init();
|
|
|
|
MX_I2C1_Init();
|
|
|
|
MX_I2C1_Init();
|
|
|
|
MX_SPI1_Init();
|
|
|
|
MX_SPI1_Init();
|
|
|
|
MX_USART1_UART_Init();
|
|
|
|
MX_USART1_UART_Init();
|
|
|
|
|
|
|
|
MX_USART3_UART_Init();
|
|
|
|
/* USER CODE BEGIN 2 */
|
|
|
|
/* USER CODE BEGIN 2 */
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize SPI clock
|
|
|
|
// Initialize SPI clock
|
|
|
@ -123,6 +130,7 @@ int main(void){
|
|
|
|
|
|
|
|
|
|
|
|
ButCube_imager *transmitter = new ButCube_imager();
|
|
|
|
ButCube_imager *transmitter = new ButCube_imager();
|
|
|
|
transmitter->Add_output(huart1);
|
|
|
|
transmitter->Add_output(huart1);
|
|
|
|
|
|
|
|
transmitter->Add_output(huart3);
|
|
|
|
transmitter->Camera_power(true);
|
|
|
|
transmitter->Camera_power(true);
|
|
|
|
|
|
|
|
|
|
|
|
// Wait for power rail to stabilize
|
|
|
|
// Wait for power rail to stabilize
|
|
|
@ -131,10 +139,12 @@ int main(void){
|
|
|
|
OV2640 *camera = new OV2640(hi2c1, 0x60, hspi1, SPI_camera::Chip_select_pin{ GPIOB, GPIO_PIN_0 });
|
|
|
|
OV2640 *camera = new OV2640(hi2c1, 0x60, hspi1, SPI_camera::Chip_select_pin{ GPIOB, GPIO_PIN_0 });
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END 2 */
|
|
|
|
/* USER CODE END 2 */
|
|
|
|
|
|
|
|
|
|
|
|
/* Infinite loop */
|
|
|
|
/* Infinite loop */
|
|
|
|
/* USER CODE BEGIN WHILE */
|
|
|
|
/* USER CODE BEGIN WHILE */
|
|
|
|
while (1) {
|
|
|
|
while (1) {
|
|
|
|
/* USER CODE END WHILE */
|
|
|
|
/* USER CODE END WHILE */
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN 3 */
|
|
|
|
/* USER CODE BEGIN 3 */
|
|
|
|
Image_capture(camera, transmitter);
|
|
|
|
Image_capture(camera, transmitter);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -296,6 +306,37 @@ static void MX_USART1_UART_Init(void){
|
|
|
|
/* USER CODE END USART1_Init 2 */
|
|
|
|
/* USER CODE END USART1_Init 2 */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief USART3 Initialization Function
|
|
|
|
|
|
|
|
* @param None
|
|
|
|
|
|
|
|
* @retval None
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void MX_USART3_UART_Init(void){
|
|
|
|
|
|
|
|
/* USER CODE BEGIN USART3_Init 0 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END USART3_Init 0 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN USART3_Init 1 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END USART3_Init 1 */
|
|
|
|
|
|
|
|
huart3.Instance = USART3;
|
|
|
|
|
|
|
|
huart3.Init.BaudRate = 115200;
|
|
|
|
|
|
|
|
huart3.Init.WordLength = UART_WORDLENGTH_8B;
|
|
|
|
|
|
|
|
huart3.Init.StopBits = UART_STOPBITS_1;
|
|
|
|
|
|
|
|
huart3.Init.Parity = UART_PARITY_NONE;
|
|
|
|
|
|
|
|
huart3.Init.Mode = UART_MODE_TX_RX;
|
|
|
|
|
|
|
|
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
|
|
|
|
|
|
|
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
|
|
|
|
|
|
|
|
huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
|
|
|
|
|
|
|
|
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
|
|
|
|
|
|
|
if (HAL_UART_Init(&huart3) != HAL_OK) {
|
|
|
|
|
|
|
|
Error_Handler();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* USER CODE BEGIN USART3_Init 2 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END USART3_Init 2 */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Enable DMA controller clock
|
|
|
|
* Enable DMA controller clock
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|