mirror of https://github.com/rusefi/canable-fw.git
Disable interrupts during critical period
This commit is contained in:
parent
8ca5d39d63
commit
3c0a6fc53b
|
@ -4,5 +4,8 @@
|
|||
|
||||
void system_init(void);
|
||||
void system_hex32(char *out, uint32_t val);
|
||||
void system_irq_enable(void);
|
||||
void system_irq_disable(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
17
src/system.c
17
src/system.c
|
@ -86,3 +86,20 @@ void system_hex32(char *out, uint32_t val)
|
|||
p--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Disable all interrupts
|
||||
void system_irq_disable(void)
|
||||
{
|
||||
__disable_irq();
|
||||
__DSB();
|
||||
__ISB();
|
||||
}
|
||||
|
||||
|
||||
// Enable all interrupts
|
||||
void system_irq_enable(void)
|
||||
{
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
|
|
|
@ -167,6 +167,7 @@ static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)
|
|||
// Process incoming USB-CDC messages from RX FIFO
|
||||
void cdc_process(void)
|
||||
{
|
||||
system_irq_disable();
|
||||
if(rxbuf.tail != rxbuf.head)
|
||||
{
|
||||
// Process one whole buffer
|
||||
|
@ -201,6 +202,7 @@ void cdc_process(void)
|
|||
// Move on to next buffer
|
||||
rxbuf.tail = (rxbuf.tail + 1) % NUM_RX_BUFS;
|
||||
}
|
||||
system_irq_enable();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue