Wipe out s_dHidActivity because it doesn't make a fucking sense the way it works. Use is_usb_active() instead.
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
#include "peripherals/test_led.h"
|
#include "peripherals/test_led.h"
|
||||||
|
|
||||||
bool usb_hid_poll_for_activity(const peripheral_descriptor_t *self);
|
bool is_usb_active();
|
||||||
static status_t usb_device_full_init(const peripheral_descriptor_t *self, serial_byte_receive_func_t function);
|
static status_t usb_device_full_init(const peripheral_descriptor_t *self, serial_byte_receive_func_t function);
|
||||||
static void usb_device_full_shutdown(const peripheral_descriptor_t *self);
|
static void usb_device_full_shutdown(const peripheral_descriptor_t *self);
|
||||||
|
|
||||||
@@ -17,8 +17,6 @@ static status_t usb_hid_packet_finalize(const peripheral_descriptor_t *self);
|
|||||||
static uint32_t usb_hid_packet_get_max_packet_size(const peripheral_descriptor_t *self);
|
static uint32_t usb_hid_packet_get_max_packet_size(const peripheral_descriptor_t *self);
|
||||||
static void init_i2c(uint32_t instance);
|
static void init_i2c(uint32_t instance);
|
||||||
|
|
||||||
static bool s_dHidActivity = false;
|
|
||||||
|
|
||||||
const peripheral_control_interface_t g_usbHidControlInterface = {.init = usb_device_full_init,
|
const peripheral_control_interface_t g_usbHidControlInterface = {.init = usb_device_full_init,
|
||||||
.shutdown = usb_device_full_shutdown};
|
.shutdown = usb_device_full_shutdown};
|
||||||
|
|
||||||
@@ -71,7 +69,7 @@ bool usb_clock_init(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool usb_hid_poll_for_activity(const peripheral_descriptor_t *self)
|
bool is_usb_active()
|
||||||
{
|
{
|
||||||
return g_device_composite.attach && g_device_composite.hid_generic.hid_packet.didReceiveFirstReport;
|
return g_device_composite.attach && g_device_composite.hid_generic.hid_packet.didReceiveFirstReport;
|
||||||
}
|
}
|
||||||
@@ -229,18 +227,6 @@ void usb_device_full_shutdown(const peripheral_descriptor_t *self)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*FUNCTION**********************************************************************
|
|
||||||
*
|
|
||||||
* Function Name : usb_msc_pump
|
|
||||||
* Description : This function is called repeatedly by the main application
|
|
||||||
* loop. We use it to run the state machine from non-interrupt context
|
|
||||||
*
|
|
||||||
*END**************************************************************************/
|
|
||||||
void usb_msc_pump(const peripheral_descriptor_t *self)
|
|
||||||
{
|
|
||||||
s_dHidActivity = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t usb_hid_packet_init(const peripheral_descriptor_t *self)
|
status_t usb_hid_packet_init(const peripheral_descriptor_t *self)
|
||||||
{
|
{
|
||||||
sync_init(&g_device_composite.hid_generic.hid_packet.receiveSync, false);
|
sync_init(&g_device_composite.hid_generic.hid_packet.receiveSync, false);
|
||||||
@@ -277,7 +263,7 @@ status_t usb_hid_packet_read(const peripheral_descriptor_t *self,
|
|||||||
// debug_printf("usbhid: unsupported packet type %d\r\n", (int)packetType);
|
// debug_printf("usbhid: unsupported packet type %d\r\n", (int)packetType);
|
||||||
return kStatus_Fail;
|
return kStatus_Fail;
|
||||||
};
|
};
|
||||||
if (s_dHidActivity)
|
if (is_usb_active())
|
||||||
{
|
{
|
||||||
// The first receive data request was initiated after enumeration.
|
// The first receive data request was initiated after enumeration.
|
||||||
// After that we wait until we are ready to read data before
|
// After that we wait until we are ready to read data before
|
||||||
@@ -339,7 +325,7 @@ status_t usb_hid_packet_write(const peripheral_descriptor_t *self,
|
|||||||
uint32_t byteCount,
|
uint32_t byteCount,
|
||||||
packet_type_t packetType)
|
packet_type_t packetType)
|
||||||
{
|
{
|
||||||
if (s_dHidActivity)
|
if (is_usb_active())
|
||||||
{
|
{
|
||||||
if (byteCount > kMinPacketBufferSize)
|
if (byteCount > kMinPacketBufferSize)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,10 +19,8 @@ void configure_i2c_address(uint8_t address);
|
|||||||
void configure_i2c_speed(uint32_t speedkhz);
|
void configure_i2c_speed(uint32_t speedkhz);
|
||||||
status_t send_i2c_data(uint8_t *src, uint32_t writeLength);
|
status_t send_i2c_data(uint8_t *src, uint32_t writeLength);
|
||||||
status_t receive_i2c_data(uint8_t *dest, uint32_t readLength);
|
status_t receive_i2c_data(uint8_t *dest, uint32_t readLength);
|
||||||
bool usb_hid_poll_for_activity(const peripheral_descriptor_t *self);
|
|
||||||
status_t usb_hid_packet_init(const peripheral_descriptor_t *self);
|
status_t usb_hid_packet_init(const peripheral_descriptor_t *self);
|
||||||
status_t usb_hid_packet_read(const peripheral_descriptor_t *self, uint8_t **packet, uint32_t *packetLength, packet_type_t packetType);
|
status_t usb_hid_packet_read(const peripheral_descriptor_t *self, uint8_t **packet, uint32_t *packetLength, packet_type_t packetType);
|
||||||
status_t usb_hid_packet_write(const peripheral_descriptor_t *self, const uint8_t *packet, uint32_t byteCount,packet_type_t packetType);
|
status_t usb_hid_packet_write(const peripheral_descriptor_t *self, const uint8_t *packet, uint32_t byteCount,packet_type_t packetType);
|
||||||
extern void usb_msc_pump(const peripheral_descriptor_t *self);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,11 +23,8 @@ void handleUsbBusPalCommand()
|
|||||||
{
|
{
|
||||||
g_commandData.state = kCommandState_CommandPhase;
|
g_commandData.state = kCommandState_CommandPhase;
|
||||||
|
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
usb_msc_pump(g_peripherals);
|
|
||||||
bootloader_command_pump();
|
bootloader_command_pump();
|
||||||
usb_msc_pump(g_peripherals);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,7 +374,7 @@ status_t bootloader_command_pump()
|
|||||||
|
|
||||||
status = usb_hid_packet_read(&g_peripherals[0], &g_commandData.packet, &g_commandData.packetLength,
|
status = usb_hid_packet_read(&g_peripherals[0], &g_commandData.packet, &g_commandData.packetLength,
|
||||||
kPacketType_Command);
|
kPacketType_Command);
|
||||||
//if (g_commandData.packet[12] == 0x64) TEST_LED_OFF();
|
|
||||||
if (status != kStatus_Success)
|
if (status != kStatus_Success)
|
||||||
{
|
{
|
||||||
debug_printf("Error: readPacket returned status 0x%x\r\n", status);
|
debug_printf("Error: readPacket returned status 0x%x\r\n", status);
|
||||||
|
|||||||
Reference in New Issue
Block a user