void Uart::com4TXChar( void* src, char c )
{
    Fifo *fifo;

    fifo = (Fifo *)src;
    putcUSART4( fifo->popChar() );
}
Exemple #2
0
void UsbMidiModule::_poll()
{
	midi_event_t midiEvent;
	int numReceived;

	while (numReceived = USB_Recv(getOutEndpointId(), &midiEvent, sizeof(midiEvent)))
	{
		// MIDI USB messages are 4 bytes in size.
		if (numReceived != 4)
			return;

		// They get decoded to up to 3 MIDI Serial bytes.
		u8 data[3];

		unsigned count = UsbToMidi::process(midiEvent, data);

		if (m_midiInFifo.hasSpaceFor(count))
		{
			for (unsigned i=0; i<count; ++i)
			{
				m_midiInFifo.push(data[i]);
			}
		}
	}
}
Exemple #3
0
   void print(PtrLen<const char> str)
    {
     SingleHook<Video::VideoConsole> hook(host);

     if( +hook )
       {
        fifo.get(*hook);

        hook->print(str);
       }
     else
       {
        fifo.put(str);
       }
    }
int main (void)
{
	Fifo fifo;
	fifo.reset();

	Sem mutex(1, 1234);
	Sem min3(0, 1235);
	Sem puste(9, 1236);
	Sem czytA(0, 1237);
	Sem czytB(0, 1238);
	Sem nCzytA(1, 1239);
	Sem nCzytB(1, 1240);

	cout << "Alokacja gotowa" << endl;
	return 0;
}
Exemple #5
0
void Game::Run()
{
	while(1)
	{
		int res = rc5Buffer.Get();
		if(res == -1)
		{
			continue;
		}

		Command cmd(res);
		if(!hasToggle)
		{
			toggle = cmd.toggle;
			hasToggle = true;
		}
		else
		{
			if(toggle == cmd.toggle)
			{
				continue;
			}
			toggle = !toggle;
		}

		switch(cmd.command)
		{
		case 2: window.Move(Window::UP); break;
		case 4: window.Move(Window::LEFT); break;
		case 6: window.Move(Window::RIGHT); break;
		case 8: window.Move(Window::DOWN); break;
		}
	}
}
void produkuj()
{
	cout << "[A czeka na miejsce]" << endl;
	puste.down();
	
	cout << "[A chce wstawiac]" << endl;
	mutex.down();
		cout << "[A wstawia]";
		fifo.push('A');
		fifo.de();
		if(fifo.size() > 3)
		{
			min3.up();
		}
	mutex.up();
}
uint16_t rxBtuart()
{
  uint8_t result;
  if (!btRxFifo.pop(result))
    return 0xffff;

  return result;
}
Exemple #8
0
int UsbMidiModule::_read()
{
	_poll();

	u8 byte = 0;
	m_midiInFifo.pop(&byte);

	return byte;
}
Exemple #9
0
int UsbMidiModule::_peek()
{
	_poll();

	u8 byte = 0;
	m_midiInFifo.peek(&byte);

	return byte;
}
Exemple #10
0
 void debug_print(PtrLen<const char> str)
  {
   if( Dev::IsIntContext() )
     {
      fifo.put(str);
     }
   else
     {
      print(str);
     }
  }
Exemple #11
0
extern "C" void UART1_IRQHandler()
{
  Uart *pUart = BT_USART ;
  if ( pUart->UART_SR & UART_SR_TXBUFE ) {
    pUart->UART_IDR = UART_IDR_TXBUFE ;
    pUart->UART_PTCR = US_PTCR_TXTDIS ;
    Current_bt->ready = 0 ;
  }
  if ( pUart->UART_SR & UART_SR_RXRDY ) {
    btRxFifo.push(pUart->UART_RHR);
  }
}
Exemple #12
0
extern "C" void USART3_IRQHandler(void)
{
  if (USART_GetITStatus(UART3, USART_IT_TXE) != RESET) {
    uint8_t txchar;
    if (debugTxFifo.pop(txchar)) {
      /* Write one byte to the transmit data register */
      USART_SendData(UART3, txchar);
    }
    else {
      USART_ITConfig(UART3, USART_IT_TXE, DISABLE);
    }
  }
}
Exemple #13
0
  void run () {
    int cnt;
    xprintf("receiver\n");

    while(1) {
      bool ok = fifo.get(cnt);
      if (ok) {
        PRINTF("reading %d\n", cnt);
      } else {
        suspendCallerUntil(NOW() + 1*SECONDS);
      }
    }
  }
Exemple #14
0
extern "C" void USART2_IRQHandler()
{
  uint32_t status;
  uint8_t data;

  status = SPORT->SR;

  while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
    data = SPORT->DR;

    if (!(status & USART_FLAG_ERRORS))
      telemetryFifo.push(data);

    status = SPORT->SR;
  }
}
Exemple #15
0
extern "C" void HEARTBEAT_USART_IRQHandler()
{
  uint32_t status;
  uint8_t data;

  status = HEARTBEAT_USART->SR;

  while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
    data = HEARTBEAT_USART->DR;

    if (!(status & USART_FLAG_ERRORS))
      sbusFifo.push(data);

    status = HEARTBEAT_USART->SR;
  }
}
Exemple #16
0
  void run () {
    int  cnt = 0;
    xprintf("sender\n");
    while(1) {
      cnt++;
      bool ok = fifo.put(cnt);
      if (ok) { 
        PRINTF("Sending %d\n", cnt);
      } else {
        PRINTF("Fifo full\n");
      }	
      if ((cnt % 15) == 0) {
        PRINTF("Wainting 3 seconds\n");
	suspendCallerUntil(NOW() + 3*SECONDS);
      }
    }
  }
