Problems in UART communication between ESP32 and STM32 - stm32

I have a problem with the UART communication between an ESP32 and a STM32. Everything is working fine until I hardreset the ESP32 then I see a frame error on RX and in TX a shift in the response.
response. As soon as I hardreset the STM32 then everything works again and I see the same output as input. Can someone
help me?
#include "main.h"
#include "ProductMain.h"
#include <string.h>
#include "DebugOutput.h"
#include "GUI.h"
uint8_t UART7_rxBuffer[2] = {0};
uint8_t pass1 = 99;
uint8_t rfidDetected = 0;
SPI_HandleTypeDef hspi1;
UART_HandleTypeDef huart7;
UART_HandleTypeDef huart1;
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_SPI1_Init(void);
static void MX_UART7_Init(void);
static void MX_USART1_UART_Init(void);
char spi_buf ='A';
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_SPI1_Init();
MX_UART7_Init();
MX_USART1_UART_Init();
Product_init();
HAL_UART_Receive_IT (&huart7, UART7_rxBuffer, 2);
HAL_UART_Transmit_IT(&huart7, UART7_rxBuffer, 2);
while (1)
{
Product_loop(pass1);
}
}
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 16;
RCC_OscInitStruct.PLL.PLLN = 192;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
RCC_OscInitStruct.PLL.PLLQ = 4;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV8;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler();
}
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_PLLCLK, RCC_MCODIV_1);
}
static void MX_SPI1_Init(void)
{
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi1.Init.NSS = SPI_NSS_SOFT;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi1.Init.CRCPolynomial = 10;
if (HAL_SPI_Init(&hspi1) != HAL_OK)
{
Error_Handler();
}
}
static void MX_UART7_Init(void)
{
huart7.Instance = UART7;
huart7.Init.BaudRate = 9600;
huart7.Init.WordLength = UART_WORDLENGTH_8B;
huart7.Init.StopBits = UART_STOPBITS_1;
huart7.Init.Parity = UART_PARITY_NONE;
huart7.Init.Mode = UART_MODE_TX_RX;
huart7.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart7.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart7) != HAL_OK)
{
Error_Handler();
}
}
static void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 9600;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
}
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6, GPIO_PIN_RESET);
HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOD, DISPLAY_RESET_Pin|DISPLAY_DATA_CMD_Pin, GPIO_PIN_RESET);
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
GPIO_InitStruct.Pin = SPI1_CS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(SPI1_CS_GPIO_Port, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = DISPLAY_RESET_Pin|DISPLAY_DATA_CMD_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
GPIO_InitStruct.Pin = DISPLAY_BUSY_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(DISPLAY_BUSY_GPIO_Port, &GPIO_InitStruct);
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
HAL_UART_Transmit_IT(&huart7, UART7_rxBuffer, 2);
HAL_UART_Receive_IT(&huart7, UART7_rxBuffer, 2);
}
void Error_Handler(void)
{
__disable_irq();
while (1)
{
}
}
#ifdef USE_FULL_ASSERT
void assert_failed(uint8_t *file, uint32_t line)
{
}
#endif /* USE_FULL_ASSERT */
Best regards
Framing Error
Shift

Related

How to prevent picked up object from changing its scale?

