Example #1
0
int HAL_UART::getcharNoWait(){
  uint8_t c = 0;
  
  if(context->idx == 0) {
	  if( isDataReady() ) {
      c = *(UART0_BASEADDR + uart_rxOffset) & 0xff;
      return c;
    } 
  }
#ifdef USE_DEV_BOARD_BIROS
  else if (context->idx == 1) {
    if( (*(PPU_BASEADDR + ppu_tcCtrlOffset) & (1<<RX1_EMPTY))==0x00 ) {
      c = *(PPU_BASEADDR + ppu_tc1DataOffset) & 0xff;
      return c;
    } 
  }
  else if (context->idx == 2) {
   if( (*(PPU_BASEADDR + ppu_tcCtrlOffset) & (1<<RX2_EMPTY))==0x00 ) {
      c=*(PPU_BASEADDR + ppu_tc2DataOffset);
      return c ;
    } 
  }
#endif
  return -1;
}
Example #2
0
void ADCSequencer::triggerAndWait()
{
	trigger();
	while (!isDataReady()) { Task::yield(); }
	readData();
	clearInterrupt();
}
Example #3
0
int HAL_UART::read(char* recBuf, int maxLen){
  int i=-1;
  if(context->idx == 0) {
    for(i=0;i<maxLen && isDataReady();i++) {
      recBuf[i] = *(UART0_BASEADDR + uart_rxOffset);
    }
  }
#ifdef USE_DEV_BOARD_BIROS
  else if (context->idx == 1){
	  for (i = 0; i < maxLen &&  isDataReady(); i++ )
	  {
		  recBuf[i] = *(PPU_BASEADDR + ppu_tc1DataOffset) & 0xff;
	  }	  
  }
  else if (context->idx == 2) {
	  for (i = 0; i < maxLen &&  isDataReady(); i++ )
	  {
		  recBuf[i] = *(PPU_BASEADDR + ppu_tc2DataOffset) & 0xff;
	  }	  
  }
#endif
  return i;
}
int initCellModem(Serial *serial)
{

    size_t success = 0;
    size_t attempts = 0;
    g_cellmodem_status = CELLMODEM_STATUS_NOT_INIT;

    while (!success && attempts++ < 3) {
        closeNet(serial);

        if (attempts > 1) {
            pr_debug("SIM900: power cycling\r\n");
            if (sendCommandOK(serial, "AT\r") == 1 && attempts > 1) {
                pr_debug("SIM900: powering down\r\n");
                powerCycleCellModem();
            }
            powerCycleCellModem();
        }

        if (sendCommandRetry(serial, "ATZ\r", "OK", 2, 2) != 1) continue;
        if (sendCommandRetry(serial, "ATE0\r", "OK", 2, 2) != 1) continue;
        sendCommand(serial, "AT+CIPSHUT\r", "OK");
        if (isNetworkConnected(serial, 60, 3) != 1) continue;
        getSignalStrength(serial);
        read_subscriber_number(serial);
        read_IMEI(serial);
        if (isDataReady(serial, 30, 2) != 1) continue;
        success = 1;
    }
    if ( success ) {
        g_cellmodem_status = CELLMODEM_STATUS_PROVISIONED;
        return 0;
    } else {
        g_cellmodem_status = CELLMODEM_STATUS_NO_NETWORK;
        return -1;
    }
}