Skip to content

New BLE API preview #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions cores/arduino/UARTClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ int UARTClass::read( void )

void UARTClass::flush( void )
{
while (_tx_buffer->_iHead != *(volatile int*)&(_tx_buffer->_iTail)); //wait for transmit data to be sent
while (_tx_buffer->_iHead != _tx_buffer->_iTail); //wait for transmit data to be sent
// Wait for transmission to complete
while(!uart_tx_complete(CONFIG_UART_CONSOLE_INDEX));
}
Expand All @@ -179,11 +179,12 @@ size_t UARTClass::write( const uint8_t uc_data )
return(0);

// Is the hardware currently busy?
if (_tx_buffer->_iTail != _tx_buffer->_iHead || !uart_tx_ready(CONFIG_UART_CONSOLE_INDEX))
if (_tx_buffer->_iTail != _tx_buffer->_iHead)
{
// If busy we buffer
int l = (_tx_buffer->_iHead + 1) % UART_BUFFER_SIZE;
while (*(volatile int*)&(_tx_buffer->_iTail) == l); // Spin locks if we're about to overwrite the buffer. This continues once the data is sent
while (_tx_buffer->_iTail == l)
; // Spin locks if we're about to overwrite the buffer. This continues once the data is sent

_tx_buffer->_aucBuffer[_tx_buffer->_iHead] = uc_data;
_tx_buffer->_iHead = l;
Expand All @@ -200,29 +201,21 @@ size_t UARTClass::write( const uint8_t uc_data )

void UARTClass::IrqHandler( void )
{
uart_irq_update(CONFIG_UART_CONSOLE_INDEX);
// if irq is Receiver Data Available
if(uart_irq_rx_ready(CONFIG_UART_CONSOLE_INDEX))
{
uint8_t uc_data;
int ret;
uint8_t uc_data;
int ret;
ret = uart_poll_in(CONFIG_UART_CONSOLE_INDEX, &uc_data);

while ( ret != -1 ) {
_rx_buffer->store_char(uc_data);
ret = uart_poll_in(CONFIG_UART_CONSOLE_INDEX, &uc_data);

while ( ret != -1 ) {
_rx_buffer->store_char(uc_data);
ret = uart_poll_in(CONFIG_UART_CONSOLE_INDEX, &uc_data);
}
}

// if irq is Transmitter Holding Register
else if(uart_irq_tx_ready(CONFIG_UART_CONSOLE_INDEX))
// Do we need to keep sending data?
if (!uart_irq_tx_ready(CONFIG_UART_CONSOLE_INDEX))
{
if(_tx_buffer->_iTail != _tx_buffer->_iHead)
{
int end = (_tx_buffer->_iTail < _tx_buffer->_iHead) ? _tx_buffer->_iHead:UART_BUFFER_SIZE;
int l = min(end - _tx_buffer->_iTail, UART_FIFO_SIZE);
uart_fifo_fill(CONFIG_UART_CONSOLE_INDEX, _tx_buffer->_aucBuffer+_tx_buffer->_iTail, l);
_tx_buffer->_iTail = (_tx_buffer->_iTail+l)%UART_BUFFER_SIZE;
if (_tx_buffer->_iTail != _tx_buffer->_iHead) {
uart_poll_out(CONFIG_UART_CONSOLE_INDEX, _tx_buffer->_aucBuffer[_tx_buffer->_iTail]);
_tx_buffer->_iTail = (unsigned int)(_tx_buffer->_iTail + 1) % UART_BUFFER_SIZE;
}
else
{
Expand Down
116 changes: 0 additions & 116 deletions libraries/CurieBLE/examples/BatteryAdvChange/BatteryAdvChange.ino

This file was deleted.

143 changes: 0 additions & 143 deletions libraries/CurieBLE/examples/BatteryMonitor/BatteryMonitor.ino

This file was deleted.

Loading