Hi,
the problem was in calling chEvtRegisterMaskWithFlags and chEvtWaitAny from different threads.
Thanks!
Serial Driver flush buffer
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: Serial Driver flush buffer
Hi, Giovanni!
So I need to call chEvtRegisterMaskWithFlags for every thread. Right?
In initial implementation there was only one call chEvtRegisterMaskWithFlags during logger initialisation and event listener declared as static global variable in c file.
There is no problem with event processing in new implementation of logLock and logUnlock:
But there is strange behaviour of Serial Driver after exit from low power sleep mode.
Output is completely broken. Something like this: 00:0���12����" U�main.c���253 - Blinking��
Does it enough to do these steps after low power sleep mode to make Serial Driver works properly (btw spi driver works fine with the same steps):
1. Enable APB1 with rccEnableAPB1
2. Restore pins AF: palSetLineMode
3. Start Serial Driver with sdStart
Thanks a lot in advance!
So I need to call chEvtRegisterMaskWithFlags for every thread. Right?
In initial implementation there was only one call chEvtRegisterMaskWithFlags during logger initialisation and event listener declared as static global variable in c file.
There is no problem with event processing in new implementation of logLock and logUnlock:
bool logLock(void) {
if (logInited) {
chMtxLock(&logMtx);
sdStart(&LOG_SD, sdConf);
chEvtRegisterMaskWithFlags(&LOG_SD.event, &logListener, EVENT_MASK(0),
CHN_TRANSMISSION_END);
return true;
} else {
return false;
}
}
void logUnlock(void) {
do {
chEvtWaitAny(EVENT_MASK(0));
} while ((chEvtGetAndClearFlags(&logListener) & CHN_TRANSMISSION_END ) == 0);
chEvtUnregister(&(STDOUT_SD.event), &logListener);
sdStop(&LOG_SD);
chMtxUnlock(&logMtx);
}
But there is strange behaviour of Serial Driver after exit from low power sleep mode.
Output is completely broken. Something like this: 00:0���12����" U�main.c���253 - Blinking��
Does it enough to do these steps after low power sleep mode to make Serial Driver works properly (btw spi driver works fine with the same steps):
1. Enable APB1 with rccEnableAPB1
2. Restore pins AF: palSetLineMode
3. Start Serial Driver with sdStart
Thanks a lot in advance!
Vitaly
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: Serial Driver flush buffer
Each thread that needs to wait for events must register using a separate listener.
Exiting low power modes probably requires a clock reinitialization, see the STM32 RM, without that the baud rate is not correct. It is something I never personally used, be alert.
Giovanni
Exiting low power modes probably requires a clock reinitialization, see the STM32 RM, without that the baud rate is not correct. It is something I never personally used, be alert.
Giovanni
Re: Serial Driver flush buffer
Giovanni,
Ok, no more questions about events ) thanks a lot!
I will check RM.
BTW: I implemented simple Power Driver for STM32L1,
it supports:
- low power sleep mode with active chibios ST timer (tickless mode)
- switching between HSI in run mode and MSI in LP sleep mode
- configurable MSI clock source for LP sleep mode
- configurable VOS for LP
- automatic clock switching to MSI for LP mode, timer prescaler modification and back to HSI for run mode
- hooks for disable/enable periphs
- chibios drivers state checking - activate LP sleep mode if all drivers are in stop state
result: about 5uA in LP deep sleep mode @ 65kHz MSI
so I would like to discuss high level driver interface, some chibios modification (MSI values at least, and new feature: bit field for all drivers state) and share the source code.
What do you think?
Ok, no more questions about events ) thanks a lot!
I will check RM.
BTW: I implemented simple Power Driver for STM32L1,
it supports:
- low power sleep mode with active chibios ST timer (tickless mode)
- switching between HSI in run mode and MSI in LP sleep mode
- configurable MSI clock source for LP sleep mode
- configurable VOS for LP
- automatic clock switching to MSI for LP mode, timer prescaler modification and back to HSI for run mode
- hooks for disable/enable periphs
- chibios drivers state checking - activate LP sleep mode if all drivers are in stop state
result: about 5uA in LP deep sleep mode @ 65kHz MSI
so I would like to discuss high level driver interface, some chibios modification (MSI values at least, and new feature: bit field for all drivers state) and share the source code.
What do you think?
Vitaly
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Who is online
Users browsing this forum: No registered users and 9 guests