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 tm1637::i2cStart(void) { CLK_HIGH(); DIO_HIGH(); delayMicroseconds(2); DIO_LOW(); }
int main(void) { CPU_PRESCALE(0); GBA_DDR &= ~(1<<MISO_BIT); GBA_DDR |= (1<<MOSI_BIT) | (1<<CLK_BIT); CLK_HIGH(); usb_init(); while (!usb_configured()); _delay_ms(1000); INIT_TIMER(); while (1) { if (usb_serial_available() >= 4) { uint32_t data = 0; data |= (uint32_t)usb_serial_getchar()<<24; data |= (uint32_t)usb_serial_getchar()<<16; data |= (uint32_t)usb_serial_getchar()<<8; data |= (uint32_t)usb_serial_getchar(); xfer(&data); usb_serial_putchar((data>>24) & 0xff); usb_serial_putchar((data>>16) & 0xff); usb_serial_putchar((data>>8) & 0xff); usb_serial_putchar(data & 0xff); usb_serial_flush_output(); } }
/// ============================================= void tm1637::i2cAck (void) { CLK_LOW(); DIO_HIGH(); delayMicroseconds (5); while (digitalRead(_dio)); CLK_HIGH(); delayMicroseconds (2); CLK_LOW(); }
static void spear_adc_set_clk(struct spear_adc_info *info, u32 val) { u32 clk_high, clk_low, count; u32 apb_clk = clk_get_rate(info->clk); count = (apb_clk + val - 1) / val; clk_low = count / 2; clk_high = count - clk_low; info->current_clk = apb_clk / count; __raw_writel(CLK_LOW(clk_low) | CLK_HIGH(clk_high), &info->adc_base_spear6xx->clk); }
void tm1637::i2cWrite (uint8_t oneByte) { uint8_t i; for (i=0; i<8; i++) { CLK_LOW(); (oneByte & 0x01)? DIO_HIGH(): DIO_LOW(); delayMicroseconds (3); oneByte = oneByte >> 1; CLK_HIGH(); delayMicroseconds (3); } }
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; }