Esempio n. 1
0
void MI0283QT2::drawStart(void)
{
  CS_ENABLE();
  wr_spi(LCD_REGISTER);
  wr_spi(0x22);
  CS_DISABLE();

  CS_ENABLE();
  wr_spi(LCD_DATA);

  return;
}
Esempio n. 2
0
static void wr_cmd(u08 reg, u08 param)
{
    CS_ENABLE();
    wr_spi(LCD_REGISTER);
    wr_spi(reg);
    CS_DISABLE();

    CS_ENABLE();
    wr_spi(LCD_DATA);
    wr_spi(param);
    CS_DISABLE();
}
Esempio n. 3
0
void ADS7846_rd_data(void)
{
	uint_least8_t p, a1, a2, b1, b2;
	uint_least16_t x, y;

	//SPI speed-down
#if !defined(SOFTWARE_SPI) && (defined(__AVR__) || defined(ARDUINO_ARCH_AVR))
	uint_least8_t spcr, spsr;
	spcr = SPCR;
	spsr = SPSR;
#if F_CPU >= 8000000UL
	SPI.setClockDivider(SPI_CLOCK_DIV4);
#else	/* if F_CPU >= 4000000UL */
	SPI.setClockDivider(SPI_CLOCK_DIV2);
#endif
#endif

	//get pressure
	CS_ENABLE();
	ADS7846_wr_spi(CMD_START | CMD_8BIT | CMD_Z1_POS);
	p = ADS7846_rd_spi() & 0x7F;
	CS_DISABLE();
	ADS7846_delay_ms(1);

	if (p > MIN_PRESSURE) {
		pressure = p;
		//get X data
		CS_ENABLE();
		ADS7846_wr_spi(CMD_START | CMD_8BIT | CMD_X_POS);
		tp_x = ADS7846_rd_spi();
		CS_DISABLE();
		ADS7846_delay_ms(1);
		// get y
		CS_ENABLE();
		ADS7846_wr_spi(CMD_START | CMD_8BIT | CMD_Y_POS);
		tp_y = ADS7846_rd_spi();
		CS_DISABLE();
		ADS7846_delay_ms(1);

	} else {
		pressure = 0;
	}

	//restore SPI settings
#if !defined(SOFTWARE_SPI) && (defined(__AVR__) || defined(ARDUINO_ARCH_AVR))
	SPCR = spcr;
	SPSR = spsr;
#endif

	return;
}
Esempio n. 4
0
void MI0283QT9::drawStart(void)
{
  wr_cmd(LCD_CMD_WRITE);
  CS_ENABLE();

  return;
}
void S65LS020::drawStart(void)
{
  RS_ENABLE(); //data
  CS_ENABLE();

  return;
}
Esempio n. 6
0
void S65L2F50::drawStart(void)
{
  wr_cmd(0x5C);
  RS_DISABLE(); //data
  CS_ENABLE();

  return;
}
void S65LPH88::drawStart(void)
{
  wr_reg(0x22);
  CS_ENABLE();
  wr_spi(0x76);

  return;
}
Esempio n. 8
0
static void wr_data(u16 data)
{
    CS_ENABLE();
    wr_spi(LCD_DATA);
    wr_spi(data>>8);
    wr_spi(data);
    CS_DISABLE();
}
Esempio n. 9
0
void REDFLY::enable(void) //select module
{
  flush();
  setbaudrate(baudrate);
  read_state = 0;
  CS_ENABLE();

  return;
}
Esempio n. 10
0
unsigned char SD_command(unsigned char cmd, unsigned long arg,
                         unsigned char crc, unsigned char read) {
  unsigned char i, buffer[8], ret = 0xFF;

  #ifdef DEBUG
    USART_printstr("  CMD ");
    USART_printhex(cmd);
  #endif

  CS_ENABLE();

  SPI_transfer(cmd);
  SPI_transfer(arg >> 24);
  SPI_transfer(arg >> 16);
  SPI_transfer(arg >> 8);
  SPI_transfer(arg);
  SPI_transfer(crc);

  for (i = 0; i < read; i++)
    buffer[i] = SPI_transfer(0xFF);

  CS_DISABLE();  

  for (i = 0; i < read; i++) {
    #ifdef DEBUG
      USART_printch(' ');
      USART_printhex(buffer[i]);
    #endif

    if (buffer[i] != 0xFF)
      ret = buffer[i];
  }

  #ifdef DEBUG
    USART_printstr("\r\n");
  #endif

  return ret;
}
void ADS7846::rd_data(void)
{
  uint_least8_t p, a1, a2, b1, b2;
  uint_least16_t x, y;

  //SPI speed-down
#if !defined(SOFTWARE_SPI) && defined(__AVR__)
  uint_least8_t spcr, spsr;
  spcr = SPCR;
  spsr = SPSR;
# if F_CPU >= 8000000UL
  SPI.setClockDivider(SPI_CLOCK_DIV4);
# else if F_CPU >= 4000000UL
  SPI.setClockDivider(SPI_CLOCK_DIV2);
# endif
#endif

  //get pressure
  CS_ENABLE();
  wr_spi(CMD_START | CMD_8BIT | CMD_DIFF | CMD_Z1_POS);
  a1 = rd_spi()&0x7F;
  wr_spi(CMD_START | CMD_8BIT | CMD_DIFF | CMD_Z2_POS);
  b1 = (255-rd_spi())&0x7F;
  CS_DISABLE();
  p = a1 + b1;

  if(p > MIN_PRESSURE)
  {
    /*//using 4 samples for x and y position
    for(x=0, y=0, i=4; i!=0; i--)
    {
      CS_ENABLE();
      //get X data
      wr_spi(CMD_START | CMD_12BIT | CMD_DIFF | CMD_X_POS);
      a = rd_spi();
      b = rd_spi();
      x += 1023-((a<<2)|(b>>6)); //12bit: ((a<<4)|(b>>4)) //10bit: ((a<<2)|(b>>6))
      //get Y data
      wr_spi(CMD_START | CMD_12BIT | CMD_DIFF | CMD_Y_POS);
      a = rd_spi();
      b = rd_spi();
      y += ((a<<2)|(b>>6)); //12bit: ((a<<4)|(b>>4)) //10bit: ((a<<2)|(b>>6))
      CS_DISABLE();
    }
    x >>= 2; //x/4
    y >>= 2; //y/4*/
    
    //using 2 samples for x and y position
    CS_ENABLE();
    //get X data
    wr_spi(CMD_START | CMD_12BIT | CMD_DIFF | CMD_X_POS);
    a1 = rd_spi();
    b1 = rd_spi();
    wr_spi(CMD_START | CMD_12BIT | CMD_DIFF | CMD_X_POS);
    a2 = rd_spi();
    b2 = rd_spi();

    if(a1 == a2)
    {
      x = 1023-((a2<<2)|(b2>>6)); //12bit: ((a<<4)|(b>>4)) //10bit: ((a<<2)|(b>>6))

      //get Y data
      wr_spi(CMD_START | CMD_12BIT | CMD_DIFF | CMD_Y_POS);
      a1 = rd_spi();
      b1 = rd_spi();
      wr_spi(CMD_START | CMD_12BIT | CMD_DIFF | CMD_Y_POS);
      a2 = rd_spi();
      b2 = rd_spi();

      if(a1 == a2)
      {
        y = ((a2<<2)|(b2>>6)); //12bit: ((a<<4)|(b>>4)) //10bit: ((a<<2)|(b>>6))
        if(x && y)
        {
          tp_x = x;
          tp_y = y;
        }
        pressure = p;
      }