Ejemplo n.º 1
0
// Set the 4 digits Int value
void SEVENSEGHW::setIntValue(unsigned int value, unsigned int pos_dot)
{
    REGISTER( IO_SLOT(wishboneSlot), 7 ) = int_to_7seg( value      %10) | (pos_dot==4 ? 0x80:0x00);
    REGISTER( IO_SLOT(wishboneSlot), 6 ) = int_to_7seg((value/10  )%10) | (pos_dot==3 ? 0x80:0x00);
    REGISTER( IO_SLOT(wishboneSlot), 5 ) = int_to_7seg((value/100 )%10) | (pos_dot==2 ? 0x80:0x00);
    REGISTER( IO_SLOT(wishboneSlot), 4 ) = int_to_7seg((value/1000)%10) | (pos_dot==1 ? 0x80:0x00);
}
Ejemplo n.º 2
0
// Set 16 bits Hex value
void SEVENSEGHW::setHexValue(unsigned int value)
{
    REGISTER( IO_SLOT(wishboneSlot), 7 ) = int_to_7seg( value            %16) ;
    REGISTER( IO_SLOT(wishboneSlot), 6 ) = int_to_7seg((value/16        )%16) ;
    REGISTER( IO_SLOT(wishboneSlot), 5 ) = int_to_7seg((value/(16*16)   )%16) ;
    REGISTER( IO_SLOT(wishboneSlot), 4 ) = int_to_7seg((value/(16*16*16))%16) ;
}
Ejemplo n.º 3
0
// Get Dot position
unsigned int SEVENSEGHW::getDotPosition()
{
    if ((REGISTER( IO_SLOT(wishboneSlot), 7 ) & 0x80) == 0x80)
    {
        return 1;
    } else if ((REGISTER( IO_SLOT(wishboneSlot), 6 ) & 0x80) == 0x80)
    {
        return 2;
    } else if ((REGISTER( IO_SLOT(wishboneSlot), 5 ) & 0x80) == 0x80)
    {
        return 3;
    } else if ((REGISTER( IO_SLOT(wishboneSlot), 4 ) & 0x80) == 0x80)
    {
        return 4;
    }

    return 0;
}
Ejemplo n.º 4
0
 int BaseDevice::deviceBegin(uint8_t vendor, uint8_t product) {
     uint8_t slot;
     slot = DeviceRegistry::scanDevice(vendor,product,m_instance);
     if (slot==NO_DEVICE) {
         /* Uuups */
         m_slot=0xff;
         return -1;
     }
     m_slot=slot;
     m_baseaddress = (register_t)IO_SLOT(m_slot);
     return 0;
 }
Ejemplo n.º 5
0
static uint32_t spiRec32(uint8_t wishboneSlot) {
	 spiSend(0XFF);
	 spiSend(0XFF);
	 spiSend(0XFF);
	 spiSend(0XFF);
// Serial.print(USPIDATA&0xff);
// Serial.print(" ");
	//return USPIDATA&0xff;
	//return USPIDATA;
	//return SPI.transfer32(0xFFFFFFFF);
	//REGISTER(IO_SLOT(12),5) = 0xFFFFFFFF;
	return REGISTER(IO_SLOT(wishboneSlot),1);
	//return SPI.transfer32(0xFFFFFFFF);
}
Ejemplo n.º 6
0
int Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
  errorCode_ = inBlock_ = partialBlockRead_ = type_ = 0;
  chipSelectPin_ = chipSelectPin;
  // 16-bit init start time allows over a minute
  uint16_t t0 = (uint16_t)millis();
  uint32_t arg;

  // set pin modes
  pinMode(chipSelectPin_, OUTPUT);
  chipSelectHigh();
#ifndef USE_SPI_LIB
  pinMode(SPI_MISO_PIN, INPUT);
  pinMode(SPI_MOSI_PIN, OUTPUT);
  pinMode(SPI_SCK_PIN, OUTPUT);
#endif

#ifndef SOFTWARE_SPI
#ifndef USE_SPI_LIB
#ifndef ZPU
  // SS must be in output mode even it is not chip select
  pinMode(SS_PIN, OUTPUT);
  digitalWrite(SS_PIN, HIGH); // disable any SPI device using hardware SS pin
  // Enable SPI, Master, clock rate f_osc/128
  SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR1) | (1 << SPR0);
  // clear double speed
  SPSR &= ~(1 << SPI2X);
#endif // defined ZPU
#else // USE_SPI_LIB
  //SPI.begin();
  SPI.begin(WishboneSlot(wishboneSlot_));
  //SPI.begin(wishboneSlot_);
  REGISTER(IO_SLOT(wishboneSlot_),0)=BIT(SPICP1)|BIT(SPICPOL)|BIT(SPISRE)|BIT(SPIEN)|BIT(SPIBLOCK);
  //SPI.setClockDivider(128);