I'm facing an issue when I pick up an object in my game. Whenever I pick up an object and look around while holding the object, it stretches based on the perspective. Here is an example of an object before and after picking up:
Before picking up:
After picking up:
How can I maintain the object's scale and prevent it from stretching?
public void PickupObject()
{
physicsObject = lookObject.GetComponentInChildren<PhysicsObjects>();
currentlyPickedUpObject = lookObject;
pickupRB = currentlyPickedUpObject.GetComponent<Rigidbody>();
/* priorConstraints = pickupRB.constraints; // <--- NEW
pickupRB.constraints = RigidbodyConstraints.FreezeAll; // <--- NEW*/
pickupRB.constraints = RigidbodyConstraints.FreezeRotation;
physicsObject.playerInteractions = this;
pickupRB.isKinematic = true;
pickupRB.transform.parent = PickupParent.transform;
// pickupRB.isKinematic = true;
// StartCoroutine(physicsObject.PickUp());
}
The following code snippet is in Update() :
if (currentlyPickedUpObject != null)
{
HoldingItemIcon.SetActive(true);
InteractIcon.SetActive(false);
CenterIcon.SetActive(false);
currentDist = Vector3.Distance(PickupParent.position, pickupRB.position);
currentSpeed = Mathf.SmoothStep(minSpeed, maxSpeed, currentDist / maxDistance);
currentSpeed *= Time.fixedDeltaTime;
pickupRB.transform.position = PickupParent.position;
// pickupRB.transform.SetParent(PickupParent.transform);
Vector3 direction = PickupParent.position - pickupRB.position;
pickupRB.velocity = direction.normalized * currentSpeed;
Vector3 camerDirection = mainCamera.transform.forward;
// Throw object
if (Throw)
{
HoldingItemIcon.SetActive(false);
InteractIcon.SetActive(false);
pickupRB.constraints = RigidbodyConstraints.None;
pickupRB.isKinematic = false;
pickupRB.AddForce(camerDirection * 500);
currentlyPickedUpObject = null;
pickupRB.transform.parent = null;
}
Throw = false;
}
public void BreakConnection()
{
pickupRB.isKinematic = false;
pickupRB.transform.parent = null;
pickupRB.constraints = priorConstraints;
// pickupRB.constraints = RigidbodyConstraints.None;
currentlyPickedUpObject = null;
lookObject = null;
physicsObject.pickedUp = false;
currentDist = 0;
pickupRB.useGravity = true;
}
pickupParent's lossy scale while an object is picked:
What you can do is have an empty gameObject as a child of your player. That object is going to be the pickableObjectsParent and give this parent object the scale values of 1/(player's scale).

How to throw object to the direction the player is facing?

I'm trying to throw an object after it is being held. Here is how the pickup works:
public void PickupObject()
{
physicsObject = lookObject.GetComponentInChildren<PhysicsObjects>();
currentlyPickedUpObject = lookObject;
pickupRB = currentlyPickedUpObject.GetComponent<Rigidbody>();
priorConstraints = pickupRB.constraints;
pickupRB.constraints = RigidbodyConstraints.FreezeAll;
pickupRB.constraints = RigidbodyConstraints.FreezeRotation;
physicsObject.playerInteractions = this;
pickupRB.isKinematic = true;
pickupRB.transform.parent = PickupParent.transform;
// pickupRB.isKinematic = true;
StartCoroutine(physicsObject.PickUp());
}
in the update():
if (currentlyPickedUpObject != null)
{
currentDist = Vector3.Distance(PickupParent.position, pickupRB.position);
currentSpeed = Mathf.SmoothStep(minSpeed, maxSpeed, currentDist / maxDistance);
currentSpeed *= Time.fixedDeltaTime;
pickupRB.transform.position = PickupParent.position;
// pickupRB.transform.SetParent(PickupParent.transform);
Vector3 direction = PickupParent.position - pickupRB.position;
pickupRB.velocity = direction.normalized * currentSpeed;
Vector3 camerDirection = mainCamera.transform.forward;
// Throw object
if (Throw)
{
pickupRB.constraints = RigidbodyConstraints.None;
pickupRB.isKinematic = false;
Debug.Log("Object is being thrown");
pickupRB.AddForce(camerDirection * 100);
}
Throw = false;
}
as shown above I was trying to add force to the direction the player to be able to throw the item in that direction in this part:
Vector3 camerDirection = mainCamera.transform.forward;
if (Throw)
{
pickupRB.constraints = RigidbodyConstraints.None;
pickupRB.isKinematic = false;
Debug.Log("Object is being thrown");
pickupRB.AddForce(camerDirection * 100);
}
Throw = false;
The line is printed in the console when the throw button is pressed but nothing happens. How to fix this?
I think you're throwing the object but you're not releasing it, so on the next frame the currentlyPickedUpObject is not null so you go right back to moving it with the PickupParent again. Try setting it to null inside your if (Throw) statement so you don't keep moving it:
if (currentlyPickedUpObject != null)
{
currentDist = Vector3.Distance(PickupParent.position, pickupRB.position);
currentSpeed = Mathf.SmoothStep(minSpeed, maxSpeed, currentDist / maxDistance);
currentSpeed *= Time.fixedDeltaTime;
pickupRB.transform.position = PickupParent.position;
// pickupRB.transform.SetParent(PickupParent.transform);
Vector3 direction = PickupParent.position - pickupRB.position;
pickupRB.velocity = direction.normalized * currentSpeed;
Vector3 camerDirection = mainCamera.transform.forward;
// Throw object
if (Throw)
{
pickupRB.constraints = RigidbodyConstraints.None;
pickupRB.isKinematic = false;
Debug.Log("Object is being thrown");
pickupRB.AddForce(camerDirection * 100);
currentlyPickedUpObject = null; // <--- NEW
}
Throw = false;
}
The problem is when you pick the object up you are setting the pickupRB kinematic with line
pickupRB.isKinematic = true
So to fix this, you should add
pickupRB.isKinematic = false
before you add force to the rigidbody.

STM32L4 ADC not working (multiple channels no DMA)

I am trying to run a code I found some time ago here, that allows to choose an ADC channel from a few channels and to read it individually when necessary. No DMA involved. I use STM32L4R5. My idea is just to confirm proper ADC reading by switching status LEDs on and off if some level is available and it is not working at all so far (status led for is always ON).
For input signal source I use a GPIO pin, set to high, that passes through a 1k resistor and a LED so the voltage is about 0.7V.
I call __HAL_RCC_ADC_CLK_ENABLE(); and __HAL_RCC_GPIOC_CLK_ENABLE(); in the HAL_ADC_MspInit().
status_led() function is not shown but I use it a lot, no problem with it.
The rest of the code is as follows:
uint32_t pdlvl=0;
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_ADC1_Init();
MX_TIM1_Init();
// Test ADC reading voltage input
//
while(1){
pdlvl=read_ADC_channel(ADC_CHANNEL_13);
if(pdlvl<10){
status_led(4,1);
status_led(3,0);
}
if(pdlvl>10){
status_led(3,1);
status_led(4,0);
}
}
} // end of main
static void MX_ADC1_Init(void)
{
ADC_ChannelConfTypeDef sConfig = {0};
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.ScanConvMode = DISABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.NbrOfConversion = 1;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.DMAContinuousRequests = DISABLE;
hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc1.Init.OversamplingMode = DISABLE;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_13;
sConfig.Rank = ADC_RANK_NONE;
sConfig.SamplingTime = ADC_SAMPLETIME_640CYCLES_5;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_14;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
}
Pin initialization
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
__HAL_RCC_GPIOC_CLK_ENABLE();
GPIO_InitStruct.Pin = ROUT1_Pin|ROUT2_Pin; // ADC_CHANNEL_13 and ADC_CHANNEL_14
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
}
Now the tricky part with pre-config of channels:
void config_ADC_channel(uint32_t channel, uint8_t val)
{
ADC_ChannelConfTypeDef sConfig;
sConfig.Channel = channel;
sConfig.SamplingTime = ADC_SAMPLETIME_640CYCLES_5;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
if(val==1){
sConfig.Rank = 1;
}
else{
sConfig.Rank = ADC_RANK_NONE;
}
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
}
and the reading function
uint32_t read_ADC_channel(uint32_t channel)
{
uint32_t digital_result;
config_ADC_channel(channel, 1);
// HAL_ADCEx_Calibration_Start(&hadc1,ADC_SINGLE_ENDED);
HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1, 1000);
digital_result = HAL_ADC_GetValue(&hadc1);
HAL_ADC_Stop(&hadc1);
config_ADC_channel(channel, 0);
return digital_result;
}
Any ideas where I am wrong?
Thank you!
I found the problem. I did not set correctly the Periphery clock source (initially generated by CubeMX, and modified source by me later):
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_PLLSAI1;
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSE;
PeriphClkInit.PLLSAI1.PLLSAI1M = 6;
PeriphClkInit.PLLSAI1.PLLSAI1N = 20;
PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV2;
PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2;
PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2;
PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_ADC1CLK;

