diff --git a/bootloader/clubdance_v2_bootloader.X/nbproject/configurations.xml b/bootloader/clubdance_v2_bootloader.X/nbproject/configurations.xml index ea65c32..114dc98 100644 --- a/bootloader/clubdance_v2_bootloader.X/nbproject/configurations.xml +++ b/bootloader/clubdance_v2_bootloader.X/nbproject/configurations.xml @@ -26,7 +26,6 @@ projectFiles="true"> ../src/usb_config.h ../src/bootloader.h - ../src/typedefs.h - + @@ -105,14 +104,14 @@ - + - + @@ -138,13 +137,13 @@ - + - - - - + + + + diff --git a/bootloader/src/bootloader.c b/bootloader/src/bootloader.c index 58cd024..b4c6b14 100644 --- a/bootloader/src/bootloader.c +++ b/bootloader/src/bootloader.c @@ -1,5 +1,5 @@ #include "bootloader.h" -#include "typedefs.h" +#include #include "usb.h" #include "usb_device_hid.h" @@ -143,8 +143,8 @@ typedef union }; } PacketToFromPC; -PacketToFromPC PacketFromPC; -PacketToFromPC PacketToPC; +PacketToFromPC PacketFromPC __at(0x500); +PacketToFromPC PacketToPC __at(0x550); unsigned char ProgrammingBuffer[ERASE_PAGE_SIZE]; unsigned char BootState; unsigned int ErasePageTracker; @@ -170,7 +170,10 @@ void UserInit(void) BootState = IDLE; ProgrammedPointer = INVALID_ADDRESS; BufferedDataIndex = 0; - ConfigsLockValue = TRUE; + ConfigsLockValue = 1; + + USBEnableEndpoint(HID_EP, USB_IN_ENABLED|USB_OUT_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP); + rxHandle = HIDRxPacket(HID_EP, (char *)&PacketFromPC, USB_PACKET_SIZE); } /****************************************************************************** @@ -193,7 +196,7 @@ void UserInit(void) void ProcessIO(void) { static unsigned char i; - static ROM uint8_t* pROM; + static const uint8_t* pROM; //Checks for and processes application related USB packets (assuming the //USB bus is in the CONFIGURED_STATE, which is the only state where @@ -216,7 +219,7 @@ void ProcessIO(void) { //We received a new command from the host. Copy the OUT packet from //the host into a local buffer for processing. - rxHandle = HIDRxPacket(HID_IN_EP, (char *)&PacketFromPC, USB_PACKET_SIZE); //Also re-arms the OUT endpoint to be able to receive the next packet + rxHandle = HIDRxPacket(HID_EP, (char *)&PacketFromPC, USB_PACKET_SIZE); //Also re-arms the OUT endpoint to be able to receive the next packet //HIDRxReport((char *)&PacketFromPC, USB_PACKET_SIZE); //Also re-arms the OUT endpoint to be able to receive the next packet BootState = NOT_IDLE; //Set flag letting state machine know it has a command that needs processing. @@ -260,15 +263,15 @@ void ProcessIO(void) //Init pad bytes to 0x00... Already done after we received the QUERY_DEVICE command (just after calling HIDRxReport()). //Now send the packet to the USB host software, assuming the USB endpoint is available/ready to accept new data. - txHandle = HIDTxPacket(HID_OUT_EP, (char *)&PacketToPC, USB_PACKET_SIZE); + txHandle = HIDTxPacket(HID_EP, (char *)&PacketToPC, USB_PACKET_SIZE); BootState = IDLE; } break; case UNLOCK_CONFIG: - ConfigsLockValue = TRUE; + ConfigsLockValue = 1; if(PacketFromPC.LockValue == UNLOCKCONFIG) { - ConfigsLockValue = FALSE; + ConfigsLockValue = 0; } BootState = IDLE; break; @@ -315,7 +318,7 @@ void ProcessIO(void) //Check if host is trying to program the config bits if(PacketFromPC.Contents[3] == 0x30) // //PacketFromPC.Contents[3] is bits 23:16 of the address. { //0x30 implies config bits - if(ConfigsLockValue == FALSE) + if(ConfigsLockValue == 0) { WriteConfigBits(); //Doesn't get reprogrammed if the UNLOCK_CONFIG (LockValue = UNLOCKCONFIG) command hasn't previously been sent } @@ -365,7 +368,7 @@ void ProcessIO(void) PacketToPC.Address = PacketFromPC.Address; PacketToPC.Size = PacketFromPC.Size; - pROM = (ROM uint8_t*)PacketFromPC.Address; + pROM = (const uint8_t*)PacketFromPC.Address; for(i = 0; i < PacketFromPC.Size; i++) { if(PacketFromPC.Contents[3] == 0xF0) //PacketFromPC.Contents[3] is bits 23:16 of the address. @@ -403,7 +406,7 @@ void ProcessIO(void) //in this firmware and is available for requesting by the host software. PacketToPC.Command = QUERY_EXTENDED_INFO; //Echo the command byte PacketToPC.BootloaderVersion = ((unsigned int)BOOTLOADER_VERSION_MAJOR << 8)| BOOTLOADER_VERSION_MINOR; - PacketToPC.ApplicationVersion = *(ROM unsigned int*)APP_VERSION_ADDRESS; + PacketToPC.ApplicationVersion = *(const unsigned int*)APP_VERSION_ADDRESS; PacketToPC.SignatureAddress = APP_SIGNATURE_ADDRESS; PacketToPC.SignatureValue = APP_SIGNATURE_VALUE; PacketToPC.ErasePageSize = ERASE_PAGE_SIZE; @@ -451,11 +454,11 @@ void ProcessIO(void) void SignFlash(void) { static unsigned char i; - static ROM uint8_t* pROM; + static const uint8_t* pROM; //First read in the erase page contents of the page with the signature WORD //in it, and temporarily store it in a RAM buffer. - pROM = (ROM uint8_t*)(APP_SIGNATURE_ADDRESS & ERASE_PAGE_ADDRESS_MASK); + pROM = (const uint8_t*)(APP_SIGNATURE_ADDRESS & ERASE_PAGE_ADDRESS_MASK); for(i = 0; i < ERASE_PAGE_SIZE; i++) { ProgrammingBuffer[i] = *pROM++; @@ -480,7 +483,7 @@ void SignFlash(void) //programmed (assuming the flash signature resides on the lowest address //write page, which is recommended, so that it becomes the first page //erased, and the last page programmed). - pROM = (ROM uint8_t*)((APP_SIGNATURE_ADDRESS & ERASE_PAGE_ADDRESS_MASK) + ERASE_PAGE_SIZE - 1); //Point to last byte on the erase page + pROM = (const uint8_t*)((APP_SIGNATURE_ADDRESS & ERASE_PAGE_ADDRESS_MASK) + ERASE_PAGE_SIZE - 1); //Point to last byte on the erase page //TBLPTR = (APP_SIGNATURE_ADDRESS & ERASE_PAGE_ADDRESS_MASK) + ERASE_PAGE_SIZE - 1; //Point to last byte on the erase page i = ERASE_PAGE_SIZE - 1; while(1) @@ -527,7 +530,16 @@ void SignFlash(void) } i--; } -} +} + + +void FugDisXD(unsigned int delay) +{ + while (delay) + { + delay--; + } +} //Before resetting the microcontroller, we should shut down the USB module @@ -541,7 +553,10 @@ void SignFlash(void) //a new attachment event. void ResetDeviceCleanly(void) { - //USBDisableWithLongDelay(); + // detach USB peripheral & delay + USBSoftDetach(); + FugDisXD(0xFFFF); + // reset the microcontroller Reset(); Nop(); Nop(); @@ -558,16 +573,12 @@ void WriteFlashBlock(void) //Use to write blocks of data to flash. static unsigned char BytesTakenFromBuffer; static unsigned char CorrectionFactor; - #ifdef __XC8__ - static ROM uint8_t* pROM; + static const uint8_t* pROM; - pROM = (ROM uint8_t*)(ProgrammedPointer - BufferedDataIndex); - TBLPTRU = 0x00; - TBLPTRH = (uint8_t)((uint16_t)pROM >> 8); - TBLPTRL = (uint8_t)pROM; - #else - TBLPTR = (ProgrammedPointer - BufferedDataIndex); - #endif + pROM = (const uint8_t*)((uint8_t)ProgrammedPointer - BufferedDataIndex); + TBLPTRU = 0x00; + TBLPTRH = (uint8_t)((uint16_t)pROM >> 8); + TBLPTRL = (uint8_t)pROM; BytesTakenFromBuffer = 0; @@ -763,7 +774,18 @@ void UnlockAndActivate(unsigned char UnlockKey) while(EECON1bits.WR); //Wait until complete (relevant when programming EEPROM, not important when programming flash since processor stalls during flash program) EECON1bits.WREN = 0; //Good practice now to clear the WREN bit, as further protection against any accidental activation of self write/erase operations. -} +} + +//Helper function to reduce code size when built with C18. The ClrWdt() is an +//inline assembly macro, and on the C18 compiler, if you execute an inline asm +//instruction in a C function, it prevents the compiler from implementing +//optimizations to that particular function (since the compiler doesn't know what +//the user did in the inline asm). Therefore, inline asm is more efficient if +//implemented outside of large C functions, when using C18. +void ClearWatchdog(void) +{ + ClrWdt(); +} //Note: The ClrWdt() and "_asm tblrdpostinc _endasm" are inline assembly language diff --git a/bootloader/src/bootloader.h b/bootloader/src/bootloader.h index 2ffab5b..31419b1 100644 --- a/bootloader/src/bootloader.h +++ b/bootloader/src/bootloader.h @@ -34,14 +34,14 @@ void DisableUSBandExecuteLongDelay(void); //Vector remapping/absolute address constants -#define REMAPPED_APPLICATION_RESET_VECTOR 0x1400 -//#define REMAPPED_APPLICATION_HIGH_ISR_VECTOR 0x1408 //See VectorRemap.asm -//#define REMAPPED_APPLICATION_LOW_ISR_VECTOR 0x1418 //See VectorRemap.asm +#define REMAPPED_APPLICATION_RESET_VECTOR 0x1C00 +//#define REMAPPED_APPLICATION_HIGH_ISR_VECTOR 0x1C08 //See VectorRemap.asm +//#define REMAPPED_APPLICATION_LOW_ISR_VECTOR 0x1C18 //See VectorRemap.asm #define BOOTLOADER_ABSOLUTE_ENTRY_ADDRESS 0x001C //Execute a "goto 0x001C" inline assembly instruction, if you want to enter the bootloader mode from the application via software -#define APP_SIGNATURE_ADDRESS 0x1406 //0x1006 and 0x1007 contains the "signature" WORD, indicating successful erase/program/verify operation +#define APP_SIGNATURE_ADDRESS 0x1C06 //0x1C06 and 0x1C07 contains the "signature" WORD, indicating successful erase/program/verify operation #define APP_SIGNATURE_VALUE 0x600D //leet "GOOD", implying that the erase/program was a success and the bootloader intentionally programmed the APP_SIGNATURE_ADDRESS with this value -#define APP_VERSION_ADDRESS 0x1416 //0x1016 and 0x1017 should contain the application image firmware version number +#define APP_VERSION_ADDRESS 0x1C16 //0x1C16 and 0x1C17 should contain the application image firmware version number #endif /* BOOTLOADER_ */ diff --git a/bootloader/src/main.c b/bootloader/src/main.c index ce431db..655e914 100644 --- a/bootloader/src/main.c +++ b/bootloader/src/main.c @@ -10,7 +10,7 @@ #include "bootloader.h" void main(void) { - UserInit(); + //UserInit(); // initialize the USB framework USBDeviceInit(); diff --git a/bootloader/src/typedefs.h b/bootloader/src/typedefs.h deleted file mode 100644 index 655682c..0000000 --- a/bootloader/src/typedefs.h +++ /dev/null @@ -1,426 +0,0 @@ -/******************************************************************************* -Copyright 2016 Microchip Technology Inc. (www.microchip.com) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -To request to license the code under the MLA license (www.microchip.com/mla_license), -please contact mla_licensing@microchip.com -*******************************************************************************/ - -#ifndef __CUSTOMIZED_TYPE_DEFS_H_ -#define __CUSTOMIZED_TYPE_DEFS_H_ - -#include -#define ROM const -#define rom -#include -#include -#ifndef Nop() -#define Nop() {asm("NOP");} -#endif -#ifndef ClrWdt() -#define ClrWdt() {asm("CLRWDT");} -#endif -#ifndef Reset() -#define Reset() {asm("RESET");} -#endif -#ifndef Sleep() -#define Sleep() {asm("SLEEP");} -#endif - -#define __EXTENSION - -#if !defined(__PACKED) - #define __PACKED -#endif - -/* get compiler defined type definitions (NULL, size_t, etc) */ -#include -#include -#include -#include - -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - -#define PUBLIC /* Function attributes */ -#define PROTECTED -#define PRIVATE static - -/* INT is processor specific in length may vary in size */ -typedef signed int INT; -typedef signed char INT8; -typedef signed short int INT16; -typedef signed long int INT32; - -/* UINT is processor specific in length may vary in size */ -typedef unsigned int UINT; -typedef unsigned char UINT8; -typedef unsigned short int UINT16; -typedef unsigned long int UINT32; /* other name for 32-bit integer */ - - -typedef union -{ - UINT8 Val; - struct - { - __EXTENSION UINT8 b0:1; - __EXTENSION UINT8 b1:1; - __EXTENSION UINT8 b2:1; - __EXTENSION UINT8 b3:1; - __EXTENSION UINT8 b4:1; - __EXTENSION UINT8 b5:1; - __EXTENSION UINT8 b6:1; - __EXTENSION UINT8 b7:1; - } bits; -} UINT8_VAL, UINT8_BITS; - -typedef union -{ - UINT16 Val; - UINT8 v[2] __PACKED; - struct __PACKED - { - UINT8 LB; - UINT8 HB; - } byte; - struct __PACKED - { - __EXTENSION UINT8 b0:1; - __EXTENSION UINT8 b1:1; - __EXTENSION UINT8 b2:1; - __EXTENSION UINT8 b3:1; - __EXTENSION UINT8 b4:1; - __EXTENSION UINT8 b5:1; - __EXTENSION UINT8 b6:1; - __EXTENSION UINT8 b7:1; - __EXTENSION UINT8 b8:1; - __EXTENSION UINT8 b9:1; - __EXTENSION UINT8 b10:1; - __EXTENSION UINT8 b11:1; - __EXTENSION UINT8 b12:1; - __EXTENSION UINT8 b13:1; - __EXTENSION UINT8 b14:1; - __EXTENSION UINT8 b15:1; - } bits; -} UINT16_VAL, UINT16_BITS; - -typedef union -{ - UINT32 Val; - UINT16 w[2] __PACKED; - UINT8 v[4] __PACKED; - struct __PACKED - { - UINT16 LW; - UINT16 HW; - } word; - struct __PACKED - { - UINT8 LB; - UINT8 HB; - UINT8 UB; - UINT8 MB; - } byte; - struct __PACKED - { - UINT16_VAL low; - UINT16_VAL high; - }wordUnion; - struct __PACKED - { - __EXTENSION UINT8 b0:1; - __EXTENSION UINT8 b1:1; - __EXTENSION UINT8 b2:1; - __EXTENSION UINT8 b3:1; - __EXTENSION UINT8 b4:1; - __EXTENSION UINT8 b5:1; - __EXTENSION UINT8 b6:1; - __EXTENSION UINT8 b7:1; - __EXTENSION UINT8 b8:1; - __EXTENSION UINT8 b9:1; - __EXTENSION UINT8 b10:1; - __EXTENSION UINT8 b11:1; - __EXTENSION UINT8 b12:1; - __EXTENSION UINT8 b13:1; - __EXTENSION UINT8 b14:1; - __EXTENSION UINT8 b15:1; - __EXTENSION UINT8 b16:1; - __EXTENSION UINT8 b17:1; - __EXTENSION UINT8 b18:1; - __EXTENSION UINT8 b19:1; - __EXTENSION UINT8 b20:1; - __EXTENSION UINT8 b21:1; - __EXTENSION UINT8 b22:1; - __EXTENSION UINT8 b23:1; - __EXTENSION UINT8 b24:1; - __EXTENSION UINT8 b25:1; - __EXTENSION UINT8 b26:1; - __EXTENSION UINT8 b27:1; - __EXTENSION UINT8 b28:1; - __EXTENSION UINT8 b29:1; - __EXTENSION UINT8 b30:1; - __EXTENSION UINT8 b31:1; - } bits; -} UINT32_VAL; - -/***********************************************************************************/ - -/* Alternate definitions */ -typedef void VOID; - -typedef char CHAR8; -typedef unsigned char UCHAR8; - -typedef unsigned char BYTE; /* 8-bit unsigned */ -typedef unsigned short int WORD; /* 16-bit unsigned */ -typedef unsigned long DWORD; /* 32-bit unsigned */ -//typedef unsigned long long QWORD; /* 64-bit unsigned */ -typedef signed char CHAR; /* 8-bit signed */ -typedef signed short int SHORT; /* 16-bit signed */ -typedef signed long LONG; /* 32-bit signed */ -//typedef signed long long LONGLONG; /* 64-bit signed */ -typedef union -{ - BYTE Val; - struct __PACKED - { - __EXTENSION BYTE b0:1; - __EXTENSION BYTE b1:1; - __EXTENSION BYTE b2:1; - __EXTENSION BYTE b3:1; - __EXTENSION BYTE b4:1; - __EXTENSION BYTE b5:1; - __EXTENSION BYTE b6:1; - __EXTENSION BYTE b7:1; - } bits; -} BYTE_VAL, BYTE_BITS; - -typedef union -{ - WORD Val; - BYTE v[2] __PACKED; - struct __PACKED - { - BYTE LB; - BYTE HB; - } byte; - struct __PACKED - { - __EXTENSION BYTE b0:1; - __EXTENSION BYTE b1:1; - __EXTENSION BYTE b2:1; - __EXTENSION BYTE b3:1; - __EXTENSION BYTE b4:1; - __EXTENSION BYTE b5:1; - __EXTENSION BYTE b6:1; - __EXTENSION BYTE b7:1; - __EXTENSION BYTE b8:1; - __EXTENSION BYTE b9:1; - __EXTENSION BYTE b10:1; - __EXTENSION BYTE b11:1; - __EXTENSION BYTE b12:1; - __EXTENSION BYTE b13:1; - __EXTENSION BYTE b14:1; - __EXTENSION BYTE b15:1; - } bits; -} WORD_VAL, WORD_BITS; - -typedef union -{ - DWORD Val; - WORD w[2] __PACKED; - BYTE v[4] __PACKED; - struct __PACKED - { - WORD LW; - WORD HW; - } word; - struct __PACKED - { - BYTE LB; - BYTE HB; - BYTE UB; - BYTE MB; - } byte; - struct __PACKED - { - WORD_VAL low; - WORD_VAL high; - }wordUnion; - struct __PACKED - { - __EXTENSION BYTE b0:1; - __EXTENSION BYTE b1:1; - __EXTENSION BYTE b2:1; - __EXTENSION BYTE b3:1; - __EXTENSION BYTE b4:1; - __EXTENSION BYTE b5:1; - __EXTENSION BYTE b6:1; - __EXTENSION BYTE b7:1; - __EXTENSION BYTE b8:1; - __EXTENSION BYTE b9:1; - __EXTENSION BYTE b10:1; - __EXTENSION BYTE b11:1; - __EXTENSION BYTE b12:1; - __EXTENSION BYTE b13:1; - __EXTENSION BYTE b14:1; - __EXTENSION BYTE b15:1; - __EXTENSION BYTE b16:1; - __EXTENSION BYTE b17:1; - __EXTENSION BYTE b18:1; - __EXTENSION BYTE b19:1; - __EXTENSION BYTE b20:1; - __EXTENSION BYTE b21:1; - __EXTENSION BYTE b22:1; - __EXTENSION BYTE b23:1; - __EXTENSION BYTE b24:1; - __EXTENSION BYTE b25:1; - __EXTENSION BYTE b26:1; - __EXTENSION BYTE b27:1; - __EXTENSION BYTE b28:1; - __EXTENSION BYTE b29:1; - __EXTENSION BYTE b30:1; - __EXTENSION BYTE b31:1; - } bits; -} DWORD_VAL; - -/* MPLAB C Compiler for PIC18 does not support 64-bit integers */ -/*typedef union -{ - QWORD Val; - DWORD d[2] __PACKED; - WORD w[4] __PACKED; - BYTE v[8] __PACKED; - struct __PACKED - { - DWORD LD; - DWORD HD; - } dword; - struct __PACKED - { - WORD LW; - WORD HW; - WORD UW; - WORD MW; - } word; - struct __PACKED - { - __EXTENSION BYTE b0:1; - __EXTENSION BYTE b1:1; - __EXTENSION BYTE b2:1; - __EXTENSION BYTE b3:1; - __EXTENSION BYTE b4:1; - __EXTENSION BYTE b5:1; - __EXTENSION BYTE b6:1; - __EXTENSION BYTE b7:1; - __EXTENSION BYTE b8:1; - __EXTENSION BYTE b9:1; - __EXTENSION BYTE b10:1; - __EXTENSION BYTE b11:1; - __EXTENSION BYTE b12:1; - __EXTENSION BYTE b13:1; - __EXTENSION BYTE b14:1; - __EXTENSION BYTE b15:1; - __EXTENSION BYTE b16:1; - __EXTENSION BYTE b17:1; - __EXTENSION BYTE b18:1; - __EXTENSION BYTE b19:1; - __EXTENSION BYTE b20:1; - __EXTENSION BYTE b21:1; - __EXTENSION BYTE b22:1; - __EXTENSION BYTE b23:1; - __EXTENSION BYTE b24:1; - __EXTENSION BYTE b25:1; - __EXTENSION BYTE b26:1; - __EXTENSION BYTE b27:1; - __EXTENSION BYTE b28:1; - __EXTENSION BYTE b29:1; - __EXTENSION BYTE b30:1; - __EXTENSION BYTE b31:1; - __EXTENSION BYTE b32:1; - __EXTENSION BYTE b33:1; - __EXTENSION BYTE b34:1; - __EXTENSION BYTE b35:1; - __EXTENSION BYTE b36:1; - __EXTENSION BYTE b37:1; - __EXTENSION BYTE b38:1; - __EXTENSION BYTE b39:1; - __EXTENSION BYTE b40:1; - __EXTENSION BYTE b41:1; - __EXTENSION BYTE b42:1; - __EXTENSION BYTE b43:1; - __EXTENSION BYTE b44:1; - __EXTENSION BYTE b45:1; - __EXTENSION BYTE b46:1; - __EXTENSION BYTE b47:1; - __EXTENSION BYTE b48:1; - __EXTENSION BYTE b49:1; - __EXTENSION BYTE b50:1; - __EXTENSION BYTE b51:1; - __EXTENSION BYTE b52:1; - __EXTENSION BYTE b53:1; - __EXTENSION BYTE b54:1; - __EXTENSION BYTE b55:1; - __EXTENSION BYTE b56:1; - __EXTENSION BYTE b57:1; - __EXTENSION BYTE b58:1; - __EXTENSION BYTE b59:1; - __EXTENSION BYTE b60:1; - __EXTENSION BYTE b61:1; - __EXTENSION BYTE b62:1; - __EXTENSION BYTE b63:1; - } bits; -} QWORD_VAL; -*/ -#undef __EXTENSION - -#ifndef uint24_t - #define uint24_t uint32_t -#endif - -typedef void(*pFunc)(void); -/* -typedef union _POINTER -{ - struct - { - BYTE bLow; - BYTE bHigh; - //BYTE bUpper; - }; - uint16_t _word; // bLow & bHigh - - //pFunc _pFunc; // Usage: ptr.pFunc(); Init: ptr.pFunc = &; - - BYTE* bRam; // Ram byte pointer: 2 bytes pointer pointing - // to 1 byte of data - uint16_t* wRam; // Ram word poitner: 2 bytes poitner pointing - // to 2 bytes of data - - ROM BYTE* bRom; // Size depends on compiler setting - ROM WORD* wRom; - //ROM near BYTE* nbRom; // Near = 2 bytes pointer - //ROM near uint16_t* nwRom; - //ROM far BYTE* fbRom; // Far = 3 bytes pointer - //ROM far uint16_t* fwRom; -} POINTER; -*/ - - -#endif /* __CUSTOMIZED_TYPE_DEFS_H_ */ diff --git a/bootloader/src/usb_config.h b/bootloader/src/usb_config.h index a9dde19..67b2192 100644 --- a/bootloader/src/usb_config.h +++ b/bootloader/src/usb_config.h @@ -171,8 +171,9 @@ #define HID_NUM_OF_DSC 1 #define HID_RPT01_SIZE 29 -#define HID_IN_EP 0 -#define HID_OUT_EP 1 +#define HID_EP 1 +#define HID_IN_EP HID_EP +#define HID_OUT_EP HID_EP /** DEFINITIONS ****************************************************/ diff --git a/bootloader/src/usb_events.c b/bootloader/src/usb_events.c index aa08319..47674b6 100644 --- a/bootloader/src/usb_events.c +++ b/bootloader/src/usb_events.c @@ -55,8 +55,6 @@ bool USER_USB_CALLBACK_EVENT_HANDLER(USB_EVENT event, void *pdata, uint16_t size case EVENT_CONFIGURED: // When the device is configured, we should (re)initialize our state variables UserInit(); - USBEnableEndpoint(HID_IN_EP, USB_IN_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP); - USBEnableEndpoint(HID_OUT_EP, USB_OUT_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP); break; case EVENT_SET_DESCRIPTOR: