ringbuffer: Make ring buffer access irq-save

We have to temporarily disable nterrupts when performing rinbuffer
operations, as the ring buffer is used both from IRQ as well as process
context.
This commit is contained in:
Harald Welte
2016-03-03 17:48:32 +01:00
parent 7dd3dfd992
commit 7abdb51f8f
7 changed files with 61 additions and 16 deletions

View File

@@ -77,10 +77,16 @@
* This includes EFC and master clock configuration.
* It also enable a low level on the pin NRST triggers a user reset.
*/
#define _LED_GREN (1 << 18)
#define _LED_RED (1 << 17)
extern WEAK void LowLevelInit( void )
{
uint32_t timeout = 0;
PIOA->PIO_PER |= _LED_RED | _LED_GREN;
PIOA->PIO_OER |= _LED_RED | _LED_GREN;
PIOA->PIO_CODR |= _LED_RED | _LED_GREN;
/* Set 3 FWS for Embedded Flash Access */
EFC->EEFC_FMR = EEFC_FMR_FWS(3);
@@ -110,6 +116,8 @@ extern WEAK void LowLevelInit( void )
timeout = 0;
while (!(PMC->PMC_SR & PMC_SR_MOSCSELS) && (timeout++ < CLOCK_TIMEOUT));
PIOA->PIO_SODR = _LED_RED;
/* "switch" to main clock as master clock source (should already be the case */
PMC->PMC_MCKR = (PMC->PMC_MCKR & ~(uint32_t)PMC_MCKR_CSS_Msk) | PMC_MCKR_CSS_MAIN_CLK;
/* wait for master clock to be ready */

View File

@@ -129,8 +129,6 @@ uint32_t ISO7816_SendChar( uint8_t CharToSend, Usart_info *usart )
Usart *us_base = usart->base;
uint32_t us_id = usart->id;
TRACE_DEBUG("***Send char: 0x%X\n\r", CharToSend);
if( usart->state == USART_RCV ) {
us_base->US_CR = US_CR_RSTSTA | US_CR_RSTIT | US_CR_RSTNACK;
usart->state = USART_SEND;