STM32 HAL SPI Clock issues

New to using HAL, and I'm having several issues with setting up the SPI.
I'm using SPI 1 on an STM32F429ZGT6.
Here's my setup:
SPI_HandleTypeDef SPI_1;
void SPI_INIT(void)
{
__HAL_RCC_SPI1_CLK_ENABLE();
SPI_1.Instance = SPI1;
SPI_1.Init.Mode = SPI_MODE_MASTER;
SPI_1.Init.Direction = SPI_DIRECTION_2LINES;
SPI_1.Init.DataSize = SPI_DATASIZE_8BIT;
SPI_1.Init.CLKPolarity = SPI_POLARITY_HIGH;
SPI_1.Init.CLKPhase = SPI_PHASE_2EDGE;
SPI_1.Init.NSS = SPI_NSS_SOFT;
SPI_1.Init.FirstBit = SPI_FIRSTBIT_MSB;
SPI_1.Init.TIMode = SPI_TIMODE_DISABLE;
SPI_1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
SPI_1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
HAL_SPI_Init(&SPI_1);
}
static void ConfigGPIOA(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
static void ConfigGPIOE(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
__HAL_RCC_GPIOE_CLK_ENABLE();
GPIO_InitStruct.Pin = SPI_CS02_Pin|SPI_CS03_Pin|SPI_CS00_Pin|SPI_CS01_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_0, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_SET);
}
Just initializing SPI 1 and configuring GPIO Pins 5, 6 and 7 for SPI1. I set up GPIOE Pins 0, 1, 2 and 3 for a manual chip select, and I'm writing to them for an idle high (initializing them as pullup doesn't seem to work)
Here's my main:
int main(void)
{
HAL_Init();
SystemClock_Config();
GPIOInit();
SPI_INIT();
for(spibyte=0; spibyte < 4; spibyte++)
{
CS_LOW();
if(spibyte == 0)
{
HAL_SPI_Transmit(&SPI_1, (uint8_t *)0x51, 2, 10);
}
if(spibyte >= 1)
{
HAL_SPI_Transmit(&SPI_1, (uint8_t *)0xFF, 2, 10);
}
_DELAY(TDISCS);
CS_HIGH();
}
}
GPIOInit() runs both ConfigGPIOA and ConfigGPIOE.
CS_LOW() and CS_HIGH() are macros that just pull the chip select up and down. I've watched the chip select line on the oscilloscope and it does switch.
Project builds and loads onto the board, but the MOSI pin is silent, and putting the scope on the clock pin, the clock line is pulled up once, comes back down, and remains that way.
I will also note that the clock idles low, even though I've clearly set the clock polarity to high on my SPI initiailization.
Is there something I'm missing? I don't understand why the SPI lines are acting this way.

