Hey. Is anyone here familliar with stm32cubeMX generated libraries for USART? I am working with MIDI data and just need to receive MIDI messages send from a MIDI keyboard that is connected to a microcontroller through USART using simmilar hardware just changed to +3.3V:
Everytime the keyboard button is pressed, I am expecting to receive 3 bytes of data:
I am struggling to understand how to properly write a code to receive 3 bytes of data. I have written the code above, would that work? I dont have the hardware yet so I cannot test it yet.
Everytime the keyboard button is pressed, I am expecting to receive 3 bytes of data:
C:
__IO ITStatus UartReady = RESET;
void READ_3_BYTES(){
UART_HandleTypeDef huart1;
uint8_t byte[3];
int i = 1
//Buffer used for reception
uint8_t aRxBuffer[16];
if(HAL_UART_Receive_IT(&huart1, (uint8_t *)aRxBuffer, sizeof(RXBUFFERSIZE) != HAL_OK)
{
Error_Handler();
}
if(aRxBuffer && 0xff) == channel_number){
//valid MIDI
while(i<3)
{
byte[i++]=aRxBuffer;
}
}
/*##-3- Wait for the end of the transfer ###################################*/
while (UartReady != SET)
{
}
/* Reset transmission flag */
UartReady = RESET;
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart1)
{
/* Set transmission flag: transfer complete */
UartReady = SET;
}
I am struggling to understand how to properly write a code to receive 3 bytes of data. I have written the code above, would that work? I dont have the hardware yet so I cannot test it yet.
Last edited: