static void wr_data(u16 data) { CS_ENABLE(); wr_spi(LCD_DATA); wr_spi(data>>8); wr_spi(data); CS_DISABLE(); }
void MI0283QT2::drawStart(void) { CS_ENABLE(); wr_spi(LCD_REGISTER); wr_spi(0x22); CS_DISABLE(); CS_ENABLE(); wr_spi(LCD_DATA); return; }
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(); }
void DAC8760::wr_reg(uint_least8_t reg, uint_least16_t data) { /* //set SPI settings #if !defined(SOFTWARE_SPI) # if defined(__AVR__) uint_least8_t spcr, spsr; spcr = SPCR; spsr = SPSR; # endif SPI.setClockDivider(SPI_CLOCK_DIV4); //SPI_CLOCK_DIV4 SPI.setDataMode(SPI_MODE0); //SPI_MODE0 //SPI.setBitOrder(MSBFIRST); #endif */ wr_spi(reg); wr_spi(data>>8); wr_spi(data>>0); LATCH_HIGH(); LATCH_LOW(); /* //restore SPI settings #if !defined(SOFTWARE_SPI) && defined(__AVR__) SPCR = spcr; SPSR = spsr; #endif */ return; }
void MI0283QT9::draw(uint16_t color) { //9th bit MOSI_HIGH(); //data CLK_LOW(); #if defined(SOFTWARE_SPI) CLK_HIGH(); #else SPCR &= ~(1<<SPE); //disable SPI CLK_HIGH(); SPCR |= (1<<SPE); //enable SPI #endif wr_spi(color>>8); //9th bit MOSI_HIGH(); //data CLK_LOW(); #if defined(SOFTWARE_SPI) CLK_HIGH(); #else SPCR &= ~(1<<SPE); //disable SPI CLK_HIGH(); SPCR |= (1<<SPE); //enable SPI #endif wr_spi(color); return; }
void S65LPH88::drawStart(void) { wr_reg(0x22); CS_ENABLE(); wr_spi(0x76); return; }
uint8_t wiring_write_then_read(uint8_t* out, uint16_t out_len, uint8_t* in, uint16_t in_len) { int i; send_usb(21); if (NULL != out) for (i=0; i<out_len; i++) // отправить #if 1 if (i+4<= out_len) { // отправка 4 байта за раз //printf ("data %d\n",i); w_spi_array(out[i],out[i+1],out[i+2],out[i+3]); i+=3; } else #endif wr_spi(out[i]); if (NULL != in) for (i=0; i<in_len; i++) #if 1 if (i+32<= in_len) { // прием 32 байта за раз r_spi_array(); memcpy(&in[i],buffer, 32); i+=31; } else #endif in[i]=wr_spi(0); // прочитать send_usb(20); return in_len+out_len; }
void MI0283QT9::draw(uint_least16_t color) { #if defined(USE_8BIT_SPI) // RS_HIGH(); //data # else //9th bit MOSI_HIGH(); //data CLK_LOW(); # if defined(__AVR__) && !defined(SOFTWARE_SPI) SPCR &= ~(1<<SPE); //disable SPI CLK_HIGH(); SPCR |= (1<<SPE); //enable SPI # else CLK_HIGH(); # endif #endif wr_spi(color>>8); #if defined(USE_8BIT_SPI) // RS_HIGH(); //data # else //9th bit MOSI_HIGH(); //data CLK_LOW(); # if defined(__AVR__) && !defined(SOFTWARE_SPI) SPCR &= ~(1<<SPE); //disable SPI CLK_HIGH(); SPCR |= (1<<SPE); //enable SPI # else CLK_HIGH(); # endif #endif wr_spi(color); return; }
void MI0283QT9::draw(uint_least16_t color) { #if defined(LCD_8BIT_SPI) // RS_HIGH(); //data # else //9th bit MOSI_HIGH(); //data SCK_LOW(); # if !defined(SOFTWARE_SPI) && (defined(__AVR__) || defined(ARDUINO_ARCH_AVR)) SPCR &= ~(1<<SPE); //disable SPI SCK_HIGH(); SPCR |= (1<<SPE); //enable SPI # else SCK_HIGH(); # endif #endif wr_spi(color>>8); #if defined(LCD_8BIT_SPI) // RS_HIGH(); //data # else //9th bit MOSI_HIGH(); //data SCK_LOW(); # if !defined(SOFTWARE_SPI) && (defined(__AVR__) || defined(ARDUINO_ARCH_AVR)) SPCR &= ~(1<<SPE); //disable SPI SCK_HIGH(); SPCR |= (1<<SPE); //enable SPI # else SCK_HIGH(); # endif #endif wr_spi(color); return; }
uint_least8_t MI0283QT9::touchRead(void) { #if defined(ADS7846) 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 >= 16000000UL SPI.setClockDivider(SPI_CLOCK_DIV8); # elif F_CPU >= 8000000UL SPI.setClockDivider(SPI_CLOCK_DIV4); # else //elif F_CPU >= 4000000UL SPI.setClockDivider(SPI_CLOCK_DIV2); # endif #endif //get pressure ADSCS_ENABLE(); wr_spi(ADS_CMD_START | ADS_CMD_8BIT | ADS_CMD_DIFF | ADS_CMD_Z1_POS); a1 = rd_spi()&0x7F; wr_spi(ADS_CMD_START | ADS_CMD_8BIT | ADS_CMD_DIFF | ADS_CMD_Z2_POS); b1 = (255-rd_spi())&0x7F; ADSCS_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--) { ADSCS_ENABLE(); //get X data wr_spi(ADS_CMD_START | ADS_CMD_12BIT | ADS_CMD_DIFF | ADS_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(ADS_CMD_START | ADS_CMD_12BIT | ADS_CMD_DIFF | ADS_CMD_Y_POS); a = rd_spi(); b = rd_spi(); y += ((a<<2)|(b>>6)); //12bit: ((a<<4)|(b>>4)) //10bit: ((a<<2)|(b>>6)) ADSCS_DISABLE(); } x >>= 2; //x/4 y >>= 2; //y/4*/ //using 2 samples for x and y position ADSCS_ENABLE(); //get X data wr_spi(ADS_CMD_START | ADS_CMD_12BIT | ADS_CMD_DIFF | ADS_CMD_X_POS); a1 = rd_spi(); b1 = rd_spi(); wr_spi(ADS_CMD_START | ADS_CMD_12BIT | ADS_CMD_DIFF | ADS_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(ADS_CMD_START | ADS_CMD_12BIT | ADS_CMD_DIFF | ADS_CMD_Y_POS); a1 = rd_spi(); b1 = rd_spi(); wr_spi(ADS_CMD_START | ADS_CMD_12BIT | ADS_CMD_DIFF | ADS_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; } lcd_z = p; }