Exemple #17
0
extern "C" void HEARTBEAT_USART_IRQHandler()
{
  uint32_t status;
  uint8_t data;

  status = HEARTBEAT_USART->SR;

  while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
    data = HEARTBEAT_USART->DR;

    if (!(status & USART_FLAG_ERRORS)) {
      if (currentTrainerMode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE)
        sbusFifo.push(data);
    }

    status = HEARTBEAT_USART->SR;
  }
}
Exemple #18
0
void cliTask(void * pdata)
{
  char line[CLI_COMMAND_MAX_LEN+1];
  int pos = 0;

  cliPrompt();

  for (;;) {
    uint8_t c;

    while (!cliRxFifo.pop(c)) {
      CoTickDelay(10); // 20ms
    }

    if (c == 12) {
      // clear screen
      serialPrint("\033[2J\033[1;1H");
      cliPrompt();
    }
    else if (c == 127) {
      // backspace
      if (pos) {
        line[--pos] = '\0';
        serialPutc(c);
      }
    }
    else if (c == '\r' || c == '\n') {
      // enter
      serialCrlf();
      line[pos] = '\0';
      cliExecLine(line);
      pos = 0;
      cliPrompt();
    }
    else if (isascii(c) && pos < CLI_COMMAND_MAX_LEN) {
      line[pos++] = c;
      serialPutc(c);
    }
  }
}
Exemple #19
0
void CAN_Ctrl::IRQHandler(){
	CanMsg msg;
	uint64_t iflags= can_mb_int_flag(can);
#define CHECK_IFLAG(n) ((iflags & ((uint64_t)1<<(n))) != 0)

	if(CHECK_IFLAG(TX_MAILBOX)){

		if(txFifo.get(msg)){
			putIntoTxMailbox(msg);
		}else{
			txInProgrss=false;
			//This may call upCall multiple times for one hal, but it is simpleset solution
			for (int i=0;i<numFilters;i++){
				filters[i].owner->upCallWriteFinished();
			}
		}
		can_mb_int_ack(can,TX_MAILBOX);
	}

	while(CHECK_IFLAG(FIFO_FLAG_DATARDY)){
		if(numFilters>0){
			int32_t matchedFilter = REG_RD(REG_RXFIR(can->base)) & 0x1FF;
			if(matchedFilter >= numFilters){
				matchedFilter =numFilters-1;
			}

			getFromRxFifo(msg);
			if(filters[matchedFilter].owner_context->RxFifo.put(msg)){
				filters[matchedFilter].owner->upCallDataReady();
			}
			//Silently ignore FIFO overflow
		}

		can_mb_int_ack(can,FIFO_FLAG_DATARDY);
		iflags= can_mb_int_flag(can);

	}

}
extern "C" void UART0_IRQHandler()
{
  serial2RxFifo.push(SECOND_SERIAL_UART->UART_RHR);
}
void push(Fifo& fifo, T& seed)
{
    fifo.push(seed);
}
Exemple #22
0
extern "C" void UART0_IRQHandler()
{
  debugRxFifo.push(CONSOLE_USART->UART_RHR);
}
void pop(Fifo& fifo)
{
    typename Fifo::value_type t;
    fifo.pop(t);
}
Exemple #24
0
void debugPutc(const char c)
{
  debugTxFifo.push(c);
  USART_ITConfig(UART3, USART_IT_TXE, ENABLE);
}
Exemple #25
0
void btTask(void* pdata)
{
  uint8_t byte;

  btFlag = CoCreateFlag(true, false);
  btTx.size = 0;

  // Look for BT module baudrate, try 115200, and 9600
  // Already initialised to g_eeGeneral.bt_baudrate
  // 0 : 115200, 1 : 9600, 2 : 19200

  uint32_t x = g_eeGeneral.btBaudrate;

  btStatus = btPollDevice() ;              // Do we get a response?

  for (int y=0; y<2; y++) {
    if (btStatus == 0) {
      x += 1 ;
      if (x > 2) {
        x = 0 ;
      }
      btSetBaudrate(x) ;
      CoTickDelay(1) ;                                        // 2mS
      btStatus = btPollDevice() ;              // Do we get a response?
    }
  }

  if (btStatus) {
    btStatus = x + 1 ;
    if ( x != g_eeGeneral.btBaudrate ) {
      x = g_eeGeneral.btBaudrate ;
      // Need to change Bt Baudrate
      btChangeBaudrate( x ) ;
      btStatus += (x+1) * 10 ;
      btSetBaudrate( x ) ;
    }
  }
  else {
    btInit();
  }

  CoTickDelay(1) ;

  btPollDevice(); // Do we get a response?

  while (1) {
    uint32_t x = CoWaitForSingleFlag(btFlag, 10); // Wait for data in Fifo
    if (x == E_OK) {
      // We have some data in the Fifo
      while (btTxFifo.pop(byte)) {
        btTxBuffer[btTx.size++] = byte;
        if (btTx.size > 31) {
          btSendBuffer();
        }
      }
    }
    else if (btTx.size) {
      btSendBuffer();
    }
  }
}
Exemple #26
0
void btPushByte(uint8_t data)
{
  btTxFifo.push(data);
  CoSetFlag(btFlag); // Tell the Bt task something to do
}
Exemple #27
0
int UsbMidiModule::_available()
{
	_poll();
	return !m_midiInFifo.isEmpty();
}
bool telemetrySecondPortReceive(uint8_t & data)
{
  return serial2RxFifo.pop(data);
}