Jump to content

david1982

Members
  • Content Count

    29
  • Joined

  • Last visited

About david1982

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. david1982

    Just a little help with multiple displays..

    Yes you where right inmarket.. I have it working now, you don’t do anything with the spi in int board but you do all spi work in acquire bus. Below is my board file for 2 ILI9341 displays running on a STM32F1 via spi. It my help others as an example. #ifndef _GDISP_LLD_BOARD_H #define _GDISP_LLD_BOARD_H //**** ILI9341 on SPI1. TESTED on STM32L1, STM32F1 AND STM32F4. // Pin & SPI setup #define SPI_METHOD_IRQ 1 #define SPI_METHOD_POLLING 2 #define SPI_METHOD SPI_METHOD_POLLING // SPI1 #define SPI_DRIVER (&SPID1) #define SPI_PORT GPIOA #define SCK_PAD 5 //PA5 #define MISO_PAD 6 //PA6 #define MOSI_PAD 7 //PA7 #define CS_PORT GPIOA #define CS2_PORT GPIOB #define RESET_PORT GPIOA #define DNC_PORT GPIOA #define CS_PAD 4 // PA4 -- 0 = chip selected #define CS2_PAD 0 // PB0 -- 0 = chip selected #define RESET_PAD 1 // PA1 -- 0 = reset #define DNC_PAD 0 // PA0 -- control=0, data=1 -- DNC or D/C // SPI setup ajust " SPI_BaudRatePrescaler_X" to set SPI speed. // Peripherial Clock 42MHz SPI2 SPI3 // Peripherial Clock 84MHz SPI1 SPI1 SPI2/3 #define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000) // 42 MHz 21 MHZ #define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008) // 21 MHz 10.5 MHz #define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010) // 10.5 MHz 5.25 MHz #define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018) // 5.25 MHz 2.626 MHz #define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020) // 2.626 MHz 1.3125 MHz #define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028) // 1.3125 MHz 656.25 KHz #define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030) // 656.25 KHz 328.125 KHz #define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038) // 328.125 KHz 164.06 KHz static SPIConfig spi_cfg = { NULL, CS_PORT, CS_PAD, SPI_BaudRatePrescaler_2 //AJUST SPEED HERE.. }; static SPIConfig spi_cfg2 = { NULL, CS2_PORT, CS2_PAD, SPI_BaudRatePrescaler_2 //AJUST SPEED HERE.. }; static inline void init_board(GDisplay *g) { (void) g; //Set up the pins.. palSetPadMode(GPIOB, 0, PAL_MODE_OUTPUT_PUSHPULL);//cs 2 palSetPadMode(SPI_PORT, CS_PAD, PAL_MODE_OUTPUT_PUSHPULL);//cs 1 palSetPadMode(SPI_PORT, SCK_PAD, PAL_MODE_STM32_ALTERNATE_PUSHPULL); palSetPadMode(SPI_PORT, MISO_PAD, PAL_MODE_STM32_ALTERNATE_PUSHPULL); palSetPadMode(SPI_PORT, MOSI_PAD, PAL_MODE_STM32_ALTERNATE_PUSHPULL); palSetPadMode(RESET_PORT, RESET_PAD, PAL_MODE_OUTPUT_PUSHPULL ); palSetPadMode(DNC_PORT, DNC_PAD, PAL_MODE_OUTPUT_PUSHPULL); //Select both displays palSetPad(CS_PORT, CS_PAD); palSetPad(CS2_PORT, CS2_PAD); //Reset both displays palSetPad(RESET_PORT, RESET_PAD); palClearPad(DNC_PORT, DNC_PAD); //Unselect both displays palClearPad(CS_PORT, CS_PAD); palClearPad(CS2_PORT, CS2_PAD); } static inline void post_init_board(GDisplay *g) { (void) g; } static inline void setpin_reset(GDisplay *g, bool_t state) { (void) g; palWritePad(RESET_PORT, RESET_PAD, !state); } static inline void set_backlight(GDisplay *g, uint8_t percent) { (void) g; (void) percent; } //This is where we select each display static inline void acquire_bus(GDisplay *g) { (void) g; switch(g->controllerdisplay) { case 0: spiStart(SPI_DRIVER, &spi_cfg); spiSelectI(SPI_DRIVER); break; case 1: spiStart(SPI_DRIVER, &spi_cfg2); spiSelectI(SPI_DRIVER); break; } } static inline void release_bus(GDisplay *g) { (void) g; switch(g->controllerdisplay) { case 0: spiUnselectI(SPI_DRIVER); break; case 1: spiUnselectI(SPI_DRIVER); break; } } static inline void write_index(GDisplay *g, uint8_t index) { (void) g; palClearPad(DNC_PORT, DNC_PAD); #if SPI_METHOD == SPI_METHOD_IRQ spiSend(SPI_DRIVER, 1, &index); #elif SPI_METHOD == SPI_METHOD_POLLING spiPolledExchange(SPI_DRIVER, index); #endif palSetPad(DNC_PORT, DNC_PAD); } static inline void write_data(GDisplay *g, uint8_t data) { (void) g; #if SPI_METHOD == SPI_METHOD_IRQ spiSend(SPI_DRIVER, 1, &data); #elif SPI_METHOD == SPI_METHOD_POLLING spiPolledExchange(SPI_DRIVER, data); #endif } static inline void setreadmode(GDisplay *g) { (void) g; } static inline void setwritemode(GDisplay *g) { (void) g; } static inline uint16_t read_data(GDisplay *g) { (void) g; return 0; } #endif /* _GDISP_LLD_BOARD_H */
  2. david1982

    Just a little help with multiple displays..

    I think that what I am doing .. and sorry yes both displays use the same controller. I have set the following in my ugfxconf.. #define GDISP_TOTAL_DISPLAYS 2 #define GDISP_TOTAL_CONTROLLERS 1 #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 My board int looks like.. static inline void init_board(GDisplay *g) { (void) g; //Set up the pins.. palSetPadMode(GPIOB, 0, PAL_MODE_OUTPUT_PUSHPULL);//cs 2 palSetPadMode(SPI_PORT, CS_PAD, PAL_MODE_OUTPUT_PUSHPULL);//cs 1 palSetPadMode(SPI_PORT, SCK_PAD, PAL_MODE_STM32_ALTERNATE_PUSHPULL); palSetPadMode(SPI_PORT, MISO_PAD, PAL_MODE_STM32_ALTERNATE_PUSHPULL); palSetPadMode(SPI_PORT, MOSI_PAD, PAL_MODE_STM32_ALTERNATE_PUSHPULL); palSetPadMode(RESET_PORT, RESET_PAD, PAL_MODE_OUTPUT_PUSHPULL ); palSetPadMode(DNC_PORT, DNC_PAD, PAL_MODE_OUTPUT_PUSHPULL); switch(g->controllerdisplay) { case 0: //Set pins. palSetPad(CS_PORT, CS_PAD); palSetPad(RESET_PORT, RESET_PAD); palClearPad(DNC_PORT, DNC_PAD); break; //Start SPI1 with our config. spiStart(SPI_DRIVER, &spi_cfg); spiSelectI(SPI_DRIVER); /* Slave Select assertion. */ case 1: //Set pins. palSetPad(GPIOB, 0); palSetPad(RESET_PORT, RESET_PAD); palClearPad(DNC_PORT, DNC_PAD); //Start SPI1 with our config. spiStart(SPI_DRIVER, &spi_cfg2); spiSelectI(SPI_DRIVER); break; } } But when I draw to each display only the second display works.. I am switching between displays like so.. coord_t displayA,displayB; displayA = 0; displayB = 1; gdispSetDisplay(gdispGetDisplay(displayA)); ///Do some drawing This does not show gdispSetDisplay(gdispGetDisplay(displayB)); ///Do some drawing This does show
  3. Hello all, Can some one please just help me with my multiple display set-up. I understand the basics of using the multiple displays from the examples but how do I set-up my board file as the only difference between the two displays is the chip select (SPI). Thanks.
  4. david1982

    Can someone please test my font?

    Hello, Just having some trouble displaying a custom font can someone please test it for me? userfonts.h.zip
  5. david1982

    Saving and loading data via sd card

    Hello all, I have a working spi SD card setup using gfile. What I want to do is have a file on the SD card with some settings (numbers) and have my code read the file and then have the setting number applied to an int. How would I best go about this? Thank you.
  6. david1982

    STDIO help.

    I have fixed the error by enabling #define GFILE_NEED_STRINGS TRUE #define GFILE_NEED_PRINTG TRUE in the gfxconf file.
  7. david1982

    STDIO help.

    Hello, I am trying to use the stdio with ugfx as I need sprintf. I have updated my stdio file to fix the compile errors but now I get this error went I use sprintf undefined reference to `snprintg' How could I resolve this? Thank you.
  8. david1982

    Image from Chibios Fat FS

    I got it all working. Thank you very much.
  9. david1982

    Image from Chibios Fat FS

    Hello, I have got my sd card working under chibios (I can read and write). Now how do I display an bmp file that is on that sd card? I have the basics for displaying images down just don't know how to open image from the sd card. I will be grateful for any help. Thank you.
  10. david1982

    SSD1289 Multi Colored Pixels..

    Is it safe to assume that the fsmc is working? Where should I start to look to fix it. Thank you
  11. david1982

    SSD1289 Multi Colored Pixels..

    Hello, Just trying to get my SSD1289 display working and all I am getting is a screen full of multi colored pixels what would be the cause of this?? Here is my board file. /* #ifndef _GDISP_LLD_BOARD_H #define _GDISP_LLD_BOARD_H // For a multiple display configuration we would put all this in a structure and then // set g->board to that structure. /* Using FSMC A19 (PE3) as DC */ #define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* DC = 0 */ #define GDISP_RAM (*((volatile uint16_t *) 0x60100000)) /* DC = 1 */ #define GDISP_DMA_STREAM STM32_DMA2_STREAM6 #define SET_RST palSetPad(GPIOD, 3); #define CLR_RST palClearPad(GPIOD, 3); static inline void init_board(GDisplay *g) { // As we are not using multiple displays we set g->board to NULL as we don't use it. g->board = 0; switch(g->controllerdisplay) { case 0: // Set up for Display 0 #if defined(STM32F4XX) || defined(STM32F2XX) /* STM32F4 FSMC init */ rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0); #if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM) if (dmaStreamAllocate(GDISP_DMA_STREAM, 0, 0, 0)) gfxExit(); dmaStreamSetMemory0(GDISP_DMA_STREAM, &GDISP_RAM); dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M); #endif #else #error "FSMC not implemented for this device" #endif /* Group pins */ IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 14) | (1 << 15), 0}; IOBus busE = {GPIOE, (1 << 3) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) | (1 << 13) | (1 << 14) | (1 << 15), 0}; /* FSMC is an alternate function 12 (AF12) */ palSetBusMode(&busD, PAL_MODE_ALTERNATE(12)); palSetBusMode(&busE, PAL_MODE_ALTERNATE(12)); /* FSMC timing register configuration */ FSMC_Bank1->BTCR[0 + 1] = (FSMC_BTR1_ADDSET_1 | FSMC_BTR1_ADDSET_3) \ | (FSMC_BTR1_DATAST_1 | FSMC_BTR1_DATAST_3) \ | (FSMC_BTR1_BUSTURN_1 | FSMC_BTR1_BUSTURN_3) ; // FSMC_Bank1->BTCR[0 + 1] = (FSMC_BTR1_ADDSET_3 | FSMC_BTR1_ADDSET_0) \ // | (FSMC_BTR1_DATAST_3 | FSMC_BTR1_DATAST_0) \ // | FSMC_BTR1_BUSTURN_0; /* Bank1 NOR/PSRAM control register configuration * Write enable, memory databus width set to 16 bit, memory bank enable */ // FSMC_Bank1->BTCR[0] = FSMC_BCR1_WREN | FSMC_BCR1_MWID_0 | FSMC_BCR1_MBKEN; break; } } static inline void post_init_board(GDisplay *g) { (void) g; } static inline void setpin_reset(GDisplay *g, bool_t state) { (void) g; if (state) { CLR_RST; } else { SET_RST; } } static inline void set_backlight(GDisplay *g, uint8_t percent) { (void) g; } static inline void acquire_bus(GDisplay *g) { (void) g; } static inline void release_bus(GDisplay *g) { (void) g; } static inline void write_index(GDisplay *g, uint16_t index) { (void) g; GDISP_REG = index; } static inline void write_data(GDisplay *g, uint16_t data) { (void) g; GDISP_RAM = data; } static inline void setreadmode(GDisplay *g) { (void) g; } static inline void setwritemode(GDisplay *g) { (void) g; } static inline uint16_t read_data(GDisplay *g) { (void) g; return GDISP_RAM; } #if defined(GDISP_USE_DMA) static inline void dma_with_noinc(GDisplay *g, color_t *buffer, int area) { (void) g; dmaStreamSetPeripheral(GDISP_DMA_STREAM, buffer); dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M); for (; area > 0; area -= 65535) { dmaStreamSetTransactionSize(GDISP_DMA_STREAM, area > 65535 ? 65535 : area); dmaStreamEnable(GDISP_DMA_STREAM); dmaWaitCompletion(GDISP_DMA_STREAM); } } static inline void dma_with_inc(GDisplay *g, color_t *buffer, int area) { (void) g; dmaStreamSetPeripheral(GDISP_DMA_STREAM, buffer); dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PINC | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M); for (; area > 0; area -= 65535) { dmaStreamSetTransactionSize(GDISP_DMA_STREAM, area > 65535 ? 65535 : area); dmaStreamEnable(GDISP_DMA_STREAM); dmaWaitCompletion(GDISP_DMA_STREAM); } } #endif #endif /* _GDISP_LLD_BOARD_H */
  12. david1982

    Any info on D51E5TA7601

    Hello, I have just got hold of a tft1p4705 TFT with an D51E5TA7601 driver ic I was just wondering if any one has played with one of there before? Thank you. Here is a link to the driver ic datasheet. https://drive.google.com/file/d/0B_B2fQCYwJRiNnpzcWxqeldoZHM/view?usp=sharing
  13. david1982

    Large Font Problems.

    Hello, I have been trying to get a large number (50+) font working for use with a temperature sensor but I am having some problems. I have userfonts working but only at a font size of 5 as soon as I try to go for the larger sizes the userfont will not work. I have also filtered for just numbers to reduce the size in case that was the problem but no luck. Is there a limit on the font size that I can use? The font I am currently trying to use is DejaVuSansMono. Any help would be great.
  14. david1982

    ILI9341 SPI stm32f103

    Very nice !! :shock: Thank you!
  15. david1982

    ILI9341 SPI stm32f103

    Wow that is a big difference. Thanks for cleaning up the code I to can run SPI_BaudRatePrescaler_2 now. My setup is also running about the same speed as your ugfx setup. Thank you.
×