#ifdef SPI_CLOCK_DIV128
    SPI.setClockDivider(SPI_CLOCK_DIV128);
#else
#ifndef ZPU
    SPI.setClockDivider(255);
#endif
#endif
#endif // USE_SPI_LIB
#endif // SOFTWARE_SPI

  // must supply min of 74 clock cycles with CS high.
  for (uint8_t i = 0; i < 10; i++) spiSend(0XFF);

  chipSelectLow();

  // command to go idle in SPI mode
  while ((status_ = cardCommand(CMD0, 0)) != R1_IDLE_STATE) {
    if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) {
      error(SD_CARD_ERROR_CMD0);
      goto fail;
    }
  }
  // check SD version
  if ((cardCommand(CMD8, 0x1AA) & R1_ILLEGAL_COMMAND)) {
    type(SD_CARD_TYPE_SD1);
  } else {
    // only need last byte of r7 response
    for (uint8_t i = 0; i < 4; i++) status_ = spiRec();
    if (status_ != 0XAA) {
      error(SD_CARD_ERROR_CMD8);
      goto fail;
    }
    type(SD_CARD_TYPE_SD2);
  }
  // initialize card and send host supports SDHC if SD2
  arg = type() == SD_CARD_TYPE_SD2 ? 0X40000000 : 0;

  while ((status_ = cardAcmd(ACMD41, arg)) != R1_READY_STATE) {
    // check for timeout
    if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) {
      error(SD_CARD_ERROR_ACMD41);
      goto fail;
    }
  }

  // if SD2 read OCR register to check for SDHC card
  if (type() == SD_CARD_TYPE_SD2) {
    if (cardCommand(CMD58, 0)) {
      error(SD_CARD_ERROR_CMD58);
      goto fail;
    }
    if ((spiRec() & 0XC0) == 0XC0) type(SD_CARD_TYPE_SDHC);
    // discard rest of ocr - contains allowed voltage range
    for (uint8_t i = 0; i < 3; i++) spiRec();
  }
  chipSelectHigh();

  return true;

#ifndef SOFTWARE_SPI
  return setSckRate(sckRateID);
#else  // SOFTWARE_SPI
  return true;
#endif  // SOFTWARE_SPI

 fail:
  chipSelectHigh();
  return false;
}
unsigned long edit_library::readButtons()
{
	return REGISTER(IO_SLOT(wishboneSlot),1);
}
void edit_library::writeLEDs(unsigned long value)
{
	REGISTER(IO_SLOT(wishboneSlot),0) = value;
}
Ejemplo n.º 9
0
unsigned long ZPUino_2::readButtons()
{
    return REGISTER(IO_SLOT(wishboneSlot),1);
}
Ejemplo n.º 10
0
// Set Brightness
void SEVENSEGHW::setBrightness(unsigned int value)
{
    //SEVSEGBRIGHT = (value << 4 )| getSegmentStatus();
	//SEVSEGBRIGHT = (0xE000F);
	REGISTER( IO_SLOT(wishboneSlot), 0 ) = (0xF | (value<<16));
}
void Robot_Control_Library::setPWMDuty(unsigned int i,int speed)
{
	REGISTER(IO_SLOT(wishboneSlotPWM),i) = speed;
}
Ejemplo n.º 12
0
void SPIClass::begin(int wishboneSlot)
{
	this->wishboneSlot = wishboneSlot;
	REGISTER(IO_SLOT(wishboneSlot),0)=BIT(SPICP1)|BIT(SPIEN)|BIT(SPIBLOCK);
}
Ejemplo n.º 13
0
// Set a digit value
void SEVENSEGHW::setDigitValue(unsigned int value, unsigned int dot, unsigned int digit)
{
    REGISTER( IO_SLOT(wishboneSlot), (4 + digit) ) = int_to_7seg(value%10) | (dot==1 ? 0x80:0x00);

}
int Robot_Control_Library::getRevCount(unsigned int i){
  return REGISTER(IO_SLOT(wishboneSlotQuad),i*4+1);
}
Ejemplo n.º 15
0
// Get Brightness
unsigned int SEVENSEGHW::getBrightness()
{
    return REGISTER( IO_SLOT(wishboneSlot), 0 ) >> 4 ;
}
Ejemplo n.º 16
0
unsigned int SEVENSEGHW::getSegmentStatus()
{
    return REGISTER( IO_SLOT(wishboneSlot), 0 ) & 0xF ;
}
Ejemplo n.º 17
0
// enable/disable segment
void SEVENSEGHW::setSegmentStatus(unsigned int enabled)
{
    REGISTER( IO_SLOT(wishboneSlot), 0 ) = enabled & 0xF | (getBrightness() << 4);
}
Ejemplo n.º 18
0
// Get Extra value
unsigned int SEVENSEGHW::getExtra()
{
    return REGISTER( IO_SLOT(wishboneSlot), 1 ) ;
}
Ejemplo n.º 19
0
// Set Extra value
void SEVENSEGHW::setExtra(unsigned int value)
{
    REGISTER( IO_SLOT(wishboneSlot), 1 ) = value;
}
int Robot_Control_Library::getAccel(unsigned int i){
  return REGISTER(IO_SLOT(wishboneSlotQuad),i*4+3);
}
Ejemplo n.º 21
0
// Get the 4 digits Int value
unsigned int SEVENSEGHW::getIntValue()
{
    return REGISTER( IO_SLOT(wishboneSlot), 7 ) + (REGISTER( IO_SLOT(wishboneSlot), 6 ) *10) + (REGISTER( IO_SLOT(wishboneSlot), 5 ) *100) + (REGISTER( IO_SLOT(wishboneSlot), 4 ) *1000)   ;
	//return SEVSEGDIGITO + (SEVSEGDIGIT1 *10) + (SEVSEGDIGIT2 *100) + (SEVSEGDIGIT3 *1000)   ;
}
int Robot_Control_Library::getPWMDuty(unsigned int i){
	// Serial.print(wishboneSlotPWM);
	// Serial.print(" ");
  return REGISTER(IO_SLOT(wishboneSlotPWM),i);
}
Ejemplo n.º 23
0
// Get a digit value
unsigned int SEVENSEGHW::getDigitValue(unsigned int digit)
{
    return REGISTER( IO_SLOT(wishboneSlot), 4+ digit );
}
// waits until swap is complete before returning
void SmartMatrix::apply(void) {

	uint8_t r,g,b,brightness;
	uint16_t temp0red,temp0green,temp0blue,temp1red,temp1green,temp1blue;

	bool bHasForeground = hasForeground;
	bool bHasCC = SmartMatrix::_ccmode != ccNone;

        int x,y;
        unsigned offset = 32*128;
        unsigned soff = offset;

		rgb24 *pix = &currentDrawBufferPtr[0][0];

		rgb24 tempPixel0;
		
        for (y=0;y<MATRIX_HEIGHT;y++) {

            for (x=0;x<MATRIX_WIDTH;x++) {
				brightness = dimmingFactor;
				
				
/* 			if (bHasForeground && getForegroundPixel(x, y, &tempPixel0)) {
				if(bHasCC) {
					// load foreground pixel with color correction
					r = colorCorrection(tempPixel0.red);
					g = colorCorrection(tempPixel0.green);
					b = colorCorrection(tempPixel0.blue);
				} else {
					// load foreground pixel without color correction
					r = tempPixel0.red;
					g = tempPixel0.green;
					b = tempPixel0.blue;
				}
			} else {
				if(bHasCC) {
					// load background pixel with color correction
					r = backgroundColorCorrection(pix->red);
					g = backgroundColorCorrection(pix->green);
					b = backgroundColorCorrection(pix->blue);
				} else {
					// load background pixel without color correction
					r = pix->red;
					g = pix->green;
					b = pix->blue;
				}
			} */				
				
				
				if (bHasForeground && getForegroundPixel(x, y, &tempPixel0)) {
					r = tempPixel0.red;
					g = tempPixel0.green;
					b = tempPixel0.blue;				
				}
				else {
					r = pix->red;
					g = pix->green;
					b = pix->blue;
				}
				
				r = ((unsigned)r * brightness)>>8;
				g = ((unsigned)g * brightness)>>8;
				b = ((unsigned)b * brightness)>>8;				
				
				unsigned v = ((unsigned)r<<16) + ((unsigned)g<<8) + ((unsigned)b);
				REGISTER(IO_SLOT(9),soff + x) = v;
                pix++;
            }
            soff+=128;
			handleBufferSwap();
			handleForegroundDrawingCopy();
			calculateBackgroundLUT();
			updateForeground();
        }		
}
Ejemplo n.º 25
0
// Set a Hexadecimal value
void SEVENSEGHW::setHexValue(unsigned int value, unsigned int digit)
{
    REGISTER( IO_SLOT(wishboneSlot), (4 + digit) ) = int_to_7seg(value%16) ;

}
Ejemplo n.º 26
0
void ZPUino_2::writeLEDs(unsigned long value)
{
    REGISTER(IO_SLOT(wishboneSlot),0) = value;
}
Ejemplo n.º 27
0
// Set a Custom value
void SEVENSEGHW::custom(unsigned int value, unsigned int digit)
{
    REGISTER( IO_SLOT(wishboneSlot), (4 + digit) ) = value ;

}