im an idiot interrupt deadlock

vtcsec_summit
Conor 2016-03-05 20:56:30 -05:00
rodzic ab5249b7c6
commit a6e963b336
3 zmienionych plików z 22 dodań i 11 usunięć

Wyświetl plik

@ -8,6 +8,7 @@
#include <SI_EFM8UB1_Register_Enums.h>
#include <stdarg.h>
#include "u2f_hid.h"
// debug options
#define U2F_PRINT
@ -25,6 +26,7 @@
typedef enum
{
APP_NOTHING = 0,
APP_HID_MSG,
APP_WINK,
_APP_WINK,
APP_ERROR,
@ -54,13 +56,16 @@ struct APP_DATA
uint8_t tmp[70];
uint8_t state;
uint8_t error;
struct u2f_hid_msg * hid_msg;
};
extern uint8_t hidmsgbuf[64];
extern data struct APP_DATA appdata;
void set_app_u2f_hid_msg(struct u2f_hid_msg * msg );
void set_app_error(APP_ERROR_CODE ec);
// should be called after initializing eeprom

Wyświetl plik

@ -152,17 +152,10 @@ uint16_t USBD_XferCompleteCb(uint8_t epAddr, USB_Status_TypeDef status,
if (epAddr == EP1OUT)
{
#ifdef U2F_PRINT
int i = 0;
for (i=0; i < sizeof(hidmsgbuf); i++)
{
uint8_t l = (uint8_t)hidmsgbuf[i];
u2f_putb(l);
}
u2f_prints("\r\n");
#endif
dump_hex(hidmsgbuf, sizeof(hidmsgbuf));
#ifndef U2F_HID_DISABLE
u2f_hid_request((struct u2f_hid_msg*)hidmsgbuf);
set_app_u2f_hid_msg((struct u2f_hid_msg *) hidmsgbuf );
#endif
}

Wyświetl plik

@ -34,6 +34,12 @@ void set_app_error(APP_ERROR_CODE ec)
appdata.error = ec;
}
void set_app_u2f_hid_msg(struct u2f_hid_msg * msg )
{
appdata.state = APP_HID_MSG;
appdata.hid_msg = msg;
}
void dump_eeprom()
{
@ -103,6 +109,13 @@ int16_t main(void) {
switch(appdata.state)
{
case APP_NOTHING:
break;
case APP_HID_MSG:
u2f_hid_request(appdata.hid_msg);
if (appdata.state == APP_HID_MSG)
appdata.state = APP_NOTHING;
break;
case APP_WINK:
LED_B = 0;