aboutsummaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'libraries')
-rw-r--r--libraries/HID/HID.cpp6
-rw-r--r--libraries/HID/HID.h6
-rw-r--r--libraries/Wire/Wire.cpp5
-rw-r--r--libraries/Wire/Wire.h4
-rw-r--r--libraries/Wire/utility/twi.c18
-rw-r--r--libraries/Wire/utility/twi.h1
6 files changed, 32 insertions, 8 deletions
diff --git a/libraries/HID/HID.cpp b/libraries/HID/HID.cpp
index 0d2133e..c629eb9 100644
--- a/libraries/HID/HID.cpp
+++ b/libraries/HID/HID.cpp
@@ -43,7 +43,7 @@ static u8 HID_INTERFACE;
HIDDescriptor _hidInterface;
static HIDDescriptorListNode* rootNode = NULL;
-static uint8_t sizeof_hidReportDescriptor = 0;
+static uint16_t sizeof_hidReportDescriptor = 0;
static uint8_t modules_count = 0;
//================================================================================
//================================================================================
@@ -59,7 +59,7 @@ int HID_GetInterface(u8* interfaceNum)
{
D_INTERFACE(HID_INTERFACE,1,3,0,0),
D_HIDREPORT(sizeof_hidReportDescriptor),
- D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
+ D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,USB_EP_SIZE,0x01)
};
return USB_SendControl(0,&_hidInterface,sizeof(_hidInterface));
}
@@ -91,7 +91,7 @@ void HID_::AppendDescriptor(HIDDescriptorListNode *node)
current->next = node;
}
modules_count++;
- sizeof_hidReportDescriptor += node->cb->length;
+ sizeof_hidReportDescriptor += (uint16_t)node->cb->length;
}
void HID_::SendReport(u8 id, const void* data, int len)
diff --git a/libraries/HID/HID.h b/libraries/HID/HID.h
index 89832a9..b9f29b4 100644
--- a/libraries/HID/HID.h
+++ b/libraries/HID/HID.h
@@ -45,7 +45,7 @@
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23
typedef struct __attribute__((packed)) {
- u8 length;
+ uint16_t length;
const void* descriptor;
} HID_Descriptor;
@@ -88,10 +88,10 @@ typedef struct
#define HID_TX HID_ENDPOINT_INT
#define D_HIDREPORT(_descriptorLength) \
- { 9, 0x21, 0x1, 0x1, 0, 1, 0x22, _descriptorLength, 0 }
+ { 9, 0x21, 0x1, 0x1, 0, 1, 0x22, _descriptorLength & 0xFF, _descriptorLength >> 8 }
#define WEAK __attribute__ ((weak))
#endif
-#endif \ No newline at end of file
+#endif
diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp
index 835b794..2bd48ed 100644
--- a/libraries/Wire/Wire.cpp
+++ b/libraries/Wire/Wire.cpp
@@ -75,6 +75,11 @@ void TwoWire::begin(int address)
begin((uint8_t)address);
}
+void TwoWire::end(void)
+{
+ twi_disable();
+}
+
void TwoWire::setClock(uint32_t frequency)
{
TWBR = ((F_CPU / frequency) - 16) / 2;
diff --git a/libraries/Wire/Wire.h b/libraries/Wire/Wire.h
index 7d00959..702f37d 100644
--- a/libraries/Wire/Wire.h
+++ b/libraries/Wire/Wire.h
@@ -27,6 +27,9 @@
#define BUFFER_LENGTH 32
+// WIRE_HAS_END means Wire has end()
+#define WIRE_HAS_END 1
+
class TwoWire : public Stream
{
private:
@@ -49,6 +52,7 @@ class TwoWire : public Stream
void begin();
void begin(uint8_t);
void begin(int);
+ void end();
void setClock(uint32_t);
void beginTransmission(uint8_t);
void beginTransmission(int);
diff --git a/libraries/Wire/utility/twi.c b/libraries/Wire/utility/twi.c
index 201d7d1..b436e69 100644
--- a/libraries/Wire/utility/twi.c
+++ b/libraries/Wire/utility/twi.c
@@ -91,6 +91,22 @@ void twi_init(void)
}
/*
+ * Function twi_disable
+ * Desc disables twi pins
+ * Input none
+ * Output none
+ */
+void twi_disable(void)
+{
+ // disable twi module, acks, and twi interrupt
+ TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
+
+ // deactivate internal pullups for twi.
+ digitalWrite(SDA, 0);
+ digitalWrite(SCL, 0);
+}
+
+/*
* Function twi_slaveInit
* Desc sets slave address and enables interrupt
* Input none
@@ -464,8 +480,6 @@ ISR(TWI_vect)
if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
twi_rxBuffer[twi_rxBufferIndex] = '\0';
}
- // sends ack and stops interface for clock stretching
- twi_stop();
// callback to user defined callback
twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
// since we submit rx buffer to "wire" library, we can reset it
diff --git a/libraries/Wire/utility/twi.h b/libraries/Wire/utility/twi.h
index 6526593..4c52bc5 100644
--- a/libraries/Wire/utility/twi.h
+++ b/libraries/Wire/utility/twi.h
@@ -39,6 +39,7 @@
#define TWI_STX 4
void twi_init(void);
+ void twi_disable(void);
void twi_setAddress(uint8_t);
uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t);
uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t);