(add forgotten files)

Conflicts:
	Upstream/Src/upstream_statemachine.c
USG_1.0
Robert Fisk 5 years ago
parent 34bfe421b5
commit 0b75f7d1c6

@ -53,7 +53,8 @@ typedef enum
COMMAND_MSC_GET_CAPACITY, //Returns uint32_t blk_nbr, uint32_t blk_size
COMMAND_MSC_READ, //Returns data stream or error packet
COMMAND_MSC_WRITE, //Waits for data stream or returns error packet
COMMAND_MSC_DISCONNECT //Returns same packet after sending Stop command to device
COMMAND_MSC_DISCONNECT, //Returns same packet after sending Stop command to device
COMMAND_MSC_POLL_DISCONNECT //Returns same packet if device is still connected
}
InterfaceCommandMscTypeDef;

@ -46,6 +46,7 @@ void Upstream_StateMachine_DeviceDisconnected(void);
void Upstream_StateMachine_Suspend(void);
void Upstream_StateMachine_CheckResume(void);
void Upstream_StateMachine_Wakeup(void);
void Upstream_StateMachine_PollDeviceConnected(void);

@ -42,6 +42,7 @@
#include "build_config.h"
#include "led.h"
#include "upstream_hid_botdetect.h"
#include "upstream_statemachine.h"
/* USER CODE BEGIN 0 */
@ -63,6 +64,7 @@ void SysTick_Handler(void)
{
HAL_IncTick();
LED_Tick();
Upstream_StateMachine_PollDeviceConnected();
#if (defined (CONFIG_KEYBOARD_ENABLED) && defined (CONFIG_KEYBOARD_BOT_DETECT_ENABLED)) || \
(defined (CONFIG_MOUSE_ENABLED) && defined (CONFIG_MOUSE_BOT_DETECT_ENABLED))

@ -19,14 +19,18 @@
#include "usbd_hid.h"
#include "build_config.h"
#define POLL_DEVICE_CONNECTED_TIMEOUT_MS 1000
UpstreamStateTypeDef UpstreamState = STATE_TEST_INTERFACE;
InterfaceCommandClassTypeDef ConfiguredDeviceClass = COMMAND_CLASS_INTERFACE;
uint32_t PollDeviceConnectedTimer;
void Upstream_StateMachine_TestInterfaceReplyCallback(UpstreamPacketTypeDef* replyPacket);
void Upstream_StateMachine_NotifyDevice(UpstreamPacketTypeDef* freePacket);
void Upstream_StateMachine_NotifyDeviceReplyCallback(UpstreamPacketTypeDef* replyPacket);
void Upstream_StateMachine_PollDeviceConnectedReplyCallback(UpstreamPacketTypeDef* replyPacket);
@ -259,6 +263,7 @@ void Upstream_StateMachine_Suspend(void)
return;
}
PollDeviceConnectedTimer = 0;
UpstreamState = STATE_SUSPENDED;
}
@ -295,3 +300,47 @@ void Upstream_StateMachine_Wakeup(void)
}
//Called by Systick_Handler every 1ms, at high interrupt priority.
void Upstream_StateMachine_PollDeviceConnected(void)
{
UpstreamPacketTypeDef* freePacket;
if ((UpstreamState != STATE_SUSPENDED) ||
(ConfiguredDeviceClass != COMMAND_CLASS_MASS_STORAGE))
{
return;
}
if (++PollDeviceConnectedTimer >= POLL_DEVICE_CONNECTED_TIMEOUT_MS)
{
PollDeviceConnectedTimer = 0;
freePacket = Upstream_GetFreePacketImmediately();
if (freePacket == NULL)
{
UpstreamState = STATE_ERROR;
return;
}
freePacket->Length16 = UPSTREAM_PACKET_HEADER_LEN_16;
freePacket->CommandClass = COMMAND_CLASS_MASS_STORAGE;
freePacket->Command = COMMAND_MSC_POLL_DISCONNECT;
if (Upstream_TransmitPacket(freePacket) == HAL_OK)
{
Upstream_ReceivePacket(Upstream_StateMachine_PollDeviceConnectedReplyCallback);
}
}
}
void Upstream_StateMachine_PollDeviceConnectedReplyCallback(UpstreamPacketTypeDef* replyPacket)
{
if ((UpstreamState != STATE_SUSPENDED) ||
(replyPacket == NULL))
{
UPSTREAM_STATEMACHINE_FREAKOUT;
return;
}
//Downstream device is still connected, so nothing to do here
Upstream_ReleasePacket(replyPacket);
}

Loading…
Cancel
Save