summaryrefslogtreecommitdiffstats
path: root/firmware/main.c
diff options
context:
space:
mode:
authorcpldcpu <cpldcpu@gmail.com>2013-12-15 07:38:36 +0100
committercpldcpu <cpldcpu@gmail.com>2013-12-15 07:38:36 +0100
commit04a03561056846825aec4b4df4f91a5d6f4b009e (patch)
treea15315bb7e934a30bfa5ae44dde1f73842f9385a /firmware/main.c
parent57fba9c8fa6db91224f4d20ee0b3f5219bd00cd6 (diff)
downloadmicronucleus-04a03561056846825aec4b4df4f91a5d6f4b009e.tar.gz
micronucleus-04a03561056846825aec4b4df4f91a5d6f4b009e.tar.bz2
micronucleus-04a03561056846825aec4b4df4f91a5d6f4b009e.zip
more cleaning up
Diffstat (limited to 'firmware/main.c')
-rw-r--r--firmware/main.c37
1 files changed, 8 insertions, 29 deletions
diff --git a/firmware/main.c b/firmware/main.c
index 760eaa2..8a3a0b0 100644
--- a/firmware/main.c
+++ b/firmware/main.c
@@ -30,28 +30,6 @@ static void leaveBootloader() __attribute__((__noreturn__));
#include "usbdrv/usbdrv.c"
/* ------------------------------------------------------------------------ */
-
-#ifndef ulong
-# define ulong unsigned long
-#endif
-#ifndef uint
-# define uint unsigned int
-#endif
-
-#ifndef BOOTLOADER_CAN_EXIT
-# define BOOTLOADER_CAN_EXIT 0
-#endif
-
-/* allow compatibility with avrusbboot's bootloaderconfig.h: */
-#ifdef BOOTLOADER_INIT
-# define bootLoaderInit() BOOTLOADER_INIT
-# define bootLoaderExit()
-#endif
-#ifdef BOOTLOADER_CONDITION
-# define bootLoaderCondition() BOOTLOADER_CONDITION
-#endif
-
-/* ------------------------------------------------------------------------ */
// postscript are the few bytes at the end of programmable memory which store tinyVectors
// and used to in USBaspLoader-tiny85 store the checksum iirc
#define POSTSCRIPT_SIZE 6
@@ -120,7 +98,7 @@ static inline void eraseApplication(void) {
}
currentAddress = 0;
- for (i=0; i<16; i++) writeWordToPageBuffer(0xFFFF); // Write first 16 words to fill in vectors.
+ for (i=0; i<8; i++) writeWordToPageBuffer(0xFFFF); // Write first 8 words to fill in vectors.
writeFlashPage(); // enables interrupts
}
@@ -193,8 +171,8 @@ static uchar usbFunctionSetup(uchar data[8]) {
((uint8_t*)&idlePolls)[1] = 0; // reset idle polls when we get usb traffic
static uchar replyBuffer[4] = {
- (((uint)PROGMEM_SIZE) >> 8) & 0xff,
- ((uint)PROGMEM_SIZE) & 0xff,
+ (((uint16_t)PROGMEM_SIZE) >> 8) & 0xff,
+ ((uint16_t)PROGMEM_SIZE) & 0xff,
SPM_PAGESIZE,
MICRONUCLEUS_WRITE_SLEEP
};
@@ -291,10 +269,7 @@ int main(void) {
#if (!SET_CLOCK_PRESCALER) && LOW_POWER_MODE
uint8_t prescaler_default = CLKPR;
#endif
-
- MCUSR=0; /* need this to properly disable watchdog */
- wdt_disable();
-
+
bootLoaderInit();
# if AUTO_EXIT_NO_USB_MS
@@ -302,6 +277,10 @@ int main(void) {
# endif
if (bootLoaderStartCondition()) {
+
+ MCUSR=0; /* need this to properly disable watchdog */
+ wdt_disable();
+
#if LOW_POWER_MODE
// turn off clock prescalling - chip must run at full speed for usb
// if you might run chip at lower voltages, detect that in bootLoaderStartCondition