mhhh, I've tried this so I will make first time the initialization of the screen that uses i2c bus to talk with the display controller
flash program, detach power for a cold boot.
i2c bus works fine
then go to standby.
when wake up try to check if the chSysLock() call works. With my disappointment IT WORK.
Code: Select all
int main(void) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
palClearPad(GPIOA,GPIOA_PWR_OFF);
wkup = 0;
palSetPad(GPIOC,GPIOC_2V5_EN);//2.5v en
sdStart(&SERIAL_PORT, NULL);
chprintf((BaseSequentialStream *)&SERIAL_PORT, "\r\nApplication started!\r\n");
/* Initialize backup SRAM */
//TM_BKPSRAM_Init();//non serve visto che ho abilitato in mcuconf.h la backup sram!
//TestBkpRam();
if (TM_LOWPOWER_StandbyReset()) {
chprintf((BaseSequentialStream *)&SERIAL_PORT, "detect wakeup from standby!\r\n");
wkup = 1;
#if 1
chThdCreateStatic(waThread10, sizeof(waThread10), NORMALPRIO, Thread10, NULL);
chThdSleepMilliseconds(1000);
chSysLock();
chSysUnlock();
while (true) {
chThdSleepMilliseconds(1000);
}
#endif
}
i2cStart(&I2CD1, &i2cfg1);
chThdCreateStatic(waThread10, sizeof(waThread10), NORMALPRIO, Thread10, NULL);
SRAM_Init();
// Clear the SDRAM
memset((void *)SRAM_BANK_ADDR, 0, 0x400000);
chThdSleepMilliseconds(1000);
NOR_Init();
ffs_init();
chHeapObjectInit(&ext_heap, (void*)(SRAM_BANK_ADDR+4*1024*1024), 10*1024*1024);
ImgManagement_Init();
gfxInit();
TM_LOWPOWER_DisableWakeUpPin();
PWR_ClearFlag(PWR_FLAG_SB | PWR_FLAG_WU);
TM_LOWPOWER_EnableWakeUpPin();
chThdSleepMilliseconds(1000);
TM_LOWPOWER_Standby();
while (true) {
chThdSleepMilliseconds(1000);
}
}
But I'm sure, since I got the log from serial, that after a standby and wakup, the system hangs around osalSysLock(); inside i2cMasterTransmitTimeout, because I've checked the argument of osalDbgCheck(chk); and osalDbgAssert(i2cp->state == I2C_READY, "not ready"); and both are good (I reach the first chprintf((BaseSequentialStream *)&SERIAL_PORT, "%s: %d\n\r",__func__,i++);)
Code: Select all
osalDbgCheck(chk);
osalDbgAssert(i2cp->state == I2C_READY, "not ready");
if(wkup){
chprintf((BaseSequentialStream *)&SERIAL_PORT, "%s: %d\n\r",__func__,i++);
chThdSleepMilliseconds(250);
}
osalSysLock();
i2cp->errors = I2C_NO_ERROR;
i2cp->state = I2C_ACTIVE_TX;
if(wkup){
chprintf((BaseSequentialStream *)&SERIAL_PORT, "%s: %d\n\r",__func__,i++);
chThdSleepMilliseconds(250);
}
rdymsg = i2c_lld_master_transmit_timeout(i2cp, addr, txbuf, txbytes,
rxbuf, rxbytes, timeout);
So I don't understand.. and quite lost..