/* Check if the sample reload timer period has elapsed, and that the USB bus is ready for a new sample */
if ((TIFR0 & (1 << OCF0A)) && Audio_Device_IsReadyForNextSample(&Microphone_Audio_Interface))
{
+ /* Clear the sample reload timer compare flag, ready for the next interval */
TIFR0 |= (1 << OCF0A);
/* Audio sample is ADC value scaled to fit the entire range */
/* Check if the sample reload timer period has elapsed, and that the USB bus is ready for a new sample */
if ((TIFR0 & (1 << OCF0A)) && Audio_Device_IsSampleReceived(&Speaker_Audio_Interface))
{
- /* Clear the sample reload timer */
+ /* Clear the sample reload timer compare flag, ready for the next interval */
TIFR0 |= (1 << OCF0A);
/* Retrieve the signed 16-bit left and right audio samples, convert to 8-bit */
printf_P(PSTR("***PACKET (Size %d)***\r\n"), PacketLength);
for (uint16_t i = 0; i < PacketLength; i++)
- printf("%02x ", PacketBuffer[i]);
+ printf("0x%02x ", PacketBuffer[i]);
printf_P(PSTR("\r\n\r\n"));
Bluetooth_Connection.RemoteAddress[5], Bluetooth_Connection.RemoteAddress[4],
Bluetooth_Connection.RemoteAddress[3], Bluetooth_Connection.RemoteAddress[2],
Bluetooth_Connection.RemoteAddress[1], Bluetooth_Connection.RemoteAddress[0]);
+
+ LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
}
/** Bluetooth stack callback event for a completed Bluetooth disconnection. When this callback is made,
Bluetooth_Connection.RemoteAddress[5], Bluetooth_Connection.RemoteAddress[4],
Bluetooth_Connection.RemoteAddress[3], Bluetooth_Connection.RemoteAddress[2],
Bluetooth_Connection.RemoteAddress[1], Bluetooth_Connection.RemoteAddress[0]);
+
+ LEDs_SetAllLEDs(LEDMASK_USB_READY);
}
/** Bluetooth stack callback event for a Bluetooth ACL Channel connection request. When is callback fires,
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
+ /** LED mask for the library LED driver, to indicate that the USB interface is busy. */
+ #define LEDMASK_USB_BUSY LEDS_LED2
+
/* Task Definitions: */
void Bluetooth_Host_Task(void);
const uint8_t* FrameData = (const uint8_t*)Data + sizeof(RFCOMM_Header_t);
uint16_t FrameDataLen = RFCOMM_GetFrameDataLength(FrameData);
+ /* Adjust the frame data pointer to skip over the variable size field */
FrameData += (FrameDataLen < 128) ? 1 : 2;
/* Decode the RFCOMM frame type from the header */
RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, false, RFCOMM_Frame_UIH, sizeof(RFCOMM_Command_t), &Response, Channel);
break;
+ default:
+ BT_RFCOMM_DEBUG(1, "<< Unknown Command");
}
}
static uint8_t RFCOMM_GetFCSValue(const void* FrameStart, uint8_t Length)
{
- const uint8_t* CurrPos = FrameStart;
- uint8_t FCS = 0xFF;
+ uint8_t FCS = 0xFF;
for (uint8_t i = 0; i < Length; i++)
- FCS = pgm_read_byte(&CRC8_Table[FCS ^ *(CurrPos++)]);
+ FCS = pgm_read_byte(&CRC8_Table[FCS ^ ((uint8_t*)FrameStart)[i]]);
return ~FCS;
}
Pipe_Read_Stream_LE(&PacketBuffer, PacketLength);
for (uint16_t i = 0; i < PacketLength; i++)
- printf("%02x ", PacketBuffer[i]);
+ printf("0x%02x ", PacketBuffer[i]);
}
Pipe_ClearIN();