dm36x uart: Allow UART write from interrupt context.

This commit is contained in:
Kelvin Lawson
2013-11-14 01:01:06 +00:00
parent 735b42a182
commit 2393a08321

View File

@@ -243,8 +243,8 @@ int uart_write (const char *ptr, int len)
return 0; return 0;
} }
/* Block thread on private access to the UART */ /* Block thread on private access to the UART unless at interrupt context */
if (atomOSStarted && atomMutexGet(&uart_mutex, 0) == ATOM_OK) if (atomOSStarted && ((atomCurrentContext() == NULL) || (atomMutexGet(&uart_mutex, 0) == ATOM_OK)))
{ {
/* Loop through all bytes to write */ /* Loop through all bytes to write */
for (todo = 0; todo < len; todo++) for (todo = 0; todo < len; todo++)
@@ -257,8 +257,8 @@ int uart_write (const char *ptr, int len)
uart_write_char(*ptr++); uart_write_char(*ptr++);
} }
/* Return mutex access */ /* Return mutex access if not at interrupt context */
if (atomOSStarted) if (atomOSStarted && (atomCurrentContext() != NULL))
{ {
atomMutexPut(&uart_mutex); atomMutexPut(&uart_mutex);
} }