updates
This commit is contained in:
@@ -170,7 +170,7 @@
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="com.silabs.ss.framework.ide.project.core.cpp" project.generation="56" projectCommon.boardIds="brd5000a:0.0.0.A02" projectCommon.buildArtifactType="EXE" projectCommon.importModeId="COPY" projectCommon.partId="mcu.8051.efm8.ub1.efm8ub10f16g-b-qfn28" projectCommon.sdkId="com.silabs.sdk.8051:4.1.1._-963069327"/>
|
||||
<storageModule moduleId="com.silabs.ss.framework.ide.project.core.cpp" project.generation="70" projectCommon.boardIds="brd5000a:0.0.0.A02" projectCommon.buildArtifactType="EXE" projectCommon.importModeId="COPY" projectCommon.partId="mcu.8051.efm8.ub1.efm8ub10f16g-b-qfn28" projectCommon.sdkId="com.silabs.sdk.8051:4.1.1._-963069327"/>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="efm8.com.silabs.ss.framework.ide.project.core.cdt.cdtMbsProjectType.972220390" name="SLS CDT Project" projectType="com.silabs.ss.framework.ide.project.core.cdt.cdtMbsProjectType"/>
|
||||
</storageModule>
|
||||
|
@@ -25,6 +25,7 @@
|
||||
<property object="P0.7" propertyId="ports.settings.outputmode" value="Push-pull"/>
|
||||
<property object="P1.1" propertyId="ports.settings.iomode" value="Digital Push-Pull Output"/>
|
||||
<property object="P1.1" propertyId="ports.settings.outputmode" value="Push-pull"/>
|
||||
<property object="P1.2" propertyId="ports.settings.latch" value="Low"/>
|
||||
<property object="P1.4" propertyId="ports.settings.iomode" value="Digital Push-Pull Output"/>
|
||||
<property object="P1.4" propertyId="ports.settings.outputmode" value="Push-pull"/>
|
||||
<property object="P1.5" propertyId="ports.settings.iomode" value="Digital Push-Pull Output"/>
|
||||
@@ -77,16 +78,27 @@
|
||||
<property object="USBLIB_0" propertyId="configuration.configurationparameters.devicepower" value="Bus-Powered"/>
|
||||
<property object="USBLIB_0" propertyId="device.deviceproperties.bmaxpacketsize" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="device.deviceproperties.productidpid" value="35535"/>
|
||||
<property object="USBLIB_0" propertyId="device.deviceproperties.productstring" value="EOS Wallet"/>
|
||||
<property object="USBLIB_0" propertyId="device.deviceproperties.productstring" value="EOS Bridge"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1in.bulkmaxpacketsizebytes" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1in.endpoint1in" value="Enabled"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1in.maxpacketsizebytes" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1in.pollingintervalms" value="5"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1in.transfertype" value="Interrupt"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1out.endpoint1out" value="Enabled"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1out.maxpacketsizebytes" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1out.pollingintervalms" value="5"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1out.transfertype" value="Interrupt"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint2in.bulkmaxpacketsizebytes" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint2in.maxpacketsizebytes" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint2in.pollingintervalms" value="5"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint2in.transfertype" value="Interrupt"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint2out.bulkmaxpacketsizebytes" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint2out.endpoint2out" value="Enabled"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint2out.maxpacketsizebytes" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint2out.pollingintervalms" value="5"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint2out.transfertype" value="Interrupt"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint3in.endpoint3in" value="Enabled"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint3in.maxpacketsizebytes" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint3in.pollingintervalms" value="5"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint3in.transfertype" value="Interrupt"/>
|
||||
<property object="USBLIB_0" propertyId="interfaces.interface0.interfaceclass" value="HID (Human Interface Device)"/>
|
||||
<property object="USBLIB_0" propertyId="library.callbackfunctions.resetcallback" value="Enabled"/>
|
||||
<property object="USBLIB_0" propertyId="library.callbackfunctions.selfpoweredcallback" value="Enabled"/>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#ifndef INC_APP_H_
|
||||
#define INC_APP_H_
|
||||
|
||||
//#define USE_PRINTING
|
||||
#define USE_PRINTING
|
||||
|
||||
void usb_transfer_complete();
|
||||
void spi_transfer_complete();
|
||||
|
@@ -53,11 +53,11 @@
|
||||
// Enable or disable each endpoint
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[Endpoints Used]
|
||||
#define SLAB_USB_EP1IN_USED 1
|
||||
#define SLAB_USB_EP1OUT_USED 1
|
||||
#define SLAB_USB_EP1IN_USED 0
|
||||
#define SLAB_USB_EP1OUT_USED 0
|
||||
#define SLAB_USB_EP2IN_USED 0
|
||||
#define SLAB_USB_EP2OUT_USED 0
|
||||
#define SLAB_USB_EP3IN_USED 0
|
||||
#define SLAB_USB_EP2OUT_USED 1
|
||||
#define SLAB_USB_EP3IN_USED 1
|
||||
#define SLAB_USB_EP3OUT_USED 0
|
||||
// [Endpoints Used]$
|
||||
|
||||
@@ -67,9 +67,9 @@
|
||||
// $[Endpoint Max Packet Size]
|
||||
#define SLAB_USB_EP1IN_MAX_PACKET_SIZE 64
|
||||
#define SLAB_USB_EP1OUT_MAX_PACKET_SIZE 64
|
||||
#define SLAB_USB_EP2IN_MAX_PACKET_SIZE 1
|
||||
#define SLAB_USB_EP2OUT_MAX_PACKET_SIZE 1
|
||||
#define SLAB_USB_EP3IN_MAX_PACKET_SIZE 1
|
||||
#define SLAB_USB_EP2IN_MAX_PACKET_SIZE 64
|
||||
#define SLAB_USB_EP2OUT_MAX_PACKET_SIZE 64
|
||||
#define SLAB_USB_EP3IN_MAX_PACKET_SIZE 64
|
||||
#define SLAB_USB_EP3OUT_MAX_PACKET_SIZE 1
|
||||
// [Endpoint Max Packet Size]$
|
||||
|
||||
@@ -79,9 +79,9 @@
|
||||
// $[Endpoint Transfer Type]
|
||||
#define SLAB_USB_EP1IN_TRANSFER_TYPE USB_EPTYPE_INTR
|
||||
#define SLAB_USB_EP1OUT_TRANSFER_TYPE USB_EPTYPE_INTR
|
||||
#define SLAB_USB_EP2IN_TRANSFER_TYPE USB_EPTYPE_BULK
|
||||
#define SLAB_USB_EP2OUT_TRANSFER_TYPE USB_EPTYPE_BULK
|
||||
#define SLAB_USB_EP3IN_TRANSFER_TYPE USB_EPTYPE_ISOC
|
||||
#define SLAB_USB_EP2IN_TRANSFER_TYPE USB_EPTYPE_INTR
|
||||
#define SLAB_USB_EP2OUT_TRANSFER_TYPE USB_EPTYPE_INTR
|
||||
#define SLAB_USB_EP3IN_TRANSFER_TYPE USB_EPTYPE_INTR
|
||||
#define SLAB_USB_EP3OUT_TRANSFER_TYPE USB_EPTYPE_ISOC
|
||||
// [Endpoint Transfer Type]$
|
||||
|
||||
|
@@ -407,6 +407,18 @@ extern void PORTS_0_enter_DefaultMode_from_RESET(void) {
|
||||
extern void PORTS_1_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[P1 - Port 1 Pin Latch]
|
||||
/***********************************************************************
|
||||
- P1.0 is high. Set P1.0 to drive or float high
|
||||
- P1.1 is high. Set P1.1 to drive or float high
|
||||
- P1.2 is low. Set P1.2 to drive low
|
||||
- P1.3 is high. Set P1.3 to drive or float high
|
||||
- P1.4 is high. Set P1.4 to drive or float high
|
||||
- P1.5 is high. Set P1.5 to drive or float high
|
||||
- P1.6 is high. Set P1.6 to drive or float high
|
||||
- P1.7 is high. Set P1.7 to drive or float high
|
||||
***********************************************************************/
|
||||
P1 = P1_B0__HIGH | P1_B1__HIGH | P1_B2__LOW | P1_B3__HIGH | P1_B4__HIGH
|
||||
| P1_B5__HIGH | P1_B6__HIGH | P1_B7__HIGH;
|
||||
// [P1 - Port 1 Pin Latch]$
|
||||
|
||||
// $[P1MDOUT - Port 1 Output Mode]
|
||||
|
@@ -147,10 +147,14 @@ uint16_t USBD_XferCompleteCb(uint8_t epAddr, USB_Status_TypeDef status,
|
||||
UNUSED(xferred);
|
||||
UNUSED(remaining);
|
||||
|
||||
if (epAddr == EP1OUT)
|
||||
if (epAddr == EP2OUT)
|
||||
{
|
||||
usb_transfer_complete();
|
||||
}
|
||||
else if (epAddr == EP3IN)
|
||||
{
|
||||
usb_writeback_complete();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -104,19 +104,19 @@ SI_SEGMENT_VARIABLE(configDesc[],
|
||||
sizeof( ReportDescriptor0 ),// wDescriptorLength(LSB)
|
||||
sizeof( ReportDescriptor0 )>>8,// wDescriptorLength(MSB)
|
||||
|
||||
//Endpoint 1 IN Descriptor
|
||||
//Endpoint 2 IN Descriptor
|
||||
USB_ENDPOINT_DESCSIZE,// bLength
|
||||
USB_ENDPOINT_DESCRIPTOR,// bDescriptorType
|
||||
0x81,// bEndpointAddress
|
||||
0x83,// bEndpointAddress
|
||||
USB_EPTYPE_INTR,// bAttrib
|
||||
HID_PACKET_SIZE,// wMaxPacketSize (LSB)
|
||||
0x00,// wMaxPacketSize (MSB)
|
||||
5,// bInterval
|
||||
|
||||
//Endpoint 1 OUT Descriptor
|
||||
//Endpoint 3 OUT Descriptor
|
||||
USB_ENDPOINT_DESCSIZE,// bLength
|
||||
USB_ENDPOINT_DESCRIPTOR,// bDescriptorType
|
||||
0x01,// bEndpointAddress
|
||||
0x02,// bEndpointAddress
|
||||
USB_EPTYPE_INTR,// bAttrib
|
||||
HID_PACKET_SIZE,// wMaxPacketSize (LSB)
|
||||
0x00,// wMaxPacketSize (MSB)
|
||||
|
107
efm8/src/main.c
107
efm8/src/main.c
@@ -4,7 +4,10 @@
|
||||
#include "uart_1.h"
|
||||
#include "printing.h"
|
||||
|
||||
#define BUFFER_SIZE 13
|
||||
#define BUFFER_SIZE 12
|
||||
|
||||
#define SIGNAL_WRITE_BSY() P1 = P1 & (~(1<<2)) // Set P1 low
|
||||
#define SIGNAL_WRITE_RDY() P1 = P1 | (1<<2) // Set P1 high
|
||||
|
||||
data uint8_t write_ptr = 0;
|
||||
data uint8_t read_ptr = 0;
|
||||
@@ -12,20 +15,28 @@ data uint8_t i_ptr = 0;
|
||||
data uint8_t count = 0;
|
||||
data uint8_t writebackbuf_count = 0;
|
||||
|
||||
uint8_t hidmsgbuf[64][BUFFER_SIZE];
|
||||
uint8_t hidmsgbuf[64*BUFFER_SIZE];
|
||||
//uint8_t debugR[64];
|
||||
//uint8_t debugRi;
|
||||
//uint8_t debugW[64];
|
||||
//uint8_t debugW2[64];
|
||||
//uint8_t debugWi;
|
||||
data uint8_t writebackbuf[64];
|
||||
|
||||
void usb_transfer_complete()
|
||||
{
|
||||
count++;
|
||||
// memmove(debugR, hidmsgbuf + write_ptr*64, 64);
|
||||
// debugRi = write_ptr;
|
||||
write_ptr++;
|
||||
|
||||
if (write_ptr == BUFFER_SIZE)
|
||||
{
|
||||
write_ptr = 0;
|
||||
}
|
||||
if (count == 1 && i_ptr == 0)
|
||||
{
|
||||
SPI0DAT = hidmsgbuf[read_ptr][i_ptr++];
|
||||
SPI0DAT = (hidmsgbuf+read_ptr*64)[i_ptr++];
|
||||
}
|
||||
|
||||
|
||||
@@ -34,27 +45,48 @@ void usb_transfer_complete()
|
||||
|
||||
}
|
||||
|
||||
uint16_t USB_TX_COUNT = 0;
|
||||
|
||||
void usb_writeback_complete()
|
||||
{
|
||||
if (USB_TX_COUNT >= 511/2)
|
||||
{
|
||||
USB_TX_COUNT -= 64;
|
||||
if (USB_TX_COUNT < 511)
|
||||
{
|
||||
SIGNAL_WRITE_RDY();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
USB_TX_COUNT -= 64;
|
||||
}
|
||||
}
|
||||
|
||||
void spi_transfer_complete()
|
||||
{
|
||||
count--;
|
||||
i_ptr = 0;
|
||||
SPI0FCN0 |= (1<<2); // Flush rx fifo buffer
|
||||
if (count)
|
||||
{
|
||||
SPI0DAT = hidmsgbuf[read_ptr][i_ptr++];
|
||||
}
|
||||
|
||||
// debugWi = read_ptr;
|
||||
|
||||
read_ptr++;
|
||||
|
||||
if (read_ptr == BUFFER_SIZE)
|
||||
{
|
||||
read_ptr = 0;
|
||||
}
|
||||
|
||||
if (count)
|
||||
{
|
||||
SPI0DAT = (hidmsgbuf+read_ptr*64)[i_ptr++];
|
||||
}
|
||||
// cprints("sent hid msg\r\n");
|
||||
}
|
||||
|
||||
data int overrun = 0;
|
||||
SI_INTERRUPT (SPI0_ISR, SPI0_IRQn)
|
||||
{
|
||||
data uint8_t byt;
|
||||
if (SPI0CN0_WCOL == 1)
|
||||
{
|
||||
// Write collision occurred
|
||||
@@ -65,14 +97,22 @@ SI_INTERRUPT (SPI0_ISR, SPI0_IRQn)
|
||||
{
|
||||
// Receive overrun occurred
|
||||
SPI0CN0_RXOVRN = 0;
|
||||
overrun = 1;
|
||||
// cprints("SPI0CN0_RXOVRN\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EFM32_RW_PIN)
|
||||
{
|
||||
if (writebackbuf_count < 64) writebackbuf[writebackbuf_count++] = SPI0DAT;
|
||||
else cprints("overflow\r\n");
|
||||
if (writebackbuf_count < 64)
|
||||
{
|
||||
writebackbuf[writebackbuf_count++] = SPI0DAT;
|
||||
SIGNAL_WRITE_BSY();
|
||||
}
|
||||
else
|
||||
{
|
||||
cprints("overflow\r\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -80,8 +120,12 @@ SI_INTERRUPT (SPI0_ISR, SPI0_IRQn)
|
||||
{
|
||||
if (i_ptr < 64)
|
||||
{
|
||||
SPI0DAT = hidmsgbuf[read_ptr][i_ptr++];
|
||||
|
||||
// debugW[i_ptr] = (hidmsgbuf+read_ptr*64)[i_ptr];
|
||||
// debugW2[i_ptr] = read_ptr;
|
||||
// if (i_ptr == 63)
|
||||
// debugW2[i_ptr] = 0xaa;
|
||||
SPI0DAT = (hidmsgbuf+read_ptr*64)[i_ptr++];
|
||||
byt = SPI0DAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -97,7 +141,8 @@ SI_INTERRUPT (SPI0_ISR, SPI0_IRQn)
|
||||
void usb_write()
|
||||
{
|
||||
data uint8_t errors = 0;
|
||||
while (USB_STATUS_OK != (USBD_Write(EP1IN, writebackbuf, 64, false)))
|
||||
USB_TX_COUNT += 64;
|
||||
while (USB_STATUS_OK != (USBD_Write(EP3IN, writebackbuf, 64, true)))
|
||||
{
|
||||
delay(2);
|
||||
if (errors++ > 30)
|
||||
@@ -131,6 +176,8 @@ int main(void) {
|
||||
IE_EA = 1;
|
||||
IE_ESPI0 = 1;
|
||||
|
||||
SIGNAL_WRITE_RDY();
|
||||
|
||||
cprints("hello,world\r\n");
|
||||
|
||||
reset = RSTSRC;
|
||||
@@ -138,21 +185,30 @@ int main(void) {
|
||||
|
||||
while (1) {
|
||||
// delay(1500);
|
||||
if (overrun)
|
||||
{
|
||||
cprints("O\r\n");
|
||||
overrun = 0;
|
||||
}
|
||||
if (millis() - t1 > 1500)
|
||||
{
|
||||
P1_B5 = k++&1;
|
||||
// if (k&1)
|
||||
// SIGNAL_WRITE_RDY();
|
||||
// else
|
||||
// SIGNAL_WRITE_BSY();
|
||||
t1 = millis();
|
||||
}
|
||||
if (!USBD_EpIsBusy(EP1OUT) && !USBD_EpIsBusy(EP1IN))
|
||||
if (!USBD_EpIsBusy(EP2OUT) && !USBD_EpIsBusy(EP3IN) && lastcount==count)
|
||||
{
|
||||
// cprintd("sched read to ",1,reset);
|
||||
// cprintd("sched read to ",1,(int)(hidmsgbuf + write_ptr*64));
|
||||
if (count == BUFFER_SIZE)
|
||||
{
|
||||
cprints("Warning, USB buffer full\r\n");
|
||||
// cprints("Warning, USB buffer full\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
USBD_Read(EP1OUT, hidmsgbuf[write_ptr], 64, true);
|
||||
USBD_Read(EP2OUT, hidmsgbuf + write_ptr*64, 64, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,26 +216,31 @@ int main(void) {
|
||||
{
|
||||
// cprints("<< ");
|
||||
// dump_hex(writebackbuf,64);
|
||||
writebackbuf_count = 0;
|
||||
// while (USBD_EpIsBusy(EP1IN))
|
||||
// ;
|
||||
usb_write();
|
||||
writebackbuf_count = 0;
|
||||
if (USB_TX_COUNT < 511/2)
|
||||
{
|
||||
SIGNAL_WRITE_RDY();
|
||||
}
|
||||
}
|
||||
|
||||
if (lastcount != count)
|
||||
{
|
||||
if (count > lastcount)
|
||||
{
|
||||
// cprints(">> ");
|
||||
// dump_hex(writebackbuf,64);
|
||||
// cputd(debugRi); cprints(">> ");
|
||||
// dump_hex(debugR,64);
|
||||
|
||||
MSG_RDY_INT_PIN = 0;
|
||||
MSG_RDY_INT_PIN = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// cprints("efm32 read hid msg\r\n>> ");
|
||||
// dump_hex(debug,64);
|
||||
// cputd(debugWi); cprints(">>>> ");
|
||||
// dump_hex(debugW,64);
|
||||
// dump_hex(debugW2,64);
|
||||
}
|
||||
lastcount = count;
|
||||
}
|
||||
|
@@ -42,6 +42,7 @@ void dump_hex(uint8_t* hex, uint8_t len)
|
||||
putf(lut[b]);
|
||||
b = ((*hex) & 0x0f);
|
||||
putf(lut[b]);
|
||||
putf(' ');
|
||||
hex++;
|
||||
}
|
||||
cprints("\r\n");
|
||||
|
Reference in New Issue
Block a user