kopia lustrzana https://github.com/conorpp/u2f-zero
slight clean up and optimizing
rodzic
2e320d1bc7
commit
291ea274dd
|
|
@ -123,6 +123,7 @@
|
|||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usb/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/EFM8UB1/peripheral_driver/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_assert""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/tests""/>
|
||||
</option>
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.general.code.389376290" name="Code size" superClass="com.silabs.ide.si8051.keil.compiler.category.general.code" value="com.silabs.ide.si8051.keil.compiler.category.general.code.large" valueType="enumerated"/>
|
||||
<inputType id="com.silabs.ide.si8051.keil.compiler.inputType.261436307" superClass="com.silabs.ide.si8051.keil.compiler.inputType"/>
|
||||
|
|
@ -134,6 +135,7 @@
|
|||
<option id="com.silabs.ide.si8051.keil.assembler.category.includes.paths.158046198" name="Include paths (INCDIR(...))" superClass="com.silabs.ide.si8051.keil.assembler.category.includes.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc/config}""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/tests""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/tinyprintf""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/shared/si8051Base""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/EFM8UB1""/>
|
||||
|
|
@ -141,7 +143,6 @@
|
|||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usb/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/EFM8UB1/peripheral_driver/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_assert""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/tests""/>
|
||||
</option>
|
||||
<inputType id="com.silabs.ide.si8051.keil.assembler.inputType.1636083418" superClass="com.silabs.ide.si8051.keil.assembler.inputType"/>
|
||||
</tool>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
void atecc_send(uint8_t cmd, uint8_t p1, uint16_t p2,
|
||||
uint8_t * buf, uint8_t len)
|
||||
{
|
||||
static uint8_t params[6];
|
||||
static data uint8_t params[6];
|
||||
params[0] = 0x3;
|
||||
params[1] = 7+len;
|
||||
params[2] = cmd;
|
||||
|
|
@ -33,7 +33,7 @@ void atecc_send(uint8_t cmd, uint8_t p1, uint16_t p2,
|
|||
|
||||
uint8_t atecc_recv(uint8_t * buf, uint8_t buflen)
|
||||
{
|
||||
uint8_t pkt_len;
|
||||
data uint8_t pkt_len;
|
||||
smb_init_crc();
|
||||
pkt_len = smb_read( 0xc0,buf,buflen);
|
||||
|
||||
|
|
|
|||
|
|
@ -74,8 +74,7 @@ uint16_t feed_crc(uint16_t crc, uint8_t b)
|
|||
crc = crc & 1 ? (crc >> 1) ^ 0xa001 : crc >> 1;
|
||||
crc = crc & 1 ? (crc >> 1) ^ 0xa001 : crc >> 1;
|
||||
crc = crc & 1 ? (crc >> 1) ^ 0xa001 : crc >> 1;
|
||||
crc = crc & 1 ? (crc >> 1) ^ 0xa001 : crc >> 1;
|
||||
return crc;
|
||||
return crc & 1 ? (crc >> 1) ^ 0xa001 : crc >> 1;
|
||||
}
|
||||
|
||||
uint16_t reverse_bits(uint16_t crc)
|
||||
|
|
@ -84,8 +83,7 @@ uint16_t reverse_bits(uint16_t crc)
|
|||
crc = (((crc & 0xaaaa) >> 1) | ((crc & 0x5555) << 1));
|
||||
crc = (((crc & 0xcccc) >> 2) | ((crc & 0x3333) << 2));
|
||||
crc = (((crc & 0xf0f0) >> 4) | ((crc & 0x0f0f) << 4));
|
||||
crc = (((crc & 0xff00) >> 8) | ((crc & 0x00ff) << 8));
|
||||
return crc;
|
||||
return (((crc & 0xff00) >> 8) | ((crc & 0x00ff) << 8));
|
||||
}
|
||||
|
||||
void smb_init()
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "u2f_hid.h"
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
data struct APP_DATA appdata;
|
||||
|
||||
|
||||
|
|
@ -39,13 +40,9 @@ data struct APP_DATA appdata;
|
|||
static void init(struct APP_DATA* ap)
|
||||
{
|
||||
memset(ap,0, sizeof(struct APP_DATA));
|
||||
|
||||
ap->state = APP_NOTHING;
|
||||
debug_fifo_init();
|
||||
u2f_hid_init();
|
||||
|
||||
smb_init();
|
||||
|
||||
}
|
||||
|
||||
static void listen_for_pkt(struct APP_DATA* ap)
|
||||
|
|
@ -55,9 +52,6 @@ static void listen_for_pkt(struct APP_DATA* ap)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void test_ecc508a()
|
||||
{
|
||||
uint8_t buf[40];
|
||||
|
|
@ -86,8 +80,8 @@ int16_t main(void) {
|
|||
data uint16_t last_ms = get_ms();
|
||||
data uint16_t ms_heart;
|
||||
data uint16_t ms_wink;
|
||||
uint8_t winks = 0;
|
||||
uint8_t test = 0;
|
||||
data uint8_t winks = 0;
|
||||
data uint8_t test = 0;
|
||||
|
||||
|
||||
init(&appdata);
|
||||
|
|
@ -129,8 +123,6 @@ int16_t main(void) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch(appdata.state)
|
||||
{
|
||||
case APP_NOTHING:
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef TESTS_H_
|
||||
#define TESTS_H_
|
||||
|
||||
#define ENABLE_TESTS
|
||||
// #define ENABLE_TESTS
|
||||
|
||||
#ifdef ENABLE_TESTS
|
||||
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue