mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
added a wait when init I2C, seems to increase stability
This commit is contained in:
parent
ac84e855a9
commit
8eb6f60ba6
3 changed files with 9 additions and 5 deletions
|
@ -2608,7 +2608,7 @@ void __attribute__((noreturn)) AppMain(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_SMARTCARD
|
#ifdef WITH_SMARTCARD
|
||||||
I2C_init();
|
I2C_init(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_FPC_USART
|
#ifdef WITH_FPC_USART
|
||||||
|
|
10
armsrc/i2c.c
10
armsrc/i2c.c
|
@ -91,7 +91,7 @@ void I2C_recovery(void) {
|
||||||
DbpString("I2C bus recovery complete");
|
DbpString("I2C bus recovery complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2C_init(void) {
|
void I2C_init(bool has_ticks) {
|
||||||
// Configure reset pin, close up pull up, push-pull output, default high
|
// Configure reset pin, close up pull up, push-pull output, default high
|
||||||
AT91C_BASE_PIOA->PIO_PPUDR = GPIO_RST;
|
AT91C_BASE_PIOA->PIO_PPUDR = GPIO_RST;
|
||||||
AT91C_BASE_PIOA->PIO_MDDR = GPIO_RST;
|
AT91C_BASE_PIOA->PIO_MDDR = GPIO_RST;
|
||||||
|
@ -106,6 +106,10 @@ void I2C_init(void) {
|
||||||
AT91C_BASE_PIOA->PIO_OER |= (GPIO_SCL | GPIO_SDA | GPIO_RST);
|
AT91C_BASE_PIOA->PIO_OER |= (GPIO_SCL | GPIO_SDA | GPIO_RST);
|
||||||
AT91C_BASE_PIOA->PIO_PER |= (GPIO_SCL | GPIO_SDA | GPIO_RST);
|
AT91C_BASE_PIOA->PIO_PER |= (GPIO_SCL | GPIO_SDA | GPIO_RST);
|
||||||
|
|
||||||
|
if (has_ticks) {
|
||||||
|
WaitMS(2);
|
||||||
|
}
|
||||||
|
|
||||||
bool isok = (SCL_read && SDA_read);
|
bool isok = (SCL_read && SDA_read);
|
||||||
if (isok == false)
|
if (isok == false)
|
||||||
I2C_recovery();
|
I2C_recovery();
|
||||||
|
@ -133,7 +137,7 @@ void I2C_SetResetStatus(uint8_t LineRST, uint8_t LineSCK, uint8_t LineSDA) {
|
||||||
// Note: the SIM_Adapter will not enter the main program after power up. Please run this function before use SIM_Adapter.
|
// Note: the SIM_Adapter will not enter the main program after power up. Please run this function before use SIM_Adapter.
|
||||||
void I2C_Reset_EnterMainProgram(void) {
|
void I2C_Reset_EnterMainProgram(void) {
|
||||||
StartTicks();
|
StartTicks();
|
||||||
I2C_init();
|
I2C_init(true);
|
||||||
I2C_SetResetStatus(0, 0, 0);
|
I2C_SetResetStatus(0, 0, 0);
|
||||||
WaitMS(30);
|
WaitMS(30);
|
||||||
I2C_SetResetStatus(1, 0, 0);
|
I2C_SetResetStatus(1, 0, 0);
|
||||||
|
@ -146,7 +150,7 @@ void I2C_Reset_EnterMainProgram(void) {
|
||||||
// Reserve for firmware update.
|
// Reserve for firmware update.
|
||||||
void I2C_Reset_EnterBootloader(void) {
|
void I2C_Reset_EnterBootloader(void) {
|
||||||
StartTicks();
|
StartTicks();
|
||||||
I2C_init();
|
I2C_init(true);
|
||||||
I2C_SetResetStatus(0, 1, 1);
|
I2C_SetResetStatus(0, 1, 1);
|
||||||
WaitMS(100);
|
WaitMS(100);
|
||||||
I2C_SetResetStatus(1, 1, 1);
|
I2C_SetResetStatus(1, 1, 1);
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#define I2C_DEVICE_CMD_SEND_T0 0x07
|
#define I2C_DEVICE_CMD_SEND_T0 0x07
|
||||||
|
|
||||||
void I2C_recovery(void);
|
void I2C_recovery(void);
|
||||||
void I2C_init(void);
|
void I2C_init(bool has_ticks);
|
||||||
void I2C_Reset(void);
|
void I2C_Reset(void);
|
||||||
void I2C_SetResetStatus(uint8_t LineRST, uint8_t LineSCK, uint8_t LineSDA);
|
void I2C_SetResetStatus(uint8_t LineRST, uint8_t LineSCK, uint8_t LineSDA);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue