summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcpldcpu <cpldcpu@gmail.com>2015-07-27 09:05:57 +0200
committercpldcpu <cpldcpu@gmail.com>2015-07-27 09:05:57 +0200
commit584f66ac8a88a554aae426b7112dd3254a08924e (patch)
tree60440d80142ece0b0eeb9af8eef4afd1c5e29d22
parent04b6fae106784ac4a63b2afc572a1357f4a7c2df (diff)
downloadmicronucleus-584f66ac8a88a554aae426b7112dd3254a08924e.tar.gz
micronucleus-584f66ac8a88a554aae426b7112dd3254a08924e.tar.bz2
micronucleus-584f66ac8a88a554aae426b7112dd3254a08924e.zip
firmware: Release D- before starting user program
-rw-r--r--Readme.txt16
-rw-r--r--firmware/main.c9
2 files changed, 15 insertions, 10 deletions
diff --git a/Readme.txt b/Readme.txt
index a6e6341..c4de75a 100644
--- a/Readme.txt
+++ b/Readme.txt
@@ -42,12 +42,12 @@ To allow maximum flexibility, micronucleus supports a configuration system. To c
Currently, the following configurations are included and tested. Please check the subfolders /firmware/configurations/ for details. Hex files can be found in /releases.
-t84_default - ATtiny84A default configuration - 1556 bytes
-t841_default - ATtiny841 default configuration - 1608 bytes
-t85_default - ATtiny85 default configuration - 1610 bytes
-t85_aggressive - ATtiny85 smaller size - critical - 1418 bytes
-t167_default - ATtiny167 default (uses xtal) - 1414 bytes
-Nanite841 - Nanite841 firmware - 1632 bytes
+t84_default - ATtiny84A default configuration - 1560 bytes
+t841_default - ATtiny841 default configuration - 1612 bytes
+t85_default - ATtiny85 default configuration - 1614 bytes
+t85_aggressive - ATtiny85 smaller size - critical - 1422 bytes
+t167_default - ATtiny167 default (uses xtal) - 1418 bytes
+Nanite841 - Nanite841 firmware - 1634 bytes
You can add your own configuration by adding a new folder to /firmware/configurations/. The folder has to contain a customized "Makefile.inc" and "bootloaderconfig.h". Feel free to supply a pull request if you added and tested a previously unsupported device.
@@ -102,6 +102,10 @@ Changes
connected to a USB3.0 port.
- Fixes one bug that could lead to a deadlock if no USB was connected
while the bootloader was active and noise was injected into the floating D+ input.
+ - D- line is released before the user program is started, instead of pulling it down.
+ This solves various issues where Micronucleus was not recognized after a reset.
+ Att: This may lead to a "Unknown device" pop-up in Windows, if the user program does
+ not have USB functionality itself.
Credits
=======
diff --git a/firmware/main.c b/firmware/main.c
index 80b5d3a..ddd03e3 100644
--- a/firmware/main.c
+++ b/firmware/main.c
@@ -266,7 +266,7 @@ int main(void) {
// adjust fastctr for 5ms timeout
uint16_t fastctr=(uint16_t)(F_CPU/(1000.0f*15.0f/5.0f));
- uint8_t resetctr=100;
+ uint8_t resetctr=100;
do {
if ((USBIN & USBMASK) !=0) resetctr=100;
@@ -303,8 +303,6 @@ int main(void) {
OSCCAL = osccal_tmp;
#endif
-
-
if (command==cmd_exit) {
if (!fastctr) break; // Only exit after 5 ms timeout
} else {
@@ -315,10 +313,12 @@ int main(void) {
// This is usbpoll() minus reset logic and double buffering
int8_t len;
len = usbRxLen - 3;
+
if(len >= 0){
usbProcessRx(usbRxBuf + 1, len); // only single buffer due to in-order processing
usbRxLen = 0; /* mark rx buffer as available */
}
+
if(usbTxLen & 0x10){ /* transmit system idle */
if(usbMsgLen != USB_NO_MSG){ /* transmit data pending? */
usbBuildTxBlock();
@@ -359,7 +359,8 @@ int main(void) {
LED_EXIT();
- usbDeviceDisconnect(); /* Disconnect micronucleus */
+ initHardware(); /* Disconnect micronucleus */
+
USB_INTR_ENABLE = 0;
USB_INTR_CFG = 0; /* also reset config bits */