mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-20 15:26:13 +08:00
CHG: restored the wait in flash-mode. Its waiting for the device to "reboot"..
CHG: usb_Cdc, : usb specs say 100ms delay. Previous delay was much longer...
This commit is contained in:
parent
dc7473135c
commit
1f0a1edfbe
|
@ -11,6 +11,7 @@ ARMSRC =
|
||||||
THUMBSRC = cmd.c \
|
THUMBSRC = cmd.c \
|
||||||
usb_cdc.c \
|
usb_cdc.c \
|
||||||
bootrom.c
|
bootrom.c
|
||||||
|
|
||||||
ASMSRC = ram-reset.s flash-reset.s
|
ASMSRC = ram-reset.s flash-reset.s
|
||||||
|
|
||||||
## There is a strange bug with the linker: Sometimes it will not emit the glue to call
|
## There is a strange bug with the linker: Sometimes it will not emit the glue to call
|
||||||
|
|
|
@ -193,7 +193,8 @@ static void flash_mode(int externally_entered) {
|
||||||
byte_t rx[sizeof(UsbCommand)];
|
byte_t rx[sizeof(UsbCommand)];
|
||||||
|
|
||||||
usb_enable();
|
usb_enable();
|
||||||
//for (volatile size_t i=0; i<0x100000; i++) {};
|
|
||||||
|
for (volatile size_t i=0; i<0x100000; i++) {};
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "usb_cdc.h"
|
#include "usb_cdc.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
AT91SAM7S256 USB Device Port
|
AT91SAM7S256 USB Device Port
|
||||||
• Embedded 328-byte dual-port RAM for endpoints
|
• Embedded 328-byte dual-port RAM for endpoints
|
||||||
|
@ -442,6 +441,29 @@ uint8_t btConfiguration = 0;
|
||||||
uint8_t btConnection = 0;
|
uint8_t btConnection = 0;
|
||||||
uint8_t btReceiveBank = AT91C_UDP_RX_DATA_BK0;
|
uint8_t btReceiveBank = AT91C_UDP_RX_DATA_BK0;
|
||||||
|
|
||||||
|
static void SpinDelay(int ms) {
|
||||||
|
int us = ms * 1000;
|
||||||
|
int ticks = (48 * us) >> 10;
|
||||||
|
|
||||||
|
// Borrow a PWM unit for my real-time clock
|
||||||
|
AT91C_BASE_PWMC->PWMC_ENA = PWM_CHANNEL(0);
|
||||||
|
|
||||||
|
// 48 MHz / 1024 gives 46.875 kHz
|
||||||
|
AT91C_BASE_PWMC_CH0->PWMC_CMR = PWM_CH_MODE_PRESCALER(10);
|
||||||
|
AT91C_BASE_PWMC_CH0->PWMC_CDTYR = 0;
|
||||||
|
AT91C_BASE_PWMC_CH0->PWMC_CPRDR = 0xffff;
|
||||||
|
|
||||||
|
uint16_t start = AT91C_BASE_PWMC_CH0->PWMC_CCNTR;
|
||||||
|
|
||||||
|
for(;;) {
|
||||||
|
uint16_t now = AT91C_BASE_PWMC_CH0->PWMC_CCNTR;
|
||||||
|
if (now == (uint16_t)(start + ticks))
|
||||||
|
return;
|
||||||
|
|
||||||
|
WDT_HIT();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//*----------------------------------------------------------------------------
|
//*----------------------------------------------------------------------------
|
||||||
//* \fn usb_disable
|
//* \fn usb_disable
|
||||||
//* \brief This function deactivates the USB device
|
//* \brief This function deactivates the USB device
|
||||||
|
@ -480,8 +502,9 @@ void usb_enable() {
|
||||||
// Disconnect and reconnect USB controller for 100ms
|
// Disconnect and reconnect USB controller for 100ms
|
||||||
usb_disable();
|
usb_disable();
|
||||||
|
|
||||||
|
SpinDelay(100);
|
||||||
// Wait for a short while
|
// Wait for a short while
|
||||||
for (volatile size_t i=0; i<0x100000; i++) {};
|
//for (volatile size_t i=0; i<0x100000; i++) {};
|
||||||
|
|
||||||
// Reconnect USB reconnect
|
// Reconnect USB reconnect
|
||||||
AT91C_BASE_PIOA->PIO_SODR = GPIO_USB_PU;
|
AT91C_BASE_PIOA->PIO_SODR = GPIO_USB_PU;
|
||||||
|
@ -550,7 +573,7 @@ bool usb_check() {
|
||||||
else if (isr & AT91C_UDP_EPINT0) {
|
else if (isr & AT91C_UDP_EPINT0) {
|
||||||
pUdp->UDP_ICR = AT91C_UDP_EPINT0;
|
pUdp->UDP_ICR = AT91C_UDP_EPINT0;
|
||||||
AT91F_CDC_Enumerate();
|
AT91F_CDC_Enumerate();
|
||||||
pUdp->UDP_ICR |= AT91C_UDP_EPINT0;
|
//pUdp->UDP_ICR |= AT91C_UDP_EPINT0;
|
||||||
}
|
}
|
||||||
else if (isr & AT91C_UDP_EPINT3 ) {
|
else if (isr & AT91C_UDP_EPINT3 ) {
|
||||||
pUdp->UDP_ICR = AT91C_UDP_EPINT3;
|
pUdp->UDP_ICR = AT91C_UDP_EPINT3;
|
||||||
|
|
Loading…
Reference in a new issue