// Function that writes data to the display void writeData(byte data, bool d_c) { if(d_c) // display Data gioSetBit(hetPORT1, DCPIN, 1); else // command data gioSetBit(hetPORT1, DCPIN, 0); gioSetBit(gioPORTA, CEPIN, 0); // Comment this for the default SPI1 CS1 spiTransmitData(spiREG1, (spiDAT1_t *)&config, 1, (unsigned short int *)&data); gioSetBit(gioPORTA, CEPIN, 1); // Comment this for the default SPI1 CS1 }
void esmHighLevelInterrupt(void) { /* too indicate we are in the ESM interrupt light up the BLUE leds */ /* Initalise the IO ports that drive the LEDs */ gioSetDirection(hetPORT, 0xFFFFFFFF); /* switch all leds off */ gioSetPort(hetPORT, 0x08110034); /* switch on blue leds */ gioSetBit(hetPORT, 5, 0); gioSetBit(hetPORT, 27, 0); for(;;); }
void displayInit(void) { // SPI Variables config.CS_HOLD = false; config.WDEL = true; config.DFSEL = SPI_FMT_0; config.CSNR = 0x00; // Sets up the environment _enable_IRQ(); // This enables interrupts rtiEnableNotification(rtiNOTIFICATION_COMPARE0); // This enables the Real Time Interrupt notification // Powers up the display gioSetBit(hetPORT1, VCCPIN, 1); // Resets the display resetDisplay(); // Initialization commands writeData(0x21, commandData); // Extended instruction set control writeData(0xB8, commandData); //Set LCD Vop (Contrast) writeData(0x04, commandData); //Set Temp coefficent writeData(0x14, commandData); //LCD bias mode 1:48 (try 0x13) //We must send 0x20 before modifying the display control mode writeData(0x20, commandData); writeData(0x0C, commandData); //Set display control, normal mode. // Clears the display buffer variable clearBuffer(WHITE); }
// ported from Screen_HX8353E void _writeData16(uint16_t data16) { gioSetBit(_portDataCommand, _pinDataCommand, 1); mibspiSetData(mibspiREG3, 1, &data16); mibspiTransfer(mibspiREG3, 1 ); while(!(mibspiIsTransferComplete(mibspiREG3, 1))) { } }
// ported from Screen_HX8353E void _fastFill(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t colour) { if (x1 > x2) _swapU(&x1, &x2); if (y1 > y2) _swapU(&y1, &y2); _setWindow(x1, y1, x2, y2); gioSetBit(_portDataCommand, _pinDataCommand, 1); // uint32_t t; // todo: this can be extremely optimized using the mibspi buffer + dma // for (t=(uint32_t)(y2-y1+1)*(x2-x1+1); t>1; t--) { // mibspiSetData(mibspiREG3, 2, &colour); // mibspiTransfer(mibspiREG3, 2 ); // while(!(mibspiIsTransferComplete(mibspiREG3, 2))) { // } // } // mibspiSetData(mibspiREG3, 1, &colour); // mibspiTransfer(mibspiREG3, 1 ); // while(!(mibspiIsTransferComplete(mibspiREG3, 1))) { // } uint32_t t; // todo: this can be extremely optimized using the mibspi buffer + dma for (t=(uint32_t)(y2-y1+1)*(x2-x1+1); t>0; t--) { mibspiSetData(mibspiREG3, 1, &colour); mibspiTransfer(mibspiREG3, 1 ); while(!(mibspiIsTransferComplete(mibspiREG3, 1))) { } } }
// ported from Screen_HX8353E void _writeData64(uint16_t *data) { gioSetBit(_portDataCommand, _pinDataCommand, 1); mibspiSetData(mibspiREG3, 2, &data[0]); mibspiTransfer(mibspiREG3, 2 ); while(!(mibspiIsTransferComplete(mibspiREG3, 2))) { } }
// ported from Screen_HX8353E void _writeCommand(uint16_t command8) { gioSetBit(_portDataCommand, _pinDataCommand, 0); mibspiSetData(mibspiREG3, 0, &command8); mibspiTransfer(mibspiREG3,0 ); while(!(mibspiIsTransferComplete(mibspiREG3,0))) { } }
void screenBegin() { // Screen_HX8353E::begin() /* * this is a 8MHz speed (16MHz Arduino speed/2) * In HalCoGen, on data format 0, I defined Baudrate 8000 kHz */ mibspiInit(); gioSetBit(_portReset, _pinReset, 1); delay(100); gioSetBit(_portReset, _pinReset, 0); delay(50); gioSetBit(_portReset, _pinReset, 1); delay(120); _writeCommand(HX8353E_SWRESET); delay(150); _writeCommand(HX8353E_SLPOUT); delay(200); _writeRegister(HX8353E_GAMSET, 0x04); _writeCommand(HX8353E_SETPWCTR); _writeData88(0x0A, 0x14); _writeCommand(HX8353E_SETSTBA); _writeData88(0x0A, 0x00); _writeRegister(HX8353E_COLMOD, 0x05); delay(10); _writeRegister(HX8353E_MADCTL, HX8353E_MADCTL_RGB); _writeCommand(HX8353E_CASET); _writeData8888(0x00, 0x00, 0x00, 0x79); _writeCommand(HX8353E_RASET); _writeData8888(0x00, 0x00, 0x00, 0x79); _writeCommand(HX8353E_NORON); delay(10); _writeCommand(HX8353E_DISPON); delay(120); _writeCommand(HX8353E_RAMWR); setBacklight(true); setOrientation(0); _screenWidth = HX8353E_WIDTH; _screenHeigth = HX8353E_HEIGHT; _penSolid = false; _fontSolid = true; _flagRead = false; clear(blackColour); }
retval_t led_set(uint32_t led_id, led_state_t state) { if (led_id >= LED_MAX) { return RV_ILLEGAL; } switch (state) { case LED_ON: gioSetBit(gioPORTA, gio_bit[led_id], 1); break; case LED_OFF: gioSetBit(gioPORTA, gio_bit[led_id], 0); break; } return RV_SUCCESS; }
void vParTestToggleLED( unsigned long ulLED ) { unsigned long ulBitState; if( ulLED < ulNumLEDs ) { ulBitState = gioGetBit( hetPORT, ulLEDBits[ ulLED ] ); gioSetBit( hetPORT, ulLEDBits[ ulLED ], !ulBitState ); } }
// ported from Screen_HX8353E void _writeData88(uint16_t dataHigh16, uint16_t dataLow16) { uint16_t data = (dataHigh16 << 8) | 0x00FF ; uint16_t data_low = dataLow16 | 0xFF00; data &= data_low; gioSetBit(_portDataCommand, _pinDataCommand, 1); mibspiSetData(mibspiREG3, 1, &data); mibspiTransfer(mibspiREG3, 1 ); while(!(mibspiIsTransferComplete(mibspiREG3, 1))) { } }
static void user_thread_entry(void *p) { int i; gioSetDirection(hetPORT1, 0xFFFFFFFF); for(i = 0; ;i++) { gioSetBit(hetPORT1, 17, gioGetBit(hetPORT1, 17) ^ 1); rt_thread_delay(100); } }
void vParTestInitialise( void ) { unsigned long ul; /* Initalise the IO ports that drive the LEDs */ gioSetDirection( hetPORT, 0xFFFFFFFF ); /* Turn all the LEDs off. */ for( ul = 0; ul < ulNumLEDs; ul++ ) { gioSetBit( hetPORT, ulLEDBits[ ul ], !ulOnStates[ ul ] ); } }
void vParTestSetLED( unsigned long ulLED, signed long xValue ) { if( ulLED < ulNumLEDs ) { if( xValue == pdFALSE ) { xValue = !ulOnStates[ ulLED ]; } else { xValue = ulOnStates[ ulLED ]; } gioSetBit( hetPORT, ulLEDBits[ ulLED ], xValue ); } }
void output_dato(int variable) { if(((variable & (1<<0)) != 0)) gioSetBit(hetPORT1,16,1); else gioSetBit(hetPORT1,16,0); if(((variable & (1<<1)) != 0)) gioSetBit(hetPORT1,14,1); else gioSetBit(hetPORT1,14,0); if(((variable & (1<<2)) != 0)) gioSetBit(hetPORT1,12,1); else gioSetBit(hetPORT1,12,0); if(((variable & (1<<3)) != 0)) gioSetBit(hetPORT1,10,1); else gioSetBit(hetPORT1,10,0); if(((variable & (1<<4)) != 0)) gioSetBit(hetPORT1,6,1); else gioSetBit(hetPORT1,6,0); if(((variable & (1<<5)) != 0)) gioSetBit(hetPORT1,4,1); else gioSetBit(hetPORT1,4,0); if(((variable & (1<<6)) != 0)) gioSetBit(hetPORT1,2,1); else gioSetBit(hetPORT1,2,0); if(((variable & (1<<7)) != 0)) gioSetBit(hetPORT1,0,1); else gioSetBit(hetPORT1,0,0); }
void vLedTask(void *pvParameters) { unsigned led = 0; unsigned count = 0; unsigned colour = 0; /* Initalise the IO ports that drive the LEDs */ gioSetDirection(hetPORT, 0xFFFFFFFF); /* switch all leds off */ gioSetPort(hetPORT, 0x08110034); for(;;) { /* toggle on/off */ led ^= 1; /* switch TOP row */ gioSetBit(hetPORT, 25, led); gioSetBit(hetPORT, 18, led); gioSetBit(hetPORT, 29, led); /* switch BOTTOM row */ gioSetBit(hetPORT, 17, led ^ 1); gioSetBit(hetPORT, 31, led ^ 1); gioSetBit(hetPORT, 0, led ^ 1); vTaskDelay(500); if (++count > 5) { count = 0; /* both leds to off */ gioSetBit(hetPORT, 2, 1); gioSetBit(hetPORT, 5, 1); gioSetBit(hetPORT, 20, 1); gioSetBit(hetPORT, 4, 1); gioSetBit(hetPORT, 27, 1); gioSetBit(hetPORT, 16, 1); switch(colour) { case 0: gioSetBit(hetPORT, 2, 0); /* red */ gioSetBit(hetPORT, 4, 0); colour++; continue; case 1: gioSetBit(hetPORT, 5, 0); /* blue */ gioSetBit(hetPORT, 27, 0); colour++; continue; case 2: gioSetBit(hetPORT, 20, 0); /* green */ gioSetBit(hetPORT, 16, 0); colour++; continue; } colour = 0; } } }
void _writeData64DMA() { gioSetBit(_portDataCommand, _pinDataCommand, 1); mibspiTransfer(mibspiREG3, 2 ); while(!(mibspiIsTransferComplete(mibspiREG3, 2))) { } }
// Sends a reset signal to the display void resetDisplay(void) { gioSetBit(hetPORT1, RSTPIN, 0); ckDelay(); gioSetBit(hetPORT1, RSTPIN, 1); }