void HAL_MIDI_TxMsg(MIDIMsg_t* msg) { uint8_t bytesToSend; uint8_t messageIndex; uint8_t cableNo = 0; messageIndex = LookupMIDIMessage(msg->status); bytesToSend = GetNumberOfBytesToRead(messageIndex); UART_TxByte(msg->status); USBMIDI_PutByte(msg->status, cableNo); if( bytesToSend > 1) { UART_TxByte(msg->data1); USBMIDI_PutByte(msg->data1, cableNo); } if( bytesToSend > 2) { UART_TxByte(msg->data2); USBMIDI_PutByte(msg->data2, cableNo); } }
void printNumber(uint16_t number) { uint16_t temp; uint16_t divisor = 10000; UART_TxByte(0xF0); while(divisor) { UART_TxByte(number / divisor ); if( number >= divisor ) { temp = (number / divisor); number = number - (temp * divisor); } divisor = divisor / 10; } UART_TxByte(0xF7); }
void BSP_UARTHandler (void) { CPU_INT32U status; CPU_INT32U int_en; status = BSP_UART_INTSTAT; /* Read the interrupt status register */ int_en = BSP_UART_INTEN; /* Read the interrupt enabled register */ status &= BSP_UART_INTMASK; /* Mask all other interrupts */ BSP_UART_INTCLR = status; /* Clear all triggered interrupts */ status &= int_en; /* Mask non-enabled interrupts */ if (status & BSP_UART_INTRX) { /* If a Rx interrupt has occured and is enabled... */ UART_TxByte(UART_RxByte()); /* Notify Probe and provide the incoming character */ } }
void printMsg(uint8_t* buffer) { UART_TxByte(0xF0); UART_TxBuffer(buffer, strlen((const char*)buffer) ); UART_TxByte(0xF7); }
void UART_TxStr (CPU_CHAR *str) { while (*str) { UART_TxByte(*str++); } }