Visual C++ Form Variable Errors

I'm new to Visual C++, have added a form to my project, which has given me a file kamisado_board.h with entirely auto-generated code, which I have included at the bottom of this post for reference. I assume this is fine as it was generated by the program.
I've written a separate file, kamisado_main.cpp, and get the following errors upon compiling:
"Error 1 error C2065: 'KamisadoBoard' : undeclared identifier"
"Error 2 error C2146: syntax error : missing ';' before identifier 'form'"
"Error 3 error C2065: 'form' : undeclared identifier"
"Error 4 error C2061: syntax error : identifier 'KamisadoBoard'"
"Error 5 error C2065: 'form' : undeclared identifier"
"Error 6 error C2227: left of '->Show' must point to class/struct/union/generic type"
I have included the code for this file here:
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <iostream>
#include "kamisado_board.h"
int
main(int argc, char *argv[])
{
bool running = true;
int input = 0;
KamisadoBoard form = gcnew KamisadoBoard;
return(0);
}
I figured that it might be a missing #include from my experience with C (I code C for my job but am new to C++), but it's still complaining even with me including kamisado_board.h. Am I missing a line somewhere? I've included the auto-generated form file kamisado_board.h below for reference though I'm assuming this will be correct! Thanks in advance.
//kamisado_board.h
#pragma once
namespace Project1 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for KamisadoBoard
/// </summary>
public ref class KamisadoBoard : public System::Windows::Forms::Form
{
public:
KamisadoBoard(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~KamisadoBoard()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::Button^ button6;
private: System::Windows::Forms::Button^ button7;
private: System::Windows::Forms::Button^ button8;
private: System::Windows::Forms::Button^ button9;
private: System::Windows::Forms::Button^ button10;
private: System::Windows::Forms::Button^ button11;
private: System::Windows::Forms::Button^ button12;
private: System::Windows::Forms::Button^ button13;
private: System::Windows::Forms::Button^ button14;
private: System::Windows::Forms::Button^ button15;
private: System::Windows::Forms::Button^ button16;
private: System::Windows::Forms::Button^ button17;
private: System::Windows::Forms::Button^ button18;
private: System::Windows::Forms::Button^ button19;
private: System::Windows::Forms::Button^ button20;
private: System::Windows::Forms::Button^ button21;
private: System::Windows::Forms::Button^ button22;
private: System::Windows::Forms::Button^ button23;
private: System::Windows::Forms::Button^ button24;
private: System::Windows::Forms::Button^ button25;
private: System::Windows::Forms::Button^ button26;
private: System::Windows::Forms::Button^ button27;
private: System::Windows::Forms::Button^ button28;
private: System::Windows::Forms::Button^ button29;
private: System::Windows::Forms::Button^ button30;
private: System::Windows::Forms::Button^ button31;
private: System::Windows::Forms::Button^ button32;
private: System::Windows::Forms::Button^ button33;
private: System::Windows::Forms::Button^ button34;
private: System::Windows::Forms::Button^ button35;
private: System::Windows::Forms::Button^ button36;
private: System::Windows::Forms::Button^ button37;
private: System::Windows::Forms::Button^ button38;
private: System::Windows::Forms::Button^ button39;
private: System::Windows::Forms::Button^ button40;
private: System::Windows::Forms::Button^ button41;
private: System::Windows::Forms::Button^ button42;
private: System::Windows::Forms::Button^ button43;
private: System::Windows::Forms::Button^ button44;
private: System::Windows::Forms::Button^ button45;
private: System::Windows::Forms::Button^ button46;
private: System::Windows::Forms::Button^ button47;
private: System::Windows::Forms::Button^ button48;
private: System::Windows::Forms::Button^ button49;
private: System::Windows::Forms::Button^ button50;
private: System::Windows::Forms::Button^ button51;
private: System::Windows::Forms::Button^ button52;
private: System::Windows::Forms::Button^ button53;
private: System::Windows::Forms::Button^ button54;
private: System::Windows::Forms::Button^ button55;
private: System::Windows::Forms::Button^ button56;
private: System::Windows::Forms::Button^ button57;
private: System::Windows::Forms::Button^ button58;
private: System::Windows::Forms::Button^ button59;
private: System::Windows::Forms::Button^ button60;
private: System::Windows::Forms::Button^ button61;
private: System::Windows::Forms::Button^ button62;
private: System::Windows::Forms::Button^ button63;
private: System::Windows::Forms::Button^ button64;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->button5 = (gcnew System::Windows::Forms::Button());
this->button6 = (gcnew System::Windows::Forms::Button());
this->button7 = (gcnew System::Windows::Forms::Button());
this->button8 = (gcnew System::Windows::Forms::Button());
this->button9 = (gcnew System::Windows::Forms::Button());
this->button10 = (gcnew System::Windows::Forms::Button());
this->button11 = (gcnew System::Windows::Forms::Button());
this->button12 = (gcnew System::Windows::Forms::Button());
this->button13 = (gcnew System::Windows::Forms::Button());
this->button14 = (gcnew System::Windows::Forms::Button());
this->button15 = (gcnew System::Windows::Forms::Button());
this->button16 = (gcnew System::Windows::Forms::Button());
this->button17 = (gcnew System::Windows::Forms::Button());
this->button18 = (gcnew System::Windows::Forms::Button());
this->button19 = (gcnew System::Windows::Forms::Button());
this->button20 = (gcnew System::Windows::Forms::Button());
this->button21 = (gcnew System::Windows::Forms::Button());
this->button22 = (gcnew System::Windows::Forms::Button());
this->button23 = (gcnew System::Windows::Forms::Button());
this->button24 = (gcnew System::Windows::Forms::Button());
this->button25 = (gcnew System::Windows::Forms::Button());
this->button26 = (gcnew System::Windows::Forms::Button());
this->button27 = (gcnew System::Windows::Forms::Button());
this->button28 = (gcnew System::Windows::Forms::Button());
this->button29 = (gcnew System::Windows::Forms::Button());
this->button30 = (gcnew System::Windows::Forms::Button());
this->button31 = (gcnew System::Windows::Forms::Button());
this->button32 = (gcnew System::Windows::Forms::Button());
this->button33 = (gcnew System::Windows::Forms::Button());
this->button34 = (gcnew System::Windows::Forms::Button());
this->button35 = (gcnew System::Windows::Forms::Button());
this->button36 = (gcnew System::Windows::Forms::Button());
this->button37 = (gcnew System::Windows::Forms::Button());
this->button38 = (gcnew System::Windows::Forms::Button());
this->button39 = (gcnew System::Windows::Forms::Button());
this->button40 = (gcnew System::Windows::Forms::Button());
this->button41 = (gcnew System::Windows::Forms::Button());
this->button42 = (gcnew System::Windows::Forms::Button());
this->button43 = (gcnew System::Windows::Forms::Button());
this->button44 = (gcnew System::Windows::Forms::Button());
this->button45 = (gcnew System::Windows::Forms::Button());
this->button46 = (gcnew System::Windows::Forms::Button());
this->button47 = (gcnew System::Windows::Forms::Button());
this->button48 = (gcnew System::Windows::Forms::Button());
this->button49 = (gcnew System::Windows::Forms::Button());
this->button50 = (gcnew System::Windows::Forms::Button());
this->button51 = (gcnew System::Windows::Forms::Button());
this->button52 = (gcnew System::Windows::Forms::Button());
this->button53 = (gcnew System::Windows::Forms::Button());
this->button54 = (gcnew System::Windows::Forms::Button());
this->button55 = (gcnew System::Windows::Forms::Button());
this->button56 = (gcnew System::Windows::Forms::Button());
this->button57 = (gcnew System::Windows::Forms::Button());
this->button58 = (gcnew System::Windows::Forms::Button());
this->button59 = (gcnew System::Windows::Forms::Button());
this->button60 = (gcnew System::Windows::Forms::Button());
this->button61 = (gcnew System::Windows::Forms::Button());
this->button62 = (gcnew System::Windows::Forms::Button());
this->button63 = (gcnew System::Windows::Forms::Button());
this->button64 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->BackColor = System::Drawing::Color::Orange;
this->button1->Location = System::Drawing::Point(43, 24);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(23, 23);
this->button1->TabIndex = 0;
this->button1->UseVisualStyleBackColor = false;
//
// button2
//
this->button2->BackColor = System::Drawing::Color::Blue;
this->button2->Location = System::Drawing::Point(72, 24);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(23, 23);
this->button2->TabIndex = 1;
this->button2->UseVisualStyleBackColor = false;
//
// button3
//
this->button3->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->button3->Location = System::Drawing::Point(129, 24);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(23, 23);
this->button3->TabIndex = 3;
this->button3->UseVisualStyleBackColor = false;
//
// button4
//
this->button4->BackColor = System::Drawing::Color::Purple;
this->button4->Location = System::Drawing::Point(100, 24);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(23, 23);
this->button4->TabIndex = 2;
this->button4->UseVisualStyleBackColor = false;
//
// button5
//
this->button5->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(128)), static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button5->Location = System::Drawing::Point(244, 24);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(23, 23);
this->button5->TabIndex = 7;
this->button5->UseVisualStyleBackColor = false;
//
// button6
//
this->button6->BackColor = System::Drawing::Color::Green;
this->button6->Location = System::Drawing::Point(215, 24);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(23, 23);
this->button6->TabIndex = 6;
this->button6->UseVisualStyleBackColor = false;
//
// button7
//
this->button7->BackColor = System::Drawing::Color::Red;
this->button7->Location = System::Drawing::Point(187, 24);
this->button7->Name = L"button7";
this->button7->Size = System::Drawing::Size(23, 23);
this->button7->TabIndex = 5;
this->button7->UseVisualStyleBackColor = false;
//
// button8
//
this->button8->BackColor = System::Drawing::Color::Yellow;
this->button8->Location = System::Drawing::Point(158, 24);
this->button8->Name = L"button8";
this->button8->Size = System::Drawing::Size(23, 23);
this->button8->TabIndex = 4;
this->button8->UseVisualStyleBackColor = false;
//
// button9
//
this->button9->BackColor = System::Drawing::Color::Purple;
this->button9->Location = System::Drawing::Point(244, 53);
this->button9->Name = L"button9";
this->button9->Size = System::Drawing::Size(23, 23);
this->button9->TabIndex = 15;
this->button9->UseVisualStyleBackColor = false;
//
// button10
//
this->button10->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(128)), static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button10->Location = System::Drawing::Point(215, 53);
this->button10->Name = L"button10";
this->button10->Size = System::Drawing::Size(23, 23);
this->button10->TabIndex = 14;
this->button10->UseVisualStyleBackColor = false;
this->button10->Click += gcnew System::EventHandler(this, &KamisadoBoard::button10_Click);
//
// button11
//
this->button11->BackColor = System::Drawing::Color::Yellow;
this->button11->Location = System::Drawing::Point(187, 53);
this->button11->Name = L"button11";
this->button11->Size = System::Drawing::Size(23, 23);
this->button11->TabIndex = 13;
this->button11->UseVisualStyleBackColor = false;
//
// button12
//
this->button12->BackColor = System::Drawing::Color::Blue;
this->button12->Location = System::Drawing::Point(158, 53);
this->button12->Name = L"button12";
this->button12->Size = System::Drawing::Size(23, 23);
this->button12->TabIndex = 12;
this->button12->UseVisualStyleBackColor = false;
this->button12->Click += gcnew System::EventHandler(this, &KamisadoBoard::button12_Click);
//
// button13
//
this->button13->BackColor = System::Drawing::Color::Green;
this->button13->Location = System::Drawing::Point(129, 53);
this->button13->Name = L"button13";
this->button13->Size = System::Drawing::Size(23, 23);
this->button13->TabIndex = 11;
this->button13->UseVisualStyleBackColor = false;
this->button13->Click += gcnew System::EventHandler(this, &KamisadoBoard::button13_Click);
//
// button14
//
this->button14->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->button14->Location = System::Drawing::Point(100, 53);
this->button14->Name = L"button14";
this->button14->Size = System::Drawing::Size(23, 23);
this->button14->TabIndex = 10;
this->button14->UseVisualStyleBackColor = false;
//
// button15
//
this->button15->BackColor = System::Drawing::Color::Orange;
this->button15->Location = System::Drawing::Point(72, 53);
this->button15->Name = L"button15";
this->button15->Size = System::Drawing::Size(23, 23);
this->button15->TabIndex = 9;
this->button15->UseVisualStyleBackColor = false;
//
// button16
//
this->button16->BackColor = System::Drawing::Color::Red;
this->button16->Location = System::Drawing::Point(43, 53);
this->button16->Name = L"button16";
this->button16->Size = System::Drawing::Size(23, 23);
this->button16->TabIndex = 8;
this->button16->UseVisualStyleBackColor = false;
//
// button17
//
this->button17->BackColor = System::Drawing::Color::Yellow;
this->button17->Location = System::Drawing::Point(244, 111);
this->button17->Name = L"button17";
this->button17->Size = System::Drawing::Size(23, 23);
this->button17->TabIndex = 31;
this->button17->UseVisualStyleBackColor = false;
//
// button18
//
this->button18->BackColor = System::Drawing::Color::Red;
this->button18->Location = System::Drawing::Point(215, 111);
this->button18->Name = L"button18";
this->button18->Size = System::Drawing::Size(23, 23);
this->button18->TabIndex = 30;
this->button18->UseVisualStyleBackColor = false;
//
// button19
//
this->button19->BackColor = System::Drawing::Color::Green;
this->button19->Location = System::Drawing::Point(187, 111);
this->button19->Name = L"button19";
this->button19->Size = System::Drawing::Size(23, 23);
this->button19->TabIndex = 29;
this->button19->UseVisualStyleBackColor = false;
//
// button20
//
this->button20->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(128)), static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button20->Location = System::Drawing::Point(158, 111);
this->button20->Name = L"button20";
this->button20->Size = System::Drawing::Size(23, 23);
this->button20->TabIndex = 28;
this->button20->UseVisualStyleBackColor = false;
//
// button21
//
this->button21->BackColor = System::Drawing::Color::Orange;
this->button21->Location = System::Drawing::Point(129, 111);
this->button21->Name = L"button21";
this->button21->Size = System::Drawing::Size(23, 23);
this->button21->TabIndex = 27;
this->button21->UseVisualStyleBackColor = false;
//
// button22
//
this->button22->BackColor = System::Drawing::Color::Blue;
this->button22->Location = System::Drawing::Point(100, 111);
this->button22->Name = L"button22";
this->button22->Size = System::Drawing::Size(23, 23);
this->button22->TabIndex = 26;
this->button22->UseVisualStyleBackColor = false;
//
// button23
//
this->button23->BackColor = System::Drawing::Color::Purple;
this->button23->Location = System::Drawing::Point(72, 111);
this->button23->Name = L"button23";
this->button23->Size = System::Drawing::Size(23, 23);
this->button23->TabIndex = 25;
this->button23->UseVisualStyleBackColor = false;
//
// button24
//
this->button24->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->button24->Location = System::Drawing::Point(43, 111);
this->button24->Name = L"button24";
this->button24->Size = System::Drawing::Size(23, 23);
this->button24->TabIndex = 24;
this->button24->UseVisualStyleBackColor = false;
//
// button25
//
this->button25->BackColor = System::Drawing::Color::Blue;
this->button25->Location = System::Drawing::Point(244, 82);
this->button25->Name = L"button25";
this->button25->Size = System::Drawing::Size(23, 23);
this->button25->TabIndex = 23;
this->button25->UseVisualStyleBackColor = false;
//
// button26
//
this->button26->BackColor = System::Drawing::Color::Yellow;
this->button26->Location = System::Drawing::Point(215, 82);
this->button26->Name = L"button26";
this->button26->Size = System::Drawing::Size(23, 23);
this->button26->TabIndex = 22;
this->button26->UseVisualStyleBackColor = false;
//
// button27
//
this->button27->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(128)), static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button27->Location = System::Drawing::Point(187, 82);
this->button27->Name = L"button27";
this->button27->Size = System::Drawing::Size(23, 23);
this->button27->TabIndex = 21;
this->button27->UseVisualStyleBackColor = false;
//
// button28
//
this->button28->BackColor = System::Drawing::Color::Purple;
this->button28->Location = System::Drawing::Point(158, 82);
this->button28->Name = L"button28";
this->button28->Size = System::Drawing::Size(23, 23);
this->button28->TabIndex = 20;
this->button28->UseVisualStyleBackColor = false;
//
// button29
//
this->button29->BackColor = System::Drawing::Color::Red;
this->button29->Location = System::Drawing::Point(129, 82);
this->button29->Name = L"button29";
this->button29->Size = System::Drawing::Size(23, 23);
this->button29->TabIndex = 19;
this->button29->UseVisualStyleBackColor = false;
//
// button30
//
this->button30->BackColor = System::Drawing::Color::Orange;
this->button30->Location = System::Drawing::Point(100, 82);
this->button30->Name = L"button30";
this->button30->Size = System::Drawing::Size(23, 23);
this->button30->TabIndex = 18;
this->button30->UseVisualStyleBackColor = false;
//
// button31
//
this->button31->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->button31->Location = System::Drawing::Point(72, 82);
this->button31->Name = L"button31";
this->button31->Size = System::Drawing::Size(23, 23);
this->button31->TabIndex = 17;
this->button31->UseVisualStyleBackColor = false;
//
// button32
//
this->button32->BackColor = System::Drawing::Color::Green;
this->button32->Location = System::Drawing::Point(43, 82);
this->button32->Name = L"button32";
this->button32->Size = System::Drawing::Size(23, 23);
this->button32->TabIndex = 16;
this->button32->UseVisualStyleBackColor = false;
//
// button33
//
this->button33->BackColor = System::Drawing::Color::Orange;
this->button33->Location = System::Drawing::Point(244, 225);
this->button33->Name = L"button33";
this->button33->Size = System::Drawing::Size(23, 23);
this->button33->TabIndex = 63;
this->button33->UseVisualStyleBackColor = false;
//
// button34
//
this->button34->BackColor = System::Drawing::Color::Blue;
this->button34->Location = System::Drawing::Point(215, 225);
this->button34->Name = L"button34";
this->button34->Size = System::Drawing::Size(23, 23);
this->button34->TabIndex = 62;
this->button34->UseVisualStyleBackColor = false;
//
// button35
//
this->button35->BackColor = System::Drawing::Color::Purple;
this->button35->Location = System::Drawing::Point(187, 225);
this->button35->Name = L"button35";
this->button35->Size = System::Drawing::Size(23, 23);
this->button35->TabIndex = 61;
this->button35->UseVisualStyleBackColor = false;
//
// button36
//
this->button36->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->button36->Location = System::Drawing::Point(158, 225);
this->button36->Name = L"button36";
this->button36->Size = System::Drawing::Size(23, 23);
this->button36->TabIndex = 60;
this->button36->UseVisualStyleBackColor = false;
//
// button37
//
this->button37->BackColor = System::Drawing::Color::Yellow;
this->button37->Location = System::Drawing::Point(129, 225);
this->button37->Name = L"button37";
this->button37->Size = System::Drawing::Size(23, 23);
this->button37->TabIndex = 59;
this->button37->UseVisualStyleBackColor = false;
//
// button38
//
this->button38->BackColor = System::Drawing::Color::Red;
this->button38->Location = System::Drawing::Point(100, 225);
this->button38->Name = L"button38";
this->button38->Size = System::Drawing::Size(23, 23);
this->button38->TabIndex = 58;
this->button38->UseVisualStyleBackColor = false;
//
// button39
//
this->button39->BackColor = System::Drawing::Color::Green;
this->button39->Location = System::Drawing::Point(72, 225);
this->button39->Name = L"button39";
this->button39->Size = System::Drawing::Size(23, 23);
this->button39->TabIndex = 57;
this->button39->UseVisualStyleBackColor = false;
<... truncated - 30k character limit ...>`
Ok, I'm assuming that the kamisado_main.h is your main form, because you have the main routine in the .c++ file.
I cant't see the whole header file, but I think it looks fine, I hope you created the project with the CLI option.
You have to create the form variable like this, you*re missing ^, this should resolve all the errors: KamisadoBoard ^ form = gcnew KamisadoBoard;
I'm not sure if you can use this native main routine for C++/CLI, if it doesn't work try using this code in your kamisado_main.cpp:
#include "kamisado_main.h"
using namespace Project1;
[STAThreadAttribute]
int main(cli::array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew KamisadoBoard ());
return 0;
}